CMS 3D CMS Logo

MuonME0DigisHarvestor.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 
4 // user include files
12 #include "TGraphAsymmErrors.h"
13 
17 
22 
24 
28 
30 
32  dbe_path_ = std::string("MuonME0DigisV/ME0DigisTask/");
33 }
34 
36 
37 TProfile *MuonME0DigisHarvestor::ComputeEff(TH1F *num, TH1F *denum, std::string nameHist) {
38  std::string name = "eff_" + nameHist;
39  std::string title = "Digi Efficiency" + std::string(num->GetTitle());
40  TProfile *efficHist = new TProfile(name.c_str(),
41  title.c_str(),
42  denum->GetXaxis()->GetNbins(),
43  denum->GetXaxis()->GetXmin(),
44  denum->GetXaxis()->GetXmax());
45 
46  for (int i = 1; i <= denum->GetNbinsX(); i++) {
47  double nNum = num->GetBinContent(i);
48  double nDenum = denum->GetBinContent(i);
49  if (nDenum == 0 || nNum == 0) {
50  continue;
51  }
52  if (nNum > nDenum) {
53  double temp = nDenum;
54  nDenum = nNum;
55  nNum = temp;
56  edm::LogWarning("MuonME0DigisHarvestor")
57  << "Alert! specific bin's num is bigger than denum " << i << " " << nNum << " " << nDenum;
58  }
59  const double effVal = nNum / nDenum;
60  efficHist->SetBinContent(i, effVal);
61  efficHist->SetBinEntries(i, 1);
62  efficHist->SetBinError(i, 0);
63  const double errLo = TEfficiency::ClopperPearson((int)nDenum, (int)nNum, 0.683, false);
64  const double errUp = TEfficiency::ClopperPearson((int)nDenum, (int)nNum, 0.683, true);
65  const double errVal = (effVal - errLo > errUp - effVal) ? effVal - errLo : errUp - effVal;
66  efficHist->SetBinError(i, sqrt(effVal * effVal + errVal * errVal));
67  }
68  return efficHist;
69 }
70 
72  DQMStore::IBooker &ibooker, DQMStore::IGetter &ig, std::string nameHist, TH1F *num, TH1F *den) {
73  if (num != nullptr && den != nullptr) {
74  TProfile *profile = ComputeEff(num, den, nameHist);
75 
76  TString x_axis_title = TString(num->GetXaxis()->GetTitle());
77  TString title = TString::Format("Digi Efficiency;%s;Eff.", x_axis_title.Data());
78 
79  profile->SetTitle(title.Data());
80  ibooker.bookProfile(profile->GetName(), profile);
81 
82  delete profile;
83 
84  } else {
85  edm::LogWarning("MuonME0DigisHarvestor") << "Can not find histograms";
86  if (num == nullptr)
87  edm::LogWarning("MuonME0DigisHarvestor") << "num not found";
88  if (den == nullptr)
89  edm::LogWarning("MuonME0DigisHarvestor") << "den not found";
90  }
91  return;
92 }
93 
94 TH1F *MuonME0DigisHarvestor::ComputeBKG(TH1F *hist1, TH1F *hist2, std::string nameHist) {
95  std::string name = "rate_" + nameHist;
96  hist1->SetName(name.c_str());
97  for (int bin = 1; bin <= hist1->GetNbinsX(); ++bin) {
98  double R_min = hist1->GetBinCenter(bin) - 0.5 * hist1->GetBinWidth(bin);
99  double R_max = hist1->GetBinCenter(bin) + 0.5 * hist1->GetBinWidth(bin);
100 
101  double Area = TMath::Pi() * (R_max * R_max - R_min * R_min);
102  hist1->SetBinContent(bin, (hist1->GetBinContent(bin)) / Area);
103  hist1->SetBinError(bin, (hist1->GetBinError(bin)) / Area);
104  }
105 
106  int nEvts = hist2->GetEntries();
107  float scale = 6 * 2 * nEvts * 3 * 25e-9; // New redigitizer saves hits only in the BX range: [-1,+1], so the
108  // number of background hits has to be divided by 3
109  hist1->Scale(1.0 / scale);
110  return hist1;
111 }
112 
114  DQMStore::IBooker &ibooker, DQMStore::IGetter &ig, std::string nameHist, TH1F *hist1, TH1F *hist2) {
115  if (hist1 != nullptr && hist2 != nullptr) {
116  TH1F *rate = ComputeBKG(hist1, hist2, nameHist);
117 
118  TString x_axis_title = TString(hist1->GetXaxis()->GetTitle());
119  TString origTitle = TString(hist1->GetTitle());
120  TString title = TString::Format((origTitle + ";%s;Rate [Hz/cm^{2}]").Data(), x_axis_title.Data());
121 
122  rate->SetTitle(title.Data());
123  ibooker.book1D(rate->GetName(), rate);
124 
125  } else {
126  edm::LogWarning("MuonME0DigisHarvestor") << "Can not find histograms";
127  if (hist1 == nullptr)
128  edm::LogWarning("MuonME0DigisHarvestor") << "num not found";
129  if (hist2 == nullptr)
130  edm::LogWarning("MuonME0DigisHarvestor") << "den not found";
131  }
132  return;
133 }
134 
137 
138  const char *l_suffix[6] = {"_l1", "_l2", "_l3", "_l4", "_l5", "_l6"};
139  const char *r_suffix[2] = {"-1", "1"};
140 
141  TString eta_label_den_tot = TString(dbe_path_) + "me0_strip_dg_den_eta_tot";
142  TString eta_label_num_tot = TString(dbe_path_) + "me0_strip_dg_num_eta_tot";
143  if (ig.get(eta_label_num_tot.Data()) != nullptr && ig.get(eta_label_den_tot.Data()) != nullptr) {
144  TH1F *num_vs_eta_tot = (TH1F *)ig.get(eta_label_num_tot.Data())->getTH1F()->Clone();
145  num_vs_eta_tot->Sumw2();
146  TH1F *den_vs_eta_tot = (TH1F *)ig.get(eta_label_den_tot.Data())->getTH1F()->Clone();
147  den_vs_eta_tot->Sumw2();
148 
149  ProcessBooking(ibooker, ig, "me0_strip_dg_eta_tot", num_vs_eta_tot, den_vs_eta_tot);
150 
151  delete num_vs_eta_tot;
152  delete den_vs_eta_tot;
153 
154  } else
155  edm::LogWarning("MuonME0DigisHarvestor")
156  << "Can not find histograms: " << eta_label_num_tot << " or " << eta_label_den_tot;
157 
158  for (int i = 0; i < 2; i++) {
159  for (int j = 0; j < 6; j++) {
160  TString eta_label_den = TString(dbe_path_) + "me0_strip_dg_den_eta" + r_suffix[i] + l_suffix[j];
161  TString eta_label_num = TString(dbe_path_) + "me0_strip_dg_num_eta" + r_suffix[i] + l_suffix[j];
162 
163  if (ig.get(eta_label_num.Data()) != nullptr && ig.get(eta_label_den.Data()) != nullptr) {
164  TH1F *num_vs_eta = (TH1F *)ig.get(eta_label_num.Data())->getTH1F()->Clone();
165  num_vs_eta->Sumw2();
166  TH1F *den_vs_eta = (TH1F *)ig.get(eta_label_den.Data())->getTH1F()->Clone();
167  den_vs_eta->Sumw2();
168 
169  std::string r_s = r_suffix[i];
170  std::string l_s = l_suffix[j];
171  std::string name = "me0_strip_dg_eta" + r_s + l_s;
172  ProcessBooking(ibooker, ig, name, num_vs_eta, den_vs_eta);
173 
174  delete num_vs_eta;
175  delete den_vs_eta;
176 
177  } else
178  edm::LogWarning("MuonME0DigisHarvestor")
179  << "Can not find histograms: " << eta_label_num << " " << eta_label_den;
180  }
181  }
182 
183  TString label_eleBkg = TString(dbe_path_) + "me0_strip_dg_bkgElePos_radius";
184  TString label_neuBkg = TString(dbe_path_) + "me0_strip_dg_bkgNeutral_radius";
185  TString label_totBkg = TString(dbe_path_) + "me0_strip_dg_bkg_radius_tot";
186  TString label_evts = TString(dbe_path_) + "num_evts";
187 
188  if (ig.get(label_evts.Data()) != nullptr) {
189  TH1F *numEvts = (TH1F *)ig.get(label_evts.Data())->getTH1F()->Clone();
190 
191  if (ig.get(label_eleBkg.Data()) != nullptr) {
192  TH1F *eleBkg = (TH1F *)ig.get(label_eleBkg.Data())->getTH1F()->Clone();
193  eleBkg->Sumw2();
194  ProcessBookingBKG(ibooker, ig, "me0_strip_dg_elePosBkg_rad", eleBkg, numEvts);
195 
196  delete eleBkg;
197  }
198  if (ig.get(label_neuBkg.Data()) != nullptr) {
199  TH1F *neuBkg = (TH1F *)ig.get(label_neuBkg.Data())->getTH1F()->Clone();
200  neuBkg->Sumw2();
201  ProcessBookingBKG(ibooker, ig, "me0_strip_dg_neuBkg_rad", neuBkg, numEvts);
202 
203  delete neuBkg;
204  }
205  if (ig.get(label_totBkg.Data()) != nullptr) {
206  TH1F *totBkg = (TH1F *)ig.get(label_totBkg.Data())->getTH1F()->Clone();
207  totBkg->Sumw2();
208  ProcessBookingBKG(ibooker, ig, "me0_strip_dg_totBkg_rad", totBkg, numEvts);
209 
210  delete totBkg;
211  }
212 
213  delete numEvts;
214  }
215 }
216 
217 // define this as a plug-in
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
ME0EtaPartitionSpecs.h
DQMStore.h
EDAnalyzer.h
StripTopology.h
MuonME0DigisHarvestor::~MuonME0DigisHarvestor
~MuonME0DigisHarvestor() override
destructor
Definition: MuonME0DigisHarvestor.cc:35
RPCpg::rate
double rate(double x)
Definition: Constants.cc:3
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
MuonME0DigisHarvestor::ProcessBookingBKG
void ProcessBookingBKG(DQMStore::IBooker &ibooker, DQMStore::IGetter &ig, std::string nameHist, TH1F *hist, TH1F *hist2)
Definition: MuonME0DigisHarvestor.cc:113
MakerMacros.h
nEvts
const int nEvts
Definition: recycleTccEmu.cc:12
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MuonME0DigisHarvestor::ComputeEff
TProfile * ComputeEff(TH1F *num, TH1F *denum, std::string nameHist)
Definition: MuonME0DigisHarvestor.cc:37
Service.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
dqm::implementation::IBooker::bookProfile
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:322
MuonME0DigisHarvestor.h
MuonME0DigisHarvestor
Definition: MuonME0DigisHarvestor.h:17
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PostProcessor_cff.profile
profile
Definition: PostProcessor_cff.py:38
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
MuonME0DigisHarvestor::MuonME0DigisHarvestor
MuonME0DigisHarvestor(const edm::ParameterSet &)
constructor
Definition: MuonME0DigisHarvestor.cc:31
MuonME0DigisHarvestor::dbe_path_
std::string dbe_path_
Definition: MuonME0DigisHarvestor.h:32
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
InputTag.h
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
MuonME0DigisHarvestor::ProcessBooking
void ProcessBooking(DQMStore::IBooker &, DQMStore::IGetter &, std::string nameHist, TH1F *num, TH1F *den)
Definition: MuonME0DigisHarvestor.cc:71
ME0Geometry.h
GeomDet.h
MuonME0DigisHarvestor::ComputeBKG
TH1F * ComputeBKG(TH1F *hist1, TH1F *hist2, std::string nameHist)
Definition: MuonME0DigisHarvestor.cc:94
Frameworkfwd.h
dqm::implementation::IGetter
Definition: DQMStore.h:484
ME0EtaPartition.h
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:651
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
dqm::implementation::IBooker
Definition: DQMStore.h:43
Pi
const double Pi
Definition: CosmicMuonParameters.h:18
ParameterSet.h
MuonGeometryRecord.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
MuonME0DigisHarvestor::dqmEndJob
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Definition: MuonME0DigisHarvestor.cc:135
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37