Project
Loading...
Searching...
No Matches
RecoReaderSpec.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>
19#include "Framework/Logger.h"
28
29using namespace o2::framework;
30
31namespace o2
32{
33namespace zdc
34{
35
37{
38 auto filename = o2::utils::Str::concat_string(o2::utils::Str::rectifyDirectory(ic.options().get<std::string>("input-dir")), ic.options().get<std::string>("zdc-reco-infile"));
39 mFile.reset(TFile::Open(filename.c_str()));
40 if (!mFile->IsOpen()) {
41 LOG(error) << "Cannot open the " << filename.c_str() << " file !";
42 throw std::runtime_error("cannot open input digits file");
43 }
44 mTree.reset((TTree*)mFile->Get("o2rec"));
45 if (!mTree) {
46 LOG(error) << "Did not find o2sim tree in " << filename.c_str();
47 throw std::runtime_error("Did not find o2rec tree in ZDC reco file");
48 }
49}
50
52{
53
54 std::vector<o2::zdc::BCRecData> RecBC, *RecBCPtr = &RecBC;
55 std::vector<o2::zdc::ZDCEnergy> Energy, *EnergyPtr = &Energy;
56 std::vector<o2::zdc::ZDCTDCData> TDCData, *TDCDataPtr = &TDCData;
57 std::vector<uint16_t> Info, *InfoPtr = &Info;
58 std::vector<o2::zdc::ZDCWaveform> WaveformData, *WaveformDataPtr = &WaveformData;
59
60 mTree->SetBranchAddress("ZDCRecBC", &RecBCPtr);
61 mTree->SetBranchAddress("ZDCRecE", &EnergyPtr);
62 mTree->SetBranchAddress("ZDCRecTDC", &TDCDataPtr);
63 mTree->SetBranchAddress("ZDCRecInfo", &InfoPtr);
64 mTree->SetBranchAddress("ZDCWaveform", &WaveformDataPtr);
65
66 auto ent = mTree->GetReadEntry() + 1;
67 // A timeframe holds no collision at all whenever the interaction rate is low enough, and
68 // the tree then has no entry to read. Publish empty containers instead of reading past the
69 // end and pushing branch addresses that GetEntry has not filled, so that the consumers
70 // downstream still see the timeframe. (This used to be an assert, which is compiled out of
71 // every production build since ENABLE_CASSERT defaults to OFF.)
72 const bool noEntry = ent >= mTree->GetEntries();
73 if (noEntry) {
74 LOG(info) << "no entry to read, publishing empty output";
75 } else {
76 mTree->GetEntry(ent);
77 }
78 LOG(info) << "ZDCRecoReader pushed " << RecBC.size() << " b.c. " << Energy.size() << " Energies " << TDCData.size() << " TDCs " << Info.size() << " Infos " << WaveformData.size() << " Waveform chunks";
79 pc.outputs().snapshot(Output{"ZDC", "BCREC", 0}, RecBC);
80 pc.outputs().snapshot(Output{"ZDC", "ENERGY", 0}, Energy);
81 pc.outputs().snapshot(Output{"ZDC", "TDCDATA", 0}, TDCData);
82 pc.outputs().snapshot(Output{"ZDC", "INFO", 0}, Info);
83 pc.outputs().snapshot(Output{"ZDC", "WAVE", 0}, WaveformData);
84
85 if (noEntry || mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
87 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
88 }
89}
90
92{
93 std::vector<OutputSpec> outputs;
94 outputs.emplace_back("ZDC", "BCREC", 0, Lifetime::Timeframe);
95 outputs.emplace_back("ZDC", "ENERGY", 0, Lifetime::Timeframe);
96 outputs.emplace_back("ZDC", "TDCDATA", 0, Lifetime::Timeframe);
97 outputs.emplace_back("ZDC", "INFO", 0, Lifetime::Timeframe);
98 outputs.emplace_back("ZDC", "WAVE", 0, Lifetime::Timeframe);
99
100 return DataProcessorSpec{
101 "zdc-reco-reader",
102 Inputs{},
103 outputs,
104 AlgorithmSpec{adaptFromTask<RecoReader>()},
105 Options{
106 {"zdc-reco-infile", VariantType::String, "zdcreco.root", {"Name of the input file"}},
107 {"enable-waveform", VariantType::Bool, false, {"Read waveform data"}},
108 {"input-dir", VariantType::String, "none", {"Input directory"}}}};
109}
110
111} // namespace zdc
112} // namespace o2
Class to describe fired triggered and/or stored channels for the BC and to refer to channel data.
Definition of the Names Generator class.
Class to describe pedestal data accumulated over the orbit.
Class to describe reconstructed ZDC event (single BC with signal in one of detectors)
Container class to store the interpolated waveform of the ZDC.
Container class to store NTimeBinsPerBC ADC values of single ZDC channel.
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(framework::InitContext &ic) final
void run(framework::ProcessingContext &pc) final
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
struct o2::upgrades_utils::@478 zdc
structure to keep FT0 information
framework::DataProcessorSpec getRecoReaderSpec()
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"