ATLAS Offline Software
Loading...
Searching...
No Matches
InDet::TRT_ElectronPidToolRun2 Class Reference

TRT_ElectronPidToolRun2 is a tool for identification of electrons based on information mainly from the TRT and partially from the whole ID. More...

#include <TRT_ElectronPidToolRun2.h>

Inheritance diagram for InDet::TRT_ElectronPidToolRun2:
Collaboration diagram for InDet::TRT_ElectronPidToolRun2:

Public Member Functions

 TRT_ElectronPidToolRun2 (const std::string &, const std::string &, const IInterface *)
virtual ~TRT_ElectronPidToolRun2 ()
 default destructor
virtual StatusCode initialize () override
 standard Athena-Algorithm method
virtual StatusCode finalize () override
 standard Athena-Algorithm method
virtual std::vector< float > electronProbability (const EventContext &ctx, const Trk::Track &track) const override final
 Electron probabilities to be returned.
virtual double probHT (const double pTrk, const Trk::ParticleHypothesis hypothesis, const int HitPart, const int Layer, const int Strawlayer) const override final
 return high threshold probability
virtual double probHTRun2 (const EventContext &ctx, float pTrk, Trk::ParticleHypothesis hypothesis, int TrtPart, int GasType, int StrawLayer, float ZR, float rTrkWire, float Occupancy) const override final
 DeclareInterfaceID (ITRT_ElectronPidTool, 1, 0)
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static std::vector< float > electronProbability_old (const Trk::Track &track)
 Electron probabilities to be returned.
static const InterfaceID & interfaceID ()
 AlgTool interface methods.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

bool CheckGeometry (int BEC, int Layer, int Strawlayer) const
double sqr (double a)
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

const TRT_IDm_trtId {nullptr}
UnsignedIntegerProperty m_minTRThits
FloatProperty m_ptMinNN
BooleanProperty m_calculateNN
ToolHandle< ITRT_ToT_dEdxm_TRTdEdxTool
ToolHandle< InDet::ITRT_LocalOccupancym_LocalOccTool
ToolHandle< ITRT_StrawStatusSummaryToolm_TRTStrawSummaryTool
SG::ReadCondHandleKey< HTcalculatorm_HTReadKey
SG::ReadCondHandleKey< InDet::TRTPIDNNm_TRTPIDNNReadKey
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

TRT_ElectronPidToolRun2 is a tool for identification of electrons based on information mainly from the TRT and partially from the whole ID.

Given a track, multiple quantities are calculated (see also TrkTrackSummary/TrackSummary.h):

1: eProbabilityComb - combined probability from High Threshold (HT) and Time-over- Threshold (ToT) information (see below).

2: eProbabilityHT - likelihood calculated using High Threshold (HT) information. Sensitive to Transition Radiation (TR) photons emitted by electrons, when traversing the TRT radiator material between the straws. Electrons start to emit TR at 500 MeV, but only fully at 5 GeV.

3: eProbabilityToT - likelihood calculated using Time-over-Threshold (ToT) information. Sensitive to (increased) ionization by electrons compared to heavier particles (eg. pions, protons, etc.). ToT is computed only for straws without a HT hit (to avoid correlations). The separation is largest at low momentum, and deminishes with increased energy.

4: eProbabilityBrem - Electron probability from Brem fitting (DNA).

5: eProbabilityNN - neural network that combines HT, ToT and other hit- and track-level properties into a combined classifier.

6: TRTTrackOccupancy - fraction of TRT straws that fired in the modules that are traversed by the track.

7: TRTdEdx - calibrated dE/dx measurement from all TRT hits along the track (see TRT_ToT_dEdx.h).

8: eProbabilityNumberOfTRTHitsUsedFordEdx - number of good TRT hits that entered the dE/dx calculation.

Definition at line 88 of file TRT_ElectronPidToolRun2.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TRT_ElectronPidToolRun2()

InDet::TRT_ElectronPidToolRun2::TRT_ElectronPidToolRun2 ( const std::string & t,
const std::string & n,
const IInterface * p )

Definition at line 67 of file TRT_ElectronPidToolRun2.cxx.

68 :
69 AthAlgTool(t,n,p)
70{
71 declareInterface<ITRT_ElectronPidTool>(this);
72 declareInterface<ITRT_ElectronToTTool>(this);
73}
AthAlgTool()
Default constructor:

◆ ~TRT_ElectronPidToolRun2()

InDet::TRT_ElectronPidToolRun2::~TRT_ElectronPidToolRun2 ( )
virtualdefault

default destructor

Member Function Documentation

◆ CheckGeometry()

bool InDet::TRT_ElectronPidToolRun2::CheckGeometry ( int BEC,
int Layer,
int Strawlayer ) const
private

Definition at line 556 of file TRT_ElectronPidToolRun2.cxx.

