Go to the documentation of this file.00001 #include "FWCore/Framework/interface/EDAnalyzer.h"
00002 #include "DataFormats/Common/interface/Handle.h"
00003 #include "FWCore/Framework/interface/Event.h"
00004 #include "FWCore/Framework/interface/MakerMacros.h"
00005
00006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00007 #include "DQM/HLTEvF/interface/HLTMonElectronConsumer.h"
00008 #include "DataFormats/Common/interface/RefToBase.h"
00009 #include "DQMServices/Core/interface/DQMStore.h"
00010 #include "DQMServices/Core/interface/MonitorElement.h"
00011
00012 using namespace edm;
00013
00014 HLTMonElectronConsumer::HLTMonElectronConsumer(const edm::ParameterSet& iConfig)
00015 {
00016
00017 LogDebug("HLTMonElectronConsumer") << "constructor...." ;
00018
00019 logFile_.open("HLTMonElectronConsumer.log");
00020
00021 dbe = NULL;
00022 if (iConfig.getUntrackedParameter < bool > ("DQMStore", false)) {
00023 dbe = Service < DQMStore > ().operator->();
00024 dbe->setVerbose(0);
00025 }
00026
00027 outputFile_ =
00028 iConfig.getUntrackedParameter <std::string>("outputFile", "");
00029 if (outputFile_.size() != 0) {
00030 LogInfo("HLTMonElectronConsumer") << "L1T Monitoring histograms will be saved to "
00031 << outputFile_ ;
00032 }
00033 else {
00034 outputFile_ = "L1TDQM.root";
00035 }
00036
00037 bool disable =
00038 iConfig.getUntrackedParameter < bool > ("disableROOToutput", false);
00039 if (disable) {
00040 outputFile_ = "";
00041 }
00042
00043 pixeltag_=iConfig.getParameter<edm::InputTag>("PixelTag");
00044 isotag_=iConfig.getParameter<edm::InputTag>("IsoTag");
00045
00046 dirname_="HLT/HLTMonElectron/"+iConfig.getParameter<std::string>("@module_label");
00047 pixeldirname_="HLT/HLTMonElectron/"+pixeltag_.label();
00048 isodirname_="HLT/HLTMonElectron/"+isotag_.label();
00049
00050 if (dbe != NULL) {
00051 dbe->setCurrentFolder(dirname_);
00052 }
00053
00054 }
00055
00056
00057 HLTMonElectronConsumer::~HLTMonElectronConsumer()
00058 {
00059
00060
00061
00062
00063 }
00064
00065
00066
00067
00068
00069
00070
00071 void
00072 HLTMonElectronConsumer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00073 {
00074
00075 if(pixeltotal!=NULL){
00076 LogInfo("HLTMonElectronConsumer") << " pixelhisto " << pixeltotal->getBinContent(1);
00077 if(pixeltotal->getBinContent(1)!=0)
00078 pixelEff->Fill(pixeltotal->getBinContent(2)/pixeltotal->getBinContent(1));
00079 else
00080 pixelEff->Fill(0.);
00081
00082 if(pixeltotal->getBinContent(3)!=0)
00083 trackEff->Fill(pixeltotal->getBinContent(4)/pixeltotal->getBinContent(3));
00084 else
00085 trackEff->Fill(0.);
00086
00087
00088 for(int i =0; i<2 ;i++){
00089 TH1F* num;
00090 TH1F* denom;
00091 num=pixelhistosEt[2*i+1]->getTH1F();
00092 denom=pixelhistosEt[2*i]->getTH1F();
00093 for(int j=1; j <= pixelhistosEtOut[i]->getNbinsX();j++ ){
00094 if(denom->GetBinContent(j)!=0)
00095 pixelhistosEtOut[i]->setBinContent(j,num->GetBinContent(j)/denom->GetBinContent(j));
00096 else
00097 pixelhistosEtOut[i]->setBinContent(j,0.);
00098 }
00099 num=pixelhistosEta[2*i+1]->getTH1F();
00100 denom=pixelhistosEta[2*i]->getTH1F();
00101 for(int j=1; j <= pixelhistosEtaOut[i]->getNbinsX();j++ ){
00102 if(denom->GetBinContent(j)!=0)
00103 pixelhistosEtaOut[i]->setBinContent(j,num->GetBinContent(j)/denom->GetBinContent(j));
00104 else
00105 pixelhistosEtaOut[i]->setBinContent(j,0.);
00106 }
00107 num=pixelhistosPhi[2*i+1]->getTH1F();
00108 denom=pixelhistosPhi[2*i]->getTH1F();
00109 for(int j=1; j <= pixelhistosPhiOut[i]->getNbinsX();j++ ){
00110 if(denom->GetBinContent(j)!=0)
00111 pixelhistosPhiOut[i]->setBinContent(j,num->GetBinContent(j)/denom->GetBinContent(j));
00112 else
00113 pixelhistosPhiOut[i]->setBinContent(j,0.);
00114 }
00115 }
00116 }else
00117 LogInfo("HLTMonElectronConsumer") << " empty pixelhisto " ;
00118
00119 if(isototal!=NULL){
00120 TH1F* refhist = isototal->getTH1F();
00121 for(int i =1; i<= refhist->GetNbinsX();i++){
00122 if(refhist->GetMaximum(i)!=0)
00123 isocheck->setBinContent(i,refhist->GetBinContent(i)/refhist->GetMaximum());
00124 else
00125 isocheck->setBinContent(i,0.);
00126 }
00127 }else
00128 LogInfo("HLTMonElectronConsumer") << " empty isohisto " ;
00129
00130
00131
00132 }
00133
00134
00135
00136 void
00137 HLTMonElectronConsumer::beginJob()
00138 {
00139
00140 DQMStore *dbe = 0;
00141 dbe = Service < DQMStore > ().operator->();
00142
00143 if (dbe) {
00144 dbe->setCurrentFolder(dirname_);
00145 dbe->rmdir(dirname_);
00146 }
00147
00148
00149 if (dbe) {
00150 dbe->setCurrentFolder(dirname_);
00151
00152
00153
00154 std::string tmpname = pixeldirname_ + "/total eff";
00155 LogInfo("HLTMonElectronConsumer") << " reading histo: " << tmpname;
00156 pixeltotal=dbe->get(tmpname);
00157 TH1F* refhist;
00158 if(pixeltotal!=0){
00159 for(int i = 0; i<4; i++){
00160 LogInfo("HLTMonElectronConsumer") << "loop iteration: "<<i ;
00161 refhist=pixeltotal->getTH1F();
00162 LogInfo("HLTMonElectronConsumer") << "retrieving: " << pixeldirname_ + "/" + refhist->GetXaxis()->GetBinLabel(i+1) + "eta";
00163 tmpname = pixeldirname_ + "/" + refhist->GetXaxis()->GetBinLabel(i+1) + "eta";
00164 pixelhistosEta[i]=dbe->get(tmpname);
00165 tmpname = pixeldirname_ + "/" + refhist->GetXaxis()->GetBinLabel(i+1) + "et";
00166 pixelhistosEt[i]=dbe->get(tmpname);
00167 tmpname = pixeldirname_ + "/" + refhist->GetXaxis()->GetBinLabel(i+1) + "phi";
00168 pixelhistosPhi[i]=dbe->get(tmpname);
00169 }
00170 LogInfo("HLTMonElectronConsumer") << "Et ";
00171 refhist = pixelhistosEt[0]->getTH1F();
00172 pixelhistosEtOut[0] =dbe->book1D("pixel eff et","pixel eff et",refhist->GetNbinsX(),refhist->GetXaxis()->GetXmin(),refhist->GetXaxis()->GetXmax());
00173 pixelhistosEtOut[1] =dbe->book1D("track eff et","track eff et",refhist->GetNbinsX(),refhist->GetXaxis()->GetXmin(),refhist->GetXaxis()->GetXmax());
00174 LogInfo("HLTMonElectronConsumer") << "Eta ";
00175 refhist = pixelhistosEta[0]->getTH1F();
00176 pixelhistosEtaOut[0] =dbe->book1D("pixel eff eta","pixel eff eta",refhist->GetNbinsX(),refhist->GetXaxis()->GetXmin(),refhist->GetXaxis()->GetXmax());
00177 pixelhistosEtaOut[1] =dbe->book1D("track eff eta","track eff eta",refhist->GetNbinsX(),refhist->GetXaxis()->GetXmin(),refhist->GetXaxis()->GetXmax());
00178 LogInfo("HLTMonElectronConsumer") << "Phi ";
00179 refhist = pixelhistosPhi[0]->getTH1F();
00180 pixelhistosPhiOut[0] =dbe->book1D("pixel eff phi","pixel eff phi",refhist->GetNbinsX(),refhist->GetXaxis()->GetXmin(),refhist->GetXaxis()->GetXmax());
00181 pixelhistosPhiOut[1] =dbe->book1D("track eff phi","track eff phi",refhist->GetNbinsX(),refhist->GetXaxis()->GetXmin(),refhist->GetXaxis()->GetXmax());
00182 }else
00183 LogInfo("HLTMonElectronConsumer") << "pixelhisto doesn't exist during beginJob" ;
00184
00185 pixelEff=dbe->bookFloat("total pixelmatch");
00186 trackEff=dbe->bookFloat("total trackmatch");
00187
00188 LogInfo("HLTMonElectronConsumer") << "writing: " << pixelEff->getPathname();
00189
00190
00191 tmpname = isodirname_ + "/total eff";
00192 LogInfo("HLTMonElectronConsumer") << " reading histo: " << tmpname;
00193 isototal=dbe->get(tmpname);
00194 refhist = isototal->getTH1F();
00195 isocheck = dbe->book1D("consistency check","consistency check",refhist->GetNbinsX(),refhist->GetXaxis()->GetXmin(),refhist->GetXaxis()->GetXmax());
00196
00197
00198 }
00199 }
00200
00201
00202 void
00203 HLTMonElectronConsumer::endJob() {
00204
00205
00206
00207 if (outputFile_.size() != 0 && dbe)
00208 dbe->save(outputFile_);
00209
00210 return;
00211 }
00212
00213