#include "AliMUONGeometryTransformer.h"
#include "AliMUONGeometryModuleTransformer.h"
#include "AliMUONGeometryDetElement.h"
-#include "AliMUONGeometryStore.h"
#include "AliMUONGeometryBuilder.h"
+#include "AliMpDEManager.h"
+#include "AliMpExMap.h"
+
#include "AliLog.h"
#include "AliAlignObjMatrix.h"
#include "AliAlignObj.h"
#include <sstream>
+/// \cond CLASSIMP
ClassImp(AliMUONGeometryTransformer)
+/// \endcond
//______________________________________________________________________________
-AliMUONGeometryTransformer::AliMUONGeometryTransformer(Bool_t isOwner)
+AliMUONGeometryTransformer::AliMUONGeometryTransformer(Bool_t isOwner,
+ const TString& detectorName)
+
: TObject(),
+ fDetectorName(detectorName),
fModuleTransformers(0),
fMisAlignArray(0)
{
/// Standard constructor
// Create array for geometry modules
- fModuleTransformers = new TObjArray();
+ fModuleTransformers = new TObjArray(100);
fModuleTransformers->SetOwner(isOwner);
}
//______________________________________________________________________________
AliMUONGeometryTransformer::AliMUONGeometryTransformer()
: TObject(),
+ fDetectorName(),
fModuleTransformers(0),
fMisAlignArray(0)
{
/// Default constructor
}
-//______________________________________________________________________________
-AliMUONGeometryTransformer::AliMUONGeometryTransformer(
- const AliMUONGeometryTransformer& right)
- : TObject(right)
-{
-/// Copy constructor (not implemented)
-
- AliFatal("Copy constructor not provided.");
-}
-
//______________________________________________________________________________
AliMUONGeometryTransformer::~AliMUONGeometryTransformer()
{
delete fMisAlignArray;
}
-//______________________________________________________________________________
-AliMUONGeometryTransformer&
-AliMUONGeometryTransformer::operator=(const AliMUONGeometryTransformer& right)
-{
-/// Assignement operator (not implemented)
-
- // check assignement to self
- if (this == &right) return *this;
-
- AliFatal("Assignement operator not provided.");
-
- return *this;
-}
-
//
// private methods
//
Double_t a1, Double_t a2, Double_t a3,
Double_t a4, Double_t a5, Double_t a6) const
{
-// Builds the transformation from the given parameters
-// ---
+/// Build the transformation from the given parameters
// Compose transform
return TGeoCombiTrans(TGeoTranslation(x, y, z),
void AliMUONGeometryTransformer::FillModuleVolPath(Int_t moduleId,
const TString& volPath)
{
-// Create module with the given moduleId and volPath
-// ---
+/// Create module with the given moduleId and volPath
// Get/Create geometry module transformer
AliMUONGeometryModuleTransformer* moduleTransformer
void AliMUONGeometryTransformer::FillDetElemVolPath(Int_t detElemId,
const TString& volPath)
{
-// Create detection element with the given detElemId and volPath
+/// Create detection element with the given detElemId and volPath
// Module Id
- Int_t moduleId = AliMUONGeometryStore::GetModuleId(detElemId);
+ Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
// Get detection element store
- AliMUONGeometryStore* detElements =
+ AliMpExMap* detElements =
GetModuleTransformer(moduleId)->GetDetElementStore();
// Add detection element
Double_t a1, Double_t a2, Double_t a3,
Double_t a4, Double_t a5, Double_t a6)
{
-// Fill the transformation of the module.
-// ---
-
- // Get/Create geometry module transformer
- moduleId--;
- // Modules numbers in the file are starting from 1
+/// Fill the transformation of the module.
AliMUONGeometryModuleTransformer* moduleTransformer
= GetModuleTransformerNonConst(moduleId, false);
Double_t a1, Double_t a2, Double_t a3,
Double_t a4, Double_t a5, Double_t a6)
{
-// Fill the transformation of the detection element.
-// ---
+/// Fill the transformation of the detection element.
// Module Id
- Int_t moduleId = AliMUONGeometryStore::GetModuleId(detElemId);
+ Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
// Get module transformer
const AliMUONGeometryModuleTransformer* kModuleTransformer
Bool_t
AliMUONGeometryTransformer::ReadVolPaths(ifstream& in)
{
-// Reads modules and detection element volume paths from stream
-// ---
+/// Read modules and detection element volume paths from stream
Int_t id;
TString key, volumePath;
// << "volPath= " << volumePath
// << endl;
- if ( key == TString("CH") )
+ if ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() )
FillModuleVolPath(id, volumePath);
- else if ( key == TString("DE") )
+ else if ( key == AliMUONGeometryDetElement::GetDENamePrefix() )
FillDetElemVolPath(id, volumePath);
else {
//______________________________________________________________________________
TString AliMUONGeometryTransformer::ReadModuleTransforms(ifstream& in)
{
-// Reads and fills modules transformations from a file
-// Returns true, if reading finished correctly.
-// ---
+/// Read and fill modules transformations from the stream.
+/// Return true, if reading finished correctly.
- TString key("CH");
- while ( key == TString("CH") ) {
+ TString key(AliMUONGeometryModuleTransformer::GetModuleNamePrefix());
+ while ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() ) {
Int_t id;
Double_t x, y, z;
Double_t a1, a2, a3, a4, a5, a6;
//______________________________________________________________________________
TString AliMUONGeometryTransformer::ReadDetElemTransforms(ifstream& in)
{
-// Reads detection elements transformations from a file
-// Returns true, if reading finished correctly.
-// ---
+/// Read detection elements transformations from the stream.
+/// Return true, if reading finished correctly.
- TString key("DE");
- while ( key == TString("DE") ) {
+ TString key(AliMUONGeometryDetElement::GetDENamePrefix());
+ while ( key == AliMUONGeometryDetElement::GetDENamePrefix() ) {
// Input data
Int_t detElemId;
Bool_t
AliMUONGeometryTransformer::LoadTransforms(TGeoManager* tgeoManager)
{
-/// Loads transformations for defined modules and detection elements
+/// Load transformations for defined modules and detection elements
/// from the root file
if ( !tgeoManager) {
moduleTransformer->SetTransformation(matrix);
// Loop over detection elements
- AliMUONGeometryStore* detElements
- = moduleTransformer->GetDetElementStore();
+ AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
- for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
+ for (Int_t j=0; j<detElements->GetSize(); j++) {
AliMUONGeometryDetElement* detElement
- = (AliMUONGeometryDetElement*)detElements->GetEntry(j);
+ = (AliMUONGeometryDetElement*)detElements->GetObject(j);
// Det element path
TString dePath = detElement->GetVolumePath();
Bool_t
AliMUONGeometryTransformer::ReadVolPaths(const TString& fileName)
{
-// Reads detection element volume paths from a file
-// Returns true, if reading finished correctly.
-// ---
+/// Read detection element volume paths from a file.
+/// Return true, if reading finished correctly.
// File path
TString filePath = gSystem->Getenv("ALICE_ROOT");
Bool_t
AliMUONGeometryTransformer::ReadTransformations(const TString& fileName)
{
-// Reads transformations from a file
-// Returns true, if reading finished correctly.
-// ---
+/// Read transformations from a file.
+/// Return true, if reading finished correctly.
// File path
TString filePath = gSystem->Getenv("ALICE_ROOT");
TString key;
in >> key;
while ( !in.eof() ) {
- if (key == TString("CH"))
+ if ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() )
key = ReadModuleTransforms(in);
- else if (key == TString("DE"))
+ else if ( key == AliMUONGeometryDetElement::GetDENamePrefix() )
key = ReadDetElemTransforms(in);
else {
AliFatal(Form("%s key not recognized", key.Data()));
Bool_t
AliMUONGeometryTransformer::ReadTransformations2(const TString& fileName)
{
-// Reads transformations from root geometry file
-// Returns true, if reading finished correctly.
-// ---
+/// Read transformations from root geometry file.
+/// Return true, if reading finished correctly.
// File path
TString filePath = gSystem->Getenv("ALICE_ROOT");
filePath += fileName;
// Load root geometry
- TGeoManager* tgeoManager = TGeoManager::Import(fileName);
+ TGeoManager* tgeoManager = gGeoManager;
+ if (!tgeoManager)
+ tgeoManager = TGeoManager::Import(fileName);
// Retrieve matrices
LoadTransforms(tgeoManager);
-
+
return true;
}
void AliMUONGeometryTransformer::WriteTransform(ofstream& out,
const TGeoMatrix* transform) const
{
-// Writes the transformations
-// ---
+/// Write given transformation
out << " pos: ";
const Double_t* xyz = transform->GetTranslation();
//______________________________________________________________________________
void AliMUONGeometryTransformer::WriteModuleVolPaths(ofstream& out) const
{
-// Write modules volume paths
+/// Write module volume paths for all module transformers
for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
AliMUONGeometryModuleTransformer* moduleTransformer
= (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
// Write data on out
- out << "CH "
+ out << AliMUONGeometryModuleTransformer::GetModuleNamePrefix() << " "
<< setw(4) << moduleTransformer->GetModuleId() << " "
<< moduleTransformer->GetVolumePath() << endl;
}
//______________________________________________________________________________
void AliMUONGeometryTransformer::WriteDetElemVolPaths(ofstream& out) const
{
-// Write detection elements volume paths
+/// Write detection element volume paths for all detection elements in all
+/// module transformers
for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
AliMUONGeometryModuleTransformer* moduleTransformer
= (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
- AliMUONGeometryStore* detElements
- = moduleTransformer->GetDetElementStore();
+ AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
- for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
+ for (Int_t j=0; j<detElements->GetSize(); j++) {
AliMUONGeometryDetElement* detElement
- = (AliMUONGeometryDetElement*)detElements->GetEntry(j);
+ = (AliMUONGeometryDetElement*)detElements->GetObject(j);
// Write data on out
- out << "DE "
+ out << AliMUONGeometryDetElement::GetDENamePrefix() << " "
<< setw(4) << detElement->GetId() << " "
<< detElement->GetVolumePath() << endl;
}
//______________________________________________________________________________
void AliMUONGeometryTransformer::WriteModuleTransforms(ofstream& out) const
{
-// Write modules transformations
+/// Write module transformations for all module transformers
for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
AliMUONGeometryModuleTransformer* moduleTransformer
= moduleTransformer->GetTransformation();
// Write data on out
- out << "CH "
- << setw(4) << moduleTransformer->GetModuleId() + 1;
+ out << AliMUONGeometryModuleTransformer::GetModuleNamePrefix() << " "
+ << setw(4) << moduleTransformer->GetModuleId();
WriteTransform(out, transform);
}
//______________________________________________________________________________
void AliMUONGeometryTransformer::WriteDetElemTransforms(ofstream& out) const
{
-// Writes detection elements transformations
-// ---
+/// Write detection element transformations for all detection elements in all
+/// module transformers
for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
AliMUONGeometryModuleTransformer* moduleTransformer
= (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
- AliMUONGeometryStore* detElements
- = moduleTransformer->GetDetElementStore();
+ AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
- for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
+ for (Int_t j=0; j<detElements->GetSize(); j++) {
AliMUONGeometryDetElement* detElement
- = (AliMUONGeometryDetElement*)detElements->GetEntry(j);
+ = (AliMUONGeometryDetElement*)detElements->GetObject(j);
const TGeoMatrix* transform
= detElement->GetLocalTransformation();
// Write data on out
- out << "DE " << setw(4) << detElement->GetId();
+ out << AliMUONGeometryDetElement::GetDENamePrefix() << " "
+ << setw(4) << detElement->GetId();
WriteTransform(out, transform);
}
}
}
+//______________________________________________________________________________
+TString AliMUONGeometryTransformer::GetModuleSymName(Int_t moduleId) const
+{
+/// Return the module symbolic name (use for alignment)
+
+ const AliMUONGeometryModuleTransformer* kTransformer
+ = GetModuleTransformer(moduleId);
+ if ( ! kTransformer ) {
+ AliErrorStream() << "Module " << moduleId << " not found." << endl;
+ return "";
+ }
+
+ return "/" + fDetectorName + "/" + kTransformer->GetModuleName();
+}
+
+//______________________________________________________________________________
+TString AliMUONGeometryTransformer::GetDESymName(Int_t detElemId) const
+{
+/// Return the detection element symbolic name (used for alignment)
+
+ const AliMUONGeometryDetElement* kDetElement
+ = GetDetElement(detElemId);
+ if ( ! kDetElement ) {
+ AliErrorStream() << "Det element " << detElemId << " not found." << endl;
+ return "";
+ }
+
+ // Module Id
+ Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+
+ return GetModuleSymName(moduleId) + "/" + kDetElement->GetDEName();
+}
+
//
// public functions
//
TGeoManager* tgeoManager)
{
/// Load geometry data from root geometry using defined
-/// voluem paths from file
+/// volume paths from file
Bool_t result1 = ReadVolPaths(volPathFileName);
Bool_t
AliMUONGeometryTransformer::WriteVolumePaths(const TString& fileName) const
{
-// Writes volume paths for modules and detection element volumes into a file
-// Returns true, if writing finished correctly.
-// ---
+/// Write volume paths for modules and detection element volumes into a file.
+/// Return true, if writing finished correctly.
// No writing
// if builder is not associated with any geometry module
Bool_t
AliMUONGeometryTransformer::WriteTransformations(const TString& fileName) const
{
-// Writes transformations into a file
-// Returns true, if writing finished correctly.
-// ---
+/// Write transformations into a file.
+/// Return true, if writing finished correctly.
// No writing
// if builder is not associated with any geometry module
Bool_t
AliMUONGeometryTransformer::WriteMisAlignmentData(const TString& fileName) const
{
-// Writes misalignment data into a file
-// Returns true, if writing finished correctly.
-// ---
+/// Write misalignment data into a file
+/// Return true, if writing finished correctly.
// No writing
// if builder is not associated with any geometry module
void AliMUONGeometryTransformer::AddModuleTransformer(
AliMUONGeometryModuleTransformer* moduleTransformer)
{
-/// Add the geometrymodule to the array
+/// Add the module transformer to the array
+
+ // Expand the size if not sufficient
+ Int_t moduleId = moduleTransformer->GetModuleId();
+ if ( moduleId >= fModuleTransformers->GetSize() )
+ fModuleTransformers->Expand(moduleId+1);
- fModuleTransformers->AddAt(moduleTransformer,
- moduleTransformer->GetModuleId());
+ fModuleTransformers->AddAt(moduleTransformer, moduleId);
}
//_____________________________________________________________________________
void AliMUONGeometryTransformer::AddMisAlignModule(Int_t moduleId,
const TGeoHMatrix& matrix)
{
-/// Build AliAlignObjMatrix with module ID, its volumePaths
+/// Build AliAlignObjMatrix with module ID, its volumePath
/// and the given delta transformation matrix
if ( ! fMisAlignArray )
return;
}
- // Get path
- TString path = kTransformer->GetVolumePath();
-
// Get unique align object ID
Int_t volId = AliAlignObj::LayerToVolUID(AliAlignObj::kMUON, moduleId);
// Create mis align matrix
TClonesArray& refArray =*fMisAlignArray;
Int_t pos = fMisAlignArray->GetEntriesFast();
- new (refArray[pos]) AliAlignObjMatrix(path.Data(), volId,
- const_cast<TGeoHMatrix&>(matrix));
+ new (refArray[pos]) AliAlignObjMatrix(GetModuleSymName(moduleId), volId,
+ const_cast<TGeoHMatrix&>(matrix),kTRUE);
}
//_____________________________________________________________________________
void AliMUONGeometryTransformer::AddMisAlignDetElement(Int_t detElemId,
const TGeoHMatrix& matrix)
{
-/// Build AliAlignObjMatrix with detection element ID, its volumePaths
+/// Build AliAlignObjMatrix with detection element ID, its volumePath
/// and the given delta transformation matrix
if ( ! fMisAlignArray )
return;
}
- // Get path
- TString path = kDetElement->GetVolumePath();
-
// Get unique align object ID
Int_t volId = AliAlignObj::LayerToVolUID(AliAlignObj::kMUON, detElemId);
// Create mis align matrix
TClonesArray& refArray =*fMisAlignArray;
Int_t pos = fMisAlignArray->GetEntriesFast();
- new(refArray[pos]) AliAlignObjMatrix(path.Data(), volId,
- const_cast<TGeoHMatrix&>(matrix));
+ new(refArray[pos]) AliAlignObjMatrix(GetDESymName(detElemId), volId,
+ const_cast<TGeoHMatrix&>(matrix),kTRUE);
}
+//_____________________________________________________________________________
+void AliMUONGeometryTransformer::AddAlignableVolumes() const
+{
+/// Set symbolic names to alignable objects to TGeo
+
+ if ( ! gGeoManager ) {
+ AliWarning("TGeoManager not defined.");
+ return;
+ }
+
+ // Modules
+ for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
+ AliMUONGeometryModuleTransformer* module
+ = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
+
+ // Set module symbolic name
+ gGeoManager->SetAlignableEntry(GetModuleSymName(module->GetModuleId()),
+ module->GetVolumePath());
+ //cout << "Module sym name: " << GetModuleSymName(module->GetModuleId())
+ // << " volPath: " << module->GetVolumePath() << endl;
+
+ // Detection elements
+ AliMpExMap* detElements = module->GetDetElementStore();
+
+ for (Int_t j=0; j<detElements->GetSize(); j++) {
+ AliMUONGeometryDetElement* detElement
+ = (AliMUONGeometryDetElement*)detElements->GetObject(j);
+
+ // Set detection element symbolic name
+ gGeoManager->SetAlignableEntry(GetDESymName(detElement->GetId()),
+ detElement->GetVolumePath());
+ //cout << "DE name: " << GetDESymName(detElement->GetId())
+ // << " volPath: " << detElement->GetVolumePath() << endl;
+ }
+ }
+}
+
//_____________________________________________________________________________
TClonesArray* AliMUONGeometryTransformer::CreateZeroAlignmentData() const
{
AliMUONGeometryModuleTransformer* module
= (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
- TString path = module->GetVolumePath();
Int_t moduleId = module->GetModuleId();
// Align object ID
// Create mis align matrix
Int_t pos = array->GetEntriesFast();
- new (refArray[pos]) AliAlignObjMatrix(path.Data(), volId, matrix);
+ new (refArray[pos]) AliAlignObjMatrix(GetModuleSymName(moduleId), volId, matrix, kTRUE);
}
// Detection elements
for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
AliMUONGeometryModuleTransformer* moduleTransformer
= (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
- AliMUONGeometryStore* detElements
- = moduleTransformer->GetDetElementStore();
+ AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
- for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
+ for (Int_t j=0; j<detElements->GetSize(); j++) {
AliMUONGeometryDetElement* detElement
- = (AliMUONGeometryDetElement*)detElements->GetEntry(j);
+ = (AliMUONGeometryDetElement*)detElements->GetObject(j);
- TString path = detElement->GetVolumePath();
Int_t detElemId = detElement->GetId();
// Align object ID
// Create mis align matrix
Int_t pos = array->GetEntriesFast();
- new (refArray[pos]) AliAlignObjMatrix(path.Data(), volId, matrix);
+ new (refArray[pos]) AliAlignObjMatrix(GetDESymName(detElemId), volId, matrix, kTRUE);
}
}
const AliMUONGeometryModuleTransformer*
AliMUONGeometryTransformer::GetModuleTransformer(Int_t index, Bool_t warn) const
{
-/// Return the geometry module specified by index
+/// Return the geometry module transformer specified by index
return GetModuleTransformerNonConst(index, warn);
}
AliMUONGeometryTransformer::GetModuleTransformerByDEId(Int_t detElemId,
Bool_t warn) const
{
-/// Return the geometry module specified by index
+/// Return the geometry module transformer specified by detection element ID
// Get module index
- Int_t index = AliMUONGeometryStore::GetModuleId(detElemId);
+ Int_t index = AliMpDEManager::GetGeomModuleId(detElemId);
return GetModuleTransformer(index, warn);
}
const AliMUONGeometryDetElement*
AliMUONGeometryTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const
{
-/// Return detection ellemnt with given detElemId
+/// Return detection element with given detElemId
const AliMUONGeometryModuleTransformer* kTransformer
= GetModuleTransformerByDEId(detElemId, warn);