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)
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;
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->GetDimensionX());
145 Double_t dy(seg->GetDimensionY());
147 if ( stationType == AliMp::kStation12 )
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* itp = cathode->CreateIterator();
163 while ( !itp->IsDone() )
165 AliMpPad pad = itp->CurrentItem();
166 AliMpArea a(pad.GetPositionX(),pad.GetPositionY(),
167 pad.GetDimensionX(), pad.GetDimensionY());
168 xmin = TMath::Min(xmin,a.LeftBorder());
169 xmax = TMath::Max(xmax,a.RightBorder());
170 ymin = TMath::Min(ymin,a.DownBorder());
171 ymax = TMath::Max(ymax,a.UpBorder());
178 xl = (xmin+xmax)/2.0;
179 yl = (ymin+ymax)/2.0;
180 dx = (xmax-xmin)/2.0;
181 dy = (ymax-ymin)/2.0;
183 Local2Global(detElemId,xl,yl,zl,xg,yg,zg);
187 Local2Global(detElemId,xl,yl,zl,xg,yg,zg);
190 fDEAreas->Add(detElemId,new AliMpArea(xg,yg,dx,dy));
196 //_____________________________________________________________________________
197 Bool_t AliMUONGeometryTransformer::LoadMapping() const
199 /// Load mapping from CDB
201 if ( ! AliMpCDB::LoadMpSegmentation() )
203 AliFatal("Could not access mapping from OCDB !");
210 //_____________________________________________________________________________
211 AliMUONGeometryModuleTransformer*
212 AliMUONGeometryTransformer::GetModuleTransformerNonConst(
213 Int_t index, Bool_t warn) const
215 /// Return the geometry module specified by index
217 if (index < 0 || index >= fModuleTransformers->GetEntriesFast()) {
220 << "Index: " << index << " outside limits" << std::endl;
225 return (AliMUONGeometryModuleTransformer*) fModuleTransformers->At(index);
228 //______________________________________________________________________________
229 TGeoHMatrix AliMUONGeometryTransformer::GetTransform(
230 Double_t x, Double_t y, Double_t z,
231 Double_t a1, Double_t a2, Double_t a3,
232 Double_t a4, Double_t a5, Double_t a6) const
234 /// Build the transformation from the given parameters
237 return TGeoCombiTrans(TGeoTranslation(x, y, z),
238 TGeoRotation("rot", a1, a2, a3, a4, a5, a6));
242 //______________________________________________________________________________
243 void AliMUONGeometryTransformer::FillModuleTransform(Int_t moduleId,
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)
248 /// Fill the transformation of the module.
250 AliMUONGeometryModuleTransformer* moduleTransformer
251 = GetModuleTransformerNonConst(moduleId, false);
253 if ( !moduleTransformer) {
255 << "Module " << moduleId << " has not volume path defined." << endl;
258 // Build the transformation from the parameters
259 TGeoHMatrix transform
260 = GetTransform(x, y, z, a1, a2, a3, a4, a5, a6);
262 moduleTransformer->SetTransformation(transform);
265 //______________________________________________________________________________
266 void AliMUONGeometryTransformer::FillDetElemTransform(
268 Double_t x, Double_t y, Double_t z,
269 Double_t a1, Double_t a2, Double_t a3,
270 Double_t a4, Double_t a5, Double_t a6)
272 /// Fill the transformation of the detection element.
275 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
277 // Get module transformer
278 const AliMUONGeometryModuleTransformer* kModuleTransformer
279 = GetModuleTransformer(moduleId);
281 if ( ! kModuleTransformer ) {
282 AliFatal(Form("Module transformer not defined, detElemId: %d", detElemId));
286 // Get detection element
287 AliMUONGeometryDetElement* detElement
288 = kModuleTransformer->GetDetElement(detElemId);
290 if ( ! detElement ) {
291 AliFatal(Form("Det element %d has not volume path defined", detElemId));
295 // Build the transformation from the parameters
296 TGeoHMatrix localTransform
297 = GetTransform(x, y, z, a1, a2, a3, a4, a5, a6);
298 detElement->SetLocalTransformation(localTransform);
300 // Compute global transformation
301 TGeoHMatrix globalTransform
302 = AliMUONGeometryBuilder::Multiply(
303 *kModuleTransformer->GetTransformation(),
305 detElement->SetGlobalTransformation(globalTransform);
308 //______________________________________________________________________________
309 TString AliMUONGeometryTransformer::ReadModuleTransforms(ifstream& in)
311 /// Read and fill modules transformations from the stream.
312 /// Return true, if reading finished correctly.
314 TString key(AliMUONGeometryModuleTransformer::GetModuleNamePrefix());
315 while ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() ) {
318 Double_t a1, a2, a3, a4, a5, a6;
334 //cout << "moduleId=" << id << " "
335 // << "position= " << x << ", " << y << ", " << z << " "
336 // << "rotation= " << a1 << ", " << a2 << ", " << a3 << ", "
337 // << a4 << ", " << a5 << ", " << a6
341 FillModuleTransform(id, x, y, z, a1, a2, a3, a4, a5, a6);
350 //______________________________________________________________________________
351 TString AliMUONGeometryTransformer::ReadDetElemTransforms(ifstream& in)
353 /// Read detection elements transformations from the stream.
354 /// Return true, if reading finished correctly.
356 TString key(AliMUONGeometryDetElement::GetDENamePrefix());
357 while ( key == AliMUONGeometryDetElement::GetDENamePrefix() ) {
362 Double_t a1, a2, a3, a4, a5, a6;
378 //cout << "detElemId=" << detElemId << " "
379 // << "position= " << x << ", " << y << ", " << z << " "
380 // << "rotation= " << a1 << ", " << a2 << ", " << a3 << ", "
381 // << a4 << ", " << a5 << ", " << a6
385 FillDetElemTransform(detElemId, x, y, z, a1, a2, a3, a4, a5, a6);
394 //______________________________________________________________________________
396 AliMUONGeometryTransformer::ReadTransformations(const TString& fileName)
398 /// Read transformations from a file.
399 /// Return true, if reading finished correctly.
402 TString filePath = gSystem->Getenv("ALICE_ROOT");
403 filePath += "/MUON/data/";
404 filePath += fileName;
407 ifstream in(filePath, ios::in);
409 cerr << filePath << endl;
410 AliFatal("File not found.");
416 while ( !in.eof() ) {
417 if ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() )
418 key = ReadModuleTransforms(in);
419 else if ( key == AliMUONGeometryDetElement::GetDENamePrefix() )
420 key = ReadDetElemTransforms(in);
422 AliFatal(Form("%s key not recognized", key.Data()));
430 //______________________________________________________________________________
431 void AliMUONGeometryTransformer::WriteTransform(ofstream& out,
432 const TGeoMatrix* transform) const
434 /// Write given transformation
437 const Double_t* xyz = transform->GetTranslation();
438 out << setw(10) << setprecision(4) << xyz[0] << " "
439 << setw(10) << setprecision(4) << xyz[1] << " "
440 << setw(10) << setprecision(4) << xyz[2];
443 const Double_t* rm = transform->GetRotationMatrix();
444 TGeoRotation rotation;
445 rotation.SetMatrix(const_cast<Double_t*>(rm));
446 Double_t a1, a2, a3, a4, a5, a6;
447 rotation.GetAngles(a1, a2, a3, a4, a5, a6);
449 out << setw(8) << setprecision(4) << a1 << " "
450 << setw(8) << setprecision(4) << a2 << " "
451 << setw(8) << setprecision(4) << a3 << " "
452 << setw(8) << setprecision(4) << a4 << " "
453 << setw(8) << setprecision(4) << a5 << " "
454 << setw(8) << setprecision(4) << a6 << " " << endl;
457 //______________________________________________________________________________
458 void AliMUONGeometryTransformer::WriteModuleTransforms(ofstream& out) const
460 /// Write module transformations for all module transformers
462 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
463 AliMUONGeometryModuleTransformer* moduleTransformer
464 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
465 const TGeoMatrix* transform
466 = moduleTransformer->GetTransformation();
469 out << AliMUONGeometryModuleTransformer::GetModuleNamePrefix() << " "
470 << setw(4) << moduleTransformer->GetModuleId();
472 WriteTransform(out, transform);
477 //______________________________________________________________________________
478 void AliMUONGeometryTransformer::WriteDetElemTransforms(ofstream& out) const
480 /// Write detection element transformations for all detection elements in all
481 /// module transformers
483 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
484 AliMUONGeometryModuleTransformer* moduleTransformer
485 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
486 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
487 TIter next(detElements->CreateIterator());
488 AliMUONGeometryDetElement* detElement;
489 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
491 const TGeoMatrix* transform
492 = detElement->GetLocalTransformation();
495 out << AliMUONGeometryDetElement::GetDENamePrefix() << " "
496 << setw(4) << detElement->GetId();
498 WriteTransform(out, transform);
504 //______________________________________________________________________________
505 TString AliMUONGeometryTransformer::GetModuleSymName(Int_t moduleId) const
507 /// Return the module symbolic name (use for alignment)
509 return "/" + fDetectorName + "/"
510 + AliMUONGeometryModuleTransformer::GetModuleName(moduleId);
513 //______________________________________________________________________________
514 TString AliMUONGeometryTransformer::GetDESymName(Int_t detElemId) const
516 /// Return the detection element symbolic name (used for alignment)
519 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
521 return GetModuleSymName(moduleId) + "/"
522 + AliMUONGeometryDetElement::GetDEName(detElemId);
529 //______________________________________________________________________________
531 AliMUONGeometryTransformer::LoadTransformations()
533 /// Load transformations for defined modules and detection elements
534 /// using AliGeomManager
536 if ( ! AliGeomManager::GetGeometry() ) {
537 AliFatal("Geometry has to be laoded in AliGeomManager first.");
541 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
542 AliMUONGeometryModuleTransformer* moduleTransformer
543 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
545 // Module symbolic name
546 TString symname = GetModuleSymName(moduleTransformer->GetModuleId());
548 // Set matrix from physical node
549 TGeoHMatrix* matrix = AliGeomManager::GetMatrix(symname);
551 AliErrorStream() << "Geometry module matrix not found." << endl;
554 moduleTransformer->SetTransformation(*matrix);
556 // Loop over detection elements
557 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
558 TIter next(detElements->CreateIterator());
559 AliMUONGeometryDetElement* detElement;
561 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
563 // Det element symbolic name
564 TString symnameDE = GetDESymName(detElement->GetId());
566 // Set global matrix from physical node
567 TGeoHMatrix* globalMatrix = AliGeomManager::GetMatrix(symnameDE);
568 if ( ! globalMatrix ) {
569 AliErrorStream() << "Detection element matrix not found." << endl;
572 detElement->SetGlobalTransformation(*globalMatrix, false);
575 TGeoHMatrix localMatrix =
576 AliMUONGeometryBuilder::Multiply(
577 (*matrix).Inverse(), (*globalMatrix) );
578 detElement->SetLocalTransformation(localMatrix, false);
584 //______________________________________________________________________________
586 AliMUONGeometryTransformer::LoadGeometryData(const TString& fileName)
588 /// Read geometry data either from ASCII file with transformations or
589 /// from root geometry file (if fileName has ".root" extension)
593 // Get file extension
594 std::string fileName2 = fileName.Data();
595 std::string rootExt = fileName2.substr(fileName2.size()-5, fileName2.size());
597 if ( rootExt != ".root" )
598 return ReadTransformations(fileName);
600 // Load root geometry
601 AliGeomManager::LoadGeometry(fileName.Data());
602 return LoadTransformations();
606 //______________________________________________________________________________
608 AliMUONGeometryTransformer::LoadGeometryData()
610 /// Load geometry data from already loaded Root geometry using AliGeomManager
612 if ( ! AliGeomManager::GetGeometry() ) {
613 AliErrorStream() << "Geometry has not been loaded in AliGeomManager" << endl;
619 return LoadTransformations();
622 //______________________________________________________________________________
624 AliMUONGeometryTransformer::WriteTransformations(const TString& fileName) const
626 /// Write transformations into a file.
627 /// Return true, if writing finished correctly.
630 // if builder is not associated with any geometry module
631 if (fModuleTransformers->GetEntriesFast() == 0) return false;
634 TString filePath = gSystem->Getenv("ALICE_ROOT");
635 filePath += "/MUON/data/";
636 filePath += fileName;
639 ofstream out(filePath, ios::out);
641 cerr << filePath << endl;
642 AliError("File not found.");
645 #if !defined (__DECCXX)
646 out.setf(std::ios::fixed);
648 WriteModuleTransforms(out);
649 WriteDetElemTransforms(out);
654 //______________________________________________________________________________
656 AliMUONGeometryTransformer::WriteMisAlignmentData(const TString& fileName) const
658 /// Write misalignment data into a file
659 /// Return true, if writing finished correctly.
662 // if builder is not associated with any geometry module
663 if ( fModuleTransformers->GetEntriesFast() == 0 ) {
664 AliWarningStream() << "No geometry modules defined." << endl;
669 // if builder has no mis-alignment data
670 if ( ! fMisAlignArray ) {
671 AliWarningStream() << "No mis-alignment data defined." << endl;
676 TString filePath = gSystem->Getenv("ALICE_ROOT");
677 filePath += "/MUON/data/";
678 filePath += fileName;
680 // Write mis-alignment data in the root file
681 TFile file(fileName.Data(), "RECREATE");
682 fMisAlignArray->Write();
688 //_____________________________________________________________________________
689 void AliMUONGeometryTransformer::AddModuleTransformer(
690 AliMUONGeometryModuleTransformer* moduleTransformer)
692 /// Add the module transformer to the array
694 // Expand the size if not sufficient
695 Int_t moduleId = moduleTransformer->GetModuleId();
696 if ( moduleId >= fModuleTransformers->GetSize() )
697 fModuleTransformers->Expand(moduleId+1);
699 fModuleTransformers->AddAt(moduleTransformer, moduleId);
702 //_____________________________________________________________________________
703 void AliMUONGeometryTransformer::AddMisAlignModule(Int_t moduleId,
704 const TGeoHMatrix& matrix)
706 /// Build AliAlignObjMatrix with module ID, its volumePath
707 /// and the given delta transformation matrix
709 if ( ! fMisAlignArray )
710 fMisAlignArray = new TClonesArray("AliAlignObjMatrix", 200);
712 const AliMUONGeometryModuleTransformer* kTransformer
713 = GetModuleTransformer(moduleId);
714 if ( ! kTransformer ) {
715 AliErrorStream() << "Module " << moduleId << " not found." << endl;
719 // Get unique align object ID
720 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, moduleId);
722 // Create mis align matrix
723 TClonesArray& refArray =*fMisAlignArray;
724 Int_t pos = fMisAlignArray->GetEntriesFast();
725 new (refArray[pos]) AliAlignObjMatrix(GetModuleSymName(moduleId), volId,
726 const_cast<TGeoHMatrix&>(matrix),kTRUE);
729 //_____________________________________________________________________________
730 void AliMUONGeometryTransformer::AddMisAlignDetElement(Int_t detElemId,
731 const TGeoHMatrix& matrix)
733 /// Build AliAlignObjMatrix with detection element ID, its volumePath
734 /// and the given delta transformation matrix
736 if ( ! fMisAlignArray )
737 fMisAlignArray = new TClonesArray("AliAlignObjMatrix", 200);
739 const AliMUONGeometryDetElement* kDetElement
740 = GetDetElement(detElemId);
742 if ( ! kDetElement ) {
743 AliErrorStream() << "Det element " << detElemId << " not found." << endl;
747 // Get unique align object ID
748 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, detElemId);
750 // Create mis align matrix
751 TClonesArray& refArray =*fMisAlignArray;
752 Int_t pos = fMisAlignArray->GetEntriesFast();
753 new(refArray[pos]) AliAlignObjMatrix(GetDESymName(detElemId), volId,
754 const_cast<TGeoHMatrix&>(matrix),kTRUE);
757 //______________________________________________________________________________
758 void AliMUONGeometryTransformer::CreateModules()
760 /// Create modules and their detection elements using info from mapping;
761 /// but do not fill matrices
763 // Load mapping as its info is used to define modules & DEs
766 if ( fModuleTransformers->GetEntriesFast() == 0 ) {
767 // Create modules only if they do not yet exist
769 // Loop over geometry module
770 for (Int_t moduleId = 0; moduleId < AliMpConstants::NofGeomModules(); ++moduleId ) {
772 // Create geometry module transformer
773 AliMUONGeometryModuleTransformer* moduleTransformer
774 = new AliMUONGeometryModuleTransformer(moduleId);
775 AddModuleTransformer(moduleTransformer);
779 // Loop over detection elements
781 for ( it.First(); ! it.IsDone(); it.Next() ) {
783 Int_t detElemId = it.CurrentDEId();
784 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
786 // Get detection element store
787 AliMpExMap* detElements =
788 GetModuleTransformer(moduleId)->GetDetElementStore();
790 // Add detection element
791 AliMUONGeometryDetElement* detElement
792 = new AliMUONGeometryDetElement(detElemId);
793 detElements->Add(detElemId, detElement);
797 //_____________________________________________________________________________
798 void AliMUONGeometryTransformer::AddAlignableVolumes() const
800 /// Set symbolic names and matrices to alignable objects to TGeo
802 if ( ! gGeoManager ) {
803 AliWarning("TGeoManager not defined.");
808 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
809 AliMUONGeometryModuleTransformer* module
810 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
812 // Set module symbolic name
814 = gGeoManager->SetAlignableEntry(GetModuleSymName(module->GetModuleId()),
815 module->GetVolumePath());
818 << "Volume path " << module->GetVolumePath().Data()
819 << " for geometry module " << module->GetModuleId() << " " << module
820 << " not found in geometry." << endl;
824 pnEntry->SetMatrix(new TGeoHMatrix(*module->GetTransformation()));
825 // the matrix will be deleted via TGeoManager
828 // Detection elements
829 AliMpExMap* detElements = module->GetDetElementStore();
830 TIter next(detElements->CreateIterator());
831 AliMUONGeometryDetElement* detElement;
833 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
835 // Set detection element symbolic name
836 TGeoPNEntry* pnEntryDE
837 = gGeoManager->SetAlignableEntry(GetDESymName(detElement->GetId()),
838 detElement->GetVolumePath());
842 << detElement->GetVolumePath().Data()
843 << " for detection element " << detElement->GetId()
844 << " not found in geometry." << endl;
847 // Set detection element matrix
848 pnEntryDE->SetMatrix(new TGeoHMatrix(*detElement->GetGlobalTransformation()));
849 // the matrix will be deleted via TGeoManager
855 //_____________________________________________________________________________
856 TClonesArray* AliMUONGeometryTransformer::CreateZeroAlignmentData() const
858 /// Create array with zero alignment data
860 // Create array for zero-alignment objects
861 TClonesArray* array = new TClonesArray("AliAlignObjMatrix", 200);
862 TClonesArray& refArray =*array;
863 array->SetOwner(true);
869 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
870 AliMUONGeometryModuleTransformer* module
871 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
873 Int_t moduleId = module->GetModuleId();
876 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, moduleId);
878 // Create mis align matrix
879 Int_t pos = array->GetEntriesFast();
880 new (refArray[pos]) AliAlignObjMatrix(GetModuleSymName(moduleId), volId, matrix, kTRUE);
883 // Detection elements
884 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
885 AliMUONGeometryModuleTransformer* moduleTransformer
886 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
888 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
889 TIter next(detElements->CreateIterator());
890 AliMUONGeometryDetElement* detElement;
892 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
894 Int_t detElemId = detElement->GetId();
897 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, detElemId);
899 // Create mis align matrix
900 Int_t pos = array->GetEntriesFast();
901 new (refArray[pos]) AliAlignObjMatrix(GetDESymName(detElemId), volId, matrix, kTRUE);
908 //_____________________________________________________________________________
909 void AliMUONGeometryTransformer::ClearMisAlignmentData()
911 /// Clear the array of misalignment data
913 if ( ! fMisAlignArray ) return;
915 fMisAlignArray->Delete();
918 //_____________________________________________________________________________
919 void AliMUONGeometryTransformer::Global2Local(Int_t detElemId,
920 Float_t xg, Float_t yg, Float_t zg,
921 Float_t& xl, Float_t& yl, Float_t& zl) const
923 /// Transform point from the global reference frame (ALIC)
924 /// to the local reference frame of the detection element specified
927 const AliMUONGeometryModuleTransformer* kTransformer
928 = GetModuleTransformerByDEId(detElemId);
931 kTransformer->Global2Local(detElemId, xg, yg, zg, xl, yl, zl);
934 //_____________________________________________________________________________
935 void AliMUONGeometryTransformer::Global2Local(Int_t detElemId,
936 Double_t xg, Double_t yg, Double_t zg,
937 Double_t& xl, Double_t& yl, Double_t& zl) const
939 /// Transform point from the global reference frame (ALIC)
940 /// to the local reference frame of the detection element specified
943 const AliMUONGeometryModuleTransformer* kTransformer
944 = GetModuleTransformerByDEId(detElemId);
947 kTransformer->Global2Local(detElemId, xg, yg, zg, xl, yl, zl);
950 //_____________________________________________________________________________
951 void AliMUONGeometryTransformer::Local2Global(Int_t detElemId,
952 Float_t xl, Float_t yl, Float_t zl,
953 Float_t& xg, Float_t& yg, Float_t& zg) const
955 /// Transform point from the local reference frame of the detection element
956 /// specified by detElemId to the global reference frame (ALIC).
958 const AliMUONGeometryModuleTransformer* kTransformer
959 = GetModuleTransformerByDEId(detElemId);
962 kTransformer->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
965 //_____________________________________________________________________________
966 void AliMUONGeometryTransformer::Local2Global(Int_t detElemId,
967 Double_t xl, Double_t yl, Double_t zl,
968 Double_t& xg, Double_t& yg, Double_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 const AliMUONGeometryModuleTransformer*
982 AliMUONGeometryTransformer::GetModuleTransformer(Int_t index, Bool_t warn) const
984 /// Return the geometry module transformer specified by index
986 return GetModuleTransformerNonConst(index, warn);
989 //_____________________________________________________________________________
990 const AliMUONGeometryModuleTransformer*
991 AliMUONGeometryTransformer::GetModuleTransformerByDEId(Int_t detElemId,
994 /// Return the geometry module transformer specified by detection element ID
997 Int_t index = AliMpDEManager::GetGeomModuleId(detElemId);
999 return GetModuleTransformer(index, warn);
1002 //_____________________________________________________________________________
1003 const AliMUONGeometryDetElement*
1004 AliMUONGeometryTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const
1006 /// Return detection element with given detElemId
1008 const AliMUONGeometryModuleTransformer* kTransformer
1009 = GetModuleTransformerByDEId(detElemId, warn);
1011 if (!kTransformer) return 0;
1013 return kTransformer->GetDetElement(detElemId, warn);
1016 //_____________________________________________________________________________
1017 Bool_t AliMUONGeometryTransformer::HasDE(Int_t detElemId) const
1019 /// Return true if detection element with given detElemId is defined
1021 const AliMUONGeometryModuleTransformer* kTransformer
1022 = GetModuleTransformerByDEId(detElemId, false);
1024 if (!kTransformer) return false;
1026 return ( kTransformer->GetDetElement(detElemId, false) != 0 );