ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
AthTruthSelectionTool Class Reference

class to apply selection to xAOD::TruthParticles,required by validation More...

#include <AthTruthSelectionTool.h>

Inheritance diagram for AthTruthSelectionTool:
Collaboration diagram for AthTruthSelectionTool:

Public Member Functions

 AthTruthSelectionTool (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual ~AthTruthSelectionTool ()
 
StatusCode initialize () final
 
StatusCode finalize () final
 
virtual IAthSelectionTool::CutResult accept (const xAOD::IParticle *particle) const final
 The most important method to determine whether the particle is accepted. More...
 
virtual IAthSelectionTool::CutResult testAllCuts (const xAOD::IParticle *p, std::vector< unsigned int > &counter) const final
 The most important method to determine whether the particle is accepted. More...
 
unsigned int nCuts () const final
 return the number of cuts. More...
 
std::vector< std::string > names () const final
 return the names of the cuts as a vector<string> More...
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 interfaceID reimplemented from base More...
 

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
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. More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

CutList< xAOD::TruthParticlem_cutList
 
float m_maxEta
 
float m_maxPt
 
float m_minPt
 
bool m_requireOnlyPrimary
 
bool m_requireCharged
 
int m_selectedCharge
 
bool m_requireStable
 
int m_requireSiHit
 
double m_maxProdVertRadius
 
int m_pdgId
 
bool m_grandparent
 
bool m_poselectronfromgamma
 
std::vector< unsigned int > m_counters
 
std::vector< int > m_ancestors
 
float m_radiusCylinder
 for cylinder topology: radius of cylinder More...
 
float m_minZCylinder
 for cylinder topology: minimum |z| More...
 
float m_maxZCylinder
 for cylinder topology: maximum |z| More...
 
float m_zDisc
 for disk topology: Z position of disk More...
 
float m_minRadiusDisc
 for disk topology: minimum radius More...
 
float m_maxRadiusDisc
 for disk topology: maximum radius More...
 
std::unique_ptr< Trk::CylinderSurfacem_cylinder
 
std::unique_ptr< Trk::DiscSurfacem_disc1
 
std::unique_ptr< Trk::DiscSurfacem_disc2
 
PublicToolHandle< Trk::IExtrapolatorm_extrapolator {this,"Extrapolator","Trk::Extrapolator/AtlasExtrapolator",""}
 Too handle for truth-track extrapolation. More...
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

class to apply selection to xAOD::TruthParticles,required by validation

Definition at line 28 of file AthTruthSelectionTool.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

◆ AthTruthSelectionTool()

AthTruthSelectionTool::AthTruthSelectionTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 44 of file AthTruthSelectionTool.cxx.

45  :
47  m_counters{}
48 {
49  // declare interface from base class
50  declareInterface<IAthSelectionTool>(this);
51  // declareProperty( "Property", m_nProperty ); set defaults
52  declareProperty("maxEta", m_maxEta = 2.5);
53  declareProperty("minPt", m_minPt = 400);
54  declareProperty("maxPt", m_maxPt = -1);
55  declareProperty("requireOnlyPrimary", m_requireOnlyPrimary = true);
56  declareProperty("requireCharged", m_requireCharged = true);
57  declareProperty("selectedCharge", m_selectedCharge = 0);
58  declareProperty("requireStable", m_requireStable = true);
59  declareProperty("requireSiHit", m_requireSiHit = 0);
60  declareProperty("maxProdVertRadius", m_maxProdVertRadius = 110.);
61  declareProperty("pdgId", m_pdgId = -1);
62  declareProperty("hasNoGrandparent", m_grandparent = false);
63  declareProperty("ancestorList", m_ancestors = {});
64  declareProperty("poselectronfromgamma", m_poselectronfromgamma = false);
65  declareProperty("radiusCylinder", m_radiusCylinder=-1, "Select truth particle based on extrapolated position on cylinder placed at this radius. Enabled if greater than 0.");
66  declareProperty("minZCylinder", m_minZCylinder=0.0, "Minimum |Z| on cylinder for accepting extrapolated truth particle to surface.");
67  declareProperty("maxZCylinder", m_maxZCylinder=0.0, "Maximum |Z| on cylinder for accepting extrapolated truth particle to surface.");
68  declareProperty("zDisc", m_zDisc=-1.0, "Select truth particle based on extrapolated position on disks placed at +/- z positions. Enabled if greater than 0.");
69  declareProperty("minRadiusDisc", m_minRadiusDisc=0.0, "Minimum radius on disk for accepting extrapolated truth particle to surface.");
70  declareProperty("maxRadiusDisc", m_maxRadiusDisc=0.0, "Maximum radius on disk for accepting extrapolated truth particle to surface.");
71 }

◆ ~AthTruthSelectionTool()

virtual AthTruthSelectionTool::~AthTruthSelectionTool ( )
inlinevirtual

Definition at line 31 of file AthTruthSelectionTool.h.

31  {
32  /*nop*/
33  };

Member Function Documentation

◆ accept()

IAthSelectionTool::CutResult AthTruthSelectionTool::accept ( const xAOD::IParticle p) const
finalvirtual

The most important method to determine whether the particle is accepted.

Parameters
pPointer to particle baseclass, will be cast to truth or track
Returns
the number of cuts which are not passed or tested

Implements IAthSelectionTool.

Definition at line 272 of file AthTruthSelectionTool.cxx.

272  {
273  const xAOD::TruthParticle* pTruth = dynamic_cast<const xAOD::TruthParticle*>(particle);
274 
275  //@TODO
276  if (not pTruth) {
277  return m_cutList.size()+1; // marker for invalid particles
278  }
279  return m_cutList.accept(*pTruth);
280 }

◆ declareGaudiProperty() [1/4]

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

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

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

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

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

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

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

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

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

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

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ 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.

95 { return m_detStore; }

◆ evtStore() [1/2]

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.

85 { return m_evtStore; }

◆ evtStore() [2/2]

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

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

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ 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 AthTruthSelectionTool::finalize ( )
final

Definition at line 260 of file AthTruthSelectionTool.cxx.

260  {
261  // nop
262  return StatusCode::SUCCESS;
263 }

◆ initialize()

StatusCode AthTruthSelectionTool::initialize ( )
final

Definition at line 74 of file AthTruthSelectionTool.cxx.

74  {
75  // can set cut properties now
76  using P_t = xAOD::TruthParticle;
77  using Accept_t = Accept<P_t>;
78  //
79  const std::vector<Accept_t> filters = {
80  // if p.pt=0, TVector3 generates an error when querying p.eta(); a limit of 1e-7 was not found to be enough to
81  // prevent this
82  // the following also vetoes the case where the p.pt()=NaN, as any inequality with NaN evaluates to false
83  Accept_t([this](const P_t& p) -> bool {
84  return((p.pt() > 0.1) ? (std::abs(p.eta()) < m_maxEta) : false);
85  }, std::string("eta")),
86  Accept_t([this](const P_t& p) -> bool {
87  return(p.pt() > m_minPt);
88  }, std::string("min_pt"))
89  };
90  //
91  m_cutList = CutList<P_t>(filters);
92  if (m_maxProdVertRadius>0) {
93  m_cutList.add(Accept_t([&m_maxProdVertRadius = std::as_const(m_maxProdVertRadius)](const P_t& p) -> bool {
94  return((not (p.hasProdVtx()))or(p.prodVtx()->perp() < m_maxProdVertRadius));
95  },
96  "decay_before_" + std::to_string(m_maxProdVertRadius)));
97  }
98  if (m_maxPt > 0) {
99  m_cutList.add(Accept_t([&m_maxPt = std::as_const(m_maxPt)](const P_t& p) {
100  return(p.pt() < m_maxPt);
101  }, "max_pt"));
102  }
103  if (m_requireSiHit > 0) {
104  m_cutList.add(Accept_t([&m_requireSiHit = std::as_const(m_requireSiHit)](const P_t& p) {
105  static const SG::AuxElement::ConstAccessor< float > nSilHitsAcc("nSilHits");
106  if (nSilHitsAcc.isAvailable(p)) return (nSilHitsAcc(p) >= m_requireSiHit);
107  else return false;
108  }, "siHit"));
109  }
110  if (m_requireOnlyPrimary) {
111  m_cutList.add(Accept_t([](const P_t& p) {
112  return(!HepMC::is_simulation_particle(&p));
113  }, "OnlyPrimary"));
114  }
115  if (m_requireCharged) {
116  m_cutList.add(Accept_t([&m_selectedCharge = std::as_const(m_selectedCharge)](const P_t& p) {
117  if(m_selectedCharge ==0) return(not (p.isNeutral()));
118  else return(not(p.isNeutral()) and p.charge()==m_selectedCharge);
119  }, "charged"));
120  }
121  if (m_requireStable) {
122  m_cutList.add(Accept_t([](const P_t& p) {
123  return(MC::isStable(&p));
124  }, "stable"));
125  }
126  if (m_pdgId > 0) {
127  m_cutList.add(Accept_t([&m_pdgId = std::as_const(m_pdgId)](const P_t& p) {
128  return(std::abs(p.pdgId()) == m_pdgId);
129  }, "pdgId"));
130  }
131  if (m_grandparent) {
132  m_cutList.add(Accept_t([](const P_t& p) {
133  return((p.nParents() == 0) || ((p.nParents() == 1)and((p.parent(0))->nParents() == 0)));
134  }, "hasNoGrandparent"));
135  }
136  //require the truth particles to come from certain ancesters
137  if (!m_ancestors.empty()) {
138  m_cutList.add(Accept_t([&m_ancestors = std::as_const(m_ancestors)](const P_t& p) -> bool {
139  const xAOD::TruthParticle* pTruth = dynamic_cast<const xAOD::TruthParticle*>(&p);
140  if (not pTruth) return false;
141  else return hasAncestor(pTruth, m_ancestors);
142  }, "ancestors"));
143  }
145  m_cutList.add(Accept_t([](const P_t& p) {
146  return((p.absPdgId() == electronId)and(p.nParents() >= 1) and(p.parent(0)) and(p.parent(0)->pdgId() == gammaId));
147  }, "poselectronfromgamma"));
148  }
149  if (m_radiusCylinder > 0) {
150  // m_cutList.add(Accept_t(acceptExtrapolatedTPToSurface, "SelectCylinder"));
151  if (not m_cylinder) {
152  ATH_MSG_VERBOSE("Creating and caching cylinder surface");
153  Amg::Transform3D trnsf;
154  trnsf.setIdentity();
155  m_cylinder = std::make_unique<Trk::CylinderSurface>( trnsf, m_radiusCylinder, 20000.);
156  }
157  m_cutList.add(Accept_t([this](const P_t& p) -> bool {
158  ATH_MSG_VERBOSE("Checking particle for intersection with cylinder of radius " << m_radiusCylinder);
159  //create surface we extrapolate to and cache it
160  const xAOD::TruthVertex* ptruthVertex = p.prodVtx();
161  if (ptruthVertex == nullptr) {
162  //cannot derive production vertex, reject track
163  ATH_MSG_VERBOSE("Rejecting particle without production vertex.");
164  return false;
165  }
166  const auto xPos = ptruthVertex->x();
167  const auto yPos = ptruthVertex->y();
168  const auto z_truth = ptruthVertex->z();
169  const Amg::Vector3D position(xPos, yPos, z_truth);
170  const Amg::Vector3D momentum(p.px(), p.py(), p.pz());
171  const Trk::CurvilinearParameters cParameters(position, momentum, p.charge());
172  const Trk::TrackParameters *exParameters = m_extrapolator->extrapolate(Gaudi::Hive::currentContext(),
173  cParameters,
174  *m_cylinder,
175  Trk::anyDirection, false, Trk::pion).release();
176  if (!exParameters) {
177  ATH_MSG_VERBOSE("Failed extrapolation. Rejecting track.");
178  return false;
179  }
180  ATH_MSG_VERBOSE("Extrapolated parameters to cylinder: " << *exParameters);
181  const float ex_abs_z = fabs(exParameters->position().z());
182  if ( (ex_abs_z > m_minZCylinder) and (ex_abs_z < m_maxZCylinder) ) {
183  ATH_MSG_VERBOSE("Particle accepted.");
184  return true;
185  }
186  //else..
187  ATH_MSG_VERBOSE("Particle rejected");
188  return false;
189  }, "SelectCylinder"));
190  } else if (m_zDisc > 0) {
191  //m_cutList.add(Accept_t(acceptExtrapolatedTPToSurface, "SelectDisc"));
192  if (not m_disc1 || not m_disc2) { //m_disc2 == 0 implied
193  ATH_MSG_VERBOSE("Creating and caching disc surface");
195  m_disc1 = std::make_unique<Trk::DiscSurface>( trnsf_shiftZ, m_minRadiusDisc, m_maxRadiusDisc);
196  trnsf_shiftZ = Amg::Translation3D(0.,0.,-m_zDisc);
197  m_disc2 = std::make_unique<Trk::DiscSurface>( trnsf_shiftZ, m_minRadiusDisc, m_maxRadiusDisc);
198  }
199  m_cutList.add(Accept_t([this](const P_t& p) -> bool {
200  ATH_MSG_VERBOSE("Checking particle for intersection with discs of |z| " << m_zDisc);
201  //create surface we extrapolate to and cache it
202  const xAOD::TruthVertex* ptruthVertex = p.prodVtx();
203  if (ptruthVertex == nullptr) {
204  //cannot derive production vertex, reject track
205  ATH_MSG_VERBOSE("Rejecting particle without production vertex.");
206  return false;
207  }
208  const auto xPos = ptruthVertex->x();
209  const auto yPos = ptruthVertex->y();
210  const auto z_truth = ptruthVertex->z();
211  const Amg::Vector3D position(xPos, yPos, z_truth);
212  const Amg::Vector3D momentum(p.px(), p.py(), p.pz());
213  const Trk::CurvilinearParameters cParameters(position, momentum, p.charge());
214  const Trk::TrackParameters *exParameters = m_extrapolator->extrapolate(Gaudi::Hive::currentContext(),
215  cParameters,
216  *m_disc1, Trk::anyDirection, true, Trk::pion).release();
217  if (exParameters) {
218  //since boundary check is true, should be enough to say we've hit the disk..
219  ATH_MSG_VERBOSE("Successfully extrapolated track to disk at +" << m_zDisc << ": " << *exParameters);
220  float ex_radius = sqrt(pow(exParameters->position().x(),2)+pow(exParameters->position().y(),2));
221  ATH_MSG_VERBOSE("radial position at surface: " << ex_radius);
222  if ((ex_radius > m_minRadiusDisc) and (ex_radius < m_maxRadiusDisc)) {
223  ATH_MSG_VERBOSE("Confirmed within the disk. Accepting particle");
224  return true;
225  }
226  //else...
227  ATH_MSG_VERBOSE("Strange, extrapolation succeeded but extrapolated position not within disc radius! Test next disc");
228  }
229  exParameters = m_extrapolator->extrapolate(Gaudi::Hive::currentContext(),cParameters, *m_disc2, Trk::anyDirection, true, Trk::pion).release();
230  if (exParameters) {
231  //since boundary check is true, should be enough to say we've hit the disk..
232  ATH_MSG_VERBOSE("Successfully extrapolated track to disk at -" << m_zDisc << ": " << *exParameters);
233  float ex_radius = sqrt(pow(exParameters->position().x(),2)+pow(exParameters->position().y(),2));
234  ATH_MSG_VERBOSE("radial position at surface: " << ex_radius);
235  if ((ex_radius > m_minRadiusDisc) and (ex_radius < m_maxRadiusDisc)) {
236  ATH_MSG_VERBOSE("Confirmed within the disk. Accepting particle");
237  return true;
238  }
239  //else...
240  ATH_MSG_VERBOSE("Strange, extrapolation succeeded but extrapolated position not within disc radius! Rejecting");
241  }
242  //else..
243  ATH_MSG_VERBOSE("Particle rejected");
244  return false;
245  }, "SelectDisc"));
246  } //m_zDisc > 0
247 
248  std::string msg = std::to_string(m_cutList.size()) + " truth acceptance cuts are used:\n";
249  for (const auto& i:m_cutList.names()) {
250  msg += i + "\n";
251  }
252  ATH_MSG_INFO(msg);
253 
254  ATH_CHECK(m_extrapolator.retrieve(EnableTool{ m_radiusCylinder > 0 || m_zDisc >0 }));
255 
256  return StatusCode::SUCCESS;
257 }

