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