X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=EMCAL%2FAliEMCALHistoUtilities.cxx;h=b48fb6f8ed962129397b7bc0d371a584d3b4c233;hb=ccfdd67fc2d34525a6ab8a2b7ae5f14bf2e48db2;hp=e8e537f149f29fc97dd59129eb3d621da7f1d847;hpb=c0e92bade0d888adc51033762cd7c82b77412a8e;p=u%2Fmrichter%2FAliRoot.git diff --git a/EMCAL/AliEMCALHistoUtilities.cxx b/EMCAL/AliEMCALHistoUtilities.cxx index e8e537f149f..b48fb6f8ed9 100644 --- a/EMCAL/AliEMCALHistoUtilities.cxx +++ b/EMCAL/AliEMCALHistoUtilities.cxx @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include #include #include @@ -48,9 +50,9 @@ #include // color, line style and so on #include -#include "AliESDCaloCluster.h" -#include "AliEMCALRecPoint.h" -#include "AliRunLoader.h" +//#include "AliESDCaloCluster.h" +//#include "AliEMCALRecPoint.h" +//#include "AliRunLoader.h" #include "AliHeader.h" #include "AliGenEventHeader.h" #include "AliGenPythiaEventHeader.h" @@ -69,32 +71,47 @@ AliEMCALHistoUtilities::~AliEMCALHistoUtilities() //destructor } -TList* AliEMCALHistoUtilities::MoveHistsToList(const char* name, Bool_t putToBrowser) +TList* AliEMCALHistoUtilities::MoveHistsToList(const char* name, Bool_t putToBrowser, Bool_t setOwner) { // Move HIST to list gROOT->cd(); TIter nextHist(gDirectory->GetList()); TList *list = new TList; list->SetName(name); - TObject *objHist; + if(setOwner) list->SetOwner(setOwner); + TObject *objHist=0; + // Move from gROOT to list while((objHist=nextHist())){ + //objHist->Dump(); if (!objHist->InheritsFrom("TH1")) continue; - ((TH1*)objHist)->SetDirectory(0); // Remove from gROOT + ((TH1*)objHist)->SetDirectory(0); list->Add(objHist); - gDirectory->GetList()->Remove(objHist); } + // Clear gROOT + gDirectory->GetList()->Clear(); + if(putToBrowser) gROOT->GetListOfBrowsables()->Add((TObject*)list); return list; } -void AliEMCALHistoUtilities::FillH1(TList *l, Int_t ind, Double_t x, Double_t w) +void AliEMCALHistoUtilities::FillH1(TList *l, Int_t ind, Double_t x, Double_t w, Double_t error) { //fill 1d histogram static TH1* hid=0; + static int bin=0; if(l == 0) return; + if(ind>=0 && ind < l->GetSize()){ - hid = (TH1*)l->At(ind); - hid->Fill(x,w); + hid = dynamic_cast(l->At(ind)); + if (hid==0) return; + + if(error <= 0.0) { // standard way + hid->Fill(x,w); + } else { + bin = hid->FindBin(x); + hid->SetBinContent(bin,w); + hid->SetBinError(bin,error); + } } } @@ -104,8 +121,30 @@ void AliEMCALHistoUtilities::FillH2(TList *l, Int_t ind, Double_t x, Double_t y, static TH2* hid=0; if(l == 0) return; if(ind>=0 && ind < l->GetSize()){ - hid = (TH2*)l->At(ind); - hid->Fill(x,y,w); + hid = dynamic_cast(l->At(ind)); + if(hid) hid->Fill(x,y,w); + } +} + +void AliEMCALHistoUtilities::FillHProf(TList *l, Int_t ind, Double_t x, Double_t y, Double_t w) +{ + // fill profile histogram + static TProfile* h=0; + if(l == 0) return; + if(ind>=0 && ind < l->GetSize()){ + h = dynamic_cast(l->At(ind)); + if(h) h->Fill(x,y,w); + } +} + +void AliEMCALHistoUtilities:: FillHnSparse(TList *l, Int_t ind, Double_t* x, Double_t w) +{ + // Nov 02,2010: fill THnSparse hist + static THnSparse* hsp=0; + if(l==0 || x==0) return; + if(ind>=0 && ind < l->GetSize()){ + hsp = dynamic_cast(l->At(ind)); + if(hsp) hsp->Fill(x,w); } } @@ -146,7 +185,7 @@ int AliEMCALHistoUtilities::SaveListOfHists(TList *mylist,const char* name,Bool_ return save; } -void AliEMCALHistoUtilities::AddToNameAndTitle(TH1 *h, const char *name, const char *title) +void AliEMCALHistoUtilities::AddToNameAndTitle(TNamed *h, const char *name, const char *title) { // Oct 15, 2007 if(h==0) return; @@ -161,8 +200,8 @@ void AliEMCALHistoUtilities::AddToNameAndTitleToList(TList *l, const char *name, if(name || title) { for(int i=0; iGetSize(); i++) { TObject *o = l->At(i); - if(o->InheritsFrom("TH1")) { - TH1 *h = (TH1*)o; + if(o->InheritsFrom("TNamed")) { + TNamed *h = dynamic_cast(o); AddToNameAndTitle(h, name, title); } } @@ -179,6 +218,55 @@ void AliEMCALHistoUtilities::ResetListOfHists(TList *l) } } +void AliEMCALHistoUtilities::Titles(TH1 *hid, const char *titx,const char *tity) +{ + if(hid) { + hid->SetXTitle(titx); + hid->SetYTitle(tity); + } else { + printf(" TAliasPAI::titles() -> hid is 0 !\n"); + } +} + +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 @@ -263,7 +351,7 @@ const char *optFit, const char *fun) TGraphErrors *AliEMCALHistoUtilities::DrawGraphErrors(const Int_t n,Double_t *x,Double_t *y,Double_t *ex, Double_t *ey, Int_t markerColor, Int_t markerStyle, const char* opt, const char* tit, -const char* xTit,char* yTit, Int_t ifun, const char *optFit, const char *fun) +const char* xTit,const char* yTit, Int_t ifun, const char *optFit, const char *fun) { // Oct 15, 2007 printf("AliEMCALHistoUtilities::drawGraphErrors started \n"); @@ -355,65 +443,65 @@ void AliEMCALHistoUtilities::InitChain(TChain *chain, const char* nameListOfFile // chain->Lookup(); } -AliRunLoader* AliEMCALHistoUtilities::InitKinematics(const Int_t nev, const char* galiceName) -{ - // Oct 15, 2007 - // nev == 0 - new file - static AliRunLoader *rl = 0; - - if((rl == 0 || nev==0) && galiceName) { - printf(" AliEMCALHistoUtilities::InitKinematics() : nev %i : rl %p : %s (IN)\n", - nev, rl, galiceName); - if(rl) { - rl->UnloadgAlice(); - delete rl; - } - rl = AliRunLoader::Open(galiceName,AliConfig::GetDefaultEventFolderName(),"read"); - rl->LoadgAlice(); // obligatory - printf(" AliEMCALHistoUtilities::InitKinematics() : nev %i : rl %p : %s (OUT)\n", - nev, rl, galiceName); - } - if(rl) { - rl->GetEvent(nev); - rl->LoadKinematics(); - /* Get what you need after that - rl->LoadHits(); - AliStack *stack=rl->Stack(); - AliESDCaloCluster * clus = esd->GetCaloCluster(n); - Int_t label = clus->GetLabel(); // what is this - TParticle *primary=stack->Particle(label); - */ - } - return rl; -} - -AliRunLoader* AliEMCALHistoUtilities::GetRunLoader(const Int_t nev, const Char_t* galiceName, - const Char_t* eventFolderName, AliRunLoader* rlOld) -{ - // Nov 26, 2007 - // nev == 0 - new file - AliRunLoader *rl = 0; - - if(nev==0 && galiceName) { - printf(" AliEMCALHistoUtilities::GetLoader() : nev %i : %s (IN)\n", - nev, galiceName); - if(rlOld) { - rlOld->UnloadgAlice(); - delete rlOld; - } - TString folderName(eventFolderName); - if(folderName.Length() == 0) folderName = AliConfig::GetDefaultEventFolderName(); - rl = AliRunLoader::Open(galiceName, folderName.Data(),"read"); - rl->LoadgAlice(); // obligatory - printf(" AliEMCALHistoUtilities::GetLoader() : nev %i : %s : %s (OUT)\n", - nev, galiceName, folderName.Data()); - } else { - rl = rlOld; - } - if(rl) rl->LoadgAlice(); // obligatory - // if(rl) rl->GetEvent(nev); - return rl; -} +//AliRunLoader* AliEMCALHistoUtilities::InitKinematics(const Int_t nev, const char* galiceName) +//{ +// // Oct 15, 2007 +// // nev == 0 - new file +// static AliRunLoader *rl = 0; +// +// if((rl == 0 || nev==0) && galiceName) { +// //printf(" AliEMCALHistoUtilities::InitKinematics() : nev %i : rl %p : %s (IN)\n", +// // nev, rl, galiceName); +// if(rl) { +// rl->UnloadgAlice(); +// delete rl; +// } +// rl = AliRunLoader::Open(galiceName,AliConfig::GetDefaultEventFolderName(),"read"); +// rl->LoadgAlice(); // obligatory +// //printf(" AliEMCALHistoUtilities::InitKinematics() : nev %i : rl %p : %s (OUT)\n", +// //nev, rl, galiceName); +// } +// if(rl) { +// rl->GetEvent(nev); +// rl->LoadKinematics(); +// /* Get what you need after that +// rl->LoadHits(); +// AliStack *stack=rl->Stack(); +// AliESDCaloCluster * clus = esd->GetCaloCluster(n); +// Int_t label = clus->GetLabel(); // what is this +// TParticle *primary=stack->Particle(label); +// */ +// } +// return rl; +//} + +//AliRunLoader* AliEMCALHistoUtilities::GetRunLoader(const Int_t nev, const Char_t* galiceName, +// const Char_t* eventFolderName, AliRunLoader* rlOld) +//{ +// // Nov 26, 2007 +// // nev == 0 - new file +// AliRunLoader *rl = 0; +// +// if(nev==0 && galiceName) { +// printf(" AliEMCALHistoUtilities::GetLoader() : nev %i : %s (IN)\n", +// nev, galiceName); +// if(rlOld) { +// rlOld->UnloadgAlice(); +// delete rlOld; +// } +// TString folderName(eventFolderName); +// if(folderName.Length() == 0) folderName = AliConfig::GetDefaultEventFolderName(); +// rl = AliRunLoader::Open(galiceName, folderName.Data(),"read"); +// rl->LoadgAlice(); // obligatory +// printf(" AliEMCALHistoUtilities::GetLoader() : nev %i : %s : %s (OUT)\n", +// nev, galiceName, folderName.Data()); +// } else { +// rl = rlOld; +// } +// if(rl) rl->LoadgAlice(); // obligatory +// // if(rl) rl->GetEvent(nev); +// return rl; +//} Double_t AliEMCALHistoUtilities::GetMomentum(const char* nameListOfFiles) { @@ -456,45 +544,45 @@ int AliEMCALHistoUtilities::ParseString(const TString &topt, TObjArray &Opt) } // Analysis utilites -Bool_t AliEMCALHistoUtilities::GetLorentzVectorFromESDCluster(TLorentzVector &v, const AliESDCaloCluster* cl) -{ - // May 8, 2007 - static Double_t e=0.0; - static Float_t pos[3]; - static TVector3 gpos; - if(cl==0) return kFALSE; - - e = Double_t(cl->E()); - if(e<=0.0) { - printf(" negative cluster energy : %f \n", e); - return kFALSE; - } - cl->GetPosition(pos); - gpos.SetXYZ(Double_t(pos[0]), Double_t(pos[1]), Double_t(pos[2])); - gpos.SetMag(e); - v.SetVectM(gpos, 0.0); - - return kTRUE; -} - -Bool_t AliEMCALHistoUtilities::GetLorentzVectorFromRecPoint(TLorentzVector &v, const AliEMCALRecPoint *rp) -{ - // Jun 20, 2007 - static Double_t e=0.0; - static TVector3 gpos; - if(rp==0) return kFALSE; - - e = Double_t(rp->GetPointEnergy()); - if(e<=0.0) { - printf(" negative rec.point energy : %f \n", e); - return kFALSE; - } - rp->GetGlobalPosition(gpos); - gpos.SetMag(e); - v.SetVectM(gpos, 0.0); - - return kTRUE; -} +//Bool_t AliEMCALHistoUtilities::GetLorentzVectorFromESDCluster(TLorentzVector &v, const AliESDCaloCluster* cl) +//{ +// // May 8, 2007 +// static Double_t e=0.0; +// static Float_t pos[3]; +// static TVector3 gpos; +// if(cl==0) return kFALSE; +// +// e = Double_t(cl->E()); +// if(e<=0.0) { +// printf(" negative cluster energy : %f \n", e); +// return kFALSE; +// } +// cl->GetPosition(pos); +// gpos.SetXYZ(Double_t(pos[0]), Double_t(pos[1]), Double_t(pos[2])); +// gpos.SetMag(e); +// v.SetVectM(gpos, 0.0); +// +// return kTRUE; +//} + +//Bool_t AliEMCALHistoUtilities::GetLorentzVectorFromRecPoint(TLorentzVector &v, const AliEMCALRecPoint *rp) +//{ +// // Jun 20, 2007 +// static Double_t e=0.0; +// static TVector3 gpos; +// if(rp==0) return kFALSE; +// +// e = Double_t(rp->GetPointEnergy()); +// if(e<=0.0) { +// printf(" negative rec.point energy : %f \n", e); +// return kFALSE; +// } +// rp->GetGlobalPosition(gpos); +// gpos.SetMag(e); +// v.SetVectM(gpos, 0.0); +// +// return kTRUE; +//} // //// Drawing: // @@ -627,7 +715,7 @@ Double_t AliEMCALHistoUtilities::GetCorrectedEnergyForGamma1(const Double_t eRec } // Trigger -TList* AliEMCALHistoUtilities::GetTriggersListOfHists(const Int_t scale, const Bool_t toBrowser) +TList* AliEMCALHistoUtilities::GetTriggersListOfHists(const Int_t scale, const Int_t nTrig, const Bool_t toBrowser) { // Oct 22, 2007 - trigger technical assurance gROOT->cd(); @@ -639,21 +727,30 @@ TList* AliEMCALHistoUtilities::GetTriggersListOfHists(const Int_t scale, const B new TH1F("03_hXposnxn", "X coord. of max Amp NXN",100, -500., +500.); new TH1F("04_hYposnxn", "Y coord. of max Amp NXN",100, -500., +500.); new TH1F("05_hZposnxn", "Z coord. of max Amp NXN",100, -500., +500.); + // May 7, 2008 - jet trigger + new TH1F("06_hJetTriggerPhi", "%phi of COG of jet trigger patch", 110, 80., 190.); + new TH1F("07_hJetTriggerEta", "%eta of COG of jet trigger patch", 70, -0.7, +0.7); // - new TH1F("06_hMaxAmp2x2", "max Amp 2x2", 1000, 0.0, pow(2.,14.)); - new TH1F("07_hAmpOutOf2x2", "Amp out of patch 2x2", 1000, 0.0, pow(2.,14.)); - new TH1F("08_hMaxAmpnxn", "max Amp NXN", 1000, 0.0, pow(2.,14.)); - new TH1F("09_hAmpOutOfnxn", "Amp out of patch nxn", 1000, 0.0, pow(2.,14.)); + new TH1F("08_hMaxAmp2x2", "max Amp 2x2", 1000, 0.0, pow(2.,14.)); + new TH1F("09_hAmpOutOf2x2", "Amp out of patch 2x2", 1000, 0.0, pow(2.,14.)); + new TH1F("10_hMaxAmpnxn", "max Amp NXN", 1000, 0.0, pow(2.,14.)); + new TH1F("11_hAmpOutOfnxn", "Amp out of patch nxn", 1000, 0.0, pow(2.,14.)); + // May 7, 2008 - jet trigger + for(Int_t i=0; i FillTriggersListOfHists() : list of hists undefined. \n"); return; } - if(triggerPosition && triggerPosition->GetSize() == 6) { - for(int i=0; i<6; i++) { - FillH1(l, i, double(triggerPosition->At(i))); - } + for(int i=0; iGetSize(); i++) { + FillH1(l, i, double(triggerPosition->At(i))); } - if(triggerAmplitudes && triggerAmplitudes->GetSize() == 4) { - for(int i=0; i<4; i++) { - FillH1(l, 6+i, double(triggerAmplitudes->At(i)) ); - } + + for(int i=0; iGetSize(); i++) { + FillH1(l, triggerPosition->GetSize() + i, double(triggerAmplitudes->At(i)) ); } } @@ -701,49 +795,49 @@ TList* AliEMCALHistoUtilities::GetJetsListOfHists(Int_t njet, Bool_t toBrowser) return MoveHistsToList("JetLiOfHists", toBrowser); } -void AliEMCALHistoUtilities::FillJetKineListOfHists(TList *l, AliRunLoader* rl, TLorentzVector &goodJet) -{ - // Oct 30, 2007; Nov 07; - // goodJet - output; only one jet with EMCAL acceptance - - // Bad case - goodJet.SetPxPyPzE(0., 0., 0., 0.); - - if(l==0 || rl==0) return; - //try to get trigger jet info - AliHeader* alih = rl->GetHeader(); - if (alih == 0) return; - - AliGenEventHeader * genh = alih->GenEventHeader(); - if (genh == 0) return; - - AliGenPythiaEventHeader* genhpy = dynamic_cast(genh); - if(genhpy==0) return; // Not Pythia - - Int_t nj = genhpy->NTriggerJets(); - FillH1(l, 0, double(nj)); - - TLorentzVector* jets[4]; - nj = nj>4?4:nj; - - int ic=1; - for (Int_t i=0; i< nj; i++) { - Float_t p[4]; - genhpy->TriggerJet(i,p); - jets[i] = new TLorentzVector(p); - FillH1(l, ic++, jets[i]->Eta()); - FillH1(l, ic++, jets[i]->Theta()*TMath::RadToDeg()); - FillH1(l, ic++, TVector2::Phi_0_2pi(jets[i]->Phi())*TMath::RadToDeg()); - FillH1(l, ic++, jets[i]->Pt()); - FillH1(l, ic++, jets[i]->E()); - - //printf(" %i pj %f %f %f %f : ic %i\n", i, p[0], p[1], p[2], p[3], ic); - if(ic >= l->GetSize()) break; - } - if(nj==1) { - Double_t eta=jets[0]->Eta(), phi=TVector2::Phi_0_2pi(jets[0]->Phi())*TMath::RadToDeg(); - if(TMath::Abs(eta)<0.5 && (phi>90.&&phi<180.)) { - goodJet = (*jets[0]); - } - } -} +//void AliEMCALHistoUtilities::FillJetKineListOfHists(TList *l, AliRunLoader* rl, TLorentzVector &goodJet) +//{ +// // Oct 30, 2007; Nov 07; +// // goodJet - output; only one jet with EMCAL acceptance +// +// // Bad case +// goodJet.SetPxPyPzE(0., 0., 0., 0.); +// +// if(l==0 || rl==0) return; +// //try to get trigger jet info +// AliHeader* alih = rl->GetHeader(); +// if (alih == 0) return; +// +// AliGenEventHeader * genh = alih->GenEventHeader(); +// if (genh == 0) return; +// +// AliGenPythiaEventHeader* genhpy = dynamic_cast(genh); +// if(genhpy==0) return; // Not Pythia +// +// Int_t nj = genhpy->NTriggerJets(); +// FillH1(l, 0, double(nj)); +// +// TLorentzVector* jets[4]; +// nj = nj>4?4:nj; +// +// int ic=1; +// for (Int_t i=0; i< nj; i++) { +// Float_t p[4]; +// genhpy->TriggerJet(i,p); +// jets[i] = new TLorentzVector(p); +// FillH1(l, ic++, jets[i]->Eta()); +// FillH1(l, ic++, jets[i]->Theta()*TMath::RadToDeg()); +// FillH1(l, ic++, TVector2::Phi_0_2pi(jets[i]->Phi())*TMath::RadToDeg()); +// FillH1(l, ic++, jets[i]->Pt()); +// FillH1(l, ic++, jets[i]->E()); +// +// //printf(" %i pj %f %f %f %f : ic %i\n", i, p[0], p[1], p[2], p[3], ic); +// if(ic >= l->GetSize()) break; +// } +// if(nj==1) { +// Double_t eta=jets[0]->Eta(), phi=TVector2::Phi_0_2pi(jets[0]->Phi())*TMath::RadToDeg(); +// if(TMath::Abs(eta)<0.5 && (phi>90.&&phi<180.)) { +// goodJet = (*jets[0]); +// } +// } +//}