FairRoot/PandaRoot
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PndRingSorter Class Referenceabstract

#include <PndRingSorter.h>

Inheritance diagram for PndRingSorter:

Public Member Functions

 PndRingSorter (int size=100, double width=10)
 
virtual ~PndRingSorter ()
 
virtual FairTimeStamp * CreateElement (FairTimeStamp *data)=0
 
virtual void AddElement (FairTimeStamp *digi, double timestamp)
 
virtual void WriteOutElements (int index)
 writes out the entries from LowerBoundPointer up to index More...
 
virtual void WriteOutElement (int index)
 writes out the entry at the index and clears it More...
 
virtual void WriteOutAll ()
 
virtual double GetBufferSize ()
 
virtual std::vector
< FairTimeStamp * > 
GetOutputData ()
 
virtual void DeleteOutputData ()
 
virtual void SetLowerBound (double timestampOfHitToWrite)
 
virtual void Print (std::ostream &out=std::cout)
 

Private Member Functions

int CalcIndex (double val)
 

Private Attributes

std::vector< std::multimap
< double, FairTimeStamp * > > 
fRingBuffer
 
std::vector< FairTimeStamp * > fOutputData
 
std::pair< int, double > fLowerBoundPointer
 
double fCellWidth
 
int fVerbose
 

Detailed Description

Definition at line 20 of file PndRingSorter.h.

Constructor & Destructor Documentation

PndRingSorter::PndRingSorter ( int  size = 100,
double  width = 10 
)
inline

Definition at line 22 of file PndRingSorter.h.

References fRingBuffer.

22  :fLowerBoundPointer(0,0), fCellWidth(width), fVerbose(0)
23  {
24  fRingBuffer.resize(size);
25  }
double fCellWidth
Definition: PndRingSorter.h:61
std::pair< int, double > fLowerBoundPointer
Definition: PndRingSorter.h:60
std::vector< std::multimap< double, FairTimeStamp * > > fRingBuffer
Definition: PndRingSorter.h:58
virtual PndRingSorter::~PndRingSorter ( )
inlinevirtual

Definition at line 27 of file PndRingSorter.h.

27 {};

Member Function Documentation

void PndRingSorter::AddElement ( FairTimeStamp *  digi,
double  timestamp 
)
virtual

Definition at line 10 of file PndRingSorter.cxx.

References CalcIndex(), CreateElement(), fLowerBoundPointer, fRingBuffer, fVerbose, GetBufferSize(), SetLowerBound(), WriteOutAll(), and WriteOutElements().

Referenced by PndSorterTask::Exec(), and PndSorterTask::FinishTask().

10  {
11 
12  FairTimeStamp* newElement = CreateElement(digi);
13 
14  if (timestamp < fLowerBoundPointer.second){
15  std::cout << "-E- Timestamp " << timestamp << " below lower bound " << fLowerBoundPointer.second << std::endl;
16  newElement->Print();
17  return;
18  }
19  int index = CalcIndex(timestamp);
20 
21  if (timestamp >= fLowerBoundPointer.second + (2 * GetBufferSize())){
22  if (fVerbose > 0) std::cout << "-I- PndRingSorterT::AddElement : Timestamp " << timestamp << " larger than 2 * bufferspace: " << fLowerBoundPointer.second + GetBufferSize() << " writing out " << index+1 << std::endl;
23  WriteOutAll();
24  SetLowerBound(timestamp);
25  }
26  else if (timestamp >= fLowerBoundPointer.second + GetBufferSize()){
27  if (fVerbose > 0) std::cout << "-I- PndRingSorterT::AddElement : Timestamp " << timestamp << " larger than bufferspace: " << fLowerBoundPointer.second + GetBufferSize() << " writing out " << index+1 << std::endl;
28  WriteOutElements(index+1);
29  SetLowerBound(timestamp);
30  }
31  fRingBuffer[index].insert(std::pair<double, FairTimeStamp*> (timestamp, newElement));
32 }
TClonesArray * digi
virtual FairTimeStamp * CreateElement(FairTimeStamp *data)=0
virtual void WriteOutAll()
Definition: PndRingSorter.h:34
int CalcIndex(double val)
virtual void SetLowerBound(double timestampOfHitToWrite)
virtual double GetBufferSize()
Definition: PndRingSorter.h:37
std::pair< int, double > fLowerBoundPointer
Definition: PndRingSorter.h:60
virtual void WriteOutElements(int index)
writes out the entries from LowerBoundPointer up to index
std::vector< std::multimap< double, FairTimeStamp * > > fRingBuffer
Definition: PndRingSorter.h:58
int PndRingSorter::CalcIndex ( double  val)
private

