]>
Commit | Line | Data |
---|---|---|
1c5acb87 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | /* $Id: $ */ | |
16 | ||
17 | //_________________________________________________________________________ | |
f37fa8d2 | 18 | // Example class on how to read CaloClusters, and AODTracks and how |
1c5acb87 | 19 | // fill AODs with PWG4PartCorr analysis frame |
20 | // Select the type of detector information that you want to analyze, CTS (tracking), PHOS or EMCAL | |
21 | // Select the PID custer type of the calorimeters | |
22 | // Set min momentum of the cluster/tracks | |
23 | // Fill few histograms | |
24 | // | |
25 | //-- Author: Gustavo Conesa (INFN-LNF) | |
26 | //_________________________________________________________________________ | |
27 | ||
28 | ||
29 | // --- ROOT system --- | |
30 | //#include "Riostream.h" | |
591cc579 | 31 | #include "TObjArray.h" |
1c5acb87 | 32 | #include "TParticle.h" |
6639984f | 33 | #include "TCanvas.h" |
34 | #include "TPad.h" | |
35 | #include "TROOT.h" | |
477d6cee | 36 | #include "TH2F.h" |
1c5acb87 | 37 | |
38 | //---- AliRoot system ---- | |
39 | #include "AliAnaExample.h" | |
40 | #include "AliCaloTrackReader.h" | |
1c5acb87 | 41 | #include "AliAODPWG4Particle.h" |
1c5acb87 | 42 | #include "AliStack.h" |
43 | #include "AliCaloPID.h" | |
ff45398a | 44 | #include "AliFiducialCut.h" |
f37fa8d2 | 45 | #include "AliVCluster.h" |
477d6cee | 46 | #include "AliAODTrack.h" |
1c5acb87 | 47 | |
48 | ClassImp(AliAnaExample) | |
49 | ||
50 | //____________________________________________________________________________ | |
51 | AliAnaExample::AliAnaExample() : | |
f37fa8d2 | 52 | AliAnaPartCorrBaseClass(),fPdg(0), fDetector(""), fhPt(0),fhPhi(0),fhEta(0), fh2Pt(0),fh2Phi(0),fh2Eta(0) |
1c5acb87 | 53 | { |
54 | //Default Ctor | |
55 | ||
56 | //Initialize parameters | |
57 | InitParameters(); | |
58 | } | |
1c5acb87 | 59 | |
60 | //________________________________________________________________________ | |
61 | TList * AliAnaExample::GetCreateOutputObjects() | |
62 | { | |
477d6cee | 63 | // Create histograms to be saved in output file and |
64 | // store them in fOutputContainer | |
65 | ||
66 | TList * outputContainer = new TList() ; | |
67 | outputContainer->SetName("ExampleHistos") ; | |
68 | ||
5a2dbc3c | 69 | Int_t nptbins = GetHistoPtBins(); |
70 | Int_t nphibins = GetHistoPhiBins(); | |
71 | Int_t netabins = GetHistoEtaBins(); | |
477d6cee | 72 | Float_t ptmax = GetHistoPtMax(); |
73 | Float_t phimax = GetHistoPhiMax(); | |
74 | Float_t etamax = GetHistoEtaMax(); | |
75 | Float_t ptmin = GetHistoPtMin(); | |
76 | Float_t phimin = GetHistoPhiMin(); | |
77 | Float_t etamin = GetHistoEtaMin(); | |
78 | ||
79 | fhPt = new TH1F ("hPt","p_T distribution", nptbins,ptmin,ptmax); | |
80 | fhPt->SetXTitle("p_{T} (GeV/c)"); | |
81 | outputContainer->Add(fhPt); | |
82 | ||
83 | fhPhi = new TH1F ("hPhi","#phi distribution",nphibins,phimin,phimax); | |
84 | fhPhi->SetXTitle("#phi (rad)"); | |
85 | outputContainer->Add(fhPhi); | |
86 | ||
87 | fhEta = new TH1F ("hEta","#eta distribution",netabins,etamin,etamax); | |
88 | fhEta->SetXTitle("#eta "); | |
89 | outputContainer->Add(fhEta); | |
90 | ||
477d6cee | 91 | if(IsDataMC()){ |
92 | fh2Pt = new TH2F ("h2Pt","p_T distribution, reconstructed vs generated", nptbins,ptmin,ptmax,nptbins,ptmin,ptmax); | |
93 | fh2Pt->SetXTitle("p_{T,rec} (GeV/c)"); | |
94 | fh2Pt->SetYTitle("p_{T,gen} (GeV/c)"); | |
95 | outputContainer->Add(fh2Pt); | |
96 | ||
97 | fh2Phi = new TH2F ("h2Phi","#phi distribution, reconstructed vs generated", nphibins,phimin,phimax, nphibins,phimin,phimax); | |
98 | fh2Phi->SetXTitle("#phi_{rec} (rad)"); | |
99 | fh2Phi->SetYTitle("#phi_{gen} (rad)"); | |
100 | outputContainer->Add(fh2Phi); | |
101 | ||
102 | fh2Eta = new TH2F ("h2Eta","#eta distribution, reconstructed vs generated", netabins,etamin,etamax,netabins,etamin,etamax); | |
103 | fh2Eta->SetXTitle("#eta_{rec} "); | |
104 | fh2Eta->SetYTitle("#eta_{gen} "); | |
105 | outputContainer->Add(fh2Eta); | |
106 | ||
107 | } | |
a3aebfff | 108 | |
477d6cee | 109 | return outputContainer; |
1c5acb87 | 110 | } |
111 | ||
477d6cee | 112 | //__________________________________________________ |
1c5acb87 | 113 | void AliAnaExample::InitParameters() |
114 | { | |
115 | //Initialize the parameters of the analysis. | |
116 | SetOutputAODClassName("AliAODPWG4Particle"); | |
a3aebfff | 117 | SetOutputAODName("PWG4Particle"); |
118 | AddToHistogramsName("AnaExample_"); | |
119 | ||
1c5acb87 | 120 | fPdg = 22; //Keep photons |
121 | fDetector = "PHOS"; | |
122 | ||
123 | } | |
124 | ||
125 | //__________________________________________________________________ | |
126 | void AliAnaExample::Print(const Option_t * opt) const | |
127 | { | |
128 | //Print some relevant parameters set for the analysis | |
129 | if(! opt) | |
130 | return; | |
131 | ||
a3aebfff | 132 | printf("**** Print %s %s ****\n", GetName(), GetTitle() ) ; |
133 | AliAnaPartCorrBaseClass::Print(" "); | |
134 | ||
1c5acb87 | 135 | printf("Select clusters with pdg %d \n",fPdg); |
136 | printf("Select detector %s \n",fDetector.Data()); | |
137 | ||
138 | } | |
139 | ||
140 | //__________________________________________________________________ | |
141 | void AliAnaExample::MakeAnalysisFillAOD() | |
142 | { | |
477d6cee | 143 | //Do analysis and fill aods |
144 | ||
145 | //Some prints | |
146 | if(GetDebug() > 0){ | |
a3aebfff | 147 | if(fDetector == "EMCAL" && GetAODEMCAL())printf("AliAnaExample::MakeAnalysisFillAOD() - In EMCAL aod entries %d\n", GetAODEMCAL()->GetEntriesFast()); |
f37fa8d2 | 148 | if(fDetector == "CTS" && GetAODCTS()) printf("AliAnaExample::MakeAnalysisFillAOD() - In CTS aod entries %d\n", GetAODCTS() ->GetEntriesFast()); |
149 | if(fDetector == "PHOS" && GetAODPHOS()) printf("AliAnaExample::MakeAnalysisFillAOD() - In PHOS aod entries %d\n", GetAODPHOS() ->GetEntriesFast()); | |
477d6cee | 150 | } |
151 | ||
152 | //Get List with tracks or clusters | |
4a745797 | 153 | TObjArray * partList = 0x0; |
f37fa8d2 | 154 | if(fDetector == "CTS") partList = GetAODCTS(); |
477d6cee | 155 | else if(fDetector == "EMCAL") partList = GetAODEMCAL(); |
f37fa8d2 | 156 | else if(fDetector == "PHOS") partList = GetAODPHOS(); |
477d6cee | 157 | |
158 | if(!partList || partList->GetEntriesFast() == 0) return ; | |
159 | ||
160 | //Fill AODCaloClusters and AODParticle with PHOS/EMCAL aods | |
161 | if(fDetector == "EMCAL" || fDetector == "PHOS"){ | |
162 | ||
163 | //Get vertex for photon momentum calculation | |
164 | Double_t v[3] ; //vertex ; | |
165 | GetReader()->GetVertex(v); | |
166 | ||
167 | TLorentzVector mom ; | |
168 | for(Int_t i = 0; i < partList->GetEntriesFast(); i++){ | |
169 | ||
f37fa8d2 | 170 | AliVCluster * calo = (AliVCluster*) (partList->At(i)); |
477d6cee | 171 | |
172 | //Fill AODParticle after some selection | |
173 | calo->GetMomentum(mom,v); | |
174 | Int_t pdg = fPdg; | |
175 | ||
176 | if(IsCaloPIDOn()){ | |
f37fa8d2 | 177 | const Double_t *pid = calo->GetPID(); |
178 | pdg = GetCaloPID()->GetPdg(fDetector,pid,mom.E()); | |
179 | //pdg = GetCaloPID()->GetPdg(fDetector,mom, | |
180 | // calo->GetM02(), calo->GetM02(), | |
181 | // calo->GetDispersion(), 0, 0); | |
477d6cee | 182 | } |
183 | ||
184 | //Acceptance selection | |
185 | Bool_t in = kTRUE; | |
ff45398a | 186 | if(IsFiducialCutOn()) |
f37fa8d2 | 187 | in = GetFiducialCut()->IsInFiducialCut(mom,fDetector) ; |
477d6cee | 188 | |
ff45398a | 189 | if(GetDebug() > 1) printf("AliAnaExample::MakeAnalysisFillAOD() - Cluster pt %2.2f, phi %2.2f, pdg %d, in fiducial cut %d \n",mom.Pt(), mom.Phi(), pdg, in); |
477d6cee | 190 | |
191 | //Select cluster if momentum, pdg and acceptance are good | |
192 | if(mom.Pt() > GetMinPt() && pdg ==fPdg && in) { | |
f37fa8d2 | 193 | AliAODPWG4Particle ph = AliAODPWG4Particle(mom); |
194 | //AddAODParticleCorrelation(AliAODPWG4ParticleCorrelation(mom)); | |
195 | ph.SetLabel(calo->GetLabel()); | |
196 | ph.SetPdg(pdg); | |
197 | ph.SetDetector(fDetector); | |
198 | AddAODParticle(ph); | |
477d6cee | 199 | }//selection |
200 | }//loop | |
f37fa8d2 | 201 | }//Calorimeters |
477d6cee | 202 | else if(fDetector == "CTS"){ //Track analysis |
203 | //Fill AODParticle with CTS aods | |
204 | TVector3 p3; | |
205 | for(Int_t i = 0; i < GetAODCTS()->GetEntriesFast(); i++){ | |
206 | ||
207 | AliAODTrack * track = (AliAODTrack*) (GetAODCTS()->At(i)); | |
208 | ||
209 | //Fill AODParticle after some selection | |
210 | Double_t mom[3] = {track->Px(),track->Py(),track->Pz()}; | |
211 | p3.SetXYZ(mom[0],mom[1],mom[2]); | |
212 | ||
213 | //Acceptance selection | |
ff45398a | 214 | Bool_t in = GetFiducialCut()->IsInFiducialCut(mom,"CTS") ; |
215 | if(GetDebug() > 1) printf("AliAnaExample::MakeAnalysisFillAOD() - Track pt %2.2f, phi %2.2f, in fiducial cut %d\n",p3.Pt(), p3.Phi(), in); | |
477d6cee | 216 | if(p3.Pt() > GetMinPt() && in) { |
f37fa8d2 | 217 | AliAODPWG4Particle tr = AliAODPWG4Particle(mom[0],mom[1],mom[2],0); |
218 | tr.SetDetector("CTS"); | |
219 | AddAODParticle(tr); | |
477d6cee | 220 | }//selection |
221 | }//loop | |
222 | }//CTS analysis | |
223 | ||
224 | if(GetDebug() > 0) { | |
225 | if(fDetector!="CTS" && GetReader()->GetDataType()!= AliCaloTrackReader::kMC) | |
226 | //printf("Example: final aod calocluster entries %d\n", GetAODCaloClusters()->GetEntriesFast()); | |
a3aebfff | 227 | printf("AliAnaExample::MakeAnalysisFillAOD() - Final aod branch entries %d\n", GetOutputAODBranch()->GetEntriesFast()); |
477d6cee | 228 | // if(fDetector!="CTS" && GetReader()->GetDataType()!= AliCaloTrackReader::kMC) |
229 | //printf("Example: final aod cell entries %d\n", GetAODCaloCells()->GetNumberOfCells()); | |
230 | } | |
1c5acb87 | 231 | } |
232 | ||
233 | //__________________________________________________________________ | |
234 | void AliAnaExample::MakeAnalysisFillHistograms() | |
235 | { | |
477d6cee | 236 | //Do analysis and fill histograms |
237 | ||
238 | //Loop on stored AODParticles | |
239 | Int_t naod = GetOutputAODBranch()->GetEntriesFast(); | |
a3aebfff | 240 | if(GetDebug() > 0) printf("AliAnaExample::MakeAnalysisFillHistograms() - Histo aod branch entries %d\n", naod); |
477d6cee | 241 | for(Int_t iaod = 0; iaod < naod ; iaod++){ |
242 | AliAODPWG4Particle* ph = (AliAODPWG4Particle*) (GetOutputAODBranch()->At(iaod)); | |
243 | ||
244 | fhPt->Fill(ph->Pt()); | |
245 | fhPhi->Fill(ph->Phi()); | |
246 | fhEta->Fill(ph->Eta()); | |
247 | ||
248 | if(IsDataMC()){ | |
f37fa8d2 | 249 | //Play with the MC stack if available |
591cc579 | 250 | Float_t ptprim = 0; |
251 | Float_t phiprim = 0; | |
252 | Float_t etaprim = 0; | |
253 | if(GetReader()->ReadStack()){ | |
254 | AliStack * stack = GetMCStack() ; | |
477d6cee | 255 | |
591cc579 | 256 | if(ph->GetLabel() < 0 || !stack) { |
257 | printf("AliAnaExample::MakeAnalysisFillHistograms() *** bad label or no stack ***: label %d \n", ph->GetLabel()); | |
258 | continue; | |
259 | } | |
477d6cee | 260 | |
591cc579 | 261 | if(ph->GetLabel() >= stack->GetNtrack()) { |
262 | printf("AliAnaExample::MakeAnalysisFillHistograms() *** large label ***: label %d, n tracks %d \n", ph->GetLabel(), stack->GetNtrack()); | |
263 | continue ; | |
264 | } | |
477d6cee | 265 | |
591cc579 | 266 | TParticle * mom = GetMCStack()->Particle(ph->GetLabel()); |
f37fa8d2 | 267 | ptprim = mom->Pt(); |
591cc579 | 268 | phiprim = mom->Phi(); |
269 | etaprim = mom->Eta(); | |
270 | } | |
271 | else if(GetReader()->ReadAODMCParticles()){ | |
272 | printf("AliAnaExample::MakeAnalysisFillHistograms() - Acceptance calculation with MCParticles not implemented yet\n"); | |
273 | } | |
274 | fh2Pt->Fill(ph->Pt(), ptprim); | |
275 | fh2Phi->Fill(ph->Phi(), phiprim); | |
276 | fh2Eta->Fill(ph->Eta(), etaprim); | |
477d6cee | 277 | }//Work with stack also |
278 | }// aod branch loop | |
279 | ||
f37fa8d2 | 280 | } |
6639984f | 281 | |
a5cc4f03 | 282 | //________________________________________________________________________ |
283 | void AliAnaExample::ReadHistograms(TList* outputList) | |
284 | { | |
285 | // Needed when Terminate is executed in distributed environment | |
286 | // Refill analysis histograms of this class with corresponding histograms in output list. | |
287 | ||
288 | // Histograms of this analsys are kept in the same list as other analysis, recover the position of | |
289 | // the first one and then add the next | |
290 | Int_t index = outputList->IndexOf(outputList->FindObject(GetAddedHistogramsStringToName()+"hPt")); | |
291 | ||
292 | //Read histograms, must be in the same order as in GetCreateOutputObject. | |
293 | fhPt = (TH1F *) outputList->At(index++); | |
294 | fhPhi = (TH1F *) outputList->At(index++); | |
295 | fhEta = (TH1F *) outputList->At(index++); | |
296 | ||
a5cc4f03 | 297 | if(IsDataMC()){ |
298 | fh2Pt = (TH2F *) outputList->At(index++); | |
299 | fh2Phi = (TH2F *) outputList->At(index++); | |
300 | fh2Eta = (TH2F *) outputList->At(index); | |
301 | } | |
302 | ||
303 | } | |
304 | ||
6639984f | 305 | //__________________________________________________________________ |
a5cc4f03 | 306 | void AliAnaExample::Terminate(TList* outputList) |
6639984f | 307 | { |
477d6cee | 308 | |
6639984f | 309 | //Do some plots to end |
477d6cee | 310 | |
a5cc4f03 | 311 | //Recover histograms from output histograms list, needed for distributed analysis. |
312 | ReadHistograms(outputList); | |
313 | ||
a3aebfff | 314 | printf(" AliAnaExample::Terminate() *** %s Report:", GetName()) ; |
315 | printf(" AliAnaExample::Terminate() pt : %5.3f , RMS : %5.3f \n", fhPt->GetMean(), fhPt->GetRMS() ) ; | |
6639984f | 316 | |
317 | TCanvas * c = new TCanvas("c", "PHOS ESD Test", 400, 10, 600, 700) ; | |
318 | c->Divide(1, 3); | |
319 | ||
320 | c->cd(1) ; | |
321 | gPad->SetLogy(); | |
322 | fhPt->SetLineColor(2); | |
323 | fhPt->Draw(); | |
324 | ||
325 | c->cd(2) ; | |
326 | fhPhi->SetLineColor(2); | |
327 | fhPhi->Draw(); | |
328 | ||
329 | c->cd(3) ; | |
330 | fhEta->SetLineColor(2); | |
331 | fhEta->Draw(); | |
332 | ||
333 | c->Print("Example.eps"); | |
334 | ||
335 | char line[1024] ; | |
336 | sprintf(line, ".!tar -zcf %s.tar.gz *.eps", GetName()) ; | |
337 | gROOT->ProcessLine(line); | |
338 | sprintf(line, ".!rm -fR *.eps"); | |
339 | gROOT->ProcessLine(line); | |
340 | ||
a3aebfff | 341 | printf("AliAnaExample::Terminate() - !! All the eps files are in %s.tar.gz !!!", GetName()); |
6639984f | 342 | |
343 | } |