**************************************************************************/
// $Id$
-//
+
+//-----------------------------------------------------------------------------
// Class AliMUONVGeometryBuilder
// -----------------------------
-// Abstract base class for geometry construction per chamber(s).
+// Abstract base class for geometry construction per geometry module(s).
// Author: Ivana Hrivnacova, IPN Orsay
// 23/01/2004
+//-----------------------------------------------------------------------------
+
+#include "AliMUONVGeometryBuilder.h"
+#include "AliMUONGeometryModule.h"
+#include "AliMUONGeometryDetElement.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 <TGeoMatrix.h>
#include <TVirtualMC.h>
-#include "AliMUONVGeometryBuilder.h"
-#include "AliMUONChamber.h"
-#include "AliMUONChamberGeometry.h"
-#include "AliMUONGeometryTransformStore.h"
-#include "AliMUONGeometrySVMap.h"
-#include "AliMUONGeometryEnvelopeStore.h"
-#include "AliMUONGeometryEnvelope.h"
-#include "AliMUONGeometryConstituent.h"
-#include "AliMUONConstants.h"
-
+/// \cond CLASSIMP
ClassImp(AliMUONVGeometryBuilder)
-
-const TString AliMUONVGeometryBuilder::fgkTransformFileNamePrefix = "transform_";
-const TString AliMUONVGeometryBuilder::fgkSVMapFileNamePrefix = "svmap_";
-const TString AliMUONVGeometryBuilder::fgkOutFileNameSuffix = ".out";
+/// \endcond
//______________________________________________________________________________
-AliMUONVGeometryBuilder::AliMUONVGeometryBuilder(const TString& fileName,
- AliMUONChamber* ch1, AliMUONChamber* ch2,
- AliMUONChamber* ch3, AliMUONChamber* ch4,
- AliMUONChamber* ch5, AliMUONChamber* ch6)
+AliMUONVGeometryBuilder::AliMUONVGeometryBuilder(
+ Int_t firstModuleId,
+ Int_t nofModules)
: TObject(),
- fTransformFileName(fgkTransformFileNamePrefix+fileName),
- fSVMapFileName(fgkSVMapFileNamePrefix+fileName),
- fChambers(0)
+ fGeometryModules(0),
+ fReferenceFrame()
{
-// Standard constructor
+/// Standard constructor
- // Create the chambers array
- fChambers = new TObjArray();
-
- if (ch1) fChambers->Add(ch1);
- if (ch2) fChambers->Add(ch2);
- if (ch3) fChambers->Add(ch3);
- if (ch4) fChambers->Add(ch4);
- if (ch5) fChambers->Add(ch5);
- if (ch6) fChambers->Add(ch6);
+ // Create the module geometries array
+ fGeometryModules = new TObjArray();
+ fGeometryModules->SetOwner(kFALSE);
+
+ for (Int_t i=0; i<nofModules; i++ )
+ fGeometryModules->Add(new AliMUONGeometryModule(firstModuleId++));
}
-
//______________________________________________________________________________
AliMUONVGeometryBuilder::AliMUONVGeometryBuilder()
: TObject(),
- fTransformFileName(),
- fSVMapFileName(),
- fChambers(0)
+ fGeometryModules(0),
+ fReferenceFrame()
{
-// Default constructor
+/// Default constructor
}
-
//______________________________________________________________________________
-AliMUONVGeometryBuilder::AliMUONVGeometryBuilder(const AliMUONVGeometryBuilder& rhs)
- : TObject(rhs)
+AliMUONVGeometryBuilder::~AliMUONVGeometryBuilder()
{
-// Protected copy constructor
+/// Destructor
- Fatal("Copy constructor",
- "Copy constructor is not implemented.");
+ if (fGeometryModules) {
+ fGeometryModules->Clear(); // Sets pointers to 0 since it is not the owner
+ delete fGeometryModules;
+ }
}
-//______________________________________________________________________________
-AliMUONVGeometryBuilder::~AliMUONVGeometryBuilder() {
//
- if (fChambers) {
- fChambers->Clear(); // Sets pointers to 0 sinche it is not the owner
- delete fChambers;
- }
-}
+// private methods
+//
//______________________________________________________________________________
-AliMUONVGeometryBuilder&
-AliMUONVGeometryBuilder::operator = (const AliMUONVGeometryBuilder& rhs)
+TGeoHMatrix
+AliMUONVGeometryBuilder::ConvertTransform(const TGeoHMatrix& transform) const
{
-// Protected assignement operator
-
- // check assignement to self
- if (this == &rhs) return *this;
-
- Fatal("operator=",
- "Assignment operator is not implemented.");
-
- return *this;
+/// Convert transformation into the reference frame
+
+ if ( fReferenceFrame.IsIdentity() )
+ return transform;
+ else {
+ return AliMUONGeometryBuilder::Multiply( fReferenceFrame,
+ transform,
+ fReferenceFrame.Inverse() );
+ }
}
-//
-// private methods
-//
+//______________________________________________________________________________
+TGeoHMatrix
+AliMUONVGeometryBuilder::ConvertDETransform(const TGeoHMatrix& transform) const
+{
+/// Convert DE transformation into the reference frame
+
+ if ( fReferenceFrame.IsIdentity() )
+ return transform;
+ else {
+ return AliMUONGeometryBuilder::Multiply( fReferenceFrame,
+ transform );
+ }
+}
//______________________________________________________________________________
- TString AliMUONVGeometryBuilder::ComposePath(const TString& volName,
- Int_t copyNo) const
+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(volName);
- path += ".";
+ TString path = "/";
+ path += volName;
+ path += '_';
path += copyNo;
return path;
}
-/*
//______________________________________________________________________________
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 = AliMpDEManager::GetGeomModuleId(detElemId);
+ AliMUONStringIntMap* svMap = GetSVMap(moduleId);
Int_t nofDaughters = gMC->NofVolDaughters(volName);
if (nofDaughters == 0) {
// 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));
+ Ssiz_t npos2 = path0.Last('_');
+ TString volName0(path0(npos1, npos2-npos1));
// Check if it is sensitive volume
- Int_t chamberId = AliMUONConstants::GetChamberId(detElemId);
- AliMUONChamberGeometry* geometry = GetChamber(chamberId)->GetGeometry();
- if (geometry->IsSensitiveVolume(volName)) {
+ AliMUONGeometryModule* geometry = GetGeometry(moduleId);
+ if ( geometry->IsSensitiveVolume(volName0) &&
+ ! svMap->Get(path0) ) {
//cout << ".. adding to the map "
// << path0 << " " << detElemId << endl;
- FillData(path0, detElemId);
+
+ // Map the sensitive volume to detection element
+ svMap->Add(path0, detElemId);
}
return;
}
TString newName = gMC->VolDaughterName(volName, i);
TString path = path0;
- path += "/";
path += ComposePath(newName, copyNo);
MapSV(path, newName, detElemId);
}
}
-*/
-
-//______________________________________________________________________________
-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
-// ---
-
- Warning("MapSV", "Not yet available");
-}
-
-//______________________________________________________________________________
-void AliMUONVGeometryBuilder::FillData(Int_t chamberId,
- 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 chamber.
-// ---
- chamberId--;
- // Chambers numbers in the file are starting from 1
+//
+// protected methods
+//
- GetChamber(chamberId)->GetGeometry()
- ->SetTranslation(TGeoTranslation(x, y, z));
- GetChamber(chamberId)->GetGeometry()
- ->SetRotation(TGeoRotation("rot", a1, a2, a3, a4, a5, a6));
-}
-
//______________________________________________________________________________
-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
+AliMUONGeometryModule*
+AliMUONVGeometryBuilder::GetGeometry(Int_t moduleId) const
{
-// Fill the transformation of the detection element.
-// ---
+/// Return the module geometry specified by moduleId
- // Chamber Id
- Int_t chamberId = AliMUONConstants::GetChamberId(detElemId);
+ for (Int_t i=0; i<fGeometryModules->GetEntriesFast(); i++) {
- // Get chamber transformations
- AliMUONGeometryTransformStore* transforms
- = GetTransforms(chamberId);
+ AliMUONGeometryModule* geometry
+ = (AliMUONGeometryModule*)fGeometryModules->At(i);
- // Compose path
- TString path = ComposePath(volName, copyNo);
-
- // Compose matrix
- TGeoCombiTrans transform(path, x, y, z,
- new TGeoRotation(path, a1, a2, a3, a4, a5, a6));
-
- // Add detection element transformation
- transforms->Add(detElemId, path, transform);
-}
+ if ( geometry->GetModuleId() == moduleId) return geometry;
+ }
-//______________________________________________________________________________
-void AliMUONVGeometryBuilder::FillData(
- const TString& sensVolumePath, Int_t detElemId) const
-{
-// Fill the mapping of the sensitive volume path to the detection element.
-// ---
-
- // Chamber Id
- Int_t chamberId = AliMUONConstants::GetChamberId(detElemId);
-
- // Get chamber transformations
- AliMUONGeometrySVMap* svMap = GetSVMap(chamberId);
+ return 0;
+}
- // Map the sensitive volume to detection element
- svMap->Add(sensVolumePath, detElemId);
-}
-
//______________________________________________________________________________
-TString AliMUONVGeometryBuilder::ReadData1(ifstream& in) const
+AliMUONGeometryEnvelopeStore*
+AliMUONVGeometryBuilder::GetEnvelopes(Int_t moduleId) const
{
-// Reads and fills chambers transformations from a file
-// Returns true, if reading finished correctly.
-// ---
-
- TString key("CH");
- while ( key == TString("CH") ) {
- Int_t id;
- Double_t x, y, z;
- Double_t a1, a2, a3, a4, a5, a6;
- TString dummy;
-
- in >> id;
- 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, x, y, z, a1, a2, a3, a4, a5, a6);
-
- // Go to next line
- in >> key;
- }
-
- return key;
-}
+/// Return the envelope store of the module geometry specified by moduleId
-//______________________________________________________________________________
-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;
+ AliMUONGeometryModule* geometry = GetGeometry(moduleId);
- 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;
- }
+ if (!geometry) {
+ AliFatal(Form("Module geometry %d is not defined", moduleId));
+ return 0;
+ }
- return key;
-}
+ return geometry->GetEnvelopeStore();
+}
//______________________________________________________________________________
-TString AliMUONVGeometryBuilder::ReadData3(ifstream& in) const
+AliMUONStringIntMap*
+AliMUONVGeometryBuilder::GetSVMap(Int_t moduleId) const
{
-// Reads detection elements transformations from a file
-// Returns true, if reading finished correctly.
-// ---
-
- TString key("SV");
- while ( key == TString("SV") ) {
+/// Return the transformation store of the module geometry specified by moduleId
- // Input data
- TString volumePath;
- Int_t detElemId;
+ AliMUONGeometryModule* geometry = GetGeometry(moduleId);
- 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
-// ---
-
- out << " pos: ";
- const Double_t* xyz = transform->GetTranslation();
- out << setw(10) << setprecision(4) << xyz[0] << " "
- << setw(10) << setprecision(4) << xyz[1] << " "
- << setw(10) << setprecision(4) << xyz[2];
-
- out << " rot: ";
- Double_t a1, a2, a3, a4, a5, a6;
- TGeoRotation* rotation = transform->GetRotation();
- 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 chamber transformations
-// ---
-
- for (Int_t i=0; i<fChambers->GetEntriesFast(); i++) {
- AliMUONChamber* chamber
- = (AliMUONChamber*)fChambers->At(i);
- AliMUONChamberGeometry* chamberGeometry
- = chamber->GetGeometry();
- const TGeoCombiTrans* transform
- = chamberGeometry->GetTransformation();
-
- out << "CH "
- << setw(4) << chamber->GetId() + 1 << " ";
-
- WriteTransform(out, transform);
+ if (!geometry) {
+ AliFatal(Form("Geometry %d is not defined", moduleId));
+ return 0;
}
- out << endl;
-}
+
+ return geometry->GetSVMap();
+}
//______________________________________________________________________________
-void AliMUONVGeometryBuilder::WriteData2(ofstream& out) const
+Int_t
+AliMUONVGeometryBuilder::GetModuleId(const TString& envName) const
{
-// Writes detection elements (envelopes) transformations
-// ---
+/// Return module Id which has the envelope with given name
+ for (Int_t i=0; i<fGeometryModules->GetEntriesFast(); i++) {
- for (Int_t i=0; i<fChambers->GetEntriesFast(); i++) {
- AliMUONChamber* chamber
- = (AliMUONChamber*)fChambers->At(i);
- AliMUONChamberGeometry* chamberGeometry
- = chamber->GetGeometry();
- const TObjArray* envelopes
- = chamberGeometry->GetEnvelopeStore()->GetEnvelopes();
-
- for (Int_t j=0; j<envelopes->GetEntriesFast(); j++) {
- AliMUONGeometryEnvelope* envelope
- = (AliMUONGeometryEnvelope*)envelopes->At(j);
- const TGeoCombiTrans* transform
- = envelope->GetTransformation();
+ AliMUONGeometryModule* geometry
+ = (AliMUONGeometryModule*)fGeometryModules->At(i);
- // 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; i<fChambers->GetEntriesFast(); i++) {
- AliMUONChamber* chamber
- = (AliMUONChamber*)fChambers->At(i);
- AliMUONChamberGeometry* chamberGeometry
- = chamber->GetGeometry();
- AliMUONGeometrySVMap* svMap
- = chamberGeometry->GetSVMap();
-
- svMap->WriteMap(out);
- out << endl;
- }
-}
-
-//
-// protected methods
-//
-
-//______________________________________________________________________________
-AliMUONChamber* AliMUONVGeometryBuilder::GetChamber(Int_t chamberId) const
-{
-// Returns the chamber specified by chamberId
-// ---
-
- for (Int_t i=0; i<fChambers->GetEntriesFast(); i++) {
- AliMUONChamber* chamber = (AliMUONChamber*)fChambers->At(i);
- if ( chamber->GetId() == chamberId) return chamber;
+ if ( geometry->GetEnvelopeStore()->FindEnvelope(envName) )
+ return geometry->GetModuleId();
}
- return 0;
+ return -1;
}
+
//______________________________________________________________________________
-AliMUONGeometryEnvelopeStore*
-AliMUONVGeometryBuilder::GetEnvelopes(Int_t chamberId) const
+void AliMUONVGeometryBuilder::SetTranslation(Int_t moduleId,
+ const TGeoTranslation& translation)
{
-// Returns the envelope store of the chamber specified by chamberId
-// ---
+/// Set the translation to the geometry module given by moduleId,
+/// apply reference frame transformation
- AliMUONChamber* chamber = GetChamber(chamberId);
+ AliMUONGeometryModule* geometry = GetGeometry(moduleId);
- if (!chamber) {
- Fatal("GetEnvelopes", "Chamber %d is not defined", chamberId);
- return 0;
+ if (!geometry) {
+ AliFatal(Form("Geometry %d is not defined", moduleId));
+ return;
}
- return chamber->GetGeometry()->GetEnvelopeStore();
+ // Apply frame transform
+ TGeoHMatrix newTransform = ConvertTransform(translation);
+
+ // Set new transformation
+ geometry->SetTransformation(newTransform);
}
+
//______________________________________________________________________________
-AliMUONGeometryTransformStore*
-AliMUONVGeometryBuilder::GetTransforms(Int_t chamberId) const
+void AliMUONVGeometryBuilder::SetTransformation(Int_t moduleId,
+ const TGeoTranslation& translation,
+ const TGeoRotation& rotation)
{
-// Returns the transformation store of the chamber specified by chamberId
-// ---
+/// Set the transformation to the geometry module given by moduleId,
+/// apply reference frame transformation
- AliMUONChamber* chamber = GetChamber(chamberId);
+ AliMUONGeometryModule* geometry = GetGeometry(moduleId);
- if (!chamber) {
- Fatal("GetTransforms", "Chamber %d is not defined", chamberId);
- return 0;
+ if (!geometry) {
+ AliFatal(Form("Geometry %d is not defined", moduleId));
+ return;
}
- return chamber->GetGeometry()->GetTransformStore();
+ TGeoCombiTrans transformation
+ = TGeoCombiTrans(translation, rotation);
+
+ // Apply frame transform
+ TGeoHMatrix newTransform = ConvertTransform(transformation);
+
+ // Set new transformation
+ geometry->SetTransformation(newTransform);
}
//______________________________________________________________________________
-AliMUONGeometrySVMap*
-AliMUONVGeometryBuilder::GetSVMap(Int_t chamberId) const
+void AliMUONVGeometryBuilder::SetVolume(Int_t moduleId,
+ const TString& volumeName,
+ Bool_t isVirtual)
{
-// Returns the transformation store of the chamber specified by chamberId
-// ---
+/// Set volume name, virtuality
- AliMUONChamber* chamber = GetChamber(chamberId);
+ TString path = GetGeometry(moduleId)->GetVolumePath();
+ // cout << "in AliMUONVGeometryBuilder::SetVolume " << path.Data() << endl;
- if (!chamber) {
- Fatal("GetSVMap", "Chamber %d is not defined", chamberId);
- return 0;
- }
+ if ( path == "" ) path = "/ALIC_1";
+ path += ComposePath(volumeName, 1);
+
+ GetGeometry(moduleId)->SetVolumePath(path);
+ GetGeometry(moduleId)->SetIsVirtual(isVirtual);
+ // cout << "... set " << path.Data() << endl;
+}
+
+//______________________________________________________________________________
+void AliMUONVGeometryBuilder::SetMotherVolume(Int_t moduleId,
+ const TString& volumeName)
+{
+/// Set mother volume name
+
+ TString motherVolumeName = ComposePath(volumeName, 1);
+
+ TString path = GetGeometry(moduleId)->GetVolumePath();
+ if ( path == "" ) path = "/ALIC_1";
+ path.Insert(7, motherVolumeName);
- return chamber->GetGeometry()->GetSVMap();
-}
+ GetGeometry(moduleId)->SetVolumePath(path);
+}
//
// public functions
//
//______________________________________________________________________________
-void AliMUONVGeometryBuilder:: FillTransformations() const
+void AliMUONVGeometryBuilder::SetReferenceFrame(
+ const TGeoCombiTrans& referenceFrame)
+{
+/// Set reference frame to builder and to all associated geometry
+/// modules
+
+ fReferenceFrame = referenceFrame;
+
+ for (Int_t i=0; i<fGeometryModules->GetEntriesFast(); i++) {
+ AliMUONGeometryModule* geometry
+ = (AliMUONGeometryModule*)fGeometryModules->At(i);
+ AliMUONGeometryEnvelopeStore* envelopeStore
+ = geometry->GetEnvelopeStore();
+
+ envelopeStore->SetReferenceFrame(referenceFrame);
+ }
+}
+
+//______________________________________________________________________________
+void AliMUONVGeometryBuilder::UpdateDetElements(Bool_t create) const
{
-// Fills transformations store from defined geometry.
-// ---
-
- for (Int_t i=0; i<fChambers->GetEntriesFast(); i++) {
- AliMUONChamber* chamber
- = (AliMUONChamber*)fChambers->At(i);
- AliMUONChamberGeometry* chamberGeometry
- = chamber->GetGeometry();
+/// 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
+ = (AliMUONGeometryModule*)fGeometryModules->At(i);
+
const TObjArray* envelopes
- = chamberGeometry->GetEnvelopeStore()->GetEnvelopes();
- AliMUONGeometryTransformStore* transforms
- = chamberGeometry->GetTransformStore();
-
+ = geometry->GetEnvelopeStore()->GetEnvelopes();
+
+ AliMpExMap* detElements
+ = geometry->GetTransformer()->GetDetElementStore();
+
for (Int_t j=0; j<envelopes->GetEntriesFast(); j++) {
AliMUONGeometryEnvelope* envelope
= (AliMUONGeometryEnvelope*)envelopes->At(j);
// skip envelope not corresponding to detection element
- if(envelope->GetUniqueID() == 0) continue;
+ if ( envelope->GetUniqueID() == 0) continue;
// Get envelope data
Int_t detElemId = envelope->GetUniqueID();
- TString path = ComposePath(envelope->GetName(),
- envelope->GetCopyNo());
- const TGeoCombiTrans* transform = envelope->GetTransformation();
- // Add detection element transformation
- transforms->Add(detElemId, path, *transform);
- }
+ // Compose full volume path
+ TString volPath = geometry->GetVolumePath();
+ volPath += ComposePath(envelope->GetName(), envelope->GetCopyNo());
+
+ 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);
+ }
+ else {
+ // Get existing det elements
+ AliMUONGeometryDetElement* detElement
+ = (AliMUONGeometryDetElement*)detElements->GetValue(detElemId);
+
+ // Set volume path
+ detElement->SetVolumePath(volPath);
+ }
+ }
}
}
//_____ _________________________________________________________________________
-void AliMUONVGeometryBuilder::RebuildSVMaps() const
+void AliMUONVGeometryBuilder::RebuildSVMaps(Bool_t withEnvelopes) const
{
-// Clear the SV maps in memory and fill them from defined geometry.
-// ---
-
- for (Int_t i=0; i<fChambers->GetEntriesFast(); i++) {
- AliMUONChamber* chamber
- = (AliMUONChamber*)fChambers->At(i);
- AliMUONChamberGeometry* chamberGeometry
- = chamber->GetGeometry();
+/// Clear the SV maps in memory and fill them from defined geometry.
+
+ for (Int_t i=0; i<fGeometryModules->GetEntriesFast(); i++) {
+ AliMUONGeometryModule* geometry
+ = (AliMUONGeometryModule*)fGeometryModules->At(i);
// Clear the map
- chamberGeometry->GetSVMap()->Clear();
+ geometry->GetSVMap()->Clear();
// Fill the map from geometry
const TObjArray* envelopes
- = chamberGeometry->GetEnvelopeStore()->GetEnvelopes();
+ = geometry->GetEnvelopeStore()->GetEnvelopes();
for (Int_t j=0; j<envelopes->GetEntriesFast(); j++) {
AliMUONGeometryEnvelope* envelope
= (AliMUONGeometryEnvelope*)envelopes->At(j);
// skip envelope not corresponding to detection element
- if(envelope->GetUniqueID() == 0) continue;
-
- TString path0("/ALIC.1");
- if (chamberGeometry->GetMotherVolume() != "ALIC") {
- path0 += "/";
- path0 += ComposePath(chamberGeometry->GetMotherVolume(), 1);
+ if ( envelope->GetUniqueID() == 0 ) continue;
+
+ // Get volume path of detection element
+ AliMUONGeometryDetElement* detElement
+ = geometry->GetTransformer()->GetDetElement(envelope->GetUniqueID());
+ std::string path0 = detElement->GetVolumePath().Data();
+
+ if ( ! withEnvelopes && geometry->IsVirtual() ) {
+ std::string vName = geometry->GetTransformer()->GetVolumeName().Data();
+ std::string vPath = ComposePath(vName, 1).Data();
+ std::string::size_type vPathPos = path0.find(vPath);
+ if ( vPathPos != std::string::npos )
+ path0.erase(vPathPos, vPath.size());
}
- if (!envelope->IsVirtual()) {
- TString path = path0;
- path += "/";
- path += ComposePath(envelope->GetName(), envelope->GetCopyNo());
- MapSV(path, envelope->GetName(), envelope->GetUniqueID());
+ if ( ! withEnvelopes && envelope->IsVirtual()) {
+ std::string eName = envelope->GetName();
+ std::string ePath = ComposePath(eName, envelope->GetCopyNo()).Data();
+ std::string::size_type ePathPos = path0.find(ePath);
+ if ( ePathPos != std::string::npos )
+ path0.erase(ePathPos, ePath.size());
}
- else {
+
+ if ( ! envelope->IsVirtual() )
+ MapSV(path0, envelope->GetName(), envelope->GetUniqueID());
+ else {
for (Int_t k=0; k<envelope->GetConstituents()->GetEntriesFast(); k++) {
AliMUONGeometryConstituent* constituent
= (AliMUONGeometryConstituent*)envelope->GetConstituents()->At(k);
TString path = path0;
- path += "/";
path += ComposePath(constituent->GetName(), constituent->GetCopyNo());
MapSV(path, constituent->GetName(), envelope->GetUniqueID());
}
}
}
-//______________________________________________________________________________
-Bool_t AliMUONVGeometryBuilder::ReadTransformations() const
-{
-// Reads transformations from a file
-// Returns true, if reading finished correctly.
-// ---
-
- // 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;
- Fatal("ReadTransformations", "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 {
- Fatal("ReadTransformations", "%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.
-// ---
-
- // 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;
- Fatal("ReadSVMap", "File not found.");
- return false;
- }
-
- TString key;
- in >> key;
- while ( !in.eof() ) {
- if (key == TString("SV"))
- key = ReadData3(in);
- else {
- Fatal("ReadSVMap", "%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.
-// ---
-
- // 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;
- Error("WriteTransformations", "File not found.");
- return false;
- }
- out.setf(std::ios::fixed);
-
- 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.
-// ---
-
- // 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;
- Error("WriteTransformations", "File not found.");
- return false;
- }
- out.setf(std::ios::fixed);
-
- if (rebuild) RebuildSVMaps();
-
- WriteData3(out);
-
- return true;
-}
-