◆ 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 & IAthSelectionTool::interfaceID ( )
inlinestaticinherited

interfaceID reimplemented from base

Definition at line 73 of file IAthSelectionTool.h.

73  {
74  return IID_IAthSelectionTool;
75 }

◆ msg() [1/2]

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msg() [2/2]

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

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ 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  }

◆ names()

std::vector< std::string > AthTruthSelectionTool::names ( ) const
finalvirtual

return the names of the cuts as a vector<string>

Implements IAthSelectionTool.

Definition at line 267 of file AthTruthSelectionTool.cxx.

267  {
268  return m_cutList.names();
269 }

◆ nCuts()

unsigned int AthTruthSelectionTool::nCuts ( ) const
inlinefinalvirtual

return the number of cuts.

Returns
the number of cuts

Implements IAthSelectionTool.

Definition at line 43 of file AthTruthSelectionTool.h.

43  {
44  return m_cutList.size();
45  }

◆ 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.

◆ 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();
383  PBASE::renounce (h);
384  }

◆ 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  {
365  handlesArray.renounce();
366  }

◆ 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 DerivationFramework::CfAthAlgTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and asg::AsgMetadataTool.

◆ 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.

◆ testAllCuts()

IAthSelectionTool::CutResult AthTruthSelectionTool::testAllCuts ( const xAOD::IParticle p,
std::vector< unsigned int > &  counter 
) const
finalvirtual