556 {
557
558 //first check that the BEC is valid:
559 if( BEC!=-2 && BEC !=-1 && BEC!=1 && BEC!=2){
560 ATH_MSG_ERROR("Found a wrong TRT part: "<<BEC<<" expected one of (-2,-1,1,2)");
561 return false;
562 }
563 const int part = abs(BEC)-1;
564
565 //next check that the layer is valid
566 if( Layer < 0){
567 ATH_MSG_ERROR("Found a negative TRT Layer");
568 return false; //must be positive
569 }
570
571 static const int nlayers[2]={3,14};
572
573 if( not ( Layer < nlayers[part] ) ){
574 ATH_MSG_ERROR("Found TRT Layer index "<<Layer<<" in part "<<BEC<<" but part only has "<<nlayers[part]<<" layers.");
575 return false;
576 }
577
578 //and finally check that the StrawLayer is valid:
579 if( StrawLayer < 0){
580 ATH_MSG_ERROR("Found a negative TRT StrawLayer");
581 return false; //must be positive
582 }
583
584 static const int strawsPerBEC[2][14]={{19,24,30, 0, 0, 0,0,0,0,0,0,0,0,0},
585 {16,16,16,16,16,16,8,8,8,8,8,8,8,8}};
586
587 if(not(StrawLayer < strawsPerBEC[part][Layer])){
588 ATH_MSG_ERROR("TRT part " << BEC << " Layer " << Layer << " only has "
589 << strawsPerBEC[part][Layer]
590 << " straws. Found index " << StrawLayer);
591 return false;
592 }
593
594 return true;
595}
#define ATH_MSG_ERROR(x)

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ DeclareInterfaceID()

Trk::ITRT_ElectronPidTool::DeclareInterfaceID ( ITRT_ElectronPidTool ,
1 ,
0  )
inherited

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ electronProbability()

std::vector< float > InDet::TRT_ElectronPidToolRun2::electronProbability ( const EventContext & ctx,
const Trk::Track & track ) const
finaloverridevirtual

Electron probabilities to be returned.

Implements Trk::ITRT_ElectronPidTool.

Definition at line 135 of file TRT_ElectronPidToolRun2.cxx.

