19#include <FairRootManager.h>
22#include <TClonesArray.h>
23#include <TStopwatch.h>
48 int32_t nLinks = (match !=
nullptr) ? match->
GetNofLinks() : 0;
50 for (int32_t iLink = 0; iLink < nLinks; iLink++) {
53 if (mcInput < 0 || mcEvent < 0) {
56 eventMatch.
AddLink(1., 0, mcEvent, mcInput);
70 uint64_t nDigisTot = 0;
71 uint64_t nDigisNoise = 0;
72 uint64_t nDigisAmbig = 0;
82 map<pair<int32_t, int32_t>,
CbmEvent> eventMap;
108 LOG(fatal) <<
"unknown type of the module";
117 for (int32_t iDigi = 0; iDigi < nDigis; iDigi++) {
122 for (int32_t iLink = 0; iLink < matchedEvents.
GetNofLinks(); iLink++) {
123 const auto& link = matchedEvents.
GetLink(iLink);
124 auto eventID = make_pair(link.GetFile(), link.GetEntry());
127 auto eventIt = eventMap.find(eventID);
128 if (eventIt == eventMap.end()) {
129 auto result = eventMap.insert(make_pair(eventID,
CbmEvent()));
130 assert(result.second);
131 eventIt = result.first;
133 eventIt->second.AddData(digiType, iDigi);
136 auto digiEventIt = digiEventMap.find(eventID);
137 if (digiEventIt == digiEventMap.end()) {
138 auto result = digiEventMap.insert(make_pair(eventID,
CbmDigiEvent()));
139 assert(result.second);
140 digiEventIt = result.first;
163 << nAmbig <<
" ambiguous), noise " << nNoise;
165 nDigisAmbig += nAmbig;
166 nDigisNoise += nNoise;
172 for (
auto& kv : eventMap) {
188 double eventTime = tsStart;
189 assert(nEvents ==
fEvents->GetEntriesFast());
191 store->
Swap(kv.second);
199 for (
auto& kv : digiEventMap) {
215 double eventTime = tsStart;
216 kv.second.fTime = eventTime;
217 kv.second.fNumber = evNum++;
224 logOut << setw(20) << left << GetName() <<
" [";
225 logOut << fixed << setw(8) << setprecision(1) << right << timer.RealTime() * 1000. <<
" ms] ";
227 if (
fEvents) logOut <<
", events " << nEvents;
228 logOut <<
", digis " << nDigisTot <<
" (" << nDigisAmbig <<
" ambiguous), noise: " << nDigisNoise;
229 LOG(info) << logOut.str();
235 fTime += timer.RealTime();
238 if (fair::Logger::Logging(fair::Severity::debug)) {
239 for (int32_t iEvent = 0; iEvent <
fEvents->GetEntriesFast(); iEvent++) {
252 std::cout << std::endl;
253 LOG(info) <<
"=====================================";
254 LOG(info) << GetName() <<
": Run summary";
262 LOG(info) <<
"Time / TS : " << fixed << setprecision(2) << 1000. *
fTime / double(
fNumEntries) <<
" ms";
263 LOG(info) <<
"=====================================";
273 FairRootManager* ioman = FairRootManager::Instance();
280 std::cout << std::endl;
281 LOG(info) <<
"==================================================";
282 LOG(info) << GetName() <<
": Initialising...";
293 LOG(fatal) << GetName() <<
": No match branch found!";
300 LOG(warn) << GetName() <<
": No TimeSlice branch found!";
307 LOG(warn) << GetName() <<
": No MCEventList branch found!";
313 if (ioman->GetObject(
"CbmEvent")) {
314 LOG(fatal) << GetName() <<
": Branch CbmEvent already exists!";
317 fEvents =
new TClonesArray(
"CbmEvent", 100);
318 ioman->Register(
"CbmEvent",
"Cbm_Event",
fEvents, IsOutputBranchPersistent(
"CbmEvent"));
320 LOG(fatal) << GetName() <<
": Output branch could not be created!";
325 if (ioman->GetObject(
"DigiEvent")) {
326 LOG(fatal) << GetName() <<
": Branch DigiEvent already exists!";
330 ioman->RegisterAny(
"DigiEvent",
fDigiEvents, IsOutputBranchPersistent(
"DigiEvent"));
332 LOG(fatal) << GetName() <<
": Output branch could not be created!";
337 LOG(info) <<
"==================================================";
338 std::cout << std::endl;
ClassImp(CbmConverterManager)
@ kMvd
Micro-Vertex Detector.
@ kTrd
Transition Radiation Detector.
@ kTof
Time-of-flight Detector.
@ kPsd
Projectile spectator detector.
@ kSts
Silicon Tracking System.
@ kMuch
Muon detection system.
@ kFsd
Forward spectator detector.
@ kNofSystems
For loops over active systems.
@ kRich
Ring-Imaging Cherenkov Detector.
CbmMatch EventsInMatch(const CbmMatch *match)
Number of different MC events in a match object.
CbmBuildEventsIdeal()
Constructor.
virtual void Finish()
Finish timeslice.
CbmDigiManager * fDigiMan
virtual InitStatus Init()
Task initialisation.
virtual void Exec(Option_t *opt)
Task execution.
CbmTimeSlice * fTimeslice
Input (digis)
virtual ~CbmBuildEventsIdeal()
Destructor.
CbmMCEventList * fMCEvents
Input (timeslice meta-data)
std::vector< CbmDigiEvent > * fDigiEvents
Output (CbmEvent)
std::vector< ECbmModuleId > fSystems
Collection of digis from all detector systems within one event.
static Int_t GetNofDigis(ECbmModuleId systemId)
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
static Bool_t IsMatchPresent(ECbmModuleId systemId)
Presence of a digi match branch.
InitStatus Init()
Initialisation.
const Digi * Get(Int_t index) const
Get a digi object.
static CbmDigiManager * Instance()
Static instance.
const CbmMatch * GetMatch(ECbmModuleId systemId, UInt_t index) const
Get a match object.
Class characterising one event by a collection of links (indices) to data objects,...
void SetNumber(int32_t number)
void SetStartTime(double startTime)
void SetEndTime(double endTime)
std::string ToString() const
Container class for MC events with number, file and start time.
const CbmLink & GetLink(int32_t i) const
int32_t GetNofLinks() const
void AddLink(const CbmLink &newLink)
static TString GetModuleNameCaps(ECbmModuleId moduleId)
Data class for a single-channel message in the STS.
Bookkeeping of time-slice content.
double GetStartTime() const