#include <TString.h>
#include <TLorentzVector.h>
#include <Gtypes.h> // color, line style and so on
+#include <TArrayF.h>
#include "AliESDCaloCluster.h"
#include "AliEMCALRecPoint.h"
#include "AliRunLoader.h"
+#include "AliHeader.h"
+#include "AliGenEventHeader.h"
+#include "AliGenPythiaEventHeader.h"
using namespace std;
void AliEMCALHistoUtilities::AddToNameAndTitle(TH1 *h, const char *name, const char *title)
{
+ // Oct 15, 2007
if(h==0) return;
if(name && strlen(name)) h->SetName(Form("%s%s",h->GetName(),name));
if(title && strlen(title)) h->SetTitle(Form("%s%s",h->GetTitle(),title));
void AliEMCALHistoUtilities::AddToNameAndTitleToList(TList *l, const char *name, const char *title)
{
+ // Oct 15, 2007
if(l==0) return;
if(name || title) {
for(int i=0; i<l->GetSize(); i++) {
void AliEMCALHistoUtilities::ResetListOfHists(TList *l)
{
+ // Oct 15, 2007
if(l==0) return;
-
for(int i=0; i<l->GetSize(); i++) {
TH1F* h = (TH1F*)l->At(i);
h->Reset();
TLatex *AliEMCALHistoUtilities::Lat(const char *text, Float_t x,Float_t y, Int_t align, Float_t tsize, short tcolor)
{
+ // Oct 15, 2007
double y1=y;
TLatex *latex = new TLatex;
latex->SetTextAlign(align);
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)
{
+ // Oct 15, 2007
printf("AliEMCALHistoUtilities::drawGraphErrors started \n");
printf("Drawing opt |%s| : ifun %i: Fitting opt |%s|, fun |%s|\n",
opt, ifun, optFit, fun);
TF1* AliEMCALHistoUtilities::GetResolutionFunction(const char *opt, TString &latexName)
{
- TString OPT(opt);
- OPT.ToUpper();
+ // Oct 15, 2007
+ TString sopt(opt);
+ sopt.ToUpper();
TF1 *fres=0;
- if (OPT.Contains("FRES1")) {
+ if (sopt.Contains("FRES1")) {
fres = new TF1("fres","[0]+[1]/sqrt(x)", 0.0, 101.);
latexName = "#frac{#sigma_{E}}{E} = A+#frac{B}{#sqrt{E}}";
- } else if(OPT.Contains("FRES2")) {
+ } else if(sopt.Contains("FRES2")) {
fres = new TF1("fres","sqrt([0]*[0]+[1]*[1]/x)", 0.0, 101.);
latexName = "#sqrt{A^{2}+#frac{B^{2}}{E}}";
}
// Read name of files from text file with nameListOfFiles and added to the chain
if(chain==0 || nameListOfFiles==0) return;
- ifstream in;
- in.open(nameListOfFiles);
- if (!in) {
+ ifstream fin;
+ fin.open(nameListOfFiles);
+ if (!fin.is_open()) {
cout << "Input file "<<nameListOfFiles<<" cannot be opened.\n";
return;
}
Int_t nfiles = 0; // number of files in chain
char nf[200]; // name of current file
- while (!in.getline(nf,200).eof()) {
- if(!in.good()) break;
+ while (!fin.getline(nf,200).eof()) {
+ if(!fin.good()) break;
chain->Add(nf);
nfiles++;
cout<<nfiles<<" "<<nf<<endl;
if(nFileMax && nfiles>=nFileMax) break;
}
+ fin.close();
+ //
cout << " \n ********** <I> Accepted file "<< nfiles << "********* \n"<<endl;
// chainEsd->Print();
// chain->Lookup();
AliRunLoader* AliEMCALHistoUtilities::InitKinematics(const Int_t nev, const char* galiceName)
{
- static AliRunLoader *RL = 0;
- if(RL == 0 || nev%1000==0) {
- if(RL) {
- RL->UnloadgAlice();
- delete RL;
+ // Oct 15, 2007
+ // nev == 0 - new file
+ static AliRunLoader *rl = 0;
+
+ if((rl == 0 || nev==0) && galiceName) {
+ printf("<I> 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
+ rl = AliRunLoader::Open(galiceName,AliConfig::GetDefaultEventFolderName(),"read");
+ rl->LoadgAlice(); // obligatory
+ printf("<I> AliEMCALHistoUtilities::InitKinematics() : nev %i : rl %p : %s (OUT)\n",
+ nev, rl, galiceName);
}
- if(RL) {
- RL->GetEvent(nev%1000);
- RL->LoadKinematics();
+ if(rl) {
+ rl->GetEvent(nev);
+ rl->LoadKinematics();
/* Get what you need after that
- RL->LoadHits();
- AliStack *stack=RL->Stack();
+ 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;
+ 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("<I> 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("<I> 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)
//
void AliEMCALHistoUtilities::DrawHist(TH1* hid,int lineWidth,int lineColor,const char* opt, int lineStyle)
{
- TString OPT;
- OPT = opt;
+ // Oct 15, 2007
+ TString sopt;
+ sopt = opt;
if(!hid) return;
printf(" Hist. %s : option |%s| \n", hid->GetName(), opt);
if(hid && hid->GetEntries()>=1.) {
if(lineWidth) hid->SetLineWidth(lineWidth);
if(lineColor) hid->SetLineColor(lineColor);
if(lineStyle) hid->SetLineStyle(lineStyle);
- if(OPT.Contains("stat",TString::kIgnoreCase)) hid->SetStats(kTRUE);
+ if(sopt.Contains("stat",TString::kIgnoreCase)) hid->SetStats(kTRUE);
hid->Draw(opt);
} else {
if (strcmp(opt,"empty")==0) hid->Draw();
//// Fitting:
//
TF1* AliEMCALHistoUtilities::Gausi(const char *addName,double xmi,double xma,double N,double mean,double sig,double width)
-{ // Fit by gaus where first parameter is the number of events under ga
+{
+ // Fit by gaus where first parameter is the number of events under ga
+ // Oct 15, 2007
TString name("gi");
name += addName;
- TF1 *F = new TF1(name.Data(), Gi, xmi, xma, 4);
- F->SetParNames("INTEGRAL","MEAN","SIGMA","WIDTH");
+ TF1 *f = new TF1(name.Data(), Gi, xmi, xma, 4);
+ f->SetParNames("INTEGRAL","MEAN","SIGMA","WIDTH");
- F->SetParameter(0,N);
- F->SetParameter(1,mean);
- F->SetParameter(2,sig);
+ f->SetParameter(0,N);
+ f->SetParameter(1,mean);
+ f->SetParameter(2,sig);
- F->FixParameter(3,width); // width of histogramm bin
- return F;
+ f->FixParameter(3,width); // width of histogramm bin
+ return f;
}
TF1* AliEMCALHistoUtilities::Gausi(const char *addName, double xmi, double xma, TH1 *h)
}
TF1* AliEMCALHistoUtilities::GausiPol2(const char *addName,double xmi,double xma, TF1 *g, TF1* bg)
-{ // Fit by gaus where first parameter is the number of events under ga
+{
+ // Fit by gaus where first parameter is the number of events under ga
TString name("giPol2");
name += addName;
- TF1 *F = new TF1(name.Data(), GiPol2, xmi, xma, 7);
- F->SetParNames("INTEGRAL","MEAN","SIGMA","WIDTH","a0","a1","a2");
+ TF1 *f = new TF1(name.Data(), GiPol2, xmi, xma, 7);
+ f->SetParNames("INTEGRAL","MEAN","SIGMA","WIDTH","a0","a1","a2");
if(g) {
- for(int i=0; i<4; i++) F->SetParameter(i, g->GetParameter(i));
- F->FixParameter(3,g->GetParameter(3));
+ for(int i=0; i<4; i++) f->SetParameter(i, g->GetParameter(i));
+ f->FixParameter(3,g->GetParameter(3));
}
if(bg) {
- for(int i=4; i<7; i++) F->SetParameter(i, bg->GetParameter(i+4));
+ for(int i=4; i<7; i++) f->SetParameter(i, bg->GetParameter(i+4));
}
- F->SetLineColor(kRed);
- return F;
+ f->SetLineColor(kRed);
+ return f;
}
Double_t AliEMCALHistoUtilities::Gi(Double_t *x, Double_t *par)
// Forth parameter (par[3]) is width of histogram bin
// gaus(0) is a substitute for [0]*exp(-0.5*((x-[1])/[2])**2)
- static Double_t C = TMath::Sqrt(2.*TMath::Pi()), y=0.0, f=0.0; // sqrt(2.*pi)
+ static Double_t c = TMath::Sqrt(2.*TMath::Pi()), y=0.0, f=0.0; // sqrt(2.*pi)
y = (x[0]-par[1])/par[2];
- f = par[0]*par[3]/(par[2]*C) * TMath::Exp(-0.5*y*y);
+ f = par[0]*par[3]/(par[2]*c) * TMath::Exp(-0.5*y*y);
return f;
}
// Forth parameter (par[3]) is width of histogram bin
// gaus(0) is a substitute for [0]*exp(-0.5*((x-[1])/[2])**2)
// + pol2 -> 7 parameters
- static Double_t C = TMath::Sqrt(2.*TMath::Pi()), y=0.0, f=0.0; // sqrt(2.*pi)
+ static Double_t c = TMath::Sqrt(2.*TMath::Pi()), y=0.0, f=0.0; // sqrt(2.*pi)
y = (x[0]-par[1])/par[2];
- f = par[0]*par[3]/(par[2]*C) * TMath::Exp(-0.5*y*y);
+ f = par[0]*par[3]/(par[2]*c) * TMath::Exp(-0.5*y*y);
f += par[4] + par[5]*x[0] + par[6]*x[0]*x[0];
}
// Calibration stuff
-Double_t AliEMCALHistoUtilities::GetCorrectionCoefficientForGamma_1(const Double_t eRec)
+Double_t AliEMCALHistoUtilities::GetCorrectionCoefficientForGamma1(const Double_t eRec)
{
// Correction to rec.energy - Jul 15, 2007
// E(gamma) = corr * E(eRec);
return corr;
}
-Double_t AliEMCALHistoUtilities::GetCorrectedEnergyForGamma_1(const Double_t eRec)
+Double_t AliEMCALHistoUtilities::GetCorrectedEnergyForGamma1(const Double_t eRec)
+{
+ return GetCorrectionCoefficientForGamma1(eRec) * eRec;
+}
+
+// Trigger
+TList* AliEMCALHistoUtilities::GetTriggersListOfHists(const Int_t scale, const Int_t nTrig, const Bool_t toBrowser)
+{
+ // Oct 22, 2007 - trigger technical assurance
+ gROOT->cd();
+ TH1::AddDirectory(1);
+
+ new TH1F("00_hXpos2x2", "X coord. of max Amp 2x2",100, -500., +500.);
+ new TH1F("01_hYpos2x2", "Y coord. of max Amp 2x2",100, -500., +500.);
+ new TH1F("02_hZpos2x2", "Z coord. of max Amp 2x2",100, -500., +500.);
+ 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("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<nTrig; i++) {
+ new TH1F(Form("%2.2i_hJetPatchAmp%2.2i",i+12,i), Form("jet patch amplitude : jet trig %i",i),
+ 1000, 0.0, pow(2.,14.));
+ }
+ // For checking
+ Double_t maxEdigit=100., maxN=1000., maxPC = 200.;
+ if(scale==1) {
+ maxN *= 10.;
+ maxPC *= 10.;
+ }
+ Int_t ind = 12+nTrig;
+ new TH1F(Form("%2.2i_hDigitsAmp",ind++), "amplitude of digits (PC) ", 1001, -0.5, 1000.5);
+ new TH1F(Form("%2.2i_hDigitsE",ind++), " energy of digits (PC)", 1000, 0.0, maxEdigit);
+ new TH1F(Form("%2.2i_hNDigitsInPCs",ind++), " number of digits in PC's", 1000, 0.0, maxN);
+ new TH1F(Form("%2.2i_hEinInPCs",ind++), " energy in PC's", 200, 0.0, maxPC);
+
+ return MoveHistsToList("TriggerLiOfHists", toBrowser);
+}
+
+void AliEMCALHistoUtilities::FillTriggersListOfHists(TList *l, TArrayF *triggerPosition, TArrayF *triggerAmplitudes)
+{
+ // Oct 22, 2007 - trigger technical assurance
+ if(l==0) {
+ printf("<E> FillTriggersListOfHists() : list of hists undefined. \n");
+ return;
+ }
+ for(int i=0; i<triggerPosition->GetSize(); i++) {
+ FillH1(l, i, double(triggerPosition->At(i)));
+ }
+
+ for(int i=0; i<triggerAmplitudes->GetSize(); i++) {
+ FillH1(l, triggerPosition->GetSize() + i, double(triggerAmplitudes->At(i)) );
+ }
+}
+
+// Jet(s) kinematics
+TList* AliEMCALHistoUtilities::GetJetsListOfHists(Int_t njet, Bool_t toBrowser)
{
- return GetCorrectionCoefficientForGamma_1(eRec) * eRec;
+ // Oct 30, 2007
+ gROOT->cd();
+ TH1::AddDirectory(1);
+ new TH1F("00_nJet", "number of jets in Pythia",5, -0.5, +4.5);
+ int ic=1;
+ for(Int_t ij=0; ij<njet; ij++)
+ {
+ new TH1F(Form("%2.2i_EtaOfJet%i",ic++,ij), Form("#eta of jet (%i)",ij),80, -2., 2.);
+ new TH1F(Form("%2.2i_ThetaOfJet%i",ic++,ij), Form("#theta(degree) of jet (%i)",ij),
+ 180, 0.0, 180.);
+ new TH1F(Form("%2.2i_PhiOfJet%i",ic++,ij), Form("#phi(degree) of jet (%i)",ij),
+ 180, 0.0, 360.);
+ new TH1F(Form("%2.2i_PtOfJet%i",ic++,ij), Form(" p_{T} of jet (%i)",ij),
+ 200, 0.0, 200.);
+ new TH1F(Form("%2.2i_EOfJet%i",ic++,ij), Form(" E of jet (%i)",ij),
+ 200, 0.0, 200.);
+ }
+
+ 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<AliGenPythiaEventHeader *>(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]);
+ }
+ }
}