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