]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/AliAODForwardMult.cxx
Fixes for coverty complaints
[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 {
38   // 
39   // Constructor 
40   // 
41 }
42
43 //____________________________________________________________________
44 AliAODForwardMult::AliAODForwardMult(Bool_t isMC) 
45   : fIsMC(isMC),
46     fHist("forwardMult", "d^{2}N_{ch}/d#etad#varphi in the forward regions", 
47           200, -4, 6, 20, 0, 2*TMath::Pi()),
48     fTriggers(0),
49     fIpZ(fgkInvalidIpZ)
50 {
51   // 
52   // Constructor 
53   // 
54   // Parameters: 
55   //  isMC   If set to true this is for MC data (effects branch name)
56   // 
57   fHist.SetXTitle("#eta");
58   fHist.SetYTitle("#varphi [radians]");
59   fHist.SetZTitle("#frac{d^{2}N_{ch}}{d#etad#varphi}");
60   fHist.SetDirectory(0);
61   fHist.Sumw2();
62 }
63
64 //____________________________________________________________________
65 void
66 AliAODForwardMult::Init(const TAxis& etaAxis)
67 {
68   // Initialize the histogram with an eta axis 
69   // 
70   // Parameters: 
71   //   etaAxis       Eta axis to use 
72   // 
73   fHist.SetBins(etaAxis.GetNbins(), etaAxis.GetXmin(), etaAxis.GetXmax(), 
74                 20, 0, 2*TMath::Pi());
75 }
76
77 //____________________________________________________________________
78 void
79 AliAODForwardMult::Clear(Option_t* option)
80 {
81   // Clear (or reset) internal values 
82   // 
83   // Parameters: 
84   //  option   Passed to TH1::Reset 
85   // 
86   fHist.Reset(option);
87   fTriggers = 0;
88   fIpZ      = fgkInvalidIpZ;
89 }
90 //____________________________________________________________________
91 void
92 AliAODForwardMult::SetSNN(UShort_t snn)
93 {
94   // set the center of mass energy per nucleon pair (GeV). 
95   // This is stored in bin (0,0) of the histogram 
96   // 
97   // Parameters: 
98   //   sNN   Center of mass energy per nuclean 
99   fHist.SetBinContent(0,0,snn);
100 }
101 //____________________________________________________________________
102 void
103 AliAODForwardMult::SetSystem(UShort_t sys)
104 {
105   // set the center of mass energy per nucleon pair (GeV). 
106   // This is stored in bin (N+1,0) of the histogram 
107   // 
108   // Parameters: 
109   //   sys   Collision system number 
110   fHist.SetBinContent(fHist.GetNbinsX()+1,0,sys);
111 }
112
113 //____________________________________________________________________
114 Bool_t
115 AliAODForwardMult::HasIpZ() const
116 {
117   // Check if we have valid z coordinate of the interaction point 
118   // 
119   // Return:
120   //   true if the z coordinate of the interaction point is valid 
121   // 
122   return TMath::Abs(fIpZ - fgkInvalidIpZ) > 1;
123 }
124
125 //____________________________________________________________________
126 UShort_t
127 AliAODForwardMult::GetSNN() const
128 {
129   // set the center of mass energy per nucleon pair (GeV). 
130   // This is stored in bin (0,0) of the histogram 
131   // 
132   // Parameters: 
133   //   sNN   Center of mass energy per nuclean 
134   return UShort_t(fHist.GetBinContent(0,0));
135 }
136
137 //____________________________________________________________________
138 UShort_t
139 AliAODForwardMult::GetSystem() const
140 {
141   // set the center of mass energy per nucleon pair (GeV). 
142   // This is stored in bin (N+1,0) of the histogram 
143   // 
144   // Parameters: 
145   //   sNN   Center of mass energy per nuclean 
146   return UShort_t(fHist.GetBinContent(fHist.GetNbinsX()+1,0));
147 }
148
149 //____________________________________________________________________
150 void
151 AliAODForwardMult::Browse(TBrowser* b)
152 {
153   // Browse this object 
154   // 
155   // Parameters: 
156   //   b   Browser to use 
157   static TObjString ipz;
158   static TObjString trg;
159   ipz = Form("ip_z=%fcm", fIpZ);
160   trg = GetTriggerString(fTriggers);
161   b->Add(&fHist);
162   b->Add(&ipz);
163   b->Add(&trg);
164 }
165
166 //____________________________________________________________________
167 const Char_t*
168 AliAODForwardMult::GetTriggerString(UInt_t mask)
169 {
170   // Get a string that describes the triggers 
171   // 
172   // Parameters: 
173   //   mask  Bit pattern of triggers 
174   // Return: 
175   //   Character string representation of mask 
176   static TString trg;
177   trg = "";
178   if ((mask & kInel)    != 0x0) trg.Append("INEL ");
179   if ((mask & kInelGt0) != 0x0) trg.Append("INEL>0 ");
180   if ((mask & kNSD)     != 0x0) trg.Append("NSD ");
181   if ((mask & kA)       != 0x0) trg.Append("A ");
182   if ((mask & kB)       != 0x0) trg.Append("B ");
183   if ((mask & kC)       != 0x0) trg.Append("C ");
184   if ((mask & kE)       != 0x0) trg.Append("E ");
185   return trg.Data();
186 }
187   
188 //____________________________________________________________________
189 void
190 AliAODForwardMult::Print(Option_t* option) const
191 {
192   // Print this object 
193   // 
194   // Parameters: 
195   //  option   Passed to TH1::Print 
196   fHist.Print(option);
197   UShort_t sys = GetSystem();
198   TString  str = "unknown";
199   switch (sys) { 
200   case 1:  str = "pp"; break;
201   case 2:  str = "PbPb"; break;
202   }
203   std::cout << "Ipz:      " << fIpZ << "cm " << (HasIpZ() ? "" : "in") 
204             << "valid\n"
205             << "Triggers: " << GetTriggerString(fTriggers) 
206             << "sNN:      " << GetSNN() << "GeV\n" 
207             << "System:   " << str 
208             << std::endl;
209 }
210
211 //____________________________________________________________________
212 //
213 // EOF
214 //