**************************************************************************/
// $Id$
-//
+
+//-----------------------------------------------------------------------------
// Class AliMUONVGeometryBuilder
// -----------------------------
// Abstract base class for geometry construction per geometry module(s).
// Author: Ivana Hrivnacova, IPN Orsay
// 23/01/2004
-
-#include <Riostream.h>
-#include <TObjArray.h>
-#include <TSystem.h>
-#include <TGeoMatrix.h>
-#include <TVirtualMC.h>
+//-----------------------------------------------------------------------------
#include "AliMUONVGeometryBuilder.h"
#include "AliMUONGeometryModule.h"
#include "AliMUONGeometryDetElement.h"
-#include "AliMUONGeometryStore.h"
#include "AliMUONGeometryEnvelopeStore.h"
#include "AliMUONGeometryEnvelope.h"
#include "AliMUONGeometryConstituent.h"
#include "AliMUONGeometryBuilder.h"
#include "AliMUONStringIntMap.h"
+
+#include "AliMpDEManager.h"
+#include "AliMpExMap.h"
+
#include "AliLog.h"
+#include <Riostream.h>
+#include <TObjArray.h>
+#include <TSystem.h>
+#include <TGeoMatrix.h>
+#include <TVirtualMC.h>
+
+/// \cond CLASSIMP
ClassImp(AliMUONVGeometryBuilder)
+/// \endcond
//______________________________________________________________________________
AliMUONVGeometryBuilder::AliMUONVGeometryBuilder(
- Int_t moduleId1, Int_t moduleId2,
- Int_t moduleId3, Int_t moduleId4,
- Int_t moduleId5, Int_t moduleId6)
+ Int_t firstModuleId,
+ Int_t nofModules)
: TObject(),
fGeometryModules(0),
fReferenceFrame()
{
-// Standard constructor
+/// Standard constructor
// Create the module geometries array
fGeometryModules = new TObjArray();
-
- 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));
+ fGeometryModules->SetOwner(kFALSE);
+
+ for (Int_t i=0; i<nofModules; i++ )
+ fGeometryModules->Add(new AliMUONGeometryModule(firstModuleId++));
}
//______________________________________________________________________________
fGeometryModules(0),
fReferenceFrame()
{
-// Default constructor
+/// Default constructor
}
-
//______________________________________________________________________________
-AliMUONVGeometryBuilder::AliMUONVGeometryBuilder(const AliMUONVGeometryBuilder& rhs)
- : TObject(rhs)
+AliMUONVGeometryBuilder::~AliMUONVGeometryBuilder()
{
-// Protected copy constructor
-
- AliFatal("Copy constructor is not implemented.");
-}
+/// Destructor
-//______________________________________________________________________________
-AliMUONVGeometryBuilder::~AliMUONVGeometryBuilder() {
-//
if (fGeometryModules) {
fGeometryModules->Clear(); // Sets pointers to 0 since it is not the owner
delete fGeometryModules;
}
}
-//______________________________________________________________________________
-AliMUONVGeometryBuilder&
-AliMUONVGeometryBuilder::operator = (const AliMUONVGeometryBuilder& rhs)
-{
-// Protected assignement operator
-
- // check assignement to self
- if (this == &rhs) return *this;
-
- AliFatal("Assignment operator is not implemented.");
-
- return *this;
-}
-
//
// private methods
//
TGeoHMatrix
AliMUONVGeometryBuilder::ConvertTransform(const TGeoHMatrix& transform) const
{
-// Convert transformation into the reference frame
+/// Convert transformation into the reference frame
if ( fReferenceFrame.IsIdentity() )
return transform;
TGeoHMatrix
AliMUONVGeometryBuilder::ConvertDETransform(const TGeoHMatrix& transform) const
{
-// Convert transformation into the reference frame
+/// Convert DE transformation into the reference frame
if ( fReferenceFrame.IsIdentity() )
return transform;
TString AliMUONVGeometryBuilder::ComposePath(const TString& volName,
Int_t copyNo) const
{
-// Compose path from given volName and copyNo
-// ---
+/// Compose path from given volName and copyNo
TString path = "/";
path += volName;
void AliMUONVGeometryBuilder::MapSV(const TString& path0,
const TString& volName, Int_t detElemId) const
{
-// Update the path with all daughters volumes recursively
-// and map it to the detection element Id if it is a sensitive volume
-// ---
+/// Update the path with all daughters volumes recursively
+/// and map it to the detection element Id if it is a sensitive volume
// Get module sensitive volumes map
- Int_t moduleId = AliMUONGeometryStore::GetModuleId(detElemId);
+ Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
AliMUONStringIntMap* svMap = GetSVMap(moduleId);
Int_t nofDaughters = gMC->NofVolDaughters(volName);
// Get the name of the last volume in the path
Ssiz_t npos1 = path0.Last('/')+1;
Ssiz_t npos2 = path0.Last('_');
- TString volName(path0(npos1, npos2-npos1));
+ TString volName0(path0(npos1, npos2-npos1));
// Check if it is sensitive volume
- Int_t moduleId = AliMUONGeometryStore::GetModuleId(detElemId);
AliMUONGeometryModule* geometry = GetGeometry(moduleId);
- if ( geometry->IsSensitiveVolume(volName) &&
+ if ( geometry->IsSensitiveVolume(volName0) &&
! svMap->Get(path0) ) {
//cout << ".. adding to the map "
// << path0 << " " << detElemId << endl;
AliMUONGeometryModule*
AliMUONVGeometryBuilder::GetGeometry(Int_t moduleId) const
{
-// Returns the module geometry specified by moduleId
-// ---
+/// Return the module geometry specified by moduleId
for (Int_t i=0; i<fGeometryModules->GetEntriesFast(); i++) {
AliMUONGeometryEnvelopeStore*
AliMUONVGeometryBuilder::GetEnvelopes(Int_t moduleId) const
{
-// Returns the envelope store of the module geometry specified by moduleId
-// ---
+/// Return the envelope store of the module geometry specified by moduleId
AliMUONGeometryModule* geometry = GetGeometry(moduleId);
AliMUONStringIntMap*
AliMUONVGeometryBuilder::GetSVMap(Int_t moduleId) const
{
-// Returns the transformation store of the module geometry specified by moduleId
-// ---
+/// Return the transformation store of the module geometry specified by moduleId
AliMUONGeometryModule* geometry = GetGeometry(moduleId);
return geometry->GetSVMap();
}
+//______________________________________________________________________________
+Int_t
+AliMUONVGeometryBuilder::GetModuleId(const TString& envName) const
+{
+/// Return module Id which has the envelope with given name
+
+ for (Int_t i=0; i<fGeometryModules->GetEntriesFast(); i++) {
+
+ AliMUONGeometryModule* geometry
+ = (AliMUONGeometryModule*)fGeometryModules->At(i);
+
+ if ( geometry->GetEnvelopeStore()->FindEnvelope(envName) )
+ return geometry->GetModuleId();
+ }
+
+ return -1;
+}
+
+
//______________________________________________________________________________
void AliMUONVGeometryBuilder::SetTranslation(Int_t moduleId,
const TGeoTranslation& translation)
{
-// Sets the translation to the geometry module given by moduleId,
-// applies reference frame transformation
-// ---
+/// Set the translation to the geometry module given by moduleId,
+/// apply reference frame transformation
AliMUONGeometryModule* geometry = GetGeometry(moduleId);
const TGeoTranslation& translation,
const TGeoRotation& rotation)
{
-// Sets the translation to the geometry module given by moduleId,
-// applies reference frame transformation
-// ---
+/// Set the transformation to the geometry module given by moduleId,
+/// apply reference frame transformation
AliMUONGeometryModule* geometry = GetGeometry(moduleId);
}
}
-
//______________________________________________________________________________
-void AliMUONVGeometryBuilder::CreateDetElements() const
+void AliMUONVGeometryBuilder::UpdateDetElements(Bool_t create) const
{
-/// Create detection element 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
const TObjArray* envelopes
= geometry->GetEnvelopeStore()->GetEnvelopes();
- AliMUONGeometryStore* detElements
+ AliMpExMap* detElements
= geometry->GetTransformer()->GetDetElementStore();
for (Int_t j=0; j<envelopes->GetEntriesFast(); j++) {
TString volPath = geometry->GetVolumePath();
volPath += ComposePath(envelope->GetName(), envelope->GetCopyNo());
- // 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(
+ 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(
(*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
{
-// Clear the SV maps in memory and fill them from defined geometry.
-// ---
+/// Clear the SV maps in memory and fill them from defined geometry.
for (Int_t i=0; i<fGeometryModules->GetEntriesFast(); i++) {
AliMUONGeometryModule* geometry
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() )