Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
DerivationFramework::TruthIsolationTool Class Reference

#include <TruthIsolationTool.h>

Inheritance diagram for DerivationFramework::TruthIsolationTool:
Collaboration diagram for DerivationFramework::TruthIsolationTool:

Public Member Functions

 TruthIsolationTool (const std::string &t, const std::string &n, const IInterface *p)
 
 ~TruthIsolationTool ()
 
virtual StatusCode initialize () override
 
virtual StatusCode addBranches () const override
 

Private Member Functions

void calcIsos (const xAOD::TruthParticle *particle, const std::vector< const xAOD::TruthParticle * > &, std::vector< float > &) const
 

Static Private Member Functions

static float calculateDeltaR2 (const xAOD::IParticle *p1, float eta2, float phi2)
 

Private Attributes

SG::ReadHandleKey< xAOD::TruthParticleContainerm_isoParticlesKey {this, "isoParticlesKey", "TruthParticles", "Name of TruthParticle key for input"}
 Parameter: input collection key. More...
 
SG::ReadHandleKey< xAOD::TruthParticleContainerm_allParticlesKey {this, "allParticlesKey", "TruthParticles", "Name of Truthparticle key to find in iso cone"}
 Parameter: input collection key for particles used in calculation. More...
 
SG::WriteDecorHandleKeyArray< xAOD::TruthParticleContainer, float > m_isoDecorKeys {this, "DoNotSet_isoDecorKeys", {}, "WriteDecorHandleKeyArray - set internally but must be property"}
 Decor handle key array. More...
 
Gaudi::Property< std::vector< float > > m_coneSizes {this, "IsolationConeSizes", {0.2}, "Vector of sizes of dR cone in which to include particles"}
 Parameter: Cone size for Isolation. More...
 
Gaudi::Property< bool > m_chargedOnly {this, "ChargedParticlesOnly", false, "Only keep charged particles in isolation cone"}
 Parameter: only use charged particles for iso? More...
 
Gaudi::Property< std::vector< int > > m_listOfPIDs {this, "particleIDsToCalculate", {11,13,22}, "List of the pdgIDs of particles for which to calculate isolation"}
 Parameter: List of pdgIDs of particles to dress. More...
 
Gaudi::Property< std::vector< int > > m_excludeFromCone {this, "excludeIDsFromCone", {}, "List of the pdgIDs of particles to exclude from the cone when calculating isolation"}
 Parameter: List of pdgIDs to exclude from cone calculation. More...
 
Gaudi::Property< std::string > m_isoVarNamePrefix {this, "IsolationVarNamePrefix", "", "Prefix of name of the variable to add to output xAOD"}
 Parameter: name of output variable. More...
 
Gaudi::Property< bool > m_includeNonInteracting {this, "IncludeNonInteracting", false, "Include non-interacting particles in the isolation definition"}
 Parameter: Include non-interacting particles? More...
 
Gaudi::Property< bool > m_variableR {this, "VariableR", false, "Use radius that shrinks with pT in isolation"}
 Parameter: Use variable radius? More...
 
std::vector< float > m_coneSizesSort
 

Detailed Description

Definition at line 21 of file DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h.

Constructor & Destructor Documentation

◆ TruthIsolationTool()

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

Definition at line 17 of file DerivationFramework/DerivationFrameworkMCTruth/src/TruthIsolationTool.cxx.

19  :
20  base_class(t,n,p)
21 {
22 }

◆ ~TruthIsolationTool()

TruthIsolationTool::~TruthIsolationTool ( )

Member Function Documentation

◆ addBranches()

StatusCode TruthIsolationTool::addBranches ( ) const
overridevirtual

Even if this is with some dummy value

Definition at line 53 of file DerivationFramework/DerivationFrameworkMCTruth/src/TruthIsolationTool.cxx.