The most important method to determine whether the particle is accepted.

Parameters
pPointer to particle baseclass, will be cast to truth or track
Returns
true if particle passes cuts

Implements IAthSelectionTool.

Definition at line 283 of file AthTruthSelectionTool.cxx.

283  {
284  const xAOD::TruthParticle* pTruth = dynamic_cast<const xAOD::TruthParticle*>(particle);
285 
286  //@TODO
287  if (not pTruth) {
288  return m_cutList.size()+1; // marker for invalid particles
289  }
290  return m_cutList.testAllCuts(*pTruth,counter);
291 }

◆ 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) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

Member Data Documentation

◆ m_ancestors

std::vector<int> AthTruthSelectionTool::m_ancestors
private

Definition at line 67 of file AthTruthSelectionTool.h.

◆ m_counters

std::vector<unsigned int> AthTruthSelectionTool::m_counters
private

Definition at line 66 of file AthTruthSelectionTool.h.

◆ m_cutList

CutList<xAOD::TruthParticle> AthTruthSelectionTool::m_cutList
private

Definition at line 50 of file AthTruthSelectionTool.h.

◆ m_cylinder

std::unique_ptr<Trk::CylinderSurface> AthTruthSelectionTool::m_cylinder
private

Definition at line 80 of file AthTruthSelectionTool.h.

