AliPhysics  9c7580a (9c7580a)
CompareCorrs.C
Go to the documentation of this file.
1 
12 #ifndef __CINT__
13 #include <TCanvas.h>
14 #include <TFile.h>
15 #include <TLatex.h>
16 #include <TStyle.h>
17 #include <TMath.h>
19 #endif
20 
21 
22 //======================================================================
29 struct Canvas
30 {
31  //____________________________________________________________________
40  Canvas(const char* name, const char* title,
41  const char* n1, const char* n2)
42  : fName(name),
43  fTitle(title),
44  fN1(n1),
45  fN2(n2),
46  fCanvas(0),
47  fBody(0)
48  {
49  gStyle->SetPalette(1);
50  gStyle->SetTitleX(.50);
51  gStyle->SetTitleY(.99);
52  gStyle->SetTitleW(.85);
53  gStyle->SetTitleH(.085);
54  gStyle->SetTitleAlign(23);
55  gStyle->SetTitleFillColor(kWhite);
56  gStyle->SetTitleBorderSize(1);
57  }
58  //____________________________________________________________________
63  void Open()
64  {
65  fCanvas = new TCanvas(fName, fTitle, 800, TMath::Sqrt(2)*800);
66  fCanvas->SetFillColor(0);
67  fCanvas->SetLeftMargin(0.15);
68  fCanvas->SetBottomMargin(0.15);
69 
70  fCanvas->Print("comparison.pdf[", "pdf");
71  }
72  //____________________________________________________________________
83  TPad*
84  Clear(UShort_t nPad, UShort_t d, Char_t r, Bool_t flush=false)
85  {
86  fCanvas->Clear();
87  TPad* top = new TPad("top", "Top", 0, .95, 1, 1, 0, 0);
88  top->Draw();
89  top->cd();
90 
91  TLatex* l = new TLatex(.5, .5, Form("%s for FMD%d%c (%s / %s)",
92  fTitle, d, r, fN1, fN2));
93  l->SetNDC();
94  l->SetTextAlign(22);
95  l->SetTextSize(0.3);
96  l->Draw();
97 
98  fCanvas->cd();
99  fBody = new TPad("body", "Body", 0, 0, 1, .95, 0, 0);
100  fBody->SetTopMargin(0.05);
101  fBody->SetRightMargin(0.05);
102  Int_t nCol = Int_t(TMath::Sqrt(nPad));
103  Int_t nRow = Int_t(Float_t(nPad)/nCol+.5);
104  fBody->Divide(nCol, nRow, flush ? 0 : 0.001, flush ? 0 : 0.001);
105  fBody->Draw();
106 
107  return fBody;
108  }
109  //____________________________________________________________________
117  TVirtualPad* cd(Int_t i)
118  {
119  if (!fBody) return 0;
120 
121  return fBody->cd(i);
122  }
123  //____________________________________________________________________
131  void Print(UShort_t d, Char_t r, const char* extra="")
132  {
133  fCanvas->Print("comparison.pdf",
134  Form("Title:FMD%d%c %s", d, r, extra));
135  }
136  //____________________________________________________________________
141  void Close()
142  {
143  fCanvas->Print("comparison.pdf]", "pdf");
144  }
145  //____________________________________________________________________
147  const char* fName;
149  const char* fTitle;
151  const char* fN1;
153  const char* fN2;
155  TCanvas* fCanvas;
157  TPad* fBody;
158 };
159 
160 //======================================================================
161 
173 void
174 GetObjects(const char* what,
175  const char* fn1, const char* fn2,
176  TObject*& o1, TObject*& o2)
177 {
178  // --- Open files --------------------------------------------------
179  TFile* file1 = TFile::Open(fn1, "READ");
180  TFile* file2 = TFile::Open(fn2, "READ");
181 
182  if (!file1) {
183  Error("CompareSecMaps", "File %s cannot be opened", fn1);
184  return;
185  }
186 
187  if (!file2) {
188  Error("CompareSecMaps", "File %s cannot be opened", fn2);
189  return;
190  }
191 
192  // --- Find Objects ------------------------------------------------
193  const char* objName = what;
194  o1 = file1->Get(objName);
195  o2 = file2->Get(objName);
196 
197  if (!o1) {
198  TList* l = static_cast<TList*>(file1->Get("ForwardCorrResults"));
199  if (l) o1 = l->FindObject(objName);
200  }
201  if (!o1) {
202  Error("CompareSecMaps", "File %s does not contain an object named %s",
203  fn1, objName);
204  return;
205  }
206  if (!o2) {
207  TList* l = static_cast<TList*>(file2->Get("ForwardCorrResults"));
208  if (l) o2 = l->FindObject(objName);
209  }
210  if (!o2) {
211  Error("CompareSecMaps", "File %s does not contain an object named %s",
212  fn2, objName);
213  return;
214  }
215 };
216 
228 void
230  const char* fn1, const char* fn2,
231  TObject*& o1, TObject*& o2)
232 {
233  // --- Find Objects ------------------------------------------------
235  // (AliForwardCorrectionManager::ECorrection)what;
236  const char* objName =
238 
239  GetObjects(objName,fn1,fn2,o1,o2);
240 };
241 
242 
243 
244 //
245 // EOF
246 //
const char * title
Definition: MakeQAPdf.C:27
char Char_t
Definition: External.C:18
Canvas(const char *name, const char *title, const char *n1, const char *n2)
Definition: CompareCorrs.C:40
void Print(UShort_t d, Char_t r, const char *extra="")
Definition: CompareCorrs.C:131
void Close()
Definition: CompareCorrs.C:141
TPad * Clear(UShort_t nPad, UShort_t d, Char_t r, Bool_t flush=false)
Definition: CompareCorrs.C:84
int Int_t
Definition: External.C:63
float Float_t
Definition: External.C:68
const char * fN1
N1.
Definition: CompareCorrs.C:151
TVirtualPad * cd(Int_t i)
Definition: CompareCorrs.C:117
const char * GetObjectName(Int_t what) const
TPad * fBody
Body.
Definition: CompareCorrs.C:157
TCanvas * fCanvas
Canvas.
Definition: CompareCorrs.C:155
void Open()
Definition: CompareCorrs.C:63
const char * fN2
N2.
Definition: CompareCorrs.C:153
unsigned short UShort_t
Definition: External.C:28
const char * fTitle
Title.
Definition: CompareCorrs.C:149
bool Bool_t
Definition: External.C:53
const char * fName
NAme.
Definition: CompareCorrs.C:147
void GetObjects(const char *what, const char *fn1, const char *fn2, TObject *&o1, TObject *&o2)
Definition: CompareCorrs.C:174
static AliForwardCorrectionManager & Instance()