Project
Loading...
Searching...
No Matches
TPCUnbinnedResidualReaderSpec.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
15
18#include "fairlogger/Logger.h"
20
21using namespace o2::framework;
22
23namespace o2
24{
25namespace tpc
26{
27
29{
30 // get the option from the init context
31 LOG(info) << "Init TPC unbinned residual reader!";
32 mInFileName = o2::utils::Str::concat_string(o2::utils::Str::rectifyDirectory(ic.options().get<std::string>("input-dir")),
33 ic.options().get<std::string>("input-filename"));
34 mInTreeName = ic.options().get<std::string>("treename");
35 connectTree();
36}
37
38void TPCUnbinnedResidualReader::connectTree()
39{
40 mTreeIn.reset(nullptr); // in case it was already loaded
41 mFileIn.reset(TFile::Open(mInFileName.c_str()));
42 assert(mFileIn && !mFileIn->IsZombie());
43 mTreeIn.reset((TTree*)mFileIn->Get(mInTreeName.c_str()));
44 assert(mTreeIn);
45 mTreeIn->SetBranchAddress("residuals", &mUnbinnedResidPtr);
46 mTreeIn->SetBranchAddress("trackRefs", &mTrackDataCompactPtr);
47 if (mTrackInput) {
48 mTreeIn->SetBranchAddress("tracks", &mTrackDataPtr);
49 }
50 LOG(info) << "Loaded tree from " << mInFileName << " with " << mTreeIn->GetEntries() << " entries";
51}
52
54{
55 auto currEntry = mTreeIn->GetReadEntry() + 1;
56 assert(currEntry < mTreeIn->GetEntries()); // this should not happen
57 mTreeIn->GetEntry(currEntry);
58 LOG(info) << "Pushing " << mUnbinnedResid.size() << " unbinned residuals at entry " << currEntry;
59 pc.outputs().snapshot(Output{"GLO", "UNBINNEDRES", 0}, mUnbinnedResid);
60 pc.outputs().snapshot(Output{"GLO", "TRKREFS", 0}, mTrackDataCompact);
61 if (mTrackInput) {
62 LOG(info) << "Pushing " << mTrackData.size() << " reference tracks for these residuals";
63 pc.outputs().snapshot(Output{"GLO", "TRKDATA", 0}, mTrackData);
64 }
65
66 if (mTreeIn->GetReadEntry() + 1 >= mTreeIn->GetEntries()) {
68 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
69 }
70}
71
73{
74 std::vector<OutputSpec> outputs;
75 outputs.emplace_back("GLO", "UNBINNEDRES", 0, Lifetime::Timeframe);
76 outputs.emplace_back("GLO", "TRKREFS", 0, Lifetime::Timeframe);
77 if (trkInput) {
78 outputs.emplace_back("GLO", "TRKDATA", 0, Lifetime::Timeframe);
79 }
80
81 return DataProcessorSpec{
82 "TPCUnbinnedResidualReader",
83 Inputs{},
84 outputs,
85 AlgorithmSpec{adaptFromTask<TPCUnbinnedResidualReader>(trkInput)},
86 Options{
87 {"input-filename", VariantType::String, "o2residuals_tpc.root", {"Name of the input file"}},
88 {"input-dir", VariantType::String, "none", {"Input directory"}},
89 {"treename", VariantType::String, "residualsTPC", {"Name of top-level TTree"}},
90 }};
91}
92
93} // namespace tpc
94} // 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 init(o2::framework::InitContext &ic) final
void run(o2::framework::ProcessingContext &pc) final
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
framework::DataProcessorSpec getUnbinnedTPCResidualsReaderSpec(bool trkInput)
read unbinned TPC residuals and reference tracks from a root file
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"