Project
Loading...
Searching...
No Matches
TrackBasedCalibSpec.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
18#include "Framework/Task.h"
25#include "Headers/DataHeader.h"
27#include "TStopwatch.h"
29#include <cstring>
30
31using namespace o2::framework;
32using namespace o2::globaltracking;
34
35namespace o2
36{
37namespace trd
38{
39
41{
42 public:
43 TRDTrackBasedCalibDevice(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, bool vdexb, bool gain) : mDataRequest(dr), mGGCCDBRequest(gr), mDoVdExBCalib(vdexb), mDoGainCalib(gain) {}
44 ~TRDTrackBasedCalibDevice() override = default;
45 void init(InitContext& ic) final;
46 void run(ProcessingContext& pc) final;
47 void finaliseCCDB(framework::ConcreteDataMatcher& matcher, void* obj) final;
49
50 private:
51 void updateTimeDependentParams(framework::ProcessingContext& pc);
52
53 bool mDoGainCalib{false};
54 bool mDoVdExBCalib{false};
55
56 std::shared_ptr<DataRequest> mDataRequest;
57 std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
58 TrackBasedCalib mCalibrator; // gather input data for calibration of vD, ExB and gain
59 TStopwatch mTimer;
60};
61
63{
65 if (getenv("ALIEN_JDL_LPMPRODUCTIONTYPE") && std::strcmp(getenv("ALIEN_JDL_LPMPRODUCTIONTYPE"), "MC") == 0) {
66 // apply artificial pad shift in case non-ideal alignment is used to compensate for shift in current alignment from real data
67 mCalibrator.setApplyShift(false);
68 }
69 mTimer.Stop();
70 mTimer.Reset();
71}
72
74{
75 mTimer.Start(false);
76 RecoContainer recoData;
77 recoData.collectData(pc, *mDataRequest.get());
78 updateTimeDependentParams(pc); // Make sure this is called after recoData.collectData, which may load some conditions
79 mCalibrator.setInput(recoData);
80
81 if (mDoVdExBCalib) {
82 mCalibrator.calculateAngResHistos();
83 pc.outputs().snapshot(Output{o2::header::gDataOriginTRD, "ANGRESHISTS", 0}, mCalibrator.getAngResHistos());
84 }
85
86 if (mDoGainCalib) {
87 mCalibrator.calculateGainCalibObjs();
88 pc.outputs().snapshot(Output{o2::header::gDataOriginTRD, "GAINCALIBHISTS", 0}, mCalibrator.getGainCalibHistos());
89 }
90
91 mCalibrator.reset();
92 mTimer.Stop();
93}
94
95void TRDTrackBasedCalibDevice::updateTimeDependentParams(ProcessingContext& pc)
96{
98 pc.inputs().get<o2::trd::NoiseStatusMCM*>("mcmnoisemap"); // just to trigger the finaliseCCDB
99 if (mDoGainCalib) {
100 pc.inputs().get<o2::trd::LocalGainFactor*>("localgainfactors"); // just to trigger the finaliseCCDB
101 }
102 static bool initOnceDone = false;
103 if (!initOnceDone) { // this params need to be queried only once
104 initOnceDone = true;
105 // init-once stuff
106 mCalibrator.init();
107 }
108}
109
111{
113 return;
114 }
115 if (matcher == ConcreteDataMatcher("TRD", "MCMNOISEMAP", 0)) {
116 LOG(info) << "NoiseStatusMCM object has been updated";
117 mCalibrator.setNoiseMapMCM((const o2::trd::NoiseStatusMCM*)obj);
118 return;
119 }
120 if (matcher == ConcreteDataMatcher("TRD", "LOCALGAINFACTORS", 0)) {
121 LOG(info) << "Local gain factors object has been updated";
122 mCalibrator.setLocalGainFactors((const o2::trd::LocalGainFactor*)obj);
123 return;
124 }
125}
126
128{
129 LOGF(info, "TRD track-based calibration total timing: Cpu: %.3e Real: %.3e s in %d slots",
130 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
131}
132
134{
135 std::vector<OutputSpec> outputs;
136 auto dataRequest = std::make_shared<DataRequest>();
137
138 GTrackID::mask_t srcTrk;
139 if (GTrackID::includesSource(GTrackID::Source::ITSTPC, src)) {
140 LOGF(info, "Found ITS-TPC tracks as input, loading ITS-TPC-TRD");
141 srcTrk |= GTrackID::getSourcesMask("ITS-TPC-TRD");
142 if (gain) {
143 srcTrk |= GTrackID::getSourcesMask("ITS-TPC");
144 }
145 }
146 if (GTrackID::includesSource(GTrackID::Source::TPC, src)) {
147 LOGF(info, "Found TPC tracks as input, loading TPC-TRD");
148 srcTrk |= GTrackID::getSourcesMask("TPC-TRD");
149 }
150 if (gain) {
151 srcTrk |= GTrackID::getSourcesMask("TPC");
152 }
153 GTrackID::mask_t srcClu = GTrackID::getSourcesMask("TRD"); // we don't need all clusters, only TRD tracklets
154 dataRequest->requestTracks(srcTrk, false);
155 dataRequest->requestClusters(srcClu, false);
156
157 auto& inputs = dataRequest->inputs;
158 inputs.emplace_back("mcmnoisemap", "TRD", "MCMNOISEMAP", 0, Lifetime::Condition, ccdbParamSpec("TRD/Calib/NoiseMapMCM"));
159 if (gain) {
160 inputs.emplace_back("localgainfactors", "TRD", "LOCALGAINFACTORS", 0, Lifetime::Condition, ccdbParamSpec("TRD/Calib/LocalGainFactor"));
161 }
162 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
163 false, // GRPECS=true
164 false, // GRPLHCIF
165 true, // GRPMagField
166 true, // askMatLUT
168 inputs,
169 true);
170 if (gain) {
171 outputs.emplace_back(o2::header::gDataOriginTRD, "GAINCALIBHISTS", 0, Lifetime::Timeframe);
172 }
173 if (vdexb) {
174 outputs.emplace_back(o2::header::gDataOriginTRD, "ANGRESHISTS", 0, Lifetime::Timeframe);
175 }
176 if (!gain && !vdexb) {
177 LOG(error) << "TRD track based calibration requested, but neither gain nor vD and ExB calibration enabled";
178 }
179
180 return DataProcessorSpec{
181 "trd-trackbased-calib",
182 inputs,
183 outputs,
184 AlgorithmSpec{adaptFromTask<TRDTrackBasedCalibDevice>(dataRequest, ggRequest, vdexb, gain)},
185 Options{}};
186}
187
188} // namespace trd
189} // namespace o2
Wrapper container for different reconstructed object types.
Definition of the GeometryManager class.
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h trd
Helper for geometry and GRP related CCDB requests.
Header of the General Run Parameters object.
char error[CURL_ERROR_SIZE]
Definition of the Names Generator class.
Steers the creation of calibration input based on tracks.
Provides information required for TRD calibration which is based on the global tracking.
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
static mask_t getSourcesMask(const std::string_view srcList)
void snapshot(const Output &spec, T const &object)
decltype(auto) get(R binding, int part=0) const
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
Simple noise status bit for each MCM of the TRD.
void endOfStream(framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void finaliseCCDB(framework::ConcreteDataMatcher &matcher, void *obj) final
void run(ProcessingContext &pc) final
TRDTrackBasedCalibDevice(std::shared_ptr< DataRequest > dr, std::shared_ptr< o2::base::GRPGeomRequest > gr, bool vdexb, bool gain)
~TRDTrackBasedCalibDevice() override=default
void setInput(const o2::globaltracking::RecoContainer &input)
Initialize the input arrays.
void setNoiseMapMCM(const NoiseStatusMCM *map)
Set the MCM noise map.
void reset()
Reset the output.
void init()
Load geometry and apply magnetic field setting.
const auto & getGainCalibHistos() const
void calculateAngResHistos()
Main processing function for creating angular residual histograms for vDrift and ExB calibration.
void setLocalGainFactors(const LocalGainFactor *localGain)
const AngularResidHistos & getAngResHistos() const
constexpr o2::header::DataOrigin gDataOriginTRD
Definition DataHeader.h:580
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
framework::DataProcessorSpec getTRDTrackBasedCalibSpec(o2::dataformats::GlobalTrackID::mask_t src, bool vdexb, bool gain)
create a processor spec
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
void collectData(o2::framework::ProcessingContext &pc, const DataRequest &request)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"