FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairRingSorter.h
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 (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 /*
9  * FairRingSorter.h
10  *
11  * Created on: Jul 15, 2010
12  * Author: stockman
13  */
14 
15 #ifndef FairRingSorter_H_
16 #define FairRingSorter_H_
17 
18 #include <Rtypes.h> // for FairRingSorter::Class, etc
19 #include <TObject.h> // for TObject
20 #include <iostream> // for operator<<, ostream, etc
21 #include <map> // for multimap
22 #include <utility> // for pair
23 #include <vector> // for vector
24 
25 class FairTimeStamp;
26 
27 class FairRingSorter : public TObject
28 {
29  public:
30  FairRingSorter(int size = 100, double width = 10)
31  : TObject()
32  , fRingBuffer(size)
33  , fOutputData()
34  , fLowerBoundPointer(0, 0)
35  , fCellWidth(width)
36  , fVerbose(0)
37  {}
38 
39  virtual ~FairRingSorter(){};
40 
42 
43  virtual void AddElement(FairTimeStamp* digi, double timestamp);
44  virtual void WriteOutElements(int index);
45  virtual void WriteOutElement(int index);
46  virtual void WriteOutAll() { WriteOutElements(fLowerBoundPointer.first); }
47  virtual double GetBufferSize() { return fCellWidth * fRingBuffer.size(); }
48  virtual std::vector<FairTimeStamp*> GetOutputData() { return fOutputData; }
49 
50  virtual void DeleteOutputData() { fOutputData.clear(); }
51  virtual void SetLowerBound(double timestampOfHitToWrite);
52 
53  virtual void print(std::ostream& out = std::cout)
54  {
55  out << "RingSorter: Size " << fRingBuffer.size() << " CellWidth: " << fCellWidth << "\n";
56  out << "LowerBoundPointer at index: " << fLowerBoundPointer.first << " Time: " << fLowerBoundPointer.second
57  << "\n";
58  out << "| ";
59  for (unsigned int i = 0; i < fRingBuffer.size(); i++) {
60  out << fRingBuffer[i].size() << " |";
61  }
62  out << std::endl;
63  }
64 
65  private:
66  int CalcIndex(double val);
67  std::vector<std::multimap<double, FairTimeStamp*>> fRingBuffer;
68  std::vector<FairTimeStamp*> fOutputData;
69  std::pair<int, double> fLowerBoundPointer;
70  double fCellWidth;
71  int fVerbose;
72 
73  ClassDef(FairRingSorter, 1);
74 };
75 
76 #endif /* FairRingSorter_H_ */
virtual void print(std::ostream &out=std::cout)
virtual void WriteOutElement(int index)
writes out the entry at the index and clears it
virtual void WriteOutElements(int index)
writes out the entries from LowerBoundPointer up to index
virtual void AddElement(FairTimeStamp *digi, double timestamp)
FairRingSorter(int size=100, double width=10)
virtual void DeleteOutputData()
virtual double GetBufferSize()
virtual FairTimeStamp * CreateElement(FairTimeStamp *data)
virtual ~FairRingSorter()
virtual std::vector< FairTimeStamp * > GetOutputData()
virtual void WriteOutAll()
virtual void SetLowerBound(double timestampOfHitToWrite)