17#include <FairEventHeader.h>
18#include <FairRootManager.h>
19#include <FairRunAna.h>
23#include <TGenericClassInfo.h>
24#include <TStopwatch.h>
39using std::setprecision;
42using std::stringstream;
48 , fIsEventByEvent(eventMode)
49 , fTimeSliceLength(-1.)
50 , fStoreEmptySlices(kFALSE)
51 , fTimeEventPrevious(-1.)
56 , fNofTimeSlicesEmpty(0)
59 , fTimeSliceFirst(-1.)
66 , fEventsCurrent(nullptr)
76 , fIsEventByEvent(kFALSE)
77 , fTimeSliceLength(tsLength)
78 , fStoreEmptySlices(kFALSE)
79 , fTimeEventPrevious(-1.)
84 , fNofTimeSlicesEmpty(0)
87 , fTimeSliceFirst(-1.)
94 , fEventsCurrent(nullptr)
109 Bool_t result = kTRUE;
111 result = (result && digitizer.second->CheckOutput());
138 if (entry.second) entry.second->FillCustomData(1, kTRUE);
145 FairRootManager::Instance()->Fill();
165 for (Int_t iLink = 0; iLink < match.
GetNofLinks(); iLink++) {
187 Int_t file = FairRunAna::Instance()->GetEventHeader()->GetInputFileId();
188 Int_t
event = FairRunAna::Instance()->GetEventHeader()->GetMCEntryNumber();
189 Double_t eventTime = FairRunAna::Instance()->GetEventHeader()->GetEventTime();
196 LOG(debug) << GetName() <<
": Fill time is " << fillTime <<
" ns";
224 LOG(info) << left << setw(15) << GetName() <<
"[" << fixed << setprecision(3) <<
fTimer.RealTime() <<
" s]"
239 LOG(debug) << GetName() <<
": Fill time slice up to t = " << tMax <<
" ns";
241 LOG(debug) << GetName() <<
": Fill time slice";
246 std::stringstream ss;
247 ss << GetName() <<
": Fill data: ";
248 ULong64_t nDataAll = 0;
252 nData = digitizer.second->FillTimeSlice(
fTimeSlice, tMax);
254 nData = digitizer.second->FillTimeSlice(
fTimeSlice);
260 LOG(debug) << ss.str();
263 LOG(debug) << GetName() <<
": total " << nData <<
" moved";
274 std::cout << std::endl;
275 LOG(info) << fName <<
": Finish run";
295 LOG(fatal) << GetName() <<
": Time-slice mode is flexible but "
296 <<
" buffers are not empty after fill!";
304 LOG(fatal) << GetName() <<
": Time-slice mode is event but "
305 <<
" buffers are not empty!";
310 std::cout << std::endl;
311 LOG(info) <<
"=====================================";
312 LOG(info) << GetName() <<
": Run summary";
313 LOG(info) <<
"Events: " << setw(10) << right <<
fNofEvents;
314 LOG(info) <<
"Digis: " << setw(10) << right <<
fNofDigis <<
" from " << setw(10) << right << fixed
315 << setprecision(1) <<
fTimeDigiFirst <<
" ns to " << setw(10) << right << fixed << setprecision(1)
319 LOG(info) <<
"Time slices: " << setw(10) << right <<
fNofTimeSlices <<
" from " << setw(10) << right << fixed
320 << setprecision(1) <<
fTimeSliceFirst <<
" ns to " << setw(10) << right << fixed << setprecision(1)
323 LOG(info) <<
"Time slices: " << setw(10) << right <<
fNofTimeSlices;
325 LOG(info) <<
"=====================================";
327 std::cout << std::endl;
339 nData += digitizer.second->GetDaqBufferSize();
350 ss <<
"Buffer status: empty";
358 << digitizer.second->GetDaqBufferStatus();
370 Double_t test = digitizer.second->GetDaqBufferTimeFirst();
374 tMin = (tMin < test ? tMin : test);
386 Double_t test = digitizer.second->GetDaqBufferTimeLast();
390 tMax = (tMax > test ? tMax : test);
401 std::cout << std::endl;
402 LOG(info) <<
"==========================================================";
403 LOG(info) << fName <<
": Initialisation";
408 LOG(info) << fName <<
": Event mode";
413 LOG(info) << fName <<
": Time-based mode, time slice duration " <<
fTimeSliceLength <<
" ns";
417 LOG(info) << fName <<
": Time-based mode, flexible time slice";
426 FairRootManager::Instance()->Register(
"TimeSlice.",
"DAQ",
fTimeSlice, kTRUE);
430 FairRootManager::Instance()->Register(
"MCEventList.",
"DAQ",
fEventsCurrent, kTRUE);
432 LOG(info) << GetName() <<
": Initialisation successful";
433 LOG(info) <<
"==========================================================";
434 std::cout << std::endl;
444 Bool_t empty = kTRUE;
446 if (digitizer.second->GetDaqBufferSize()) {
460 std::stringstream ss;
461 ss << GetName() <<
": Current MC event range: ";
464 LOG(info) << ss.str();
469 Int_t file = it->first;
470 Int_t firstEvent = it->second.first;
471 Int_t lastEvent = it->second.second;
472 ss <<
"\n Input file " << file <<
", first event " << firstEvent <<
", last event " << lastEvent;
475 LOG(info) << ss.str();
507 entry.second->ClearOutput();
515 LOG(info) <<
"The latency was set from " <<
fLatency <<
"ns to " << time <<
"ns";
ClassImp(CbmConverterManager)
CBM task class for filling digis into time slices.
Int_t fNofTimeSlices
Number of time slices.
Int_t fNofEvents
Number of processed events.
Bool_t IsDaqBufferEmpty() const
Check for empty DAQ buffers.
Double_t fLatency
Maximal time disorder of input data [ns].
Double_t fTimeDigiFirst
Time of first digi.
Int_t fNofDigisIgnored
Number of ignored digis.
CbmDaq(Bool_t eventMode=kFALSE)
Constructor.
Bool_t CheckOutput() const
Check the output arrays for being time-sorted.
Int_t fNofTimeSlicesEmpty
Number of empty time slices.
void StartNextTimeSlice()
Start a new time slice in the output tree.
Double_t fTimeSliceLength
Time-slice length [ns].
Double_t fTimeDigiLast
Time of last digi.
Bool_t fIsEventByEvent
Flag for event-by-event mode.
Int_t fNofDigis
Total number of processed digis.
void SetLatency(Double_t time)
Set the DAQ buffer latency.
Double_t fTimeSliceFirst
Start time of first time slice.
CbmTimeSlice * fTimeSlice
Array of registered digitizers.
std::string GetBufferStatus(Bool_t verbose=kFALSE) const
Debug output of DAQ buffer status @value String with status of DAQ buffers.
std::map< Int_t, std::pair< Int_t, Int_t > > fEventRange
MC events for current time slice.
CbmMCEventList * fEventsCurrent
MC event list (all)
Double_t GetBufferTimeFirst() const
Time of first datum in DAQ buffers @value Minimum time stamp in all DAQ buffers.
virtual InitStatus Init()
Initialisation.
virtual void Exec(Option_t *opt)
Task execution.
ULong64_t GetBufferSize() const
Size of DAQ buffers @value Sum of number of data in all DAQ buffers.
Bool_t fStoreEmptySlices
Flag to store also empty time slices.
void PrintCurrentEventRange() const
Double_t fTimeEventPrevious
Time of previous event [ns].
Double_t GetBufferTimeLast() const
Time of last datum in DAQ buffers @value Maximum time stamp in all DAQ buffers.
ULong64_t FillTimeSlice(Bool_t timeLimit, Double_t fillTime=-1.)
Double_t fTimeSliceLast
Stop time of last time slice.
void SetDigitizer(ECbmModuleId system, CbmDigitizeBase *digitizer)
Set the digitizer for a given system.
CbmMCEventList fEventList
Current time slice.
std::map< ECbmModuleId, CbmDigitizeBase * > fDigitizers
Output arrays (digis)
Abstract base class for CBM digitisation tasks.
Container class for MC events with number, file and start time.
std::string ToString(const char *option="") const
void Sort()
Sort the list.
virtual void Clear(Option_t *)
Delete all event entries.
double GetEventTime(uint32_t event, uint32_t file)
Event start time.
bool Insert(uint32_t event, uint32_t file, double time)
const CbmLink & GetLink(int32_t i) const
int32_t GetNofLinks() const
static TString GetModuleNameCaps(ECbmModuleId moduleId)
Bookkeeping of time-slice content.
@ kEvent
Flexible time slice; no fixed time limits.
@ kFlexible
Regular time slice with fixed-size time interval.
std::string ToString() const
const CbmMatch & GetMatch() const
double GetTimeDataFirst() const
Time stamp of first data.
double GetEndTime() const
void Reset()
Reset the time slice.
double GetTimeDataLast() const
Time stamp of last data.
double GetStartTime() const