ATLAS Offline Software
DecaysFinalStateFilter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // GeneratorFilters/DecaysFinalStateFilter
6 //
7 // Picks events with a given number of quarks, leptons and neutrinos from
8 // decays of a list of specified resonances (e.g. W, Z, ...).
9 // Will work only if resonances are explicitly included in event record.
10 //
11 // Examples:
12 //
13 // topAlg.DecaysFinalStateFilter.PDGAllowedParents = [ 23 ]
14 // topAlg.DecaysFinalStateFilter.NQuarks = 2
15 // topAlg.DecaysFinalStateFilter.NChargedLeptons = 2
16 // -> picks semileptonic ZZ decays
17 //
18 // topAlg.DecaysFinalStateFilter.PDGAllowedParents = [ 23, 24, -24 ]
19 // topAlg.DecaysFinalStateFilter.NQuarks = 2
20 // topAlg.DecaysFinalStateFilter.NChargedLeptons = 2
21 // -> allows W(qq)Z(ll) and Z(qq)Z(ll)
22 //
23 // topAlg.DecaysFinalStateFilter.PDGAllowedParents = [ 23 ]
24 // topAlg.DecaysFinalStateFilter.NbQuarks = 2
25 // topAlg.DecaysFinalStateFilter.NChargedLeptons = 2
26 // -> allows Z(bb)Z(ll)
27 //
28 // Authors:
29 // Kerim Suruliz Nov 2014
30 // Frank Siegert Nov 2014
31 
33 #include <cmath>
34 
35 
36 DecaysFinalStateFilter::DecaysFinalStateFilter(const std::string& name, ISvcLocator* pSvcLocator)
37  : GenFilter(name,pSvcLocator)
38 {
39  declareProperty("PDGAllowedParents", m_PDGAllowedParents);
40 
41  declareProperty("NQuarks", m_NQuarks = -1);
42  declareProperty("NbQuarks", m_NbQuarks = -1);
43  declareProperty("NChargedLeptons", m_NChargedLeptons = -1);
44  declareProperty("NNeutrinos", m_NNeutrinos = -1);
45  declareProperty("NPhotons", m_NPhotons = -1);
46 
47  declareProperty("MinNQuarks", m_MinNQuarks = 0);
48  declareProperty("MinNbQuarks", m_MinNbQuarks = 0);
49  declareProperty("MinNChargedLeptons", m_MinNChargedLeptons = 0);
50  declareProperty("MinNNeutrinos", m_MinNNeutrinos = 0);
51  declareProperty("MinNPhotons", m_MinNPhotons = 0);
52 }
53 
54 
56  int nChargedLeptons = 0;
57  int nQuarks = 0;
58  int nbQuarks = 0;
59  int nNeutrinos = 0;
60  int nPhotons = 0;
61 
63  for (itr = events()->begin(); itr != events()->end(); ++itr) {
64  const HepMC::GenEvent* genEvt = *itr;
65 
66 
67  for (const auto& part: *genEvt){
68  // look only at the allowed parents (e.g. W, Z)
69  bool allowedParent = false;
70  for (size_t i=0; i<m_PDGAllowedParents.size(); ++i) {
71  if ( part->pdg_id() == m_PDGAllowedParents[i]) allowedParent = true;
72  }
73  if (!allowedParent) continue;
74 
75  if (!part->end_vertex()) continue;
76 
77  for (const auto& opitr: *(part->end_vertex())) {
78  int apid = std::abs(opitr->pdg_id());
79  if (apid == 1 || apid == 2 || apid == 3 || apid == 4 || apid ==5) nQuarks++;
80  if (apid == 5) nbQuarks++;
81  if (apid == 11 || apid == 13 || apid == 15) nChargedLeptons++;
82  if (apid == 12 || apid == 14 || apid == 16) nNeutrinos++;
83  if (apid == 22) nPhotons++;
84  }
85  }
86  }
87 
88  if (nQuarks < m_MinNQuarks || (m_NQuarks != -1 && nQuarks != m_NQuarks)) {
89  setFilterPassed(false);
90  }
91  else if (nbQuarks < m_MinNbQuarks || (m_NbQuarks != -1 && nbQuarks != m_NbQuarks)) {
92  setFilterPassed(false);
93  }
94  else if (nChargedLeptons < m_MinNChargedLeptons || (m_NChargedLeptons != -1 && nChargedLeptons != m_NChargedLeptons)) {
95  setFilterPassed(false);
96  }
97  else if (nNeutrinos < m_MinNNeutrinos || (m_NNeutrinos != -1 && nNeutrinos != m_NNeutrinos)) {
98  setFilterPassed(false);
99  }
100  else if (nPhotons < m_MinNPhotons || (m_NPhotons != -1 && nPhotons != m_NPhotons)) {
101  setFilterPassed(false);
102  }
103  else {
104  setFilterPassed(true);
105  }
106  return StatusCode::SUCCESS;
107 }
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
DecaysFinalStateFilter::m_MinNNeutrinos
int m_MinNNeutrinos
Definition: DecaysFinalStateFilter.h:52
DecaysFinalStateFilter::m_MinNQuarks
int m_MinNQuarks
Definition: DecaysFinalStateFilter.h:52
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
DecaysFinalStateFilter::DecaysFinalStateFilter
DecaysFinalStateFilter(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: DecaysFinalStateFilter.cxx:36
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
DecaysFinalStateFilter::m_PDGAllowedParents
std::vector< int > m_PDGAllowedParents
Definition: DecaysFinalStateFilter.h:46
DecaysFinalStateFilter::m_MinNChargedLeptons
int m_MinNChargedLeptons
Definition: DecaysFinalStateFilter.h:52
python.DataFormatRates.events
events
Definition: DataFormatRates.py:105
DecaysFinalStateFilter::m_NChargedLeptons
int m_NChargedLeptons
Definition: DecaysFinalStateFilter.h:49
GenFilter
Base class for event generator filtering modules.
Definition: GenFilter.h:30
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DecaysFinalStateFilter::m_MinNbQuarks
int m_MinNbQuarks
Definition: DecaysFinalStateFilter.h:52
DecaysFinalStateFilter.h
DecaysFinalStateFilter::m_NNeutrinos
int m_NNeutrinos
Definition: DecaysFinalStateFilter.h:49
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DecaysFinalStateFilter::m_NQuarks
int m_NQuarks
Definition: DecaysFinalStateFilter.h:49
DecaysFinalStateFilter::m_NPhotons
int m_NPhotons
Definition: DecaysFinalStateFilter.h:49
DecaysFinalStateFilter::filterEvent
virtual StatusCode filterEvent()
Do the filtering.
Definition: DecaysFinalStateFilter.cxx:55
DecaysFinalStateFilter::m_NbQuarks
int m_NbQuarks
Definition: DecaysFinalStateFilter.h:49
DecaysFinalStateFilter::m_MinNPhotons
int m_MinNPhotons
Definition: DecaysFinalStateFilter.h:52