]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSPIDv1.cxx
Temporary disable the raw version, it will be taken from FEE
[u/mrichter/AliRoot.git] / PHOS / AliPHOSPIDv1.cxx
index 8ca5f6787534111c661a09ad43773a0714bf7392..ac064a65362cacb4182252b00a4fba43ea41ec3e 100644 (file)
 /* History of cvs commits:
  *
  * $Log$
+ * Revision 1.112  2007/07/11 13:43:30  hristov
+ * New class AliESDEvent, backward compatibility with the old AliESD (Christian)
+ *
+ * Revision 1.111  2007/05/04 14:49:29  policheh
+ * AliPHOSRecPoint inheritance from AliCluster
+ *
+ * Revision 1.110  2007/04/24 10:08:03  kharlov
+ * Vertex extraction from GenHeader
+ *
+ * Revision 1.109  2007/04/18 09:34:05  kharlov
+ * Geometry bug fixes
+ *
+ * Revision 1.108  2007/04/16 09:03:37  kharlov
+ * Incedent angle correction fixed
+ *
  * Revision 1.107  2007/04/02 15:00:16  cvetan
  * No more calls to gAlice in the reconstruction
  *
 #include "AliPHOS.h"
 #include "AliPHOSPIDv1.h"
 #include "AliPHOSGetter.h"
-#include "AliESD.h"
+#include "AliESDEvent.h"
 #include "AliESDVertex.h"
+#include "AliHeader.h"
+#include "AliGenEventHeader.h"
 
 ClassImp( AliPHOSPIDv1) 
 
 //____________________________________________________________________________
 AliPHOSPIDv1::AliPHOSPIDv1() :
+  AliPHOSPID(),
   fBayesian(kFALSE),
   fDefaultInit(kFALSE),
   fWrite(kFALSE),
@@ -142,6 +160,7 @@ AliPHOSPIDv1::AliPHOSPIDv1() :
   fPPi0(0),
   fRecParticlesInRun(0),
   fParameters(0),
+  fVtx(0.), 
   fTFphoton(0),
   fTFpiong(0),
   fTFkaong(0),
@@ -178,6 +197,7 @@ AliPHOSPIDv1::AliPHOSPIDv1(const AliPHOSPIDv1 & pid ) :
   fPPi0(0),
   fRecParticlesInRun(0),
   fParameters(0),
+  fVtx(0.), 
   fTFphoton(0),
   fTFpiong(0),
   fTFkaong(0),
@@ -215,6 +235,7 @@ AliPHOSPIDv1::AliPHOSPIDv1(const TString alirunFileName, const TString eventFold
   fPPi0(0),
   fRecParticlesInRun(0),
   fParameters(0),
+  fVtx(0.), 
   fTFphoton(0),
   fTFpiong(0),
   fTFkaong(0),
@@ -896,11 +917,6 @@ TVector3 AliPHOSPIDv1::GetMomentumDirection(AliPHOSEmcRecPoint * emc, AliPHOSCpv
   //  However because of the poor position resolution of PPSD the direction is always taken as if we were 
   //  in case 1.
 
-  TVector3 dir(0,0,0) ; 
-  TMatrixF  dummy ;
-  
-  emc->GetGlobalPosition(dir, dummy) ;
-
   TVector3 local ; 
   emc->GetLocalPosition(local) ;
 
@@ -925,22 +941,23 @@ TVector3 AliPHOSPIDv1::GetMomentumDirection(AliPHOSEmcRecPoint * emc, AliPHOSCpv
   }
   else{
     AliError("Cluster with zero energy \n");
-  } 
+  }
   //Apply Real vertex
   phosgeom->GetIncidentVector(fVtx,emc->GetPHOSMod(),x,z,vInc) ;
   Float_t depthx = 0.;
   Float_t depthz = 0.;
   if (energy > 0 && vInc.Y()!=0.) {
-    depthx = ( para * TMath::Log(energy) + parb ) * vInc.X()/vInc.Y() ;
-    depthz = ( para * TMath::Log(energy) + parb ) * vInc.Z()/vInc.Y() ;
+    depthx = ( para * TMath::Log(energy) + parb ) * vInc.X()/TMath::Abs(vInc.Y()) ;
+    depthz = ( para * TMath::Log(energy) + parb ) * vInc.Z()/TMath::Abs(vInc.Y()) ;
   }
 
-  dir.SetXYZ(dir.X()-(depthxOld-depthx)*TMath::Sin(dir.Phi()),
-             dir.Y()-(depthxOld-depthx)*TMath::Cos(dir.Phi()),
-             dir.Z()+depthzOld-depthz) ;
+  //Correct for the vertex position and shower depth
+  Double_t xd=x+(depthxOld-depthx) ;
+  Double_t zd=z+(depthzOld-depthz) ; 
+  TVector3 dir(0,0,0) ; 
+  phosgeom->Local2Global(emc->GetPHOSMod(),xd,zd,dir) ;
 
-  //Correct for the vertex position
-  dir = dir - fVtx ;
+  dir-=fVtx ;
   dir.SetMag(1.) ;
 
   return dir ;  
@@ -1500,7 +1517,7 @@ void  AliPHOSPIDv1::MakeRecParticles()
     AliPHOSTrackSegment * ts  = gime->TrackSegment(rp->GetPHOSTSIndex()) ; 
     AliPHOSEmcRecPoint  * erp = gime->EmcRecPoint(ts->GetEmcIndex()) ; 
     TVector3 pos ; 
-    geom->GetGlobal(erp, pos) ; 
+    geom->GetGlobalPHOS(erp, pos) ; 
     rp->SetPos(pos);
     index++ ; 
   }
@@ -1747,11 +1764,18 @@ void AliPHOSPIDv1::GetVertex(void)
   //Try to extract vertex from data
   if(fESD){
     const AliESDVertex *esdVtx = fESD->GetVertex() ;
-    if(esdVtx){
+    if(esdVtx && esdVtx->GetChi2()!=0.){
       fVtx.SetXYZ(esdVtx->GetXv(),esdVtx->GetYv(),esdVtx->GetZv()) ;
       return ;
     }
   }
+  if(gAlice && gAlice->GetHeader() && gAlice->GetHeader()->GenEventHeader()){
+     AliGenEventHeader *eh = gAlice->GetHeader()->GenEventHeader() ;
+     TArrayF ftx ;
+     eh->PrimaryVertex(ftx);
+     fVtx.SetXYZ(ftx[0],ftx[1],ftx[2]) ;
+     return ;
+  }
  
   AliWarning("Can not read vertex from data, use fixed \n") ;
   fVtx.SetXYZ(0.,0.,0.) ;