]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONGeometrySVMap.cxx
New class of global trigger boards
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometrySVMap.cxx
CommitLineData
e118b27e 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
89cc3034 16// $Id$
17//
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/...
26//
27// The array of global positions of sensitive volumes fSVPositions
28// is included to make easier the verification of the assignements
29// in the fSVMap.
30//
31// Author: Ivana Hrivnacova, IPN Orsay
32
33#include <Riostream.h>
34#include <TGeoMatrix.h>
35#include <TObjString.h>
36
37#include "AliMUONGeometrySVMap.h"
8c343c7c 38#include "AliLog.h"
89cc3034 39
40ClassImp(AliMUONGeometrySVMap)
41
89cc3034 42//______________________________________________________________________________
43AliMUONGeometrySVMap::AliMUONGeometrySVMap(Int_t initSize)
44 : TObject(),
45 fSVMap(),
46 fSVPositions(initSize)
47{
692de412 48/// Standard constructor
89cc3034 49
50 fSVPositions.SetOwner(true);
51}
52
53//______________________________________________________________________________
54AliMUONGeometrySVMap::AliMUONGeometrySVMap()
55 : TObject(),
56 fSVMap(),
57 fSVPositions()
58{
692de412 59/// Default constructor
89cc3034 60}
61
62//______________________________________________________________________________
63AliMUONGeometrySVMap::AliMUONGeometrySVMap(const AliMUONGeometrySVMap& rhs)
64 : TObject(rhs)
65{
692de412 66/// Protected copy constructor
67
8c343c7c 68 AliFatal("Copy constructor is not implemented.");
89cc3034 69}
70
71//______________________________________________________________________________
692de412 72AliMUONGeometrySVMap::~AliMUONGeometrySVMap()
73{
74/// Destructor
75
89cc3034 76 fSVPositions.Delete();
77}
78
79//______________________________________________________________________________
80AliMUONGeometrySVMap&
81AliMUONGeometrySVMap::operator = (const AliMUONGeometrySVMap& rhs)
82{
692de412 83/// Protected assignement operator
84
89cc3034 85 // check assignement to self
86 if (this == &rhs) return *this;
87
8c343c7c 88 AliFatal("Assignment operator is not implemented.");
89cc3034 89
90 return *this;
91}
92
93//
94// private methods
95//
96
97//______________________________________________________________________________
98const TGeoCombiTrans*
99AliMUONGeometrySVMap::FindByName(const TString& name) const
100{
692de412 101/// Find TGeoCombiTrans in the array of positions by name
89cc3034 102
103 for (Int_t i=0; i<fSVPositions.GetEntriesFast(); i++) {
104 TGeoCombiTrans* transform = (TGeoCombiTrans*) fSVPositions.At(i);
105 if ( transform && TString(transform->GetTitle()) == name )
106 return transform;
107 }
108
109 return 0;
110}
111
112
113//
114// public methods
115//
116
117//______________________________________________________________________________
118void AliMUONGeometrySVMap::Add(const TString& volumePath,
119 Int_t detElemId)
120{
692de412 121/// Add the specified sensitive volume path and the detElemId
122/// to the map
89cc3034 123
124 fSVMap.Add(volumePath, detElemId);
125}
126
127//______________________________________________________________________________
128void AliMUONGeometrySVMap::AddPosition(const TString& volumePath,
129 const TGeoTranslation& globalPosition)
130{
692de412 131/// Add global position for the sensitive volume specified by volumePath
132/// in the array of transformations if this volumePath is not yet present.
89cc3034 133
134 TGeoTranslation* newTransform = new TGeoTranslation(globalPosition);
135 Int_t detElemId = fSVMap.Get(volumePath);
136
137 TString detElemIdString("");
138 detElemIdString += detElemId;
139
140 newTransform->SetName(detElemIdString);
141 newTransform->SetTitle(volumePath);
142
143 // cout << ".. adding " << volumePath << " " << detElemId << endl;
144
145 // Add to the map
146 if ( !FindByName(volumePath )) {
147
148 newTransform->SetUniqueID(detElemId);
149 // Set detector element id as unique id
150
151 fSVPositions.Add(newTransform);
152 }
153}
154
155//______________________________________________________________________________
4ebc2323 156void AliMUONGeometrySVMap::Clear(Option_t* /*option*/)
89cc3034 157{
158// Clears the sensitive volumes map
159
160 fSVMap.Clear();
161}
162
163//______________________________________________________________________________
164void AliMUONGeometrySVMap::ClearPositions()
165{
692de412 166/// Clear the array of transformations
89cc3034 167
168 fSVPositions.Delete();
169}
170
171//______________________________________________________________________________
172void AliMUONGeometrySVMap::SortPositions()
173{
692de412 174/// Sort the array of positions by names.
89cc3034 175
176 fSVPositions.Sort(fSVPositions.GetEntriesFast());
177}
178
179//______________________________________________________________________________
180void AliMUONGeometrySVMap::Print(const char* option) const
181{
692de412 182/// Print the map of sensitive volumes and detector elements
89cc3034 183
184 fSVMap.Print(option);
185}
186
187//______________________________________________________________________________
188void AliMUONGeometrySVMap::PrintPositions() const
189{
692de412 190/// Print the sensitive volumes global positions
89cc3034 191
192 for (Int_t i=0; i<fSVPositions.GetEntriesFast(); i++) {
193
194 TGeoTranslation* matrix = (TGeoTranslation*)fSVPositions.At(i);
195
196 cout << "DetElemId: " << matrix->GetUniqueID();
197 cout << " name: " << matrix->GetTitle() << endl;
198
199 const double* translation = matrix->GetTranslation();
200 cout << " translation: "
e516b01d 201#if defined (__DECCXX)
202 << translation[0] << ", "
203 << translation[1] << ", "
204 << translation[2] << endl;
205#else
89cc3034 206 << std::fixed
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;
e516b01d 210#endif
89cc3034 211 }
212}
213
214//______________________________________________________________________________
215void AliMUONGeometrySVMap::WriteMap(ofstream& out) const
216{
692de412 217/// Print the map of sensitive volumes and detector elements
218/// into specified stream
89cc3034 219
220 fSVMap.Print("SV", out);
221}
222
223//______________________________________________________________________________
224Int_t AliMUONGeometrySVMap::GetDetElemId(const TString& volumePath) const
225{
692de412 226/// Return detection element Id for the sensitive volume specified by path
89cc3034 227
228 return fSVMap.Get(volumePath);
229}