ATLAS Offline Software
TrigEgammaFastElectronHypoTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
10 #include <cmath>
11 
12 namespace TCU = TrigCompositeUtils;
13 
15  const std::string& name,
16  const IInterface* parent )
17  : base_class( type, name, parent ),
18  m_decisionId( HLT::Identifier::fromToolName( name ) )
19 {}
20 
21 //==================================================================
22 
23 
25 
26  if ( !m_monTool.empty() ) ATH_CHECK( m_monTool.retrieve() );
27 
28 
29  ATH_MSG_DEBUG( "AcceptAll = " << ( m_acceptAll? "True" : "False" ) );
30  ATH_MSG_DEBUG( "Do_Ringer = " << ( m_doRinger ? "True" : "False" ) );
31  ATH_MSG_DEBUG( "TrackPt = " << m_trackPt );
32  ATH_MSG_DEBUG( "CaloTrackdETA = " << m_caloTrackDEta );
33  ATH_MSG_DEBUG( "CaloTrackdPHI = " << m_caloTrackDPhi );
34  ATH_MSG_DEBUG( "CaloTrackdEoverPLow = " << m_caloTrackdEoverPLow );
35  ATH_MSG_DEBUG( "CaloTrackdEoverPHigh = " << m_caloTrackdEoverPHigh );
36  ATH_MSG_DEBUG( "TRTRatio = " << m_trtRatio );
37  ATH_MSG_DEBUG( "Do_LRT = " << m_doLRT );
38  ATH_MSG_DEBUG( "d0Cut = " << m_d0 );
39 
40  ATH_MSG_DEBUG( "Tool configured for chain/id: " << m_decisionId );
41 
42  ATH_MSG_DEBUG( "Initialization completed successfully:" );
43  return StatusCode::SUCCESS;
44 }
45 
46 //==================================================================
47 
48 StatusCode TrigEgammaFastElectronHypoTool::decide( std::vector<ITrigEgammaFastElectronHypoTool::ElectronInfo>& input) const {
49  for ( auto& i: input ) {
50  if ( TCU::passed ( m_decisionId.numeric(), i.previousDecisionIDs ) ) {
51  if ( decide( i ) ) {
52  TCU::addDecisionID( m_decisionId, i.decision );
53  }
54  }
55  }
56  return StatusCode::SUCCESS;
57 }
58 
59 //==================================================================
60 
62 {
64 }
65 
66 //==================================================================
67 
69 
70 {
71 
72  if ( m_acceptAll ) {
73  ATH_MSG_DEBUG( "AcceptAll property is set: taking all events" );
74  return true;
75  } else {
76  ATH_MSG_DEBUG( "AcceptAll property not set: applying selection" );
77  }
78 
79  auto cutCounter = Monitored::Scalar<int>( "CutCounter", -1 );
80  auto mon_ptCalo = Monitored::Scalar( "PtCalo", -999. );
81  auto mon_ptTrack = Monitored::Scalar( "PtTrack", -999. );
82  auto mon_dEtaCalo = Monitored::Scalar( "CaloTrackdEta", -1. );
83  auto mon_dPhiCalo = Monitored::Scalar( "CaloTrackdPhi", -1. );
84  auto mon_eToverPt = Monitored::Scalar( "CaloTrackEoverP", -1. );
85  auto mon_caloEta = Monitored::Scalar( "CaloEta", -100. );
86  auto mon_caloPhi = Monitored::Scalar( "CaloPhi", -100. );
87  auto mon_trk_d0 = Monitored::Scalar( "d0Value", -1. );
88  auto monitorIt = Monitored::Group( m_monTool,
89  cutCounter,
90  mon_ptCalo, mon_ptTrack,
91  mon_dEtaCalo, mon_dPhiCalo,
92  mon_eToverPt,
93  mon_caloEta, mon_caloPhi, mon_trk_d0);
94 
95  auto electron = input.electron;
96 
97  if(!electron){
98  ATH_MSG_DEBUG("disconsider candidates without electron");
99  return false;
100  }
101 
102  float ptCalo(0), dEtaCalo(0), dPhiCalo(0), eToverPt(0), caloEta(0), caloPhi(0), trk_d0(0);
103 
104  const xAOD::TrackParticle* trkIter = electron->trackParticle();
105 
106  if ( !trkIter ){ // disconsider candidates without track
107  ATH_MSG_DEBUG("disconsider candidates without track");
108  return false;
109  }
110  cutCounter++;
111 
112  // Retrieve all quantities
113  dPhiCalo = electron->trkClusDphi();
114  dEtaCalo = electron->trkClusDeta();
115  ptCalo = electron->pt();
116  eToverPt = electron->etOverPt();
117  caloEta = electron->caloEta();
118  caloPhi = electron->caloPhi();
119  trk_d0 = std::abs(trkIter->d0());
120 
121  float NTRHits = static_cast<float>( electron->nTRTHits() );
122  float NStrawHits = static_cast<float>( electron->nTRTHiThresholdHits() );
123  float TRTHitRatio = NStrawHits == 0 ? 1e10 : NTRHits/NStrawHits;
124 
125  if ( ptCalo < m_trackPt ){
126  ATH_MSG_DEBUG( "Fails pt cut" << ptCalo << " < " << m_trackPt );
127  return false;
128  }
129  mon_ptCalo = ptCalo;
130  mon_ptTrack = m_trackPt;
131  cutCounter++;
132 
133  if ( dEtaCalo > m_caloTrackDEta ) {
134  ATH_MSG_DEBUG( "Fails dEta cut " << dEtaCalo << " < " << m_caloTrackDEta );
135  return false;
136  }
137  mon_dEtaCalo = dEtaCalo;
138  mon_caloEta = caloEta;
139 
140  cutCounter++;
141  if ( dPhiCalo > m_caloTrackDPhi ) {
142  ATH_MSG_DEBUG( "Fails dPhi cut " << dPhiCalo << " < " << m_caloTrackDPhi );
143  return false;
144  }
145 
146  mon_dPhiCalo = dPhiCalo;
147  mon_caloPhi = caloPhi;
148  cutCounter++;
149  if( eToverPt < m_caloTrackdEoverPLow ) {
150  ATH_MSG_DEBUG( "Fails eoverp low cut " << eToverPt << " < " << m_caloTrackdEoverPLow );
151  return false;
152  }
153 
154 
155  cutCounter++;
156  if ( eToverPt > m_caloTrackdEoverPHigh ) {
157  ATH_MSG_DEBUG( "Fails eoverp high cut " << eToverPt << " < " << m_caloTrackdEoverPHigh );
158  return false;
159  }
160  mon_eToverPt = eToverPt;
161 
162  cutCounter++;
163  if ( TRTHitRatio < m_trtRatio ){
164  ATH_MSG_DEBUG( "Fails TRT cut " << TRTHitRatio << " < " << m_trtRatio );
165  return false;
166  }
167 
168 
169  cutCounter++;
170  if(m_doLRT){
171  ATH_MSG_DEBUG( "doLRT: " <<m_doLRT);
172  ATH_MSG_DEBUG( "Track d0: " <<trk_d0);
173 
174  if(trk_d0 < m_d0){
175  ATH_MSG_DEBUG( "Fails d0 cut " <<trk_d0<< " < " <<m_d0 );
176  return false;
177  }
178  }
179  mon_trk_d0 = trk_d0;
180 
181  ATH_MSG_DEBUG( "Passed selection" );
182  return true;
183 
184 }
185 
186 
187 //==================================================================
188 
189 
191 {
192 
193  if ( m_acceptAll ) {
194  ATH_MSG_DEBUG( "AcceptAll property is set: taking all events" );
195  return true;
196  } else {
197  ATH_MSG_DEBUG( "AcceptAll property not set: applying selection" );
198  }
199  auto cutCounter = Monitored::Scalar<int>( "CutCounter", -1 );
200  auto mon_ptCalo = Monitored::Scalar( "PtCalo", -999. );
201  auto mon_ptTrack = Monitored::Scalar( "PtTrack", -999. );
202  auto mon_dEtaCalo = Monitored::Scalar( "CaloTrackdEta", -1. );
203  auto mon_dPhiCalo = Monitored::Scalar( "CaloTrackdPhi", -1. );
204  auto mon_eToverPt = Monitored::Scalar( "CaloTrackEoverP", -1. );
205  auto mon_caloEta = Monitored::Scalar( "CaloEta", -100. );
206  auto mon_caloPhi = Monitored::Scalar( "CaloPhi", -100. );
207  auto mon_trk_d0 = Monitored::Scalar( "d0Value", -1. );
208  auto mon_nnOutput = Monitored::Scalar("NNOutput",-100);
209 
210  auto mon = Monitored::Group( m_monTool,
211  cutCounter,
212  mon_ptCalo,
213  mon_ptTrack,
214  mon_dEtaCalo,
215  mon_dPhiCalo,
216  mon_eToverPt,
217  mon_caloEta,
218  mon_caloPhi,
219  mon_trk_d0,
220  mon_nnOutput);
221 
222  auto el = input.electron;
223 
224  if(!el){
225  return false;
226  }
227 
228  float ptCalo(0), dEtaCalo(0), dPhiCalo(0), eToverPt(0), caloEta(0), caloPhi(0), trk_d0(0), nnOutput(0);
229 
230  cutCounter++;
231 
232  const xAOD::TrackParticle* trk = el->trackParticle();
233  if ( !trk ){
234  ATH_MSG_DEBUG("disconsider candidates without track");
235  return false;
236  }
237  cutCounter++;
238 
239  // Retrieve all quantities
240  dPhiCalo = el->trkClusDphi();
241  dEtaCalo = el->trkClusDeta();
242  ptCalo = el->pt();
243  eToverPt = el->etOverPt();
244  caloEta = el->caloEta();
245  caloPhi = el->caloPhi();
246  trk_d0 = std::abs(trk->d0());
247 
248 
249  if ( ptCalo < m_trackPt ){
250  ATH_MSG_DEBUG( "Fails pt cut" << ptCalo << " < " << m_trackPt );
251  return false;
252  }
253  mon_ptCalo = ptCalo;
254  cutCounter++;
255 
256  auto rings = input.rings;
257  if(!rings){
258  ATH_MSG_DEBUG("disconsider candidates without rings");
259  return false;
260  }
261  cutCounter++;
262 
263  auto clus = input.cluster;
264  if(!clus){
265  ATH_MSG_DEBUG("disconsider candidates without cluster");
266  return false;
267  }
268  cutCounter++;
269 
270 
271  bool pass = false;
272  if( input.pidDecorator.count(m_pidName)){
273  nnOutput = input.valueDecorator.at(m_pidName+"NNOutput");
274  pass = input.pidDecorator.at(m_pidName);
275  ATH_MSG_DEBUG( "Get the decision for " << m_pidName << ": " << (pass?"Yes":"No") );
276  }
277 
278 
279  mon_ptTrack = m_trackPt;
280  mon_dEtaCalo = dEtaCalo;
281  mon_dPhiCalo = dPhiCalo;
282  mon_eToverPt = eToverPt;
283  mon_caloEta = caloEta;
284  mon_caloPhi = caloPhi;
285  mon_trk_d0 = trk_d0;
286  mon_nnOutput = nnOutput;
287 
288 
289  return pass;
290 }
291 
292 
TrigEgammaFastElectronHypoTool::m_pidName
Gaudi::Property< std::string > m_pidName
Definition: TrigEgammaFastElectronHypoTool.h:53
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
TrigCompositeUtils::passed
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
Definition: TrigCompositeUtilsRoot.cxx:117
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
TrigEgammaFastElectronHypoTool::m_acceptAll
Gaudi::Property< bool > m_acceptAll
Definition: TrigEgammaFastElectronHypoTool.h:43
TrigCompositeUtils::addDecisionID
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
Definition: TrigCompositeUtilsRoot.cxx:61
TrigEgammaFastElectronHypoTool::decide_ringer
bool decide_ringer(const ITrigEgammaFastElectronHypoTool::ElectronInfo &i) const
Definition: TrigEgammaFastElectronHypoTool.cxx:190
xAOD::TrackParticle_v1::d0
float d0() const
Returns the parameter.
TrigEgammaFastElectronHypoTool::initialize
virtual StatusCode initialize() override
Definition: TrigEgammaFastElectronHypoTool.cxx:24
TrigEgammaFastElectronHypoTool::m_doLRT
Gaudi::Property< bool > m_doLRT
Definition: TrigEgammaFastElectronHypoTool.h:44
TrigEgammaFastElectronHypoTool::TrigEgammaFastElectronHypoTool
TrigEgammaFastElectronHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TrigEgammaFastElectronHypoTool.cxx:14
TrigEgammaFastElectronHypoTool::m_trtRatio
Gaudi::Property< float > m_trtRatio
Definition: TrigEgammaFastElectronHypoTool.h:51
HLT
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Definition: HLTResultReader.h:26
TrigEgammaFastElectronHypoTool.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
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
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
test_pyathena.parent
parent
Definition: test_pyathena.py:15
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::caloPhi
setRcore setEtHad setFside setPt caloPhi
Definition: TrigPhoton_v1.cxx:111
TrigEgammaFastElectronHypoTool::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: TrigEgammaFastElectronHypoTool.h:54
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
TrigEgammaFastElectronHypoTool::decide_cb
bool decide_cb(const ITrigEgammaFastElectronHypoTool::ElectronInfo &i) const
Definition: TrigEgammaFastElectronHypoTool.cxx:68
TrigEgammaFastElectronHypoTool::decide
virtual StatusCode decide(std::vector< ITrigEgammaFastElectronHypoTool::ElectronInfo > &input) const override
Definition: TrigEgammaFastElectronHypoTool.cxx:48
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TrigEgammaFastElectronHypoTool::m_doRinger
Gaudi::Property< bool > m_doRinger
Definition: TrigEgammaFastElectronHypoTool.h:45
TrigEgammaFastElectronHypoTool::m_caloTrackdEoverPHigh
Gaudi::Property< float > m_caloTrackdEoverPHigh
Definition: TrigEgammaFastElectronHypoTool.h:50
ITrigEgammaFastElectronHypoTool::ElectronInfo
Definition: ITrigEgammaFastElectronHypoTool.h:31
Combinators.h
TrigEgammaFastElectronHypoTool::m_decisionId
HLT::Identifier m_decisionId
Definition: TrigEgammaFastElectronHypoTool.h:41
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
plotBeamSpotMon.mon
mon
Definition: plotBeamSpotMon.py:67
HLTIdentifier.h
TrigEgammaFastElectronHypoTool::m_d0
Gaudi::Property< float > m_d0
Definition: TrigEgammaFastElectronHypoTool.h:52
TrigEgammaFastElectronHypoTool::m_caloTrackDEta
Gaudi::Property< float > m_caloTrackDEta
Definition: TrigEgammaFastElectronHypoTool.h:47
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
TrigEgammaFastElectronHypoTool::m_caloTrackDPhi
Gaudi::Property< float > m_caloTrackDPhi
Definition: TrigEgammaFastElectronHypoTool.h:48
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
TrigEgammaFastElectronHypoTool::m_caloTrackdEoverPLow
Gaudi::Property< float > m_caloTrackdEoverPLow
Definition: TrigEgammaFastElectronHypoTool.h:49
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
TrigEgammaFastElectronHypoTool::m_trackPt
Gaudi::Property< float > m_trackPt
Definition: TrigEgammaFastElectronHypoTool.h:46
Identifier
Definition: IdentifierFieldParser.cxx:14