1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 //_________________________________________________________________________
18 // Class for track selection and identification (not done now)
19 // Tracks from the CTS are kept in the AOD.
20 // Few histograms produced.
22 //-- Author: Gustavo Conesa (INFN-LNF)
23 //_________________________________________________________________________
26 // --- ROOT system ---
27 #include "TParticle.h"
30 //---- AliRoot system ----
31 #include "AliAnaChargedParticles.h"
32 #include "AliCaloTrackReader.h"
33 #include "AliAODPWG4Particle.h"
35 #include "AliFiducialCut.h"
36 #include "AliVTrack.h"
37 #include "AliAODMCParticle.h"
39 ClassImp(AliAnaChargedParticles)
41 //__________________________________________________
42 AliAnaChargedParticles::AliAnaChargedParticles() :
43 AliAnaCaloTrackCorrBaseClass(),
45 fhNtracks(0), fhPt(0),
46 fhPhiNeg(0), fhEtaNeg(0),
47 fhPhiPos(0), fhEtaPos(0),
48 fhEtaPhiPos(0), fhEtaPhiNeg(0),
50 fhPtPion(0), fhPhiPion(0), fhEtaPion(0),
51 fhPtProton(0), fhPhiProton(0), fhEtaProton(0),
52 fhPtElectron(0), fhPhiElectron(0), fhEtaElectron(0),
53 fhPtKaon(0), fhPhiKaon(0), fhEtaKaon(0),
54 fhPtUnknown(0), fhPhiUnknown(0), fhEtaUnknown(0),
55 fhTOFSignal(0), fhTOFSignalPtCut(0),
56 fhPtTOFSignal(0), fhPtTOFStatus0(0), fhEtaPhiTOFStatus0(0)
60 for(Int_t i = 0; i < 7; i++) fhPtTOFSignalPileUp[i] = 0;
62 //Initialize parameters
67 //_______________________________________________________
68 TList * AliAnaChargedParticles::GetCreateOutputObjects()
70 // Create histograms to be saved in output file and
71 // store them in fOutputContainer
74 TList * outputContainer = new TList() ;
75 outputContainer->SetName("ExampleHistos") ;
77 Int_t nptbins = GetHistogramRanges()->GetHistoPtBins(); Int_t nphibins = GetHistogramRanges()->GetHistoPhiBins(); Int_t netabins = GetHistogramRanges()->GetHistoEtaBins();
78 Float_t ptmax = GetHistogramRanges()->GetHistoPtMax(); Float_t phimax = GetHistogramRanges()->GetHistoPhiMax(); Float_t etamax = GetHistogramRanges()->GetHistoEtaMax();
79 Float_t ptmin = GetHistogramRanges()->GetHistoPtMin(); Float_t phimin = GetHistogramRanges()->GetHistoPhiMin(); Float_t etamin = GetHistogramRanges()->GetHistoEtaMin();
81 fhNtracks = new TH1F ("hNtracks","# of tracks", 1000,0,1000);
82 fhNtracks->SetXTitle("# of tracks");
83 outputContainer->Add(fhNtracks);
85 fhPt = new TH1F ("hPt","p_T distribution", nptbins,ptmin,ptmax);
86 fhPt->SetXTitle("p_{T} (GeV/c)");
87 outputContainer->Add(fhPt);
89 fhPhiNeg = new TH2F ("hPhiNegative","#phi of negative charges distribution",
90 nptbins,ptmin,ptmax, nphibins,phimin,phimax);
91 fhPhiNeg->SetYTitle("#phi (rad)");
92 fhPhiNeg->SetXTitle("p_{T} (GeV/c)");
93 outputContainer->Add(fhPhiNeg);
95 fhEtaNeg = new TH2F ("hEtaNegative","#eta of negative charges distribution",
96 nptbins,ptmin,ptmax, netabins,etamin,etamax);
97 fhEtaNeg->SetYTitle("#eta ");
98 fhEtaNeg->SetXTitle("p_{T} (GeV/c)");
99 outputContainer->Add(fhEtaNeg);
101 fhPhiPos = new TH2F ("hPhiPositive","#phi of positive charges distribution",
102 nptbins,ptmin,ptmax, nphibins,phimin,phimax);
103 fhPhiPos->SetYTitle("#phi (rad)");
104 fhPhiPos->SetXTitle("p_{T} (GeV/c)");
105 outputContainer->Add(fhPhiPos);
107 fhEtaPos = new TH2F ("hEtaPositive","#eta of positive charges distribution",
108 nptbins,ptmin,ptmax, netabins,etamin,etamax);
109 fhEtaPos->SetYTitle("#eta ");
110 fhEtaPos->SetXTitle("p_{T} (GeV/c)");
111 outputContainer->Add(fhEtaPos);
113 fhEtaPhiPos = new TH2F ("hEtaPhiPositive","pt/eta/phi of positive charge",netabins,etamin,etamax, nphibins,phimin,phimax);
114 fhEtaPhiPos->SetXTitle("#eta ");
115 fhEtaPhiPos->SetYTitle("#phi (rad)");
116 outputContainer->Add(fhEtaPhiPos);
118 fhEtaPhiNeg = new TH2F ("hEtaPhiNegative","eta vs phi of negative charge",netabins,etamin,etamax, nphibins,phimin,phimax);
119 fhEtaPhiNeg->SetXTitle("#eta ");
120 fhEtaPhiNeg->SetYTitle("#phi (rad)");
121 outputContainer->Add(fhEtaPhiNeg);
123 Int_t ntofbins = 1000;
127 fhTOFSignal = new TH1F ("hTOFSignal","TOF signal", ntofbins,mintof,maxtof);
128 fhTOFSignal->SetXTitle("TOF signal #times (ns?)");
129 outputContainer->Add(fhTOFSignal);
131 fhTOFSignalPtCut = new TH1F ("hTOFSignalPtCut","TOF signal", ntofbins,mintof,maxtof);
132 fhTOFSignalPtCut->SetXTitle("TOF signal (ns?)");
133 outputContainer->Add(fhTOFSignalPtCut);
135 fhPtTOFSignal = new TH2F ("hPtTOFSignal","TOF signal", nptbins,ptmin,ptmax,ntofbins,mintof,maxtof);
136 fhPtTOFSignal->SetYTitle("TOF signal (ns?)");
137 fhPtTOFSignal->SetXTitle("p_{T} (GeV/c)");
138 outputContainer->Add(fhPtTOFSignal);
140 TString pileUpName[] = {"SPD","EMCAL","SPDOrEMCAL","SPDAndEMCAL","SPDAndNotEMCAL","EMCALAndNotSPD","NotSPDAndNotEMCAL"} ;
142 for(Int_t i = 0 ; i < 7 ; i++)
144 fhPtTOFSignalPileUp[i] = new TH2F(Form("hPtTOFSignalPileUp%s",pileUpName[i].Data()),
145 Form("Track TOF vs p_{T} distribution, %s Pile-Up event",pileUpName[i].Data()),
146 nptbins,ptmin,ptmax,ntofbins,mintof,maxtof);
147 fhPtTOFSignalPileUp[i]->SetXTitle("p_{T} (GeV/c)");
148 fhPtTOFSignalPileUp[i]->SetXTitle("TOF signal (ns?)");
149 outputContainer->Add(fhPtTOFSignalPileUp[i]);
152 fhPtTOFStatus0 = new TH1F ("hPtTOFStatus0","p_T distribution of tracks not hitting TOF", nptbins,ptmin,ptmax);
153 fhPtTOFStatus0->SetXTitle("p_{T} (GeV/c)");
154 outputContainer->Add(fhPtTOFStatus0);
157 fhEtaPhiTOFStatus0 = new TH2F ("hEtaPhiTOFStatus0","pt/eta/phi for tracks without hit on TOF",netabins,etamin,etamax, nphibins,phimin,phimax);
158 fhEtaPhiTOFStatus0->SetXTitle("#eta ");
159 fhEtaPhiTOFStatus0->SetYTitle("#phi (rad)");
160 outputContainer->Add(fhEtaPhiTOFStatus0);
165 fhPtPion = new TH1F ("hPtMCPion","p_T distribution from #pi", nptbins,ptmin,ptmax);
166 fhPtPion->SetXTitle("p_{T} (GeV/c)");
167 outputContainer->Add(fhPtPion);
169 fhPhiPion = new TH2F ("hPhiMCPion","#phi distribution from #pi",nptbins,ptmin,ptmax, nphibins,phimin,phimax);
170 fhPhiPion->SetXTitle("#phi (rad)");
171 outputContainer->Add(fhPhiPion);
173 fhEtaPion = new TH2F ("hEtaMCPion","#eta distribution from #pi",nptbins,ptmin,ptmax, netabins,etamin,etamax);
174 fhEtaPion->SetXTitle("#eta ");
175 outputContainer->Add(fhEtaPion);
177 fhPtProton = new TH1F ("hPtMCProton","p_T distribution from proton", nptbins,ptmin,ptmax);
178 fhPtProton->SetXTitle("p_{T} (GeV/c)");
179 outputContainer->Add(fhPtProton);
181 fhPhiProton = new TH2F ("hPhiMCProton","#phi distribution from proton",nptbins,ptmin,ptmax, nphibins,phimin,phimax);
182 fhPhiProton->SetXTitle("#phi (rad)");
183 outputContainer->Add(fhPhiProton);
185 fhEtaProton = new TH2F ("hEtaMCProton","#eta distribution from proton",nptbins,ptmin,ptmax, netabins,etamin,etamax);
186 fhEtaProton->SetXTitle("#eta ");
187 outputContainer->Add(fhEtaProton);
189 fhPtKaon = new TH1F ("hPtMCKaon","p_T distribution from kaon", nptbins,ptmin,ptmax);
190 fhPtKaon->SetXTitle("p_{T} (GeV/c)");
191 outputContainer->Add(fhPtKaon);
193 fhPhiKaon = new TH2F ("hPhiMCKaon","#phi distribution from kaon",nptbins,ptmin,ptmax, nphibins,phimin,phimax);
194 fhPhiKaon->SetXTitle("#phi (rad)");
195 outputContainer->Add(fhPhiKaon);
197 fhEtaKaon = new TH2F ("hEtaMCKaon","#eta distribution from kaon",nptbins,ptmin,ptmax, netabins,etamin,etamax);
198 fhEtaKaon->SetXTitle("#eta ");
199 outputContainer->Add(fhEtaKaon);
201 fhPtElectron = new TH1F ("hPtMCElectron","p_T distribution from electron", nptbins,ptmin,ptmax);
202 fhPtElectron->SetXTitle("p_{T} (GeV/c)");
203 outputContainer->Add(fhPtElectron);
205 fhPhiElectron = new TH2F ("hPhiMCElectron","#phi distribution from electron",nptbins,ptmin,ptmax, nphibins,phimin,phimax);
206 fhPhiElectron->SetXTitle("#phi (rad)");
207 outputContainer->Add(fhPhiElectron);
209 fhEtaElectron = new TH2F ("hEtaMCElectron","#eta distribution from electron",nptbins,ptmin,ptmax, netabins,etamin,etamax);
210 fhEtaElectron->SetXTitle("#eta ");
211 outputContainer->Add(fhEtaElectron);
213 fhPtUnknown = new TH1F ("hPtMCUnknown","p_T distribution from unknown", nptbins,ptmin,ptmax);
214 fhPtUnknown->SetXTitle("p_{T} (GeV/c)");
215 outputContainer->Add(fhPtUnknown);
217 fhPhiUnknown = new TH2F ("hPhiMCUnknown","#phi distribution from unknown",nptbins,ptmin,ptmax, nphibins,phimin,phimax);
218 fhPhiUnknown->SetXTitle("#phi (rad)");
219 outputContainer->Add(fhPhiUnknown);
221 fhEtaUnknown = new TH2F ("hEtaMCUnknown","#eta distribution from unknown",nptbins,ptmin,ptmax, netabins,etamin,etamax);
222 fhEtaUnknown->SetXTitle("#eta ");
223 outputContainer->Add(fhEtaUnknown);
227 return outputContainer;
231 //___________________________________________
232 void AliAnaChargedParticles::InitParameters()
234 //Initialize the parameters of the analysis.
235 SetOutputAODClassName("AliAODPWG4Particle");
236 SetOutputAODName("PWG4Particle");
238 AddToHistogramsName("AnaCharged_");
240 fPdg = -1; //Select all tracks
244 //____________________________________________________________
245 void AliAnaChargedParticles::Print(const Option_t * opt) const
247 //Print some relevant parameters set for the analysis
251 printf("**** Print %s %s ****\n", GetName(), GetTitle() ) ;
252 AliAnaCaloTrackCorrBaseClass::Print(" ");
254 printf("Min Pt = %3.2f\n", GetMinPt());
255 printf("Max Pt = %3.2f\n", GetMaxPt());
256 printf("Select clusters with pdg %d \n",fPdg);
260 //_________________________________
261 void AliAnaChargedParticles::Init()
265 if(!GetReader()->IsCTSSwitchedOn()){
266 printf("AliAnaChargedParticles::Init() - STOP!: You want to use CTS tracks in analysis but not read!! \n!!Check the configuration file!!\n");
272 //_________________________________________________
273 void AliAnaChargedParticles::MakeAnalysisFillAOD()
275 //Do analysis and fill aods
276 if(!GetCTSTracks() || GetCTSTracks()->GetEntriesFast() == 0) return ;
278 Int_t ntracks = GetCTSTracks()->GetEntriesFast();
279 Double_t vert[3] = {0,0,0}; //vertex ;
283 printf("AliAnaChargedParticles::MakeAnalysisFillAOD() - In CTS aod entries %d\n", ntracks);
285 //Fill AODParticle with CTS aods
288 for(Int_t i = 0; i < ntracks; i++){
290 AliVTrack * track = (AliVTrack*) (GetCTSTracks()->At(i));
292 //Fill AODParticle after some selection
293 Double_t mom[3] = {track->Px(),track->Py(),track->Pz()};
294 p3.SetXYZ(mom[0],mom[1],mom[2]);
297 ULong_t status = track->GetStatus();
298 Bool_t okTOF = ( (status & AliVTrack::kTOFout) == AliVTrack::kTOFout ) && ( (status & AliVTrack::kTIME) == AliVTrack::kTIME );
299 Double32_t tof = track->GetTOFsignal()*1e-3;
300 //if( tof < 0) printf("TOF Signal %e, status %d, pt %f\n", tof,status,status2,p3.Pt());
304 fhTOFSignal ->Fill(tof);
305 fhPtTOFSignal->Fill(p3.Pt(), tof);
307 if(GetReader()->IsPileUpFromSPD()) fhPtTOFSignalPileUp[0]->Fill(p3.Pt(), tof);
308 if(GetReader()->IsPileUpFromEMCal()) fhPtTOFSignalPileUp[1]->Fill(p3.Pt(), tof);
309 if(GetReader()->IsPileUpFromSPDOrEMCal()) fhPtTOFSignalPileUp[2]->Fill(p3.Pt(), tof);
310 if(GetReader()->IsPileUpFromSPDAndEMCal()) fhPtTOFSignalPileUp[3]->Fill(p3.Pt(), tof);
311 if(GetReader()->IsPileUpFromSPDAndNotEMCal()) fhPtTOFSignalPileUp[4]->Fill(p3.Pt(), tof);
312 if(GetReader()->IsPileUpFromEMCalAndNotSPD()) fhPtTOFSignalPileUp[5]->Fill(p3.Pt(), tof);
313 if(GetReader()->IsPileUpFromNotSPDAndNotEMCal()) fhPtTOFSignalPileUp[6]->Fill(p3.Pt(), tof);
316 Bool_t in = GetFiducialCut()->IsInFiducialCut(mom,"CTS") ;
319 printf("AliAnaChargedParticles::MakeAnalysisFillAOD() - Track pt %2.2f, phi %2.2f, eta %2.2f in fiducial cut %d\n",p3.Pt(), p3.Phi(), p3.Eta(),in);
321 //Acceptance selection
322 if(IsFiducialCutOn() && ! in ) continue ;
324 // Momentum selection
325 if(track->Pt() < GetMinPt() || track->Pt() > GetMaxPt()) continue;
327 if(okTOF) fhTOFSignalPtCut->Fill(tof);
330 fhPtTOFStatus0 ->Fill(track->Pt());
331 fhEtaPhiTOFStatus0->Fill(track->Eta(),track->Phi());
334 //Keep only particles identified with fPdg
335 //Selection not done for the moment
336 //Should be done here.
341 evtIndex = GetMixedEvent()->EventIndex(track->GetID()) ;
344 GetVertex(vert,evtIndex);
345 if(TMath::Abs(vert[2])> GetZvertexCut()) return;
347 AliAODPWG4Particle tr = AliAODPWG4Particle(mom[0],mom[1],mom[2],0);
348 tr.SetDetector("CTS");
349 tr.SetLabel(track->GetLabel());
350 tr.SetTrackLabel(track->GetID(),-1);
351 tr.SetChargedBit(track->Charge()>0);
358 printf("AliAnaChargedParticles::MakeAnalysisFillAOD() - Final aod branch entries %d\n", GetOutputAODBranch()->GetEntriesFast());
361 //__________________________________________________________________
362 void AliAnaChargedParticles::MakeAnalysisFillHistograms()
364 //Do analysis and fill histograms
366 //Loop on stored AODParticles
367 Int_t naod = GetOutputAODBranch()->GetEntriesFast();
369 fhNtracks->Fill(GetReader()->GetTrackMultiplicity()) ;
372 printf("AliAnaChargedParticles::MakeAnalysisFillHistograms() - aod branch entries %d\n", naod);
374 for(Int_t iaod = 0; iaod < naod ; iaod++){
375 AliAODPWG4Particle* tr = (AliAODPWG4Particle*) (GetOutputAODBranch()->At(iaod));
377 fhPt->Fill(tr->Pt());
379 if(tr->GetChargedBit()){
380 fhPhiPos ->Fill(tr->Pt(), tr->Phi());
381 fhEtaPos ->Fill(tr->Pt(), tr->Eta());
382 fhEtaPhiPos->Fill(tr->Eta(),tr->Phi());
385 fhPhiNeg ->Fill(tr->Pt(), tr->Phi());
386 fhEtaNeg ->Fill(tr->Pt(), tr->Eta());
387 fhEtaPhiNeg->Fill(tr->Eta(),tr->Phi());
392 //Play with the MC stack if available
394 Int_t label = tr->GetLabel();
397 if( GetReader()->ReadStack() && label < GetMCStack()->GetNtrack())
399 TParticle * mom = GetMCStack()->Particle(label);
400 mompdg =TMath::Abs(mom->GetPdgCode());
402 else if(GetReader()->ReadAODMCParticles())
404 AliAODMCParticle * aodmom = 0;
405 //Get the list of MC particles
406 aodmom = (AliAODMCParticle*) (GetReader()->GetAODMCParticles(tr->GetInputFileIndex()))->At(label);
407 mompdg =TMath::Abs(aodmom->GetPdgCode());
413 fhPtPion ->Fill(tr->Pt());
414 fhPhiPion->Fill(tr->Pt(), tr->Phi());
415 fhEtaPion->Fill(tr->Pt(), tr->Eta());
417 else if(mompdg==2212)
419 fhPtProton ->Fill(tr->Pt());
420 fhPhiProton->Fill(tr->Pt(), tr->Phi());
421 fhEtaProton->Fill(tr->Pt(), tr->Eta());
425 fhPtKaon ->Fill(tr->Pt());
426 fhPhiKaon->Fill(tr->Pt(), tr->Phi());
427 fhEtaKaon->Fill(tr->Pt(), tr->Eta());
431 fhPtElectron ->Fill(tr->Pt());
432 fhPhiElectron->Fill(tr->Pt(), tr->Phi());
433 fhEtaElectron->Fill(tr->Pt(), tr->Eta());
436 //printf("unknown pdg %d\n",mompdg);
437 fhPtUnknown ->Fill(tr->Pt());
438 fhPhiUnknown->Fill(tr->Pt(), tr->Phi());
439 fhEtaUnknown->Fill(tr->Pt(), tr->Eta());
442 }//Work with stack also