Definition at line 78 of file PndRingSorter.cxx.

References fCellWidth, and fRingBuffer.

Referenced by AddElement(), and SetLowerBound().

78  {
79  int index = val / fCellWidth;
80  while (index >= fRingBuffer.size()){
81  index -= fRingBuffer.size();
82  }
83  return index;
84 }
Double_t val[nBoxes][nFEBox]
Definition: createCalib.C:11
double fCellWidth
Definition: PndRingSorter.h:61
std::vector< std::multimap< double, FairTimeStamp * > > fRingBuffer
Definition: PndRingSorter.h:58
virtual FairTimeStamp* PndRingSorter::CreateElement ( FairTimeStamp *  data)
pure virtual

Referenced by AddElement().

virtual void PndRingSorter::DeleteOutputData ( )
inlinevirtual

Definition at line 42 of file PndRingSorter.h.

References fOutputData.

Referenced by PndSorterTask::Exec(), and PndSorterTask::FinishTask().

42 {fOutputData.clear(); }
std::vector< FairTimeStamp * > fOutputData
Definition: PndRingSorter.h:59
virtual double PndRingSorter::GetBufferSize ( )
inlinevirtual

Definition at line 37 of file PndRingSorter.h.

References fCellWidth, and fRingBuffer.

Referenced by AddElement(), and SetLowerBound().

37 {return fCellWidth * fRingBuffer.size();}
double fCellWidth
Definition: PndRingSorter.h:61
std::vector< std::multimap< double, FairTimeStamp * > > fRingBuffer
Definition: PndRingSorter.h:58
virtual std::vector<FairTimeStamp*> PndRingSorter::GetOutputData ( )
inlinevirtual

Definition at line 38 of file PndRingSorter.h.

References fOutputData.

Referenced by PndSorterTask::Exec(), and PndSorterTask::FinishTask().

38  {
39  return fOutputData;
40  }
std::vector< FairTimeStamp * > fOutputData
Definition: PndRingSorter.h:59
virtual void PndRingSorter::Print ( std::ostream out = std::cout)
inlinevirtual

Definition at line 45 of file PndRingSorter.h.

References fCellWidth, fLowerBoundPointer, fRingBuffer, i, and out.

Referenced by PndSorterTask::Exec(), and PndSorterTask::FinishTask().

45  {
46  out << "RingSorter: Size " << fRingBuffer.size() << " CellWidth: " << fCellWidth << std::endl;
47  out << "LowerBoundPointer at index: " << fLowerBoundPointer.first << " Time: " << fLowerBoundPointer.second << std::endl;
48  out << "| ";
49  for (int i = 0; i < fRingBuffer.size(); i++){
50  out << fRingBuffer[i].size() << " |";
51  }
52  out << std::endl;
53  }
Int_t i
Definition: run_full.C:25
double fCellWidth
Definition: PndRingSorter.h:61
std::pair< int, double > fLowerBoundPointer
Definition: PndRingSorter.h:60
std::vector< std::multimap< double, FairTimeStamp * > > fRingBuffer
Definition: PndRingSorter.h:58
void PndRingSorter::SetLowerBound ( double  timestampOfHitToWrite)
virtual

Definition at line 34 of file PndRingSorter.cxx.

References CalcIndex(), fCellWidth, fLowerBoundPointer, fVerbose, and GetBufferSize().

Referenced by AddElement().

34  {
35  int index = CalcIndex(timestampOfHitToWrite + fCellWidth);
36 
37  int cellValue = timestampOfHitToWrite / fCellWidth;
38 
39  fLowerBoundPointer.second = ((cellValue + 1) * fCellWidth) - GetBufferSize();
40  fLowerBoundPointer.first = index;
41  if (fVerbose > 0) std::cout << "-I- PndRingSorter::SetLowerBound " << index << " / " << fLowerBoundPointer.second << std::endl;
42 }
double fCellWidth
Definition: PndRingSorter.h:61
int CalcIndex(double val)
virtual double GetBufferSize()
Definition: PndRingSorter.h:37
std::pair< int, double > fLowerBoundPointer
Definition: PndRingSorter.h:60
virtual void PndRingSorter::WriteOutAll ( )
inlinevirtual

