14 #include "TGraphAsymmErrors.h" 68 TProfile * efficHist =
new TProfile(name.c_str(), title.c_str(),denum->GetXaxis()->GetNbins(), denum->GetXaxis()->GetXmin(),denum->GetXaxis()->GetXmax());
70 for (
int i=1;
i <= denum->GetNbinsX();
i++) {
72 double nNum = num->GetBinContent(
i);
73 double nDenum = denum->GetBinContent(
i);
74 if ( nDenum == 0 || nNum ==0 ) {
77 if ( nNum > nDenum ) {
81 LogDebug(
"MuonGEMDigisHarvestor")<<
"Alert! specific bin's num is bigger than denum";
83 const double effVal = nNum/nDenum;
84 efficHist->SetBinContent(
i, effVal);
85 efficHist->SetBinEntries(
i,1);
86 efficHist->SetBinError(
i,0);
87 const double errLo = TEfficiency::ClopperPearson((
int)nDenum,(
int)nNum,0.683,
false);
88 const double errUp = TEfficiency::ClopperPearson((
int)nDenum,(
int)nNum,0.683,
true);
89 const double errVal = (effVal - errLo > errUp - effVal) ? effVal - errLo : errUp - effVal;
90 efficHist->SetBinError(
i,
sqrt(effVal * effVal + errVal * errVal));
97 TString dbe_label = TString(dbe_path_)+label+
suffix;
98 if( ig.
get(dbe_label.Data()) !=
nullptr && sh_hist !=
nullptr && track_hist !=
nullptr ) {
99 TH1F*
hist = (TH1F*)ig.
get( dbe_label.Data() )->getTH1F()->Clone();
100 TProfile*
profile = ComputeEff( hist, track_hist);
101 TProfile* profile_sh = ComputeEff( hist, sh_hist );
102 profile_sh->SetName( (profile->GetName()+
std::string(
"_sh")).c_str());
103 TString x_axis_title = TString(hist->GetXaxis()->GetTitle());
104 TString
title = TString::Format(
"Eff. for a SimTrack to have an associated GEM digi in %s;%s;Eff.",suffix.Data(),x_axis_title.Data());
105 TString title2 = TString::Format(
"Eff. for a SimTrack to have an associated GEM digi in %s with a matched SimHit;%s;Eff.",suffix.Data(),x_axis_title.Data() );
106 profile->SetTitle( title.Data());
107 profile_sh->SetTitle( title2.Data() );
109 ibooker.
bookProfile( profile_sh->GetName(),profile_sh);
112 LogDebug(
"MuonGEMDigisHarvestor")<<
"Can not found histogram of "<<dbe_label;
113 if ( track_hist ==
nullptr)
LogDebug(
"MuonGEMDigisHarvestor")<<
"track not found";
114 if ( sh_hist ==
nullptr)
LogDebug(
"MuonGEMDigisHarvestor")<<
"sh_hist not found";
124 TH1F* gem_trk_eta[3];
125 TH1F* gem_trk_phi[3][2];
128 TH1F* sh_phi[3][4][3];
166 for(
int i = 0 ;
i < 3 ;
i++) {
167 TString eta_label = TString(dbe_path_)+
"track_eta"+
s_suffix[
i];
169 if ( ig.
get(eta_label.Data()) !=
nullptr ) {
170 gem_trk_eta[
i] = (TH1F*)ig.
get(eta_label.Data())->getTH1F()->Clone();
171 gem_trk_eta[
i]->Sumw2();
173 else LogDebug(
"MuonGEMDigisHarvestor")<<
"Can not found track_eta";
174 for (
int k=0 ;
k <3 ;
k++) {
176 if ( ig.
get(phi_label.Data()) !=
nullptr ) {
177 gem_trk_phi[
i][
k] = (TH1F*)ig.
get(phi_label.Data())->getTH1F()->Clone();
178 gem_trk_phi[
i][
k]->Sumw2();
180 else LogDebug(
"MuonGEMDigisHarvestor")<<
"Can not found track_phi";
183 if ( ig.
get(eta_label.Data()) !=
nullptr && ig.
get(phi_label.Data()) !=
nullptr ) {
184 for(
int j = 0; j < 4 ; j++) {
186 TString eta_label = TString(dbe_path_)+
"dg_sh_eta"+
suffix;
187 if( ig.
get(eta_label.Data()) !=
nullptr ) {
188 sh_eta[
i][j] = (TH1F*)ig.
get(eta_label.Data())->getTH1F()->Clone();
189 sh_eta[
i][j]->Sumw2();
191 else LogDebug(
"MuonGEMDigisHarvestor")<<
"Can not found eta histogram : "<<eta_label;
192 ProcessBooking( ibooker, ig,
"dg_eta", suffix, gem_trk_eta[i], sh_eta[i][j]);
193 ProcessBooking( ibooker, ig,
"pad_eta", suffix, gem_trk_eta[i], sh_eta[i][j]);
194 ProcessBooking( ibooker, ig,
"copad_eta", suffix, gem_trk_eta[i], sh_eta[i][j]);
195 for (
int k= 0 ;
k< 3 ;
k++) {
197 TString phi_label = TString(dbe_path_)+
"dg_sh_phi"+
suffix;
198 if( ig.
get(phi_label.Data()) !=
nullptr ) {
199 sh_phi[
i][j][
k] = (TH1F*)ig.
get(phi_label.Data())->getTH1F()->Clone();
200 sh_phi[
i][j][
k]->Sumw2();
202 else {
LogDebug(
"MuonGEMDigisHarvestor")<<
"Can not found phi plots : "<<phi_label;
continue; }
203 ProcessBooking( ibooker, ig,
"dg_phi",suffix, gem_trk_phi[i][k], sh_phi[i][j][k]);
204 ProcessBooking( ibooker, ig,
"pad_phi",suffix,gem_trk_phi[i][k], sh_phi[i][j][k]);
205 ProcessBooking( ibooker, ig,
"copad_phi",suffix,gem_trk_phi[i][k], sh_phi[i][j][k]);
209 else LogDebug(
"MuonGEMDigisHarvestor")<<
"Can not find eta or phi of all track";
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual ~MuonGEMDigisHarvestor()
destructor
static const std::array< std::string, 4 > l_suffix
MonitorElement * bookProfile(Args &&...args)
MonitorElement * get(const std::string &path)
#define DEFINE_FWK_MODULE(type)
TProfile * ComputeEff(TH1F *num, TH1F *denum)
static const std::array< std::string, 2 > s_suffix
MuonGEMDigisHarvestor(const edm::ParameterSet &)
constructor
virtual void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &)
void setCurrentFolder(const std::string &fullpath)
void ProcessBooking(DQMStore::IBooker &, DQMStore::IGetter &, const char *label, TString suffix, TH1F *track_hist, TH1F *sh_hist)
static const std::array< std::string, 3 > c_suffix