Project
Loading...
Searching...
No Matches
TRDDigitReaderSpec.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
18#include "fairlogger/Logger.h"
19
22
23using namespace o2::framework;
24
25namespace o2
26{
27namespace trd
28{
29
31{
32
33 mFileName = o2::utils::Str::concat_string(o2::utils::Str::rectifyDirectory(ic.options().get<std::string>("input-dir")),
34 ic.options().get<std::string>("digitsfile"));
35 connectTree();
36}
37
38void TRDDigitReaderSpec::connectTree()
39{
40 mTreeDigits.reset(nullptr); // in case it was already loaded
41 mFile.reset(TFile::Open(mFileName.c_str()));
42 assert(mFile && !mFile->IsZombie());
43 mTreeDigits.reset((TTree*)mFile->Get(mDigitTreeName.c_str()));
44 assert(mTreeDigits);
45 mTreeDigits->SetBranchAddress(mDigitBranchName.c_str(), &mDigitsPtr);
46 if (mUseTriggerRecords) {
47 mTreeDigits->SetBranchAddress(mTriggerRecordBranchName.c_str(), &mTriggerRecordsPtr);
48 }
49 if (mUseMC) {
50 mTreeDigits->SetBranchAddress(mMCLabelsBranchName.c_str(), &mLabels);
51 }
52 LOG(info) << "Loaded tree from " << mFileName << " with " << mTreeDigits->GetEntries() << " entries";
53}
54
56{
57 auto currEntry = mTreeDigits->GetReadEntry() + 1;
58 assert(currEntry < mTreeDigits->GetEntries()); // this should not happen
59 mTreeDigits->GetEntry(currEntry);
60 LOGP(info, "Pushing {} digits for tree entry {}", mDigits.size(), currEntry);
61 pc.outputs().snapshot(Output{o2::header::gDataOriginTRD, "DIGITS", mSubSpec}, mDigits);
62 if (mUseTriggerRecords) {
63 LOGP(info, "Pushing {} trigger records for tree entry {}", mTriggerRecords.size(), currEntry);
64 pc.outputs().snapshot(Output{o2::header::gDataOriginTRD, "TRKTRGRD", mSubSpec}, mTriggerRecords);
65 }
66 if (mUseMC) {
68 mLabels->copyandflatten(sharedlabels);
69 }
70 if (mTreeDigits->GetReadEntry() + 1 >= mTreeDigits->GetEntries()) {
72 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
73 }
74}
75
76DataProcessorSpec getTRDDigitReaderSpec(bool useMC, bool trigRec, int dataSubspec)
77{
78 std::vector<OutputSpec> outputs;
79 outputs.emplace_back("TRD", "DIGITS", dataSubspec, Lifetime::Timeframe);
80 if (trigRec) {
81 outputs.emplace_back("TRD", "TRKTRGRD", dataSubspec, Lifetime::Timeframe);
82 }
83 if (useMC) {
84 outputs.emplace_back("TRD", "LABELS", 0, Lifetime::Timeframe);
85 }
86 return DataProcessorSpec{"TRDDIGITREADER",
87 Inputs{},
88 outputs,
89 AlgorithmSpec{adaptFromTask<TRDDigitReaderSpec>(useMC, trigRec, dataSubspec)},
90 Options{
91 {"digitsfile", VariantType::String, "trddigits.root", {"Input data file containing TRD digits"}},
92 {"input-dir", VariantType::String, "none", {"Input directory"}}}};
93};
94
95} //end namespace trd
96} //end namespace o2
A const (ready only) version of MCTruthContainer.
A read-only version of MCTruthContainer allowing for storage optimisation.
void copyandflatten(std::vector< char, Alloc > &output) const
void snapshot(const Output &spec, T const &object)
decltype(auto) make(const Output &spec, Args... args)
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) override
void run(o2::framework::ProcessingContext &pc) override
constexpr o2::header::DataOrigin gDataOriginTRD
Definition DataHeader.h:577
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
o2::framework::DataProcessorSpec getTRDDigitReaderSpec(bool useMC, bool trigRec=true, int dataSubspec=1)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static std::string rectifyDirectory(const std::string_view p)
static std::string concat_string(Ts const &... ts)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"