14#include "FairRootManager.h"
36 , fListOfFolders(new TObjArray())
44 , fMode(
cbm::sim::
Mode::Timebased)
45 , fCurrentInputSet(nullptr)
46 , fSwitchInputSet(kFALSE)
56 if (inputSet)
delete inputSet;
68 inputSet->ActivateObject(
object, branchName);
81 LOG(fatal) <<
"DigitizationSource: Input ID " << inputId <<
" is already defined!";
87 inputSet->
AddInput(inputId, chain, mode);
95 LOG(fatal) <<
"DigitizationSource: Incompatible branch list!";
104 LOG(info) <<
"DigitizationSource: Added input " << inputId <<
" with rate " << rate <<
" / s, mode: "
115 Bool_t success = kTRUE;
119 LOG(debug) <<
"DigitizationSource: required branch " << entry <<
" not present in input set!";
126 std::stringstream ss;
127 ss <<
"DigitizationSource: Global branch list is ";
130 LOG(info) << ss.str();
131 std::stringstream ss1;
132 ss1 <<
"DigitizationSource: Input set branch list is ";
136 LOG(info) << ss1.str();
159 return (maxEvents >= 0 ? maxEvents : 1e6);
170 LOG(fatal) <<
"DigitizationSource: Input ID " << inputId <<
" is already defined!";
176 LOG(fatal) <<
"DigitizationSource: Target input ID " << targetInputId <<
" for input " << inputId
177 <<
" does not exist!";
182 fInputMap[targetInputId]->AddInput(inputId, chain, mode);
185 LOG(info) <<
"DigitizationSource: Embedded input " << inputId <<
" into input " << targetInputId <<
", mode: "
209 return fInputMap.begin()->second->GetFirstInput().second;
220 LOG(fatal) <<
"DigitizationSource: No input sets defined!";
224 LOG(fatal) <<
"DigitizationSource: More than one input defined "
225 <<
"in event-by-event mode!";
231 inputSet->RegisterChains();
235 TFile* file = input->
GetChain()->GetFile();
237 TFolder* folder = file->Get<TFolder>(
"cbmroot");
239 gROOT->GetListOfBrowsables()->Add(folder);
252 if (
fMode == Mode::Timebased) {
253 for (
size_t iSet = 0; iSet <
fInputSets.size(); iSet++) {
256 LOG(info) <<
"First time for input set " << iSet <<
" is " << time <<
" ns.";
257 fNextEvent.insert(std::make_pair(time, inputSet));
312 std::cout << std::endl;
313 LOG(info) <<
"DigitizationSource: Event " <<
event <<
" at t = " << std::fixed << std::setprecision(3) <<
fCurrentTime
319 LOG(info) <<
"DigitizationSource: No more entries in input " <<
fCurrentInputId;
333 auto result =
fInputSets.front()->GetFirstInput();
341 LOG(info) <<
"DigitizationSource: Requested event " <<
event <<
" exceeds number of entries in input "
355 LOG(info) <<
"DigitizationSource: Event " <<
event <<
" at t = " <<
fCurrentTime <<
" ns"
367 auto firstInput =
fInputSets.front()->GetFirstInput();
375 LOG(info) <<
"DigitizationSource: Run ID is " <<
fCurrentRunId;
ClassImp(CbmConverterManager)
ECbmTreeAccess
Mode to read entries from a ROOT TTree.
Source class for the input to digitization in CBM.
std::vector< CbmMCInputSet * > fInputSets
CbmMCInput * GetFirstInput()
First input from the first input set @value Pointer to first input.
FairMCEventHeader * fMCEventHeader
time -> inputSet
virtual Bool_t Init()
Abstract in base class. No implementation here.
Int_t ReadEventByEvent(UInt_t event)
Get next entry in event-by-event mode.
virtual Bool_t ActivateObject(TObject **object, const char *branchName)
Activate a branch and set its address.
Bool_t CheckBranchList(CbmMCInputSet *input)
Compare an input set branch list with the reference list.
void AddInput(UInt_t inputId, TChain *chain, cbm::sim::TimeDist dist, Double_t rate, ECbmTreeAccess mode=ECbmTreeAccess::kRegular)
Add a transport input.
virtual ~CbmDigitizationSource()
Destructor.
TObjArray * fListOfFolders
void EmbedInput(UInt_t inputId, TChain *chain, UInt_t targetInputId, ECbmTreeAccess mode=ECbmTreeAccess::kRegular)
Embed a transport input.
std::set< TString > fBranches
virtual Int_t CheckMaxEventNo(Int_t lastEntry=0)
Maximal entry number the source can run to.
void ReadRunId()
Read run ID from the first entry in the first input.
virtual void FillEventHeader(FairEventHeader *event)
Fill the output event header.
std::map< UInt_t, CbmMCInputSet * > fInputMap
CbmMCInputSet * fCurrentInputSet
CbmDigitizationSource()
Constructor.
std::multimap< Double_t, CbmMCInputSet * > fNextEvent
input ID -> inputSet
virtual Int_t ReadEvent(UInt_t event=0)
Provide one tree entry.