138{
139
140 // Get the probability calculator
141 SG::ReadCondHandle<HTcalculator> readHandle{m_HTReadKey,ctx};
142 const HTcalculator* HTcalc = (*readHandle);
143 // make sure some calibration is available
144 if(HTcalc==nullptr) {
145 ATH_MSG_WARNING (" No Pid calibration from the DB.");
146 return {};
147 }
148
149 // Get the PID NN
150 const InDet::TRTPIDNN* PIDNN = nullptr;
151 if (m_calculateNN) {
152 SG::ReadCondHandle<InDet::TRTPIDNN> readHandlePIDNN{m_TRTPIDNNReadKey,ctx};
153 PIDNN = (*readHandlePIDNN);
154 // make sure some calibration is available
155 if(PIDNN==nullptr) {
156 ATH_MSG_WARNING (" No PID NN available from the DB.");
157 return {};
158 }
159 }
160
161 // Initialize the vector with default PID values
162 std::vector<float> PIDvalues = Trk::eProbabilityDefault;
163
164 // Check for perigee:
165 const Trk::TrackParameters* perigee = track.perigeeParameters();
166 if (!perigee) return PIDvalues;
167
168 // Get parameters at perigee and check that they are reasonable:
169 const AmgVector(Trk::TrackParameters::dim)& parameterVector = perigee->parameters();
170 double qOverP = parameterVector[Trk::qOverP];
171 double theta = parameterVector[Trk::theta];
172 double phi = parameterVector[Trk::phi];
173
174 // Check the parameters are reasonable:
175 if (tan(theta/2.0) < 0.0001) {
176 ATH_MSG_DEBUG(" Track has negative theta or is VERY close to beampipe! "
177 "(tan(theta/2) < 0.0001). Returning default Pid values.");
178 return PIDvalues;
179 }
180
181 if (qOverP == 0.0) {
182 ATH_MSG_DEBUG (" Track momentum infinite! (i.e. q/p = 0). Returning default Pid values.");
183 return PIDvalues;
184 }
185
186 double pTrk = fabs(1.0 / qOverP);
187 double pT = pTrk * sin(theta);
188 double eta = -log(tan(theta/2.0));
189
190 // Check the tool to get the local occupancy (i.e. for the track in question):
191 PIDvalues[Trk::TRTTrackOccupancy] = m_LocalOccTool->LocalOccupancy(ctx,track);
192
193 if (PIDvalues[Trk::TRTTrackOccupancy] > 1.0 || PIDvalues[Trk::TRTTrackOccupancy] < 0.0) {
194 ATH_MSG_WARNING(" Occupancy was outside allowed range! Returning default Pid values. Occupancy = "
195 << PIDvalues[Trk::TRTTrackOccupancy] );
196 return PIDvalues;
197 }
198
199 ATH_MSG_DEBUG ("");
200 ATH_MSG_DEBUG ("");
201 ATH_MSG_DEBUG ("check---------------------------------------------------------------------------------------");
202 ATH_MSG_DEBUG ("check Got track: pT: " << pT << " eta: " << eta << " phi: " << phi);
203 ATH_MSG_DEBUG ("check---------------------------------------------------------------------------------------");
204
205 // For calculation of HT probability:
206 double pHTel_prod = 1.0;
207 double pHTpi_prod = 1.0;
208
209 // ------------------------------------------------------------------------------------
210 // Loop over TRT hits on track, and calculate HT and R-ToT probability:
211 // ------------------------------------------------------------------------------------
212
213 std::vector<double> hit_HTMB;
214 std::vector<double> hit_gasType;
215 std::vector<double> hit_tot;
216 std::vector<double> hit_L;
217 std::vector<double> hit_rTrkWire;
218 std::vector<double> hit_HitZ;
219 std::vector<double> hit_HitR;
220 std::vector<double> hit_isPrec;
221
222 unsigned int nTRThits = 0;
223 unsigned int nTRThitsHTMB = 0;
224 unsigned int nXehits = 0;
225 unsigned int nArhits = 0;
226 unsigned int nPrecHits = 0;
227
228
229 // Check for track states:
230 const Trk::TrackStates* recoTrackStates = track.trackStateOnSurfaces();
231 if (not recoTrackStates) {
232 ATH_MSG_DEBUG("track.trackStateOnSurfaces() was zero");
233 //m_timingProfile->chronoStop("Tool::electronProb");
234 return PIDvalues;
235 }
236
237 Trk::TrackStates::const_iterator tsosIter = recoTrackStates->begin();
238 Trk::TrackStates::const_iterator tsosIterEnd = recoTrackStates->end();
239
240 // Loop over track states on surfaces (i.e. generalized hits):
241 for ( ; tsosIter != tsosIterEnd; ++tsosIter) {
242
243 const Trk::MeasurementBase *measurement = (*tsosIter)->measurementOnTrack();
244 if (!measurement) continue;
245
246 // Get drift circle (ensures that hit is from TRT):
247 // use the type methods to avoid dynamic_cast in a loop
248 const InDet::TRT_DriftCircleOnTrack* driftcircle = nullptr;
250 const Trk::RIO_OnTrack* tmpRio =
251 static_cast<const Trk::RIO_OnTrack*>(measurement);
253 driftcircle = static_cast<const InDet::TRT_DriftCircleOnTrack*>(tmpRio);
254 }
255 }
256
257 if (!driftcircle) continue;
258
259 // From now (May 2015) onwards, we ONLY USE MIDDLE HT BIT:
260 bool isHTMB = (driftcircle->prepRawData()->getWord() & 0x00020000) > 0;
261
262 nTRThits++;
263 if (isHTMB) nTRThitsHTMB++;
264 hit_HTMB.push_back(static_cast<double>(isHTMB));
265
266
267 // ------------------------------------------------------------------------------------
268 // Get the necessary input for the probability calculations:
269 // ------------------------------------------------------------------------------------
270 Identifier DCid = driftcircle->identify();
271
272 // Part of TRT hit belongs to (TrtPart = 0: Barrel, 1: EndcapA, 2: EndcapB).
273 int TrtPart = 0; // 0: Barrel, 1: EndcapA, 2: EndcapB
274 if (abs(m_trtId->barrel_ec(DCid)) == 2)
275 TrtPart = (m_trtId->layer_or_wheel(DCid) < 6) ? 1 : 2;
276
277 // Get Straw Layer (Barrel: 0-72, EndcapA: 0-95 (16 layers in 6 modules), EndcapB: 0-63 (8 layers in 8 modules)):
278 int StrawLayer = 0;
279 if (TrtPart == 0) {
280 // Barrel:
281 if (m_trtId->layer_or_wheel(DCid) == 0) {
282 StrawLayer = m_trtId->straw_layer(DCid);
283 } else if (m_trtId->layer_or_wheel(DCid) == 1) {
284 StrawLayer = 19 + m_trtId->straw_layer(DCid);
285 } else {
286 StrawLayer = 19 + 24 + m_trtId->straw_layer(DCid);
287 }
288 } else {
289 // Endcap:
290 if (m_trtId->layer_or_wheel(DCid) < 6) {
291 StrawLayer =
292 16 * m_trtId->layer_or_wheel(DCid) + m_trtId->straw_layer(DCid);
293 } else {
294 StrawLayer =
295 8 * (m_trtId->layer_or_wheel(DCid) - 6) + m_trtId->straw_layer(DCid);
296 }
297 }
298
299 // Get Z (Barrel) or R (Endcap) location of the hit, and distance from track to wire (i.e. anode) in straw:
300 double HitZ = 0.;
301 double HitR = 0.;
302 double rTrkWire = 0.;
303 bool hasTrackParameters = true; // Keep track of this for HT prob calculation
304 if ((*tsosIter)->trackParameters()) {
305 // If we have precise information (from hit), get that:
306 const Amg::Vector3D& gp = driftcircle->globalPosition();
307 HitR = gp.perp();
308 HitZ = gp.z();
309 rTrkWire = fabs((*tsosIter)->trackParameters()->parameters()[Trk::driftRadius]);
310 if (rTrkWire > 2.2) rTrkWire = 2.175; // cut off track-to-wire distance for outliers
311 } else {
312 // Otherwise just use the straw coordinates:
313 hasTrackParameters = false; // Jared - pass this to HT calculation
314 HitZ = driftcircle->associatedSurface().center().z();
315 HitR = driftcircle->associatedSurface().center().perp();
316 rTrkWire = 0;
317 }
318
319 // fill vectors for NN PID
320 if (m_calculateNN and pT >= m_ptMinNN) {
321 hit_HitZ.push_back(HitZ);
322 hit_HitR.push_back(HitR);
323 hit_rTrkWire.push_back(rTrkWire);
324 hit_L.push_back(TRT_ToT_dEdx::calculateTrackLengthInStraw((*tsosIter), m_trtId));
325 hit_tot.push_back(driftcircle->timeOverThreshold());
326 }
327
328 // ------------------------------------------------------------------------------------
329 // Collection and checks of input variables for HT probability calculation:
330 // ------------------------------------------------------------------------------------
331
332 int SL_max[3] = {73, 96, 64};
333 if (StrawLayer > SL_max[TrtPart] || StrawLayer < 0) {
334 ATH_MSG_WARNING(" StrawLayer was outside allowed range! TrtPart = " << TrtPart << " SL = " << StrawLayer);
335 continue;
336 }
337
338 double ZRpos[3] = {fabs(HitZ), HitR, HitR};
339 double ZRpos_min[3] = { 0.0, 630.0, 630.0};
340 double ZRpos_max[3] = {720.0, 1030.0, 1030.0};
341 if (ZRpos[TrtPart] > ZRpos_max[TrtPart]) {
342 ATH_MSG_WARNING(" ZRpos was above allowed range - adjusted! TrtPart = " << TrtPart << " ZRpos = " << ZRpos[TrtPart]);
343 ZRpos[TrtPart] = ZRpos_max[TrtPart] - 0.001;
344 }
345 if (ZRpos[TrtPart] < ZRpos_min[TrtPart]) {
346 ATH_MSG_WARNING(" ZRpos was below allowed range - adjusted! TrtPart = " << TrtPart << " ZRpos = " << ZRpos[TrtPart]);
347 ZRpos[TrtPart] = ZRpos_min[TrtPart] + 0.001;
348 }
349
350 // ------------------------------------------------------------------------------------
351 // Calculate the HT probability:
352 // ------------------------------------------------------------------------------------
353
354 // getStatusHT returns enum {Undefined, Dead, Good, Xenon, Argon, Krypton, EmulatedArgon, EmulatedKrypton}.
355 // Our representation of 'GasType' is 0:Xenon, 1:Argon, 2:Krypton
356 int GasType=0; // Xenon is default
357 if (!m_TRTStrawSummaryTool.empty()) {
358 int stat = m_TRTStrawSummaryTool->getStatusHT(DCid,ctx);
359 if ( stat==2 || stat==3 ) { GasType = 0; } // Xe
360 else if ( stat==1 || stat==4 ) { GasType = 1; } // Ar
361 else if ( stat==5 ) { GasType = 1; } // Kr -- ESTIMATED AS AR UNTIL PID IS TUNED TO HANDLE KR
362 else if ( stat==6 ) { GasType = 1; } // Emulated Ar
363 else if ( stat==7 ) { GasType = 1;
364 } // Emulated Kr -- ESTIMATED AS AR UNTIL PID IS TUNED TO HANDLE KR
365 else {
367 "getStatusHT = "
368 << stat
369 << ", must be 'Good(2)||Xenon(3)' or 'Dead(1)||Argon(4)' or "
370 "'Krypton(5)' or 'EmulatedArgon(6)' or 'EmulatedKr(7)'!");
371 throw std::exception();
372 }
373 }
374
375 ATH_MSG_DEBUG("check Hit: "
376 << nTRThits << " TrtPart: " << TrtPart
377 << " GasType: " << GasType << " SL: " << StrawLayer
378 << " ZRpos: " << ZRpos[TrtPart] << " TWdist: " << rTrkWire
379 << " Occ_Local: " << PIDvalues[Trk::TRTTrackOccupancy] << " HTMB: " << isHTMB);
380
381 if (m_calculateNN and pT >= m_ptMinNN) {
382 // RNN gas type observables
383 hit_gasType.push_back(static_cast<double>(GasType));
384 if (GasType == 0) {
385 nXehits++;
386 } else if (GasType == 1) {
387 nArhits++;
388 }
389
390 // RNN hit preciion observables
391 float errDc = sqrt(driftcircle->localCovariance()(Trk::driftRadius, Trk::driftRadius));
392 bool isPrec = false;
393 if (errDc < 1.0) {
394 isPrec = true;
395 nPrecHits++;
396 }
397 hit_isPrec.push_back(static_cast<double>(isPrec));
398 }
399
400 // Then call pHT functions with these values:
401 // ------------------------------------------
402
403 double pHTel = HTcalc->getProbHT(pTrk,
405 TrtPart,
406 GasType,
407 StrawLayer,
408 ZRpos[TrtPart],
409 rTrkWire,
410 PIDvalues[Trk::TRTTrackOccupancy] ,
411 hasTrackParameters);
412 double pHTpi = HTcalc->getProbHT(pTrk,
413 Trk::pion,
414 TrtPart,
415 GasType,
416 StrawLayer,
417 ZRpos[TrtPart],
418 rTrkWire,
419 PIDvalues[Trk::TRTTrackOccupancy] ,
420 hasTrackParameters);
421
422 if (pHTel > 0.999 || pHTpi > 0.999 || pHTel < 0.001 || pHTpi < 0.001) {
423 ATH_MSG_DEBUG(" pHT outside allowed range! pHTel = "
424 << pHTel << " pHTpi = " << pHTpi
425 << " TrtPart: " << TrtPart << " SL: " << StrawLayer
426 << " ZRpos: " << ZRpos[TrtPart] << " TWdist: " << rTrkWire
427 << " Occ_Local: " << PIDvalues[Trk::TRTTrackOccupancy] );
428 continue;
429 }
430
431 if (pHTel > 0.80 || pHTpi > 0.50 || pHTel < 0.025 || pHTpi < 0.010) {
432 ATH_MSG_DEBUG(" pHT has abnormal value! pHTel = "
433 << pHTel << " pHTpi = " << pHTpi
434 << " TrtPart: " << TrtPart << " SL: " << StrawLayer
435 << " ZRpos: " << ZRpos[TrtPart] << " TWdist: " << rTrkWire
436 << " Occ_Local: " << PIDvalues[Trk::TRTTrackOccupancy] );
437 continue;
438 }
439
440 // From now (May 2015) onwards, we ONLY USE MIDDLE HT BIT:
441 if (isHTMB) {pHTel_prod *= pHTel; pHTpi_prod *= pHTpi;}
442 else {pHTel_prod *= 1.0-pHTel; pHTpi_prod *= 1.0-pHTpi;}
443 ATH_MSG_DEBUG ("check pHT(el): " << pHTel << " pHT(pi): " << pHTpi );
444
445 } // end of loop over hits
446
447
448 // If number of hits is adequate (default is 5 hits), calculate HT and ToT probability.
449 if (not (nTRThits >= m_minTRThits)) return PIDvalues;
450
451 // Calculate electron probability (HT)
452 PIDvalues[Trk::eProbabilityHT] = pHTel_prod / (pHTel_prod + pHTpi_prod);
453
454 ATH_MSG_DEBUG ("check nTRThits: " << nTRThits << " : " << nTRThitsHTMB
455 << " pHTel_prod: " << pHTel_prod
456 << " pHTpi_prod: " << pHTpi_prod
457 << " probEl: " << PIDvalues[Trk::eProbabilityHT]);
458
459 PIDvalues[Trk::TRTdEdx] = m_TRTdEdxTool->dEdx(
460 ctx,
461 &track,
462 true, //be expicit as optional below can be converted to bool
463 PIDvalues[Trk::TRTTrackOccupancy]); // default dEdx using all hits
464
466 m_TRTdEdxTool->usedHits(ctx, &track);
467 double dEdx_noHTHits = m_TRTdEdxTool->dEdx(
468 ctx,
469 &track,
470 false,//be expicit as optional below can be converted to bool
471 PIDvalues[Trk::TRTTrackOccupancy]); // Divide by L, exclude HT hits
472
473 double dEdx_usedHits_noHTHits = m_TRTdEdxTool->usedHits(ctx, &track, false);
474 PIDvalues[Trk::eProbabilityToT] = m_TRTdEdxTool->getTest(
475 ctx, dEdx_noHTHits, pTrk, Trk::electron, Trk::pion, dEdx_usedHits_noHTHits);
476
477 // Limit the probability values the upper and lower limits that are given/trusted for each part:
478 double limProbHT = HTcalculator::Limit(PIDvalues[Trk::eProbabilityHT]);
479 double limProbToT = HTcalculator::Limit(PIDvalues[Trk::eProbabilityToT]);
480
481 // Calculate the combined probability, assuming no correlations (none are expected).
482 PIDvalues[Trk::eProbabilityComb] =
483 (limProbHT * limProbToT) /
484 ((limProbHT * limProbToT) + ((1.0 - limProbHT) * (1.0 - limProbToT)));
485
486 // Troels: VERY NASTY NAMING, BUT AGREED UPON FOR NOW (for debugging, 27. NOV. 2014):
487 PIDvalues[Trk::eProbabilityBrem] = pHTel_prod; // decorates electron LH to el brem for now... (still used?)
488
489 if (!m_calculateNN or pT < m_ptMinNN) {
490 return PIDvalues;
491 }
492
493 // Calculate RNN PID score
494 std::map<std::string, std::map<std::string, double>> scalarInputs_NN = PIDNN->getScalarInputs();
495 std::map<std::string, std::map<std::string, std::vector<double>>> vectorInputs_NN = PIDNN->getVectorInputs();
496
497 // Calculate the hit fraction
498 if (nTRThits == 0)[[unlikely]]{
499 ATH_MSG_ERROR("Number of TRT hits is zero");
500 return {};
501 }
502 double fAr = static_cast<double>(nArhits) / nTRThits;
503 double fHTMB = static_cast<double>(nTRThitsHTMB) / nTRThits;
504 double PHF = static_cast<double>(nPrecHits) / nTRThits;
505
506 if (!scalarInputs_NN.empty()) {
507 std::map<std::string, double>& trackVarMap = scalarInputs_NN.begin()->second;
508 storeNNVariable(trackVarMap, "trkOcc", static_cast<double>(PIDvalues[Trk::TRTTrackOccupancy]));
509 storeNNVariable(trackVarMap, "p", pTrk);
510 storeNNVariable(trackVarMap, "pT", pT);
511 storeNNVariable(trackVarMap, "nXehits", static_cast<double>(nXehits));
512 storeNNVariable(trackVarMap, "fAr", fAr);
513 storeNNVariable(trackVarMap, "fHTMB", fHTMB);
514 storeNNVariable(trackVarMap, "PHF", PHF);
515 storeNNVariable(trackVarMap, "dEdx", static_cast<double>(dEdx_noHTHits));
516 }
517
518 if (!vectorInputs_NN.empty()) {
519 std::map<std::string, std::vector<double>>& hitVarMap = vectorInputs_NN.begin()->second;
520 storeNNVariable(hitVarMap, "hit_HTMB", hit_HTMB);
521 storeNNVariable(hitVarMap, "hit_gasType", hit_gasType);
522 storeNNVariable(hitVarMap, "hit_tot", hit_tot);
523 storeNNVariable(hitVarMap, "hit_L", hit_L);
524 storeNNVariable(hitVarMap, "hit_rTrkWire", hit_rTrkWire);
525 storeNNVariable(hitVarMap, "hit_HitZ", hit_HitZ);
526 storeNNVariable(hitVarMap, "hit_HitR", hit_HitR);
527 storeNNVariable(hitVarMap, "hit_isPrec", hit_isPrec);
528 }
529 PIDvalues[Trk::eProbabilityNN] = PIDNN->evaluate(scalarInputs_NN, vectorInputs_NN);
530
531 ATH_MSG_DEBUG ("check NN PID calculation: ");
532 for (const auto& scalarInputs : scalarInputs_NN) {
533 ATH_MSG_DEBUG (" scalar inputs: " << scalarInputs.first);
534 for (const auto& variable : scalarInputs.second) {
535 ATH_MSG_DEBUG (" " << variable.first << " = " << variable.second);
536 }
537 }
538 for (const auto& vectorInputs : vectorInputs_NN) {
539 ATH_MSG_DEBUG (" vector inputs: " << vectorInputs.first);
540 for (const auto& variable : vectorInputs.second) {
541 ATH_MSG_DEBUG (" " << variable.first << " = " << variable.second);
542 }
543 }
544 ATH_MSG_DEBUG (" eProbilityNN: " << PIDvalues[Trk::eProbabilityNN]);
545
546 return PIDvalues;
547}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define AmgVector(rows)
void storeNNVariable(std::map< std::string, T > &theMap, const std::string &name, const T &value)
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
float getProbHT(float pTrk, Trk::ParticleHypothesis hypothesis, int TrtPart, int GasType, int StrawLayer, float ZR, float rTrkAnode, float Occupancy, bool hasTrackPars) const
static float Limit(float prob)
const std::map< std::string, std::map< std::string, double > > & getScalarInputs() const
Definition TRTPIDNN.h:42
double evaluate(std::map< std::string, std::map< std::string, double > > &scalarInputs, std::map< std::string, std::map< std::string, std::vector< double > > > &vectorInputs) const
Definition TRTPIDNN.h:52
const std::map< std::string, std::map< std::string, std::vector< double > > > & getVectorInputs() const
Definition TRTPIDNN.h:47
double timeOverThreshold() const
returns time over threshold in ns for valid digits; zero otherwise
virtual const TRT_DriftCircle * prepRawData() const override final
returns the PrepRawData - is a TRT_DriftCircle in this scope
virtual const Amg::Vector3D & globalPosition() const override final
return the global position of this RIO_OnTrack
virtual const Trk::Surface & associatedSurface() const override final
returns the surface for the local to global transformation
ToolHandle< ITRT_ToT_dEdx > m_TRTdEdxTool
ToolHandle< ITRT_StrawStatusSummaryTool > m_TRTStrawSummaryTool
ToolHandle< InDet::ITRT_LocalOccupancy > m_LocalOccTool
SG::ReadCondHandleKey< InDet::TRTPIDNN > m_TRTPIDNNReadKey
SG::ReadCondHandleKey< HTcalculator > m_HTReadKey
static double calculateTrackLengthInStraw(const Trk::TrackStateOnSurface *trackState, const TRT_ID *identifier)
virtual bool type(MeasurementBaseType::Type type) const =0
Interface method checking the type.
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
Identifier identify() const
return the identifier -extends MeasurementBase
virtual bool rioType(RIO_OnTrackType::Type type) const =0
Method checking the Rio On Track type.
const Amg::Vector3D & center() const
Returns the center position of the Surface.
Eigen::Matrix< double, 3, 1 > Vector3D
@ qOverP
perigee
DataVector< const Trk::TrackStateOnSurface > TrackStates
@ eProbabilityBrem
Electron probability from Brem fitting (DNA).
@ eProbabilityComb
Electron probability from combining the below probabilities.
@ eProbabilityNumberOfTRTHitsUsedFordEdx
Number of TRT hits used for dEdx measurement.
@ eProbabilityToT
Electron probability from Time-Over-Threshold (ToT) information.
@ eProbabilityHT
Electron probability from High Threshold (HT) information.
static const std::vector< float > eProbabilityDefault(numberOfeProbabilityTypes, 0.5)
@ driftRadius
trt, straws
Definition ParamDefs.h:53
@ theta
Definition ParamDefs.h:66
@ qOverP
perigee
Definition ParamDefs.h:67
@ phi
Definition ParamDefs.h:75
ParametersBase< TrackParametersDim, Charged > TrackParameters
#define unlikely(x)

