17 #include "TPaveStats.h" 32 EcalTPGPedestalsPlot() :
cond::payloadInspector::PlotImage<
EcalTPGPedestals>(
"ECAL Gain Ratios - map ") {
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];
53 auto iov = iovs.front();
55 unsigned int run = std::get<0>(iov);
58 int thesign =
sign==1 ? 1:-1;
60 for (
int ieta = 0; ieta <
MAX_IETA; ieta++) {
61 for (
int iphi = 0; iphi <
MAX_IPHI; iphi++) {
64 if(
sign == 1) y = ieta;
65 float val = (*payload)[
id.rawId()].mean_x12;
66 barrel_m[0]->Fill(iphi, y, val);
67 if(val < mEBmin[0]) mEBmin[0] =
val;
68 if(val > mEBmax[0]) mEBmax[0] =
val;
69 val = (*payload)[
id.rawId()].mean_x6;
70 barrel_m[1]->Fill(iphi, y, val);
71 if(val < mEBmin[1]) mEBmin[1] =
val;
72 if(val > mEBmax[1]) mEBmax[1] =
val;
73 val = (*payload)[
id.rawId()].mean_x1;
74 barrel_m[2]->Fill(iphi, y, val);
75 if(val < mEBmin[2]) mEBmin[2] =
val;
76 if(val > mEBmax[2]) mEBmax[2] =
val;
80 for (
int ix = 0; ix <
IX_MAX; ix++) {
81 for (
int iy = 0; iy <
IY_MAX; iy++) {
84 float val = (*payload)[
id.rawId()].mean_x12;
85 if (thesign==1) endc_p_m[0]->Fill(ix + 1, iy + 1, val);
86 else endc_m_m[0]->Fill(ix + 1, iy + 1, val);
87 if(val < mEEmin[0]) mEEmin[0] =
val;
88 if(val > mEEmax[0]) mEEmax[0] =
val;
89 val = (*payload)[
id.rawId()].mean_x6;
90 if (thesign==1) endc_p_m[1]->Fill(ix + 1, iy + 1, val);
91 else endc_m_m[1]->Fill(ix + 1, iy + 1, val);
92 if(val < mEEmin[1]) mEEmin[1] =
val;
93 if(val > mEEmax[1]) mEEmax[1] =
val;
94 val = (*payload)[
id.rawId()].mean_x1;
95 if (thesign==1) endc_p_m[2]->Fill(ix + 1, iy + 1, val);
96 else endc_m_m[2]->Fill(ix + 1, iy + 1, val);
97 if(val < mEEmin[2]) mEEmin[2] =
val;
98 if(val > mEEmax[2]) mEEmax[2] =
val;
108 gStyle->SetPalette(1);
109 gStyle->SetOptStat(0);
110 TCanvas
canvas(
"CC map",
"CC map",1200,900);
114 t1.SetTextSize(0.05);
115 t1.DrawLatex(0.5, 0.96, Form(
"Ecal Gain TPGPedestals, IOV %i", run));
117 float xmi[3] = {0.0 , 0.22, 0.78};
118 float xma[3] = {0.22, 0.78, 1.00};
119 TPad*** pad =
new TPad**[
kGains];
120 for (
int gId = 0; gId <
kGains; gId++) {
121 pad[gId] =
new TPad*[3];
123 float yma = 0.94 - (0.32 * gId);
124 float ymi = yma - 0.30;
125 pad[gId][
obj] =
new TPad(Form(
"p_%i_%i",
obj, gId),Form(
"p_%i_%i",
obj, gId),
126 xmi[
obj], ymi, xma[obj], yma);
127 pad[gId][
obj]->Draw();
131 for (
int gId = 0; gId <
kGains; gId++) {
133 DrawEE(endc_m_m[gId], mEEmin[gId], mEEmax[gId]);
135 DrawEB(barrel_m[gId], mEBmin[gId], mEBmax[gId]);
137 DrawEE(endc_p_m[gId], mEEmin[gId], mEEmax[gId]);
141 canvas.SaveAs(ImageName.c_str());
152 EcalTPGPedestalsDiff() :
cond::payloadInspector::PlotImage<
EcalTPGPedestals>(
"ECAL Gain Ratios difference") {
156 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override{
157 TH2F** barrel_m =
new TH2F*[
kGains];
158 TH2F** endc_p_m =
new TH2F*[
kGains];
159 TH2F** endc_m_m =
new TH2F*[
kGains];
163 barrel_m[
gainId] =
new TH2F(Form(
"EBm%i",
gainId), Form(
"EB mean_x%i ", gainValues[
gainId]), MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
164 endc_p_m[
gainId] =
new TH2F(Form(
"EE+m%i",
gainId), Form(
"EE+ mean_x%i", gainValues[
gainId]), IX_MAX,
IX_MIN, IX_MAX + 1, IY_MAX,
IY_MIN, IY_MAX + 1);
165 endc_m_m[
gainId] =
new TH2F(Form(
"EE-m%i",
gainId), Form(
"EE- mean_x%i", gainValues[
gainId]), IX_MAX,
IX_MIN, IX_MAX + 1, IY_MAX,
IY_MIN, IY_MAX + 1);
172 unsigned int run[2], irun = 0;
174 for (
auto const & iov: iovs) {
175 std::shared_ptr<EcalTPGPedestals> payload = fetchPayload( std::get<1>(iov) );
176 run[irun] = std::get<0>(iov);
179 int thesign =
sign==1 ? 1:-1;
181 for (
int ieta = 0; ieta <
MAX_IETA; ieta++) {
182 for (
int iphi = 0; iphi <
MAX_IPHI; iphi++) {
184 int hashindex =
id.hashedIndex();
186 if(
sign == 1) y = ieta;
187 float val = (*payload)[
id.rawId()].mean_x12;
189 mEB[0][hashindex] =
val;
192 float diff = val - mEB[0][hashindex];
193 barrel_m[0]->Fill(iphi, y, diff);
194 if(diff < mEBmin[0]) mEBmin[0] =
diff;
195 if(diff > mEBmax[0]) mEBmax[0] =
diff;
197 val = (*payload)[
id.rawId()].mean_x6;
199 mEB[1][hashindex] =
val;
202 float diff = val - mEB[1][hashindex];
203 barrel_m[1]->Fill(iphi, y, diff);
204 if(diff < mEBmin[1]) mEBmin[1] =
diff;
205 if(diff > mEBmax[1]) mEBmax[1] =
diff;
207 val = (*payload)[
id.rawId()].mean_x1;
209 mEB[2][hashindex] =
val;
212 float diff = val - mEB[2][hashindex];
213 barrel_m[2]->Fill(iphi, y, diff);
214 if(diff < mEBmin[2]) mEBmin[2] =
diff;
215 if(diff > mEBmax[2]) mEBmax[2] =
diff;
220 for (
int ix = 0; ix <
IX_MAX; ix++) {
221 for (
int iy = 0; iy <
IY_MAX; iy++) {
224 int hashindex =
id.hashedIndex();
225 float val = (*payload)[
id.rawId()].mean_x12;
227 mEE[0][hashindex] =
val;
230 float diff = val - mEE[0][hashindex];
231 if (thesign==1) endc_p_m[0]->Fill(ix + 1, iy + 1, diff);
232 else endc_m_m[0]->Fill(ix + 1, iy + 1, diff);
233 if(diff < mEEmin[0]) mEEmin[0] =
diff;
234 if(diff > mEEmax[0]) mEEmax[0] =
diff;
236 val = (*payload)[
id.rawId()].mean_x6;
238 mEE[1][hashindex] =
val;
241 float diff = val - mEE[1][hashindex];
242 if (thesign==1) endc_p_m[1]->Fill(ix + 1, iy + 1, diff);
243 else endc_m_m[1]->Fill(ix + 1, iy + 1, diff);
244 if(diff < mEEmin[1]) mEEmin[1] =
diff;
245 if(diff > mEEmax[1]) mEEmax[1] =
diff;
247 val = (*payload)[
id.rawId()].mean_x1;
249 mEE[2][hashindex] =
val;
252 float diff = val - mEE[2][hashindex];
253 if (thesign==1) endc_p_m[2]->Fill(ix + 1, iy + 1, diff);
254 else endc_m_m[2]->Fill(ix + 1, iy + 1, diff);
255 if(diff < mEEmin[2]) mEEmin[2] =
diff;
256 if(diff > mEEmax[2]) mEEmax[2] =
diff;
267 gStyle->SetPalette(1);
268 gStyle->SetOptStat(0);
269 TCanvas
canvas(
"CC map",
"CC map",1200, 900);
273 t1.SetTextSize(0.05);
274 t1.DrawLatex(0.5, 0.96, Form(
"Ecal TPGPedestals, IOV %i - %i", run[1], run[0]));
276 float xmi[3] = {0.0 , 0.22, 0.78};
277 float xma[3] = {0.22, 0.78, 1.00};
278 TPad*** pad =
new TPad**[
kGains];
279 for (
int gId = 0; gId <
kGains; gId++) {
280 pad[gId] =
new TPad*[3];
282 float yma = 0.94 - (0.32 * gId);
283 float ymi = yma - 0.30;
284 pad[gId][
obj] =
new TPad(Form(
"p_%i_%i",
obj, gId),Form(
"p_%i_%i",
obj, gId),
285 xmi[
obj], ymi, xma[obj], yma);
286 pad[gId][
obj]->Draw();
290 for (
int gId = 0; gId <
kGains; gId++) {
292 DrawEE(endc_m_m[gId], mEEmin[gId], mEEmax[gId]);
294 DrawEB(barrel_m[gId], mEBmin[gId], mEBmax[gId]);
296 DrawEE(endc_p_m[gId], mEEmin[gId], mEEmax[gId]);
300 canvas.SaveAs(ImageName.c_str());
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
const Int_t gainValues[kGains]
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)
constexpr int gainId(sample_type sample)
get the gainId (2 bits)