]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSDebug.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / PHOS / AliPHOSDebug.cxx
index 535aa4976cd05aa394b61a45f9ae093872b53833..eeb4c6de49d1453cda4977b57757f521cc9993ee 100644 (file)
 //_________________________________________________________________________
 // Implementation version v1 of PHOS Manager class 
 //---
-// Layout EMC + PPSD has name GPS2:
-// Produces cumulated hits
-//---
 // Layout EMC + CPV  has name IHEP:
 // Produces hits for CPV, cumulated hits
 //---
-// Layout EMC + CPV + PPSD has name GPS:
-// Produces hits for CPV, cumulated hits
-//---
 //*-- Author: Yves Schutz (SUBATECH)
 
 
 // --- ROOT system ---
 
-#include "TBRIK.h"
-#include "TNode.h"
 #include "TRandom.h"
 #include "TTree.h"
 
 #include "AliPHOSv1.h"
 #include "AliPHOSHit.h"
 #include "AliPHOSDigit.h"
-#include "AliPHOSReconstructioner.h"
+#include "AliPHOSReconstructor.h"
 #include "AliRun.h"
 #include "AliConst.h"
-#include "AliMC.h"
 
 ClassImp(AliPHOSv1)
 
@@ -73,9 +64,7 @@ AliPHOSv1::AliPHOSv1(const char *name, const char *title):
 AliPHOSv0(name,title) 
 {
   // ctor : title is used to identify the layout
-  //        GPS2 = 5 modules (EMC + PPSD)
   //        IHEP = 5 modules (EMC + CPV )
-  //        MIXT = 4 modules (EMC + CPV ) and 1 module (EMC + PPSD)
   //
   // We store hits :
   //   - fHits (the "normal" one), which retains the hits associated with
@@ -106,11 +95,10 @@ AliPHOSv0(name,title)
 }
 
 //____________________________________________________________________________
