ATLAS Offline Software
Loading...
Searching...
No Matches
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"
16
17Trk::PrimaryTruthClassifier::PrimaryTruthClassifier(const std::string& type, const std::string& name, const IInterface* parent)
18 : AthAlgTool (type,name,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;
109 if (primary) return Trk::TruthClassification::Primary;
110 ATH_MSG_DEBUG ( "Could not classify this particle: " << genParticle );
112
113}
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
PrimaryTruthClassifier(const std::string &type, const std::string &name, const IInterface *parent)
float m_minREndPrimary
If track has end vertex, this is min R of end vertex to be considered primary.
float m_minZEndPrimary
If track has end vertex, this is min Z of end vertex to be considered primary.
virtual StatusCode initialize()
initialize
float m_maxRStartPrimary
Max R of start vertex to be considered primary.
virtual void initClassification(const McEventCollection &, const std::vector< HepMC::ConstGenParticlePtr > *) const
explain
float m_maxZStartPrimary
Max Z of start vertex to be considered primary.
virtual unsigned int classify(HepMC::ConstGenParticlePtr) const
const GenParticle * ConstGenParticlePtr
Definition GenParticle.h:38
@ OutsideClassification
providing some well-defined error condition