#ifndef ALIEMCALGEOMETRY_H
#define ALIEMCALGEOMETRY_H
#include <TNamed.h>
#include <TMath.h>
#include <TArrayD.h>
#include <TVector3.h>
#include <TGeoMatrix.h>
class TBrowser ;
class TParticle ;
#include "AliEMCALEMCGeometry.h"
#include "AliEMCALGeoParams.h"
class AliEMCALShishKebabTrd1Module;
class AliLog;
class AliEMCALGeometry : public TNamed {
public:
enum fEMCSMType { kEMCAL_Standard = 0, kEMCAL_Half = 1, kEMCAL_3rd = 2, kDCAL_Standard = 3, kDCAL_Ext= 4 };
AliEMCALGeometry();
AliEMCALGeometry(const Text_t* name, const Text_t* title="",
const Text_t* mcname="", const Text_t* mctitle="");
AliEMCALGeometry(const AliEMCALGeometry & geom);
virtual ~AliEMCALGeometry(void);
AliEMCALGeometry & operator = (const AliEMCALGeometry & rvalue);
static AliEMCALGeometry * GetInstance(const Text_t* name, const Text_t* title="",
const Text_t* mcname="TGeant3", const Text_t* mctitle="") ;
static AliEMCALGeometry * GetInstance();
static Bool_t IsInitialized(void) {return AliEMCALEMCGeometry::fgInit; }
static const Char_t* GetDefaultGeometryName() {return AliEMCALEMCGeometry::fgkDefaultGeometryName;}
void CreateListOfTrd1Modules();
TList *GetShishKebabTrd1Modules() const {return fShishKebabTrd1Modules;}
AliEMCALShishKebabTrd1Module *GetShishKebabModule(Int_t neta) const;
void PrintGeometryGeoUtils();
void PrintCellIndexes(Int_t absId=0, int pri=0, const char *tit="") const ;
void PrintLocalTrd1(Int_t pri=0) const;
virtual void Browse(TBrowser* b);
virtual Bool_t IsFolder() const;
virtual Bool_t Impact(const TParticle *particle) const;
void ImpactOnEmcal(TVector3 vtx, Double_t theta, Double_t phi, Int_t & absId, TVector3 & vimpact) const;
Bool_t IsInEMCAL(Double_t x, Double_t y, Double_t z) const;
Bool_t IsInDCAL(Double_t x, Double_t y, Double_t z) const;
Int_t IsInEMCALOrDCAL(Double_t x, Double_t y, Double_t z) const;
AliEMCALEMCGeometry* GetEMCGeometry() const { return fEMCGeometry ; }
const Char_t* GetNameOfEMCALEnvelope(void) const { return fEMCGeometry->GetNameOfEMCALEnvelope() ; }
Float_t GetArm1PhiMin(void) const { return fEMCGeometry->GetArm1PhiMin() ; }
Float_t GetArm1PhiMax(void) const { return fEMCGeometry->GetArm1PhiMax() ; }
Float_t GetArm1EtaMin(void) const { return fEMCGeometry->GetArm1EtaMin() ; }
Float_t GetArm1EtaMax(void) const { return fEMCGeometry->GetArm1EtaMax() ; }
Float_t GetIPDistance(void) const { return fEMCGeometry->GetIPDistance() ; }
Float_t GetEnvelop(Int_t index) const { return fEMCGeometry->GetEnvelop(index) ; }
Float_t GetShellThickness(void) const { return fEMCGeometry->GetShellThickness() ; }
Float_t GetZLength(void) const { return fEMCGeometry->GetZLength() ; }
Float_t GetDCALInnerEdge(void) const { return fEMCGeometry->GetDCALInnerEdge() ; }
Float_t GetDCALPhiMin(void) const { return fEMCGeometry->GetDCALPhiMin() ; }
Float_t GetDCALPhiMax(void) const { return fEMCGeometry->GetDCALPhiMax() ; }
Float_t GetEMCALPhiMax(void) const { return fEMCGeometry->GetEMCALPhiMax() ; }
Int_t GetNECLayers(void) const { return fEMCGeometry->GetNECLayers() ; }
Float_t GetDCALInnerExtandedEta(void) const { return fEMCGeometry->GetDCALInnerExtandedEta() ; }
Int_t GetNZ(void) const { return fEMCGeometry->GetNZ() ; }
Int_t GetNEta(void) const { return fEMCGeometry->GetNEta() ; }
Int_t GetNPhi(void) const { return fEMCGeometry->GetNPhi() ; }
Float_t GetECPbRadThick(void) const { return fEMCGeometry->GetECPbRadThick() ; }
Float_t GetECScintThick(void) const { return fEMCGeometry->GetECScintThick() ; }
Float_t GetSampling(void) const { return fEMCGeometry->GetSampling() ; }
Int_t GetNumberOfSuperModules(void) const { return fEMCGeometry->GetNumberOfSuperModules() ; }
Float_t GetPhiGapForSuperModules(void) const { return fEMCGeometry->GetPhiGapForSuperModules(); }
Float_t GetPhiModuleSize(void) const { return fEMCGeometry->GetPhiModuleSize() ; }
Float_t GetEtaModuleSize(void) const { return fEMCGeometry->GetEtaModuleSize() ; }
Float_t GetFrontSteelStrip(void) const { return fEMCGeometry->GetFrontSteelStrip() ; }
Float_t GetLateralSteelStrip(void) const { return fEMCGeometry->GetLateralSteelStrip() ; }
Float_t GetPassiveScintThick(void) const { return fEMCGeometry->GetPassiveScintThick() ; }
Float_t GetPhiTileSize(void) const { return fEMCGeometry->GetPhiTileSize() ; }
Float_t GetEtaTileSize(void) const { return fEMCGeometry->GetEtaTileSize() ; }
Float_t GetPhiSuperModule(void) const { return fEMCGeometry->GetPhiSuperModule() ; }
Int_t GetNPhiSuperModule(void) const { return fEMCGeometry->GetNPhiSuperModule() ; }
Int_t GetNPHIdiv(void) const { return fEMCGeometry->GetNPHIdiv() ; }
Int_t GetNETAdiv(void) const { return fEMCGeometry->GetNETAdiv() ; }
Int_t GetNCells(void) const { return fEMCGeometry->GetNCells() ; }
Float_t GetLongModuleSize(void) const { return fEMCGeometry->GetLongModuleSize() ; }
Float_t GetTrd1Angle(void) const { return fEMCGeometry->GetTrd1Angle() ; }
Float_t Get2Trd1Dx2(void) const { return fEMCGeometry->Get2Trd1Dx2() ; }
Float_t GetTrd1AlFrontThick() const { return fEMCGeometry->GetTrd1AlFrontThick() ; }
Float_t GetTrd1BondPaperThick() const { return fEMCGeometry->GetTrd1BondPaperThick() ; }
Int_t GetNCellsInSupMod(void) const { return fEMCGeometry->GetNCellsInSupMod() ; }
Int_t GetNCellsInModule(void) const { return fEMCGeometry->GetNCellsInModule() ; }
Int_t GetKey110DEG(void) const { return fEMCGeometry->GetKey110DEG() ; }
Int_t GetnSupModInDCAL(void) const { return fEMCGeometry->GetnSupModInDCAL() ; }
Int_t GetILOSS(void) const { return fEMCGeometry->GetILOSS() ; }
Int_t GetIHADR(void) const { return fEMCGeometry->GetIHADR() ; }
Float_t GetDeltaEta(void) const { return fEMCGeometry->GetDeltaEta() ; }
Float_t GetDeltaPhi(void) const { return fEMCGeometry->GetDeltaPhi() ; }
Int_t GetNTowers(void) const { return fEMCGeometry->GetNTowers() ; }
Double_t GetPhiCenterOfSM(Int_t nsupmod) const { return fEMCGeometry->GetPhiCenterOfSM(nsupmod) ; }
Double_t GetPhiCenterOfSMSec(Int_t nsupmod) const { return fEMCGeometry->GetPhiCenterOfSMSec(nsupmod) ; }
Float_t GetSuperModulesPar(Int_t ipar) const { return fEMCGeometry->GetSuperModulesPar(ipar) ; }
Int_t GetSMType(Int_t nSupMod) const { if( nSupMod > fEMCGeometry->GetNumberOfSuperModules() ) return -1;
return fEMCSMSystem[nSupMod] ; }
Bool_t IsDCALSM(Int_t nSupMod) const;
Bool_t IsDCALExtSM(Int_t nSupMod) const;
Bool_t GetPhiBoundariesOfSM(Int_t nSupMod, Double_t &phiMin, Double_t &phiMax) const
{ return fEMCGeometry->GetPhiBoundariesOfSM(nSupMod, phiMin, phiMax) ; }
Bool_t GetPhiBoundariesOfSMGap(Int_t nPhiSec, Double_t &phiMin, Double_t &phiMax) const
{ return fEMCGeometry->GetPhiBoundariesOfSMGap(nPhiSec, phiMin, phiMax); }
Float_t GetGap2Active(void) const { return fEMCGeometry->GetGap2Active() ; }
Float_t GetSteelFrontThickness(void) const { return fEMCGeometry->GetSteelFrontThickness() ; }
Float_t GetTrd2AngleY(void) const { return fEMCGeometry->GetTrd2AngleY() ; }
Float_t Get2Trd2Dy2(void) const { return fEMCGeometry->Get2Trd2Dy2() ; }
Float_t GetTubsR(void) const { return fEMCGeometry->GetTubsR() ; }
Float_t GetTubsTurnAngle(void) const { return fEMCGeometry->GetTubsTurnAngle() ; }
void SetNZ(Int_t nz) { fEMCGeometry->SetNZ(nz) ; }
void SetNPhi(Int_t nphi) { fEMCGeometry->SetNPhi(nphi) ; }
void SetNTRUEta(Int_t ntru) { fEMCGeometry->SetNTRUEta(ntru) ; }
void SetNTRUPhi(Int_t ntru) { fEMCGeometry->SetNTRUPhi(ntru) ; }
void SetSampling(Float_t samp) { fEMCGeometry->SetSampling(samp) ; }
void PrintGeometry() { fEMCGeometry->PrintGeometry() ; }
void GetGlobal(const Double_t *loc, Double_t *glob, int ind) const;
void GetGlobal(const TVector3 &vloc, TVector3 &vglob, int ind) const;
void GetGlobal(Int_t absId, Double_t glob[3]) const;
void GetGlobal(Int_t absId, TVector3 &vglob) const;
void EtaPhiFromIndex(Int_t absId, Double_t &eta, Double_t &phi) const;
void EtaPhiFromIndex(Int_t absId, Float_t &eta, Float_t &phi) const;
Bool_t GetAbsCellIdFromEtaPhi(Double_t eta,Double_t phi, Int_t &absId) const;
Bool_t SuperModuleNumberFromEtaPhi(Double_t eta, Double_t phi, Int_t &nSupMod) const;
Int_t GetAbsCellId(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta) const;
Bool_t CheckAbsCellId(Int_t absId) const;
Bool_t GetCellIndex(Int_t absId, Int_t &nSupMod, Int_t &nModule, Int_t &nIphi,
Int_t &nIeta) const;
void GetModulePhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, Int_t &iphim,
Int_t &ietam) const;
void GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta,
Int_t &iphi, Int_t &ieta) const ;
Int_t GetSuperModuleNumber(Int_t absId) const;
Int_t GetNumberOfModuleInPhiDirection(Int_t nSupMod) const
{
if( GetSMType(nSupMod) == kEMCAL_Half) return fNPhi/2;
else if(GetSMType(nSupMod) == kEMCAL_3rd) return fNPhi/3;
else if(GetSMType(nSupMod) == kDCAL_Ext) return fNPhi/3;
else return fNPhi;
}
void GetModuleIndexesFromCellIndexesInSModule(Int_t nSupMod, Int_t iphi, Int_t ieta,
Int_t &iphim, Int_t &ietam, Int_t &nModule) const;
Int_t GetAbsCellIdFromCellIndexes(Int_t nSupMod, Int_t iphi, Int_t ieta) const;
Bool_t RelPosCellInSModule(Int_t absId,
Double_t &xr, Double_t &yr, Double_t &zr) const;
Bool_t RelPosCellInSModule(Int_t absId, Double_t distEff,
Double_t &xr, Double_t &yr, Double_t &zr) const;
Bool_t RelPosCellInSModule(Int_t absId, Double_t loc[3]) const;
Bool_t RelPosCellInSModule(Int_t absId, TVector3 &vloc) const;
Int_t * GetEMCSystem() const { return fEMCSMSystem ; }
TArrayD GetCentersOfCellsEtaDir() const { return fCentersOfCellsEtaDir ; }
TArrayD GetCentersOfCellsXDir() const { return fCentersOfCellsXDir ; }
TArrayD GetCentersOfCellsPhiDir() const { return fCentersOfCellsPhiDir ; }
TArrayD GetEtaCentersOfCells() const { return fEtaCentersOfCells ; }
TArrayD GetPhiCentersOfCells() const { return fPhiCentersOfCells ; }
Int_t GetNTRU() const { return fEMCGeometry->GetNTRU() ; }
Int_t GetNTRUEta() const { return fEMCGeometry->GetNTRUEta() ; }
Int_t GetNTRUPhi() const { return fEMCGeometry->GetNTRUPhi() ; }
Int_t GetNEtaSubOfTRU() const { return fEMCGeometry->GetNEtaSubOfTRU() ; }
Int_t GetNModulesInTRU() const { return fEMCGeometry->GetNModulesInTRU() ; }
Int_t GetNModulesInTRUEta() const { return fEMCGeometry->GetNModulesInTRUEta() ; }
Int_t GetNModulesInTRUPhi() const { return fEMCGeometry->GetNModulesInTRUPhi() ; }
Int_t GetNTotalTRU() const {return fEMCGeometry->GetNTotalTRU() ; }
void GetModulePhiEtaIndexInSModuleFromTRUIndex(Int_t itru, Int_t iphitru, Int_t ietatru,
Int_t &ietaSM, Int_t &iphiSM) const;
Int_t GetAbsTRUNumberFromNumberInSm(const Int_t row, const Int_t col, const Int_t sm) const ;
void BuildFastOR2DMap();
Bool_t GetAbsFastORIndexFromTRU(const Int_t iTRU, const Int_t iADC, Int_t& id) const;
Bool_t GetAbsFastORIndexFromPositionInTRU(const Int_t iTRU, const Int_t iEta, const Int_t iPhi, Int_t& id) const;
Bool_t GetAbsFastORIndexFromPositionInSM( const Int_t iSM, const Int_t iEta, const Int_t iPhi, Int_t& id) const;
Bool_t GetAbsFastORIndexFromPositionInEMCAL( const Int_t iEta, const Int_t iPhi, Int_t& id) const;
Bool_t GetTRUFromAbsFastORIndex(const Int_t id, Int_t& iTRU, Int_t& iADC) const;
Bool_t GetPositionInTRUFromAbsFastORIndex(const Int_t id, Int_t& iTRU, Int_t& iEta, Int_t& iPhi) const;
Bool_t GetPositionInSMFromAbsFastORIndex(const Int_t id, Int_t& iSM, Int_t& iEta, Int_t& iPhi) const;
Bool_t GetPositionInEMCALFromAbsFastORIndex(const Int_t id, Int_t& iEta, Int_t& iPhi) const;
Bool_t GetFastORIndexFromCellIndex(const Int_t id, Int_t& idx) const;
Bool_t GetCellIndexFromFastORIndex(const Int_t id, Int_t idx[4]) const;
Bool_t GetTRUIndexFromSTUIndex(const Int_t id, Int_t& idx) const;
Int_t GetTRUIndexFromSTUIndex(const Int_t id) const;
Bool_t GetTRUIndexFromOnlineIndex(const Int_t id, Int_t& idx) const;
Int_t GetTRUIndexFromOnlineIndex(const Int_t id) const;
Bool_t GetOnlineIndexFromTRUIndex(const Int_t id, Int_t& idx) const;
Int_t GetOnlineIndexFromTRUIndex(const Int_t id) const;
Bool_t GetFastORIndexFromL0Index(const Int_t iTRU, const Int_t id, Int_t idx[], const Int_t size) const;
Float_t AngleFromEta(Float_t eta) const {
return 2.0*TMath::ATan(TMath::Exp(-eta));
}
Float_t ZFromEtaR(Float_t r,Float_t eta) const {
return r/TMath::Tan(AngleFromEta(eta));
}
void SetMisalMatrix(const TGeoHMatrix * m, Int_t smod);
void RecalculateTowerPosition(Float_t drow, Float_t dcol, const Int_t sm, const Float_t depth,
const Float_t misaligTransShifts[15], const Float_t misaligRotShifts[15],Float_t global[3]) const;
const TGeoHMatrix * GetMatrixForSuperModule(Int_t smod)const ;
protected:
void Init(void);
AliEMCALEMCGeometry * fEMCGeometry;
TString fGeoName;
Int_t *fEMCSMSystem;
Int_t fKey110DEG;
Int_t fnSupModInDCAL;
Int_t fNCellsInSupMod;
Int_t fNETAdiv;
Int_t fNPHIdiv;
Int_t fNCellsInModule;
TArrayD fPhiBoundariesOfSM;
TArrayD fPhiCentersOfSM;
TArrayD fPhiCentersOfSMSec;
TArrayD fPhiCentersOfCells;
TArrayD fCentersOfCellsEtaDir;
TArrayD fCentersOfCellsPhiDir;
TArrayD fEtaCentersOfCells;
Int_t fNCells;
Int_t fNPhi;
TArrayD fCentersOfCellsXDir;
Float_t fEnvelop[3];
Float_t fArm1EtaMin;
Float_t fArm1EtaMax;
Float_t fArm1PhiMin;
Float_t fArm1PhiMax;
Float_t fEtaMaxOfTRD1;
Float_t fDCALPhiMin;
Float_t fDCALPhiMax;
Float_t fEMCALPhiMax;
Float_t fDCALStandardPhiMax;
Float_t fDCALInnerExtandedEta;
TList *fShishKebabTrd1Modules;
Float_t fParSM[3];
Float_t fPhiModuleSize;
Float_t fEtaModuleSize;
Float_t fPhiTileSize;
Float_t fEtaTileSize;
Int_t fNZ;
Float_t fIPDistance;
Float_t fLongModuleSize;
Float_t fShellThickness;
Float_t fZLength;
Float_t fSampling;
Int_t fFastOR2DMap[48][124];
TGeoHMatrix* fkSModuleMatrix[AliEMCALGeoParams::fgkEMCALModules] ;
Bool_t fUseExternalMatrices;
private:
static AliEMCALGeometry *fgGeom;
static Bool_t fgInit;
static const Char_t *fgkDefaultGeometryName;
ClassDef(AliEMCALGeometry,17)
} ;
#endif // AliEMCALGEOUTILS_H