17 #include "TPaveStats.h" 25 int gainValues[kGains] = {12, 6, 1};
36 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override{
37 TH2F** barrel_m =
new TH2F*[kGains];
38 TH2F** endc_p_m =
new TH2F*[kGains];
39 TH2F** endc_m_m =
new TH2F*[kGains];
40 TH2F** barrel_r =
new TH2F*[kGains];
41 TH2F** endc_p_r =
new TH2F*[kGains];
42 TH2F** endc_m_r =
new TH2F*[kGains];
43 float mEBmin[kGains], mEEmin[kGains], mEBmax[kGains], mEEmax[kGains], rEBmin[kGains], rEEmin[kGains], rEBmax[kGains], rEEmax[kGains];
63 auto iov = iovs.front();
65 unsigned int run = std::get<0>(iov);
68 int thesign =
sign==1 ? 1:-1;
70 for (
int ieta = 0; ieta <
MAX_IETA; ieta++) {
71 for (
int iphi = 0; iphi <
MAX_IPHI; iphi++) {
74 if(
sign == 1) y = ieta;
75 float val = (*payload)[
id.rawId()].mult_x12;
76 barrel_m[0]->Fill(iphi, y, val);
77 if(val < mEBmin[0]) mEBmin[0] =
val;
78 if(val > mEBmax[0]) mEBmax[0] =
val;
79 val = (*payload)[
id.rawId()].shift_x12;
80 barrel_r[0]->Fill(iphi, y, val);
81 if(val < rEBmin[0]) rEBmin[0] =
val;
82 if(val > rEBmax[0]) rEBmax[0] =
val;
83 val = (*payload)[
id.rawId()].mult_x6;
84 barrel_m[1]->Fill(iphi, y, val);
85 if(val < mEBmin[1]) mEBmin[1] =
val;
86 if(val > mEBmax[1]) mEBmax[1] =
val;
87 val = (*payload)[
id.rawId()].shift_x6;
88 barrel_r[1]->Fill(iphi, y, val);
89 if(val < rEBmin[1]) rEBmin[1] =
val;
90 if(val > rEBmax[1]) rEBmax[1] =
val;
91 val = (*payload)[
id.rawId()].mult_x1;
92 barrel_m[2]->Fill(iphi, y, val);
93 if(val < mEBmin[2]) mEBmin[2] =
val;
94 if(val > mEBmax[2]) mEBmax[2] =
val;
95 val = (*payload)[
id.rawId()].shift_x1;
96 barrel_r[2]->Fill(iphi, y, val);
97 if(val < rEBmin[2]) rEBmin[2] =
val;
98 if(val > rEBmax[2]) rEBmax[2] =
val;
102 for (
int ix = 0; ix <
IX_MAX; ix++) {
103 for (
int iy = 0; iy <
IY_MAX; iy++) {
106 float val = (*payload)[
id.rawId()].mult_x12;
107 if (thesign==1) endc_p_m[0]->Fill(ix + 1, iy + 1, val);
108 else endc_m_m[0]->Fill(ix + 1, iy + 1, val);
109 if(val < mEEmin[0]) mEEmin[0] =
val;
110 if(val > mEEmax[0]) mEEmax[0] =
val;
111 val = (*payload)[
id.rawId()].shift_x12;
112 if (thesign==1) endc_p_r[0]->Fill(ix + 1, iy + 1, val);
113 else endc_m_r[0]->Fill(ix + 1, iy + 1, val);
114 if(val < rEEmin[0]) rEEmin[0] =
val;
115 if(val > rEEmax[0]) rEEmax[0] =
val;
116 val = (*payload)[
id.rawId()].mult_x6;
117 if (thesign==1) endc_p_m[1]->Fill(ix + 1, iy + 1, val);
118 else endc_m_m[1]->Fill(ix + 1, iy + 1, val);
119 if(val < mEEmin[1]) mEEmin[1] =
val;
120 if(val > mEEmax[1]) mEEmax[1] =
val;
121 val = (*payload)[
id.rawId()].shift_x6;
122 if (thesign==1) endc_p_r[1]->Fill(ix + 1, iy + 1, val);
123 else endc_m_r[1]->Fill(ix + 1, iy + 1, val);
124 if(val < rEEmin[1]) rEEmin[1] =
val;
125 if(val > rEEmax[1]) rEEmax[1] =
val;
126 val = (*payload)[
id.rawId()].mult_x1;
127 if (thesign==1) endc_p_m[2]->Fill(ix + 1, iy + 1, val);
128 else endc_m_m[2]->Fill(ix + 1, iy + 1, val);
129 if(val < mEEmin[2]) mEEmin[2] =
val;
130 if(val > mEEmax[2]) mEEmax[2] =
val;
131 val = (*payload)[
id.rawId()].shift_x1;
132 if (thesign==1) endc_p_r[2]->Fill(ix + 1, iy + 1, val);
133 else endc_m_r[2]->Fill(ix + 1, iy + 1, val);
134 if(val < rEEmin[2]) rEEmin[2] =
val;
135 if(val > rEEmax[2]) rEEmax[2] =
val;
145 gStyle->SetPalette(1);
146 gStyle->SetOptStat(0);
147 TCanvas
canvas(
"CC map",
"CC map",1200,1800);
151 t1.SetTextSize(0.05);
152 t1.DrawLatex(0.5, 0.96, Form(
"Ecal Gain TPGLinearizationConst, IOV %i", run));
154 float xmi[3] = {0.0 , 0.22, 0.78};
155 float xma[3] = {0.22, 0.78, 1.00};
156 TPad*** pad =
new TPad**[6];
157 for (
int gId = 0; gId < 6; gId++) {
158 pad[gId] =
new TPad*[3];
160 float yma = 0.94 - (0.16 * gId);
161 float ymi = yma - 0.14;
162 pad[gId][
obj] =
new TPad(Form(
"p_%i_%i",
obj, gId),Form(
"p_%i_%i",
obj, gId),
163 xmi[
obj], ymi, xma[obj], yma);
164 pad[gId][
obj]->Draw();
168 for (
int gId = 0; gId < kGains; gId++) {
170 DrawEE(endc_m_m[gId], mEEmin[gId], mEEmax[gId]);
171 pad[gId + 3][0]->cd();
172 DrawEE(endc_m_r[gId], rEEmin[gId], rEEmax[gId]);
174 DrawEB(barrel_m[gId], mEBmin[gId], mEBmax[gId]);
175 pad[gId + 3][1]->cd();
176 DrawEB(barrel_r[gId], rEBmin[gId], rEBmax[gId]);
178 DrawEE(endc_p_m[gId], mEEmin[gId], mEEmax[gId]);
179 pad[gId + 3][2]->cd();
180 DrawEE(endc_p_r[gId], rEEmin[gId], rEEmax[gId]);
184 canvas.SaveAs(ImageName.c_str());
199 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override{
200 TH2F** barrel_m =
new TH2F*[kGains];
201 TH2F** endc_p_m =
new TH2F*[kGains];
202 TH2F** endc_m_m =
new TH2F*[kGains];
203 TH2F** barrel_r =
new TH2F*[kGains];
204 TH2F** endc_p_r =
new TH2F*[kGains];
205 TH2F** endc_m_r =
new TH2F*[kGains];
206 float mEBmin[kGains], mEEmin[kGains], mEBmax[kGains], mEEmax[kGains], rEBmin[kGains], rEEmin[kGains], rEBmax[kGains], rEEmax[kGains];
209 barrel_m[
gainId] =
new TH2F(Form(
"EBm%i",
gainId), Form(
"EB mult_x%i ", gainValues[
gainId]), MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
210 endc_p_m[
gainId] =
new TH2F(Form(
"EE+m%i",
gainId), Form(
"EE+ mult_x%i", gainValues[
gainId]), IX_MAX,
IX_MIN, IX_MAX + 1, IY_MAX,
IY_MIN, IY_MAX + 1);
211 endc_m_m[
gainId] =
new TH2F(Form(
"EE-m%i",
gainId), Form(
"EE- mult_x%i", gainValues[
gainId]), IX_MAX,
IX_MIN, IX_MAX + 1, IY_MAX,
IY_MIN, IY_MAX + 1);
212 barrel_r[
gainId] =
new TH2F(Form(
"EBr%i",
gainId), Form(
"EB shift_x%i", gainValues[
gainId]), MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
213 endc_p_r[
gainId] =
new TH2F(Form(
"EE+r%i",
gainId), Form(
"EE+ shift_x%i", gainValues[
gainId]), IX_MAX,
IX_MIN, IX_MAX + 1, IY_MAX,
IY_MIN, IY_MAX + 1);
214 endc_m_r[
gainId] =
new TH2F(Form(
"EE-r%i",
gainId), Form(
"EE- shift_x%i", gainValues[
gainId]), IX_MAX,
IX_MIN, IX_MAX + 1, IY_MAX,
IY_MIN, IY_MAX + 1);
225 unsigned int run[2], irun = 0;
227 for (
auto const & iov: iovs) {
228 std::shared_ptr<EcalTPGLinearizationConst> payload = fetchPayload( std::get<1>(iov) );
229 run[irun] = std::get<0>(iov);
232 int thesign =
sign==1 ? 1:-1;
234 for (
int ieta = 0; ieta <
MAX_IETA; ieta++) {
235 for (
int iphi = 0; iphi <
MAX_IPHI; iphi++) {
237 int hashindex =
id.hashedIndex();
239 if(
sign == 1) y = ieta;
240 float val = (*payload)[
id.rawId()].mult_x12;
242 mEB[0][hashindex] =
val;
245 float diff = val - mEB[0][hashindex];
246 barrel_m[0]->Fill(iphi, y, diff);
247 if(diff < mEBmin[0]) mEBmin[0] =
diff;
248 if(diff > mEBmax[0]) mEBmax[0] =
diff;
250 val = (*payload)[
id.rawId()].shift_x12;
252 rEB[0][hashindex] =
val;
255 float diff = val - rEB[0][hashindex];
256 barrel_r[0]->Fill(iphi, y, diff);
257 if(diff < rEBmin[0]) rEBmin[0] =
diff;
258 if(diff > rEBmax[0]) rEBmax[0] =
diff;
260 val = (*payload)[
id.rawId()].mult_x6;
262 mEB[1][hashindex] =
val;
265 float diff = val - mEB[1][hashindex];
266 barrel_m[1]->Fill(iphi, y, diff);
267 if(diff < mEBmin[1]) mEBmin[1] =
diff;
268 if(diff > mEBmax[1]) mEBmax[1] =
diff;
270 val = (*payload)[
id.rawId()].shift_x6;
272 rEB[1][hashindex] =
val;
275 float diff = val - rEB[1][hashindex];
276 barrel_r[1]->Fill(iphi, y, diff);
277 if(diff < rEBmin[1]) rEBmin[1] =
diff;
278 if(diff > rEBmax[1]) rEBmax[1] =
diff;
280 val = (*payload)[
id.rawId()].mult_x1;
282 mEB[2][hashindex] =
val;
285 float diff = val - mEB[2][hashindex];
286 barrel_m[2]->Fill(iphi, y, diff);
287 if(diff < mEBmin[2]) mEBmin[2] =
diff;
288 if(diff > mEBmax[2]) mEBmax[2] =
diff;
290 val = (*payload)[
id.rawId()].shift_x1;
292 rEB[2][hashindex] =
val;
295 float diff = val - rEB[2][hashindex];
296 barrel_r[2]->Fill(iphi, y, diff);
297 if(diff < rEBmin[2]) rEBmin[2] =
diff;
298 if(diff > rEBmax[2]) rEBmax[2] =
diff;
303 for (
int ix = 0; ix <
IX_MAX; ix++) {
304 for (
int iy = 0; iy <
IY_MAX; iy++) {
307 int hashindex =
id.hashedIndex();
308 float val = (*payload)[
id.rawId()].mult_x12;
310 mEE[0][hashindex] =
val;
313 float diff = val - mEE[0][hashindex];
314 if (thesign==1) endc_p_m[0]->Fill(ix + 1, iy + 1, diff);
315 else endc_m_m[0]->Fill(ix + 1, iy + 1, diff);
316 if(diff < mEEmin[0]) mEEmin[0] =
diff;
317 if(diff > mEEmax[0]) mEEmax[0] =
diff;
319 val = (*payload)[
id.rawId()].shift_x12;
321 rEE[0][hashindex] =
val;
324 float diff = val - rEE[0][hashindex];
325 if (thesign==1) endc_p_r[0]->Fill(ix + 1, iy + 1, diff);
326 else endc_m_r[0]->Fill(ix + 1, iy + 1, diff);
327 if(diff < rEEmin[0]) rEEmin[0] =
diff;
328 if(diff > rEEmax[0]) rEEmax[0] =
diff;
330 val = (*payload)[
id.rawId()].mult_x6;
332 mEE[1][hashindex] =
val;
335 float diff = val - mEE[1][hashindex];
336 if (thesign==1) endc_p_m[1]->Fill(ix + 1, iy + 1, diff);
337 else endc_m_m[1]->Fill(ix + 1, iy + 1, diff);
338 if(diff < mEEmin[1]) mEEmin[1] =
diff;
339 if(diff > mEEmax[1]) mEEmax[1] =
diff;
341 val = (*payload)[
id.rawId()].shift_x6;
343 rEE[1][hashindex] =
val;
346 float diff = val - rEE[1][hashindex];
347 if (thesign==1) endc_p_r[1]->Fill(ix + 1, iy + 1, diff);
348 else endc_m_r[1]->Fill(ix + 1, iy + 1, diff);
349 if(diff < rEEmin[1]) rEEmin[1] =
diff;
350 if(diff > rEEmax[1]) rEEmax[1] =
diff;
352 val = (*payload)[
id.rawId()].mult_x1;
354 mEE[2][hashindex] =
val;
357 float diff = val - mEE[2][hashindex];
358 if (thesign==1) endc_p_m[2]->Fill(ix + 1, iy + 1, diff);
359 else endc_m_m[2]->Fill(ix + 1, iy + 1, diff);
360 if(diff < mEEmin[2]) mEEmin[2] =
diff;
361 if(diff > mEEmax[2]) mEEmax[2] =
diff;
363 val = (*payload)[
id.rawId()].shift_x1;
365 rEE[2][hashindex] =
val;
368 float diff = val - rEE[2][hashindex];
369 if (thesign==1) endc_p_r[2]->Fill(ix + 1, iy + 1, diff);
370 else endc_m_r[2]->Fill(ix + 1, iy + 1, diff);
371 if(diff < rEEmin[2]) rEEmin[2] =
diff;
372 if(diff > rEEmax[2]) rEEmax[2] =
diff;
383 gStyle->SetPalette(1);
384 gStyle->SetOptStat(0);
385 TCanvas
canvas(
"CC map",
"CC map",1200,1800);
389 t1.SetTextSize(0.05);
390 t1.DrawLatex(0.5, 0.96, Form(
"Ecal TPGLinearizationConst, IOV %i - %i", run[1], run[0]));
392 float xmi[3] = {0.0 , 0.22, 0.78};
393 float xma[3] = {0.22, 0.78, 1.00};
394 TPad*** pad =
new TPad**[6];
395 for (
int gId = 0; gId < 6; gId++) {
396 pad[gId] =
new TPad*[3];
398 float yma = 0.94 - (0.16 * gId);
399 float ymi = yma - 0.14;
400 pad[gId][
obj] =
new TPad(Form(
"p_%i_%i",
obj, gId),Form(
"p_%i_%i",
obj, gId),
401 xmi[
obj], ymi, xma[obj], yma);
402 pad[gId][
obj]->Draw();
406 for (
int gId = 0; gId < kGains; gId++) {
408 DrawEE(endc_m_m[gId], mEEmin[gId], mEEmax[gId]);
409 pad[gId + 3][0]->cd();
410 DrawEE(endc_m_r[gId], rEEmin[gId], rEEmax[gId]);
412 DrawEB(barrel_m[gId], mEBmin[gId], mEBmax[gId]);
413 pad[gId + 3][1]->cd();
414 DrawEB(barrel_r[gId], rEBmin[gId], rEBmax[gId]);
416 DrawEE(endc_p_m[gId], mEEmin[gId], mEEmax[gId]);
417 pad[gId + 3][2]->cd();
418 DrawEE(endc_p_r[gId], rEEmin[gId], rEEmax[gId]);
422 canvas.SaveAs(ImageName.c_str());
int gainId(sample_type sample)
get the gainId (2 bits)
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
void DrawEE(TH2F *endc, float min, float max)
void DrawEB(TH2F *ebmap, float min, float max)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
virtual bool fill(const std::vector< std::tuple< cond::Time_t, cond::Hash > > &iovs)=0
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
void setSingleIov(bool flag)