ATLAS Offline Software
SUSYGenFilterTool.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 
8 #include "xAODJet/JetContainer.h"
11 
12 namespace DerivationFramework {
13 
14  using namespace MCTruthPartClassifier;
15 
16  static const SG::AuxElement::Decorator<float> dec_genFiltHT("GenFiltHT");
17  static const SG::AuxElement::Decorator<float> dec_genFiltMET("GenFiltMET");
18 
19  SUSYGenFilterTool::SUSYGenFilterTool(const std::string& t, const std::string& n, const IInterface* p):
20  AthAlgTool(t,n,p),
21  m_classif("MCTruthClassifier/SUSYGenFilt_MCTruthClassifier")
22  {
23 
24  declareInterface<DerivationFramework::IAugmentationTool>(this);
25 
26  declareProperty("EventInfoName",m_eventInfoName="EventInfo");
27  declareProperty("MCCollectionName",m_mcName="TruthParticles");
28  declareProperty("TruthJetCollectionName",m_truthJetsName="AntiKt4TruthWZJets");
29  declareProperty("MinJetPt",m_MinJetPt = 35e3);
30  declareProperty("MaxJetEta",m_MaxJetEta = 2.5);
31  declareProperty("MinLeptonPt",m_MinLepPt = 25e3);
32  declareProperty("MaxLeptonEta",m_MaxLepEta = 2.5);
33  }
34 
35 
36 
38 
39 
40 
42 
43  ATH_MSG_INFO("Initialize " );
44 
45  return StatusCode::SUCCESS;
46 
47  }
48 
49 
51  {
52  ParticleOrigin orig = m_classif->particleTruthClassifier( tp ).second;
53  ATH_MSG_VERBOSE("Particle has origin " << orig);
54 
55  switch(orig) {
56  case PhotonConv:
57  case DalitzDec:
58  case ElMagProc:
59  case Mu:
60  case TauLep:
61  case LightMeson:
62  case StrangeMeson:
63  case CharmedMeson:
64  case BottomMeson:
65  case CCbarMeson:
66  case JPsi:
67  case BBbarMeson:
68  case LightBaryon:
69  case StrangeBaryon:
70  case CharmedBaryon:
71  case BottomBaryon:
72  case PionDecay:
73  case KaonDecay:
74  return false;
75  default:
76  break;
77  }
78  return true;
79  }
80 
82  ATH_MSG_VERBOSE("SUSYGenFilterTool::addBranches()");
83 
84  const xAOD::EventInfo* eventInfo;
85  if (evtStore()->retrieve(eventInfo,m_eventInfoName).isFailure()) {
86  ATH_MSG_ERROR("could not retrieve event info " <<m_eventInfoName);
87  return StatusCode::FAILURE;
88  }
89 
90  const xAOD::TruthParticleContainer* truthPC = 0;
91  if (evtStore()->retrieve(truthPC,m_mcName).isFailure()) {
92  ATH_MSG_ERROR("WARNING could not retrieve TruthParticleContainer " <<m_mcName);
93  return StatusCode::FAILURE;
94  }
95 
96  float genFiltHT(0.), genFiltMET(0.);
97  ATH_CHECK( getGenFiltVars(truthPC, genFiltHT, genFiltMET) );
98 
99  ATH_MSG_DEBUG("Computed generator filter quantities: HT " << genFiltHT/1e3 << ", MET " << genFiltMET/1e3 );
100 
101  dec_genFiltHT(*eventInfo) = genFiltHT;
102  dec_genFiltMET(*eventInfo) = genFiltMET;
103 
104  return StatusCode::SUCCESS;
105  }
106 
107  StatusCode SUSYGenFilterTool::getGenFiltVars(const xAOD::TruthParticleContainer* tpc, float& genFiltHT, float& genFiltMET) const {
108  // Get jet container out
109  const xAOD::JetContainer* truthjets = 0;
110  if ( evtStore()->retrieve( truthjets, m_truthJetsName).isFailure() || !truthjets ){
111  ATH_MSG_ERROR( "No xAOD::JetContainer found in StoreGate with key " << m_truthJetsName );
112  return StatusCode::FAILURE;
113  }
114 
115  // Get HT
116  genFiltHT = -1;
117  for (const auto tj : *truthjets) {
118  if ( tj->pt()>m_MinJetPt && fabs(tj->eta())<m_MaxJetEta ) {
119  ATH_MSG_VERBOSE("Adding truth jet with pt " << tj->pt()
120  << ", eta " << tj->eta()
121  << ", phi " << tj->phi()
122  << ", nconst = " << tj->numConstituents());
123  genFiltHT += tj->pt();
124  }
125  }
126 
127  float MEx(0.), MEy(0.);
128  for (const auto tp : *tpc){
129  int pdgid = tp->pdgId();
130  if (HepMC::is_simulation_particle(tp)) continue; // Particle is from G4
131  if (MC::isZeroEnergyPhoton(tp)) continue; // Work around for an old generator bug
132  if ( !MC::isStable(tp) ) continue; // Stable!
133 
134  if ((std::abs(pdgid)==11 || std::abs(pdgid)==13) && tp->pt()>m_MinLepPt && std::fabs(tp->eta())<m_MaxLepEta) {
135  if( isPrompt(tp) ) {
136  ATH_MSG_VERBOSE("Adding prompt lepton with pt " << tp->pt()
137  << ", eta " << tp->eta()
138  << ", phi " << tp->phi()
139  << ", status " << tp->status()
140  << ", pdgId " << pdgid);
141  genFiltHT += tp->pt();
142  }
143  }
144 
146  ATH_MSG_VERBOSE("Found prompt nonInteracting particle with pt " << tp->pt()
147  << ", eta " << tp->eta()
148  << ", phi " << tp->phi()
149  << ", status " << tp->status()
150  << ", pdgId " << pdgid);
151  MEx += tp->px();
152  MEy += tp->py();
153  }
154  }
155  genFiltMET = sqrt(MEx*MEx+MEy*MEy);
156 
157  return StatusCode::SUCCESS;
158  }
159 
160 
161 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
SUSYGenFilterTool.h
DerivationFramework::SUSYGenFilterTool::~SUSYGenFilterTool
~SUSYGenFilterTool()
Definition: SUSYGenFilterTool.cxx:37
TauLep
@ TauLep
Definition: TruthClasses.h:63
StrangeMeson
@ StrangeMeson
Definition: TruthClasses.h:80
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
DerivationFramework::SUSYGenFilterTool::isPrompt
bool isPrompt(const xAOD::TruthParticle *tp) const
Definition: SUSYGenFilterTool.cxx:50
Mu
@ Mu
Definition: TruthClasses.h:62
BBbarMeson
@ BBbarMeson
Definition: TruthClasses.h:85
BottomMeson
@ BottomMeson
Definition: TruthClasses.h:82
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DerivationFramework::SUSYGenFilterTool::m_MinJetPt
float m_MinJetPt
Min pT for the truth jets.
Definition: SUSYGenFilterTool.h:49
MC::isSpecialNonInteracting
bool isSpecialNonInteracting(const T &p)
Definition: HepMCHelpers.h:57
PionDecay
@ PionDecay
Definition: TruthClasses.h:90
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ElMagProc
@ ElMagProc
Definition: TruthClasses.h:61
DerivationFramework::SUSYGenFilterTool::addBranches
virtual StatusCode addBranches() const override
Pass the thinning service
Definition: SUSYGenFilterTool.cxx:81
DerivationFramework::SUSYGenFilterTool::m_MinLepPt
float m_MinLepPt
Min pT for the truth leptons.
Definition: SUSYGenFilterTool.h:51
ParticleTest.tp
tp
Definition: ParticleTest.py:25
PhotonConv
@ PhotonConv
Definition: TruthClasses.h:59
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DerivationFramework::SUSYGenFilterTool::initialize
virtual StatusCode initialize() override
Definition: SUSYGenFilterTool.cxx:41
CCbarMeson
@ CCbarMeson
Definition: TruthClasses.h:83
DerivationFramework::SUSYGenFilterTool::SUSYGenFilterTool
SUSYGenFilterTool(const std::string &t, const std::string &n, const IInterface *p)
Definition: SUSYGenFilterTool.cxx:19
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
CharmedBaryon
@ CharmedBaryon
Definition: TruthClasses.h:88
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CheckAppliedSFs.e3
e3
Definition: CheckAppliedSFs.py:264
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:58
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:299
DerivationFramework::SUSYGenFilterTool::m_mcName
std::string m_mcName
Definition: SUSYGenFilterTool.h:46
beamspotman.n
n
Definition: beamspotman.py:731
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
ParticleOrigin
ParticleOrigin
Definition: TruthClasses.h:51
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:41
StrangeBaryon
@ StrangeBaryon
Definition: TruthClasses.h:87
LightMeson
@ LightMeson
Definition: TruthClasses.h:79
DerivationFramework::SUSYGenFilterTool::m_MaxLepEta
float m_MaxLepEta
Max eta for the truth leptons.
Definition: SUSYGenFilterTool.h:52
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
JPsi
@ JPsi
Definition: TruthClasses.h:84
CharmedMeson
@ CharmedMeson
Definition: TruthClasses.h:81
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
DerivationFramework::SUSYGenFilterTool::m_MaxJetEta
float m_MaxJetEta
Max eta for the truth jets.
Definition: SUSYGenFilterTool.h:50
MagicNumbers.h
BottomBaryon
@ BottomBaryon
Definition: TruthClasses.h:89
LightBaryon
@ LightBaryon
Definition: TruthClasses.h:86
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
MC::isStable
bool isStable(const T &p)
Definition: HepMCHelpers.h:30
DerivationFramework::SUSYGenFilterTool::m_truthJetsName
std::string m_truthJetsName
Definition: SUSYGenFilterTool.h:47
JetContainer.h
MCTruthPartClassifier
Definition: TruthClassifiers.h:12
DerivationFramework::SUSYGenFilterTool::m_classif
ToolHandle< IMCTruthClassifier > m_classif
Definition: SUSYGenFilterTool.h:54
DalitzDec
@ DalitzDec
Definition: TruthClasses.h:60
MC::isZeroEnergyPhoton
bool isZeroEnergyPhoton(const T &p)
Identify a photon with zero energy. Probably a workaround for a generator bug.
Definition: HepMCHelpers.h:53
AthAlgTool
Definition: AthAlgTool.h:26
DerivationFramework::SUSYGenFilterTool::getGenFiltVars
StatusCode getGenFiltVars(const xAOD::TruthParticleContainer *tpc, float &genFiltHT, float &genFiltMET) const
Definition: SUSYGenFilterTool.cxx:107
KaonDecay
@ KaonDecay
Definition: TruthClasses.h:91
DerivationFramework::SUSYGenFilterTool::m_eventInfoName
std::string m_eventInfoName
Definition: SUSYGenFilterTool.h:45
HepMCHelpers.h