54 {
55  // Event context
56  const EventContext& ctx = Gaudi::Hive::currentContext();
57 
58  // Retrieve the truth collections
60  if (!isoTruthParticles.isValid()) {
61  ATH_MSG_ERROR("Couldn't retrieve collection with name " << m_isoParticlesKey);
62  return StatusCode::FAILURE;
63  }
64 
66  if (!allTruthParticles.isValid()) {
67  ATH_MSG_ERROR("Couldn't retrieve collection with name " << m_allParticlesKey);
68  return StatusCode::FAILURE;
69  }
70 
71  //get struct of helper functions
73 
74  // Isolation is applied to selected particles only
75  std::vector<const xAOD::TruthParticle*> listOfParticlesForIso;
76  decayHelper.constructListOfFinalParticles(isoTruthParticles.ptr(), listOfParticlesForIso, m_listOfPIDs);
77 
78  // Vectors to store particles which will be dressed
79  std::vector<const xAOD::TruthParticle*> candidateParticlesList;
80 
81  std::vector<int> emptyList;
82  //make a list of all candidate particles that could fall inside the cone of the particle of interest from listOfParticlesForIso
83  decayHelper.constructListOfFinalParticles(allTruthParticles.ptr(), candidateParticlesList, emptyList, true, m_chargedOnly);
84 
85  std::vector<SG::WriteDecorHandle< xAOD::TruthParticleContainer, float > >
86  decorator_iso = m_isoDecorKeys.makeHandles (ctx);
87 
88  //All isolation must filled for all Particles.
90  for ( unsigned int icone = 0; icone < m_coneSizesSort.size(); ++icone ) {
91  for (const auto part : *isoTruthParticles) {
92  decorator_iso.at(icone)(*part) = -1;
93  }
94  }
95 
96  // Standard particle loop over final state particles of interest
97  for (const auto& part : listOfParticlesForIso) {
98  std::vector<float> isolationsCalcs(m_coneSizesSort.size(), 0.0);
99  calcIsos(part, candidateParticlesList, isolationsCalcs);
100  for ( unsigned int icone = 0; icone < m_coneSizesSort.size(); ++icone ) {
101  decorator_iso.at(icone)(*part) = isolationsCalcs.at(icone);
102  }
103  }
104 
105  return StatusCode::SUCCESS;
106 }

◆ calcIsos()

void TruthIsolationTool::calcIsos ( const xAOD::TruthParticle particle,
const std::vector< const xAOD::TruthParticle * > &  candidateParticlesList,
std::vector< float > &  isoCalcs 
) const
private

Definition at line 108 of file DerivationFramework/DerivationFrameworkMCTruth/src/TruthIsolationTool.cxx.

111 {
112  //given a bare TruthParticle particle, calculate the isolation(s) using the
113  //particles in candidateParticlesList, filling isoCalcs in order corresponding
114  //to the sorted cone sizes
115 
116  float part_eta = particle->eta();
117  float part_phi = particle->phi();
118  for (const auto& cand_part : candidateParticlesList) {
119  if (find(m_excludeFromCone.begin(), m_excludeFromCone.end(), cand_part->pdgId()) != m_excludeFromCone.end()) {
120  //skip if we find a particle in the exclude list
121  continue;
122  }
123  if (!m_includeNonInteracting && !MC::isInteracting(cand_part->pdgId())){
124  // Do not include non-interacting particles, and this particle is non-interacting
125  continue;
126  }
127  if (!HepMC::is_same_particle(cand_part,particle)) {
128  //iteration over sorted cone sizes
129  for ( unsigned int icone = 0; icone < m_coneSizesSort.size(); ++icone ) {
130  const float dr2 = calculateDeltaR2(cand_part, part_eta, part_phi);
131  const float coneSize = m_coneSizesSort.at(icone);
132  if (dr2 < coneSize*coneSize &&
133  (!m_variableR || dr2*particle->pt()*particle->pt() < 100000000.)) {
134  //sum the transverse momenta
135  isoCalcs.at(icone) = isoCalcs.at(icone) + cand_part->pt();
136  } else {
137  //break out of the loop safely since the cone sizes are sorted descending
138  break;
139  }
140  }
141  }
142  }
143  return;
144 }

◆ calculateDeltaR2()

float TruthIsolationTool::calculateDeltaR2 ( const xAOD::IParticle p1,
float  eta2,
float  phi2 
)
staticprivate

Definition at line 146 of file DerivationFramework/DerivationFrameworkMCTruth/src/TruthIsolationTool.cxx.

147 {
148  //calculate dR^2 this way to hopefully do fewer sqrt and TVector3::Pseudorapidity calls
149  float phi1 = p1->phi();
150  float eta1 = p1->eta();
151  float deltaPhi = fabs(phi1-phi2);
152  if (deltaPhi>TMath::Pi()) deltaPhi = 2.0*TMath::Pi() - deltaPhi;
153  float deltaPhiSq = deltaPhi * deltaPhi;
154  float deltaEtaSq = (eta1-eta2)*(eta1-eta2);
155  return deltaPhiSq+deltaEtaSq;
156 }

◆ initialize()

StatusCode TruthIsolationTool::initialize ( )
overridevirtual

