1-New correlation analysis for particle and jet-JETAN correlation; 2-Change GetEntrie...
[u/mrichter/AliRoot.git] / PWG4 / AliCaloTrackESDReader.cxx
CommitLineData
d92b41ad 1
2/**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16/* $Id: $ */
17
d92b41ad 18//_________________________________________________________________________
19// Class for reading data (ESDs) in order to do prompt gamma
20// or other particle identification and correlations
21//
22//
23//*-- Author: Gustavo Conesa (LNF-INFN)
24//////////////////////////////////////////////////////////////////////////////
25
26
27// --- ROOT system ---
28
29//---- ANALYSIS system ----
30#include "AliCaloTrackESDReader.h"
31#include "AliESDEvent.h"
32#include "AliESDVertex.h"
33#include "AliESDCaloCluster.h"
34#include "AliAODCaloCluster.h"
35#include "AliAODTrack.h"
36#include "AliAODEvent.h"
37#include "AliMCEvent.h"
38#include "AliLog.h"
39#include "Riostream.h"
40
41ClassImp(AliCaloTrackESDReader)
42
43//____________________________________________________________________________
44AliCaloTrackESDReader::AliCaloTrackESDReader() :
45 AliCaloTrackReader()
46{
47 //Default Ctor
48
49 //Initialize parameters
50 fDataType=kESD;
51
52}
53
54//____________________________________________________________________________
55AliCaloTrackESDReader::AliCaloTrackESDReader(const AliCaloTrackESDReader & g) :
56 AliCaloTrackReader(g)
57{
58 // cpy ctor
59}
60
61//_________________________________________________________________________
62AliCaloTrackESDReader & AliCaloTrackESDReader::operator = (const AliCaloTrackESDReader & source)
63{
64 // assignment operator
65
66 if(&source == this) return *this;
67
68 return *this;
69
70}
71
72//____________________________________________________________________________
73void AliCaloTrackESDReader::FillInputCTS() {
74 //Return array with CTS tracks
75
76 fAODCTS = new TClonesArray("AliAODTrack",0);
77
78 Int_t nTracks = fESD->GetNumberOfTracks() ;
79 Int_t naod = 0;
80 Double_t pos[3];
81 Double_t p[3];
82 Double_t covTr[21];
83 Double_t pid[10];
84 for (Int_t itrack = 0; itrack < nTracks; itrack++) {////////////// track loop
85 AliESDtrack * track = fESD->GetTrack(itrack) ; // retrieve track from esd
86
87 //We want tracks fitted in the detectors:
88 ULong_t status=AliESDtrack::kTPCrefit;
89 status|=AliESDtrack::kITSrefit;
90
91 if ( (track->GetStatus() & status) == status) {//Check if the bits we want are set
92
93 track->GetPxPyPz(p) ;
94 TLorentzVector momentum(p[0],p[1],p[2],0);
95
96 if(fCTSPtMin < momentum.Pt() &&fFidutialCut->IsInFidutialCut(momentum,"CTS")){
97
98 if(fDebug > 3 && momentum.Pt() > 0.2)printf("FillInputCTS():: Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
99 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
100
101 track->GetXYZ(pos);
102 track->GetCovarianceXYZPxPyPz(covTr);
103 track->GetESDpid(pid);
104
105 Float_t impactXY, impactZ;
106
107 track->GetImpactParameters(impactXY,impactZ);
108
109 if (impactXY<3) {
110 // track inside the beam pipe
111
112 AliAODTrack *aodTrack = new((*fAODCTS)[naod++])
113 AliAODTrack(track->GetID(), track->GetLabel(), p, kTRUE, pos, kFALSE,covTr, (Short_t)track->GetSign(), track->GetITSClusterMap(),
114 pid,
115 0x0,//primary,
116 kTRUE, // check if this is right
117 kTRUE, // check if this is right
118 AliAODTrack::kPrimary,
119 0);
120
121 aodTrack->SetFlags(track->GetStatus());
122 aodTrack->ConvertAliPIDtoAODPID();
123 }
124 else continue; // outside the beam pipe: orphan track
125 }//Pt and Fidutial cut passed.
126 }// track status
127 }// track loop
76518957 128 if(fDebug > 1) printf("FillInputCTS():: aod entries %d\n", fAODCTS->GetEntriesFast());
d92b41ad 129}
130
131//____________________________________________________________________________
132void AliCaloTrackESDReader::FillInputEMCAL() {
133 //Return array with EMCAL clusters in aod format
134
135 fAODEMCAL = new TClonesArray("AliAODCaloCluster",0);
136
137 TRefArray * caloClusters = new TRefArray();
138 fESD->GetEMCALClusters(caloClusters);
139
140 //Get vertex for momentum calculation
141 Double_t v[3] ; //vertex ;
142 GetVertex(v);
143
144 //Loop to select clusters in fidutial cut and fill container with aodClusters
145 Int_t naod = 0;
146 Float_t pos[3] ;
147// Double_t * pid = new Double_t[AliPID::kSPECIESN];
148
76518957 149 for (Int_t iclus = 0; iclus < caloClusters->GetEntriesFast(); iclus++) {
d92b41ad 150 AliESDCaloCluster * clus = (AliESDCaloCluster *) caloClusters->At(iclus) ;
151 TLorentzVector momentum ;
152 clus->GetMomentum(momentum, v);
153 if(fDebug > 3 && momentum.E() > 0.1)printf("FillInputEMCAL():: all clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
154 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
155 if(fEMCALPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"EMCAL")){
156
157 if(fDebug > 2 && momentum.E() > 0.1)printf("FillInputEMCAL():: Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
158 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
159// pid=clus->GetPid();
160 clus->GetPosition(pos) ;
161// printf("Reader PID ESD: ph %0.2f, pi0 %0.2f, el %0.2f, conv el %0.2f,pi %0.2f, k %0.2f, p %0.2f, k0 %0.2f, n %0.2f, mu %0.2f \n",
162// pid[AliPID::kPhoton],pid[AliPID::kPi0],
163// pid[AliPID::kElectron],pid[AliPID::kEleCon],pid[AliPID::kPion],
164// pid[AliPID::kKaon],pid[AliPID::kProton], pid[AliPID::kKaon0],
165// pid[AliPID::kNeutron], pid[AliPID::kMuon]);
166 Int_t id = clus->GetID();
167 Int_t nLabel = clus->GetNLabels();
168 Int_t *labels=0x0;
169 if(clus->GetLabels()) labels = (clus->GetLabels())->GetArray();
170
171 Float_t energy = clus->E();
172 Char_t ttype= AliAODCluster::kEMCALClusterv1;
173 AliAODCaloCluster *caloCluster = new((*fAODEMCAL)[naod++])
174 AliAODCaloCluster(id,nLabel,labels,energy, pos, NULL,ttype,0);
175
176 caloCluster->SetPIDFromESD(clus->GetPid());
177 caloCluster->SetCaloCluster(clus->GetDistanceToBadChannel(), clus->GetClusterDisp(),
178 clus->GetM20(), clus->GetM02(),
179 clus->GetEmcCpvDistance(), clus->GetNExMax(), clus->GetTOF()) ;
180 caloCluster->SetNCells(clus->GetNCells());
181 caloCluster->SetCellsAbsId(clus->GetCellsAbsId());
182 caloCluster->SetCellsAmplitudeFraction(clus->GetCellsAmplitudeFraction());
183
184 TArrayI* matchedT = clus->GetTracksMatched();
185 if (matchedT && clus->GetTrackMatched() > 0) {
186 for (Int_t im = 0; im < matchedT->GetSize(); im++) {
187 caloCluster->AddTrackMatched((fESD->GetTrack(im)));
188 }
189 }
190
191 }//Pt and Fidutial cut passed.
192 }//esd cluster loop
193
76518957 194 if(fDebug > 1) printf("FillInputEMCAL():: aod entries %d\n", fAODEMCAL->GetEntriesFast());
d92b41ad 195
196}
197
198//____________________________________________________________________________
199void AliCaloTrackESDReader::FillInputPHOS() {
200 //Return array with PHOS clusters in aod format
201 fAODPHOS = new TClonesArray("AliAODCaloCluster",0);
202
203 TRefArray * caloClusters = new TRefArray();
204 fESD->GetPHOSClusters(caloClusters);
205
206 //Get vertex for momentum calculation
207 Double_t v[3] ; //vertex ;
208 GetVertex(v);
209
210 //Loop to select clusters in fidutial cut and fill container with aodClusters
211 Int_t naod = 0;
212 Float_t pos[3] ;
213 Double_t * pid = new Double_t[AliPID::kSPECIESN];
214
76518957 215 for (Int_t iclus = 0; iclus < caloClusters->GetEntriesFast(); iclus++) {
d92b41ad 216 AliESDCaloCluster * clus = (AliESDCaloCluster *) caloClusters->At(iclus) ;
217 TLorentzVector momentum ;
218 clus->GetMomentum(momentum, v);
219 if(fDebug > 3 && momentum.E() > 0.1)printf("FillInputPHOS():: all clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
220 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
221 if(fPHOSPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"PHOS")){
222
223 if(fDebug > 2 && momentum.E() > 0.1)printf("FillInputPHOS():: Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
224 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
225
226 pid=clus->GetPid();
227 // printf("Reader PID ESD: ph %0.2f, pi0 %0.2f, el %0.2f, conv el %0.2f,pi %0.2f, k %0.2f, p %0.2f, k0 %0.2f, n %0.2f, mu %0.2f \n",
228 // pid[AliPID::kPhoton],pid[AliPID::kPi0],
229 // pid[AliPID::kElectron],pid[AliPID::kEleCon],pid[AliPID::kPion],
230 // pid[AliPID::kKaon],pid[AliPID::kProton], pid[AliPID::kKaon0],
231 // pid[AliPID::kNeutron], pid[AliPID::kMuon]);
232
233 clus->GetPosition(pos) ;
234 Int_t id = clus->GetID();
235 Int_t nLabel = clus->GetNLabels();
236 Int_t *labels=0x0;
237 if(clus->GetLabels()) labels = (clus->GetLabels())->GetArray();
238 Float_t energy = clus->E();
239
240 //Phos cluster type
241 Char_t ttype= AliAODCluster::kPHOSNeutral;
242 Float_t wNeutral = pid[AliPID::kNeutron]+ pid[AliPID::kKaon0]+pid[AliPID::kPhoton]+pid[AliPID::kPi0];
243 Float_t wCharged = pid[AliPID::kMuon] + pid[AliPID::kElectron] + pid[AliPID::kEleCon]+
244 pid[AliPID::kProton]+pid[AliPID::kKaon]+pid[AliPID::kPion];
245 if( wCharged > wNeutral) ttype= AliAODCluster::kPHOSCharged;
246
247 AliAODCaloCluster *caloCluster = new((*fAODPHOS)[naod++])
248 AliAODCaloCluster(id,nLabel,labels,energy, pos, NULL, ttype, 0);
249 caloCluster->SetPIDFromESD(clus->GetPid());
250 caloCluster->SetCaloCluster(clus->GetDistanceToBadChannel(), clus->GetClusterDisp(),
251 clus->GetM20(), clus->GetM02(),
252 clus->GetEmcCpvDistance(), clus->GetNExMax()) ;
253 caloCluster->SetNCells(clus->GetNCells());
254 caloCluster->SetCellsAbsId(clus->GetCellsAbsId());
255 caloCluster->SetCellsAmplitudeFraction(clus->GetCellsAmplitudeFraction());
256 TArrayI* matchedT = clus->GetTracksMatched();
257 if (matchedT) {
258 for (Int_t im = 0; im < matchedT->GetSize(); im++) {
259 caloCluster->AddTrackMatched((fESD->GetTrack(im)));
260 }
261 }
262
263 }//Pt and Fidutial cut passed.
264 }//esd cluster loop
76518957 265 if(fDebug > 1) printf("FillInputPHOS():: aod entries %d\n", fAODPHOS->GetEntriesFast());
d92b41ad 266
267
268}
269
270//____________________________________________________________________________
271void AliCaloTrackESDReader::FillInputEMCALCells() {
272 //Return array with EMCAL cells in esd format
273
274 fEMCALCells = (TNamed*) fESD->GetEMCALCells();
275
276}
277
278//____________________________________________________________________________
279void AliCaloTrackESDReader::FillInputPHOSCells() {
280 //Return array with PHOS cells in esd format
281
282 fPHOSCells = (TNamed*) fESD->GetPHOSCells();
283
284}
285
286//____________________________________________________________________________
287void AliCaloTrackESDReader::GetVertex(Double_t v[3]) {
288 //Return vertex position
289
290 fESD->GetVertex()->GetXYZ(v) ;
291
292}
293
294
295//____________________________________________________________________________
296void AliCaloTrackESDReader::SetInputEvent(TObject* esd, TObject* aod, TObject* mc) {
297 // Connect the data pointers
933d8b1e 298
299 if(strcmp(esd->GetName(),"AliESDEvent"))
300 AliFatal(Form("Wrong reader, here only ESDs. Input name: %s != AliESDEvent \n",esd->GetName()));
301
d92b41ad 302 SetESD((AliESDEvent*) esd);
303 SetAOD ((AliAODEvent*) aod);
304 SetMC((AliMCEvent*) mc);
933d8b1e 305
d92b41ad 306}