#include "LCDCalHit.h"
#include <iostream.h>
#include "LCDMcPart.h"

///////////////////////////////////////////////////////////////////////////
//                                                                       
// LCDCalHit                                                                
// The LCDCalHit class contains the information about a single calorimeter  
// tower. This includes the towerID tag, the total energy in the tower,  
// and the list of particles which deposited energy in the tower and how 
// much energy they deposited.                                           
//                                                                       
///////////////////////////////////////////////////////////////////////////

ClassImp(LCDCalHit)

Float_t* LCDCalHit::energyScale = 0;
Float_t* LCDCalHit::phiSeg      = 0;
Float_t* LCDCalHit::ThetaSeg    = 0;

Float_t* LCDCalHit::barrelThick = 0;
Float_t* LCDCalHit::endcapThick = 0;
Float_t* LCDCalHit::barrelInner = 0;
Float_t* LCDCalHit::endcapInner = 0;

Int_t LCDCalHit::sys2det[]={-1,-1,-1,-1,
			    -1,+3,-1,-1,
			    -1,-1,+0,+0,
			    +1,+1,+2,+2};

//_________________________________________________________________________
//Double_t LCDCalHit::AddE(Double_t hit){
//  // Function to increment the total energy in the tower 
//  // and return the new total
//  m_Etot += hit;
//  return m_Etot;
//}
//_________________________________________________________________________

//_________________________________________________________________________
 void LCDCalHit::AddHit(Int_t mcindex, Double_t edep){
  // Add a hit to the list
  //  AddE(EDep->GetEDeposit());
  if (m_nMCE > 49) {
    fprintf(stderr,"LCDCalHit::AddHit m_nMCE exceeds 49! m_nMCE=%dn",m_nMCE);
  } else {
    //m_Etot += edep;
    m_MCE[m_nMCE].SetPart(mcindex);
    m_MCE[m_nMCE].SetEDeposit(edep);
    m_nMCE++;
  }
}
//_________________________________________________________________________

//_________________________________________________________________________
 Double_t LCDCalHit::GetEtotMCE(){
  // Function to increment the total energy in the tower 
  // and return the new total
  Double_t e=0;
  for (Int_t imc=0 ; imc < m_nMCE ; imc++) {
    e+=m_MCE[imc].GetEDeposit();
  }
  return e;
}
//_________________________________________________________________________

//_________________________________________________________________________
 Double_t LCDCalHit::GetEscale(){
  // get energy scale factor
  Int_t t_system = m_tower.GetSystem();
  return *(energyScale+sys2det[t_system]);
  //return energyScale[m_tower->system()];
  
}
//_________________________________________________________________________

//_________________________________________________________________________
 Double_t LCDCalHit::GetThetaSeg(){
  // get segementation in theta
  Int_t t_system = m_tower.GetSystem();
  return *(ThetaSeg+sys2det[t_system]);
  //	return ThetaSeg[m_tower->system()];
}
//_________________________________________________________________________

//_________________________________________________________________________
 Double_t LCDCalHit::GetPhiSeg(){
  // get segementation in phi
  Int_t t_system = m_tower.GetSystem();
  return *(phiSeg+sys2det[t_system]);
  //return phiSeg[m_tower->system()];
}
//_________________________________________________________________________

//_________________________________________________________________________
 Double_t LCDCalHit::GetR(){
  // Get IP to Hit distance. This is not cylindrical R.
  Int_t endbarrel = m_tower.GetBarrelEndcap();
  Int_t layer     = m_tower.GetLayer();
  Double_t   r;  
  Double_t theta  = GetTheta();
  
  Int_t t_system = m_tower.GetSystem();
  
  if (endbarrel == 0 ) { // barrel
    r = *(barrelInner+sys2det[t_system]) + 
      (layer+0.5) * (*(barrelThick+sys2det[t_system]));
    //r = barrelInner[m_tower->t_system()] +
    //     (layer + 0.5) * barrelThick[m_tower->t_system()];
    return  TMath::Abs( r / TMath::Sin(theta) );
  } else if (endbarrel == 1 ) { // endcap
    r = *(endcapInner+sys2det[t_system]) + 
      (layer+0.5) * (*(endcapThick+sys2det[t_system]));
    // r = endcapInner[m_tower->t_system()] +
    //     (layer + 0.5) * endcapThick[m_tower->t_system()];
    return  TMath::Abs( r / TMath::Cos(theta) );
  } else {
    printf(" Strange section!! Not barrel, nor endcap. %i n" ,
	   endbarrel );   
    return 0. ;
  }
}
//_________________________________________________________________________

//_________________________________________________________________________
 Double_t LCDCalHit::GetRcyl(){
  // This is cylindrical R.
  Int_t endbarrel = m_tower.GetBarrelEndcap();
  Int_t layer     = m_tower.GetLayer();
  Double_t   r;  
  
  Int_t t_system = m_tower.GetSystem();
  
  if (endbarrel == 0 ) { // barrel
    r = *(barrelInner+sys2det[t_system]) + 
      (layer+0.5) * (*(barrelThick+sys2det[t_system]));
    //r = barrelInner[m_tower->t_system()] +
    //     (layer + 0.5) * barrelThick[m_tower->t_system()];
    return  r;
  } else if (endbarrel == 1 ) { // endcap
    r = *(endcapInner+sys2det[t_system]) + 
      (layer+0.5) * (*(endcapThick+sys2det[t_system]));
    // r = endcapInner[m_tower->t_system()] +
    //     (layer + 0.5) * endcapThick[m_tower->t_system()];
    return  r;
  } else {
    printf(" Strange section!! Not barrel, nor endcap. %i n" ,
	   endbarrel );   
    return 0. ;
  }
}
//_________________________________________________________________________



ROOT page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.