Project
Loading...
Searching...
No Matches
TrackCosmicsExtendedReaderSpec.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
21
22using namespace o2::framework;
23using namespace o2::globaltracking;
24
25namespace o2
26{
27namespace globaltracking
28{
30{
31 mFileName = o2::utils::Str::concat_string(o2::utils::Str::rectifyDirectory(ic.options().get<std::string>("input-dir")),
32 ic.options().get<std::string>("cosmics-full-infile"));
33 connectTree(mFileName);
34}
35
37{
38 auto ent = mTree->GetReadEntry() + 1;
39 // Same as in TrackCosmicsReader: publish empty containers if the tree has no entry left
40 const bool noEntry = ent >= mTree->GetEntries();
41 if (noEntry) {
42 LOG(info) << "no entry to read, publishing empty output";
43 mCosmics.clear();
44 mTFInfo = {};
45 } else {
46 mTree->GetEntry(ent);
47 }
48 LOG(info) << "Pushing " << mCosmics.size() << " cosmics with clusters at entry " << ent;
49
50 pc.outputs().snapshot(Output{"GLO", "COSMFULL", 0}, mCosmics);
51 pc.outputs().snapshot(Output{"GLO", "COSMFULLTF", 0}, mTFInfo);
52 if (noEntry || mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
54 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
55 }
56}
57
58void TrackCosmicsExtendedReader::connectTree(const std::string& filename)
59{
60 mTree.reset(nullptr); // in case it was already loaded
61 mFile.reset(TFile::Open(filename.c_str()));
62 if (!mFile || mFile->IsZombie()) {
63 LOGP(fatal, "Failed to open {}", filename);
64 }
65 mTree.reset((TTree*)mFile->Get("cosmicsFull"));
66 if (!mTree) {
67 LOGP(fatal, "Tree cosmicsFull is not found in {}", filename);
68 }
69 mTree->SetBranchAddress("cosmics", &mCosmicsPtr);
70 mTree->SetBranchAddress("tfInfo", &mTFInfoPtr);
71 LOG(info) << "Loaded tree from " << filename << " with " << mTree->GetEntries() << " entries";
72}
73
75{
76 std::vector<OutputSpec> outputs;
77 outputs.emplace_back("GLO", "COSMFULL", 0, Lifetime::Timeframe);
78 outputs.emplace_back("GLO", "COSMFULLTF", 0, Lifetime::Timeframe);
79
80 return DataProcessorSpec{
81 "cosmic-ext-reader",
82 Inputs{},
83 outputs,
84 AlgorithmSpec{adaptFromTask<TrackCosmicsExtendedReader>()},
85 Options{
86 {"cosmics-full-infile", VariantType::String, "o2_cosmics_full.root", {"Name of the input file"}},
87 {"input-dir", VariantType::String, "none", {"Input directory"}}}};
88}
89
90} // namespace globaltracking
91} // 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
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< InputSpec > Inputs
framework::DataProcessorSpec getTrackCosmicsExtendedReaderSpec()
create a processor spec to read the extended cosmics (as written by cosmics-full-writer) from a root ...
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"