CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/Validation/RecoParticleFlow/plugins/PFTauElecRejectionBenchMarkAnalyzer.cc

Go to the documentation of this file.
00001 // system include files
00002 #include <memory>
00003 
00004 // user include files
00005 #include "FWCore/Framework/interface/Frameworkfwd.h"
00006 #include "FWCore/Framework/interface/EDAnalyzer.h"
00007 
00008 #include "FWCore/Framework/interface/Event.h"
00009 #include "FWCore/Framework/interface/MakerMacros.h"
00010 
00011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00012 #include "FWCore/ServiceRegistry/interface/Service.h" 
00013 #include "FWCore/Utilities/interface/InputTag.h"
00014 
00015 #include "RecoParticleFlow/Benchmark/interface/PFTauElecRejectionBenchmark.h"
00016 
00017 
00018 using namespace edm;
00019 using namespace reco;
00020 using namespace std;
00021 
00022 //
00023 // class declaration
00024 
00025  
00026 class PFTauElecRejectionBenchmarkAnalyzer : public edm::EDAnalyzer {
00027 public:
00028   explicit PFTauElecRejectionBenchmarkAnalyzer(const edm::ParameterSet&);
00029   ~PFTauElecRejectionBenchmarkAnalyzer();
00030 
00031 
00032 private:
00033   virtual void beginJob() ;
00034   virtual void analyze(const edm::Event&, const edm::EventSetup&);
00035   virtual void endJob() ;  
00036   // ----------member data ---------------------------
00037 
00038   string outputfile;
00039   DQMStore * db;
00040   string benchmarkLabel;
00041   InputTag sGenParticleSource;
00042   double maxDeltaR;
00043   double minMCPt;
00044   double maxMCAbsEta;
00045   double minRecoPt;
00046   double maxRecoAbsEta;
00047   InputTag pfTauProducer; 
00048   InputTag pfTauDiscriminatorByIsolationProducer; 
00049   InputTag pfTauDiscriminatorAgainstElectronProducer; 
00050   bool applyEcalCrackCut;
00051   string  sGenMatchObjectLabel;
00052   
00053   PFTauElecRejectionBenchmark PFTauElecRejectionBenchmark_;
00054 };
00056 
00057 //
00058 // constants, enums and typedefs
00059 //
00060 
00061 //
00062 // static data member definitions
00063 //
00064 
00065 //
00066 // constructors and destructor
00067 //
00068 PFTauElecRejectionBenchmarkAnalyzer::PFTauElecRejectionBenchmarkAnalyzer(const edm::ParameterSet& iConfig)
00069 
00070 {
00071   //now do what ever initialization is needed
00072   outputfile = 
00073     iConfig.getUntrackedParameter<string>("OutputFile");
00074   benchmarkLabel =
00075     iConfig.getParameter<string>("BenchmarkLabel");
00076   sGenParticleSource = 
00077     iConfig.getParameter<InputTag>("InputTruthLabel");
00078   maxDeltaR = 
00079     iConfig.getParameter<double>("maxDeltaR");    
00080   minMCPt  = 
00081     iConfig.getParameter<double>("minMCPt"); 
00082   maxMCAbsEta = 
00083     iConfig.getParameter<double>("maxMCAbsEta"); 
00084   minRecoPt  = 
00085     iConfig.getParameter<double>("minRecoPt"); 
00086   maxRecoAbsEta = 
00087     iConfig.getParameter<double>("maxRecoAbsEta"); 
00088   pfTauProducer = 
00089     iConfig.getParameter<InputTag>("PFTauProducer");
00090   pfTauDiscriminatorByIsolationProducer = 
00091     iConfig.getParameter<InputTag>("PFTauDiscriminatorByIsolationProducer");
00092   pfTauDiscriminatorAgainstElectronProducer = 
00093     iConfig.getParameter<InputTag>("PFTauDiscriminatorAgainstElectronProducer");
00094   sGenMatchObjectLabel =
00095     iConfig.getParameter<string>("GenMatchObjectLabel");
00096   applyEcalCrackCut =
00097     iConfig.getParameter<bool>("ApplyEcalCrackCut");
00098 
00099 
00100   db = edm::Service<DQMStore>().operator->();
00101   
00102 
00103   PFTauElecRejectionBenchmark_.setup(
00104                         outputfile,
00105                         benchmarkLabel,
00106                         maxDeltaR,
00107                         minRecoPt, 
00108                         maxRecoAbsEta,
00109                         minMCPt, 
00110                         maxMCAbsEta,
00111                         sGenMatchObjectLabel,
00112                         applyEcalCrackCut,
00113                         db);
00114 }
00115 
00116 
00117 PFTauElecRejectionBenchmarkAnalyzer::~PFTauElecRejectionBenchmarkAnalyzer()
00118 {
00119   // do anything here that needs to be done at desctruction time
00120   // (e.g. close files, deallocate resources etc.)
00121 }
00122 
00123 
00124 //
00125 // member functions
00126 //
00127 
00128 // ------------ method called to for each event  ------------
00129 void
00130 PFTauElecRejectionBenchmarkAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00131 {
00132 
00133   // get gen products
00134   Handle<HepMCProduct> mcevt;
00135   iEvent.getByLabel(sGenParticleSource, mcevt);
00136 
00137   // get pftau collection
00138   Handle<PFTauCollection> thePFTau;
00139   iEvent.getByLabel(pfTauProducer,thePFTau);
00140   
00141   // get iso discriminator association vector
00142   Handle<PFTauDiscriminator> thePFTauDiscriminatorByIsolation;
00143   iEvent.getByLabel(pfTauDiscriminatorByIsolationProducer,thePFTauDiscriminatorByIsolation);
00144 
00145   // get anti-elec discriminator association vector
00146   Handle<PFTauDiscriminator> thePFTauDiscriminatorAgainstElectron;
00147   iEvent.getByLabel(pfTauDiscriminatorAgainstElectronProducer,thePFTauDiscriminatorAgainstElectron);
00148 
00149   PFTauElecRejectionBenchmark_.process(mcevt, thePFTau, thePFTauDiscriminatorByIsolation, 
00150                                        thePFTauDiscriminatorAgainstElectron);
00151 }
00152 
00153 
00154 // ------------ method called once each job just before starting event loop  ------------
00155 void 
00156 PFTauElecRejectionBenchmarkAnalyzer::beginJob()
00157 {
00158 }
00159 
00160 // ------------ method called once each job just after ending the event loop  ------------
00161 void 
00162 PFTauElecRejectionBenchmarkAnalyzer::endJob() {
00163   PFTauElecRejectionBenchmark_.write();
00164 }
00165 
00166 //define this as a plug-in
00167 DEFINE_FWK_MODULE(PFTauElecRejectionBenchmarkAnalyzer);
00168