CMS 3D CMS Logo

TotemRPDQMHarvester.cc
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * This is a part of TotemDQM and TOTEM offline software.
4 * Authors:
5 * Jan Kašpar (jan.kaspar@gmail.com)
6 *
7 ****************************************************************************/
8 
12 
15 
17 
18 //----------------------------------------------------------------------------------------------------
19 
20 class TotemRPDQMHarvester : public DQMEDHarvester {
21 public:
23  ~TotemRPDQMHarvester() override;
24 
25 protected:
26  void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override {}
27 
31  const edm::EventSetup &) override;
32 
33 private:
34  void MakeHitNumberRatios(unsigned int id, DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter);
35 
36  void MakePlaneEfficiencyHistograms(unsigned int id,
37  DQMStore::IBooker &ibooker,
38  DQMStore::IGetter &igetter,
39  bool &rpPlotInitialized);
40 };
41 
42 //----------------------------------------------------------------------------------------------------
43 //----------------------------------------------------------------------------------------------------
44 
45 using namespace std;
46 using namespace edm;
47 
48 //----------------------------------------------------------------------------------------------------
49 
51 
52 //----------------------------------------------------------------------------------------------------
53 
55 
56 //----------------------------------------------------------------------------------------------------
57 
58 void TotemRPDQMHarvester::MakeHitNumberRatios(unsigned int id, DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) {
59  // get source histogram
60  string path;
62 
63  MonitorElement *activity = igetter.get(path + "/activity in planes (2D)");
64 
65  if (!activity)
66  return;
67 
68  // book new histogram, if not yet done
69  const string hit_ratio_name = "hit ratio in hot spot";
70  MonitorElement *hit_ratio = igetter.get(path + "/" + hit_ratio_name);
71 
72  if (hit_ratio == nullptr) {
73  ibooker.setCurrentFolder(path);
74  string title;
76  hit_ratio = ibooker.book1D(hit_ratio_name, title + ";plane;N_hits(320<strip<440) / N_hits(all)", 10, -0.5, 9.5);
77  } else {
78  hit_ratio->getTH1F()->Reset();
79  }
80 
81  // calculate ratios
82  TAxis *y_axis = activity->getTH2F()->GetYaxis();
83  for (int bix = 1; bix <= activity->getNbinsX(); ++bix) {
84  double S_full = 0., S_sel = 0.;
85  for (int biy = 1; biy <= activity->getNbinsY(); ++biy) {
86  double c = activity->getBinContent(bix, biy);
87  double s = y_axis->GetBinCenter(biy);
88 
89  S_full += c;
90 
91  if (s > 320. && s < 440.)
92  S_sel += c;
93  }
94 
95  double r = (S_full > 0.) ? S_sel / S_full : 0.;
96 
97  hit_ratio->setBinContent(bix, r);
98  }
99 }
100 
101 //----------------------------------------------------------------------------------------------------
102 
104  DQMStore::IBooker &ibooker,
105  DQMStore::IGetter &igetter,
106  bool &rpPlotInitialized) {
107  TotemRPDetId detId(id);
108 
109  // get source histograms
110  string path;
112 
113  MonitorElement *efficiency_num = igetter.get(path + "/efficiency num");
114  MonitorElement *efficiency_den = igetter.get(path + "/efficiency den");
115 
116  if (!efficiency_num || !efficiency_den)
117  return;
118 
119  // book new plane histogram, if not yet done
120  const string efficiency_name = "efficiency";
121  MonitorElement *efficiency = igetter.get(path + "/" + efficiency_name);
122 
123  if (efficiency == nullptr) {
124  string title;
126  TAxis *axis = efficiency_den->getTH1()->GetXaxis();
127  ibooker.setCurrentFolder(path);
128  efficiency = ibooker.book1D(
129  efficiency_name, title + ";track position (mm)", axis->GetNbins(), axis->GetXmin(), axis->GetXmax());
130  } else {
131  efficiency->getTH1F()->Reset();
132  }
133 
134  // book new RP histogram, if not yet done
135  CTPPSDetId rpId = detId.rpId();
136  rpId.rpName(path, TotemRPDetId::nPath);
137  const string rp_efficiency_name = "plane efficiency";
138  MonitorElement *rp_efficiency = igetter.get(path + "/" + rp_efficiency_name);
139 
140  if (rp_efficiency == nullptr) {
141  string title;
142  rpId.rpName(title, TotemRPDetId::nFull);
143  TAxis *axis = efficiency_den->getTH1()->GetXaxis();
144  ibooker.setCurrentFolder(path);
145  rp_efficiency = ibooker.book2D(rp_efficiency_name,
146  title + ";plane;track position (mm)",
147  10,
148  -0.5,
149  9.5,
150  axis->GetNbins(),
151  axis->GetXmin(),
152  axis->GetXmax());
153  rpPlotInitialized = true;
154  } else {
155  if (!rpPlotInitialized)
156  rp_efficiency->getTH2F()->Reset();
157  rpPlotInitialized = true;
158  }
159 
160  // calculate and fill efficiencies
161  for (signed int bi = 1; bi <= efficiency->getNbinsX(); bi++) {
162  double num = efficiency_num->getBinContent(bi);
163  double den = efficiency_den->getBinContent(bi);
164 
165  if (den > 0) {
166  double p = num / den;
167  double p_unc = sqrt(p * (1. - p) / den);
168  efficiency->setBinContent(bi, p);
169  efficiency->setBinError(bi, p_unc);
170 
171  int pl_bi = detId.plane() + 1;
172  rp_efficiency->setBinContent(pl_bi, bi, p);
173  } else {
174  efficiency->setBinContent(bi, 0.);
175  }
176  }
177 }
178 
179 //----------------------------------------------------------------------------------------------------
180 
182  DQMStore::IGetter &igetter,
183  const edm::LuminosityBlock &,
184  const edm::EventSetup &) {
185  // loop over arms
186  for (unsigned int arm = 0; arm < 2; arm++) {
187  // loop over stations
188  for (unsigned int st = 0; st < 3; st += 2) {
189  // loop over RPs
190  for (unsigned int rp = 0; rp < 6; ++rp) {
191  if (st == 2) {
192  // unit 220-nr is not equipped
193  if (rp <= 2)
194  continue;
195 
196  // RP 220-fr-hr contains pixels
197  if (rp == 3)
198  continue;
199  }
200 
201  TotemRPDetId rpId(arm, st, rp);
202 
203  MakeHitNumberRatios(rpId, ibooker, igetter);
204 
205  bool rpPlotInitialized = false;
206 
207  // loop over planes
208  for (unsigned int pl = 0; pl < 10; ++pl) {
209  TotemRPDetId plId(arm, st, rp, pl);
210 
211  MakePlaneEfficiencyHistograms(plId, ibooker, igetter, rpPlotInitialized);
212  }
213  }
214  }
215  }
216 }
217 
218 //----------------------------------------------------------------------------------------------------
219 
DQMEDHarvester.h
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
MessageLogger.h
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
TotemRPDQMHarvester
Definition: TotemRPDQMHarvester.cc:19
TotemRPDQMHarvester::TotemRPDQMHarvester
TotemRPDQMHarvester(const edm::ParameterSet &ps)
Definition: TotemRPDQMHarvester.cc:49
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
TotemRPDQMHarvester::dqmEndLuminosityBlock
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, const edm::LuminosityBlock &, const edm::EventSetup &) override
Definition: TotemRPDQMHarvester.cc:180
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
TotemRPDetId::plane
uint32_t plane() const
Definition: TotemRPDetId.h:51
L1TObjectsTimingClient_cff.efficiency
efficiency
Definition: L1TObjectsTimingClient_cff.py:10
year_2016_postTS2_cff.rpId
rpId
Definition: year_2016_postTS2_cff.py:23
CTPPSDetId::nPath
Definition: CTPPSDetId.h:87
dqm::legacy::MonitorElement::getTH1F
virtual TH1F * getTH1F() const
Definition: MonitorElement.h:478
TotemRPDetId::planeName
void planeName(std::string &name, NameFlag flag=nFull) const
Definition: TotemRPDetId.h:84
TotemRPDQMHarvester::MakePlaneEfficiencyHistograms
void MakePlaneEfficiencyHistograms(unsigned int id, DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, bool &rpPlotInitialized)
Definition: TotemRPDQMHarvester.cc:102
MakerMacros.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
dqm::legacy::MonitorElement::getTH1
virtual TH1 * getTH1() const
Definition: MonitorElement.h:474
edm::ParameterSet
Definition: ParameterSet.h:47
dqm::impl::MonitorElement::getNbinsY
virtual int getNbinsY() const
get # of bins in Y-axis
Definition: MonitorElement.cc:580
CTPPSDetId::nFull
Definition: CTPPSDetId.h:87
CTPPSDetId
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:31
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
alignCSCRings.r
r
Definition: alignCSCRings.py:93
TotemRPDQMHarvester::MakeHitNumberRatios
void MakeHitNumberRatios(unsigned int id, DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
Definition: TotemRPDQMHarvester.cc:57
DQMEDHarvester
Definition: DQMEDHarvester.py:1
dqm::impl::MonitorElement::setBinContent
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
Definition: MonitorElement.cc:691
std
Definition: JetResolutionObject.h:76
dqm::implementation::IGetter
Definition: DQMStore.h:484
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
dqm::impl::MonitorElement::getNbinsX
virtual int getNbinsX() const
get # of bins in X-axis
Definition: MonitorElement.cc:574
TotemRPDetId.h
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:651
TotemRPDQMHarvester::~TotemRPDQMHarvester
~TotemRPDQMHarvester() override
Definition: TotemRPDQMHarvester.cc:53
dqm::implementation::IBooker
Definition: DQMStore.h:43
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
ParameterSet.h
CTPPSDetId::rpId
CTPPSDetId rpId() const
Definition: CTPPSDetId.h:82
dqm::impl::MonitorElement::getBinContent
virtual double getBinContent(int binx) const
get content of bin (1-D)
Definition: MonitorElement.cc:592
TotemRPDetId
Detector ID class for TOTEM Si strip detectors.
Definition: TotemRPDetId.h:29
TotemRPDQMHarvester::dqmEndJob
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Definition: TotemRPDQMHarvester.cc:30
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
dqm::legacy::MonitorElement::getTH2F
virtual TH2F * getTH2F() const
Definition: MonitorElement.h:490
CTPPSDetId::rpName
void rpName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:132