CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
PythiaDauVFilter Class Reference

#include <PythiaDauVFilter.h>

Inheritance diagram for PythiaDauVFilter:
edm::EDFilter edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

virtual bool filter (edm::Event &, const edm::EventSetup &)
 
 PythiaDauVFilter (const edm::ParameterSet &)
 
 ~PythiaDauVFilter ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

bool chargeconju
 
std::vector< int > dauIDs
 
int fVerbose
 
std::string label_
 
std::vector< double > maxetacut
 
double maxptcut
 
std::vector< double > minetacut
 
std::vector< double > minptcut
 
int motherID
 
int ndaughters
 
int particleID
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
typedef WorkerT< EDFilterWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDFilter
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Description: Filter events using MotherId and ChildrenIds infos

Implementation: <Notes on="" implementation>="">

Definition at line 40 of file PythiaDauVFilter.h.

Constructor & Destructor Documentation

PythiaDauVFilter::PythiaDauVFilter ( const edm::ParameterSet iConfig)
explicit

Definition at line 13 of file PythiaDauVFilter.cc.

References gather_cfg::cout, dauIDs, edm::ParameterSet::getUntrackedParameter(), i, maxetacut, maxptcut, minetacut, minptcut, motherID, and particleID.

13  :
14  fVerbose(iConfig.getUntrackedParameter("verbose",0)),
15  label_(iConfig.getUntrackedParameter("moduleLabel",std::string("generator"))),
16  particleID(iConfig.getUntrackedParameter("ParticleID", 0)),
17  motherID(iConfig.getUntrackedParameter("MotherID", 0)),
18  chargeconju(iConfig.getUntrackedParameter("ChargeConjugation", true)),
19  ndaughters(iConfig.getUntrackedParameter("NumberDaughters", 0)),
20  //minptcut(iConfig.getUntrackedParameter("MinPt", 0.)),
21  maxptcut(iConfig.getUntrackedParameter("MaxPt", 14000.))
22  //minetacut(iConfig.getUntrackedParameter("MinEta", -10.)),
23  //maxetacut(iConfig.getUntrackedParameter("MaxEta", 10.))
24 {
25  //now do what ever initialization is needed
26  vector<int> defdauID;
27  defdauID.push_back(0);
28  dauIDs = iConfig.getUntrackedParameter< vector<int> >("DaughterIDs",defdauID);
29  vector<double> defminptcut;
30  defminptcut.push_back(0.);
31  minptcut = iConfig.getUntrackedParameter< vector<double> >("MinPt",defminptcut);
32  vector<double> defminetacut;
33  defminetacut.push_back(-10.);
34  minetacut = iConfig.getUntrackedParameter< vector<double> >("MinEta",defminetacut);
35  vector<double> defmaxetacut;
36  defmaxetacut.push_back(10.);
37  maxetacut = iConfig.getUntrackedParameter< vector<double> >("MaxEta",defmaxetacut);
38 
39  cout << "----------------------------------------------------------------------" << endl;
40  cout << "--- PythiaDauVFilter" << endl;
41  for (unsigned int i=0; i<dauIDs.size(); ++i) {
42  cout << "ID: " << dauIDs[i] << " pT > " << minptcut[i] << " " << minetacut[i] << " eta < " << maxetacut[i] << endl;
43  }
44  cout << "maxptcut = " << maxptcut << endl;
45  cout << "particleID = " << particleID << endl;
46  cout << "motherID = " << motherID << endl;
47  cout << "----------------------------------------------------------------------" << endl;
48 
49 }
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< double > maxetacut
std::vector< int > dauIDs
std::vector< double > minetacut
std::vector< double > minptcut
std::string label_
tuple cout
Definition: gather_cfg.py:121
PythiaDauVFilter::~PythiaDauVFilter ( )

Definition at line 52 of file PythiaDauVFilter.cc.

53 {
54 
55  // do anything here that needs to be done at desctruction time
56  // (e.g. close files, deallocate resources etc.)
57 
58 }

Member Function Documentation

bool PythiaDauVFilter::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDFilter.

Definition at line 66 of file PythiaDauVFilter.cc.

References abs, chargeconju, gather_cfg::cout, dauIDs, fVerbose, edm::Event::getByLabel(), i, label_, maxetacut, maxptcut, minetacut, minptcut, motherID, ndaughters, AlCaHLTBitMon_ParallelJobs::p, particleID, and PYCOMP.