◆ electronProbability_old()

std::vector< float > InDet::TRT_ElectronPidToolRun2::electronProbability_old ( const Trk::Track & track)
static

Electron probabilities to be returned.

Definition at line 122 of file TRT_ElectronPidToolRun2.cxx.

123{
124 // Simply return values without calculation
125 std::vector<float> PIDvalues = Trk::eProbabilityDefault;
126 return PIDvalues;
127}

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

StatusCode InDet::TRT_ElectronPidToolRun2::finalize ( )
overridevirtual

standard Athena-Algorithm method

Definition at line 115 of file TRT_ElectronPidToolRun2.cxx.

116{
117 return AthAlgTool::finalize();
118}

◆ initialize()

StatusCode InDet::TRT_ElectronPidToolRun2::initialize ( )
overridevirtual

standard Athena-Algorithm method

Definition at line 87 of file TRT_ElectronPidToolRun2.cxx.

88{
89 StatusCode sc = AthAlgTool::initialize();
90 if (sc.isFailure()) return sc;
91
92 // Get the TRT Identifier-helper:
93 CHECK (detStore()->retrieve(m_trtId, "TRT_ID"));
94
95 /* Get the TRT_ToT_dEdx tool */
96 CHECK( m_TRTdEdxTool.retrieve() );
97
98 CHECK( m_LocalOccTool.retrieve() );
99
100 ATH_CHECK( m_HTReadKey.initialize() );
101
103
104 CHECK( m_TRTStrawSummaryTool.retrieve() );
105
106 return StatusCode::SUCCESS;
107}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define CHECK(...)
Evaluate an expression and check for errors.
static Double_t sc
const ServiceHandle< StoreGateSvc > & detStore() const
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & ITRT_ElectronToTTool::interfaceID ( )
inlinestaticinherited

