23 if (timestamp < fLowerBoundPointer.second) {
24 std::cout <<
"-E- Timestamp " << timestamp <<
" below lower bound " << fLowerBoundPointer.second << std::endl;
28 int index = CalcIndex(timestamp);
30 if (timestamp >= fLowerBoundPointer.second + (2 *
GetBufferSize())) {
32 std::cout <<
"-I- FairRingSorterT::AddElement : Timestamp " << timestamp
33 <<
" larger than 2 * bufferspace: " << fLowerBoundPointer.second +
GetBufferSize()
34 <<
" writing out " << index + 1 << std::endl;
38 }
else if (timestamp >= fLowerBoundPointer.second +
GetBufferSize()) {
40 std::cout <<
"-I- FairRingSorterT::AddElement :Timestamp " << timestamp
41 <<
" larger than bufferspace: " << fLowerBoundPointer.second +
GetBufferSize() <<
" writing out "
42 << index + 1 << std::endl;
47 fRingBuffer[index].insert(std::pair<double, FairTimeStamp*>(timestamp, newElement));
52 int index = CalcIndex(timestampOfHitToWrite + fCellWidth);
54 int cellValue =
static_cast<int>(timestampOfHitToWrite / fCellWidth);
56 fLowerBoundPointer.second = ((cellValue + 1) * fCellWidth) -
GetBufferSize();
57 fLowerBoundPointer.first = index;
59 std::cout <<
"-I- FairRingSorter::SetLowerBound " << index <<
" / " << fLowerBoundPointer.second << std::endl;
65 if (fLowerBoundPointer.first >= index) {
66 for (
unsigned int i = fLowerBoundPointer.first; i < fRingBuffer.size(); i++) {
69 for (
int i = 0; i < index; i++) {
73 for (
int i = fLowerBoundPointer.first; i < index; i++) {
78 std::cout <<
"-I- FairRingSorter::WriteOutElements: Size of Output-Array: " << fOutputData.size() << std::endl;
79 for (
unsigned int i = 0; i < fOutputData.size(); i++) {
80 fOutputData[i]->Print();
83 std::cout << std::endl;
89 std::multimap<double, FairTimeStamp*>* myDataField = &fRingBuffer.at(index);
90 std::multimap<double, FairTimeStamp*>::iterator it;
91 if (!myDataField->empty()) {
93 std::cout <<
"-I- FairRingSorter:WriteOutElement ";
94 myDataField->begin()->second->Print();
95 std::cout << std::endl;
97 for (
auto& mmi : *myDataField) {
98 fOutputData.push_back(mmi.second);
100 myDataField->clear();
104 int FairRingSorter::CalcIndex(
double val)
106 unsigned int index =
static_cast<unsigned int>(val / fCellWidth);
107 while (index >= fRingBuffer.size()) {
108 index -= fRingBuffer.size();
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
ClassImp(FairEventBuilder)
virtual void AddElement(FairTimeStamp *digi, double timestamp)
virtual double GetBufferSize()
virtual FairTimeStamp * CreateElement(FairTimeStamp *data)
virtual void WriteOutAll()
virtual void SetLowerBound(double timestampOfHitToWrite)