added the charged track reference in the construction of the links
[u/mrichter/AliRoot.git] / PHOS / AnaESD.C
CommitLineData
12391a12 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15/* $Id$ */
16//_________________________________________________________________________
17// Macros analyzing the ESD file
18// Use Case :
19// root> .L AnaESD.C++
20// root> ana() --> prints the objects stored in ESD
21//
22// author : Yves Schutz (CERN/SUBATECH)
23// February 2004
24//_________________________________________________________________________
e82c1b8f 25#if !defined(__CINT__) || defined(__MAKECINT__)
baf5b427 26#include "TFile.h"
c7f69b3a 27#include "TMath.h"
d6faca62 28#include "TH1D.h"
a90d1169 29#include "TROOT.h"
30#include "TBrowser.h"
baf5b427 31#include "AliPHOSGetter.h"
2631352f 32#include "AliPHOSGeometry.h"
baf5b427 33#include "Riostream.h"
34#include "AliESD.h"
c7f69b3a 35#include "AliESDtrack.h"
1d13ffb1 36#include "AliESDCaloTrack.h"
37#include "AliEMCALRecParticle.h"
38#include "AliPHOSRecParticle.h"
c7f69b3a 39#include "AliKalmanTrack.h"
44913864 40#include "AliPHOSGridFile.h"
e82c1b8f 41#endif
baf5b427 42
a90d1169 43Bool_t AnaESD(TString filename) ;
44void Match(AliESDtrack * ct, AliESDtrack * cp, Double_t * dist) ;
03b531f2 45
a90d1169 46
47//__________________________________________________________________________
d31d94a8 48Bool_t Ana(const TString type = "per5", const Int_t run = 1, const Int_t nOfEvt = 1)
d6faca62 49{
a90d1169 50 // Analyzes data from the AliEn data catalog
51
52 // Data Challenge identification
53 const TString kYear("2004") ;
54 const TString kProd("02") ;
55 const TString kVers("V4.01.Rev.00") ;
56
44913864 57 // get the LFN file name in the Grid catalogue ;
58 AliPHOSGridFile lfn ;
59 if (!lfn.IsConnected())
60 return kFALSE ;
d31d94a8 61 lfn.SetPath(kYear, kProd, kVers, type) ;
62 lfn.SetRun(run) ;
d6faca62 63
d31d94a8 64 //loop over the events
65 Int_t nevt, evt = 0 ;
66 for (nevt = 0 ; nevt < nOfEvt ; nevt++) {
67 evt++ ;
68 lfn.SetEvt(evt) ;
69 TString fileName = lfn.GetLFN() ;
70
71 if (fileName.IsNull()) {
72 nevt-- ;
73 continue ;
74 }
75
76 printf(">>>>>>>>>>>> Processing %s-%s/%s/%s : run # %d event # %d \n",
a90d1169 77 kYear.Data(), kProd.Data(), kVers.Data(), type.Data(), run, evt) ;
78 AnaESD(fileName) ;
79 }
80 return kTRUE ;
81}
82
83//__________________________________________________________________________
84Bool_t AnaESD(TString fileName)
85{
86 // Analyze ESD from file fileName
87 // calo track histograms ;
88
89 TFile * out = new TFile("out.root", "RECREATE") ;
90 TH1D * hCaloEnergy = 0 ;
91 TH1D * heta = 0 ;
92 TH1D * hphi = 0 ;
93 Double_t dist[3] ;
94
95 AliPHOSGetter * gime = AliPHOSGetter::Instance(fileName) ;
96
97 Int_t nEvent = gime->MaxEvent() ;
98 Int_t event ;
99 AliESD * esd = 0 ;
100 for (event = 0 ; event < nEvent; event++) {
101 cout << "AnaESD : Processing event # " << event << endl ;
102 esd = gime->ESD(event) ;
103 if (!esd)
104 return kFALSE ;
d31d94a8 105
a90d1169 106 //esd->Print();
107 // Calorimeter tracks
108 AliESDtrack * ct ;
109 Int_t caloindex ;
110 for (caloindex = 0 ; caloindex < esd->GetNumberOfTracks() ; caloindex++) {
111 // get the tracks and check if it is from PHOS
112 ct = esd->GetTrack(caloindex) ;
113 if ( !ct->IsPHOS() )
114 continue ;
115 Double_t energy = ct->GetPHOSsignal() ;
116 if(!hCaloEnergy) {
117 out->cd() ;
118 hCaloEnergy = new TH1D("CaloEnergy", "Energy in calorimeter", 1500, 0., 150.) ;
119 }
120 hCaloEnergy->Fill(energy) ;
121 AliESDtrack * cp ;
122 Int_t cpindex ;
123 for (cpindex = 0 ; cpindex < esd->GetNumberOfTracks() ; cpindex++) {
124 // get the charged tracks from central tracking
125 cp = esd->GetTrack(cpindex) ;
126 if ( cp->IsPHOS() )
127 continue ;
128 Match(ct, cp, dist) ;
129 if (!heta && !hphi) {
130 heta = new TH1D("Correta", "neutral-charged correlation in eta" , 100, 0., 360.) ;
131 hphi = new TH1D("Corrphi", "neutral-charged correlation in phi" , 100, 0., 360.) ;
d31d94a8 132 }
a90d1169 133 heta->Fill(dist[1]) ;
134 hphi->Fill(dist[2]) ;
c7f69b3a 135 }
136 }
d6faca62 137 }
a90d1169 138 TBrowser * bs = new TBrowser("Root Memory Bowser", gROOT->FindObjectAny("out.root") ) ;
139 bs->Show() ;
140 out->Write() ;
d31d94a8 141 return kTRUE ;
d6faca62 142}
03b531f2 143
a90d1169 144//__________________________________________________________________________
145void Match(AliESDtrack * ct, AliESDtrack * cp, Double_t * dist)
d6faca62 146{
147 // Calculates the distance (x,z) between the particle detected by PHOS and
148 // the charged particle reconstructed by the global tracking
149
a90d1169 150
151 // Int_t phN ;
152// Double_t phZ, phX ;
d6faca62 153
a90d1169 154// if (ct->IsPHOS()) { // it is a PHOS particle
155// Double_t cpTheta, cpPhi ;
156// Double_t phTheta, phPhi ;
157// cpTheta = cpPhi = phTheta = phPhi = 0. ;
158// // cout << "PHOS particle # " << " pos ("
159// // << pp->GetPos().X() << ", " << pp->GetPos().Y() << ", " << pp->GetPos().Z() << ")" << endl ;
d6faca62 160
a90d1169 161// AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
162// gime->PHOSGeometry()->ImpactOnEmc(*pp, phN, phZ, phX) ;
163// Double_t xyzAtPHOS[3] ;
164// cp->GetOuterXYZ(xyzAtPHOS) ;
165// if ( (xyzAtPHOS[0] + xyzAtPHOS[1] + xyzAtPHOS[2]) != 0.) { //it has reached PHOS
166// //the next check are only if we want high quality tracks
167// // ULong_t status = cp->GetStatus() ;
168// // if ((status & AliESDtrack::kTRDput)==0)
169// // do not continue;
170// // if ((status & AliESDtrack::kTRDStop)!=0)
171// // do not continue;
172// // cout << "Charged particle # " << " pos ("
173// // << xyzAtPHOS[0] << ", " << xyzAtPHOS[1] << ", " << xyzAtPHOS[2] << ")" << endl ;
174// TVector3 poscp(xyzAtPHOS[0], xyzAtPHOS[1], xyzAtPHOS[2]) ;
175// Int_t cpN ;
176// Double_t cpZ,cpX ;
177// gime->PHOSGeometry()->ImpactOnEmc(poscp, cpN, cpZ, cpX) ;
178// if (cpN) {// we are inside the PHOS acceptance
179// // cout << "Charged Matching 1: " << cpN << " " << cpZ << " " << cpX << endl ;
180// // cout << "Charged Matching 2: " << phN << " " << phZ << " " << phX << endl ;
181// dist[0] = TMath::Sqrt( (cpZ-phZ)*(cpZ-phZ) + (cpX-phX)*(cpX-phX)) ;
182// }
183// phTheta = pp->Theta() ;
184// phPhi = pp->Phi() ;
185// TParticle tempo ;
186// tempo.SetMomentum(xyzAtPHOS[0], xyzAtPHOS[1], xyzAtPHOS[2], 0.) ;
187// cpTheta = tempo.Theta() ;
188// cpPhi = tempo.Phi() ;
189// //cout << phTheta << " " << phPhi << " " << endl
190// //cout << cpTheta << " " << cpPhi-phPhi << " " << endl ;
191// }
192// dist[1] = (phTheta - cpTheta)*TMath::RadToDeg() ;
193// dist[2] = (phPhi - cpPhi)*TMath::RadToDeg() ;
194// }
d6faca62 195
a90d1169 196// if (ep) {
197// //cout << "EMCAL particle # " << endl ;
198// }
baf5b427 199}