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