test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
16 
18 
19 //----------------------------------------------------------------------------------------------------
20 
22 {
23  public:
25  virtual ~TotemRPDQMHarvester();
26 
27  protected:
29 
31 
32  private:
33  void MakeHitNumberRatios(unsigned int id, DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter);
34 
35  void MakePlaneEfficiencyHistograms(unsigned int id, DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter, bool &rpPlotInitialized);
36 };
37 
38 //----------------------------------------------------------------------------------------------------
39 //----------------------------------------------------------------------------------------------------
40 
41 using namespace std;
42 using namespace edm;
43 
44 //----------------------------------------------------------------------------------------------------
45 
47 {
48 }
49 
50 //----------------------------------------------------------------------------------------------------
51 
53 {
54 }
55 
56 //----------------------------------------------------------------------------------------------------
57 
59 {
60  // get source histogram
62  path.replace(0, 2, "CTPPS/TrackingStrip");
63 
64  MonitorElement *activity = igetter.get(path + "/activity in planes (2D)");
65 
66  if (!activity)
67  return;
68 
69  // book new histogram, if not yet done
70  const string hit_ratio_name = "hit ratio in hot spot";
71  MonitorElement *hit_ratio = igetter.get(path + "/" + hit_ratio_name);
72 
73  if (hit_ratio == NULL)
74  {
75  ibooker.setCurrentFolder(path);
77  hit_ratio = ibooker.book1D(hit_ratio_name, title+";plane;N_hits(320<strip<440) / N_hits(all)", 10, -0.5, 9.5);
78  } else {
79  hit_ratio->getTH1F()->Reset();
80  }
81 
82  // calculate ratios
83  TAxis *y_axis = activity->getTH2F()->GetYaxis();
84  for (int bix = 1; bix <= activity->getNbinsX(); ++bix)
85  {
86  double S_full = 0., S_sel = 0.;
87  for (int biy = 1; biy <= activity->getNbinsY(); ++biy)
88  {
89  double c = activity->getBinContent(bix, biy);
90  double s = y_axis->GetBinCenter(biy);
91 
92  S_full += c;
93 
94  if (s > 320. && s < 440.)
95  S_sel += c;
96  }
97 
98  double r = (S_full > 0.) ? S_sel / S_full : 0.;
99 
100  hit_ratio->setBinContent(bix, r);
101  }
102 }
103 
104 //----------------------------------------------------------------------------------------------------
105 
107  DQMStore::IGetter& igetter, bool &rpPlotInitialized)
108 {
109  // get source histograms
111  path.replace(0, 2, "CTPPS/TrackingStrip");
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 == NULL)
124  {
126  TAxis *axis = efficiency_den->getTH1()->GetXaxis();
127  ibooker.setCurrentFolder(path);
128  efficiency = ibooker.book1D(efficiency_name, title+";track position (mm)", axis->GetNbins(), axis->GetXmin(), axis->GetXmax());
129  } else {
130  efficiency->getTH1F()->Reset();
131  }
132 
133  // book new RP histogram, if not yet done
135  path.replace(0, 2, "CTPPS/TrackingStrip");
136  const string rp_efficiency_name = "plane efficiency";
137  MonitorElement *rp_efficiency = igetter.get(path + "/" + rp_efficiency_name);
138 
139  if (rp_efficiency == NULL)
140  {
142  TAxis *axis = efficiency_den->getTH1()->GetXaxis();
143  ibooker.setCurrentFolder(path);
144  rp_efficiency = ibooker.book2D(rp_efficiency_name, title+";plane;track position (mm)",
145  10, -0.5, 9.5, axis->GetNbins(), axis->GetXmin(), axis->GetXmax());
146  rpPlotInitialized = true;
147  } else {
148  if (!rpPlotInitialized)
149  rp_efficiency->getTH2F()->Reset();
150  rpPlotInitialized = true;
151  }
152 
153  // calculate and fill efficiencies
154  for (signed int bi = 1; bi <= efficiency->getNbinsX(); bi++)
155  {
156  double num = efficiency_num->getBinContent(bi);
157  double den = efficiency_den->getBinContent(bi);
158 
159  if (den > 0)
160  {
161  double p = num / den;
162  double p_unc = sqrt(p * (1. - p) / den);
163  efficiency->setBinContent(bi, p);
164  efficiency->setBinError(bi, p_unc);
165 
166  int pl_bi = (id%10) + 1;
167  rp_efficiency->setBinContent(pl_bi, bi, p);
168  } else {
169  efficiency->setBinContent(bi, 0.);
170  }
171  }
172 }
173 
174 //----------------------------------------------------------------------------------------------------
175 
177  const edm::LuminosityBlock &, const edm::EventSetup &)
178 {
179  // loop over arms
180  for (unsigned int arm = 0; arm < 2; arm++)
181  {
182  // loop over stations
183  for (unsigned int st = 0; st < 3; st += 2)
184  {
185  unsigned int stId = 10*arm + st;
186 
187  // loop over RPs
188  for (unsigned int rp = 0; rp < 6; ++rp)
189  {
190  unsigned int rpId = 10*stId + rp;
191 
192  MakeHitNumberRatios(rpId, ibooker, igetter);
193 
194  bool rpPlotInitialized = false;
195 
196  // loop over planes
197  for (unsigned int pl = 0; pl < 10; ++pl)
198  {
199  unsigned int plId = 10*rpId + pl;
200 
201  MakePlaneEfficiencyHistograms(plId, ibooker, igetter, rpPlotInitialized);
202  }
203  }
204  }
205  }
206 }
207 
208 //----------------------------------------------------------------------------------------------------
209 
static std::string rpName(unsigned int id, NameFlag flag=nFull)
returns official name of a RP characterized by &#39;&#39;id&#39;&#39;; if &#39;&#39;full&#39;&#39; is true, name of station is prefix...
void setBinContent(int binx, double content)
set content of bin (1-D)
static std::string planeName(unsigned int id, NameFlag flag=nFull)
returns official name of a plane characterized by &#39;&#39;id&#39;&#39;; if &#39;&#39;full&#39;&#39; is true, name of RP is prefixed...
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:304
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
#define NULL
Definition: scimark2.h:8
int getNbinsY(void) const
get # of bins in Y-axis
T sqrt(T t)
Definition: SSEVec.h:18
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
void MakeHitNumberRatios(unsigned int id, DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
TH1 * getTH1(void) const
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, const edm::LuminosityBlock &, const edm::EventSetup &) override
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:276
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
TH1F * getTH1F(void) const
void MakePlaneEfficiencyHistograms(unsigned int id, DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, bool &rpPlotInitialized)
double getBinContent(int binx) const
get content of bin (1-D)
int getNbinsX(void) const
get # of bins in X-axis
TH2F * getTH2F(void) const
TotemRPDQMHarvester(const edm::ParameterSet &ps)