14 #include "TGraphAsymmErrors.h"
63 TProfile * efficHist =
new TProfile(name.c_str(), title.c_str(),denum->GetXaxis()->GetNbins(), denum->GetXaxis()->GetXmin(),denum->GetXaxis()->GetXmax());
65 for (
int i=1;
i <= denum->GetNbinsX();
i++) {
67 double nNum = num->GetBinContent(
i);
68 double nDenum = denum->GetBinContent(
i);
69 if ( nDenum == 0 || nNum ==0 ) {
72 if ( nNum > nDenum ) {
76 std::cout<<
"Alert! specific bin's num is bigger than denum"<<std::endl;
78 const double effVal = nNum/nDenum;
79 efficHist->SetBinContent(
i, effVal);
80 efficHist->SetBinEntries(
i,1);
81 efficHist->SetBinError(
i,0);
82 const double errLo = TEfficiency::ClopperPearson((
int)nDenum,(
int)nNum,0.683,
false);
83 const double errUp = TEfficiency::ClopperPearson((
int)nDenum,(
int)nNum,0.683,
true);
84 const double errVal = (effVal - errLo > errUp - effVal) ? effVal - errLo : errUp - effVal;
85 efficHist->SetBinError(
i,
sqrt(effVal * effVal + errVal * errVal));
93 if( ig.
get(dbe_label.Data()) !=
nullptr && sh_hist !=
nullptr && track_hist !=
nullptr ) {
94 TH1F*
hist = (TH1F*)ig.
get( dbe_label.Data() )->getTH1F()->Clone();
95 TProfile* profile =
ComputeEff( hist, track_hist);
96 TProfile* profile_sh =
ComputeEff( hist, sh_hist );
97 profile_sh->SetName( (profile->GetName()+
std::string(
"_sh")).c_str());
98 TString x_axis_title = TString(hist->GetXaxis()->GetTitle());
99 TString
title = TString::Format(
"Eff. for a SimTrack to have an associated GEM RecHits in %s;%s;Eff.",suffix.Data(),x_axis_title.Data());
100 TString title2 = TString::Format(
"Eff. for a SimTrack to have an associated GEM RecHits in %s with a matched SimHit;%s;Eff.",suffix.Data(),x_axis_title.Data() );
101 profile->SetTitle( title.Data());
102 profile_sh->SetTitle( title2.Data() );
104 ibooker.
bookProfile( profile_sh->GetName(),profile_sh);
107 std::cout<<
"Can not found histogram of "<<dbe_label<<std::endl;
108 if ( track_hist ==
nullptr)
std::cout<<
"track not found"<<std::endl;
109 if ( sh_hist ==
nullptr)
std::cout<<
"sh_hist not found"<<std::endl;
120 const char*
l_suffix[4] = {
"_l1",
"_l2",
"_l1or2",
"_l1and2"};
121 const char*
s_suffix[2] = {
"_st1",
"_st2"};
122 const char*
c_suffix[3] = {
"_even",
"_odd",
"_all"};
124 TH1F* gem_trk_eta[2];
125 TH1F* gem_trk_phi[2][2];
128 TH1F* sh_phi[2][4][3];
130 for(
int i = 0 ;
i < 2 ;
i++) {
131 TString eta_label = TString(
dbe_path_)+
"track_eta"+s_suffix[
i];
133 if ( ig.
get(eta_label.Data()) !=
nullptr ) {
134 gem_trk_eta[
i] = (TH1F*)ig.
get(eta_label.Data())->getTH1F()->Clone();
135 gem_trk_eta[
i]->Sumw2();
137 else std::cout<<
"Can not found track_eta"<<std::endl;
138 for (
int k=0 ;
k <3 ;
k++) {
139 phi_label = TString(
dbe_path_.c_str())+
"track_phi"+s_suffix[
i]+c_suffix[
k];
140 if ( ig.
get(phi_label.Data()) !=
nullptr ) {
141 gem_trk_phi[
i][
k] = (TH1F*)ig.
get(phi_label.Data())->getTH1F()->Clone();
142 gem_trk_phi[
i][
k]->Sumw2();
144 else std::cout<<
"Can not found track_phi"<<std::endl;
147 if ( ig.
get(eta_label.Data()) !=
nullptr && ig.
get(phi_label.Data()) !=
nullptr ) {
148 for(
int j = 0;
j < 4 ;
j++) {
149 TString
suffix = TString( s_suffix[
i] )+TString( l_suffix[
j]);
151 if( ig.
get(eta_label.Data()) !=
nullptr ) {
152 sh_eta[
i][
j] = (TH1F*)ig.
get(eta_label.Data())->getTH1F()->Clone();
153 sh_eta[
i][
j]->Sumw2();
155 else std::cout<<
"Can not found eta histogram : "<<eta_label<<std::endl;
156 ProcessBooking( ibooker, ig,
"rh_eta", suffix, gem_trk_eta[i], sh_eta[i][j]);
157 for (
int k= 0 ;
k< 3 ;
k++) {
158 suffix = TString( s_suffix[i])+TString( l_suffix[j]) +TString(c_suffix[
k]);
160 if( ig.
get(phi_label.Data()) !=
nullptr ) {
161 sh_phi[
i][
j][
k] = (TH1F*)ig.
get(phi_label.Data())->getTH1F()->Clone();
162 sh_phi[
i][
j][
k]->Sumw2();
164 else {
std::cout<<
"Can not found phi plots : "<<phi_label<<std::endl;
continue; }
165 ProcessBooking( ibooker, ig,
"rh_phi",suffix, gem_trk_phi[i][k], sh_phi[i][j][k]);
169 else std::cout<<
"Can not find eta or phi of all track"<<std::endl;
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * bookProfile(Args &&...args)
MonitorElement * get(const std::string &path)
#define DEFINE_FWK_MODULE(type)
TProfile * ComputeEff(TH1F *num, TH1F *denum)
MuonGEMRecHitsHarvestor(const edm::ParameterSet &)
constructor
static const std::string l_suffix[4]
static const std::string s_suffix[2]
virtual ~MuonGEMRecHitsHarvestor()
destructor
static const std::string c_suffix[3]
void setCurrentFolder(const std::string &fullpath)
void ProcessBooking(DQMStore::IBooker &, DQMStore::IGetter &, const char *label, TString suffix, TH1F *track_hist, TH1F *sh_hist)
virtual void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &)