AliPhysics  63e47e1 (63e47e1)
AliPtEtaPidWeights.cxx
Go to the documentation of this file.
1 
11 #include "AliPtEtaPidWeights.h"
12 #include "AliForwardUtil.h"
13 #include <TROOT.h>
14 #include <TH2.h>
15 #include <iostream>
16 
17 //____________________________________________________________________
19  : AliBaseMCWeights(),
20  fPdgs(10),
21  fWeights()
22 {
23  fWeights.SetOwner();
24 }
25 //____________________________________________________________________
27  : AliBaseMCWeights(o),
28  fPdgs(o.fPdgs),
29  fWeights()
30 {
31  fWeights.SetOwner();
32  for (int i=0;i<o.fWeights.GetEntries();i++) {
33  TObject* obj = o.fWeights.At(i);
34  fWeights.Add(obj->Clone());
35  }
36 }
37 
38 //____________________________________________________________________
41 {
42  if (&o == this) return *this;
43 
44  fWeights.Clear();
45 
47  fPdgs = o.fPdgs;
48  for (int i = 0; i < o.fWeights.GetEntries(); i++) {
49  TObject* obj = o.fWeights.At(i);
50  fWeights.AddAt(obj->Clone(), i);
51  }
52 
53  return *this;
54 }
55 //____________________________________________________________________
57 {}
58 
59 //____________________________________________________________________
61  Double_t pt,
62  Double_t phi,
63  Int_t id,
64  Double_t phiR,
65  Double_t b) const
66 {
67  for (Int_t i = 0; i < fPdgs.GetSize(); i++) {
68  Int_t v = fPdgs.At(i);
69  if (v == 0)
70  break;
71  if (v == id) {
72  TH2* hist = static_cast<TH2*>(fWeights.At(i));
73  Int_t binpt = hist->GetYaxis()->FindBin(pt);
74  Int_t bineta = hist->GetXaxis()->FindBin(eta);
75  return hist->GetBinContent(bineta,binpt);
76  }
77  }
78  return 1.;
79 }
80 //____________________________________________________________________
82 {
83 
84  Int_t n = fPdgs.GetSize();
85  Int_t pos = 0;
86  // Find first empty slot
87  for (pos = 0; pos < n; pos++) if (fPdgs.At(pos) == 0) break;
88 
89  // If no empty slot is found, resize to twice the size
90  if (pos >= n) {
91  fPdgs.Set(2*n);
92  }
93 
94  // Now set the slot
95  fPdgs.AddAt(pdg, pos);
96  fWeights.AddAt(weight, pos);
97 }
98 //____________________________________________________________________
99 #define PF(N,V,...) \
100  AliForwardUtil::PrintField(N,V, ## __VA_ARGS__)
101 #define PFB(N,FLAG) \
102  do { \
103  AliForwardUtil::PrintName(N); \
104  std::cout << std::boolalpha << (FLAG) << std::noboolalpha << std::endl; \
105  } while(false)
106 #define PFV(N,VALUE) \
107  do { \
108  AliForwardUtil::PrintName(N); \
109  std::cout << (VALUE) << std::endl; } while(false)
110 
111 //____________________________________________________________________
113 {
114  PFV("MC Weights", "PtEta PID based");
115 #if 0
116  gROOT->IncreaseDirLevel();
117  for (Int_t i = 0; i < fPdgs.GetSize(); i++) {
118  Int_t v = fPdgs.At(i);
119  if (v == 0) break;
120  // PFV(Form("%d", v));
121  // fWeights.Print("all");
122  }
123  gROOT->DecreaseDirLevel();
124 #endif
125 }
126 
127 //____________________________________________________________________
128 //
129 // EOF
130 //
virtual void Init(TList *l)
Int_t pdg
double Double_t
Definition: External.C:58
virtual Double_t CalcWeight(Double_t eta, Double_t pt, Double_t phi, Int_t id, Double_t phiR, Double_t b) const
int Int_t
Definition: External.C:63
AliBaseMCWeights & operator=(const AliBaseMCWeights &o)
Various utilities used in PWGLF/FORWARD.
virtual void Print(Option_t *option="") const
virtual void AddPDGCode(Int_t pdg, TH2 *weight)
#define PFV(N, VALUE)
Definition: External.C:220
const char Option_t
Definition: External.C:48
AliPtEtaPidWeights & operator=(const AliPtEtaPidWeights &o)