Project
Loading...
Searching...
No Matches
FairWriteoutBuffer.cxx
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 * FairWriteoutBuffer.cpp
10 *
11 * Created on: Jul 30, 2010
12 * Author: stockman
13 */
14
15#include "FairWriteoutBuffer.h"
16
17#include "FairLogger.h" // for FairLogger
18#include "FairRootManager.h" // for FairRootManager
19
20#include <iostream> // for operator<<, ostream, cout, etc
21#include <iterator> // for reverse_iterator
22
23FairWriteoutBuffer::FairWriteoutBuffer(TString branchName, TString className, TString folderName, Bool_t persistance)
24 : TObject()
25 , fStartTime_map()
26 , fDeadTime_map()
27 , fBranchName(branchName)
28 , fClassName(className)
29 , fTreeSave(true)
30 , fActivateBuffering(kTRUE)
31 , fVerbose(0)
32 , fLogger(FairLogger::GetLogger())
33{
34 FairRootManager::Instance()->Register(branchName, className, folderName, persistance);
35 if (fBranchName == "" || fClassName == "") {
36 fTreeSave = false;
37 } else {
38 fTreeSave = true;
39 }
40}
41
43{
45 if (fVerbose > 0) {
46 std::cout << "Before removing: ";
49 }
50
52
53 if (fVerbose > 0) {
54 std::cout << "After removing: ";
57 }
58
60
61 if (fVerbose > 0) {
62 std::cout << "DeadTime map after readout time: " << time << std::endl;
64 }
65
66 } else {
68 }
69}
70
72{
74 std::vector<FairTimeStamp*> data;
76 if (fVerbose > 0) {
77 std::cout << "-I- FairWriteoutBuffer::WriteOutData for time: " << time << std::endl;
78 }
80 if (fTreeSave && data.size() > 0) {
81 TClonesArray* myArray = ioman->GetTClonesArray(fBranchName);
82 if (!myArray) {
83 std::cout << "-E- FairWriteoutBuffer::WriteOutData " << fBranchName << " array is not available!"
84 << std::endl;
85 }
86 if (fVerbose > 0) {
87 std::cout << "-I- FairWriteoutBuffer::WriteOutData size: " << data.size() << std::endl;
88 }
89 for (unsigned int i = 0; i < data.size(); i++) {
91 if (fVerbose > 1) {
92 std::cout << i << " : ";
93 data[i]->Print();
94 std::cout << std::endl;
95 }
96 delete data[i];
97 }
98 }
99 } else {
101 }
102}
103
105{
106 double ultimateTime = 0;
107
108 if (fStartTime_map.size() > 0) {
109 ultimateTime = fStartTime_map.rbegin()->first + 1;
111 }
112
113 if (fDeadTime_map.size() > 0) {
114 if (fDeadTime_map.rbegin()->first > ultimateTime) {
115 ultimateTime = fDeadTime_map.rbegin()->first + 1;
116 }
117 }
118
119 if (ultimateTime > 0) {
120 WriteOutData(ultimateTime);
121 }
122}
123
124std::vector<FairTimeStamp*> FairWriteoutBuffer::GetRemoveOldData(double time)
125{
126 typedef std::multimap<double, FairTimeStamp*>::iterator DTMapIter;
127 std::vector<FairTimeStamp*> result;
128 for (DTMapIter it = fDeadTime_map.begin(); it != fDeadTime_map.lower_bound(time); ++it) {
129 if (fVerbose > 1) {
130 std::cout << "-I- GetRemoveOldData: DeadTime: " << it->first << " Data: " << it->second << std::endl;
131 }
132 result.push_back(it->second);
133 EraseDataFromDataMap(it->second);
134 }
135 fDeadTime_map.erase(fDeadTime_map.begin(), fDeadTime_map.lower_bound(time));
136 return result;
137}
138
139std::vector<FairTimeStamp*> FairWriteoutBuffer::GetAllData()
140{
141 return GetRemoveOldData(fDeadTime_map.rbegin()->first + 1);
142}
143
144void FairWriteoutBuffer::FillNewData(FairTimeStamp* data, double startTime, double activeTime)
145{
146 FairTimeStamp* dataClone = static_cast<FairTimeStamp*>(data->Clone());
147
148 if (fActivateBuffering) {
149 if (fVerbose > 0) {
150 std::cout << "StartTime: " << startTime << std::endl;
151 }
152 std::pair<double, FairTimeStamp*> timeData(activeTime, dataClone);
153 fStartTime_map.insert(std::pair<double, std::pair<double, FairTimeStamp*>>(startTime, timeData));
154 } else {
155 AddNewDataToTClonesArray(dataClone);
156 delete dataClone;
157 }
158}
159
160void FairWriteoutBuffer::FillDataToDeadTimeMap(FairTimeStamp* data, double activeTime, double startTime)
161{
162 if (fActivateBuffering) {
163 typedef std::multimap<double, FairTimeStamp*>::iterator DTMapIter;
164 // typedef std::map<FairTimeStamp, double>::iterator DataMapIter;
165 if (activeTime < 0)
166 activeTime = 0; // to avoid errors due to wrong (negative) returnvalues of overwritten modify function by
167 // subdetector groups. A negative (-1) aktiveTime already indicate empty data maps!
168 double timeOfOldData = FindTimeForData(data);
169 // PrintDeadTimeMap();
170 if (timeOfOldData > -1) { // if an older active data object is already present
171 if (fVerbose > 1) {
172 std::cout << " OldData found! " << timeOfOldData << std::endl;
173 }
174 if (fVerbose > 1) {
175 std::cout << "New Data: " << activeTime << " : " << data << std::endl;
176 }
177 double currentdeadtime = timeOfOldData;
178 FairTimeStamp* oldData;
179 bool dataFound = false;
180
181 // PrintDeadTimeMap();
182 for (DTMapIter it = fDeadTime_map.lower_bound(currentdeadtime);
183 it != fDeadTime_map.upper_bound(currentdeadtime);
184 ++it) {
185 oldData = it->second;
186 if (fVerbose > 1) {
187 std::cout << "Check Data: " << it->first << " : " << oldData << std::endl;
188 }
189 if (oldData->equal(data)) {
190 if (fVerbose > 1) {
191 std::cout << " oldData == data " << std::endl;
192 }
193 if (fVerbose > 1) {
194 std::cout << it->first << " : " << it->second << std::endl;
195 }
196 fDeadTime_map.erase(it);
197 EraseDataFromDataMap(oldData);
198 dataFound = true;
199 break;
200 }
201 }
202
203 if (dataFound == true) {
204 if (timeOfOldData
205 > startTime) { // if older active data can interference with the new data call modify function
206 std::vector<std::pair<double, FairTimeStamp*>> modifiedData =
207 Modify(std::pair<double, FairTimeStamp*>(currentdeadtime, oldData),
208 std::pair<double, FairTimeStamp*>(activeTime, data));
209 for (unsigned int i = 0; i < modifiedData.size(); i++) {
210 FillDataToDeadTimeMap(modifiedData[i].second,
211 modifiedData[i].first,
212 0); // startTime = 0 since the Maps are already empty and the startTime
213 // therefore doesn't matter anymore
214 if (fVerbose > 1) {
215 std::cout << i << " :Modified Data: " << modifiedData[i].first << " : "
216 << modifiedData[i].second << std::endl;
217 }
218 }
219 } else { // no interference can happen between old hit and new hit
220 AddNewDataToTClonesArray(oldData); // therefore the old hit is written out
221 fDeadTime_map.insert(
222 std::pair<double, FairTimeStamp*>(activeTime, data)); // and the new hit is stored
223 FillDataMap(data, activeTime);
224 }
225 } else {
226 std::cout << "-E- FairWriteoutBuffer::FillDataToDeadTimeMap: old data present in dataMap but not in "
227 "deadTimeMap!"
228 << std::endl;
229 }
230
231 } else {
232 if (fVerbose > 1) {
233 std::cout << "-I- FairWriteoutBuffer::FillDataToDeadTimeMap Data Inserted: " << activeTime << " : ";
234 data->Print();
235 std::cout << std::endl;
236 }
237 fDeadTime_map.insert(std::pair<double, FairTimeStamp*>(activeTime, data));
238 FillDataMap(data, activeTime);
239 }
240 } else {
242 delete data;
243 }
244}
245
247{
248 typedef std::multimap<double, std::pair<double, FairTimeStamp*>>::iterator startTimeMapIter;
249
250 startTimeMapIter stopTime = fStartTime_map.lower_bound(time);
251 for (startTimeMapIter iter = fStartTime_map.begin(); iter != stopTime; ++iter) {
252 std::pair<double, FairTimeStamp*> data = iter->second;
253 double startTime = iter->first;
254 FillDataToDeadTimeMap(data.second, data.first, startTime);
255 }
256 fStartTime_map.erase(fStartTime_map.begin(), stopTime);
257}
258
260{
261 typedef std::multimap<double, std::pair<double, FairTimeStamp*>>::iterator startTimeMapIter;
262 std::cout << "StartTimeMap: " << std::endl;
263 for (startTimeMapIter iter = fStartTime_map.begin(); iter != fStartTime_map.end(); ++iter) {
264 FairTimeStamp* data = iter->second.second;
265 std::cout << " | " << iter->first << "/" << data->GetTimeStamp();
266 }
267 std::cout << " |" << std::endl;
268}
269
271{
272 typedef std::multimap<double, FairTimeStamp*>::iterator DTMapIter;
273 std::cout << "DeadTimeMap: " << std::endl;
274 for (DTMapIter it = fDeadTime_map.begin(); it != fDeadTime_map.end(); ++it) {
275 std::cout << it->first << " / ";
276 PrintData(it->second);
277 std::cout << std::endl;
278 }
279 std::cout << std::endl;
280}
281
int16_t time
Definition RawEventData.h:4
ClassImp(FairWriteoutBuffer)
int32_t i
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc true
std::string className
Definition Objects.cxx:33
TClonesArray * GetTClonesArray(TString branchName)
void Register(const char *name, const char *Foldername, TNamed *obj, Bool_t toFile)
static FairRootManager * Instance()
virtual bool equal(FairTimeStamp *data)
A container class to store digi data during events.
virtual void FillNewData(FairTimeStamp *data, double startTime, double activeTime)
virtual double FindTimeForData(FairTimeStamp *data)=0
virtual void WriteOutAllData()
virtual void WriteOutData(double time)
virtual void PrintData(FairTimeStamp *data)
virtual void EraseDataFromDataMap(FairTimeStamp *data)=0
delete the element from the search buffer (see PndSdsDigiPixelWriteoutBuffer)
virtual std::vector< FairTimeStamp * > GetAllData()
virtual void FillDataToDeadTimeMap(FairTimeStamp *data, double activeTime, double startTime)
virtual void PrintStartTimeMap()
virtual void FillDataMap(FairTimeStamp *data, double activeTime)=0
add a new element in the search buffer
virtual std::vector< std::pair< double, FairTimeStamp * > > Modify(std::pair< double, FairTimeStamp * > oldData, std::pair< double, FairTimeStamp * >)
std::multimap< double, FairTimeStamp * > fDeadTime_map
virtual void PrintDeadTimeMap()
Method should be overwritten in derived classes to print the data of an object stored in the buffer.
std::multimap< double, std::pair< double, FairTimeStamp * > > fStartTime_map
virtual void WriteOutDataDeadTimeMap(double time)
virtual void AddNewDataToTClonesArray(FairTimeStamp *data)=0
virtual std::vector< FairTimeStamp * > GetRemoveOldData(double time)
virtual void MoveDataFromStartTimeMapToDeadTimeMap(double time)
GLuint64EXT * result
Definition glcorearb.h:5662
GLint first
Definition glcorearb.h:399
GLboolean * data
Definition glcorearb.h:298