AlgTool interface methods.

Definition at line 25 of file ITRT_ElectronToTTool.h.

25{ return IID_ITRT_ElectronToTTool; };
static const InterfaceID IID_ITRT_ElectronToTTool("ITRT_ElectronToTTool", 1, 0)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ probHT()

double InDet::TRT_ElectronPidToolRun2::probHT ( const double p,
const Trk::ParticleHypothesis hypothesis,
const int HitPart,
const int Layer,
const int Strawlayer ) const
finaloverridevirtual

return high threshold probability

Returns
double of probability

Implements Trk::ITRT_ElectronPidTool.

Definition at line 603 of file TRT_ElectronPidToolRun2.cxx.

609{
610 if (not CheckGeometry(HitPart,Layer,StrawLayer) ){
611 ATH_MSG_ERROR("TRT geometry fail. Returning default value.");
612 return 0.5;
613 }
614
615 return 1.0;
616}
bool CheckGeometry(int BEC, int Layer, int Strawlayer) const

◆ probHTRun2()

double InDet::TRT_ElectronPidToolRun2::probHTRun2 ( const EventContext & ctx,
float pTrk,
Trk::ParticleHypothesis hypothesis,
int TrtPart,
int GasType,
int StrawLayer,
float ZR,
float rTrkWire,
float Occupancy ) const
finaloverridevirtual

