forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReconstructionSpec.cxx
More file actions
154 lines (136 loc) · 6.05 KB
/
ReconstructionSpec.cxx
File metadata and controls
154 lines (136 loc) · 6.05 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// 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 ReconstructionSpec.cxx
#include <vector>
#include "SimulationDataFormat/MCTruthContainer.h"
#include "Framework/ControlService.h"
#include "Framework/Logger.h"
#include "Framework/CCDBParamSpec.h"
#include "FT0Workflow/ReconstructionSpec.h"
#include "DataFormatsFT0/Digit.h"
#include "DataFormatsFT0/ChannelData.h"
#include "DataFormatsFT0/DigitFilterParam.h"
#include "DataFormatsFT0/CalibParam.h"
#include "DataFormatsFT0/MCLabel.h"
#include "DataFormatsFT0/SpectraInfoObject.h"
#include "Framework/CCDBParamSpec.h"
using namespace o2::framework;
namespace o2
{
namespace ft0
{
void ReconstructionDPL::init(InitContext& ic)
{
mTimer.Stop();
mTimer.Reset();
o2::ft0::ChannelFilterParam::Instance().printKeyValues();
o2::ft0::TimeFilterParam::Instance().printKeyValues();
// Parameters which are used in reco, too many will be printed if use printKeyValues()
LOG(info) << "FT0 param mMinEntriesThreshold: " << CalibParam::Instance().mMinEntriesThreshold;
LOG(info) << "FT0 param mMaxEntriesThreshold:" << CalibParam::Instance().mMaxEntriesThreshold;
LOG(info) << "FT0 param mMinRMS: " << CalibParam::Instance().mMinRMS;
LOG(info) << "FT0 param mMaxSigma: " << CalibParam::Instance().mMaxSigma;
LOG(info) << "FT0 param mMaxDiffMean: " << CalibParam::Instance().mMaxDiffMean;
LOG(info) << "FT0 dead channel map will be applied " << mUseDeadChannelMap;
}
void ReconstructionDPL::run(ProcessingContext& pc)
{
mTimer.Start(false);
mRecPoints.clear();
mRecChData.clear();
auto digits = pc.inputs().get<gsl::span<o2::ft0::Digit>>("digits");
auto channels = pc.inputs().get<gsl::span<o2::ft0::ChannelData>>("digch");
// RS: if we need to process MC truth, uncomment lines below
// std::unique_ptr<const o2::dataformats::MCTruthContainer<o2::ft0::MCLabel>> labels;
// const o2::dataformats::MCTruthContainer<o2::ft0::MCLabel>* lblPtr = nullptr;
if (mUseMC) {
LOG(info) << "Ignoring MC info";
}
if (mUseTimeOffsetCalib) {
auto timeOffsetCalibObject = pc.inputs().get<o2::ft0::TimeSpectraInfoObject*>("ft0_timespectra");
mReco.SetTimeCalibObject(timeOffsetCalibObject.get());
}
if (mUseSlewingCalib) {
auto slewingCalibObject = pc.inputs().get<o2::ft0::SlewingCoef*>("ft0_slewing_coef");
mReco.SetSlewingCalibObject(slewingCalibObject.get());
}
if (mUseDeadChannelMap && mUpdateDeadChannelMap) {
LOG(debug) << "Applying dead channel map";
auto deadChannelMap = pc.inputs().get<o2::fit::DeadChannelMap*>("deadChannelMap");
mReco.SetDeadChannelMap(deadChannelMap.get());
}
mRecPoints.reserve(digits.size());
mRecChData.reserve(channels.size());
mReco.processTF(digits, channels, mRecPoints, mRecChData);
// do we ignore MC in this task?
LOG(debug) << "FT0 reconstruction pushes " << mRecPoints.size() << " RecPoints";
pc.outputs().snapshot(Output{mOrigin, "RECPOINTS", 0}, mRecPoints);
pc.outputs().snapshot(Output{mOrigin, "RECCHDATA", 0}, mRecChData);
mTimer.Stop();
}
//_______________________________________
void ReconstructionDPL::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
{
if (matcher == ConcreteDataMatcher("FT0", "TimeSpectraInfo", 0)) {
LOG(debug) << "New TimeSpectraInfo is uploaded";
return;
}
if (matcher == ConcreteDataMatcher("FT0", "SlewingCoef", 0)) {
LOG(debug) << "New SlewingCoef is uploaded";
mUseSlewingCalib = false; // upload only once, slewing should be stable during the run
return;
}
if (matcher == ConcreteDataMatcher("FT0", "DeadChannelMap", 0)) {
LOG(debug) << "New DeadChannelMap is uploaded";
mUpdateDeadChannelMap = false;
return;
}
}
void ReconstructionDPL::endOfStream(EndOfStreamContext& ec)
{
LOGF(info, "FT0 reconstruction total timing: Cpu: %.3e Real: %.3e s in %d slots",
mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
}
DataProcessorSpec getReconstructionSpec(bool useMC, const std::string ccdbpath, bool useTimeOffsetCalib, bool useSlewingCalib, bool useDeadChannelMap)
{
std::vector<InputSpec> inputSpec;
std::vector<OutputSpec> outputSpec;
inputSpec.emplace_back("digits", o2::header::gDataOriginFT0, "DIGITSBC", 0, Lifetime::Timeframe);
inputSpec.emplace_back("digch", o2::header::gDataOriginFT0, "DIGITSCH", 0, Lifetime::Timeframe);
if (useMC) {
LOG(info) << "Currently Reconstruction does not consume and provide MC truth";
inputSpec.emplace_back("labels", o2::header::gDataOriginFT0, "DIGITSMCTR", 0, Lifetime::Timeframe);
}
if (useTimeOffsetCalib) {
inputSpec.emplace_back("ft0_timespectra", "FT0", "TimeSpectraInfo", 0,
Lifetime::Condition,
ccdbParamSpec("FT0/Calib/TimeSpectraInfo", {}, 1));
}
if (useSlewingCalib) {
inputSpec.emplace_back("ft0_slewing_coef", "FT0", "SlewingCoef", 0,
Lifetime::Condition,
ccdbParamSpec("FT0/Calib/SlewingCoef"));
}
if (useDeadChannelMap) {
LOG(info) << "Dead channel map will be applied during reconstruction";
inputSpec.emplace_back("deadChannelMap", o2::header::gDataOriginFT0, "DeadChannelMap", 0, Lifetime::Condition, ccdbParamSpec("FT0/Calib/DeadChannelMap"));
}
outputSpec.emplace_back(o2::header::gDataOriginFT0, "RECPOINTS", 0, Lifetime::Timeframe);
outputSpec.emplace_back(o2::header::gDataOriginFT0, "RECCHDATA", 0, Lifetime::Timeframe);
return DataProcessorSpec{
"ft0-reconstructor",
inputSpec,
outputSpec,
AlgorithmSpec{adaptFromTask<ReconstructionDPL>(useMC, ccdbpath, useTimeOffsetCalib, useSlewingCalib, useDeadChannelMap)},
Options{}};
}
} // namespace ft0
} // namespace o2