Go to the documentation of this file.00001 #include "GeneratorInterface/Core/interface/GenFilterEfficiencyProducer.h"
00002
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004
00005 GenFilterEfficiencyProducer::GenFilterEfficiencyProducer(const edm::ParameterSet& iConfig) :
00006 filterPath(iConfig.getParameter<std::string>("filterPath")),
00007 tns_(),
00008 thisProcess(),pathIndex(100000),
00009 numEventsTotal(0),numEventsPassed(0)
00010 {
00011
00012 if (edm::Service<edm::service::TriggerNamesService>().isAvailable()) {
00013
00014 tns_ = edm::Service<edm::service::TriggerNamesService>().operator->();
00015 if (tns_!=0) {
00016 thisProcess = tns_->getProcessName();
00017 std::vector<std::string> theNames = tns_->getTrigPaths();
00018 for ( unsigned int i = 0; i < theNames.size(); i++ ) {
00019 if ( theNames[i] == filterPath ) { pathIndex = i; continue; }
00020 }
00021 }
00022 else
00023 edm::LogError("ServiceNotAvailable") << "TriggerNamesServive not available, no filter information stored";
00024 }
00025
00026 produces<GenFilterInfo, edm::InLumi>();
00027
00028 }
00029
00030
00031 GenFilterEfficiencyProducer::~GenFilterEfficiencyProducer()
00032 {
00033
00034 }
00035
00036
00037
00038
00039
00040
00041
00042 void
00043 GenFilterEfficiencyProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00044 {
00045
00046 edm::InputTag theTrig("TriggerResults","",thisProcess);
00047 edm::Handle<edm::TriggerResults> trigR;
00048 iEvent.getByLabel(theTrig,trigR);
00049
00050 unsigned int nSize = (*trigR).size();
00051
00052 if ( nSize >= pathIndex ) {
00053 if ( trigR->wasrun(pathIndex) ) { numEventsTotal++; }
00054 if ( trigR->accept(pathIndex) ) { numEventsPassed++; }
00055
00056 }
00057
00058 }
00059
00060
00061 void
00062 GenFilterEfficiencyProducer::beginLuminosityBlock(edm::LuminosityBlock & iLumi, const edm::EventSetup&) {
00063
00064 numEventsTotal = 0;
00065 numEventsPassed = 0;
00066
00067 }
00068
00069 void
00070 GenFilterEfficiencyProducer::endLuminosityBlock(edm::LuminosityBlock & iLumi, const edm::EventSetup&) {
00071
00072 std::auto_ptr<GenFilterInfo> thisProduct(new GenFilterInfo(numEventsTotal,numEventsPassed));
00073 iLumi.put(thisProduct);
00074
00075 }
00076
00077