36ClusterReader<N>::ClusterReader(
bool useMC,
bool doStag,
bool usePatterns,
bool triggerOut) : mUseMC(useMC), mUsePatterns(usePatterns), mTriggerOut(triggerOut), mDetName(Origin.as<
std::
string>()), mDetNameLC(mDetName)
52 ic.
options().
get<std::string>((mDetNameLC +
"-cluster-infile").c_str()));
53 connectTree(mFileName);
59 auto ent = mTree->GetReadEntry() + 1;
65 const bool noEntry = ent >= mTree->GetEntries();
67 LOG(info) <<
"no entry to read, publishing empty output";
72 static const std::vector<o2::itsmft::ROFRecord> noClusROFRec;
73 static const std::vector<o2::itsmft::CompClusterExt> noClusters;
74 static const std::vector<unsigned char> noPatterns;
76 for (uint32_t iLayer = 0; iLayer < mLayers; ++iLayer) {
77 const auto& clusROFRec = noEntry ? noClusROFRec : *mClusROFRec[iLayer];
78 const auto&
clusters = noEntry ? noClusters : *mClusterCompArray[iLayer];
79 LOG(info) << mDetName <<
"ClusterReader" << (mDoStaggering ? std::format(
" on layer {}", iLayer) :
"") <<
" pushes " << clusROFRec.size() <<
" ROFRecords, " <<
clusters.size() <<
" compact clusters at entry " << ent;
83 pc.
outputs().
snapshot(
Output{Origin,
"PATTERNS", iLayer}, noEntry ? noPatterns : *mPatternsArray[iLayer]);
86 pc.
outputs().
snapshot(
Output{Origin,
"CLUSTERSMCTR", iLayer}, noEntry ? noLabels : *mClusterMCTruth[iLayer]);
88 static std::vector<o2::itsmft::MC2ROFRecord> dummyMC2ROF;
93 std::vector<o2::itsmft::PhysTrigger> dummyTrig;
96 if (noEntry || mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
105 mTree.reset(
nullptr);
106 mFile.reset(TFile::Open(
filename.c_str()));
107 assert(mFile && !mFile->IsZombie());
108 mTree.reset((TTree*)mFile->Get(mClusTreeName.c_str()));
111 for (uint32_t iLayer = 0; iLayer < mLayers; ++iLayer) {
112 setBranchAddress(mClusROFBranchName, mClusROFRec[iLayer], iLayer);
113 setBranchAddress(mClusterCompBranchName, mClusterCompArray[iLayer], iLayer);
115 setBranchAddress(mClusterPattBranchName, mPatternsArray[iLayer], iLayer);
118 if (mTree->GetBranch(getBranchName(mClustMCTruthBranchName, iLayer).c_str())) {
119 setBranchAddress(mClustMCTruthBranchName, mClusterMCTruth[iLayer], iLayer);
121 LOG(info) <<
"MC-truth is missing";
126 LOG(info) <<
"Loaded tree from " <<
filename <<
" with " << mTree->GetEntries() <<
" entries";
135 return mDetName + base;
139template <
typename Ptr>
142 const auto name = getBranchName(base,
layer);
143 if (Int_t ret = mTree->SetBranchAddress(
name.c_str(), &addr); ret != 0) {
144 LOGP(fatal,
"failed to set branch address for {} ret={}",
name, ret);
151std::vector<OutputSpec> makeOutChannels(
o2::header::DataOrigin detOrig,
bool mctruth,
bool doStag,
bool usePatterns,
bool triggerOut)
153 std::vector<OutputSpec> outputs;
155 outputs.emplace_back(detOrig,
"CLUSTERSROF", iLayer, Lifetime::Timeframe);
156 outputs.emplace_back(detOrig,
"COMPCLUSTERS", iLayer, Lifetime::Timeframe);
158 outputs.emplace_back(detOrig,
"PATTERNS", iLayer, Lifetime::Timeframe);
161 outputs.emplace_back(detOrig,
"CLUSTERSMCTR", iLayer, Lifetime::Timeframe);
162 outputs.emplace_back(detOrig,
"CLUSTERSMC2ROF", iLayer, Lifetime::Timeframe);
166 outputs.emplace_back(detOrig,
"PHYSTRIG", 0, Lifetime::Timeframe);
175 .
name =
"its-cluster-reader",
177 .outputs = makeOutChannels<o2::detectors::DetID::ITS>(
"ITS", useMC, doStag, usePatterns, triggerOut),
178 .algorithm =
AlgorithmSpec{adaptFromTask<ITSClusterReader>(useMC, doStag, usePatterns, triggerOut)},
180 {
"its-cluster-infile", VariantType::String,
"o2clus_its.root", {
"Name of the input cluster file"}},
181 {
"input-dir", VariantType::String,
"none", {
"Input directory"}}}};
187 .
name =
"mft-cluster-reader",
189 .outputs = makeOutChannels<o2::detectors::DetID::MFT>(
"MFT", useMC, doStag, usePatterns, triggerOut),
190 .algorithm =
AlgorithmSpec{adaptFromTask<MFTClusterReader>(useMC, doStag, usePatterns, triggerOut)},
192 {
"mft-cluster-infile", VariantType::String,
"mftclusters.root", {
"Name of the input cluster file"}},
193 {
"input-dir", VariantType::String,
"none", {
"Input directory"}}}};
Definition of the Names Generator class.
Definition Physics trigger record extracted from the ITS/MFT stream.
T get(const char *key) const
void snapshot(const Output &spec, T const &object)
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.
void run(ProcessingContext &pc) final
std::string getBranchName(const std::string &base, int index) const
std::vector< std::vector< o2::itsmft::CompClusterExt > * > mClusterCompArray
void connectTree(const std::string &filename)
std::vector< std::vector< unsigned char > * > mPatternsArray
void init(InitContext &ic) final
void setBranchAddress(const std::string &base, Ptr &addr, int layer)
std::vector< std::vector< o2::itsmft::ROFRecord > * > mClusROFRec
std::vector< o2::dataformats::MCTruthContainer< o2::MCCompLabel > * > mClusterMCTruth
GLsizei const GLchar *const * string
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 getMFTClusterReaderSpec(bool useMC=true, bool doStag=false, bool usePatterns=true, bool useTriggers=true)
framework::DataProcessorSpec getITSClusterReaderSpec(bool useMC=true, bool doStag=false, bool usePatterns=true, bool useTriggers=true)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string to_string(gsl::span< T, Size > span)
static constexpr int getNLayers()
static std::string rectifyDirectory(const std::string_view p)
static std::string concat_string(Ts const &... ts)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Cluster > clusters