#include "DrawResBase.h"
/**
* @defgroup pwg2_forward_analysis_scripts PWG2 Forward analysis - scripts
*
* @ingroup pwg2_forward_analysis
*/
/**
* Example macro to loop over the event-by-event 2D histogram of
* @f[
* \frac{d^{2}N_{ch}}{d\eta\,d\phi}
* @f]
* stored in an AOD.
*
* The class needs the files <base>_hists.root
* containing the histograms generated by AliForwardMultiplicity and
* the file <base>_aods.root containing the tree
* with AliAODEvent objects where AliAODForwardMult objects have been
* added to in the branch Forward
*
* @ingroup pwg2_forward_analysis_scripts
*/
class DrawRes2D : public DrawResBase
{
public:
/**
* Constructor
*
* @param special If true, add to the list of 'specials'
*/
DrawRes2D()
: fTotal2D(0)
{
}
//__________________________________________________________________
virtual void Clear(Option_t* option)
{
DrawResBase::Clear(option);
if (fTotal2D) delete fTotal2D;
fTotal2D = 0;
}
//__________________________________________________________________
Bool_t IsInit() const { return fTotal2D; }
//__________________________________________________________________
/**
* Utility function to set-up histograms based on the input
* @f$ dd^{2}N_{ch}/d\eta\,d\phi@f$ histogram. This member function
* is called on the first event so that we have the proper binning
*
* @param templ Input histogram
*
* @return true on succcess
*/
Bool_t FirstEvent(const TH2D& templ)
{
if (!DrawResBase::FirstEvent(templ)) return kFALSE;
const TAxis* etaAxis = templ.GetXaxis();
const TAxis* phiAxis = templ.GetYaxis();
// Generate sum histograms.
// - fTotal2D will be the direct sum of the input histograms.
fTotal2D = new TH2D("d2ndetadphi", "1/N dN^{2}_{ch}/d#etad#phi",
etaAxis->GetNbins(),
etaAxis->GetXmin(),
etaAxis->GetXmax(),
phiAxis->GetNbins(),
phiAxis->GetXmin(),
phiAxis->GetXmax());
fTotal2D->SetXTitle("#eta");
fTotal2D->SetYTitle("#varphi [radians]");
fTotal2D->SetZTitle(fTotal2D->GetTitle());
fTotal2D->Sumw2();
fTotal2D->SetStats(0);
fTotal2D->SetDirectory(0);
return kTRUE;
}
//__________________________________________________________________
/**
* Process the events
*
*
* @return true on success, false otherwise
*/
void AddContrib(const TH2D& hist, Int_t)
{
fTotal2D->Add(&hist);
}
//__________________________________________________________________
/**
* Process the events
*
*
* @return true on success, false otherwise
*/
TH1D* GetResult()
{
// Do not sum underflow bins!
TH1D* proj = fTotal2D->ProjectionX("dndeta_proj", 1, -1, "e");
TH1D* norm = fTotal2D->ProjectionX("norm", 0, 1, "");
proj->SetTitle("1/N dN_{ch}/d#eta");
proj->Divide(norm);
proj->Scale(1., "width");
return proj;
}
/**
* Browse this object
*
* @param b Browser to use
*/
void Browse(TBrowser* b)
{
if (fTotal2D) b->Add(fTotal2D);
DrawResBase::Browse(b);
}
/**
* Create a new object of this class, and add it to the list of
* specials, and create a browse and browse to this object
*
* @return Newly created object
*/
static DrawResBase* Create()
{
DrawRes2D* dr = new DrawRes2D;
gROOT->GetListOfSpecials()->Add(dr);
TBrowser* b = new TBrowser("b");
b->BrowseObject(gROOT->GetListOfSpecials());
return dr;
}
protected:
TH2D* fTotal2D; // Direct sum of input histograms
ClassDef(DrawRes2D,0)
};
//
// EOF
//