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
MCSmartSingleParticleFilter Class Reference

#include <MCSmartSingleParticleFilter.h>

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

Public Member Functions

virtual bool filter (edm::Event &, const edm::EventSetup &)
 
 MCSmartSingleParticleFilter (const edm::ParameterSet &)
 
 ~MCSmartSingleParticleFilter ()
 
- 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

std::vector< double > decayRadiusMax
 
std::vector< double > decayRadiusMin
 
std::vector< double > decayZMax
 
std::vector< double > decayZMin
 
std::vector< double > etaMax
 
std::vector< double > etaMin
 
std::string label_
 
std::vector< int > particleID
 
std::vector< double > pMin
 
std::vector< double > ptMin
 
std::vector< int > status
 

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

Definition at line 36 of file MCSmartSingleParticleFilter.h.

Constructor & Destructor Documentation

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

Definition at line 11 of file MCSmartSingleParticleFilter.cc.

References gather_cfg::cout, decayRadiusMax, decayRadiusMin, decayZMax, decayZMin, etaMax, etaMin, edm::ParameterSet::getUntrackedParameter(), i, particleID, pMin, ptMin, and status.

11  :
12 label_(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")))
13 {
14  //here do whatever other initialization is needed
15  vector<int> defpid ;
16  defpid.push_back(0) ;
17  particleID = iConfig.getUntrackedParameter< vector<int> >("ParticleID",defpid);
18  vector<double> defpmin ;
19  defpmin.push_back(0.);
20  pMin = iConfig.getUntrackedParameter< vector<double> >("MinP", defpmin);
21 
22  vector<double> defptmin ;
23  defptmin.push_back(0.);
24  ptMin = iConfig.getUntrackedParameter< vector<double> >("MinPt", defptmin);
25 
26  vector<double> defetamin ;
27  defetamin.push_back(-10.);
28  etaMin = iConfig.getUntrackedParameter< vector<double> >("MinEta", defetamin);
29  vector<double> defetamax ;
30  defetamax.push_back(10.);
31  etaMax = iConfig.getUntrackedParameter< vector<double> >("MaxEta", defetamax);
32  vector<int> defstat ;
33  defstat.push_back(0);
34  status = iConfig.getUntrackedParameter< vector<int> >("Status", defstat);
35 
36  vector<double> defDecayRadiusmin;
37  defDecayRadiusmin.push_back(-1.);
38  decayRadiusMin = iConfig.getUntrackedParameter< vector<double> >("MinDecayRadius", defDecayRadiusmin);
39 
40  vector<double> defDecayRadiusmax;
41  defDecayRadiusmax.push_back(1.e5);
42  decayRadiusMax = iConfig.getUntrackedParameter< vector<double> >("MaxDecayRadius", defDecayRadiusmax);
43 
44  vector<double> defDecayZmin;
45  defDecayZmin.push_back(-1.e5);
46  decayZMin = iConfig.getUntrackedParameter< vector<double> >("MinDecayZ", defDecayZmin);
47 
48  vector<double> defDecayZmax;
49  defDecayZmax.push_back(1.e5);
50  decayZMax = iConfig.getUntrackedParameter< vector<double> >("MaxDecayZ", defDecayZmax);
51 
52  // check for same size
53  if ( (pMin.size() > 1 && particleID.size() != pMin.size())
54  || (ptMin.size() > 1 && particleID.size() != ptMin.size())
55  || (etaMin.size() > 1 && particleID.size() != etaMin.size())
56  || (etaMax.size() > 1 && particleID.size() != etaMax.size())
57  || (status.size() > 1 && particleID.size() != status.size())
58  || (decayRadiusMin.size() > 1 && particleID.size() != decayRadiusMin.size())
59  || (decayRadiusMax.size() > 1 && particleID.size() != decayRadiusMax.size())
60  || (decayZMin.size() > 1 && particleID.size() != decayZMin.size())
61  || (decayZMax.size() > 1 && particleID.size() != decayZMax.size()) ) {
62  cout << "WARNING: MCPROCESSFILTER : size of MinPthat and/or MaxPthat not matching with ProcessID size!!" << endl;
63  }
64 
65  // if pMin size smaller than particleID , fill up further with defaults
66  if (particleID.size() > pMin.size() ){
67  vector<double> defpmin2 ;
68  for (unsigned int i = 0; i < particleID.size(); i++){ defpmin2.push_back(0.);}
69  pMin = defpmin2;
70  }
71  // if ptMin size smaller than particleID , fill up further with defaults
72  if (particleID.size() > ptMin.size() ){
73  vector<double> defptmin2 ;
74  for (unsigned int i = 0; i < particleID.size(); i++){ defptmin2.push_back(0.);}
75  ptMin = defptmin2;
76  }
77  // if etaMin size smaller than particleID , fill up further with defaults
78  if (particleID.size() > etaMin.size() ){
79  vector<double> defetamin2 ;
80  for (unsigned int i = 0; i < particleID.size(); i++){ defetamin2.push_back(-10.);}
81  etaMin = defetamin2;
82  }
83  // if etaMax size smaller than particleID , fill up further with defaults
84  if (particleID.size() > etaMax.size() ){
85  vector<double> defetamax2 ;
86  for (unsigned int i = 0; i < particleID.size(); i++){ defetamax2.push_back(10.);}
87  etaMax = defetamax2;
88  }
89  // if status size smaller than particleID , fill up further with defaults
90  if (particleID.size() > status.size() ){
91  vector<int> defstat2 ;
92  for (unsigned int i = 0; i < particleID.size(); i++){ defstat2.push_back(0);}
93  status = defstat2;
94  }
95 
96  // if decayRadiusMin size smaller than particleID , fill up further with defaults
97  if (particleID.size() > decayRadiusMin.size() ){
98  vector<double> decayRadiusmin2 ;
99  for (unsigned int i = 0; i < particleID.size(); i++){ decayRadiusmin2.push_back(-10.);}
100  decayRadiusMin = decayRadiusmin2;
101  }
102  // if decayRadiusMax size smaller than particleID , fill up further with defaults
103  if (particleID.size() > decayRadiusMax.size() ){
104  vector<double> decayRadiusmax2 ;
105  for (unsigned int i = 0; i < particleID.size(); i++){ decayRadiusmax2.push_back(1.e5);}
106  decayRadiusMax = decayRadiusmax2;
107  }
108 
109  // if decayZMin size smaller than particleID , fill up further with defaults
110  if (particleID.size() > decayZMin.size() ){
111  vector<double> decayZmin2 ;
112  for (unsigned int i = 0; i < particleID.size(); i++){ decayZmin2.push_back(-1.e5);}
113  decayZMin = decayZmin2;
114  }
115  // if decayZMax size smaller than particleID , fill up further with defaults
116  if (particleID.size() > decayZMax.size() ){
117  vector<double> decayZmax2 ;
118  for (unsigned int i = 0; i < particleID.size(); i++){ decayZmax2.push_back(1.e5);}
119  decayZMax = decayZmax2;
120  }
121 
122 
123 }
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
tuple cout
Definition: gather_cfg.py:121
MCSmartSingleParticleFilter::~MCSmartSingleParticleFilter ( )

Definition at line 126 of file MCSmartSingleParticleFilter.cc.

127 {
128 
129  // do anything here that needs to be done at desctruction time
130  // (e.g. close files, deallocate resources etc.)
131 
132 }

Member Function Documentation

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

Implements edm::EDFilter.

Definition at line 136 of file MCSmartSingleParticleFilter.cc.

References decayRadiusMax, decayRadiusMin, decayZMax, decayZMin, etaMax, etaMin, edm::Event::getByLabel(), i, label_, AlCaHLTBitMon_ParallelJobs::p, particleID, pMin, ptMin, mathSSE::sqrt(), and status.

137 {
138  using namespace edm;
139  bool accepted = false;
141  iEvent.getByLabel(label_, evt);
142 
143  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
144 
145 
146  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
147  p != myGenEvent->particles_end(); ++p ) {
148 
149 
150  for (unsigned int i = 0; i < particleID.size(); i++){
151  if (particleID[i] == (*p)->pdg_id() || particleID[i] == 0) {
152 
153  if ( (*p)->momentum().rho() > pMin[i] && (*p)->momentum().perp() > ptMin[i]
154  && (*p)->momentum().eta() > etaMin[i] && (*p)->momentum().eta() < etaMax[i]
155  && ((*p)->status() == status[i] || status[i] == 0)) {
156 
157  if (!((*p)->production_vertex())) continue;
158 
159  double decx = (*p)->production_vertex()->position().x();
160  double decy = (*p)->production_vertex()->position().y();
161  double decrad = sqrt(decx*decx+decy*decy);
162  if (decrad<decayRadiusMin[i] ) continue;
163  if (decrad>decayRadiusMax[i] ) continue;
164 
165  double decz = (*p)->production_vertex()->position().z();
166  if (decz<decayZMin[i] ) continue;
167  if (decz>decayZMax[i] ) continue;
168 
169  accepted = true;
170  }
171 
172  }
173  }
174 
175 
176  }
177 
178  if (accepted){ return true; } else {return false;}
179 
180 }
int i
Definition: DBlmapReader.cc:9
T sqrt(T t)
Definition: SSEVec.h:46
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356

Member Data Documentation

std::vector<double> MCSmartSingleParticleFilter::decayRadiusMax
private

Definition at line 54 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

std::vector<double> MCSmartSingleParticleFilter::decayRadiusMin
private

Definition at line 53 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

std::vector<double> MCSmartSingleParticleFilter::decayZMax
private

Definition at line 56 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

std::vector<double> MCSmartSingleParticleFilter::decayZMin
private

Definition at line 55 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

std::vector<double> MCSmartSingleParticleFilter::etaMax
private

Definition at line 51 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

std::vector<double> MCSmartSingleParticleFilter::etaMin
private

Definition at line 50 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

std::string MCSmartSingleParticleFilter::label_
private
std::vector<int> MCSmartSingleParticleFilter::particleID
private

Definition at line 47 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

std::vector<double> MCSmartSingleParticleFilter::pMin
private

Definition at line 48 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

std::vector<double> MCSmartSingleParticleFilter::ptMin
private

Definition at line 49 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

std::vector<int> MCSmartSingleParticleFilter::status
private