File indexing completed on 2025-08-05 08:20:34
0001 #include "/phenix/u/shlim/Style.h"
0002
0003 void Draw(const int runnumber=28, const int segnumber=200){
0004
0005 int bPOST_ALIGN = false;
0006 int bPRE_ALIGN = false;
0007
0008 float z_min = 200;
0009 float z_max = 800;
0010 float x_min = 200;
0011 float x_max = 500;
0012
0013 gStyle->SetOptStat(0);
0014
0015 const int nColor[4] = {1, 2, 4, 8};
0016
0017 TFile *infile = new TFile(Form("MvtxQAHisto-%08d-%04d.root",runnumber,segnumber),"read");
0018
0019 TH2F *h2d_hit[4];
0020 TH2F *h2d_hit_trk[4];
0021 TH1F *h1d_hit_per_evt[4];
0022 TH1F *h1d_hit_x[4];
0023 TH1F *h1d_hit_y[4];
0024 TH1F *h1d_hit_trk_x[4];
0025 TH1F *h1d_hit_trk_y[4];
0026
0027 TH1F *h1d_clus_size_x[4];
0028 TH1F *h1d_clus_size_z[4];
0029 TH2F *h2d_clus[4];
0030 TH1F *h1d_clus_per_evt[4];
0031
0032 TH1F *h1d_clus_res_x[4];
0033 TH1F *h1d_clus_res_z[4];
0034 TProfile *h1p_clus_res_x[4];
0035 TProfile *h1p_clus_res_z[4];
0036
0037 TF1 *f1p_clus_res_x[4];
0038 TF1 *f1p_clus_res_z[4];
0039
0040
0041 for (int ichip=0; ichip<4; ichip++){
0042 h2d_hit[ichip] = (TH2F*)infile->Get(Form("h2d_hit_chip%d",ichip));
0043 h2d_hit_trk[ichip] = (TH2F*)infile->Get(Form("h2d_hit_trk_chip%d",ichip));
0044 h1d_hit_per_evt[ichip] = (TH1F*)infile->Get(Form("h1d_hit_per_evt_chip%d",ichip));
0045
0046 h1d_hit_x[ichip] = (TH1F*)h2d_hit[ichip]->ProjectionX(Form("h1d_hit_x_chip%d",ichip));
0047 h1d_hit_y[ichip] = (TH1F*)h2d_hit[ichip]->ProjectionY(Form("h1d_hit_y_chip%d",ichip));
0048 h1d_hit_x[ichip]->SetLineColor(1);
0049 h1d_hit_y[ichip]->SetLineColor(1);
0050
0051 h1d_hit_trk_x[ichip] = (TH1F*)h2d_hit_trk[ichip]->ProjectionX(Form("h1d_hit_trk_x_chip%d",ichip));
0052 h1d_hit_trk_y[ichip] = (TH1F*)h2d_hit_trk[ichip]->ProjectionY(Form("h1d_hit_trk_y_chip%d",ichip));
0053 h1d_hit_trk_x[ichip]->SetLineColor(1);
0054 h1d_hit_trk_y[ichip]->SetLineColor(1);
0055
0056 h2d_clus[ichip] = (TH2F*)infile->Get(Form("h2d_clus_chip%d",ichip));
0057
0058 h1d_clus_size_x[ichip] = (TH1F*)infile->Get(Form("h1d_clus_size_x_chip%d",ichip));
0059 h1d_clus_size_z[ichip] = (TH1F*)infile->Get(Form("h1d_clus_size_z_chip%d",ichip));
0060
0061 h1d_clus_per_evt[ichip] = (TH1F*)infile->Get(Form("h1d_clus_per_evt_chip%d",ichip));
0062
0063 h1d_clus_size_x[ichip]->SetLineColor(1);
0064 h1d_clus_size_z[ichip]->SetLineColor(2);
0065
0066 h1d_clus_res_x[ichip] = (TH1F*)infile->Get(Form("h1d_clus_res_x_chip%d",ichip));
0067 h1d_clus_res_z[ichip] = (TH1F*)infile->Get(Form("h1d_clus_res_z_chip%d",ichip));
0068
0069 h1d_clus_res_x[ichip]->SetLineColor(nColor[ichip]);
0070 h1d_clus_res_z[ichip]->SetLineColor(nColor[ichip]);
0071
0072 h1p_clus_res_x[ichip] = (TProfile*)infile->Get(Form("h1p_clus_res_x_chip%d",ichip));
0073 h1p_clus_res_z[ichip] = (TProfile*)infile->Get(Form("h1p_clus_res_z_chip%d",ichip));
0074
0075 h1p_clus_res_x[ichip]->SetLineColor(nColor[ichip]);
0076 h1p_clus_res_z[ichip]->SetLineColor(nColor[ichip]);
0077 }
0078
0079 TH1F *h1d_clus_eff = (TH1F*)infile->Get("h1d_clus_eff");
0080 TH1F *h1d_clus_associated = (TH1F*)infile->Get("h1d_clus_associated");
0081
0082 TCanvas *c0 = new TCanvas("c0","c0",1.1*2*400,400);
0083 c0->Divide(2,1);
0084
0085 c0->cd(1);
0086 SetPadStyle();
0087 gPad->SetLogy();
0088
0089 htmp = (TH1F*)gPad->DrawFrame(0,1,50,1.5*h1d_hit_per_evt[0]->GetMaximum());
0090 SetHistoStyle();
0091
0092 for (int ichip=0; ichip<4; ichip++){
0093 h1d_hit_per_evt[ichip]->SetLineColor(nColor[ichip]);
0094 h1d_hit_per_evt[ichip]->SetLineWidth(2);
0095 h1d_hit_per_evt[ichip]->Draw("same");
0096 }
0097
0098 c0->cd(2);
0099 SetPadStyle();
0100 gPad->SetLogy();
0101
0102 htmp = (TH1F*)gPad->DrawFrame(0,1,10,1.5*h1d_clus_per_evt[0]->GetMaximum());
0103 SetHistoStyle();
0104
0105 for (int ichip=0; ichip<4; ichip++){
0106 h1d_clus_per_evt[ichip]->SetLineColor(nColor[ichip]);
0107 h1d_clus_per_evt[ichip]->SetLineWidth(2);
0108 h1d_clus_per_evt[ichip]->Draw("same");
0109 }
0110
0111
0112
0113
0114 ofstream fpre;
0115 if ( bPRE_ALIGN ){
0116 char fname[300];
0117 sprintf(fname,"beamcenter/beamcenter_%08d.txt",runnumber);
0118 fpre.open(fname);
0119 }
0120
0121 TCanvas *c1 = new TCanvas("c1","c1",150*1.1*3,150*4);
0122 c1->Divide(3,4);
0123
0124 for (int ichip=0; ichip<4; ichip++){
0125
0126 c1->cd(3*ichip+1);
0127 SetPadStyle();
0128 gPad->SetLogz();
0129
0130 htmp = (TH1F*)h2d_hit[ichip];
0131 SetHistoStyle();
0132
0133 htmp->Draw("col2");
0134
0135 c1->cd(3*ichip+2);
0136 SetPadStyle();
0137
0138 htmp = (TH1F*)h1d_hit_x[ichip];
0139 SetHistoStyle();
0140 htmp->Draw();
0141
0142 TF1 *fx = new TF1("fx","gaus",z_min,z_max);
0143 htmp->Fit(fx,"R0Q");
0144
0145
0146 fx->SetRange(fx->GetParameter(1)-fx->GetParameter(2), fx->GetParameter(1)+fx->GetParameter(2));
0147 htmp->Fit(fx,"R0Q");
0148 fx->Draw("same");
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162 c1->cd(3*ichip+3);
0163 SetPadStyle();
0164
0165 htmp = (TH1F*)h1d_hit_y[ichip];
0166 SetHistoStyle();
0167 htmp->Draw();
0168
0169 TF1 *fy = new TF1("fy","gaus",x_min,x_max);
0170 htmp->Fit(fy,"R0Q");
0171
0172
0173 fy->SetRange(fy->GetParameter(1)-fy->GetParameter(2), fy->GetParameter(1)+fy->GetParameter(2));
0174 htmp->Fit(fy,"R0Q");
0175 fy->Draw("same");
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189 double offset_xx = fx->GetParameter(1);
0190 double offset_yy = fy->GetParameter(1);
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201 if ( bPRE_ALIGN ){
0202 fpre << ichip << " 0 " << ichip << " " << offset_yy << " " << -2.2*ichip/(28e-4) << " " << offset_xx << endl;
0203 cout << ichip << " 0 " << ichip << " " << offset_yy << " " << -2.2*ichip/(28e-4) << " " << offset_xx << endl;
0204 }
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217 }
0218
0219 if ( bPRE_ALIGN ){
0220 fpre.close();
0221 }
0222
0223 TCanvas *c3 = new TCanvas("c3","c3",200*1.1*2,200*2);
0224 c3->Divide(2,2);
0225
0226 for (int ichip=0; ichip<4; ichip++){
0227 c3->cd(ichip+1);
0228 SetPadStyle();
0229 gPad->SetLogy();
0230
0231 htmp = (TH1F*)gPad->DrawFrame(0,5,10,1.5*h1d_clus_size_x[ichip]->GetMaximum());
0232 SetHistoStyle();
0233
0234 h1d_clus_size_x[ichip]->Draw("same");
0235 h1d_clus_size_z[ichip]->Draw("same");
0236
0237
0238 }
0239
0240 TCanvas *c4 = new TCanvas("c4","c4",300*1.1*2,300*2);
0241 c4->Divide(2,2);
0242
0243 c4->cd(1);
0244 SetPadStyle();
0245 gPad->SetLogy();
0246
0247 htmp = (TH1F*)gPad->DrawFrame(-6,1,6,1.5*h1d_clus_res_z[0]->GetMaximum());
0248 SetHistoStyle("dz (pixel, 28 #mum)");
0249
0250 for (int ichip=0; ichip<4; ichip++){
0251 h1d_clus_res_z[ichip]->SetLineWidth(2);
0252 h1d_clus_res_z[ichip]->Draw("same");
0253 }
0254
0255 c4->cd(2);
0256 SetPadStyle();
0257
0258
0259 htmp = (TH1F*)gPad->DrawFrame(0,-2.5,1024,+2.5);
0260 SetHistoStyle();
0261 SetHistoStyle("Column index","dz (pixel, 28 #mum)");
0262
0263 for (int ichip=0; ichip<4; ichip++){
0264 h1p_clus_res_z[ichip]->Draw("same");
0265
0266 f1p_clus_res_z[ichip] = new TF1(Form("f1p_clus_res_z_%d",ichip),"pol1",z_min,z_max);
0267 h1p_clus_res_z[ichip]->Fit(f1p_clus_res_z[ichip],"R0Q");
0268 f1p_clus_res_z[ichip]->SetLineColor(nColor[ichip]);
0269 if ( bPOST_ALIGN )
0270 f1p_clus_res_z[ichip]->Draw("same");
0271 }
0272
0273 c4->cd(3);
0274 SetPadStyle();
0275 gPad->SetLogy();
0276
0277 htmp = (TH1F*)gPad->DrawFrame(-6,1,6,1.5*h1d_clus_res_x[0]->GetMaximum());
0278 SetHistoStyle("dx (pixel, 28 #mum)");
0279
0280 for (int ichip=0; ichip<4; ichip++){
0281 h1d_clus_res_x[ichip]->SetLineWidth(2);
0282 h1d_clus_res_x[ichip]->Draw("same");
0283 }
0284
0285 c4->cd(4);
0286 SetPadStyle();
0287
0288
0289 htmp = (TH1F*)gPad->DrawFrame(0,-2.5,512,+2.5);
0290 SetHistoStyle("Row index","dx (pixel, 28 #mum)");
0291
0292 for (int ichip=0; ichip<4; ichip++){
0293 h1p_clus_res_x[ichip]->Draw("same");
0294
0295 f1p_clus_res_x[ichip] = new TF1(Form("f1p_clus_res_x_%d",ichip),"pol1",x_min,x_max);
0296 h1p_clus_res_x[ichip]->Fit(f1p_clus_res_x[ichip],"R0Q");
0297 f1p_clus_res_x[ichip]->SetLineColor(nColor[ichip]);
0298 if ( bPOST_ALIGN )
0299 f1p_clus_res_x[ichip]->Draw("same");
0300 }
0301
0302 if ( bPOST_ALIGN ){
0303 char fname[300];
0304 sprintf(fname,"beamcenter/beamcenter_%08d.txt",runnumber);
0305 ifstream fpar;
0306 fpar.open(fname);
0307 int tmp_layer, tmp_stave, tmp_chip;
0308 double tmp_xx, tmp_yy, tmp_zz;
0309
0310 double par_xx[4], par_yy[4], par_zz[4];
0311
0312 while ( fpar >> tmp_layer >> tmp_stave >> tmp_chip >> tmp_xx >> tmp_yy >> tmp_zz ){
0313 par_xx[tmp_chip] = tmp_xx;
0314 par_yy[tmp_chip] = tmp_yy;
0315 par_zz[tmp_chip] = tmp_zz;
0316 }
0317 fpar.close();
0318
0319 ofstream fpar_out;
0320 sprintf(fname,"beamcenter/beamcenter_%08d.txt",runnumber);
0321 fpar_out.open(fname);
0322
0323 for (int ichip=0; ichip<4; ichip++){
0324 cout
0325 << ichip << " "
0326 << "0 "
0327 << ichip << " "
0328 << par_xx[ichip] + (f1p_clus_res_x[ichip]->Eval(par_xx[0]) - f1p_clus_res_x[0]->Eval(par_xx[0])) << " "
0329 << par_yy[ichip] << " "
0330 << par_zz[ichip] + (f1p_clus_res_z[ichip]->Eval(par_zz[0]) - f1p_clus_res_z[0]->Eval(par_zz[0]))
0331 << endl;
0332
0333 fpar_out
0334 << ichip << " "
0335 << "0 "
0336 << ichip << " "
0337 << par_xx[ichip] + (f1p_clus_res_x[ichip]->Eval(par_xx[0]) - f1p_clus_res_x[0]->Eval(par_xx[0])) << " "
0338 << par_yy[ichip] << " "
0339 << par_zz[ichip] + (f1p_clus_res_z[ichip]->Eval(par_zz[0]) - f1p_clus_res_z[0]->Eval(par_zz[0]))
0340 << endl;
0341 }
0342 fpar_out.close();
0343 }
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404
0405
0406
0407
0408
0409
0410
0411
0412
0413
0414
0415 }