]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/older/DrawRes1D.C
New implementation of the forward multiplicity analysis.
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / older / DrawRes1D.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 DrawRes1D : public DrawResBase
24 {
25 public:
26   /** 
27    * Constructor 
28    * 
29    * @param special If true, add to the list of 'specials'
30    */
31   DrawRes1D()
32     : fTotal1D(0)
33   {}
34   //__________________________________________________________________
35   virtual void Clear(Option_t* option) 
36   {
37     DrawResBase::Clear(option);
38     if (fTotal1D) delete fTotal1D;
39     fTotal1D = 0;
40   }
41   //__________________________________________________________________
42   virtual Bool_t IsInit() const { return fTotal1D; }
43   //__________________________________________________________________
44   /** 
45    * Utility function to set-up histograms based on the input 
46    * @f$ dd^{2}N_{ch}/d\eta\,d\phi@f$ histogram.   This member function 
47    * is called on the first event so that we have the proper binning 
48    * 
49    * @param templ Input histogram
50    * 
51    * @return true on succcess
52    */
53   virtual Bool_t FirstEvent(const TH2D& templ) 
54   { 
55     if (!DrawResBase::FirstEvent(templ)) return kFALSE;
56     const TAxis* etaAxis = templ.GetXaxis();
57     
58     // Generate sum histograms. 
59     // - fTotal1D will be the sum of projections on the X axis of the input  
60     //   histograms 
61     fTotal1D = new TH1D("dndeta", 
62                         "#frac{1}{N}#frac{dN_{ch}}{d#eta}",
63                         etaAxis->GetNbins(),
64                         etaAxis->GetXmin(),
65                         etaAxis->GetXmax());
66     fTotal1D->SetMarkerStyle(29);
67     fTotal1D->SetMarkerSize(1);
68     fTotal1D->SetStats(0);
69     fTotal1D->SetDirectory(0);
70     fTotal1D->Sumw2();
71
72     return kTRUE;
73   }
74
75
76   //__________________________________________________________________
77   /** 
78    * Process the events 
79    * 
80    * 
81    * @return true on success, false otherwise 
82    */
83   virtual void AddContrib(const TH2D& hist, Int_t) 
84   {
85     // Make a projection on the X axis of the input histogram 
86     TH1D*    proj  = hist.ProjectionX("_px", 0, -1, "e");
87     
88     // Add to 1D summed histogram
89     fTotal1D->Add(proj); // , scale);
90     
91     // Remove the projection 
92     delete proj;
93   }
94   //__________________________________________________________________
95   /** 
96    * Process the events 
97    * 
98    * 
99    * @return true on success, false otherwise 
100    */
101   virtual TH1D* GetResult() 
102   {
103     // Scale our direct sum of the projects of the input histograms to 
104     // the number of vertex bins and the bin width. If we do rebinning, 
105     // we must scale it one more time.
106     // fTotal1D->Scale(1. / fNAccepted, "width");
107     fTotal1D->Divide(fNorm);
108     fTotal1D->Scale(1., "width");
109     return fTotal1D;
110   }
111   /** 
112    * Browse this object 
113    * 
114    * @param b Browser to use 
115    */
116   virtual void Browse(TBrowser* b) 
117   {
118     if (fTotal1D) b->Add(fTotal1D);
119     DrawResBase::Browse(b);
120   }
121   /** 
122    * Create a new object of this class, and add it to the list of 
123    * specials, and create a browse and browse to this object 
124    * 
125    * @return Newly created object
126    */
127   static DrawRes1D* Create() 
128   {
129     DrawRes1D* dr = new DrawRes1D;
130     gROOT->GetListOfSpecials()->Add(dr);
131     TBrowser* b = new TBrowser("b");
132     b->BrowseObject(gROOT->GetListOfSpecials());
133     return dr;
134   }
135 protected:
136   TH1D*              fTotal1D;   // Direct sum of input histograms
137
138   ClassDef(DrawRes1D,0)
139 };
140
141 //
142 // EOF
143 //