Project
Loading...
Searching...
No Matches
VertexReaderSpec.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"
21
22using namespace o2::framework;
23using namespace o2::its;
24
25namespace o2
26{
27namespace its
28{
29
31{
33 ic.options().get<std::string>("its-vertex-infile"));
35}
36
38{
39 auto ent = mTree->GetReadEntry() + 1;
40 // A timeframe holds no collision at all whenever the interaction rate is low enough, and
41 // the tree then has no entry to read. Publish empty containers instead of reading past the
42 // end and pushing branch addresses that GetEntry has not filled, so that the consumers
43 // downstream still see the timeframe. (This used to be an assert, which is compiled out of
44 // every production build since ENABLE_CASSERT defaults to OFF.)
45 const bool noEntry = ent >= mTree->GetEntries();
46 if (noEntry) {
47 LOG(info) << "no entry to read, publishing empty output";
48 } else {
49 mTree->GetEntry(ent);
50 }
51 LOG(info) << "Pushing " << mVerticesPtr->size() << " vertices in " << mVerticesROFRecPtr->size()
52 << " ROFs at entry " << ent;
53 pc.outputs().snapshot(Output{"ITS", "VERTICES", 0}, mVertices);
54 pc.outputs().snapshot(Output{"ITS", "VERTICESROF", 0}, mVerticesROFRec);
55
56 if (noEntry || mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
58 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
59 }
60}
61
62void VertexReader::connectTree(const std::string& filename)
63{
64 mTree.reset(nullptr); // in case it was already loaded
65 mFile.reset(TFile::Open(filename.c_str()));
66 assert(mFile && !mFile->IsZombie());
67 mTree.reset((TTree*)mFile->Get(mVertexTreeName.c_str()));
68 assert(mTree);
69 assert(mTree->GetBranch(mVertexBranchName.c_str()));
70 assert(mTree->GetBranch(mVertexROFBranchName.c_str()));
71 mTree->SetBranchAddress(mVertexBranchName.c_str(), &mVerticesPtr);
72 mTree->SetBranchAddress(mVertexROFBranchName.c_str(), &mVerticesROFRecPtr);
73 LOG(info) << "Loaded tree from " << filename << " with " << mTree->GetEntries() << " entries";
74}
75
77{
78 std::vector<OutputSpec> outputSpec;
79 outputSpec.emplace_back("ITS", "VERTICES", 0, Lifetime::Timeframe);
80 outputSpec.emplace_back("ITS", "VERTICESROF", 0, Lifetime::Timeframe);
81
82 return DataProcessorSpec{
83 "its-vertex-reader",
84 Inputs{},
85 outputSpec,
86 AlgorithmSpec{adaptFromTask<VertexReader>()},
87 Options{
88 {"its-vertex-infile", VariantType::String, "o2trac_its.root", {"Name of the input ITS vertex file"}},
89 {"input-dir", VariantType::String, "none", {"Input directory"}}}};
90}
91
92} // namespace its
93} // namespace o2
Definition of the Names Generator class.
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
void connectTree(const std::string &filename)
std::unique_ptr< TFile > mFile
std::string mVertexROFBranchName
std::vector< Vertex > * mVerticesPtr
std::unique_ptr< TTree > mTree
void init(o2::framework::InitContext &ic) final
std::vector< Vertex > mVertices
std::vector< o2::itsmft::ROFRecord > mVerticesROFRec
void run(o2::framework::ProcessingContext &pc) final
std::vector< o2::itsmft::ROFRecord > * mVerticesROFRecPtr
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
o2::framework::DataProcessorSpec getITSVertexReaderSpec()
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"