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 **************************************************************************/
17 /* History of cvs commits:
23 //_________________________________________________________________________
24 // Example class on how to read AODCaloClusters, ESDCaloCells and AODTracks and how
25 // fill AODs with PWG4PartCorr analysis frame
26 // Select the type of detector information that you want to analyze, CTS (tracking), PHOS or EMCAL
27 // Select the PID custer type of the calorimeters
28 // Set min momentum of the cluster/tracks
29 // Fill few histograms
31 //-- Author: Gustavo Conesa (INFN-LNF)
32 //-- Author: Gustavo Conesa (LNF-INFN)
33 //_________________________________________________________________________
36 // --- ROOT system ---
37 #include "Riostream.h"
38 #include "TClonesArray.h"
40 #include "TParticle.h"
42 //---- AliRoot system ----
43 #include "AliAnaExample.h"
44 #include "AliCaloTrackReader.h"
46 #include "AliAODParticleCorrelation.h"
47 #include "AliESDCaloCells.h"
49 ClassImp(AliAnaExample)
51 //____________________________________________________________________________
52 AliAnaExample::AliAnaExample() :
53 AliAnaBaseClass(),fPdg(0), fDetector(""), fhPt(0),fhPhi(0),fhEta(0), fh2Pt(0),fh2Phi(0),fh2Eta(0),
54 fhNCells(0), fhAmplitude(0)
58 //Initialize parameters
62 //____________________________________________________________________________
63 AliAnaExample::AliAnaExample(const AliAnaExample & ex) :
64 AliAnaBaseClass(ex), fPdg(ex.fPdg), fDetector(ex.fDetector), fhPt(ex.fhPt), fhPhi(ex.fhPhi),fhEta(ex.fhEta),
65 fh2Pt(ex.fh2Pt), fh2Phi(ex.fh2Phi),fh2Eta(ex.fh2Eta), fhNCells(ex.fhNCells), fhAmplitude(ex.fhAmplitude)
71 //_________________________________________________________________________
72 AliAnaExample & AliAnaExample::operator = (const AliAnaExample & ex)
74 // assignment operator
76 if(this == &ex)return *this;
77 ((AliAnaBaseClass *)this)->operator=(ex);
80 fDetector = ex.fDetector;
87 fhNCells = ex.fhNCells;
88 fhAmplitude = ex.fhAmplitude;
94 // //____________________________________________________________________________
95 // AliAnaExample::~AliAnaExample()
97 // // Remove all pointers except analysis output pointers.
103 //________________________________________________________________________
104 TList * AliAnaExample::GetCreateOutputObjects()
106 // Create histograms to be saved in output file and
107 // store them in fOutputContainer
109 AliDebug(1,"Init parton histograms");
111 TList * outputContainer = new TList() ;
112 outputContainer->SetName("ExampleHistos") ;
114 fhPt = new TH1F ("hPt","p_T distribution", 100,0,100);
115 fhPt->SetXTitle("p_{T} (GeV/c)");
116 outputContainer->Add(fhPt);
118 fhPhi = new TH1F ("hPhi","#phi distribution", 100,0,TMath::TwoPi());
119 fhPhi->SetXTitle("#phi (rad)");
120 outputContainer->Add(fhPhi);
122 fhEta = new TH1F ("hEta","#eta distribution", 100,-2,2);
123 fhEta->SetXTitle("#eta ");
124 outputContainer->Add(fhEta);
127 fhNCells = new TH1F ("hNCells","# cells per event", 100,0,1000);
128 fhNCells->SetXTitle("n cells");
129 outputContainer->Add(fhNCells);
131 fhAmplitude = new TH1F ("hAmplitude","#eta distribution", 100,0,1000);
132 fhAmplitude->SetXTitle("Amplitude ");
133 outputContainer->Add(fhAmplitude);
136 fh2Pt = new TH2F ("h2Pt","p_T distribution, reconstructed vs generated", 100,0,100,100,0,100);
137 fh2Pt->SetXTitle("p_{T,rec} (GeV/c)");
138 fh2Pt->SetYTitle("p_{T,gen} (GeV/c)");
139 outputContainer->Add(fh2Pt);
141 fh2Phi = new TH2F ("h2Phi","#phi distribution, reconstructed vs generated", 100,0,TMath::TwoPi(), 100,0,TMath::TwoPi());
142 fh2Phi->SetXTitle("#phi_{rec} (rad)");
143 fh2Phi->SetYTitle("#phi_{gen} (rad)");
144 outputContainer->Add(fh2Phi);
146 fh2Eta = new TH2F ("h2Eta","#eta distribution, reconstructed vs generated", 100,-1,1,100,-1,1);
147 fh2Eta->SetXTitle("#eta_{rec} ");
148 fh2Eta->SetYTitle("#eta_{gen} ");
149 outputContainer->Add(fh2Eta);
151 return outputContainer;
154 //__________________________________________________
155 void AliAnaExample::InitParameters()
157 //Initialize the parameters of the analysis.
159 fPdg = 22; //Keep photons
164 //__________________________________________________________________
165 void AliAnaExample::Print(const Option_t * opt) const
167 //Print some relevant parameters set for the analysis
171 printf("Min Pt = %3.2f\n", GetMinPt());
172 printf("Max Pt = %3.2f\n", GetMaxPt());
173 printf("Select clusters with pdg %d \n",fPdg);
174 printf("Select detector %s \n",fDetector.Data());
178 //__________________________________________________________________
179 void AliAnaExample::MakeAnalysisFillAOD()
181 //Do analysis and fill aods
185 if(fDetector == "EMCAL" && GetAODEMCAL())printf("Example : in emcal aod entries %d\n", GetAODEMCAL()->GetEntries());
186 if(fDetector == "CTS" && GetAODCTS())printf("Example : in CTS aod entries %d\n", GetAODCTS()->GetEntries());
187 if(fDetector == "PHOS" && GetAODPHOS())printf("Example : in PHOS aod entries %d\n", GetAODPHOS()->GetEntries());
190 //Get List with tracks or clusters
191 TClonesArray * partList = new TClonesArray;
192 if(fDetector == "CTS") partList = GetAODCTS();
193 else if(fDetector == "EMCAL") partList = GetAODEMCAL();
194 else if(fDetector == "PHOS") partList = GetAODPHOS();
196 if(!partList || partList->GetEntries() == 0) return ;
198 //Fill AODCaloClusters and AODParticleCorrelation with PHOS/EMCAL aods
199 if(fDetector == "EMCAL" || fDetector == "PHOS"){
201 //WORK WITH CALOCLUSTERS
202 ConnectAODCaloClusters(); //Do Only when filling AODCaloClusters
203 if(GetDebug() > 0) printf("Example: in calo clusters aod entries %d\n", GetAODCaloClusters()->GetEntries());
205 //Get vertex for photon momentum calculation
206 Double_t v[3] ; //vertex ;
207 GetReader()->GetVertex(v);
210 for(Int_t i = 0; i < partList->GetEntries(); i++){
212 AliAODCaloCluster * calo = dynamic_cast<AliAODCaloCluster*> (partList->At(i));
214 //Fill AODCaloClusters
215 AddAODCaloCluster(AliAODCaloCluster(*(calo)));
217 //Fill AODParticleCorrelation after some selection
218 calo->GetMomentum(mom,v);
223 pdg = GetCaloPID()->GetPdg(fDetector,pid,mom.E());
224 //pdg = GetCaloPID()->GetPdg(fDetector,mom,
225 // calo->GetM02(), calo->GetM02(),
226 // calo->GetDispersion(), 0, 0);
229 //Acceptance selection
231 if(IsFidutialCutOn())
232 in = GetFidutialCut()->IsInFidutialCut(mom,fDetector) ;
234 if(GetDebug() > 1) printf("cluster pt %2.2f, phi %2.2f, pdg %d, in fidutial cut %d \n",mom.Pt(), mom.Phi(), pdg, in);
236 //Select cluster if momentum, pdg and acceptance are good
237 if(mom.Pt() > GetMinPt() && pdg ==fPdg && in) {
238 AliAODParticleCorrelation ph = AliAODParticleCorrelation(mom);
239 //AddAODParticleCorrelation(AliAODParticleCorrelation(mom));
240 ph.SetLabel(calo->GetLabel(0));
242 ph.SetDetector(fDetector);
243 AddAODParticleCorrelation(ph);
247 //WORK WITH ESDCALOCELLS
248 //Don't connect in the same analysis PHOS and EMCAL cells.
249 AliESDCaloCells * esdCell = new AliESDCaloCells ;
250 if(fDetector == "PHOS") {
251 ConnectAODPHOSCells(); //Do Only when filling AODCaloCells
252 esdCell = (AliESDCaloCells *) GetPHOSCells();
255 ConnectAODEMCALCells(); //Do Only when filling AODCaloCells
256 esdCell = (AliESDCaloCells *) GetEMCALCells();
259 if(GetDebug() > 0 && esdCell )
260 printf("Example : in ESD %s cell entries %d\n", fDetector.Data(), esdCell->GetNumberOfCells());
262 //Fill AODCells in file
263 Int_t ncells = esdCell->GetNumberOfCells() ;
264 GetAODCaloCells()->CreateContainer(ncells);
266 GetAODCaloCells()->SetType((AliAODCaloCells::AODCells_t) esdCell->GetType());
268 for (Int_t iCell = 0; iCell < ncells; iCell++) {
269 if(GetDebug() > 2) printf("cell : amp %f, absId %d, time %f\n", esdCell->GetAmplitude(iCell), esdCell->GetCellNumber(iCell), esdCell->GetTime(iCell));
271 GetAODCaloCells()->SetCell(iCell,esdCell->GetCellNumber(iCell),esdCell->GetAmplitude(iCell));
273 GetAODCaloCells()->Sort();
275 }//cluster-cell analysis
276 else if(fDetector == "CTS"){ //Track analysis
277 //Fill AODParticleCorrelation with CTS aods
279 for(Int_t i = 0; i < GetAODCTS()->GetEntries(); i++){
281 AliAODTrack * track = dynamic_cast<AliAODTrack*> (GetAODCTS()->At(i));
283 //Fill AODParticleCorrelation after some selection
284 Double_t mom[3] = {track->Px(),track->Py(),track->Pz()};
285 p3.SetXYZ(mom[0],mom[1],mom[2]);
287 //Acceptance selection
288 Bool_t in = GetFidutialCut()->IsInFidutialCut(mom,"CTS") ;
289 if(GetDebug() > 1) printf("track pt %2.2f, phi %2.2f, in fidutial cut %d\n",p3.Pt(), p3.Phi(), in);
290 if(p3.Pt() > GetMinPt() && in) {
291 AliAODParticleCorrelation tr = AliAODParticleCorrelation(mom[0],mom[1],mom[2],0);
292 //AddAODParticleCorrelation(AliAODParticleCorrelation(mom));
293 tr.SetDetector("CTS");
294 AddAODParticleCorrelation(tr);
301 printf("Example: final aod calocluster entries %d\n", GetAODCaloClusters()->GetEntries());
302 printf("Example: final aod branch entries %d\n", GetAODBranch()->GetEntries());
303 printf("Example: final aod cell entries %d\n", GetAODCaloCells()->GetNumberOfCells());
307 //__________________________________________________________________
308 void AliAnaExample::MakeAnalysisFillHistograms()
310 //Do analysis and fill histograms
312 //Loop on stored AODParticles
313 Int_t naod = GetAODBranch()->GetEntriesFast();
314 if(GetDebug() > 0) printf("histo aod branch entries %d\n", naod);
315 for(Int_t iaod = 0; iaod < naod ; iaod++){
316 AliAODParticleCorrelation* ph = dynamic_cast<AliAODParticleCorrelation*> (GetAODBranch()->At(iaod));
318 fhPt->Fill(ph->Pt());
319 fhPhi->Fill(ph->Phi());
320 fhEta->Fill(ph->Eta());
323 //Play with the MC stack if available
324 AliStack * stack = GetMCStack() ;
326 if(ph->GetLabel() < 0 || !stack) {
327 printf("*** bad label or no stack ***: label %d \n", ph->GetLabel());
331 if(ph->GetLabel() >= stack->GetNtrack()) {
332 printf("*** large label ***: label %d, n tracks %d \n", ph->GetLabel(), stack->GetNtrack());
336 TParticle * mom = GetMCStack()->Particle(ph->GetLabel());
338 fh2Pt->Fill(ph->Pt(), mom->Pt());
339 fh2Phi->Fill(ph->Phi(), mom->Phi());
340 fh2Eta->Fill(ph->Eta(), mom->Eta());
341 }//Work with stack also
344 // CaloCells histograms
345 if(GetAODCaloCells()){
347 Int_t ncells = GetAODCaloCells()->GetNumberOfCells();
348 fhNCells->Fill(ncells) ;
350 for (Int_t iCell = 0; iCell < ncells; iCell++) {
351 if(GetDebug() > 2) printf("cell : amp %f, absId %d \n", GetAODCaloCells()->GetAmplitude(iCell), GetAODCaloCells()->GetCellNumber(iCell));
352 fhAmplitude->Fill(GetAODCaloCells()->GetAmplitude(iCell));
354 }//calo cells container exist