16 #include "CLHEP/GenericFunctions/CumulativeChiSquare.hh"
26 const IInterface*
p ) :
31 declareInterface<Trk::ITrackScoringTool>(
this);
61 if (
sc.isFailure())
return sc;
66 return StatusCode::FAILURE;
77 msg(
MSG::FATAL) <<
"Both on, normal ambi funciton and the one for back tracking, configuration problem, not recoverable" <<
endmsg;
78 return StatusCode::FAILURE;
90 if (nnCutConfigPath.empty()){
92 return StatusCode::FAILURE;
94 ATH_MSG_DEBUG (
"Loading configuration file:" << nnCutConfigPath);
96 std::ifstream
inFile(nnCutConfigPath);
105 return StatusCode::SUCCESS;
117 if (beamSpotHandle.isValid()) beamSpotPosition = beamSpotHandle->beamVtx().position();
124 const EventContext& ctx = Gaudi::Hive::currentContext();
127 if (fieldCondObj ==
nullptr) {
132 fieldCondObj->getInitializedCache (fieldCache);
147 std::unique_ptr<const Trk::TrackParameters> parm(
m_extrapolator->extrapolateDirectly(ctx, *
input, perigeeSurface) );
150 ATH_MSG_WARNING(
"Extrapolation of perigee failed, this should never happen" );
166 if (std::abs(parm->parameters()[
Trk::d0]) > maxD0) {
167 ATH_MSG_DEBUG (
"Track Rphi impact > "<<maxD0<<
", reject it");
182 if (!
track.trackSummary()) {
205 if (numPixelDead<0) numPixelDead = 0;
206 if (numSCTDead<0) numSCTDead = 0;
216 if (ispatterntrack) {
217 ATH_MSG_DEBUG (
"==> this is a pattern track, no hit cuts !");
219 ATH_MSG_DEBUG (
"==> this is a refitted track, so we can use the chi2 and other stuff ! ");
222 if (
track.fitQuality()) {
226 if (numSCTDoubleHoles>=0) {
228 ATH_MSG_DEBUG (
"Track has "<< numSCTDoubleHoles <<
" double holes, reject it!");
255 ATH_MSG_DEBUG (
"Track has " << numTRT <<
" TRT hits, reject it");
260 ATH_MSG_DEBUG (
"Track has " << ((
double)numTRTTube)/numTRT <<
" TRT tube hit fraction, reject it");
264 if ( numSCT>=0 && numPixel>=0) {
266 ATH_MSG_DEBUG (
"Track has " << numPixel+numSCT <<
" Si clusters and " << numPixelDead+numSCTDead <<
" dead sensors, reject it");
272 ATH_MSG_DEBUG (
"Track has " << numPixel <<
" pixel hits, reject it");
279 if (
track.fitQuality()) {
282 if (beamSpotHandle.isValid()) beamSpotPosition = beamSpotHandle->beamVtx().position();
287 const EventContext& ctx = Gaudi::Hive::currentContext();
288 std::unique_ptr<const Trk::TrackParameters> parm(
m_extrapolator->extrapolateDirectly(ctx, *
input, perigeeSurface) );
292 ATH_MSG_DEBUG (
"Rejecting track for falling below nn threshold");
327 if (
track.fitQuality()!=
nullptr &&
track.fitQuality()->chiSquared()>0 &&
track.fitQuality()->numberDoF()>0 ) {
328 double p = 1.0-Genfun::CumulativeChiSquare(
track.fitQuality()->numberDoF())(
track.fitQuality()->chiSquared());
348 double pt = std::abs(
track.trackParameters()->front()->pT());
349 double prob = log10(
pt ) - 1.;
365 <<
" New score now: " <<
prob);
379 <<
" New score now: " <<
prob);
390 <<
" New score now: " <<
prob);
411 <<
" New score now: " <<
prob);
423 <<
" New score now: " <<
prob);
434 <<
" New score now: " <<
prob);
445 <<
" New score now: " <<
prob);
459 <<
" New score now: " <<
prob);
470 double nTrtExpected = 30.;
473 ATH_MSG_DEBUG (
"Expected number of TRT hits: " << nTrtExpected <<
" for eta: "
474 << std::abs(
track.trackParameters()->front()->eta()));
475 double ratio = (nTrtExpected != 0) ? iTRT_Hits / nTrtExpected : 0;
488 double fitted =
double(iTRT_Hits) /
double(iTRT_Hits + iTRT_Outliers);
506 if (!ispatterntrack) {
507 if (
track.fitQuality()!=
nullptr &&
track.fitQuality()->chiSquared()>0 &&
track.fitQuality()->numberDoF()>0 ) {
508 int indf =
track.fitQuality()->numberDoF();
509 double chi2 =
track.fitQuality()->chiSquared();
510 double fac = 1. / log10 (10. + 10. *
chi2 / indf);
513 <<
" is : "<< fac <<
" New score now: " <<
prob);
522 int ndf =
track.fitQuality()->numberDoF();
523 double chi2 =
track.fitQuality()->chiSquared();
530 if (sigmaChi2times100 > 0) {
531 double testvar =
double(sigmaChi2times100)/100. - sqrt(2.*
chi2/
ndf);
536 <<
" New score now: " <<
prob);
540 <<
" New score now: " <<
prob);
546 <<
" New score now: " <<
prob);
567 const int maxPixHoles = 2;
568 const double goodPixHoles[maxPixHoles+1] = {1.0 , 0.04 , 0.004 };
569 const double fakePixHoles[maxPixHoles+1] = {1.0 , 0.30 , 0.200 };
579 const int maxSCT_Holes = 5;
580 const double goodSCT_Holes[maxSCT_Holes+1] = { 1.0 , 0.06 , 0.010 , 0.0007, 0.0005, 0.0003 };
581 const double fakeSCT_Holes[maxSCT_Holes+1] = { 1.0 , 0.15 , 0.100 , 0.0100, 0.0100, 0.0100 };
587 const int maxSCT_Holes = 6;
588 const double goodSCT_Holes[maxSCT_Holes+1] = {0.910, 0.074, 0.014, 0.001, 0.001, 0.00001, 0.00001};
589 const double fakeSCT_Holes[maxSCT_Holes+1] = {0.910, 0.192, 0.229, 0.061, 0.065, 0.016 , 0.025};
599 const int maxDblHoles = 3;
600 const double goodDblHoles[maxDblHoles+1] = { 1. , 0.03 , 0.007 , 0.0003 };
601 const double fakeDblHoles[maxDblHoles+1] = { 1. , 0.09 , 0.09 , 0.008 };
611 const int maxB_LayerHits = 3;
612 const double goodB_LayerHits[maxB_LayerHits+1] = {0.203, 0.732, 0.081, 0.010};
613 const double fakeB_LayerHits[maxB_LayerHits+1] = {0.808, 0.174, 0.018, 0.002};
619 const int maxB_LayerHits = 3;
620 const double goodB_LayerHits[maxB_LayerHits+1] = {0.605, 0.349, 0.044, 0.010};
621 const double fakeB_LayerHits[maxB_LayerHits+1] = {0.865, 0.124, 0.011, 0.002};
632 const int maxPixelHits = 8;
633 const double goodPixelHits[maxPixelHits+1] = {0.095, 0.031, 0.118, 0.615, 0.137, 0.011, 0.01 , 0.011, 0.012};
634 const double fakePixelHits[maxPixelHits+1] = {0.658, 0.100, 0.091, 0.124, 0.026, 0.002, 0.001 , 0.001, 0.001};
639 const int maxPixelHits = 8;
640 const double goodPixelHits[maxPixelHits+1] = {0.401, 0.079, 0.140, 0.291, 0.011, 0.078, 0.01 , 0.011, 0.012};
641 const double fakePixelHits[maxPixelHits+1] = {0.673, 0.138, 0.113, 0.057, 0.002, 0.011, 0.001 , 0.001, 0.001};
651 const int maxPixLay = 7;
652 const double goodPixLay[maxPixLay+1] = {0.095, 0.033, 0.131, 0.740, 0.840, 0.940, 1.040,1.140};
653 const double fakePixLay[maxPixLay+1] = {0.658, 0.106, 0.092, 0.144, 0.144, 0.144, 0.144,0.144};
659 const int maxPixLay = 7;
660 const double goodPixLay[maxPixLay+1] = {0.401, 0.088, 0.152, 0.355, 0.405, 0.455, 0.505, 0.555};
661 const double fakePixLay[maxPixLay+1] = {0.673, 0.146, 0.115, 0.065, 0.065, 0.065, 0.065, 0.065};
671 const int maxGangedFakes = 2;
672 const double goodGangedFakes[maxGangedFakes+1] = {0.62 , 0.23 , 0.15 };
673 const double fakeGangedFakes[maxGangedFakes+1] = {0.12 , 0.41 , 0.47 };
682 const int maxHits = 19;
683 const double goodSiHits[maxHits+1] = { 0.001 , 0.002 , 0.003 , 0.004 , 0.01 , 0.01 , 0.01 ,
684 0.015 , 0.02 , 0.06 , 0.1 , 0.3 , 0.2 , 0.50 , 0.055,
685 0.03 , 0.015 , 0.010 , 0.002 , 0.0005 };
686 const double fakeSiHits[maxHits+1] = { 1.0 , 1.0 , 1.0 , 1.0 , 0.5 , 0.25 , 0.15 ,
687 0.20 , 0.1 , 0.2 , 0.08 , 0.07 , 0.035 , 0.08 , 0.008,
688 0.004 , 0.0015 , 0.0008 , 0.0001 , 0.00001 };
697 const int maxTrtRatio = 7 ;
698 const double TrtRatioBounds[maxTrtRatio+1] = { 0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 2.4};
700 const double goodTrtRatio[maxTrtRatio] = { 0.05, 0.11, 0.12, 0.15, 0.20, 0.16, 0.17};
701 const double fakeTrtRatio[maxTrtRatio] = { 0.6 , 0.08, 0.06, 0.05, 0.04, 0.03, 0.03};
711 const int maxTrtFittedRatio = 4;
712 const double TrtFittedRatioBounds[maxTrtFittedRatio+1] = { 0, 0.3, 0.6, 0.9, 1.0};
714 const double goodTrtFittedRatio[maxTrtFittedRatio] = { 0.1, 0.2, 0.3, 0.5};
715 const double fakeTrtFittedRatio[maxTrtFittedRatio] = { 0.6, 0.1, 0.1, 0.1};
729 const int maxSigmaChi2 = 13 ;
730 const double SigmaChi2Bounds[maxSigmaChi2+1] = { -5.,-4.,-3.,-2.,-1.,0.,1.,2.,3.,4.,5.,6.,7.,8.};
731 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};
732 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};
793 for (
const auto *tsos : *
track.trackStateOnSurfaces() ) {
795 const auto *meas = tsos->measurementOnTrack();
796 const auto *
tp = tsos->trackParameters();
819 double DNNscore(-1.0);
822 double d0 = extrapolatedPerigee->parameters()[
Trk::d0];
823 double z0 = extrapolatedPerigee->parameters()[
Trk::z0];
829 std::map<std::string, double> trackInputs{
830 {
"pT",
track.trackParameters()->front()->pT()},
831 {
"eta",
track.trackParameters()->front()->eta()},
834 {
"numberDoF", (
double)
track.fitQuality()->numberDoF()},
842 std::map<std::string, std::map<std::string, double> >
inputs{
843 {
"trackInputs", trackInputs}
850 DNNscore =
output[
"nnScore"];