◆ 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_disc1

std::unique_ptr<Trk::DiscSurface> AthTruthSelectionTool::m_disc1
private

Definition at line 81 of file AthTruthSelectionTool.h.

◆ m_disc2

std::unique_ptr<Trk::DiscSurface> AthTruthSelectionTool::m_disc2
private

Definition at line 82 of file AthTruthSelectionTool.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_extrapolator

PublicToolHandle<Trk::IExtrapolator> AthTruthSelectionTool::m_extrapolator {this,"Extrapolator","Trk::Extrapolator/AtlasExtrapolator",""}
private

Too handle for truth-track extrapolation.

Definition at line 88 of file AthTruthSelectionTool.h.

◆ m_grandparent

bool AthTruthSelectionTool::m_grandparent
private

Definition at line 64 of file AthTruthSelectionTool.h.

◆ m_maxEta

float AthTruthSelectionTool::m_maxEta
private

Definition at line 52 of file AthTruthSelectionTool.h.

◆ m_maxProdVertRadius

double AthTruthSelectionTool::m_maxProdVertRadius
private

Definition at line 62 of file AthTruthSelectionTool.h.

◆ m_maxPt

float AthTruthSelectionTool::m_maxPt
private

Definition at line 53 of file AthTruthSelectionTool.h.

