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