forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecPointReaderSpec.cxx
More file actions
99 lines (83 loc) · 3.33 KB
/
RecPointReaderSpec.cxx
File metadata and controls
99 lines (83 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// @file RecPointReaderSpec.cxx
#include "Framework/ConfigParamRegistry.h"
#include "Framework/ControlService.h"
#include "Framework/Logger.h"
#include "FDDWorkflow/RecPointReaderSpec.h"
#include "CommonUtils/NameConf.h"
#include <vector>
using namespace o2::framework;
using namespace o2::fdd;
namespace o2
{
namespace fdd
{
RecPointReader::RecPointReader(bool useMC)
{
mUseMC = useMC;
if (useMC) {
LOG(warning) << "FDD RecPoint reader at the moment does not process MC";
}
}
void RecPointReader::init(InitContext& ic)
{
mInputFileName = o2::utils::Str::concat_string(o2::utils::Str::rectifyDirectory(ic.options().get<std::string>("input-dir")),
ic.options().get<std::string>("fdd-recpoints-infile"));
connectTree(mInputFileName);
}
void RecPointReader::run(ProcessingContext& pc)
{
auto ent = mTree->GetReadEntry() + 1;
assert(ent < mTree->GetEntries()); // this should not happen
mTree->GetEntry(ent);
LOG(info) << "FDD RecPointReader pushes " << mRecPoints->size() << " recpoints with " << mChannelData->size() << " channels at entry " << ent;
pc.outputs().snapshot(Output{mOrigin, "RECPOINTS", 0}, *mRecPoints);
pc.outputs().snapshot(Output{mOrigin, "RECCHDATA", 0}, *mChannelData);
if (mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
pc.services().get<ControlService>().endOfStream();
pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
}
}
void RecPointReader::connectTree(const std::string& filename)
{
mTree.reset(nullptr); // in case it was already loaded
mFile.reset(TFile::Open(filename.c_str()));
assert(mFile && !mFile->IsZombie());
mTree.reset((TTree*)mFile->Get(mRecPointTreeName.c_str()));
assert(mTree);
mTree->SetBranchAddress(mRecPointBranchName.c_str(), &mRecPoints);
mTree->SetBranchAddress(mChannelDataBranchName.c_str(), &mChannelData);
if (mUseMC) {
LOG(warning) << "MC-truth is not supported for FDD recpoints currently";
mUseMC = false;
}
LOG(info) << "Loaded FDD RecPoints tree from " << filename << " with " << mTree->GetEntries() << " entries";
}
DataProcessorSpec getFDDRecPointReaderSpec(bool useMC)
{
std::vector<OutputSpec> outputSpec;
outputSpec.emplace_back(o2::header::gDataOriginFDD, "RECPOINTS", 0, Lifetime::Timeframe);
outputSpec.emplace_back(o2::header::gDataOriginFDD, "RECCHDATA", 0, Lifetime::Timeframe);
if (useMC) {
LOG(warning) << "MC-truth is not supported for FDD recpoints currently";
}
return DataProcessorSpec{
"fdd-recpoints-reader",
Inputs{},
outputSpec,
AlgorithmSpec{adaptFromTask<RecPointReader>()},
Options{
{"fdd-recpoints-infile", VariantType::String, "o2reco_fdd.root", {"Name of the input file"}},
{"input-dir", VariantType::String, "none", {"Input directory"}}}};
}
} // namespace fdd
} // namespace o2