◆ m_maxRadiusDisc

float AthTruthSelectionTool::m_maxRadiusDisc
private

for disk topology: maximum radius

Definition at line 77 of file AthTruthSelectionTool.h.

◆ m_maxZCylinder

float AthTruthSelectionTool::m_maxZCylinder
private

for cylinder topology: maximum |z|

Definition at line 74 of file AthTruthSelectionTool.h.

◆ m_minPt

float AthTruthSelectionTool::m_minPt
private

Definition at line 54 of file AthTruthSelectionTool.h.

◆ m_minRadiusDisc

float AthTruthSelectionTool::m_minRadiusDisc
private

for disk topology: minimum radius

Definition at line 76 of file AthTruthSelectionTool.h.

◆ m_minZCylinder

float AthTruthSelectionTool::m_minZCylinder
private

for cylinder topology: minimum |z|

Definition at line 73 of file AthTruthSelectionTool.h.

◆ m_pdgId

int AthTruthSelectionTool::m_pdgId
private

Definition at line 63 of file AthTruthSelectionTool.h.

◆ m_poselectronfromgamma

bool AthTruthSelectionTool::m_poselectronfromgamma
private

Definition at line 65 of file AthTruthSelectionTool.h.

◆ m_radiusCylinder

float AthTruthSelectionTool::m_radiusCylinder
private

