CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/DQMOffline/CalibCalo/src/DQMHcalIsoTrackPostProcessor.cc

Go to the documentation of this file.
00001 #include "DQMServices/Core/interface/DQMStore.h"
00002 #include "DQMServices/Core/interface/MonitorElement.h"
00003 #include "FWCore/ServiceRegistry/interface/Service.h"
00004 #include "FWCore/Framework/interface/MakerMacros.h"
00005 
00006 #include "FWCore/Framework/interface/Frameworkfwd.h"
00007 #include "FWCore/Framework/interface/EDAnalyzer.h"
00008 
00009 #include <iostream>
00010 #include <string.h>
00011 #include <iomanip>
00012 #include<fstream>
00013 #include <math.h>
00014 
00015 
00016 class DQMHcalIsoTrackPostProcessor : public edm::EDAnalyzer {
00017  public:
00018   DQMHcalIsoTrackPostProcessor(const edm::ParameterSet& pset);
00019   ~DQMHcalIsoTrackPostProcessor() {};
00020 
00021   void analyze(const edm::Event& event, const edm::EventSetup& eventSetup) {};
00022   void endRun(edm::Run const&, edm::EventSetup const&);
00023   void endJob();
00024 
00025  private:
00026 
00027   std::string subDir_;
00028   bool saveToFile_;
00029   std::string outputRootFileName_;
00030 
00031 };
00032 
00033 
00034 DQMHcalIsoTrackPostProcessor::DQMHcalIsoTrackPostProcessor(const edm::ParameterSet& pset)
00035 {
00036   subDir_ = pset.getUntrackedParameter<std::string>("subDir");
00037   saveToFile_=pset.getParameter<bool>("saveToFile");
00038   outputRootFileName_=pset.getParameter<std::string>("outputFile");
00039 }
00040 
00041 void DQMHcalIsoTrackPostProcessor::endRun(edm::Run const& run, edm::EventSetup const& es)
00042 {
00043 }
00044 
00045 void DQMHcalIsoTrackPostProcessor::endJob()
00046 {
00047 
00048   DQMStore* dqm;
00049   dqm = 0;
00050   dqm = edm::Service<DQMStore>().operator->();
00051 
00052   if ( ! dqm ) {
00053     edm::LogInfo("DQMHcalIsoTrackPostProcessor") << "Cannot create DQMStore instance\n";
00054     return;
00055   }
00056 
00057   std::cout<<"endjob"<<std::endl;
00058   if(dqm->dirExists(subDir_)) dqm->cd(subDir_);
00059   else {
00060    edm::LogWarning("DQMHcalIsoTrackPostProcessor") << "cannot find directory: " << subDir_ << " , skipping";
00061     return;
00062   }
00063 
00064   MonitorElement* hPurityEta=dqm->book1D("hPurityEta","Purity of sample vs eta",16,-2,2);
00065   MonitorElement* hPurityPhi=dqm->book1D("hPurityPhi","Purity of sample vs phi",16,-3.2,3.2);
00066 
00067   MonitorElement* hSumOffEta=dqm->book1D("hSumOffEta","hSumOffEta",16,-2,2);
00068   MonitorElement* hSumOffPhi=dqm->book1D("hSumOffPhi","hSumOffPhi",16,-3.2,3.2);
00069   
00070   MonitorElement* hSumL3Eta=dqm->book1D("hSumL3Eta","hSumL3Eta",16,-2,2);
00071   MonitorElement* hSumL3Phi=dqm->book1D("hSumL3Phi","hSumL3Phi",16,-3.2,3.2);
00072 
00073   hSumOffEta->getTH1F()->Add(dqm->get(dqm->pwd() + "/hOffEtaFP")->getTH1F(),1);
00074   hSumOffPhi->getTH1F()->Add(dqm->get(dqm->pwd() + "/hOffPhiFP")->getTH1F(),1);
00075     
00076   hSumL3Eta->getTH1F()->Add(dqm->get(dqm->pwd() + "/hl3eta")->getTH1F(),1);
00077   hSumL3Phi->getTH1F()->Add(dqm->get(dqm->pwd() + "/hl3phi")->getTH1F(),1);
00078  
00079 
00080   hSumOffEta->getTH1F()->TH1F::Sumw2();
00081   hSumOffPhi->getTH1F()->TH1F::Sumw2();
00082   hSumL3Eta->getTH1F()->TH1F::Sumw2();
00083   hSumL3Phi->getTH1F()->TH1F::Sumw2();
00084 
00085   hPurityEta->getTH1F()->Divide(hSumOffEta->getTH1F(),hSumL3Eta->getTH1F(),1,1);
00086   hPurityPhi->getTH1F()->Divide(hSumOffPhi->getTH1F(),hSumL3Phi->getTH1F(),1,1);
00087 
00088   if (saveToFile_) dqm->save(outputRootFileName_);
00089 }
00090 
00091 DEFINE_FWK_MODULE(DQMHcalIsoTrackPostProcessor);
00092 
00093