Project
Loading...
Searching...
No Matches
ClusterReaderSpec.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 <vector>
15#include <cassert>
20
21using namespace o2::framework;
22using namespace o2::cpv;
23
24namespace o2
25{
26namespace cpv
27{
28
30{
31 mUseMC = useMC;
32}
33
35{
37 ic.options().get<std::string>("cpv-clusters-infile"));
39}
40
42{
43 auto ent = mTree->GetReadEntry() + 1;
44 assert(ent < mTree->GetEntries()); // this should not happen
45 mTree->GetEntry(ent);
46 LOG(info) << "Pushing " << mClusters.size() << " Clusters in " << mTRs.size() << " TriggerRecords at entry " << ent;
47 pc.outputs().snapshot(Output{mOrigin, "CLUSTERS", 0}, mClusters);
48 pc.outputs().snapshot(Output{mOrigin, "CLUSTERTRIGRECS", 0}, mTRs);
49 if (mUseMC) {
50 pc.outputs().snapshot(Output{mOrigin, "CLUSTERTRUEMC", 0}, mMCTruth);
51 }
52
53 if (mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
55 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
56 }
57}
58
59void ClusterReader::connectTree(const std::string& filename)
60{
61 mTree.reset(nullptr); // in case it was already loaded
62 mFile.reset(TFile::Open(filename.c_str()));
63 assert(mFile && !mFile->IsZombie());
64 mTree.reset((TTree*)mFile->Get(mClusterTreeName.c_str()));
65 assert(mTree);
66 assert(mTree->GetBranch(mTRBranchName.c_str()));
67
68 mTree->SetBranchAddress(mTRBranchName.c_str(), &mTRsInp);
69 mTree->SetBranchAddress(mClusterBranchName.c_str(), &mClustersInp);
70 if (mUseMC) {
71 if (mTree->GetBranch(mClusterMCTruthBranchName.c_str())) {
72 mTree->SetBranchAddress(mClusterMCTruthBranchName.c_str(), &mMCTruthInp);
73 } else {
74 LOG(warning) << "MC-truth is missing, message will be empty";
75 }
76 }
77 LOG(info) << "Loaded tree from " << filename << " with " << mTree->GetEntries() << " entries";
78}
79
81{
82 std::vector<OutputSpec> outputSpec;
83 outputSpec.emplace_back("CPV", "CLUSTERS", 0, Lifetime::Timeframe);
84 outputSpec.emplace_back("CPV", "CLUSTERTRIGRECS", 0, Lifetime::Timeframe);
85 if (useMC) {
86 outputSpec.emplace_back("CPV", "CLUSTERTRUEMC", 0, Lifetime::Timeframe);
87 }
88
89 return DataProcessorSpec{
90 "cpv-cluster-reader",
91 Inputs{},
92 outputSpec,
93 AlgorithmSpec{adaptFromTask<ClusterReader>(useMC)},
94 Options{
95 {"cpv-clusters-infile", VariantType::String, "cpvclusters.root", {"Name of the input Cluster file"}},
96 {"input-dir", VariantType::String, "none", {"Input directory"}}}};
97}
98
99} // namespace cpv
100} // namespace o2
Definition of the Names Generator class.
void init(o2::framework::InitContext &ic) final
std::vector< o2::cpv::Cluster > * mClustersInp
o2::header::DataOrigin mOrigin
void connectTree(const std::string &filename)
std::vector< o2::cpv::TriggerRecord > * mTRsInp
std::vector< o2::cpv::TriggerRecord > mTRs
std::unique_ptr< TFile > mFile
std::vector< o2::cpv::Cluster > mClusters
void run(o2::framework::ProcessingContext &pc) final
ClusterReader(bool useMC=true)
o2::dataformats::MCTruthContainer< o2::MCCompLabel > mMCTruth
std::unique_ptr< TTree > mTree
o2::dataformats::MCTruthContainer< o2::MCCompLabel > * mMCTruthInp
std::string mClusterMCTruthBranchName
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
framework::DataProcessorSpec getCPVClusterReaderSpec(bool useMC=true)
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string filename()
static std::string rectifyDirectory(const std::string_view p)
static std::string concat_string(Ts const &... ts)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"