]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/PartCorrBase/AliCaloTrackAODReader.cxx
1) AliCaloTrackReader: Possibility to open a second input file with events, when...
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / 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 //_________________________________________________________________________
19 // Class for reading data (AODs) in order to do prompt gamma
20 //  or other particle identification and correlations.
21 // Mixing analysis can be done, input AOD with events
22 // is opened in the AliCaloTrackReader::Init()
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"
35 #include "AliAODCaloCluster.h"
36 #include "AliAODTrack.h"
37 #include "AliESDtrack.h"
38 #include "AliFidutialCut.h"
39
40 ClassImp(AliCaloTrackAODReader)
41
42 //____________________________________________________________________________
43 AliCaloTrackAODReader::AliCaloTrackAODReader() : 
44   AliCaloTrackReader()
45 {
46   //Default Ctor
47   
48   //Initialize parameters
49   fDataType=kAOD;
50   fReadStack          = kTRUE;
51   fReadAODMCParticles = kFALSE;
52   //We want tracks fitted in the detectors:
53   fTrackStatus=AliESDtrack::kTPCrefit;
54   fTrackStatus|=AliESDtrack::kITSrefit;
55
56 }
57
58 //____________________________________________________________________________
59 AliCaloTrackAODReader::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 //____________________________________________________________________________
77 void AliCaloTrackAODReader::FillInputCTS() {
78   //Return array with Central Tracking System (CTS) tracks
79
80   Int_t nTracks   = fInputEvent->GetNumberOfTracks() ;
81   Double_t p[3];
82   for (Int_t itrack =  0; itrack <  nTracks; itrack++) {////////////// track loop
83     AliAODTrack * track = ((AliAODEvent*)fInputEvent)->GetTrack(itrack) ; // retrieve track from esd
84           
85     //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
86         if (fTrackStatus && !((track->GetStatus() & fTrackStatus) == fTrackStatus)) continue ;
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       
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",
94                                                   momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
95  
96       fAODCTS->Add(track);
97     }//Pt and Fidutial cut passed. 
98   }// track loop
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         
129 }
130
131 //____________________________________________________________________________
132 void AliCaloTrackAODReader::FillInputEMCAL() {
133   //Return array with EMCAL clusters in aod format
134   
135   //Get vertex for momentum calculation  
136   Double_t v[3] ; //vertex ;
137   GetVertex(v);
138   
139   //Loop to select clusters in fidutial cut and fill container with aodClusters
140   Int_t nclusters = ((AliAODEvent*)fInputEvent)->GetNCaloClusters();
141   for (Int_t iclus =  0; iclus <  nclusters; iclus++) {
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")){
149     
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",
151                                                      momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
152           
153           fAODEMCAL->Add(clus); 
154         }//Pt and Fidutial cut passed.
155       }//EMCAL cluster
156     }// cluster exists
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());
184
185         } //second input loop
186 }
187
188 //____________________________________________________________________________
189 void AliCaloTrackAODReader::FillInputPHOS() {
190   //Return array with PHOS clusters in aod format
191   
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
197   Int_t nclusters = ((AliAODEvent*)fInputEvent)->GetNCaloClusters();
198   for (Int_t iclus =  0; iclus < nclusters; iclus++) {
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           
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",
208                                                      momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
209
210           fAODPHOS->Add(clus);  
211         }//Pt and Fidutial cut passed.
212       }//PHOS cluster
213     }//cluster exists
214   }//esd cluster loop
215         
216   fAODPHOSNormalInputEntries = fAODPHOS->GetEntriesFast() ;
217   if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputPHOS()  - aod entries %d\n", fAODPHOSNormalInputEntries);
218
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
241
242 }
243
244 //____________________________________________________________________________
245 void AliCaloTrackAODReader::FillInputEMCALCells() {
246   //Return array with EMCAL cells in aod format
247
248   fEMCALCells = (TNamed*) ((AliAODEvent*)fInputEvent)->GetEMCALCells(); 
249
250 }
251
252 //____________________________________________________________________________
253 void AliCaloTrackAODReader::FillInputPHOSCells() {
254   //Return array with PHOS cells in aod format
255
256   fPHOSCells = (TNamed*) ((AliAODEvent*)fInputEvent)->GetPHOSCells(); 
257
258 }
259
260 //____________________________________________________________________________
261 void AliCaloTrackAODReader::GetVertex(Double_t  v[3]) const {
262   //Return vertex position
263
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!!!
267 }
268
269
270 //____________________________________________________________________________
271 void AliCaloTrackAODReader::SetInputOutputMCEvent(AliVEvent* input, AliAODEvent* aod, AliMCEvent* mc) {
272   // Connect the data pointers
273   // If input is AOD, do analysis with input, if not, do analysis with the output aod.
274   if(!strcmp(input->GetName(),"AliESDEvent"))   {
275     SetInputEvent(aod);
276     SetOutputEvent(aod);
277   }
278   else if(!strcmp(input->GetName(),"AliAODEvent")){
279     SetInputEvent(input);
280     SetOutputEvent(aod);
281   }
282   else{ 
283     printf("AliCaloTrackAODReader::SetInputOutputMCEvent() - STOP : Wrong data format: %s\n",input->GetName());
284     abort();
285   }
286   
287   SetMC(mc);
288   
289 }