ATLAS Offline Software
PrimaryTruthClassifier.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // PrimaryTruthClassifier.cxx
7 // Source file for class PrimaryTruthClassifier
9 // (c) ATLAS Detector software
11 
14 #include "CLHEP/Units/SystemOfUnits.h"
15 #include "AtlasHepMC/GenVertex.h"
16 
17 Trk::PrimaryTruthClassifier::PrimaryTruthClassifier(const std::string& type, const std::string& name, const IInterface* parent)
19  m_maxRStartPrimary ( 25.0*CLHEP::mm),
20  m_maxZStartPrimary ( 200.0*CLHEP::mm),
21  m_minREndPrimary ( 400.0*CLHEP::mm),
22  m_minZEndPrimary (2300.0*CLHEP::mm),
23  m_maxRStartSecondary ( 360.0*CLHEP::mm),
24  m_maxZStartSecondary (2000.0*CLHEP::mm),
25  m_minREndSecondary (1000.0*CLHEP::mm),
26  m_minZEndSecondary (3200.0*CLHEP::mm)
27 {
28  declareInterface<ITrackTruthClassifier>(this);
29 
30  declareProperty("maxRStartPrimary", m_maxRStartPrimary);
31  declareProperty("maxZStartPrimary", m_maxZStartPrimary);
32  declareProperty("minREndPrimary", m_minREndPrimary);
33  declareProperty("minZEndPrimary", m_minZEndPrimary);
34  declareProperty("maxRStartSecondary", m_maxRStartSecondary);
35  declareProperty("maxZStartSecondary", m_maxZStartSecondary);
36  declareProperty("minREndSecondary", m_minREndSecondary);
37  declareProperty("minZEndSecondary", m_minZEndSecondary);
38 
39 }
40 
45  ATH_MSG_INFO ("initialise successful in "<<name() );
46  return StatusCode::SUCCESS;
47 }
48 
50  ATH_MSG_INFO ("starting finalize() in " << name() );
51  return StatusCode::SUCCESS;
52 }
53 
55 (const McEventCollection& /*SimTracks*/,
56  const std::vector<HepMC::ConstGenParticlePtr>* /*genSignal*/) const {
57 
58  // nothing to prepare as local data at start of collection analysis
59  }
60 
62 // classification from InDetRecStatistics
65 
66 
67  /* note on using HepMC::FourVector/3Vector against HepGeom::Point3D<double>: The versions from HepMC2 do not know
68  operator+, operator- etc. */
69 
70 
71  //classify as primary, secondary or truncated
72  bool primary=false;
73  bool secondary=false;
74  bool truncated=false;
75 
76  if (genParticle->production_vertex()) {
77  HepMC::FourVector startVertex = genParticle->production_vertex()->position();
78 
79  // primary vertex inside innermost layer?
80  if ( fabs(startVertex.perp()) < m_maxRStartPrimary
81  && fabs(startVertex.z()) < m_maxZStartPrimary)
82  {
83  if (genParticle->end_vertex() == nullptr) {
84  primary=true;
85  } else {
86  HepMC::FourVector endVertex = genParticle->end_vertex()->position();
87  if ( endVertex.perp() > m_minREndPrimary
88  || fabs(startVertex.z()) > m_minZEndPrimary)
89  primary=true; else truncated = true;
90  }
91  }
92  else if ( startVertex.perp() < m_maxRStartSecondary &&
93  fabs(startVertex.z()) < m_maxZStartSecondary)
94  {
95  if (genParticle->end_vertex() == nullptr) {
96  secondary=true;
97  } else {
98  HepMC::FourVector endVertex = genParticle->end_vertex()->position();
99  if (endVertex.perp() > m_minREndSecondary
100  || fabs(endVertex.z()) > m_minZEndSecondary) {
101  secondary=true;
102  }
103  }
104  }
105  } //end classification
106 
107  if (truncated) return Trk::TruthClassification::Truncated;
108  if (secondary) return Trk::TruthClassification::Secondary;
110  ATH_MSG_DEBUG ( "Could not classify this particle: " << genParticle );
112 
113 }
Trk::PrimaryTruthClassifier::m_minREndPrimary
float m_minREndPrimary
If track has end vertex, this is min R of end vertex to be considered primary.
Definition: PrimaryTruthClassifier.h:58
Trk::PrimaryTruthClassifier::m_maxZStartSecondary
float m_maxZStartSecondary
Definition: PrimaryTruthClassifier.h:62
Trk::PrimaryTruthClassifier::finalize
virtual StatusCode finalize()
Definition: PrimaryTruthClassifier.cxx:49
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Trk::PrimaryTruthClassifier::m_minREndSecondary
float m_minREndSecondary
Definition: PrimaryTruthClassifier.h:63
Trk::PrimaryTruthClassifier::initialize
virtual StatusCode initialize()
initialize
Definition: PrimaryTruthClassifier.cxx:44
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
GenVertex.h
Trk::PrimaryTruthClassifier::m_maxZStartPrimary
float m_maxZStartPrimary
Max Z of start vertex to be considered primary.
Definition: PrimaryTruthClassifier.h:56
Trk::TruthClassification::Secondary
@ Secondary
Definition: TruthClassificationDefs.h:26
Trk::PrimaryTruthClassifier::PrimaryTruthClassifier
PrimaryTruthClassifier(const std::string &type, const std::string &name, const IInterface *parent)
Definition: PrimaryTruthClassifier.cxx:17
Trk::PrimaryTruthClassifier::classify
virtual unsigned int classify(HepMC::ConstGenParticlePtr) const
Definition: PrimaryTruthClassifier.cxx:64
StateLessPT_NewConfig.primary
primary
Definition: StateLessPT_NewConfig.py:228
PrimaryTruthClassifier.h
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
CLHEP
STD'S.
Definition: IAtRndmGenSvc.h:19
test_pyathena.parent
parent
Definition: test_pyathena.py:15
Trk::PrimaryTruthClassifier::m_maxRStartPrimary
float m_maxRStartPrimary
Max R of start vertex to be considered primary.
Definition: PrimaryTruthClassifier.h:55
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
Trk::TruthClassification::OutsideClassification
@ OutsideClassification
providing some well-defined error condition
Definition: TruthClassificationDefs.h:19
Trk::PrimaryTruthClassifier::initClassification
virtual void initClassification(const McEventCollection &, const std::vector< HepMC::ConstGenParticlePtr > *) const
explain
Definition: PrimaryTruthClassifier.cxx:55
Trk::TruthClassification::Truncated
@ Truncated
Definition: TruthClassificationDefs.h:27
Trk::PrimaryTruthClassifier::m_minZEndSecondary
float m_minZEndSecondary
Definition: PrimaryTruthClassifier.h:64
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
Trk::PrimaryTruthClassifier::m_maxRStartSecondary
float m_maxRStartSecondary
Definition: PrimaryTruthClassifier.h:61
Trk::TruthClassification::Primary
@ Primary
Definition: TruthClassificationDefs.h:25
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AthAlgTool
Definition: AthAlgTool.h:26
TruthClassificationDefs.h
Trk::PrimaryTruthClassifier::m_minZEndPrimary
float m_minZEndPrimary
If track has end vertex, this is min Z of end vertex to be considered primary.
Definition: PrimaryTruthClassifier.h:60