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>
61 using std::setprecision;
63 ClassImp(AliMUONGeometryTransformer)
67 // static private methods
70 //______________________________________________________________________________
71 const TString& AliMUONGeometryTransformer::GetDefaultDetectorName()
73 /// Default detector name
74 static const TString kDefaultDetectorName = "MUON";
75 return kDefaultDetectorName;
82 //______________________________________________________________________________
83 AliMUONGeometryTransformer::AliMUONGeometryTransformer()
86 fDetectorName(GetDefaultDetectorName()),
87 fModuleTransformers(0),
91 /// Standard constructor
93 // Create array for geometry modules
94 fModuleTransformers = new TObjArray(100);
95 fModuleTransformers->SetOwner(true);
98 //______________________________________________________________________________
99 AliMUONGeometryTransformer::AliMUONGeometryTransformer(TRootIOCtor* /*ioCtor*/)
102 fModuleTransformers(0),
106 /// Default constructor
109 //______________________________________________________________________________
110 AliMUONGeometryTransformer::~AliMUONGeometryTransformer()
114 delete fModuleTransformers;
115 delete fMisAlignArray;
124 //_____________________________________________________________________________
126 AliMUONGeometryTransformer::GetDEArea(Int_t detElemId) const
128 /// Get area (in global coordinates) covered by a given detection element
133 return static_cast<AliMpArea*>(fDEAreas->GetValue(detElemId));
136 //_____________________________________________________________________________
138 AliMUONGeometryTransformer::CreateDEAreas() const
142 fDEAreas = new AliMpExMap;
148 /// Generate the DE areas in global coordinates
150 while ( !it.IsDone() )
152 Int_t detElemId = it.CurrentDEId();
154 if ( !HasDE(detElemId) ) continue;
156 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::kCath0);
160 AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId);
162 Double_t xl(0.0), yl(0.0), zl(0.0);
163 Double_t dx(seg->GetDimensionX());
164 Double_t dy(seg->GetDimensionY());
166 if ( stationType == AliMp::kStation12 )
168 Double_t xmin(FLT_MAX);
169 Double_t xmax(-FLT_MAX);
170 Double_t ymin(FLT_MAX);
171 Double_t ymax(-FLT_MAX);
173 for ( Int_t icathode = 0; icathode < 2; ++icathode )
175 const AliMpVSegmentation* cathode
176 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(icathode));
178 AliMpVPadIterator* itp = cathode->CreateIterator();
182 while ( !itp->IsDone() )
184 AliMpPad pad = itp->CurrentItem();
185 AliMpArea a(pad.GetPositionX(),pad.GetPositionY(),
186 pad.GetDimensionX(), pad.GetDimensionY());
187 xmin = TMath::Min(xmin,a.LeftBorder());
188 xmax = TMath::Max(xmax,a.RightBorder());
189 ymin = TMath::Min(ymin,a.DownBorder());
190 ymax = TMath::Max(ymax,a.UpBorder());
197 xl = (xmin+xmax)/2.0;
198 yl = (ymin+ymax)/2.0;
199 dx = (xmax-xmin)/2.0;
200 dy = (ymax-ymin)/2.0;
202 Local2Global(detElemId,xl,yl,zl,xg,yg,zg);
206 Local2Global(detElemId,xl,yl,zl,xg,yg,zg);
209 fDEAreas->Add(detElemId,new AliMpArea(xg,yg,dx,dy));
215 //_____________________________________________________________________________
216 Bool_t AliMUONGeometryTransformer::LoadMapping() const
218 /// Load mapping from CDB
220 if ( ! AliMpCDB::LoadMpSegmentation() )
222 AliFatal("Could not access mapping from OCDB !");
229 //_____________________________________________________________________________
230 AliMUONGeometryModuleTransformer*
231 AliMUONGeometryTransformer::GetModuleTransformerNonConst(
232 Int_t index, Bool_t warn) const
234 /// Return the geometry module specified by index
236 if (index < 0 || index >= fModuleTransformers->GetEntriesFast()) {
239 << "Index: " << index << " outside limits" << std::endl;
244 return (AliMUONGeometryModuleTransformer*) fModuleTransformers->At(index);
247 //______________________________________________________________________________
248 TGeoHMatrix AliMUONGeometryTransformer::GetTransform(
249 Double_t x, Double_t y, Double_t z,
250 Double_t a1, Double_t a2, Double_t a3,
251 Double_t a4, Double_t a5, Double_t a6) const
253 /// Build the transformation from the given parameters
256 return TGeoCombiTrans(TGeoTranslation(x, y, z),
257 TGeoRotation("rot", a1, a2, a3, a4, a5, a6));
261 //______________________________________________________________________________
262 void AliMUONGeometryTransformer::FillModuleTransform(Int_t moduleId,
263 Double_t x, Double_t y, Double_t z,
264 Double_t a1, Double_t a2, Double_t a3,
265 Double_t a4, Double_t a5, Double_t a6)
267 /// Fill the transformation of the module.
269 AliMUONGeometryModuleTransformer* moduleTransformer
270 = GetModuleTransformerNonConst(moduleId, false);
272 if ( !moduleTransformer) {
274 << "Module " << moduleId << " has not volume path defined." << endl;
278 // Build the transformation from the parameters
279 TGeoHMatrix transform
280 = GetTransform(x, y, z, a1, a2, a3, a4, a5, a6);
282 moduleTransformer->SetTransformation(transform);
285 //______________________________________________________________________________
286 void AliMUONGeometryTransformer::FillDetElemTransform(
288 Double_t x, Double_t y, Double_t z,
289 Double_t a1, Double_t a2, Double_t a3,
290 Double_t a4, Double_t a5, Double_t a6)
292 /// Fill the transformation of the detection element.
295 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
297 // Get module transformer
298 const AliMUONGeometryModuleTransformer* kModuleTransformer
299 = GetModuleTransformer(moduleId);
301 if ( ! kModuleTransformer ) {
302 AliFatal(Form("Module transformer not defined, detElemId: %d", detElemId));
306 // Get detection element
307 AliMUONGeometryDetElement* detElement
308 = kModuleTransformer->GetDetElement(detElemId);
310 if ( ! detElement ) {
311 AliFatal(Form("Det element %d has not volume path defined", detElemId));
315 // Build the transformation from the parameters
316 TGeoHMatrix localTransform
317 = GetTransform(x, y, z, a1, a2, a3, a4, a5, a6);
318 detElement->SetLocalTransformation(localTransform);
320 // Compute global transformation
321 TGeoHMatrix globalTransform
322 = AliMUONGeometryBuilder::Multiply(
323 *kModuleTransformer->GetTransformation(),
325 detElement->SetGlobalTransformation(globalTransform);
328 //______________________________________________________________________________
329 TString AliMUONGeometryTransformer::ReadModuleTransforms(ifstream& in)
331 /// Read and fill modules transformations from the stream.
332 /// Return true, if reading finished correctly.
334 TString key(AliMUONGeometryModuleTransformer::GetModuleNamePrefix());
335 while ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() ) {
338 Double_t a1, a2, a3, a4, a5, a6;
354 //cout << "moduleId=" << id << " "
355 // << "position= " << x << ", " << y << ", " << z << " "
356 // << "rotation= " << a1 << ", " << a2 << ", " << a3 << ", "
357 // << a4 << ", " << a5 << ", " << a6
361 FillModuleTransform(id, x, y, z, a1, a2, a3, a4, a5, a6);
370 //______________________________________________________________________________
371 TString AliMUONGeometryTransformer::ReadDetElemTransforms(ifstream& in)
373 /// Read detection elements transformations from the stream.
374 /// Return true, if reading finished correctly.
376 TString key(AliMUONGeometryDetElement::GetDENamePrefix());
377 while ( key == AliMUONGeometryDetElement::GetDENamePrefix() ) {
382 Double_t a1, a2, a3, a4, a5, a6;
398 //cout << "detElemId=" << detElemId << " "
399 // << "position= " << x << ", " << y << ", " << z << " "
400 // << "rotation= " << a1 << ", " << a2 << ", " << a3 << ", "
401 // << a4 << ", " << a5 << ", " << a6
405 FillDetElemTransform(detElemId, x, y, z, a1, a2, a3, a4, a5, a6);
414 //______________________________________________________________________________
416 AliMUONGeometryTransformer::ReadTransformations(const TString& fileName)
418 /// Read transformations from a file.
419 /// Return true, if reading finished correctly.
422 TString filePath = gSystem->Getenv("ALICE_ROOT");
423 filePath += "/MUON/data/";
424 filePath += fileName;
427 ifstream in(filePath, ios::in);
429 cerr << filePath << endl;
430 AliFatal("File not found.");
436 while ( !in.eof() ) {
437 if ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() )
438 key = ReadModuleTransforms(in);
439 else if ( key == AliMUONGeometryDetElement::GetDENamePrefix() )
440 key = ReadDetElemTransforms(in);
442 AliFatal(Form("%s key not recognized", key.Data()));
450 //______________________________________________________________________________
451 void AliMUONGeometryTransformer::WriteTransform(ofstream& out,
452 const TGeoMatrix* transform) const
454 /// Write given transformation
457 const Double_t* xyz = transform->GetTranslation();
458 out << setw(10) << setprecision(4) << xyz[0] << " "
459 << setw(10) << setprecision(4) << xyz[1] << " "
460 << setw(10) << setprecision(4) << xyz[2];
463 const Double_t* rm = transform->GetRotationMatrix();
464 TGeoRotation rotation;
465 rotation.SetMatrix(const_cast<Double_t*>(rm));
466 Double_t a1, a2, a3, a4, a5, a6;
467 rotation.GetAngles(a1, a2, a3, a4, a5, a6);
469 out << setw(8) << setprecision(4) << a1 << " "
470 << setw(8) << setprecision(4) << a2 << " "
471 << setw(8) << setprecision(4) << a3 << " "
472 << setw(8) << setprecision(4) << a4 << " "
473 << setw(8) << setprecision(4) << a5 << " "
474 << setw(8) << setprecision(4) << a6 << " " << endl;
477 //______________________________________________________________________________
478 void AliMUONGeometryTransformer::WriteModuleTransforms(ofstream& out) const
480 /// Write module transformations for all module transformers
482 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
483 AliMUONGeometryModuleTransformer* moduleTransformer
484 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
485 const TGeoMatrix* transform
486 = moduleTransformer->GetTransformation();
489 out << AliMUONGeometryModuleTransformer::GetModuleNamePrefix() << " "
490 << setw(4) << moduleTransformer->GetModuleId();
492 WriteTransform(out, transform);
497 //______________________________________________________________________________
498 void AliMUONGeometryTransformer::WriteDetElemTransforms(ofstream& out) const
500 /// Write detection element transformations for all detection elements in all
501 /// module transformers
503 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
504 AliMUONGeometryModuleTransformer* moduleTransformer
505 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
506 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
507 TIter next(detElements->CreateIterator());
508 AliMUONGeometryDetElement* detElement;
509 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
511 const TGeoMatrix* transform
512 = detElement->GetLocalTransformation();
515 out << AliMUONGeometryDetElement::GetDENamePrefix() << " "
516 << setw(4) << detElement->GetId();
518 WriteTransform(out, transform);
524 //______________________________________________________________________________
525 TString AliMUONGeometryTransformer::GetModuleSymName(Int_t moduleId) const
527 /// Return the module symbolic name (use for alignment)
529 return "/" + fDetectorName + "/"
530 + AliMUONGeometryModuleTransformer::GetModuleName(moduleId);
533 //______________________________________________________________________________
534 TString AliMUONGeometryTransformer::GetDESymName(Int_t detElemId) const
536 /// Return the detection element symbolic name (used for alignment)
539 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
541 return GetModuleSymName(moduleId) + "/"
542 + AliMUONGeometryDetElement::GetDEName(detElemId);
549 //______________________________________________________________________________
551 AliMUONGeometryTransformer::LoadTransformations()
553 /// Load transformations for defined modules and detection elements
554 /// using AliGeomManager
556 if ( ! AliGeomManager::GetGeometry() ) {
557 AliFatal("Geometry has to be laoded in AliGeomManager first.");
561 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
562 AliMUONGeometryModuleTransformer* moduleTransformer
563 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
565 // Module symbolic name
566 TString symname = GetModuleSymName(moduleTransformer->GetModuleId());
568 // Set matrix from physical node
569 TGeoHMatrix* matrix = AliGeomManager::GetMatrix(symname);
571 AliErrorStream() << "Geometry module matrix not found." << endl;
574 moduleTransformer->SetTransformation(*matrix);
576 // Loop over detection elements
577 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
578 TIter next(detElements->CreateIterator());
579 AliMUONGeometryDetElement* detElement;
581 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
583 // Det element symbolic name
584 TString symnameDE = GetDESymName(detElement->GetId());
586 // Set global matrix from physical node
587 TGeoHMatrix* globalMatrix = AliGeomManager::GetMatrix(symnameDE);
588 if ( ! globalMatrix ) {
589 AliErrorStream() << "Detection element matrix not found." << endl;
592 detElement->SetGlobalTransformation(*globalMatrix, false);
595 TGeoHMatrix localMatrix =
596 AliMUONGeometryBuilder::Multiply(
597 (*matrix).Inverse(), (*globalMatrix) );
598 detElement->SetLocalTransformation(localMatrix, false);
604 //______________________________________________________________________________
606 AliMUONGeometryTransformer::LoadGeometryData(const TString& fileName)
608 /// Read geometry data either from ASCII file with transformations or
609 /// from root geometry file (if fileName has ".root" extension)
613 // Get file extension
614 std::string fileName2 = fileName.Data();
615 std::string rootExt = fileName2.substr(fileName2.size()-5, fileName2.size());
617 if ( rootExt != ".root" )
618 return ReadTransformations(fileName);
620 // Load root geometry
621 AliGeomManager::LoadGeometry(fileName.Data());
622 return LoadTransformations();
626 //______________________________________________________________________________
628 AliMUONGeometryTransformer::LoadGeometryData()
630 /// Load geometry data from already loaded Root geometry using AliGeomManager
632 if ( ! AliGeomManager::GetGeometry() ) {
633 AliErrorStream() << "Geometry has not been loaded in AliGeomManager" << endl;
639 return LoadTransformations();
642 //______________________________________________________________________________
644 AliMUONGeometryTransformer::WriteTransformations(const TString& fileName) const
646 /// Write transformations into a file.
647 /// Return true, if writing finished correctly.
650 // if builder is not associated with any geometry module
651 if (fModuleTransformers->GetEntriesFast() == 0) return false;
654 TString filePath = gSystem->Getenv("ALICE_ROOT");
655 filePath += "/MUON/data/";
656 filePath += fileName;
659 ofstream out(filePath, ios::out);
661 cerr << filePath << endl;
662 AliError("File not found.");
665 #if !defined (__DECCXX)
666 out.setf(std::ios::fixed);
668 WriteModuleTransforms(out);
669 WriteDetElemTransforms(out);
674 //______________________________________________________________________________
676 AliMUONGeometryTransformer::WriteMisAlignmentData(const TString& fileName) const
678 /// Write misalignment data into a file
679 /// Return true, if writing finished correctly.
682 // if builder is not associated with any geometry module
683 if ( fModuleTransformers->GetEntriesFast() == 0 ) {
684 AliWarningStream() << "No geometry modules defined." << endl;
689 // if builder has no mis-alignment data
690 if ( ! fMisAlignArray ) {
691 AliWarningStream() << "No mis-alignment data defined." << endl;
696 TString filePath = gSystem->Getenv("ALICE_ROOT");
697 filePath += "/MUON/data/";
698 filePath += fileName;
700 // Write mis-alignment data in the root file
701 TFile file(fileName.Data(), "RECREATE");
702 fMisAlignArray->Write();
708 //_____________________________________________________________________________
709 void AliMUONGeometryTransformer::AddModuleTransformer(
710 AliMUONGeometryModuleTransformer* moduleTransformer)
712 /// Add the module transformer to the array
714 // Expand the size if not sufficient
715 Int_t moduleId = moduleTransformer->GetModuleId();
716 if ( moduleId >= fModuleTransformers->GetSize() )
717 fModuleTransformers->Expand(moduleId+1);
719 fModuleTransformers->AddAt(moduleTransformer, moduleId);
722 //_____________________________________________________________________________
723 void AliMUONGeometryTransformer::AddMisAlignModule(Int_t moduleId,
724 const TGeoHMatrix& matrix, Bool_t bGlobal)
726 /// Build AliAlignObjMatrix with module ID, its volumePath
727 /// and the given delta transformation matrix
729 if ( ! fMisAlignArray )
730 fMisAlignArray = new TClonesArray("AliAlignObjMatrix", 200);
732 const AliMUONGeometryModuleTransformer* kTransformer
733 = GetModuleTransformer(moduleId);
734 if ( ! kTransformer ) {
735 AliErrorStream() << "Module " << moduleId << " not found." << endl;
739 // Get unique align object ID
740 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, moduleId);
742 // Create mis align matrix
743 TClonesArray& refArray =*fMisAlignArray;
744 Int_t pos = fMisAlignArray->GetEntriesFast();
745 new (refArray[pos]) AliAlignObjMatrix(GetModuleSymName(moduleId), volId,
746 const_cast<TGeoHMatrix&>(matrix),bGlobal);
749 //_____________________________________________________________________________
750 void AliMUONGeometryTransformer::AddMisAlignDetElement(Int_t detElemId,
751 const TGeoHMatrix& matrix, Bool_t bGlobal)
753 /// Build AliAlignObjMatrix with detection element ID, its volumePath
754 /// and the given delta transformation matrix
756 if ( ! fMisAlignArray )
757 fMisAlignArray = new TClonesArray("AliAlignObjMatrix", 200);
759 const AliMUONGeometryDetElement* kDetElement
760 = GetDetElement(detElemId);
762 if ( ! kDetElement ) {
763 AliErrorStream() << "Det element " << detElemId << " not found." << endl;
767 // Get unique align object ID
768 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, detElemId);
770 // Create mis align matrix
771 TClonesArray& refArray =*fMisAlignArray;
772 Int_t pos = fMisAlignArray->GetEntriesFast();
773 new(refArray[pos]) AliAlignObjMatrix(GetDESymName(detElemId), volId,
774 const_cast<TGeoHMatrix&>(matrix),bGlobal);
777 //______________________________________________________________________________
778 void AliMUONGeometryTransformer::CreateModules()
780 /// Create modules and their detection elements using info from mapping;
781 /// but do not fill matrices
783 // Load mapping as its info is used to define modules & DEs
786 if ( fModuleTransformers->GetEntriesFast() == 0 ) {
787 // Create modules only if they do not yet exist
789 // Loop over geometry module
790 for (Int_t moduleId = 0; moduleId < AliMpConstants::NofGeomModules(); ++moduleId ) {
792 // Create geometry module transformer
793 AliMUONGeometryModuleTransformer* moduleTransformer
794 = new AliMUONGeometryModuleTransformer(moduleId);
795 AddModuleTransformer(moduleTransformer);
799 // Loop over detection elements
801 for ( it.First(); ! it.IsDone(); it.Next() ) {
803 Int_t detElemId = it.CurrentDEId();
804 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
806 // Get detection element store
807 AliMpExMap* detElements =
808 GetModuleTransformer(moduleId)->GetDetElementStore();
810 // Add detection element
811 AliMUONGeometryDetElement* detElement
812 = new AliMUONGeometryDetElement(detElemId);
813 detElements->Add(detElemId, detElement);
817 //_____________________________________________________________________________
818 void AliMUONGeometryTransformer::AddAlignableVolumes() const
820 /// Set symbolic names and matrices to alignable objects to TGeo
822 if ( ! gGeoManager ) {
823 AliWarning("TGeoManager not defined.");
828 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
829 AliMUONGeometryModuleTransformer* module
830 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
832 // Set module symbolic name
834 = gGeoManager->SetAlignableEntry(GetModuleSymName(module->GetModuleId()),
835 module->GetVolumePath());
838 << "Volume path " << module->GetVolumePath().Data()
839 << " for geometry module " << module->GetModuleId() << " " << module
840 << " not found in geometry." << endl;
844 pnEntry->SetMatrix(new TGeoHMatrix(*module->GetTransformation()));
845 // the matrix will be deleted via TGeoManager
848 // Detection elements
849 AliMpExMap* detElements = module->GetDetElementStore();
850 TIter next(detElements->CreateIterator());
851 AliMUONGeometryDetElement* detElement;
853 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
855 // Set detection element symbolic name
856 TGeoPNEntry* pnEntryDE
857 = gGeoManager->SetAlignableEntry(GetDESymName(detElement->GetId()),
858 detElement->GetVolumePath());
862 << detElement->GetVolumePath().Data()
863 << " for detection element " << detElement->GetId()
864 << " not found in geometry." << endl;
867 // Set detection element matrix
868 pnEntryDE->SetMatrix(new TGeoHMatrix(*detElement->GetGlobalTransformation()));
869 // the matrix will be deleted via TGeoManager
875 //_____________________________________________________________________________
876 TClonesArray* AliMUONGeometryTransformer::CreateZeroAlignmentData() const
878 /// Create array with zero alignment data
880 // Create array for zero-alignment objects
881 TClonesArray* array = new TClonesArray("AliAlignObjMatrix", 200);
882 TClonesArray& refArray =*array;
883 array->SetOwner(true);
889 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
890 AliMUONGeometryModuleTransformer* module
891 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
893 Int_t moduleId = module->GetModuleId();
896 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, moduleId);
898 // Create mis align matrix
899 Int_t pos = array->GetEntriesFast();
900 new (refArray[pos]) AliAlignObjMatrix(GetModuleSymName(moduleId), volId, matrix, kTRUE);
903 // Detection elements
904 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
905 AliMUONGeometryModuleTransformer* moduleTransformer
906 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
908 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
909 TIter next(detElements->CreateIterator());
910 AliMUONGeometryDetElement* detElement;
912 while ( ( detElement = static_cast<AliMUONGeometryDetElement*>(next()) ) )
914 Int_t detElemId = detElement->GetId();
917 Int_t volId = AliGeomManager::LayerToVolUID(AliGeomManager::kMUON, detElemId);
919 // Create mis align matrix
920 Int_t pos = array->GetEntriesFast();
921 new (refArray[pos]) AliAlignObjMatrix(GetDESymName(detElemId), volId, matrix, kTRUE);
928 //_____________________________________________________________________________
929 void AliMUONGeometryTransformer::ClearMisAlignmentData()
931 /// Clear the array of misalignment data
933 if ( ! fMisAlignArray ) return;
935 fMisAlignArray->Delete();
938 //_____________________________________________________________________________
939 void AliMUONGeometryTransformer::Global2Local(Int_t detElemId,
940 Float_t xg, Float_t yg, Float_t zg,
941 Float_t& xl, Float_t& yl, Float_t& zl) const
943 /// Transform point from the global reference frame (ALIC)
944 /// to the local reference frame of the detection element specified
947 const AliMUONGeometryModuleTransformer* kTransformer
948 = GetModuleTransformerByDEId(detElemId);
951 kTransformer->Global2Local(detElemId, xg, yg, zg, xl, yl, zl);
954 //_____________________________________________________________________________
955 void AliMUONGeometryTransformer::Global2Local(Int_t detElemId,
956 Double_t xg, Double_t yg, Double_t zg,
957 Double_t& xl, Double_t& yl, Double_t& zl) const
959 /// Transform point from the global reference frame (ALIC)
960 /// to the local reference frame of the detection element specified
963 const AliMUONGeometryModuleTransformer* kTransformer
964 = GetModuleTransformerByDEId(detElemId);
967 kTransformer->Global2Local(detElemId, xg, yg, zg, xl, yl, zl);
970 //_____________________________________________________________________________
971 void AliMUONGeometryTransformer::Local2Global(Int_t detElemId,
972 Float_t xl, Float_t yl, Float_t zl,
973 Float_t& xg, Float_t& yg, Float_t& zg) const
975 /// Transform point from the local reference frame of the detection element
976 /// specified by detElemId to the global reference frame (ALIC).
978 const AliMUONGeometryModuleTransformer* kTransformer
979 = GetModuleTransformerByDEId(detElemId);
982 kTransformer->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
985 //_____________________________________________________________________________
986 void AliMUONGeometryTransformer::Local2Global(Int_t detElemId,
987 Double_t xl, Double_t yl, Double_t zl,
988 Double_t& xg, Double_t& yg, Double_t& zg) const
990 /// Transform point from the local reference frame of the detection element
991 /// specified by detElemId to the global reference frame (ALIC).
993 const AliMUONGeometryModuleTransformer* kTransformer
994 = GetModuleTransformerByDEId(detElemId);
997 kTransformer->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
1000 //_____________________________________________________________________________
1001 const AliMUONGeometryModuleTransformer*
1002 AliMUONGeometryTransformer::GetModuleTransformer(Int_t index, Bool_t warn) const
1004 /// Return the geometry module transformer specified by index
1006 return GetModuleTransformerNonConst(index, warn);
1009 //_____________________________________________________________________________
1010 const AliMUONGeometryModuleTransformer*
1011 AliMUONGeometryTransformer::GetModuleTransformerByDEId(Int_t detElemId,
1014 /// Return the geometry module transformer specified by detection element ID
1017 Int_t index = AliMpDEManager::GetGeomModuleId(detElemId);
1019 return GetModuleTransformer(index, warn);
1022 //_____________________________________________________________________________
1023 const AliMUONGeometryDetElement*
1024 AliMUONGeometryTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const
1026 /// Return detection element with given detElemId
1028 const AliMUONGeometryModuleTransformer* kTransformer
1029 = GetModuleTransformerByDEId(detElemId, warn);
1031 if (!kTransformer) return 0;
1033 return kTransformer->GetDetElement(detElemId, warn);
1036 //_____________________________________________________________________________
1037 Bool_t AliMUONGeometryTransformer::HasDE(Int_t detElemId) const
1039 /// Return true if detection element with given detElemId is defined
1041 const AliMUONGeometryModuleTransformer* kTransformer
1042 = GetModuleTransformerByDEId(detElemId, false);
1044 if (!kTransformer) return false;
1046 return ( kTransformer->GetDetElement(detElemId, false) != 0 );