From a2aaed492f8614b0d1ede59ffb4faa0e0028a6e9 Mon Sep 17 00:00:00 2001 From: pavlinov Date: Sun, 9 Jan 2011 18:47:02 +0000 Subject: [PATCH] Added new methods --- EMCAL/AliEMCALHistoUtilities.cxx | 39 ++++++++++++++++++++++++++++++++ EMCAL/AliEMCALHistoUtilities.h | 1 + 2 files changed, 40 insertions(+) diff --git a/EMCAL/AliEMCALHistoUtilities.cxx b/EMCAL/AliEMCALHistoUtilities.cxx index 76be738dbb7..69d78ad0dd6 100644 --- a/EMCAL/AliEMCALHistoUtilities.cxx +++ b/EMCAL/AliEMCALHistoUtilities.cxx @@ -210,6 +210,45 @@ void AliEMCALHistoUtilities::Titles(TH1 *hid, const char *titx,const char *tity) } } +TList* AliEMCALHistoUtilities::CreateProjectionsX(TList *l, const Int_t ind, const Char_t* name) +{ + // Sep 4 - seperate list for projections + TH2F *hid = dynamic_cast(l->At(ind)); + if(hid == 0) { + printf(" Object at ind %i is %s : should ne TH2F \n", + ind, l->At(ind)->ClassName()); + return 0; + } + + TList *lpt = new TList; + lpt->SetName(Form("%s%s", hid->GetName(), name)); + l->Add(lpt); + + TAxis* yax = hid->GetYaxis(); + TString tity = yax->GetTitle(); + tity.ReplaceAll(" ",""); + TString name1 = hid->GetName(); + TString nam = name1(3,name1.Length()-3); + TString tit1 = hid->GetTitle(), tit=tit1; + + TH1::AddDirectory(0); + + TH1D *hd = hid->ProjectionX(Form("00_%sProx",nam.Data()), 1, yax->GetNbins()); + tit += Form(" : %5.2f < %s < %5.2f (GeV/c)", yax->GetXmin(),tity.Data(),yax->GetXmax()); + hd->SetTitle(tit.Data()); + lpt->Add(hd); + + for(Int_t iy=1; iy<=yax->GetNbins(); iy++){ + tit = tit1; + tit += Form(" : %5.2f < %s < %5.2f (GeV/c)", yax->GetBinLowEdge(iy), tity.Data(), yax->GetBinUpEdge(iy)); + hd = hid->ProjectionX(Form("%2.2i_%sProx%i",iy, nam.Data(),iy),iy,iy); + hd->SetTitle(tit.Data()); + lpt->Add(hd); + } + + return lpt; +} + TLatex *AliEMCALHistoUtilities::Lat(const char *text, Float_t x,Float_t y, Int_t align, Float_t tsize, short tcolor) { // Oct 15, 2007 diff --git a/EMCAL/AliEMCALHistoUtilities.h b/EMCAL/AliEMCALHistoUtilities.h index 51a3cee1a32..c25ea09230d 100644 --- a/EMCAL/AliEMCALHistoUtilities.h +++ b/EMCAL/AliEMCALHistoUtilities.h @@ -48,6 +48,7 @@ class AliEMCALHistoUtilities: public TNamed { static void AddToNameAndTitleToList(TList *l=0, const char *name=0, const char *title=0); static void ResetListOfHists(TList *l); static void Titles(TH1 *hid=0, const char *titx="",const char *tity=""); + static TList* CreateProjectionsX(TList *l=0, const Int_t ind=2, const Char_t* name="prox"); static TLatex *Lat(const char *text="", Float_t x=0.0,Float_t y=0.0, Int_t align=12, Float_t tsize=0.05, short tcolor = 1); static TGraph *DrawGraph(Int_t n=4, Double_t *x=0, Double_t *y=0, Int_t markerColor=4, -- 2.43.5