CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GenFilterEfficiencyProducer.cc
Go to the documentation of this file.
2 
4 
6  filterPath(iConfig.getParameter<std::string>("filterPath")),
7  tns_(),
8  thisProcess(),pathIndex(100000),
9  numEventsPassPos_(0),
10  numEventsPassNeg_(0),
11  numEventsTotalPos_(0),
12  numEventsTotalNeg_(0),
13  sumpass_w_(0.),
14  sumpass_w2_(0.),
15  sumtotal_w_(0.),
16  sumtotal_w2_(0.)
17 {
18  //now do what ever initialization is needed
20  // get tns pointer
22  if (tns_!=0) {
24  std::vector<std::string> theNames = tns_->getTrigPaths();
25  for ( unsigned int i = 0; i < theNames.size(); i++ ) {
26  if ( theNames[i] == filterPath ) { pathIndex = i; continue; }
27  }
28  }
29  else
30  edm::LogError("ServiceNotAvailable") << "TriggerNamesServive not available, no filter information stored";
31  }
32 
33  produces<GenFilterInfo, edm::InLumi>();
34 
35 }
36 
37 
39 {
40 
41 }
42 
43 
44 //
45 // member functions
46 //
47 
48 // ------------ method called to for each event ------------
49 void
51 {
52 
53  edm::InputTag theTrig("TriggerResults","",thisProcess);
55  iEvent.getByLabel(theTrig,trigR);
57  if (!iEvent.getByLabel("generator", genEventScale))return;
58  double weight = genEventScale->weight();
59 
60  unsigned int nSize = (*trigR).size();
61  // std::cout << "Number of paths in TriggerResults = " << nSize << std::endl;
62  if ( nSize >= pathIndex ) {
63 
64  if (!trigR->wasrun(pathIndex))return;
65  if ( trigR->accept(pathIndex) ) {
66  sumpass_w_ += weight;
67  sumpass_w2_+= weight*weight;
68 
70  sumtotal_w2_+= weight*weight;
71 
72  if(weight > 0)
73  {
76  }
77  else
78  {
81  }
82 
83  }
84  else // if fail the filter
85  {
87  sumtotal_w2_+= weight*weight;
88 
89  if(weight > 0)
91  else
93  }
94  // std::cout << "Total events = " << numEventsTotal << " passed = " << numEventsPassed << std::endl;
95  }
96 
97 }
98 
99 
100 void
102 
107  sumpass_w_=0;
108  sumpass_w2_=0;
109  sumtotal_w_=0;
110  sumtotal_w2_=0;
111 
112 }
113 
114 void
116 
117  std::auto_ptr<GenFilterInfo> thisProduct(new GenFilterInfo(
122  sumpass_w_,
123  sumpass_w2_,
124  sumtotal_w_,
126  ));
127  iLumi.put(thisProduct);
128 
129 }
130 
131 
int i
Definition: DBlmapReader.cc:9
std::string const & getProcessName() const
int iEvent
Definition: GenABIO.cc:243
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
virtual void beginLuminosityBlock(edm::LuminosityBlock &, const edm::EventSetup &)
GenFilterEfficiencyProducer(const edm::ParameterSet &)
virtual void produce(edm::Event &, const edm::EventSetup &)
Strings const & getTrigPaths() const
edm::service::TriggerNamesService * tns_
virtual void endLuminosityBlock(edm::LuminosityBlock &, const edm::EventSetup &)
void put(std::auto_ptr< PROD > product)
Put a new product.