AliPhysics  f05a842 (f05a842)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MakeWeight.C
Go to the documentation of this file.
1 void
3 {
4  gSystem->AddIncludePath("-I${ALICE_ROOT}/include -I${ALICE_PHYSICS}/include");
5  gROOT->LoadMacro("AliAODTracklet.C+g");
6  gROOT->LoadMacro("AliTrackletWeights.C+g");
7 
9 
10  TFile* ptFile = TFile::Open("../tracklets/REWEIGHTpt.root","READ");
11 
12  Double_t c1Bins[] = { 0, 5, 10, 20, 30, 40, 50, 60, 70, 80 };
13  TH2D* cPt = new TH2D("cPt", "cPt", 9, c1Bins,
14  1000, 0, 5);
15  for (Int_t i = 1; i <= cPt->GetNbinsX(); i++) {
16  TString histName;
17  histName.Form("ptWeight_c%d_%d",
18  Int_t(cPt->GetXaxis()->GetBinLowEdge(i)),
19  Int_t(cPt->GetXaxis()->GetBinUpEdge(i)));
20  TH1* hist = static_cast<TH1*>(ptFile->Get(histName));
21  if (!hist) {
22  Warning("MakeWeight", "pt histogram %s not found", histName);
23  continue;
24  }
25  for (Int_t j = 1; j <= cPt->GetNbinsY(); j++) {
26  cPt->SetBinContent(i, j, hist->GetBinContent(j));
27  cPt->SetBinError (i, j, hist->GetBinError (j));
28  }
29  }
30  weights->SetPtWeight(cPt);
31 
32  TFile* pidFile = TFile::Open("../tracklets/REWEIGHTpid.root","READ");
33  Double_t c2Bins[] = { 0, 2.5, 5, 7.5, 10, 20, 30,
34  40, 50, 60, 70, 80, 90, 100 };
35  Short_t pids[] = { 211, 321, 2212 };
36  for (Int_t i = 0; i < 3; i++) {
37  TString histName;
38  Short_t pdg = pids[i];
39  histName.Form("pidWeight_%s", (pdg == 211 ? "pi" :
40  pdg == 321 ? "ka" :
41  "pr"));
42  TH1* hist = static_cast<TH1*>(pidFile->Get(histName));
43  if (!hist) {
44  Warning("MakeWeight", "pid histogram %s not found", histName.Data());
45  continue;
46  }
47  TH1D* out = new TH1D(Form("w%d", pdg), Form("PID %d weight", pdg),
48  13, c2Bins);
49  for (Int_t j = 1; j <= out->GetNbinsX(); j++) {
50  out->SetBinContent(j, hist->GetBinContent(j));
51  out->SetBinError (j, hist->GetBinError (j));
52  }
53  weights->AddAbundanceWeight(pdg, out);
54  }
55 
56  TFile* strFile = TFile::Open("../tracklets/REWEIGHTstr.root","READ");
57  Short_t strs[] = { 211, 321, 2212, 310, 3122, 3212, 3322 };
58  for (Int_t i = 0; i < 7; i++) {
59  TString histName;
60  Short_t pdg = strs[i];
61  histName.Form("strWeight_%s", (pdg == 211 ? "pi" :
62  pdg == 321 ? "ka" :
63  pdg == 2212 ? "pr" :
64  pdg == 310 ? "k0" :
65  pdg == 3122 ? "la" :
66  pdg == 3212 ? "si" :
67  pdg == 3322 ? "xi" : ""));
68  TH1* hist = static_cast<TH1*>(strFile->Get(histName));
69  if (!hist) {
70  Warning("MakeWeight", "strangeness histogram %s not found",
71  histName.Data());
72  continue;
73  }
74  TH1D* out = new TH1D(Form("w%d", pdg), Form("Strangeness %d weight", pdg),
75  13, c2Bins);
76  for (Int_t j = 1; j <= out->GetNbinsX(); j++) {
77  out->SetBinContent(j, hist->GetBinContent(j));
78  out->SetBinError (j, hist->GetBinError (j));
79  }
80  weights->AddStrangenessWeight(pdg, out);
81  }
82 
83 
84 
85 
86  new TBrowser;
87 
88  TFile* outW = TFile::Open("weights.root", "RECREATE");
89  weights->Write();
90  outW->Write();
91  weights->Draw();
92  weights->Print();
93 }
Int_t pdg
double Double_t
Definition: External.C:58
Bool_t AddAbundanceWeight(Short_t pdg, const TH1D *h, UShort_t mode=0)
Bool_t AddStrangenessWeight(Short_t pdg, const TH1D *h, UShort_t mode=0)
TSystem * gSystem
void Print(Option_t *option="") const
void Draw(Option_t *option="")
int Int_t
Definition: External.C:63
Definition: External.C:228
Definition: External.C:212
Bool_t SetPtWeight(const TH2D *h, UShort_t mode=0)
short Short_t
Definition: External.C:23
Definition: External.C:196
void MakeWeight()
Definition: MakeWeight.C:2