updating
[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"
baf5b427 29#include "AliPHOSGetter.h"
2631352f 30#include "AliPHOSGeometry.h"
baf5b427 31#include "Riostream.h"
32#include "AliESD.h"
c7f69b3a 33#include "AliESDtrack.h"
1d13ffb1 34#include "AliESDCaloTrack.h"
35#include "AliEMCALRecParticle.h"
36#include "AliPHOSRecParticle.h"
c7f69b3a 37#include "AliKalmanTrack.h"
e82c1b8f 38#endif
baf5b427 39
d6faca62 40Double_t Match(TParticle * pp, AliESDtrack * cp) ;
41TH1D * heta = new TH1D("heta", "Eta correlation", 100, -2., 2.) ;
42TH1D * hphi = new TH1D("hphi", "Phi correlation", 360, 0., 360.) ;
43
baf5b427 44void Ana()
d6faca62 45{
baf5b427 46 AliPHOSGetter * gime = AliPHOSGetter::Instance("galice.root") ;
47 Int_t nEvent = gime->MaxEvent() ;
48 Int_t event ;
1d13ffb1 49 AliESD * esd = 0 ;
baf5b427 50 for (event = 0 ; event < nEvent; event++) {
51 esd = gime->ESD(event) ;
d6faca62 52 //esd->Print();
53 Int_t caloindex ;
c7f69b3a 54 // Calorimeter tracks
1d13ffb1 55 AliESDCaloTrack * ct ;
d6faca62 56 for (caloindex = 0 ; caloindex < esd->GetNumberOfCaloTracks() ; caloindex++) {
57 // get the calorimeter type of particles (PHOS or EMCAL)
58 ct = esd->GetCaloTrack(caloindex) ;
59 TParticle * part = ct->GetRecParticle() ;
60
61 AliESDtrack * cp ;
62 Int_t cpindex ;
63 for (cpindex = 0 ; cpindex < esd->GetNumberOfTracks() ; cpindex++) {
64 // get the charged tracks from central tracking
65 cp = esd->GetTrack(cpindex) ;
66 Double_t dist = Match(part, cp) ;
67
68 if (dist < 99999.)
69 cout << "================ Distance = " << dist << endl ;
c7f69b3a 70 }
71 }
d6faca62 72 }
73 // heta->Draw() ;
74 hphi->Draw() ;
75}
76Double_t Match(TParticle * part, AliESDtrack * cp)
77{
78 // Calculates the distance (x,z) between the particle detected by PHOS and
79 // the charged particle reconstructed by the global tracking
80
81 Double_t dist = 99999. ;
82
83 AliPHOSRecParticle * pp = dynamic_cast<AliPHOSRecParticle*>(part) ;
84 AliEMCALRecParticle * ep = dynamic_cast<AliEMCALRecParticle*>(part) ;
85
86 Int_t phN ;
87 Double_t phZ, phX ;
88
89 if (pp) { // it is a PHOS particle
90
91 // cout << "PHOS particle # " << " pos ("
92// << pp->GetPos().X() << ", " << pp->GetPos().Y() << ", " << pp->GetPos().Z() << ")" << endl ;
93
94 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
95 gime->PHOSGeometry()->ImpactOnEmc(*pp, phN, phZ, phX) ;
96 Double_t xyzAtPHOS[3] ;
97 cp->GetOuterXYZ(xyzAtPHOS) ;
98 if ( (xyzAtPHOS[0] + xyzAtPHOS[1] + xyzAtPHOS[2]) != 0.) { //it has reached PHOS
99 //the next check are only if we want high quality tracks
80427b5a 100 // ULong_t status = cp->GetStatus() ;
101 // if ((status & AliESDtrack::kTRDput)==0)
d6faca62 102 // do not continue;
80427b5a 103 // if ((status & AliESDtrack::kTRDStop)!=0)
d6faca62 104 // do not continue;
105// cout << "Charged particle # " << " pos ("
106// << xyzAtPHOS[0] << ", " << xyzAtPHOS[1] << ", " << xyzAtPHOS[2] << ")" << endl ;
107 TVector3 poscp(xyzAtPHOS[0], xyzAtPHOS[1], xyzAtPHOS[2]) ;
108 Int_t cpN ;
109 Double_t cpZ,cpX ;
110 gime->PHOSGeometry()->ImpactOnEmc(poscp, cpN, cpZ, cpX) ;
111 if (cpN) {// we are inside the PHOS acceptance
112// cout << "Charged Matching 1: " << cpN << " " << cpZ << " " << cpX << endl ;
113// cout << "Charged Matching 2: " << phN << " " << phZ << " " << phX << endl ;
114 dist = TMath::Sqrt( (cpZ-phZ)*(cpZ-phZ) + (cpX-phX)*(cpX-phX)) ;
115 }
116 Double_t phTheta = pp->Theta() ;
117 Double_t phPhi = pp->Phi() ;
118 TParticle tempo ;
119 tempo.SetMomentum(xyzAtPHOS[0], xyzAtPHOS[1], xyzAtPHOS[2], 0.) ;
120 Double_t cpTheta = tempo.Theta() ;
121 Double_t cpPhi = tempo.Phi() ;
122 //cout << phTheta << " " << phPhi << " " << endl
123 //cout << cpTheta << " " << cpPhi-phPhi << " " << endl ;
124 heta->Fill( (phTheta - cpTheta)*TMath::RadToDeg() ) ;
125 hphi->Fill( (phPhi - cpPhi)*TMath::RadToDeg() ) ;
1d13ffb1 126 }
baf5b427 127 }
d6faca62 128
129 if (ep) {
130 //cout << "EMCAL particle # " << endl ;
131 }
132 return dist ;
baf5b427 133}
d6faca62 134