16 #include "CLHEP/GenericFunctions/CumulativeChiSquare.hh"
26 const IInterface*
p ) :
35 m_maxTrtFittedRatio(-1),
40 m_selectortool(
"InDet::InDetTrtDriftCircleCutTool", this),
42 m_extrapolator(
"Trk::Extrapolator", this)
44 declareInterface<Trk::ITrackScoringTool>(
this);
111 if (
sc.isFailure())
return sc;
114 if (
sc.isFailure()) {
116 return StatusCode::FAILURE;
127 msg(
MSG::FATAL) <<
"Both on, normal ambi funciton and the one for back tracking, configuration problem, not recoverable" <<
endmsg;
128 return StatusCode::FAILURE;
140 if (nnCutConfigPath.empty()){
142 return StatusCode::FAILURE;
144 ATH_MSG_DEBUG (
"Loading configuration file:" << nnCutConfigPath);
146 std::ifstream
inFile(nnCutConfigPath);
155 return StatusCode::SUCCESS;
162 if (!
track.trackSummary()) {
186 if (numPixelDead<0) numPixelDead = 0;
187 if (numSCTDead<0) numSCTDead = 0;
197 if (ispatterntrack) {
198 ATH_MSG_DEBUG (
"==> this is a pattern track, no hit cuts !");
200 ATH_MSG_DEBUG (
"==> this is a refitted track, so we can use the chi2 and other stuff ! ");
203 if (
track.fitQuality()) {
207 if (numSCTDoubleHoles>=0) {
209 ATH_MSG_DEBUG (
"Track has "<< numSCTDoubleHoles <<
" double holes, reject it!");
236 ATH_MSG_DEBUG (
"Track has " << numTRT <<
" TRT hits, reject it");
241 ATH_MSG_DEBUG (
"Track has " << ((
double)numTRTTube)/numTRT <<
" TRT tube hit fraction, reject it");
245 if ( numSCT>=0 && numPixel>=0) {
247 ATH_MSG_DEBUG (
"Track has " << numPixel+numSCT <<
" Si clusters and " << numPixelDead+numSCTDead <<
" dead sensors, reject it");
253 ATH_MSG_DEBUG (
"Track has " << numPixel <<
" pixel hits, reject it");
263 if (beamSpotHandle.isValid()) beamSpotPosition = beamSpotHandle->beamVtx().position();
270 const EventContext& ctx = Gaudi::Hive::currentContext();
273 if (fieldCondObj ==
nullptr) {
278 fieldCondObj->getInitializedCache (fieldCache);
294 std::unique_ptr<const Trk::TrackParameters> parm(
m_extrapolator->extrapolateDirectly(ctx, *
input, perigeeSurface) );
297 if (!extrapolatedPerigee) {
298 ATH_MSG_WARNING(
"Extrapolation of perigee failed, this should never happen" );
314 if (fabs(extrapolatedPerigee->parameters()[
Trk::d0]) > maxD0) {
315 ATH_MSG_DEBUG (
"Track Rphi impact > "<<maxD0<<
", reject it");
321 if (
track.fitQuality()) {
323 ATH_MSG_DEBUG (
"Rejecting track for falling below nn threshold");
360 if (
track.fitQuality()!=
nullptr &&
track.fitQuality()->chiSquared()>0 &&
track.fitQuality()->numberDoF()>0 ) {
361 double p = 1.0-Genfun::CumulativeChiSquare(
track.fitQuality()->numberDoF())(
track.fitQuality()->chiSquared());
381 double pt = fabs(
track.trackParameters()->front()->pT());
382 double prob = log10(
pt ) - 1.;
398 <<
" New score now: " <<
prob);
412 <<
" New score now: " <<
prob);
423 <<
" New score now: " <<
prob);
444 <<
" New score now: " <<
prob);
456 <<
" New score now: " <<
prob);
467 <<
" New score now: " <<
prob);
478 <<
" New score now: " <<
prob);
492 <<
" New score now: " <<
prob);
503 double nTrtExpected = 30.;
506 ATH_MSG_DEBUG (
"Expected number of TRT hits: " << nTrtExpected <<
" for eta: "
507 << fabs(
track.trackParameters()->front()->eta()));
508 double ratio = (nTrtExpected != 0) ? iTRT_Hits / nTrtExpected : 0;
521 double fitted =
double(iTRT_Hits) /
double(iTRT_Hits + iTRT_Outliers);
539 if (!ispatterntrack) {
540 if (
track.fitQuality()!=
nullptr &&
track.fitQuality()->chiSquared()>0 &&
track.fitQuality()->numberDoF()>0 ) {
541 int indf =
track.fitQuality()->numberDoF();
542 double chi2 =
track.fitQuality()->chiSquared();
543 double fac = 1. / log10 (10. + 10. *
chi2 / indf);
546 <<
" is : "<< fac <<
" New score now: " <<
prob);
555 int ndf =
track.fitQuality()->numberDoF();
556 double chi2 =
track.fitQuality()->chiSquared();
563 if (sigmaChi2times100 > 0) {
564 double testvar =
double(sigmaChi2times100)/100. - sqrt(2.*
chi2/
ndf);
569 <<
" New score now: " <<
prob);
573 <<
" New score now: " <<
prob);
579 <<
" New score now: " <<
prob);
600 const int maxPixHoles = 2;
601 const double goodPixHoles[maxPixHoles+1] = {1.0 , 0.04 , 0.004 };
602 const double fakePixHoles[maxPixHoles+1] = {1.0 , 0.30 , 0.200 };
612 const int maxSCT_Holes = 5;
613 const double goodSCT_Holes[maxSCT_Holes+1] = { 1.0 , 0.06 , 0.010 , 0.0007, 0.0005, 0.0003 };
614 const double fakeSCT_Holes[maxSCT_Holes+1] = { 1.0 , 0.15 , 0.100 , 0.0100, 0.0100, 0.0100 };
620 const int maxSCT_Holes = 6;
621 const double goodSCT_Holes[maxSCT_Holes+1] = {0.910, 0.074, 0.014, 0.001, 0.001, 0.00001, 0.00001};
622 const double fakeSCT_Holes[maxSCT_Holes+1] = {0.910, 0.192, 0.229, 0.061, 0.065, 0.016 , 0.025};
632 const int maxDblHoles = 3;
633 const double goodDblHoles[maxDblHoles+1] = { 1. , 0.03 , 0.007 , 0.0003 };
634 const double fakeDblHoles[maxDblHoles+1] = { 1. , 0.09 , 0.09 , 0.008 };
644 const int maxB_LayerHits = 3;
645 const double goodB_LayerHits[maxB_LayerHits+1] = {0.203, 0.732, 0.081, 0.010};
646 const double fakeB_LayerHits[maxB_LayerHits+1] = {0.808, 0.174, 0.018, 0.002};
652 const int maxB_LayerHits = 3;
653 const double goodB_LayerHits[maxB_LayerHits+1] = {0.605, 0.349, 0.044, 0.010};
654 const double fakeB_LayerHits[maxB_LayerHits+1] = {0.865, 0.124, 0.011, 0.002};
665 const int maxPixelHits = 8;
666 const double goodPixelHits[maxPixelHits+1] = {0.095, 0.031, 0.118, 0.615, 0.137, 0.011, 0.01 , 0.011, 0.012};
667 const double fakePixelHits[maxPixelHits+1] = {0.658, 0.100, 0.091, 0.124, 0.026, 0.002, 0.001 , 0.001, 0.001};
672 const int maxPixelHits = 8;
673 const double goodPixelHits[maxPixelHits+1] = {0.401, 0.079, 0.140, 0.291, 0.011, 0.078, 0.01 , 0.011, 0.012};
674 const double fakePixelHits[maxPixelHits+1] = {0.673, 0.138, 0.113, 0.057, 0.002, 0.011, 0.001 , 0.001, 0.001};
684 const int maxPixLay = 7;
685 const double goodPixLay[maxPixLay+1] = {0.095, 0.033, 0.131, 0.740, 0.840, 0.940, 1.040,1.140};
686 const double fakePixLay[maxPixLay+1] = {0.658, 0.106, 0.092, 0.144, 0.144, 0.144, 0.144,0.144};
692 const int maxPixLay = 7;
693 const double goodPixLay[maxPixLay+1] = {0.401, 0.088, 0.152, 0.355, 0.405, 0.455, 0.505, 0.555};
694 const double fakePixLay[maxPixLay+1] = {0.673, 0.146, 0.115, 0.065, 0.065, 0.065, 0.065, 0.065};
704 const int maxGangedFakes = 2;
705 const double goodGangedFakes[maxGangedFakes+1] = {0.62 , 0.23 , 0.15 };
706 const double fakeGangedFakes[maxGangedFakes+1] = {0.12 , 0.41 , 0.47 };
715 const int maxHits = 19;
716 const double goodSiHits[maxHits+1] = { 0.001 , 0.002 , 0.003 , 0.004 , 0.01 , 0.01 , 0.01 ,
717 0.015 , 0.02 , 0.06 , 0.1 , 0.3 , 0.2 , 0.50 , 0.055,
718 0.03 , 0.015 , 0.010 , 0.002 , 0.0005 };
719 const double fakeSiHits[maxHits+1] = { 1.0 , 1.0 , 1.0 , 1.0 , 0.5 , 0.25 , 0.15 ,
720 0.20 , 0.1 , 0.2 , 0.08 , 0.07 , 0.035 , 0.08 , 0.008,
721 0.004 , 0.0015 , 0.0008 , 0.0001 , 0.00001 };
730 const int maxTrtRatio = 7 ;
731 const double TrtRatioBounds[maxTrtRatio+1] = { 0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 2.4};
733 const double goodTrtRatio[maxTrtRatio] = { 0.05, 0.11, 0.12, 0.15, 0.20, 0.16, 0.17};
734 const double fakeTrtRatio[maxTrtRatio] = { 0.6 , 0.08, 0.06, 0.05, 0.04, 0.03, 0.03};
744 const int maxTrtFittedRatio = 4;
745 const double TrtFittedRatioBounds[maxTrtFittedRatio+1] = { 0, 0.3, 0.6, 0.9, 1.0};
747 const double goodTrtFittedRatio[maxTrtFittedRatio] = { 0.1, 0.2, 0.3, 0.5};
748 const double fakeTrtFittedRatio[maxTrtFittedRatio] = { 0.6, 0.1, 0.1, 0.1};
762 const int maxSigmaChi2 = 13 ;
763 const double SigmaChi2Bounds[maxSigmaChi2+1] = { -5.,-4.,-3.,-2.,-1.,0.,1.,2.,3.,4.,5.,6.,7.,8.};
764 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};
765 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};
826 for (
const auto *tsos : *
track.trackStateOnSurfaces() ) {
828 const auto *meas = tsos->measurementOnTrack();
829 const auto *
tp = tsos->trackParameters();
852 double DNNscore(-1.0);
855 double d0 = extrapolatedPerigee->parameters()[
Trk::d0];
856 double z0 = extrapolatedPerigee->parameters()[
Trk::z0];
862 std::map<std::string, double> trackInputs{
863 {
"pT",
track.trackParameters()->front()->pT()},
864 {
"eta",
track.trackParameters()->front()->eta()},
867 {
"numberDoF", (
double)
track.fitQuality()->numberDoF()},
875 std::map<std::string, std::map<std::string, double> >
inputs{
876 {
"trackInputs", trackInputs}
883 DNNscore =
output[
"nnScore"];