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