]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSv4.cxx
position of the particle initiating the hit in PHOS
[u/mrichter/AliRoot.git] / PHOS / AliPHOSv4.cxx
index 50de8350a11549c3d6a17804277642b8d49ce0ed..7892b9ecf8b1f41dd9fdffe0987db607080d2b02 100644 (file)
@@ -29,6 +29,9 @@
 #include "TBRIK.h"
 #include "TNode.h"
 #include "TParticle.h"
+#include "TTree.h"
+#include "TGeometry.h"
+#include "TFile.h"
 
 // --- Standard library ---
 
@@ -39,6 +42,7 @@
 #include "AliPHOSv4.h"
 #include "AliRun.h"
 #include "AliConst.h"
+#include "AliMC.h"
 
 ClassImp(AliPHOSv4)
 
@@ -49,19 +53,17 @@ AliPHOSv4::AliPHOSv4(const char *name, const char *title):
   // ctor
 
   // gets an instance of the geometry parameters class  
-   
-  fGeom =  AliPHOSGeometry::GetInstance(title, "") ; 
-
-  if (fGeom != 0 ) {
-    cout << "AliPHOSv4 : PHOS geometry intialized for " << fGeom->GetName() << endl ;
+  if (strcmp(GetTitle(),"") != 0 ) 
+    fGeom =  AliPHOSGeometry::GetInstance(GetTitle(), "") ; 
+     
     
     SetBigBox(0, fGeom->GetOuterBoxSize(0) ) ;
-    SetBigBox(1, fGeom->GetOuterBoxSize(1) + fGeom->GetPPSDBoxSize(1) ) ; 
+    SetBigBox(1, fGeom->GetOuterBoxSize(1) + fGeom->GetCPVBoxSize(1) ) ; 
     SetBigBox(2, fGeom->GetOuterBoxSize(0) ); 
     
     fNRecParticles = 0 ; 
     fFastRecParticles = new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100) ;
-    
+
     fResPara1 = 0.030 ;    // GeV
     fResPara2 = 0.00003 ; 
     fResPara3 = 0.00001 ; 
@@ -71,9 +73,6 @@ AliPHOSv4::AliPHOSv4(const char *name, const char *title):
     fPosParaB0 = 0.257 ;   
     fPosParaB1 = 0.137 ; 
     fPosParaB2 = 0.00619 ; 
-  }
-  else
-    cout << "AliPHOSv4 : PHOS geometry initialization failed !" << endl ;   
 }
 
 //____________________________________________________________________________
@@ -240,18 +239,19 @@ Float_t AliPHOSv4::GetBigBox(Int_t index)
 }
 
 //___________________________________________________________________________
-void AliPHOSv4::MakeBranch(Option_t* opt)
+void AliPHOSv4::MakeBranch(Option_t* opt, char *file)
 {  
   // Create new branch in the current reconstructed Root Tree
  
-  AliDetector::MakeBranch(opt) ;
+  AliDetector::MakeBranch(opt,file) ;
   
   char branchname[10];
   sprintf(branchname,"%s",GetName());
   char *cd = strstr(opt,"R");
   
   if (fFastRecParticles && gAlice->TreeR() && cd) {
-    gAlice->TreeR()->Branch(branchname, &fFastRecParticles, fBufferSize);
+    gAlice->MakeBranchInTree(gAlice->TreeR(), 
+                             branchname, &fFastRecParticles, fBufferSize, file) ;
   }
 }
 
@@ -462,30 +462,40 @@ Double_t AliPHOSv4::SigmaP(Double_t energy, Int_t incidence)
 void AliPHOSv4::StepManager(void)
 {
   // Only verifies if the particle reaches PHOS and stops the tracking 
-  
+
   Int_t primary =  gAlice->GetPrimary( gAlice->CurrentTrack() ); 
+
   TLorentzVector lv ; 
   gMC->TrackPosition(lv) ;
   TVector3 pos = lv.Vect() ; 
   Int_t modid  ; 
   gMC->CurrentVolID(modid);
   
-  // Makes a reconstructed particle from the primary particle
+  Float_t energy = gMC->Etot() ; //Total energy of current track
 
-  TClonesArray * particlelist = gAlice->Particles() ;
-  TParticle * part = (TParticle *)particlelist->At(primary) ;  
+  //Calculating mass of current particle
+  TDatabasePDG * pdg = TDatabasePDG::Instance() ;
+  TParticlePDG * partPDG = pdg->GetParticle(gMC->TrackPid()) ;
+  Float_t mass = partPDG->Mass() ;
 
-  AliPHOSFastRecParticle rp(*part) ;
-  rp.SetPrimary(primary) ; 
+  if(energy > mass){
+    pos.SetMag(TMath::Sqrt(energy*energy-mass*mass)) ;
+    TLorentzVector pTrack(pos, energy) ;  
 
-  // Adds the response of PHOS to the particle
+    TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv)  ;
+        
+    AliPHOSFastRecParticle rp(*part) ;
+    rp.SetPrimary(primary) ; 
 
-  MakeRecParticle(modid, pos, rp) ;
-  
-  // add the primary particle to the FastRecParticles list
+    // Adds the response of PHOS to the particle
+    MakeRecParticle(modid, pos, rp) ;
+    
+    // add the `track' particle to the FastRecParticles list
   
-  AddRecParticle(rp) ;
+    AddRecParticle(rp) ;
 
+    part->Delete() ;
+  }
   // stop the track as soon PHOS is reached
   
   gMC->StopTrack() ;