66  {
67  using namespace edm;
68  bool accepted = false;
70  iEvent.getByLabel(label_, evt);
71 
72  int OK(1);
73  vector<int> vparticles;
74 
75  HepMC::GenEvent *myGenEvent = new HepMC::GenEvent(*(evt->GetEvent()));
76 
77  if (fVerbose > 5) {
78  cout << "looking for " << particleID << endl;
79  }
80 
81  for (HepMC::GenEvent::particle_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p) {
82 
83  if ((*p)->pdg_id() != particleID) continue ;
84 
85  // -- Check for mother of this particle
86  if (0 != motherID) {
87  OK = 0;
88  for (HepMC::GenVertex::particles_in_const_iterator des = (*p)->production_vertex()->particles_in_const_begin();
89  des != (*p)->production_vertex()->particles_in_const_end();
90  ++des) {
91  if (fVerbose > 10) {
92  cout << "mother: " << (*des)->pdg_id() << " pT: " << (*des)->momentum().perp() << " eta: " << (*des)->momentum().eta() << endl;
93  }
94  if (abs(motherID) == abs((*des)->pdg_id())) {
95  OK = 1;
96  break;
97  }
98  }
99  }
100  if (0 == OK) continue;
101 
102  // -- check for daugthers
103  int ndauac = 0;
104  int ndau = 0;
105  if (fVerbose > 5) {
106  cout << "found ID: " << (*p)->pdg_id() << " pT: " << (*p)->momentum().perp() << " eta: " << (*p)->momentum().eta() << endl;
107  }
108  vparticles.push_back((*p)->pdg_id());
109  if ((*p)->end_vertex()) {
110  for (HepMC::GenVertex::particle_iterator des=(*p)->end_vertex()->particles_begin(HepMC::children);
111  des != (*p)->end_vertex()->particles_end(HepMC::children);
112  ++des) {
113  ++ndau;
114  if (fVerbose > 5) {
115  cout << "ID: " << (*des)->pdg_id() << " pT: " << (*des)->momentum().perp() << " eta: " << (*des)->momentum().eta() << endl;
116  }
117  for (unsigned int i=0; i<dauIDs.size(); ++i) {
118  if ((*des)->pdg_id() != dauIDs[i] ) continue ;
119  if (fVerbose > 5) {
120  cout << "i = " << i << " pT = " << (*des)->momentum().perp() << " eta = " << (*des)->momentum().eta() << endl;
121  }
122  if ((*des)->momentum().perp() > minptcut[i] &&
123  (*des)->momentum().perp() < maxptcut &&
124  (*des)->momentum().eta() > minetacut[i] &&
125  (*des)->momentum().eta() < maxetacut[i] ) {
126  ++ndauac;
127  vparticles.push_back((*des)->pdg_id());
128  if (fVerbose > 2) {
129  cout << " accepted this particle " << (*des)->pdg_id()
130  << " pT = " << (*des)->momentum().perp() << " eta = " << (*des)->momentum().eta() << endl;
131  }
132  break;
133  }
134  }
135  }
136  }
137 
138  // -- allow photons
139  if (ndau >= ndaughters && ndauac == ndaughters) {
140  accepted = true;
141  if (fVerbose > 0) {
142  cout << " accepted this decay: ";
143  for (unsigned int iv = 0; iv < vparticles.size(); ++iv) cout << vparticles[iv] << " ";
144  cout << " from mother = " << motherID << endl;
145  }
146  break;
147  }
148 
149  }
150 
151 
152  if (!accepted && chargeconju ) {
153  OK = 1;
154 
155  for (HepMC::GenEvent::particle_iterator p = myGenEvent->particles_begin();
156  p != myGenEvent->particles_end(); ++p) {
157 
158  if ((*p)->pdg_id() != -particleID) continue ;
159 
160  // -- Check for mother of this particle
161  if (0 != motherID) {
162  OK = 0;
163  for (HepMC::GenVertex::particles_in_const_iterator des = (*p)->production_vertex()->particles_in_const_begin();
164  des != (*p)->production_vertex()->particles_in_const_end();
165  ++des) {
166  if (fVerbose > 10) {
167  cout << "mother: " << (*des)->pdg_id() << " pT: " << (*des)->momentum().perp() << " eta: " << (*des)->momentum().eta() << endl;
168  }
169  if (abs(motherID) == abs((*des)->pdg_id())) {
170  OK = 1;
171  break;
172  }
173  }
174  }
175  if (0 == OK) continue;
176 
177  if (fVerbose > 5) {
178  cout << "found ID: " << (*p)->pdg_id() << " pT: " << (*p)->momentum().perp() << " eta: " << (*p)->momentum().eta() << endl;
179  }
180  vparticles.push_back((*p)->pdg_id());
181  int ndauac = 0;
182  int ndau = 0;
183  if ((*p)->end_vertex()) {
184  for (HepMC::GenVertex::particle_iterator des=(*p)->end_vertex()->particles_begin(HepMC::children);
185  des != (*p)->end_vertex()->particles_end(HepMC::children);
186  ++des) {
187  ++ndau;
188  if (fVerbose > 5) {
189  cout << "ID: " << (*des)->pdg_id() << " pT: " << (*des)->momentum().perp() << " eta: " << (*des)->momentum().eta() << endl;
190  }
191  for (unsigned int i=0; i<dauIDs.size(); ++i) {
192  int IDanti = -dauIDs[i];
193  int pythiaCode = PYCOMP(dauIDs[i]);
194  int has_antipart = pydat2.kchg[3-1][pythiaCode-1];
195  if (has_antipart == 0) IDanti = dauIDs[i];
196  if ((*des)->pdg_id() != IDanti) continue ;
197  if (fVerbose > 5) {
198  cout << "i = " << i << " pT = " << (*des)->momentum().perp() << " eta = " << (*des)->momentum().eta() << endl;
199  }
200  if ((*des)->momentum().perp() > minptcut[i] &&
201  (*des)->momentum().perp() < maxptcut &&
202  (*des)->momentum().eta() > minetacut[i] &&
203  (*des)->momentum().eta() < maxetacut[i] ) {
204  ++ndauac;
205  vparticles.push_back((*des)->pdg_id());
206  if (fVerbose > 2) {
207  cout << " accepted this particle " << (*des)->pdg_id()
208  << " pT = " << (*des)->momentum().perp() << " eta = " << (*des)->momentum().eta() << endl;
209  }
210  break;
211  }
212  }
213  }
214  }
215  if (ndau >= ndaughters && ndauac == ndaughters ) {
216  accepted = true;
217  if (fVerbose > 0) {
218  cout << " accepted this anti-decay: ";
219  for (unsigned int iv = 0; iv < vparticles.size(); ++iv) cout << vparticles[iv] << " ";
220  cout << " from mother = " << motherID << endl;
221  }
222  break;
223  }
224  }
225 
226  }
227 
228  delete myGenEvent;
229 
230 
231  if (accepted){
232  return true;
233  } else {
234  return false;
235  }
236 
237 }
int i
Definition: DBlmapReader.cc:9
#define abs(x)
Definition: mlp_lapack.h:159
std::vector< double > maxetacut
std::vector< int > dauIDs
std::vector< double > minetacut
#define PYCOMP
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::vector< double > minptcut
std::string label_
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