for cylinder topology: radius of cylinder

Definition at line 72 of file AthTruthSelectionTool.h.

◆ m_requireCharged

bool AthTruthSelectionTool::m_requireCharged
private

Definition at line 56 of file AthTruthSelectionTool.h.

◆ m_requireOnlyPrimary

bool AthTruthSelectionTool::m_requireOnlyPrimary
private

Definition at line 55 of file AthTruthSelectionTool.h.

◆ m_requireSiHit

int AthTruthSelectionTool::m_requireSiHit
private

Definition at line 59 of file AthTruthSelectionTool.h.

◆ m_requireStable

bool AthTruthSelectionTool::m_requireStable
private

Definition at line 58 of file AthTruthSelectionTool.h.

◆ m_selectedCharge

int AthTruthSelectionTool::m_selectedCharge
private

Definition at line 57 of file AthTruthSelectionTool.h.

◆ 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.

◆ m_zDisc

float AthTruthSelectionTool::m_zDisc
private

for disk topology: Z position of disk

Definition at line 75 of file AthTruthSelectionTool.h.


The documentation for this class was generated from the following files:
Trk::anyDirection
@ anyDirection
Definition: PropDirection.h:22
AthTruthSelectionTool::m_grandparent
bool m_grandparent
Definition: AthTruthSelectionTool.h:64
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
AthTruthSelectionTool::m_cylinder
std::unique_ptr< Trk::CylinderSurface > m_cylinder
Definition: AthTruthSelectionTool.h:80
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Trk::ParametersBase::position
const Amg::Vector3D & position() const
Access method for the position.
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
AthTruthSelectionTool::m_pdgId
int m_pdgId
Definition: AthTruthSelectionTool.h:63
AthTruthSelectionTool::m_radiusCylinder
float m_radiusCylinder
for cylinder topology: radius of cylinder
Definition: AthTruthSelectionTool.h:72
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
AthTruthSelectionTool::m_requireStable
bool m_requireStable
Definition: AthTruthSelectionTool.h:58
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
AthTruthSelectionTool::m_requireCharged
bool m_requireCharged
Definition: AthTruthSelectionTool.h:56
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
AthTruthSelectionTool::m_counters
std::vector< unsigned int > m_counters
Definition: AthTruthSelectionTool.h:66
CutList
Templated CutList class to contain a group of cuts.
Definition: CutFlow.h:93
AthTruthSelectionTool::m_minRadiusDisc
float m_minRadiusDisc
for disk topology: minimum radius
Definition: AthTruthSelectionTool.h:76
AthTruthSelectionTool::m_ancestors
std::vector< int > m_ancestors
Definition: AthTruthSelectionTool.h:67
xAOD::TruthVertex_v1::y
float y() const
Vertex y displacement.
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:27
AthTruthSelectionTool::m_requireOnlyPrimary
bool m_requireOnlyPrimary
Definition: AthTruthSelectionTool.h:55
AthTruthSelectionTool::m_maxEta
float m_maxEta
Definition: AthTruthSelectionTool.h:52
AthTruthSelectionTool::m_disc1
std::unique_ptr< Trk::DiscSurface > m_disc1
Definition: AthTruthSelectionTool.h:81
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ParticleGun_EoverP_Config.momentum
momentum
Definition: ParticleGun_EoverP_Config.py:63
HepMC::is_simulation_particle
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
Definition: MagicNumbers.h:342
lumiFormat.i
int i
Definition: lumiFormat.py:85
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
Trk::pion
@ pion
Definition: ParticleHypothesis.h:29
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
xAOD::TruthParticle
TruthParticle_v1 TruthParticle
Typedef to implementation.
Definition: Event/xAOD/xAODTruth/xAODTruth/TruthParticle.h:15
test_pyathena.parent
parent
Definition: test_pyathena.py:15
AthTruthSelectionTool::m_poselectronfromgamma
bool m_poselectronfromgamma
Definition: AthTruthSelectionTool.h:65
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthTruthSelectionTool::m_maxProdVertRadius
double m_maxProdVertRadius
Definition: AthTruthSelectionTool.h:62
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::CurvilinearParametersT
Definition: CurvilinearParametersT.h:48
AthTruthSelectionTool::m_minPt
float m_minPt
Definition: AthTruthSelectionTool.h:54
AthAlgTool::AthAlgTool
AthAlgTool()
Default constructor:
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
xAOD::TruthVertex_v1
Class describing a truth vertex in the MC record.
Definition: TruthVertex_v1.h:37
AthTruthSelectionTool::m_selectedCharge
int m_selectedCharge
Definition: AthTruthSelectionTool.h:57
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
AthTruthSelectionTool::m_extrapolator
PublicToolHandle< Trk::IExtrapolator > m_extrapolator
Too handle for truth-track extrapolation.
Definition: AthTruthSelectionTool.h:89
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
AthTruthSelectionTool::m_requireSiHit
int m_requireSiHit
Definition: AthTruthSelectionTool.h:59
xAOD::TruthVertex_v1::x
float x() const
Vertex x displacement.
AthTruthSelectionTool::m_zDisc
float m_zDisc
for disk topology: Z position of disk
Definition: AthTruthSelectionTool.h:75
MC::isStable
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
Definition: HepMCHelpers.h:45
a
TList * a
Definition: liststreamerinfos.cxx:10
h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xAOD::TruthVertex_v1::z
float z() const
Vertex longitudinal distance along the beam line form the origin.
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition: GeoPrimitives.h:44
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:623
AthTruthSelectionTool::m_disc2
std::unique_ptr< Trk::DiscSurface > m_disc2
Definition: AthTruthSelectionTool.h:82
AthTruthSelectionTool::m_maxPt
float m_maxPt
Definition: AthTruthSelectionTool.h:53
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
AthTruthSelectionTool::m_cutList
CutList< xAOD::TruthParticle > m_cutList
Definition: AthTruthSelectionTool.h:50
Accept
Templated class containing a cut, name of cut and description of cut(optional) Typically,...
Definition: CutFlow.h:28
AthTruthSelectionTool::m_minZCylinder
float m_minZCylinder
for cylinder topology: minimum |z|
Definition: AthTruthSelectionTool.h:73
test_pyathena.counter
counter
Definition: test_pyathena.py:15
AthTruthSelectionTool::m_maxRadiusDisc
float m_maxRadiusDisc
for disk topology: maximum radius
Definition: AthTruthSelectionTool.h:77
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
fitman.k
k
Definition: fitman.py:528
AthTruthSelectionTool::m_maxZCylinder
float m_maxZCylinder
for cylinder topology: maximum |z|
Definition: AthTruthSelectionTool.h:74