FairRoot/PandaRoot
tools/PndMQ/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 #include "FairTimeStamp.h" // for FairTimeStamp
16 
17 FairTimeStamp* PndMapSorter::CreateElement(FairTimeStamp* data)
18 {
19  return (FairTimeStamp*)data->Clone();
20 }
21 
22 void PndMapSorter::AddElement(FairTimeStamp* digi, double timestamp)
23 {
24  if (fVerbose > 0)
25  std::cout << "PndMapSorter::AddElement " << timestamp << std::endl;
26  fMapBuffer.insert(std::pair<double,FairTimeStamp*>(timestamp, CreateElement(digi)));
27 }
28 
29 void PndMapSorter::WriteOutData(double time)
30 {
31  if (time > fTimeOffset){
32  if (fVerbose > 0)
33  std::cout << "PndMapSorter::WriteOutData for time " << time << std::endl;
34  // std::cout << "PrintMap before!" << std::endl;
35  // PrintMap();
36  for (std::multimap<double, FairTimeStamp*>::iterator itr = fMapBuffer.begin(); itr != fMapBuffer.lower_bound(time - fTimeOffset); itr++){
37  fOutputData.push_back(itr->second);
38  if (fVerbose > 1){
39  std::cout << "TS: " << itr->first << " " << itr->second->GetTimeStamp() << " diff " << itr->first - fOldTS << std::endl;
40  }
41  if (itr->first - fOldTS < 0)
42  std::cout << "*** Error *** PndMapSorter::WriteOutData negative difference " << itr->first << " - " << fOldTS << std::endl;
43  fOldTS = itr->first;
44  }
45  fMapBuffer.erase(fMapBuffer.begin(), fMapBuffer.lower_bound(time - fTimeOffset));
46 // std::cout << "PrintMap after!" << std::endl;
47 // PrintMap();
48  }
49 }
50 
52  if (fVerbose > 0)
53  std::cout << "PndMapSorter::WriteOutAll called!" << std::endl;
54  for (std::multimap<double, FairTimeStamp*>::iterator itr = fMapBuffer.begin(); itr != fMapBuffer.end(); itr++)
55  fOutputData.push_back(itr->second);
56 }
57 
58 //ClassImp(PndMapSorter);
TClonesArray * digi
virtual FairTimeStamp * CreateElement(FairTimeStamp *data)
virtual void AddElement(FairTimeStamp *digi, double timestamp)
std::multimap< double, FairTimeStamp * > fMapBuffer