bool PythiaDauVFilter::chargeconju
private

Definition at line 53 of file PythiaDauVFilter.h.

Referenced by filter().

std::vector<int> PythiaDauVFilter::dauIDs
private

Definition at line 50 of file PythiaDauVFilter.h.

Referenced by filter(), and PythiaDauVFilter().

int PythiaDauVFilter::fVerbose
private

Definition at line 48 of file PythiaDauVFilter.h.

Referenced by filter().

std::string PythiaDauVFilter::label_
private
std::vector<double> PythiaDauVFilter::maxetacut
private

Definition at line 58 of file PythiaDauVFilter.h.

Referenced by filter(), and PythiaDauVFilter().

double PythiaDauVFilter::maxptcut
private

Definition at line 56 of file PythiaDauVFilter.h.

Referenced by filter(), and PythiaDauVFilter().

std::vector<double> PythiaDauVFilter::minetacut
private

Definition at line 57 of file PythiaDauVFilter.h.

Referenced by filter(), and PythiaDauVFilter().

std::vector<double> PythiaDauVFilter::minptcut
private

Definition at line 55 of file PythiaDauVFilter.h.

Referenced by filter(), and PythiaDauVFilter().

int PythiaDauVFilter::motherID
private

Definition at line 52 of file PythiaDauVFilter.h.

Referenced by filter(), and PythiaDauVFilter().

int PythiaDauVFilter::ndaughters
private

Definition at line 54 of file PythiaDauVFilter.h.

Referenced by filter().

int PythiaDauVFilter::particleID
private

Definition at line 51 of file PythiaDauVFilter.h.

Referenced by filter(), and PythiaDauVFilter().