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
24 #include "AliMUONGeometryTransformer.h"
25 #include "AliMUONGeometryModuleTransformer.h"
26 #include "AliMUONGeometryDetElement.h"
27 #include "AliMUONGeometryBuilder.h"
29 #include "AliMpDEManager.h"
30 #include "AliMpExMap.h"
33 #include "AliAlignObjMatrix.h"
34 #include "AliAlignObj.h"
36 #include <Riostream.h>
38 #include <TClonesArray.h>
39 #include <TGeoManager.h>
40 #include <TGeoPhysicalNode.h>
46 ClassImp(AliMUONGeometryTransformer)
49 //______________________________________________________________________________
50 AliMUONGeometryTransformer::AliMUONGeometryTransformer(Bool_t isOwner,
51 const TString& detectorName)
54 fDetectorName(detectorName),
55 fModuleTransformers(0),
58 /// Standard constructor
60 // Create array for geometry modules
61 fModuleTransformers = new TObjArray(100);
62 fModuleTransformers->SetOwner(isOwner);
65 //______________________________________________________________________________
66 AliMUONGeometryTransformer::AliMUONGeometryTransformer()
69 fModuleTransformers(0),
72 /// Default constructor
75 //______________________________________________________________________________
76 AliMUONGeometryTransformer::~AliMUONGeometryTransformer()
80 delete fModuleTransformers;
81 delete fMisAlignArray;
88 //_____________________________________________________________________________
89 AliMUONGeometryModuleTransformer*
90 AliMUONGeometryTransformer::GetModuleTransformerNonConst(
91 Int_t index, Bool_t warn) const
93 /// Return the geometry module specified by index
95 if (index < 0 || index >= fModuleTransformers->GetEntriesFast()) {
98 << "Index: " << index << " outside limits" << std::endl;
103 return (AliMUONGeometryModuleTransformer*) fModuleTransformers->At(index);
106 //______________________________________________________________________________
107 TGeoHMatrix AliMUONGeometryTransformer::GetTransform(
108 Double_t x, Double_t y, Double_t z,
109 Double_t a1, Double_t a2, Double_t a3,
110 Double_t a4, Double_t a5, Double_t a6) const
112 /// Build the transformation from the given parameters
115 return TGeoCombiTrans(TGeoTranslation(x, y, z),
116 TGeoRotation("rot", a1, a2, a3, a4, a5, a6));
120 //______________________________________________________________________________
121 void AliMUONGeometryTransformer::FillModuleVolPath(Int_t moduleId,
122 const TString& volPath)
124 /// Create module with the given moduleId and volPath
126 // Get/Create geometry module transformer
127 AliMUONGeometryModuleTransformer* moduleTransformer
128 = GetModuleTransformerNonConst(moduleId, false);
130 if ( !moduleTransformer ) {
131 moduleTransformer = new AliMUONGeometryModuleTransformer(moduleId);
132 AddModuleTransformer(moduleTransformer);
134 moduleTransformer->SetVolumePath(volPath);
137 //______________________________________________________________________________
138 void AliMUONGeometryTransformer::FillDetElemVolPath(Int_t detElemId,
139 const TString& volPath)
141 /// Create detection element with the given detElemId and volPath
144 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
146 // Get detection element store
147 AliMpExMap* detElements =
148 GetModuleTransformer(moduleId)->GetDetElementStore();
150 // Add detection element
151 AliMUONGeometryDetElement* detElement
152 = new AliMUONGeometryDetElement(detElemId, volPath);
153 detElements->Add(detElemId, detElement);
157 //______________________________________________________________________________
158 void AliMUONGeometryTransformer::FillModuleTransform(Int_t moduleId,
159 Double_t x, Double_t y, Double_t z,
160 Double_t a1, Double_t a2, Double_t a3,
161 Double_t a4, Double_t a5, Double_t a6)
163 /// Fill the transformation of the module.
165 AliMUONGeometryModuleTransformer* moduleTransformer
166 = GetModuleTransformerNonConst(moduleId, false);
168 if ( !moduleTransformer) {
170 << "Module " << moduleId << " has not volume path defined." << endl;
173 // Build the transformation from the parameters
174 TGeoHMatrix transform
175 = GetTransform(x, y, z, a1, a2, a3, a4, a5, a6);
177 moduleTransformer->SetTransformation(transform);
180 //______________________________________________________________________________
181 void AliMUONGeometryTransformer::FillDetElemTransform(
183 Double_t x, Double_t y, Double_t z,
184 Double_t a1, Double_t a2, Double_t a3,
185 Double_t a4, Double_t a5, Double_t a6)
187 /// Fill the transformation of the detection element.
190 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
192 // Get module transformer
193 const AliMUONGeometryModuleTransformer* kModuleTransformer
194 = GetModuleTransformer(moduleId);
196 if ( ! kModuleTransformer ) {
197 AliFatal(Form("Module transformer not defined, detElemId: %d", detElemId));
201 // Get detection element
202 AliMUONGeometryDetElement* detElement
203 = kModuleTransformer->GetDetElement(detElemId);
205 if ( ! detElement ) {
206 AliFatal(Form("Det element %d has not volume path defined", detElemId));
210 // Build the transformation from the parameters
211 TGeoHMatrix localTransform
212 = GetTransform(x, y, z, a1, a2, a3, a4, a5, a6);
213 detElement->SetLocalTransformation(localTransform);
215 // Compute global transformation
216 TGeoHMatrix globalTransform
217 = AliMUONGeometryBuilder::Multiply(
218 *kModuleTransformer->GetTransformation(),
220 detElement->SetGlobalTransformation(globalTransform);
223 //______________________________________________________________________________
225 AliMUONGeometryTransformer::ReadVolPaths(ifstream& in)
227 /// Read modules and detection element volume paths from stream
230 TString key, volumePath;
233 while ( !in.eof() ) {
235 in >> id >> volumePath;
237 // cout << "id=" << id << " "
238 // << "volPath= " << volumePath
241 if ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() )
242 FillModuleVolPath(id, volumePath);
244 else if ( key == AliMUONGeometryDetElement::GetDENamePrefix() )
245 FillDetElemVolPath(id, volumePath);
248 AliFatal(Form("%s key not recognized", key.Data()));
257 //______________________________________________________________________________
258 TString AliMUONGeometryTransformer::ReadModuleTransforms(ifstream& in)
260 /// Read and fill modules transformations from the stream.
261 /// Return true, if reading finished correctly.
263 TString key(AliMUONGeometryModuleTransformer::GetModuleNamePrefix());
264 while ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() ) {
267 Double_t a1, a2, a3, a4, a5, a6;
283 //cout << "moduleId=" << id << " "
284 // << "position= " << x << ", " << y << ", " << z << " "
285 // << "rotation= " << a1 << ", " << a2 << ", " << a3 << ", "
286 // << a4 << ", " << a5 << ", " << a6
290 FillModuleTransform(id, x, y, z, a1, a2, a3, a4, a5, a6);
299 //______________________________________________________________________________
300 TString AliMUONGeometryTransformer::ReadDetElemTransforms(ifstream& in)
302 /// Read detection elements transformations from the stream.
303 /// Return true, if reading finished correctly.
305 TString key(AliMUONGeometryDetElement::GetDENamePrefix());
306 while ( key == AliMUONGeometryDetElement::GetDENamePrefix() ) {
311 Double_t a1, a2, a3, a4, a5, a6;
327 //cout << "detElemId=" << detElemId << " "
328 // << "position= " << x << ", " << y << ", " << z << " "
329 // << "rotation= " << a1 << ", " << a2 << ", " << a3 << ", "
330 // << a4 << ", " << a5 << ", " << a6
334 FillDetElemTransform(detElemId, x, y, z, a1, a2, a3, a4, a5, a6);
343 //______________________________________________________________________________
345 AliMUONGeometryTransformer::LoadTransforms(TGeoManager* tgeoManager)
347 /// Load transformations for defined modules and detection elements
348 /// from the root file
351 AliFatal("No TGeoManager defined.");
355 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
356 AliMUONGeometryModuleTransformer* moduleTransformer
357 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
360 TString path = moduleTransformer->GetVolumePath();
362 // Make physical node
363 TGeoPhysicalNode* moduleNode = tgeoManager->MakePhysicalNode(path);
364 if ( ! moduleNode ) {
366 << "Module id: " << moduleTransformer->GetModuleId()
367 << " volume path: " << path << " not found in geometry." << endl;
371 // Set matrix from physical node
372 TGeoHMatrix matrix = *moduleNode->GetMatrix();
373 moduleTransformer->SetTransformation(matrix);
375 // Loop over detection elements
376 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
378 for (Int_t j=0; j<detElements->GetSize(); j++) {
379 AliMUONGeometryDetElement* detElement
380 = (AliMUONGeometryDetElement*)detElements->GetObject(j);
383 TString dePath = detElement->GetVolumePath();
385 // Make physical node
386 TGeoPhysicalNode* deNode = tgeoManager->MakePhysicalNode(dePath);
389 << "Det element id: " << detElement->GetId()
390 << " volume path: " << path << " not found in geometry." << endl;
394 // Set global matrix from physical node
395 TGeoHMatrix globalMatrix = *deNode->GetMatrix();
396 detElement->SetGlobalTransformation(globalMatrix);
399 TGeoHMatrix localMatrix =
400 AliMUONGeometryBuilder::Multiply(
401 matrix.Inverse(), globalMatrix );
402 detElement->SetLocalTransformation(localMatrix);
408 //______________________________________________________________________________
410 AliMUONGeometryTransformer::ReadVolPaths(const TString& fileName)
412 /// Read detection element volume paths from a file.
413 /// Return true, if reading finished correctly.
416 TString filePath = gSystem->Getenv("ALICE_ROOT");
417 filePath += "/MUON/data/";
418 filePath += fileName;
421 ifstream in(filePath, ios::in);
423 cerr << filePath << endl;
424 AliFatal("File not found.");
432 //______________________________________________________________________________
434 AliMUONGeometryTransformer::ReadTransformations(const TString& fileName)
436 /// Read transformations from a file.
437 /// Return true, if reading finished correctly.
440 TString filePath = gSystem->Getenv("ALICE_ROOT");
441 filePath += "/MUON/data/";
442 filePath += fileName;
445 ifstream in(filePath, ios::in);
447 cerr << filePath << endl;
448 AliFatal("File not found.");
454 while ( !in.eof() ) {
455 if ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() )
456 key = ReadModuleTransforms(in);
457 else if ( key == AliMUONGeometryDetElement::GetDENamePrefix() )
458 key = ReadDetElemTransforms(in);
460 AliFatal(Form("%s key not recognized", key.Data()));
468 //______________________________________________________________________________
470 AliMUONGeometryTransformer::ReadTransformations2(const TString& fileName)
472 /// Read transformations from root geometry file.
473 /// Return true, if reading finished correctly.
476 TString filePath = gSystem->Getenv("ALICE_ROOT");
477 filePath += "/MUON/data/";
478 filePath += fileName;
480 // Load root geometry
481 TGeoManager* tgeoManager = gGeoManager;
483 tgeoManager = TGeoManager::Import(fileName);
486 LoadTransforms(tgeoManager);
491 //______________________________________________________________________________
492 void AliMUONGeometryTransformer::WriteTransform(ofstream& out,
493 const TGeoMatrix* transform) const
495 /// Write given transformation
498 const Double_t* xyz = transform->GetTranslation();
499 out << setw(10) << setprecision(4) << xyz[0] << " "
500 << setw(10) << setprecision(4) << xyz[1] << " "
501 << setw(10) << setprecision(4) << xyz[2];
504 const Double_t* rm = transform->GetRotationMatrix();
505 TGeoRotation rotation;
506 rotation.SetMatrix(const_cast<Double_t*>(rm));
507 Double_t a1, a2, a3, a4, a5, a6;
508 rotation.GetAngles(a1, a2, a3, a4, a5, a6);
510 out << setw(8) << setprecision(4) << a1 << " "
511 << setw(8) << setprecision(4) << a2 << " "
512 << setw(8) << setprecision(4) << a3 << " "
513 << setw(8) << setprecision(4) << a4 << " "
514 << setw(8) << setprecision(4) << a5 << " "
515 << setw(8) << setprecision(4) << a6 << " " << endl;
518 //______________________________________________________________________________
519 void AliMUONGeometryTransformer::WriteModuleVolPaths(ofstream& out) const
521 /// Write module volume paths for all module transformers
523 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
524 AliMUONGeometryModuleTransformer* moduleTransformer
525 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
528 out << AliMUONGeometryModuleTransformer::GetModuleNamePrefix() << " "
529 << setw(4) << moduleTransformer->GetModuleId() << " "
530 << moduleTransformer->GetVolumePath() << endl;
535 //______________________________________________________________________________
536 void AliMUONGeometryTransformer::WriteDetElemVolPaths(ofstream& out) const
538 /// Write detection element volume paths for all detection elements in all
539 /// module transformers
541 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
542 AliMUONGeometryModuleTransformer* moduleTransformer
543 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
544 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
546 for (Int_t j=0; j<detElements->GetSize(); j++) {
547 AliMUONGeometryDetElement* detElement
548 = (AliMUONGeometryDetElement*)detElements->GetObject(j);
551 out << AliMUONGeometryDetElement::GetDENamePrefix() << " "
552 << setw(4) << detElement->GetId() << " "
553 << detElement->GetVolumePath() << endl;
559 //______________________________________________________________________________
560 void AliMUONGeometryTransformer::WriteModuleTransforms(ofstream& out) const
562 /// Write module transformations for all module transformers
564 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
565 AliMUONGeometryModuleTransformer* moduleTransformer
566 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
567 const TGeoMatrix* transform
568 = moduleTransformer->GetTransformation();
571 out << AliMUONGeometryModuleTransformer::GetModuleNamePrefix() << " "
572 << setw(4) << moduleTransformer->GetModuleId();
574 WriteTransform(out, transform);
579 //______________________________________________________________________________
580 void AliMUONGeometryTransformer::WriteDetElemTransforms(ofstream& out) const
582 /// Write detection element transformations for all detection elements in all
583 /// module transformers
585 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
586 AliMUONGeometryModuleTransformer* moduleTransformer
587 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
588 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
590 for (Int_t j=0; j<detElements->GetSize(); j++) {
591 AliMUONGeometryDetElement* detElement
592 = (AliMUONGeometryDetElement*)detElements->GetObject(j);
593 const TGeoMatrix* transform
594 = detElement->GetLocalTransformation();
597 out << AliMUONGeometryDetElement::GetDENamePrefix() << " "
598 << setw(4) << detElement->GetId();
600 WriteTransform(out, transform);
606 //______________________________________________________________________________
607 TString AliMUONGeometryTransformer::GetModuleSymName(Int_t moduleId) const
609 /// Return the module symbolic name (use for alignment)
611 const AliMUONGeometryModuleTransformer* kTransformer
612 = GetModuleTransformer(moduleId);
613 if ( ! kTransformer ) {
614 AliErrorStream() << "Module " << moduleId << " not found." << endl;
618 return "/" + fDetectorName + "/" + kTransformer->GetModuleName();
621 //______________________________________________________________________________
622 TString AliMUONGeometryTransformer::GetDESymName(Int_t detElemId) const
624 /// Return the detection element symbolic name (used for alignment)
626 const AliMUONGeometryDetElement* kDetElement
627 = GetDetElement(detElemId);
628 if ( ! kDetElement ) {
629 AliErrorStream() << "Det element " << detElemId << " not found." << endl;
634 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
636 return GetModuleSymName(moduleId) + "/" + kDetElement->GetDEName();
643 //______________________________________________________________________________
645 AliMUONGeometryTransformer::ReadGeometryData(
646 const TString& volPathFileName,
647 const TString& transformFileName)
649 /// Read geometry data from given files;
650 /// if transformFileName has ".root" extension, the transformations
651 /// are loaded from root geometry file, otherwise ASCII file
652 /// format is supposed
654 Bool_t result1 = ReadVolPaths(volPathFileName);
656 // Get file extension
657 std::string fileName = transformFileName.Data();
658 std::string rootExt = fileName.substr(fileName.size()-5, fileName.size());
660 if ( rootExt != ".root" )
661 result2 = ReadTransformations(transformFileName);
663 result2 = ReadTransformations2(transformFileName);
665 return result1 && result2;
668 //______________________________________________________________________________
670 AliMUONGeometryTransformer::ReadGeometryData(
671 const TString& volPathFileName,
672 TGeoManager* tgeoManager)
674 /// Load geometry data from root geometry using defined
675 /// volume paths from file
677 Bool_t result1 = ReadVolPaths(volPathFileName);
679 Bool_t result2 = LoadTransforms(tgeoManager);
681 return result1 && result2;
684 //______________________________________________________________________________
686 AliMUONGeometryTransformer::WriteGeometryData(
687 const TString& volPathFileName,
688 const TString& transformFileName,
689 const TString& misalignFileName) const
691 /// Write geometry data into given files
693 Bool_t result1 = WriteVolumePaths(volPathFileName);
694 Bool_t result2 = WriteTransformations(transformFileName);
696 Bool_t result3 = true;
697 if ( misalignFileName != "" )
698 result3 = WriteMisAlignmentData(misalignFileName);
700 return result1 && result2 && result3;
703 //______________________________________________________________________________
705 AliMUONGeometryTransformer::WriteVolumePaths(const TString& fileName) const
707 /// Write volume paths for modules and detection element volumes into a file.
708 /// Return true, if writing finished correctly.
711 // if builder is not associated with any geometry module
712 if (fModuleTransformers->GetEntriesFast() == 0) return false;
715 TString filePath = gSystem->Getenv("ALICE_ROOT");
716 filePath += "/MUON/data/";
717 filePath += fileName;
720 ofstream out(filePath, ios::out);
722 cerr << filePath << endl;
723 AliError("File not found.");
726 #if !defined (__DECCXX)
727 out.setf(std::ios::fixed);
729 WriteModuleVolPaths(out);
730 WriteDetElemVolPaths(out);
735 //______________________________________________________________________________
737 AliMUONGeometryTransformer::WriteTransformations(const TString& fileName) const
739 /// Write transformations into a file.
740 /// Return true, if writing finished correctly.
743 // if builder is not associated with any geometry module
744 if (fModuleTransformers->GetEntriesFast() == 0) return false;
747 TString filePath = gSystem->Getenv("ALICE_ROOT");
748 filePath += "/MUON/data/";
749 filePath += fileName;
752 ofstream out(filePath, ios::out);
754 cerr << filePath << endl;
755 AliError("File not found.");
758 #if !defined (__DECCXX)
759 out.setf(std::ios::fixed);
761 WriteModuleTransforms(out);
762 WriteDetElemTransforms(out);
767 //______________________________________________________________________________
769 AliMUONGeometryTransformer::WriteMisAlignmentData(const TString& fileName) const
771 /// Write misalignment data into a file
772 /// Return true, if writing finished correctly.
775 // if builder is not associated with any geometry module
776 if ( fModuleTransformers->GetEntriesFast() == 0 ) {
777 AliWarningStream() << "No geometry modules defined." << endl;
782 // if builder has no mis-alignment data
783 if ( ! fMisAlignArray ) {
784 AliWarningStream() << "No mis-alignment data defined." << endl;
789 TString filePath = gSystem->Getenv("ALICE_ROOT");
790 filePath += "/MUON/data/";
791 filePath += fileName;
793 // Write mis-alignment data in the root file
794 TFile file(fileName.Data(), "RECREATE");
795 fMisAlignArray->Write();
801 //_____________________________________________________________________________
802 void AliMUONGeometryTransformer::AddModuleTransformer(
803 AliMUONGeometryModuleTransformer* moduleTransformer)
805 /// Add the module transformer to the array
807 // Expand the size if not sufficient
808 Int_t moduleId = moduleTransformer->GetModuleId();
809 if ( moduleId >= fModuleTransformers->GetSize() )
810 fModuleTransformers->Expand(moduleId+1);
812 fModuleTransformers->AddAt(moduleTransformer, moduleId);
815 //_____________________________________________________________________________
816 void AliMUONGeometryTransformer::AddMisAlignModule(Int_t moduleId,
817 const TGeoHMatrix& matrix)
819 /// Build AliAlignObjMatrix with module ID, its volumePath
820 /// and the given delta transformation matrix
822 if ( ! fMisAlignArray )
823 fMisAlignArray = new TClonesArray("AliAlignObjMatrix", 200);
825 const AliMUONGeometryModuleTransformer* kTransformer
826 = GetModuleTransformer(moduleId);
827 if ( ! kTransformer ) {
828 AliErrorStream() << "Module " << moduleId << " not found." << endl;
832 // Get unique align object ID
833 Int_t volId = AliAlignObj::LayerToVolUID(AliAlignObj::kMUON, moduleId);
835 // Create mis align matrix
836 TClonesArray& refArray =*fMisAlignArray;
837 Int_t pos = fMisAlignArray->GetEntriesFast();
838 new (refArray[pos]) AliAlignObjMatrix(GetModuleSymName(moduleId), volId,
839 const_cast<TGeoHMatrix&>(matrix),kTRUE);
842 //_____________________________________________________________________________
843 void AliMUONGeometryTransformer::AddMisAlignDetElement(Int_t detElemId,
844 const TGeoHMatrix& matrix)
846 /// Build AliAlignObjMatrix with detection element ID, its volumePath
847 /// and the given delta transformation matrix
849 if ( ! fMisAlignArray )
850 fMisAlignArray = new TClonesArray("AliAlignObjMatrix", 200);
852 const AliMUONGeometryDetElement* kDetElement
853 = GetDetElement(detElemId);
855 if ( ! kDetElement ) {
856 AliErrorStream() << "Det element " << detElemId << " not found." << endl;
860 // Get unique align object ID
861 Int_t volId = AliAlignObj::LayerToVolUID(AliAlignObj::kMUON, detElemId);
863 // Create mis align matrix
864 TClonesArray& refArray =*fMisAlignArray;
865 Int_t pos = fMisAlignArray->GetEntriesFast();
866 new(refArray[pos]) AliAlignObjMatrix(GetDESymName(detElemId), volId,
867 const_cast<TGeoHMatrix&>(matrix),kTRUE);
870 //_____________________________________________________________________________
871 void AliMUONGeometryTransformer::AddAlignableVolumes() const
873 /// Set symbolic names to alignable objects to TGeo
875 if ( ! gGeoManager ) {
876 AliWarning("TGeoManager not defined.");
881 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
882 AliMUONGeometryModuleTransformer* module
883 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
885 // Set module symbolic name
886 gGeoManager->SetAlignableEntry(GetModuleSymName(module->GetModuleId()),
887 module->GetVolumePath());
888 //cout << "Module sym name: " << GetModuleSymName(module->GetModuleId())
889 // << " volPath: " << module->GetVolumePath() << endl;
891 // Detection elements
892 AliMpExMap* detElements = module->GetDetElementStore();
894 for (Int_t j=0; j<detElements->GetSize(); j++) {
895 AliMUONGeometryDetElement* detElement
896 = (AliMUONGeometryDetElement*)detElements->GetObject(j);
898 // Set detection element symbolic name
899 gGeoManager->SetAlignableEntry(GetDESymName(detElement->GetId()),
900 detElement->GetVolumePath());
901 //cout << "DE name: " << GetDESymName(detElement->GetId())
902 // << " volPath: " << detElement->GetVolumePath() << endl;
907 //_____________________________________________________________________________
908 TClonesArray* AliMUONGeometryTransformer::CreateZeroAlignmentData() const
910 /// Create array with zero alignment data
912 // Create array for zero-alignment objects
913 TClonesArray* array = new TClonesArray("AliAlignObjMatrix", 200);
914 TClonesArray& refArray =*array;
915 array->SetOwner(true);
921 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
922 AliMUONGeometryModuleTransformer* module
923 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
925 Int_t moduleId = module->GetModuleId();
928 Int_t volId = AliAlignObj::LayerToVolUID(AliAlignObj::kMUON, moduleId);
930 // Create mis align matrix
931 Int_t pos = array->GetEntriesFast();
932 new (refArray[pos]) AliAlignObjMatrix(GetModuleSymName(moduleId), volId, matrix, kTRUE);
935 // Detection elements
936 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
937 AliMUONGeometryModuleTransformer* moduleTransformer
938 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
939 AliMpExMap* detElements = moduleTransformer->GetDetElementStore();
941 for (Int_t j=0; j<detElements->GetSize(); j++) {
942 AliMUONGeometryDetElement* detElement
943 = (AliMUONGeometryDetElement*)detElements->GetObject(j);
945 Int_t detElemId = detElement->GetId();
948 Int_t volId = AliAlignObj::LayerToVolUID(AliAlignObj::kMUON, detElemId);
950 // Create mis align matrix
951 Int_t pos = array->GetEntriesFast();
952 new (refArray[pos]) AliAlignObjMatrix(GetDESymName(detElemId), volId, matrix, kTRUE);
959 //_____________________________________________________________________________
960 void AliMUONGeometryTransformer::Global2Local(Int_t detElemId,
961 Float_t xg, Float_t yg, Float_t zg,
962 Float_t& xl, Float_t& yl, Float_t& zl) const
964 /// Transform point from the global reference frame (ALIC)
965 /// to the local reference frame of the detection element specified
968 const AliMUONGeometryModuleTransformer* kTransformer
969 = GetModuleTransformerByDEId(detElemId);
972 kTransformer->Global2Local(detElemId, xg, yg, zg, xl, yl, zl);
975 //_____________________________________________________________________________
976 void AliMUONGeometryTransformer::Global2Local(Int_t detElemId,
977 Double_t xg, Double_t yg, Double_t zg,
978 Double_t& xl, Double_t& yl, Double_t& zl) const
980 /// Transform point from the global reference frame (ALIC)
981 /// to the local reference frame of the detection element specified
984 const AliMUONGeometryModuleTransformer* kTransformer
985 = GetModuleTransformerByDEId(detElemId);
988 kTransformer->Global2Local(detElemId, xg, yg, zg, xl, yl, zl);
991 //_____________________________________________________________________________
992 void AliMUONGeometryTransformer::Local2Global(Int_t detElemId,
993 Float_t xl, Float_t yl, Float_t zl,
994 Float_t& xg, Float_t& yg, Float_t& zg) const
996 /// Transform point from the local reference frame of the detection element
997 /// specified by detElemId to the global reference frame (ALIC).
999 const AliMUONGeometryModuleTransformer* kTransformer
1000 = GetModuleTransformerByDEId(detElemId);
1003 kTransformer->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
1006 //_____________________________________________________________________________
1007 void AliMUONGeometryTransformer::Local2Global(Int_t detElemId,
1008 Double_t xl, Double_t yl, Double_t zl,
1009 Double_t& xg, Double_t& yg, Double_t& zg) const
1011 /// Transform point from the local reference frame of the detection element
1012 /// specified by detElemId to the global reference frame (ALIC).
1014 const AliMUONGeometryModuleTransformer* kTransformer
1015 = GetModuleTransformerByDEId(detElemId);
1018 kTransformer->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
1021 //_____________________________________________________________________________
1022 const AliMUONGeometryModuleTransformer*
1023 AliMUONGeometryTransformer::GetModuleTransformer(Int_t index, Bool_t warn) const
1025 /// Return the geometry module transformer specified by index
1027 return GetModuleTransformerNonConst(index, warn);
1030 //_____________________________________________________________________________
1031 const AliMUONGeometryModuleTransformer*
1032 AliMUONGeometryTransformer::GetModuleTransformerByDEId(Int_t detElemId,
1035 /// Return the geometry module transformer specified by detection element ID
1038 Int_t index = AliMpDEManager::GetGeomModuleId(detElemId);
1040 return GetModuleTransformer(index, warn);
1043 //_____________________________________________________________________________
1044 const AliMUONGeometryDetElement*
1045 AliMUONGeometryTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const
1047 /// Return detection element with given detElemId
1049 const AliMUONGeometryModuleTransformer* kTransformer
1050 = GetModuleTransformerByDEId(detElemId, warn);
1052 if (!kTransformer) return 0;
1054 return kTransformer->GetDetElement(detElemId, warn);
1057 //_____________________________________________________________________________
1058 Bool_t AliMUONGeometryTransformer::HasDE(Int_t detElemId) const
1060 /// Return true if detection element with given detElemId is defined
1062 const AliMUONGeometryModuleTransformer* kTransformer
1063 = GetModuleTransformerByDEId(detElemId, false);
1065 if (!kTransformer) return false;
1067 return ( kTransformer->GetDetElement(detElemId, false) != 0 );