ATLAS Offline Software
FourLeptonMassFilter.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 
9 FourLeptonMassFilter::FourLeptonMassFilter(const std::string& name, ISvcLocator* pSvcLocator)
10  : GenFilter(name,pSvcLocator)
11 {
12  declareProperty("MinPt", m_minPt = 5000.);
13  declareProperty("MaxEta", m_maxEta = 3.0);
14  declareProperty("MinMass1", m_minMass1 = 60000); // To avoid fsr etc
15  declareProperty("MaxMass1", m_maxMass1 = 14000000);
16  declareProperty("MinMass2", m_minMass2 = 12000); // To avoid fsr etc
17  declareProperty("MaxMass2", m_maxMass2 = 14000000);
18  declareProperty("AllowElecMu", m_allowElecMu = true);
19  declareProperty("AllowSameCharge", m_allowSameCharge = true);
20 }
21 
22 
24  ATH_MSG_DEBUG("MinPt " << m_minPt);
25  ATH_MSG_DEBUG("MaxEta " << m_maxEta);
26  ATH_MSG_DEBUG("MinMass1 " << m_minMass1);
27  ATH_MSG_DEBUG("MaxMass1 " << m_maxMass1);
28  ATH_MSG_DEBUG("MinMass2 " << m_minMass2);
29  ATH_MSG_DEBUG("MaxMass2 " << m_maxMass2);
30  ATH_MSG_DEBUG("AllowElecMu " << m_allowElecMu);
31  ATH_MSG_DEBUG("AllowSameCharge " << m_allowSameCharge);
32  return StatusCode::SUCCESS;
33 }
34 
35 
38 
39  for (itr = events()->begin(); itr!=events()->end(); ++itr) {
40  const HepMC::GenEvent* genEvt = *itr;
41  auto genEvt_particles_begin = HepMC::begin(*genEvt);
42  auto genEvt_particles_end = HepMC::end(*genEvt);
43  for (auto pitr1 = genEvt_particles_begin; pitr1 != genEvt_particles_end; ++pitr1) {
44  if (!MC::isStable(*pitr1)) continue;
45 
46  // Pick electrons or muons with Pt > m_inPt and |eta| < m_maxEta
47  int pdgId1((*pitr1)->pdg_id());
48 
49  if (!(std::abs(pdgId1) == 11 || std::abs(pdgId1) == 13)) continue;
50 
51  if (!((*pitr1)->momentum().perp() >= m_minPt && std::abs((*pitr1)->momentum().pseudoRapidity()) <= m_maxEta)) continue;
52 
53  // Loop over all remaining particles in the event
54  auto pitr2 = pitr1;
55  pitr2++;
56 
57 
58 
59  for (; pitr2 != genEvt_particles_end; ++pitr2) {
60  if (!MC::isStable(*pitr2) || pitr1 == pitr2) continue;
61  // Pick electrons or muons with Pt > m_inPt and |eta| < m_maxEta
62  int pdgId2((*pitr2)->pdg_id());
63  if (!(std::abs(pdgId2) == 11 || abs(pdgId2) == 13)) continue;
64  if (!((*pitr2)->momentum().perp() >= m_minPt && std::abs((*pitr2)->momentum().pseudoRapidity()) <= m_maxEta)) continue;
65 
66  // Loop over all remaining particles in the event
67  auto pitr3 = pitr2;
68  pitr3++;
69 
70  for (; pitr3 != genEvt_particles_end; ++pitr3) {
71  if (!MC::isStable(*pitr3) || pitr1 == pitr3 || pitr2 == pitr3 ) continue;
72 
73  // Pick electrons or muons with Pt > m_inPt and |eta| < m_maxEta
74  int pdgId3((*pitr3)->pdg_id());
75  if (!(std::abs(pdgId3) == 11 || std::abs(pdgId3) == 13)) continue;
76  if (!((*pitr3)->momentum().perp() >= m_minPt && std::abs((*pitr3)->momentum().pseudoRapidity()) <= m_maxEta)) continue;
77 
78  // Loop over all remaining particles in the event
79  auto pitr4 = pitr3;
80  pitr4++;
81 
82  for (; pitr4 != genEvt_particles_end; ++pitr4) {
83  if (!MC::isStable(*pitr4) || pitr1 == pitr4 || pitr2 == pitr4 || pitr3 == pitr4) continue;
84 
85  // Pick electrons or muons with Pt > m_inPt and |eta| < m_maxEta
86  int pdgId4((*pitr4)->pdg_id());
87  if (!(std::abs(pdgId4) == 11 || abs(pdgId4) == 13)) continue;
88  if (!((*pitr4)->momentum().perp() >= m_minPt && std::abs((*pitr4)->momentum().pseudoRapidity()) <= m_maxEta)) continue;
89 
90  decltype(pitr1) apitr[4] = {pitr1,pitr2,pitr3,pitr4};
91  int pdgIds[4]={pdgId1,pdgId2,pdgId3,pdgId4};
92  for (int ii = 0; ii < 4; ii++) {
93  for (int jj = 0; jj < 4; jj++) {
94  if (jj == ii) continue;
95  for (int kk = 0; kk < 4; kk++) {
96  if (kk == jj || kk == ii) continue;
97  for (int ll = 0; ll < 4; ll++) {
98  if (ll == kk || ll == jj|| ll == ii) continue;
99  if (!m_allowElecMu && (std::abs(pdgIds[ii])!=abs(pdgIds[jj]) || abs(pdgIds[kk])!=abs(pdgIds[ll]))) continue;
100  if (!m_allowSameCharge && (pdgIds[ii]*pdgIds[jj]>0. || pdgIds[kk]*pdgIds[ll]>0.)) continue;
101 
102  // Leading dilepton pair
103  HepMC::FourVector vec((*(apitr[ii]))->momentum().px() + (*(apitr[jj]))->momentum().px(),
104  (*(apitr[ii]))->momentum().py() + (*(apitr[jj]))->momentum().py(),
105  (*(apitr[ii]))->momentum().pz() + (*(apitr[jj]))->momentum().pz(),
106  (*(apitr[ii]))->momentum().e() + (*(apitr[jj]))->momentum().e() );
107  double invMass1 = vec.m();
108  if (invMass1 < m_minMass1 || invMass1 > m_maxMass1) continue;
109  ATH_MSG_DEBUG("PASSED FILTER1 " << invMass1);
110 
111  // Sub-leading dilepton pair
112  HepMC::FourVector vec2((*(apitr[kk]))->momentum().px() + (*(apitr[ll]))->momentum().px(),
113  (*(apitr[kk]))->momentum().py() + (*(apitr[ll]))->momentum().py(),
114  (*(apitr[kk]))->momentum().pz() + (*(apitr[ll]))->momentum().pz(),
115  (*(apitr[kk]))->momentum().e() + (*(apitr[ll]))->momentum().e() );
116  double invMass2 = vec2.m();
117  if (invMass2 < m_minMass2 || invMass2 > m_maxMass2) continue;
118  ATH_MSG_DEBUG("PASSED FILTER2 " << invMass2);
119 
120  return StatusCode::SUCCESS;
121  }
122  }
123  }
124  }
125  }
126  }
127  }
128  }
129  }
130  setFilterPassed(false);
131  return StatusCode::SUCCESS;
132 }
FourLeptonMassFilter::filterInitialize
virtual StatusCode filterInitialize()
Definition: FourLeptonMassFilter.cxx:23
D3PDMakerTestInstan::vec2
std::vector< D3PDTest::MyVec2 > vec2
Definition: D3PDMakerTestDict.h:14
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
test_pyathena.px
px
Definition: test_pyathena.py:18
FourLeptonMassFilter::FourLeptonMassFilter
FourLeptonMassFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: FourLeptonMassFilter.cxx:9
FourLeptonMassFilter.h
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
FourLeptonMassFilter::m_minPt
double m_minPt
Definition: FourLeptonMassFilter.h:27
FourLeptonMassFilter::m_minMass1
double m_minMass1
Definition: FourLeptonMassFilter.h:29
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
FourLeptonMassFilter::m_allowElecMu
bool m_allowElecMu
Definition: FourLeptonMassFilter.h:33
FourLeptonMassFilter::m_maxMass1
double m_maxMass1
Definition: FourLeptonMassFilter.h:30
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
python.changerun.kk
list kk
Definition: changerun.py:41
GenFilter
Base class for event generator filtering modules.
Definition: GenFilter.h:30
ParticleGun_EoverP_Config.momentum
momentum
Definition: ParticleGun_EoverP_Config.py:63
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
Amg::pz
@ pz
Definition: GeoPrimitives.h:40
FourLeptonMassFilter::m_allowSameCharge
bool m_allowSameCharge
Definition: FourLeptonMassFilter.h:34
Amg::py
@ py
Definition: GeoPrimitives.h:39
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
FourLeptonMassFilter::filterEvent
virtual StatusCode filterEvent()
Definition: FourLeptonMassFilter.cxx:36
MC::isStable
bool isStable(const T &p)
Definition: HepMCHelpers.h:30
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
FourLeptonMassFilter::m_minMass2
double m_minMass2
Definition: FourLeptonMassFilter.h:31
HepMC::begin
GenEvent::particle_iterator begin(HepMC::GenEvent &e)
Definition: GenEvent.h:498
FourLeptonMassFilter::m_maxMass2
double m_maxMass2
Definition: FourLeptonMassFilter.h:32
HepMCHelpers.h
DiTauMassTools::TauTypes::ll
@ ll
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:49
FourLeptonMassFilter::m_maxEta
double m_maxEta
Definition: FourLeptonMassFilter.h:28