Definition at line 34 of file PndRingSorter.h.

References fLowerBoundPointer, and WriteOutElements().

Referenced by AddElement(), and PndSorterTask::FinishTask().

34  {
36  }
std::pair< int, double > fLowerBoundPointer
Definition: PndRingSorter.h:60
virtual void WriteOutElements(int index)
writes out the entries from LowerBoundPointer up to index
void PndRingSorter::WriteOutElement ( int  index)
virtual

writes out the entry at the index and clears it

Definition at line 63 of file PndRingSorter.cxx.

References fOutputData, fRingBuffer, and fVerbose.

Referenced by WriteOutElements().

63  {
64  std::multimap<double, FairTimeStamp*>* myDataField = &fRingBuffer.at(index);
65  std::multimap<double, FairTimeStamp*>::iterator it;
66  if (!myDataField->empty()) {
67  if (fVerbose > 1);
68  std::cout << "-I- PndRingSorterT:WriteOutElement ";
69  myDataField->begin()->second->Print();
70  std::cout << std::endl;
71  for (it = myDataField->begin(); it != myDataField->end(); it++){
72  fOutputData.push_back(it->second);
73  }
74  myDataField->clear();
75  }
76 }
std::vector< FairTimeStamp * > fOutputData
Definition: PndRingSorter.h:59
std::vector< std::multimap< double, FairTimeStamp * > > fRingBuffer
Definition: PndRingSorter.h:58
void PndRingSorter::WriteOutElements ( int  index)
virtual

writes out the entries from LowerBoundPointer up to index

Definition at line 44 of file PndRingSorter.cxx.

References fLowerBoundPointer, fOutputData, fRingBuffer, i, and WriteOutElement().

Referenced by AddElement(), and WriteOutAll().

44  {
45  if (fLowerBoundPointer.first >= index){
46  for (int i = fLowerBoundPointer.first; i < fRingBuffer.size(); i++)
48  for (int i = 0; i < index; i++)
50  }
51  else{
52  for (int i = fLowerBoundPointer.first; i < index; i++)
54  }
55 // if (fVerbose > 1){
56  std::cout << "-I- PndRingSorter::WriteOutElements: Size of Output-Array: " << fOutputData.size() << std::endl;
57 // for (int i = 0; i < fOutputData.size(); i++)
58 // std::cout << fOutputData[i].size() << " | ";
59 // std::cout << std::endl;
60 // }
61 }
std::vector< FairTimeStamp * > fOutputData
Definition: PndRingSorter.h:59
Int_t i
Definition: run_full.C:25
std::pair< int, double > fLowerBoundPointer
Definition: PndRingSorter.h:60
virtual void WriteOutElement(int index)
writes out the entry at the index and clears it
std::vector< std::multimap< double, FairTimeStamp * > > fRingBuffer
Definition: PndRingSorter.h:58

Member Data Documentation

double PndRingSorter::fCellWidth
private

Definition at line 61 of file PndRingSorter.h.

Referenced by CalcIndex(), GetBufferSize(), Print(), and SetLowerBound().

std::pair<int, double> PndRingSorter::fLowerBoundPointer
private

Definition at line 60 of file PndRingSorter.h.

Referenced by AddElement(), Print(), SetLowerBound(), WriteOutAll(), and WriteOutElements().

std::vector<FairTimeStamp*> PndRingSorter::fOutputData
private

Definition at line 59 of file PndRingSorter.h.

Referenced by DeleteOutputData(), GetOutputData(), WriteOutElement(), and WriteOutElements().

std::vector<std::multimap<double, FairTimeStamp*> > PndRingSorter::fRingBuffer
private
int PndRingSorter::fVerbose
private

Definition at line 62 of file PndRingSorter.h.

Referenced by AddElement(), SetLowerBound(), and WriteOutElement().


The documentation for this class was generated from the following files: