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