PandaRoot
PndRingSorter.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /*
14  * PndRingSorter.h
15  *
16  * Created on: Jul 15, 2010
17  * Author: stockman
18  */
19 
20 #ifndef PndRingSorter_H_
21 #define PndRingSorter_H_
22 
23 #include "TObject.h"
24 #include "FairTimeStamp.h"
25 
26 #include <vector>
27 #include <stack>
28 #include <map>
29 
30 #include <iostream>
31 
32 class PndRingSorter : public TObject {
33  public:
34  PndRingSorter(int size = 100, double width = 10) : fLowerBoundPointer(0, 0), fCellWidth(width), fVerbose(0) { fRingBuffer.resize(size); }
35 
36  virtual ~PndRingSorter(){};
37 
38  virtual FairTimeStamp *CreateElement(FairTimeStamp *data) = 0;
39 
40  virtual void AddElement(FairTimeStamp *digi, double timestamp);
41  virtual void WriteOutElements(int index);
42  virtual void WriteOutElement(int index);
43  virtual void WriteOutAll() { WriteOutElements(fLowerBoundPointer.first); }
44  virtual double GetBufferSize() { return fCellWidth * fRingBuffer.size(); }
45  virtual std::vector<FairTimeStamp *> GetOutputData() { return fOutputData; }
46 
47  virtual void DeleteOutputData() { fOutputData.clear(); }
48  virtual void SetLowerBound(double timestampOfHitToWrite);
49 
50  virtual void Print(std::ostream &out = std::cout)
51  {
52  out << "RingSorter: Size " << fRingBuffer.size() << " CellWidth: " << fCellWidth << std::endl;
53  out << "LowerBoundPointer at index: " << fLowerBoundPointer.first << " Time: " << fLowerBoundPointer.second << std::endl;
54  out << "| ";
55  for (int i = 0; i < fRingBuffer.size(); i++) {
56  out << fRingBuffer[i].size() << " |";
57  }
58  out << std::endl;
59  }
60 
61  private:
62  int CalcIndex(double val);
63  std::vector<std::multimap<double, FairTimeStamp *>> fRingBuffer;
64  std::vector<FairTimeStamp *> fOutputData;
65  std::pair<int, double> fLowerBoundPointer;
66  double fCellWidth;
67  int fVerbose;
68 
69  ClassDef(PndRingSorter, 1)
70 };
71 
72 #endif /* PndRingSorter_H_ */
virtual std::vector< FairTimeStamp * > GetOutputData()
Definition: PndRingSorter.h:45
virtual void SetLowerBound(double timestampOfHitToWrite)
virtual ~PndRingSorter()
Definition: PndRingSorter.h:36
virtual FairTimeStamp * CreateElement(FairTimeStamp *data)=0
virtual void Print(std::ostream &out=std::cout)
Definition: PndRingSorter.h:50
unsigned int i
Definition: P4_F32vec4.h:33
virtual void AddElement(FairTimeStamp *digi, double timestamp)
virtual void WriteOutElement(int index)
writes out the entry at the index and clears it
virtual void WriteOutAll()
Definition: PndRingSorter.h:43
virtual void WriteOutElements(int index)
writes out the entries from LowerBoundPointer up to index
virtual void DeleteOutputData()
Definition: PndRingSorter.h:47
virtual double GetBufferSize()
Definition: PndRingSorter.h:44
PndRingSorter(int size=100, double width=10)
Definition: PndRingSorter.h:34