ATLAS Offline Software
SoftLeptonInJetFilter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 SoftLeptonInJetFilter::SoftLeptonInJetFilter(const std::string& name, ISvcLocator* pSvcLocator)
9 : GenFilter(name,pSvcLocator)
10 {
11  declareProperty("Ptcut",m_Ptmin = 1000.);
12  declareProperty("Etacut",m_EtaRange = 10.0);
13  declareProperty("NLeptons",m_NLeptons = 0);
14  declareProperty("NPartons",m_NPartons = 0);
15  declareProperty("PtPartcut",m_part_Ptmin = 15.0);
16  declareProperty("EtaPartcut",m_part_EtaRange = 2.5);
17  declareProperty("IDPart",m_part_ID = 0);
18  declareProperty("JetCone",m_jet_cone = 0.4);
19 }
20 
21 
23  double eta_b[10];
24  double phi_b[10];
25  double eta_e[30];
26  double phi_e[30];
27  //int ele_pos[10];
28  int e_found[2];
29 
30  int NLeptons = 0;
31  int NPartons = 0;
32  for (McEventCollection::const_iterator itr = events()->begin(); itr!=events()->end(); ++itr) {
33  const HepMC::GenEvent* genEvt = (*itr);
34 #ifdef HEPMC3
35  for (const auto& pitr: *genEvt) {
36  if ( m_NPartons == 0 ) continue;
37  if (isParton(pitr)) {
38  eta_b[NPartons] = pitr->momentum().pseudoRapidity();
39  phi_b[NPartons] = pitr->momentum().phi();
40  NPartons++;
41  }
42  if (isElectron(pitr)) {
43  for (auto thisParent: pitr->production_vertex()->particles_in()) {
44  int parentID = std::abs(thisParent->pdg_id());
45  if ( MC::isBottomMeson(parentID) || MC::isBottomBaryon(parentID) || MC::isCharmMeson(parentID) || MC::isCharmBaryon(parentID) ) {
46  eta_e[NLeptons] = pitr->momentum().pseudoRapidity();
47  phi_e[NLeptons] = pitr->momentum().phi();
48  NLeptons++;
49  }
50  }
51  }
52  }
53 #else
54  for (HepMC::GenEvent::particle_const_iterator pitr=genEvt->particles_begin(); pitr != genEvt->particles_end(); ++pitr) {
55  if ( m_NPartons !=0 ) {
56  if (isParton(*pitr)) {
57  eta_b[NPartons] = (*pitr)->momentum().pseudoRapidity();
58  phi_b[NPartons] = (*pitr)->momentum().phi();
59  NPartons++;
60  }
61  if (isElectron(*pitr)) {
62  HepMC::GenVertex::particle_iterator firstParent, lastParent, thisParent;
63  firstParent = (*pitr)->production_vertex()->particles_begin(HepMC::parents);
64  lastParent = (*pitr)->production_vertex()->particles_end(HepMC::parents);
65  for (thisParent = firstParent; thisParent != lastParent++; ++thisParent) {
66  int parentID = abs((*thisParent)->pdg_id());
67  if ( MC::isBottomMeson(parentID) || MC::isBottomBaryon(parentID) || MC::isCharmMeson(parentID) || MC::isCharmBaryon(parentID) ) {
68  eta_e[NLeptons] = (*pitr)->momentum().pseudoRapidity();
69  phi_e[NLeptons] = (*pitr)->momentum().phi();
70  NLeptons++;
71  }
72  }
73  }
74  }
75  }
76 #endif
77  }
78 
79  if (NPartons == m_NPartons && NLeptons >= m_NLeptons) {
80  for (int ib=0; ib < NPartons; ib++) {
81  double dR = 0.;
82  e_found[ib] = 0 ;
83  //ele_pos[ib] = -1;
84 
85  for (int ie=0; ie < NLeptons; ie++ ) {
86  double deltaEta = eta_b[ib]-eta_e[ie];
87  double deltaPhi = std::abs(phi_b[ib]-phi_e[ie]);
88  if (deltaPhi > M_PI ) deltaPhi = std::abs(deltaPhi-2*M_PI);
89  dR = std::sqrt(deltaEta*deltaEta + deltaPhi*deltaPhi);
90 
91  if (dR < m_jet_cone) {
92  e_found[ib]++;
93  //ele_pos[ib] = ie;
94  }
95  }
96  }
97  }
98 
99  if (m_NPartons != 0) {
100  if (NPartons == m_NPartons && NLeptons >= m_NLeptons) {
101  int is_OK = 1;
102  for (int ib = 0; ib < NPartons; ib++) {
103  is_OK = is_OK * e_found[ib];
104  }
105  // e found for each parton in event
106  if (is_OK > 0) {
107  ATH_MSG_INFO("Event is accepted ");
108  m_nPass++;
109  return StatusCode::SUCCESS;
110  }
111  }
112  }
113 
114  // If we get here we have failed
115  m_nFail++;
116  setFilterPassed(false);
117  return StatusCode::SUCCESS;
118 }
119 
121  return (MC::isElectron(p) && MC::isStable(p) &&
122  p->momentum().perp() >= m_Ptmin &&
123  std::abs(p->momentum().pseudoRapidity()) <= m_EtaRange );
124 }
125 
127  return (std::abs(p->pdg_id()) == m_part_ID && !MC::isPhysical(p) &&
128  p->momentum().perp() >= m_part_Ptmin &&
129  std::abs(p->momentum().pseudoRapidity()) <= m_part_EtaRange);
130 }
isBottomMeson
bool isBottomMeson(const T &p)
Definition: AtlasPID.h:473
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
SoftLeptonInJetFilter::m_part_Ptmin
double m_part_Ptmin
Definition: SoftLeptonInJetFilter.h:29
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
SoftLeptonInJetFilter::isParton
bool isParton(const HepMC::ConstGenParticlePtr &p) const
Definition: SoftLeptonInJetFilter.cxx:126
isBottomBaryon
bool isBottomBaryon(const T &p)
Definition: AtlasPID.h:489
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SoftLeptonInJetFilter::m_Ptmin
double m_Ptmin
Definition: SoftLeptonInJetFilter.h:25
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
python.DecayParser.parents
parents
print ("==> buf:",buf)
Definition: DecayParser.py:31
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
SoftLeptonInJetFilter::m_NPartons
int m_NPartons
Definition: SoftLeptonInJetFilter.h:28
isCharmMeson
bool isCharmMeson(const T &p)
Definition: AtlasPID.h:472
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
M_PI
#define M_PI
Definition: ActiveFraction.h:11
PlotCalibFromCool.ib
ib
Definition: PlotCalibFromCool.py:419
SoftLeptonInJetFilter::m_NLeptons
int m_NLeptons
Definition: SoftLeptonInJetFilter.h:27
SoftLeptonInJetFilter::m_part_ID
int m_part_ID
Definition: SoftLeptonInJetFilter.h:31
python.DataFormatRates.events
events
Definition: DataFormatRates.py:105
PlotCalibFromCool.ie
ie
Definition: PlotCalibFromCool.py:420
MC::isPhysical
bool isPhysical(const T &p)
Definition: HepMCHelpers.h:32
GenFilter
Base class for event generator filtering modules.
Definition: GenFilter.h:30
SoftLeptonInJetFilter::SoftLeptonInJetFilter
SoftLeptonInJetFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SoftLeptonInJetFilter.cxx:8
P4Helpers::deltaEta
double deltaEta(const I4Momentum &p1, const I4Momentum &p2)
Computes efficiently .
Definition: P4Helpers.h:53
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::EgammaHelpers::isElectron
bool isElectron(const xAOD::Egamma *eg)
is the object an electron (not Fwd)
Definition: EgammaxAODHelpers.cxx:12
isCharmBaryon
bool isCharmBaryon(const T &p)
Definition: AtlasPID.h:488
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SoftLeptonInJetFilter::isElectron
bool isElectron(const HepMC::ConstGenParticlePtr &p) const
Definition: SoftLeptonInJetFilter.cxx:120
GenFilter::m_nPass
int m_nPass
Definition: GenFilter.h:65
MC::isStable
bool isStable(const T &p)
Definition: HepMCHelpers.h:30
SoftLeptonInJetFilter::m_part_EtaRange
double m_part_EtaRange
Definition: SoftLeptonInJetFilter.h:30
SoftLeptonInJetFilter.h
SoftLeptonInJetFilter::m_EtaRange
double m_EtaRange
Definition: SoftLeptonInJetFilter.h:26
GenFilter::m_nFail
int m_nFail
Definition: GenFilter.h:66
SoftLeptonInJetFilter::filterEvent
virtual StatusCode filterEvent()
Definition: SoftLeptonInJetFilter.cxx:22
SoftLeptonInJetFilter::m_jet_cone
double m_jet_cone
Definition: SoftLeptonInJetFilter.h:32
HepMCHelpers.h