Implements Trk::ITRT_ElectronPidTool.

Definition at line 619 of file TRT_ElectronPidToolRun2.cxx.

628{
629 SG::ReadCondHandle<HTcalculator> readHandle{ m_HTReadKey, ctx };
630 bool hasTrackPar = true;
631 return (*readHandle)
632 ->getProbHT(pTrk,
633 hypothesis,
634 TrtPart,
635 GasType,
636 StrawLayer,
637 ZR,
638 rTrkWire,
639 Occupancy,
640 hasTrackPar);
641}

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sqr()

double InDet::TRT_ElectronPidToolRun2::sqr ( double a)
inlineprivate

Definition at line 133 of file TRT_ElectronPidToolRun2.h.

133{return a*a;}
static Double_t a

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, and AthCheckedComponent<::AthAlgTool >.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_calculateNN

BooleanProperty InDet::TRT_ElectronPidToolRun2::m_calculateNN
private
Initial value:
{this, "CalculateNNPid", true,
"Decide whether to use NN PID"}

Definition at line 140 of file TRT_ElectronPidToolRun2.h.

140 {this, "CalculateNNPid", true,
141 "Decide whether to use NN PID"};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_HTReadKey

SG::ReadCondHandleKey<HTcalculator> InDet::TRT_ElectronPidToolRun2::m_HTReadKey
private
Initial value:
{ this,
"HTcalculator",
"HTcalculator",
"HTcalculator in-key" }

