11#define CBMDIGITIZE_H 1
18#include <FairRootManager.h>
23#include <RtypesCore.h>
48 typedef std::pair<std::unique_ptr<Digi>, std::unique_ptr<CbmMatch>>
Data;
70 if (
fDigis->empty())
return kTRUE;
71 Double_t prevTime =
fDigis->begin()->GetTime();
72 for (
auto it = (
fDigis->begin())++; it !=
fDigis->end(); it++) {
73 if (it->GetTime() < prevTime) {
74 LOG(error) << GetName() <<
": CheckBuffer: Found digi at t = " << it->GetTime()
75 <<
" ns after digi at t = " << prevTime <<
" ns";
79 prevTime = it->GetTime();
150 std::stringstream ss;
193 FairRootManager* ioman = FairRootManager::Instance();
199 if (digiBranchName.IsNull()) {
200 TString digiClassName = Digi::GetClassName();
201 if (digiClassName.BeginsWith(
"Cbm")) digiBranchName = digiClassName(3, digiClassName.Length());
206 fDigis =
new std::vector<Digi>();
207 ioman->RegisterAny(digiBranchName.Data(),
fDigis, IsOutputBranchPersistent(digiBranchName));
208 LOG(info) << GetName() <<
": Registered branch " << digiBranchName;
212 TString matchBranchName = digiBranchName +
"Match";
213 fMatches =
new std::vector<CbmMatch>();
214 ioman->RegisterAny(matchBranchName.Data(),
fMatches, IsOutputBranchPersistent(matchBranchName));
215 LOG(info) << GetName() <<
": Registered branch " << matchBranchName;
240 std::unique_ptr<Digi> tmpDigi(digi);
241 std::unique_ptr<CbmMatch> tmpMatch(match);
242 fDaqBuffer.insert(make_pair(time, std::make_pair(std::move(tmpDigi), std::move(tmpMatch))));
280 Bool_t checkMinTime = kTRUE;
281 Bool_t checkMaxTime = kTRUE;
283 if (checkLimit && fillTime < tMax) tMax = fillTime;
286 checkMinTime = kFALSE;
287 checkMaxTime = checkLimit;
292 LOG(fatal) << GetName() <<
": Unknown time-slice type!";
298 while (it !=
fDaqBuffer.end() && ((!checkMaxTime) || it->first < tMax)) {
303 if (timeSlice->
IsRegular() && it->first < 0.) {
310 assert((!checkMinTime) || it->first >= tMin);
316 Double_t globalTime = it->first;
317 std::unique_ptr<Digi>& d = it->second.first;
319 d->SetTime(globalTime - tMin);
323 assert(it->second.second);
324 fMatches->push_back(*(it->second.second));
Abstract base class for CBM digitisation tasks.
std::set< uint32_t > fInactiveChannels
Name of file with inactive channels.
virtual ECbmModuleId GetSystemId() const =0
Detector system ID.
Bool_t fCreateMatches
Flag for production of inter-event noise.
Base class template for CBM digitisation tasks.
Double_t GetLatency() const
Return the detector specific latency @value latency.
Double_t GetDaqBufferTimeLast() const
Time stamp of last data in the DAQ buffer @value Time stamp of last data in the DAQ buffer.
Double_t GetDaqBufferTimeFirst() const
Time stamp of first data in the DAQ buffer @value Time stamp of first data in the DAQ buffer.
std::vector< CbmMatch > * fMatches
Output array (Digi)
virtual ~CbmDigitize()
Destructor.
void ClearOutput()
Clear the output arrays.
ULong64_t GetDaqBufferSize() const
Size of DAQ buffer @value Number of data in the DAQ buffer.
void RegisterOutput()
Register the output arrays.
CbmDigitize()
Default constructor.
CbmDigitize(const char *name, const char *branchName="")
Constructor with name.
std::vector< Digi > * fDigis
bool IsChannelActive(const Digi &digi)
Test if the channel of a digi object is set active.
TString fBranchName
Output branch name.
ULong64_t FillTimeSlice(CbmTimeSlice *timeSlice)
Move data from the DaqBuffer into the current time slice.
void SendData(Double_t time, Digi *digi, CbmMatch *match=nullptr)
Send a digi and the corresponding match object to the DAQ.
std::string GetDaqBufferStatus() const
Debug output of DAQ buffer status @value String with status of DAQ buffer.
ULong64_t FillTimeSlice(CbmTimeSlice *timeSlice, Double_t fillTime)
Move data from the DaqBuffer into the current time slice.
std::multimap< double, Data > fDaqBuffer
Output array (CbmMatch)
std::pair< std::unique_ptr< Digi >, std::unique_ptr< CbmMatch > > Data
Short for data to be handled (pair of digi and match)
Bool_t CheckOutput()
Check the output for being time-sorted.
ULong64_t FillTimeSlice(CbmTimeSlice *timeSlice, Bool_t checkLimit, Double_t fillTime)
Move data from the DaqBuffer into the current time slice.
Bookkeeping of time-slice content.
double GetEndTime() const
bool RegisterData(ECbmModuleId system, double time)
Register data to time-slice header.
double GetStartTime() const