Project
Loading...
Searching...
No Matches
Tracking.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
17#include "TRDQC/Tracking.h"
20#include "TRDBase/Geometry.h"
21#include "TRDBase/PadPlane.h"
22#include <fairlogger/Logger.h>
23
24using namespace o2::trd;
25using namespace o2::trd::constants;
26
28{
29 mRecoParam.init(o2::base::Propagator::Instance()->getNominalBz());
30}
31
33{
34 mTracksTPC = input.getTPCTracks();
35 mTracksITSTPC = input.getTPCITSTracks();
36 mTracksITSTPCTRD = input.getITSTPCTRDTracks<TrackTRD>();
37 mTracksTPCTRD = input.getTPCTRDTracks<TrackTRD>();
38 mTrackletsRaw = input.getTRDTracklets();
39 mTrackletsCalib = input.getTRDCalibratedTracklets();
40 mTrackTriggerRecordsITSTPCTRD = input.getITSTPCTRDTriggers();
41 mTrackTriggerRecordsTPCTRD = input.getTPCTRDTriggers();
42}
43
45{
46 mCurrentTriggerRecord = 0;
47 mCurrentTrackId = 0;
48 for (const auto& trkTrd : mTracksTPCTRD) {
49 checkTrack(trkTrd, true);
50 mCurrentTrackId++;
51 }
52 mCurrentTriggerRecord = 0;
53 mCurrentTrackId = 0;
54 for (const auto& trkTrd : mTracksITSTPCTRD) {
55 checkTrack(trkTrd, false);
56 mCurrentTrackId++;
57 }
58}
59
60void Tracking::checkTrack(const TrackTRD& trkTrd, bool isTPCTRD)
61{
62 auto propagator = o2::base::Propagator::Instance();
63 auto id = trkTrd.getRefGlobalTrackId();
64 TrackQC qcStruct;
65
66 qcStruct.refGlobalTrackId = id;
67 qcStruct.trackTRD = trkTrd;
68
69 LOGF(debug, "Got track with %i tracklets and ID %i", trkTrd.getNtracklets(), (int)id);
70 o2::track::TrackParCov trk = isTPCTRD ? mTracksTPC[id].getParamOut() : mTracksITSTPC[id].getParamOut();
71 qcStruct.trackSeed = trk;
72 if (mPID) {
73 qcStruct.dEdxTotTPC = isTPCTRD ? mTracksTPC[id].getdEdx().dEdxTotTPC : mTracksTPC[mTracksITSTPC[id].getRefTPC()].getdEdx().dEdxTotTPC;
74 }
75
76 // find corresponding track trigger record to get track timing
77 int triggeredBC = 0;
78 for (; mCurrentTriggerRecord < (isTPCTRD ? mTrackTriggerRecordsTPCTRD.size() : mTrackTriggerRecordsITSTPCTRD.size()); mCurrentTriggerRecord++) {
79 auto& tRecord = (isTPCTRD ? mTrackTriggerRecordsTPCTRD[mCurrentTriggerRecord] : mTrackTriggerRecordsITSTPCTRD[mCurrentTriggerRecord]);
80 if (mCurrentTrackId >= tRecord.getFirstTrack() && mCurrentTrackId < tRecord.getFirstTrack() + tRecord.getNumberOfTracks()) {
81 triggeredBC = tRecord.getBCData().differenceInBC({0, mFirstOrbit});
82 break;
83 }
84 }
85
86 // Find most probable BCs and RMS for pile-up correction and error. Same BC is assumed for all tracklets
87 float tCorrPileUp = 0.;
88 float tCorrPileUp_weightedMean = 0.;
89 float tErrPileUp2 = 0;
90 float maxProb = 0.f;
91 // The uncertainty is the RMS wrt the default correction of all possible corrections weighted by their probability
92 float sumCorr = 0.f;
93 float sumCorr2 = 0.f;
94 float sumProb = 0.f;
95 for (int iBC = 0; iBC < mTriggeredBCFT0.size(); iBC++) {
96 int deltaBC = roundf(mTriggeredBCFT0[iBC] - triggeredBC);
97 if (deltaBC <= mRecoParam.getPileUpRangeBefore()) {
98 continue;
99 }
100 if (deltaBC >= mRecoParam.getPileUpRangeAfter()) {
101 break;
102 }
103 // collect the charges
104 std::array<int, 6> q0;
105 std::array<int, 6> q1;
106 for (int iLy = 0; iLy < NLAYER; iLy++) {
107 int trkltId = trkTrd.getTrackletIndex(iLy);
108 if (trkltId < 0) {
109 q0[iLy] = -1;
110 q1[iLy] = -1;
111 } else {
112 q0[iLy] = mTrackletsRaw[trkltId].getQ0();
113 q1[iLy] = mTrackletsRaw[trkltId].getQ1();
114 }
115 }
116 // get pile-up probability
117 float probBC = mRecoParam.getPileUpProbTrack(deltaBC, q0, q1);
118 sumCorr += probBC * deltaBC;
119 sumCorr2 += probBC * deltaBC * deltaBC;
120 sumProb += probBC;
121 tCorrPileUp_weightedMean -= probBC * deltaBC;
122 if (probBC > maxProb) {
123 maxProb = probBC;
124 tCorrPileUp = -deltaBC;
125 }
126 }
127 if (sumProb > 1e-6) {
128 tErrPileUp2 = sumCorr2 / sumProb - 2 * tCorrPileUp * sumCorr / sumProb + tCorrPileUp * tCorrPileUp;
129 tCorrPileUp_weightedMean /= sumProb;
130 }
131
132 for (int iLayer = 0; iLayer < NLAYER; ++iLayer) {
133 int trkltId = trkTrd.getTrackletIndex(iLayer);
134 if (trkltId < 0) {
135 continue;
136 }
137 const auto& tracklet = mTrackletsRaw[trkltId];
138 qcStruct.trklt64[iLayer] = tracklet;
139 qcStruct.trkltCalib[iLayer] = mTrackletsCalib[trkltId];
140 int trkltDet = tracklet.getDetector();
141 int trkltSec = trkltDet / (NLAYER * NSTACK);
142 if (trkltSec != o2::math_utils::angle2Sector(trk.getAlpha())) {
143 if (!trk.rotate(o2::math_utils::sector2Angle(trkltSec))) {
144 LOGF(debug, "Track could not be rotated in tracklet coordinate system");
145 break;
146 }
147 }
148 if (!propagator->PropagateToXBxByBz(trk, mTrackletsCalib[trkltId].getX(), mMaxSnp, mMaxStep, mMatCorr)) {
149 LOGF(debug, "Track propagation failed in layer %i (pt=%f, xTrk=%f, xToGo=%f)", iLayer, trk.getPt(), trk.getX(), mTrackletsCalib[trkltId].getX());
150 break;
151 }
152 const PadPlane* pad = Geometry::instance()->getPadPlane(trkltDet);
153 float tilt = tan(TMath::DegToRad() * pad->getTiltingAngle()); // tilt is signed! and returned in degrees
154 float tiltCorrUp = tilt * (mTrackletsCalib[trkltId].getZ() - trk.getZ());
155 float dyTiltCorr = tilt * trk.getTgl() * Geometry::instance()->cdrHght();
156 float zPosCorrUp = mTrackletsCalib[trkltId].getZ() + mRecoParam.getZCorrCoeffNRC() * trk.getTgl();
157 float padLength = pad->getRowSize(tracklet.getPadRow());
158 if (!((trk.getSigmaZ2() < (padLength * padLength / 12.f)) && (std::fabs(mTrackletsCalib[trkltId].getZ() - trk.getZ()) < padLength))) {
159 tiltCorrUp = 0.f;
160 }
161
162 // conversion from slope in pad per time bin to slope in cm per BC = tracklets[trkltIdx].getSlopeFloat() * padWidth / BCperTimeBin
163 float slopeFactor = mTrackletsRaw[trkltId].getSlopeFloat() * pad->getWidthIPad() / 4.f;
164 // float yCorrPileUp = tCorrPileUp * slopeFactor;
165 float yCorrPileUp = tCorrPileUp_weightedMean * slopeFactor;
166 float yAddErrPileUp2 = tErrPileUp2 * slopeFactor * slopeFactor;
167 float yPosCorrUp = mTrackletsCalib[trkltId].getY() - tiltCorrUp + yCorrPileUp;
168
169 float angularPull = (mTrackletsCalib[trkltId].getDy() + dyTiltCorr - mRecoParam.convertAngleToDy(trk.getSnp())) / std::sqrt(mRecoParam.getDyRes(trk.getSnp(), 0));
170 // Correction of y position based on angular pull
171 float corrPull = -angularPull * mRecoParam.getCorrYDy(trk.getSnp());
172 yPosCorrUp += corrPull;
173
174 std::array<float, 2> trkltPosUp{yPosCorrUp, zPosCorrUp};
175 std::array<float, 3> trkltCovUp;
176 mRecoParam.recalcTrkltCov(tilt, trk.getSnp(), pad->getRowSize(tracklet.getPadRow()), trkltCovUp, angularPull, 0);
177 trkltCovUp[0] += yAddErrPileUp2;
178 auto chi2trklt = trk.getPredictedChi2(trkltPosUp, trkltCovUp);
179
180 qcStruct.trackProp[iLayer] = trk;
181 qcStruct.trackletY[iLayer] = trkltPosUp[0];
182 qcStruct.trackletZ[iLayer] = trkltPosUp[1];
183 qcStruct.trackletChi2[iLayer] = chi2trklt;
184
186 // To correct for longer drift lengths in the drfit chamber and hence more energy deposition,
187 // we calculate the variation to reference for the tracklets (exrapolated from the track fit).
188 // \sqrt{ (dx/dx)^2 + (dy/dx)^2 + (dz/dx)^2}
189 auto tphi = trk.getSnp() / std::sqrt((1.f - trk.getSnp()) * (1.f + trk.getSnp()));
190 auto trackletLength = std::sqrt(1.f + tphi * tphi + trk.getTgl() * trk.getTgl());
191 auto cor = mLocalGain.getValue(tracklet.getHCID() / 2, tracklet.getPadCol(false), tracklet.getPadRow()) * trackletLength;
192 float q0{tracklet.getQ0() / cor}, q1{tracklet.getQ1() / cor}, q2{tracklet.getQ2() / cor};
193
194 // z-row merging
195 if (trkTrd.getIsCrossingNeighbor(iLayer) && trkTrd.getHasNeighbor()) {
196 for (const auto& trklt : mTrackletsRaw) {
197 if (tracklet.getTrackletWord() == trklt.getTrackletWord()) { // skip original tracklet
198 continue;
199 }
200 if (std::abs(tracklet.getPadCol(false) - trklt.getPadCol(false)) <= 1 && std::abs(tracklet.getPadRow() - trklt.getPadRow()) == 1) {
201 // Add charge information
202 auto cor = mLocalGain.getValue(trklt.getHCID() / 2, trklt.getPadCol(false), trklt.getPadRow()) * trackletLength;
203 q0 += trklt.getQ0() / cor;
204 q1 += trklt.getQ1() / cor;
205 q2 += trklt.getQ2() / cor;
206 break;
207 }
208 }
209 }
210
211 qcStruct.trackletCorCharges[iLayer] = {q0, q1, q2};
212 }
213 mTrackQC.push_back(qcStruct);
214}
Wrapper container for different reconstructed object types.
Definition of the GeometryManager class.
std::ostringstream debug
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
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 configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in tan(phi) dependence of tracklet error due to radial misalignment(centered at 0 angle)") AddOptionRTC(maxChi2Red
Check the performance of the TRD in global tracking.
GPUd() value_type estimateLTFast(o2 static GPUd() float estimateLTIncrement(const o2 PropagatorImpl * Instance(bool uninitialized=false)
Definition Propagator.h:180
void init(float bz, const GPUSettingsRec *rec=nullptr)
Load parameterization for given magnetic field.
static Geometry * instance()
Definition Geometry.h:33
T getValue(int roc, int col, int row) const
void setInput(const o2::globaltracking::RecoContainer &input)
Initialize the input arrays.
Definition Tracking.cxx:32
void run()
Main processing function.
Definition Tracking.cxx:44
void checkTrack(const TrackTRD &trk, bool isTPCTRD)
Check track QC.
Definition Tracking.cxx:60
void init()
Load geometry and apply magnetic field setting.
Definition Tracking.cxx:27
GLuint id
Definition glcorearb.h:650
int angle2Sector(float phi)
Definition Utils.h:183
float sector2Angle(int sect)
Definition Utils.h:193
TrackParCovF TrackParCov
Definition Track.h:33
gsl::span< const o2::trd::CalibratedTracklet > getTRDCalibratedTracklets() const
gsl::span< const o2::trd::Tracklet64 > getTRDTracklets() const
float dEdxTotTPC
raw total dEdx information for seeding track in TPC
Definition Tracking.h:55
std::array< o2::track::TrackPar, constants::NLAYER > trackProp
the track parameters stored at the radius where the track is updated with TRD info
Definition Tracking.h:57
GTrackID refGlobalTrackId
GlobalTrackID of the seeding track (either ITS-TPC or TPC)
Definition Tracking.h:52
std::array< float, constants::NLAYER > trackletChi2
estimated chi2 for the update of the track with the given tracklet
Definition Tracking.h:63
std::array< CalibratedTracklet, constants::NLAYER > trkltCalib
the TRD space point used for the update (not yet tilt-corrected and z-shift corrected)
Definition Tracking.h:59
TrackTRD trackTRD
the found TRD track
Definition Tracking.h:53
std::array< float, constants::NLAYER > trackletY
y-position of tracklet used for track update (including correction)
Definition Tracking.h:61
std::array< std::array< float, constants::NCHARGES >, constants::NLAYER > trackletCorCharges
corrected charges of tracklets
Definition Tracking.h:64
std::array< Tracklet64, constants::NLAYER > trklt64
the raw tracklet used for the update (includes uncorrected charges)
Definition Tracking.h:58
std::array< float, constants::NLAYER > trackletZ
z-position of tracklet used for track update (including correction)
Definition Tracking.h:62
o2::track::TrackParCov trackSeed
outer param of the seeding track
Definition Tracking.h:54