CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MCProcessFilter.cc
Go to the documentation of this file.
1 
3 
5 #include <iostream>
6 
7 using namespace edm;
8 using namespace std;
9 
10 
12 token_(consumes<edm::HepMCProduct>(edm::InputTag(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")),"unsmeared")))
13 {
14  //here do whatever other initialization is needed
15  vector<int> defproc ;
16  defproc.push_back(0) ;
17  processID = iConfig.getUntrackedParameter< vector<int> >("ProcessID",defproc);
18  vector<double> defpthatmin ;
19  defpthatmin.push_back(0.);
20  pthatMin = iConfig.getUntrackedParameter< vector<double> >("MinPthat", defpthatmin);
21  vector<double> defpthatmax ;
22  defpthatmax.push_back(10000.);
23  pthatMax = iConfig.getUntrackedParameter< vector<double> >("MaxPthat", defpthatmax);
24 
25 
26  // checkin size of phthat vectors -- default is allowed
27  if ( (pthatMin.size() > 1 && processID.size() != pthatMin.size())
28  || (pthatMax.size() > 1 && processID.size() != pthatMax.size()) ) {
29  cout << "WARNING: MCPROCESSFILTER : size of MinPthat and/or MaxPthat not matching with ProcessID size!!" << endl;
30  }
31 
32  // if pthatMin size smaller than processID , fill up further with defaults
33  if (processID.size() > pthatMin.size() ){
34  vector<double> defpthatmin2 ;
35  for (unsigned int i = 0; i < processID.size(); i++){ defpthatmin2.push_back(0.);}
36  pthatMin = defpthatmin2;
37  }
38  // if pthatMax size smaller than processID , fill up further with defaults
39  if (processID.size() > pthatMax.size() ){
40  vector<double> defpthatmax2 ;
41  for (unsigned int i = 0; i < processID.size(); i++){ defpthatmax2.push_back(10000.);}
42  pthatMax = defpthatmax2;
43  }
44 
45 
46 }
47 
48 
50 {
51 
52  // do anything here that needs to be done at desctruction time
53  // (e.g. close files, deallocate resources etc.)
54 
55 }
56 
57 
58 // ------------ method called to skim the data ------------
60 {
61  using namespace edm;
62  bool accepted = false;
64  iEvent.getByToken(token_, evt);
65 
66  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
67 
68 
69  // do the selection -- processID 0 is always accepted
70  for (unsigned int i = 0; i < processID.size(); i++){
71  if (processID[i] == myGenEvent->signal_process_id() || processID[i] == 0) {
72 
73  if ( myGenEvent->event_scale() > pthatMin[i] && myGenEvent->event_scale() < pthatMax[i] ) {
74  accepted = true;
75  }
76 
77  }
78  }
79 
80  if (accepted){ return true; } else {return false;}
81 
82 }
83 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< edm::HepMCProduct > token_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
std::vector< double > pthatMin
std::vector< int > processID
int iEvent
Definition: GenABIO.cc:230
MCProcessFilter(const edm::ParameterSet &)
std::vector< double > pthatMax
tuple cout
Definition: gather_cfg.py:121
virtual bool filter(edm::Event &, const edm::EventSetup &)