FairRoot/PandaRoot
detectors/mvd/MvdOfflineTBAnalysis_Topix4/PndMapSorter.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence version 3 (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 // -------------------------------------------------------------------------
9 // PndMapSorter.cxx
10 // Created on: Jul 30, 2010
11 // Author: stockman
12 // -------------------------------------------------------------------------
13 
14 #include "PndMapSorter.h"
15 
16 #include "FairTimeStamp.h" // for FairTimeStamp
17 
18 FairTimeStamp* PndMapSorter::CreateElement(FairTimeStamp* data)
19 {
20  return (FairTimeStamp*)data->Clone();
21 }
22 
23 void PndMapSorter::AddElement(FairTimeStamp* digi, double timestamp)
24 {
25  if (fVerbose > 0)
26  std::cout << "PndMapSorter::AddElement " << timestamp << std::endl;
27  fMapBuffer.insert(std::pair<double,FairTimeStamp*>(timestamp, CreateElement(digi)));
28 }
29 
30 void PndMapSorter::WriteOutData(double time)
31 {
32  if (time > fTimeOffset){
33  if (fVerbose > 0)
34  std::cout << "PndMapSorter::WriteOutData for time " << time << std::endl;
35  // std::cout << "PrintMap before!" << std::endl;
36  // PrintMap();
37  for (std::multimap<double, FairTimeStamp*>::iterator itr = fMapBuffer.begin(); itr != fMapBuffer.lower_bound(time - fTimeOffset); itr++){
38  fOutputData.push_back(itr->second);
39  if (fVerbose > 1){
40  std::cout << "TS: " << itr->first << " " << itr->second->GetTimeStamp() << " diff " << itr->first - fOldTS << std::endl;
41  }
42  if (itr->first - fOldTS < 0)
43  std::cout << "*** Error *** PndMapSorter::WriteOutData negative difference " << itr->first << " - " << fOldTS << std::endl;
44  fOldTS = itr->first;
45  }
46  fMapBuffer.erase(fMapBuffer.begin(), fMapBuffer.lower_bound(time - fTimeOffset));
47 // std::cout << "PrintMap after!" << std::endl;
48 // PrintMap();
49  }
50 }
51 
53  if (fVerbose > 0)
54  std::cout << "PndMapSorter::WriteOutAll called!" << std::endl;
55  for (std::multimap<double, FairTimeStamp*>::iterator itr = fMapBuffer.begin(); itr != fMapBuffer.end(); itr++)
56  fOutputData.push_back(itr->second);
57 }
58 
TClonesArray * digi
virtual FairTimeStamp * CreateElement(FairTimeStamp *data)
virtual void AddElement(FairTimeStamp *digi, double timestamp)
std::multimap< double, FairTimeStamp * > fMapBuffer
ClassImp(PndAnaContFact)