1 //===============================================================
2 // In this Macro (which can (must) be compilated), you will find all the
3 // analysis functions to build photon spectrum, invariant mass
4 // spectrum of photon pairs and combinatorial background calculations
5 // in ALICE electromagnetic calorimeter
6 // Author: Gines MARTINEZ, Subatech, 15 june 2001
7 //==============================================================
13 #include "TObjectTable.h"
15 #include "AliPHOSGetter.h"
16 #include "AliPHOSRecParticle.h"
17 #include "TLorentzVector.h"
18 #include "TGraphErrors.h"
21 TObjectTable * gObjectTable;
26 void AnaMinv(char * filename)
28 TH2F * h_Minv_lowpT = new TH2F("h_Minv_lowpT","Minv vs pT low",500,0.0,1.0,40,0.,10.);
29 TH2F * h_Minv_highpT = new TH2F("h_Minv_highpT","Minv vs pT high",500,0.0,1.0,50,0.,100.);
30 TH2F * h_Minv_lowpT_back = new TH2F("h_Minv_lowpT_back","Minv vs pT low back",500,0.0,1.0,40,0.,10.);
31 TH2F * h_Minv_highpT_back = new TH2F("h_Minv_highpT_back","Minv vs pT high back",500,0.0,1.0,50,0.,100.);
34 TH1F * h_Pseudoeta = new TH1F("h_Pseudoeta","Pseudoeta photons",500,-1.0,1.0);
35 TH1F * h_Pt = new TH1F("h_Pt","Pt photons",400,0.,10.);
36 TH2F * h_Peta_Pt = new TH2F("h_Peta_Pt","Pseudo vs pT",40,0.,10.,50,-1.0,1.0);
37 TH1F * h_Phi = new TH1F("h_Phi","Phi photons",400,-4.,4.);
38 TH2F * h_Peta_Phi = new TH2F("h_Peta_Phi","Pseudo vs Phi",200,-4,4,200,-1.0,1.0);
39 TH1F * h_Dispersion= new TH1F("h_Dispersion","Dispersion",50,0.,10.);
40 TH1F * h_Type = new TH1F("h_Type","Particle Type",10,0.,10.);
42 TH1F * h_DeltaR = new TH1F("h_DeltaR","Delta R",400,0.,2.);
43 TH1F * h_Asymmetry= new TH1F("h_Asymmetry","Asymmetry",400, -2., 2.);
45 AliPHOSGetter * RecData = AliPHOSGetter::GetInstance(filename,"Gines") ;
47 AliPHOSRecParticle * RecParticle1;
48 AliPHOSRecParticle * RecParticle2;
50 Float_t RelativeRCut = 0.00001 ;
51 Float_t AsymmetryCut = 0.7 ;
55 Int_t iEvent, iRecParticle1, iRecParticle2;
57 Float_t invariant_mass, invariant_mass_mixed;
59 Float_t average_multiplicity = 0.;
61 for(iEvent=0; iEvent<gAlice->TreeE()->GetEntries(); iEvent++)
63 TLorentzVector P_photon1, P_photon2, P_photonMixed1, P_photonMixed2 ;
65 RecData->Event(iEvent);
66 printf(">>> Event %d \n",iEvent);
67 nRecParticle=RecData->NRecParticles();
68 average_multiplicity += ((Float_t) (nRecParticle) ) / ( (Float_t)gAlice->TreeE()->GetEntries() ) ;
69 // Construction de la masse invariante des pairs
72 for(iRecParticle1=0; iRecParticle1<nRecParticle; iRecParticle1++)
74 RecParticle1 = (AliPHOSRecParticle *) RecData->RecParticle(iRecParticle1);
75 RecParticle1->Momentum(P_photon1);
76 Type = RecParticle1->GetType();
80 h_Pseudoeta->Fill(P_photon1.PseudoRapidity());
81 h_Pt->Fill(P_photon1.Pt());
82 h_Phi->Fill(P_photon1.Phi());
83 h_Peta_Pt->Fill(P_photon1.Pt(), P_photon1.PseudoRapidity());
84 h_Peta_Phi->Fill(P_photon1.Phi(), P_photon1.PseudoRapidity() );
86 for(iRecParticle2=iRecParticle1+1; iRecParticle2<nRecParticle; iRecParticle2++)
88 RecParticle2 = (AliPHOSRecParticle *) RecData->RecParticle(iRecParticle2);
89 RecParticle2->Momentum(P_photon2);
90 Asymmetry = TMath::Abs((P_photon1.E()-P_photon2.E())/(P_photon1.E()+P_photon2.E()));
91 if ( (P_photon1 != P_photon2) &&
92 (P_photon1.DeltaR(P_photon2) > RelativeRCut) &&
93 (Asymmetry < AsymmetryCut) )
95 h_DeltaR->Fill(P_photon1.DeltaR(P_photon2));
96 h_Asymmetry->Fill( Asymmetry );
98 // printf("A. p1 es %f \n",P_photon1->E());
99 invariant_mass = (P_photon1 + P_photon2).M();
100 // printf("B. p1 es %f \n",P_photon1->E());
101 h_Minv_lowpT->Fill(invariant_mass, (P_photon1 + P_photon2).Pt() );
102 h_Minv_highpT->Fill(invariant_mass,(P_photon1 + P_photon2).Pt() );
108 printf(">>> Average Multiplicity is %f \n",average_multiplicity);
109 Int_t Background = (Int_t) (gAlice->TreeE()->GetEntries() * average_multiplicity * (average_multiplicity-1.)/2.) ;
110 printf(">>> Background is %d \n",Background);
112 Double_t Pt_Mixed1, Pt_Mixed2;
113 Double_t Y_Mixed1, Y_Mixed2;
114 Double_t Phi_Mixed1, Phi_Mixed2;
116 for(iEvent=0; iEvent<Background; iEvent++)
118 TLorentzVector P_photon1, P_photon2, P_photonMixed1, P_photonMixed2 ;
119 // printf(">>> Background Event %d \n",iEvent);
120 Pt_Mixed1 = h_Pt->GetRandom();
121 Pt_Mixed2 = h_Pt->GetRandom();
122 h_Peta_Phi->GetRandom2(Phi_Mixed1, Y_Mixed1);
123 h_Peta_Phi->GetRandom2(Phi_Mixed2, Y_Mixed2);
124 P_photonMixed1.SetPtEtaPhiM( Pt_Mixed1, Y_Mixed1, Phi_Mixed1, 0.0);
125 P_photonMixed2.SetPtEtaPhiM( Pt_Mixed2, Y_Mixed2, Phi_Mixed2, 0.0);
126 Asymmetry = TMath::Abs((P_photonMixed1.E()-P_photonMixed2.E())/(P_photonMixed1.E()+P_photonMixed2.E()));
128 if ( (P_photonMixed1.DeltaR(P_photonMixed2) > RelativeRCut) &&
129 (Asymmetry < AsymmetryCut ) )
131 invariant_mass_mixed = (P_photonMixed1 + P_photonMixed2).M();
132 h_Minv_lowpT_back->Fill(invariant_mass_mixed, (P_photonMixed1 + P_photonMixed2).Pt() );
133 h_Minv_highpT_back->Fill(invariant_mass_mixed,(P_photonMixed1 + P_photonMixed2).Pt() );
139 sprintf(outputname,"%s.Minv",filename);
140 TFile output(outputname,"recreate");
141 h_Minv_lowpT->Write();
142 h_Minv_highpT->Write();
143 h_Minv_lowpT_back->Write();
144 h_Minv_highpT_back->Write();
145 h_Pseudoeta->Write();
150 h_Dispersion->Write();
152 h_Asymmetry->Write();
159 void AnaPtSpectrum(char * filename, Int_t NumberPerPtBin, Option_t * particle, Option_t * opt)
162 Int_t NumberOfPtBins = NumberPerPtBin;
163 Float_t PtCalibration = 0.250;
165 TFile * in = new TFile(filename);
167 TH2F * h_Minv_pT = 0;
168 TH2F * h_Minv_pT_back = 0;
171 if (strstr(opt,"low"))
173 h_Minv_pT = (TH2F *) in->Get("h_Minv_lowpT"); ;
174 h_Minv_pT_back = (TH2F *) in->Get("h_Minv_lowpT_back");
175 PtCalibration = 0.250;
176 frame = new TH2F("PtSpectrumlow","Pt Spectrum low",10, 0.,10.,10,0.1,10000);
178 if (strstr(opt,"high"))
180 h_Minv_pT = (TH2F *) in->Get("h_Minv_highpT"); ;
181 h_Minv_pT_back = (TH2F *) in->Get("h_Minv_highpT_back");
183 frame = new TH2F("PtSpectrumhigh","Pt Spectrum high",10, 0.,100.,10,0.1,10000);
186 if ( h_Minv_pT == 0 )
188 printf(">>> Bad Option! \n");
191 Int_t Norma_1 = 100; Float_t Norma_minv_1 = 0.2;
192 Int_t Norma_2 = 200; Float_t Norma_minv_2 = 0.4;
196 if (strstr(particle,"eta"))
202 if (strstr(particle,"norma"))
208 Int_t NHistos = 40/NumberOfPtBins;
212 TH1D * background = 0;
214 TH1D * difference = 0;
217 Float_t PtError[NHistos];
218 Float_t Nmesons[NHistos];
219 Float_t NmesonsError[NHistos];
221 Float_t Ntota, Nback, Norma, NormaError, Renorma;
223 for(iHistos=0; iHistos<NHistos; iHistos++)
225 signal = h_Minv_pT->ProjectionX("signal", NumberOfPtBins*iHistos+1,NumberOfPtBins*(iHistos+1));
226 background = h_Minv_pT_back->ProjectionX("background",NumberOfPtBins*iHistos+1,NumberOfPtBins*(iHistos+1));
228 ratio = new TH1D(*signal);
230 ratio->Add(background,-1.0);
231 ratio->Divide(background);
232 difference = new TH1D(*signal);
234 ratio->Fit("pol0","","",Norma_minv_1,Norma_minv_2);
235 if (background->Integral(Norma_1,Norma_2) == 0)
238 Renorma = signal->Integral(Norma_1,Norma_2)/background->Integral(Norma_1,Norma_2);
239 difference->Add(background,(-1.)*Renorma);
242 Ntota = signal->Integral(Minv_1,Minv_2);
243 Nback = background->Integral(Minv_1,Minv_2);
244 Norma = ratio->GetFunction("pol0")->GetParameter(0);
248 NormaError = ratio->GetFunction("pol0")->GetParError(0);
249 printf("Ntotal %f Nback %f Norma %f and NormaError %f \n",Ntota, Nback, Norma, NormaError);
250 printf("differencia is %f \n",difference->Integral(Minv_1,Minv_2));
251 Nmesons[iHistos] = Ntota - Renorma * Nback;
252 NmesonsError[iHistos] = TMath::Sqrt( Ntota + Nback*Renorma*Renorma + Nback*Nback*NormaError*NormaError );
253 Pt[iHistos] = (iHistos+0.5)*NumberOfPtBins*PtCalibration;
254 PtError[iHistos] = NumberOfPtBins*PtCalibration/2.;
258 char filenameout[80];
259 sprintf(filenameout,"%s.PtSpectrum_%d_%s_%s",filename, NumberPerPtBin, particle, opt);
260 TFile out(filenameout,"recreate");
261 TGraphErrors * PtSpectrum = new TGraphErrors(NHistos, Pt, Nmesons, PtError, NmesonsError);
262 PtSpectrum->SetName("PtSpectrum");
268 frame->SetXTitle("Neutral meson pT (GeV/c)");
269 frame->SetYTitle("Number of neutral mesons per pT bin");
270 PtSpectrum->SetMarkerStyle(27);
271 PtSpectrum->Draw("P");