AliPhysics  56f1704 (56f1704)
AliSimplePidWeights.cxx
Go to the documentation of this file.
1 
11 #include "AliSimplePidWeights.h"
12 #include "AliForwardUtil.h"
13 #include <TROOT.h>
14 #include <iostream>
15 
16 //____________________________________________________________________
18  : AliBaseMCWeights(),
19  fPdgs(10),
20  fWeights(10)
21 {
22 }
23 //____________________________________________________________________
25  : AliBaseMCWeights(o),
26  fPdgs(o.fPdgs),
28 {
29 }
30 
31 //____________________________________________________________________
34 {
35  if (&o == this) return *this;
36 
38  fWeights = o.fWeights;
39  fPdgs = o.fPdgs;
40 
41  return *this;
42 }
43 //____________________________________________________________________
45 {}
46 
47 //____________________________________________________________________
49  Double_t,
50  Double_t,
51  Int_t id,
52  Double_t,
53  Double_t) const
54 {
55  for (Int_t i = 0; i < fPdgs.GetSize(); i++) {
56  Int_t v = fPdgs.At(i);
57  if (v == 0) break;
58  if (v == id) return fWeights.At(i);
59  }
60  return 1.;
61 }
62 //____________________________________________________________________
64 {
65 
66  Int_t n = fPdgs.GetSize();
67  Int_t pos = 0;
68 
69  // Find first empty slot
70  for (pos = 0; pos < n; pos++) if (fPdgs.At(pos) == 0) break;
71 
72  // If no empty slot is found, resize to twice the size
73  if (pos >= n) {
74  fPdgs.Set(2*n);
75  fWeights.Set(2*n);
76  }
77 
78  // Now set the slot
79  fPdgs.AddAt(pdg, pos);
80  fWeights.AddAt(factor, pos);
81 
82  if (anti) AddPDGCode(-pdg,factor,false);
83 }
84 #define PF(N,V,...) \
85  AliForwardUtil::PrintField(N,V, ## __VA_ARGS__)
86 #define PFB(N,FLAG) \
87  do { \
88  AliForwardUtil::PrintName(N); \
89  std::cout << std::boolalpha << (FLAG) << std::noboolalpha << std::endl; \
90  } while(false)
91 #define PFV(N,VALUE) \
92  do { \
93  AliForwardUtil::PrintName(N); \
94  std::cout << (VALUE) << std::endl; } while(false)
95 
96 //____________________________________________________________________
98 {
99  PFV("MC Weights", "Simple PID based");
100  gROOT->IncreaseDirLevel();
101  for (Int_t i = 0; i < fPdgs.GetSize(); i++) {
102  Int_t v = fPdgs.At(i);
103  if (v == 0) break;
104  PFV(Form("%d", v), fWeights.At(i));
105  }
106  gROOT->DecreaseDirLevel();
107 }
108 
109 //____________________________________________________________________
110 //
111 // EOF
112 //
Int_t pdg
double Double_t
Definition: External.C:58
AliSimplePidWeights & operator=(const AliSimplePidWeights &o)
virtual Double_t CalcWeight(Double_t eta, Double_t pt, Double_t phi, Int_t id, Double_t phiR, Double_t b) const
virtual void Print(Option_t *option="") const
#define PFV(N, VALUE)
int Int_t
Definition: External.C:63
AliBaseMCWeights & operator=(const AliBaseMCWeights &o)
Various utilities used in PWGLF/FORWARD.
const char Option_t
Definition: External.C:48
bool Bool_t
Definition: External.C:53
virtual void AddPDGCode(Int_t pdg, Double_t weight, Bool_t anti=false)
virtual void Init(TList *l)