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 ---
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"
39 #include "Riostream.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->GetEntries());
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->GetEntries(); 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.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();
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()) ;
180 caloCluster->SetNCells(clus->GetNCells());
181 caloCluster->SetCellsAbsId(clus->GetCellsAbsId());
182 caloCluster->SetCellsAmplitudeFraction(clus->GetCellsAmplitudeFraction());
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)));
191 }//Pt and Fidutial cut passed.
194 if(fDebug > 1) printf("FillInputEMCAL():: aod entries %d\n", fAODEMCAL->GetEntries());
198 //____________________________________________________________________________
199 void AliCaloTrackESDReader::FillInputPHOS() {
200 //Return array with PHOS clusters in aod format
201 fAODPHOS = new TClonesArray("AliAODCaloCluster",0);
203 TRefArray * caloClusters = new TRefArray();
204 fESD->GetPHOSClusters(caloClusters);
206 //Get vertex for momentum calculation
207 Double_t v[3] ; //vertex ;
210 //Loop to select clusters in fidutial cut and fill container with aodClusters
213 Double_t * pid = new Double_t[AliPID::kSPECIESN];
215 for (Int_t iclus = 0; iclus < caloClusters->GetEntries(); iclus++) {
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")){
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());
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]);
233 clus->GetPosition(pos) ;
234 Int_t id = clus->GetID();
235 Int_t nLabel = clus->GetNLabels();
237 if(clus->GetLabels()) labels = (clus->GetLabels())->GetArray();
238 Float_t energy = clus->E();
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;
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();
258 for (Int_t im = 0; im < matchedT->GetSize(); im++) {
259 caloCluster->AddTrackMatched((fESD->GetTrack(im)));
263 }//Pt and Fidutial cut passed.
265 if(fDebug > 1) printf("FillInputPHOS():: aod entries %d\n", fAODPHOS->GetEntries());
270 //____________________________________________________________________________
271 void AliCaloTrackESDReader::FillInputEMCALCells() {
272 //Return array with EMCAL cells in esd format
274 fEMCALCells = (TNamed*) fESD->GetEMCALCells();
278 //____________________________________________________________________________
279 void AliCaloTrackESDReader::FillInputPHOSCells() {
280 //Return array with PHOS cells in esd format
282 fPHOSCells = (TNamed*) fESD->GetPHOSCells();
286 //____________________________________________________________________________
287 void AliCaloTrackESDReader::GetVertex(Double_t v[3]) {
288 //Return vertex position
290 fESD->GetVertex()->GetXYZ(v) ;
295 //____________________________________________________________________________
296 void AliCaloTrackESDReader::SetInputEvent(TObject* esd, TObject* aod, TObject* mc) {
297 // Connect the data pointers
299 if(strcmp(esd->GetName(),"AliESDEvent"))
300 AliFatal(Form("Wrong reader, here only ESDs. Input name: %s != AliESDEvent \n",esd->GetName()));
302 SetESD((AliESDEvent*) esd);
303 SetAOD ((AliAODEvent*) aod);
304 SetMC((AliMCEvent*) mc);