ATLAS Offline Software
FourLeptonInvMassFilter.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 #include <math.h>
8 
9 
10 FourLeptonInvMassFilter::FourLeptonInvMassFilter(const std::string& name, ISvcLocator* pSvcLocator) :
11  GenFilter(name,pSvcLocator) {
12 
13  declareProperty("MinPt", m_minPt = 5000.);
14  declareProperty("MaxEta", m_maxEta = 5.0);
15  declareProperty("MinMass", m_minMass = 60000);
16  declareProperty("MaxMass", m_maxMass = 14000000);
17 }
18 
20 
22  ATH_MSG_DEBUG( "MinPt " << m_minPt);
23  ATH_MSG_DEBUG( "MaxEta " << m_maxEta);
24  ATH_MSG_DEBUG( "MinMass " << m_minMass);
25  ATH_MSG_DEBUG( "MaxMass " << m_maxMass);
26 
27  return StatusCode::SUCCESS;
28 }
29 
31  return StatusCode::SUCCESS;
32 }
33 
35  // Loop over all events in McEventCollection
37  for (itr = events()->begin(); itr!=events()->end(); ++itr) {
38  const HepMC::GenEvent* genEvt = (*itr);
39  auto genEvt_particles_begin = HepMC::begin(*genEvt);
40  auto genEvt_particles_end = HepMC::end(*genEvt);
41  // Loop over all particles in the event
42  for (auto pitr1 = genEvt_particles_begin; pitr1 != genEvt_particles_end; ++pitr1 ){
43  if(!MC::isStable(*pitr1)) continue;
44 
45  // Pick electrons or muons with Pt > m_inPt and |eta| < m_maxEta
46  int pdgId1((*pitr1)->pdg_id());
47  if (!(std::abs(pdgId1) == 11 || std::abs(pdgId1) == 13)) continue;
48  if (!((*pitr1)->momentum().perp() >= m_minPt && std::abs((*pitr1)->momentum().pseudoRapidity()) <= m_maxEta)) continue;
49 
50  // Loop over all remaining particles in the event
51  auto pitr2 = pitr1;
52  pitr2++;
53 
54  for(; pitr2 != genEvt_particles_end; ++pitr2){
55  if( !MC::isStable(*pitr2) || pitr1 == pitr2) continue;
56 
57  // Pick electrons or muons with Pt > m_inPt and |eta| < m_maxEta
58  int pdgId2((*pitr2)->pdg_id());
59  if (!(std::abs(pdgId2) == 11 || std::abs(pdgId2) == 13)) continue;
60  if (!((*pitr2)->momentum().perp() >= m_minPt && std::abs((*pitr2)->momentum().pseudoRapidity()) <= m_maxEta)) continue;
61 
62  // Loop over all remaining particles in the event
63  auto pitr3 = pitr2;
64  pitr3++;
65 
66  for(; pitr3 != genEvt_particles_end; ++pitr3){
67  if(!MC::isStable(*pitr3) || pitr1 == pitr3 || pitr2 == pitr3 ) continue;
68 
69  // Pick electrons or muons with Pt > m_inPt and |eta| < m_maxEta
70  int pdgId3((*pitr3)->pdg_id());
71  if (!(std::abs(pdgId3) == 11 || std::abs(pdgId3) == 13)) continue;
72  if (!((*pitr3)->momentum().perp() >= m_minPt && std::abs((*pitr3)->momentum().pseudoRapidity()) <= m_maxEta)) continue;
73 
74  // Loop over all remaining particles in the event
75  auto pitr4 = pitr3;
76  pitr4++;
77 
78  for(; pitr4 != genEvt_particles_end; ++pitr4){
79  if(!MC::isStable(*pitr4) || pitr1 == pitr4 || pitr2 == pitr4 || pitr3 == pitr4) continue;
80 
81  // Pick electrons or muons with Pt > m_inPt and |eta| < m_maxEta
82  int pdgId4((*pitr4)->pdg_id());
83  if (!(std::abs(pdgId4) == 11 || std::abs(pdgId4) == 13)) continue;
84  if (!((*pitr4)->momentum().perp() >= m_minPt && std::abs((*pitr4)->momentum().pseudoRapidity()) <= m_maxEta)) continue;
85 
86  // 4lepton vector
87  HepMC::FourVector vec((*pitr1)->momentum().px() + (*pitr2)->momentum().px() + (*pitr3)->momentum().px() + (*pitr4)->momentum().px(),
88  (*pitr1)->momentum().py() + (*pitr2)->momentum().py() + (*pitr3)->momentum().py() + (*pitr4)->momentum().py(),
89  (*pitr1)->momentum().pz() + (*pitr2)->momentum().pz() + (*pitr3)->momentum().pz() + (*pitr4)->momentum().pz(),
90  (*pitr1)->momentum().e() + (*pitr2)->momentum().e() + (*pitr3)->momentum().e() + (*pitr4)->momentum().e());
91  double invMass = vec.m();
93  ATH_MSG_DEBUG( "PASSED FILTER " << invMass );
94  return StatusCode::SUCCESS;
95  }
96  }
97  }
98  }
99  }
100  }
101  setFilterPassed(false);
102  return StatusCode::SUCCESS;
103 }
104 
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
FourLeptonInvMassFilter::m_minMass
double m_minMass
Definition: FourLeptonInvMassFilter.h:35
P4Helpers::invMass
double invMass(const I4Momentum &pA, const I4Momentum &pB)
invariant mass from two I4momentum references
Definition: P4Helpers.h:239
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
FourLeptonInvMassFilter::m_minPt
double m_minPt
Definition: FourLeptonInvMassFilter.h:33
FourLeptonInvMassFilter::FourLeptonInvMassFilter
FourLeptonInvMassFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: FourLeptonInvMassFilter.cxx:10
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
FourLeptonInvMassFilter::m_maxMass
double m_maxMass
Definition: FourLeptonInvMassFilter.h:36
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
python.DataFormatRates.events
events
Definition: DataFormatRates.py:105
HepMC::end
GenEvent::particle_iterator end(HepMC::GenEvent &e)
Definition: GenEvent.h:499
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
GenFilter
Base class for event generator filtering modules.
Definition: GenFilter.h:30
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
FourLeptonInvMassFilter.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
FourLeptonInvMassFilter::~FourLeptonInvMassFilter
virtual ~FourLeptonInvMassFilter()
Definition: FourLeptonInvMassFilter.cxx:19
FourLeptonInvMassFilter::filterInitialize
virtual StatusCode filterInitialize()
Definition: FourLeptonInvMassFilter.cxx:21
FourLeptonInvMassFilter::filterFinalize
virtual StatusCode filterFinalize()
Definition: FourLeptonInvMassFilter.cxx:30
MC::isStable
bool isStable(const T &p)
Definition: HepMCHelpers.h:30
HepMC::begin
GenEvent::particle_iterator begin(HepMC::GenEvent &e)
Definition: GenEvent.h:498
FourLeptonInvMassFilter::m_maxEta
double m_maxEta
Definition: FourLeptonInvMassFilter.h:34
FourLeptonInvMassFilter::filterEvent
virtual StatusCode filterEvent()
Definition: FourLeptonInvMassFilter.cxx:34
HepMCHelpers.h