File indexing completed on 2025-08-05 08:20:34
0001 #include "/phenix/u/shlim/Style.h"
0002
0003 void Draw_hotmap(const int runnumber=28, const int segnumber=100){
0004
0005 gStyle->SetOptStat(0);
0006
0007 const int nColor[4] = {1, 2, 4, 8};
0008
0009 bool bWRITE = true;
0010 double cut_val = 2.0e-4;
0011
0012 if ( runnumber==41 || runnumber==42 || runnumber==44 || runnumber==49 || runnumber==50 || runnumber==51 || runnumber==52
0013 || runnumber==78 || runnumber==79 || runnumber==82 ) cut_val = 9.0e-4;
0014 else if ( runnumber==43 || runnumber==77 || (runnumber>=126 && runnumber<=127) ) cut_val = 2.0e-3;
0015 else if ( runnumber==46 || runnumber==47 || runnumber==48 || runnumber==98 ) cut_val = 1.0e-3;
0016 else if ( runnumber==53 || runnumber==54 || (runnumber>=56 && runnumber<=65) || runnumber==97 || runnumber==116 ) cut_val = 4.0e-4;
0017 else if ( runnumber==121 ) cut_val = 1e10;
0018
0019 TFile *infile = new TFile(Form("MvtxQAHisto-%08d-%04d.root",runnumber,segnumber),"read");
0020
0021 TH2F *h2d_hit[4];
0022 TH2F *h2d_hit_trk[4];
0023 TH1F *h1d_hit_per_evt[4];
0024 TH1F *h1d_hit_x[4];
0025 TH1F *h1d_hit_y[4];
0026 TH1F *h1d_hit_trk_x[4];
0027 TH1F *h1d_hit_trk_y[4];
0028
0029 TH1F *h1d_rate[4];
0030 TH2F *h2d_hit_cut[4];
0031
0032 int nbad[4] = {0};
0033
0034 for (int ichip=0; ichip<4; ichip++){
0035 h2d_hit[ichip] = (TH2F*)infile->Get(Form("h2d_hit_chip%d",ichip));
0036 h2d_hit_trk[ichip] = (TH2F*)infile->Get(Form("h2d_hit_trk_chip%d",ichip));
0037 h1d_hit_per_evt[ichip] = (TH1F*)infile->Get(Form("h1d_hit_per_evt_chip%d",ichip));
0038
0039 h1d_hit_x[ichip] = (TH1F*)h2d_hit[ichip]->ProjectionX(Form("h1d_hit_x_chip%d",ichip));
0040 h1d_hit_y[ichip] = (TH1F*)h2d_hit[ichip]->ProjectionY(Form("h1d_hit_y_chip%d",ichip));
0041 h1d_hit_x[ichip]->SetLineColor(1);
0042 h1d_hit_y[ichip]->SetLineColor(1);
0043
0044 h1d_hit_trk_x[ichip] = (TH1F*)h2d_hit_trk[ichip]->ProjectionX(Form("h1d_hit_trk_x_chip%d",ichip));
0045 h1d_hit_trk_y[ichip] = (TH1F*)h2d_hit_trk[ichip]->ProjectionY(Form("h1d_hit_trk_y_chip%d",ichip));
0046 h1d_hit_trk_x[ichip]->SetLineColor(1);
0047 h1d_hit_trk_y[ichip]->SetLineColor(1);
0048
0049 h1d_rate[ichip] = new TH1F(Form("h1d_rate_chip%d",ichip),"",5000,0.000005,0.1);
0050 }
0051
0052 h1d_hit_norm = (TH1F*)infile->Get("h1d_hit_norm");
0053
0054 ofstream fpar;
0055
0056 if ( bWRITE ){
0057 char fname[300];
0058 sprintf(fname,"hotmap/hotmap_testbeam_%08d.txt",runnumber);
0059
0060 fpar.open(fname);
0061 }
0062
0063 TCanvas *c1 = new TCanvas("c1","c1",150*1.1*4,150*4);
0064 c1->Divide(4,4);
0065
0066 for (int ichip=0; ichip<4; ichip++){
0067
0068
0069 double norm = h1d_hit_norm->Integral();
0070 cout << "CHIP: " << ichip << ", EVT: " << norm << endl;
0071
0072 c1->cd(4*ichip+1);
0073 SetPadStyle();
0074 gPad->SetLogz();
0075
0076 htmp = (TH1F*)h2d_hit[ichip];
0077 SetHistoStyle();
0078 htmp->GetXaxis()->SetLabelSize(0.08);
0079
0080 htmp->Draw("col2");
0081
0082 h2d_hit_cut[ichip] = (TH2F*)h2d_hit[ichip]->Clone(Form("h2d_hit_cut_%d",ichip));
0083
0084 for (int ix=0; ix<h1d_hit_x[ichip]->GetNbinsX(); ix++){
0085 for (int iy=0; iy<h1d_hit_y[ichip]->GetNbinsX(); iy++){
0086
0087 if ( h2d_hit[ichip]->GetBinContent(ix+1,iy+1)<1 ) continue;
0088
0089 double val = h2d_hit[ichip]->GetBinContent(ix+1,iy+1)/norm;
0090 h1d_rate[ichip]->Fill(val);
0091
0092 if ( val>cut_val ){
0093 h2d_hit_cut[ichip]->SetBinContent(ix+1,iy+1,0);
0094
0095 }else{
0096
0097 }
0098
0099 if ( bWRITE ){
0100 if ( val>cut_val ){
0101 fpar << ichip << " 0 " << ichip << " " << ix << " " << iy << endl;
0102 nbad[ichip]++;
0103 }
0104 }
0105
0106 }
0107 }
0108
0109
0110 c1->cd(4*ichip+2);
0111 SetPadStyle();
0112 gPad->SetLogy();
0113 gPad->SetLogx();
0114
0115 htmp = (TH1F*)h1d_rate[ichip];
0116 SetHistoStyle();
0117 htmp->SetMinimum(0.5);
0118 htmp->GetXaxis()->SetLabelSize(0.08);
0119 htmp->Draw();
0120
0121 TLine *line = new TLine(cut_val, 0.5, cut_val, htmp->GetMaximum());
0122 line->SetLineWidth(2);
0123 line->Draw();
0124
0125 c1->cd(4*ichip+3);
0126 SetPadStyle();
0127
0128 TH1F *h1 = (TH1F*)h2d_hit_cut[ichip]->ProjectionX(Form("h1d_hit_cut_x_%d",ichip));
0129 htmp = (TH1F*)h1;
0130 SetHistoStyle();
0131 htmp->GetXaxis()->SetLabelSize(0.08);
0132 h1->Draw("");
0133
0134 c1->cd(4*ichip+4);
0135 SetPadStyle();
0136
0137 h1 = (TH1F*)h2d_hit_cut[ichip]->ProjectionY(Form("h1d_hit_cut_y_%d",ichip));
0138 htmp = (TH1F*)h1;
0139 SetHistoStyle();
0140 htmp->GetXaxis()->SetLabelSize(0.08);
0141 h1->Draw("");
0142
0143 cout << "N BAD CH: " << nbad[ichip] << endl;
0144
0145 }
0146
0147 if ( bWRITE )
0148 fpar.close();
0149
0150 return;
0151
0152 TCanvas *c3 = new TCanvas("c3","c3",200*1.1*2,200*2);
0153 c3->Divide(2,2);
0154
0155 for (int ichip=0; ichip<4; ichip++){
0156 c3->cd(ichip+1);
0157 SetPadStyle();
0158 gPad->SetLogy();
0159
0160 htmp = (TH1F*)gPad->DrawFrame(0,5,10,1.5*h1d_clus_size_x[ichip]->GetMaximum());
0161 SetHistoStyle();
0162
0163 h1d_clus_size_x[ichip]->Draw("same");
0164 h1d_clus_size_z[ichip]->Draw("same");
0165
0166
0167 }
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239 }