]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/AliCaloTrackAODReader.cxx
correction of PHOS AOD pointer filled while reading EMCAL data
[u/mrichter/AliRoot.git] / PWG4 / AliCaloTrackAODReader.cxx
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 /* History of cvs commits:
19  *
20  * $Log$
21  *
22  */
23
24 //_________________________________________________________________________
25 // Class for reading data (AODs) in order to do prompt gamma
26 //  or other particle identification and correlations
27 // 
28 //
29 //*-- Author: Gustavo Conesa (LNF-INFN) 
30 //////////////////////////////////////////////////////////////////////////////
31
32
33 // --- ROOT system ---
34
35 //---- ANALYSIS system ----
36 #include "AliCaloTrackAODReader.h" 
37 #include "AliAODEvent.h"
38 #include "AliAODVertex.h"
39 #include "AliAODCaloCluster.h"
40 #include "AliAODCaloCluster.h"
41 #include "AliAODTrack.h"
42 #include "AliMCEvent.h"
43 #include "AliLog.h"
44 #include "Riostream.h"
45
46 ClassImp(AliCaloTrackAODReader)
47
48 //____________________________________________________________________________
49 AliCaloTrackAODReader::AliCaloTrackAODReader() : 
50   AliCaloTrackReader()
51 {
52   //Default Ctor
53   
54   //Initialize parameters
55   fDataType=kAOD;
56   
57 }
58
59 //____________________________________________________________________________
60 AliCaloTrackAODReader::AliCaloTrackAODReader(const AliCaloTrackAODReader & g) :   
61   AliCaloTrackReader(g)
62 {
63   // cpy ctor
64 }
65
66 //_________________________________________________________________________
67 AliCaloTrackAODReader & AliCaloTrackAODReader::operator = (const AliCaloTrackAODReader & source)
68 {
69   // assignment operator
70
71   if(&source == this) return *this;
72
73   return *this;
74
75 }
76
77 //____________________________________________________________________________
78 void AliCaloTrackAODReader::FillInputCTS() {
79   //Return array with CTS tracks
80   fAODCTS = new TClonesArray("AliAODTrack",0);
81
82   Int_t nTracks   = fAOD->GetNumberOfTracks() ;
83   Int_t naod = 0;
84   Double_t p[3];
85   
86   for (Int_t itrack =  0; itrack <  nTracks; itrack++) {////////////// track loop
87     AliAODTrack * track = fAOD->GetTrack(itrack) ; // retrieve track from esd
88     
89     //     //We want tracks fitted in the detectors:
90     //     ULong_t status=AliAODTrack::kTPCrefit;
91     //     status|=AliAODTrack::kITSrefit;
92     
93     //We want tracks whose PID bit is set:
94     //     ULong_t status =AliAODTrack::kITSpid;
95     //     status|=AliAODTrack::kTPCpid;
96     
97     //   if ( (track->GetStatus() & status) == status) {//Check if the bits we want are set
98     
99     track->GetPxPyPz(p) ;
100     TLorentzVector momentum(p[0],p[1],p[2],0);
101     
102     if(fCTSPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"CTS")){
103       
104       if(fDebug > 2 && momentum.Pt() > 0.1)printf("FillInputCTS():: Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
105                                                   momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
106       
107       //      AliAODTrack *newtrack =
108       new((*fAODCTS)[naod++])  AliAODTrack(*track);
109       
110     }//Pt and Fidutial cut passed. 
111     //}// track status
112   }// track loop
113   if(fDebug > 1) printf("FillInputCTS():: aod entries %d\n", fAODCTS->GetEntries());
114 }
115
116 //____________________________________________________________________________
117 void AliCaloTrackAODReader::FillInputEMCAL() {
118   //Return array with EMCAL clusters in aod format
119    fAODEMCAL = new TClonesArray("AliAODCaloCluster",0);
120
121   TRefArray * caloClusters = new TRefArray();
122   fAOD->GetEMCALClusters(caloClusters);
123   
124   //Get vertex for momentum calculation  
125   Double_t v[3] ; //vertex ;
126   GetVertex(v);
127
128   //Loop to select clusters in fidutial cut and fill container with aodClusters
129   Int_t naod = 0;
130
131   for (Int_t iclus =  0; iclus <  caloClusters->GetEntries(); iclus++) {
132     AliAODCaloCluster * clus = (AliAODCaloCluster *) caloClusters->At(iclus) ;
133     TLorentzVector momentum ;
134     clus->GetMomentum(momentum, v);      
135     
136     if(fEMCALPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"EMCAL")){
137     
138       if(fDebug > 2 && momentum.E() > 0.1)printf("FillInputEMCAL():: Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
139                                                  momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
140
141       new((*fAODEMCAL)[naod++]) AliAODCaloCluster(*clus);
142
143     }//Pt and Fidutial cut passed.
144   }//esd cluster loop
145   
146   if(fDebug > 1) printf("FillInputEMCAL():: aod entries %d\n", fAODEMCAL->GetEntries());
147
148 }
149
150 //____________________________________________________________________________
151 void AliCaloTrackAODReader::FillInputPHOS() {
152   //Return array with PHOS clusters in aod format
153   fAODPHOS = new TClonesArray("AliAODCaloCluster",0);
154
155   TRefArray * caloClusters = new TRefArray();
156   fAOD->GetPHOSClusters(caloClusters);
157
158   //Get vertex for momentum calculation  
159   Double_t v[3] ; //vertex ;
160   GetVertex(v);
161
162   //Loop to select clusters in fidutial cut and fill container with aodClusters
163   Int_t naod = 0;
164
165   for (Int_t iclus =  0; iclus <  caloClusters->GetEntries(); iclus++) {
166     AliAODCaloCluster * clus = (AliAODCaloCluster *) caloClusters->At(iclus) ;
167     TLorentzVector momentum ;
168     clus->GetMomentum(momentum, v);      
169     
170     if(fPHOSPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"PHOS")){
171       
172       if(fDebug > 2 && momentum.E() > 0.1)printf("FillInputPHOS():: Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
173                                                  momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
174
175       new((*fAODPHOS)[naod++])  AliAODCaloCluster(*clus);
176       
177     }//Pt and Fidutial cut passed.
178   }//esd cluster loop
179   
180   if(fDebug > 1) printf("FillInputPHOS():: aod entries %d\n", fAODPHOS->GetEntries());
181
182
183 }
184
185 //____________________________________________________________________________
186 void AliCaloTrackAODReader::FillInputEMCALCells() {
187   //Return array with EMCAL cells in aod format
188
189   fEMCALCells = (TNamed*) fAOD->GetEMCALCells(); 
190
191 }
192
193 //____________________________________________________________________________
194 void AliCaloTrackAODReader::FillInputPHOSCells() {
195   //Return array with PHOS cells in aod format
196
197   fPHOSCells = (TNamed*) fAOD->GetPHOSCells(); 
198
199 }
200
201 //____________________________________________________________________________
202 void AliCaloTrackAODReader::GetVertex(Double_t  v[3]) {
203   //Return vertex position
204
205   v[0]=fAOD->GetVertex(0)->GetX() ;//CHECK!!!
206   v[1]=fAOD->GetVertex(0)->GetY() ;//CHECK!!!
207   v[2]=fAOD->GetVertex(0)->GetZ() ;//CHECK!!!
208 }
209
210
211 //____________________________________________________________________________
212 void AliCaloTrackAODReader::SetInputEvent(TObject* /*esd*/, TObject* aod, TObject* mc) {
213   // Connect the data pointers
214   SetAOD((AliAODEvent*) aod);
215   SetMC((AliMCEvent*) mc);
216 }