11#include <FairRootManager.h>
14#include <TStopwatch.h>
38 for (
const auto& entry :
fConfig->fWindows) {
39 auto system = entry.first;
41 if (digiBranch ==
nullptr)
continue;
44 const vector<CbmStsDigi>* digiVec =
47 std::copy(digiVec->begin(), digiVec->end(), std::back_inserter(ts.
fData.
fSts.
fDigis));
51 const vector<CbmRichDigi>* digiVec =
54 std::copy(digiVec->begin(), digiVec->end(), std::back_inserter(ts.
fData.
fRich.
fDigis));
58 const vector<CbmMuchDigi>* digiVec =
61 std::copy(digiVec->begin(), digiVec->end(), std::back_inserter(ts.
fData.
fMuch.
fDigis));
65 const vector<CbmTrdDigi>* digiVec =
68 std::copy(digiVec->begin(), digiVec->end(), std::back_inserter(ts.
fData.
fTrd.
fDigis));
72 const vector<CbmTrdDigi>* digiVec =
75 std::copy(digiVec->begin(), digiVec->end(), std::back_inserter(ts.
fData.
fTrd2d.
fDigis));
79 const vector<CbmTofDigi>* digiVec =
82 std::copy(digiVec->begin(), digiVec->end(), std::back_inserter(ts.
fData.
fTof.
fDigis));
86 const vector<CbmFsdDigi>* digiVec =
89 std::copy(digiVec->begin(), digiVec->end(), std::back_inserter(ts.
fData.
fFsd.
fDigis));
93 const vector<CbmPsdDigi>* digiVec =
100 const vector<CbmBmonDigi>* digiVec =
103 std::copy(digiVec->begin(), digiVec->end(), std::back_inserter(ts.
fData.
fTof.
fDigis));
106 default: LOG(fatal) << GetName() <<
": Unknown detector type!";
119 TStopwatch timerStep;
122 std::map<ECbmModuleId, size_t> numDigisTs;
123 std::map<ECbmModuleId, size_t> numDigisEv;
135 for (
const auto& entry :
fConfig->fWindows)
143 for (
const auto& entry :
fConfig->fWindows)
144 numDigisTs[entry.first] = ts.
fData.
Size(entry.first);
158 auto removeIt = std::remove_if(
fEvents->begin(),
fEvents->end(), noTrigger);
166 size_t numEvents =
fEvents->size();
167 for (
const auto& entry :
fConfig->fWindows) {
168 for (
auto& event : (*
fEvents)) {
169 numDigisEv[entry.first] +=
GetNumDigis(event.fData, entry.first);
177 logOut << setw(15) << left << GetName() <<
" [";
178 logOut << fixed << setw(8) << setprecision(1) << right << timerTot.RealTime() * 1000. <<
" ms] ";
179 logOut <<
"TS " <<
fNumTs <<
", triggers " << numTriggers <<
", events " << numEvents;
181 for (
const auto& entry :
fConfig->fWindows) {
182 auto system = entry.first;
183 logOut <<
", frac " <<
ToString(system) <<
" digis "
184 << 100. * double(numDigisEv[system]) / double(numDigisTs[system]) <<
" %";
187 LOG(info) << logOut.str();
194 for (
const auto& entry :
fConfig->fWindows) {
195 auto system = entry.first;
206 LOG(info) <<
"=====================================";
207 LOG(info) << GetName() <<
": Run summary";
208 LOG(info) <<
"Timeslices : " <<
fNumTs;
211 for (
const auto& entry :
fConfig->fWindows) {
212 auto system = entry.first;
213 LOG(info) << setw(4) << left <<
ToString(system) <<
" digis in TS : " <<
fNumDigisTs[system];
214 LOG(info) << setw(4) << left <<
ToString(system) <<
" digis in events : " <<
fNumDigisEv[system] <<
" = " << fixed
217 LOG(info) <<
"Time / TS : " << fixed << setprecision(2) << 1000. *
fTimeTot / double(
fNumTs) <<
" ms";
218 LOG(info) <<
"Time fill TS : " << fixed << setprecision(2) << 1000. *
fTimeFillTs / double(
fNumTs)
220 LOG(info) <<
"Time build events : " << fixed << setprecision(2) << 1000. *
fTimeBuildEvt / double(
fNumTs)
222 LOG(info) <<
"Time selector events : " << fixed << setprecision(2) << 1000. *
fTimeSelectorEvt / double(
fNumTs)
224 LOG(info) <<
"=====================================";
242 default: result = 0;
break;
253 FairRootManager* ioman = FairRootManager::Instance();
256 LOG(info) <<
"==================================================";
257 LOG(info) << GetName() <<
": Initialising...";
263 LOG(info) <<
"--- Found branch DigiTimeslice.";
269 for (
const auto& entry :
fConfig->fWindows) {
270 auto system = entry.first;
272 LOG(warn) << GetName() <<
": No digi branch for " <<
ToString(system);
274 LOG(info) <<
"--- Found digi branch for " <<
ToString(system);
279 for (
const auto& entry :
fConfig->fWindows) {
280 auto system = entry.first;
286 fTriggers = ioman->InitObjectAs<std::vector<double>
const*>(
"Trigger");
288 LOG(fatal) << GetName() <<
": No Trigger branch!" << endl;
291 LOG(info) <<
"--- Found branch Trigger";
294 if (ioman->GetObject(
"DigiEvent")) {
295 LOG(fatal) << GetName() <<
": Branch DigiEvent already exists!";
298 fEvents =
new vector<CbmDigiEvent>;
299 ioman->RegisterAny(
"DigiEvent",
fEvents, IsOutputBranchPersistent(
"DigiEvent"));
301 LOG(fatal) << GetName() <<
": Output branch could not be created!";
304 LOG(info) <<
"--- Registered branch DigiEvent";
308 LOG(info) <<
fAlgo->ToString();
314 LOG(info) <<
"--- No event selection";
316 LOG(info) <<
"==================================================";
ClassImp(CbmConverterManager)
std::string ToString(ECbmModuleId modId)
@ kTrd
Transition Radiation Detector.
@ kTof
Time-of-flight Detector.
@ kPsd
Projectile spectator detector.
@ kSts
Silicon Tracking System.
@ kTrd2d
TRD-FASP Detector (FIXME)
@ kMuch
Muon detection system.
@ kFsd
Forward spectator detector.
@ kRich
Ring-Imaging Cherenkov Detector.
std::vector< CbmBmonDigi > fDigis
Data vector.
Abstract base class for CBM digi branches.
virtual boost::any GetBranchContainer() const
Get branch pointer.
Collection of digis from all detector systems.
CbmPsdDigiData fPsd
PSD data.
CbmTrdDigiData fTrd2d
TRD2D data.
CbmTrdDigiData fTrd
TRD data.
CbmTofDigiData fTof
TOF data.
CbmStsDigiData fSts
STS data.
CbmFsdDigiData fFsd
FSD data.
size_t Size(ECbmModuleId system) const
Size of detector data.
CbmRichDigiData fRich
RICH data.
CbmMuchDigiData fMuch
MUCH data.
CbmBmonDigiData fBmon
Beam monitor data.
Collection of digis from all detector systems within one event.
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
CbmDigiBranchBase * GetBranch(ECbmModuleId system)
Access to a digi branch.
InitStatus Init()
Initialisation.
static CbmDigiManager * Instance()
Static instance.
Collection of digis from all detector systems within one timeslice.
CbmDigiData fData
Timeslice data.
std::vector< CbmFsdDigi > fDigis
Data vector.
std::vector< CbmMuchDigi > fDigis
Data vector.
std::vector< CbmPsdDigi > fDigis
Data vector.
std::vector< CbmRichDigi > fDigis
Data vector.
std::vector< CbmStsDigi > fDigis
Data vector.
Task class for associating digis to events.
std::map< ECbmModuleId, size_t > fNumDigisTs
Event builder configuration.
virtual InitStatus Init()
Task initialisation.
const CbmDigiTimeslice * fTimeslice
CbmDigiTimeslice FillTimeSlice()
Construct a DigiTimeslice from the data in CbmDigiManager.
CbmTaskBuildEvents()
Constructor.
std::unique_ptr< cbm::algo::evbuild::EventBuilder > fAlgo
Event selector.
size_t GetNumDigis(const CbmDigiData &data, ECbmModuleId system)
Number of digis for a given system.
virtual ~CbmTaskBuildEvents()
Destructor.
const std::vector< double > * fTriggers
Input data (from simulation)
std::map< ECbmModuleId, size_t > fNumDigisEv
std::vector< CbmDigiEvent > * fEvents
Input data (triggers)
virtual void Finish()
Finish timeslice.
std::unique_ptr< cbm::algo::evbuild::DigiEventSelector > fSelector
Output data (events)
virtual void Exec(Option_t *opt)
Task execution.
CbmDigiManager * fDigiMan
Input data (from unpacking)
std::unique_ptr< cbm::algo::evbuild::EventBuilderConfig > fConfig
Algorithm.
std::vector< CbmTofDigi > fDigis
Data vector.
std::vector< CbmTrdDigi > fDigis
Data vector.
Constructs CbmDigiEvents out of CbmDigiTimeslices.
Collection of digis from all detector systems.
static std::vector< CbmDigiEvent > ToCbmDigiEvents(const std::vector< DigiEvent > &events)