EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairRingSorter.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairRingSorter.h
1 /*
2  * FairRingSorter.h
3  *
4  * Created on: Jul 15, 2010
5  * Author: stockman
6  */
7 
8 #ifndef FairRingSorter_H_
9 #define FairRingSorter_H_
10 
11 #include "TObject.h"
12 #include "FairTimeStamp.h"
13 
14 #include <vector>
15 #include <stack>
16 #include <map>
17 
18 #include <iostream>
19 
20 class FairRingSorter : public TObject
21 {
22  public:
23  FairRingSorter(int size = 100, double width = 10)
26  }
27 
28  virtual ~FairRingSorter() {};
29 
31 
32  virtual void AddElement(FairTimeStamp* digi, double timestamp);
33  virtual void WriteOutElements(int index);
34  virtual void WriteOutElement(int index);
35  virtual void WriteOutAll() {
37  }
38  virtual double GetBufferSize() {return fCellWidth * fRingBuffer.size();}
39  virtual std::vector<FairTimeStamp*> GetOutputData() {
40  return fOutputData;
41  }
42 
43  virtual void DeleteOutputData() {fOutputData.clear(); }
44  virtual void SetLowerBound(double timestampOfHitToWrite);
45 
46  virtual void Print(std::ostream& out = std::cout) {
47  out << "RingSorter: Size " << fRingBuffer.size() << " CellWidth: " << fCellWidth << std::endl;
48  out << "LowerBoundPointer at index: " << fLowerBoundPointer.first << " Time: " << fLowerBoundPointer.second << std::endl;
49  out << "| ";
50  for (int i = 0; i < fRingBuffer.size(); i++) {
51  out << fRingBuffer[i].size() << " |";
52  }
53  out << std::endl;
54  }
55 
56 
57  private:
58  int CalcIndex(double val);
59  std::vector<std::multimap<double, FairTimeStamp*> > fRingBuffer;
60  std::vector<FairTimeStamp*> fOutputData;
61  std::pair<int, double> fLowerBoundPointer;
62  double fCellWidth;
63  int fVerbose;
64 
65  ClassDef(FairRingSorter,1)
66 
67 };
68 
69 #endif /* FairRingSorter_H_ */