-
Notifications
You must be signed in to change notification settings - Fork 499
Expand file tree
/
Copy pathFilteredTFReaderSpec.cxx
More file actions
102 lines (87 loc) · 3.83 KB
/
FilteredTFReaderSpec.cxx
File metadata and controls
102 lines (87 loc) · 3.83 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
100
101
102
// 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 FilteredTFReaderSpec.cxx
#include <cassert>
#include "Framework/ControlService.h"
#include "Framework/ConfigParamRegistry.h"
#include "FilteredTFReaderSpec.h"
#include "CommonUtils/NameConf.h"
using namespace o2::framework;
using namespace o2::dataformats;
namespace o2::filtering
{
FilteredTFReader::FilteredTFReader(bool useMC)
{
mUseMC = useMC;
}
void FilteredTFReader::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>("filtered-tf-infile"));
connectTree(mInputFileName);
}
void FilteredTFReader::run(ProcessingContext& pc)
{
// FIXME: fill all output headers by TF specific info (extend findMessageHeaderStack)
auto ent = mTree->GetReadEntry() + 1;
assert(ent < mTree->GetEntries()); // this should not happen
mTree->GetEntry(ent);
LOG(info) << "Pushing filtered TF: " << mFiltTF.header.asString();
// ITS
pc.outputs().snapshot(Output{"ITS", "ITSTrackROF", 0}, mFiltTF.ITSTrackROFs);
pc.outputs().snapshot(Output{"ITS", "TRACKS", 0}, mFiltTF.ITSTracks);
pc.outputs().snapshot(Output{"ITS", "TRACKCLSID", 0}, mFiltTF.ITSClusterIndices);
if (mUseMC) {
pc.outputs().snapshot(Output{"ITS", "TRACKSMCTR", 0}, mFiltTF.ITSTrackMCTruth);
}
pc.outputs().snapshot(Output{"ITS", "CLUSTERSROF", 0}, mFiltTF.ITSClusterROFs);
pc.outputs().snapshot(Output{"ITS", "COMPCLUSTERS", 0}, mFiltTF.ITSClusters);
pc.outputs().snapshot(Output{"ITS", "PATTERNS", 0}, mFiltTF.ITSClusterPatterns);
if (mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
pc.services().get<ControlService>().endOfStream();
pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
}
}
void FilteredTFReader::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(mInputTreeName.c_str()));
assert(mTree);
assert(mTree->GetBranch(mFTFBranchName.c_str()));
mTree->SetBranchAddress(mFTFBranchName.c_str(), &mFiltTFPtr);
LOG(info) << "Loaded tree from " << filename << " with " << mTree->GetEntries() << " entries";
}
DataProcessorSpec getFilteredTFReaderSpec(bool useMC)
{
std::vector<OutputSpec> outputSpec;
// same as ITSWorkflow/TrackReaderSpec
outputSpec.emplace_back("ITS", "ITSTrackROF", 0, Lifetime::Timeframe);
outputSpec.emplace_back("ITS", "TRACKS", 0, Lifetime::Timeframe);
outputSpec.emplace_back("ITS", "TRACKCLSID", 0, Lifetime::Timeframe);
if (useMC) {
outputSpec.emplace_back("ITS", "TRACKSMCTR", 0, Lifetime::Timeframe);
}
// same as ITSMFTWorkflow/ClusterReaderSpec
outputSpec.emplace_back("ITS", "CLUSTERSROF", 0, Lifetime::Timeframe);
outputSpec.emplace_back("ITS", "COMPCLUSTERS", 0, Lifetime::Timeframe);
outputSpec.emplace_back("ITS", "PATTERNS", 0, Lifetime::Timeframe);
return DataProcessorSpec{
"filtered-reco-tf-reader",
Inputs{},
outputSpec,
AlgorithmSpec{adaptFromTask<FilteredTFReader>(useMC)},
Options{
{"filtered-tf-infile", VariantType::String, "o2_filtered_tf.root", {"Name of the input file"}},
{"input-dir", VariantType::String, "none", {"Input directory"}}}};
}
} // namespace o2::filtering