Project
Loading...
Searching...
No Matches
FilteredTFReaderSpec.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
13
14#include <cassert>
19
20using namespace o2::framework;
21using namespace o2::dataformats;
22
24{
25
27{
28 mUseMC = useMC;
29}
30
32{
34 ic.options().get<std::string>("filtered-tf-infile"));
36}
37
39{
40 // FIXME: fill all output headers by TF specific info (extend findMessageHeaderStack)
41
42 auto ent = mTree->GetReadEntry() + 1;
43 // A timeframe holds no collision at all whenever the interaction rate is low enough, and
44 // the tree then has no entry to read. Publish empty containers instead of reading past the
45 // end and pushing branch addresses that GetEntry has not filled, so that the consumers
46 // downstream still see the timeframe. (This used to be an assert, which is compiled out of
47 // every production build since ENABLE_CASSERT defaults to OFF.)
48 const bool noEntry = ent >= mTree->GetEntries();
49 if (noEntry) {
50 LOG(info) << "no entry to read, publishing empty output";
51 } else {
52 mTree->GetEntry(ent);
53 }
54
55 LOG(info) << "Pushing filtered TF: " << mFiltTF.header.asString();
56 // ITS
57 pc.outputs().snapshot(Output{"ITS", "ITSTrackROF", 0}, mFiltTF.ITSTrackROFs);
58 pc.outputs().snapshot(Output{"ITS", "TRACKS", 0}, mFiltTF.ITSTracks);
59 pc.outputs().snapshot(Output{"ITS", "TRACKCLSID", 0}, mFiltTF.ITSClusterIndices);
60 if (mUseMC) {
61 pc.outputs().snapshot(Output{"ITS", "TRACKSMCTR", 0}, mFiltTF.ITSTrackMCTruth);
62 }
63 pc.outputs().snapshot(Output{"ITS", "CLUSTERSROF", 0}, mFiltTF.ITSClusterROFs);
64 pc.outputs().snapshot(Output{"ITS", "COMPCLUSTERS", 0}, mFiltTF.ITSClusters);
65 pc.outputs().snapshot(Output{"ITS", "PATTERNS", 0}, mFiltTF.ITSClusterPatterns);
66
67 if (noEntry || mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
69 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
70 }
71}
72
74{
75 mTree.reset(nullptr); // in case it was already loaded
76 mFile.reset(TFile::Open(filename.c_str()));
77 assert(mFile && !mFile->IsZombie());
78 mTree.reset((TTree*)mFile->Get(mInputTreeName.c_str()));
79 assert(mTree);
80 assert(mTree->GetBranch(mFTFBranchName.c_str()));
81 mTree->SetBranchAddress(mFTFBranchName.c_str(), &mFiltTFPtr);
82 LOG(info) << "Loaded tree from " << filename << " with " << mTree->GetEntries() << " entries";
83}
84
86{
87
88 std::vector<OutputSpec> outputSpec;
89 // same as ITSWorkflow/TrackReaderSpec
90 outputSpec.emplace_back("ITS", "ITSTrackROF", 0, Lifetime::Timeframe);
91 outputSpec.emplace_back("ITS", "TRACKS", 0, Lifetime::Timeframe);
92 outputSpec.emplace_back("ITS", "TRACKCLSID", 0, Lifetime::Timeframe);
93 if (useMC) {
94 outputSpec.emplace_back("ITS", "TRACKSMCTR", 0, Lifetime::Timeframe);
95 }
96 // same as ITSMFTWorkflow/ClusterReaderSpec
97 outputSpec.emplace_back("ITS", "CLUSTERSROF", 0, Lifetime::Timeframe);
98 outputSpec.emplace_back("ITS", "COMPCLUSTERS", 0, Lifetime::Timeframe);
99 outputSpec.emplace_back("ITS", "PATTERNS", 0, Lifetime::Timeframe);
100
101 return DataProcessorSpec{
102 "filtered-reco-tf-reader",
103 Inputs{},
104 outputSpec,
105 AlgorithmSpec{adaptFromTask<FilteredTFReader>(useMC)},
106 Options{
107 {"filtered-tf-infile", VariantType::String, "o2_filtered_tf.root", {"Name of the input file"}},
108 {"input-dir", VariantType::String, "none", {"Input directory"}}}};
109}
110
111} // namespace o2::filtering
Reader for the reconstructed and filtered TF.
Definition of the Names Generator class.
void run(o2::framework::ProcessingContext &pc) final
void init(o2::framework::InitContext &ic) final
o2::dataformats::FilteredRecoTF mFiltTF
o2::dataformats::FilteredRecoTF * mFiltTFPtr
void connectTree(const std::string &filename)
void snapshot(const Output &spec, T const &object)
ConfigParamRegistry const & options()
Definition InitContext.h:33
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.
Definition Task.h:43
Definition of a container to keep/associate and arbitrary number of labels associated to an index wit...
DataProcessorSpec getFilteredTFReaderSpec(bool useMC)
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
std::string filename()
std::vector< o2::itsmft::ROFRecord > ITSClusterROFs
std::vector< o2::its::TrackITS > ITSTracks
std::vector< o2::MCCompLabel > ITSTrackMCTruth
std::vector< o2::itsmft::ROFRecord > ITSTrackROFs
std::vector< int > ITSClusterIndices
std::vector< unsigned char > ITSClusterPatterns
std::vector< o2::itsmft::CompClusterExt > ITSClusters
static std::string rectifyDirectory(const std::string_view p)
static std::string concat_string(Ts const &... ts)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"