// $Id$
//
+// ----------------------------
// Class AliMUONGeometryTransformer
// ----------------------------
// Top container class for geometry transformations
-//
// Author: Ivana Hrivnacova, IPN Orsay
#include "AliMUONGeometryTransformer.h"
#include "AliLog.h"
#include "AliAlignObjMatrix.h"
+#include "AliAlignObj.h"
#include <Riostream.h>
#include <TSystem.h>
#include <TClonesArray.h>
#include <TGeoManager.h>
#include <TGeoPhysicalNode.h>
+#include <TFile.h>
#include <sstream>
+/// \cond CLASSIMP
ClassImp(AliMUONGeometryTransformer)
+/// \endcond
//______________________________________________________________________________
AliMUONGeometryTransformer::AliMUONGeometryTransformer(Bool_t isOwner)
/// 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);
Double_t a1, Double_t a2, Double_t a3,
Double_t a4, Double_t a5, Double_t a6)
{
-// Fill the transformation of the module.
-// ---
+/// Fill the transformation of the module.
// Get/Create geometry module transformer
moduleId--;
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);
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;
//______________________________________________________________________________
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 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") ) {
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) {
+ AliFatal("No TGeoManager defined.");
+ return false;
+ }
+
for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
AliMUONGeometryModuleTransformer* moduleTransformer
= (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
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");
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");
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
//______________________________________________________________________________
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
//______________________________________________________________________________
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
//______________________________________________________________________________
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
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
fModuleTransformers->AddAt(moduleTransformer,
moduleTransformer->GetModuleId());
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 )
// 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(), moduleId,
+ new (refArray[pos]) AliAlignObjMatrix(path.Data(), volId,
const_cast<TGeoHMatrix&>(matrix));
}
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 )
// 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(), detElemId,
+ new(refArray[pos]) AliAlignObjMatrix(path.Data(), volId,
const_cast<TGeoHMatrix&>(matrix));
}
+//_____________________________________________________________________________
+TClonesArray* AliMUONGeometryTransformer::CreateZeroAlignmentData() const
+{
+/// Create array with zero alignment data
+
+ // Create array for zero-alignment objects
+ TClonesArray* array = new TClonesArray("AliAlignObjMatrix", 200);
+ TClonesArray& refArray =*array;
+ array->SetOwner(true);
+
+ // Identity matrix
+ TGeoHMatrix matrix;
+
+ // Modules
+ for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
+ AliMUONGeometryModuleTransformer* module
+ = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
+
+ TString path = module->GetVolumePath();
+ Int_t moduleId = module->GetModuleId();
+
+ // Align object ID
+ Int_t volId = AliAlignObj::LayerToVolUID(AliAlignObj::kMUON, moduleId);
+
+ // Create mis align matrix
+ Int_t pos = array->GetEntriesFast();
+ new (refArray[pos]) AliAlignObjMatrix(path.Data(), volId, matrix);
+ }
+
+ // Detection elements
+ for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
+ AliMUONGeometryModuleTransformer* moduleTransformer
+ = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
+ AliMUONGeometryStore* detElements
+ = moduleTransformer->GetDetElementStore();
+
+ for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
+ AliMUONGeometryDetElement* detElement
+ = (AliMUONGeometryDetElement*)detElements->GetEntry(j);
+
+ TString path = detElement->GetVolumePath();
+ Int_t detElemId = detElement->GetId();
+
+ // Align object ID
+ Int_t volId = AliAlignObj::LayerToVolUID(AliAlignObj::kMUON, detElemId);
+
+ // Create mis align matrix
+ Int_t pos = array->GetEntriesFast();
+ new (refArray[pos]) AliAlignObjMatrix(path.Data(), volId, matrix);
+ }
+ }
+
+ return array;
+}
+
//_____________________________________________________________________________
void AliMUONGeometryTransformer::Global2Local(Int_t detElemId,
Float_t xg, Float_t yg, Float_t zg,
/// Transform point from the global reference frame (ALIC)
/// to the local reference frame of the detection element specified
/// by detElemId.
-
+
const AliMUONGeometryModuleTransformer* kTransformer
= GetModuleTransformerByDEId(detElemId);
/// Transform point from the global reference frame (ALIC)
/// to the local reference frame of the detection element specified
/// by detElemId.
-
+
const AliMUONGeometryModuleTransformer* kTransformer
= GetModuleTransformerByDEId(detElemId);
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);
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);