AliPhysics  754e963 (754e963)
LInfo.cxx
Go to the documentation of this file.
1 #include "LInfo.h"
2 #include <TCanvas.h>
3 #include <TDatime.h>
4 #include <TFile.h>
5 #include <TFile.h>
6 #include <TGrid.h>
7 #include <TH2F.h>
8 #include <TMap.h>
9 #include <TNtuple.h>
10 
12 {
13  if (fIsComputed)
14  return;
15 
16  char id[100];
17  char title[100];
18  const char *sideStr[] = {"A", "C"};
19  const Int_t kNCol = NCol();
20  const Int_t kNRow = NRow();
21  const Int_t kNStrip = NStrip();
22 
23  for (Int_t iSM=0; iSM<kNSM; ++iSM) {
24  Int_t isector = iSM/2;
25  Int_t iside = iSM%2;
26  for (Int_t igain=0; igain<2; ++igain) {
27  if (!fhAmpOverMon[iSM][igain]) {
28  sprintf(id, "hAmpOverMon%02d%d", iSM, igain);
29  sprintf(title, "LED amplitude over LEDMON: SM %d (%1s%d) gain %d", iSM, sideStr[iside], isector, igain);
30  fhAmpOverMon[iSM][igain] = new TH2F(id, title, kNCol, -0.5, kNCol-0.5, kNRow, -0.5, kNRow - 0.5);
31  fhAmpOverMon[iSM][igain]->SetDirectory(0);
32  sprintf(id, "hStripRmsOverMean%02d%d", iSM, igain);
33  sprintf(title, "LedMon rms over mean: SM %d (%1s%d) gain %d", iSM, sideStr[iside], isector, igain);
34  fhStripRmsOverMean[iSM][igain] = new TH1F(id, title, kNCol, -0.5, kNCol-0.5);
35  fhStripRmsOverMean[iSM][igain]->SetDirectory(0);
36  sprintf(id, "hLedRmsOverMean%02d%d", iSM, igain);
37  sprintf(title, "Led rms over mean: SM %d (%1s%d) gain %d", iSM, sideStr[iside], isector, igain);
38  fhLedRmsOverMean[iSM][igain] = new TH2F(id, title, kNCol, -0.5, kNCol-0.5, kNRow, -0.5, kNRow-0.5);
39  fhLedRmsOverMean[iSM][igain]->SetDirectory(0);
40  } else {
41  fhAmpOverMon[iSM][igain]->Reset();
42  fhStripRmsOverMean[iSM][igain]->Reset();
43  fhLedRmsOverMean[iSM][igain]->Reset();
44  }
45  }
46  }
47 
48  for (Int_t iSM=0; iSM<kNSM; ++iSM) {
49  Int_t isector = iSM/2;
50  Int_t iside = iSM%2;
51  for (Int_t igain=0; igain<2; ++igain) {
52  for (Int_t col=0;col<kNCol;++col) {
53  Int_t strip = col / 2;
54  Int_t mbin = fhStrip[iSM][igain]->FindBin(strip);
55  Double_t ledMonAmp = fhStrip[iSM][igain]->GetBinContent(mbin);
56  for (Int_t row=0;row<kNRow;++row) {
57  Int_t lbin = fhLed[iSM][igain]->FindBin(col,row);
58  Double_t ledAmp = fhLed[iSM][igain]->GetBinContent(lbin);
59  if (ledMonAmp!=0) {
60  Double_t weightf = ledAmp/ledMonAmp;
61  fhAmpOverMon[iSM][igain]->SetBinContent(lbin,weightf);
62  }
63  Double_t ledRms = fhLedCount[iSM][igain]->GetBinContent(lbin);
64  if (ledAmp>0) {
65  fhLedRmsOverMean[iSM][igain]->SetBinContent(lbin,ledRms/ledAmp);
66  }
67  }
68  }
69  for (Int_t strip=0;strip<kNStrip;++strip) {
70  Int_t bin = fhStrip[iSM][igain]->FindBin(strip);
71  Double_t mean = fhStrip[iSM][igain]->GetBinContent(bin);
72  Double_t rms = fhStripCount[iSM][igain]->GetBinContent(bin);
73  if (mean>0)
74  fhStripRmsOverMean[iSM][igain]->SetBinContent(bin,rms/mean);
75  }
76  }
77  }
78  fIsComputed = 1;
79 }
80 
82 {
83  // book histograms
84  char id[100];
85  char title[100];
86  const char *sideStr[] = {"A", "C"};
87  const Int_t kNCol = NCol();
88  const Int_t kNRow = NRow();
89  const Int_t kNStrip = NStrip();
90 
91  for (Int_t iSM=0; iSM<kNSM; ++iSM) {
92  Int_t isector = iSM/2;
93  Int_t iside = iSM%2;
94  for (Int_t igain=0; igain<2; ++igain) {
95  sprintf(id, "hStrip%02d%d", iSM, igain);
96  sprintf(title, "LEDMon Amplitude: SM %d (%1s%d) gain %d", iSM, sideStr[iside], isector, igain);
97  fhStrip[iSM][igain] = new TH1F(id, title, kNStrip, -0.5, kNStrip-0.5);
98  fhStrip[iSM][igain]->SetDirectory(0);
99 
100  sprintf(id, "hStripCount%02d%d", iSM, igain);
101  sprintf(title, "LEDMon Entries: SM %d (%1s%d) gain %d", iSM, sideStr[iside], isector, igain);
102  fhStripCount[iSM][igain] = new TH1F(id, title, kNStrip, -0.5, kNStrip-0.5);
103  fhStripCount[iSM][igain]->SetDirectory(0);
104 
105  sprintf(id, "hLed%02d%d", iSM, igain);
106  sprintf(title, "Led Amplitude: SM %d (%1s%d) gain %d", iSM, sideStr[iside], isector, igain);
107  fhLed[iSM][igain] = new TH2F(id, title, kNCol, -0.5, kNCol-0.5, kNRow, -0.5, kNRow - 0.5);
108  fhLed[iSM][igain]->SetDirectory(0);
109 
110  sprintf(id, "hLedCount%02d%d", iSM, igain);
111  sprintf(title, "Led Entries: SM %d (%1s%d) gain %d", iSM, sideStr[iside], isector, igain);
112  fhLedCount[iSM][igain] = new TH2F(id, title, kNCol, -0.5, kNCol-0.5, kNRow, -0.5, kNRow - 0.5);
113  fhLedCount[iSM][igain]->SetDirectory(0);
114 
115  fhAmpOverMon[iSM][igain] = 0;
116  fhLedRmsOverMean[iSM][igain] = 0;
117  fhStripRmsOverMean[iSM][igain] = 0;
118  }
119  }
120 }
121 
122 void LInfo::FillLed(Int_t mod,Int_t gain, Int_t col, Int_t row, Double_t amp, Double_t rms)
123 {
124  fhLed[mod][gain]->Fill(col, row, amp);
125  fhLedCount[mod][gain]->Fill(col, row, rms);
126 }
127 
128 TCanvas *LInfo::DrawHist(Int_t which, Int_t gain, const char *opt) const
129 {
130  TString name;
131  TString hopt;
132  if ((which<1||which>4) && !fIsComputed) {
133  cerr << "Execute Linfo::Compute first" << endl;
134  return 0;
135  }
136  TCanvas *c = new TCanvas("c","c",1600,1600);
137  c->Divide(2,10);
138  c->SetLeftMargin(0.02);
139  c->SetRightMargin(0.02);
140  c->SetTopMargin(0.02);
141  c->SetBottomMargin(0.02);
142  for (Int_t sm=0;sm<kNSM;++sm) {
143  c->cd(sm+1);
144  gPad->SetLeftMargin(0.02);
145  gPad->SetRightMargin(0.02);
146  gPad->SetTopMargin(0.02);
147  gPad->SetBottomMargin(0.02);
148  TH1 *h = 0;
149  switch (which) {
150  case 1:
151  h = GetStripHist(sm,gain);
152  name = Form("StripMeanHist_%d_%d",gain,fRunNo);
153  break;
154  case 2:
155  h = GetStripRmsHist(sm,gain);
156  name = Form("StripRmsHist_%d_%d",gain,fRunNo);
157  break;
158  case 3:
159  h = GetLedHist(sm,gain);
160  name = Form("LedMeanHist_%d_%d",gain,fRunNo);
161  hopt = "colz";
162  break;
163  case 4:
164  h = GetLedRmsHist(sm,gain);
165  name = Form("LedRmsHist_%d_%d",gain,fRunNo);
166  hopt = "colz";
167  break;
168  case 5:
169  h = GetLedMonDispHist(sm,gain);
170  name = Form("LedMonDispHist_%d_%d",gain,fRunNo);
171  break;
172  case 6:
173  h = GetLedDispHist(sm,gain);
174  name = Form("LedDispHist_%d_%d",gain,fRunNo);
175  hopt = "colz";
176  break;
177  default :
178  h = GetLedOverMonHist(sm,gain);
179  name = Form("LedOverMonHist_%d_%d",gain,fRunNo);
180  hopt = "colz";
181  }
182  if (opt)
183  h->Draw(opt);
184  else
185  h->Draw(hopt);
186  }
187  c->SetName(name);
188  c->SetTitle(name);
189  return c;
190 }
191 
192 
193 void LInfo::FillStrip(Int_t mod, Int_t gain, Int_t strip, Double_t amp, Double_t rms)
194 {
195  fhStrip[mod][gain]->Fill(strip, amp);
196  fhStripCount[mod][gain]->Fill(strip, rms);
197 }
198 
200 {
201  const Int_t kGain=gain;
202  Double_t ret=0,all=0;
203  for (Int_t iSM=0; iSM<kNSM; ++iSM) {
204  if (sm>=0&&iSM!=sm)
205  continue;
206  Int_t ncols=NCol();
207  if (iSM>11 && iSM<18)
208  ncols=32;
209  Int_t nrows=NRow();
210  if (iSM==10||iSM==11||iSM==18||iSM==19)
211  nrows=8;
212  for (Int_t col=0;col<ncols;++col) {
213  for (Int_t row=0;row<nrows;++row) {
214  ++all;
215  Int_t bin=fhLed[iSM][kGain]->GetBin(col,row);
216  if (fhLed[iSM][kGain]->GetBinContent(bin)>0.)
217  ++ret;
218  }
219  }
220  }
221  if (all>0)
222  return ret/all;
223  return 0;
224 }
225 
227 {
228  const Int_t kstripGain=gain;
229  Double_t ret=0,all=0;
230  for (Int_t iSM=0; iSM<kNSM; ++iSM) {
231  if (sm>=0&&iSM!=sm)
232  continue;
233  Int_t nstrips=NStrip();
234  if (iSM>11 && iSM<18)
235  nstrips=32/2;
236  for (Int_t strip=1; strip<=nstrips; ++strip) {
237  ++all;
238  if (fhStrip[iSM][kstripGain]->GetBinContent(strip)>0.)
239  ++ret;
240  }
241  }
242  if (all>0)
243  return ret/all;
244  return 0;
245 }
246 
247 void LInfo::Print(Option_t *option) const
248 {
249  cout << "Runno: " << fRunNo << endl;
250 }
double Double_t
Definition: External.C:58
Definition: External.C:236
const char * title
Definition: MakeQAPdf.C:27
Double_t FracLeds(Int_t sm, Int_t gain=1) const
Definition: LInfo.cxx:199
TH1 * GetLedMonDispHist(Int_t sm, Int_t gain=1) const
Definition: LInfo.h:26
TCanvas * DrawHist(Int_t which, Int_t gain=1, const char *opt=0) const
Definition: LInfo.cxx:128
TH1 * GetStripHist(Int_t sm, Int_t gain=1) const
Definition: LInfo.h:19
TCanvas * c
Definition: TestFitELoss.C:172
void Print(Option_t *option="") const
Definition: LInfo.cxx:247
TH2 * fhAmpOverMon[kNSM][2]
Definition: LInfo.h:49
static Int_t NCol()
Definition: LInfo.h:38
TH1 * fhStripCount[kNSM][2]
Definition: LInfo.h:46
int Int_t
Definition: External.C:63
Bool_t fIsComputed
RMS over Mean for Led.
Definition: LInfo.h:52
static Int_t NStrip()
Definition: LInfo.h:40
void FillLed(Int_t mod, Int_t gain, Int_t col, Int_t row, Double_t amp, Double_t rms)
Definition: LInfo.cxx:122
void Compute()
Definition: LInfo.cxx:11
TH2 * fhLedCount[kNSM][2]
Definition: LInfo.h:48
Double_t FracStrips(Int_t sm, Int_t gain=1) const
Definition: LInfo.cxx:226
TH1 * fhStripRmsOverMean[kNSM][2]
Led/LedMon ratio.
Definition: LInfo.h:50
TH2 * GetLedRmsHist(Int_t sm, Int_t gain=1) const
Definition: LInfo.h:24
static const Int_t kNSM
Definition: LInfo.h:36
void CreateHistograms()
Definition: LInfo.cxx:81
TH1 * GetStripRmsHist(Int_t sm, Int_t gain=1) const
Definition: LInfo.h:20
TH2 * GetLedDispHist(Int_t sm, Int_t gain=1) const
Definition: LInfo.h:27
Int_t fRunNo
Definition: LInfo.h:44
TH2 * fhLed[kNSM][2]
Definition: LInfo.h:47
void FillStrip(Int_t mod, Int_t gain, Int_t strip, Double_t amp, Double_t rms)
Definition: LInfo.cxx:193
TH1 * fhStrip[kNSM][2]
Definition: LInfo.h:45
const char Option_t
Definition: External.C:48
TH2 * fhLedRmsOverMean[kNSM][2]
RMS over Mean for LedMon.
Definition: LInfo.h:51
TH2 * GetLedHist(Int_t sm, Int_t gain=1) const
Definition: LInfo.h:23
Definition: External.C:196
TH2 * GetLedOverMonHist(Int_t sm, Int_t gain=1) const
Definition: LInfo.h:25
static Int_t NRow()
Definition: LInfo.h:39