AliRoot Core  edcc906 (edcc906)
AliEMCALRecoUtilsBase.cxx
Go to the documentation of this file.
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 
16 // ROOT includes
17 #include <TGeoManager.h>
18 #include <TGeoBBox.h>
19 
20 // STEER includes
21 #include "AliVCluster.h"
22 #include "AliESDtrack.h"
23 #include "AliAODTrack.h"
24 #include "AliExternalTrackParam.h"
25 #include "AliTrackerBase.h"
26 
27 // EMCAL includes
28 #include "AliEMCALRecoUtilsBase.h"
29 #include "AliEMCALGeometry.h"
30 
32 ClassImp(AliEMCALRecoUtilsBase) ;
34 
40 //_____________________________________
42 {
43 }
44 
45 //
46 // Copy constructor.
47 //
48 //______________________________________________________________________
50 : TNamed(reco)
51 {
52 }
53 
57 //______________________________________________________________________
59 {
60  if (this == &reco)return *this;
61  ((TNamed *)this)->operator=(reco);
62 
63  return *this;
64 }
65 
81 //------------------------------------------------------------------------------------
83  Double_t emcalR,
84  Double_t mass,
85  Double_t step,
86  Double_t minpt,
87  Bool_t useMassForTracking,
88  Bool_t useDCA)
89 {
90  track->SetTrackPhiEtaPtOnEMCal(-999, -999, -999);
91 
92  if ( track->Pt() < minpt )
93  return kFALSE;
94 
95  if ( TMath::Abs(track->Eta()) > 0.9 ) return kFALSE;
96 
97  // Save some time and memory in case of no DCal present
99 
100  Int_t nSupMod = AliEMCALGeoParams::fgkEMCALModules;
101  if ( geom ) nSupMod = geom->GetNumberOfSuperModules();
102 
103  if ( nSupMod < 13 ) // Run1 10 (12, 2 not active but present)
104  {
105  Double_t phi = track->Phi()*TMath::RadToDeg();
106  if ( phi <= 10 || phi >= 250 ) return kFALSE;
107  }
108 
109  AliESDtrack *esdt = dynamic_cast<AliESDtrack*>(track);
110  AliAODTrack *aodt = 0;
111  if (!esdt)
112  {
113  aodt = dynamic_cast<AliAODTrack*>(track);
114 
115  if (!aodt)
116  return kFALSE;
117  }
118 
119  // Select the mass hypothesis
120  if ( mass < 0 )
121  {
122  Bool_t onlyTPC = kFALSE;
123  if ( mass == -99 ) onlyTPC=kTRUE;
124 
125  if (esdt)
126  {
127  if ( useMassForTracking ) mass = esdt->GetMassForTracking();
128  else mass = esdt->GetMass(onlyTPC);
129  }
130  else
131  {
132  if ( useMassForTracking ) mass = aodt->GetMassForTracking();
133  else mass = aodt->M();
134  }
135  }
136 
137  AliExternalTrackParam *trackParam = 0;
138  if (esdt)
139  {
140  const AliExternalTrackParam *in = esdt->GetInnerParam();
141 
142  if (!in)
143  return kFALSE;
144 
145  trackParam = new AliExternalTrackParam(*in);
146  }
147  else
148  {
149  Double_t xyz[3] = {0}, pxpypz[3] = {0}, cv[21] = {0};
150  aodt->PxPyPz(pxpypz);
151  if (useDCA) {
152  // Note: useDCA is by default false in this function only for backwards compatibility
153  aodt->GetXYZ(xyz);
154  }
155  else {
156  aodt->XvYvZv(xyz);
157  }
158  aodt->GetCovarianceXYZPxPyPz(cv);
159  trackParam = new AliExternalTrackParam(xyz,pxpypz,cv,aodt->Charge());
160  }
161 
162  if (!trackParam)
163  return kFALSE;
164 
165  Float_t etaout=-999, phiout=-999, ptout=-999;
166  Bool_t ret = ExtrapolateTrackToEMCalSurface(trackParam,
167  emcalR,
168  mass,
169  step,
170  etaout,
171  phiout,
172  ptout);
173 
174  delete trackParam;
175 
176  if (!ret) return kFALSE;
177 
178  if ( TMath::Abs(etaout) > 0.75 ) return kFALSE;
179 
180  // Save some time and memory in case of no DCal present
181  if ( nSupMod < 13 ) // Run1 10 (12, 2 not active but present)
182  {
183  if ( (phiout < 70*TMath::DegToRad()) || (phiout > 190*TMath::DegToRad()) ) return kFALSE;
184  }
185 
186  track->SetTrackPhiEtaPtOnEMCal(phiout, etaout, ptout);
187 
188  return kTRUE;
189 }
190 
191 
206 //---------------------------------------------------------------------------------------
208  Double_t emcalR,
209  Double_t mass,
210  Double_t step,
211  Float_t &eta,
212  Float_t &phi,
213  Float_t &pt)
214 {
215  eta = -999, phi = -999, pt = -999;
216 
217  if (!trkParam) return kFALSE;
218 
219  if (!AliTrackerBase::PropagateTrackToBxByBz(trkParam, emcalR, mass, step, kTRUE, 0.8, -1)) return kFALSE;
220 
221  Double_t trkPos[3] = {0.,0.,0.};
222 
223  if (!trkParam->GetXYZ(trkPos)) return kFALSE;
224 
225  TVector3 trkPosVec(trkPos[0],trkPos[1],trkPos[2]);
226 
227  eta = trkPosVec.Eta();
228  phi = trkPosVec.Phi();
229  pt = trkParam->Pt();
230 
231  if ( phi < 0 )
232  phi += TMath::TwoPi();
233 
234  return kTRUE;
235 }
236 
249 //-----------------------------------------------------------------------------------
251  const Float_t *clsPos,
252  Double_t mass,
253  Double_t step,
254  Float_t &tmpEta,
255  Float_t &tmpPhi)
256 {
257  tmpEta = -999;
258  tmpPhi = -999;
259 
260  if (!trkParam) return kFALSE;
261 
262  Double_t trkPos[3] = {0.,0.,0.};
263  TVector3 vec(clsPos[0],clsPos[1],clsPos[2]);
264 
265  Float_t phi = vec.Phi();
266 
267  if ( phi < 0 )
268  phi += TMath::TwoPi();
269 
270  // Rotate the cluster to the local extrapolation coordinate system
271  Double_t alpha = ((int)(phi*TMath::RadToDeg()/20)+0.5)*20*TMath::DegToRad();
272 
273  vec.RotateZ(-alpha);
274 
275  if (!AliTrackerBase::PropagateTrackToBxByBz(trkParam, vec.X(), mass, step,kTRUE, 0.8, -1))
276  return kFALSE;
277 
278  if (!trkParam->GetXYZ(trkPos))
279  return kFALSE; // Get the extrapolated global position
280 
281  TVector3 clsPosVec(clsPos[0],clsPos[1],clsPos[2]);
282  TVector3 trkPosVec(trkPos[0],trkPos[1],trkPos[2]);
283 
284  // Track cluster matching
285  tmpPhi = clsPosVec.DeltaPhi(trkPosVec); // tmpPhi is between -pi and pi
286  tmpEta = clsPosVec.Eta()-trkPosVec.Eta();
287 
288  return kTRUE;
289 }
290 
304 //----------------------------------------------------------------------------------
306  const AliVCluster *cluster,
307  Double_t mass,
308  Double_t step,
309  Float_t &tmpEta,
310  Float_t &tmpPhi)
311 {
312  tmpEta = -999;
313  tmpPhi = -999;
314 
315  if (!cluster || !trkParam)
316  return kFALSE;
317 
318  Float_t clsPos[3] = {0.,0.,0.};
319  cluster->GetPosition(clsPos);
320 
321  return ExtrapolateTrackToPosition(trkParam, clsPos, mass, step, tmpEta, tmpPhi);
322 }
323 
332 //_________________________________________________________
333 Float_t AliEMCALRecoUtilsBase::GetDepth(Float_t energy,
334  Int_t iParticle,
335  Int_t iSM ) const
336 {
337  // parameters
338  Float_t x0 = 1.31;
339  Float_t ecr = 8;
340  Float_t depth = 0;
341  Float_t arg = energy*1000/ ecr; //Multiply energy by 1000 to transform to MeV
342 
343  switch ( iParticle )
344  {
345  case kPhoton:
346  if (arg < 1)
347  depth = 0;
348  else
349  depth = x0 * (TMath::Log(arg) + 0.5);
350  break;
351 
352  case kElectron:
353  if (arg < 1)
354  depth = 0;
355  else
356  depth = x0 * (TMath::Log(arg) - 0.5);
357  break;
358 
359  case kHadron:
360  // hadron
361  // boxes anc. here
362  if (gGeoManager)
363  {
364  gGeoManager->cd("ALIC_1/XEN1_1");
365  TGeoNode *geoXEn1 = gGeoManager->GetCurrentNode();
366  TGeoNodeMatrix *geoSM = dynamic_cast<TGeoNodeMatrix *>(geoXEn1->GetDaughter(iSM));
367  if (geoSM)
368  {
369  TGeoVolume *geoSMVol = geoSM->GetVolume();
370  TGeoShape *geoSMShape = geoSMVol->GetShape();
371  TGeoBBox *geoBox = dynamic_cast<TGeoBBox *>(geoSMShape);
372  if (geoBox) depth = 0.5 * geoBox->GetDX()*2 ;
373  else AliFatal("Null GEANT box");
374  }
375  else AliFatal("NULL GEANT node matrix");
376  }
377  else
378  {//electron
379  if (arg < 1)
380  depth = 0;
381  else
382  depth = x0 * (TMath::Log(arg) - 0.5);
383  }
384 
385  break;
386 
387  default://photon
388  if (arg < 1)
389  depth = 0;
390  else
391  depth = x0 * (TMath::Log(arg) + 0.5);
392  }
393 
394  return depth;
395 }
396 
virtual Double_t M() const
Definition: AliAODTrack.h:155
virtual Double_t Phi() const =0
const AliExternalTrackParam * GetInnerParam() const
Definition: AliESDtrack.h:132
TVectorD vec
Definition: AnalyzeLaser.C:8
Bool_t GetXYZ(Double_t *p) const
virtual Bool_t PxPyPz(Double_t p[3]) const
Definition: AliAODTrack.h:126
Bool_t GetXYZ(Double_t *p) const
Definition: AliAODTrack.h:234
Double_t GetMassForTracking() const
Int_t GetNumberOfSuperModules(void) const
AliTPCfastTrack * track
Virtual class for calorimeter cluster data handling.
Definition: AliVCluster.h:20
Float_t GetDepth(Float_t eCluster, Int_t iParticle, Int_t iSM) const
static Bool_t ExtrapolateTrackToCluster(AliExternalTrackParam *trkParam, const AliVCluster *cluster, Double_t mass, Double_t step, Float_t &tmpEta, Float_t &tmpPhi)
TGeoManager * gGeoManager
Bool_t GetCovarianceXYZPxPyPz(Double_t cv[21]) const
Definition: AliAODTrack.h:240
static Bool_t ExtrapolateTrackToPosition(AliExternalTrackParam *trkParam, const Float_t *clsPos, Double_t mass, Double_t step, Float_t &tmpEta, Float_t &tmpPhi)
Double_t GetMass(Bool_t tpcOnly=kFALSE) const
Definition: AliESDtrack.h:98
Some utilities for track matching.
static Bool_t PropagateTrackToBxByBz(AliExternalTrackParam *track, Double_t x, Double_t m, Double_t maxStep, Bool_t rotateTo=kTRUE, Double_t maxSnp=0.8, Int_t sign=0, Bool_t addTimeStep=kFALSE, Bool_t correctMaterialBudget=kTRUE)
virtual Bool_t XvYvZv(Double_t x[3]) const
Definition: AliAODTrack.h:131
#define AliFatal(message)
Definition: AliLog.h:640
virtual Double_t Pt() const =0
virtual Short_t Charge() const
Definition: AliAODTrack.h:166
AliEMCALRecoUtilsBase & operator=(const AliEMCALRecoUtilsBase &)
static const int fgkEMCALModules
Number of modules, 12 for EMCal + 8 for DCAL.
static Bool_t ExtrapolateTrackToEMCalSurface(AliVTrack *track, Double_t emcalR=440, Double_t mass=0.1396, Double_t step=20, Double_t minpT=0.35, Bool_t useMassForTracking=kFALSE, Bool_t useDCA=kFALSE)
static AliEMCALGeometry * GetInstance()
virtual Double_t Eta() const =0
TEveGeoShape * geom
Definition: tpc_tracks.C:10
EMCal geometry, singleton.
Double_t GetMassForTracking() const
virtual void SetTrackPhiEtaPtOnEMCal(Double_t, Double_t, Double_t=-999)
Definition: AliVTrack.h:147
virtual void GetPosition(Float_t *) const
Definition: AliVCluster.h:82