]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONVGeometryBuilder.cxx
Remove the dollar-id-dollar in the responsible name which interfere with CDB_MD metad...
[u/mrichter/AliRoot.git] / MUON / AliMUONVGeometryBuilder.cxx
index 7c55f6dcdd5ba2d51b1fc6d4ee57f47521e7e442..74f3538b363799a18459e60d0b611dacd2b79592 100644 (file)
@@ -350,12 +350,14 @@ void  AliMUONVGeometryBuilder::SetReferenceFrame(
   }          
 }
 
-
 //______________________________________________________________________________
-void  AliMUONVGeometryBuilder::CreateDetElements() const
+void  AliMUONVGeometryBuilder::UpdateDetElements(Bool_t create) const
 {
-/// Create detection elements and fill their global and
-/// local transformations from geometry.
+/// Create or update detection elements:
+/// - if parameter create is true: detection elements are
+/// created and their global and local transformations are filled from geometry.
+/// - otherwise: only the volume path is passed from geometry
+/// to detection elements
 
   for (Int_t i=0; i<fGeometryModules->GetEntriesFast(); i++) {
     AliMUONGeometryModule* geometry 
@@ -381,29 +383,39 @@ void  AliMUONVGeometryBuilder::CreateDetElements() const
       TString volPath = geometry->GetVolumePath();
       volPath += ComposePath(envelope->GetName(), envelope->GetCopyNo());
 
-      // Create detection element 
-      AliMUONGeometryDetElement* detElement
-        = new AliMUONGeometryDetElement(detElemId, volPath);
-      detElements->Add(detElemId, detElement);
+      if ( create ) {
+        // Create detection element 
+        AliMUONGeometryDetElement* detElement
+          = new AliMUONGeometryDetElement(detElemId, volPath);
+        detElements->Add(detElemId, detElement);
       
-      // Compose  local transformation
-      const TGeoCombiTrans* transform = envelope->GetTransformation(); 
-      // Apply frame transform
-      TGeoHMatrix localTransform = ConvertDETransform(*transform);
-      detElement->SetLocalTransformation(localTransform);
-
-      // Compose global transformation
-      TGeoHMatrix globalTransform 
-       = AliMUONGeometryBuilder::Multiply( 
+        // Compose  local transformation
+        const TGeoCombiTrans* transform = envelope->GetTransformation(); 
+        // Apply frame transform
+        TGeoHMatrix localTransform = ConvertDETransform(*transform);
+        detElement->SetLocalTransformation(localTransform);
+
+        // Compose global transformation
+        TGeoHMatrix globalTransform 
+         = AliMUONGeometryBuilder::Multiply( 
                    (*geometry->GetTransformer()->GetTransformation()),
                     localTransform );
                    ;
-      // Set the global transformation to detection element
-      detElement->SetGlobalTransformation(globalTransform);
-      
-    }  
+        // Set the global transformation to detection element
+        detElement->SetGlobalTransformation(globalTransform);
+      }
+      else {
+        // Get existing det elements
+        AliMUONGeometryDetElement* detElement
+          = (AliMUONGeometryDetElement*)detElements->GetValue(detElemId);
+          
+        // Set volume path  
+        detElement->SetVolumePath(volPath); 
+      }
+    }    
   }
 }
+
 //_____ _________________________________________________________________________
 void  AliMUONVGeometryBuilder::RebuildSVMaps(Bool_t withEnvelopes) const
 {
@@ -435,13 +447,17 @@ void  AliMUONVGeometryBuilder::RebuildSVMaps(Bool_t withEnvelopes) const
       if ( ! withEnvelopes && geometry->IsVirtual() ) {
          std::string vName = geometry->GetTransformer()->GetVolumeName().Data();
         std::string vPath = ComposePath(vName, 1).Data();
-        path0.erase(path0.find(vPath), vPath.size());
+         std::string::size_type vPathPos = path0.find(vPath);
+         if ( vPathPos != std::string::npos )
+           path0.erase(vPathPos, vPath.size());
       }  
        
       if ( ! withEnvelopes && envelope->IsVirtual()) {
          std::string eName = envelope->GetName();
         std::string ePath = ComposePath(eName, envelope->GetCopyNo()).Data();
-        path0.erase(path0.find(ePath), ePath.size());
+         std::string::size_type ePathPos = path0.find(ePath);
+         if ( ePathPos != std::string::npos )
+           path0.erase(ePathPos, ePath.size());
       }
 
       if ( ! envelope->IsVirtual() )