18 #include "TEfficiency.h" 41 myDQMrootFolder( pset.getUntrackedParameter<
string>(
"MyDQMrootFolder") ),
55 if(numDenEffMEnames.size()!=3){
56 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"NumDenEffMEnames must have three names"<<endl;
63 if(denME==
nullptr || numME==
nullptr){
64 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"Could not find MEs: "<<denMEname<<
" or "<<numMEname<<endl;
67 TH1 *den = denME->
getTH1();
70 if( den->GetNbinsX() != num->GetNbinsX() || den->GetNbinsY() != num->GetNbinsY() || den->GetNbinsZ() != num->GetNbinsZ() ){
71 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"Monitoring elements "<<numMEname<<
" and "<<denMEname<<
"are incompatible"<<endl;
75 string effName = numDenEffMEnames[2];
78 if ( string::npos != slashPos ) {
79 effDir +=
"/"+effName.substr(0, slashPos);
80 effName.erase(0, slashPos+1);
87 }
else if(dimensions==2){
89 TH1D* numX = ((TH2F*)num)->ProjectionX();
90 TH1D* denX = ((TH2F*)den)->ProjectionX();
94 TH1D* numY = ((TH2F*)num)->ProjectionY();
95 TH1D* denY = ((TH2F*)den)->ProjectionY();
106 if(num->GetXaxis()->GetXbins()->GetSize()==0){
107 eff =
new TProfile(effName.c_str(),effName.c_str(),num->GetXaxis()->GetNbins(),num->GetXaxis()->GetXmin(),num->GetXaxis()->GetXmax());
109 eff =
new TProfile(effName.c_str(),effName.c_str(),num->GetXaxis()->GetNbins(),num->GetXaxis()->GetXbins()->GetArray());
111 eff->SetTitle(effName.c_str());
112 eff->SetXTitle( num->GetXaxis()->GetTitle() );
113 eff->SetYTitle(
"Efficiency");
114 eff->SetOption(
"PE");
115 eff->SetLineColor(2);
116 eff->SetLineWidth(2);
117 eff->SetMarkerStyle(20);
118 eff->SetMarkerSize(0.8);
119 eff->GetYaxis()->SetRangeUser(-0.001,1.001);
120 eff->SetStats(kFALSE);
121 for(
int i=1;
i<=num->GetNbinsX();
i++){
123 if (
int(den->GetBinContent(
i))>0.) e= double(num->GetBinContent(
i))/
double(den->GetBinContent(
i));
125 low=TEfficiency::Wilson((
double)den->GetBinContent(
i),(double)num->GetBinContent(
i),0.683,
false);
126 high=TEfficiency::Wilson((
double)den->GetBinContent(
i),(double)num->GetBinContent(
i),0.683,
true);
128 double err = e-low>high-e ? e-low : high-
e;
130 eff->SetBinContent(
i, e );
131 eff->SetBinEntries(
i, 1 );
132 eff->SetBinError(
i,
sqrt(e*e+err*err) );
140 if(num->GetXaxis()->GetXbins()->GetSize()==0 && num->GetYaxis()->GetXbins()->GetSize()==0){
141 eff =
new TProfile2D(effName.c_str(),effName.c_str(),num->GetXaxis()->GetNbins(),num->GetXaxis()->GetXmin(),num->GetXaxis()->GetXmax(),num->GetYaxis()->GetNbins(),num->GetYaxis()->GetXmin(),num->GetYaxis()->GetXmax());
142 }
else if(num->GetXaxis()->GetXbins()->GetSize()!=0 && num->GetYaxis()->GetXbins()->GetSize()==0){
143 eff =
new TProfile2D(effName.c_str(),effName.c_str(),num->GetXaxis()->GetNbins(),num->GetXaxis()->GetXbins()->GetArray(),num->GetYaxis()->GetNbins(),num->GetYaxis()->GetXmin(),num->GetYaxis()->GetXmax());
144 }
else if(num->GetXaxis()->GetXbins()->GetSize()==0 && num->GetYaxis()->GetXbins()->GetSize()!=0){
145 eff =
new TProfile2D(effName.c_str(),effName.c_str(),num->GetXaxis()->GetNbins(),num->GetXaxis()->GetXmin(),num->GetXaxis()->GetXmax(),num->GetYaxis()->GetNbins(),num->GetYaxis()->GetXbins()->GetArray());
147 eff =
new TProfile2D(effName.c_str(),effName.c_str(),num->GetXaxis()->GetNbins(),num->GetXaxis()->GetXbins()->GetArray(),num->GetYaxis()->GetNbins(),num->GetYaxis()->GetXbins()->GetArray());
149 eff->SetTitle(effName.c_str());
150 eff->SetXTitle( num->GetXaxis()->GetTitle() );
151 eff->SetYTitle( num->GetYaxis()->GetTitle() );
152 eff->SetZTitle(
"Efficiency");
153 eff->SetOption(
"colztexte");
154 eff->GetZaxis()->SetRangeUser(-0.001,1.001);
155 eff->SetStats(kFALSE);
156 for(
int i=0;
i<num->GetSize();
i++){
158 if (
int(den->GetBinContent(
i))>0.) e= double(num->GetBinContent(
i))/
double(den->GetBinContent(
i));
160 low=TEfficiency::Wilson((
double)den->GetBinContent(
i),(double)num->GetBinContent(
i),0.683,
false);
161 high=TEfficiency::Wilson((
double)den->GetBinContent(
i),(double)num->GetBinContent(
i),0.683,
true);
163 double err = e-low>high-e ? e-low : high-
e;
165 eff->SetBinContent(
i, e );
166 eff->SetBinEntries(
i, 1 );
167 eff->SetBinError(
i,
sqrt(e*e+err*err) );
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * bookProfile(Args &&...args)
#define DEFINE_FWK_MODULE(type)
std::vector< ParameterSet > VParameterSet
void calculateEfficiency1D(TH1 *num, TH1 *den, string name, DQMStore::IBooker &, DQMStore::IGetter &)
void setCurrentFolder(std::string const &fullpath)
const VParameterSet efficiencies
MonitorElement * bookProfile2D(Args &&...args)
HeavyFlavorHarvesting(const edm::ParameterSet &pset)
void calculateEfficiency2D(TH2F *num, TH2F *den, string name, DQMStore::IBooker &, DQMStore::IGetter &)
MonitorElement * get(std::string const &path)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
~HeavyFlavorHarvesting() override
void calculateEfficiency(const ParameterSet &pset, DQMStore::IBooker &, DQMStore::IGetter &)