ATLAS Offline Software
JetTrackFilterTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 
12 
13 #include <TH2.h>
14 #include <TRandom3.h>
15 #include <TFile.h>
16 #include <utility>
17 
18 namespace InDet {
19 
20  static const CP::SystematicSet FilterSystematics =
21  {
25  };
26 
27  JetTrackFilterTool::JetTrackFilterTool(const std::string& name) :
28  InDetTrackSystematicsTool(name),
29  m_trackOriginTool("InDet::InDetTrackTruthOriginTool", this)
30  {
31 
32 #ifndef XAOD_STANDALONE
33  declareInterface<IJetTrackFilterTool>(this);
34 #endif
35 
36  declareProperty("Seed", m_seed, "Seed used to initialize the RNG");
37  declareProperty("DeltaR", m_deltaR, "Delta-R cut in which to apply jet-track efficiency rejection");
38  declareProperty("trkEffSystScale", m_trkEffSystScale, "Option to scale the effect of the systematic (default 1)");
39  declareProperty("FakeUncertainty", m_fakeUncertTIDE, "Option to set the fake uncertainty");
40  declareProperty("FLostUncertainty", m_effUncertTIDE, "Option to set the uncertainty on FLost");
41  declareProperty("calibFileNomEff", m_calibFileNomEff = "InDetTrackSystematicsTools/CalibData_22.0_2022-v00/TrackingRecommendations_prelim_rel22.root");
42  declareProperty("trackOriginTool", m_trackOriginTool);
43  }
44 
46  {
47 
48  m_rnd = std::make_unique<TRandom3>(m_seed);
49 
50  ATH_CHECK( initObject<TH2>( m_trkNomEff,
51  m_calibFileNomEff,
52  "EfficiencyVSEtaPt_AfterRebinningNominal_Loose" ) );
53 
54  ATH_MSG_INFO( "Using for nominal track efficiency the calibration file " << PathResolverFindCalibFile(m_calibFileNomEff) );
55 
56  ATH_CHECK ( m_trackOriginTool.retrieve() );
57 
59 
60  return StatusCode::SUCCESS;
61  }
62 
63 
64  JetTrackFilterTool::~JetTrackFilterTool()
65  {
66  delete m_trkNomEff; m_trkNomEff = nullptr;
67  }
68 
70  {
71 
72  if ( track == nullptr) {
73  ATH_MSG_DEBUG( "Pointer to track is null!" );
74  return false;
75  }
76  if ( jet == nullptr ) {
77  ATH_MSG_DEBUG( "Pointer to jet is null." );
78  return true;
79  }
80 
81  // if the track is outside of the range of this jet, then it is allowed to pass
82  constexpr bool useRapidity = false; // use eta instead of rapidity - the default for this function is true
83  if ( !xAOD::P4Helpers::isInDeltaR( *track, *jet, m_deltaR, useRapidity ) ) return true;
84 
85  if ( isActive( TRK_EFF_LOOSE_TIDE ) ) {
86  // the probability to drop a track scales with the tracking efficiency,
87  // on account of the method used to derive the uncertainties
88  float probDrop = std::fabs(m_trkEffSystScale); // default is one; adjust this parameter to increase / decrease the effect
89  probDrop *= m_effUncertTIDE;
90  probDrop *= getNomTrkEff( track );
91  if ( m_rnd->Uniform(0, 1) < probDrop ) return false;
92  }
93 
94  int origin = m_trackOriginTool->getTrackOrigin(track);
95 
96  if( isActive( TRK_FAKE_RATE_LOOSE_TIDE ) ){
97  if ( InDet::TrkOrigin::isFake(origin) ) {
98  if(m_rnd->Uniform(0, 1) < m_fakeUncertTIDE) return false;
99  }
100  }
101 
102  if( isActive( TRK_FAKE_RATE_TIGHT_TIDE ) ){
103  if ( InDet::TrkOrigin::isFake(origin) ) {
104  ATH_MSG_DEBUG("Track fakes in jets uncertainty (Tight) covered by inclusive (Tight) uncertainty - operating in pass-through mode...");
105  return true;
106  }
107  }
108 
109  return true;
110  }
111 
113  {
114  if ( jets == nullptr ) {
115  ATH_MSG_DEBUG( "Pointer to jet container is null." );
116  return true;
117  }
118  // check that the track passes every jet
119  for ( const auto* jet : *jets ) {
120  if ( !accept( track, jet ) ) return false;
121  }
122  return true;
123  }
124 
125  float JetTrackFilterTool::getNomTrkEff(const xAOD::TrackParticle* track) const
126  {
127  if (m_trkNomEff == nullptr) {
128  ATH_MSG_ERROR( "Nominal track efficiency histogram is not property initialized!" );
129  return 0.;
130  }
131  // this histogram has pt on the x-axis and eta on the y-axis, unlike some other histograms used in this package
132  // make sure to convert to GeV
133  return m_trkNomEff->GetBinContent(std::as_const(m_trkNomEff)->FindBin(track->pt()*1e-3, track->eta()));
134  }
135 
136  bool JetTrackFilterTool::isAffectedBySystematic( const CP::SystematicVariation& syst ) const
137  {
138  return InDetTrackSystematicsTool::isAffectedBySystematic( syst );
139  }
140 
141  CP::SystematicSet JetTrackFilterTool::affectingSystematics() const
142  {
143  return FilterSystematics;
144  }
145 
146  CP::SystematicSet JetTrackFilterTool::recommendedSystematics() const
147  {
148  return InDetTrackSystematicsTool::recommendedSystematics();
149  }
150 
151  StatusCode JetTrackFilterTool::applySystematicVariation( const CP::SystematicSet& systs )
152  {
153  return InDetTrackSystematicsTool::applySystematicVariation(systs);
154  }
155 
156 
157 } // namespace InDet
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAODP4Helpers.h
RootHelpers::FindBin
Int_t FindBin(const TAxis *axis, const double x)
Definition: RootHelpers.cxx:14
InDet
DUMMY Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
initialize
void initialize()
Definition: run_EoverP.cxx:894
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
CP::SystematicVariation
Definition: SystematicVariation.h:47
InDet::TRK_FAKE_RATE_TIGHT_TIDE
@ TRK_FAKE_RATE_TIGHT_TIDE
Definition: InDetTrackSystematics.h:48
InDet::TRK_FAKE_RATE_LOOSE_TIDE
@ TRK_FAKE_RATE_LOOSE_TIDE
Definition: InDetTrackSystematics.h:49
InDet::FilterSystematics
static const CP::SystematicSet FilterSystematics
Definition: InclusiveTrackFilterTool.cxx:11
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDet::TrackSystematicMap
static const std::unordered_map< InDet::TrackSystematic, CP::SystematicVariation, std::hash< int > > TrackSystematicMap
Definition: InDetTrackSystematics.h:56
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
InDet::TrkOrigin::isFake
bool isFake(int origin)
Helper functions.
Definition: InDetTrackTruthOriginDefs.h:43
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
JetTrackFilterTool.h
InDetTrackTruthOriginTool.h
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
InDetTrackTruthOriginDefs.h
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
InDet::TRK_EFF_LOOSE_TIDE
@ TRK_EFF_LOOSE_TIDE
Definition: InDetTrackSystematics.h:46
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
xAOD::P4Helpers::isInDeltaR
bool isInDeltaR(const xAOD::IParticle &p1, const xAOD::IParticle &p2, double dR, bool useRapidity=true)
Check if 2 xAOD::IParticle are in a cone.
Definition: xAODP4Helpers.h:174
TrackParticleContainer.h