2 /**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //_________________________________________________________________________
19 // Class for reading data (ESDs) in order to do prompt gamma
20 // or other particle identification and correlations
23 //*-- Author: Gustavo Conesa (LNF-INFN)
24 //////////////////////////////////////////////////////////////////////////////
27 // --- ROOT system ---
28 //#include "Riostream.h"
30 //---- ANALYSIS system ----
31 #include "AliCaloTrackESDReader.h"
32 #include "AliESDEvent.h"
33 #include "AliESDVertex.h"
34 #include "AliESDCaloCluster.h"
35 #include "AliAODCaloCluster.h"
36 #include "AliAODTrack.h"
37 #include "AliAODEvent.h"
38 #include "AliMCEvent.h"
41 ClassImp(AliCaloTrackESDReader)
43 //____________________________________________________________________________
44 AliCaloTrackESDReader::AliCaloTrackESDReader() :
49 //Initialize parameters
54 //____________________________________________________________________________
55 AliCaloTrackESDReader::AliCaloTrackESDReader(const AliCaloTrackESDReader & g) :
61 //_________________________________________________________________________
62 //AliCaloTrackESDReader & AliCaloTrackESDReader::operator = (const AliCaloTrackESDReader & source)
64 // // assignment operator
66 // if(&source == this) return *this;
72 //____________________________________________________________________________
73 void AliCaloTrackESDReader::FillInputCTS() {
74 //Return array with CTS tracks
76 fAODCTS = new TClonesArray("AliAODTrack",0);
78 Int_t nTracks = fESD->GetNumberOfTracks() ;
84 for (Int_t itrack = 0; itrack < nTracks; itrack++) {////////////// track loop
85 AliESDtrack * track = fESD->GetTrack(itrack) ; // retrieve track from esd
87 //We want tracks fitted in the detectors:
88 ULong_t status=AliESDtrack::kTPCrefit;
89 status|=AliESDtrack::kITSrefit;
91 if ( (track->GetStatus() & status) == status) {//Check if the bits we want are set
94 TLorentzVector momentum(p[0],p[1],p[2],0);
96 if(fCTSPtMin < momentum.Pt() &&fFidutialCut->IsInFidutialCut(momentum,"CTS")){
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());
102 track->GetCovarianceXYZPxPyPz(covTr);
103 track->GetESDpid(pid);
105 Float_t impactXY, impactZ;
107 track->GetImpactParameters(impactXY,impactZ);
110 // track inside the beam pipe
112 AliAODTrack *aodTrack = new((*fAODCTS)[naod++])
113 AliAODTrack(track->GetID(), track->GetLabel(), p, kTRUE, pos, kFALSE,covTr, (Short_t)track->GetSign(), track->GetITSClusterMap(),
116 kTRUE, // check if this is right
117 kTRUE, // check if this is right
118 AliAODTrack::kPrimary,
121 aodTrack->SetFlags(track->GetStatus());
122 aodTrack->ConvertAliPIDtoAODPID();
124 else continue; // outside the beam pipe: orphan track
125 }//Pt and Fidutial cut passed.
128 if(fDebug > 1) printf("FillInputCTS():: aod entries %d\n", fAODCTS->GetEntriesFast());
131 //____________________________________________________________________________
132 void AliCaloTrackESDReader::FillInputEMCAL() {
133 //Return array with EMCAL clusters in aod format
135 fAODEMCAL = new TClonesArray("AliAODCaloCluster",0);
137 TRefArray * caloClusters = new TRefArray();
138 fESD->GetEMCALClusters(caloClusters);
140 //Get vertex for momentum calculation
141 Double_t v[3] ; //vertex ;
144 //Loop to select clusters in fidutial cut and fill container with aodClusters
147 // Double_t * pid = new Double_t[AliPID::kSPECIESN];
149 for (Int_t iclus = 0; iclus < caloClusters->GetEntriesFast(); iclus++) {
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")){
157 if(fDebug > 2 && momentum.E() > 0.2)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();
169 if(clus->GetLabels()) labels = (clus->GetLabels())->GetArray();
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);
176 caloCluster->SetPIDFromESD(clus->GetPid());
177 caloCluster->SetCaloCluster(clus->GetDistanceToBadChannel(), clus->GetClusterDisp(),
178 clus->GetM20(), clus->GetM02(),
179 clus->GetEmcCpvDistance(), clus->GetNExMax(), clus->GetTOF()) ;
182 if(fDebug > 3 && momentum.E() > 0.2)
183 printf("FillInputEMCAL():: Selected clusters Distance BC %2.2f, dispersion %2.2f, M20 %f, M02 %3.2f, NexMax %d, TOF %e\n",
184 clus->GetDistanceToBadChannel(), clus->GetClusterDisp(),clus->GetM20(), clus->GetM02(),
185 clus->GetNExMax(), clus->GetTOF());
187 caloCluster->SetNCells(clus->GetNCells());
188 caloCluster->SetCellsAbsId(clus->GetCellsAbsId());
189 caloCluster->SetCellsAmplitudeFraction(clus->GetCellsAmplitudeFraction());
191 TArrayI* matchedT = clus->GetTracksMatched();
192 if (matchedT && clus->GetTrackMatched() > 0) {
193 for (Int_t im = 0; im < matchedT->GetSize(); im++) {
194 caloCluster->AddTrackMatched((fESD->GetTrack(im)));
198 }//Pt and Fidutial cut passed.
201 if(fDebug > 1) printf("FillInputEMCAL():: aod entries %d\n", fAODEMCAL->GetEntriesFast());
205 //____________________________________________________________________________
206 void AliCaloTrackESDReader::FillInputPHOS() {
207 //Return array with PHOS clusters in aod format
208 fAODPHOS = new TClonesArray("AliAODCaloCluster",0);
210 TRefArray * caloClusters = new TRefArray();
211 fESD->GetPHOSClusters(caloClusters);
213 //Get vertex for momentum calculation
214 Double_t v[3] ; //vertex ;
217 //Loop to select clusters in fidutial cut and fill container with aodClusters
220 Double_t * pid = new Double_t[AliPID::kSPECIESN];
222 for (Int_t iclus = 0; iclus < caloClusters->GetEntriesFast(); iclus++) {
223 AliESDCaloCluster * clus = (AliESDCaloCluster *) caloClusters->At(iclus) ;
224 TLorentzVector momentum ;
225 clus->GetMomentum(momentum, v);
226 if(fDebug > 3 && momentum.E() > 0.1)printf("FillInputPHOS():: all clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
227 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
228 if(fPHOSPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"PHOS")){
230 if(fDebug > 2 && momentum.E() > 0.1)printf("FillInputPHOS():: Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
231 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
234 // 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",
235 // pid[AliPID::kPhoton],pid[AliPID::kPi0],
236 // pid[AliPID::kElectron],pid[AliPID::kEleCon],pid[AliPID::kPion],
237 // pid[AliPID::kKaon],pid[AliPID::kProton], pid[AliPID::kKaon0],
238 // pid[AliPID::kNeutron], pid[AliPID::kMuon]);
240 clus->GetPosition(pos) ;
241 Int_t id = clus->GetID();
242 Int_t nLabel = clus->GetNLabels();
244 if(clus->GetLabels()) labels = (clus->GetLabels())->GetArray();
245 Float_t energy = clus->E();
248 Char_t ttype= AliAODCluster::kPHOSNeutral;
249 Float_t wNeutral = pid[AliPID::kNeutron]+ pid[AliPID::kKaon0]+pid[AliPID::kPhoton]+pid[AliPID::kPi0];
250 Float_t wCharged = pid[AliPID::kMuon] + pid[AliPID::kElectron] + pid[AliPID::kEleCon]+
251 pid[AliPID::kProton]+pid[AliPID::kKaon]+pid[AliPID::kPion];
252 if( wCharged > wNeutral) ttype= AliAODCluster::kPHOSCharged;
254 AliAODCaloCluster *caloCluster = new((*fAODPHOS)[naod++])
255 AliAODCaloCluster(id,nLabel,labels,energy, pos, NULL, ttype, 0);
256 caloCluster->SetPIDFromESD(clus->GetPid());
257 caloCluster->SetCaloCluster(clus->GetDistanceToBadChannel(), clus->GetClusterDisp(),
258 clus->GetM20(), clus->GetM02(),
259 clus->GetEmcCpvDistance(), clus->GetNExMax()) ;
261 if(fDebug > 3 && momentum.E() > 0.2)
262 printf("FillInputPHOS():: Selected clusters Distance BC %2.2f, dispersion %2.2f, M20 %f, M02 %3.2f, EmcCpvDist %3.3f, NexMax %d, TOF %e\n",
263 clus->GetDistanceToBadChannel(), clus->GetClusterDisp(),clus->GetM20(), clus->GetM02(),
264 clus->GetEmcCpvDistance(), clus->GetNExMax(), clus->GetTOF());
266 caloCluster->SetNCells(clus->GetNCells());
267 caloCluster->SetCellsAbsId(clus->GetCellsAbsId());
268 caloCluster->SetCellsAmplitudeFraction(clus->GetCellsAmplitudeFraction());
269 TArrayI* matchedT = clus->GetTracksMatched();
271 for (Int_t im = 0; im < matchedT->GetSize(); im++) {
272 caloCluster->AddTrackMatched((fESD->GetTrack(im)));
276 }//Pt and Fidutial cut passed.
278 if(fDebug > 1) printf("FillInputPHOS():: aod entries %d\n", fAODPHOS->GetEntriesFast());
283 //____________________________________________________________________________
284 void AliCaloTrackESDReader::FillInputEMCALCells() {
285 //Return array with EMCAL cells in esd format
287 fEMCALCells = (TNamed*) fESD->GetEMCALCells();
291 //____________________________________________________________________________
292 void AliCaloTrackESDReader::FillInputPHOSCells() {
293 //Return array with PHOS cells in esd format
295 fPHOSCells = (TNamed*) fESD->GetPHOSCells();
299 //____________________________________________________________________________
300 void AliCaloTrackESDReader::GetVertex(Double_t v[3]) const {
301 //Return vertex position
303 fESD->GetVertex()->GetXYZ(v) ;
308 //____________________________________________________________________________
309 void AliCaloTrackESDReader::SetInputEvent(TObject* esd, TObject* aod, TObject* mc) {
310 // Connect the data pointers
312 if(strcmp(esd->GetName(),"AliESDEvent"))
313 AliFatal(Form("Wrong reader, here only ESDs. Input name: %s != AliESDEvent \n",esd->GetName()));
315 SetESD((AliESDEvent*) esd);
316 SetAOD ((AliAODEvent*) aod);
317 SetMC((AliMCEvent*) mc);