From 450ca6fb0f28c82111c728b8b443d313f15bc13b Mon Sep 17 00:00:00 2001 From: ivana Date: Mon, 9 Mar 2009 15:20:55 +0000 Subject: [PATCH] Fix in taking into account alignment in simulation: Adding AliMUONv1::UpdateInternalGeometry(), which updates the transformations in AliMUONGeometryTransformer after applying mis-alignment by framework and so the right transformations are then used in response. (Javier, Ivana) --- MUON/AliMUONGeometryBuilder.cxx | 9 +++ MUON/AliMUONGeometryBuilder.h | 1 + MUON/AliMUONGeometryDetElement.cxx | 16 ++-- MUON/AliMUONGeometryDetElement.h | 4 +- MUON/AliMUONGeometryTransformer.cxx | 110 ++++++++++++++-------------- MUON/AliMUONGeometryTransformer.h | 2 +- MUON/AliMUONv1.cxx | 8 ++ MUON/AliMUONv1.h | 1 + 8 files changed, 88 insertions(+), 63 deletions(-) diff --git a/MUON/AliMUONGeometryBuilder.cxx b/MUON/AliMUONGeometryBuilder.cxx index c17062c7eff..aea1e706042 100644 --- a/MUON/AliMUONGeometryBuilder.cxx +++ b/MUON/AliMUONGeometryBuilder.cxx @@ -592,6 +592,15 @@ void AliMUONGeometryBuilder::InitGeometry(const TString& svmapFileName) } } +//________________________________________________________________ +void AliMUONGeometryBuilder::UpdateInternalGeometry() +{ +/// Update geometry after applying mis-alignment: +/// reload transformations in geometry builder. + + fGeometry->GetTransformer()->LoadTransformations(); +} + //______________________________________________________________________________ void AliMUONGeometryBuilder::WriteSVMaps(const TString& fileName, Bool_t rebuild, Bool_t writeEnvelopes) diff --git a/MUON/AliMUONGeometryBuilder.h b/MUON/AliMUONGeometryBuilder.h index a6b8a8c8f32..88c1b8ae520 100644 --- a/MUON/AliMUONGeometryBuilder.h +++ b/MUON/AliMUONGeometryBuilder.h @@ -44,6 +44,7 @@ class AliMUONGeometryBuilder : public TObject void InitGeometry(); void InitGeometry(const TString& svmapFileName); + void UpdateInternalGeometry(); void WriteSVMaps(); void WriteSVMaps(const TString& fileName, diff --git a/MUON/AliMUONGeometryDetElement.cxx b/MUON/AliMUONGeometryDetElement.cxx index c7d77364958..be6b5b09c52 100644 --- a/MUON/AliMUONGeometryDetElement.cxx +++ b/MUON/AliMUONGeometryDetElement.cxx @@ -243,14 +243,17 @@ void AliMUONGeometryDetElement::Local2Global( //______________________________________________________________________________ void AliMUONGeometryDetElement::SetLocalTransformation( - const TGeoHMatrix& transform) + const TGeoHMatrix& transform, + Bool_t warn) { /// Set local transformation; /// give warning if the global transformation is already defined. - if (fLocalTransformation) { + if ( fLocalTransformation ) { delete fLocalTransformation; - AliWarning("Local transformation already defined was deleted."); + if ( warn ) { + AliWarning("Local transformation already defined was deleted."); + } } fLocalTransformation = new TGeoHMatrix(transform); @@ -258,14 +261,17 @@ void AliMUONGeometryDetElement::SetLocalTransformation( //______________________________________________________________________________ void AliMUONGeometryDetElement::SetGlobalTransformation( - const TGeoHMatrix& transform) + const TGeoHMatrix& transform, + Bool_t warn) { /// Set global transformation; /// give warning if the global transformation is already defined. if (fGlobalTransformation) { delete fGlobalTransformation; - AliWarning("Global transformation already defined was deleted."); + if ( warn ) { + AliWarning("Global transformation already defined was deleted."); + } } fGlobalTransformation = new TGeoHMatrix(transform); diff --git a/MUON/AliMUONGeometryDetElement.h b/MUON/AliMUONGeometryDetElement.h index 22040cbcb91..768e6638834 100644 --- a/MUON/AliMUONGeometryDetElement.h +++ b/MUON/AliMUONGeometryDetElement.h @@ -47,8 +47,8 @@ class AliMUONGeometryDetElement : public TObject void PrintGlobalTransform() const; // set methods - void SetLocalTransformation(const TGeoHMatrix& transform); - void SetGlobalTransformation(const TGeoHMatrix& transform); + void SetLocalTransformation(const TGeoHMatrix& transform, Bool_t warn = true); + void SetGlobalTransformation(const TGeoHMatrix& transform, Bool_t warn = true); void SetVolumePath(const TString& volumePath); // get methods diff --git a/MUON/AliMUONGeometryTransformer.cxx b/MUON/AliMUONGeometryTransformer.cxx index 03eaa3b3d78..6d34e730bd7 100644 --- a/MUON/AliMUONGeometryTransformer.cxx +++ b/MUON/AliMUONGeometryTransformer.cxx @@ -426,61 +426,6 @@ AliMUONGeometryTransformer::ReadTransformations(const TString& fileName) return true; } -//______________________________________________________________________________ -Bool_t -AliMUONGeometryTransformer::LoadTransformations() -{ -/// Load transformations for defined modules and detection elements -/// using AliGeomManager - - if ( ! AliGeomManager::GetGeometry() ) { - AliFatal("Geometry has to be laoded in AliGeomManager first."); - return false; - } - - for (Int_t i=0; iGetEntriesFast(); i++) { - AliMUONGeometryModuleTransformer* moduleTransformer - = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i); - - // Module symbolic name - TString symname = GetModuleSymName(moduleTransformer->GetModuleId()); - - // Set matrix from physical node - TGeoHMatrix* matrix = AliGeomManager::GetMatrix(symname); - if ( ! matrix ) { - AliErrorStream() << "Geometry module matrix not found." << endl; - return false; - } - moduleTransformer->SetTransformation(*matrix); - - // Loop over detection elements - AliMpExMap* detElements = moduleTransformer->GetDetElementStore(); - TIter next(detElements->CreateIterator()); - AliMUONGeometryDetElement* detElement; - - while ( ( detElement = static_cast(next()) ) ) - { - // Det element symbolic name - TString symnameDE = GetDESymName(detElement->GetId()); - - // Set global matrix from physical node - TGeoHMatrix* globalMatrix = AliGeomManager::GetMatrix(symnameDE); - if ( ! globalMatrix ) { - AliErrorStream() << "Detection element matrix not found." << endl; - return false; - } - detElement->SetGlobalTransformation(*globalMatrix); - - // Set local matrix - TGeoHMatrix localMatrix = - AliMUONGeometryBuilder::Multiply( - (*matrix).Inverse(), (*globalMatrix) ); - detElement->SetLocalTransformation(localMatrix); - } - } - return true; -} - //______________________________________________________________________________ void AliMUONGeometryTransformer::WriteTransform(ofstream& out, const TGeoMatrix* transform) const @@ -580,6 +525,61 @@ TString AliMUONGeometryTransformer::GetDESymName(Int_t detElemId) const // public functions // +//______________________________________________________________________________ +Bool_t +AliMUONGeometryTransformer::LoadTransformations() +{ +/// Load transformations for defined modules and detection elements +/// using AliGeomManager + + if ( ! AliGeomManager::GetGeometry() ) { + AliFatal("Geometry has to be laoded in AliGeomManager first."); + return false; + } + + for (Int_t i=0; iGetEntriesFast(); i++) { + AliMUONGeometryModuleTransformer* moduleTransformer + = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i); + + // Module symbolic name + TString symname = GetModuleSymName(moduleTransformer->GetModuleId()); + + // Set matrix from physical node + TGeoHMatrix* matrix = AliGeomManager::GetMatrix(symname); + if ( ! matrix ) { + AliErrorStream() << "Geometry module matrix not found." << endl; + return false; + } + moduleTransformer->SetTransformation(*matrix); + + // Loop over detection elements + AliMpExMap* detElements = moduleTransformer->GetDetElementStore(); + TIter next(detElements->CreateIterator()); + AliMUONGeometryDetElement* detElement; + + while ( ( detElement = static_cast(next()) ) ) + { + // Det element symbolic name + TString symnameDE = GetDESymName(detElement->GetId()); + + // Set global matrix from physical node + TGeoHMatrix* globalMatrix = AliGeomManager::GetMatrix(symnameDE); + if ( ! globalMatrix ) { + AliErrorStream() << "Detection element matrix not found." << endl; + return false; + } + detElement->SetGlobalTransformation(*globalMatrix, false); + + // Set local matrix + TGeoHMatrix localMatrix = + AliMUONGeometryBuilder::Multiply( + (*matrix).Inverse(), (*globalMatrix) ); + detElement->SetLocalTransformation(localMatrix, false); + } + } + return true; +} + //______________________________________________________________________________ Bool_t AliMUONGeometryTransformer::LoadGeometryData(const TString& fileName) diff --git a/MUON/AliMUONGeometryTransformer.h b/MUON/AliMUONGeometryTransformer.h index 14a4f4871dd..0626839e51d 100644 --- a/MUON/AliMUONGeometryTransformer.h +++ b/MUON/AliMUONGeometryTransformer.h @@ -52,6 +52,7 @@ class AliMUONGeometryTransformer : public TObject // IO // + Bool_t LoadTransformations(); Bool_t LoadGeometryData(const TString& fileName); Bool_t LoadGeometryData(); @@ -128,7 +129,6 @@ class AliMUONGeometryTransformer : public TObject TString ReadModuleTransforms(ifstream& in); TString ReadDetElemTransforms(ifstream& in); Bool_t ReadTransformations(const TString& fileName); - Bool_t LoadTransformations(); void WriteTransform(ofstream& out, const TGeoMatrix* transform) const; void WriteModuleTransforms(ofstream& out) const; diff --git a/MUON/AliMUONv1.cxx b/MUON/AliMUONv1.cxx index fb0dde761f9..2a63d117030 100644 --- a/MUON/AliMUONv1.cxx +++ b/MUON/AliMUONv1.cxx @@ -169,6 +169,14 @@ void AliMUONv1::CreateMaterials() fGeometryBuilder->CreateMaterials(); } +//________________________________________________________________ +void AliMUONv1::UpdateInternalGeometry() +{ +/// Update geometry after applying mis-alignment + + fGeometryBuilder->UpdateInternalGeometry(); +} + //________________________________________________________________ void AliMUONv1::AddAlignableVolumes() const { diff --git a/MUON/AliMUONv1.h b/MUON/AliMUONv1.h index 0538b0ad6fe..94ac7f7489e 100644 --- a/MUON/AliMUONv1.h +++ b/MUON/AliMUONv1.h @@ -29,6 +29,7 @@ class AliMUONv1 : public AliMUON virtual ~AliMUONv1(); virtual void CreateGeometry(); virtual void CreateMaterials(); + virtual void UpdateInternalGeometry(); virtual void AddAlignableVolumes() const; virtual void Init(); -- 2.43.0