14 #include "TGraphAsymmErrors.h" 52 dbe_path_ =
std::string(
"MuonGEMHitsV/GEMHitsTask/");
62 if ( num==
nullptr || denum==
nullptr) {
63 std::cout<<
"num or denum are missing"<<std::endl;
66 if ( num->GetNbinsX() != denum->GetNbinsX()) {
67 std::cout<<
"Wrong Xbin. Please, check histogram's name"<<std::endl;
72 TProfile * efficHist =
new TProfile(name.c_str(), title.c_str(),num->GetXaxis()->GetNbins(), num->GetXaxis()->GetXmin(),num->GetXaxis()->GetXmax());
73 for (
int i=1;
i <= num->GetNbinsX();
i++) {
74 const double nNum = num->GetBinContent(
i);
75 const double nDenum = denum->GetBinContent(
i);
76 if ( nDenum == 0 || nNum > nDenum )
continue;
77 if ( nNum == 0 )
continue;
78 const double effVal = nNum/nDenum;
79 const double errLo = TEfficiency::ClopperPearson((
int)nDenum,(
int)nNum,0.683,
false);
80 const double errUp = TEfficiency::ClopperPearson((
int)nDenum,(
int)nNum,0.683,
true);
81 const double errVal = (effVal - errLo > errUp - effVal) ? effVal - errLo : errUp - effVal;
82 efficHist->SetBinContent(
i, effVal);
83 efficHist->SetBinEntries(
i, 1);
84 efficHist->SetBinError(
i,
sqrt(effVal * effVal + errVal * errVal));
90 TString dbe_label = TString(dbe_path_)+label_suffix;
92 if( ig.
get(dbe_label.Data()) !=
nullptr && track_hist !=
nullptr ) {
93 TH1F*
hist = (TH1F*)ig.
get( dbe_label.Data() )->getTH1F()->Clone();
94 TProfile*
profile = ComputeEff( hist, track_hist);
95 TString x_axis_title = TString(hist->GetXaxis()->GetTitle());
96 TString
title = TString::Format(
"Eff. for a SimTrack to have an associated GEM Strip in %s;%s;Eff.",label_suffix.c_str(),x_axis_title.Data());
97 profile->SetTitle( title.Data());
99 if ( sh_hist!=
nullptr) {
100 TProfile* profile_sh = ComputeEff( hist, sh_hist );
101 profile_sh->SetName( (profile->GetName()+
std::string(
"_sh")).c_str());
102 TString title2 = TString::Format(
"Eff. for a SimTrack to have an associated GEM Strip in %s with a matched SimHit;%s;Eff.",label_suffix.c_str(),x_axis_title.Data() );
103 profile_sh->SetTitle( title2.Data() );
104 ibooker.
bookProfile( profile_sh->GetName(),profile_sh);
115 TH1F* track_phi[3][3];
117 for (
unsigned int i = 0;
i < 3;
i++) {
118 track_eta[
i]=
nullptr;
119 for (
unsigned int j=0; j < 3; j++) {
120 track_phi[
i][j]=
nullptr;
124 for (
unsigned int i = 0;
i <
s_suffix.size();
i++) {
126 string track_eta_name = dbe_path_+
"track_eta"+
suffix;
127 if ( ig.
get(track_eta_name) !=
nullptr) track_eta[
i] = (TH1F*)ig.
get(track_eta_name)->
getTH1F()->Clone();
128 for (
unsigned int j = 0; j <
l_suffix.size(); j++) {
130 ProcessBooking( ibooker, ig,
"sh_eta"+suffix,track_eta[
i]);
133 for (
unsigned int i = 0;
i <
s_suffix.size();
i++) {
134 for (
unsigned int j = 0 ; j <
c_suffix.size(); j++) {
136 string track_phi_name = dbe_path_+
"track_phi"+
suffix;
137 if ( ig.
get(track_phi_name) !=
nullptr) track_phi[
i][j] = (TH1F*)ig.
get(track_phi_name)->
getTH1F()->Clone();
138 for (
unsigned int k = 0;
k <
l_suffix.size();
k++) {
140 ProcessBooking( ibooker, ig,
"sh_phi"+suffix,track_phi[
i][j]);
T getUntrackedParameter(std::string const &, T const &) const
static const std::array< std::string, 4 > l_suffix
MuonGEMHitsHarvestor(const edm::ParameterSet &)
constructor
MonitorElement * bookProfile(Args &&...args)
void setCurrentFolder(std::string const &fullpath)
static const std::array< std::string, 2 > s_suffix
#define DEFINE_FWK_MODULE(type)
TProfile * ComputeEff(TH1F *num, TH1F *denum)
~MuonGEMHitsHarvestor() override
destructor
MonitorElement * get(std::string const &path)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
void ProcessBooking(DQMStore::IBooker &, DQMStore::IGetter &, std::string label_suffix, TH1F *track_hist, TH1F *sh_hist=0)
static const std::array< std::string, 3 > c_suffix