]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/AliAODForwardMult.h
New implementation of the forward multiplicity analysis.
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / AliAODForwardMult.h
1 #ifndef ALIROOT_PWG2_FORWARD_ANALYSIS_ALIAODFORWARDMULT_H
2 #define ALIROOT_PWG2_FORWARD_ANALYSIS_ALIAODFORWARDMULT_H
3 #include <TObject.h>
4 #include <TH2D.h>
5 class TBrowser;
6 /**
7  * Class that contains the forward multiplicity data per event 
8  *
9  * This class contains a histogram of 
10  * @f[
11  *   \frac{d^2N_{ch}}{d\eta d\phi}\quad,
12  * @f]
13  * as well as a trigger mask for each analysed event.  
14  * 
15  * The eta acceptance of the event is stored in the underflow bins of
16  * the histogram.  So to build the final histogram, one needs to
17  * correct for this acceptance (properly weighted by the events), and
18  * the vertex efficiency.  This simply boils down to defining a 2D
19  * histogram and summing the event histograms in that histogram.  One
20  * should of course also do proper book-keeping of the accepted event.
21  *
22  * @code 
23  *   TH2D*              sum        = 0;                   // Summed hist
24  *   TTree*             tree       = GetAODTree();        // AOD tree
25  *   AliAODForwardMult* mult       = 0;                   // AOD object
26  *   Int_t              nTriggered = 0;                   // # of triggered ev.
27  *   Int_t              nAccepted  = 0;                   // # of ev. w/vertex
28  *   Int_t              nAvailable = tree->GetEntries();  // How many entries
29  *   Float_t            vzLow      = -10;                 // Lower ip cut
30  *   Float_t            vzHigh     =  10;                 // Upper ip cut
31  *   Int_t              mask       = AliAODForward::kINEL;// Trigger mask
32  *   tree->SetBranchAddress("forward", &forward);         // Set the address
33  * 
34  *   for (int i = 0; i < nAvailable; i++) { 
35  *     // Create sum histogram on first event - to match binning to input
36  *     if (!sum) sum = static_cast<TH2D*>(mult->Clone("d2ndetadphi"));
37  * 
38  *     tree->GetEntry(i);
39  * 
40  *     // Other trigger/event requirements could be defined 
41  *     if (!mult->IsTriggerBits(mask)) continue; 
42  *     nTriggered++;
43  * 
44  *     // Select vertex range (in centimeters) 
45  *     if (!mult->InRange(vzLow, vzHigh) continue; 
46  *     nAccepted++;
47  * 
48  *     // Add contribution from this event
49  *     sum->Add(&(mult->GetHistogram()));
50  *   }
51  * 
52  *   // Get acceptance normalisation from underflow bins 
53  *   TH1D* norm   = sum->Projection("norm", 0, 1, "");
54  *   // Project onto eta axis - _ignoring_underflow_bins_!
55  *   TH1D* dndeta = sum->Projection("dndeta", 1, -1, "e");
56  *   // Normalize to the acceptance 
57  *   dndeta->Divide(norm);
58  *   // Scale by the vertex efficiency 
59  *   dndeta->Scale(Double_t(nAccepted)/nTriggered, "width");
60  *   // And draw the result
61  *   dndeta->Draw();
62  * @endcode   
63  *     
64  * The above code will draw the final @f$ dN_{ch}/d\eta@f$ for the
65  * selected event class and vertex range
66  *
67  * The histogram can be used as input for other kinds of analysis too, 
68  * like flow, event-plane, centrality, and so on. 
69  *
70  * @ingroup pwg2_forward_analysis 
71  */
72 class AliAODForwardMult : public TObject
73 {
74 public:
75   /** 
76    * Bits of the trigger pattern
77    */
78   enum { 
79     /** In-elastic collision */
80     kInel     = 0x001, 
81     /** In-elastic collision with at least one SPD tracklet */
82     kInelGt0  = 0x002, 
83     /** Non-single diffractive collision */
84     kNSD      = 0x004, 
85     /** Empty bunch crossing */
86     kEmpty    = 0x008, 
87     /** A-side trigger */
88     kA        = 0x010, 
89     /** B(arrel) trigger */
90     kB        = 0x020, 
91     /** C-side trigger */
92     kC        = 0x080,  
93     /** Empty trigger */
94     kE        = 0x100
95   };
96   /** 
97    * Default constructor 
98    * 
99    * Used by ROOT I/O sub-system - do not use
100    */
101   AliAODForwardMult();
102   /** 
103    * Constructor 
104    * 
105    */
106   AliAODForwardMult(Bool_t);
107   /** 
108    * Destructor 
109    */
110   ~AliAODForwardMult() {}
111   /** 
112    * Initialize 
113    * 
114    * @param etaAxis  Pseudo-rapidity axis
115    */
116   void Init(const TAxis& etaAxis);
117   /** 
118    * Get the @f$ d^2N_{ch}/d\eta d\phi@f$ histogram, 
119    *
120    * @return @f$ d^2N_{ch}/d\eta d\phi@f$ histogram, 
121    */  
122   const TH2D& GetHistogram() const { return fHist; }
123   /** 
124    * Get the @f$ d^2N_{ch}/d\eta d\phi@f$ histogram, 
125    *
126    * @return @f$ d^2N_{ch}/d\eta d\phi@f$ histogram, 
127    */  
128   TH2D& GetHistogram() { return fHist; }
129   /** 
130    * Get the trigger mask 
131    * 
132    * @return Trigger mask 
133    */
134   UInt_t GetTriggerMask() const { return fTriggers; }
135   /** 
136    * Set the trigger mask 
137    * 
138    * @param trg Trigger mask
139    */
140   void SetTriggerMask(UInt_t trg) { fTriggers = trg; }
141   /** 
142    * Set bit(s) in trigger mask 
143    * 
144    * @param bits bit(s) to set 
145    */
146   void SetTriggerBits(UInt_t bits) { fTriggers |= bits; }
147   /** 
148    * Check if bit(s) are set in the trigger mask 
149    * 
150    * @param bits Bits to test for 
151    * 
152    * @return 
153    */
154   Bool_t IsTriggerBits(UInt_t bits) const;
155   /** 
156    * Whether we have any trigger bits 
157    */
158   Bool_t HasTrigger() const { return fTriggers != 0; }
159   /** 
160    * Clear all data 
161    * 
162    * @param option  Passed on to TH2::Reset verbatim
163    */
164   void Clear(Option_t* option="");
165   /** 
166    * browse this object 
167    * 
168    * @param b Browser 
169    */
170   void Browse(TBrowser* b);
171   /** 
172    * This is a folder 
173    * 
174    * @return Always true
175    */
176   Bool_t IsFolder() const { return kTRUE; }
177   /** 
178    * Print content 
179    * 
180    * @param option Passed verbatim to TH2::Print 
181    */
182   void Print(Option_t* option="") const;
183   /** 
184    * Set the z coordinate of the interaction point
185    * 
186    * @param ipZ Interaction point z coordinate
187    */
188   void SetIpZ(Float_t ipZ) { fIpZ = ipZ; }
189   /** 
190    * Set the z coordinate of the interaction point
191    * 
192    * @return Interaction point z coordinate
193    */
194   Float_t GetIpZ() const { return fIpZ; }
195   /** 
196    * Check if we have a valid z coordinate of the interaction point
197    *
198    * @return True if we have a valid interaction point z coordinate
199    */
200   Bool_t HasIpZ() const;
201   /** 
202    * Check if the z coordinate of the interaction point is within the
203    * given limits.  Note that the convention used corresponds to the
204    * convention used in ROOTs TAxis.
205    * 
206    * @param low  Lower cut (inclusive)
207    * @param high Upper cut (exclusive)
208    * 
209    * @return true if @f$ low \ge ipz < high@f$ 
210    */
211   Bool_t InRange(Float_t low, Float_t high) const;
212   /** 
213    * Get the name of the object 
214    * 
215    * @return Name of object 
216    */
217   const Char_t* GetName() const { return "Forward"; }
218   /** 
219    * Get a string correspondig to the trigger mask
220    * 
221    * @param mask Trigger mask 
222    * 
223    * @return Static string (copy before use)
224    */
225   static const Char_t* GetTriggerString(UInt_t mask);
226 protected: 
227   TH2D    fHist;     // Histogram of d^2N_{ch}/(deta dphi) for this event
228   UInt_t  fTriggers; // Trigger bit mask 
229   Float_t fIpZ;      // Z coordinate of the interaction point
230
231   static const Float_t fgkInvalidIpZ; // Invalid IpZ value 
232   ClassDef(AliAODForwardMult,1); // AOD forward multiplicity 
233 };
234
235 //____________________________________________________________________
236 inline Bool_t
237 AliAODForwardMult::InRange(Float_t low, Float_t high) const 
238 {
239   return HasIpZ() && fIpZ >= low && fIpZ < high;
240 }
241
242 //____________________________________________________________________
243 inline Bool_t 
244 AliAODForwardMult::IsTriggerBits(UInt_t bits) const 
245
246   return HasTrigger() && ((fTriggers & bits) != 0); 
247 }
248   
249
250 #endif
251 // Local Variables:
252 //  mode: C++
253 // End:
254