AliPhysics  32b88a8 (32b88a8)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MakeEposWeight.C
Go to the documentation of this file.
1 TProfile* GetOne(const char* filename)
2 {
3  TFile* file = TFile::Open(filename, "READ");
4  if (!file) return 0;
5 
6  Bool_t mc = !TString(filename).Contains("real");
7  TList* top = static_cast<TList*>(file->Get(Form("MidRapidity%sResults",
8  mc ? "MC" : "")));
9  if (!top) {
10  Error("GetOne", "Couldn't get result container in %s", filename);
11  file->Close();
12  return 0;
13  }
14 
15  TProfile* prf = static_cast<TProfile*>(top->FindObject("centTracklets"));
16  if (!prf)
17  Error("GetOne", "Couldn't get profile from %s", filename);
18 
19  file->Close();
20  return prf;
21 }
22 
23 void
24 MakeEposWeight(const char* file1, const char* file2)
25 {
26  gSystem->AddIncludePath("-I${ALICE_ROOT}/include "
27  "-I${ALICE_PHYSICS}/include "
28  "-I${ANA_SRC}/dndeta/traclets3");
29  gROOT->SetMacroPath(Form("%s:$ANA_SRC/dndeta/tracklets3",
30  gROOT->GetMacroPath()));
31  gROOT->LoadMacro("AliAODTracklet.C+g");
32  gROOT->LoadMacro("AliTrackletWeights.C+g");
33 
35 
36  // --- pT weight ---------------------------------------------------
37  // Int_t nBins = 10;
38  // Double_t bins[] = { 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90 };
39  // Double_t facs[] = { 1.12, 1.01,1.,.99,.98,.98,.98,.97,.95,.88 };
40  // TH2D* cPt = new TH2D("cPt", "cPt", nBins, bins, 1, 0, 100);
41  // for (Int_t i = 1; i <= nBins; i++)
42  // cPt->SetBinContent(i, 1, facs[i-1]);
43  TProfile* p1 = GetOne(file1);
44  TProfile* p2 = GetOne(file2);
45  if (!p1 || !p2) return;
46 
47  TH1::SetDefaultSumw2();
48  TProfile* r = static_cast<TProfile*>(p1->Clone("ratio"));
49  r->SetErrorOption(" ");
50  r->Divide(p2);
51  TF1* f = new TF1("rf", "pol6", 0, 90);
52  r->Fit(f, "Q0R+", "");
53 
54  TH2D* cPT = new TH2D("cPt", "cPt", 100, 0, 100, 1, 0, 100);
55  for (Int_t i = 1; i <= cPt->GetNbinsX(); i++)
56  cPt->SetBinContent(i, 1, f->Eval(i-.5));
57 
58  TCanvas* cp = new TCanvas("p","p");
59  cp->Divide(2,1);
60  TVirtualPad* pp = cp->cd(1);
61  p1->SetTitle(file1);
62  p2->SetTitle(file2);
63  p1->SetMarkerColor(kGreen+2); p2->SetMarkerColor(kRed+2);
64  p1->SetLineColor (kGreen+2); p2->SetLineColor (kRed+2);
65  p1->Draw();
66  p2->Draw("same");
67  pp->BuildLegend();
68  pp = cp->cd(2);
69  // r->Draw("i");
70  cPt->ProjectionX()->Draw("");
71  f->Draw("same");
72  cp->Modified();
73  cp->Update();
74  cp->cd();
75 
76  weights->SetPtWeight(cPt);
77 
78  // --- Abundance weights -------------------------------------------
79  // We do not add any!
80 
81  // --- Strangeness weights -----------------------------------------
82  // We do not add any!
83 
84  new TBrowser;
85 
86  // --- Write to file -----------------------------------------------
87  TFile* outW = TFile::Open("epos.root", "RECREATE");
88  weights->Write();
89  outW->Write();
90 
91 
92  TCanvas* c = new TCanvas("w","w");
93  weights->Draw();
94  weights->Print();
95 }
const char * filename
Definition: TestFCM.C:1
void MakeEposWeight(const char *file1, const char *file2)
TSystem * gSystem
TCanvas * c
Definition: TestFitELoss.C:172
void Print(Option_t *option="") const
void Draw(Option_t *option="")
int Int_t
Definition: External.C:63
Definition: External.C:228
Bool_t SetPtWeight(const TH2D *h, UShort_t mode=0)
TProfile * GetOne(const char *filename)
Definition: MakeEposWeight.C:1
TFile * file
bool Bool_t
Definition: External.C:53