]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/older/DrawRes2D.C
New implementation of the forward multiplicity analysis.
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / older / DrawRes2D.C
1 #include "DrawResBase.h"
2
3 /** 
4  * @defgroup pwg2_forward_analysis_scripts PWG2 Forward analysis - scripts
5  *
6  * @ingroup pwg2_forward_analysis
7  */
8 /** 
9  * Example macro to loop over the event-by-event 2D histogram of 
10  * @f[
11  *   \frac{d^{2}N_{ch}}{d\eta\,d\phi}
12  * @f]
13  * stored in an AOD.  
14  * 
15  * The class needs the files &lt;<i>base</i>&gt;<tt>_hists.root</tt> 
16  * containing the histograms generated by AliForwardMultiplicity and 
17  * the file &lt;<i>base</i>&gt;<tt>_aods.root</tt> containing the tree 
18  * with AliAODEvent objects where AliAODForwardMult objects have been 
19  * added to in the branch <tt>Forward</tt>
20  * 
21  * @ingroup pwg2_forward_analysis_scripts
22  */
23 class DrawRes2D : public DrawResBase
24 {
25 public:
26   /** 
27    * Constructor 
28    * 
29    * @param special If true, add to the list of 'specials'
30    */
31   DrawRes2D()
32     : fTotal2D(0)
33   {
34   }
35   //__________________________________________________________________
36   virtual void Clear(Option_t* option) 
37   {
38     DrawResBase::Clear(option);
39     if (fTotal2D) delete fTotal2D;
40     fTotal2D = 0;
41   }
42   //__________________________________________________________________
43   Bool_t IsInit() const { return fTotal2D; }
44   //__________________________________________________________________
45   /** 
46    * Utility function to set-up histograms based on the input 
47    * @f$ dd^{2}N_{ch}/d\eta\,d\phi@f$ histogram.   This member function 
48    * is called on the first event so that we have the proper binning 
49    * 
50    * @param templ Input histogram
51    * 
52    * @return true on succcess
53    */
54   Bool_t FirstEvent(const TH2D& templ) 
55   { 
56     if (!DrawResBase::FirstEvent(templ)) return kFALSE;
57
58     const TAxis* etaAxis = templ.GetXaxis();
59     const TAxis* phiAxis = templ.GetYaxis();
60     
61     // Generate sum histograms. 
62     // - fTotal2D will be the direct sum of the input histograms. 
63     fTotal2D = new TH2D("d2ndetadphi", "1/N dN^{2}_{ch}/d#etad#phi", 
64                         etaAxis->GetNbins(),
65                         etaAxis->GetXmin(),
66                         etaAxis->GetXmax(),
67                         phiAxis->GetNbins(),
68                         phiAxis->GetXmin(),
69                         phiAxis->GetXmax());
70     fTotal2D->SetXTitle("#eta");
71     fTotal2D->SetYTitle("#varphi [radians]");
72     fTotal2D->SetZTitle(fTotal2D->GetTitle());
73     fTotal2D->Sumw2();
74     fTotal2D->SetStats(0);
75     fTotal2D->SetDirectory(0);
76
77     return kTRUE;
78   }
79
80
81   //__________________________________________________________________
82   /** 
83    * Process the events 
84    * 
85    * 
86    * @return true on success, false otherwise 
87    */
88   void AddContrib(const TH2D& hist, Int_t) 
89   {
90     fTotal2D->Add(&hist);
91   }
92   //__________________________________________________________________
93   /** 
94    * Process the events 
95    * 
96    * 
97    * @return true on success, false otherwise 
98    */
99   TH1D* GetResult()
100   {
101     // Do not sum underflow bins!
102     TH1D* proj = fTotal2D->ProjectionX("dndeta_proj", 1, -1, "e");
103     TH1D* norm = fTotal2D->ProjectionX("norm", 0, 1, "");
104     proj->SetTitle("1/N dN_{ch}/d#eta");
105     proj->Divide(norm);
106     proj->Scale(1., "width");
107     return proj;
108   }
109   /** 
110    * Browse this object 
111    * 
112    * @param b Browser to use 
113    */
114   void Browse(TBrowser* b) 
115   {
116     if (fTotal2D) b->Add(fTotal2D);
117     DrawResBase::Browse(b);
118   }
119   /** 
120    * Create a new object of this class, and add it to the list of 
121    * specials, and create a browse and browse to this object 
122    * 
123    * @return Newly created object
124    */
125   static DrawResBase* Create() 
126   {
127     DrawRes2D* dr = new DrawRes2D;
128     gROOT->GetListOfSpecials()->Add(dr);
129     TBrowser* b = new TBrowser("b");
130     b->BrowseObject(gROOT->GetListOfSpecials());
131     return dr;
132   }
133 protected:
134   TH2D*              fTotal2D;   // Direct sum of input histograms
135
136   ClassDef(DrawRes2D,0)
137 };
138
139 //
140 // EOF
141 //