CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/HLTriggerOffline/Top/src/HLTEfficiencyCalculator.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Class:      HLTEffCalculator
00004 // 
00012 //
00013 // Original Author: Abideh Jafari 
00014 //         Created:  Wed Aug 01 09:06:32 CEST 2012
00015 // $Id: HLTEfficiencyCalculator.cc,v 1.1 2012/08/01 08:26:04 ajafari Exp $
00016 //
00017 //
00018 
00019 
00020 #include "HLTriggerOffline/Top/interface/HLTEfficiencyCalculator.h"
00021 #include "FWCore/Common/interface/TriggerNames.h"
00022 #include "TFile.h"
00023 
00024 
00025 HLTEffCalculator::HLTEffCalculator(const edm::ParameterSet& iConfig)
00026 
00027 {
00028   
00029    
00030      outputFileName      = iConfig.getParameter<std::string>("OutputFileName");
00031      HLTresCollection           = iConfig.getParameter<edm::InputTag>("TriggerResCollection");
00032      verbosity =  iConfig.getUntrackedParameter<int>("verbosity",0);    
00033      myEffHandler = new  EfficiencyHandler("TopHLTs", iConfig.getParameter<std::vector<std::string> >("hltPaths"), verbosity);   
00034 }
00035 
00036 HLTEffCalculator::~HLTEffCalculator()
00037 {
00038   
00039   // do anything here that needs to be done at desctruction time
00040   // (e.g. close files, deallocate resources etc.)
00041   
00042 }
00043 
00044 
00045 //
00046 // member functions
00047 //
00048 
00049 
00050 // ------------ method called to for each event  ------------
00051 void
00052 HLTEffCalculator::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00053 {
00054   using namespace edm;
00055   
00056  
00057   // Trigger 
00058   Handle<TriggerResults> trh;
00059   iEvent.getByLabel(HLTresCollection,trh);
00060   if( ! trh.isValid() ) {
00061     LogDebug("") << "HL TriggerResults with label ["+HLTresCollection.encode()+"] not found!";
00062     return;
00063   }  
00064   myEffHandler->Fill(iEvent,*trh);
00065   
00066 }
00067 
00068 
00069 
00070 // ------------ method called once each job just before starting event loop  ------------
00071 void 
00072 HLTEffCalculator::beginJob()
00073 {}
00074 
00075 // ------------ method called once each job just after ending the event loop  ------------
00076 void 
00077 HLTEffCalculator::endJob() {  
00078         TFile * F = new TFile(outputFileName.c_str(),"recreate");
00079         myEffHandler->WriteAll(F);
00080         F->Save();
00081 }
00082