CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/GeneratorInterface/Core/plugins/GenFilterEfficiencyAnalyzer.cc

Go to the documentation of this file.
00001 #include "GeneratorInterface/Core/interface/GenFilterEfficiencyAnalyzer.h"
00002 
00003 GenFilterEfficiencyAnalyzer::GenFilterEfficiencyAnalyzer(const edm::ParameterSet&):
00004   nTota_(0),nPass_(0)
00005 {
00006 }
00007 
00008 GenFilterEfficiencyAnalyzer::~GenFilterEfficiencyAnalyzer()
00009 {
00010 }
00011 
00012 void
00013 GenFilterEfficiencyAnalyzer::analyze(const edm::Event&, const edm::EventSetup&)
00014 {
00015 }
00016 
00017 // ------------ method called once each job just after ending the event loop  ------------
00018 
00019 void
00020 GenFilterEfficiencyAnalyzer::endLuminosityBlock(edm::LuminosityBlock const& iLumi, edm::EventSetup const&) {
00021 
00022   edm::Handle<GenFilterInfo> genFilter;
00023   iLumi.getByType(genFilter);
00024 
00025   std::cout << "Lumi section " << iLumi.id() << std::endl;
00026   nTota_ += genFilter->numEventsTried();
00027   nPass_ += genFilter->numEventsPassed();
00028   std::cout << "N total = " << genFilter->numEventsTried() << " N passed = " << genFilter->numEventsPassed() << std::endl;
00029   std::cout << "Generator filter efficiency = " << genFilter->filterEfficiency() << " +- " << genFilter->filterEfficiencyError() << std::endl;
00030   
00031 }
00032 
00033 void
00034 GenFilterEfficiencyAnalyzer::endJob() {
00035 
00036   double eff = ( nTota_ > 0 ? (double)nPass_/(double)nTota_ : 1. ) ;
00037   double err = ( nTota_ > 0 ? std::sqrt((double)nPass_*(1.-(double)nPass_/(double)nTota_))/(double)nTota_ : 1. ); 
00038   std::cout << "Total events = " << nTota_ << " Passed events = " << nPass_ << std::endl;
00039   std::cout << "Filter efficiency = " << eff << " +- " << err << std::endl;
00040 
00041 }