1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * SigmaEffect_thetadegrees *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpeateose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 // Class AliMUONGeometryTransformer
20 // ----------------------------
21 // Top container class for geometry transformations
22 // Author: Ivana Hrivnacova, IPN Orsay
23 //-----------------------------------------------------------------------------
25 #include "AliMUONGeometryTransformer.h"
26 #include "AliMUONGeometryModuleTransformer.h"
27 #include "AliMUONGeometryDetElement.h"
28 #include "AliMUONGeometryBuilder.h"
30 #include "AliMpDEManager.h"
31 #include "AliMpConstants.h"
32 #include "AliMpExMap.h"
34 #include "AliMpArea.h"
36 #include "AliMpVPadIterator.h"
38 #include "AliMpDEIterator.h"
40 #include "AliMpVSegmentation.h"
41 #include "AliMpSegmentation.h"
42 #include "AliMpExMapIterator.h"
44 #include "AliAlignObjMatrix.h"
45 #include "AliAlignObj.h"
47 #include <Riostream.h>
49 #include <TClonesArray.h>
50 #include <TGeoManager.h>
51 #include <TGeoPhysicalNode.h>
58 ClassImp(AliMUONGeometryTransformer)
62 // static private methods
65 //______________________________________________________________________________
66 const TString& AliMUONGeometryTransformer::GetDefaultDetectorName()
68 /// Default detector name
69 static const TString kDefaultDetectorName = "MUON";
70 return kDefaultDetectorName;
77 //______________________________________________________________________________
78 AliMUONGeometryTransformer::AliMUONGeometryTransformer()
81 fDetectorName(GetDefaultDetectorName()),
82 fModuleTransformers(0),
86 /// Standard constructor
88 // Create array for geometry modules
89 fModuleTransformers = new TObjArray(100);
90 fModuleTransformers->SetOwner(true);
93 //______________________________________________________________________________
94 AliMUONGeometryTransformer::AliMUONGeometryTransformer(TRootIOCtor* /*ioCtor*/)
97 fModuleTransformers(0),
101 /// Default constructor
104 //______________________________________________________________________________
105 AliMUONGeometryTransformer::~AliMUONGeometryTransformer()
109 delete fModuleTransformers;
110 delete fMisAlignArray;
119 //_____________________________________________________________________________
121 AliMUONGeometryTransformer::GetDEArea(Int_t detElemId) const
123 /// Get area (in global coordinates) covered by a given detection element
128 return static_cast<AliMpArea*>(fDEAreas->GetValue(detElemId));
131 //_____________________________________________________________________________
133 AliMUONGeometryTransformer::CreateDEAreas() const
137 fDEAreas = new AliMpExMap;
143 /// Generate the DE areas in global coordinates
145 while ( !it.IsDone() )
147 Int_t detElemId = it.CurrentDEId();
149 if ( !HasDE(detElemId) ) continue;
151 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::kCath0);
155 AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId);
157 Double_t xl(0.0), yl(0.0), zl(0.0);
158 Double_t dx(seg->GetDimensionX());
159 Double_t dy(seg->GetDimensionY());
161 if ( stationType == AliMp::kStation12 )
163 Double_t xmin(FLT_MAX);
164 Double_t xmax(-FLT_MAX);
165 Double_t ymin(FLT_MAX);
166 Double_t ymax(-FLT_MAX);
168 for ( Int_t icathode = 0; icathode < 2; ++icathode )
170 const AliMpVSegmentation* cathode
171 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(icathode));
173 AliMpVPadIterator* itp = cathode->CreateIterator();
177 while ( !itp->IsDone() )
179 AliMpPad pad = itp->CurrentItem();
180 AliMpArea a(pad.GetPositionX(),pad.GetPositionY(),
181 pad.GetDimensionX(), pad.GetDimensionY());
182 xmin = TMath::Min(xmin,a.LeftBorder());
183 xmax = TMath::Max(xmax,a.RightBorder());
184 ymin = TMath::Min(ymin,a.DownBorder());
185 ymax = TMath::Max(ymax,a.UpBorder());
192 xl = (xmin+xmax)/2.0;
193 yl = (ymin+ymax)/2.0;
194 dx = (xmax-xmin)/2.0;
195 dy = (ymax-ymin)/2.0;
197 Local2Global(detElemId,xl,yl,zl,xg,yg,zg);
201 Local2Global(detElemId,xl,yl,zl,xg,yg,zg);
204 fDEAreas->Add(detElemId,new AliMpArea(xg,yg,dx,dy));
210 //_____________________________________________________________________________
211 Bool_t AliMUONGeometryTransformer::LoadMapping() const
213 /// Load mapping from CDB
215 if ( ! AliMpCDB::LoadMpSegmentation() )
217 AliFatal("Could not access mapping from OCDB !");
224 //_____________________________________________________________________________
225 AliMUONGeometryModuleTransformer*
226 AliMUONGeometryTransformer::GetModuleTransformerNonConst(
227 Int_t index, Bool_t warn) const
229 /// Return the geometry module specified by index
231 if (index < 0 || index >= fModuleTransformers->GetEntriesFast()) {
234 << "Index: " << index << " outside limits" << std::endl;
239 return (AliMUONGeometryModuleTransformer*) fModuleTransformers->At(index);
242 //______________________________________________________________________________
243 TGeoHMatrix AliMUONGeometryTransformer::GetTransform(
244 Double_t x, Double_t y, Double_t z,
245 Double_t a1, Double_t a2, Double_t a3,
246 Double_t a4, Double_t a5, Double_t a6) const
248 /// Build the transformation from the given parameters
251 return TGeoCombiTrans(TGeoTranslation(x, y, z),
252 TGeoRotation("rot", a1, a2, a3, a4, a5, a6));
256 //______________________________________________________________________________
257 void AliMUONGeometryTransformer::FillModuleTransform(Int_t moduleId,
258 Double_t x, Double_t y, Double_t z,
259 Double_t a1, Double_t a2, Double_t a3,
260 Double_t a4, Double_t a5, Double_t a6)
262 /// Fill the transformation of the module.
264 AliMUONGeometryModuleTransformer* moduleTransformer
265 = GetModuleTransformerNonConst(moduleId, false);
267 if ( !moduleTransformer) {
269 << "Module " << moduleId << " has not volume path defined." << endl;
273 // Build the transformation from the parameters
274 TGeoHMatrix transform
275 = GetTransform(x, y, z, a1, a2, a3, a4, a5, a6);
277 moduleTransformer->SetTransformation(transform);
280 //______________________________________________________________________________
281 void AliMUONGeometryTransformer::FillDetElemTransform(
283 Double_t x, Double_t y, Double_t z,
284 Double_t a1, Double_t a2, Double_t a3,
285 Double_t a4, Double_t a5, Double_t a6)
287 /// Fill the transformation of the detection element.
290 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
292 // Get module transformer
293 const AliMUONGeometryModuleTransformer* kModuleTransformer
294 = GetModuleTransformer(moduleId);
296 if ( ! kModuleTransformer ) {
297 AliFatal(Form("Module transformer not defined, detElemId: %d", detElemId));
301 // Get detection element
302 AliMUONGeometryDetElement* detElement
303 = kModuleTransformer->GetDetElement(detElemId);
305 if ( ! detElement ) {
306 AliFatal(Form("Det element %d has not volume path defined", detElemId));
310 // Build the transformation from the parameters
311 TGeoHMatrix localTransform
312 = GetTransform(x, y, z, a1, a2, a3, a4, a5, a6);
313 detElement->SetLocalTransformation(localTransform);
315 // Compute global transformation
316 TGeoHMatrix globalTransform
317 = AliMUONGeometryBuilder::Multiply(
318 *kModuleTransformer->GetTransformation(),
320 detElement->SetGlobalTransformation(globalTransform);
323 //______________________________________________________________________________
324 TString AliMUONGeometryTransformer::ReadModuleTransforms(ifstream& in)
326 /// Read and fill modules transformations from the stream.
327 /// Return true, if reading finished correctly.
329 TString key(AliMUONGeometryModuleTransformer::GetModuleNamePrefix());
330 while ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() ) {
333 Double_t a1, a2, a3, a4, a5, a6;
349 //cout << "moduleId=" << id << " "
350 // << "position= " << x << ", " << y << ", " << z << " "
351 // << "rotation= " << a1 << ", " << a2 << ", " << a3 << ", "
352 // << a4 << ", " << a5 << ", " << a6
356 FillModuleTransform(id, x, y, z, a1, a2, a3, a4, a5, a6);
365 //______________________________________________________________________________
366 TString AliMUONGeometryTransformer::ReadDetElemTransforms(ifstream& in)
368 /// Read detection elements transformations from the stream.
369 /// Return true, if reading finished correctly.
371 TString key(AliMUONGeometryDetElement::GetDENamePrefix());
372 while ( key == AliMUONGeometryDetElement::GetDENamePrefix() ) {
377 Double_t a1, a2, a3, a4, a5, a6;
393 //cout << "detElemId=" << detElemId << " "
394 // << "position= " << x << ", " << y << ", " << z << " "
395 // << "rotation= " << a1 << ", " << a2 << ", " << a3 << ", "
396 // << a4 << ", " << a5 << ", " << a6
400 FillDetElemTransform(detElemId, x, y, z, a1, a2, a3, a4, a5, a6);
409 //______________________________________________________________________________
411 AliMUONGeometryTransformer::ReadTransformations(const TString& fileName)
413 /// Read transformations from a file.
414 /// Return true, if reading finished correctly.
417 TString filePath = gSystem->Getenv("ALICE_ROOT");
418 filePath += "/MUON/data/";
419 filePath += fileName;
422 ifstream in(filePath, ios::in);
424 cerr << filePath << endl;
425 AliFatal("File not found.");
431 while ( !in.eof() ) {
432 if ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() )
433 key = ReadModuleTransforms(in);
434 else if ( key == AliMUONGeometryDetElement::GetDENamePrefix() )
435 key = ReadDetElemTransforms(in);
437 AliFatal(Form("%s key not recognized", key.Data()));
445 //______________________________________________________________________________
446 void AliMUONGeometryTransformer::WriteTransform(ofstream& out,
447 const TGeoMatrix* transform) const
449 /// Write given transformation
452 const Double_t* xyz = transform->GetTranslation();
453 out << setw(10) << setprecision(4) << xyz[0] << " "
454 << setw(10) << setprecision(4) << xyz[1] << " "
455 << setw(10) << setprecision(4) << xyz[2];
458 const Double_t* rm = transform->GetRotationMatrix();
459 TGeoRotation rotation;
460 rotation.SetMatrix(const_cast<Double_t*>(rm));
461 Double_t a1, a2, a3, a4, a5, a6;
462 rotation.GetAngles(a1, a2, a3, a4, a5, a6);
464 out << setw(8) << setprecision(4) << a1 << " "
465 << setw(8) << setprecision(4) << a2 << " "
466 << setw(8) << setprecision(4) << a3 << " "
467 << setw(8) << setprecision(4) << a4 << " "
468 << setw(8) << setprecision(4) << a5 << " "
469 << setw(8) << setprecision(4) << a6 << " " << endl;
472 //______________________________________________________________________________
473 void AliMUONGeometryTransformer::WriteModuleTransforms(ofstream& out) const
475 /// Write module transformations for all module transformers
477 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
478 AliMUONGeometryModuleTransformer* moduleTransformer
479 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
480 const TGeoMatrix* transform
481 = moduleTransformer->GetTransformation();
484 out << AliMUONGeometryModuleTransformer::GetModuleNamePrefix() << " "
485 << setw(4) << moduleTransformer->GetModuleId();
487 WriteTransform(out, transform);
492 //______________________________________________________________________________
493 void AliMUONGeometryTransformer::WriteDetElemTransforms(ofstream& out) const
495 /// Write detection element transformations for all detection elements in all
496 /// module transformers
498 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
499 AliMUONGeometryModuleTransformer* moduleTransformer
500 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
501 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
502 TIter next(detElements->CreateIterator());
503 AliMUONGeometryDetElement* detElement;
504 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
506 const TGeoMatrix* transform
507 = detElement->GetLocalTransformation();
510 out << AliMUONGeometryDetElement::GetDENamePrefix() << " "
511 << setw(4) << detElement->GetId();
513 WriteTransform(out, transform);
519 //______________________________________________________________________________
520 TString AliMUONGeometryTransformer::GetModuleSymName(Int_t moduleId) const
522 /// Return the module symbolic name (use for alignment)
524 return "/" + fDetectorName + "/"
525 + AliMUONGeometryModuleTransformer::GetModuleName(moduleId);
528 //______________________________________________________________________________
529 TString AliMUONGeometryTransformer::GetDESymName(Int_t detElemId) const
531 /// Return the detection element symbolic name (used for alignment)
534 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
536 return GetModuleSymName(moduleId) + "/"
537 + AliMUONGeometryDetElement::GetDEName(detElemId);
544 //______________________________________________________________________________
546 AliMUONGeometryTransformer::LoadTransformations()
548 /// Load transformations for defined modules and detection elements
549 /// using AliGeomManager
551 if ( ! AliGeomManager::GetGeometry() ) {
552 AliFatal("Geometry has to be laoded in AliGeomManager first.");
556 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
557 AliMUONGeometryModuleTransformer* moduleTransformer
558 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
560 // Module symbolic name
561 TString symname = GetModuleSymName(moduleTransformer->GetModuleId());
563 // Set matrix from physical node
564 TGeoHMatrix* matrix = AliGeomManager::GetMatrix(symname);
566 AliErrorStream() << "Geometry module matrix not found." << endl;
569 moduleTransformer->SetTransformation(*matrix);
571 // Loop over detection elements
572 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
573 TIter next(detElements->CreateIterator());
574 AliMUONGeometryDetElement* detElement;
576 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
578 // Det element symbolic name
579 TString symnameDE = GetDESymName(detElement->GetId());
581 // Set global matrix from physical node
582 TGeoHMatrix* globalMatrix = AliGeomManager::GetMatrix(symnameDE);
583 if ( ! globalMatrix ) {
584 AliErrorStream() << "Detection element matrix not found." << endl;
587 detElement->SetGlobalTransformation(*globalMatrix, false);
590 TGeoHMatrix localMatrix =
591 AliMUONGeometryBuilder::Multiply(
592 (*matrix).Inverse(), (*globalMatrix) );
593 detElement->SetLocalTransformation(localMatrix, false);
599 //______________________________________________________________________________
601 AliMUONGeometryTransformer::LoadGeometryData(const TString& fileName)
603 /// Read geometry data either from ASCII file with transformations or
604 /// from root geometry file (if fileName has ".root" extension)
608 // Get file extension
609 std::string fileName2 = fileName.Data();
610 std::string rootExt = fileName2.substr(fileName2.size()-5, fileName2.size());
612 if ( rootExt != ".root" )
613 return ReadTransformations(fileName);
615 // Load root geometry
616 AliGeomManager::LoadGeometry(fileName.Data());
617 return LoadTransformations();
621 //______________________________________________________________________________
623 AliMUONGeometryTransformer::LoadGeometryData()
625 /// Load geometry data from already loaded Root geometry using AliGeomManager
627 if ( ! AliGeomManager::GetGeometry() ) {
628 AliErrorStream() << "Geometry has not been loaded in AliGeomManager" << endl;
634 return LoadTransformations();
637 //______________________________________________________________________________
639 AliMUONGeometryTransformer::WriteTransformations(const TString& fileName) const
641 /// Write transformations into a file.
642 /// Return true, if writing finished correctly.
645 // if builder is not associated with any geometry module
646 if (fModuleTransformers->GetEntriesFast() == 0) return false;
649 TString filePath = gSystem->Getenv("ALICE_ROOT");
650 filePath += "/MUON/data/";
651 filePath += fileName;
654 ofstream out(filePath, ios::out);
656 cerr << filePath << endl;
657 AliError("File not found.");
660 #if !defined (__DECCXX)
661 out.setf(std::ios::fixed);
663 WriteModuleTransforms(out);
664 WriteDetElemTransforms(out);
669 //______________________________________________________________________________
671 AliMUONGeometryTransformer::WriteMisAlignmentData(const TString& fileName) const
673 /// Write misalignment data into a file
674 /// Return true, if writing finished correctly.
677 // if builder is not associated with any geometry module
678 if ( fModuleTransformers->GetEntriesFast() == 0 ) {
679 AliWarningStream() << "No geometry modules defined." << endl;
684 // if builder has no mis-alignment data
685 if ( ! fMisAlignArray ) {
686 AliWarningStream() << "No mis-alignment data defined." << endl;
691 TString filePath = gSystem->Getenv("ALICE_ROOT");
692 filePath += "/MUON/data/";
693 filePath += fileName;
695 // Write mis-alignment data in the root file
696 TFile file(fileName.Data(), "RECREATE");
697 fMisAlignArray->Write();
703 //_____________________________________________________________________________
704 void AliMUONGeometryTransformer::AddModuleTransformer(
705 AliMUONGeometryModuleTransformer* moduleTransformer)
707 /// Add the module transformer to the array
709 // Expand the size if not sufficient
710 Int_t moduleId = moduleTransformer->GetModuleId();
711 if ( moduleId >= fModuleTransformers->GetSize() )
712 fModuleTransformers->Expand(moduleId+1);
714 fModuleTransformers->AddAt(moduleTransformer, moduleId);
717 //_____________________________________________________________________________
718 void AliMUONGeometryTransformer::AddMisAlignModule(Int_t moduleId,
719 const TGeoHMatrix& matrix, Bool_t bGlobal)
721 /// Build AliAlignObjMatrix with module ID, its volumePath
722 /// and the given delta transformation matrix
724 if ( ! fMisAlignArray )
725 fMisAlignArray = new TClonesArray("AliAlignObjMatrix", 200);
727 const AliMUONGeometryModuleTransformer* kTransformer
728 = GetModuleTransformer(moduleId);
729 if ( ! kTransformer ) {
730 AliErrorStream() << "Module " << moduleId << " not found." << endl;
734 // Get unique align object ID
735 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, moduleId);
737 // Create mis align matrix
738 TClonesArray& refArray =*fMisAlignArray;
739 Int_t pos = fMisAlignArray->GetEntriesFast();
740 new (refArray[pos]) AliAlignObjMatrix(GetModuleSymName(moduleId), volId,
741 const_cast<TGeoHMatrix&>(matrix),bGlobal);
744 //_____________________________________________________________________________
745 void AliMUONGeometryTransformer::AddMisAlignDetElement(Int_t detElemId,
746 const TGeoHMatrix& matrix, Bool_t bGlobal)
748 /// Build AliAlignObjMatrix with detection element ID, its volumePath
749 /// and the given delta transformation matrix
751 if ( ! fMisAlignArray )
752 fMisAlignArray = new TClonesArray("AliAlignObjMatrix", 200);
754 const AliMUONGeometryDetElement* kDetElement
755 = GetDetElement(detElemId);
757 if ( ! kDetElement ) {
758 AliErrorStream() << "Det element " << detElemId << " not found." << endl;
762 // Get unique align object ID
763 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, detElemId);
765 // Create mis align matrix
766 TClonesArray& refArray =*fMisAlignArray;
767 Int_t pos = fMisAlignArray->GetEntriesFast();
768 new(refArray[pos]) AliAlignObjMatrix(GetDESymName(detElemId), volId,
769 const_cast<TGeoHMatrix&>(matrix),bGlobal);
772 //______________________________________________________________________________
773 void AliMUONGeometryTransformer::CreateModules()
775 /// Create modules and their detection elements using info from mapping;
776 /// but do not fill matrices
778 // Load mapping as its info is used to define modules & DEs
781 if ( fModuleTransformers->GetEntriesFast() == 0 ) {
782 // Create modules only if they do not yet exist
784 // Loop over geometry module
785 for (Int_t moduleId = 0; moduleId < AliMpConstants::NofGeomModules(); ++moduleId ) {
787 // Create geometry module transformer
788 AliMUONGeometryModuleTransformer* moduleTransformer
789 = new AliMUONGeometryModuleTransformer(moduleId);
790 AddModuleTransformer(moduleTransformer);
794 // Loop over detection elements
796 for ( it.First(); ! it.IsDone(); it.Next() ) {
798 Int_t detElemId = it.CurrentDEId();
799 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
801 // Get detection element store
802 AliMpExMap* detElements =
803 GetModuleTransformer(moduleId)->GetDetElementStore();
805 // Add detection element
806 AliMUONGeometryDetElement* detElement
807 = new AliMUONGeometryDetElement(detElemId);
808 detElements->Add(detElemId, detElement);
812 //_____________________________________________________________________________
813 void AliMUONGeometryTransformer::AddAlignableVolumes() const
815 /// Set symbolic names and matrices to alignable objects to TGeo
817 if ( ! gGeoManager ) {
818 AliWarning("TGeoManager not defined.");
823 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
824 AliMUONGeometryModuleTransformer* module
825 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
827 // Set module symbolic name
829 = gGeoManager->SetAlignableEntry(GetModuleSymName(module->GetModuleId()),
830 module->GetVolumePath());
833 << "Volume path " << module->GetVolumePath().Data()
834 << " for geometry module " << module->GetModuleId() << " " << module
835 << " not found in geometry." << endl;
839 pnEntry->SetMatrix(new TGeoHMatrix(*module->GetTransformation()));
840 // the matrix will be deleted via TGeoManager
843 // Detection elements
844 AliMpExMap* detElements = module->GetDetElementStore();
845 TIter next(detElements->CreateIterator());
846 AliMUONGeometryDetElement* detElement;
848 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
850 // Set detection element symbolic name
851 TGeoPNEntry* pnEntryDE
852 = gGeoManager->SetAlignableEntry(GetDESymName(detElement->GetId()),
853 detElement->GetVolumePath());
857 << detElement->GetVolumePath().Data()
858 << " for detection element " << detElement->GetId()
859 << " not found in geometry." << endl;
862 // Set detection element matrix
863 pnEntryDE->SetMatrix(new TGeoHMatrix(*detElement->GetGlobalTransformation()));
864 // the matrix will be deleted via TGeoManager
870 //_____________________________________________________________________________
871 TClonesArray* AliMUONGeometryTransformer::CreateZeroAlignmentData() const
873 /// Create array with zero alignment data
875 // Create array for zero-alignment objects
876 TClonesArray* array = new TClonesArray("AliAlignObjMatrix", 200);
877 TClonesArray& refArray =*array;
878 array->SetOwner(true);
884 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
885 AliMUONGeometryModuleTransformer* module
886 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
888 Int_t moduleId = module->GetModuleId();
891 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, moduleId);
893 // Create mis align matrix
894 Int_t pos = array->GetEntriesFast();
895 new (refArray[pos]) AliAlignObjMatrix(GetModuleSymName(moduleId), volId, matrix, kTRUE);
898 // Detection elements
899 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
900 AliMUONGeometryModuleTransformer* moduleTransformer
901 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
903 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
904 TIter next(detElements->CreateIterator());
905 AliMUONGeometryDetElement* detElement;
907 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
909 Int_t detElemId = detElement->GetId();
912 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, detElemId);
914 // Create mis align matrix
915 Int_t pos = array->GetEntriesFast();
916 new (refArray[pos]) AliAlignObjMatrix(GetDESymName(detElemId), volId, matrix, kTRUE);
923 //_____________________________________________________________________________
924 void AliMUONGeometryTransformer::ClearMisAlignmentData()
926 /// Clear the array of misalignment data
928 if ( ! fMisAlignArray ) return;
930 fMisAlignArray->Delete();
933 //_____________________________________________________________________________
934 void AliMUONGeometryTransformer::Global2Local(Int_t detElemId,
935 Float_t xg, Float_t yg, Float_t zg,
936 Float_t& xl, Float_t& yl, Float_t& zl) const
938 /// Transform point from the global reference frame (ALIC)
939 /// to the local reference frame of the detection element specified
942 const AliMUONGeometryModuleTransformer* kTransformer
943 = GetModuleTransformerByDEId(detElemId);
946 kTransformer->Global2Local(detElemId, xg, yg, zg, xl, yl, zl);
949 //_____________________________________________________________________________
950 void AliMUONGeometryTransformer::Global2Local(Int_t detElemId,
951 Double_t xg, Double_t yg, Double_t zg,
952 Double_t& xl, Double_t& yl, Double_t& zl) const
954 /// Transform point from the global reference frame (ALIC)
955 /// to the local reference frame of the detection element specified
958 const AliMUONGeometryModuleTransformer* kTransformer
959 = GetModuleTransformerByDEId(detElemId);
962 kTransformer->Global2Local(detElemId, xg, yg, zg, xl, yl, zl);
965 //_____________________________________________________________________________
966 void AliMUONGeometryTransformer::Local2Global(Int_t detElemId,
967 Float_t xl, Float_t yl, Float_t zl,
968 Float_t& xg, Float_t& yg, Float_t& zg) const
970 /// Transform point from the local reference frame of the detection element
971 /// specified by detElemId to the global reference frame (ALIC).
973 const AliMUONGeometryModuleTransformer* kTransformer
974 = GetModuleTransformerByDEId(detElemId);
977 kTransformer->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
980 //_____________________________________________________________________________
981 void AliMUONGeometryTransformer::Local2Global(Int_t detElemId,
982 Double_t xl, Double_t yl, Double_t zl,
983 Double_t& xg, Double_t& yg, Double_t& zg) const
985 /// Transform point from the local reference frame of the detection element
986 /// specified by detElemId to the global reference frame (ALIC).
988 const AliMUONGeometryModuleTransformer* kTransformer
989 = GetModuleTransformerByDEId(detElemId);
992 kTransformer->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
995 //_____________________________________________________________________________
996 const AliMUONGeometryModuleTransformer*
997 AliMUONGeometryTransformer::GetModuleTransformer(Int_t index, Bool_t warn) const
999 /// Return the geometry module transformer specified by index
1001 return GetModuleTransformerNonConst(index, warn);
1004 //_____________________________________________________________________________
1005 const AliMUONGeometryModuleTransformer*
1006 AliMUONGeometryTransformer::GetModuleTransformerByDEId(Int_t detElemId,
1009 /// Return the geometry module transformer specified by detection element ID
1012 Int_t index = AliMpDEManager::GetGeomModuleId(detElemId);
1014 return GetModuleTransformer(index, warn);
1017 //_____________________________________________________________________________
1018 const AliMUONGeometryDetElement*
1019 AliMUONGeometryTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const
1021 /// Return detection element with given detElemId
1023 const AliMUONGeometryModuleTransformer* kTransformer
1024 = GetModuleTransformerByDEId(detElemId, warn);
1026 if (!kTransformer) return 0;
1028 return kTransformer->GetDetElement(detElemId, warn);
1031 //_____________________________________________________________________________
1032 Bool_t AliMUONGeometryTransformer::HasDE(Int_t detElemId) const
1034 /// Return true if detection element with given detElemId is defined
1036 const AliMUONGeometryModuleTransformer* kTransformer
1037 = GetModuleTransformerByDEId(detElemId, false);
1039 if (!kTransformer) return false;
1041 return ( kTransformer->GetDetElement(detElemId, false) != 0 );