AliPhysics  aaf9c62 (aaf9c62)
plotOCDB_LED.C
Go to the documentation of this file.
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <AliEMCALGeometry.h>
3 #include <TCanvas.h>
4 #include <TDatime.h>
5 #include <TFile.h>
6 #include <TGrid.h>
7 #include <TH2F.h>
8 #include <TLegend.h>
9 #include <TMap.h>
10 #include <TNtuple.h>
11 #include <TProfile.h>
12 #include "LInfo.h"
13 
14 class LDraw : public TNamed {
15  public:
16  LDraw(const char *name, const char *fname="tempinfo.root");
17  virtual ~LDraw() {;}
18  TObjArray *GetArray() { return fArr; }
19  void Compute();
20  Int_t GetNRuns() const { return fArr->GetEntries(); }
21  void Print(Option_t *opt="") const {};
22  void SetPrint(Bool_t b=1) { fDoPrint=b; }
23  void DrawAll();
24  TCanvas *DrawFrac(Int_t type) const;
25  TH1 *GetFracRun(Int_t sm, Int_t t) const;
26  Int_t GetRunNo(Int_t run) const { return (static_cast<LInfo*>(fArr->At(run)))->GetRunNo(); }
27  TObjArray *fArr; // array with info
28  Bool_t fDoPrint; // if true then print canvases
29  ClassDef(LDraw, 1); // Led draw class
30 };
31 #endif
32 
33 LDraw::LDraw(const char *name, const char *fname) : TNamed(name,fname), fArr(0), fDoPrint(0)
34 {
35  TFile *inf = TFile::Open("ledinfo.root");
36  fArr = dynamic_cast<TObjArray*>(inf->Get(Form("led_%s",name)));
37  delete inf;
38 }
39 
41 {
42  const Int_t rns=fArr->GetEntries();
43  for (Int_t i=0;i<rns;++i) {
44  LInfo *linfo = dynamic_cast<LInfo*>(fArr->At(i));
45  if (!linfo)
46  continue;
47  linfo->Compute();
48  if (fDoPrint) {
49  linfo->Print();
50  cout << "fraction good strips ";
51  for (Int_t i=0;i<20;++i)
52  cout << linfo->FracStrips(i) << " ";
53  cout << endl;
54  cout << "fraction good towers ";
55  for (Int_t i=0;i<20;++i)
56  cout << linfo->FracLeds(i) << " ";
57  cout << endl;
58  }
59  }
60 }
61 
63 {
64  TString cname(Form("cLedAll_%s",GetName()));
65  TCanvas *c1 = DrawFrac(0);
66  c1->Print(Form("%s.pdf[",cname.Data()));
67  c1->Print(Form("%s.pdf",cname.Data()));
68  TCanvas *c2=DrawFrac(1);
69  c2->Print(Form("%s.pdf",cname.Data()));
70  TCanvas *c = 0;
71  const Int_t rns=fArr->GetEntries();
72  for (Int_t i=0;i<rns;++i) {
73  LInfo *linfo = dynamic_cast<LInfo*>(fArr->At(i));
74  if (!linfo)
75  continue;
76  c = linfo->DrawHist(5,1);
77  c->Print(Form("%s.pdf",cname.Data()));
78  delete c;
79  c = linfo->DrawHist(6,1);
80  c->Print(Form("%s.pdf",cname.Data()));
81  delete c;
82  c = linfo->DrawHist(0,1);
83  c->Print(Form("%s.pdf",cname.Data()));
84  delete c;
85  }
86  c2->Print(Form("%s.pdf]",cname.Data()));
87 }
88 
89 TCanvas *LDraw::DrawFrac(Int_t type) const
90 {
91  const char *tname="Led";
92  if (type==0)
93  tname = "LedMon";
94  TString lab(Form("cLedFrac_%s_%s",tname,GetName()));
95  TCanvas *c = new TCanvas(lab,lab,1200,800);
96  TLegend *leg = new TLegend(0.92,0.1,0.99,0.99);
97  TObjArray arr;
98  Double_t min=1e10,max=-1e10;
99  for (Int_t i=0;i<20;++i) {
100  TH1 *h=GetFracRun(i,type);
101  Int_t col=i+1;
102  switch (i) {
103  case 9: col=kOrange+2; break;
104  case 10: col=kOrange+10; break;
105  case 11: col=kMagenta+2; break;
106  case 12: col=kCyan+2; break;
107  case 13: col=kYellow+2; break;
108  case 14: col=kGray+2; break;
109  case 15: col=kOrange-2; break;
110  case 16: col=kViolet+2; break;
111  case 17: col=kRed-2; break;
112  case 18: col=kGreen+2; break;
113  case 19: col=kGray+2; break;
114  }
115  h->SetMarkerStyle(20+(i%2));
116  h->SetMarkerSize(1.2);
117  h->SetMarkerColor(col);
118  h->SetLineColor(col);
119  h->SetLineWidth(3);
120  h->SetName(Form("SM%d",i));
121  arr.Add(h);
122  leg->AddEntry(h,h->GetName(),"p");
123  min=TMath::Min(min,h->GetMinimum());
124  max=TMath::Max(max,h->GetMaximum());
125  }
126  TH2 *h2f = new TH2F("h2f",";run idx;T",1,0,GetNRuns(),1,-0.05,1.05);
127  h2f->SetTitle(Form("Fraction %s per SM: run %d to %d, min=%.1f, max=%.1f",tname, GetRunNo(0), GetRunNo(GetNRuns()-1), min, max));
128  h2f->SetStats(0);
129  h2f->Draw();
130  leg->Draw();
131  for (Int_t i=0;i<arr.GetEntries();++i)
132  arr.At(i)->Draw("same, p, hist");
133  c->SetGridx(1);
134  c->SetGridy(1);
135  if (fDoPrint)
136  c->Print(Form("%s.pdf",c->GetName()));
137  return c;
138 }
139 
141 {
142  const Int_t rns=fArr->GetEntries();
143  TH1F *ret = new TH1F(Form("hFracRun_%d_%d",sm,t),Form(";run idx;fraction"),rns,0,rns);
144  if (t==0)
145  ret->SetTitle(Form("Fraction of strips per run: run %d to %d",GetRunNo(0), GetRunNo(GetNRuns()-1)));
146  else
147  ret->SetTitle(Form("Fraction of leds per run: run %d to %d",GetRunNo(0), GetRunNo(GetNRuns()-1)));
148  ret->SetDirectory(0);
149  ret->SetStats(0);
150  ret->SetMarkerStyle(20);
151  ret->SetMarkerSize(1);
152  Int_t r1,r2=0;
153  for (Int_t i=0;i<rns;++i) {
154  LInfo *linfo = dynamic_cast<LInfo*>(fArr->At(i));
155  if (!linfo)
156  continue;
157  Double_t val = 0;
158  if (t==0)
159  val = linfo->FracStrips(sm);
160  else
161  val = linfo->FracLeds(sm);
162  ret->SetBinContent(i+1,val);
163  }
164  return ret;
165 }
166 
167 void plotL_period(const char *period, Bool_t doprint=0)
168 {
169  LDraw d(period);
170  d.SetPrint(doprint);
171  d.Compute();
172  d.Print();
173  if (0) {
174  d.DrawFrac(0);
175  d.DrawFrac(1);
176  } else
177  d.DrawAll();
178 }
179 
180 void plotOCDB_LED(const char *period="lhc18d")
181 {
182  plotL_period(period);
183 }
184 
185 #if 0
186 void test_geo()
187 {
188  AliEMCALGeometry *g=AliEMCALGeometry::GetInstance("EMCAL_COMPLETE12SMV1_DCAL_8SM");
189  Int_t kSM=g->GetNumberOfSuperModules();
190  cout << "Number of SM: " << kSM << endl;
191  for (Int_t i=0;i<kSM;++i) {
192  Int_t nrow = g->GetNumberOfCellsInPhiDirection(i);
193  Int_t ncol = g->GetNumberOfCellsInEtaDirection(i);
194  cout << i << ": nrow(neta)=" << nrow << ", ncol(nphi)=" << ncol << endl;
195  continue;
196  TH2 *h2f = new TH2F(Form("hsm%d",i),Form(";col;row"), ncol, -0.5, ncol-0.5, nrow, -0.5, nrow-0.5);
197  for (Int_t col=0;col<ncol;++col) {
198  for (Int_t row=0;row<nrow;++row) {
199  Int_t id = g->GetAbsCellIdFromCellIndexes(i,row,col);
200  cout << "Id " << id << " " << col << " " << row << endl;
201  Int_t bin = h2f->FindBin(col,row);
202  h2f->SetBinContent(bin,id);
203  }
204  }
205  h2f->Draw("text");
206  break;
207  }
208 
209  Int_t sm=18;
210  Int_t nrow = g->GetNumberOfCellsInPhiDirection(sm);
211  Int_t ncol = g->GetNumberOfCellsInEtaDirection(sm);
212  cout << "sm " << sm << ": " << nrow << " " << ncol << endl;
213  for (Int_t col=0;col<ncol;++col) {
214  for (Int_t row=0;row<nrow;++row) {
215  Int_t id = g->GetAbsCellIdFromCellIndexes(sm,row,col);
216  cout << "Id " << id << " " << col << " " << row << endl;
217  }
218  }
219 }
220 #endif
double Double_t
Definition: External.C:58
Definition: External.C:236
Double_t FracLeds(Int_t sm, Int_t gain=1) const
Definition: LInfo.cxx:221
TObjArray * GetArray()
Definition: plotOCDB_LED.C:18
TCanvas * DrawHist(Int_t which, Int_t gain=1, const char *opt=0) const
Definition: LInfo.cxx:145
void Compute()
Definition: plotOCDB_LED.C:40
Bool_t fDoPrint
Definition: plotOCDB_LED.C:28
void SetPrint(Bool_t b=1)
Definition: plotOCDB_LED.C:22
virtual ~LDraw()
Definition: plotOCDB_LED.C:17
TCanvas * c
Definition: TestFitELoss.C:172
void Print(Option_t *option="") const
Definition: LInfo.cxx:269
Int_t GetRunNo(Int_t run) const
Definition: plotOCDB_LED.C:26
Definition: LInfo.h:11
int Int_t
Definition: External.C:63
void Compute()
Definition: LInfo.cxx:12
Double_t FracStrips(Int_t sm, Int_t gain=1) const
Definition: LInfo.cxx:248
Int_t GetNRuns() const
Definition: plotOCDB_LED.C:20
TObjArray * fArr
Definition: plotOCDB_LED.C:27
LDraw(const char *name, const char *fname="tempinfo.root")
Definition: plotOCDB_LED.C:33
Definition: External.C:220
void DrawAll()
Definition: plotOCDB_LED.C:62
void Print(Option_t *opt="") const
Definition: plotOCDB_LED.C:21
const char Option_t
Definition: External.C:48
bool Bool_t
Definition: External.C:53
TH1 * GetFracRun(Int_t sm, Int_t t) const
Definition: plotOCDB_LED.C:140
void plotOCDB_LED(const char *period="lhc18d")
Definition: plotOCDB_LED.C:180
Definition: External.C:196
TCanvas * DrawFrac(Int_t type) const
Definition: plotOCDB_LED.C:89
void plotL_period(const char *period, Bool_t doprint=0)
Definition: plotOCDB_LED.C:167