]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALv1.cxx
putting sampling fraction inside the hit making and updating digitization parameters
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALv1.cxx
index 0540291af51dc8972c6ba345bbf18a5888b3e8b7..5a9f82b699d1a1fbf21aa2d316e5c92e96fddaec 100644 (file)
 /* $Id$ */
 
 //_________________________________________________________________________
-// Implementation version v1 of EMCAL Manager class 
-// An object of this class does not produce digits
-// It is the one to use if you do want to produce outputs in TREEH 
-//                  
+//*-- Implementation version v1 of EMCAL Manager class 
+//*-- An object of this class does not produce digits
+//*-- It is the one to use if you do want to produce outputs in TREEH 
+//*--                  
 //*-- Author: Sahal Yacoob (LBL /UCT)
 //*--       : Jennifer Klay (LBL)
-
 // This Class not stores information on all particles prior to EMCAL entry - in order to facilitate analysis.
 // This is done by setting fIShunt =2, and flagging all parents of particles entering the EMCAL.
 
 //  2. Timing signal is collected and added to hit
 
 // --- ROOT system ---
-#include "TPGON.h"
-#include "TTUBS.h"
-#include "TNode.h"
-#include "TRandom.h"
-#include "TTree.h"
-#include "TGeometry.h"
 #include "TParticle.h"
 #include "TVirtualMC.h"
 
 // --- Standard library ---
 
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <Rstrstream.h>
-#include <Riostream.h>
-#include <math.h>
-
 // --- AliRoot header files ---
-
 #include "AliEMCALv1.h"
 #include "AliEMCALHit.h"
 #include "AliEMCALGeometry.h"
-#include "AliConst.h"
 #include "AliRun.h"
 #include "AliMC.h"
 
@@ -93,7 +77,7 @@ AliEMCALv1::~AliEMCALv1(){
 void AliEMCALv1::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t iparent, Float_t ienergy, 
                        Int_t id, Float_t * hits,Float_t * p){
     // Add a hit to the hit list.
-    // An EMCAL hit is the sum of all hits in a tower section (PRE, ECAL, HCAL) 
+    // An EMCAL hit is the sum of all hits in a tower section
     //   originating from the same entering particle 
     Int_t hitCounter;
     
@@ -102,7 +86,7 @@ void AliEMCALv1::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t ipa
     Bool_t deja = kFALSE;
 
     newHit = new AliEMCALHit(shunt, primary, tracknumber, iparent, ienergy, id, hits, p);
-    for ( hitCounter = fNhits-1; hitCounter >= 0 && !deja; hitCounter-- ) {
+     for ( hitCounter = fNhits-1; hitCounter >= 0 && !deja; hitCounter-- ) {
        curHit = (AliEMCALHit*) (*fHits)[hitCounter];
        // We add hits with the same tracknumber, while GEANT treats
        // primaries succesively
@@ -111,9 +95,9 @@ void AliEMCALv1::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t ipa
        if( *curHit == *newHit ) {
            *curHit = *curHit + *newHit;
            deja = kTRUE;
-       } // end if
+           } // end if
     } // end for hitCounter
-
+    
     if ( !deja ) {
        new((*fHits)[fNhits]) AliEMCALHit(*newHit);
        fNhits++;
@@ -123,10 +107,9 @@ void AliEMCALv1::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t ipa
 }
 //______________________________________________________________________
 void AliEMCALv1::StepManager(void){
-  // Accumulates hits as long as the track stays in a single
-  // crystal or PPSD gas Cell
+  // Accumulates hits as long as the track stays in a tower
 
-  Int_t          id[2];           // (layer, phi, Eta) indices
+  Int_t          id[2];           // (phi, Eta) indices
   // position wrt MRS and energy deposited
   Float_t        xyzte[5]={0.,0.,0.,0.,0.};// position wrt MRS, time and energy deposited
   Float_t        pmom[4]={0.,0.,0.,0.};
@@ -166,6 +149,9 @@ void AliEMCALv1::StepManager(void){
     
     if( (depositedEnergy = gMC->Edep()) > 0.){// Track is inside a scintillator and deposits some energy
      
+      // use sampling fraction to get original energy --HG
+      depositedEnergy = depositedEnergy * geom->GetSampling();
+
       gMC->TrackPosition(pos);
       xyzte[0] = pos[0];
       xyzte[1] = pos[1];
@@ -183,27 +169,21 @@ void AliEMCALv1::StepManager(void){
       
       Int_t tower = (id[0]-1) % geom->GetNZ() + 1 + (id[1] - 1) * geom->GetNZ() ;  
       Int_t layer = static_cast<Int_t>((id[0]-1)/(geom->GetNZ())) + 1 ; 
-      Int_t absid = tower ; 
-      if (layer <= geom->GetNPRLayers() )
-       absid += geom->GetNZ() * geom->GetNPhi() ;
-      else if (layer > geom->GetNECLayers() )
-       absid += 2 * geom->GetNZ() * geom->GetNPhi() ;
-      else {
-       Int_t nlayers = geom->GetNPRLayers()+ geom->GetNECLayers()+ geom->GetNHCLayers() ;
-       if (layer > nlayers) 
-         Fatal("StepManager", "Wrong calculation of layer number: layer = %d > %d\n", layer, nlayers) ;
-      }
+      Int_t absid = tower; 
+      Int_t nlayers = geom->GetNECLayers();
+      if ((layer > nlayers)||(layer<1)) 
+        Fatal("StepManager", "Wrong calculation of layer number: layer = %d > %d\n", layer, nlayers) ;
+
        
       Float_t lightYield =  depositedEnergy ;
-                                            ;
       xyzte[4] = lightYield  ;
    
       primary = gAlice->GetMCApp()->GetPrimary(tracknumber);
 
       if (gDebug == 2) 
-       Info("StepManager", "id0 = %d, id1 = %d, absid = %d tower = %d layer = %d energy = %f\n", id[0], id[1], absid, tower, layer, xyzte[4]) ;
+       printf("StepManager: id0 = %d, id1 = %d, absid = %d tower = %d layer = %d energy = %f\n", id[0], id[1], absid, tower, layer, xyzte[4]) ;
 
-      AddHit(fIshunt, primary,tracknumber, iparent, ienergy, absid, xyzte, pmom);
+      AddHit(fIshunt, primary,tracknumber, iparent, ienergy, absid,  xyzte, pmom);
     } // there is deposited energy
   }
 }