Project
Loading...
Searching...
No Matches
RecEventReaderSpec.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::zdc;
24
25namespace o2
26{
27namespace zdc
28{
29
31{
32 mUseMC = useMC;
33 if (useMC) {
34 LOG(warning) << "ZDC RecEvent 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>("zdc-reco-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(info) << "ZDC RecEventReader pushes " << mBCRecData->size() << " events with " << mBCRecData->size() << " energy, " << mZDCTDCData->size() << " TDC and " << mZDCInfo->size() << " info records at entry " << ent;
52 pc.outputs().snapshot(Output{"ZDC", "BCREC", 0}, *mBCRecData);
53 pc.outputs().snapshot(Output{"ZDC", "ENERGY", 0}, *mZDCEnergy);
54 pc.outputs().snapshot(Output{"ZDC", "TDCDATA", 0}, *mZDCTDCData);
55 pc.outputs().snapshot(Output{"ZDC", "INFO", 0}, *mZDCInfo);
56
57 if (mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
59 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
60 }
61}
62
63void RecEventReader::connectTree(const std::string& filename)
64{
65 mTree.reset(nullptr); // in case it was already loaded
66
67 mFile.reset(TFile::Open(filename.c_str()));
68 assert(mFile && !mFile->IsZombie());
69 mTree.reset((TTree*)mFile->Get(mRecEventTreeName.c_str()));
70 assert(mTree);
71
72 mTree->SetBranchAddress(mBCRecDataBranchName.c_str(), &mBCRecData);
73 mTree->SetBranchAddress(mZDCEnergyBranchName.c_str(), &mZDCEnergy);
74 mTree->SetBranchAddress(mZDCTDCDataBranchName.c_str(), &mZDCTDCData);
75 mTree->SetBranchAddress(mZDCInfoBranchName.c_str(), &mZDCInfo);
76 if (mUseMC) {
77 LOG(warning) << "MC-truth is not supported for ZDC recpoints currently";
78 mUseMC = false;
79 }
80
81 LOG(info) << "Loaded ZDC RecEvents tree from " << filename << " with " << mTree->GetEntries() << " entries";
82}
83
85{
86 std::vector<OutputSpec> outputs;
87 outputs.emplace_back("ZDC", "BCREC", 0, Lifetime::Timeframe);
88 outputs.emplace_back("ZDC", "ENERGY", 0, Lifetime::Timeframe);
89 outputs.emplace_back("ZDC", "TDCDATA", 0, Lifetime::Timeframe);
90 outputs.emplace_back("ZDC", "INFO", 0, Lifetime::Timeframe);
91 if (useMC) {
92 LOG(warning) << "MC-truth is not supported for ZDC RecEvents currently";
93 }
94
95 return DataProcessorSpec{
96 "zdc-reco-reader",
97 Inputs{},
98 outputs,
99 AlgorithmSpec{adaptFromTask<RecEventReader>()},
100 Options{
101 {"zdc-reco-infile", VariantType::String, "zdcreco.root", {"Name of the input file"}},
102 {"input-dir", VariantType::String, "none", {"Input directory"}}}};
103}
104
105} // namespace zdc
106} // 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 run(ProcessingContext &pc) final
void init(InitContext &ic) final
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
struct o2::upgrades_utils::@463 zdc
structure to keep FT0 information
framework::DataProcessorSpec getRecEventReaderSpec(bool useMC)
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"