ATLAS Offline Software
ParentChildwStatusFilter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // -------------------------------------------------------------
6 // File: GeneratorFilters/ParentChildFilter.cxx
7 // Description:
8 //
9 // Allows the user to search for any given decay Parent -> Child + X with particle status
10 // The Parent/Child is required to be listed in the vector PDGParent[], StatusParent[] / PDGChild[],
11 // which compactly opens for multiple OR'ed searches,
12 // e.g. setting PDGParent = [23,24] with StatusParent = [23] and PDGChild = [11,13,15] in the jobOptions
13 // accepts decay of W/Z with status=23 into any of the leptons.
14 //
15 // The filter is effective for the generator which contains the particle of intermediate state. This filter is tested with Pythia8.
16 // User should check if the filter works for other generator.
17 //
18 // Furthermore, setting PDGParent = [0] / PDGChild = [0] in the jobOption removes the
19 // PDG requirement on the Parent/Child. This setting would test on 'decays' of the
20 // type A(status 1) -> A(status 2).
21 // To mend this, Parent and Child is also required to have different PDG.
22 //
23 // Eta and Pt cuts are imposed on both Parent and Child.
24 //
25 // AuthorList:
26 // T Masubuchi April 2013
27 //
28 
29 // Header for this module:-
30 
32 
33 // Other classes used by this class:-
34 #include <math.h>
35 
36 //--------------------------------------------------------------------------
38  ISvcLocator* pSvcLocator): GenFilter(name,pSvcLocator) {
39  //--------------------------------------------------------------------------
40  declareProperty("PDGParent",m_PDGParent);
41  declareProperty("StatusParent",m_StatusParent);
42  declareProperty("PtMinParent",m_PtMinParent = 0.);
43  declareProperty("PtMaxParent",m_PtMaxParent = 1e9);
44  declareProperty("MassMinParent",m_MassMinParent = -1e9);
45  declareProperty("MassMaxParent",m_MassMaxParent = 1e9);
46  declareProperty("EtaRangeParent",m_EtaRangeParent = 10.0);
47  declareProperty("PDGChild",m_PDGChild);
48  declareProperty("PtMinChild",m_PtMinChild = 0.);
49  declareProperty("EtaRangeChild",m_EtaRangeChild = 10.0);
50 
51 }
52 
53 //--------------------------------------------------------------------------
55 //--------------------------------------------------------------------------
56 
57 }
58 
59 //---------------------------------------------------------------------------
61 //---------------------------------------------------------------------------
62 
63  msg(MSG:: INFO) << "ParentChildwStatusFilter INITIALISING " << endmsg;
64 
65  if(m_PDGParent.size()==0)
66  msg(MSG:: ERROR) << "PDGParent[] not set " << endmsg;
67  if(m_StatusParent.size()==0)
68  msg( MSG:: ERROR) << "StatusParent[] not set " << endmsg;
69  if(m_PDGChild.size()==0)
70  msg(MSG:: ERROR) << "PDGChild[] not set " << endmsg;
71 
72  for(int i=0;i<int(m_PDGParent.size());i++)
73  msg(MSG:: INFO) << "PDGParent["<<i<<"] = " << m_PDGParent[i] << endmsg;
74  for(int i=0;i<int(m_StatusParent.size());i++)
75  msg( MSG:: INFO) << "StatusParent["<<i<<"] = " << m_StatusParent[i] << endmsg;
76  msg( MSG:: INFO) << "PtMinParent = " << m_PtMinParent << endmsg;
77  msg(MSG:: INFO) << "PtMaxParent = " << m_PtMaxParent << endmsg;
78  msg(MSG:: INFO) << "MassMinParent = " << m_MassMinParent << endmsg;
79  msg( MSG:: INFO) << "MassMaxParent = " << m_MassMaxParent << endmsg;
80  msg( MSG:: INFO) << "EtaRangeParent = " << m_EtaRangeParent << endmsg;
81  for(int i=0;i<int(m_PDGChild.size());i++)
82  msg( MSG:: INFO) << "PDGChild["<<i<<"] = " << m_PDGChild[i] << endmsg;
83  msg( MSG:: INFO) << "PtMinChild = " << m_PtMinChild << endmsg;
84  msg( MSG:: INFO) << "EtaRangeChild = " << m_EtaRangeChild << endmsg;
85  return StatusCode::SUCCESS;
86 }
87 
88 //---------------------------------------------------------------------------
90 //---------------------------------------------------------------------------
91  return StatusCode::SUCCESS;
92 }
93 
94 
95 //---------------------------------------------------------------------------
97 //---------------------------------------------------------------------------
98 
99 // Loop over all events in McEventCollection
100 
101  msg(MSG:: INFO) << " ParentChildwStatusFilter filtering " << endmsg;
103  for (itr = events()->begin(); itr != events()->end(); ++itr) {
104  // Loop over all particles in the event
105  const HepMC::GenEvent* genEvt = (*itr);
106  for(const auto& pitr: *genEvt){
107  // Parent
108  int okPDGParent=0;
109  int okStatusParent=0;
110  for(int i=0;i<int(m_PDGParent.size());i++)
111  if(std::abs(pitr->pdg_id()) == m_PDGParent[i]) okPDGParent=1;
112  for(int i=0;i<int(m_StatusParent.size());i++)
113  if(std::abs(pitr->status()) == m_StatusParent[i]) okStatusParent=1;
114  if( ( (m_PDGParent[0] == 0) || (okPDGParent && okStatusParent))
115  && (pitr->momentum().perp() >= m_PtMinParent)
116  && (pitr->momentum().perp() < m_PtMaxParent)
117  && (pitr->momentum().m() >= m_MassMinParent)
118  && (pitr->momentum().m() < m_MassMaxParent)
119  && (std::abs(pitr->momentum().eta()) < m_EtaRangeParent) ) {
120  //Check if has end_vertex (skips initial protons)
121  if(!(pitr->end_vertex())) continue;
122  // Child
123  for(const auto& thisChild: *(pitr->end_vertex())){
124  int okPDGChild=0;
125  for(int i=0;i<int(m_PDGChild.size());i++)
126  if(std::abs(thisChild->pdg_id()) == m_PDGChild[i]) okPDGChild=1;
127  if( (thisChild->pdg_id() != pitr->pdg_id() )
128  && ( (m_PDGChild[0] == 0) || okPDGChild )
129  && (thisChild->momentum().perp() > m_PtMinChild)
130  && (std::abs(thisChild->momentum().eta()) < m_EtaRangeChild) ) {
131  // appropriate Child found
132  return StatusCode::SUCCESS;
133  }
134  }
135  }
136  }
137  }
138  // if we get here we have failed
139  setFilterPassed(false);
140  return StatusCode::SUCCESS;
141 }
142 
143 
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
ParentChildwStatusFilter::m_MassMaxParent
double m_MassMaxParent
Definition: ParentChildwStatusFilter.h:40
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ParentChildwStatusFilter::filterInitialize
virtual StatusCode filterInitialize()
Definition: ParentChildwStatusFilter.cxx:60
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ParentChildwStatusFilter::m_PtMaxParent
double m_PtMaxParent
Definition: ParentChildwStatusFilter.h:38
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
ParentChildwStatusFilter::m_PDGChild
std::vector< int > m_PDGChild
Definition: ParentChildwStatusFilter.h:42
python.DataFormatRates.events
events
Definition: DataFormatRates.py:105
ParentChildwStatusFilter::m_EtaRangeChild
double m_EtaRangeChild
Definition: ParentChildwStatusFilter.h:44
GenFilter
Base class for event generator filtering modules.
Definition: GenFilter.h:30
ParentChildwStatusFilter::filterEvent
virtual StatusCode filterEvent()
Definition: ParentChildwStatusFilter.cxx:96
ParentChildwStatusFilter::m_MassMinParent
double m_MassMinParent
Definition: ParentChildwStatusFilter.h:39
lumiFormat.i
int i
Definition: lumiFormat.py:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ParentChildwStatusFilter::filterFinalize
virtual StatusCode filterFinalize()
Definition: ParentChildwStatusFilter.cxx:89
ParentChildwStatusFilter::m_PtMinParent
double m_PtMinParent
Definition: ParentChildwStatusFilter.h:37
ParentChildwStatusFilter::m_PDGParent
std::vector< int > m_PDGParent
Definition: ParentChildwStatusFilter.h:35
ParentChildwStatusFilter::m_PtMinChild
double m_PtMinChild
Definition: ParentChildwStatusFilter.h:43
ParentChildwStatusFilter::ParentChildwStatusFilter
ParentChildwStatusFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: ParentChildwStatusFilter.cxx:37
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ParentChildwStatusFilter::~ParentChildwStatusFilter
virtual ~ParentChildwStatusFilter()
Definition: ParentChildwStatusFilter.cxx:54
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
ParentChildwStatusFilter.h
ParentChildwStatusFilter::m_EtaRangeParent
double m_EtaRangeParent
Definition: ParentChildwStatusFilter.h:41
ParentChildwStatusFilter::m_StatusParent
std::vector< int > m_StatusParent
Definition: ParentChildwStatusFilter.h:36