1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
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 purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 // Class AliMUONGeometrySVMap
19 // ------------------------------------
20 // As the detection element frame is different from the
21 // frame of the sensitive volume(s) defined in Geant,
22 // the sensitive volumes have to be mapped to the detection
23 // elements. In the map, fSVMap, the sensitive voolumes are specified
24 // by the full path in the volume hierarchy, defined as:
25 // /volname.copyNo/volName.copyNo1/...
27 // The array of global positions of sensitive volumes fSVPositions
28 // is included to make easier the verification of the assignements
31 // Author: Ivana Hrivnacova, IPN Orsay
33 #include <Riostream.h>
34 #include <TGeoMatrix.h>
35 #include <TObjString.h>
37 #include "AliMUONGeometrySVMap.h"
40 ClassImp(AliMUONGeometrySVMap)
42 //______________________________________________________________________________
43 AliMUONGeometrySVMap::AliMUONGeometrySVMap(Int_t initSize)
46 fSVPositions(initSize)
48 /// Standard constructor
50 fSVPositions.SetOwner(true);
53 //______________________________________________________________________________
54 AliMUONGeometrySVMap::AliMUONGeometrySVMap()
59 /// Default constructor
62 //______________________________________________________________________________
63 AliMUONGeometrySVMap::AliMUONGeometrySVMap(const AliMUONGeometrySVMap& rhs)
66 /// Protected copy constructor
68 AliFatal("Copy constructor is not implemented.");
71 //______________________________________________________________________________
72 AliMUONGeometrySVMap::~AliMUONGeometrySVMap()
76 fSVPositions.Delete();
79 //______________________________________________________________________________
81 AliMUONGeometrySVMap::operator = (const AliMUONGeometrySVMap& rhs)
83 /// Protected assignement operator
85 // check assignement to self
86 if (this == &rhs) return *this;
88 AliFatal("Assignment operator is not implemented.");
97 //______________________________________________________________________________
99 AliMUONGeometrySVMap::FindByName(const TString& name) const
101 /// Find TGeoCombiTrans in the array of positions by name
103 for (Int_t i=0; i<fSVPositions.GetEntriesFast(); i++) {
104 TGeoCombiTrans* transform = (TGeoCombiTrans*) fSVPositions.At(i);
105 if ( transform && TString(transform->GetTitle()) == name )
117 //______________________________________________________________________________
118 void AliMUONGeometrySVMap::Add(const TString& volumePath,
121 /// Add the specified sensitive volume path and the detElemId
124 fSVMap.Add(volumePath, detElemId);
127 //______________________________________________________________________________
128 void AliMUONGeometrySVMap::AddPosition(const TString& volumePath,
129 const TGeoTranslation& globalPosition)
131 /// Add global position for the sensitive volume specified by volumePath
132 /// in the array of transformations if this volumePath is not yet present.
134 TGeoTranslation* newTransform = new TGeoTranslation(globalPosition);
135 Int_t detElemId = fSVMap.Get(volumePath);
137 TString detElemIdString("");
138 detElemIdString += detElemId;
140 newTransform->SetName(detElemIdString);
141 newTransform->SetTitle(volumePath);
143 // cout << ".. adding " << volumePath << " " << detElemId << endl;
146 if ( !FindByName(volumePath )) {
148 newTransform->SetUniqueID(detElemId);
149 // Set detector element id as unique id
151 fSVPositions.Add(newTransform);
155 //______________________________________________________________________________
156 void AliMUONGeometrySVMap::Clear(Option_t* /*option*/)
158 // Clears the sensitive volumes map
163 //______________________________________________________________________________
164 void AliMUONGeometrySVMap::ClearPositions()
166 /// Clear the array of transformations
168 fSVPositions.Delete();
171 //______________________________________________________________________________
172 void AliMUONGeometrySVMap::SortPositions()
174 /// Sort the array of positions by names.
176 fSVPositions.Sort(fSVPositions.GetEntriesFast());
179 //______________________________________________________________________________
180 void AliMUONGeometrySVMap::Print(const char* option) const
182 /// Print the map of sensitive volumes and detector elements
184 fSVMap.Print(option);
187 //______________________________________________________________________________
188 void AliMUONGeometrySVMap::PrintPositions() const
190 /// Print the sensitive volumes global positions
192 for (Int_t i=0; i<fSVPositions.GetEntriesFast(); i++) {
194 TGeoTranslation* matrix = (TGeoTranslation*)fSVPositions.At(i);
196 cout << "DetElemId: " << matrix->GetUniqueID();
197 cout << " name: " << matrix->GetTitle() << endl;
199 const double* translation = matrix->GetTranslation();
200 cout << " translation: "
201 #if defined (__DECCXX)
202 << translation[0] << ", "
203 << translation[1] << ", "
204 << translation[2] << endl;
207 << std::setw(7) << std::setprecision(4) << translation[0] << ", "
208 << std::setw(7) << std::setprecision(4) << translation[1] << ", "
209 << std::setw(7) << std::setprecision(4) << translation[2] << endl;
214 //______________________________________________________________________________
215 void AliMUONGeometrySVMap::WriteMap(ofstream& out) const
217 /// Print the map of sensitive volumes and detector elements
218 /// into specified stream
220 fSVMap.Print("SV", out);
223 //______________________________________________________________________________
224 Int_t AliMUONGeometrySVMap::GetDetElemId(const TString& volumePath) const
226 /// Return detection element Id for the sensitive volume specified by path
228 return fSVMap.Get(volumePath);