}
}
-
//______________________________________________________________________________
-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
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
{
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() )