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 assert(ent < mTree->GetEntries()); // this should not happen
41 mTree->GetEntry(ent);
42 LOG(info) << "Pushing " << mVerticesPtr->size() << " vertices in " << mVerticesROFRecPtr->size()
43 << " ROFs at entry " << ent;
44 pc.outputs().snapshot(Output{"IT3", "VERTICES", 0}, mVertices);
45 pc.outputs().snapshot(Output{"IT3", "VERTICESROF", 0}, mVerticesROFRec);
46
47 if (mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
49 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
50 }
51}
52
53void VertexReader::connectTree(const std::string& filename)
54{
55 mTree.reset(nullptr); // in case it was already loaded
56 mFile.reset(TFile::Open(filename.c_str()));
57 assert(mFile && !mFile->IsZombie());
58 mTree.reset((TTree*)mFile->Get(mVertexTreeName.c_str()));
59 assert(mTree);
60 assert(mTree->GetBranch(mVertexBranchName.c_str()));
61 assert(mTree->GetBranch(mVertexROFBranchName.c_str()));
62 mTree->SetBranchAddress(mVertexBranchName.c_str(), &mVerticesPtr);
63 mTree->SetBranchAddress(mVertexROFBranchName.c_str(), &mVerticesROFRecPtr);
64 LOG(info) << "Loaded tree from " << filename << " with " << mTree->GetEntries() << " entries";
65}
66
68{
69 std::vector<OutputSpec> outputSpec;
70 outputSpec.emplace_back("IT3", "VERTICES", 0, Lifetime::Timeframe);
71 outputSpec.emplace_back("IT3", "VERTICESROF", 0, Lifetime::Timeframe);
72
73 return DataProcessorSpec{
74 "its3-vertex-reader",
75 Inputs{},
76 outputSpec,
77 AlgorithmSpec{adaptFromTask<VertexReader>()},
78 Options{
79 {"its3-vertex-infile", VariantType::String, "o2trac_its3.root", {"Name of the input ITS3 vertex file"}},
80 {"input-dir", VariantType::String, "none", {"Input directory"}}}};
81}
82
83} // namespace its
84} // 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 PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
DataProcessorSpec getITS3VertexReaderSpec()
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"