]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/PartCorrBase/AliCaloTrackAODReader.cxx
Added access to magnetic field value in readers. Corrected bugs in AliMCAnalysisUtils...
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / AliCaloTrackAODReader.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 (AODs) in order to do prompt gamma
591cc579 20// or other particle identification and correlations.
21// Mixing analysis can be done, input AOD with events
22// is opened in the AliCaloTrackReader::Init()
1c5acb87 23//
24//
25//*-- Author: Gustavo Conesa (LNF-INFN)
26//////////////////////////////////////////////////////////////////////////////
27
28
29// --- ROOT system ---
30//#include "Riostream.h"
31
32//---- ANALYSIS system ----
33#include "AliCaloTrackAODReader.h"
34#include "AliAODEvent.h"
1c5acb87 35#include "AliAODCaloCluster.h"
36#include "AliAODTrack.h"
591cc579 37#include "AliESDtrack.h"
477d6cee 38#include "AliFidutialCut.h"
1c5acb87 39
40ClassImp(AliCaloTrackAODReader)
41
42//____________________________________________________________________________
43AliCaloTrackAODReader::AliCaloTrackAODReader() :
44 AliCaloTrackReader()
45{
46 //Default Ctor
47
48 //Initialize parameters
49 fDataType=kAOD;
591cc579 50 fReadStack = kTRUE;
51 fReadAODMCParticles = kFALSE;
52 //We want tracks fitted in the detectors:
53 fTrackStatus=AliESDtrack::kTPCrefit;
54 fTrackStatus|=AliESDtrack::kITSrefit;
55
1c5acb87 56}
57
58//____________________________________________________________________________
59AliCaloTrackAODReader::AliCaloTrackAODReader(const AliCaloTrackAODReader & g) :
60 AliCaloTrackReader(g)
61{
62 // cpy ctor
63}
64
65//_________________________________________________________________________
66//AliCaloTrackAODReader & AliCaloTrackAODReader::operator = (const AliCaloTrackAODReader & source)
67//{
68// // assignment operator
69//
70// if(&source == this) return *this;
71//
72// return *this;
73//
74//}
75
76//____________________________________________________________________________
77void AliCaloTrackAODReader::FillInputCTS() {
591cc579 78 //Return array with Central Tracking System (CTS) tracks
1c5acb87 79
477d6cee 80 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
1c5acb87 81 Double_t p[3];
1c5acb87 82 for (Int_t itrack = 0; itrack < nTracks; itrack++) {////////////// track loop
477d6cee 83 AliAODTrack * track = ((AliAODEvent*)fInputEvent)->GetTrack(itrack) ; // retrieve track from esd
591cc579 84
85 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
86 if (fTrackStatus && !((track->GetStatus() & fTrackStatus) == fTrackStatus)) continue ;
1c5acb87 87
88 track->GetPxPyPz(p) ;
89 TLorentzVector momentum(p[0],p[1],p[2],0);
90
91 if(fCTSPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"CTS")){
92
a3aebfff 93 if(fDebug > 2 && momentum.Pt() > 0.1) printf("AliCaloTrackAODReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1c5acb87 94 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
591cc579 95
477d6cee 96 fAODCTS->Add(track);
1c5acb87 97 }//Pt and Fidutial cut passed.
1c5acb87 98 }// track loop
591cc579 99
100 fAODCTSNormalInputEntries = fAODCTS->GetEntriesFast();
101 if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputCTS() - aod entries %d\n", fAODCTSNormalInputEntries);
102
103 //If second input event available, add the clusters.
104 if(fSecondInputAODTree && fSecondInputAODEvent){
105 nTracks = fSecondInputAODEvent->GetNumberOfTracks() ;
106 if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputCTS() - Add second input tracks, entries %d\n", nTracks) ;
107 for (Int_t itrack = 0; itrack < nTracks; itrack++) {////////////// track loop
108 AliAODTrack * track = ((AliAODEvent*)fSecondInputAODEvent)->GetTrack(itrack) ; // retrieve track from esd
109
110 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
111 if (fTrackStatus && !((track->GetStatus() & fTrackStatus) == fTrackStatus)) continue ;
112
113 track->GetPxPyPz(p) ;
114 TLorentzVector momentum(p[0],p[1],p[2],0);
115
116 if(fCTSPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"CTS")){
117
118 if(fDebug > 2 && momentum.Pt() > 0.1) printf("AliCaloTrackAODReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
119 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
120
121 fAODCTS->Add(track);
122
123 }//Pt and Fidutial cut passed.
124 }// track loop
125
126 if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputCTS() - aod normal entries %d, after second input %d\n", fAODCTSNormalInputEntries, fAODCTS->GetEntriesFast());
127 } //second input loop
128
1c5acb87 129}
130
131//____________________________________________________________________________
132void AliCaloTrackAODReader::FillInputEMCAL() {
133 //Return array with EMCAL clusters in aod format
477d6cee 134
1c5acb87 135 //Get vertex for momentum calculation
136 Double_t v[3] ; //vertex ;
137 GetVertex(v);
477d6cee 138
1c5acb87 139 //Loop to select clusters in fidutial cut and fill container with aodClusters
591cc579 140 Int_t nclusters = ((AliAODEvent*)fInputEvent)->GetNCaloClusters();
141 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
477d6cee 142 AliAODCaloCluster * clus = 0;
143 if ( (clus = ((AliAODEvent*)fInputEvent)->GetCaloCluster(iclus)) ) {
144 if (clus->IsEMCALCluster()){
145 TLorentzVector momentum ;
146 clus->GetMomentum(momentum, v);
147
148 if(fEMCALPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"EMCAL")){
1c5acb87 149
a3aebfff 150 if(fDebug > 2 && momentum.E() > 0.1) printf("AliCaloTrackAODReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
477d6cee 151 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
152
477d6cee 153 fAODEMCAL->Add(clus);
154 }//Pt and Fidutial cut passed.
155 }//EMCAL cluster
156 }// cluster exists
591cc579 157 }// cluster loop
158
159 fAODEMCALNormalInputEntries = fAODEMCAL->GetEntriesFast();
160 if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputEMCAL() - aod entries %d\n", fAODEMCALNormalInputEntries);
161
162 //If second input event available, add the clusters.
163 if(fSecondInputAODTree && fSecondInputAODEvent){
164 nclusters = ((AliAODEvent*)fSecondInputAODEvent)->GetNCaloClusters();
165 if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputEMCAL() - Add second input clusters, entries %d\n", nclusters) ;
166 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
167 AliAODCaloCluster * clus = 0;
168 if ( (clus = ((AliAODEvent*)fSecondInputAODEvent)->GetCaloCluster(iclus)) ) {
169 if (clus->IsEMCALCluster()){
170 TLorentzVector momentum ;
171 clus->GetMomentum(momentum, v);
172
173 if(fEMCALPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"EMCAL")){
174
175 if(fDebug > 2 && momentum.E() > 0.1) printf("AliCaloTrackAODReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
176 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
177 fAODEMCAL->Add(clus);
178 }//Pt and Fidutial cut passed.
179 }//EMCAL cluster
180 }// cluster exists
181 }// cluster loop
182
183 if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputEMCAL() - aod normal entries %d, after second input %d\n", fAODEMCALNormalInputEntries, fAODEMCAL->GetEntriesFast());
1c5acb87 184
591cc579 185 } //second input loop
1c5acb87 186}
187
188//____________________________________________________________________________
189void AliCaloTrackAODReader::FillInputPHOS() {
190 //Return array with PHOS clusters in aod format
477d6cee 191
1c5acb87 192 //Get vertex for momentum calculation
193 Double_t v[3] ; //vertex ;
194 GetVertex(v);
195
196 //Loop to select clusters in fidutial cut and fill container with aodClusters
591cc579 197 Int_t nclusters = ((AliAODEvent*)fInputEvent)->GetNCaloClusters();
198 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
477d6cee 199 AliAODCaloCluster * clus = 0;
200 if ( (clus = ((AliAODEvent*)fInputEvent)->GetCaloCluster(iclus)) ) {
201 if (clus->IsPHOSCluster()){
202 TLorentzVector momentum ;
203 clus->GetMomentum(momentum, v);
204
205 if(fPHOSPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"PHOS")){
206
a3aebfff 207 if(fDebug > 2 && momentum.E() > 0.1) printf("AliCaloTrackAODReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
477d6cee 208 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
591cc579 209
477d6cee 210 fAODPHOS->Add(clus);
211 }//Pt and Fidutial cut passed.
212 }//PHOS cluster
213 }//cluster exists
1c5acb87 214 }//esd cluster loop
591cc579 215
216 fAODPHOSNormalInputEntries = fAODPHOS->GetEntriesFast() ;
217 if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputPHOS() - aod entries %d\n", fAODPHOSNormalInputEntries);
1c5acb87 218
591cc579 219 //If second input event available, add the clusters.
220 if(fSecondInputAODTree && fSecondInputAODEvent){
221 nclusters = ((AliAODEvent*)fSecondInputAODEvent)->GetNCaloClusters();
222 if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputPHOS() - Add second input clusters, entries %d\n", nclusters);
223 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
224 AliAODCaloCluster * clus = 0;
225 if ( (clus = ((AliAODEvent*)fSecondInputAODEvent)->GetCaloCluster(iclus)) ) {
226 if (clus->IsPHOSCluster()){
227 TLorentzVector momentum ;
228 clus->GetMomentum(momentum, v);
229
230 if(fPHOSPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"PHOS")){
231
232 if(fDebug > 2 && momentum.E() > 0.1) printf("AliCaloTrackAODReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
233 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
234 fAODPHOS->Add(clus);
235 }//Pt and Fidutial cut passed.
236 }//PHOS cluster
237 }// cluster exists
238 }// cluster loop
239 if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputPHOS() - aod normal entries %d, after second input %d\n", fAODPHOSNormalInputEntries, fAODPHOS->GetEntriesFast());
240 } //second input loop
1c5acb87 241
242}
243
244//____________________________________________________________________________
245void AliCaloTrackAODReader::FillInputEMCALCells() {
246 //Return array with EMCAL cells in aod format
247
477d6cee 248 fEMCALCells = (TNamed*) ((AliAODEvent*)fInputEvent)->GetEMCALCells();
1c5acb87 249
250}
251
252//____________________________________________________________________________
253void AliCaloTrackAODReader::FillInputPHOSCells() {
254 //Return array with PHOS cells in aod format
255
477d6cee 256 fPHOSCells = (TNamed*) ((AliAODEvent*)fInputEvent)->GetPHOSCells();
1c5acb87 257
258}
259
260//____________________________________________________________________________
261void AliCaloTrackAODReader::GetVertex(Double_t v[3]) const {
262 //Return vertex position
263
477d6cee 264 v[0] = ((AliAODEvent*)fInputEvent)->GetVertex(0)->GetX() ;//CHECK!!!
265 v[1] = ((AliAODEvent*)fInputEvent)->GetVertex(0)->GetY() ;//CHECK!!!
266 v[2] = ((AliAODEvent*)fInputEvent)->GetVertex(0)->GetZ() ;//CHECK!!!
1c5acb87 267}
268
8dacfd76 269//____________________________________________________________________________
270Double_t AliCaloTrackAODReader::GetBField() const {
271 //Return magnetic field
272
273 Double_t bfield = ((AliAODEvent*)fInputEvent)->GetMagneticField();
274
275 return bfield;
276
277}
1c5acb87 278
279//____________________________________________________________________________
477d6cee 280void AliCaloTrackAODReader::SetInputOutputMCEvent(AliVEvent* input, AliAODEvent* aod, AliMCEvent* mc) {
1c5acb87 281 // Connect the data pointers
477d6cee 282 // If input is AOD, do analysis with input, if not, do analysis with the output aod.
283 if(!strcmp(input->GetName(),"AliESDEvent")) {
284 SetInputEvent(aod);
285 SetOutputEvent(aod);
286 }
287 else if(!strcmp(input->GetName(),"AliAODEvent")){
288 SetInputEvent(input);
289 SetOutputEvent(aod);
290 }
291 else{
591cc579 292 printf("AliCaloTrackAODReader::SetInputOutputMCEvent() - STOP : Wrong data format: %s\n",input->GetName());
477d6cee 293 abort();
294 }
295
296 SetMC(mc);
1c5acb87 297
1c5acb87 298}