Project
Loading...
Searching...
No Matches
RecPointReaderSpec.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::ft0;
24
25namespace o2
26{
27namespace ft0
28{
29
31{
32 mUseMC = useMC;
33 if (useMC) {
34 LOG(warning) << "FT0 RecPoint reader at the moment does not process MC";
35 }
36}
37
39{
40 mInputFileName = o2::utils::Str::concat_string(o2::utils::Str::rectifyDirectory(ic.options().get<std::string>("input-dir")),
41 ic.options().get<std::string>("infile"));
42 connectTree(mInputFileName);
43}
44
46{
47 auto ent = mTree->GetReadEntry() + 1;
48 assert(ent < mTree->GetEntries()); // this should not happen
49 mTree->GetEntry(ent);
50
51 LOG(debug) << "FT0 RecPointReader pushes " << mRecPoints->size() << " recpoints with " << mChannelData->size() << " channels at entry " << ent;
52 pc.outputs().snapshot(Output{mOrigin, "RECPOINTS", 0}, *mRecPoints);
53 pc.outputs().snapshot(Output{mOrigin, "RECCHDATA", 0}, *mChannelData);
54
55 if (mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
57 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
58 }
59}
60
61void RecPointReader::connectTree(const std::string& filename)
62{
63 mTree.reset(nullptr); // in case it was already loaded
64 mFile.reset(TFile::Open(filename.c_str()));
65 assert(mFile && !mFile->IsZombie());
66 mTree.reset((TTree*)mFile->Get(mRecPointTreeName.c_str()));
67 assert(mTree);
68
69 mTree->SetBranchAddress(mRecPointBranchName.c_str(), &mRecPoints);
70 mTree->SetBranchAddress(mChannelDataBranchName.c_str(), &mChannelData);
71 if (mUseMC) {
72 LOG(warning) << "MC-truth is not supported for FT0 recpoints currently";
73 mUseMC = false;
74 }
75
76 LOG(info) << "Loaded FT0 RecPoints tree from " << filename << " with " << mTree->GetEntries() << " entries";
77}
78
80{
81 std::vector<OutputSpec> outputSpec;
82 outputSpec.emplace_back(o2::header::gDataOriginFT0, "RECPOINTS", 0, Lifetime::Timeframe);
83 outputSpec.emplace_back(o2::header::gDataOriginFT0, "RECCHDATA", 0, Lifetime::Timeframe);
84 if (useMC) {
85 LOG(warning) << "MC-truth is not supported for FT0 recpoints currently";
86 }
87
88 return DataProcessorSpec{
89 "ft0-recpoints-reader",
90 Inputs{},
91 outputSpec,
92 AlgorithmSpec{adaptFromTask<RecPointReader>()},
93 Options{
94 {"infile", VariantType::String, "o2reco_ft0.root", {"Name of the input file"}},
95 {"input-dir", VariantType::String, "none", {"Input directory"}}}};
96}
97
98} // namespace ft0
99} // namespace o2
Definition of the Names Generator class.
std::ostringstream debug
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 run(ProcessingContext &pc) final
void init(InitContext &ic) final
RecPointReader(bool useMC=false)
constexpr o2::header::DataOrigin gDataOriginFT0
Definition DataHeader.h:566
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
framework::DataProcessorSpec getRecPointReaderSpec(bool useMC)
struct o2::upgrades_utils::@462 ft0
structure to keep V0C information
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"