Project
Loading...
Searching...
No Matches
DigitReaderSpec.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"
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-digit-infile"));
39 mFirstEntry = ic.options().get<int>("first-entry");
40 mLastEntry = ic.options().get<int>("last-entry");
41 mFile.reset(TFile::Open(filename.c_str()));
42 if (!mFile->IsOpen()) {
43 LOG(error) << "Cannot open the " << filename.c_str() << " file !";
44 throw std::runtime_error("cannot open input digits file");
45 }
46 mTree.reset((TTree*)mFile->Get("o2sim"));
47 if (!mTree) {
48 LOG(error) << "Did not find o2sim tree in " << filename.c_str();
49 throw std::runtime_error("Did not fine o2sim file in ZDC digits tree");
50 }
51}
52
54{
55
56 std::vector<o2::zdc::OrbitData> zdcOrbitData, *zdcOrbitDataPtr = &zdcOrbitData;
57 std::vector<o2::zdc::BCData> zdcBCData, *zdcBCDataPtr = &zdcBCData;
58 std::vector<o2::zdc::ChannelData> zdcChData, *zdcChDataPtr = &zdcChData;
59
60 mTree->SetBranchAddress("ZDCDigitOrbit", &zdcOrbitDataPtr);
61 mTree->SetBranchAddress("ZDCDigitBC", &zdcBCDataPtr);
62 mTree->SetBranchAddress("ZDCDigitCh", &zdcChDataPtr);
64 if (mUseMC) {
65 mTree->SetBranchAddress("ZDCDigitLabels", &plabels);
66 }
67
68 auto ent = mTree->GetReadEntry() < 0 ? mTree->GetReadEntry() + mFirstEntry + 1 : mTree->GetReadEntry() + 1;
69 assert(ent < mTree->GetEntries()); // this should not happen
70 mTree->GetEntry(ent);
71 LOG(info) << "ZDCDigitReader pushed " << zdcOrbitData.size() << " orbits with " << zdcBCData.size() << " bcs and " << zdcChData.size() << " digits";
72 pc.outputs().snapshot(Output{"ZDC", "DIGITSPD", 0}, zdcOrbitData);
73 pc.outputs().snapshot(Output{"ZDC", "DIGITSBC", 0}, zdcBCData);
74 pc.outputs().snapshot(Output{"ZDC", "DIGITSCH", 0}, zdcChData);
75 if (mUseMC) {
76 pc.outputs().snapshot(Output{"ZDC", "DIGITSLBL", 0}, labels);
77 }
78 uint64_t nextEntry = mTree->GetReadEntry() + 1;
79 if (nextEntry >= mTree->GetEntries() || (mLastEntry >= 0 && nextEntry > mLastEntry)) {
81 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
82 }
83}
84
86{
87 std::vector<OutputSpec> outputs;
88 outputs.emplace_back("ZDC", "DIGITSBC", 0, Lifetime::Timeframe);
89 outputs.emplace_back("ZDC", "DIGITSCH", 0, Lifetime::Timeframe);
90 outputs.emplace_back("ZDC", "DIGITSPD", 0, Lifetime::Timeframe);
91 if (useMC) {
92 outputs.emplace_back("ZDC", "DIGITSLBL", 0, Lifetime::Timeframe);
93 }
94 return DataProcessorSpec{
95 "zdc-digit-reader",
96 Inputs{},
97 outputs,
98 AlgorithmSpec{adaptFromTask<DigitReader>(useMC)},
99 Options{
100 {"zdc-digit-infile", VariantType::String, "zdcdigits.root", {"Name of the input file"}},
101 {"input-dir", VariantType::String, "none", {"Input directory"}},
102 {"first-entry", o2::framework::VariantType::Int, 0, {"First digit entry"}},
103 {"last-entry", o2::framework::VariantType::Int, -1, {"Last digit entry"}}}};
104}
105
106} // namespace zdc
107} // namespace o2
Class to describe fired triggered and/or stored channels for the BC and to refer to channel data.
Definition of a container to keep Monte Carlo truth external to simulation objects.
Definition of the Names Generator class.
Class to describe pedestal data accumulated over the orbit.
Container class to store NTimeBinsPerBC ADC values of single ZDC channel.
A container to hold and manage MC truth information/labels.
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(framework::ProcessingContext &pc) final
void init(framework::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 getDigitReaderSpec(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"