Definition at line 160 of file TRT_ElectronPidToolRun2.h.

160 { this,
161 "HTcalculator",
162 "HTcalculator",
163 "HTcalculator in-key" };

◆ m_LocalOccTool

ToolHandle<InDet::ITRT_LocalOccupancy> InDet::TRT_ElectronPidToolRun2::m_LocalOccTool
private
Initial value:
{
this,
"TRT_LocalOccupancyTool",
{},
"TRT Local occupancy tool"
}

Definition at line 147 of file TRT_ElectronPidToolRun2.h.

147 {
148 this,
149 "TRT_LocalOccupancyTool",
150 {},
151 "TRT Local occupancy tool"
152 };

◆ m_minTRThits

UnsignedIntegerProperty InDet::TRT_ElectronPidToolRun2::m_minTRThits
private
Initial value:
{this, "MinimumTRThitsForIDpid", 5,
"Minimum number of TRT hits to give PID"}

Definition at line 136 of file TRT_ElectronPidToolRun2.h.

136 {this, "MinimumTRThitsForIDpid", 5,
137 "Minimum number of TRT hits to give PID"};

◆ m_ptMinNN

FloatProperty InDet::TRT_ElectronPidToolRun2::m_ptMinNN
private
Initial value:
{this, "MinimumTrackPtForNNPid", 2000.,
"Minimum track pt to calculate NN response for PID"}

