]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/AliAODForwardMult.cxx
Mostly documentation changes.
[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 #ifdef DOXY_INPUT
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 TH1I*
196 AliAODForwardMult::MakeTriggerHistogram(const char* name) 
197 {
198   // 
199   // Make a histogram to record triggers in. 
200   //
201   // The bins defined by the trigger enumeration in this class.  One
202   // can use this enumeration to retrieve the number of triggers for
203   // each class.
204   // 
205   // Parameters:
206   //    name Name of the histogram 
207   // 
208   // Return:
209   //    Newly allocated histogram 
210   //
211   TH1I* ret = new TH1I(name, "Triggers", kAccepted+1, -.5, kAccepted+.5);
212   ret->SetYTitle("Events");
213   ret->SetFillColor(kRed+1);
214   ret->SetFillStyle(3001);
215   ret->GetXaxis()->SetBinLabel(kBinAll,         "All events");
216   ret->GetXaxis()->SetBinLabel(kBinB,           "w/B trigger");
217   ret->GetXaxis()->SetBinLabel(kBinA,           "w/A trigger");
218   ret->GetXaxis()->SetBinLabel(kBinC,           "w/C trigger");
219   ret->GetXaxis()->SetBinLabel(kBinE,           "w/E trigger");
220   ret->GetXaxis()->SetBinLabel(kBinInel,        "Minimum Bias");
221   ret->GetXaxis()->SetBinLabel(kBinInelGt0,     "INEL>0");
222   ret->GetXaxis()->SetBinLabel(kBinNSD,         "NSD");
223   ret->GetXaxis()->SetBinLabel(kBinMCNSD,       "NSD (MC truth)");
224   ret->GetXaxis()->SetBinLabel(kBinPileUp,      "w/Pileup");
225   ret->GetXaxis()->SetBinLabel(kWithVertex,     "w/Vertex");
226   ret->GetXaxis()->SetBinLabel(kWithTrigger,    "w/Selected trigger");
227   ret->GetXaxis()->SetBinLabel(kAccepted,       "Accepted by cut");
228   ret->GetXaxis()->SetNdivisions(kAccepted, false);
229   ret->SetStats(0);
230
231   return ret;
232 }
233
234 //____________________________________________________________________
235 Bool_t
236 AliAODForwardMult::CheckEvent(Int_t    triggerMask,
237                               Double_t vzMin, Double_t vzMax,
238                               UShort_t cMin,  UShort_t cMax, 
239                               TH1*     hist) const
240 {
241   // 
242   // Check if event meets the passses requirements.   
243   //
244   // It returns true if @e all of the following is true 
245   //
246   // - The trigger is within the bit mask passed.
247   // - The vertex is within the specified limits. 
248   // - The centrality is within the specified limits, or if lower
249   //   limit is equal to or larger than the upper limit.
250   // 
251   // If a histogram is passed in the last parameter, then that
252   // histogram is filled with the trigger bits. 
253   // 
254   // Parameters:
255   //    triggerMask  Trigger mask
256   //    vzMin        Minimum @f$ v_z@f$ (in centimeters)
257   //    vzMax        Maximum @f$ v_z@f$ (in centimeters) 
258   //    cMin         Minimum centrality (in percent)
259   //    cMax         Maximum centrality (in percent)
260   //    hist         Histogram to fill 
261   // 
262   // Return:
263   //    @c true if the event meets the requirements 
264   //
265   if (cMin < cMax && (cMin > fCentrality || cMax <= fCentrality)) return false;
266
267   if (hist) { 
268     hist->AddBinContent(kBinAll);
269     if (IsTriggerBits(kB))        hist->AddBinContent(kBinB);
270     if (IsTriggerBits(kA))        hist->AddBinContent(kBinA);
271     if (IsTriggerBits(kC))        hist->AddBinContent(kBinC);
272     if (IsTriggerBits(kE))        hist->AddBinContent(kBinE);
273     if (IsTriggerBits(kInel))     hist->AddBinContent(kBinInel);
274     if (IsTriggerBits(kInelGt0))  hist->AddBinContent(kBinInelGt0);
275     if (IsTriggerBits(kNSD))      hist->AddBinContent(kBinNSD);
276     if (IsTriggerBits(kPileUp))   hist->AddBinContent(kBinPileUp);
277     if (IsTriggerBits(kMCNSD))    hist->AddBinContent(kBinMCNSD);
278   }
279   // Check if we have an event of interest. 
280   if (!IsTriggerBits(triggerMask)) return false;
281   
282   // Check for pileup
283   if (IsTriggerBits(kPileUp)) return false;
284   if (hist) hist->AddBinContent(kWithTrigger);
285   
286   // Check that we have a valid vertex
287   if (!HasIpZ()) return false;
288   if (hist) hist->AddBinContent(kWithVertex);
289
290   // Check that vertex is within cuts 
291   if (!InRange(vzMin, vzMax)) return false;
292   if (hist) hist->AddBinContent(kAccepted);
293   
294   return true;
295 }
296
297 //____________________________________________________________________
298 void
299 AliAODForwardMult::Print(Option_t* option) const
300 {
301   // Print this object 
302   // 
303   // Parameters: 
304   //  option   Passed to TH1::Print 
305   fHist.Print(option);
306   UShort_t sys = GetSystem();
307   TString  str = "unknown";
308   switch (sys) { 
309   case 1:  str = "pp"; break;
310   case 2:  str = "PbPb"; break;
311   }
312   std::cout << "Ipz:         " << fIpZ << "cm " << (HasIpZ() ? "" : "in") 
313             << "valid\n"
314             << "Triggers:    " << GetTriggerString(fTriggers) 
315             << "sNN:         " << GetSNN() << "GeV\n" 
316             << "System:      " << str 
317             << "Centrality:  " << fCentrality << "%" 
318             << std::endl;
319 }
320
321 //____________________________________________________________________
322 //
323 // EOF
324 //