-AliPHOSv1::AliPHOSv1(AliPHOSReconstructioner * Reconstructioner, const char *name, const char *title):
+AliPHOSv1::AliPHOSv1(AliPHOSReconstructor * Reconstructioner, const char *name, const char *title):
   AliPHOSv0(name,title)
 {
   // ctor : title is used to identify the layout
-  //        GPS2 = 5 modules (EMC + PPSD)   
 
   fPinElectronicNoise = 0.010 ;
 
@@ -124,12 +112,12 @@ AliPHOSv1::AliPHOSv1(AliPHOSReconstructioner * Reconstructioner, const char *nam
   fIshunt     =  1 ; // All hits are associated with primary particles
  
   // gets an instance of the geometry parameters class  
-  fGeom =  AliPHOSGeometry::GetInstance(title, "") ; 
+  AliPHOSGeometry::GetInstance(title, "") ; 
 
-  if (fGeom->IsInitialized() ) 
-    cout << "AliPHOS" << Version() << " : PHOS geometry intialized for " << fGeom->GetName() << endl ;
+  if (GetGeometry()->IsInitialized() ) 
+    Info("AliPHOSv1", "AliPHOS %d : PHOS geometry intialized for %s", Version(), GetGeometry()->GetName() );
   else
-    cout << "AliPHOS" << Version() << " : PHOS geometry initialization failed !" << endl ;   
+    Info("AliPHOSv1", "AliPHOS %d : PHOS geometry initialization failed !", Version() ) ;   
 
   // Defining the PHOS Reconstructioner
  
@@ -211,8 +199,10 @@ void AliPHOSv1::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t Id,
 }
 
 //____________________________________________________________________________
-void AliPHOSv1::Hits2SDigits(){
-  //Collects all hits in the same active volume into digit
+void AliPHOSv1::Hits2SDigits()
+{
+  // Collects all hits in the same active volume into digit
+  // OBSOLETE replace by SDigitizer
 
   Int_t i ;
   Int_t j ; 
@@ -226,8 +216,13 @@ void AliPHOSv1::Hits2SDigits(){
   for (itrack=0; itrack<gAlice->GetNtrack(); itrack++){
         
     //=========== Get the Hits Tree for the Primary track itrack
-    gAlice->ResetHits();    
-    gAlice->TreeH()->GetEvent(itrack);
+    gAlice->ResetHits();
+    if (TreeH() == 0x0)
+     {
+       Error("Hits2SDigits","Can not find TreeH in the folder");
+       return;
+     }
+    TreeH()->GetEvent(itrack);
       
 
     for ( i = 0 ; i < fHits->GetEntries() ; i++ ) {
@@ -274,10 +269,11 @@ void AliPHOSv1::Hits2SDigits(){
 
 }
 //____________________________________________________________________________
-void AliPHOSv1::SDigits2Digits(){
-  //Adds noise to the summable digits and removes everething below thresholds
-  //Note, that sDigits should be SORTED in accordance with abs ID.
-
+void AliPHOSv1::SDigits2Digits()
+{
+  // Adds noise to the summable digits and removes everething below thresholds
+  // Note, that sDigits should be SORTED in accordance with abs ID.
+  // OBSOLETE Replaced by Digitzer
 
   gAlice->TreeS()->GetEvent(0) ;
 
@@ -286,14 +282,14 @@ void AliPHOSv1::SDigits2Digits(){
 
   //we assume, that there is al least one EMC digit...
   if(fSDigits->GetEntries() == 0) {
-    cout << "PHOS::SDigits2Digits>  No SDigits !!! Do not produce Digits " << endl ;
+    Warning("SDigits2Digits", "No SDigits !!! Do not produce Digits ") ;
     return ;
   }
 
   Int_t idCurSDigit = ((AliPHOSDigit *)fSDigits->At(0))->GetId() ;
 
   Int_t absID ;
-  for(absID = 1; absID < fGeom->GetNModules()*fGeom->GetNPhi()*fGeom->GetNZ(); absID++){
+  for(absID = 1; absID < GetGeometry()->GetNModules()*GetGeometry()->GetNPhi()*GetGeometry()->GetNZ(); absID++){
     Float_t noise = gRandom->Gaus(0., fPinElectronicNoise) ; 
     if(absID < idCurSDigit ){ 
       if(noise >fDigitThreshold ){
@@ -328,8 +324,8 @@ void AliPHOSv1::SDigits2Digits(){
     Float_t ene = Calibrate(digit->GetAmp()) ;
     
     Int_t relid[4] ; 
-    fGeom->AbsToRelNumbering(digit->GetId(), relid) ; 
-    if ( relid[0] > fGeom->GetNCPVModules() ){ //ppsd
+    GetGeometry()->AbsToRelNumbering(digit->GetId(), relid) ; 
+    if ( relid[0] > GetGeometry()->GetNCPVModules() ){ //ppsd
       if ( ( (relid[1] > 0) && (ene > fPpsdEnergyThreshold)) ||    //PPSD digit
           ( (relid[1] < 0) && (ene > fCpvEnergyThreshold ) ) )    //CPV digit 
        new((*fDigits)[fNdigits]) AliPHOSDigit( *digit ) ;
@@ -357,6 +353,7 @@ void AliPHOSv1::SDigits2Digits(){
 //___________________________________________________________________________
 void AliPHOSv1::MakeBranch(Option_t* opt, char *file)
 { 
+  // Called by AliRun
 
   char *cH ; 
   // Create new branche in the current Root Tree in the digit Tree
@@ -431,7 +428,7 @@ void AliPHOSv1::MakeBranch(Option_t* opt, char *file)
 }
 
 //_____________________________________________________________________________
-void AliPHOSv1::Reconstruction(AliPHOSReconstructioner * Reconstructioner)
+void AliPHOSv1::Reconstruction(AliPHOSReconstructor * Reconstructioner)
 { 
   // 1. Reinitializes the existing RecPoint, TrackSegment, and RecParticles Lists and 
   // 2. Creates TreeR with a branch for each list
@@ -508,87 +505,55 @@ void AliPHOSv1::StepManager(void)
   Bool_t         entered = kFALSE ;  
   Int_t          copy     ;
 
-  Int_t tracknumber =  gAlice->CurrentTrack() ; 
-  Int_t primary     =  gAlice->GetPrimary( gAlice->CurrentTrack() ); 
-  TString name      =  fGeom->GetName() ; 
+  Int_t tracknumber =  gAlice->GetCurrentTrackNumber() ; 
+  Int_t primary     =  gAlice->GetPrimary( gAlice->GetCurrentTrackNumber() ); 
+  TString name      =  GetGeometry()->GetName() ; 
   Int_t trackpid    =  0  ; 
 
-  if( gMC->IsTrackEntering() ){ // create hit with position and momentum of new particle, 
+  if( TVirtualMC::GetMC()->IsTrackEntering() ){ // create hit with position and momentum of new particle, 
                                 // but may be without energy deposition
 
     // Current position of the hit in the local ref. system
-      gMC -> TrackPosition(pos);
+      TVirtualMC::GetMC() -> TrackPosition(pos);
       Float_t xyzm[3], xyzd[3] ;
       Int_t i;
       for (i=0; i<3; i++) xyzm[i] = pos[i];
-      gMC -> Gmtod (xyzm, xyzd, 1);    // transform coordinate from master to daughter system
+      TVirtualMC::GetMC() -> Gmtod (xyzm, xyzd, 1);    // transform coordinate from master to daughter system
       xyd[0]  = xyzd[0];
       xyd[1]  =-xyzd[1];
       xyd[2]  =-xyzd[2];
 
       
       // Current momentum of the hit's track in the local ref. system
-      gMC -> TrackMomentum(pmom);
+      TVirtualMC::GetMC() -> TrackMomentum(pmom);
       Float_t pm[3], pd[3];
       for (i=0; i<3; i++) pm[i]   = pmom[i];
-      gMC -> Gmtod (pm, pd, 2);        // transform 3-momentum from master to daughter system
+      TVirtualMC::GetMC() -> Gmtod (pm, pd, 2);        // transform 3-momentum from master to daughter system
       pmom[0] = pd[0];
       pmom[1] =-pd[1];
       pmom[2] =-pd[2];
 
-      trackpid = gMC->TrackPid();
+      trackpid = TVirtualMC::GetMC()->TrackPid();
       entered = kTRUE ;      // Mark to create hit even withou energy deposition
 
   }
 
 
-  if ( name == "GPS2" || name == "MIXT" ) {            // ======> CPV is a GPS' PPSD
-
-    if( gMC->CurrentVolID(copy) == gMC->VolId("PCEL") ) // We are inside a gas cell 
-    {
-      gMC->TrackPosition(pos) ;
-      xyze[0] = pos[0] ;
-      xyze[1] = pos[1] ;
-      xyze[2] = pos[2] ;
-      xyze[3] = gMC->Edep() ; 
-
-      if ( (xyze[3] != 0) || entered ) { // there is deposited energy or new particle entering  PPSD
-               gMC->CurrentVolOffID(5, relid[0]) ;  // get the PHOS Module number
-       if ( name == "MIXT" && strcmp(gMC->CurrentVolOffName(5),"PHO1") == 0 ){
-         relid[0] += fGeom->GetNModules() - fGeom->GetNPPSDModules();
-       }
-               gMC->CurrentVolOffID(3, relid[1]) ;  // get the Micromegas Module number 
-      // 1-> fGeom->GetNumberOfModulesPhi() * fGeom->GetNumberOfModulesZ() upper
-      //   > fGeom->GetNumberOfModulesPhi() * fGeom->GetNumberOfModulesZ() lower
-               gMC->CurrentVolOffID(1, relid[2]) ;  // get the row number of the cell
-        gMC->CurrentVolID(relid[3]) ;        // get the column number 
-
-       // get the absolute Id number
-
-               fGeom->RelToAbsNumbering(relid, absid) ; 
-
-       // add current hit to the hit list      
-         AddHit(fIshunt, primary, tracknumber, absid, xyze, trackpid, pmom, xyd);
-
-
-      } // there is deposited energy 
-    } // We are inside the gas of the CPV  
-  } // GPS2 configuration
-
-  if ( name == "IHEP" || name == "MIXT" ) {       // ======> CPV is a IHEP's one
+  if ( name == "IHEP" ) {       // ======> CPV is a IHEP's one
 
     // Yuri Kharlov, 28 September 2000
 
-    if( gMC->CurrentVolID(copy) == gMC->VolId("PCPQ") &&
+    static Int_t idPCPQ = TVirtualMC::GetMC()->VolId("PCPQ");
+    if( TVirtualMC::GetMC()->CurrentVolID(copy) == idPCPQ &&
        entered &&
-       gMC->TrackCharge() != 0) {      
+       TVirtualMC::GetMC()->TrackCharge() != 0) {      
       
       // Digitize the current CPV hit:
 
       // 1. find pad response and
       
       Int_t moduleNumber;
-      gMC->CurrentVolOffID(3,moduleNumber);
+      TVirtualMC::GetMC()->CurrentVolOffID(3,moduleNumber);
       moduleNumber--;
 
 
@@ -631,7 +596,7 @@ void AliPHOSv1::StepManager(void)
        relid[3] = cpvDigit->GetYpad() ;                          // row    number of a pad
        
        // get the absolute Id number
-       fGeom->RelToAbsNumbering(relid, absid) ; 
+       GetGeometry()->RelToAbsNumbering(relid, absid) ; 
 
        // add current digit to the temporary hit list
        xyze[0] = 0. ;
@@ -652,27 +617,24 @@ void AliPHOSv1::StepManager(void)
   } // end of IHEP configuration
   
 
-  if(gMC->CurrentVolID(copy) == gMC->VolId("PXTL") ) { //  We are inside a PBWO crystal
-    gMC->TrackPosition(pos) ;
+  if(TVirtualMC::GetMC()->CurrentVolID(copy) == TVirtualMC::GetMC()->VolId("PXTL") ) { //  We are inside a PBWO crystal
+    TVirtualMC::GetMC()->TrackPosition(pos) ;
     xyze[0] = pos[0] ;
     xyze[1] = pos[1] ;
     xyze[2] = pos[2] ;
-    xyze[3] = gMC->Edep() ;
+    xyze[3] = TVirtualMC::GetMC()->Edep() ;
 
   
     if ( (xyze[3] != 0) || entered ) {  // Track is inside the crystal and deposits some energy or just entered 
 
-      gMC->CurrentVolOffID(10, relid[0]) ; // get the PHOS module number ;
-
-      if ( name == "MIXT" && strcmp(gMC->CurrentVolOffName(10),"PHO1") == 0 )
-       relid[0] += fGeom->GetNModules() - fGeom->GetNPPSDModules();      
+      TVirtualMC::GetMC()->CurrentVolOffID(10, relid[0]) ; // get the PHOS module number ;
 
       relid[1] = 0   ;                    // means PBW04
-      gMC->CurrentVolOffID(4, relid[2]) ; // get the row number inside the module
-      gMC->CurrentVolOffID(3, relid[3]) ; // get the cell number inside the module
+      TVirtualMC::GetMC()->CurrentVolOffID(4, relid[2]) ; // get the row number inside the module
+      TVirtualMC::GetMC()->CurrentVolOffID(3, relid[3]) ; // get the cell number inside the module
       
       // get the absolute Id number
-      fGeom->RelToAbsNumbering(relid, absid) ; 
+      GetGeometry()->RelToAbsNumbering(relid, absid) ; 
 
       // add current hit to the hit list
        AddHit(fIshunt, primary,tracknumber, absid, xyze, trackpid,pmom, xyd);
@@ -697,7 +659,7 @@ void AliPHOSv1::CPVDigitize (TLorentzVector p, Float_t *zxhit, Int_t moduleNumbe
   // 2 October 2000
   // ------------------------------------------------------------------------
 
-  const Float_t kCelWr  = fGeom->GetPadSizePhi()/2;  // Distance between wires (2 wires above 1 pad)
+  const Float_t kCelWr  = GetGeometry()->GetPadSizePhi()/2;  // Distance between wires (2 wires above 1 pad)
   const Float_t kDetR   = 0.1;     // Relative energy fluctuation in track for 100 e-
   const Float_t kdEdx   = 4.0;     // Average energy loss in CPV;
   const Int_t   kNgamz  = 5;       // Ionization size in Z
@@ -718,15 +680,13 @@ void AliPHOSv1::CPVDigitize (TLorentzVector p, Float_t *zxhit, Int_t moduleNumbe
   Float_t pNorm = p.Py();
   Float_t eloss = kdEdx;
 
-//    cout << "CPVDigitize: YVK : "<<hitX<<" "<<hitZ<<" | "<<pX<<" "<<pZ<<" "<<pNorm<<endl;
-
-  Float_t dZY   = pZ/pNorm * fGeom->GetCPVGasThickness();
-  Float_t dXY   = pX/pNorm * fGeom->GetCPVGasThickness();
+  Float_t dZY   = pZ/pNorm * GetGeometry()->GetCPVGasThickness();
+  Float_t dXY   = pX/pNorm * GetGeometry()->GetCPVGasThickness();
   gRandom->Rannor(rnor1,rnor2);
   eloss *= (1 + kDetR*rnor1) *
-           TMath::Sqrt((1 + ( pow(dZY,2) + pow(dXY,2) ) / pow(fGeom->GetCPVGasThickness(),2)));
-  Float_t zhit1 = hitZ + fGeom->GetCPVActiveSize(1)/2 - dZY/2;
-  Float_t xhit1 = hitX + fGeom->GetCPVActiveSize(0)/2 - dXY/2;
+           TMath::Sqrt((1 + ( pow(dZY,2) + pow(dXY,2) ) / pow(GetGeometry()->GetCPVGasThickness(),2)));
+  Float_t zhit1 = hitZ + GetGeometry()->GetCPVActiveSize(1)/2 - dZY/2;
+  Float_t xhit1 = hitX + GetGeometry()->GetCPVActiveSize(0)/2 - dXY/2;
   Float_t zhit2 = zhit1 + dZY;
   Float_t xhit2 = xhit1 + dXY;
 
@@ -786,8 +746,8 @@ void AliPHOSv1::CPVDigitize (TLorentzVector p, Float_t *zxhit, Int_t moduleNumbe
 
   // Finite size of ionization region
 
-  Int_t nCellZ  = fGeom->GetNumberOfCPVPadsZ();
-  Int_t nCellX  = fGeom->GetNumberOfCPVPadsPhi();
+  Int_t nCellZ  = GetGeometry()->GetNumberOfCPVPadsZ();
+  Int_t nCellX  = GetGeometry()->GetNumberOfCPVPadsPhi();
   Int_t nz3     = (kNgamz+1)/2;
   Int_t nx3     = (kNgamx+1)/2;
   cpvDigits->Expand(nIter*kNgamx*kNgamz);
@@ -798,8 +758,8 @@ void AliPHOSv1::CPVDigitize (TLorentzVector p, Float_t *zxhit, Int_t moduleNumbe
     Float_t zhit = zxe[0][iter];
     Float_t xhit = zxe[1][iter];
     Float_t qhit = zxe[2][iter];
-    Float_t zcell = zhit / fGeom->GetPadSizeZ();
-    Float_t xcell = xhit / fGeom->GetPadSizePhi();
+    Float_t zcell = zhit / GetGeometry()->GetPadSizeZ();
+    Float_t xcell = xhit / GetGeometry()->GetPadSizePhi();
     if ( zcell<=0      || xcell<=0 ||
         zcell>=nCellZ || xcell>=nCellX) return;
     Int_t izcell = (Int_t) zcell;
@@ -836,10 +796,10 @@ Float_t AliPHOSv1::CPVPadResponseFunction(Float_t qhit, Float_t zhit, Float_t xh
   // 3 October 2000
   // ------------------------------------------------------------------------
 
-  Double_t dz = fGeom->GetPadSizeZ()   / 2;
-  Double_t dx = fGeom->GetPadSizePhi() / 2;
-  Double_t z  = zhit * fGeom->GetPadSizeZ();
-  Double_t x  = xhit * fGeom->GetPadSizePhi();
+  Double_t dz = GetGeometry()->GetPadSizeZ()   / 2;
+  Double_t dx = GetGeometry()->GetPadSizePhi() / 2;
+  Double_t z  = zhit * GetGeometry()->GetPadSizeZ();
+  Double_t x  = xhit * GetGeometry()->GetPadSizePhi();
   Double_t amplitude = qhit *
     (CPVCumulPadResponse(z+dz,x+dx) - CPVCumulPadResponse(z+dz,x-dx) -
      CPVCumulPadResponse(z-dz,x+dx) + CPVCumulPadResponse(z-dz,x-dx));