Protection to skip PYTHIA events with large jet energy compared to pTHard
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / AliCaloTrackESDReader.cxx
CommitLineData
1c5acb87 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
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//#include "Riostream.h"
29
30//---- ANALYSIS system ----
31#include "AliCaloTrackESDReader.h"
32#include "AliESDEvent.h"
1c5acb87 33#include "AliESDCaloCluster.h"
34#include "AliAODCaloCluster.h"
35#include "AliAODTrack.h"
36#include "AliAODEvent.h"
477d6cee 37#include "AliFidutialCut.h"
1c5acb87 38
39ClassImp(AliCaloTrackESDReader)
40
41//____________________________________________________________________________
42AliCaloTrackESDReader::AliCaloTrackESDReader() :
43AliCaloTrackReader()
44{
45 //Default Ctor
46
47 //Initialize parameters
48 fDataType=kESD;
49
50}
51
52//____________________________________________________________________________
53AliCaloTrackESDReader::AliCaloTrackESDReader(const AliCaloTrackESDReader & g) :
477d6cee 54 AliCaloTrackReader(g)
1c5acb87 55{
477d6cee 56 // cpy ctor
1c5acb87 57}
58
59//_________________________________________________________________________
60//AliCaloTrackESDReader & AliCaloTrackESDReader::operator = (const AliCaloTrackESDReader & source)
61//{
62// // assignment operator
63//
64// if(&source == this) return *this;
65//
66// return *this;
67//
68//}
69
70//____________________________________________________________________________
71void AliCaloTrackESDReader::FillInputCTS() {
477d6cee 72 //Return array with CTS tracks
73 //TRefArray * fAODCTS = new TRefArray();
74 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
75 Int_t naod = 0;
76 Double_t pos[3];
77 Double_t p[3];
78 Double_t covTr[21];
79 Double_t pid[10];
80 for (Int_t itrack = 0; itrack < nTracks; itrack++) {////////////// track loop
81 AliESDtrack * track = (AliESDtrack*) ((AliESDEvent*)fInputEvent)->GetTrack(itrack) ; // retrieve track from esd
82
83 //We want tracks fitted in the detectors:
84 ULong_t status=AliESDtrack::kTPCrefit;
85 status|=AliESDtrack::kITSrefit;
86
87 if ( (track->GetStatus() & status) == status) {//Check if the bits we want are set
88
89 track->GetPxPyPz(p) ;
90 TLorentzVector momentum(p[0],p[1],p[2],0);
91
92 if(fCTSPtMin < momentum.Pt() &&fFidutialCut->IsInFidutialCut(momentum,"CTS")){
1c5acb87 93
a3aebfff 94 if(fDebug > 3 && momentum.Pt() > 0.2) printf("AliCaloTrackESDReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
477d6cee 95 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1c5acb87 96
477d6cee 97 track->GetXYZ(pos);
98 track->GetCovarianceXYZPxPyPz(covTr);
99 track->GetESDpid(pid);
100
101 Float_t impactXY, impactZ;
102
103 track->GetImpactParameters(impactXY,impactZ);
104
105 if (impactXY<3) {
106 // track inside the beam pipe
107 //Put new aod object in file in AOD tracks array
108 AliAODTrack *aodTrack = new((*(fOutputEvent->GetTracks()))[naod++])
109 AliAODTrack(track->GetID(), track->GetLabel(), p, kTRUE, pos, kFALSE,covTr, (Short_t)track->GetSign(), track->GetITSClusterMap(),
110 pid,
111 0x0,//primary,
112 kTRUE, // check if this is right
113 kTRUE, // check if this is right
114 AliAODTrack::kPrimary,
115 0);
116
117 aodTrack->SetFlags(track->GetStatus());
118 aodTrack->ConvertAliPIDtoAODPID();
119
120 fAODCTS->Add(aodTrack); }
121 else continue; // outside the beam pipe: orphan track
122 }//Pt and Fidutial cut passed.
123 }// track status
124 }// track loop
125
126 //Put references to selected tracks in array
127 for(Int_t itrack = 0; itrack < (fOutputEvent->GetTracks())->GetEntriesFast(); itrack++){
128 AliAODTrack * track = (AliAODTrack*) (fOutputEvent->GetTracks())->At(itrack);
129 fAODCTS->Add(track);
130 }
131
a3aebfff 132 if(fDebug > 1) printf("AliCaloTrackESDReader::FillInputCTS() - aod entries %d\n", fAODCTS->GetEntriesFast());
1c5acb87 133}
134
135//____________________________________________________________________________
136void AliCaloTrackESDReader::FillInputEMCAL() {
477d6cee 137 //Return array with EMCAL clusters in aod format
138
139 //Get vertex for momentum calculation
140 Double_t v[3] ; //vertex ;
141 GetVertex(v);
142
477d6cee 143 Float_t pos[3] ;
a3aebfff 144 Int_t naod = (fOutputEvent->GetCaloClusters())->GetEntriesFast();
145 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
146
147 //Loop to select clusters in fidutial cut and fill container with aodClusters
477d6cee 148 for (Int_t iclus = 0; iclus < ((AliESDEvent*)fInputEvent)->GetNumberOfCaloClusters(); iclus++) {
149 AliESDCaloCluster * clus = 0;
150 if ( (clus = ((AliESDEvent*)fInputEvent)->GetCaloCluster(iclus)) ) {
151 if (clus->IsEMCAL()){
152 TLorentzVector momentum ;
153 clus->GetMomentum(momentum, v);
a3aebfff 154 if(fDebug > 3 && momentum.E() > 0.2) printf("AliCaloTrackESDReader::FillInputEMCAL() - all clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
477d6cee 155 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
156 if(fEMCALPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"EMCAL")){
157
a3aebfff 158 if(fDebug > 2 && momentum.E() > 0.2) printf("AliCaloTrackESDReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
477d6cee 159 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
a3aebfff 160
477d6cee 161 clus->GetPosition(pos) ;
477d6cee 162 Int_t id = clus->GetID();
163 Int_t nLabel = clus->GetNLabels();
164 Int_t *labels=0x0;
165 if(clus->GetLabels()) labels = (clus->GetLabels())->GetArray();
166
167 Float_t energy = clus->E();
168 Char_t ttype= AliAODCluster::kEMCALClusterv1;
169
170 //Put new aod object in file in AOD calo clusters array
171 AliAODCaloCluster *caloCluster = new((*(fOutputEvent->GetCaloClusters()))[naod++])
172 AliAODCaloCluster(id,nLabel,labels,energy, pos, NULL,ttype,0);
173
a3aebfff 174 // 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",
175 // pid[AliPID::kPhoton],pid[AliPID::kPi0],pid[AliPID::kElectron],pid[AliPID::kEleCon],pid[AliPID::kPion],
176 // pid[AliPID::kKaon],pid[AliPID::kProton], pid[AliPID::kKaon0],pid[AliPID::kNeutron], pid[AliPID::kMuon]);
477d6cee 177 caloCluster->SetPIDFromESD(clus->GetPid());
178 caloCluster->SetCaloCluster(clus->GetDistanceToBadChannel(), clus->GetClusterDisp(),
179 clus->GetM20(), clus->GetM02(),
180 clus->GetEmcCpvDistance(), clus->GetNExMax(), clus->GetTOF()) ;
181
182
183 if(fDebug > 3 && momentum.E() > 0.2)
a3aebfff 184 printf("AliCaloTrackESDReader::FillInputEMCAL() - Selected clusters Distance BC %2.2f, dispersion %2.2f, M20 %f, M02 %3.2f, NexMax %d, TOF %e\n",
477d6cee 185 clus->GetDistanceToBadChannel(), clus->GetClusterDisp(),clus->GetM20(), clus->GetM02(),
186 clus->GetNExMax(), clus->GetTOF());
187
188 caloCluster->SetNCells(clus->GetNCells());
189 caloCluster->SetCellsAbsId(clus->GetCellsAbsId());
190 caloCluster->SetCellsAmplitudeFraction(clus->GetCellsAmplitudeFraction());
191
192 TArrayI* matchedT = clus->GetTracksMatched();
a3aebfff 193 if (nTracks > 0 && matchedT && clus->GetTrackMatched() >= 0) {
477d6cee 194 for (Int_t im = 0; im < matchedT->GetSize(); im++) {
a3aebfff 195 Int_t iESDtrack = matchedT->At(im);
196 if(iESDtrack < nTracks && iESDtrack > -1)
197 caloCluster->AddTrackMatched((fInputEvent->GetTrack(iESDtrack)));
477d6cee 198 }
199 }
200 //Fill reference array
201 }//Pt and Fidutial cut passed.
202 }//EMCAL cluster
203 }//cluster exists
204 }//esd cluster loop
205
206 //Put references to selected clusters in array
207 for(Int_t iclus = 0; iclus < (fOutputEvent->GetCaloClusters())->GetEntriesFast(); iclus++){
208 AliAODCaloCluster * clus = (AliAODCaloCluster*) (fOutputEvent->GetCaloClusters())->At(iclus);
209 fAODEMCAL->Add(clus);
210 }
a3aebfff 211 if(fDebug > 1) printf("AliCaloTrackESDReader::FillInputEMCAL() - aod entries %d\n", fAODEMCAL->GetEntriesFast());
477d6cee 212
1c5acb87 213}
214
215//____________________________________________________________________________
216void AliCaloTrackESDReader::FillInputPHOS() {
477d6cee 217 //Return array with PHOS clusters in aod format
8896b363 218 Int_t nEMCAL = (fOutputEvent->GetCaloClusters())->GetEntriesFast();
477d6cee 219 //Get vertex for momentum calculation
220 Double_t v[3] ; //vertex ;
221 GetVertex(v);
222
477d6cee 223 Float_t pos[3] ;
224 Double_t * pid = new Double_t[AliPID::kSPECIESN];
a3aebfff 225 Int_t naod = (fOutputEvent->GetCaloClusters())->GetEntriesFast();
226 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
227
228 //Loop to select clusters in fidutial cut and fill container with aodClusters
477d6cee 229 for (Int_t iclus = 0; iclus < ((AliESDEvent*)fInputEvent)->GetNumberOfCaloClusters(); iclus++) {
230 AliESDCaloCluster * clus = 0;
231 if ( (clus = ((AliESDEvent*)fInputEvent)->GetCaloCluster(iclus)) ) {
232 if (clus->IsPHOS()){
233 TLorentzVector momentum ;
234 clus->GetMomentum(momentum, v);
a3aebfff 235 if(fDebug > 3 && momentum.E() > 0.1)printf("AliCaloTrackESDReader::FillInputPHOS() - all clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
477d6cee 236 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
237 if(fPHOSPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"PHOS")){
238
a3aebfff 239 if(fDebug > 2 && momentum.E() > 0.1)printf("AliCaloTrackESDReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
477d6cee 240 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
241
477d6cee 242 clus->GetPosition(pos) ;
243 Int_t id = clus->GetID();
244 Int_t nLabel = clus->GetNLabels();
245 Int_t *labels=0x0;
246 if(clus->GetLabels()) labels = (clus->GetLabels())->GetArray();
247 Float_t energy = clus->E();
248
249 //Phos cluster type
a3aebfff 250 pid = clus->GetPid();
251 // 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",
252 // pid[AliPID::kPhoton],pid[AliPID::kPi0],pid[AliPID::kElectron],pid[AliPID::kEleCon],pid[AliPID::kPion],
253 // pid[AliPID::kKaon],pid[AliPID::kProton], pid[AliPID::kKaon0],pid[AliPID::kNeutron], pid[AliPID::kMuon]);
477d6cee 254 Char_t ttype= AliAODCluster::kPHOSNeutral;
255 Float_t wNeutral = pid[AliPID::kNeutron]+ pid[AliPID::kKaon0]+pid[AliPID::kPhoton]+pid[AliPID::kPi0];
256 Float_t wCharged = pid[AliPID::kMuon] + pid[AliPID::kElectron] + pid[AliPID::kEleCon]+
257 pid[AliPID::kProton]+pid[AliPID::kKaon]+pid[AliPID::kPion];
258 if( wCharged > wNeutral) ttype= AliAODCluster::kPHOSCharged;
259
260 //Put new aod object in file in AOD calo clusters array
261 AliAODCaloCluster *caloCluster = new((*(fOutputEvent->GetCaloClusters()))[naod++])
262 AliAODCaloCluster(id,nLabel,labels,energy, pos, NULL, ttype, 0);
a3aebfff 263
264
265 caloCluster->SetPIDFromESD(pid);
477d6cee 266 caloCluster->SetCaloCluster(clus->GetDistanceToBadChannel(), clus->GetClusterDisp(),
267 clus->GetM20(), clus->GetM02(),
268 clus->GetEmcCpvDistance(), clus->GetNExMax()) ;
269
270 if(fDebug > 3 && momentum.E() > 0.2)
a3aebfff 271 printf("AliCaloTrackESDReader::FillInputPHOS() - Selected clusters Distance BC %2.2f, dispersion %2.2f, M20 %f, M02 %3.2f, EmcCpvDist %3.3f, NexMax %d, TOF %e\n",
477d6cee 272 clus->GetDistanceToBadChannel(), clus->GetClusterDisp(),clus->GetM20(), clus->GetM02(),
273 clus->GetEmcCpvDistance(), clus->GetNExMax(), clus->GetTOF());
274
275 caloCluster->SetNCells(clus->GetNCells());
276 caloCluster->SetCellsAbsId(clus->GetCellsAbsId());
277 caloCluster->SetCellsAmplitudeFraction(clus->GetCellsAmplitudeFraction());
a3aebfff 278
477d6cee 279 TArrayI* matchedT = clus->GetTracksMatched();
a3aebfff 280 if (nTracks > 0 && matchedT && clus->GetTrackMatched() >= 0) {
477d6cee 281 for (Int_t im = 0; im < matchedT->GetSize(); im++) {
a3aebfff 282 Int_t iESDtrack = matchedT->At(im);
283 if(iESDtrack < nTracks && iESDtrack > -1)
284 caloCluster->AddTrackMatched((fInputEvent->GetTrack(iESDtrack)));
477d6cee 285 }
286 }
287 }//Pt and Fidutial cut passed.
288 }//PHOS cluster
289 }//cluster exists
290 }//esd cluster loop
291
292 //Put references to selected clusters in array
8896b363 293 for(Int_t iclus = nEMCAL; iclus < (fOutputEvent->GetCaloClusters())->GetEntriesFast(); iclus++){
477d6cee 294 AliAODCaloCluster * clus = (AliAODCaloCluster*) (fOutputEvent->GetCaloClusters())->At(iclus);
295 fAODPHOS->Add(clus);
296 }
dde5a268 297 if(fDebug > 1) printf("AliCaloTrackESDReader::FillInputPHOS() - aod entries %d\n", fAODPHOS->GetEntriesFast());
477d6cee 298
1c5acb87 299}
300
301//____________________________________________________________________________
302void AliCaloTrackESDReader::FillInputEMCALCells() {
477d6cee 303 //Return array with EMCAL cells in esd format
304
305 fEMCALCells = (TNamed*) ((AliESDEvent*)fInputEvent)->GetEMCALCells();
306
1c5acb87 307}
308
309//____________________________________________________________________________
310void AliCaloTrackESDReader::FillInputPHOSCells() {
477d6cee 311 //Return array with PHOS cells in esd format
312
313 fPHOSCells = (TNamed*) ((AliESDEvent*)fInputEvent)->GetPHOSCells();
314
1c5acb87 315}
316
317//____________________________________________________________________________
318void AliCaloTrackESDReader::GetVertex(Double_t v[3]) const {
477d6cee 319 //Return vertex position
320
321 ((AliESDEvent*)fInputEvent)->GetVertex()->GetXYZ(v) ;
322
1c5acb87 323}
324
325
326//____________________________________________________________________________
477d6cee 327void AliCaloTrackESDReader::SetInputOutputMCEvent(AliVEvent* esd, AliAODEvent* aod, AliMCEvent* mc) {
328 // Connect the data pointers
329
330 if(strcmp(esd->GetName(),"AliESDEvent")){
a3aebfff 331 printf("AliCaloTrackESDReader::SetInputOutputMCEvent() - ABORT::Wrong reader, here only ESDs. Input name: %s != AliESDEvent \n",esd->GetName());
477d6cee 332 abort();
333 }
334
335 SetInputEvent(esd);
336 SetOutputEvent(aod);
337 SetMC(mc);
338
1c5acb87 339}