ATLAS Offline Software
ParticleLevelIsolationAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8 
9 namespace CP {
10 
12 
14 
15  // decorators
17  std::make_unique<SG::AuxElement::Decorator<char>>(m_isolated.value());
19  std::make_unique<SG::AuxElement::Decorator<char>>(m_notTauOrigin.value());
20 
21  // accessors
22  if (m_isolationVariable.value() != "") {
23  m_acc_isoVar = std::make_unique<SG::AuxElement::ConstAccessor<float>>(
24  m_isolationVariable.value());
25  }
26 
27  // set up MCTruthClassifier comparisons
28  MCTruthPartClassifier::ParticleDef partDef;
29  const auto it =
30  std::find(partDef.sParticleType.begin(), partDef.sParticleType.end(),
31  m_checkTypeName.value());
32  if (it == partDef.sParticleType.end()) {
34  "checkType = "
35  << m_checkTypeName.value()
36  << " is not a valid MCTruthPartClassifier::ParticleType string!");
37  return StatusCode::FAILURE;
38  } else {
40  std::distance(partDef.sParticleType.begin(), it));
41  }
42 
43  return StatusCode::SUCCESS;
44 }
45 
47 
49 
50  // accessors
51  static const SG::AuxElement::ConstAccessor<unsigned int> acc_type(
52  "classifierParticleType");
53  static const SG::AuxElement::ConstAccessor<unsigned int> acc_orig(
54  "classifierParticleOrigin");
55 
56  // decorators
57  static const SG::AuxElement::Decorator<float> dec_charge("charge");
58 
59  for (const auto* particle : *particles) {
60 
61  // check the particle is isolated
62  if (acc_type.isAvailable(*particle)) {
63  bool isolation = acc_type(*particle) == m_checkType;
64  // check further custom isolation cuts
65  if (m_acc_isoVar && isolation) {
66  if ((*m_acc_isoVar).isAvailable(*particle)) {
67  isolation =
68  isolation && ((*m_acc_isoVar)(*particle) / particle->pt() <
69  m_isolationCut.value());
70  } else {
71  ANA_MSG_ERROR("Truth particle is missing the decoration: "
72  << m_isolationVariable.value() << ".");
73  return StatusCode::FAILURE;
74  }
75  }
76  (*m_dec_isolated)(*particle) = isolation;
77  } else {
79  "Truth particle is missing the decoration: classifierParticleType.");
80  return StatusCode::FAILURE;
81  }
82 
83  // check the particle doesn't come from a tau decay
84  if (acc_orig.isAvailable(*particle)) {
85  (*m_dec_notTauOrigin)(*particle) =
87  } else {
89  "Truth particle is missing the decoration: "
90  "classifierParticleOrigin.");
91  return StatusCode::FAILURE;
92  }
93  }
94  return StatusCode::SUCCESS;
95 }
96 
97 } // namespace CP
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
TauLep
@ TauLep
Definition: TruthClasses.h:63
CP::ParticleLevelIsolationAlg::m_acc_isoVar
std::unique_ptr< const SG::AuxElement::ConstAccessor< float > > m_acc_isoVar
Definition: ParticleLevelIsolationAlg.h:47
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
CP::ParticleLevelIsolationAlg::m_dec_notTauOrigin
std::unique_ptr< const SG::AuxElement::Decorator< char > > m_dec_notTauOrigin
Definition: ParticleLevelIsolationAlg.h:46
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
CP::ParticleLevelIsolationAlg::m_dec_isolated
std::unique_ptr< const SG::AuxElement::Decorator< char > > m_dec_isolated
Definition: ParticleLevelIsolationAlg.h:45
CP::ParticleLevelIsolationAlg::m_isolated
Gaudi::Property< std::string > m_isolated
Definition: ParticleLevelIsolationAlg.h:30
skel.it
it
Definition: skel.GENtoEVGEN.py:396
CP::ParticleLevelIsolationAlg::execute
virtual StatusCode execute() final
Definition: ParticleLevelIsolationAlg.cxx:46
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
CP::ParticleLevelIsolationAlg::m_notTauOrigin
Gaudi::Property< std::string > m_notTauOrigin
Definition: ParticleLevelIsolationAlg.h:32
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::ParticleLevelIsolationAlg::m_isolationCut
Gaudi::Property< float > m_isolationCut
Definition: ParticleLevelIsolationAlg.h:41
CP::ParticleLevelIsolationAlg::m_particlesKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_particlesKey
Definition: ParticleLevelIsolationAlg.h:28
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
CP::ParticleLevelIsolationAlg::initialize
virtual StatusCode initialize() final
Definition: ParticleLevelIsolationAlg.cxx:11
CP::ParticleLevelIsolationAlg::m_isolationVariable
Gaudi::Property< std::string > m_isolationVariable
Definition: ParticleLevelIsolationAlg.h:38
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
CP::ParticleLevelIsolationAlg::m_checkTypeName
Gaudi::Property< std::string > m_checkTypeName
Definition: ParticleLevelIsolationAlg.h:35
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
CP::ParticleLevelIsolationAlg::m_checkType
MCTruthPartClassifier::ParticleType m_checkType
Definition: ParticleLevelIsolationAlg.h:44
ParticleType
ParticleType
Definition: TruthClasses.h:8
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
ParticleLevelIsolationAlg.h