//______________________________________________________________________
AliITSUGeomTGeo::AliITSUGeomTGeo(Bool_t build)
-: fVersion(kITSVNA)
+ :fVersion(kITSVNA)
,fNLayers(0)
,fNModules(0)
,fNLadders(0)
,fLrDetType(0)
,fNDetectors(0)
,fLastModIndex(0)
+ ,fMatSens(0)
+ ,fMatT2L(0)
{
// default c-tor
if (build) BuildITS();
,fLrDetType(0)
,fNDetectors(0)
,fLastModIndex(0)
+ ,fMatSens(0)
+ ,fMatT2L(0)
{
// copy c-tor
if (fNLayers) {
fLrDetType[i] = src.fLrDetType[i];
fLastModIndex[i] = src.fLastModIndex[i];
}
+ if (src.fMatSens) {
+ fMatSens = new TObjArray(fNModules);
+ fMatSens->SetOwner(kTRUE);
+ for (int i=0;i<fNModules;i++) {
+ const TGeoHMatrix* mat = (TGeoHMatrix*)src.fMatSens->At(i);
+ fMatSens->AddAt(new TGeoHMatrix(*mat),i);
+ }
+ }
+ if (src.fMatT2L) {
+ fMatT2L = new TObjArray(fNModules);
+ fMatT2L->SetOwner(kTRUE);
+ for (int i=0;i<fNModules;i++) {
+ const TGeoHMatrix* mat =(TGeoHMatrix*) src.fMatT2L->At(i);
+ fMatSens->AddAt(new TGeoHMatrix(*mat),i);
+ }
+ }
}
}
delete[] fLrDetType;
delete[] fNDetectors;
delete[] fLastModIndex;
+ delete fMatT2L;
+ delete fMatSens;
}
fVersion = src.fVersion;
fNLayers = src.fNLayers;
fNModules = src.fNModules;
+ if (src.fMatSens) {
+ delete fMatSens;
+ fMatSens = new TObjArray(fNModules);
+ fMatSens->SetOwner(kTRUE);
+ for (int i=0;i<fNModules;i++) {
+ const TGeoHMatrix* mat = (TGeoHMatrix*) src.fMatSens->At(i);
+ fMatSens->AddAt(new TGeoHMatrix(*mat),i);
+ }
+ }
+ if (src.fMatT2L) {
+ delete fMatT2L;
+ fMatT2L = new TObjArray(fNModules);
+ fMatT2L->SetOwner(kTRUE);
+ for (int i=0;i<fNModules;i++) {
+ const TGeoHMatrix* mat = (TGeoHMatrix*) src.fMatT2L->At(i);
+ fMatT2L->AddAt(new TGeoHMatrix(*mat),i);
+ }
+ }
+ //
if (fNLayers) {
fNLadders = new Int_t[fNLayers];
fNDetectors = new Int_t[fNLayers];
}
//______________________________________________________________________
-const TGeoHMatrix* AliITSUGeomTGeo::GetTracking2LocalMatrix(Int_t index) const
+TGeoHMatrix* AliITSUGeomTGeo::ExtractMatrixT2L(Int_t index) const
{
// Get the matrix which transforms from the tracking to local r.s.
// The method queries directly the TGeoPNEntry
TGeoPNEntry *pne = GetPNEntry(index);
if (!pne) return NULL;
- const TGeoHMatrix *m = pne->GetMatrix();
- if (!m)
- AliError(Form("TGeoPNEntry (%s) contains no matrix !",pne->GetName()));
+ TGeoHMatrix *m = (TGeoHMatrix*) pne->GetMatrix();
+ if (!m) AliError(Form("TGeoPNEntry (%s) contains no matrix !",pne->GetName()));
return m;
}
//______________________________________________________________________
-Bool_t AliITSUGeomTGeo::GetTrackingMatrix(Int_t index, TGeoHMatrix &m) const
+Bool_t AliITSUGeomTGeo::GetTrackingMatrix(Int_t index, TGeoHMatrix &m)
{
// Get the matrix which transforms from the tracking r.s. to
// the global one.
TGeoHMatrix *m1 = GetMatrix(index);
if (!m1) return kFALSE;
- const TGeoHMatrix *m2 = GetTracking2LocalMatrix(index);
+ const TGeoHMatrix *m2 = GetMatrixT2L(index);
if (!m2) return kFALSE;
m = *m1;
}
//______________________________________________________________________
-TGeoHMatrix* AliITSUGeomTGeo::GetMatrixSens(Int_t lay, Int_t ladd, Int_t detInLad) const
+TGeoHMatrix* AliITSUGeomTGeo::ExtractMatrixSens(Int_t index) const
{
- // Get the transformation matrix of the SENSOR (not ncessary the same as the module) for a given module 'index'
- // by quering the TGeoManager
+ // Get the transformation matrix of the SENSOR (not ncessary the same as the module)
+ // for a given module 'index' by quering the TGeoManager
const TString kPathBase = Form("/ALIC_1/%s_2/",AliITSUGeomTGeo::GetITSVolPattern());
const TString kNames = Form("%%s%s%%d_1/%s%%d_%%d/%s%%d_%%d/%s%%d_%%d"
,AliITSUGeomTGeo::GetITSLayerPattern()
,AliITSUGeomTGeo::GetITSModulePattern()
,AliITSUGeomTGeo::GetITSSensorPattern());
TString path;
+ Int_t lay,ladd,detInLad;
+ GetModuleId(index,lay,ladd,detInLad);
//
path.Form(kNames.Data(),kPathBase.Data(),lay,lay,ladd,lay,detInLad,lay,1);
gGeoManager->PushPath();
return pne;
}
-//______________________________________________________________________
-Bool_t AliITSUGeomTGeo::LocalToGlobal(Int_t index,const Double_t *loc, Double_t *glob) const
-{
- // Make the conversion from the local sensitive reference system to the global
- // reference system, for an arbitrary local position. The input is the pointer
- // to the array of local coordinates, the result is sent to the glob pointer.
- //
- // Please don't use this method to get the global coordinates of clusters, use
- // the direct method of AliCluster instead.
- //
- const TGeoHMatrix *m2 = GetTracking2LocalMatrix(index);
- if (!m2) return kFALSE;
-
- // The shift (in local y only) between alignable and sensitive volume
- // is extracted directly from the Tracking2Local matrix
- Double_t locSens[] = {loc[0], loc[1]+m2->GetTranslation()[1], loc[2]};
-
- TGeoHMatrix *ml = GetMatrix(index);
- if (!ml) return kFALSE;
- ml->LocalToMaster(locSens,glob);
- return kTRUE;
-}
-
-//______________________________________________________________________
-Bool_t AliITSUGeomTGeo::GlobalToLocal(Int_t index, const Double_t *glob, Double_t *loc) const
-{
- // Make the conversion from the global reference system to the sensitive local
- // reference system, for an arbitrary global position. The input is the pointer
- // to the array of global coordinates, the result is sent to the loc pointer.
- //
- TGeoHMatrix *ml = GetMatrix(index);
- if (!ml) return kFALSE;
-
- const TGeoHMatrix *m2 = GetTracking2LocalMatrix(index);
- if (!m2) return kFALSE;
- ml->MasterToLocal(glob,loc);
- // The shift (in local y only) between alignable and sensitive volume
- // is extracted directly from the Tracking2Local matrix
- loc[1] -= m2->GetTranslation()[1];
-
- return kTRUE;
-}
-
-//______________________________________________________________________
-Bool_t AliITSUGeomTGeo::LocalToGlobalVect(Int_t index, const Double_t *loc, Double_t *glob) const
-{
- // Make the conversion from the local sensitive reference system to the global
- // reference system, for an arbitrary vector. The input is the pointer to the
- // array of local coordinates, the result is sent to the glob pointer.
- //
- TGeoHMatrix *ml = GetMatrix(index);
- if (!ml) return kFALSE;
- ml->LocalToMasterVect(loc,glob);
- return kTRUE;
-}
-
-//______________________________________________________________________
-Bool_t AliITSUGeomTGeo::GlobalToLocalVect(Int_t index, const Double_t *glob, Double_t *loc) const
-{
- // Make the conversion from the global reference system to the sensitive local
- // reference system, for an arbitrary vector. The input is the pointer to the
- // array of global coordinates, the result is sent to the loc pointer.
- TGeoHMatrix *ml = GetMatrix(index);
- if (!ml) return kFALSE;
- ml->MasterToLocalVect(glob,loc);
- return kTRUE;
-}
-
//______________________________________________________________________
void AliITSUGeomTGeo::BuildITS()
{
fLastModIndex[i] = fNModules-1;
}
//
+ FetchMatrices();
fVersion = kITSVUpg;
//
}
i,fNLadders[i],fNDetectors[i],fLrDetType[i],GetFirstModIndex(i),GetLastModIndex(i));
}
}
+
+//______________________________________________________________________
+void AliITSUGeomTGeo::FetchMatrices()
+{
+ // store pointer on often used matrices for faster access
+ if (!gGeoManager) AliFatal("Geometry is not loaded");
+ fMatSens = new TObjArray(fNModules);
+ fMatSens->SetOwner(kTRUE);
+ fMatT2L = new TObjArray(fNModules);
+ fMatT2L->SetOwner(kTRUE);
+ for (int i=0;i<fNModules;i++) {
+ fMatSens->AddAt(new TGeoHMatrix(*ExtractMatrixSens(i)),i);
+ fMatT2L->AddAt(new TGeoHMatrix(*ExtractMatrixT2L(i)),i);
+ }
+}
Bool_t GetOrigRotation(Int_t index, Double_t r[9]) const;
Bool_t GetOrigRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const;
//
- const TGeoHMatrix* GetTracking2LocalMatrix(Int_t index) const;
- const TGeoHMatrix* GetTracking2LocalMatrix(Int_t lay,Int_t lad,Int_t det) const;
+ const TGeoHMatrix* GetMatrixT2L(Int_t index);
+ const TGeoHMatrix* GetMatrixT2L(Int_t lay,Int_t lad,Int_t det) {return GetMatrixT2L( GetModuleIndex(lay,lad,det) );}
+ const TGeoHMatrix* GetMatrixSens(Int_t index);
+ const TGeoHMatrix* GetMatrixSens(Int_t lay,Int_t lad,Int_t det) {return GetMatrixSens( GetModuleIndex(lay,lad,det) );}
//
- Bool_t GetTrackingMatrix(Int_t index, TGeoHMatrix &m) const;
- Bool_t GetTrackingMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m) const;
+ Bool_t GetTrackingMatrix(Int_t index, TGeoHMatrix &m);
+ Bool_t GetTrackingMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m);
//
// Attention: these are transformations wrt sensitive volume!
- TGeoHMatrix* GetMatrixSens(Int_t index) const;
- TGeoHMatrix* GetMatrixSens(Int_t lay,Int_t lad,Int_t det) const;
- Bool_t LocalToGlobal(Int_t index, const Double_t *loc, Double_t *glob) const;
- Bool_t LocalToGlobal(Int_t lay, Int_t lad, Int_t det,const Double_t *loc, Double_t *glob) const;
+ void LocalToGlobal(Int_t index, const Double_t *loc, Double_t *glob);
+ void LocalToGlobal(Int_t lay, Int_t lad, Int_t det,const Double_t *loc, Double_t *glob);
//
- Bool_t GlobalToLocal(Int_t index, const Double_t *glob, Double_t *loc) const;
- Bool_t GlobalToLocal(Int_t lay, Int_t lad, Int_t det,const Double_t *glob, Double_t *loc) const;
+ void GlobalToLocal(Int_t index, const Double_t *glob, Double_t *loc);
+ void GlobalToLocal(Int_t lay, Int_t lad, Int_t det,const Double_t *glob, Double_t *loc);
//
- Bool_t LocalToGlobalVect(Int_t index, const Double_t *loc, Double_t *glob) const;
- Bool_t GlobalToLocalVect(Int_t index, const Double_t *glob, Double_t *loc) const;
+ void LocalToGlobalVect(Int_t index, const Double_t *loc, Double_t *glob);
+ void GlobalToLocalVect(Int_t index, const Double_t *glob, Double_t *loc);
Int_t GetLayerDetTypeID(Int_t lr) const;
Int_t GetModuleDetTypeID(Int_t id) const;
//
virtual void Print(Option_t *opt="") const;
- static const char* GetITSVolPattern() {return fgkITSVolName;}
- static const char* GetITSLayerPattern() {return fgkITSLrName;}
- static const char* GetITSLadderPattern() {return fgkITSLadName;}
- static const char* GetITSModulePattern() {return fgkITSModName;}
- static const char* GetITSSensorPattern() {return fgkITSSensName;}
- static const char* GetDetTypeName(Int_t i) {return (i<0||i>=kNDetTypes) ? 0 : fgkITSDetTypeName[i];}
- static const char* GetITSsegmentationFileName() {return fgITSsegmFileName.Data();}
- static void SetITSsegmentationFileName(const char* nm) {fgITSsegmFileName = nm;}
+ static const char* GetITSVolPattern() {return fgkITSVolName;}
+ static const char* GetITSLayerPattern() {return fgkITSLrName;}
+ static const char* GetITSLadderPattern() {return fgkITSLadName;}
+ static const char* GetITSModulePattern() {return fgkITSModName;}
+ static const char* GetITSSensorPattern() {return fgkITSSensName;}
+ static const char* GetDetTypeName(Int_t i) {return (i<0||i>=kNDetTypes) ? 0 : fgkITSDetTypeName[i];}
+ static const char* GetITSsegmentationFileName() {return fgITSsegmFileName.Data();}
+ static void SetITSsegmentationFileName(const char* nm) {fgITSsegmFileName = nm;}
static UInt_t ComposeDetTypeID(UInt_t segmId);
//
// hack to avoid using AliGeomManager
- Int_t LayerToVolUID(Int_t lay,int detInLay) const {return GetModuleIndex(lay,detInLay);}
- static Int_t ModuleVolUID(Int_t mod) {return mod;}
+ Int_t LayerToVolUID(Int_t lay,int detInLay) const {return GetModuleIndex(lay,detInLay);}
+ static Int_t ModuleVolUID(Int_t mod) {return mod;}
+ //
+ protected:
+ void FetchMatrices();
+ TGeoHMatrix* ExtractMatrixT2L(Int_t index) const;
+ TGeoHMatrix* ExtractMatrixSens(Int_t index) const;
+ Bool_t GetLayer(Int_t index,Int_t &lay,Int_t &index2) const;
+ TGeoPNEntry* GetPNEntry(Int_t index) const;
+ Int_t ExtractNumberOfDetectors(Int_t lay) const;
+ Int_t ExtractNumberOfLadders(Int_t lay) const;
+ Int_t ExtractLayerDetType(Int_t lay) const;
+ Int_t ExtractNumberOfLayers() const;
+ void BuildITS();
//
private:
//
- Bool_t GetLayer(Int_t index,Int_t &lay,Int_t &index2) const;
- TGeoPNEntry* GetPNEntry(Int_t index) const;
- Int_t ExtractNumberOfDetectors(Int_t lay) const;
- Int_t ExtractNumberOfLadders(Int_t lay) const;
- Int_t ExtractLayerDetType(Int_t lay) const;
- Int_t ExtractNumberOfLayers() const;
- void BuildITS();
//
Int_t fVersion; // ITS Version
Int_t fNLayers; // number of layers
Int_t *fNDetectors; //[fNLayers] Array of the number of detector/ladder(layer)
Int_t *fLastModIndex; //[fNLayers] max ID of the detctor in the layer
//
+ TObjArray* fMatSens; // Sensor's matrices pointers in the geometry
+ TObjArray* fMatT2L; // Tracking to Local matrices pointers in the geometry
+ //
static const char* fgkITSVolName; // ITS mother volume name
static const char* fgkITSLrName; // ITS Layer name
static const char* fgkITSLadName; // ITS Ladder name
}
//_____________________________________________________________________________________________
-inline const TGeoHMatrix* AliITSUGeomTGeo::GetTracking2LocalMatrix(Int_t lay,Int_t lad,Int_t det) const
+inline Bool_t AliITSUGeomTGeo::GetTrackingMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m)
{
- // t2l matrix
- return GetTracking2LocalMatrix(GetModuleIndex(lay,lad,det));
+ // tracking mat
+ return GetTrackingMatrix(GetModuleIndex(lay,lad,det),m);
}
//_____________________________________________________________________________________________
-inline Bool_t AliITSUGeomTGeo::GetTrackingMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m) const
+inline Int_t AliITSUGeomTGeo::GetLayerDetTypeID(Int_t lr) const
{
- // tracking mat
- return GetTrackingMatrix(GetModuleIndex(lay,lad,det),m);
+ // detector type ID of layer
+ return fLrDetType[lr];
}
//_____________________________________________________________________________________________
-inline TGeoHMatrix* AliITSUGeomTGeo::GetMatrixSens(Int_t index) const
+inline Int_t AliITSUGeomTGeo::GetModuleDetTypeID(Int_t id) const
{
- // semsor matrix
- int lr,ld,dt;
- return GetModuleId(index,lr,ld,dt) ? GetMatrixSens(lr,ld,dt) : 0;
-}
+ // detector type ID of module
+ return GetLayerDetTypeID(GetLayer(id));
+}
//_____________________________________________________________________________________________
-inline Bool_t AliITSUGeomTGeo::LocalToGlobal(Int_t lay, Int_t lad, Int_t det,const Double_t *loc, Double_t *glob) const
+inline const TGeoHMatrix* AliITSUGeomTGeo::GetMatrixSens(Int_t index)
{
- // Local2Master (sensor)
- return LocalToGlobal(GetModuleIndex(lay,lad,det), loc, glob);
+ // access global to sensor matrix
+ if (!fMatSens) FetchMatrices();
+ return (TGeoHMatrix*)fMatSens->At(index);
}
//_____________________________________________________________________________________________
-inline Bool_t AliITSUGeomTGeo::GlobalToLocal(Int_t lay, Int_t lad, Int_t det,const Double_t *glob, Double_t *loc) const
+inline const TGeoHMatrix* AliITSUGeomTGeo::GetMatrixT2L(Int_t index)
{
- // master2local (sensor)
- return GlobalToLocal(GetModuleIndex(lay,lad,det), glob, loc);
+ // access tracking to local matrix
+ if (!fMatT2L) FetchMatrices();
+ return (TGeoHMatrix*)fMatT2L->At(index);
+}
+
+//______________________________________________________________________
+inline void AliITSUGeomTGeo::LocalToGlobal(Int_t index,const Double_t *loc, Double_t *glob)
+{
+ // sensor local to global
+ GetMatrixSens(index)->LocalToMaster(loc,glob);
+}
+
+//______________________________________________________________________
+inline void AliITSUGeomTGeo::GlobalToLocal(Int_t index, const Double_t *glob, Double_t *loc)
+{
+ // global to sensor local
+ GetMatrixSens(index)->MasterToLocal(glob,loc);
+}
+
+//______________________________________________________________________
+inline void AliITSUGeomTGeo::LocalToGlobalVect(Int_t index, const Double_t *loc, Double_t *glob)
+{
+ // sensor local to global
+ GetMatrixSens(index)->LocalToMasterVect(loc,glob);
+}
+
+//______________________________________________________________________
+inline void AliITSUGeomTGeo::GlobalToLocalVect(Int_t index, const Double_t *glob, Double_t *loc)
+{
+ // global to sensor local
+ GetMatrixSens(index)->MasterToLocalVect(glob,loc);
}
//_____________________________________________________________________________________________
-inline Int_t AliITSUGeomTGeo::GetLayerDetTypeID(Int_t lr) const
+inline void AliITSUGeomTGeo::LocalToGlobal(Int_t lay, Int_t lad, Int_t det,const Double_t *loc, Double_t *glob)
{
- // detector type ID of layer
- return fLrDetType[lr];
+ // Local2Master (sensor)
+ LocalToGlobal(GetModuleIndex(lay,lad,det), loc, glob);
}
//_____________________________________________________________________________________________
-inline Int_t AliITSUGeomTGeo::GetModuleDetTypeID(Int_t id) const
+inline void AliITSUGeomTGeo::GlobalToLocal(Int_t lay, Int_t lad, Int_t det,const Double_t *glob, Double_t *loc)
{
- // detector type ID of module
- return GetLayerDetTypeID(GetLayer(id));
-}
+ // master2local (sensor)
+ GlobalToLocal(GetModuleIndex(lay,lad,det), glob, loc);
+}
#endif