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#include <cassert>
20
21using namespace o2::framework;
22using namespace o2::phos;
23
24namespace o2
25{
26namespace phos
27{
28
30{
31 mUseMC = useMC;
32}
33
35{
37 ic.options().get<std::string>("phos-digits-infile"));
39}
40
42{
43 auto ent = mTree->GetReadEntry() + 1;
44 assert(ent < mTree->GetEntries()); // this should not happen
45 mTree->GetEntry(ent);
46 LOG(info) << "Pushing " << mDigits.size() << " Digits in " << mTRs.size() << " TriggerRecords at entry " << ent;
47 pc.outputs().snapshot(Output{mOrigin, "DIGITS", 0}, mDigits);
48 pc.outputs().snapshot(Output{mOrigin, "DIGITTRIGREC", 0}, mTRs);
49 if (mUseMC) {
50 pc.outputs().snapshot(Output{mOrigin, "DIGITSMCTR", 0}, mMCTruth);
51 }
52
53 if (mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
55 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
56 }
57}
58
59void DigitReader::connectTree(const std::string& filename)
60{
61 mTree.reset(nullptr); // in case it was already loaded
62 mFile.reset(TFile::Open(filename.c_str()));
63 assert(mFile && !mFile->IsZombie());
64 mTree.reset((TTree*)mFile->Get(mDigitTreeName.c_str()));
65 assert(mTree);
66 assert(mTree->GetBranch(mTRBranchName.c_str()));
67
68 mTree->SetBranchAddress(mTRBranchName.c_str(), &mTRsInp);
69 mTree->SetBranchAddress(mDigitBranchName.c_str(), &mDigitsInp);
70 if (mUseMC) {
71 if (mTree->GetBranch(mDigitMCTruthBranchName.c_str())) {
72 mTree->SetBranchAddress(mDigitMCTruthBranchName.c_str(), &mMCTruthInp);
73 } else {
74 LOG(warning) << "MC-truth is missing, message will be empty";
75 }
76 }
77 LOG(info) << "Loaded tree from " << filename << " with " << mTree->GetEntries() << " entries";
78}
79
81{
82 std::vector<OutputSpec> outputSpec;
83 outputSpec.emplace_back("PHS", "DIGITS", 0, Lifetime::Timeframe);
84 outputSpec.emplace_back("PHS", "DIGITTRIGREC", 0, Lifetime::Timeframe);
85 if (useMC) {
86 outputSpec.emplace_back("PHS", "DIGITSMCTR", 0, Lifetime::Timeframe);
87 }
88
89 return DataProcessorSpec{
90 "phos-digits-reader",
91 Inputs{},
92 outputSpec,
93 AlgorithmSpec{adaptFromTask<DigitReader>(useMC)},
94 Options{
95 {"phos-digits-infile", VariantType::String, "phosdigits.root", {"Name of the input Digit file"}},
96 {"input-dir", VariantType::String, "none", {"Input directory"}}}};
97}
98
99} // namespace phos
100} // 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 init(o2::framework::InitContext &ic) final
std::vector< o2::phos::Digit > * mDigitsInp
o2::dataformats::MCTruthContainer< o2::phos::MCLabel > * mMCTruthInp
std::unique_ptr< TFile > mFile
std::vector< o2::phos::TriggerRecord > * mTRsInp
void connectTree(const std::string &filename)
std::vector< o2::phos::Digit > mDigits
void run(o2::framework::ProcessingContext &pc) final
o2::dataformats::MCTruthContainer< o2::phos::MCLabel > mMCTruth
std::vector< o2::phos::TriggerRecord > mTRs
std::string mDigitMCTruthBranchName
DigitReader(bool useMC=true)
std::unique_ptr< TTree > mTree
o2::header::DataOrigin mOrigin
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
framework::DataProcessorSpec getPHOSDigitReaderSpec(bool useMC=true)
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"