Skip to content

Commit c0f724a

Browse files
committed
Use stable lin.ref. point for alignment track initial fit
1 parent a5c604d commit c0f724a

File tree

5 files changed

+75
-39
lines changed

5 files changed

+75
-39
lines changed

Detectors/Align/include/Align/AlignConfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ struct AlignConfig : public o2::conf::ConfigurableParamHelper<AlignConfig> {
8585
float controlFraction = -1.; // fraction for which control output is requested, if negative - only 1st instance of device will write them
8686
float MPRecOutFraction = -1.; // compact Millepede2Record fraction, if negative - only 1st instance of device will write them
8787

88+
bool useLinRef = true; // use initial track for lienarization reference point
8889
bool MilleOut = true; // Mille output
8990
bool KalmanResid = true; // Kalman residuals
9091
bool MilleOutBin = true; // text vs binary output for mille data

Detectors/Align/include/Align/AlignmentTrack.h

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class AlignmentTrack : public trackParam_t, public TObject
3939
{
4040
public:
4141
using trackParam_t = o2::track::TrackParametrizationWithError<double>;
42+
using trackPar_t = o2::track::TrackParametrization<double>;
4243
using PropagatorD = o2::base::PropagatorD;
4344
using MatCorrType = PropagatorD::MatCorrType;
4445
using GTrackID = o2::dataformats::GlobalTrackID;
@@ -83,9 +84,9 @@ class AlignmentTrack : public trackParam_t, public TObject
8384
//
8485
template <typename P>
8586
void copyFrom(const o2::track::TrackParametrizationWithError<P>& trc);
86-
bool propagateToPoint(trackParam_t& tr, const AlignmentPoint* pnt, double maxStep, double maxSnp = 0.95, MatCorrType mt = MatCorrType::USEMatCorrLUT, track::TrackLTIntegral* tLT = nullptr, int signCorr = 0);
87-
bool propagateParamToPoint(trackParam_t& tr, const AlignmentPoint* pnt, double maxStep = 3, double maxSnp = 0.95, MatCorrType mt = MatCorrType::USEMatCorrLUT, int signCorr = 0); // param only
88-
bool propagateParamToPoint(trackParam_t* trSet, int nTr, const AlignmentPoint* pnt, double maxStep = 3, double maxSnp = 0.95, MatCorrType mt = MatCorrType::USEMatCorrLUT, int signCorr = 0); // params only
87+
bool propagateToPoint(trackParam_t& tr, trackPar_t* linRef, const AlignmentPoint* pnt, double maxStep, double maxSnp = 0.95, MatCorrType mt = MatCorrType::USEMatCorrLUT, track::TrackLTIntegral* tLT = nullptr, int signCorr = 0);
88+
bool propagateParamToPoint(trackPar_t& tr, const AlignmentPoint* pnt, double maxStep = 3, double maxSnp = 0.95, MatCorrType mt = MatCorrType::USEMatCorrLUT, int signCorr = 0); // param only
89+
bool propagateParamToPoint(trackPar_t* trSet, int nTr, const AlignmentPoint* pnt, double maxStep = 3, double maxSnp = 0.95, MatCorrType mt = MatCorrType::USEMatCorrLUT, int signCorr = 0); // params only
8990
//
9091
bool calcResiduals(const double* params = nullptr);
9192
bool calcResidDeriv(double* params = nullptr);
@@ -119,23 +120,23 @@ class AlignmentTrack : public trackParam_t, public TObject
119120
void imposePtBOff(double pt) { setQ2Pt(1. / pt); }
120121
// propagation methods
121122
void copyFrom(const trackParam_t* etp);
122-
bool applyMatCorr(trackParam_t& trPar, const double* corrDiag, const AlignmentPoint* pnt);
123-
bool applyMatCorr(trackParam_t* trSet, int ntr, const double* corrDiaf, const AlignmentPoint* pnt);
124-
bool applyMatCorr(trackParam_t& trPar, const double* corrpar);
123+
bool applyMatCorr(trackPar_t& trPar, const double* corrDiag, const AlignmentPoint* pnt);
124+
bool applyMatCorr(trackPar_t* trSet, int ntr, const double* corrDiaf, const AlignmentPoint* pnt);
125+
bool applyMatCorr(trackPar_t& trPar, const double* corrpar);
125126
//
126127
double getResidual(int dim, int pntID) const { return mResid[dim][pntID]; }
127128
const double* getDResDLoc(int dim, int pntID) const { return mDResDLoc[dim].data() + (pntID * mNLocPar); }
128129
const double* getDResDGlo(int dim, int id) const { return mDResDGlo[dim].data() + id; }
129130
const int* getGloParID() const { return mGloParID.data(); }
130131
//
131-
void setParams(trackParam_t& tr, double x, double alp, const double* par, bool add);
132-
void setParams(trackParam_t* trSet, int ntr, double x, double alp, const double* par, bool add);
133-
void setParam(trackParam_t& tr, int par, double val);
134-
void setParam(trackParam_t* trSet, int ntr, int par, double val);
135-
void modParam(trackParam_t& tr, int par, double delta);
136-
void modParam(trackParam_t* trSet, int ntr, int par, double delta);
132+
void setParams(trackPar_t& tr, double x, double alp, const double* par, bool add);
133+
void setParams(trackPar_t* trSet, int ntr, double x, double alp, const double* par, bool add);
134+
void setParam(trackPar_t& tr, int par, double val);
135+
void setParam(trackPar_t* trSet, int ntr, int par, double val);
136+
void modParam(trackPar_t& tr, int par, double delta);
137+
void modParam(trackPar_t* trSet, int ntr, int par, double delta);
137138
//
138-
void richardsonDeriv(const trackParam_t* trSet, const double* delta,
139+
void richardsonDeriv(const trackPar_t* trSet, const double* delta,
139140
const AlignmentPoint* pnt, double& derY, double& derZ);
140141
//
141142
const double* getLocPars() const { return mLocPar.data(); }
@@ -179,13 +180,14 @@ class AlignmentTrack : public trackParam_t, public TObject
179180
std::vector<double> mLocPar; // local parameters array
180181
std::vector<int> mGloParID; // IDs of relevant global params
181182
private:
182-
bool propagate(trackParam_t& tr, const AlignmentPoint* pnt, double maxStep, double maxSnp, MatCorrType mt, track::TrackLTIntegral* tLT, int signCorr = 0);
183+
bool propagate(trackParam_t& tr, trackPar_t* linRef, const AlignmentPoint* pnt, double maxStep, double maxSnp, MatCorrType mt, track::TrackLTIntegral* tLT, int signCorr = 0);
184+
bool propagate(trackPar_t& tr, const AlignmentPoint* pnt, double maxStep, double maxSnp, MatCorrType mt, track::TrackLTIntegral* tLT, int signCorr = 0);
183185
//
184186
ClassDefOverride(AlignmentTrack, 2)
185187
};
186188

187189
//____________________________________________________________________________________________
188-
inline void AlignmentTrack::setParams(trackParam_t& tr, double x, double alp, const double* par, bool add)
190+
inline void AlignmentTrack::setParams(trackPar_t& tr, double x, double alp, const double* par, bool add)
189191
{
190192
// set track params
191193
const double kDefQ2PtCosm = 1;
@@ -205,7 +207,7 @@ inline void AlignmentTrack::setParams(trackParam_t& tr, double x, double alp, co
205207
}
206208

207209
//____________________________________________________________________________________________
208-
inline void AlignmentTrack::setParams(trackParam_t* trSet, int ntr, double x, double alp, const double* par, bool add)
210+
inline void AlignmentTrack::setParams(trackPar_t* trSet, int ntr, double x, double alp, const double* par, bool add)
209211
{
210212
// set parames for multiple tracks (VECTORIZE THIS)
211213
if (!add) { // full parameter supplied
@@ -224,14 +226,14 @@ inline void AlignmentTrack::setParams(trackParam_t* trSet, int ntr, double x, do
224226
}
225227

226228
//____________________________________________________________________________________________
227-
inline void AlignmentTrack::setParam(trackParam_t& tr, int par, double val)
229+
inline void AlignmentTrack::setParam(trackPar_t& tr, int par, double val)
228230
{
229231
// set track parameter
230232
tr.setParam(val, par);
231233
}
232234

233235
//____________________________________________________________________________________________
234-
inline void AlignmentTrack::setParam(trackParam_t* trSet, int ntr, int par, double val)
236+
inline void AlignmentTrack::setParam(trackPar_t* trSet, int ntr, int par, double val)
235237
{
236238
// set parames for multiple tracks (VECTORIZE THIS)
237239
for (int i = 0; i < ntr; ++i) {
@@ -240,15 +242,15 @@ inline void AlignmentTrack::setParam(trackParam_t* trSet, int ntr, int par, doub
240242
}
241243

242244
//____________________________________________________________________________________________
243-
inline void AlignmentTrack::modParam(trackParam_t& tr, int par, double delta)
245+
inline void AlignmentTrack::modParam(trackPar_t& tr, int par, double delta)
244246
{
245247
// modify track parameter
246248
const auto val = tr.getParam(par) + delta;
247249
setParam(tr, par, val);
248250
}
249251

250252
//____________________________________________________________________________________________
251-
inline void AlignmentTrack::modParam(trackParam_t* trSet, int ntr, int par, double delta)
253+
inline void AlignmentTrack::modParam(trackPar_t* trSet, int ntr, int par, double delta)
252254
{
253255
// modify track parameter (VECTORIZE THOS)
254256
for (int i = 0; i < ntr; ++i) {

Detectors/Align/src/AlignmentTrack.cxx

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ bool AlignmentTrack::calcResidDeriv(double* extendedParams, bool invert, int pFr
168168
// (like http://root.cern.ch/root/html/ROOT__Math__RichardsonDerivator.html)
169169
//
170170
const auto& algConf = AlignConfig::Instance();
171-
trackParam_t probD[kNRDClones]; // use this to vary supplied param for derivative calculation
171+
trackPar_t probD[kNRDClones]; // use this to vary supplied param for derivative calculation
172172
double varDelta[kRichardsonN];
173173
const int kInvElem[kNKinParBON] = {-1, 1, 1, -1, -1};
174174
//
@@ -511,7 +511,7 @@ bool AlignmentTrack::calcResiduals(const double* extendedParams, bool invert, in
511511
}
512512

513513
//______________________________________________________
514-
bool AlignmentTrack::propagateParamToPoint(trackParam_t* tr, int nTr, const AlignmentPoint* pnt, double maxStep, double maxSnp, MatCorrType mt, int signCorr)
514+
bool AlignmentTrack::propagateParamToPoint(trackPar_t* tr, int nTr, const AlignmentPoint* pnt, double maxStep, double maxSnp, MatCorrType mt, int signCorr)
515515
{
516516
// Propagate set of tracks to the point (only parameters, no error matrix)
517517
// VECTORIZE this
@@ -521,7 +521,7 @@ bool AlignmentTrack::propagateParamToPoint(trackParam_t* tr, int nTr, const Alig
521521
if (!propagateParamToPoint(tr[itr], pnt, maxStep, maxSnp, mt, signCorr)) {
522522
if (algConf.verbose > 2) {
523523
LOG(error) << "Failed on clone " << itr << " propagation ";
524-
tr[itr].print();
524+
tr[itr].printParam();
525525
pnt->print(AlignmentPoint::kMeasurementBit | AlignmentPoint::kMaterialBit);
526526
}
527527
return false;
@@ -531,21 +531,33 @@ bool AlignmentTrack::propagateParamToPoint(trackParam_t* tr, int nTr, const Alig
531531
}
532532

533533
//______________________________________________________
534-
bool AlignmentTrack::propagateParamToPoint(trackParam_t& tr, const AlignmentPoint* pnt, double maxStep, double maxSnp, MatCorrType mt, int signCorr)
534+
bool AlignmentTrack::propagateParamToPoint(trackPar_t& tr, const AlignmentPoint* pnt, double maxStep, double maxSnp, MatCorrType mt, int signCorr)
535535
{
536536
// propagate tracks to the point (only parameters, no error matrix)
537537
return propagate(tr, pnt, maxStep, maxSnp, mt, nullptr, signCorr);
538538
}
539539

540540
//______________________________________________________
541-
bool AlignmentTrack::propagateToPoint(trackParam_t& tr, const AlignmentPoint* pnt, double maxStep, double maxSnp, MatCorrType mt, track::TrackLTIntegral* tLT, int signCorr)
541+
bool AlignmentTrack::propagateToPoint(trackParam_t& tr, trackPar_t* linRef, const AlignmentPoint* pnt, double maxStep, double maxSnp, MatCorrType mt, track::TrackLTIntegral* tLT, int signCorr)
542542
{
543543
// propagate tracks to the point. If matCor is true, then material corrections will be applied.
544544
// if matPar pointer is provided, it will be filled by total x2x0 and signed xrho
545-
return propagate(tr, pnt, maxStep, maxSnp, mt, tLT, signCorr);
545+
return propagate(tr, linRef, pnt, maxStep, maxSnp, mt, tLT, signCorr);
546546
}
547547

548-
bool AlignmentTrack::propagate(trackParam_t& track, const AlignmentPoint* pnt, double maxStep, double maxSnp, MatCorrType mt, track::TrackLTIntegral* tLT, int signCorr)
548+
bool AlignmentTrack::propagate(trackParam_t& track, trackPar_t* linRef, const AlignmentPoint* pnt, double maxStep, double maxSnp, MatCorrType mt, track::TrackLTIntegral* tLT, int signCorr)
549+
{
550+
if (signCorr == 0) { // auto
551+
// calculate the sign of the energy loss correction and ensure the upper leg of cosmics is calculated correctly.
552+
double dx = pnt->getXTracking() - track.getX();
553+
int dir = dx > 0.f ? 1 : -1;
554+
signCorr = pnt->isInvDir() ? dir : -dir; // propagation along the track direction should have signCorr=-1
555+
}
556+
// do propagation in at least 2 step to reveal eventual effect of MS on the position
557+
return PropagatorD::Instance()->propagateToAlphaX(track, linRef, pnt->getAlphaSens(), pnt->getXTracking(), pnt->getUseBzOnly(), maxSnp, maxStep, 2, mt, tLT, signCorr);
558+
}
559+
560+
bool AlignmentTrack::propagate(trackPar_t& track, const AlignmentPoint* pnt, double maxStep, double maxSnp, MatCorrType mt, track::TrackLTIntegral* tLT, int signCorr)
549561
{
550562
if (signCorr == 0) { // auto
551563
// calculate the sign of the energy loss correction and ensure the upper leg of cosmics is calculated correctly.
@@ -603,7 +615,7 @@ bool AlignmentTrack::ApplyMS(trackParam_t& trPar, double tms,double pms)
603615
*/
604616

605617
//______________________________________________________
606-
bool AlignmentTrack::applyMatCorr(trackParam_t& trPar, const double* corrPar, const AlignmentPoint* pnt)
618+
bool AlignmentTrack::applyMatCorr(trackPar_t& trPar, const double* corrPar, const AlignmentPoint* pnt)
607619
{
608620
// Modify track param (e.g. trackParam_t) in the tracking frame
609621
// by delta accounting for material effects
@@ -630,7 +642,7 @@ bool AlignmentTrack::applyMatCorr(trackParam_t& trPar, const double* corrPar, co
630642
}
631643

632644
//______________________________________________________
633-
bool AlignmentTrack::applyMatCorr(trackParam_t& trPar, const double* corr)
645+
bool AlignmentTrack::applyMatCorr(trackPar_t& trPar, const double* corr)
634646
{
635647
// Modify track param (e.g. trackParam_t) in the tracking frame
636648
// by delta accounting for material effects
@@ -645,7 +657,7 @@ bool AlignmentTrack::applyMatCorr(trackParam_t& trPar, const double* corr)
645657
printf("%+.3e ", corr[i]);
646658
}
647659
printf("\n");
648-
trPar.print();
660+
trPar.printParam();
649661
}
650662
return false;
651663
}
@@ -656,7 +668,7 @@ bool AlignmentTrack::applyMatCorr(trackParam_t& trPar, const double* corr)
656668
}
657669

658670
//______________________________________________________
659-
bool AlignmentTrack::applyMatCorr(trackParam_t* trSet, int ntr, const double* corrDiag, const AlignmentPoint* pnt)
671+
bool AlignmentTrack::applyMatCorr(trackPar_t* trSet, int ntr, const double* corrDiag, const AlignmentPoint* pnt)
660672
{
661673
// Modify set of track params (e.g. trackParam_t) in the tracking frame
662674
// by delta accounting for material effects
@@ -683,7 +695,7 @@ bool AlignmentTrack::applyMatCorr(trackParam_t* trSet, int ntr, const double* co
683695
if (!applyMatCorr(trSet[itr], corr)) {
684696
if (algConf.verbose > 2) {
685697
LOGP(error, "Failed on clone {} materials", itr);
686-
trSet[itr].print();
698+
trSet[itr].printParam();
687699
}
688700
return false;
689701
}
@@ -732,7 +744,7 @@ double AlignmentTrack::richardsonExtrap(const double* val, int ord)
732744
}
733745

734746
//______________________________________________
735-
void AlignmentTrack::richardsonDeriv(const trackParam_t* trSet, const double* delta, const AlignmentPoint* pnt, double& derY, double& derZ)
747+
void AlignmentTrack::richardsonDeriv(const trackPar_t* trSet, const double* delta, const AlignmentPoint* pnt, double& derY, double& derZ)
736748
{
737749
// Calculate Richardson derivatives for diagonalized Y and Z from a set of kRichardsonN pairs
738750
// of tracks with same parameter of i-th pair varied by +-delta[i]
@@ -882,7 +894,7 @@ bool AlignmentTrack::iniFit()
882894
//
883895
// propagate to reference point, which is the inner point of lower leg
884896
const AlignmentPoint* refP = getPoint(getInnerPointID());
885-
if (!propagateToPoint(trcU, refP, algConf.maxStep, algConf.maxSnp, MatCorrType(algConf.matCorType), nullptr, -1)) { // moving along the track: energy is lost
897+
if (!propagateToPoint(trcU, nullptr, refP, algConf.maxStep, algConf.maxSnp, MatCorrType(algConf.matCorType), nullptr, -1)) { // moving along the track: energy is lost
886898
return false;
887899
}
888900
//
@@ -1024,6 +1036,7 @@ bool AlignmentTrack::fitLeg(trackParam_t& trc, int pFrom, int pTo, bool& inv)
10241036
}
10251037
return false;
10261038
}
1039+
trackPar_t linRef(trc), *linRefP = algConf.useLinRef ? &linRef : nullptr;
10271040
trc.setCov(kIniErr);
10281041
trc.setCov(16 * trc.getQ2Pt() * trc.getQ2Pt(), 4, 4); // lowest diagonal element (Q2Pt2)
10291042
//
@@ -1042,7 +1055,7 @@ bool AlignmentTrack::fitLeg(trackParam_t& trc, int pFrom, int pTo, bool& inv)
10421055
int pntCnt = 0;
10431056
for (int ip = pFrom; ip != pTo; ip += pinc) { // inward fit from outer point
10441057
AlignmentPoint* pnt = getPoint(ip);
1045-
if (!propagateToPoint(trc, pnt, algConf.maxStep, algConf.maxSnp, MatCorrType(algConf.matCorType), nullptr, signELoss)) { // against track direction : e.loss is compensated
1058+
if (!propagateToPoint(trc, linRefP, pnt, algConf.maxStep, algConf.maxSnp, MatCorrType(algConf.matCorType), nullptr, signELoss)) { // against track direction : e.loss is compensated
10461059
if (algConf.verbose > 2) {
10471060
LOGF(warn, "Failed on propagateToPoint %d (%d : %d) %f", ip, pFrom, pTo, pnt->getXTracking());
10481061
trc.print();
@@ -1139,7 +1152,7 @@ bool AlignmentTrack::residKalman()
11391152
trc.invert();
11401153
inv = !inv;
11411154
}
1142-
if (!propagateToPoint(trc, pnt, algConf.maxStep, algConf.maxSnp, MatCorrType(algConf.matCorType), nullptr, signELoss)) {
1155+
if (!propagateToPoint(trc, nullptr, pnt, algConf.maxStep, algConf.maxSnp, MatCorrType(algConf.matCorType), nullptr, signELoss)) {
11431156
return false;
11441157
}
11451158
if (!pnt->containsMeasurement()) {
@@ -1178,7 +1191,7 @@ bool AlignmentTrack::residKalman()
11781191
trc.invert();
11791192
inv = !inv;
11801193
}
1181-
if (!propagateToPoint(trc, pnt, algConf.maxStep, algConf.maxSnp, MatCorrType(algConf.matCorType), nullptr, signELoss)) { // we are going along track direction, e.loss is applied
1194+
if (!propagateToPoint(trc, nullptr, pnt, algConf.maxStep, algConf.maxSnp, MatCorrType(algConf.matCorType), nullptr, signELoss)) { // we are going along track direction, e.loss is applied
11821195
return false;
11831196
}
11841197
if (!pnt->containsMeasurement()) {
@@ -1335,7 +1348,7 @@ bool AlignmentTrack::processMaterials(trackParam_t& trc, int pFrom, int pTo)
13351348
//
13361349
matTL.clearFast();
13371350
// printf("-> ProcMat %d (%d->%d)\n",ip,pFrom,pTo);
1338-
if (!propagateToPoint(trc, pnt, algConf.maxStep, algConf.maxSnp, MatCorrType(algConf.matCorType), &matTL, signELoss)) { // with material corrections
1351+
if (!propagateToPoint(trc, nullptr, pnt, algConf.maxStep, algConf.maxSnp, MatCorrType(algConf.matCorType), &matTL, signELoss)) { // with material corrections
13391352
if (algConf.verbose > 2) {
13401353
LOG(error) << "Failed to take track to point" << ip << " (dir: " << pFrom << "->" << pTo << ") with mat.corr.";
13411354
trc.print();
@@ -1346,7 +1359,7 @@ bool AlignmentTrack::processMaterials(trackParam_t& trc, int pFrom, int pTo)
13461359
//
13471360
// is there enough material to consider the point as a scatterer?
13481361
bool hasMaterial = matTL.getX2X0() > minX2X0;
1349-
if (!propagateToPoint(tr0, pnt, algConf.maxStep, algConf.maxSnp, MatCorrType::USEMatCorrNONE, nullptr, signELoss)) { // no material corrections
1362+
if (!propagateToPoint(tr0, nullptr, pnt, algConf.maxStep, algConf.maxSnp, MatCorrType::USEMatCorrNONE, nullptr, signELoss)) { // no material corrections
13501363
if (algConf.verbose > 2) {
13511364
LOG(error) << "Failed to take track to point" << ip << " (dir: " << pFrom << "->" << pTo << ") with mat.corr.";
13521365
tr0.print();

Detectors/Base/include/DetectorsBase/Propagator.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ class PropagatorImpl
127127
GPUd() bool propagateToAlphaX(track_T& track, value_type alpha, value_type x, bool bzOnly = false, value_type maxSnp = MAX_SIN_PHI, value_type maxStep = MAX_STEP, int minSteps = 1,
128128
MatCorrType matCorr = MatCorrType::USEMatCorrLUT, track::TrackLTIntegral* tofInfo = nullptr, int signCorr = 0) const;
129129

130+
GPUd() bool propagateToAlphaX(TrackParCov_t& track, TrackPar_t* linRef, value_type alpha, value_type x, bool bzOnly = false, value_type maxSnp = MAX_SIN_PHI, value_type maxStep = MAX_STEP, int minSteps = 1,
131+
MatCorrType matCorr = MatCorrType::USEMatCorrLUT, track::TrackLTIntegral* tofInfo = nullptr, int signCorr = 0) const;
132+
130133
template <typename track_T>
131134
GPUd() bool propagateToR(track_T& track, value_type r, bool bzOnly = false, value_type maxSnp = MAX_SIN_PHI, value_type maxStep = MAX_STEP,
132135
MatCorrType matCorr = MatCorrType::USEMatCorrLUT, track::TrackLTIntegral* tofInfo = nullptr, int signCorr = 0) const;

0 commit comments

Comments
 (0)