00001 #include "HLTriggerOffline/SUSYBSM/interface/HltSusyExoPostProcessor.h"
00002
00003 #include "DQMServices/Core/interface/DQMStore.h"
00004 #include "DQMServices/Core/interface/MonitorElement.h"
00005 #include "FWCore/ServiceRegistry/interface/Service.h"
00006 #include "FWCore/Framework/interface/MakerMacros.h"
00007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00008
00009
00010 #include <iostream>
00011 #include <string.h>
00012 #include <iomanip>
00013 #include <fstream>
00014 #include <math.h>
00015 #include "TH1.h"
00016 #include "TProfile.h"
00017
00018 using namespace std;
00019 using namespace edm;
00020
00021 HltSusyExoPostProcessor::HltSusyExoPostProcessor(const edm::ParameterSet& pset):
00022 subDir_(pset.getUntrackedParameter<std::string>("subDir", std::string("HLT/SusyExo"))),
00023 mcFlag(pset.getUntrackedParameter<bool>("mc_flag",true)),
00024 reco_parametersets(pset.getParameter<VParameterSet>("reco_parametersets")),
00025 mc_parametersets(pset.getParameter<VParameterSet>("mc_parametersets"))
00026 {
00027 for(unsigned int i=0; i<reco_parametersets.size(); ++i)
00028 reco_dirs.push_back(reco_parametersets[i].getParameter<string>("name"));
00029 for(unsigned int i=0; i<mc_parametersets.size(); ++i)
00030 mc_dirs.push_back(mc_parametersets[i].getParameter<string>("name"));
00031 }
00032
00033
00034 void HltSusyExoPostProcessor::endRun(edm::Run const& run, edm::EventSetup const& es)
00035 {
00036
00037 LogDebug("HltSusyExoPostProcessor") << "Start endRun";
00039
00041
00042 dqm = 0;
00043 dqm = edm::Service<DQMStore>().operator->();
00044
00045 if ( ! dqm ) {
00046 edm::LogInfo("HltSusyExoPostProcessor") << "Cannot create DQMStore instance\n";
00047 return;
00048 }
00049
00050 LogDebug("HltSusyExoPostProcessor") << "DQMStore opened";
00051
00052
00053 if(dqm->dirExists(subDir_)) dqm->cd(subDir_);
00054 else {
00055 edm::LogWarning("HltSusyExoPostProcessor") << "cannot find directory: " << subDir_ << " , skipping";
00056 return;
00057 }
00058
00059 LogDebug("HltSusyExoPostProcessor") << "DQMStore cd";
00060
00061
00062 std::string triggerBitsDir = "/TriggerBits";
00063 std::string recoSelBitsDir = "/RecoSelection";
00064 std::string mcSelBitsDir = "/McSelection";
00065 std::string byEventDir = "/By_Event";
00066 std::string byMuonDir = "/By_Muon";
00067
00068
00069
00070
00071
00072 int nL1bins = (dqm->get(dqm->pwd() + triggerBitsDir + "/L1Bits")->getNbinsX());
00073 int nHltbins = (dqm->get(dqm->pwd() + triggerBitsDir + "/HltBits")->getNbinsX());
00074
00075 std::vector<int> L1placement; for(int i=0; i<nL1bins-1*mcFlag; ++i) L1placement.push_back(6);
00076 std::vector<int> Hltplacement; for(int i=0; i<nHltbins-1*mcFlag; ++i) Hltplacement.push_back(7);
00077 int L1bins[7]; for(unsigned int i=0; i<sizeof(L1bins)/sizeof(L1bins[0]); ++i) L1bins[i]=0;
00078 int Hltbins[8]; for(unsigned int i=0; i<sizeof(Hltbins)/sizeof(Hltbins[0]); ++i) Hltbins[i]=0;
00079 string L1search[8] = {"Mu","EG","Jet","ET","TauJet","X",""};
00080 string L1search3 = "HTT", L1search6 = "Bias";
00081 string Hltsearch[8] = {"Mu","Ele","Jet","Photon","MET","Tau","X",""};
00082 string Hltsearch4 = "HT", Hltsearch5 = "BTag", Hltsearch6_1 = "EG", Hltsearch6_2 = "ET", Hltsearch7_1 = "Bias", Hltsearch7_2 = "AlCa";
00083
00084
00085 LogDebug("HltSusyExoPostProcessor") << "number of L1 bins = " << nL1bins << " number of HLT bins = " << nHltbins;
00086 double value = 0;
00087 double error = 0;
00088
00089
00090 dqm->setCurrentFolder(subDir_ + triggerBitsDir);
00091
00092
00093
00094
00095
00096
00097 TH1F* hL1Paths = dqm->get(subDir_ + triggerBitsDir + "/L1Paths")->getTH1F();
00098 MonitorElement* hL1EffBeforeCuts = bookEffMEProfileFromTH1(hL1Paths, "Eff");
00099 TH1F* hHltPaths = dqm->get(subDir_ + triggerBitsDir + "/HltPaths")->getTH1F();
00100 MonitorElement* hHltEffBeforeCuts = bookEffMEProfileFromTH1(hHltPaths, "Eff");
00101
00102
00103
00104 LogDebug("HltSusyExoPostProcessor") << "MonitorElements booked";
00105
00106
00107 float nTotalBeforeCuts = -1;
00108 int reference_bin = -1;
00109 if(mcFlag)
00110 {
00111 nTotalBeforeCuts = dqm->get(subDir_ + triggerBitsDir + "/L1Bits")->getBinContent(nL1bins);
00112 reference_bin = nL1bins;
00113 }
00114 else
00115 {
00116 for(int i=0; i<nHltbins; ++i)
00117 {
00118 string triggername = ((TProfile*)hHltEffBeforeCuts->getTProfile())->GetXaxis()->GetBinLabel(i+1);
00119 string eff_search = "HLT_ZeroBias";
00120 if(triggername.find(eff_search)!=string::npos && triggername.size()==eff_search.size())
00121 {
00122 nTotalBeforeCuts = ((TProfile*)hHltEffBeforeCuts->getTProfile())->GetBinContent(i+1);
00123 reference_bin = i+1;
00124 break;
00125 }
00126 }
00127 if(nTotalBeforeCuts == -1)
00128 {
00129 nTotalBeforeCuts = dqm->get(subDir_ + triggerBitsDir + "/L1Bits")->getBinContent(nL1bins);
00130 reference_bin = nHltbins;
00131 }
00132 }
00133 LogDebug("HltSusyExoPostProcessor") << "Total number of events = " << nTotalBeforeCuts;
00134
00135
00136 for(int i=0; i<nL1bins-1*mcFlag; i++) {
00137 value = (double) dqm->get(subDir_ + triggerBitsDir + "/L1Paths")->getBinContent(i+1) / (double) nTotalBeforeCuts;
00138 error = sqrt(value*(1-value)/(double)nTotalBeforeCuts);
00139 hL1EffBeforeCuts->setBinContent(i+1,value);
00140 hL1EffBeforeCuts->setBinEntries(i+1,1);
00141 hL1EffBeforeCuts->setBinError(i+1,error);
00142
00143
00144 string triggername = ((TProfile*)hL1EffBeforeCuts->getTProfile())->GetXaxis()->GetBinLabel(i+1);
00145 if( triggername.find(L1search6)==string::npos )
00146 {
00147 for(unsigned int j=0; j<sizeof(L1search)/sizeof(L1search[0])-2; ++j)
00148 {
00149 if( triggername.find(L1search[j])!=string::npos || (j==3 && triggername.find(L1search3)!=string::npos) )
00150 {
00151 if(L1placement[i]==6)
00152 L1placement[i]=j;
00153 else if(L1placement[i]==2 && j==4)
00154 L1placement[i]=4;
00155 else
00156 L1placement[i]=5;
00157 }
00158 else if(triggername.size()==0 || triggername.find("Total")!=string::npos)
00159 L1placement[i]=-1;
00160 }
00161 }
00162 }
00163
00164 for(unsigned int i=0; i<L1placement.size(); ++i)
00165 if(L1placement[i]!=-1)
00166 ++L1bins[L1placement[i]];
00167
00168 for(int i=0; i<nHltbins-1*mcFlag; i++) {
00169 value = (double)dqm->get(subDir_ + triggerBitsDir + "/HltPaths")->getBinContent(i+1) / (double)nTotalBeforeCuts;
00170 error = sqrt(value*(1-value)/(double)nTotalBeforeCuts);
00171 hHltEffBeforeCuts->setBinContent(i+1,value);
00172 hHltEffBeforeCuts->setBinEntries(i+1,1);
00173 hHltEffBeforeCuts->setBinError(i+1,error);
00174
00175
00176 string triggername = ((TProfile*)hHltEffBeforeCuts->getTProfile())->GetXaxis()->GetBinLabel(i+1);
00177 if( triggername.find(Hltsearch7_1)==string::npos && triggername.find(Hltsearch7_2)==string::npos )
00178 {
00179 for(unsigned int j=0; j<sizeof(Hltsearch)/sizeof(Hltsearch[0])-2; ++j)
00180 {
00181 if( triggername.find(Hltsearch[j])!=string::npos || (j==4 && triggername.find(Hltsearch4)!=string::npos) || (j==5 && triggername.find(Hltsearch5)!=string::npos) )
00182 {
00183 if(Hltplacement[i]==7)
00184 Hltplacement[i]=j;
00185 else if( triggername.find(Hltsearch5)!=string::npos )
00186 Hltplacement[i]=5;
00187 else
00188 Hltplacement[i]=6;
00189 }
00190 else if(triggername.size()==0 || triggername.find("Total")!=string::npos)
00191 Hltplacement[i]=-1;
00192 }
00193 if(Hltplacement[i]>=0 && Hltplacement[i]<=5 && (triggername.find(Hltsearch6_1)!=string::npos || (triggername.find(Hltsearch6_2)!=string::npos && Hltplacement[i]!=4) ))
00194 Hltplacement[i]=6;
00195 }
00196 }
00197
00198 for(unsigned int i=0; i<Hltplacement.size(); ++i)
00199 if(Hltplacement[i]!=-1)
00200 ++Hltbins[Hltplacement[i]];
00201
00202
00203
00204
00205 LogDebug("HltSusyExoPostProcessor") << "MonitorElements filled";
00206
00207
00208 dqm->setCurrentFolder(subDir_ + triggerBitsDir);
00209 MonitorElement* hL1EffSorted[7] = {dqm->bookProfile("L1_Mu", new TProfile("L1_Mu","Efficiencies of L1 Muon Triggers",L1bins[0],0,L1bins[0])),
00210 dqm->bookProfile("L1_EG", new TProfile("L1_EG","Efficiencies of L1 EG Triggers",L1bins[1],0,L1bins[1])),
00211 dqm->bookProfile("L1_Jet", new TProfile("L1_Jet","Efficiencies of L1 Jet Triggers",L1bins[2],0,L1bins[2])),
00212 dqm->bookProfile("L1_ETM_ETT_HTT", new TProfile("L1_ETM_ETT_HTT","Efficiencies of L1 ETM, ETT, and HTT Triggers",L1bins[3],0,L1bins[3])),
00213 dqm->bookProfile("L1_TauJet", new TProfile("L1_TauJet","Efficiencies of L1 TauJet Triggers",L1bins[4],0,L1bins[4])),
00214 dqm->bookProfile("L1_XTrigger", new TProfile("L1_XTrigger","Efficiencies of L1 Cross Triggers",L1bins[5],0,L1bins[5])),
00215 dqm->bookProfile("L1_Overflow", new TProfile("L1_Overflow","Efficiencies of L1 Unsorted Triggers",L1bins[6],0,L1bins[6])) };
00216
00217 MonitorElement* hHltEffSorted[8] = {dqm->bookProfile("Hlt_Mu", new TProfile("Hlt_Mu","Efficiencies of HL Muon Triggers",Hltbins[0],0,Hltbins[0])),
00218 dqm->bookProfile("Hlt_Ele", new TProfile("Hlt_Ele","Efficiencies of HL Electron Triggers",Hltbins[1],0,Hltbins[1])),
00219 dqm->bookProfile("Hlt_Jet", new TProfile("Hlt_Jet","Efficiencies of HL Jet Triggers",Hltbins[2],0,Hltbins[2],"s")),
00220 dqm->bookProfile("Hlt_Photon", new TProfile("Hlt_Photon","Efficiencies of HL Photon Triggers",Hltbins[3],0,Hltbins[3])),
00221 dqm->bookProfile("Hlt_MET_HT", new TProfile("Hlt_MET_HT","Efficiencies of HL MET and HT Triggers",Hltbins[4],0,Hltbins[4])),
00222 dqm->bookProfile("Hlt_Tau_BTag", new TProfile("Hlt_Tau_Btag","Efficiencies of HL Tau and BTag Triggers",Hltbins[5],0,Hltbins[5])),
00223 dqm->bookProfile("Hlt_XTrigger", new TProfile("Hlt_XTrigger","Efficiencies of HL Cross Triggers",Hltbins[6],0,Hltbins[6])),
00224 dqm->bookProfile("Hlt_Overflow", new TProfile("Hlt_Overflow","Efficiencies of HL Unsorted Triggers",Hltbins[7],0,Hltbins[7])) };
00225
00226 int L1bincounter[8]; for(unsigned int i=0; i<sizeof(L1bincounter)/sizeof(L1bincounter[0]); ++i) L1bincounter[i]=0;
00227 int Hltbincounter[8]; for(unsigned int i=0; i<sizeof(Hltbincounter)/sizeof(Hltbincounter[0]); ++i) Hltbincounter[i]=0;
00228 TProfile* hL1_ = (TProfile*)hL1EffBeforeCuts->getTProfile();
00229 TProfile* hHlt_ = (TProfile*)hHltEffBeforeCuts->getTProfile();
00230
00231 for(unsigned int i=0; i<L1placement.size(); ++i)
00232 {
00233 if(L1placement[i]!=-1)
00234 {
00235 hL1EffSorted[L1placement[i]]->setBinLabel(L1bincounter[L1placement[i]]+1, hL1_->GetXaxis()->GetBinLabel(i+1));
00236 hL1EffSorted[L1placement[i]]->setBinContent(L1bincounter[L1placement[i]]+1, hL1_->GetBinContent(i+1));
00237 hL1EffSorted[L1placement[i]]->setBinEntries(L1bincounter[L1placement[i]]+1, 1);
00238 hL1EffSorted[L1placement[i]]->setBinError(L1bincounter[L1placement[i]]+1, hL1_->GetBinError(i+1));
00239 ++L1bincounter[L1placement[i]];
00240 }
00241 }
00242 for(unsigned int i=0; i<Hltplacement.size(); ++i)
00243 {
00244 if(Hltplacement[i]!=-1)
00245 {
00246 hHltEffSorted[Hltplacement[i]]->setBinLabel(Hltbincounter[Hltplacement[i]]+1, hHlt_->GetXaxis()->GetBinLabel(i+1));
00247 hHltEffSorted[Hltplacement[i]]->setBinContent(Hltbincounter[Hltplacement[i]]+1, hHlt_->GetBinContent(i+1));
00248 hHltEffSorted[Hltplacement[i]]->setBinEntries(Hltbincounter[Hltplacement[i]]+1, 1);
00249 hHltEffSorted[Hltplacement[i]]->setBinError(Hltbincounter[Hltplacement[i]]+1, hHlt_->GetBinError(i+1));
00250 ++Hltbincounter[Hltplacement[i]];
00251 }
00252 }
00253
00254 for(unsigned int i=0; i<mc_dirs.size(); ++i)
00255 {
00256
00257 dqm->setCurrentFolder(subDir_ + mcSelBitsDir + "/" + mc_dirs[i]);
00258
00259 char set_name_L1[256], set_name_Hlt[256];
00260 sprintf(set_name_L1, "L1Eff_%s", mc_dirs[i].c_str());
00261 sprintf(set_name_Hlt, "HltEff_%s", mc_dirs[i].c_str());
00262
00263 MonitorElement* hL1EffAfterMcCuts = bookEffMEProfileFromTH1(dqm->get(subDir_ + mcSelBitsDir + "/" + mc_dirs[i] + "/L1Paths_" + mc_dirs[i])->getTH1F(), (std::string) set_name_L1);
00264 hL1EffAfterMcCuts->setTitle("L1 Efficiencies for " + mc_dirs[i] + " selection");
00265
00266 MonitorElement* hHltEffAfterMcCuts = bookEffMEProfileFromTH1(dqm->get(subDir_ + mcSelBitsDir + "/" + mc_dirs[i] + "/HltPaths_" + mc_dirs[i])->getTH1F(), (std::string) set_name_Hlt);
00267 hHltEffAfterMcCuts->setTitle("HLT Efficiencies for " + mc_dirs[i] + " selection");
00268
00269 LogDebug("HltSusyExoPostProcessor") << "MonitorElements for " << mc_dirs[i] << " selection booked";
00270
00271
00272
00273 float nTotalAfterMcCuts;
00274 if(mcFlag)
00275 nTotalAfterMcCuts = dqm->get(subDir_ + mcSelBitsDir + "/" + mc_dirs[i] + "/L1Bits_" + mc_dirs[i])->getBinContent(nL1bins);
00276 else
00277 nTotalAfterMcCuts = dqm->get(subDir_ + mcSelBitsDir + "/" + mc_dirs[i] + "/HltBits_" + mc_dirs[i])->getBinContent(reference_bin);
00278
00279 LogDebug("HltSusyExoPostProcessor") << "Total number of events = " << nTotalAfterMcCuts;
00280
00281 MonitorElement* hL1EffSorted_mc[7];
00282 MonitorElement* hHltEffSorted_mc[8];
00283 char buffer1[256], buffer2[256];
00284 string L1_nametags[7] = {"Mu","EG","Jet","ETM_ETT_HTT","TauJet","XTrigger","Overflow"};
00285 string L1_titletags[7] = {"Muon","EG","Jet","ETM, ETT, and HTT","TauJet","Cross","Unsorted"};
00286 string Hlt_nametags[8] = {"Mu","Ele","Jet","Photon","MET_HT","Tau_BTag","XTrigger","Overflow"};
00287 string Hlt_titletags[8] = {"Muon","Electron","Jet","Photon","MET and HT","Tau and BTag","Cross","Unsorted"};
00288 for(unsigned int j=0; j<sizeof(hL1EffSorted_mc)/sizeof(hL1EffSorted_mc[0]); ++j)
00289 {
00290 sprintf(buffer1,"L1_%s_%s",mc_dirs[i].c_str(),L1_nametags[j].c_str());
00291 sprintf(buffer2,"Efficiencies of L1 %s Triggers for %s Selection",L1_titletags[j].c_str(),mc_dirs[i].c_str());
00292 hL1EffSorted_mc[j] = dqm->bookProfile(buffer1, new TProfile(buffer1,buffer2,L1bins[j],0,L1bins[j]));
00293 }
00294 for(unsigned int j=0; j<sizeof(hHltEffSorted_mc)/sizeof(hHltEffSorted_mc[0]); ++j)
00295 {
00296 sprintf(buffer1,"Hlt_%s_%s",mc_dirs[i].c_str(),Hlt_nametags[j].c_str());
00297 sprintf(buffer2,"Efficiencies of HL %s Triggers for %s Selection",Hlt_titletags[j].c_str(),mc_dirs[i].c_str());
00298 hHltEffSorted_mc[j] = dqm->bookProfile(buffer1, new TProfile(buffer1,buffer2,Hltbins[j],0,Hltbins[j]));
00299 }
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318 int L1bincounter_mc[8]; for(unsigned int j=0; j<sizeof(L1bincounter_mc)/sizeof(L1bincounter_mc[0]); ++j) L1bincounter_mc[j]=0;
00319 int Hltbincounter_mc[8]; for(unsigned int j=0; j<sizeof(Hltbincounter_mc)/sizeof(Hltbincounter_mc[0]); ++j) Hltbincounter_mc[j]=0;
00320 TProfile* hL1_mc = (TProfile*)hL1EffAfterMcCuts->getTProfile();
00321 TProfile* hHlt_mc = (TProfile*)hHltEffAfterMcCuts->getTProfile();
00322 for(unsigned int j=0; j<L1placement.size(); j++) {
00323 value = nTotalAfterMcCuts ? (float)dqm->get(subDir_ + mcSelBitsDir + "/" + mc_dirs[i] + "/L1Paths_" + mc_dirs[i])->getBinContent(j+1) / nTotalAfterMcCuts : 0;
00324 error = nTotalAfterMcCuts ? sqrt(value*(1-value)/nTotalAfterMcCuts) : 0;
00325 hL1EffAfterMcCuts->setBinContent(j+1,value);
00326 hL1EffAfterMcCuts->setBinEntries(j+1,1);
00327 hL1EffAfterMcCuts->setBinError(j+1,error);
00328 if(L1placement[j]!=-1)
00329 {
00330 hL1EffSorted_mc[L1placement[j]]->setBinLabel(L1bincounter_mc[L1placement[j]]+1, hL1_mc->GetXaxis()->GetBinLabel(j+1));
00331 hL1EffSorted_mc[L1placement[j]]->setBinContent(L1bincounter_mc[L1placement[j]]+1, hL1_mc->GetBinContent(j+1));
00332 hL1EffSorted_mc[L1placement[j]]->setBinEntries(L1bincounter_mc[L1placement[j]]+1, 1);
00333 hL1EffSorted_mc[L1placement[j]]->setBinError(L1bincounter_mc[L1placement[j]]+1, hL1_mc->GetBinError(j+1));
00334 ++L1bincounter_mc[L1placement[j]];
00335 }
00336 }
00337 if(nL1bins!=int(L1placement.size()))
00338 {
00339 value = nTotalAfterMcCuts ? (float)dqm->get(subDir_ + mcSelBitsDir + "/" + mc_dirs[i] + "/L1Paths_" + mc_dirs[i])->getBinContent(nL1bins) / nTotalAfterMcCuts : 0;
00340 error = nTotalAfterMcCuts ? sqrt(value*(1-value)/nTotalAfterMcCuts) : 0;
00341 hL1EffAfterMcCuts->setBinContent(nL1bins,value);
00342 hL1EffAfterMcCuts->setBinEntries(nL1bins,1);
00343 hL1EffAfterMcCuts->setBinError(nL1bins,error);
00344 }
00345 for(unsigned int j=0; j<Hltplacement.size(); j++) {
00346 value = nTotalAfterMcCuts ? (float)dqm->get(subDir_ + mcSelBitsDir + "/" + mc_dirs[i] + "/HltPaths_" + mc_dirs[i])->getBinContent(j+1) / nTotalAfterMcCuts : 0;
00347 error = nTotalAfterMcCuts ? sqrt(value*(1-value)/nTotalAfterMcCuts) : 0;
00348 hHltEffAfterMcCuts->setBinContent(j+1,value);
00349 hHltEffAfterMcCuts->setBinEntries(j+1,1);
00350 hHltEffAfterMcCuts->setBinError(j+1,error);
00351 if(Hltplacement[j]!=-1)
00352 {
00353 hHltEffSorted_mc[Hltplacement[j]]->setBinLabel(Hltbincounter_mc[Hltplacement[j]]+1, hHlt_mc->GetXaxis()->GetBinLabel(j+1));
00354 hHltEffSorted_mc[Hltplacement[j]]->setBinContent(Hltbincounter_mc[Hltplacement[j]]+1, hHlt_mc->GetBinContent(j+1));
00355 hHltEffSorted_mc[Hltplacement[j]]->setBinEntries(Hltbincounter_mc[Hltplacement[j]]+1, 1);
00356 hHltEffSorted_mc[Hltplacement[j]]->setBinError(Hltbincounter_mc[Hltplacement[j]]+1, hHlt_mc->GetBinError(j+1));
00357 ++Hltbincounter_mc[Hltplacement[j]];
00358 }
00359 }
00360 if(nHltbins!=int(Hltplacement.size()))
00361 {
00362 value = nTotalAfterMcCuts ? (float)dqm->get(subDir_ + mcSelBitsDir + "/" + mc_dirs[i] + "/HltPaths_" + mc_dirs[i])->getBinContent(nHltbins) / nTotalAfterMcCuts : 0;
00363 error = nTotalAfterMcCuts ? sqrt(value*(1-value)/nTotalAfterMcCuts) : 0;
00364 hHltEffAfterMcCuts->setBinContent(nHltbins,value);
00365 hHltEffAfterMcCuts->setBinEntries(nHltbins,1);
00366 hHltEffAfterMcCuts->setBinError(nHltbins,error);
00367 }
00368 LogDebug("HltSusyExoPostProcessor") << "MonitorElements filled for " << mc_dirs[i] <<" selection";
00369 }
00370
00371 for(unsigned int i=0; i<reco_dirs.size(); ++i)
00372 {
00373
00374 dqm->setCurrentFolder(subDir_ + recoSelBitsDir + "/" + reco_dirs[i]);
00375
00376 char set_name_L1[256], set_name_Hlt[256];
00377 sprintf(set_name_L1, "L1Eff_%s", reco_dirs[i].c_str());
00378 sprintf(set_name_Hlt, "HltEff_%s", reco_dirs[i].c_str());
00379
00380 MonitorElement* hL1EffAfterRecoCuts = bookEffMEProfileFromTH1(dqm->get(subDir_ + recoSelBitsDir + "/" + reco_dirs[i] + "/L1Paths_" + reco_dirs[i])->getTH1F(), (std::string) set_name_L1);
00381 hL1EffAfterRecoCuts->setTitle("L1 Efficiencies for " + reco_dirs[i] + " selection");
00382
00383 MonitorElement* hHltEffAfterRecoCuts = bookEffMEProfileFromTH1(dqm->get(subDir_ + recoSelBitsDir + "/" + reco_dirs[i] + "/HltPaths_" + reco_dirs[i])->getTH1F(), (std::string) set_name_Hlt);
00384 hHltEffAfterRecoCuts->setTitle("HLT Efficiencies for " + reco_dirs[i] + " selection");
00385
00386 LogDebug("HltSusyExoPostProcessor") << "MonitorElements for " << reco_dirs[i] << " selection booked";
00387
00388
00389 float nTotalAfterRecoCuts;
00390 if(mcFlag)
00391 nTotalAfterRecoCuts = dqm->get(subDir_ + recoSelBitsDir + "/" + reco_dirs[i] + "/L1Bits_" + reco_dirs[i])->getBinContent(nL1bins);
00392 else
00393 nTotalAfterRecoCuts = dqm->get(subDir_ + recoSelBitsDir + "/" + reco_dirs[i] + "/HltBits_" + reco_dirs[i])->getBinContent(reference_bin);
00394
00395 LogDebug("HltSusyExoPostProcessor") << "Total number of events = " << nTotalAfterRecoCuts;
00396
00397 MonitorElement* hL1EffSorted_reco[7];
00398 MonitorElement* hHltEffSorted_reco[8];
00399 char buffer1[256], buffer2[256];
00400 string L1_nametags[7] = {"Mu","EG","Jet","ETM_ETT_HTT","TauJet","XTrigger","Overflow"};
00401 string L1_titletags[7] = {"Muon","EG","Jet","ETM, ETT, and HTT","TauJet","Cross","Unsorted"};
00402 string Hlt_nametags[8] = {"Mu","Ele","Jet","Photon","MET_HT","Tau_BTag","XTrigger","Overflow"};
00403 string Hlt_titletags[8] = {"Muon","Electron","Jet","Photon","MET and HT","Tau and BTag","Cross","Unsorted"};
00404 for(unsigned int j=0; j<sizeof(hL1EffSorted_reco)/sizeof(hL1EffSorted_reco[0]); ++j)
00405 {
00406 sprintf(buffer1,"L1_%s_%s",reco_dirs[i].c_str(),L1_nametags[j].c_str());
00407 sprintf(buffer2,"Efficiencies of L1 %s Triggers for %s Selection",L1_titletags[j].c_str(),reco_dirs[i].c_str());
00408 hL1EffSorted_reco[j] = dqm->bookProfile(buffer1, new TProfile(buffer1,buffer2,L1bins[j],0,L1bins[j]));
00409 }
00410 for(unsigned int j=0; j<sizeof(hHltEffSorted_reco)/sizeof(hHltEffSorted_reco[0]); ++j)
00411 {
00412 sprintf(buffer1,"Hlt_%s_%s",reco_dirs[i].c_str(),Hlt_nametags[j].c_str());
00413 sprintf(buffer2,"Efficiencies of HL %s Triggers for %s Selection",Hlt_titletags[j].c_str(),reco_dirs[i].c_str());
00414 hHltEffSorted_reco[j] = dqm->bookProfile(buffer1, new TProfile(buffer1,buffer2,Hltbins[j],0,Hltbins[j]));
00415 }
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435 int L1bincounter_reco[8]; for(unsigned int j=0; j<sizeof(L1bincounter_reco)/sizeof(L1bincounter_reco[0]); ++j) L1bincounter_reco[j]=0;
00436 int Hltbincounter_reco[8]; for(unsigned int j=0; j<sizeof(Hltbincounter_reco)/sizeof(Hltbincounter_reco[0]); ++j) Hltbincounter_reco[j]=0;
00437 TProfile* hL1_reco = (TProfile*)hL1EffAfterRecoCuts->getTProfile();
00438 TProfile* hHlt_reco = (TProfile*)hHltEffAfterRecoCuts->getTProfile();
00439 for(unsigned int j=0; j<L1placement.size(); j++) {
00440 value = nTotalAfterRecoCuts ? (float)dqm->get(subDir_ + recoSelBitsDir + "/" + reco_dirs[i] + "/L1Paths_" + reco_dirs[i])->getBinContent(j+1) / nTotalAfterRecoCuts : 0;
00441 error = nTotalAfterRecoCuts ? sqrt(value*(1-value)/nTotalAfterRecoCuts) : 0;
00442 hL1EffAfterRecoCuts->setBinContent(j+1,value);
00443 hL1EffAfterRecoCuts->setBinEntries(j+1,1);
00444 hL1EffAfterRecoCuts->setBinError(j+1,error);
00445 if(L1placement[j]!=-1)
00446 {
00447 hL1EffSorted_reco[L1placement[j]]->setBinLabel(L1bincounter_reco[L1placement[j]]+1, hL1_reco->GetXaxis()->GetBinLabel(j+1));
00448 hL1EffSorted_reco[L1placement[j]]->setBinContent(L1bincounter_reco[L1placement[j]]+1, hL1_reco->GetBinContent(j+1));
00449 hL1EffSorted_reco[L1placement[j]]->setBinEntries(L1bincounter_reco[L1placement[j]]+1, 1);
00450 hL1EffSorted_reco[L1placement[j]]->setBinError(L1bincounter_reco[L1placement[j]]+1, hL1_reco->GetBinError(j+1));
00451 ++L1bincounter_reco[L1placement[j]];
00452 }
00453 }
00454 if(nL1bins!=int(L1placement.size()))
00455 {
00456 value = nTotalAfterRecoCuts ? (float)dqm->get(subDir_ + recoSelBitsDir + "/" + reco_dirs[i] + "/L1Paths_" + reco_dirs[i])->getBinContent(nL1bins) / nTotalAfterRecoCuts : 0;
00457 error = nTotalAfterRecoCuts ? sqrt(value*(1-value)/nTotalAfterRecoCuts) : 0;
00458 hL1EffAfterRecoCuts->setBinContent(nL1bins,value);
00459 hL1EffAfterRecoCuts->setBinEntries(nL1bins,1);
00460 hL1EffAfterRecoCuts->setBinError(nL1bins,error);
00461 }
00462 for(unsigned int j=0; j<Hltplacement.size(); j++) {
00463 value = nTotalAfterRecoCuts ? (float)dqm->get(subDir_ + recoSelBitsDir + "/" + reco_dirs[i] + "/HltPaths_" + reco_dirs[i])->getBinContent(j+1) / nTotalAfterRecoCuts : 0;
00464 error = nTotalAfterRecoCuts ? sqrt(value*(1-value)/nTotalAfterRecoCuts) : 0;
00465 hHltEffAfterRecoCuts->setBinContent(j+1,value);
00466 hHltEffAfterRecoCuts->setBinEntries(j+1,1);
00467 hHltEffAfterRecoCuts->setBinError(j+1,error);
00468 if(Hltplacement[j]!=-1)
00469 {
00470 hHltEffSorted_reco[Hltplacement[j]]->setBinLabel(Hltbincounter_reco[Hltplacement[j]]+1, hHlt_reco->GetXaxis()->GetBinLabel(j+1));
00471 hHltEffSorted_reco[Hltplacement[j]]->setBinContent(Hltbincounter_reco[Hltplacement[j]]+1, hHlt_reco->GetBinContent(j+1));
00472 hHltEffSorted_reco[Hltplacement[j]]->setBinEntries(Hltbincounter_reco[Hltplacement[j]]+1, 1);
00473 hHltEffSorted_reco[Hltplacement[j]]->setBinError(Hltbincounter_reco[Hltplacement[j]]+1, hHlt_reco->GetBinError(j+1));
00474 ++Hltbincounter_reco[Hltplacement[j]];
00475 }
00476 }
00477 if(nHltbins!=int(Hltplacement.size()))
00478 {
00479 value = nTotalAfterRecoCuts ? (float)dqm->get(subDir_ + recoSelBitsDir + "/" + reco_dirs[i] + "/HltPaths_" + reco_dirs[i])->getBinContent(nHltbins) / nTotalAfterRecoCuts : 0;
00480 error = nTotalAfterRecoCuts ? sqrt(value*(1-value)/nTotalAfterRecoCuts) : 0;
00481 hHltEffAfterRecoCuts->setBinContent(nHltbins,value);
00482 hHltEffAfterRecoCuts->setBinEntries(nHltbins,1);
00483 hHltEffAfterRecoCuts->setBinError(nHltbins,error);
00484 }
00485 LogDebug("HltSusyExoPostProcessor") << "MonitorElements filled";
00486 }
00487
00488 int pt_bins=100, eta_bins=100;
00489 double pt_floor=0., pt_ceiling = 200., eta_floor=-3.5, eta_ceiling=3.5;
00490 dqm->setCurrentFolder(subDir_ + byEventDir);
00491 MonitorElement* hPt_1_ByEvent = dqm->book1D("Pt_1_ByEvent","Turn on as a Function of P_{t}, |Eta|<1.2, By Event",pt_bins, pt_floor, pt_ceiling);
00492 MonitorElement* hEta_1_ByEvent= dqm->book1D("Eta_1_ByEvent","Efficiency as a Function of Eta, P_{t}>0, By Event", eta_bins, eta_floor,eta_ceiling);
00493 MonitorElement* hPt_2_ByEvent = dqm->book1D("Pt_2_ByEvent","Turn on as a Function of P_{t}, 1.2<|Eta|<2.1, By Event",pt_bins, pt_floor, pt_ceiling);
00494 MonitorElement* hEta_2_ByEvent= dqm->book1D("Eta_2_ByEvent","Efficiency as a Function of Eta, P_{t}>10, By Event", eta_bins, eta_floor,eta_ceiling);
00495 MonitorElement* hPt_3_ByEvent = dqm->book1D("Pt_3_ByEvent","Turn on as a Function of P_{t}, |Eta|>2.1, By Event",pt_bins, pt_floor, pt_ceiling);
00496 MonitorElement* hEta_3_ByEvent= dqm->book1D("Eta_3_ByEvent","Efficiency as a Function of Eta, P_{t}>20, By Event", eta_bins, eta_floor,eta_ceiling);
00497 dqm->setCurrentFolder(subDir_ + byMuonDir);
00498 MonitorElement* hPt_1_ByMuon = dqm->book1D("Pt_1_ByMuon","Turn on as a Function of P_{t}, |Eta|<1.2, By Muon",pt_bins, pt_floor, pt_ceiling);
00499 MonitorElement* hEta_1_ByMuon= dqm->book1D("Eta_1_ByMuon","Efficiency as a Function of Eta, P_{t}>0, By Muon", eta_bins, eta_floor,eta_ceiling);
00500 MonitorElement* hPt_2_ByMuon = dqm->book1D("Pt_2_ByMuon","Turn on as a Function of P_{t}, 1.2<|Eta|<2.1, By Muon",pt_bins, pt_floor, pt_ceiling);
00501 MonitorElement* hEta_2_ByMuon= dqm->book1D("Eta_2_ByMuon","Efficiency as a Function of Eta, P_{t}>10, By Muon", eta_bins, eta_floor,eta_ceiling);
00502 MonitorElement* hPt_3_ByMuon = dqm->book1D("Pt_3_ByMuon","Turn on as a Function of P_{t}, |Eta|>2.1, By Muon",pt_bins, pt_floor, pt_ceiling);
00503 MonitorElement* hEta_3_ByMuon= dqm->book1D("Eta_3_ByMuon","Efficiency as a Function of Eta, P_{t}>20, By Muon", eta_bins, eta_floor,eta_ceiling);
00504
00505 for(int i=1; i<=hPt_1_ByEvent->getNbinsX(); ++i)
00506 {
00507 double n1 = (double)dqm->get(subDir_ + byEventDir + "/LeadAssocRecoMuonPt_1_ByEvent")->getBinContent(i);
00508 double n2 = (double)dqm->get(subDir_ + byEventDir + "/LeadRecoMuonPt_1_ByEvent")->getBinContent(i);
00509 double value = (n2!=0 ? n1/n2 : 0);
00510 double error = (n2!=0 ? sqrt(value*(1-value)/n2) : 0);
00511 hPt_1_ByEvent->setBinContent(i,value);
00512 hPt_1_ByEvent->setBinError(i,error);
00513
00514 n1 = (double)dqm->get(subDir_ + byEventDir + "/LeadAssocRecoMuonPt_2_ByEvent")->getBinContent(i);
00515 n2 = (double)dqm->get(subDir_ + byEventDir + "/LeadRecoMuonPt_2_ByEvent")->getBinContent(i);
00516 value = (n2!=0 ? n1/n2 : 0);
00517 error = (n2!=0 ? sqrt(value*(1-value)/n2) : 0);
00518 hPt_2_ByEvent->setBinContent(i,value);
00519 hPt_2_ByEvent->setBinError(i,error);
00520
00521 n1 = (double)dqm->get(subDir_ + byEventDir + "/LeadAssocRecoMuonPt_3_ByEvent")->getBinContent(i);
00522 n2 = (double)dqm->get(subDir_ + byEventDir + "/LeadRecoMuonPt_3_ByEvent")->getBinContent(i);
00523 value = (n2!=0 ? n1/n2 : 0);
00524 error = (n2!=0 ? sqrt(value*(1-value)/n2) : 0);
00525 hPt_3_ByEvent->setBinContent(i,value);
00526 hPt_3_ByEvent->setBinError(i,error);
00527
00528 n1 = (double)dqm->get(subDir_ + byMuonDir + "/AssocRecoMuonPt_1_ByMuon")->getBinContent(i);
00529 n2 = (double)dqm->get(subDir_ + byMuonDir + "/RecoMuonPt_1_ByMuon")->getBinContent(i);
00530 value = (n2!=0 ? n1/n2 : 0);
00531 error = (n2!=0 ? sqrt(value*(1-value)/n2) : 0);
00532 hPt_1_ByMuon->setBinContent(i,value);
00533 hPt_1_ByMuon->setBinError(i,error);
00534
00535 n1 = (double)dqm->get(subDir_ + byMuonDir + "/AssocRecoMuonPt_2_ByMuon")->getBinContent(i);
00536 n2 = (double)dqm->get(subDir_ + byMuonDir + "/RecoMuonPt_2_ByMuon")->getBinContent(i);
00537 value = (n2!=0 ? n1/n2 : 0);
00538 error = (n2!=0 ? sqrt(value*(1-value)/n2) : 0);
00539 hPt_2_ByMuon->setBinContent(i,value);
00540 hPt_2_ByMuon->setBinError(i,error);
00541
00542 n1 = (double)dqm->get(subDir_ + byMuonDir + "/AssocRecoMuonPt_3_ByMuon")->getBinContent(i);
00543 n2 = (double)dqm->get(subDir_ + byMuonDir + "/RecoMuonPt_3_ByMuon")->getBinContent(i);
00544 value = (n2!=0 ? n1/n2 : 0);
00545 error = (n2!=0 ? sqrt(value*(1-value)/n2) : 0);
00546 hPt_3_ByMuon->setBinContent(i,value);
00547 hPt_3_ByMuon->setBinError(i,error);
00548 }
00549
00550 for(int i=1; i<=hEta_1_ByEvent->getNbinsX(); ++i)
00551 {
00552 double n1 = (double)dqm->get(subDir_ + byEventDir + "/LeadAssocRecoMuonEta_1_ByEvent")->getBinContent(i);
00553 double n2 = (double)dqm->get(subDir_ + byEventDir + "/LeadRecoMuonEta_1_ByEvent")->getBinContent(i);
00554 double value = (n2!=0 ? n1/n2 : 0);
00555 double error = (n2!=0 ? sqrt(value*(1-value)/n2) : 0);
00556 hEta_1_ByEvent->setBinContent(i,value);
00557 hEta_1_ByEvent->setBinError(i,error);
00558
00559 n1 = (double)dqm->get(subDir_ + byEventDir + "/LeadAssocRecoMuonEta_2_ByEvent")->getBinContent(i);
00560 n2 = (double)dqm->get(subDir_ + byEventDir + "/LeadRecoMuonEta_2_ByEvent")->getBinContent(i);
00561 value = (n2!=0 ? n1/n2 : 0);
00562 error = (n2!=0 ? sqrt(value*(1-value)/n2) : 0);
00563 hEta_2_ByEvent->setBinContent(i,value);
00564 hEta_2_ByEvent->setBinError(i,error);
00565
00566 n1 = (double)dqm->get(subDir_ + byEventDir + "/LeadAssocRecoMuonEta_3_ByEvent")->getBinContent(i);
00567 n2 = (double)dqm->get(subDir_ + byEventDir + "/LeadRecoMuonEta_3_ByEvent")->getBinContent(i);
00568 value = (n2!=0 ? n1/n2 : 0);
00569 error = (n2!=0 ? sqrt(value*(1-value)/n2) : 0);
00570 hEta_3_ByEvent->setBinContent(i,value);
00571 hEta_3_ByEvent->setBinError(i,error);
00572
00573 n1 = (double)dqm->get(subDir_ + byMuonDir + "/AssocRecoMuonEta_1_ByMuon")->getBinContent(i);
00574 n2 = (double)dqm->get(subDir_ + byMuonDir + "/RecoMuonEta_1_ByMuon")->getBinContent(i);
00575 value = (n2!=0 ? n1/n2 : 0);
00576 error = (n2!=0 ? sqrt(value*(1-value)/n2) : 0);
00577 hEta_1_ByMuon->setBinContent(i,value);
00578 hEta_1_ByMuon->setBinError(i,error);
00579
00580 n1 = (double)dqm->get(subDir_ + byMuonDir + "/AssocRecoMuonEta_2_ByMuon")->getBinContent(i);
00581 n2 = (double)dqm->get(subDir_ + byMuonDir + "/RecoMuonEta_2_ByMuon")->getBinContent(i);
00582 value = (n2!=0 ? n1/n2 : 0);
00583 error = (n2!=0 ? sqrt(value*(1-value)/n2) : 0);
00584 hEta_2_ByMuon->setBinContent(i,value);
00585 hEta_2_ByMuon->setBinError(i,error);
00586
00587 n1 = (double)dqm->get(subDir_ + byMuonDir + "/AssocRecoMuonEta_3_ByMuon")->getBinContent(i);
00588 n2 = (double)dqm->get(subDir_ + byMuonDir + "/RecoMuonEta_3_ByMuon")->getBinContent(i);
00589 value = (n2!=0 ? n1/n2 : 0);
00590 error = (n2!=0 ? sqrt(value*(1-value)/n2) : 0);
00591 hEta_3_ByMuon->setBinContent(i,value);
00592 hEta_3_ByMuon->setBinError(i,error);
00593 }
00594 }
00595
00596
00597
00598
00599 MonitorElement* HltSusyExoPostProcessor::bookEffMEProfileFromTH1(TH1F* histo, std::string name) {
00600 MonitorElement* myEffME;
00601 if(name == "Eff") {
00602
00603 myEffME = dqm->bookProfile((std::string) ("Eff_"+((std::string) histo->GetName())), ((std::string) histo->GetTitle()), histo->GetXaxis()->GetNbins(), histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax(), 100, 0, 1, "");
00604 }
00605 else {
00606 myEffME = dqm->bookProfile(name, new TProfile(name.c_str(), histo->GetTitle(), histo->GetXaxis()->GetNbins(), histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax()));
00607 }
00608 for(int i=0; i<histo->GetXaxis()->GetNbins(); i++) {
00609 myEffME->setBinLabel(i+1, histo->GetXaxis()->GetBinLabel(i+1),1);
00610 }
00611 return myEffME;
00612 }
00613
00614
00615
00616
00617 DEFINE_FWK_MODULE(HltSusyExoPostProcessor);
00618
00619
00620