11 #ifndef EVENTDISPLAY_FAIRTIMEBASEDDATAHANDLERT_H_
12 #define EVENTDISPLAY_FAIRTIMEBASEDDATAHANDLERT_H_
16 #include "TClonesArray.h"
17 #include "TGeoTrack.h"
20 #include <fairlogger/Logger.h>
30 : fHoldTime(holdTime){};
41 void FillTClonesArray(TClonesArray* inputArray,
int evtIndex,
double t0Event,
double t0Current);
42 std::vector<std::pair<T*, double>>&
GetData() {
return fDataVector; };
57 std::vector<std::pair<T*, double>> fDataVector;
58 int fLastEventInBuffer = -1;
71 RemoveOldTracks(t0Current);
72 if (fLastEventInBuffer != evtIndex) {
73 LOG(debug) <<
"Fill TClonesArray: CurrentTime " << t0Current <<
" Event " << evtIndex <<
" time: " << t0Event;
74 fLastEventInBuffer = evtIndex;
75 for (
int i = 0; i < inputArray->GetEntriesFast(); i++) {
76 T* data =
static_cast<T*
>(inputArray->At(i)->Clone());
77 fDataVector.push_back(std::make_pair(data, t0Event));
86 fDataVector.begin(), fDataVector.end(), [](std::pair<T*, double>
const& track) {
delete (track.first); });
88 fLastEventInBuffer = -1;
94 if (fDataVector.size() > 0) {
95 fDataVector.erase(std::remove_if(fDataVector.begin(),
97 [&](std::pair<T*, double>
const& track) {
98 double t = track.first->GetTime();
99 if ((t + track.second) < (currentTime - fHoldTime)) {
100 delete (track.first);
112 if (fDataVector.size() > 0) {
113 fDataVector.erase(std::remove_if(fDataVector.begin(),
115 [&](std::pair<TGeoTrack*, double>
const& track) {
117 track.first->GetLastPoint(x, y, z, t);
118 if (((t * 1e9) + track.second) < (currentTime - fHoldTime)) {
119 delete (track.first);
131 if (fDataVector.size() > 0) {
132 fDataVector.erase(std::remove_if(fDataVector.begin(),
134 [&](std::pair<FairMCPoint*, double>
const& track) {
135 Double_t t = track.first->GetTime();
136 if (((t) + track.second) < (currentTime - fHoldTime)) {
137 delete (track.first);
149 if (fDataVector.size() > 0) {
150 fDataVector.erase(std::remove_if(fDataVector.begin(),
152 [&](std::pair<FairHit*, double>
const& track) {
153 Double_t t = track.first->GetTimeStamp();
154 if (((t) + track.second) < (currentTime - fHoldTime)) {
155 delete (track.first);
std::vector< std::pair< T *, double > > & GetData()
FairTimebasedDataHandlerT(double holdTime=10.0)
void FillTClonesArray(TClonesArray *inputArray, int evtIndex, double t0Event, double t0Current)
virtual ~FairTimebasedDataHandlerT()
void RemoveOldTracks(double currentTime)
void SetHoldTime(double time)