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 assert(ent < mTree->GetEntries()); // this should not happen
68 mTree->GetEntry(ent);
69 LOG(info) << "ZDCRecoReader pushed " << RecBC.size() << " b.c. " << Energy.size() << " Energies " << TDCData.size() << " TDCs " << Info.size() << " Infos " << WaveformData.size() << " Waveform chunks";
70 pc.outputs().snapshot(Output{"ZDC", "BCREC", 0}, RecBC);
71 pc.outputs().snapshot(Output{"ZDC", "ENERGY", 0}, Energy);
72 pc.outputs().snapshot(Output{"ZDC", "TDCDATA", 0}, TDCData);
73 pc.outputs().snapshot(Output{"ZDC", "INFO", 0}, Info);
74 pc.outputs().snapshot(Output{"ZDC", "WAVE", 0}, WaveformData);
75
76 if (mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
78 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
79 }
80}
81
83{
84 std::vector<OutputSpec> outputs;
85 outputs.emplace_back("ZDC", "BCREC", 0, Lifetime::Timeframe);
86 outputs.emplace_back("ZDC", "ENERGY", 0, Lifetime::Timeframe);
87 outputs.emplace_back("ZDC", "TDCDATA", 0, Lifetime::Timeframe);
88 outputs.emplace_back("ZDC", "INFO", 0, Lifetime::Timeframe);
89 outputs.emplace_back("ZDC", "WAVE", 0, Lifetime::Timeframe);
90
91 return DataProcessorSpec{
92 "zdc-reco-reader",
93 Inputs{},
94 outputs,
95 AlgorithmSpec{adaptFromTask<RecoReader>()},
96 Options{
97 {"zdc-reco-infile", VariantType::String, "zdcreco.root", {"Name of the input file"}},
98 {"enable-waveform", VariantType::Bool, false, {"Read waveform data"}},
99 {"input-dir", VariantType::String, "none", {"Input directory"}}}};
100}
101
102} // namespace zdc
103} // 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 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 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"