-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathTRDGlobalTrackingQCSpec.h
More file actions
174 lines (155 loc) · 7.03 KB
/
TRDGlobalTrackingQCSpec.h
File metadata and controls
174 lines (155 loc) · 7.03 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
// 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.
#ifndef O2_TRD_GLOBALTRACKINGQCSPEC_H
#define O2_TRD_GLOBALTRACKINGQCSPEC_H
/// \file TRDGlobalTrackingQCSpec.h
/// \brief Quality control for global tracking (residuals etc)
/// \author Ole Schmidt
// input TRD tracks, TRD tracklets, TRD calibrated tracklets, ITS-TPC tracks, TPC tracks
// output QC histograms
#include "Headers/DataHeader.h"
#include "Framework/DataProcessorSpec.h"
#include "Framework/Task.h"
#include "Framework/ConfigParamRegistry.h"
#include "Framework/CCDBParamSpec.h"
#include "DPLUtils/MakeRootTreeWriterSpec.h"
#include "DetectorsBase/GeometryManager.h"
#include "DetectorsBase/Propagator.h"
#include "DataFormatsParameters/GRPObject.h"
#include "ReconstructionDataFormats/GlobalTrackID.h"
#include "DataFormatsGlobalTracking/RecoContainer.h"
#include "DataFormatsFT0/RecPoints.h"
#include "FT0Reconstruction/InteractionTag.h"
#include "TRDQC/Tracking.h"
#include <cstring>
#include "DetectorsBase/GRPGeomHelper.h"
using namespace o2::framework;
using namespace o2::globaltracking;
using GTrackID = o2::dataformats::GlobalTrackID;
namespace o2
{
namespace trd
{
class TRDGlobalTrackingQC : public Task
{
public:
TRDGlobalTrackingQC(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, bool tpcAvailable, o2::dataformats::GlobalTrackID::mask_t src) : mDataRequest(dr), mGGCCDBRequest(gr), mTPCavailable(tpcAvailable), mTrkMask(src) {}
~TRDGlobalTrackingQC() override = default;
void init(InitContext& ic) final
{
o2::base::GRPGeomHelper::instance().setRequest(mGGCCDBRequest);
if (!mTPCavailable) {
mQC.disablePID();
}
if (getenv("ALIEN_JDL_LPMPRODUCTIONTYPE") && std::strcmp(getenv("ALIEN_JDL_LPMPRODUCTIONTYPE"), "MC") == 0) {
// apply artificial pad shift in case non-ideal alignment is used to compensate for shift in current alignment from real data
mQC.setApplyShift(false);
}
}
void run(ProcessingContext& pc) final
{
RecoContainer recoData;
recoData.collectData(pc, *mDataRequest.get());
updateTimeDependentParams(pc); // Make sure this is called after recoData.collectData, which may load some conditions
mQC.reset();
mQC.setInput(recoData);
std::vector<int> triggeredBCFT0;
if (mTrkMask[GTrackID::FT0]) { // pile-up tagging was requested
auto ft0recPoints = recoData.getFT0RecPoints();
uint32_t firstOrbit = 0;
for (size_t ft0id = 0; ft0id < ft0recPoints.size(); ft0id++) {
const auto& f0rec = ft0recPoints[ft0id];
if (ft0id == 0) {
firstOrbit = f0rec.getInteractionRecord().orbit;
mQC.setFirstOrbit(firstOrbit);
}
if (o2::ft0::InteractionTag::Instance().isSelected(f0rec)) {
uint32_t currentOrbit = f0rec.getInteractionRecord().orbit;
triggeredBCFT0.push_back(f0rec.getInteractionRecord().bc + (currentOrbit - firstOrbit) * o2::constants::lhc::LHCMaxBunches);
}
}
}
mQC.setTriggeredBCFT0(triggeredBCFT0);
mQC.run();
pc.outputs().snapshot(Output{"TRD", "TRACKINGQC", 0}, mQC.getTrackQC());
}
void endOfStream(framework::EndOfStreamContext& ec) final {}
void finaliseCCDB(framework::ConcreteDataMatcher& matcher, void* obj) final
{
if (o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj)) {
return;
}
}
private:
void updateTimeDependentParams(framework::ProcessingContext& pc)
{
o2::base::GRPGeomHelper::instance().checkUpdates(pc);
static bool initOnceDone = false;
if (!initOnceDone) { // these params need to be queried only once
initOnceDone = true;
mQC.init();
// Local pad gain calibration from krypton run
auto localGain = *(pc.inputs().get<o2::trd::LocalGainFactor*>("localgainfactors"));
mQC.setLocalGainFactors(localGain);
}
}
o2::dataformats::GlobalTrackID::mask_t mTrkMask; ///< seeding track sources (TPC, ITS-TPC)
std::shared_ptr<DataRequest> mDataRequest;
std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
bool mTPCavailable{false};
Tracking mQC;
};
DataProcessorSpec getTRDGlobalTrackingQCSpec(o2::dataformats::GlobalTrackID::mask_t src)
{
std::vector<OutputSpec> outputs;
outputs.emplace_back("TRD", "TRACKINGQC", 0, Lifetime::Timeframe);
auto dataRequest = std::make_shared<DataRequest>();
bool isTPCavailable = false;
if (GTrackID::includesSource(GTrackID::Source::ITSTPC, src)) {
LOGF(debug, "Found ITS-TPC tracks as input, loading ITS-TPC-TRD");
src |= GTrackID::getSourcesMask("ITS-TPC-TRD");
}
if (GTrackID::includesSource(GTrackID::Source::TPC, src)) {
LOGF(debug, "Found TPC tracks as input, loading TPC-TRD");
src |= GTrackID::getSourcesMask("TPC-TRD");
isTPCavailable = true;
}
GTrackID::mask_t srcClu = GTrackID::getSourcesMask("TRD"); // we don't need all clusters, only TRD tracklets
dataRequest->requestTracks(src, false);
dataRequest->requestClusters(srcClu, false);
dataRequest->inputs.emplace_back("localgainfactors", "TRD", "LOCALGAINFACTORS", 0, Lifetime::Condition, ccdbParamSpec("TRD/Calib/LocalGainFactor"));
auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
false, // GRPECS=true
false, // GRPLHCIF
true, // GRPMagField
true, // askMatLUT
o2::base::GRPGeomRequest::Aligned, // geometry
dataRequest->inputs,
true);
return DataProcessorSpec{
"trd-tracking-qc",
dataRequest->inputs,
outputs,
AlgorithmSpec{adaptFromTask<TRDGlobalTrackingQC>(dataRequest, ggRequest, isTPCavailable, src)},
Options{}};
}
template <typename T>
using BranchDefinition = framework::MakeRootTreeWriterSpec::BranchDefinition<T>;
DataProcessorSpec getTRDTrackingQCWriterSpec()
{
return framework::MakeRootTreeWriterSpec("trd-tracking-qc-writer",
"trdQC.root",
"qc",
BranchDefinition<std::vector<TrackQC>>{InputSpec{"trackingqc", "TRD", "TRACKINGQC"}, "trackQC"})();
};
} // namespace trd
} // namespace o2
#endif // O2_TRD_GLOBALTRACKINGQCSPEC_H