Definition at line 29 of file DerivationFramework/DerivationFrameworkMCTruth/src/TruthIsolationTool.cxx.

30 {
31 
32  // Initialise input keys
35 
36  //sort (descsending) the cone sizes vector to optimize calculation
38  std::sort(m_coneSizesSort.begin(), m_coneSizesSort.end(), [](float a, float b){return a>b;});
39 
40  // Decorations depend on the list of cone sizes
41  for ( auto csize_itr : m_coneSizesSort ) {
42  std::ostringstream sizess;
43  if (m_variableR) sizess << "var";
44  sizess << m_isoVarNamePrefix.value() << (int)((csize_itr)*100.);
45  m_isoDecorKeys.emplace_back(m_isoParticlesKey.key()+"."+sizess.str());
46  }
47  ATH_CHECK(m_isoDecorKeys.initialize());
48 
49  return StatusCode::SUCCESS;
50 }

Member Data Documentation

◆ m_allParticlesKey

SG::ReadHandleKey<xAOD::TruthParticleContainer> DerivationFramework::TruthIsolationTool::m_allParticlesKey {this, "allParticlesKey", "TruthParticles", "Name of Truthparticle key to find in iso cone"}
private

Parameter: input collection key for particles used in calculation.

Definition at line 33 of file DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h.

◆ m_chargedOnly

Gaudi::Property<bool> DerivationFramework::TruthIsolationTool::m_chargedOnly {this, "ChargedParticlesOnly", false, "Only keep charged particles in isolation cone"}
private

Parameter: only use charged particles for iso?

Definition at line 42 of file DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h.

◆ m_coneSizes

Gaudi::Property<std::vector<float> > DerivationFramework::TruthIsolationTool::m_coneSizes {this, "IsolationConeSizes", {0.2}, "Vector of sizes of dR cone in which to include particles"}
private

Parameter: Cone size for Isolation.

Definition at line 39 of file DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h.

◆ m_coneSizesSort

std::vector<float> DerivationFramework::TruthIsolationTool::m_coneSizesSort
private

◆ m_excludeFromCone

Gaudi::Property<std::vector<int> > DerivationFramework::TruthIsolationTool::m_excludeFromCone {this, "excludeIDsFromCone", {}, "List of the pdgIDs of particles to exclude from the cone when calculating isolation"}
private

Parameter: List of pdgIDs to exclude from cone calculation.

Definition at line 48 of file DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h.

◆ m_includeNonInteracting

Gaudi::Property<bool> DerivationFramework::TruthIsolationTool::m_includeNonInteracting {this, "IncludeNonInteracting", false, "Include non-interacting particles in the isolation definition"}
private

Parameter: Include non-interacting particles?

Definition at line 54 of file DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h.

◆ m_isoDecorKeys

SG::WriteDecorHandleKeyArray<xAOD::TruthParticleContainer, float> DerivationFramework::TruthIsolationTool::m_isoDecorKeys {this, "DoNotSet_isoDecorKeys", {}, "WriteDecorHandleKeyArray - set internally but must be property"}
private

◆ m_isoParticlesKey

SG::ReadHandleKey<xAOD::TruthParticleContainer> DerivationFramework::TruthIsolationTool::m_isoParticlesKey {this, "isoParticlesKey", "TruthParticles", "Name of TruthParticle key for input"}
private

Parameter: input collection key.

Definition at line 30 of file DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h.

◆ m_isoVarNamePrefix

Gaudi::Property<std::string> DerivationFramework::TruthIsolationTool::m_isoVarNamePrefix {this, "IsolationVarNamePrefix", "", "Prefix of name of the variable to add to output xAOD"}
private

Parameter: name of output variable.

Definition at line 51 of file DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h.

◆ m_listOfPIDs

Gaudi::Property<std::vector<int> > DerivationFramework::TruthIsolationTool::m_listOfPIDs {this, "particleIDsToCalculate", {11,13,22}, "List of the pdgIDs of particles for which to calculate isolation"}
private

Parameter: List of pdgIDs of particles to dress.

Definition at line 45 of file DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h.

◆ m_variableR

Gaudi::Property<bool> DerivationFramework::TruthIsolationTool::m_variableR {this, "VariableR", false, "Use radius that shrinks with pT in isolation"}
private

