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"
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)
61 const TString AliMUONGeometryTransformer::fgkDefaultDetectorName = "MUON";
63 //______________________________________________________________________________
64 AliMUONGeometryTransformer::AliMUONGeometryTransformer()
67 fDetectorName(fgkDefaultDetectorName),
68 fModuleTransformers(0),
72 /// Standard constructor
74 // Create array for geometry modules
75 fModuleTransformers = new TObjArray(100);
76 fModuleTransformers->SetOwner(true);
79 //______________________________________________________________________________
80 AliMUONGeometryTransformer::AliMUONGeometryTransformer(TRootIOCtor* /*ioCtor*/)
83 fModuleTransformers(0),
87 /// Default constructor
90 //______________________________________________________________________________
91 AliMUONGeometryTransformer::~AliMUONGeometryTransformer()
95 delete fModuleTransformers;
96 delete fMisAlignArray;
105 //_____________________________________________________________________________
107 AliMUONGeometryTransformer::GetDEArea(Int_t detElemId) const
109 /// Get area (in global coordinates) covered by a given detection element
114 return static_cast<AliMpArea*>(fDEAreas->GetValue(detElemId));
117 //_____________________________________________________________________________
119 AliMUONGeometryTransformer::CreateDEAreas() const
123 fDEAreas = new AliMpExMap(true);
129 /// Generate the DE areas in global coordinates
131 while ( !it.IsDone() )
133 Int_t detElemId = it.CurrentDEId();
135 if ( !HasDE(detElemId) ) continue;
137 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::kCath0);
141 AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId);
143 Double_t xl(0.0), yl(0.0), zl(0.0);
144 Double_t dx(seg->Dimensions().X());
145 Double_t dy(seg->Dimensions().Y());
147 if ( stationType == AliMp::kStation1 || stationType == AliMp::kStation2 )
149 Double_t xmin(FLT_MAX);
150 Double_t xmax(-FLT_MAX);
151 Double_t ymin(FLT_MAX);
152 Double_t ymax(-FLT_MAX);
154 for ( Int_t icathode = 0; icathode < 2; ++icathode )
156 const AliMpVSegmentation* cathode
157 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(icathode));
159 AliMpVPadIterator* it = cathode->CreateIterator();
163 while ( !it->IsDone() )
165 AliMpPad pad = it->CurrentItem();
166 AliMpArea a(pad.Position(),pad.Dimensions());
167 xmin = TMath::Min(xmin,a.LeftBorder());
168 xmax = TMath::Max(xmax,a.RightBorder());
169 ymin = TMath::Min(ymin,a.DownBorder());
170 ymax = TMath::Max(ymax,a.UpBorder());
177 xl = (xmin+xmax)/2.0;
178 yl = (ymin+ymax)/2.0;
179 dx = (xmax-xmin)/2.0;
180 dy = (ymax-ymin)/2.0;
182 Local2Global(detElemId,xl,yl,zl,xg,yg,zg);
186 Local2Global(detElemId,xl,yl,zl,xg,yg,zg);
189 fDEAreas->Add(detElemId,new AliMpArea(TVector2(xg,yg),TVector2(dx,dy)));
195 //_____________________________________________________________________________
196 Bool_t AliMUONGeometryTransformer::LoadMapping() const
198 /// Load mapping from CDB
200 if ( ! AliMpCDB::LoadMpSegmentation() )
202 AliFatal("Could not access mapping from OCDB !");
209 //_____________________________________________________________________________
210 AliMUONGeometryModuleTransformer*
211 AliMUONGeometryTransformer::GetModuleTransformerNonConst(
212 Int_t index, Bool_t warn) const
214 /// Return the geometry module specified by index
216 if (index < 0 || index >= fModuleTransformers->GetEntriesFast()) {
219 << "Index: " << index << " outside limits" << std::endl;
224 return (AliMUONGeometryModuleTransformer*) fModuleTransformers->At(index);
227 //______________________________________________________________________________
228 TGeoHMatrix AliMUONGeometryTransformer::GetTransform(
229 Double_t x, Double_t y, Double_t z,
230 Double_t a1, Double_t a2, Double_t a3,
231 Double_t a4, Double_t a5, Double_t a6) const
233 /// Build the transformation from the given parameters
236 return TGeoCombiTrans(TGeoTranslation(x, y, z),
237 TGeoRotation("rot", a1, a2, a3, a4, a5, a6));
241 //______________________________________________________________________________
242 void AliMUONGeometryTransformer::FillModuleTransform(Int_t moduleId,
243 Double_t x, Double_t y, Double_t z,
244 Double_t a1, Double_t a2, Double_t a3,
245 Double_t a4, Double_t a5, Double_t a6)
247 /// Fill the transformation of the module.
249 AliMUONGeometryModuleTransformer* moduleTransformer
250 = GetModuleTransformerNonConst(moduleId, false);
252 if ( !moduleTransformer) {
254 << "Module " << moduleId << " has not volume path defined." << endl;
257 // Build the transformation from the parameters
258 TGeoHMatrix transform
259 = GetTransform(x, y, z, a1, a2, a3, a4, a5, a6);
261 moduleTransformer->SetTransformation(transform);
264 //______________________________________________________________________________
265 void AliMUONGeometryTransformer::FillDetElemTransform(
267 Double_t x, Double_t y, Double_t z,
268 Double_t a1, Double_t a2, Double_t a3,
269 Double_t a4, Double_t a5, Double_t a6)
271 /// Fill the transformation of the detection element.
274 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
276 // Get module transformer
277 const AliMUONGeometryModuleTransformer* kModuleTransformer
278 = GetModuleTransformer(moduleId);
280 if ( ! kModuleTransformer ) {
281 AliFatal(Form("Module transformer not defined, detElemId: %d", detElemId));
285 // Get detection element
286 AliMUONGeometryDetElement* detElement
287 = kModuleTransformer->GetDetElement(detElemId);
289 if ( ! detElement ) {
290 AliFatal(Form("Det element %d has not volume path defined", detElemId));
294 // Build the transformation from the parameters
295 TGeoHMatrix localTransform
296 = GetTransform(x, y, z, a1, a2, a3, a4, a5, a6);
297 detElement->SetLocalTransformation(localTransform);
299 // Compute global transformation
300 TGeoHMatrix globalTransform
301 = AliMUONGeometryBuilder::Multiply(
302 *kModuleTransformer->GetTransformation(),
304 detElement->SetGlobalTransformation(globalTransform);
307 //______________________________________________________________________________
308 TString AliMUONGeometryTransformer::ReadModuleTransforms(ifstream& in)
310 /// Read and fill modules transformations from the stream.
311 /// Return true, if reading finished correctly.
313 TString key(AliMUONGeometryModuleTransformer::GetModuleNamePrefix());
314 while ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() ) {
317 Double_t a1, a2, a3, a4, a5, a6;
333 //cout << "moduleId=" << id << " "
334 // << "position= " << x << ", " << y << ", " << z << " "
335 // << "rotation= " << a1 << ", " << a2 << ", " << a3 << ", "
336 // << a4 << ", " << a5 << ", " << a6
340 FillModuleTransform(id, x, y, z, a1, a2, a3, a4, a5, a6);
349 //______________________________________________________________________________
350 TString AliMUONGeometryTransformer::ReadDetElemTransforms(ifstream& in)
352 /// Read detection elements transformations from the stream.
353 /// Return true, if reading finished correctly.
355 TString key(AliMUONGeometryDetElement::GetDENamePrefix());
356 while ( key == AliMUONGeometryDetElement::GetDENamePrefix() ) {
361 Double_t a1, a2, a3, a4, a5, a6;
377 //cout << "detElemId=" << detElemId << " "
378 // << "position= " << x << ", " << y << ", " << z << " "
379 // << "rotation= " << a1 << ", " << a2 << ", " << a3 << ", "
380 // << a4 << ", " << a5 << ", " << a6
384 FillDetElemTransform(detElemId, x, y, z, a1, a2, a3, a4, a5, a6);
393 //______________________________________________________________________________
395 AliMUONGeometryTransformer::ReadTransformations(const TString& fileName)
397 /// Read transformations from a file.
398 /// Return true, if reading finished correctly.
401 TString filePath = gSystem->Getenv("ALICE_ROOT");
402 filePath += "/MUON/data/";
403 filePath += fileName;
406 ifstream in(filePath, ios::in);
408 cerr << filePath << endl;
409 AliFatal("File not found.");
415 while ( !in.eof() ) {
416 if ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() )
417 key = ReadModuleTransforms(in);
418 else if ( key == AliMUONGeometryDetElement::GetDENamePrefix() )
419 key = ReadDetElemTransforms(in);
421 AliFatal(Form("%s key not recognized", key.Data()));
429 //______________________________________________________________________________
431 AliMUONGeometryTransformer::LoadTransformations()
433 /// Load transformations for defined modules and detection elements
434 /// using AliGeomManager
436 if ( ! AliGeomManager::GetGeometry() ) {
437 AliFatal("Geometry has to be laoded in AliGeomManager first.");
441 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
442 AliMUONGeometryModuleTransformer* moduleTransformer
443 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
445 // Module symbolic name
446 TString symname = GetModuleSymName(moduleTransformer->GetModuleId());
448 // Set matrix from physical node
449 TGeoHMatrix* matrix = AliGeomManager::GetMatrix(symname);
451 AliErrorStream() << "Geometry module matrix not found." << endl;
454 moduleTransformer->SetTransformation(*matrix);
456 // Loop over detection elements
457 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
459 for (Int_t j=0; j<detElements->GetSize(); j++) {
460 AliMUONGeometryDetElement* detElement
461 = (AliMUONGeometryDetElement*)detElements->GetObject(j);
463 // Det element symbolic name
464 TString symname = GetDESymName(detElement->GetId());
466 // Set global matrix from physical node
467 TGeoHMatrix* globalMatrix = AliGeomManager::GetMatrix(symname);
468 if ( ! globalMatrix ) {
469 AliErrorStream() << "Detection element matrix not found." << endl;
472 detElement->SetGlobalTransformation(*globalMatrix);
475 TGeoHMatrix localMatrix =
476 AliMUONGeometryBuilder::Multiply(
477 (*matrix).Inverse(), (*globalMatrix) );
478 detElement->SetLocalTransformation(localMatrix);
484 //______________________________________________________________________________
485 void AliMUONGeometryTransformer::WriteTransform(ofstream& out,
486 const TGeoMatrix* transform) const
488 /// Write given transformation
491 const Double_t* xyz = transform->GetTranslation();
492 out << setw(10) << setprecision(4) << xyz[0] << " "
493 << setw(10) << setprecision(4) << xyz[1] << " "
494 << setw(10) << setprecision(4) << xyz[2];
497 const Double_t* rm = transform->GetRotationMatrix();
498 TGeoRotation rotation;
499 rotation.SetMatrix(const_cast<Double_t*>(rm));
500 Double_t a1, a2, a3, a4, a5, a6;
501 rotation.GetAngles(a1, a2, a3, a4, a5, a6);
503 out << setw(8) << setprecision(4) << a1 << " "
504 << setw(8) << setprecision(4) << a2 << " "
505 << setw(8) << setprecision(4) << a3 << " "
506 << setw(8) << setprecision(4) << a4 << " "
507 << setw(8) << setprecision(4) << a5 << " "
508 << setw(8) << setprecision(4) << a6 << " " << endl;
511 //______________________________________________________________________________
512 void AliMUONGeometryTransformer::WriteModuleTransforms(ofstream& out) const
514 /// Write module transformations for all module transformers
516 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
517 AliMUONGeometryModuleTransformer* moduleTransformer
518 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
519 const TGeoMatrix* transform
520 = moduleTransformer->GetTransformation();
523 out << AliMUONGeometryModuleTransformer::GetModuleNamePrefix() << " "
524 << setw(4) << moduleTransformer->GetModuleId();
526 WriteTransform(out, transform);
531 //______________________________________________________________________________
532 void AliMUONGeometryTransformer::WriteDetElemTransforms(ofstream& out) const
534 /// Write detection element transformations for all detection elements in all
535 /// module transformers
537 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
538 AliMUONGeometryModuleTransformer* moduleTransformer
539 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
540 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
542 for (Int_t j=0; j<detElements->GetSize(); j++) {
543 AliMUONGeometryDetElement* detElement
544 = (AliMUONGeometryDetElement*)detElements->GetObject(j);
545 const TGeoMatrix* transform
546 = detElement->GetLocalTransformation();
549 out << AliMUONGeometryDetElement::GetDENamePrefix() << " "
550 << setw(4) << detElement->GetId();
552 WriteTransform(out, transform);
558 //______________________________________________________________________________
559 TString AliMUONGeometryTransformer::GetModuleSymName(Int_t moduleId) const
561 /// Return the module symbolic name (use for alignment)
563 return "/" + fDetectorName + "/"
564 + AliMUONGeometryModuleTransformer::GetModuleName(moduleId);
567 //______________________________________________________________________________
568 TString AliMUONGeometryTransformer::GetDESymName(Int_t detElemId) const
570 /// Return the detection element symbolic name (used for alignment)
573 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
575 return GetModuleSymName(moduleId) + "/"
576 + AliMUONGeometryDetElement::GetDEName(detElemId);
583 //______________________________________________________________________________
585 AliMUONGeometryTransformer::LoadGeometryData(const TString& fileName)
587 /// Read geometry data either from ASCII file with transformations or
588 /// from root geometry file (if fileName has ".root" extension)
592 // Get file extension
593 std::string fileName2 = fileName.Data();
594 std::string rootExt = fileName2.substr(fileName2.size()-5, fileName2.size());
596 if ( rootExt != ".root" )
597 return ReadTransformations(fileName);
599 // Load root geometry
600 AliGeomManager::LoadGeometry(fileName.Data());
601 return LoadTransformations();
605 //______________________________________________________________________________
607 AliMUONGeometryTransformer::LoadGeometryData()
609 /// Load geometry data from already loaded Root geometry using AliGeomManager
611 if ( ! AliGeomManager::GetGeometry() ) {
612 AliErrorStream() << "Geometry has not been loaded in AliGeomManager" << endl;
618 return LoadTransformations();
621 //______________________________________________________________________________
623 AliMUONGeometryTransformer::WriteTransformations(const TString& fileName) const
625 /// Write transformations into a file.
626 /// Return true, if writing finished correctly.
629 // if builder is not associated with any geometry module
630 if (fModuleTransformers->GetEntriesFast() == 0) return false;
633 TString filePath = gSystem->Getenv("ALICE_ROOT");
634 filePath += "/MUON/data/";
635 filePath += fileName;
638 ofstream out(filePath, ios::out);
640 cerr << filePath << endl;
641 AliError("File not found.");
644 #if !defined (__DECCXX)
645 out.setf(std::ios::fixed);
647 WriteModuleTransforms(out);
648 WriteDetElemTransforms(out);
653 //______________________________________________________________________________
655 AliMUONGeometryTransformer::WriteMisAlignmentData(const TString& fileName) const
657 /// Write misalignment data into a file
658 /// Return true, if writing finished correctly.
661 // if builder is not associated with any geometry module
662 if ( fModuleTransformers->GetEntriesFast() == 0 ) {
663 AliWarningStream() << "No geometry modules defined." << endl;
668 // if builder has no mis-alignment data
669 if ( ! fMisAlignArray ) {
670 AliWarningStream() << "No mis-alignment data defined." << endl;
675 TString filePath = gSystem->Getenv("ALICE_ROOT");
676 filePath += "/MUON/data/";
677 filePath += fileName;
679 // Write mis-alignment data in the root file
680 TFile file(fileName.Data(), "RECREATE");
681 fMisAlignArray->Write();
687 //_____________________________________________________________________________
688 void AliMUONGeometryTransformer::AddModuleTransformer(
689 AliMUONGeometryModuleTransformer* moduleTransformer)
691 /// Add the module transformer to the array
693 // Expand the size if not sufficient
694 Int_t moduleId = moduleTransformer->GetModuleId();
695 if ( moduleId >= fModuleTransformers->GetSize() )
696 fModuleTransformers->Expand(moduleId+1);
698 fModuleTransformers->AddAt(moduleTransformer, moduleId);
701 //_____________________________________________________________________________
702 void AliMUONGeometryTransformer::AddMisAlignModule(Int_t moduleId,
703 const TGeoHMatrix& matrix)
705 /// Build AliAlignObjMatrix with module ID, its volumePath
706 /// and the given delta transformation matrix
708 if ( ! fMisAlignArray )
709 fMisAlignArray = new TClonesArray("AliAlignObjMatrix", 200);
711 const AliMUONGeometryModuleTransformer* kTransformer
712 = GetModuleTransformer(moduleId);
713 if ( ! kTransformer ) {
714 AliErrorStream() << "Module " << moduleId << " not found." << endl;
718 // Get unique align object ID
719 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, moduleId);
721 // Create mis align matrix
722 TClonesArray& refArray =*fMisAlignArray;
723 Int_t pos = fMisAlignArray->GetEntriesFast();
724 new (refArray[pos]) AliAlignObjMatrix(GetModuleSymName(moduleId), volId,
725 const_cast<TGeoHMatrix&>(matrix),kTRUE);
728 //_____________________________________________________________________________
729 void AliMUONGeometryTransformer::AddMisAlignDetElement(Int_t detElemId,
730 const TGeoHMatrix& matrix)
732 /// Build AliAlignObjMatrix with detection element ID, its volumePath
733 /// and the given delta transformation matrix
735 if ( ! fMisAlignArray )
736 fMisAlignArray = new TClonesArray("AliAlignObjMatrix", 200);
738 const AliMUONGeometryDetElement* kDetElement
739 = GetDetElement(detElemId);
741 if ( ! kDetElement ) {
742 AliErrorStream() << "Det element " << detElemId << " not found." << endl;
746 // Get unique align object ID
747 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, detElemId);
749 // Create mis align matrix
750 TClonesArray& refArray =*fMisAlignArray;
751 Int_t pos = fMisAlignArray->GetEntriesFast();
752 new(refArray[pos]) AliAlignObjMatrix(GetDESymName(detElemId), volId,
753 const_cast<TGeoHMatrix&>(matrix),kTRUE);
756 //______________________________________________________________________________
757 void AliMUONGeometryTransformer::CreateModules()
759 /// Create modules and their detection elements using info from mapping;
760 /// but do not fill matrices
762 // Load mapping as its info is used to define modules & DEs
765 // Loop over geometry module
766 for (Int_t moduleId = 0; moduleId < AliMpConstants::NofGeomModules(); ++moduleId ) {
768 // Create geometry module transformer
769 AliMUONGeometryModuleTransformer* moduleTransformer
770 = new AliMUONGeometryModuleTransformer(moduleId);
771 AddModuleTransformer(moduleTransformer);
774 // Loop over detection elements
776 for ( it.First(); ! it.IsDone(); it.Next() ) {
778 Int_t detElemId = it.CurrentDEId();
779 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
781 // Get detection element store
782 AliMpExMap* detElements =
783 GetModuleTransformer(moduleId)->GetDetElementStore();
785 // Add detection element
786 AliMUONGeometryDetElement* detElement
787 = new AliMUONGeometryDetElement(detElemId);
788 detElements->Add(detElemId, detElement);
792 //_____________________________________________________________________________
793 void AliMUONGeometryTransformer::AddAlignableVolumes() const
795 /// Set symbolic names and matrices to alignable objects to TGeo
797 if ( ! gGeoManager ) {
798 AliWarning("TGeoManager not defined.");
803 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
804 AliMUONGeometryModuleTransformer* module
805 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
807 // Set module symbolic name
809 = gGeoManager->SetAlignableEntry(GetModuleSymName(module->GetModuleId()),
810 module->GetVolumePath());
813 << "Volume path for geometry module "
814 << module->GetModuleId()
815 << " not found in geometry." << endl;
819 pnEntry->SetMatrix(new TGeoHMatrix(*module->GetTransformation()));
820 // the matrix will be deleted via TGeoManager
823 // Detection elements
824 AliMpExMap* detElements = module->GetDetElementStore();
826 for (Int_t j=0; j<detElements->GetSize(); j++) {
827 AliMUONGeometryDetElement* detElement
828 = (AliMUONGeometryDetElement*)detElements->GetObject(j);
830 // Set detection element symbolic name
832 = gGeoManager->SetAlignableEntry(GetDESymName(detElement->GetId()),
833 detElement->GetVolumePath());
836 << "Volume path for detection element "
837 << detElement->GetId()
838 << " not found in geometry." << endl;
841 // Set detection element matrix
842 pnEntry->SetMatrix(new TGeoHMatrix(*detElement->GetGlobalTransformation()));
843 // the matrix will be deleted via TGeoManager
849 //_____________________________________________________________________________
850 TClonesArray* AliMUONGeometryTransformer::CreateZeroAlignmentData() const
852 /// Create array with zero alignment data
854 // Create array for zero-alignment objects
855 TClonesArray* array = new TClonesArray("AliAlignObjMatrix", 200);
856 TClonesArray& refArray =*array;
857 array->SetOwner(true);
863 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
864 AliMUONGeometryModuleTransformer* module
865 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
867 Int_t moduleId = module->GetModuleId();
870 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, moduleId);
872 // Create mis align matrix
873 Int_t pos = array->GetEntriesFast();
874 new (refArray[pos]) AliAlignObjMatrix(GetModuleSymName(moduleId), volId, matrix, kTRUE);
877 // Detection elements
878 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
879 AliMUONGeometryModuleTransformer* moduleTransformer
880 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
881 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
883 for (Int_t j=0; j<detElements->GetSize(); j++) {
884 AliMUONGeometryDetElement* detElement
885 = (AliMUONGeometryDetElement*)detElements->GetObject(j);
887 Int_t detElemId = detElement->GetId();
890 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, detElemId);
892 // Create mis align matrix
893 Int_t pos = array->GetEntriesFast();
894 new (refArray[pos]) AliAlignObjMatrix(GetDESymName(detElemId), volId, matrix, kTRUE);
901 //_____________________________________________________________________________
902 void AliMUONGeometryTransformer::ClearMisAlignmentData()
904 /// Clear the array of misalignment data
906 if ( ! fMisAlignArray ) return;
908 fMisAlignArray->Delete();
911 //_____________________________________________________________________________
912 void AliMUONGeometryTransformer::Global2Local(Int_t detElemId,
913 Float_t xg, Float_t yg, Float_t zg,
914 Float_t& xl, Float_t& yl, Float_t& zl) const
916 /// Transform point from the global reference frame (ALIC)
917 /// to the local reference frame of the detection element specified
920 const AliMUONGeometryModuleTransformer* kTransformer
921 = GetModuleTransformerByDEId(detElemId);
924 kTransformer->Global2Local(detElemId, xg, yg, zg, xl, yl, zl);
927 //_____________________________________________________________________________
928 void AliMUONGeometryTransformer::Global2Local(Int_t detElemId,
929 Double_t xg, Double_t yg, Double_t zg,
930 Double_t& xl, Double_t& yl, Double_t& zl) const
932 /// Transform point from the global reference frame (ALIC)
933 /// to the local reference frame of the detection element specified
936 const AliMUONGeometryModuleTransformer* kTransformer
937 = GetModuleTransformerByDEId(detElemId);
940 kTransformer->Global2Local(detElemId, xg, yg, zg, xl, yl, zl);
943 //_____________________________________________________________________________
944 void AliMUONGeometryTransformer::Local2Global(Int_t detElemId,
945 Float_t xl, Float_t yl, Float_t zl,
946 Float_t& xg, Float_t& yg, Float_t& zg) const
948 /// Transform point from the local reference frame of the detection element
949 /// specified by detElemId to the global reference frame (ALIC).
951 const AliMUONGeometryModuleTransformer* kTransformer
952 = GetModuleTransformerByDEId(detElemId);
955 kTransformer->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
958 //_____________________________________________________________________________
959 void AliMUONGeometryTransformer::Local2Global(Int_t detElemId,
960 Double_t xl, Double_t yl, Double_t zl,
961 Double_t& xg, Double_t& yg, Double_t& zg) const
963 /// Transform point from the local reference frame of the detection element
964 /// specified by detElemId to the global reference frame (ALIC).
966 const AliMUONGeometryModuleTransformer* kTransformer
967 = GetModuleTransformerByDEId(detElemId);
970 kTransformer->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
973 //_____________________________________________________________________________
974 const AliMUONGeometryModuleTransformer*
975 AliMUONGeometryTransformer::GetModuleTransformer(Int_t index, Bool_t warn) const
977 /// Return the geometry module transformer specified by index
979 return GetModuleTransformerNonConst(index, warn);
982 //_____________________________________________________________________________
983 const AliMUONGeometryModuleTransformer*
984 AliMUONGeometryTransformer::GetModuleTransformerByDEId(Int_t detElemId,
987 /// Return the geometry module transformer specified by detection element ID
990 Int_t index = AliMpDEManager::GetGeomModuleId(detElemId);
992 return GetModuleTransformer(index, warn);
995 //_____________________________________________________________________________
996 const AliMUONGeometryDetElement*
997 AliMUONGeometryTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const
999 /// Return detection element with given detElemId
1001 const AliMUONGeometryModuleTransformer* kTransformer
1002 = GetModuleTransformerByDEId(detElemId, warn);
1004 if (!kTransformer) return 0;
1006 return kTransformer->GetDetElement(detElemId, warn);
1009 //_____________________________________________________________________________
1010 Bool_t AliMUONGeometryTransformer::HasDE(Int_t detElemId) const
1012 /// Return true if detection element with given detElemId is defined
1014 const AliMUONGeometryModuleTransformer* kTransformer
1015 = GetModuleTransformerByDEId(detElemId, false);
1017 if (!kTransformer) return false;
1019 return ( kTransformer->GetDetElement(detElemId, false) != 0 );