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 "AliMUONGeometryStore.h"
28 #include "AliMUONGeometryBuilder.h"
31 #include "AliAlignObjMatrix.h"
32 #include "AliAlignObj.h"
34 #include <Riostream.h>
36 #include <TClonesArray.h>
37 #include <TGeoManager.h>
38 #include <TGeoPhysicalNode.h>
44 ClassImp(AliMUONGeometryTransformer)
47 //______________________________________________________________________________
48 AliMUONGeometryTransformer::AliMUONGeometryTransformer(Bool_t isOwner,
49 const TString& detectorName)
52 fDetectorName(detectorName),
53 fModuleTransformers(0),
56 /// Standard constructor
58 // Create array for geometry modules
59 fModuleTransformers = new TObjArray();
60 fModuleTransformers->SetOwner(isOwner);
63 //______________________________________________________________________________
64 AliMUONGeometryTransformer::AliMUONGeometryTransformer()
67 fModuleTransformers(0),
70 /// Default constructor
73 //______________________________________________________________________________
74 AliMUONGeometryTransformer::~AliMUONGeometryTransformer()
78 delete fModuleTransformers;
79 delete fMisAlignArray;
86 //_____________________________________________________________________________
87 AliMUONGeometryModuleTransformer*
88 AliMUONGeometryTransformer::GetModuleTransformerNonConst(
89 Int_t index, Bool_t warn) const
91 /// Return the geometry module specified by index
93 if (index < 0 || index >= fModuleTransformers->GetEntriesFast()) {
96 << "Index: " << index << " outside limits" << std::endl;
101 return (AliMUONGeometryModuleTransformer*) fModuleTransformers->At(index);
104 //______________________________________________________________________________
105 TGeoHMatrix AliMUONGeometryTransformer::GetTransform(
106 Double_t x, Double_t y, Double_t z,
107 Double_t a1, Double_t a2, Double_t a3,
108 Double_t a4, Double_t a5, Double_t a6) const
110 /// Build the transformation from the given parameters
113 return TGeoCombiTrans(TGeoTranslation(x, y, z),
114 TGeoRotation("rot", a1, a2, a3, a4, a5, a6));
118 //______________________________________________________________________________
119 void AliMUONGeometryTransformer::FillModuleVolPath(Int_t moduleId,
120 const TString& volPath)
122 /// Create module with the given moduleId and volPath
124 // Get/Create geometry module transformer
125 AliMUONGeometryModuleTransformer* moduleTransformer
126 = GetModuleTransformerNonConst(moduleId, false);
128 if ( !moduleTransformer ) {
129 moduleTransformer = new AliMUONGeometryModuleTransformer(moduleId);
130 AddModuleTransformer(moduleTransformer);
132 moduleTransformer->SetVolumePath(volPath);
135 //______________________________________________________________________________
136 void AliMUONGeometryTransformer::FillDetElemVolPath(Int_t detElemId,
137 const TString& volPath)
139 /// Create detection element with the given detElemId and volPath
142 Int_t moduleId = AliMUONGeometryStore::GetModuleId(detElemId);
144 // Get detection element store
145 AliMUONGeometryStore* detElements =
146 GetModuleTransformer(moduleId)->GetDetElementStore();
148 // Add detection element
149 AliMUONGeometryDetElement* detElement
150 = new AliMUONGeometryDetElement(detElemId, volPath);
151 detElements->Add(detElemId, detElement);
155 //______________________________________________________________________________
156 void AliMUONGeometryTransformer::FillModuleTransform(Int_t moduleId,
157 Double_t x, Double_t y, Double_t z,
158 Double_t a1, Double_t a2, Double_t a3,
159 Double_t a4, Double_t a5, Double_t a6)
161 /// Fill the transformation of the module.
163 // Get/Create geometry module transformer
165 // Modules numbers in the file are starting from 1
167 AliMUONGeometryModuleTransformer* moduleTransformer
168 = GetModuleTransformerNonConst(moduleId, false);
170 if ( !moduleTransformer) {
172 << "Module " << moduleId << " has not volume path defined." << endl;
175 // Build the transformation from the parameters
176 TGeoHMatrix transform
177 = GetTransform(x, y, z, a1, a2, a3, a4, a5, a6);
179 moduleTransformer->SetTransformation(transform);
182 //______________________________________________________________________________
183 void AliMUONGeometryTransformer::FillDetElemTransform(
185 Double_t x, Double_t y, Double_t z,
186 Double_t a1, Double_t a2, Double_t a3,
187 Double_t a4, Double_t a5, Double_t a6)
189 /// Fill the transformation of the detection element.
192 Int_t moduleId = AliMUONGeometryStore::GetModuleId(detElemId);
194 // Get module transformer
195 const AliMUONGeometryModuleTransformer* kModuleTransformer
196 = GetModuleTransformer(moduleId);
198 if ( ! kModuleTransformer ) {
199 AliFatal(Form("Module transformer not defined, detElemId: %d", detElemId));
203 // Get detection element
204 AliMUONGeometryDetElement* detElement
205 = kModuleTransformer->GetDetElement(detElemId);
207 if ( ! detElement ) {
208 AliFatal(Form("Det element %d has not volume path defined", detElemId));
212 // Build the transformation from the parameters
213 TGeoHMatrix localTransform
214 = GetTransform(x, y, z, a1, a2, a3, a4, a5, a6);
215 detElement->SetLocalTransformation(localTransform);
217 // Compute global transformation
218 TGeoHMatrix globalTransform
219 = AliMUONGeometryBuilder::Multiply(
220 *kModuleTransformer->GetTransformation(),
222 detElement->SetGlobalTransformation(globalTransform);
225 //______________________________________________________________________________
227 AliMUONGeometryTransformer::ReadVolPaths(ifstream& in)
229 /// Read modules and detection element volume paths from stream
232 TString key, volumePath;
235 while ( !in.eof() ) {
237 in >> id >> volumePath;
239 // cout << "id=" << id << " "
240 // << "volPath= " << volumePath
243 if ( key == TString("CH") )
244 FillModuleVolPath(id, volumePath);
246 else if ( key == TString("DE") )
247 FillDetElemVolPath(id, volumePath);
250 AliFatal(Form("%s key not recognized", key.Data()));
259 //______________________________________________________________________________
260 TString AliMUONGeometryTransformer::ReadModuleTransforms(ifstream& in)
262 /// Read and fill modules transformations from the stream.
263 /// Return true, if reading finished correctly.
266 while ( key == TString("CH") ) {
269 Double_t a1, a2, a3, a4, a5, a6;
285 //cout << "moduleId=" << id << " "
286 // << "position= " << x << ", " << y << ", " << z << " "
287 // << "rotation= " << a1 << ", " << a2 << ", " << a3 << ", "
288 // << a4 << ", " << a5 << ", " << a6
292 FillModuleTransform(id, x, y, z, a1, a2, a3, a4, a5, a6);
301 //______________________________________________________________________________
302 TString AliMUONGeometryTransformer::ReadDetElemTransforms(ifstream& in)
304 /// Read detection elements transformations from the stream.
305 /// Return true, if reading finished correctly.
308 while ( key == TString("DE") ) {
313 Double_t a1, a2, a3, a4, a5, a6;
329 //cout << "detElemId=" << detElemId << " "
330 // << "position= " << x << ", " << y << ", " << z << " "
331 // << "rotation= " << a1 << ", " << a2 << ", " << a3 << ", "
332 // << a4 << ", " << a5 << ", " << a6
336 FillDetElemTransform(detElemId, x, y, z, a1, a2, a3, a4, a5, a6);
345 //______________________________________________________________________________
347 AliMUONGeometryTransformer::LoadTransforms(TGeoManager* tgeoManager)
349 /// Load transformations for defined modules and detection elements
350 /// from the root file
353 AliFatal("No TGeoManager defined.");
357 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
358 AliMUONGeometryModuleTransformer* moduleTransformer
359 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
362 TString path = moduleTransformer->GetVolumePath();
364 // Make physical node
365 TGeoPhysicalNode* moduleNode = tgeoManager->MakePhysicalNode(path);
366 if ( ! moduleNode ) {
368 << "Module id: " << moduleTransformer->GetModuleId()
369 << " volume path: " << path << " not found in geometry." << endl;
373 // Set matrix from physical node
374 TGeoHMatrix matrix = *moduleNode->GetMatrix();
375 moduleTransformer->SetTransformation(matrix);
377 // Loop over detection elements
378 AliMUONGeometryStore* detElements
379 = moduleTransformer->GetDetElementStore();
381 for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
382 AliMUONGeometryDetElement* detElement
383 = (AliMUONGeometryDetElement*)detElements->GetEntry(j);
386 TString dePath = detElement->GetVolumePath();
388 // Make physical node
389 TGeoPhysicalNode* deNode = tgeoManager->MakePhysicalNode(dePath);
392 << "Det element id: " << detElement->GetId()
393 << " volume path: " << path << " not found in geometry." << endl;
397 // Set global matrix from physical node
398 TGeoHMatrix globalMatrix = *deNode->GetMatrix();
399 detElement->SetGlobalTransformation(globalMatrix);
402 TGeoHMatrix localMatrix =
403 AliMUONGeometryBuilder::Multiply(
404 matrix.Inverse(), globalMatrix );
405 detElement->SetLocalTransformation(localMatrix);
411 //______________________________________________________________________________
413 AliMUONGeometryTransformer::ReadVolPaths(const TString& fileName)
415 /// Read detection element volume paths from a file.
416 /// Return true, if reading finished correctly.
419 TString filePath = gSystem->Getenv("ALICE_ROOT");
420 filePath += "/MUON/data/";
421 filePath += fileName;
424 ifstream in(filePath, ios::in);
426 cerr << filePath << endl;
427 AliFatal("File not found.");
435 //______________________________________________________________________________
437 AliMUONGeometryTransformer::ReadTransformations(const TString& fileName)
439 /// Read transformations from a file.
440 /// Return true, if reading finished correctly.
443 TString filePath = gSystem->Getenv("ALICE_ROOT");
444 filePath += "/MUON/data/";
445 filePath += fileName;
448 ifstream in(filePath, ios::in);
450 cerr << filePath << endl;
451 AliFatal("File not found.");
457 while ( !in.eof() ) {
458 if (key == TString("CH"))
459 key = ReadModuleTransforms(in);
460 else if (key == TString("DE"))
461 key = ReadDetElemTransforms(in);
463 AliFatal(Form("%s key not recognized", key.Data()));
471 //______________________________________________________________________________
473 AliMUONGeometryTransformer::ReadTransformations2(const TString& fileName)
475 /// Read transformations from root geometry file.
476 /// Return true, if reading finished correctly.
479 TString filePath = gSystem->Getenv("ALICE_ROOT");
480 filePath += "/MUON/data/";
481 filePath += fileName;
483 // Load root geometry
484 TGeoManager* tgeoManager = TGeoManager::Import(fileName);
487 LoadTransforms(tgeoManager);
492 //______________________________________________________________________________
493 void AliMUONGeometryTransformer::WriteTransform(ofstream& out,
494 const TGeoMatrix* transform) const
496 /// Write given transformation
499 const Double_t* xyz = transform->GetTranslation();
500 out << setw(10) << setprecision(4) << xyz[0] << " "
501 << setw(10) << setprecision(4) << xyz[1] << " "
502 << setw(10) << setprecision(4) << xyz[2];
505 const Double_t* rm = transform->GetRotationMatrix();
506 TGeoRotation rotation;
507 rotation.SetMatrix(const_cast<Double_t*>(rm));
508 Double_t a1, a2, a3, a4, a5, a6;
509 rotation.GetAngles(a1, a2, a3, a4, a5, a6);
511 out << setw(8) << setprecision(4) << a1 << " "
512 << setw(8) << setprecision(4) << a2 << " "
513 << setw(8) << setprecision(4) << a3 << " "
514 << setw(8) << setprecision(4) << a4 << " "
515 << setw(8) << setprecision(4) << a5 << " "
516 << setw(8) << setprecision(4) << a6 << " " << endl;
519 //______________________________________________________________________________
520 void AliMUONGeometryTransformer::WriteModuleVolPaths(ofstream& out) const
522 /// Write module volume paths for all module transformers
524 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
525 AliMUONGeometryModuleTransformer* moduleTransformer
526 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
530 << setw(4) << moduleTransformer->GetModuleId() << " "
531 << moduleTransformer->GetVolumePath() << endl;
536 //______________________________________________________________________________
537 void AliMUONGeometryTransformer::WriteDetElemVolPaths(ofstream& out) const
539 /// Write detection element volume paths for all detection elements in all
540 /// module transformers
542 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
543 AliMUONGeometryModuleTransformer* moduleTransformer
544 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
545 AliMUONGeometryStore* detElements
546 = moduleTransformer->GetDetElementStore();
548 for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
549 AliMUONGeometryDetElement* detElement
550 = (AliMUONGeometryDetElement*)detElements->GetEntry(j);
554 << setw(4) << detElement->GetId() << " "
555 << detElement->GetVolumePath() << endl;
561 //______________________________________________________________________________
562 void AliMUONGeometryTransformer::WriteModuleTransforms(ofstream& out) const
564 /// Write module transformations for all module transformers
566 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
567 AliMUONGeometryModuleTransformer* moduleTransformer
568 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
569 const TGeoMatrix* transform
570 = moduleTransformer->GetTransformation();
574 << setw(4) << moduleTransformer->GetModuleId() + 1;
576 WriteTransform(out, transform);
581 //______________________________________________________________________________
582 void AliMUONGeometryTransformer::WriteDetElemTransforms(ofstream& out) const
584 /// Write detection element transformations for all detection elements in all
585 /// module transformers
587 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
588 AliMUONGeometryModuleTransformer* moduleTransformer
589 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
590 AliMUONGeometryStore* detElements
591 = moduleTransformer->GetDetElementStore();
593 for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
594 AliMUONGeometryDetElement* detElement
595 = (AliMUONGeometryDetElement*)detElements->GetEntry(j);
596 const TGeoMatrix* transform
597 = detElement->GetLocalTransformation();
600 out << "DE " << setw(4) << detElement->GetId();
602 WriteTransform(out, transform);
608 //______________________________________________________________________________
609 TString AliMUONGeometryTransformer::GetModuleSymName(Int_t moduleId) const
611 /// Return the module symbolic name (use for alignment)
613 const AliMUONGeometryModuleTransformer* kTransformer
614 = GetModuleTransformer(moduleId);
615 if ( ! kTransformer ) {
616 AliErrorStream() << "Module " << moduleId << " not found." << endl;
620 return "/" + fDetectorName + "/" + kTransformer->GetModuleName();
623 //______________________________________________________________________________
624 TString AliMUONGeometryTransformer::GetDESymName(Int_t detElemId) const
627 const AliMUONGeometryDetElement* kDetElement
628 = GetDetElement(detElemId);
629 if ( ! kDetElement ) {
630 AliErrorStream() << "Det element " << detElemId << " not found." << endl;
635 Int_t moduleId = AliMUONGeometryStore::GetModuleId(detElemId);
637 return GetModuleSymName(moduleId) + "/" + kDetElement->GetDEName();
644 //______________________________________________________________________________
646 AliMUONGeometryTransformer::ReadGeometryData(
647 const TString& volPathFileName,
648 const TString& transformFileName)
650 /// Read geometry data from given files;
651 /// if transformFileName has ".root" extension, the transformations
652 /// are loaded from root geometry file, otherwise ASCII file
653 /// format is supposed
655 Bool_t result1 = ReadVolPaths(volPathFileName);
657 // Get file extension
658 std::string fileName = transformFileName.Data();
659 std::string rootExt = fileName.substr(fileName.size()-5, fileName.size());
661 if ( rootExt != ".root" )
662 result2 = ReadTransformations(transformFileName);
664 result2 = ReadTransformations2(transformFileName);
666 return result1 && result2;
669 //______________________________________________________________________________
671 AliMUONGeometryTransformer::ReadGeometryData(
672 const TString& volPathFileName,
673 TGeoManager* tgeoManager)
675 /// Load geometry data from root geometry using defined
676 /// volume paths from file
678 Bool_t result1 = ReadVolPaths(volPathFileName);
680 Bool_t result2 = LoadTransforms(tgeoManager);
682 return result1 && result2;
685 //______________________________________________________________________________
687 AliMUONGeometryTransformer::WriteGeometryData(
688 const TString& volPathFileName,
689 const TString& transformFileName,
690 const TString& misalignFileName) const
692 /// Write geometry data into given files
694 Bool_t result1 = WriteVolumePaths(volPathFileName);
695 Bool_t result2 = WriteTransformations(transformFileName);
697 Bool_t result3 = true;
698 if ( misalignFileName != "" )
699 result3 = WriteMisAlignmentData(misalignFileName);
701 return result1 && result2 && result3;
704 //______________________________________________________________________________
706 AliMUONGeometryTransformer::WriteVolumePaths(const TString& fileName) const
708 /// Write volume paths for modules and detection element volumes into a file.
709 /// Return true, if writing finished correctly.
712 // if builder is not associated with any geometry module
713 if (fModuleTransformers->GetEntriesFast() == 0) return false;
716 TString filePath = gSystem->Getenv("ALICE_ROOT");
717 filePath += "/MUON/data/";
718 filePath += fileName;
721 ofstream out(filePath, ios::out);
723 cerr << filePath << endl;
724 AliError("File not found.");
727 #if !defined (__DECCXX)
728 out.setf(std::ios::fixed);
730 WriteModuleVolPaths(out);
731 WriteDetElemVolPaths(out);
736 //______________________________________________________________________________
738 AliMUONGeometryTransformer::WriteTransformations(const TString& fileName) const
740 /// Write transformations into a file.
741 /// Return true, if writing finished correctly.
744 // if builder is not associated with any geometry module
745 if (fModuleTransformers->GetEntriesFast() == 0) return false;
748 TString filePath = gSystem->Getenv("ALICE_ROOT");
749 filePath += "/MUON/data/";
750 filePath += fileName;
753 ofstream out(filePath, ios::out);
755 cerr << filePath << endl;
756 AliError("File not found.");
759 #if !defined (__DECCXX)
760 out.setf(std::ios::fixed);
762 WriteModuleTransforms(out);
763 WriteDetElemTransforms(out);
768 //______________________________________________________________________________
770 AliMUONGeometryTransformer::WriteMisAlignmentData(const TString& fileName) const
772 /// Write misalignment data into a file
773 /// Return true, if writing finished correctly.
776 // if builder is not associated with any geometry module
777 if ( fModuleTransformers->GetEntriesFast() == 0 ) {
778 AliWarningStream() << "No geometry modules defined." << endl;
783 // if builder has no mis-alignment data
784 if ( ! fMisAlignArray ) {
785 AliWarningStream() << "No mis-alignment data defined." << endl;
790 TString filePath = gSystem->Getenv("ALICE_ROOT");
791 filePath += "/MUON/data/";
792 filePath += fileName;
794 // Write mis-alignment data in the root file
795 TFile file(fileName.Data(), "RECREATE");
796 fMisAlignArray->Write();
802 //_____________________________________________________________________________
803 void AliMUONGeometryTransformer::AddModuleTransformer(
804 AliMUONGeometryModuleTransformer* moduleTransformer)
806 /// Add the module transformer to the array
808 fModuleTransformers->AddAt(moduleTransformer,
809 moduleTransformer->GetModuleId());
812 //_____________________________________________________________________________
813 void AliMUONGeometryTransformer::AddMisAlignModule(Int_t moduleId,
814 const TGeoHMatrix& matrix)
816 /// Build AliAlignObjMatrix with module ID, its volumePath
817 /// and the given delta transformation matrix
819 if ( ! fMisAlignArray )
820 fMisAlignArray = new TClonesArray("AliAlignObjMatrix", 200);
822 const AliMUONGeometryModuleTransformer* kTransformer
823 = GetModuleTransformer(moduleId);
824 if ( ! kTransformer ) {
825 AliErrorStream() << "Module " << moduleId << " not found." << endl;
829 // Get unique align object ID
830 Int_t volId = AliAlignObj::LayerToVolUID(AliAlignObj::kMUON, moduleId);
832 // Create mis align matrix
833 TClonesArray& refArray =*fMisAlignArray;
834 Int_t pos = fMisAlignArray->GetEntriesFast();
835 new (refArray[pos]) AliAlignObjMatrix(GetModuleSymName(moduleId), volId,
836 const_cast<TGeoHMatrix&>(matrix),kTRUE);
839 //_____________________________________________________________________________
840 void AliMUONGeometryTransformer::AddMisAlignDetElement(Int_t detElemId,
841 const TGeoHMatrix& matrix)
843 /// Build AliAlignObjMatrix with detection element ID, its volumePath
844 /// and the given delta transformation matrix
846 if ( ! fMisAlignArray )
847 fMisAlignArray = new TClonesArray("AliAlignObjMatrix", 200);
849 const AliMUONGeometryDetElement* kDetElement
850 = GetDetElement(detElemId);
852 if ( ! kDetElement ) {
853 AliErrorStream() << "Det element " << detElemId << " not found." << endl;
857 // Get unique align object ID
858 Int_t volId = AliAlignObj::LayerToVolUID(AliAlignObj::kMUON, detElemId);
860 // Create mis align matrix
861 TClonesArray& refArray =*fMisAlignArray;
862 Int_t pos = fMisAlignArray->GetEntriesFast();
863 new(refArray[pos]) AliAlignObjMatrix(GetDESymName(detElemId), volId,
864 const_cast<TGeoHMatrix&>(matrix),kTRUE);
867 //_____________________________________________________________________________
868 void AliMUONGeometryTransformer::AddAlignableVolumes() const
870 /// Set symbolic names to alignable objects to TGeo
872 if ( ! gGeoManager ) {
873 AliWarning("TGeoManager not defined.");
878 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
879 AliMUONGeometryModuleTransformer* module
880 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
882 // Set module symbolic name
883 gGeoManager->SetAlignableEntry(GetModuleSymName(module->GetModuleId()),
884 module->GetVolumePath());
885 //cout << "Module sym name: " << GetModuleSymName(module->GetModuleId())
886 // << " volPath: " << module->GetVolumePath() << endl;
888 // Detection elements
889 AliMUONGeometryStore* detElements
890 = module->GetDetElementStore();
892 for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
893 AliMUONGeometryDetElement* detElement
894 = (AliMUONGeometryDetElement*)detElements->GetEntry(j);
896 // Set detection element symbolic name
897 gGeoManager->SetAlignableEntry(GetDESymName(detElement->GetId()),
898 detElement->GetVolumePath());
899 //cout << "DE name: " << GetDESymName(detElement->GetId())
900 // << " volPath: " << detElement->GetVolumePath() << endl;
905 //_____________________________________________________________________________
906 TClonesArray* AliMUONGeometryTransformer::CreateZeroAlignmentData() const
908 /// Create array with zero alignment data
910 // Create array for zero-alignment objects
911 TClonesArray* array = new TClonesArray("AliAlignObjMatrix", 200);
912 TClonesArray& refArray =*array;
913 array->SetOwner(true);
919 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
920 AliMUONGeometryModuleTransformer* module
921 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
923 Int_t moduleId = module->GetModuleId();
926 Int_t volId = AliAlignObj::LayerToVolUID(AliAlignObj::kMUON, moduleId);
928 // Create mis align matrix
929 Int_t pos = array->GetEntriesFast();
930 new (refArray[pos]) AliAlignObjMatrix(GetModuleSymName(moduleId), volId, matrix, kTRUE);
933 // Detection elements
934 for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
935 AliMUONGeometryModuleTransformer* moduleTransformer
936 = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
937 AliMUONGeometryStore* detElements
938 = moduleTransformer->GetDetElementStore();
940 for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
941 AliMUONGeometryDetElement* detElement
942 = (AliMUONGeometryDetElement*)detElements->GetEntry(j);
944 Int_t detElemId = detElement->GetId();
947 Int_t volId = AliAlignObj::LayerToVolUID(AliAlignObj::kMUON, detElemId);
949 // Create mis align matrix
950 Int_t pos = array->GetEntriesFast();
951 new (refArray[pos]) AliAlignObjMatrix(GetDESymName(detElemId), volId, matrix, kTRUE);
958 //_____________________________________________________________________________
959 void AliMUONGeometryTransformer::Global2Local(Int_t detElemId,
960 Float_t xg, Float_t yg, Float_t zg,
961 Float_t& xl, Float_t& yl, Float_t& zl) const
963 /// Transform point from the global reference frame (ALIC)
964 /// to the local reference frame of the detection element specified
967 const AliMUONGeometryModuleTransformer* kTransformer
968 = GetModuleTransformerByDEId(detElemId);
971 kTransformer->Global2Local(detElemId, xg, yg, zg, xl, yl, zl);
974 //_____________________________________________________________________________
975 void AliMUONGeometryTransformer::Global2Local(Int_t detElemId,
976 Double_t xg, Double_t yg, Double_t zg,
977 Double_t& xl, Double_t& yl, Double_t& zl) const
979 /// Transform point from the global reference frame (ALIC)
980 /// to the local reference frame of the detection element specified
983 const AliMUONGeometryModuleTransformer* kTransformer
984 = GetModuleTransformerByDEId(detElemId);
987 kTransformer->Global2Local(detElemId, xg, yg, zg, xl, yl, zl);
990 //_____________________________________________________________________________
991 void AliMUONGeometryTransformer::Local2Global(Int_t detElemId,
992 Float_t xl, Float_t yl, Float_t zl,
993 Float_t& xg, Float_t& yg, Float_t& zg) const
995 /// Transform point from the local reference frame of the detection element
996 /// specified by detElemId to the global reference frame (ALIC).
998 const AliMUONGeometryModuleTransformer* kTransformer
999 = GetModuleTransformerByDEId(detElemId);
1002 kTransformer->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
1005 //_____________________________________________________________________________
1006 void AliMUONGeometryTransformer::Local2Global(Int_t detElemId,
1007 Double_t xl, Double_t yl, Double_t zl,
1008 Double_t& xg, Double_t& yg, Double_t& zg) const
1010 /// Transform point from the local reference frame of the detection element
1011 /// specified by detElemId to the global reference frame (ALIC).
1013 const AliMUONGeometryModuleTransformer* kTransformer
1014 = GetModuleTransformerByDEId(detElemId);
1017 kTransformer->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
1020 //_____________________________________________________________________________
1021 const AliMUONGeometryModuleTransformer*
1022 AliMUONGeometryTransformer::GetModuleTransformer(Int_t index, Bool_t warn) const
1024 /// Return the geometry module transformer specified by index
1026 return GetModuleTransformerNonConst(index, warn);
1029 //_____________________________________________________________________________
1030 const AliMUONGeometryModuleTransformer*
1031 AliMUONGeometryTransformer::GetModuleTransformerByDEId(Int_t detElemId,
1034 /// Return the geometry module transformer specified by detection element ID
1037 Int_t index = AliMUONGeometryStore::GetModuleId(detElemId);
1039 return GetModuleTransformer(index, warn);
1042 //_____________________________________________________________________________
1043 const AliMUONGeometryDetElement*
1044 AliMUONGeometryTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const
1046 /// Return detection element with given detElemId
1048 const AliMUONGeometryModuleTransformer* kTransformer
1049 = GetModuleTransformerByDEId(detElemId, warn);
1051 if (!kTransformer) return 0;
1053 return kTransformer->GetDetElement(detElemId, warn);
1056 //_____________________________________________________________________________
1057 Bool_t AliMUONGeometryTransformer::HasDE(Int_t detElemId) const
1059 /// Return true if detection element with given detElemId is defined
1061 const AliMUONGeometryModuleTransformer* kTransformer
1062 = GetModuleTransformerByDEId(detElemId, false);
1064 if (!kTransformer) return false;
1066 return ( kTransformer->GetDetElement(detElemId, false) != 0 );