33ITS3DigitReader::ITS3DigitReader(
bool useMC,
bool doStag,
bool useCalib) : mUseMC(useMC), mDoStaggering(doStag), mUseCalib(useCalib), mDetNameLC(mDetName =
"IT3"), mDigTreeName(
"o2sim")
50 auto ent =
mTree->GetReadEntry() + 1;
56 const bool noEntry = ent >=
mTree->GetEntries();
58 LOG(info) <<
"no entry to read, publishing empty output";
62 static const std::vector<o2::itsmft::ROFRecord> noDigROFRec;
63 static const std::vector<o2::itsmft::Digit> noDigits;
66 throw std::runtime_error(
"ITS3 digit reader requires all 7 layer branches to be present and populated in every entry");
68 const auto& digROFRec = noEntry ? noDigROFRec : *
mDigROFRec[iLayer];
70 LOG(info) <<
mDetName <<
"DigitReader pushes " << digROFRec.size() <<
" ROFRecords, " <<
digits.size() <<
" digits at entry " << ent <<
" on layer " << iLayer;
75 throw std::runtime_error(
"ITS3 digit reader requires MC truth branches for all 7 layers to be present and populated in every entry");
82 mPLabels[iLayer]->copyandflatten(sharedlabels);
89 if (noEntry ||
mTree->GetReadEntry() + 1 >=
mTree->GetEntries()) {
95template <
typename Ptr>
99 if (Int_t ret =
mTree->SetBranchAddress(
name.c_str(), &addr); ret != 0) {
100 LOGP(fatal,
"failed to set branch address for {} ret={}",
name, ret);
106 mTree.reset(
nullptr);
114 if (!
mTree->GetBranch(rofBranchName.c_str()) || !
mTree->GetBranch(digBranchName.c_str())) {
115 throw std::runtime_error(
"ITS3 digit reader requires all branches in the input file");
121 throw std::runtime_error(
"ITS3 digit reader requires MC truth branches for all 7 layers in the input file");
128 LOG(info) <<
"Loaded tree from " <<
filename <<
" with " <<
mTree->GetEntries() <<
" entries";
133 std::vector<OutputSpec> outputSpec;
135 outputSpec.emplace_back(
"IT3",
"DIGITS", iLayer, Lifetime::Timeframe);
136 outputSpec.emplace_back(
"IT3",
"DIGITSROF", iLayer, Lifetime::Timeframe);
138 outputSpec.emplace_back(
"IT3",
"DIGITSMCTR", iLayer, Lifetime::Timeframe);
143 .
name =
"its3-digit-reader",
145 .outputs = outputSpec,
146 .algorithm =
AlgorithmSpec{adaptFromTask<ITS3DigitReader>(useMC, doStag, useCalib)},
148 {
"it3-digit-infile", VariantType::String, defname, {
"Name of the input digit file"}}}};
A const (ready only) version of MCTruthContainer.
A special IO container - splitting a given vector to enable ROOT IO.
Definition of a container to keep Monte Carlo truth external to simulation objects.
T get(const char *key) const
void snapshot(const Output &spec, T const &object)
decltype(auto) make(const Output &spec, Args... args)
ConfigParamRegistry const & options()
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
ServiceRegistryRef services()
The services registry associated with this processing context.
virtual void endOfStream(EndOfStreamContext &context)
This is invoked whenever we have an EndOfStream event.
std::unique_ptr< TFile > mFile
std::array< std::vector< o2::itsmft::ROFRecord > *, NLayers > mDigROFRec
std::string mDigMCTruthBranchName
std::unique_ptr< TTree > mTree
void run(ProcessingContext &pc) final
static constexpr int NLayers
void setBranchAddress(const std::string &base, Ptr &addr, int layer)
std::array< o2::dataformats::IOMCTruthContainerView *, NLayers > mPLabels
void init(InitContext &ic) final
std::string getBranchName(const std::string &base, int index) const
std::array< std::vector< o2::itsmft::Digit > *, NLayers > mDigits
ITS3DigitReader(bool useMC, bool doStag, bool useCalib)
std::string mDigBranchName
void connectTree(const std::string &filename)
std::string mDigROFBranchName
const o2::header::DataOrigin mOrigin
GLuint const GLchar * name
GLenum GLuint GLint GLint layer
Defining ITS Vertex explicitly as messageable.
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
framework::DataProcessorSpec getITS3DigitReaderSpec(bool useMC=true, bool doStag=false, bool useCalib=false, std::string defname="it3digits.root")
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Digit > digits