]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONGeometryTransformer.cxx
remove calls to AliMUONTriggerDecision
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometryTransformer.cxx
index f6885a05892c9c25202e18ea3a27d57aaa5a1ed9..292c044b6eeba6fa74822a1de590f7118f8a9596 100644 (file)
 
 #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)
 {
@@ -58,22 +63,13 @@ AliMUONGeometryTransformer::AliMUONGeometryTransformer(Bool_t 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()
 {
@@ -83,20 +79,6 @@ 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
 //
@@ -125,8 +107,7 @@ TGeoHMatrix AliMUONGeometryTransformer::GetTransform(
                  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), 
@@ -138,8 +119,7 @@ TGeoHMatrix AliMUONGeometryTransformer::GetTransform(
 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
@@ -156,7 +136,7 @@ void AliMUONGeometryTransformer::FillModuleVolPath(Int_t moduleId,
 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);
@@ -178,8 +158,7 @@ void AliMUONGeometryTransformer::FillModuleTransform(Int_t moduleId,
                  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--;
@@ -207,8 +186,7 @@ void AliMUONGeometryTransformer::FillDetElemTransform(
                  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);
@@ -248,8 +226,7 @@ void AliMUONGeometryTransformer::FillDetElemTransform(
 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;
@@ -282,9 +259,8 @@ AliMUONGeometryTransformer::ReadVolPaths(ifstream& in)
 //______________________________________________________________________________
 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") ) {
@@ -325,9 +301,8 @@ TString  AliMUONGeometryTransformer::ReadModuleTransforms(ifstream& in)
 //______________________________________________________________________________
 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") ) {
@@ -371,7 +346,7 @@ TString  AliMUONGeometryTransformer::ReadDetElemTransforms(ifstream& in)
 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) {
@@ -437,9 +412,8 @@ AliMUONGeometryTransformer::LoadTransforms(TGeoManager* tgeoManager)
 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");
@@ -462,9 +436,8 @@ AliMUONGeometryTransformer::ReadVolPaths(const TString& fileName)
 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");
@@ -499,9 +472,8 @@ AliMUONGeometryTransformer::ReadTransformations(const TString& fileName)
 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");
@@ -521,8 +493,7 @@ AliMUONGeometryTransformer::ReadTransformations2(const TString& fileName)
 void AliMUONGeometryTransformer::WriteTransform(ofstream& out,
                                    const TGeoMatrix* transform) const
 {
-// Writes the transformations 
-// ---
+/// Write given transformation 
 
   out << "   pos: ";
   const Double_t* xyz = transform->GetTranslation();
@@ -548,7 +519,7 @@ void AliMUONGeometryTransformer::WriteTransform(ofstream& out,
 //______________________________________________________________________________
 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 
@@ -565,7 +536,8 @@ void AliMUONGeometryTransformer::WriteModuleVolPaths(ofstream& out) const
 //______________________________________________________________________________
 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 
@@ -589,7 +561,7 @@ void AliMUONGeometryTransformer::WriteDetElemVolPaths(ofstream& out) const
 //______________________________________________________________________________
 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 
@@ -609,8 +581,8 @@ void AliMUONGeometryTransformer::WriteModuleTransforms(ofstream& out) const
 //______________________________________________________________________________
 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 
@@ -633,6 +605,38 @@ void AliMUONGeometryTransformer::WriteDetElemTransforms(ofstream& out) const
   }     
 }
 
+//______________________________________________________________________________
+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
+{
+
+  const AliMUONGeometryDetElement* kDetElement 
+    = GetDetElement(detElemId);
+  if ( ! kDetElement ) {
+    AliErrorStream() << "Det element " << detElemId << " not found." << endl; 
+    return "";
+  }   
+  
+  // Module Id
+  Int_t moduleId = AliMUONGeometryStore::GetModuleId(detElemId);
+
+  return GetModuleSymName(moduleId) + "/" + kDetElement->GetDEName();
+}  
+
 //
 // public functions
 //
@@ -669,7 +673,7 @@ AliMUONGeometryTransformer::ReadGeometryData(
                                 TGeoManager* tgeoManager)
 {
 /// Load geometry data from root geometry using defined
-/// voluem paths from file
+/// volume paths from file
 
   Bool_t result1 = ReadVolPaths(volPathFileName);
 
@@ -701,9 +705,8 @@ AliMUONGeometryTransformer::WriteGeometryData(
 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
@@ -734,9 +737,8 @@ AliMUONGeometryTransformer::WriteVolumePaths(const TString& fileName) const
 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
@@ -767,9 +769,8 @@ AliMUONGeometryTransformer::WriteTransformations(const TString& fileName) const
 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
@@ -802,7 +803,7 @@ AliMUONGeometryTransformer::WriteMisAlignmentData(const TString& fileName) const
 void AliMUONGeometryTransformer::AddModuleTransformer(
                           AliMUONGeometryModuleTransformer* moduleTransformer)
 {
-/// Add the geometrymodule to the array
+/// Add the module transformer to the array
 
   fModuleTransformers->AddAt(moduleTransformer, 
                              moduleTransformer->GetModuleId());
@@ -812,7 +813,7 @@ void AliMUONGeometryTransformer::AddModuleTransformer(
 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 )
@@ -825,24 +826,21 @@ void  AliMUONGeometryTransformer::AddMisAlignModule(Int_t moduleId,
     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 )
@@ -856,19 +854,54 @@ void  AliMUONGeometryTransformer::AddMisAlignDetElement(Int_t detElemId,
     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
+    AliMUONGeometryStore* detElements 
+      = module->GetDetElementStore();    
+
+    for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
+      AliMUONGeometryDetElement* detElement
+        = (AliMUONGeometryDetElement*)detElements->GetEntry(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
 {
@@ -887,7 +920,6 @@ TClonesArray* AliMUONGeometryTransformer::CreateZeroAlignmentData() const
     AliMUONGeometryModuleTransformer* module 
       = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
 
-    TString path = module->GetVolumePath(); 
     Int_t moduleId = module->GetModuleId();
   
     // Align object ID
@@ -895,7 +927,7 @@ TClonesArray* AliMUONGeometryTransformer::CreateZeroAlignmentData() const
 
     // 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
@@ -909,7 +941,6 @@ TClonesArray* AliMUONGeometryTransformer::CreateZeroAlignmentData() const
       AliMUONGeometryDetElement* detElement
         = (AliMUONGeometryDetElement*)detElements->GetEntry(j);
        
-      TString path = detElement->GetVolumePath(); 
       Int_t detElemId = detElement->GetId();
   
       // Align object ID
@@ -917,7 +948,7 @@ TClonesArray* AliMUONGeometryTransformer::CreateZeroAlignmentData() const
 
       // 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);
     }
   }
   
@@ -990,7 +1021,7 @@ void AliMUONGeometryTransformer::Local2Global(Int_t 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);
 }    
@@ -1000,7 +1031,7 @@ const AliMUONGeometryModuleTransformer*
 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);
@@ -1012,7 +1043,7 @@ AliMUONGeometryTransformer::GetModuleTransformerByDEId(Int_t 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);