1 #include "DrawResBase.h"
4 * @defgroup pwg2_forward_analysis_scripts PWG2 Forward analysis - scripts
6 * @ingroup pwg2_forward_analysis
9 * Example macro to loop over the event-by-event 2D histogram of
11 * \frac{d^{2}N_{ch}}{d\eta\,d\phi}
15 * The class needs the files <<i>base</i>><tt>_hists.root</tt>
16 * containing the histograms generated by AliForwardMultiplicity and
17 * the file <<i>base</i>><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>
21 * @ingroup pwg2_forward_analysis_scripts
23 class DrawRes1D : public DrawResBase
29 * @param special If true, add to the list of 'specials'
34 //__________________________________________________________________
35 virtual void Clear(Option_t* option)
37 DrawResBase::Clear(option);
38 if (fTotal1D) delete fTotal1D;
41 //__________________________________________________________________
42 virtual Bool_t IsInit() const { return fTotal1D; }
43 //__________________________________________________________________
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
49 * @param templ Input histogram
51 * @return true on succcess
53 virtual Bool_t FirstEvent(const TH2D& templ)
55 if (!DrawResBase::FirstEvent(templ)) return kFALSE;
56 const TAxis* etaAxis = templ.GetXaxis();
58 // Generate sum histograms.
59 // - fTotal1D will be the sum of projections on the X axis of the input
61 fTotal1D = new TH1D("dndeta",
62 "#frac{1}{N}#frac{dN_{ch}}{d#eta}",
66 fTotal1D->SetMarkerStyle(29);
67 fTotal1D->SetMarkerSize(1);
68 fTotal1D->SetStats(0);
69 fTotal1D->SetDirectory(0);
76 //__________________________________________________________________
81 * @return true on success, false otherwise
83 virtual void AddContrib(const TH2D& hist, Int_t)
85 // Make a projection on the X axis of the input histogram
86 TH1D* proj = hist.ProjectionX("_px", 0, -1, "e");
88 // Add to 1D summed histogram
89 fTotal1D->Add(proj); // , scale);
91 // Remove the projection
94 //__________________________________________________________________
99 * @return true on success, false otherwise
101 virtual TH1D* GetResult()
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");
114 * @param b Browser to use
116 virtual void Browse(TBrowser* b)
118 if (fTotal1D) b->Add(fTotal1D);
119 DrawResBase::Browse(b);
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
125 * @return Newly created object
127 static DrawRes1D* Create()
129 DrawRes1D* dr = new DrawRes1D;
130 gROOT->GetListOfSpecials()->Add(dr);
131 TBrowser* b = new TBrowser("b");
132 b->BrowseObject(gROOT->GetListOfSpecials());
136 TH1D* fTotal1D; // Direct sum of input histograms
138 ClassDef(DrawRes1D,0)