From 6cfb12b47a3765df21837ca0f1ddb2cd6b90b4ed Mon Sep 17 00:00:00 2001 From: ivana Date: Tue, 22 Nov 2005 14:03:57 +0000 Subject: [PATCH] Refactoring of geometry classes: - AliMUONGeometryModules are accessed via a new AliMUONGeometry class - Transformations data are separated in AliMUONGeometryTransformer, AliMUONGeometryModuleTransformer classses - AliMUONGeometryDetElement objects contain always transformation in a new ALIC refernce frame - Read/Write functions moved from AliMUONVGeometryBuilder in AliMUONGeometry (svmaps) and AliMUONGeometryTransformer (transformations) --- MUON/AliMUONGeometryBuilder.cxx | 205 ++++---- MUON/AliMUONGeometryEnvelopeStore.cxx | 25 +- MUON/AliMUONGeometryEnvelopeStore.h | 10 + MUON/AliMUONGeometryModule.cxx | 140 +----- MUON/AliMUONGeometryModule.h | 86 ++-- MUON/AliMUONVGeometryBuilder.cxx | 666 +++++--------------------- 6 files changed, 321 insertions(+), 811 deletions(-) diff --git a/MUON/AliMUONGeometryBuilder.cxx b/MUON/AliMUONGeometryBuilder.cxx index fba0f21e9ac..710d448ce8c 100644 --- a/MUON/AliMUONGeometryBuilder.cxx +++ b/MUON/AliMUONGeometryBuilder.cxx @@ -26,12 +26,15 @@ #include "AliMUONGeometryBuilder.h" #include "AliMUONVGeometryBuilder.h" +#include "AliMUONGeometry.h" +#include "AliMUONGeometryTransformer.h" #include "AliMUONGeometryModule.h" +#include "AliMUONGeometryModuleTransformer.h" #include "AliMUONGeometryEnvelope.h" #include "AliMUONGeometryEnvelopeStore.h" #include "AliMUONGeometryDetElement.h" #include "AliMUONGeometryStore.h" -#include "AliMUONGeometryConstituent.h" +#include "AliMUONGeometryConstituent.h" #include "AliModule.h" #include "AliLog.h" #include "AliRun.h" @@ -103,11 +106,22 @@ AliMUONGeometryBuilder::AliMUONGeometryBuilder(AliModule* module) fModule(module), fAlign(false), fGlobalTransformation(), - fGeometryBuilders(0) + fGeometryBuilders(0), + fGeometry(0) { /// Standard constructor - fGeometryBuilders = new TObjArray(100); + fGeometryBuilders = new TObjArray(); + fGeometryBuilders->SetOwner(true); + + fGeometry = new AliMUONGeometry(true); + + // Define the global transformation: + // Transformation from the old ALICE coordinate system to a new one: + // x->-x, z->-z + TGeoRotation* rotGlobal + = new TGeoRotation("rotGlobal", 90., 180., 90., 90., 180., 0.); + fGlobalTransformation = TGeoCombiTrans(0., 0., 0., rotGlobal); } //______________________________________________________________________________ @@ -116,7 +130,8 @@ AliMUONGeometryBuilder::AliMUONGeometryBuilder() fModule(0), fAlign(false), fGlobalTransformation(), - fGeometryBuilders(0) + fGeometryBuilders(0), + fGeometry(0) { /// Default constructor } @@ -134,10 +149,9 @@ AliMUONGeometryBuilder::AliMUONGeometryBuilder(const AliMUONGeometryBuilder& rig AliMUONGeometryBuilder::~AliMUONGeometryBuilder() { /// Destructor - if (fGeometryBuilders){ - fGeometryBuilders->Delete(); - delete fGeometryBuilders; - } + + delete fGeometryBuilders; + delete fGeometry; } //______________________________________________________________________________ @@ -165,11 +179,11 @@ void AliMUONGeometryBuilder::PlaceVolume(const TString& name, const TString& mNa { /// Place the volume specified by name with the given transformation matrix + TGeoHMatrix transform(matrix); // Do not apply global transformation // if mother volume was already placed in // the new system of coordinates (that is MUON in negative Z) // (as it is applied on the mother volume) - TGeoHMatrix transform(matrix); if (mName == TString("DDIP")) transform = fGlobalTransformation.Inverse() * transform; @@ -232,8 +246,11 @@ void AliMUONGeometryBuilder::FillGlobalTransformations( for (Int_t j=0; jNofGeometries(); j++) { - AliMUONGeometryModule* geometry = builder->Geometry(j); - AliMUONGeometryStore* detElements = geometry->GetDetElementStore(); + AliMUONGeometryModuleTransformer* transformer + = builder->Geometry(j)->GetTransformer(); + + AliMUONGeometryStore* detElements + = transformer->GetDetElementStore(); for (Int_t k=0; kGetNofEntries(); k++) { @@ -251,9 +268,9 @@ void AliMUONGeometryBuilder::FillGlobalTransformations( // Compose global transformation TGeoHMatrix total - = Multiply( appliedGlobalTransform, - (*geometry->GetTransformation()), - (*localTransform) ); + = Multiply( (*transformer->GetTransformation()), + (*localTransform), + appliedGlobalTransform ); // Convert TGeoHMatrix to TGeoCombiTrans TGeoCombiTrans globalTransform(localTransform->GetName()); @@ -292,6 +309,14 @@ void AliMUONGeometryBuilder::AddBuilder(AliMUONVGeometryBuilder* geomBuilder) fGeometryBuilders->Add(geomBuilder); + // Pass geometry modules created in the to the geometry parametrisation + for (Int_t i=0; iNofGeometries(); i++) { + fGeometry->AddModule(geomBuilder->Geometry(i)); + } + + if (geomBuilder->ApplyGlobalTransformation()) + geomBuilder->SetReferenceFrame(fGlobalTransformation); + SetAlign(geomBuilder); } @@ -300,6 +325,8 @@ void AliMUONGeometryBuilder::CreateGeometry() { /// Construct geometry using geometry builders. + if (fAlign) ReadTransformations(); + for (Int_t i=0; iGetEntriesFast(); i++) { // Get the builder @@ -308,43 +335,36 @@ void AliMUONGeometryBuilder::CreateGeometry() // Create geometry + envelopes // - if (fAlign) { - if (builder->ApplyGlobalTransformation()) - builder->SetReferenceFrame(fGlobalTransformation); - builder->ReadTransformations(); - builder->CreateGeometry(); - } - else { - builder->CreateGeometry(); - builder->SetTransformations(); - } - + builder->CreateGeometry(); + if (!fAlign) builder->SetTransformations(); + // Place module volumes and envelopes // for (Int_t j=0; jNofGeometries(); j++) { AliMUONGeometryModule* geometry = builder->Geometry(j); + const TGeoCombiTrans* kModuleTransform + = geometry->GetTransformer()->GetTransformation(); - TGeoCombiTrans appliedGlobalTransform; - if (builder->ApplyGlobalTransformation()) - appliedGlobalTransform = fGlobalTransformation; - // Place the module volume if ( !geometry->IsVirtual() ) { - TGeoHMatrix total - = Multiply ( appliedGlobalTransform, - (*geometry->GetTransformation()) ); - - PlaceVolume(geometry->GetVolume(), geometry->GetMotherVolume(), - 1, total, 0, 0, "ONLY"); + PlaceVolume(geometry->GetVolume(), geometry->GetMotherVolume(), + 1, *kModuleTransform, 0, 0, "ONLY"); } + TGeoCombiTrans appliedGlobalTransform; + if (builder->ApplyGlobalTransformation()) + appliedGlobalTransform = fGlobalTransformation; + // Loop over envelopes - const TObjArray* kEnvelopes = geometry->GetEnvelopeStore()->GetEnvelopes(); + const TObjArray* kEnvelopes + = geometry->GetEnvelopeStore()->GetEnvelopes(); for (Int_t k=0; kGetEntriesFast(); k++) { // Get envelope - AliMUONGeometryEnvelope* env = (AliMUONGeometryEnvelope*)kEnvelopes->At(k); + AliMUONGeometryEnvelope* env + = (AliMUONGeometryEnvelope*)kEnvelopes->At(k); + const TGeoCombiTrans* kEnvTrans = env->GetTransformation(); const char* only = "ONLY"; if (env->IsMANY()) only = "MANY"; @@ -368,20 +388,21 @@ void AliMUONGeometryBuilder::CreateGeometry() if (!env->IsVirtual() && env->GetConstituents()->GetEntriesFast() == 0 ) { // non virtual envelope + nof constituents = 0 // => place envelope in ALICE by composed transformation: - // Tglobal * Tch * Tenv + // Tch * [Tglobal] * Tenv // Compound chamber transformation with the envelope one if (geometry->IsVirtual()) { TGeoHMatrix total - = Multiply( appliedGlobalTransform, - (*geometry->GetTransformation()), + = Multiply( (*kModuleTransform), + appliedGlobalTransform, (*kEnvTrans) ); PlaceVolume(env->GetName(), geometry->GetMotherVolume(), env->GetCopyNo(), total, 0, 0, only); } else { TGeoHMatrix total - = (*kEnvTrans); + = Multiply( appliedGlobalTransform, + (*kEnvTrans) ); PlaceVolume(env->GetName(), geometry->GetVolume(), env->GetCopyNo(), total, 0, 0, only); } @@ -391,7 +412,7 @@ void AliMUONGeometryBuilder::CreateGeometry() // virtual envelope + nof constituents > 0 // => do not place envelope and place constituents // in ALICE by composed transformation: - // Tglobal * Tch * Tenv * Tconst + // Tch * [Tglobal] * Tenv * Tconst for (Int_t l=0; lGetConstituents()->GetEntriesFast(); l++) { AliMUONGeometryConstituent* constituent @@ -400,9 +421,9 @@ void AliMUONGeometryBuilder::CreateGeometry() // Compound chamber transformation with the envelope one + the constituent one if (geometry->IsVirtual()) { TGeoHMatrix total - = Multiply ( appliedGlobalTransform, - (*geometry->GetTransformation()), - (*kEnvTrans), + = Multiply ( (*kModuleTransform), + appliedGlobalTransform, + (*kEnvTrans), (*constituent->GetTransformation()) ); PlaceVolume(constituent->GetName(), geometry->GetMotherVolume(), @@ -411,7 +432,8 @@ void AliMUONGeometryBuilder::CreateGeometry() } else { TGeoHMatrix total - = Multiply ( (*kEnvTrans), + = Multiply ( appliedGlobalTransform, + (*kEnvTrans), (*constituent->GetTransformation()) ); PlaceVolume(constituent->GetName(), geometry->GetVolume(), @@ -442,10 +464,19 @@ void AliMUONGeometryBuilder::CreateMaterials() } //______________________________________________________________________________ -void AliMUONGeometryBuilder::InitGeometry() +void AliMUONGeometryBuilder::InitGeometry(const TString& svmapFileName) { /// Initialize geometry + // Read alignement data if geometry is read from Root file + if (gAlice->IsRootGeometry()) { + fAlign = true; + ReadTransformations(); + } + + // Read sensitive volume map from a file + fGeometry->ReadSVMap(svmapFileName); + // Set the chamber (sensitive region) GEANT identifier // for (Int_t i=0; iGetEntriesFast(); i++) { @@ -454,70 +485,70 @@ void AliMUONGeometryBuilder::InitGeometry() AliMUONVGeometryBuilder* builder = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i); - // Read alignement data if geometry is read from Root file - if (gAlice->IsRootGeometry()) { - fAlign = true; - builder->ReadTransformations(); - } - - // Set sesitive volumes with each builder + // Set sensitive volumes with each builder builder->SetSensitiveVolumes(); - - // Read sensitive volume map from a file - builder->ReadSVMap(); - if (!fAlign) builder->FillTransformations(); + if (!fAlign) { + // Fill local transformations from built geometry + builder->FillTransformations(); - // Compute global transformations of detection elements - FillGlobalTransformations(builder); + // Compute global transformations of detection elements + FillGlobalTransformations(builder); + } } } //______________________________________________________________________________ -void AliMUONGeometryBuilder::WriteTransformations() +void AliMUONGeometryBuilder::ReadTransformations(const TString& fileName) { -/// Write transformations into files per builder +/// Read transformations from ASCII files +/// and store them in the geometry parametrisation + // Read transformations + // + AliMUONGeometryTransformer* geomTransformer = fGeometry->GetTransformer(); + geomTransformer->ReadTransformations(fileName); + + // Compute global transformations of detection elements + // for (Int_t i=0; iGetEntriesFast(); i++) { - // Get the builder AliMUONVGeometryBuilder* builder = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i); - // Set reference frame - // which the transformation will be written with respect to - if (builder->ApplyGlobalTransformation()) - builder->SetReferenceFrame(fGlobalTransformation); - - // Write transformations - builder->WriteTransformations(); + FillGlobalTransformations(builder); } } //______________________________________________________________________________ -void AliMUONGeometryBuilder::WriteSVMaps(Bool_t rebuild) +void AliMUONGeometryBuilder::WriteTransformations(const TString& fileName) { -/// Write sensitive volume maps into files per builder - - for (Int_t i=0; iGetEntriesFast(); i++) { - - // Get the builder - AliMUONVGeometryBuilder* builder - = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i); +/// Write transformations into files per builder - // Write transformations - builder->WriteSVMap(rebuild); - } + AliMUONGeometryTransformer* geomTransformer = fGeometry->GetTransformer(); + geomTransformer->WriteTransformations(fileName); } -//_____________________________________________________________________________ -void AliMUONGeometryBuilder::SetGlobalTransformation( - const TGeoCombiTrans& transform) +//______________________________________________________________________________ +void AliMUONGeometryBuilder::WriteSVMaps(Bool_t rebuild, + const TString& fileName) { -/// Set the global transformation +/// Write sensitive volume maps into files per builder + + // Rebuild sv maps + // + if (rebuild) + for (Int_t i=0; iGetEntriesFast(); i++) { - fGlobalTransformation = transform; -} + AliMUONVGeometryBuilder* builder + = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i); + + builder->RebuildSVMaps(); + } + + // Write maps in file + fGeometry->WriteSVMap(fileName); +} //_____________________________________________________________________________ void AliMUONGeometryBuilder::SetAlign(Bool_t align) diff --git a/MUON/AliMUONGeometryEnvelopeStore.cxx b/MUON/AliMUONGeometryEnvelopeStore.cxx index 63664707e2e..0886d2361a5 100644 --- a/MUON/AliMUONGeometryEnvelopeStore.cxx +++ b/MUON/AliMUONGeometryEnvelopeStore.cxx @@ -33,6 +33,7 @@ #include "AliMUONGeometryDetElement.h" #include "AliMUONGeometryStore.h" #include "AliMUONConstants.h" +#include "AliMUONGeometryBuilder.h" #include "AliLog.h" ClassImp(AliMUONGeometryEnvelopeStore) @@ -43,6 +44,7 @@ AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore( : TObject(), fEnvelopes(0), fDetElements(detElements), + fReferenceFrame(), fDebug(false), fAlign(false) { @@ -57,6 +59,7 @@ AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore() : TObject(), fEnvelopes(0), fDetElements(0), + fReferenceFrame(), fDebug(false), fAlign(false) { @@ -102,6 +105,21 @@ AliMUONGeometryEnvelopeStore::operator = (const AliMUONGeometryEnvelopeStore& rh // private methods // +//______________________________________________________________________________ +TGeoHMatrix +AliMUONGeometryEnvelopeStore::ConvertTransform(const TGeoHMatrix& transform) const +{ +// Convert transformation into the reference frame + + if ( fReferenceFrame.IsIdentity() ) + return transform; + else { + return AliMUONGeometryBuilder::Multiply( fReferenceFrame.Inverse(), + transform, + fReferenceFrame ); + } +} + //______________________________________________________________________________ AliMUONGeometryEnvelope* AliMUONGeometryEnvelopeStore::FindEnvelope(const TString& name) const @@ -136,7 +154,12 @@ Bool_t AliMUONGeometryEnvelopeStore::AlignEnvelope( return false; }; - envelope->SetTransform(*(detElement->GetLocalTransformation())); + // Apply frame transform + TGeoHMatrix newTransform + = ConvertTransform(*(detElement->GetLocalTransformation())); + + envelope->SetTransform(newTransform); + return true; } diff --git a/MUON/AliMUONGeometryEnvelopeStore.h b/MUON/AliMUONGeometryEnvelopeStore.h index 15ae23f4af4..67b33b92b73 100644 --- a/MUON/AliMUONGeometryEnvelopeStore.h +++ b/MUON/AliMUONGeometryEnvelopeStore.h @@ -17,6 +17,7 @@ #include #include +#include class TGeoTranslation; class TGeoRotation; @@ -113,6 +114,7 @@ class AliMUONGeometryEnvelopeStore : public TObject Int_t npar, Double_t* param); void SetDebug(Bool_t debug); + void SetReferenceFrame(const TGeoCombiTrans& referenceFrame); // Alignement virtual Bool_t GetAlign() const; @@ -124,6 +126,7 @@ class AliMUONGeometryEnvelopeStore : public TObject private: // methods + TGeoHMatrix ConvertTransform(const TGeoHMatrix& transform) const; AliMUONGeometryEnvelope* FindEnvelope(const TString& name) const; Bool_t AlignEnvelope(AliMUONGeometryEnvelope* envelope) const; @@ -132,6 +135,9 @@ class AliMUONGeometryEnvelopeStore : public TObject // wrt to the chamber position in mother volume AliMUONGeometryStore* fDetElements; // detection elements // used for alignement of enevelopes + TGeoCombiTrans fReferenceFrame; // the transformation from the builder + // reference frame to that of the transform + // data files Bool_t fDebug; // Switch for debugging Bool_t fAlign; // option to read transformations from a file @@ -152,4 +158,8 @@ inline void AliMUONGeometryEnvelopeStore::SetAlign(Bool_t align) inline const TObjArray* AliMUONGeometryEnvelopeStore::GetEnvelopes() const { return fEnvelopes; } +inline void +AliMUONGeometryEnvelopeStore::SetReferenceFrame(const TGeoCombiTrans& referenceFrame) +{ fReferenceFrame = referenceFrame; } + #endif //ALI_MUON_CHAMBER_ENVELOPE_STORE_H diff --git a/MUON/AliMUONGeometryModule.cxx b/MUON/AliMUONGeometryModule.cxx index 3f8fa951631..86a54174226 100644 --- a/MUON/AliMUONGeometryModule.cxx +++ b/MUON/AliMUONGeometryModule.cxx @@ -32,12 +32,12 @@ #include "AliLog.h" #include "AliMUONGeometryModule.h" +#include "AliMUONGeometryModuleTransformer.h" #include "AliMUONGeometryEnvelope.h" #include "AliMUONGeometryEnvelopeStore.h" #include "AliMUONGeometryDetElement.h" #include "AliMUONGeometryStore.h" #include "AliMUONGeometrySVMap.h" -#include "AliMUONGeometryDEIndexing.h" ClassImp(AliMUONGeometryModule) @@ -45,36 +45,28 @@ ClassImp(AliMUONGeometryModule) AliMUONGeometryModule::AliMUONGeometryModule(Int_t moduleId) : TObject(), fIsVirtual(true), - fModuleId(moduleId), fMotherVolume("ALIC"), fVolume("NONE"), fNofSVs(0), fSVVolumeIds(0), - fTransformation(0), fEnvelopes(0), - fDEIndexing(0), - fDetElements(0), - fSVMap(0) + fSVMap(0), + fTransformer(0) { /// Standard constructor - // Chamber transformation - fTransformation = new TGeoCombiTrans(""); - // Arrays of volumes Ids fSVVolumeIds = new TArrayI(20); // Sensitive volumes map fSVMap = new AliMUONGeometrySVMap(100); - // Get indexing - fDEIndexing = new AliMUONGeometryDEIndexing(fModuleId, 0); - - // Det elements transformation stores - fDetElements = new AliMUONGeometryStore(fDEIndexing); + // Geometry parametrisation + fTransformer = new AliMUONGeometryModuleTransformer(moduleId); // Envelope store - fEnvelopes = new AliMUONGeometryEnvelopeStore(fDetElements); + fEnvelopes = new AliMUONGeometryEnvelopeStore( + fTransformer->GetDetElementStore()); } @@ -82,16 +74,13 @@ AliMUONGeometryModule::AliMUONGeometryModule(Int_t moduleId) AliMUONGeometryModule::AliMUONGeometryModule() : TObject(), fIsVirtual(true), - fModuleId(0), fMotherVolume(), fVolume(), fNofSVs(0), fSVVolumeIds(0), - fTransformation(0), fEnvelopes(0), - fDEIndexing(0), - fDetElements(0), - fSVMap(0) + fSVMap(0), + fTransformer(0) { /// Default constructor } @@ -111,12 +100,10 @@ AliMUONGeometryModule::~AliMUONGeometryModule() { /// Destructor - delete fTransformation; delete fSVVolumeIds; delete fEnvelopes; - delete fDEIndexing; - delete fDetElements; delete fSVMap; + delete fTransformer; } //______________________________________________________________________________ @@ -154,72 +141,6 @@ Int_t AliMUONGeometryModule::GetSVIndex(Int_t svVolId) const // public methods // -//______________________________________________________________________________ -void AliMUONGeometryModule::Global2Local(Int_t detElemId, - Float_t xg, Float_t yg, Float_t zg, - Float_t& xl, Float_t& yl, Float_t& zl) const -{ -/// Transform point from the global reference frame (ALIC) -/// to the local reference frame of the detection element specified -/// by detElemId. - - // Get detection element - AliMUONGeometryDetElement* detElement = GetDetElement(detElemId); - if (!detElement) return; - - // Transform point - detElement->Global2Local(xg, yg, zg, xl, yl, zl); -} - -//______________________________________________________________________________ -void AliMUONGeometryModule::Global2Local(Int_t detElemId, - Double_t xg, Double_t yg, Double_t zg, - Double_t& xl, Double_t& yl, Double_t& zl) const -{ -/// Transform point from the global reference frame (ALIC) -/// to the local reference frame of the detection element specified -/// by detElemId. - - // Get detection element - AliMUONGeometryDetElement* detElement = GetDetElement(detElemId); - if (!detElement) return; - - // Transform point - detElement->Global2Local(xg, yg, zg, xl, yl, zl); -} - -//______________________________________________________________________________ -void AliMUONGeometryModule::Local2Global(Int_t detElemId, - Float_t xl, Float_t yl, Float_t zl, - Float_t& xg, Float_t& yg, Float_t& zg) const -{ -/// Transform point from the local reference frame of the detection element -/// specified by detElemId to the global reference frame (ALIC). - - // Get detection element - AliMUONGeometryDetElement* detElement = GetDetElement(detElemId); - if (!detElement) return; - - // Transform point - detElement->Local2Global(xl, yl, zl, xg, yg, zg); -} - -//______________________________________________________________________________ -void AliMUONGeometryModule::Local2Global(Int_t detElemId, - Double_t xl, Double_t yl, Double_t zl, - Double_t& xg, Double_t& yg, Double_t& zg) const -{ -/// Transform point from the local reference frame of the detection element -/// specified by detElemId to the global reference frame (ALIC). - - // Get detection element - AliMUONGeometryDetElement* detElement = GetDetElement(detElemId); - if (!detElement) return; - - // Transform point - detElement->Local2Global(xl, yl, zl, xg, yg, zg); -} - //______________________________________________________________________________ void AliMUONGeometryModule::SetVolume(const TString& volumeName) { @@ -231,23 +152,11 @@ void AliMUONGeometryModule::SetVolume(const TString& volumeName) } //______________________________________________________________________________ -void AliMUONGeometryModule::SetTranslation(const TGeoTranslation& translation) +void AliMUONGeometryModule::SetTransformation(const TGeoCombiTrans& transform) { /// Set the module position wrt world. - fTransformation - ->SetTranslation(const_cast(translation.GetTranslation())); -} - -//______________________________________________________________________________ -void AliMUONGeometryModule::SetRotation(const TGeoRotation& rotation) -{ -/// Set the module rotation wrt ALIC. - - TGeoRotation* rot = new TGeoRotation(); - rot->SetMatrix(const_cast(rotation.GetRotationMatrix())); - - fTransformation->SetRotation(rot); + fTransformer->SetTransformation(transform); } //______________________________________________________________________________ @@ -274,7 +183,7 @@ void AliMUONGeometryModule::SetSensitiveVolume(const TString& volName) //______________________________________________________________________________ void AliMUONGeometryModule::SetAlign(Bool_t align) { -/// Set alignement option to enevelope store. +/// Set alignement option to envelope store. fEnvelopes->SetAlign(align); } @@ -290,7 +199,7 @@ AliMUONGeometryModule::FindBySensitiveVolume(const TString& sensVolume) const if (!detElemId) return 0; // The specified sensitive volume is not in the map - return (AliMUONGeometryDetElement*)fDetElements->Get(detElemId); + return fTransformer->GetDetElement(detElemId); } //______________________________________________________________________________ @@ -313,24 +222,3 @@ Bool_t AliMUONGeometryModule::IsSensitiveVolume(const TString& volName) const return IsSensitiveVolume(gMC->VolId(volName)); } - -//______________________________________________________________________________ -AliMUONGeometryDetElement* -AliMUONGeometryModule::GetDetElement(Int_t detElemId) const -{ -/// Return the detection element specified by detElemId. -/// Give error if detection element is not defined. - - // Get detection element - AliMUONGeometryDetElement* detElement - = (AliMUONGeometryDetElement*) fDetElements->Get(detElemId); - - if (!detElement) { - AliErrorStream() - << "Detection element " << detElemId - << " not found in module " << fModuleId << endl; - return 0; - } - - return detElement; -} diff --git a/MUON/AliMUONGeometryModule.h b/MUON/AliMUONGeometryModule.h index 7ea89fbd2ff..9194a882d6c 100644 --- a/MUON/AliMUONGeometryModule.h +++ b/MUON/AliMUONGeometryModule.h @@ -20,6 +20,8 @@ #include #include +#include "AliMUONGeometryModuleTransformer.h" + class TGeoTranslation; class TGeoRotation; class TGeoCombiTrans; @@ -31,7 +33,6 @@ class AliMUONGeometryEnvelopeStore; class AliMUONGeometryDetElement; class AliMUONGeometryStore; class AliMUONGeometrySVMap; -class AliMUONVGeometryDEIndexing; class AliMUONGeometryModule : public TObject { @@ -40,51 +41,36 @@ class AliMUONGeometryModule : public TObject AliMUONGeometryModule(); virtual ~AliMUONGeometryModule(); - // methods - void Global2Local(Int_t detElemId, - Float_t xg, Float_t yg, Float_t zg, - Float_t& xl, Float_t& yl, Float_t& zl) const; - void Global2Local(Int_t detElemId, - Double_t xg, Double_t yg, Double_t zg, - Double_t& xl, Double_t& yl, Double_t& zl) const; - - void Local2Global(Int_t detElemId, - Float_t xl, Float_t yl, Float_t zl, - Float_t& xg, Float_t& yg, Float_t& zg) const; - void Local2Global(Int_t detElemId, - Double_t xl, Double_t yl, Double_t zl, - Double_t& xg, Double_t& yg, Double_t& zg) const; - // set methods + // + void AddSVPath(const TString& sensVolumePath, Int_t detElemId); void SetMotherVolume(const TString& motherVolumeName); void SetVolume(const TString& volumeName); - void SetTranslation(const TGeoTranslation& translation); - void SetRotation(const TGeoRotation& rotation); + void SetTransformation(const TGeoCombiTrans& transform); void SetSensitiveVolume(Int_t volId); void SetSensitiveVolume(const TString& name); void SetAlign(Bool_t align); // get methods - Bool_t IsVirtual() const; - Int_t GetModuleId() const; - TString GetMotherVolume() const; - TString GetVolume() const; - const TGeoCombiTrans* GetTransformation() const; + // + Bool_t IsVirtual() const; + Int_t GetModuleId() const; + TString GetMotherVolume() const; + TString GetVolume() const; + AliMUONGeometryDetElement* FindBySensitiveVolume( const TString& volumePath) const; - AliMUONVGeometryDEIndexing* GetDEIndexing() const; - AliMUONGeometryEnvelopeStore* GetEnvelopeStore() const; - AliMUONGeometryStore* GetDetElementStore() const; - AliMUONGeometryDetElement* GetDetElement(Int_t detElemId) const; - AliMUONGeometrySVMap* GetSVMap() const; Bool_t IsSensitiveVolume(Int_t volId) const; Bool_t IsSensitiveVolume(const TString& volName) const; + AliMUONGeometryEnvelopeStore* GetEnvelopeStore() const; + AliMUONGeometrySVMap* GetSVMap() const; + AliMUONGeometryModuleTransformer* GetTransformer() const; + protected: AliMUONGeometryModule(const AliMUONGeometryModule& rhs); - // operators - AliMUONGeometryModule& operator = (const AliMUONGeometryModule& rhs); + AliMUONGeometryModule& operator = (const AliMUONGeometryModule& rhs); private: // methods @@ -93,32 +79,29 @@ class AliMUONGeometryModule : public TObject // data members Bool_t fIsVirtual; // true if module is not represented // by a real volume - Int_t fModuleId; // the module Id TString fMotherVolume; // mother volume name TString fVolume; // the volume name if not virtual Int_t fNofSVs; // number of sensitive volumes TArrayI* fSVVolumeIds; // densitive volumes IDs - TGeoCombiTrans* fTransformation;// the module transformation wrt to mother - // volume - AliMUONGeometryEnvelopeStore* fEnvelopes; // envelopes - AliMUONVGeometryDEIndexing* fDEIndexing; // DE indexing - AliMUONGeometryStore* fDetElements;// detection elements - AliMUONGeometrySVMap* fSVMap; // sensitive volumes map + + AliMUONGeometryEnvelopeStore* fEnvelopes; // envelopes + AliMUONGeometrySVMap* fSVMap; // sensitive volumes map + AliMUONGeometryModuleTransformer* fTransformer;// geometry transformations - ClassDef(AliMUONGeometryModule,2) // MUON geometry module class + ClassDef(AliMUONGeometryModule,3) // MUON geometry module class }; // inline functions -inline void -AliMUONGeometryModule::SetMotherVolume(const TString& motherVolumeName) +inline +void AliMUONGeometryModule::SetMotherVolume(const TString& motherVolumeName) { fMotherVolume = motherVolumeName; } inline Bool_t AliMUONGeometryModule::IsVirtual() const { return fIsVirtual; } inline Int_t AliMUONGeometryModule::GetModuleId() const -{ return fModuleId; } +{ return fTransformer->GetModuleId(); } inline TString AliMUONGeometryModule::GetMotherVolume() const { return fMotherVolume; } @@ -126,21 +109,16 @@ inline TString AliMUONGeometryModule::GetMotherVolume() const inline TString AliMUONGeometryModule::GetVolume() const { return fVolume; } -inline const TGeoCombiTrans* AliMUONGeometryModule::GetTransformation() const -{ return fTransformation; } - -inline AliMUONGeometryEnvelopeStore* -AliMUONGeometryModule::GetEnvelopeStore() const +inline +AliMUONGeometryEnvelopeStore* AliMUONGeometryModule::GetEnvelopeStore() const { return fEnvelopes; } -inline AliMUONVGeometryDEIndexing* -AliMUONGeometryModule::GetDEIndexing() const -{ return fDEIndexing; } - -inline AliMUONGeometryStore* AliMUONGeometryModule::GetDetElementStore() const -{ return fDetElements; } - -inline AliMUONGeometrySVMap* AliMUONGeometryModule::GetSVMap() const +inline +AliMUONGeometrySVMap* AliMUONGeometryModule::GetSVMap() const { return fSVMap; } +inline +AliMUONGeometryModuleTransformer* AliMUONGeometryModule::GetTransformer() const +{ return fTransformer; } + #endif //ALI_MUON_GEOMETRY_MODULE_H diff --git a/MUON/AliMUONVGeometryBuilder.cxx b/MUON/AliMUONVGeometryBuilder.cxx index 30655057e9c..822c932db60 100644 --- a/MUON/AliMUONVGeometryBuilder.cxx +++ b/MUON/AliMUONVGeometryBuilder.cxx @@ -35,47 +35,49 @@ #include "AliMUONGeometryEnvelopeStore.h" #include "AliMUONGeometryEnvelope.h" #include "AliMUONGeometryConstituent.h" -#include "AliMUONVGeometryDEIndexing.h" +#include "AliMUONGeometryDEIndexing.h" #include "AliMUONGeometryBuilder.h" #include "AliLog.h" ClassImp(AliMUONVGeometryBuilder) -const TString AliMUONVGeometryBuilder::fgkTransformFileNamePrefix = "transform_"; -const TString AliMUONVGeometryBuilder::fgkSVMapFileNamePrefix = "svmap_"; -const TString AliMUONVGeometryBuilder::fgkOutFileNameSuffix = ".out"; - //______________________________________________________________________________ -AliMUONVGeometryBuilder::AliMUONVGeometryBuilder(const TString& fileName, - AliMUONGeometryModule* mg1, AliMUONGeometryModule* mg2, - AliMUONGeometryModule* mg3, AliMUONGeometryModule* mg4, - AliMUONGeometryModule* mg5, AliMUONGeometryModule* mg6) +AliMUONVGeometryBuilder::AliMUONVGeometryBuilder( + Int_t moduleId1, Int_t moduleId2, + Int_t moduleId3, Int_t moduleId4, + Int_t moduleId5, Int_t moduleId6) : TObject(), - fTransformFileName(fgkTransformFileNamePrefix+fileName), - fSVMapFileName(fgkSVMapFileNamePrefix+fileName), - fModuleGeometries(0), + fGeometryModules(0), fReferenceFrame() { // Standard constructor // Create the module geometries array - fModuleGeometries = new TObjArray(); + fGeometryModules = new TObjArray(); - if (mg1) fModuleGeometries->Add(mg1); - if (mg2) fModuleGeometries->Add(mg2); - if (mg3) fModuleGeometries->Add(mg3); - if (mg4) fModuleGeometries->Add(mg4); - if (mg5) fModuleGeometries->Add(mg5); - if (mg6) fModuleGeometries->Add(mg6); -} + if ( moduleId1 >= 0 ) + fGeometryModules->Add(new AliMUONGeometryModule(moduleId1)); + + if ( moduleId2 >= 0 ) + fGeometryModules->Add(new AliMUONGeometryModule(moduleId2)); + + if ( moduleId3 >= 0 ) + fGeometryModules->Add(new AliMUONGeometryModule(moduleId3)); + + if ( moduleId4 >= 0 ) + fGeometryModules->Add(new AliMUONGeometryModule(moduleId4)); + if ( moduleId5 >= 0 ) + fGeometryModules->Add(new AliMUONGeometryModule(moduleId5)); + + if ( moduleId6 >= 0 ) + fGeometryModules->Add(new AliMUONGeometryModule(moduleId6)); +} //______________________________________________________________________________ AliMUONVGeometryBuilder::AliMUONVGeometryBuilder() : TObject(), - fTransformFileName(), - fSVMapFileName(), - fModuleGeometries(0), + fGeometryModules(0), fReferenceFrame() { // Default constructor @@ -94,9 +96,9 @@ AliMUONVGeometryBuilder::AliMUONVGeometryBuilder(const AliMUONVGeometryBuilder& //______________________________________________________________________________ AliMUONVGeometryBuilder::~AliMUONVGeometryBuilder() { // - if (fModuleGeometries) { - fModuleGeometries->Clear(); // Sets pointers to 0 since it is not the owner - delete fModuleGeometries; + if (fGeometryModules) { + fGeometryModules->Clear(); // Sets pointers to 0 since it is not the owner + delete fGeometryModules; } } @@ -119,7 +121,22 @@ AliMUONVGeometryBuilder::operator = (const AliMUONVGeometryBuilder& rhs) // //______________________________________________________________________________ - TString AliMUONVGeometryBuilder::ComposePath(const TString& volName, +TGeoHMatrix +AliMUONVGeometryBuilder::ConvertTransform(const TGeoHMatrix& transform) const +{ +// Convert transformation into the reference frame + + if ( fReferenceFrame.IsIdentity() ) + return transform; + else { + return AliMUONGeometryBuilder::Multiply( fReferenceFrame.Inverse(), + transform, + fReferenceFrame ); + } +} + +//______________________________________________________________________________ +TString AliMUONVGeometryBuilder::ComposePath(const TString& volName, Int_t copyNo) const { // Compose path from given volName and copyNo @@ -140,6 +157,10 @@ void AliMUONVGeometryBuilder::MapSV(const TString& path0, // and map it to the detection element Id if it is a sensitive volume // --- + // Get module sensitive volumes map + Int_t moduleId = AliMUONGeometryDEIndexing::GetModuleId(detElemId); + AliMUONGeometrySVMap* svMap = GetSVMap(moduleId); + Int_t nofDaughters = gMC->NofVolDaughters(volName); if (nofDaughters == 0) { @@ -149,12 +170,14 @@ void AliMUONVGeometryBuilder::MapSV(const TString& path0, TString volName(path0(npos1, npos2-npos1)); // Check if it is sensitive volume - Int_t moduleId = AliMUONVGeometryDEIndexing::GetModuleId(detElemId); + Int_t moduleId = AliMUONGeometryDEIndexing::GetModuleId(detElemId); AliMUONGeometryModule* geometry = GetGeometry(moduleId); if (geometry->IsSensitiveVolume(volName)) { //cout << ".. adding to the map " // << path0 << " " << detElemId << endl; - FillData(path0, detElemId); + + // Map the sensitive volume to detection element + svMap->Add(path0, detElemId); } return; } @@ -171,350 +194,6 @@ void AliMUONVGeometryBuilder::MapSV(const TString& path0, } } -//______________________________________________________________________________ -TGeoHMatrix AliMUONVGeometryBuilder::GetTransform( - Double_t x, Double_t y, Double_t z, - Double_t a1, Double_t a2, Double_t a3, - Double_t a4, Double_t a5, Double_t a6) const -{ -// Builds the transformation from the given parameters -// --- - - // Compose transform - TGeoCombiTrans transform(TGeoTranslation(x, y, z), - TGeoRotation("rot", a1, a2, a3, a4, a5, a6)); - - // Convert transform to the given reference frame - TGeoHMatrix newTransform; - if ( fReferenceFrame.IsIdentity() ) - newTransform = transform; - else { - newTransform - = AliMUONGeometryBuilder::Multiply( fReferenceFrame.Inverse(), - transform, - fReferenceFrame ); - } - - return newTransform; -} - - -//______________________________________________________________________________ -void AliMUONVGeometryBuilder::FillData(Int_t moduleId, Int_t nofDetElements, - Double_t x, Double_t y, Double_t z, - Double_t a1, Double_t a2, Double_t a3, - Double_t a4, Double_t a5, Double_t a6) const -{ -// Fill the transformation of the module. -// --- - - moduleId--; - // Modules numbers in the file are starting from 1 - - // Build the transformation from the parameters - TGeoHMatrix newTransform - = GetTransform(x, y, z, a1, a2, a3, a4, a5, a6); - - const Double_t* xyz = newTransform.GetTranslation(); - const Double_t* rm = newTransform.GetRotationMatrix(); - TGeoRotation rotation2; - rotation2.SetMatrix(const_cast(rm)); - - GetGeometry(moduleId) - ->GetDEIndexing()->SetNofDetElements(nofDetElements); - GetGeometry(moduleId) - ->SetTranslation(TGeoTranslation(xyz[0], xyz[1], xyz[2])); - GetGeometry(moduleId) - ->SetRotation(rotation2); -} - -//______________________________________________________________________________ -void AliMUONVGeometryBuilder::FillData( - Int_t detElemId, const TString& volName, Int_t copyNo, - Double_t x, Double_t y, Double_t z, - Double_t a1, Double_t a2, Double_t a3, - Double_t a4, Double_t a5, Double_t a6) const -{ -// Fill the transformation of the detection element. -// --- - - // Module Id - Int_t moduleId - = AliMUONVGeometryDEIndexing::GetModuleId(detElemId); - - // Compose path - TString path = ComposePath(volName, copyNo); - - // Build the transformation from the parameters - TGeoHMatrix newTransform - = GetTransform(x, y, z, a1, a2, a3, a4, a5, a6); - - // Compose TGeoCombiTrans - TGeoCombiTrans newCombiTransform(newTransform); - - // Get detection element store - AliMUONGeometryStore* detElements = GetDetElements(moduleId); - - // Add detection element - detElements->Add(detElemId, - new AliMUONGeometryDetElement(detElemId, path, newCombiTransform)); -} - -//______________________________________________________________________________ -void AliMUONVGeometryBuilder::FillData( - const TString& sensVolumePath, Int_t detElemId) const -{ -// Fill the mapping of the sensitive volume path to the detection element. -// --- - - // Module Id - Int_t moduleId - = AliMUONVGeometryDEIndexing::GetModuleId(detElemId); - - // Get module sensitive volumes map - AliMUONGeometrySVMap* svMap = GetSVMap(moduleId); - - // Map the sensitive volume to detection element - svMap->Add(sensVolumePath, detElemId); -} - -//______________________________________________________________________________ -TString AliMUONVGeometryBuilder::ReadData1(ifstream& in) const -{ -// Reads and fills modules transformations from a file -// Returns true, if reading finished correctly. -// --- - - TString key("CH"); - while ( key == TString("CH") ) { - Int_t id, n; - Double_t x, y, z; - Double_t a1, a2, a3, a4, a5, a6; - TString dummy; - - in >> id; - in >> n; - in >> dummy; - in >> x; - in >> y; - in >> z; - in >> dummy; - in >> a1; - in >> a2; - in >> a3; - in >> a4; - in >> a5; - in >> a6; - - //cout << "id=" << id << " " - // << "position= " << x << ", " << y << ", " << z << " " - // << "rotation= " << a1 << ", " << a2 << ", " << a3 << ", " - // << a4 << ", " << a5 << ", " << a6 - // << endl; - - // Fill data - FillData(id, n, x, y, z, a1, a2, a3, a4, a5, a6); - - // Go to next line - in >> key; - } - - return key; -} - -//______________________________________________________________________________ -TString AliMUONVGeometryBuilder::ReadData2(ifstream& in) const -{ -// Reads detection elements transformations from a file -// Returns true, if reading finished correctly. -// --- - - TString key("DE"); - while ( key == TString("DE") ) { - - // Input data - Int_t detElemId; - TString volumeName; - Int_t copyNo; - Double_t x, y, z; - Double_t a1, a2, a3, a4, a5, a6; - TString dummy; - - in >> detElemId; - in >> volumeName; - in >> copyNo; - in >> dummy; - in >> x; - in >> y; - in >> z; - in >> dummy; - in >> a1; - in >> a2; - in >> a3; - in >> a4; - in >> a5; - in >> a6; - - //cout << "detElemId=" << detElemId << " " - // << "volume=" << volumeName << " " - // << "copyNo=" << copyNo << " " - // << "position= " << x << ", " << y << ", " << z << " " - // << "rotation= " << a1 << ", " << a2 << ", " << a3 << ", " - // << a4 << ", " << a5 << ", " << a6 - // << endl; - - // Fill data - FillData(detElemId, volumeName, copyNo, x, y, z, a1, a2, a3, a4, a5, a6); - - // Go to next line - in >> key; - } - - return key; -} - -//______________________________________________________________________________ -TString AliMUONVGeometryBuilder::ReadData3(ifstream& in) const -{ -// Reads detection elements transformations from a file -// Returns true, if reading finished correctly. -// --- - - TString key("SV"); - while ( key == TString("SV") ) { - - // Input data - TString volumePath; - Int_t detElemId; - - in >> volumePath; - in >> detElemId; - - //cout << "volumePath=" << volumePath << " " - // << "detElemId=" << detElemId - // << endl; - - // Fill data - FillData(volumePath, detElemId); - - // Go to next line - in >> key; - } - - return key; -} - -//______________________________________________________________________________ -void AliMUONVGeometryBuilder::WriteTransform(ofstream& out, - const TGeoCombiTrans* transform) const -{ -// Writes the transformations -// after converting them into the specified reference frame -// --- - - // Convert transform to the given reference frame - TGeoHMatrix newTransform; - if ( fReferenceFrame.IsIdentity() ) - newTransform = *transform; - else { - newTransform = AliMUONGeometryBuilder::Multiply( fReferenceFrame, - *transform, - fReferenceFrame.Inverse() ); - } - - out << " pos: "; - const Double_t* xyz = newTransform.GetTranslation(); - out << setw(10) << setprecision(4) << xyz[0] << " " - << setw(10) << setprecision(4) << xyz[1] << " " - << setw(10) << setprecision(4) << xyz[2]; - - out << " rot: "; - const Double_t* rm = newTransform.GetRotationMatrix(); - TGeoRotation rotation; - rotation.SetMatrix(const_cast(rm)); - Double_t a1, a2, a3, a4, a5, a6; - rotation.GetAngles(a1, a2, a3, a4, a5, a6); - - out << setw(8) << setprecision(4) << a1 << " " - << setw(8) << setprecision(4) << a2 << " " - << setw(8) << setprecision(4) << a3 << " " - << setw(8) << setprecision(4) << a4 << " " - << setw(8) << setprecision(4) << a5 << " " - << setw(8) << setprecision(4) << a6 << " " << endl; -} - -//______________________________________________________________________________ -void AliMUONVGeometryBuilder::WriteData1(ofstream& out) const -{ -// Writes modules transformations -// --- - - for (Int_t i=0; iGetEntriesFast(); i++) { - AliMUONGeometryModule* geometry - = (AliMUONGeometryModule*)fModuleGeometries->At(i); - const TGeoCombiTrans* transform - = geometry->GetTransformation(); - - out << "CH " - << setw(4) << geometry->GetModuleId() + 1 << " " - << setw(4) << geometry->GetDetElementStore()->GetNofEntries() << " "; - - WriteTransform(out, transform); - } - out << endl; -} - -//______________________________________________________________________________ -void AliMUONVGeometryBuilder::WriteData2(ofstream& out) const -{ -// Writes detection elements (envelopes) transformations -// --- - - - for (Int_t i=0; iGetEntriesFast(); i++) { - AliMUONGeometryModule* geometry - = (AliMUONGeometryModule*)fModuleGeometries->At(i); - const TObjArray* envelopes - = geometry->GetEnvelopeStore()->GetEnvelopes(); - - for (Int_t j=0; jGetEntriesFast(); j++) { - AliMUONGeometryEnvelope* envelope - = (AliMUONGeometryEnvelope*)envelopes->At(j); - const TGeoCombiTrans* transform - = envelope->GetTransformation(); - - // skip envelope not corresponding to detection element - if(envelope->GetUniqueID() == 0) continue; - - out << "DE " - << setw(4) << envelope->GetUniqueID() << " " - << envelope->GetName() << " " - << setw(4)<< envelope->GetCopyNo(); - - WriteTransform(out, transform); - } - out << endl; - } -} - -//______________________________________________________________________________ -void AliMUONVGeometryBuilder::WriteData3(ofstream& out) const -{ -// Writes association of sensitive volumes and detection elements -// from the sensitive volume map -// --- - - for (Int_t i=0; iGetEntriesFast(); i++) { - AliMUONGeometryModule* geometry - = (AliMUONGeometryModule*)fModuleGeometries->At(i); - AliMUONGeometrySVMap* svMap - = geometry->GetSVMap(); - - svMap->WriteMap(out); - out << endl; - } -} - // // protected methods // @@ -526,10 +205,10 @@ AliMUONVGeometryBuilder::GetGeometry(Int_t moduleId) const // Returns the module geometry specified by moduleId // --- - for (Int_t i=0; iGetEntriesFast(); i++) { + for (Int_t i=0; iGetEntriesFast(); i++) { AliMUONGeometryModule* geometry - = (AliMUONGeometryModule*)fModuleGeometries->At(i); + = (AliMUONGeometryModule*)fGeometryModules->At(i); if ( geometry->GetModuleId() == moduleId) return geometry; } @@ -555,62 +234,107 @@ AliMUONVGeometryBuilder::GetEnvelopes(Int_t moduleId) const } //______________________________________________________________________________ -AliMUONGeometryStore* -AliMUONVGeometryBuilder::GetDetElements(Int_t moduleId) const +AliMUONGeometrySVMap* +AliMUONVGeometryBuilder::GetSVMap(Int_t moduleId) const { -// Returns the detection elemnts store of the module geometry specified -// by moduleId +// Returns the transformation store of the module geometry specified by moduleId // --- AliMUONGeometryModule* geometry = GetGeometry(moduleId); if (!geometry) { - AliFatal(Form("Module geometry %d is not defined", moduleId)); + AliFatal(Form("Geometry %d is not defined", moduleId)); return 0; } - return geometry->GetDetElementStore(); + return geometry->GetSVMap(); } //______________________________________________________________________________ -AliMUONGeometrySVMap* -AliMUONVGeometryBuilder::GetSVMap(Int_t moduleId) const +void AliMUONVGeometryBuilder::SetTranslation(Int_t moduleId, + const TGeoTranslation& translation) { -// Returns the transformation store of the module geometry specified by moduleId +// Sets the translation to the geometry module given by moduleId, +// applies reference frame transformation // --- AliMUONGeometryModule* geometry = GetGeometry(moduleId); if (!geometry) { AliFatal(Form("Geometry %d is not defined", moduleId)); - return 0; + return; } - return geometry->GetSVMap(); + // Apply frame transform + TGeoHMatrix newTransform = ConvertTransform(translation); + + // Set new transformation + geometry->SetTransformation(newTransform); +} + + +//______________________________________________________________________________ +void AliMUONVGeometryBuilder::SetTransformation(Int_t moduleId, + const TGeoTranslation& translation, + const TGeoRotation& rotation) +{ +// Sets the translation to the geometry module given by moduleId, +// applies reference frame transformation +// --- + + AliMUONGeometryModule* geometry = GetGeometry(moduleId); + + if (!geometry) { + AliFatal(Form("Geometry %d is not defined", moduleId)); + return; + } + + TGeoCombiTrans transformation + = TGeoCombiTrans(translation, rotation); + + // Apply frame transform + TGeoHMatrix newTransform = ConvertTransform(translation); + + // Set new transformation + geometry->SetTransformation(newTransform); } // // public functions // +//______________________________________________________________________________ +void AliMUONVGeometryBuilder::SetReferenceFrame( + const TGeoCombiTrans& referenceFrame) +{ + fReferenceFrame = referenceFrame; + + for (Int_t i=0; iGetEntriesFast(); i++) { + AliMUONGeometryModule* geometry + = (AliMUONGeometryModule*)fGeometryModules->At(i); + AliMUONGeometryEnvelopeStore* envelopeStore + = geometry->GetEnvelopeStore(); + + envelopeStore->SetReferenceFrame(referenceFrame); + } +} + + //______________________________________________________________________________ void AliMUONVGeometryBuilder::FillTransformations() const { // Fills transformations store from defined geometry. // --- - for (Int_t i=0; iGetEntriesFast(); i++) { + for (Int_t i=0; iGetEntriesFast(); i++) { AliMUONGeometryModule* geometry - = (AliMUONGeometryModule*)fModuleGeometries->At(i); + = (AliMUONGeometryModule*)fGeometryModules->At(i); const TObjArray* envelopes = geometry->GetEnvelopeStore()->GetEnvelopes(); - AliMUONGeometryStore* detElements = geometry->GetDetElementStore(); + AliMUONGeometryStore* detElements + = geometry->GetTransformer()->GetDetElementStore(); - // Set nof detection elements to the indexing - geometry->GetDEIndexing() - ->SetNofDetElements(geometry->GetEnvelopeStore()->GetNofDetElements()); - for (Int_t j=0; jGetEntriesFast(); j++) { AliMUONGeometryEnvelope* envelope = (AliMUONGeometryEnvelope*)envelopes->At(j); @@ -623,10 +347,13 @@ void AliMUONVGeometryBuilder::FillTransformations() const TString path = ComposePath(envelope->GetName(), envelope->GetCopyNo()); const TGeoCombiTrans* transform = envelope->GetTransformation(); + + // Apply frame transform + TGeoHMatrix newTransform = ConvertTransform(*transform); // Add detection element transformation detElements->Add(detElemId, - new AliMUONGeometryDetElement(detElemId, path, *transform)); + new AliMUONGeometryDetElement(detElemId, path, newTransform)); } } } @@ -637,9 +364,9 @@ void AliMUONVGeometryBuilder::RebuildSVMaps() const // Clear the SV maps in memory and fill them from defined geometry. // --- - for (Int_t i=0; iGetEntriesFast(); i++) { + for (Int_t i=0; iGetEntriesFast(); i++) { AliMUONGeometryModule* geometry - = (AliMUONGeometryModule*)fModuleGeometries->At(i); + = (AliMUONGeometryModule*)fGeometryModules->At(i); // Clear the map geometry->GetSVMap()->Clear(); @@ -685,150 +412,3 @@ void AliMUONVGeometryBuilder::RebuildSVMaps() const } } -//______________________________________________________________________________ -Bool_t -AliMUONVGeometryBuilder::ReadTransformations() const -{ -// Reads transformations from a file -// Returns true, if reading finished correctly. -// --- - - // No reading - // if builder is not associated with any geometry module - if (fModuleGeometries->GetEntriesFast() == 0) return false; - - // File path - TString filePath = gSystem->Getenv("ALICE_ROOT"); - filePath += "/MUON/data/"; - filePath += fTransformFileName; - - // Open input file - ifstream in(filePath, ios::in); - if (!in) { - cerr << filePath << endl; - AliFatal("File not found."); - return false; - } - - TString key; - in >> key; - while ( !in.eof() ) { - if (key == TString("CH")) - key = ReadData1(in); - else if (key == TString("DE")) - key = ReadData2(in); - else { - AliFatal(Form("%s key not recognized", key.Data())); - return false; - } - } - - return true; -} - -//______________________________________________________________________________ -Bool_t AliMUONVGeometryBuilder::ReadSVMap() const -{ -// Reads the sensitive volume from a file -// Returns true, if reading finished correctly. -// --- - - // No reading - // if builder is not associated with any geometry module - if (fModuleGeometries->GetEntriesFast() == 0) return false; - - // File path - TString filePath = gSystem->Getenv("ALICE_ROOT"); - filePath += "/MUON/data/"; - filePath += fSVMapFileName; - - // Open input file - ifstream in(filePath, ios::in); - if (!in) { - cerr << filePath << endl; - AliFatal("File not found."); - return false; - } - - TString key; - in >> key; - while ( !in.eof() ) { - if (key == TString("SV")) - key = ReadData3(in); - else { - AliFatal(Form("%s key not recognized", key.Data())); - return false; - } - } - - return true; -} - -//______________________________________________________________________________ -Bool_t -AliMUONVGeometryBuilder::WriteTransformations() const -{ -// Writes transformations into a file -// Returns true, if writing finished correctly. -// --- - - // No writing - // if builder is not associated with any geometry module - if (fModuleGeometries->GetEntriesFast() == 0) return false; - - // File path - TString filePath = gSystem->Getenv("ALICE_ROOT"); - filePath += "/MUON/data/"; - filePath += fTransformFileName; - filePath += fgkOutFileNameSuffix; - - // Open input file - ofstream out(filePath, ios::out); - if (!out) { - cerr << filePath << endl; - AliError("File not found."); - return false; - } -#if !defined (__DECCXX) - out.setf(std::ios::fixed); -#endif - WriteData1(out); - WriteData2(out); - - return true; -} - -//______________________________________________________________________________ -Bool_t AliMUONVGeometryBuilder::WriteSVMap(Bool_t rebuild) const -{ -// Writes sensitive volume map into a file -// Returns true, if writing finished correctly. -// --- - - // No writing - // if builder is not associated with any geometry module - if (fModuleGeometries->GetEntriesFast() == 0) return false; - - // File path - TString filePath = gSystem->Getenv("ALICE_ROOT"); - filePath += "/MUON/data/"; - filePath += fSVMapFileName; - filePath += fgkOutFileNameSuffix; - - // Open input file - ofstream out(filePath, ios::out); - if (!out) { - cerr << filePath << endl; - AliError("File not found."); - return false; - } -#if !defined (__DECCXX) - out.setf(std::ios::fixed); -#endif - if (rebuild) RebuildSVMaps(); - - WriteData3(out); - - return true; -} - -- 2.43.0