The documentation for this class was generated from the following files:
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
DerivationFramework::TruthIsolationTool::m_isoParticlesKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_isoParticlesKey
Parameter: input collection key.
Definition: DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h:31
P4Helpers::deltaEtaSq
double deltaEtaSq(const I4Momentum &p1, const I4Momentum &p2)
Computes efficiently .
Definition: P4Helpers.h:98
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
ParticleGun_SamplingFraction.eta2
eta2
Definition: ParticleGun_SamplingFraction.py:96
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
SG::ReadHandle< xAOD::TruthParticleContainer >
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
DerivationFramework::TruthIsolationTool::m_isoVarNamePrefix
Gaudi::Property< std::string > m_isoVarNamePrefix
Parameter: name of output variable.
Definition: DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h:52
DerivationFramework::TruthIsolationTool::m_coneSizesSort
std::vector< float > m_coneSizesSort
Definition: DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h:60
xAOD::eta1
setEt setPhi setE277 setWeta2 eta1
Definition: TrigEMCluster_v1.cxx:41
DerivationFramework::DecayGraphHelper::constructListOfFinalParticles
bool constructListOfFinalParticles(const xAOD::TruthParticleContainer *allParticles, std::vector< const xAOD::TruthParticle * > &selectedlist, const std::vector< int > &pdgId, bool allowFromHadron=false, bool chargedOnly=false) const
Definition: DecayGraphHelper.h:218
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
DerivationFramework::TruthIsolationTool::m_listOfPIDs
Gaudi::Property< std::vector< int > > m_listOfPIDs
Parameter: List of pdgIDs of particles to dress.
Definition: DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h:46
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
DerivationFramework::TruthIsolationTool::m_chargedOnly
Gaudi::Property< bool > m_chargedOnly
Parameter: only use charged particles for iso?
Definition: DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h:43
HepMC::is_same_particle
bool is_same_particle(const T1 &p1, const T2 &p2)
Method to establish if two particles in the GenEvent actually represent the same particle.
Definition: MagicNumbers.h:367
DerivationFramework::TruthIsolationTool::calcIsos
void calcIsos(const xAOD::TruthParticle *particle, const std::vector< const xAOD::TruthParticle * > &, std::vector< float > &) const
Definition: DerivationFramework/DerivationFrameworkMCTruth/src/TruthIsolationTool.cxx:108
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DerivationFramework::TruthIsolationTool::m_allParticlesKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_allParticlesKey
Parameter: input collection key for particles used in calculation.
Definition: DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h:34
beamspotman.n
n
Definition: beamspotman.py:731
DerivationFramework::TruthIsolationTool::m_variableR
Gaudi::Property< bool > m_variableR
Parameter: Use variable radius?
Definition: DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h:58
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
DerivationFramework::TruthIsolationTool::m_coneSizes
Gaudi::Property< std::vector< float > > m_coneSizes
Parameter: Cone size for Isolation.
Definition: DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h:40
P4Helpers::deltaPhiSq
double deltaPhiSq(const I4Momentum &pA, const I4Momentum &pB)
delta Phi squared in range ([-pi,pi[)^2 from two I4momentum references
Definition: P4Helpers.h:185
DerivationFramework::TruthIsolationTool::m_includeNonInteracting
Gaudi::Property< bool > m_includeNonInteracting
Parameter: Include non-interacting particles?
Definition: DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h:55
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
DerivationFramework::DecayGraphHelper
Definition: DecayGraphHelper.h:26
DerivationFramework::TruthIsolationTool::m_excludeFromCone
Gaudi::Property< std::vector< int > > m_excludeFromCone
Parameter: List of pdgIDs to exclude from cone calculation.
Definition: DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h:49
a
TList * a
Definition: liststreamerinfos.cxx:10
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
DerivationFramework::TruthIsolationTool::m_isoDecorKeys
SG::WriteDecorHandleKeyArray< xAOD::TruthParticleContainer, float > m_isoDecorKeys
Decor handle key array.
Definition: DerivationFramework/DerivationFrameworkMCTruth/DerivationFrameworkMCTruth/TruthIsolationTool.h:37
DerivationFramework::TruthIsolationTool::calculateDeltaR2
static float calculateDeltaR2(const xAOD::IParticle *p1, float eta2, float phi2)
Definition: DerivationFramework/DerivationFrameworkMCTruth/src/TruthIsolationTool.cxx:146
MC::isInteracting
bool isInteracting(const T &p)
Identify if the particle with given PDG ID would not interact with the detector, i....
Definition: HepMCHelpers.h:33
xAOD::Iso::coneSize
float coneSize(IsolationConeSize type)
convert Isolation Size into cone size
Definition: IsolationHelpers.h:27