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;
259 // Build the transformation from the parameters
260 TGeoHMatrix transform
261 = GetTransform(x, y, z, a1, a2, a3, a4, a5, a6);
263 moduleTransformer->SetTransformation(transform);
266 //______________________________________________________________________________
267 void AliMUONGeometryTransformer::FillDetElemTransform(
269 Double_t x, Double_t y, Double_t z,
270 Double_t a1, Double_t a2, Double_t a3,
271 Double_t a4, Double_t a5, Double_t a6)
273 /// Fill the transformation of the detection element.
276 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
278 // Get module transformer
279 const AliMUONGeometryModuleTransformer* kModuleTransformer
280 = GetModuleTransformer(moduleId);
282 if ( ! kModuleTransformer ) {
283 AliFatal(Form("Module transformer not defined, detElemId: %d", detElemId));
287 // Get detection element
288 AliMUONGeometryDetElement* detElement
289 = kModuleTransformer->GetDetElement(detElemId);
291 if ( ! detElement ) {
292 AliFatal(Form("Det element %d has not volume path defined", detElemId));
296 // Build the transformation from the parameters
297 TGeoHMatrix localTransform
298 = GetTransform(x, y, z, a1, a2, a3, a4, a5, a6);
299 detElement->SetLocalTransformation(localTransform);
301 // Compute global transformation
302 TGeoHMatrix globalTransform
303 = AliMUONGeometryBuilder::Multiply(
304 *kModuleTransformer->GetTransformation(),
306 detElement->SetGlobalTransformation(globalTransform);
309 //______________________________________________________________________________
310 TString AliMUONGeometryTransformer::ReadModuleTransforms(ifstream& in)
312 /// Read and fill modules transformations from the stream.
313 /// Return true, if reading finished correctly.
315 TString key(AliMUONGeometryModuleTransformer::GetModuleNamePrefix());
316 while ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() ) {
319 Double_t a1, a2, a3, a4, a5, a6;
335 //cout << "moduleId=" << id << " "
336 // << "position= " << x << ", " << y << ", " << z << " "
337 // << "rotation= " << a1 << ", " << a2 << ", " << a3 << ", "
338 // << a4 << ", " << a5 << ", " << a6
342 FillModuleTransform(id, x, y, z, a1, a2, a3, a4, a5, a6);
351 //______________________________________________________________________________
352 TString AliMUONGeometryTransformer::ReadDetElemTransforms(ifstream& in)
354 /// Read detection elements transformations from the stream.
355 /// Return true, if reading finished correctly.
357 TString key(AliMUONGeometryDetElement::GetDENamePrefix());
358 while ( key == AliMUONGeometryDetElement::GetDENamePrefix() ) {
363 Double_t a1, a2, a3, a4, a5, a6;
379 //cout << "detElemId=" << detElemId << " "
380 // << "position= " << x << ", " << y << ", " << z << " "
381 // << "rotation= " << a1 << ", " << a2 << ", " << a3 << ", "
382 // << a4 << ", " << a5 << ", " << a6
386 FillDetElemTransform(detElemId, x, y, z, a1, a2, a3, a4, a5, a6);
395 //______________________________________________________________________________
397 AliMUONGeometryTransformer::ReadTransformations(const TString& fileName)
399 /// Read transformations from a file.
400 /// Return true, if reading finished correctly.
403 TString filePath = gSystem->Getenv("ALICE_ROOT");
404 filePath += "/MUON/data/";
405 filePath += fileName;
408 ifstream in(filePath, ios::in);
410 cerr << filePath << endl;
411 AliFatal("File not found.");
417 while ( !in.eof() ) {
418 if ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() )
419 key = ReadModuleTransforms(in);
420 else if ( key == AliMUONGeometryDetElement::GetDENamePrefix() )
421 key = ReadDetElemTransforms(in);
423 AliFatal(Form("%s key not recognized", key.Data()));
431 //______________________________________________________________________________
432 void AliMUONGeometryTransformer::WriteTransform(ofstream& out,
433 const TGeoMatrix* transform) const
435 /// Write given transformation
438 const Double_t* xyz = transform->GetTranslation();
439 out << setw(10) << setprecision(4) << xyz[0] << " "
440 << setw(10) << setprecision(4) << xyz[1] << " "
441 << setw(10) << setprecision(4) << xyz[2];
444 const Double_t* rm = transform->GetRotationMatrix();
445 TGeoRotation rotation;
446 rotation.SetMatrix(const_cast<Double_t*>(rm));
447 Double_t a1, a2, a3, a4, a5, a6;
448 rotation.GetAngles(a1, a2, a3, a4, a5, a6);
450 out << setw(8) << setprecision(4) << a1 << " "
451 << setw(8) << setprecision(4) << a2 << " "
452 << setw(8) << setprecision(4) << a3 << " "
453 << setw(8) << setprecision(4) << a4 << " "
454 << setw(8) << setprecision(4) << a5 << " "
455 << setw(8) << setprecision(4) << a6 << " " << endl;
458 //______________________________________________________________________________
459 void AliMUONGeometryTransformer::WriteModuleTransforms(ofstream& out) const
461 /// Write module transformations for all module transformers
463 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
464 AliMUONGeometryModuleTransformer* moduleTransformer
465 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
466 const TGeoMatrix* transform
467 = moduleTransformer->GetTransformation();
470 out << AliMUONGeometryModuleTransformer::GetModuleNamePrefix() << " "
471 << setw(4) << moduleTransformer->GetModuleId();
473 WriteTransform(out, transform);
478 //______________________________________________________________________________
479 void AliMUONGeometryTransformer::WriteDetElemTransforms(ofstream& out) const
481 /// Write detection element transformations for all detection elements in all
482 /// module transformers
484 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
485 AliMUONGeometryModuleTransformer* moduleTransformer
486 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
487 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
488 TIter next(detElements->CreateIterator());
489 AliMUONGeometryDetElement* detElement;
490 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
492 const TGeoMatrix* transform
493 = detElement->GetLocalTransformation();
496 out << AliMUONGeometryDetElement::GetDENamePrefix() << " "
497 << setw(4) << detElement->GetId();
499 WriteTransform(out, transform);
505 //______________________________________________________________________________
506 TString AliMUONGeometryTransformer::GetModuleSymName(Int_t moduleId) const
508 /// Return the module symbolic name (use for alignment)
510 return "/" + fDetectorName + "/"
511 + AliMUONGeometryModuleTransformer::GetModuleName(moduleId);
514 //______________________________________________________________________________
515 TString AliMUONGeometryTransformer::GetDESymName(Int_t detElemId) const
517 /// Return the detection element symbolic name (used for alignment)
520 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
522 return GetModuleSymName(moduleId) + "/"
523 + AliMUONGeometryDetElement::GetDEName(detElemId);
530 //______________________________________________________________________________
532 AliMUONGeometryTransformer::LoadTransformations()
534 /// Load transformations for defined modules and detection elements
535 /// using AliGeomManager
537 if ( ! AliGeomManager::GetGeometry() ) {
538 AliFatal("Geometry has to be laoded in AliGeomManager first.");
542 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
543 AliMUONGeometryModuleTransformer* moduleTransformer
544 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
546 // Module symbolic name
547 TString symname = GetModuleSymName(moduleTransformer->GetModuleId());
549 // Set matrix from physical node
550 TGeoHMatrix* matrix = AliGeomManager::GetMatrix(symname);
552 AliErrorStream() << "Geometry module matrix not found." << endl;
555 moduleTransformer->SetTransformation(*matrix);
557 // Loop over detection elements
558 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
559 TIter next(detElements->CreateIterator());
560 AliMUONGeometryDetElement* detElement;
562 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
564 // Det element symbolic name
565 TString symnameDE = GetDESymName(detElement->GetId());
567 // Set global matrix from physical node
568 TGeoHMatrix* globalMatrix = AliGeomManager::GetMatrix(symnameDE);
569 if ( ! globalMatrix ) {
570 AliErrorStream() << "Detection element matrix not found." << endl;
573 detElement->SetGlobalTransformation(*globalMatrix, false);
576 TGeoHMatrix localMatrix =
577 AliMUONGeometryBuilder::Multiply(
578 (*matrix).Inverse(), (*globalMatrix) );
579 detElement->SetLocalTransformation(localMatrix, false);
585 //______________________________________________________________________________
587 AliMUONGeometryTransformer::LoadGeometryData(const TString& fileName)
589 /// Read geometry data either from ASCII file with transformations or
590 /// from root geometry file (if fileName has ".root" extension)
594 // Get file extension
595 std::string fileName2 = fileName.Data();
596 std::string rootExt = fileName2.substr(fileName2.size()-5, fileName2.size());
598 if ( rootExt != ".root" )
599 return ReadTransformations(fileName);
601 // Load root geometry
602 AliGeomManager::LoadGeometry(fileName.Data());
603 return LoadTransformations();
607 //______________________________________________________________________________
609 AliMUONGeometryTransformer::LoadGeometryData()
611 /// Load geometry data from already loaded Root geometry using AliGeomManager
613 if ( ! AliGeomManager::GetGeometry() ) {
614 AliErrorStream() << "Geometry has not been loaded in AliGeomManager" << endl;
620 return LoadTransformations();
623 //______________________________________________________________________________
625 AliMUONGeometryTransformer::WriteTransformations(const TString& fileName) const
627 /// Write transformations into a file.
628 /// Return true, if writing finished correctly.
631 // if builder is not associated with any geometry module
632 if (fModuleTransformers->GetEntriesFast() == 0) return false;
635 TString filePath = gSystem->Getenv("ALICE_ROOT");
636 filePath += "/MUON/data/";
637 filePath += fileName;
640 ofstream out(filePath, ios::out);
642 cerr << filePath << endl;
643 AliError("File not found.");
646 #if !defined (__DECCXX)
647 out.setf(std::ios::fixed);
649 WriteModuleTransforms(out);
650 WriteDetElemTransforms(out);
655 //______________________________________________________________________________
657 AliMUONGeometryTransformer::WriteMisAlignmentData(const TString& fileName) const
659 /// Write misalignment data into a file
660 /// Return true, if writing finished correctly.
663 // if builder is not associated with any geometry module
664 if ( fModuleTransformers->GetEntriesFast() == 0 ) {
665 AliWarningStream() << "No geometry modules defined." << endl;
670 // if builder has no mis-alignment data
671 if ( ! fMisAlignArray ) {
672 AliWarningStream() << "No mis-alignment data defined." << endl;
677 TString filePath = gSystem->Getenv("ALICE_ROOT");
678 filePath += "/MUON/data/";
679 filePath += fileName;
681 // Write mis-alignment data in the root file
682 TFile file(fileName.Data(), "RECREATE");
683 fMisAlignArray->Write();
689 //_____________________________________________________________________________
690 void AliMUONGeometryTransformer::AddModuleTransformer(
691 AliMUONGeometryModuleTransformer* moduleTransformer)
693 /// Add the module transformer to the array
695 // Expand the size if not sufficient
696 Int_t moduleId = moduleTransformer->GetModuleId();
697 if ( moduleId >= fModuleTransformers->GetSize() )
698 fModuleTransformers->Expand(moduleId+1);
700 fModuleTransformers->AddAt(moduleTransformer, moduleId);
703 //_____________________________________________________________________________
704 void AliMUONGeometryTransformer::AddMisAlignModule(Int_t moduleId,
705 const TGeoHMatrix& matrix, Bool_t bGlobal)
707 /// Build AliAlignObjMatrix with module ID, its volumePath
708 /// and the given delta transformation matrix
710 if ( ! fMisAlignArray )
711 fMisAlignArray = new TClonesArray("AliAlignObjMatrix", 200);
713 const AliMUONGeometryModuleTransformer* kTransformer
714 = GetModuleTransformer(moduleId);
715 if ( ! kTransformer ) {
716 AliErrorStream() << "Module " << moduleId << " not found." << endl;
720 // Get unique align object ID
721 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, moduleId);
723 // Create mis align matrix
724 TClonesArray& refArray =*fMisAlignArray;
725 Int_t pos = fMisAlignArray->GetEntriesFast();
726 new (refArray[pos]) AliAlignObjMatrix(GetModuleSymName(moduleId), volId,
727 const_cast<TGeoHMatrix&>(matrix),bGlobal);
730 //_____________________________________________________________________________
731 void AliMUONGeometryTransformer::AddMisAlignDetElement(Int_t detElemId,
732 const TGeoHMatrix& matrix, Bool_t bGlobal)
734 /// Build AliAlignObjMatrix with detection element ID, its volumePath
735 /// and the given delta transformation matrix
737 if ( ! fMisAlignArray )
738 fMisAlignArray = new TClonesArray("AliAlignObjMatrix", 200);
740 const AliMUONGeometryDetElement* kDetElement
741 = GetDetElement(detElemId);
743 if ( ! kDetElement ) {
744 AliErrorStream() << "Det element " << detElemId << " not found." << endl;
748 // Get unique align object ID
749 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, detElemId);
751 // Create mis align matrix
752 TClonesArray& refArray =*fMisAlignArray;
753 Int_t pos = fMisAlignArray->GetEntriesFast();
754 new(refArray[pos]) AliAlignObjMatrix(GetDESymName(detElemId), volId,
755 const_cast<TGeoHMatrix&>(matrix),bGlobal);
758 //______________________________________________________________________________
759 void AliMUONGeometryTransformer::CreateModules()
761 /// Create modules and their detection elements using info from mapping;
762 /// but do not fill matrices
764 // Load mapping as its info is used to define modules & DEs
767 if ( fModuleTransformers->GetEntriesFast() == 0 ) {
768 // Create modules only if they do not yet exist
770 // Loop over geometry module
771 for (Int_t moduleId = 0; moduleId < AliMpConstants::NofGeomModules(); ++moduleId ) {
773 // Create geometry module transformer
774 AliMUONGeometryModuleTransformer* moduleTransformer
775 = new AliMUONGeometryModuleTransformer(moduleId);
776 AddModuleTransformer(moduleTransformer);
780 // Loop over detection elements
782 for ( it.First(); ! it.IsDone(); it.Next() ) {
784 Int_t detElemId = it.CurrentDEId();
785 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
787 // Get detection element store
788 AliMpExMap* detElements =
789 GetModuleTransformer(moduleId)->GetDetElementStore();
791 // Add detection element
792 AliMUONGeometryDetElement* detElement
793 = new AliMUONGeometryDetElement(detElemId);
794 detElements->Add(detElemId, detElement);
798 //_____________________________________________________________________________
799 void AliMUONGeometryTransformer::AddAlignableVolumes() const
801 /// Set symbolic names and matrices to alignable objects to TGeo
803 if ( ! gGeoManager ) {
804 AliWarning("TGeoManager not defined.");
809 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
810 AliMUONGeometryModuleTransformer* module
811 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
813 // Set module symbolic name
815 = gGeoManager->SetAlignableEntry(GetModuleSymName(module->GetModuleId()),
816 module->GetVolumePath());
819 << "Volume path " << module->GetVolumePath().Data()
820 << " for geometry module " << module->GetModuleId() << " " << module
821 << " not found in geometry." << endl;
825 pnEntry->SetMatrix(new TGeoHMatrix(*module->GetTransformation()));
826 // the matrix will be deleted via TGeoManager
829 // Detection elements
830 AliMpExMap* detElements = module->GetDetElementStore();
831 TIter next(detElements->CreateIterator());
832 AliMUONGeometryDetElement* detElement;
834 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
836 // Set detection element symbolic name
837 TGeoPNEntry* pnEntryDE
838 = gGeoManager->SetAlignableEntry(GetDESymName(detElement->GetId()),
839 detElement->GetVolumePath());
843 << detElement->GetVolumePath().Data()
844 << " for detection element " << detElement->GetId()
845 << " not found in geometry." << endl;
848 // Set detection element matrix
849 pnEntryDE->SetMatrix(new TGeoHMatrix(*detElement->GetGlobalTransformation()));
850 // the matrix will be deleted via TGeoManager
856 //_____________________________________________________________________________
857 TClonesArray* AliMUONGeometryTransformer::CreateZeroAlignmentData() const
859 /// Create array with zero alignment data
861 // Create array for zero-alignment objects
862 TClonesArray* array = new TClonesArray("AliAlignObjMatrix", 200);
863 TClonesArray& refArray =*array;
864 array->SetOwner(true);
870 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
871 AliMUONGeometryModuleTransformer* module
872 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
874 Int_t moduleId = module->GetModuleId();
877 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, moduleId);
879 // Create mis align matrix
880 Int_t pos = array->GetEntriesFast();
881 new (refArray[pos]) AliAlignObjMatrix(GetModuleSymName(moduleId), volId, matrix, kTRUE);
884 // Detection elements
885 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
886 AliMUONGeometryModuleTransformer* moduleTransformer
887 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
889 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
890 TIter next(detElements->CreateIterator());
891 AliMUONGeometryDetElement* detElement;
893 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
895 Int_t detElemId = detElement->GetId();
898 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, detElemId);
900 // Create mis align matrix
901 Int_t pos = array->GetEntriesFast();
902 new (refArray[pos]) AliAlignObjMatrix(GetDESymName(detElemId), volId, matrix, kTRUE);
909 //_____________________________________________________________________________
910 void AliMUONGeometryTransformer::ClearMisAlignmentData()
912 /// Clear the array of misalignment data
914 if ( ! fMisAlignArray ) return;
916 fMisAlignArray->Delete();
919 //_____________________________________________________________________________
920 void AliMUONGeometryTransformer::Global2Local(Int_t detElemId,
921 Float_t xg, Float_t yg, Float_t zg,
922 Float_t& xl, Float_t& yl, Float_t& zl) const
924 /// Transform point from the global reference frame (ALIC)
925 /// to the local reference frame of the detection element specified
928 const AliMUONGeometryModuleTransformer* kTransformer
929 = GetModuleTransformerByDEId(detElemId);
932 kTransformer->Global2Local(detElemId, xg, yg, zg, xl, yl, zl);
935 //_____________________________________________________________________________
936 void AliMUONGeometryTransformer::Global2Local(Int_t detElemId,
937 Double_t xg, Double_t yg, Double_t zg,
938 Double_t& xl, Double_t& yl, Double_t& zl) const
940 /// Transform point from the global reference frame (ALIC)
941 /// to the local reference frame of the detection element specified
944 const AliMUONGeometryModuleTransformer* kTransformer
945 = GetModuleTransformerByDEId(detElemId);
948 kTransformer->Global2Local(detElemId, xg, yg, zg, xl, yl, zl);
951 //_____________________________________________________________________________
952 void AliMUONGeometryTransformer::Local2Global(Int_t detElemId,
953 Float_t xl, Float_t yl, Float_t zl,
954 Float_t& xg, Float_t& yg, Float_t& zg) const
956 /// Transform point from the local reference frame of the detection element
957 /// specified by detElemId to the global reference frame (ALIC).
959 const AliMUONGeometryModuleTransformer* kTransformer
960 = GetModuleTransformerByDEId(detElemId);
963 kTransformer->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
966 //_____________________________________________________________________________
967 void AliMUONGeometryTransformer::Local2Global(Int_t detElemId,
968 Double_t xl, Double_t yl, Double_t zl,
969 Double_t& xg, Double_t& yg, Double_t& zg) const
971 /// Transform point from the local reference frame of the detection element
972 /// specified by detElemId to the global reference frame (ALIC).
974 const AliMUONGeometryModuleTransformer* kTransformer
975 = GetModuleTransformerByDEId(detElemId);
978 kTransformer->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
981 //_____________________________________________________________________________
982 const AliMUONGeometryModuleTransformer*
983 AliMUONGeometryTransformer::GetModuleTransformer(Int_t index, Bool_t warn) const
985 /// Return the geometry module transformer specified by index
987 return GetModuleTransformerNonConst(index, warn);
990 //_____________________________________________________________________________
991 const AliMUONGeometryModuleTransformer*
992 AliMUONGeometryTransformer::GetModuleTransformerByDEId(Int_t detElemId,
995 /// Return the geometry module transformer specified by detection element ID
998 Int_t index = AliMpDEManager::GetGeomModuleId(detElemId);
1000 return GetModuleTransformer(index, warn);
1003 //_____________________________________________________________________________
1004 const AliMUONGeometryDetElement*
1005 AliMUONGeometryTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const
1007 /// Return detection element with given detElemId
1009 const AliMUONGeometryModuleTransformer* kTransformer
1010 = GetModuleTransformerByDEId(detElemId, warn);
1012 if (!kTransformer) return 0;
1014 return kTransformer->GetDetElement(detElemId, warn);
1017 //_____________________________________________________________________________
1018 Bool_t AliMUONGeometryTransformer::HasDE(Int_t detElemId) const
1020 /// Return true if detection element with given detElemId is defined
1022 const AliMUONGeometryModuleTransformer* kTransformer
1023 = GetModuleTransformerByDEId(detElemId, false);
1025 if (!kTransformer) return false;
1027 return ( kTransformer->GetDetElement(detElemId, false) != 0 );