Definition at line 138 of file TRT_ElectronPidToolRun2.h.

138 {this, "MinimumTrackPtForNNPid", 2000.,
139 "Minimum track pt to calculate NN response for PID"};

◆ m_TRTdEdxTool

ToolHandle<ITRT_ToT_dEdx> InDet::TRT_ElectronPidToolRun2::m_TRTdEdxTool
private
Initial value:
{ this,
"TRT_ToT_dEdx_Tool",
{},
"TRT ToT dEdx Tool"}

Definition at line 143 of file TRT_ElectronPidToolRun2.h.

143 { this,
144 "TRT_ToT_dEdx_Tool",
145 {},
146 "TRT ToT dEdx Tool"};

◆ m_trtId

const TRT_ID* InDet::TRT_ElectronPidToolRun2::m_trtId {nullptr}
private

Definition at line 135 of file TRT_ElectronPidToolRun2.h.

135{nullptr}; // TRT ID helper (identifying barrel/wheels and global position)

◆ m_TRTPIDNNReadKey

SG::ReadCondHandleKey<InDet::TRTPIDNN> InDet::TRT_ElectronPidToolRun2::m_TRTPIDNNReadKey
private
Initial value:
{ this,
"TRTPIDNN",
"TRTPIDNN",
"TRTPIDNN in-key" }

Definition at line 165 of file TRT_ElectronPidToolRun2.h.

165 { this,
166 "TRTPIDNN",
167 "TRTPIDNN",
168 "TRTPIDNN in-key" };

◆ m_TRTStrawSummaryTool

ToolHandle<ITRT_StrawStatusSummaryTool> InDet::TRT_ElectronPidToolRun2::m_TRTStrawSummaryTool
private
Initial value:
{
this,
"TRTStrawSummaryTool",
"InDetTRTStrawStatusSummaryTool",
"TRT straw summary tool"
}

Definition at line 153 of file TRT_ElectronPidToolRun2.h.

153 {
154 this,
155 "TRTStrawSummaryTool",
156 "InDetTRTStrawStatusSummaryTool",
157 "TRT straw summary tool"
158 };

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: