Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Draw_hotmap.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Draw_hotmap.C
1 #include "/phenix/u/shlim/Style.h"
2 
3 void Draw_hotmap(const int runnumber=28, const int segnumber=100){
4 
5  gStyle->SetOptStat(0);
6 
7  const int nColor[4] = {1, 2, 4, 8};
8 
9  bool bWRITE = true;
10  double cut_val = 2.0e-4;
11 
12  if ( runnumber==41 || runnumber==42 || runnumber==44 || runnumber==49 || runnumber==50 || runnumber==51 || runnumber==52
13  || runnumber==78 || runnumber==79 || runnumber==82 ) cut_val = 9.0e-4;
14  else if ( runnumber==43 || runnumber==77 || (runnumber>=126 && runnumber<=127) ) cut_val = 2.0e-3;
15  else if ( runnumber==46 || runnumber==47 || runnumber==48 || runnumber==98 ) cut_val = 1.0e-3;
16  else if ( runnumber==53 || runnumber==54 || (runnumber>=56 && runnumber<=65) || runnumber==97 || runnumber==116 ) cut_val = 4.0e-4;
17  else if ( runnumber==121 ) cut_val = 1e10;
18 
19  TFile *infile = new TFile(Form("MvtxQAHisto-%08d-%04d.root",runnumber,segnumber),"read");
20 
21  TH2F *h2d_hit[4];
22  TH2F *h2d_hit_trk[4];
23  TH1F *h1d_hit_per_evt[4];
24  TH1F *h1d_hit_x[4];
25  TH1F *h1d_hit_y[4];
26  TH1F *h1d_hit_trk_x[4];
27  TH1F *h1d_hit_trk_y[4];
28 
29  TH1F *h1d_rate[4];
30  TH2F *h2d_hit_cut[4];
31 
32  int nbad[4] = {0};
33 
34  for (int ichip=0; ichip<4; ichip++){
35  h2d_hit[ichip] = (TH2F*)infile->Get(Form("h2d_hit_chip%d",ichip));
36  h2d_hit_trk[ichip] = (TH2F*)infile->Get(Form("h2d_hit_trk_chip%d",ichip));
37  h1d_hit_per_evt[ichip] = (TH1F*)infile->Get(Form("h1d_hit_per_evt_chip%d",ichip));
38 
39  h1d_hit_x[ichip] = (TH1F*)h2d_hit[ichip]->ProjectionX(Form("h1d_hit_x_chip%d",ichip));
40  h1d_hit_y[ichip] = (TH1F*)h2d_hit[ichip]->ProjectionY(Form("h1d_hit_y_chip%d",ichip));
41  h1d_hit_x[ichip]->SetLineColor(1);
42  h1d_hit_y[ichip]->SetLineColor(1);
43 
44  h1d_hit_trk_x[ichip] = (TH1F*)h2d_hit_trk[ichip]->ProjectionX(Form("h1d_hit_trk_x_chip%d",ichip));
45  h1d_hit_trk_y[ichip] = (TH1F*)h2d_hit_trk[ichip]->ProjectionY(Form("h1d_hit_trk_y_chip%d",ichip));
46  h1d_hit_trk_x[ichip]->SetLineColor(1);
47  h1d_hit_trk_y[ichip]->SetLineColor(1);
48 
49  h1d_rate[ichip] = new TH1F(Form("h1d_rate_chip%d",ichip),"",5000,0.000005,0.1);
50  }
51 
52  h1d_hit_norm = (TH1F*)infile->Get("h1d_hit_norm");
53 
54  ofstream fpar;
55 
56  if ( bWRITE ){
57  char fname[300];
58  sprintf(fname,"hotmap/hotmap_testbeam_%08d.txt",runnumber);
59 
60  fpar.open(fname);
61  }
62 
63  TCanvas *c1 = new TCanvas("c1","c1",150*1.1*4,150*4);
64  c1->Divide(4,4);
65 
66  for (int ichip=0; ichip<4; ichip++){
67 
68  //double norm = h1d_hit_per_evt[ichip]->Integral(2,h1d_hit_per_evt[ichip]->GetNbinsX());
69  double norm = h1d_hit_norm->Integral();
70  cout << "CHIP: " << ichip << ", EVT: " << norm << endl;
71 
72  c1->cd(4*ichip+1);
73  SetPadStyle();
74  gPad->SetLogz();
75 
76  htmp = (TH1F*)h2d_hit[ichip];
77  SetHistoStyle();
78  htmp->GetXaxis()->SetLabelSize(0.08);
79 
80  htmp->Draw("col2");
81 
82  h2d_hit_cut[ichip] = (TH2F*)h2d_hit[ichip]->Clone(Form("h2d_hit_cut_%d",ichip));
83 
84  for (int ix=0; ix<h1d_hit_x[ichip]->GetNbinsX(); ix++){
85  for (int iy=0; iy<h1d_hit_y[ichip]->GetNbinsX(); iy++){
86 
87  if ( h2d_hit[ichip]->GetBinContent(ix+1,iy+1)<1 ) continue;
88 
89  double val = h2d_hit[ichip]->GetBinContent(ix+1,iy+1)/norm;
90  h1d_rate[ichip]->Fill(val);
91 
92  if ( val>cut_val ){
93  h2d_hit_cut[ichip]->SetBinContent(ix+1,iy+1,0);
94  //cout << ichip << " 0 " << ichip << " " << ix << " " << iy << endl;
95  }else{
96  //cout << val << endl;
97  }
98 
99  if ( bWRITE ){
100  if ( val>cut_val ){
101  fpar << ichip << " 0 " << ichip << " " << ix << " " << iy << endl;
102  nbad[ichip]++;
103  }
104  }//bWRITE
105 
106  }
107  }
108 
109 
110  c1->cd(4*ichip+2);
111  SetPadStyle();
112  gPad->SetLogy();
113  gPad->SetLogx();
114 
115  htmp = (TH1F*)h1d_rate[ichip];
116  SetHistoStyle();
117  htmp->SetMinimum(0.5);
118  htmp->GetXaxis()->SetLabelSize(0.08);
119  htmp->Draw();
120 
121  TLine *line = new TLine(cut_val, 0.5, cut_val, htmp->GetMaximum());
122  line->SetLineWidth(2);
123  line->Draw();
124 
125  c1->cd(4*ichip+3);
126  SetPadStyle();
127 
128  TH1F *h1 = (TH1F*)h2d_hit_cut[ichip]->ProjectionX(Form("h1d_hit_cut_x_%d",ichip));
129  htmp = (TH1F*)h1;
130  SetHistoStyle();
131  htmp->GetXaxis()->SetLabelSize(0.08);
132  h1->Draw("");
133 
134  c1->cd(4*ichip+4);
135  SetPadStyle();
136 
137  h1 = (TH1F*)h2d_hit_cut[ichip]->ProjectionY(Form("h1d_hit_cut_y_%d",ichip));
138  htmp = (TH1F*)h1;
139  SetHistoStyle();
140  htmp->GetXaxis()->SetLabelSize(0.08);
141  h1->Draw("");
142 
143  cout << "N BAD CH: " << nbad[ichip] << endl;
144 
145  }//
146 
147  if ( bWRITE )
148  fpar.close();
149 
150  return;
151 
152  TCanvas *c3 = new TCanvas("c3","c3",200*1.1*2,200*2);
153  c3->Divide(2,2);
154 
155  for (int ichip=0; ichip<4; ichip++){
156  c3->cd(ichip+1);
157  SetPadStyle();
158  gPad->SetLogy();
159 
160  htmp = (TH1F*)gPad->DrawFrame(0,5,10,1.5*h1d_clus_size_x[ichip]->GetMaximum());
161  SetHistoStyle();
162 
163  h1d_clus_size_x[ichip]->Draw("same");
164  h1d_clus_size_z[ichip]->Draw("same");
165 
166 
167  }
168 
169 
170  /*
171  TCanvas *c3 = new TCanvas("c3","c3",150*1.1*4,150*2);
172  c3->Divide(4,2);
173 
174  for (int ichip=0; ichip<4; ichip++){
175 
176  c3->cd(ichip+1);
177  SetPadStyle();
178  gPad->SetLogy();
179 
180  htmp = (TH1F*)h1d_hit_trk_x[ichip];
181  SetHistoStyle();
182 
183  TF1 *fx = new TF1("fx","gaus",-5,5);
184  htmp->Fit(fx,"R0Q");
185 
186  double sum = 0;
187  for (int ii=0; ii<21; ii++){
188  sum += fx->Eval(-10+ii);
189  }
190 
191  cout << "Noise R x: " << (htmp->Integral()-sum)/htmp->Integral() << endl;
192 
193  htmp->SetAxisRange(-50,50);
194  htmp->Draw("");
195  fx->Draw("same");
196 
197  c3->cd(ichip+5);
198  SetPadStyle();
199  gPad->SetLogy();
200 
201  htmp = (TH1F*)h1d_hit_trk_y[ichip];
202  SetHistoStyle();
203 
204  TF1 *fy = new TF1("fy","gaus",-5,5);
205  htmp->Fit(fy,"R0Q");
206 
207  sum = 0;
208  for (int ii=0; ii<21; ii++){
209  sum += fy->Eval(-10+ii);
210  }
211 
212  cout << "Noise R y: " << (htmp->Integral()-sum)/htmp->Integral() << endl;
213 
214  htmp->SetAxisRange(-50,50);
215  htmp->Draw("");
216  fy->Draw("same");
217 
218  //cout << "Noise R y: " << (htmp->GetEntries()-fy->Integral(-10,10))/htmp->GetEntries() << endl;
219  }//
220 
221  int nevents = h1d_clus_associated->Integral(h1d_clus_associated->FindBin(3),h1d_clus_associated->GetNbinsX());
222 
223  h1d_clus_eff->Sumw2();
224  h1d_clus_eff->Scale(1./nevents);
225 
226  TCanvas *c5 = new TCanvas("c5","c5",1.1*400,400);
227  SetPadStyle();
228 
229  htmp = (TH1F*)gPad->DrawFrame(-0.5,0.95,3.5,1.02);
230  SetHistoStyle();
231 
232  h1d_clus_eff->SetLineWidth(2);
233  h1d_clus_eff->SetLineColor(1);
234  h1d_clus_eff->Draw("same");
235 
236  */
237 
238 
239 }