replaces AliPHOSAliEnFile: references to AliEn removed
[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"
d31d94a8 38#include "AliPHOSAliEnFile.h"
e82c1b8f 39#endif
baf5b427 40
03b531f2 41void Match(TParticle * pp, AliESDtrack * cp, Double_t * dist) ;
42TH1D * heta = new TH1D("heta", "Eta correlation", 100, 0., 360.) ;
43TH1D * hphi = new TH1D("hphi", "Phi correlation", 100, 0., 360.) ;
d31d94a8 44// Data Challenge identification
45const TString kYear("2004") ;
46const TString kProd("02") ;
47const TString kVers("V4.01.Rev.00") ;
03b531f2 48
d31d94a8 49Bool_t Ana(const TString type = "per5", const Int_t run = 1, const Int_t nOfEvt = 1)
d6faca62 50{
03b531f2 51 Double_t dist[3] ;
d31d94a8 52 // get the LFN file name in the AliEn catalogue ;
53 AliPHOSAliEnFile lfn ;
54 lfn.SetPath(kYear, kProd, kVers, type) ;
55 lfn.SetRun(run) ;
d6faca62 56
d31d94a8 57 //loop over the events
58 Int_t nevt, evt = 0 ;
59 for (nevt = 0 ; nevt < nOfEvt ; nevt++) {
60 evt++ ;
61 lfn.SetEvt(evt) ;
62 TString fileName = lfn.GetLFN() ;
63
64 if (fileName.IsNull()) {
65 nevt-- ;
66 continue ;
67 }
68
69 printf(">>>>>>>>>>>> Processing %s-%s/%s/%s : run # %d event # %d \n",
70 kYear.Data(), kProd.Data(), kVers.Data(), type.Data(), run, evt) ;
71 AliPHOSGetter * gime = AliPHOSGetter::Instance(fileName) ;
72
73 Int_t nEvent = gime->MaxEvent() ;
74 Int_t event ;
75 AliESD * esd = 0 ;
76 for (event = 0 ; event < nEvent; event++) {
77 esd = gime->ESD(event) ;
78 if (!esd)
79 return kFALSE ;
80
81 //esd->Print();
82 Int_t caloindex ;
83 // Calorimeter tracks
84 AliESDCaloTrack * ct ;
85 for (caloindex = 0 ; caloindex < esd->GetNumberOfCaloTracks() ; caloindex++) {
86 // get the calorimeter type of particles (PHOS or EMCAL)
87 ct = esd->GetCaloTrack(caloindex) ;
88 TParticle * part = ct->GetRecParticle() ;
89
90 AliESDtrack * cp ;
91 Int_t cpindex ;
92 for (cpindex = 0 ; cpindex < esd->GetNumberOfTracks() ; cpindex++) {
93 // get the charged tracks from central tracking
94 cp = esd->GetTrack(cpindex) ;
95 Match(part, cp, dist) ;
96 }
97 heta->Fill( dist[1] ) ;
98 hphi->Fill( dist[2] ) ;
c7f69b3a 99 }
100 }
d6faca62 101 }
03b531f2 102 heta->Draw() ;
103 //hphi->Draw() ;
d31d94a8 104 return kTRUE ;
d6faca62 105}
03b531f2 106
107void Match(TParticle * part, AliESDtrack * cp, Double_t * dist)
d6faca62 108{
109 // Calculates the distance (x,z) between the particle detected by PHOS and
110 // the charged particle reconstructed by the global tracking
111
d6faca62 112
113 AliPHOSRecParticle * pp = dynamic_cast<AliPHOSRecParticle*>(part) ;
114 AliEMCALRecParticle * ep = dynamic_cast<AliEMCALRecParticle*>(part) ;
115
116 Int_t phN ;
117 Double_t phZ, phX ;
118
119 if (pp) { // it is a PHOS particle
03b531f2 120 Double_t cpTheta, cpPhi ;
121 Double_t phTheta, phPhi ;
122 cpTheta = cpPhi = phTheta = phPhi = 0. ;
123 // cout << "PHOS particle # " << " pos ("
124 // << pp->GetPos().X() << ", " << pp->GetPos().Y() << ", " << pp->GetPos().Z() << ")" << endl ;
d6faca62 125
126 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
127 gime->PHOSGeometry()->ImpactOnEmc(*pp, phN, phZ, phX) ;
128 Double_t xyzAtPHOS[3] ;
129 cp->GetOuterXYZ(xyzAtPHOS) ;
130 if ( (xyzAtPHOS[0] + xyzAtPHOS[1] + xyzAtPHOS[2]) != 0.) { //it has reached PHOS
131 //the next check are only if we want high quality tracks
80427b5a 132 // ULong_t status = cp->GetStatus() ;
133 // if ((status & AliESDtrack::kTRDput)==0)
d6faca62 134 // do not continue;
80427b5a 135 // if ((status & AliESDtrack::kTRDStop)!=0)
d6faca62 136 // do not continue;
03b531f2 137 // cout << "Charged particle # " << " pos ("
138 // << xyzAtPHOS[0] << ", " << xyzAtPHOS[1] << ", " << xyzAtPHOS[2] << ")" << endl ;
d6faca62 139 TVector3 poscp(xyzAtPHOS[0], xyzAtPHOS[1], xyzAtPHOS[2]) ;
140 Int_t cpN ;
141 Double_t cpZ,cpX ;
142 gime->PHOSGeometry()->ImpactOnEmc(poscp, cpN, cpZ, cpX) ;
143 if (cpN) {// we are inside the PHOS acceptance
03b531f2 144 // cout << "Charged Matching 1: " << cpN << " " << cpZ << " " << cpX << endl ;
145 // cout << "Charged Matching 2: " << phN << " " << phZ << " " << phX << endl ;
146 dist[0] = TMath::Sqrt( (cpZ-phZ)*(cpZ-phZ) + (cpX-phX)*(cpX-phX)) ;
d6faca62 147 }
03b531f2 148 phTheta = pp->Theta() ;
149 phPhi = pp->Phi() ;
d6faca62 150 TParticle tempo ;
151 tempo.SetMomentum(xyzAtPHOS[0], xyzAtPHOS[1], xyzAtPHOS[2], 0.) ;
03b531f2 152 cpTheta = tempo.Theta() ;
153 cpPhi = tempo.Phi() ;
d6faca62 154 //cout << phTheta << " " << phPhi << " " << endl
155 //cout << cpTheta << " " << cpPhi-phPhi << " " << endl ;
1d13ffb1 156 }
03b531f2 157 dist[1] = (phTheta - cpTheta)*TMath::RadToDeg() ;
158 dist[2] = (phPhi - cpPhi)*TMath::RadToDeg() ;
baf5b427 159 }
d6faca62 160
161 if (ep) {
162 //cout << "EMCAL particle # " << endl ;
163 }
baf5b427 164}