ATLAS Offline Software
MultiElecMuTauFilter.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 #include "CLHEP/Vector/LorentzVector.h"
8 
9 MultiElecMuTauFilter::MultiElecMuTauFilter(const std::string& name, ISvcLocator* pSvcLocator)
10  : GenFilter(name,pSvcLocator)
11 {
12 declareProperty("MinPt", m_minPt = 5000. );
13 declareProperty("MaxEta", m_maxEta = 10.0 );
14 declareProperty("MinVisPtHadTau", m_minVisPtHadTau = 10000.);
15 declareProperty("NLeptons", m_NLeptons = 4 );
16 declareProperty("IncludeHadTaus", m_incHadTau = true );
17 declareProperty("TwoSameSignLightLeptonsOneHadTau", m_TwoSameSignLightLeptonsOneHadTau = false );
18 }
19 
20 
22  int numLeptons = 0;
23  int numLightLeptons = 0;
24  int numHadTaus = 0;
26  if (m_NLeptons!=3) ATH_MSG_ERROR("TwoSameSignLightLeptonsOneHadTau request possible only for NLeptons = 3. Check your jobOptions.");
27  }
28  int charge1 = 0;
29  int charge2 = 0;
30 
32  for (itr = events()->begin(); itr != events()->end(); ++itr) {
33  const HepMC::GenEvent* genEvt = *itr;
34  for (const auto& pitr: *genEvt) {
35  // Electrons and muons
36  if (MC::isStable(pitr) && (MC::isElectron(pitr) || MC::isMuon(pitr))) {
37  if (pitr->momentum().perp() >= m_minPt && std::abs(pitr->momentum().pseudoRapidity()) <= m_maxEta) {
38  ATH_MSG_DEBUG("Found lepton " << pitr);
39  numLeptons++;
40  numLightLeptons++;
41  if (numLightLeptons==1) { if (pitr->pdg_id() < 0) { charge1 = -1; } else { charge1 = 1; } }
42  if (numLightLeptons==2) { if (pitr->pdg_id() < 0) { charge2 = -1; } else { charge2 = 1; } }
43 
44  }
45  continue;
46  }
47 
48  // Look for Hadronic taus (leptonic ones will be saved by above) that have status!=3 and don't decay to another tau (FSR)
49  if (!m_incHadTau) continue;
50  HepMC::ConstGenParticlePtr tau= nullptr;
51  HepMC::ConstGenParticlePtr taunu= nullptr;
52  if (MC::isTau(pitr) || !MC::isPhysical(pitr)) continue;
53  tau = pitr;
54  if(!tau->end_vertex()) continue;
55  // Loop over children and:
56  // 1. Find if it is hadronic (i.e. no decay lepton).
57  // 2. Veto tau -> tau (FSR)
58  // 3. Store the tau neutino to calculate the visible momentum
59  // cppcheck-suppress nullPointerRedundantCheck
60  for (const auto& citr: *(tau->end_vertex())) {
61  // Ignore tau -> tau (FSR)
62  if (pitr->pdg_id() == citr->pdg_id()) {
63  ATH_MSG_DEBUG("FSR tau decay. Ignoring!");
64  tau = nullptr;
65  break;
66  }
67 
68  // Ignore leptonic decays
69  if (std::abs(citr->pdg_id()) == 13 || std::abs(citr->pdg_id()) == 11) {
70  tau = nullptr;
71  break;
72  }
73 
74  // Find tau decay nu
75  if (std::abs(citr->pdg_id()) == 16) {
76  taunu = citr;
77  }
78  }
79 
80  if (tau) {
81  // Good hadronic decay
82  CLHEP::HepLorentzVector tauVisMom = CLHEP::HepLorentzVector(tau->momentum().px() - taunu->momentum().px(),
83  tau->momentum().py() - taunu->momentum().py(),
84  tau->momentum().pz() - taunu->momentum().pz(),
85  tau->momentum().e() - taunu->momentum().e());
86  if (tauVisMom.perp() >= m_minVisPtHadTau && std::abs(tauVisMom.pseudoRapidity()) <= m_maxEta) {
87  ATH_MSG_DEBUG("Found hadronic tau decay " << tau);
88  numLeptons++;
89  numHadTaus++;
90  }
91  }
92  }
93  }
94 
95  bool passed_event = false;
97  if ( ((numLightLeptons+numHadTaus)==numLeptons) && numLightLeptons == 2 && numHadTaus == 1 && charge1==charge2 ) {
98  ATH_MSG_DEBUG("Found " << numLeptons << " Leptons: two same sign ligh leptons + one hadronic tau! Event passed.");
99  passed_event = true;
100  }
101  } else {
102  if ( numLeptons >= m_NLeptons ) {
103  ATH_MSG_DEBUG("Found " << numLeptons << " Leptons. Event passed.");
104  passed_event = true;
105  }
106  }
107  setFilterPassed(passed_event);
108 
109  return StatusCode::SUCCESS;
110 }
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
MultiElecMuTauFilter::MultiElecMuTauFilter
MultiElecMuTauFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MultiElecMuTauFilter.cxx:9
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
MultiElecMuTauFilter::m_maxEta
double m_maxEta
Definition: MultiElecMuTauFilter.h:25
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
python.DataFormatRates.events
events
Definition: DataFormatRates.py:105
MultiElecMuTauFilter::m_TwoSameSignLightLeptonsOneHadTau
bool m_TwoSameSignLightLeptonsOneHadTau
Definition: MultiElecMuTauFilter.h:29
MultiElecMuTauFilter::m_minVisPtHadTau
double m_minVisPtHadTau
Definition: MultiElecMuTauFilter.h:26
MC::isPhysical
bool isPhysical(const T &p)
Definition: HepMCHelpers.h:32
GenFilter
Base class for event generator filtering modules.
Definition: GenFilter.h:30
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
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
xAOD::EgammaHelpers::isElectron
bool isElectron(const xAOD::Egamma *eg)
is the object an electron (not Fwd)
Definition: EgammaxAODHelpers.cxx:12
MultiElecMuTauFilter.h
MultiElecMuTauFilter::m_NLeptons
int m_NLeptons
Definition: MultiElecMuTauFilter.h:27
isTau
bool isTau(const T &p)
Definition: AtlasPID.h:148
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
MultiElecMuTauFilter::m_incHadTau
bool m_incHadTau
Definition: MultiElecMuTauFilter.h:28
MC::isStable
bool isStable(const T &p)
Definition: HepMCHelpers.h:30
MultiElecMuTauFilter::filterEvent
virtual StatusCode filterEvent()
Definition: MultiElecMuTauFilter.cxx:21
MultiElecMuTauFilter::m_minPt
double m_minPt
Definition: MultiElecMuTauFilter.h:24
HepMCHelpers.h
isMuon
bool isMuon(const T &p)
Definition: AtlasPID.h:145