Project
Loading...
Searching...
No Matches
SecondaryVertexReaderSpec.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
18#include "Framework/Logger.h"
25#include "TFile.h"
26#include "TTree.h"
27
28using namespace o2::framework;
29
30namespace o2
31{
32namespace vertexing
33{
34// read secondary vertices produces by the o2-secondary-vertexing-workflow
36{
39 using V0 = o2::dataformats::V0;
44
45 public:
47 ~SecondaryVertexReader() override = default;
48 void init(o2::framework::InitContext& ic) final;
50
51 protected:
52 void connectTree();
53
54 bool mVerbose = false;
55
56 std::vector<V0Index> mV0sIdx, *mV0sIdxPtr = &mV0sIdx;
57 std::vector<V0> mV0s, *mV0sPtr = &mV0s;
58 std::vector<RRef> mPV2V0Ref, *mPV2V0RefPtr = &mPV2V0Ref;
59 std::vector<CascadeIndex> mCascsIdx, *mCascsIdxPtr = &mCascsIdx;
60 std::vector<Cascade> mCascs, *mCascsPtr = &mCascs;
61 std::vector<RRef> mPV2CascRef, *mPV2CascRefPtr = &mPV2CascRef;
62 std::vector<Decay3BodyIndex> m3BodysIdx, *m3BodysIdxPtr = &m3BodysIdx;
63 std::vector<Decay3Body> m3Bodys, *m3BodysPtr = &m3Bodys;
65
66 std::unique_ptr<TFile> mFile;
67 std::unique_ptr<TTree> mTree;
68 std::string mFileName = "";
69 std::string mFileNameMatches = "";
70 std::string mSVertexTreeName = "o2sim";
71 std::string mV0IdxBranchName = "V0sID";
72 std::string mV0BranchName = "V0s";
73 std::string mPVertex2V0RefBranchName = "PV2V0Refs";
74 std::string mCascIdxBranchName = "CascadesID";
75 std::string mCascBranchName = "Cascades";
76 std::string mPVertex2CascRefBranchName = "PV2CascRefs";
77 std::string m3BodyIdxBranchName = "Decays3BodyID";
78 std::string m3BodyBranchName = "Decays3Body";
79 std::string mPVertex23BodyRefBranchName = "PV23BodyRefs";
80};
81
83{
85 ic.options().get<std::string>("secondary-vertex-infile"));
87}
88
90{
91 auto ent = mTree->GetReadEntry() + 1;
92 assert(ent < mTree->GetEntries()); // this should not happen
93 mTree->GetEntry(ent);
94 LOGP(info, "Pushing {} V0s ({} indices), {} cascades ({} indices) and {} 3-body ({} indices ) at entry {}",
95 mV0s.size(), mV0sIdx.size(), mCascs.size(), mCascsIdx.size(), m3Bodys.size(), m3BodysIdx.size(), ent);
96
97 pc.outputs().snapshot(Output{"GLO", "V0S_IDX", 0}, mV0sIdx);
98 pc.outputs().snapshot(Output{"GLO", "V0S", 0}, mV0s);
99 pc.outputs().snapshot(Output{"GLO", "PVTX_V0REFS", 0}, mPV2V0Ref);
100 pc.outputs().snapshot(Output{"GLO", "CASCS_IDX", 0}, mCascsIdx);
101 pc.outputs().snapshot(Output{"GLO", "CASCS", 0}, mCascs);
102 pc.outputs().snapshot(Output{"GLO", "PVTX_CASCREFS", 0}, mPV2CascRef);
103 pc.outputs().snapshot(Output{"GLO", "DECAYS3BODY_IDX", 0}, m3BodysIdx);
104 pc.outputs().snapshot(Output{"GLO", "DECAYS3BODY", 0}, m3Bodys);
105 pc.outputs().snapshot(Output{"GLO", "PVTX_3BODYREFS", 0}, mPV23BodyRef);
106
107 if (mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
109 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
110 }
111}
112
114{
115 mTree.reset(nullptr); // in case it was already loaded
116 mFile.reset(TFile::Open(mFileName.c_str()));
117 assert(mFile && !mFile->IsZombie());
118 mTree.reset((TTree*)mFile->Get(mSVertexTreeName.c_str()));
119 assert(mTree);
120 assert(mTree->GetBranch(mV0IdxBranchName.c_str()));
121 assert(mTree->GetBranch(mV0BranchName.c_str()));
122 assert(mTree->GetBranch(mPVertex2V0RefBranchName.c_str()));
123 assert(mTree->GetBranch(mCascBranchName.c_str()));
124 assert(mTree->GetBranch(mCascIdxBranchName.c_str()));
125 assert(mTree->GetBranch(mPVertex2CascRefBranchName.c_str()));
126 assert(mTree->GetBranch(m3BodyIdxBranchName.c_str()));
127 assert(mTree->GetBranch(m3BodyBranchName.c_str()));
128 assert(mTree->GetBranch(mPVertex23BodyRefBranchName.c_str()));
129
130 mTree->SetBranchAddress(mV0IdxBranchName.c_str(), &mV0sIdxPtr);
131 mTree->SetBranchAddress(mV0BranchName.c_str(), &mV0sPtr);
132 mTree->SetBranchAddress(mPVertex2V0RefBranchName.c_str(), &mPV2V0RefPtr);
133 mTree->SetBranchAddress(mCascIdxBranchName.c_str(), &mCascsIdxPtr);
134 mTree->SetBranchAddress(mCascBranchName.c_str(), &mCascsPtr);
135 mTree->SetBranchAddress(mPVertex2CascRefBranchName.c_str(), &mPV2CascRefPtr);
136 mTree->SetBranchAddress(m3BodyIdxBranchName.c_str(), &m3BodysIdxPtr);
137 mTree->SetBranchAddress(m3BodyBranchName.c_str(), &m3BodysPtr);
138 mTree->SetBranchAddress(mPVertex23BodyRefBranchName.c_str(), &mPV23BodyRefPtr);
139
140 LOG(info) << "Loaded " << mSVertexTreeName << " tree from " << mFileName << " with " << mTree->GetEntries() << " entries";
141}
142
144{
145 std::vector<OutputSpec> outputs;
146 outputs.emplace_back("GLO", "V0S_IDX", 0, Lifetime::Timeframe); // found V0s indices
147 outputs.emplace_back("GLO", "V0S", 0, Lifetime::Timeframe); // found V0s
148 outputs.emplace_back("GLO", "PVTX_V0REFS", 0, Lifetime::Timeframe); // prim.vertex -> V0s refs
149 outputs.emplace_back("GLO", "CASCS_IDX", 0, Lifetime::Timeframe); // found Cascades indices
150 outputs.emplace_back("GLO", "CASCS", 0, Lifetime::Timeframe); // found Cascades
151 outputs.emplace_back("GLO", "PVTX_CASCREFS", 0, Lifetime::Timeframe); // prim.vertex -> Cascades refs
152 outputs.emplace_back("GLO", "DECAYS3BODY_IDX", 0, Lifetime::Timeframe); // found 3 body vertices indices
153 outputs.emplace_back("GLO", "DECAYS3BODY", 0, Lifetime::Timeframe); // found 3 body Decays
154 outputs.emplace_back("GLO", "PVTX_3BODYREFS", 0, Lifetime::Timeframe); // prim.vertex -> 3 body Decays refs
155
156 return DataProcessorSpec{
157 "secondary-vertex-reader",
158 Inputs{},
159 outputs,
160 AlgorithmSpec{adaptFromTask<SecondaryVertexReader>()},
161 Options{
162 {"secondary-vertex-infile", VariantType::String, "o2_secondary_vertex.root", {"Name of the input secondary vertex file"}},
163 {"input-dir", VariantType::String, "none", {"Input directory"}}}};
164}
165
166} // namespace vertexing
167} // namespace o2
Definition of the Names Generator class.
Class to refer to the 1st entry and N elements of some group in the continuous container.
TO BE DONE: extend to generic N body vertex.
Definition Decay3Body.h:26
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
~SecondaryVertexReader() override=default
void init(o2::framework::InitContext &ic) final
void run(o2::framework::ProcessingContext &pc) final
std::vector< Decay3BodyIndex > * m3BodysIdxPtr
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
o2::framework::DataProcessorSpec getSecondaryVertexReaderSpec()
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static std::string rectifyDirectory(const std::string_view p)
static std::string concat_string(Ts const &... ts)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"