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