14 #include "CLHEP/GenericFunctions/CumulativeChiSquare.hh"
24 const IInterface*
p ) :
28 declareInterface<Trk::ITrackScoringTool>(
this);
59 if (
sc.isFailure())
return sc;
64 return StatusCode::FAILURE;
75 msg(
MSG::FATAL) <<
"Both on, normal ambi funciton and the one for back tracking, configuration problem, not recoverable" <<
endmsg;
76 return StatusCode::FAILURE;
88 return StatusCode::SUCCESS;
100 if (beamSpotHandle.isValid()) beamSpotPosition = beamSpotHandle->beamVtx().position();
108 const EventContext& ctx = Gaudi::Hive::currentContext();
111 if (fieldCondObj ==
nullptr) {
116 fieldCondObj->getInitializedCache (fieldCache);
121 if (std::abs(
input->pT()) < minPt) {
135 std::unique_ptr<const Trk::TrackParameters> parm(
m_extrapolator->extrapolateDirectly(ctx,*
input, perigeeSurface) );
138 ATH_MSG_WARNING(
"Extrapolation of perigee failed, this should never happen" );
145 if (std::abs(parm->parameters()[
Trk::z0]) > maxZ0) {
157 if (std::abs(parm->parameters()[
Trk::d0]) > maxD0) {
158 ATH_MSG_DEBUG (
"Track Rphi impact > "<<maxD0<<
", reject it");
174 if (!
track.trackSummary()) {
199 if (numPixelDead<0) numPixelDead = 0;
200 if (numSCTDead<0) numSCTDead = 0;
210 if (ispatterntrack) {
211 ATH_MSG_DEBUG (
"==> this is a pattern track, no hit cuts !");
213 ATH_MSG_DEBUG (
"==> this is a refitted track, so we can use the chi2 and other stuff ! ");
218 if (
track.fitQuality()) {
222 if (numSCTDoubleHoles>=0) {
226 ATH_MSG_DEBUG (
"Track has "<< numSCTDoubleHoles <<
" double holes, reject it!");
259 ATH_MSG_DEBUG (
"Track has " << numTRT <<
" TRT hits, reject it");
264 ATH_MSG_DEBUG (
"Track has " << ((
double)numTRTTube)/numTRT <<
" TRT tube hit fraction, reject it");
268 if ( numSCT>=0 && numPixel>=0) {
271 if (numPixel+numSCT+numPixelDead+numSCTDead < minSiClusters) {
272 ATH_MSG_DEBUG (
"Track has " << numPixel+numSCT <<
" Si clusters and " << numPixelDead+numSCTDead <<
" dead sensors, reject it");
280 if(numPixel < minPixel) {
281 ATH_MSG_DEBUG (
"Track has " << numPixel <<
" pixel hits, reject it");
316 if (
track.fitQuality()!=
nullptr &&
track.fitQuality()->chiSquared()>0 &&
track.fitQuality()->numberDoF()>0 ) {
317 double p = 1.0-Genfun::CumulativeChiSquare(
track.fitQuality()->numberDoF())(
track.fitQuality()->chiSquared());
337 double pt = std::abs(
track.trackParameters()->front()->pT());
338 double prob = log10(
pt ) - 1.;
354 <<
" New score now: " <<
prob);
368 <<
" New score now: " <<
prob);
379 <<
" New score now: " <<
prob);
400 <<
" New score now: " <<
prob);
412 <<
" New score now: " <<
prob);
423 <<
" New score now: " <<
prob);
434 <<
" New score now: " <<
prob);
448 <<
" New score now: " <<
prob);
460 double nTrtExpected = 30.;
463 ATH_MSG_DEBUG (
"Expected number of TRT hits: " << nTrtExpected <<
" for eta: "
464 << std::abs(
track.trackParameters()->front()->eta()));
465 double ratio = (nTrtExpected != 0) ? iTRT_Hits / nTrtExpected : 0;
478 double fitted =
double(iTRT_Hits) /
double(iTRT_Hits + iTRT_Outliers);
497 if (!ispatterntrack) {
498 if (
track.fitQuality()!=
nullptr &&
track.fitQuality()->chiSquared()>0 &&
track.fitQuality()->numberDoF()>0 ) {
499 int indf =
track.fitQuality()->numberDoF();
500 double chi2 =
track.fitQuality()->chiSquared();
501 double fac = 1. / log10 (10. + 10. *
chi2 / indf);
504 <<
" is : "<< fac <<
" New score now: " <<
prob);
513 int ndf =
track.fitQuality()->numberDoF();
514 double chi2 =
track.fitQuality()->chiSquared();
521 if (sigmaChi2times100 > 0) {
522 double testvar =
double(sigmaChi2times100)/100. - sqrt(2.*
chi2/
ndf);
527 <<
" New score now: " <<
prob);
531 <<
" New score now: " <<
prob);
537 <<
" New score now: " <<
prob);
558 const int maxPixHoles = 2;
559 const double goodPixHoles[maxPixHoles+1] = {1.0 , 0.04 , 0.004 };
560 const double fakePixHoles[maxPixHoles+1] = {1.0 , 0.30 , 0.200 };
570 const int maxSCT_Holes = 5;
571 const double goodSCT_Holes[maxSCT_Holes+1] = { 1.0 , 0.06 , 0.010 , 0.0007, 0.0005, 0.0003 };
572 const double fakeSCT_Holes[maxSCT_Holes+1] = { 1.0 , 0.15 , 0.100 , 0.0100, 0.0100, 0.0100 };
578 const int maxSCT_Holes = 6;
579 const double goodSCT_Holes[maxSCT_Holes+1] = {0.910, 0.074, 0.014, 0.001, 0.001, 0.00001, 0.00001};
580 const double fakeSCT_Holes[maxSCT_Holes+1] = {0.910, 0.192, 0.229, 0.061, 0.065, 0.016 , 0.025};
590 const int maxDblHoles = 3;
591 const double goodDblHoles[maxDblHoles+1] = { 1. , 0.03 , 0.007 , 0.0003 };
592 const double fakeDblHoles[maxDblHoles+1] = { 1. , 0.09 , 0.09 , 0.008 };
603 const int maxB_LayerHitsITk = 8;
605 const double blayModi[maxB_LayerHitsITk + 1] = {0.25, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5};
608 const int maxB_LayerHits = 3;
609 const double goodB_LayerHits[maxB_LayerHits+1] = {0.203, 0.732, 0.081, 0.010};
610 const double fakeB_LayerHits[maxB_LayerHits+1] = {0.808, 0.174, 0.018, 0.002};
617 const int maxB_LayerHits = 3;
618 const double goodB_LayerHits[maxB_LayerHits+1] = {0.605, 0.349, 0.044, 0.010};
619 const double fakeB_LayerHits[maxB_LayerHits+1] = {0.865, 0.124, 0.011, 0.002};
631 const int maxPixelHitsITk = 26;
633 double maxScore = 30.0;
634 double minScore = 5.00;
640 (maxScore - minScore) / (maxBarrel - minBarrel), (maxScore - minScore) / (maxPixelHitsITk - minEnd)
643 for (
int i = 0;
i <= maxPixelHitsITk;
i++) {
648 const int maxPixelHits = 8;
649 const double goodPixelHits[maxPixelHits+1] = {0.095, 0.031, 0.118, 0.615, 0.137, 0.011, 0.01 , 0.011, 0.012};
650 const double fakePixelHits[maxPixelHits+1] = {0.658, 0.100, 0.091, 0.124, 0.026, 0.002, 0.001 , 0.001, 0.001};
656 const int maxPixelHits = 8;
657 const double goodPixelHits[maxPixelHits+1] = {0.401, 0.079, 0.140, 0.291, 0.011, 0.078, 0.01 , 0.011, 0.012};
658 const double fakePixelHits[maxPixelHits+1] = {0.673, 0.138, 0.113, 0.057, 0.002, 0.011, 0.001 , 0.001, 0.001};
669 const int maxPixelLayITk = 16;
671 double maxScore = 30.0;
672 double minScore = 5.00;
678 (maxScore - minScore) / (maxBarrel - minBarrel), (maxScore - minScore) / (maxPixelLayITk - minEnd)
681 for (
int i = 0;
i <= maxPixelLayITk;
i++) {
686 const int maxPixLay = 7;
687 const double goodPixLay[maxPixLay+1] = {0.095, 0.033, 0.131, 0.740, 0.840, 0.940, 1.040,1.140};
688 const double fakePixLay[maxPixLay+1] = {0.658, 0.106, 0.092, 0.144, 0.144, 0.144, 0.144,0.144};
695 const int maxPixLay = 7;
696 const double goodPixLay[maxPixLay+1] = {0.401, 0.088, 0.152, 0.355, 0.405, 0.455, 0.505, 0.555};
697 const double fakePixLay[maxPixLay+1] = {0.673, 0.146, 0.115, 0.065, 0.065, 0.065, 0.065, 0.065};
707 const int maxGangedFakes = 2;
708 const double goodGangedFakes[maxGangedFakes+1] = {0.62 , 0.23 , 0.15 };
709 const double fakeGangedFakes[maxGangedFakes+1] = {0.12 , 0.41 , 0.47 };
719 const int maxHitsITk = 26;
721 double maxScore = 40.0;
722 double minScore = 5.00;
728 (maxScore - minScore) / (maxBarrel - minBarrel), (maxScore - minScore) / (maxHitsITk - minEnd)
731 for (
int i = 0;
i <= maxHitsITk;
i++) {
732 if (
i < minEnd)
m_factorHits.push_back(0.01 + (
i * 1.0 / minEnd));
736 const int maxHits = 19;
737 const double goodSiHits[maxHits+1] = { 0.001 , 0.002 , 0.003 , 0.004 , 0.01 , 0.01 , 0.01 ,
738 0.015 , 0.02 , 0.06 , 0.1 , 0.3 , 0.2 , 0.50 , 0.055,
739 0.03 , 0.015 , 0.010 , 0.002 , 0.0005 };
740 const double fakeSiHits[maxHits+1] = { 1.0 , 1.0 , 1.0 , 1.0 , 0.5 , 0.25 , 0.15 ,
741 0.20 , 0.1 , 0.2 , 0.08 , 0.07 , 0.035 , 0.08 , 0.008,
742 0.004 , 0.0015 , 0.0008 , 0.0001 , 0.00001 };
752 const int maxTrtRatio = 7 ;
753 const double TrtRatioBounds[maxTrtRatio+1] = { 0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 2.4};
755 const double goodTrtRatio[maxTrtRatio] = { 0.05, 0.11, 0.12, 0.15, 0.20, 0.16, 0.17};
756 const double fakeTrtRatio[maxTrtRatio] = { 0.6 , 0.08, 0.06, 0.05, 0.04, 0.03, 0.03};
766 const int maxTrtFittedRatio = 4;
767 const double TrtFittedRatioBounds[maxTrtFittedRatio+1] = { 0, 0.3, 0.6, 0.9, 1.0};
769 const double goodTrtFittedRatio[maxTrtFittedRatio] = { 0.1, 0.2, 0.3, 0.5};
770 const double fakeTrtFittedRatio[maxTrtFittedRatio] = { 0.6, 0.1, 0.1, 0.1};
784 const int maxSigmaChi2 = 13 ;
785 const double SigmaChi2Bounds[maxSigmaChi2+1] = { -5.,-4.,-3.,-2.,-1.,0.,1.,2.,3.,4.,5.,6.,7.,8.};
786 const double goodSigmaChi2[maxSigmaChi2] = {0.00004, 0.0004, 0.002, 0.15, 0.8, 0.015, 0.01 , 0.009, 0.008, 0.0007 , 0.0006 , 0.0005, 0.00004};
787 const double fakeSigmaChi2[maxSigmaChi2] = {0.0008 , 0.005 , 0.02 , 0.2 , 0.3, 0.1 , 0.1 , 0.1 , 0.1 , 0.01 , 0.01 , 0.01 , 0.001};
848 for (
const auto *tsos : *
track.trackStateOnSurfaces() ) {
850 const auto *meas = tsos->measurementOnTrack();
851 const auto *
tp = tsos->trackParameters();