00001 #include "DQMOffline/Trigger/interface/EgHLTOfflineClient.h"
00002
00003
00004 #include "FWCore/Framework/interface/Run.h"
00005 #include "FWCore/Framework/interface/Event.h"
00006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00007 #include "FWCore/ServiceRegistry/interface/Service.h"
00008
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010
00011 #include "DQMServices/Core/interface/DQMStore.h"
00012 #include "DQMServices/Core/interface/MonitorElement.h"
00013
00014 #include "DQMOffline/Trigger/interface/EgHLTTrigTools.h"
00015
00016 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
00017
00018 #include <boost/algorithm/string.hpp>
00019
00020 #include "TGraphAsymmErrors.h"
00021
00022 EgHLTOfflineClient::EgHLTOfflineClient(const edm::ParameterSet& iConfig):dbe_(NULL),isSetup_(false)
00023 {
00024 dbe_ = edm::Service<DQMStore>().operator->();
00025 if (!dbe_) {
00026 edm::LogError("EgHLTOfflineClient") << "unable to get DQMStore service, upshot is no client histograms will be made";
00027 }
00028 if(iConfig.getUntrackedParameter<bool>("DQMStore", false)) {
00029 if(dbe_) dbe_->setVerbose(0);
00030 }
00031
00032
00033 eleHLTFilterNames_ = iConfig.getParameter<std::vector<std::string> >("eleHLTFilterNames");
00034 eleHLTFilterNames2Leg_ = iConfig.getParameter<std::vector<std::string> >("eleHLTFilterNames2Leg");
00035 eleTightLooseTrigNames_ = iConfig.getParameter<std::vector<std::string> >("eleTightLooseTrigNames");
00036 phoHLTFilterNames_ = iConfig.getParameter<std::vector<std::string> >("phoHLTFilterNames");
00037 phoHLTFilterNames2Leg_ = iConfig.getParameter<std::vector<std::string> >("phoHLTFilterNames2Leg");
00038 phoTightLooseTrigNames_ = iConfig.getParameter<std::vector<std::string> >("phoTightLooseTrigNames");
00039
00040 eleN1EffVars_=iConfig.getParameter<std::vector<std::string> >("eleN1EffVars");
00041 eleSingleEffVars_ = iConfig.getParameter<std::vector<std::string> >("eleSingleEffVars");
00042 eleEffTags_ = iConfig.getParameter<std::vector<std::string> >("eleEffTags");
00043 eleTrigTPEffVsVars_ = iConfig.getParameter<std::vector<std::string> >("eleTrigTPEffVsVars");
00044 eleLooseTightTrigEffVsVars_ = iConfig.getParameter<std::vector<std::string> >("eleLooseTightTrigEffVsVars");
00045 eleHLTvOfflineVars_ = iConfig.getParameter<std::vector<std::string> >("eleHLTvOfflineVars");
00046
00047 phoN1EffVars_=iConfig.getParameter<std::vector<std::string> >("phoN1EffVars");
00048 phoSingleEffVars_ = iConfig.getParameter<std::vector<std::string> >("phoSingleEffVars");
00049 phoEffTags_ = iConfig.getParameter<std::vector<std::string> >("phoEffTags");
00050 phoTrigTPEffVsVars_ = iConfig.getParameter<std::vector<std::string> >("phoTrigTPEffVsVars");
00051 phoLooseTightTrigEffVsVars_ = iConfig.getParameter<std::vector<std::string> >("phoLooseTightTrigEffVsVars");
00052 phoHLTvOfflineVars_ = iConfig.getParameter<std::vector<std::string> >("phoHLTvOfflineVars");
00053
00054 runClientEndLumiBlock_ = iConfig.getParameter<bool>("runClientEndLumiBlock");
00055 runClientEndRun_ = iConfig.getParameter<bool>("runClientEndRun");
00056 runClientEndJob_ = iConfig.getParameter<bool>("runClientEndJob");
00057
00058
00059
00060 dirName_=iConfig.getParameter<std::string>("DQMDirName");
00061 if(dbe_) dbe_->setCurrentFolder(dirName_);
00062
00063
00064 filterInactiveTriggers_ =iConfig.getParameter<bool>("filterInactiveTriggers");
00065 hltTag_ = iConfig.getParameter<std::string>("hltTag");
00066
00067
00068 }
00069
00070
00071 EgHLTOfflineClient::~EgHLTOfflineClient()
00072 {
00073
00074 }
00075
00076 void EgHLTOfflineClient::beginJob()
00077 {
00078
00079
00080 }
00081
00082 void EgHLTOfflineClient::endJob()
00083 {
00084 if(runClientEndJob_) runClient_();
00085 }
00086
00087 void EgHLTOfflineClient::beginRun(const edm::Run& run, const edm::EventSetup& c)
00088 {
00089 if(!isSetup_){
00090 if(filterInactiveTriggers_){
00091 HLTConfigProvider hltConfig;
00092 bool changed=false;
00093 hltConfig.init(run,c,hltTag_,changed);
00094 std::vector<std::string> activeFilters;
00095 std::vector<std::string> activeEleFilters;
00096 std::vector<std::string> activeEle2LegFilters;
00097 std::vector<std::string> activePhoFilters;
00098 std::vector<std::string> activePho2LegFilters;
00099 egHLT::trigTools::getActiveFilters(hltConfig,activeFilters,activeEleFilters,activeEle2LegFilters,activePhoFilters,activePho2LegFilters);
00100
00101 egHLT::trigTools::filterInactiveTriggers(eleHLTFilterNames_,activeEleFilters);
00102 egHLT::trigTools::filterInactiveTriggers(eleHLTFilterNames2Leg_,activeEle2LegFilters);
00103 egHLT::trigTools::filterInactiveTriggers(phoHLTFilterNames_,activePhoFilters);
00104 egHLT::trigTools::filterInactiveTightLooseTriggers(eleTightLooseTrigNames_,activeEleFilters);
00105 egHLT::trigTools::filterInactiveTightLooseTriggers(phoTightLooseTrigNames_,activePhoFilters);
00106 }
00107 isSetup_=true;
00108 }
00109 }
00110
00111
00112 void EgHLTOfflineClient::endRun(const edm::Run& run, const edm::EventSetup& c)
00113 {
00114 if(runClientEndRun_) runClient_();
00115 }
00116
00117
00118 void EgHLTOfflineClient::analyze(const edm::Event& iEvent,const edm::EventSetup& iSetup)
00119 {
00120
00121 }
00122
00123 void EgHLTOfflineClient::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,const edm::EventSetup& c)
00124 {
00125 if(runClientEndLumiBlock_) runClient_();
00126 }
00127
00128 void EgHLTOfflineClient::runClient_()
00129 {
00130 if(!dbe_) return;
00131 dbe_->setCurrentFolder(dirName_+"/Client_Histos");
00132
00133
00134 std::vector<std::string> regions;
00135 regions.push_back("eb");
00136 regions.push_back("ee");
00137
00138 for(size_t filterNr=0;filterNr<eleHLTFilterNames_.size();filterNr++){
00139
00140 for(size_t regionNr=0;regionNr<regions.size();regionNr++){
00141 for(size_t effNr=0;effNr<eleEffTags_.size();effNr++){
00142
00143 dbe_->setCurrentFolder(dirName_+"/Client_Histos/"+eleHLTFilterNames_[filterNr]);
00144
00145 createN1EffHists(eleHLTFilterNames_[filterNr],eleHLTFilterNames_[filterNr]+"_gsfEle_"+eleEffTags_[effNr],regions[regionNr],eleN1EffVars_);
00146 createSingleEffHists(eleHLTFilterNames_[filterNr],eleHLTFilterNames_[filterNr]+"_gsfEle_"+eleEffTags_[effNr],regions[regionNr],eleSingleEffVars_);
00147 createTrigTagProbeEffHistsNewAlgo(eleHLTFilterNames_[filterNr],regions[regionNr],eleTrigTPEffVsVars_,"gsfEle");
00148 createHLTvsOfflineHists(eleHLTFilterNames_[filterNr],eleHLTFilterNames_[filterNr]+"_gsfEle_passFilter",regions[regionNr],eleHLTvOfflineVars_);
00149 }
00150 }
00151 }
00152 for(size_t filterNr=0;filterNr<eleHLTFilterNames2Leg_.size();filterNr++){
00153
00154 for(size_t regionNr=0;regionNr<regions.size();regionNr++){
00155 for(size_t effNr=0;effNr<eleEffTags_.size();effNr++){
00156 std::string trigNameLeg1 = eleHLTFilterNames2Leg_[filterNr].substr(0,eleHLTFilterNames2Leg_[filterNr].find("::"));
00157 std::string trigNameLeg2 = eleHLTFilterNames2Leg_[filterNr].substr(eleHLTFilterNames2Leg_[filterNr].find("::")+2);
00158 dbe_->setCurrentFolder(dirName_+"/Client_Histos/"+trigNameLeg2);
00159 createTrigTagProbeEffHists2Leg(trigNameLeg1,trigNameLeg2,regions[regionNr],eleTrigTPEffVsVars_,"gsfEle");
00160 }
00161 }
00162 }
00163
00164
00165
00166
00167 for(size_t filterNr=0;filterNr<phoHLTFilterNames_.size();filterNr++){
00168 for(size_t regionNr=0;regionNr<regions.size();regionNr++){
00169 for(size_t effNr=0;effNr<phoEffTags_.size();effNr++){
00170
00171 dbe_->setCurrentFolder(dirName_+"/Client_Histos/"+phoHLTFilterNames_[filterNr]);
00172
00173
00174 createN1EffHists(phoHLTFilterNames_[filterNr],phoHLTFilterNames_[filterNr]+"_pho_"+phoEffTags_[effNr],regions[regionNr],phoN1EffVars_);
00175 createSingleEffHists(phoHLTFilterNames_[filterNr],phoHLTFilterNames_[filterNr]+"_pho_"+phoEffTags_[effNr],regions[regionNr],phoSingleEffVars_);
00176 createTrigTagProbeEffHistsNewAlgo(phoHLTFilterNames_[filterNr],regions[regionNr],phoTrigTPEffVsVars_,"pho");
00177 createHLTvsOfflineHists(phoHLTFilterNames_[filterNr],phoHLTFilterNames_[filterNr]+"_pho_passFilter",regions[regionNr],phoHLTvOfflineVars_);
00178
00179
00180 }
00181 }
00182 }
00183
00184
00185
00186 for(size_t regionNr=0;regionNr<regions.size();regionNr++){
00187 createLooseTightTrigEff(eleTightLooseTrigNames_,regions[regionNr],eleLooseTightTrigEffVsVars_,"gsfEle");
00188 createLooseTightTrigEff(eleTightLooseTrigNames_,regions[regionNr],eleLooseTightTrigEffVsVars_,"gsfEle_trigCuts");
00189 createLooseTightTrigEff(phoTightLooseTrigNames_,regions[regionNr],phoLooseTightTrigEffVsVars_,"pho");
00190 createLooseTightTrigEff(phoTightLooseTrigNames_,regions[regionNr],phoLooseTightTrigEffVsVars_,"pho_trigCuts");
00191 }
00192
00193 dbe_->setCurrentFolder(dirName_);
00194
00195 }
00196
00197 void EgHLTOfflineClient::createHLTvsOfflineHists(const std::string& filterName,const std::string& baseName,const std::string& region,const std::vector<std::string>& varNames){
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214 for(size_t varNr=0;varNr<varNames.size();varNr++){
00215 MonitorElement* numer = dbe_->get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_HLT"+varNames[varNr]+"_"+region);
00216 MonitorElement* denom = dbe_->get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_"+varNames[varNr]+"_"+region);
00217 if(numer!=NULL && denom!=NULL){
00218 std::string effHistName(baseName+"_HLToverOffline_"+varNames[varNr]+"_"+region);
00219 std::string effHistTitle(effHistName);
00220 if(region=="eb" || region=="ee"){
00221 if(region=="eb") effHistTitle = "Barrel "+baseName+" HLToverOffline "+varNames[varNr];
00222 if(region=="ee") effHistTitle = "Endcap "+baseName+" HLToverOffline "+varNames[varNr];
00223 FillHLTvsOfflineHist(filterName,effHistName,effHistTitle,numer,denom);
00224 }
00225 }
00226 }
00227 }
00228 MonitorElement* EgHLTOfflineClient::FillHLTvsOfflineHist(const std::string& filter,const std::string& name,const std::string& title,const MonitorElement* numer,const MonitorElement* denom){
00229 TH1F* num = numer->getTH1F();if(num->GetSumw2N()==0) num->Sumw2();
00230 TH1F* den = denom->getTH1F();if(den->GetSumw2N()==0) den->Sumw2();
00231 TH1F* h_eff = (TH1F*)num->Clone(name.c_str());
00232 h_eff->Divide(num,den,1,1,"B");
00233 h_eff->SetTitle(title.c_str());
00234 MonitorElement* eff = dbe_->get(dirName_+"/Client_Histos/"+filter+"/"+name);
00235 if(eff==NULL)eff=dbe_->book1D(name,h_eff);
00236 else{
00237 *eff->getTH1F()=*h_eff;
00238 delete h_eff;
00239 }
00240 return eff;
00241 }
00242
00243 void EgHLTOfflineClient::createN1EffHists(const std::string& filterName,const std::string& baseName,const std::string& region,const std::vector<std::string>& varNames)
00244 {
00245 MonitorElement* numer = dbe_->get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_allCuts_"+region);
00246
00247 for(size_t varNr=0;varNr<varNames.size();varNr++){
00248 MonitorElement* denom = dbe_->get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_n1_"+varNames[varNr]+"_"+region);
00249 if(numer!=NULL && denom!=NULL){
00250 std::string effHistName(baseName+"_n1Eff_"+varNames[varNr]+"_"+region);
00251
00252
00253 std::string effHistTitle(effHistName);
00254 if(region=="eb" || region=="ee"){
00255 if(region=="eb") effHistTitle = "Barrel "+baseName+" N1eff "+varNames[varNr];
00256 if(region=="ee") effHistTitle = "Endcap "+baseName+" N1eff "+varNames[varNr];
00257 }
00258
00259 makeEffMonElemFromPassAndAll(filterName,effHistName,effHistTitle,numer,denom);
00260
00261 }
00262 }
00263 }
00264
00265 void EgHLTOfflineClient::createSingleEffHists(const std::string& filterName,const std::string& baseName,const std::string& region,const std::vector<std::string>& varNames)
00266 {
00267 MonitorElement* denom = dbe_->get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_noCuts_"+region);
00268
00269 for(size_t varNr=0;varNr<varNames.size();varNr++){
00270 MonitorElement* numer = dbe_->get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_single_"+varNames[varNr]+"_"+region);
00271 if(numer!=NULL && denom!=NULL){
00272 std::string effHistName(baseName+"_singleEff_"+varNames[varNr]+"_"+region);
00273
00274 std::string effHistTitle(effHistName);
00275 if(region=="eb" || region=="ee"){
00276 if(region=="eb") effHistTitle = "Barrel "+baseName+" SingleEff "+varNames[varNr];
00277 if(region=="ee") effHistTitle = "Endcap "+baseName+" SingleEff "+varNames[varNr];
00278 }
00279
00280 makeEffMonElemFromPassAndAll(filterName,effHistName,effHistTitle,numer,denom);
00281
00282 }
00283 }
00284 }
00285
00286 void EgHLTOfflineClient::createTrigTagProbeEffHists(const std::string& filterName,const std::string& region,const std::vector<std::string>& vsVarNames,const std::string& objName)
00287 {
00288 for(size_t varNr=0;varNr<vsVarNames.size();varNr++){
00289 std::string allName(dirName_+"/Source_Histos/"+filterName+"/"+filterName+"_trigTagProbe_"+objName+"_all_"+vsVarNames[varNr]+"_"+region);
00290 MonitorElement* all = dbe_->get(allName);
00291 if(all==NULL){
00292
00293 continue;
00294 }
00295 std::string passName(dirName_+"/Source_Histos/"+filterName+"/"+filterName+"_trigTagProbe_"+objName+"_pass_"+vsVarNames[varNr]+"_"+region);
00296 MonitorElement* pass = dbe_->get(passName);
00297 if(pass==NULL){
00298
00299 continue;
00300 }
00301
00302 std::string effHistTitle(filterName+"_trigTagProbeEff_"+objName+"_vs_"+vsVarNames[varNr]+"_"+region);
00303 if(region=="eb" || region=="ee"){
00304 if(region=="eb") effHistTitle = "Barrel "+filterName+"_"+objName+" TrigTagProbeEff vs "+vsVarNames[varNr];
00305 if(region=="ee") effHistTitle = "Endcap "+filterName+"_"+objName+" TrigTagProbeEff vs "+vsVarNames[varNr];
00306 }
00307
00308 makeEffMonElemFromPassAndAll(filterName,filterName+"_trigTagProbeEff_"+objName+"_vs_"+vsVarNames[varNr]+"_"+region,effHistTitle,pass,all);
00309 }
00310 }
00311
00312 void EgHLTOfflineClient::createTrigTagProbeEffHistsNewAlgo(const std::string& filterName,const std::string& region,const std::vector<std::string>& vsVarNames,const std::string& objName)
00313 {
00314 for(size_t varNr=0;varNr<vsVarNames.size();varNr++){
00315
00316
00317
00318
00319
00320
00321
00322 std::string passName(dirName_+"/Source_Histos/"+filterName+"/"+filterName+"_trigTagProbe_"+objName+"_passNotTag_"+vsVarNames[varNr]+"_"+region);
00323 MonitorElement* passNotTag = dbe_->get(passName);
00324 if(passNotTag==NULL){
00325
00326 continue;
00327 }
00328 std::string passTagTagName(dirName_+"/Source_Histos/"+filterName+"/"+filterName+"_trigTagProbe_"+objName+"_passTagTag_"+vsVarNames[varNr]+"_"+region);
00329 MonitorElement* passTagTag = dbe_->get(passTagTagName);
00330 if(passTagTag==NULL){
00331
00332 continue;
00333 }
00334 std::string failName(dirName_+"/Source_Histos/"+filterName+"/"+filterName+"_trigTagProbe_"+objName+"_fail_"+vsVarNames[varNr]+"_"+region);
00335 MonitorElement* fail = dbe_->get(failName);
00336 if(fail==NULL){
00337
00338 continue;
00339 }
00340
00341 std::string effHistTitle(filterName+"_trigTagProbeEff_"+objName+"_vs_"+vsVarNames[varNr]+"_"+region);
00342 if(region=="eb" || region=="ee"){
00343 if(region=="eb") effHistTitle = "Barrel "+filterName+"_"+objName+" TrigTagProbeEff vs "+vsVarNames[varNr];
00344 if(region=="ee") effHistTitle = "Endcap "+filterName+"_"+objName+" TrigTagProbeEff vs "+vsVarNames[varNr];
00345 }
00346
00347 makeEffMonElemFromPassAndFailAndTagTag(filterName,filterName+"_trigTagProbeEff_"+objName+"_vs_"+vsVarNames[varNr]+"_"+region,effHistTitle,passNotTag,fail,passTagTag);
00348 }
00349 }
00350
00351 void EgHLTOfflineClient::createTrigTagProbeEffHists2Leg(const std::string& filterNameLeg1,const std::string& filterNameLeg2,const std::string& region,const std::vector<std::string>& vsVarNames,const std::string& objName)
00352 {
00353 for(size_t varNr=0;varNr<vsVarNames.size();varNr++){
00354
00355 std::string allName(dirName_+"/Source_Histos/"+filterNameLeg2+"/"+filterNameLeg2+"_trigTagProbe_"+objName+"_all_"+vsVarNames[varNr]+"_"+region);
00356 MonitorElement* all = dbe_->get(allName);
00357 if(all==NULL){
00358 edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<allName;
00359 continue;
00360 }
00361 std::string Leg2NotLeg1SourceName(dirName_+"/Source_Histos/"+filterNameLeg2+"/"+filterNameLeg2+"_trigTagProbe_"+objName+"_passLeg2failLeg1_"+vsVarNames[varNr]+"_"+region);
00362 MonitorElement* Leg2NotLeg1Source = dbe_->get(Leg2NotLeg1SourceName);
00363 if(Leg2NotLeg1Source==NULL){
00364 edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<Leg2NotLeg1SourceName;
00365 continue;
00366 }
00367
00368 std::string Leg1EffName(dirName_+"/Client_Histos/"+filterNameLeg1+"/"+filterNameLeg1+"_trigTagProbeEff_"+objName+"_vs_"+vsVarNames[varNr]+"_"+region);
00369 MonitorElement *Leg1Eff = dbe_->get(Leg1EffName);
00370 if(Leg1Eff==NULL){
00371 edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<Leg1EffName;
00372 continue;
00373 }
00374 std::string effHistTitle(filterNameLeg2+"_trigTagProbeEff2Leg_"+objName+"_vs_"+vsVarNames[varNr]+"_"+region);
00375 if(region=="eb" || region=="ee"){
00376 if(region=="eb") effHistTitle = "Barrel "+filterNameLeg2+"_"+objName+" TrigTagProbeEff2Leg vs "+vsVarNames[varNr];
00377 if(region=="ee") effHistTitle = "Endcap "+filterNameLeg2+"_"+objName+" TrigTagProbeEff2Leg vs "+vsVarNames[varNr];
00378 }
00379 makeEffMonElem2Leg(filterNameLeg2,filterNameLeg2+"_trigTagProbeEff2Leg_"+objName+"_vs_"+vsVarNames[varNr]+"_"+region,effHistTitle,Leg1Eff,Leg2NotLeg1Source,all);
00380 }
00381 }
00382
00383
00384 void EgHLTOfflineClient::createLooseTightTrigEff(const std::vector<std::string>& tightLooseTrigNames,const std::string& region,const std::vector<std::string>& vsVarNames,const std::string& objName)
00385 {
00386 for(size_t varNr=0;varNr<vsVarNames.size();varNr++){
00387 for(size_t trigNr=0;trigNr<tightLooseTrigNames.size();trigNr++){
00388 std::vector<std::string> splitString;
00389 boost::split(splitString,tightLooseTrigNames[trigNr],boost::is_any_of(std::string(":")));
00390 if(splitString.size()!=2) continue;
00391 const std::string& tightTrig = splitString[0];
00392 const std::string& looseTrig = splitString[1];
00393 MonitorElement* fail = dbe_->get(dirName_+"/Source_Histos/"+tightTrig+"_"+looseTrig+"_"+objName+"_failTrig_"+vsVarNames[varNr]+"_"+region);
00394 if(fail==NULL){
00395
00396
00397 continue;
00398 }
00399
00400 MonitorElement* pass = dbe_->get(dirName_+"/Source_Histos/"+tightTrig+"_"+looseTrig+"_"+objName+"_passTrig_"+vsVarNames[varNr]+"_"+region);
00401 if(pass==NULL){
00402
00403
00404 continue;
00405 }
00406 const std::string newHistName(tightTrig+"_trigEffTo_"+looseTrig+"_"+objName+"_vs_"+vsVarNames[varNr]+"_"+region);
00407
00408 std::string effHistTitle(newHistName);
00409 if(region=="eb" || region=="ee"){
00410 if(region=="eb") effHistTitle = "Barrel "+tightTrig+"_TrigEffTo_"+looseTrig+"_"+objName+" vs "+vsVarNames[varNr];
00411 if(region=="ee") effHistTitle = "Endcap "+tightTrig+"_TrigEffTo_"+looseTrig+"_"+objName+" vs "+vsVarNames[varNr];
00412 }
00413
00414
00415
00416 makeEffMonElemFromPassAndFail("LooseTight",newHistName,effHistTitle,pass,fail);
00417 }
00418 }
00419
00420 }
00421
00422
00423 MonitorElement* EgHLTOfflineClient::makeEffMonElemFromPassAndAll(const std::string& filterName,const std::string& name,const std::string& title,const MonitorElement* pass,const MonitorElement* all)
00424
00425 {
00426 TH1F* passHist = pass->getTH1F();
00427 if(passHist->GetSumw2N()==0) passHist->Sumw2();
00428 TH1F* allHist = all->getTH1F();
00429 if(allHist->GetSumw2N()==0) allHist->Sumw2();
00430 TH1F* effHist = (TH1F*) passHist->Clone(name.c_str());
00431 effHist->Divide(passHist,allHist,1,1,"B");
00432
00433 effHist->SetTitle(title.c_str());
00434
00435 MonitorElement* eff = dbe_->get(dirName_+"/Client_Histos/"+filterName+"/"+name);
00436 if(eff==NULL) eff= dbe_->book1D(name,effHist);
00437 else{
00438 *eff->getTH1F()=*effHist;
00439 delete effHist;
00440 }
00441 return eff;
00442 }
00443
00444 MonitorElement* EgHLTOfflineClient::makeEffMonElemFromPassAndFailAndTagTag(const std::string& filter,const std::string& name,const std::string& title,const MonitorElement* passNotTag,const MonitorElement* fail, const MonitorElement* tagtag)
00445
00446 {
00447 TH1F* passHist = passNotTag->getTH1F();
00448 if(passHist->GetSumw2N()==0) passHist->Sumw2();
00449 TH1F* failHist = fail->getTH1F();
00450 if(failHist->GetSumw2N()==0) failHist->Sumw2();
00451 TH1F* tagtagHist = tagtag->getTH1F();
00452 if(tagtagHist->GetSumw2N()==0) tagtagHist->Sumw2();
00453 TH1F* numer = (TH1F*) passHist->Clone(name.c_str());if(numer->GetSumw2N()==0) numer->Sumw2();
00454 numer->Add(tagtagHist,passHist,2,1);
00455 TH1F* denom = (TH1F*) passHist->Clone(name.c_str());if(denom->GetSumw2N()==0) denom->Sumw2();
00456 denom->Add(tagtagHist,passHist,2,1);
00457 denom->Add(failHist,1);
00458 TH1F* effHist = (TH1F*) passHist->Clone(name.c_str());
00459
00460 effHist->Divide(numer,denom,1,1,"B");
00461
00462
00463 effHist->SetTitle(title.c_str());
00464
00465 MonitorElement* eff = dbe_->get(dirName_+"/Client_Histos/"+filter+"/"+name);
00466 if(eff==NULL) eff= dbe_->book1D(name,effHist);
00467
00468 else{
00469 *eff->getTH1F()=*effHist;
00470
00471 delete effHist;
00472 }
00473 return eff;
00474 }
00475 MonitorElement* EgHLTOfflineClient::makeEffMonElem2Leg(const std::string& filter,const std::string& name,const std::string& title,const MonitorElement* Leg1Eff,const MonitorElement* Leg2NotLeg1Source,const MonitorElement* all)
00476 {
00477 TH1F* allHist = all->getTH1F();
00478 if(allHist->GetSumw2()==0)allHist->Sumw2();
00479 TH1F* Leg2NotLeg1SourceHist = Leg2NotLeg1Source->getTH1F();
00480 if(Leg2NotLeg1SourceHist->GetSumw2()==0)Leg2NotLeg1SourceHist->Sumw2();
00481
00482 TH1F* effHistLeg2NotLeg1 = (TH1F*)allHist->Clone(name.c_str());
00483 if(effHistLeg2NotLeg1->GetSumw2()==0)effHistLeg2NotLeg1->Sumw2();
00484 effHistLeg2NotLeg1->Divide(Leg2NotLeg1SourceHist, allHist, 1, 1, "B");
00485
00486 TH1F* Leg1EffHist = Leg1Eff->getTH1F();
00487 if(Leg1EffHist->GetSumw2()==0)Leg1EffHist->Sumw2();
00488
00489 TH1F* effHistTerm1 = (TH1F*)allHist->Clone(name.c_str());
00490 if(effHistTerm1->GetSumw2()==0)effHistTerm1->Sumw2();
00491 effHistTerm1->Multiply(Leg1EffHist, Leg1EffHist, 1, 1, "B");
00492
00493 TH1F* effHistTerm2 = (TH1F*)allHist->Clone(name.c_str());
00494 if(effHistTerm2->GetSumw2()==0)effHistTerm2->Sumw2();
00495 effHistTerm2->Multiply(Leg1EffHist, effHistLeg2NotLeg1, 1, 1, "B");
00496 effHistTerm2->Scale(2);
00497
00498 TH1F* effHist = (TH1F*)allHist->Clone(name.c_str());
00499 if(effHist->GetSumw2()==0)effHist->Sumw2();
00500 effHist->Add(effHistTerm1, effHistTerm2, 1, 1);
00501 effHist->SetTitle(title.c_str());
00502
00503 MonitorElement* eff = dbe_->get(dirName_+"/Client_Histos/"+filter+"/"+name);
00504 if(eff==NULL) eff= dbe_->book1D(name,effHist);
00505 else{
00506 *eff->getTH1F()=*effHist;
00507 delete effHist;
00508 }
00509 return eff;
00510 }
00511
00512
00513
00514 MonitorElement* EgHLTOfflineClient::makeEffMonElemFromPassAndFail(const std::string& filterName,const std::string& name,const std::string& title,const MonitorElement* pass,const MonitorElement* fail)
00515
00516 {
00517 TH1F* failHist = fail->getTH1F();
00518 if(failHist->GetSumw2N()==0) failHist->Sumw2();
00519 TH1F* passHist = pass->getTH1F();
00520 if(passHist->GetSumw2N()==0) passHist->Sumw2();
00521
00522 TH1F* effHist = (TH1F*) passHist->Clone(name.c_str());
00523 effHist->Add(failHist);
00524 effHist->Divide(passHist,effHist,1,1,"B");
00525
00526 effHist->SetTitle(title.c_str());
00527
00528 MonitorElement* eff = dbe_->get(dirName_+"/Client_Histos/"+filterName+"/"+name);
00529 if(eff==NULL) eff = dbe_->book1D(name,effHist);
00530 else{
00531 *eff->getTH1F()=*effHist;
00532 delete effHist;
00533 }
00534 return eff;
00535 }