forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTPCInterpolationSpec.cxx
More file actions
214 lines (198 loc) · 9.71 KB
/
TPCInterpolationSpec.cxx
File metadata and controls
214 lines (198 loc) · 9.71 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
// 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 TPCInterpolationSpec.cxx
#include <vector>
#include <unordered_map>
#include "DataFormatsITS/TrackITS.h"
#include "ITSBase/GeometryTGeo.h"
#include "ReconstructionDataFormats/TrackTPCITS.h"
#include "DataFormatsTPC/TrackTPC.h"
#include "DataFormatsTPC/ClusterNative.h"
#include "DataFormatsTPC/Defs.h"
#include "DataFormatsTPC/WorkflowHelper.h"
#include "DataFormatsTRD/TrackTRD.h"
#include "DetectorsBase/GeometryManager.h"
#include "DetectorsBase/Propagator.h"
#include "TPCInterpolationWorkflow/TPCInterpolationSpec.h"
#include "DataFormatsGlobalTracking/RecoContainer.h"
#include "DataFormatsGlobalTracking/RecoContainerCreateTracksVariadic.h"
#include "DetectorsCommonDataFormats/DetID.h"
#include "SpacePoints/SpacePointsCalibParam.h"
#include "SpacePoints/SpacePointsCalibConfParam.h"
#include "Framework/ConfigParamRegistry.h"
#include "Framework/ControlService.h"
using namespace o2::framework;
using namespace o2::globaltracking;
using GTrackID = o2::dataformats::GlobalTrackID;
using DetID = o2::detectors::DetID;
namespace o2
{
namespace tpc
{
void TPCInterpolationDPL::init(InitContext& ic)
{
//-------- init geometry and field --------//
mTimer.Stop();
mTimer.Reset();
o2::base::GRPGeomHelper::instance().setRequest(mGGCCDBRequest);
mSlotLength = ic.options().get<uint32_t>("sec-per-slot");
mProcessSeeds = ic.options().get<bool>("process-seeds");
mMatCorr = ic.options().get<int>("matCorrType");
if (mProcessSeeds && mSources != mSourcesMap) {
LOG(fatal) << "process-seeds option is not compatible with using different track sources for vDrift and map extraction";
}
}
void TPCInterpolationDPL::updateTimeDependentParams(ProcessingContext& pc)
{
o2::base::GRPGeomHelper::instance().checkUpdates(pc);
mTPCVDriftHelper.extractCCDBInputs(pc);
static bool initOnceDone = false;
if (!initOnceDone) { // this params need to be queried only once
initOnceDone = true;
// other init-once stuff
const auto& param = SpacePointsCalibConfParam::Instance();
mInterpolation.setSqrtS(o2::base::GRPGeomHelper::instance().getGRPLHCIF()->getSqrtS());
mInterpolation.setNHBPerTF(o2::base::GRPGeomHelper::getNHBFPerTF());
mInterpolation.init(mSources, mSourcesMap);
if (mProcessITSTPConly) {
mInterpolation.setProcessITSTPConly();
}
int nTfs = mSlotLength / (o2::base::GRPGeomHelper::getNHBFPerTF() * o2::constants::lhc::LHCOrbitMUS * 1e-6);
bool limitTracks = (param.maxTracksPerCalibSlot < 0) ? false : true;
int nTracksPerTfMax = (nTfs > 0 && limitTracks) ? param.maxTracksPerCalibSlot / nTfs : -1;
if (nTracksPerTfMax > 0) {
LOGP(info, "We will stop processing tracks after validating {} tracks per TF, since we want to accumulate {} tracks for a slot with {} TFs",
nTracksPerTfMax, param.maxTracksPerCalibSlot, nTfs);
if (param.additionalTracksMap > 0) {
int nTracksAdditional = param.additionalTracksMap / nTfs;
LOGP(info, "In addition up to {} additional tracks are processed per TF", nTracksAdditional);
mInterpolation.setAddTracksForMapPerTF(nTracksAdditional);
}
} else if (nTracksPerTfMax < 0) {
LOG(info) << "The number of processed tracks per TF is not limited";
} else {
LOG(error) << "No tracks will be processed. maxTracksPerCalibSlot must be greater than slot length in TFs";
}
mInterpolation.setMaxTracksPerTF(nTracksPerTfMax);
mInterpolation.setMatCorr(static_cast<o2::base::Propagator::MatCorrType>(mMatCorr));
if (mProcessSeeds) {
mInterpolation.setProcessSeeds();
}
o2::its::GeometryTGeo::Instance()->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2GRot) | o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L));
mInterpolation.setExtDetResid(mExtDetResid);
mInterpolation.setITSClusterDictionary(mITSDict);
if (mDebugOutput) {
mInterpolation.setDumpTrackPoints();
}
}
// we may have other params which need to be queried regularly
if (mTPCVDriftHelper.isUpdated()) {
LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}",
mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift,
mTPCVDriftHelper.getVDriftObject().timeOffsetCorr, mTPCVDriftHelper.getVDriftObject().refTimeOffset,
mTPCVDriftHelper.getSourceName());
mInterpolation.setTPCVDrift(mTPCVDriftHelper.getVDriftObject());
mTPCVDriftHelper.acknowledgeUpdate();
}
}
void TPCInterpolationDPL::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
{
if (o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj)) {
return;
}
if (mTPCVDriftHelper.accountCCDBInputs(matcher, obj)) {
return;
}
if (matcher == ConcreteDataMatcher("ITS", "CLUSDICT", 0)) {
LOG(info) << "cluster dictionary updated";
mITSDict = (const o2::itsmft::TopologyDictionary*)obj;
return;
}
}
void TPCInterpolationDPL::run(ProcessingContext& pc)
{
mTimer.Start(false);
RecoContainer recoData;
recoData.collectData(pc, *mDataRequest.get());
updateTimeDependentParams(pc);
mInterpolation.prepareInputTrackSample(recoData);
mInterpolation.process();
mTimer.Stop();
LOGF(info, "TPC interpolation timing: Cpu: %.3e Real: %.3e s", mTimer.CpuTime(), mTimer.RealTime());
if (SpacePointsCalibConfParam::Instance().writeUnfiltered) {
// these are the residuals and tracks before outlier rejection; they are not used in production
pc.outputs().snapshot(Output{"GLO", "TPCINT_RES", 0}, mInterpolation.getClusterResidualsUnfiltered());
if (mSendTrackData) {
pc.outputs().snapshot(Output{"GLO", "TPCINT_TRK", 0}, mInterpolation.getReferenceTracksUnfiltered());
}
}
pc.outputs().snapshot(Output{"GLO", "UNBINNEDRES", 0}, mInterpolation.getClusterResiduals());
pc.outputs().snapshot(Output{"GLO", "DETINFORES", 0}, mInterpolation.getClusterResidualsDetInfo());
pc.outputs().snapshot(Output{"GLO", "TRKREFS", 0}, mInterpolation.getTrackDataCompact());
if (mSendTrackData) {
pc.outputs().snapshot(Output{"GLO", "TRKDATA", 0}, mInterpolation.getReferenceTracks());
}
if (mDebugOutput) {
pc.outputs().snapshot(Output{"GLO", "TRKDATAEXT", 0}, mInterpolation.getTrackDataExtended());
}
mInterpolation.reset();
}
void TPCInterpolationDPL::endOfStream(EndOfStreamContext& ec)
{
LOGF(info, "TPC residuals extraction total timing: Cpu: %.3e Real: %.3e s in %d slots",
mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
}
DataProcessorSpec getTPCInterpolationSpec(GTrackID::mask_t srcCls, GTrackID::mask_t srcVtx, GTrackID::mask_t srcTrk, GTrackID::mask_t srcTrkMap, bool useMC, bool processITSTPConly, bool sendTrackData, bool debugOutput, bool extDetResid)
{
auto dataRequest = std::make_shared<DataRequest>();
std::vector<OutputSpec> outputs;
if (useMC) {
LOG(fatal) << "MC usage must be disabled for this workflow, since it is not yet implemented";
}
dataRequest->requestTracks(srcVtx, useMC);
dataRequest->requestClusters(srcCls, useMC);
dataRequest->requestPrimaryVertices(useMC);
auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
true, // GRPECS=true
true, // GRPLHCIF
true, // GRPMagField
true, // askMatLUT
o2::base::GRPGeomRequest::Aligned, // geometry
dataRequest->inputs,
true);
o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs);
if (SpacePointsCalibConfParam::Instance().writeUnfiltered) {
outputs.emplace_back("GLO", "TPCINT_TRK", 0, Lifetime::Timeframe);
if (sendTrackData) {
outputs.emplace_back("GLO", "TPCINT_RES", 0, Lifetime::Timeframe);
}
}
outputs.emplace_back("GLO", "UNBINNEDRES", 0, Lifetime::Timeframe);
outputs.emplace_back("GLO", "DETINFORES", 0, Lifetime::Timeframe);
outputs.emplace_back("GLO", "TRKREFS", 0, Lifetime::Timeframe);
if (sendTrackData) {
outputs.emplace_back("GLO", "TRKDATA", 0, Lifetime::Timeframe);
}
if (debugOutput) {
outputs.emplace_back("GLO", "TRKDATAEXT", 0, Lifetime::Timeframe);
}
return DataProcessorSpec{
"tpc-track-interpolation",
dataRequest->inputs,
outputs,
AlgorithmSpec{adaptFromTask<TPCInterpolationDPL>(dataRequest, srcTrk, srcTrkMap, ggRequest, useMC, processITSTPConly, sendTrackData, debugOutput, extDetResid)},
Options{
{"matCorrType", VariantType::Int, 2, {"material correction type (definition in Propagator.h)"}},
{"sec-per-slot", VariantType::UInt32, 300u, {"number of seconds per calibration time slot (put 0 for infinite slot length)"}},
{"process-seeds", VariantType::Bool, false, {"do not remove duplicates, e.g. for ITS-TPC-TRD track also process its seeding ITS-TPC part"}}}};
}
} // namespace tpc
} // namespace o2