]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/AliAODForwardMult.cxx
Various upgrades. NSD true trigger for MC, pileup selection for analysis, fixes for...
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / AliAODForwardMult.cxx
1 //
2 // Class that contains the forward multiplicity data per event 
3 //
4 // This class contains a histogram of 
5 // @f[
6 //   \frac{d^2N_{ch}}{d\eta d\phi}\quad,
7 // @f]
8 // as well as a trigger mask for each analysed event.  
9 // 
10 // The eta acceptance of the event is stored in the underflow bins of
11 // the histogram.  So to build the final histogram, one needs to
12 // correct for this acceptance (properly weighted by the events), and
13 // the vertex efficiency.  This simply boils down to defining a 2D
14 // histogram and summing the event histograms in that histogram.  One
15 // should of course also do proper book-keeping of the accepted event.
16 //
17 #include "AliAODForwardMult.h"
18 #include <TBrowser.h>
19 #include <iostream>
20 #include <TMath.h>
21 #include <TObjString.h>
22
23 ClassImp(AliAODForwardMult)
24 #if 0 
25 ; // For Emacs 
26 #endif
27
28 //____________________________________________________________________
29 const Float_t AliAODForwardMult::fgkInvalidIpZ = 1e6;
30
31 //____________________________________________________________________
32 AliAODForwardMult::AliAODForwardMult()
33   : fIsMC(false),
34     fHist(),
35     fTriggers(0),
36     fIpZ(fgkInvalidIpZ), 
37     fCentrality(-1)
38 {
39   // 
40   // Constructor 
41   // 
42 }
43
44 //____________________________________________________________________
45 AliAODForwardMult::AliAODForwardMult(Bool_t isMC) 
46   : fIsMC(isMC),
47     fHist("forwardMult", "d^{2}N_{ch}/d#etad#varphi in the forward regions", 
48           200, -4, 6, 20, 0, 2*TMath::Pi()),
49     fTriggers(0),
50     fIpZ(fgkInvalidIpZ), 
51     fCentrality(-1)
52 {
53   // 
54   // Constructor 
55   // 
56   // Parameters: 
57   //  isMC   If set to true this is for MC data (effects branch name)
58   // 
59   fHist.SetXTitle("#eta");
60   fHist.SetYTitle("#varphi [radians]");
61   fHist.SetZTitle("#frac{d^{2}N_{ch}}{d#etad#varphi}");
62   fHist.SetDirectory(0);
63   fHist.Sumw2();
64 }
65
66 //____________________________________________________________________
67 void
68 AliAODForwardMult::Init(const TAxis& etaAxis)
69 {
70   // Initialize the histogram with an eta axis 
71   // 
72   // Parameters: 
73   //   etaAxis       Eta axis to use 
74   // 
75   fHist.SetBins(etaAxis.GetNbins(), etaAxis.GetXmin(), etaAxis.GetXmax(), 
76                 20, 0, 2*TMath::Pi());
77 }
78
79 //____________________________________________________________________
80 void
81 AliAODForwardMult::Clear(Option_t* option)
82 {
83   // Clear (or reset) internal values 
84   // 
85   // Parameters: 
86   //  option   Passed to TH1::Reset 
87   // 
88   fHist.Reset(option);
89   fTriggers = 0;
90   fIpZ      = fgkInvalidIpZ;
91 }
92 //____________________________________________________________________
93 void
94 AliAODForwardMult::SetSNN(UShort_t snn)
95 {
96   // set the center of mass energy per nucleon pair (GeV). 
97   // This is stored in bin (0,0) of the histogram 
98   // 
99   // Parameters: 
100   //   sNN   Center of mass energy per nuclean 
101   fHist.SetBinContent(0,0,snn);
102 }
103 //____________________________________________________________________
104 void
105 AliAODForwardMult::SetSystem(UShort_t sys)
106 {
107   // set the center of mass energy per nucleon pair (GeV). 
108   // This is stored in bin (N+1,0) of the histogram 
109   // 
110   // Parameters: 
111   //   sys   Collision system number 
112   fHist.SetBinContent(fHist.GetNbinsX()+1,0,sys);
113 }
114
115 //____________________________________________________________________
116 Bool_t
117 AliAODForwardMult::HasIpZ() const
118 {
119   // Check if we have valid z coordinate of the interaction point 
120   // 
121   // Return:
122   //   true if the z coordinate of the interaction point is valid 
123   // 
124   return TMath::Abs(fIpZ - fgkInvalidIpZ) > 1;
125 }
126
127 //____________________________________________________________________
128 UShort_t
129 AliAODForwardMult::GetSNN() const
130 {
131   // set the center of mass energy per nucleon pair (GeV). 
132   // This is stored in bin (0,0) of the histogram 
133   // 
134   // Parameters: 
135   //   sNN   Center of mass energy per nuclean 
136   return UShort_t(fHist.GetBinContent(0,0));
137 }
138
139 //____________________________________________________________________
140 UShort_t
141 AliAODForwardMult::GetSystem() const
142 {
143   // set the center of mass energy per nucleon pair (GeV). 
144   // This is stored in bin (N+1,0) of the histogram 
145   // 
146   // Parameters: 
147   //   sNN   Center of mass energy per nuclean 
148   return UShort_t(fHist.GetBinContent(fHist.GetNbinsX()+1,0));
149 }
150
151 //____________________________________________________________________
152 void
153 AliAODForwardMult::Browse(TBrowser* b)
154 {
155   // Browse this object 
156   // 
157   // Parameters: 
158   //   b   Browser to use 
159   static TObjString ipz;
160   static TObjString trg;
161   static TObjString cnt;
162   ipz = Form("ip_z=%fcm", fIpZ);
163   trg = GetTriggerString(fTriggers);
164   cnt = Form("%+6.1f%%", fCentrality);
165   b->Add(&fHist);
166   b->Add(&ipz);
167   b->Add(&trg);
168   b->Add(&cnt);
169 }
170
171 //____________________________________________________________________
172 const Char_t*
173 AliAODForwardMult::GetTriggerString(UInt_t mask)
174 {
175   // Get a string that describes the triggers 
176   // 
177   // Parameters: 
178   //   mask  Bit pattern of triggers 
179   // Return: 
180   //   Character string representation of mask 
181   static TString trg;
182   trg = "";
183   if ((mask & kInel)        != 0x0) trg.Append("INEL ");
184   if ((mask & kInelGt0)     != 0x0) trg.Append("INEL>0 ");
185   if ((mask & kNSD)         != 0x0) trg.Append("NSD ");
186   if ((mask & kA)           != 0x0) trg.Append("A ");
187   if ((mask & kB)           != 0x0) trg.Append("B ");
188   if ((mask & kC)           != 0x0) trg.Append("C ");
189   if ((mask & kE)           != 0x0) trg.Append("E ");
190   if ((mask & kMCNSD)       != 0x0) trg.Append("MCNSD ");
191   return trg.Data();
192 }
193   
194 //____________________________________________________________________
195 void
196 AliAODForwardMult::Print(Option_t* option) const
197 {
198   // Print this object 
199   // 
200   // Parameters: 
201   //  option   Passed to TH1::Print 
202   fHist.Print(option);
203   UShort_t sys = GetSystem();
204   TString  str = "unknown";
205   switch (sys) { 
206   case 1:  str = "pp"; break;
207   case 2:  str = "PbPb"; break;
208   }
209   std::cout << "Ipz:         " << fIpZ << "cm " << (HasIpZ() ? "" : "in") 
210             << "valid\n"
211             << "Triggers:    " << GetTriggerString(fTriggers) 
212             << "sNN:         " << GetSNN() << "GeV\n" 
213             << "System:      " << str 
214             << "Centrality:  " << fCentrality << "%" 
215             << std::endl;
216 }
217
218 //____________________________________________________________________
219 //
220 // EOF
221 //