]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpDEManager.cxx
added headers needed for compilation
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpDEManager.cxx
CommitLineData
32f6e426 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
16// $Id$
13985652 17// $MpId: AliMpDEManager.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
32f6e426 18// Category: management
3d1463c8 19
20//-----------------------------------------------------------------------------
32f6e426 21// Class AliMpDEManager
22// --------------------
23// The manager class for definition of detection element types
24// Authors: Ivana Hrivnacova, IPN Orsay
25// Laurent Aphecetche, SUBATECH Nantes
3d1463c8 26//-----------------------------------------------------------------------------
32f6e426 27
28#include "AliMpDEManager.h"
4af021b2 29#include "AliMpDEStore.h"
30#include "AliMpDetElement.h"
32f6e426 31#include "AliMpConstants.h"
4af021b2 32#include "AliMpCathodType.h"
168e9c4d 33#include "AliMpEncodePair.h"
32f6e426 34
35#include "AliLog.h"
36
37#include <Riostream.h>
4af021b2 38#include <TClass.h>
32f6e426 39
b80faac0 40using std::endl;
13985652 41/// \cond CLASSIMP
42ClassImp(AliMpDEManager)
43/// \endcond
44
32f6e426 45const Int_t AliMpDEManager::fgkCoefficient = 100;
6b87a46a 46
31edb2d7 47//
48// static private methods
49//
32f6e426 50//______________________________________________________________________________
31edb2d7 51TArrayI& AliMpDEManager::GetNofDEPerChamber()
32f6e426 52{
31edb2d7 53 /// number of detElemId per chamber
54 static TArrayI nofDEPerChamber;
55 return nofDEPerChamber;
32f6e426 56}
57
32f6e426 58//
31edb2d7 59// static public methods
32f6e426 60//
61
62//______________________________________________________________________________
4af021b2 63AliMpDetElement* AliMpDEManager::GetDetElement(Int_t detElemId, Bool_t warn)
32f6e426 64{
4af021b2 65/// Return det element for given detElemId
32f6e426 66
4af021b2 67 return AliMpDEStore::Instance()->GetDetElement(detElemId, warn);
68}
32f6e426 69
2eee683c 70//______________________________________________________________________________
71AliMpDetElement* AliMpDEManager::GetDetElement(const TString& deName, Bool_t warn)
72{
73/// Return det element for given deName
74
75 return AliMpDEStore::Instance()->GetDetElement(deName, warn);
76}
77
32f6e426 78//
79// static public methods
80//
81
82//______________________________________________________________________________
83Bool_t AliMpDEManager::IsValidDetElemId(Int_t detElemId, Bool_t warn)
84{
85/// Return true if detElemId is valid
4af021b2 86/// (is present in the DE map)
32f6e426 87
4af021b2 88 if ( GetDetElement(detElemId, warn) ) return true;
32f6e426 89
32f6e426 90 return false;
91}
92
32f6e426 93//______________________________________________________________________________
0a11b03f 94Bool_t AliMpDEManager::IsValidChamberId(Int_t chamberId, Bool_t warn)
95{
96/// Return true if chamberId is valid
97
98 if ( chamberId >= 0 && chamberId < AliMpConstants::NofChambers() )
99 return true;
100
101 if (warn)
102 AliErrorClassStream() << "Wrong chamber Id " << chamberId << endl;
103
104 return false;
105}
106
107//______________________________________________________________________________
108Bool_t AliMpDEManager::IsValidGeomModuleId(Int_t moduleId, Bool_t warn)
32f6e426 109{
110/// Return true if moduleId is valid
111
0a11b03f 112 if ( moduleId >= 0 && moduleId < AliMpConstants::NofGeomModules() )
32f6e426 113 return true;
114
115 if (warn)
116 AliErrorClassStream() << "Wrong module Id " << moduleId << endl;
117
118 return false;
119}
120
32f6e426 121//______________________________________________________________________________
0a11b03f 122Int_t AliMpDEManager::GetChamberId(Int_t detElemId, Bool_t warn)
32f6e426 123{
0a11b03f 124/// Return chamber Id for given detElemId
32f6e426 125
126 if ( ! IsValidDetElemId(detElemId, warn) ) return -1;
127
128 return detElemId/fgkCoefficient - 1;
129}
130
0a11b03f 131//______________________________________________________________________________
132Int_t AliMpDEManager::GetGeomModuleId(Int_t detElemId, Bool_t warn)
133{
134/// <pre>
135/// Get module Id from detection element Id
136/// !!! moduleId != chamberId
137/// Station 1: Chamber: 1 Module: 0 Det elements: 100-103
138/// Chamber: 2 Module: 1 Det elements: 200-203
139/// Station 2: Chamber: 3 Module: 2 Det elements: 300-303
140/// Chamber: 4 Module: 3 Det elements: 400-403
141/// Station 3: Chamber: 5 Module: 4 Det elements: 500-504, 514-517
142/// Module: 5 Det elements: 505-513,
143/// Chamber: 6 Module: 6 Det elements: 600-604, 614-617
144/// Module: 7 Det elements: 605-613
145/// Station 4: Chamber: 7 Module: 8 Det elements: 700-706, 720-725
146/// Module: 9 Det elements: 707-719
147/// Chamber: 8 Module: 10 Det elements: 800-806, 820-825
148/// Module: 11 Det elements: 807-819
149/// Station 5: Chamber: 9 Module: 12 Det elements: 900-906, 920-925
150/// Module: 13 Det elements: 907-919
151/// Chamber: 10 Module: 14 Det elements: 1000-1006,1020-1025
152/// Module: 15 Det elements: 1007-1019
153/// Station 6: Chamber: 11 Module: 16 Det elements: 1100-1117
154/// Chamber: 12 Module: 17 Det elements: 1200-1217
155/// Station 7: Chamber: 13 Module: 18 Det elements: 1300-1317
156/// Chamber: 14 Module: 19 Det elements: 1400-1417
157/// </pre>
158
159 if ( ! IsValidDetElemId(detElemId, warn) ) return -1;
160
161 return detElemId/fgkCoefficient
94bf739c 162 + ((detElemId >= 505 && detElemId <= 513) || detElemId >= 600 )
163 + ((detElemId >= 605 && detElemId <= 613) || detElemId >= 700 )
164 + ((detElemId >= 707 && detElemId <= 719) || detElemId >= 800 )
165 + ((detElemId >= 807 && detElemId <= 819) || detElemId >= 900 )
166 + ((detElemId >= 907 && detElemId <= 919) || detElemId >= 1000 )
167 + ((detElemId >= 1007 && detElemId <= 1019) || detElemId >= 1100 ) - 1;
0a11b03f 168}
169
32f6e426 170//______________________________________________________________________________
4af021b2 171AliMp::PlaneType AliMpDEManager::GetPlaneType(Int_t detElemId, AliMp::CathodType cath)
32f6e426 172{
173/// Return plane type \n
4af021b2 174/// Failure causes Fatal error - as AliMp::PlaneType has no possibility
32f6e426 175/// to return undefined value
176
4af021b2 177 if ( ! IsValidDetElemId(detElemId, true) ) {
178 AliFatalClass("Cannot return AliMp::PlaneType value.");
179 return AliMp::kBendingPlane;
32f6e426 180 }
181
4af021b2 182 return GetDetElement(detElemId)->GetPlaneType(cath);
32f6e426 183}
184
185//______________________________________________________________________________
4af021b2 186AliMp::StationType AliMpDEManager::GetStationType(Int_t detElemId)
32f6e426 187{
188/// Return station type \n
4af021b2 189/// Failure causes Fatal error - as AliMp::StationType has no possibility
32f6e426 190/// to return undefined value
191
192 if ( ! IsValidDetElemId(detElemId, true) ) {
4af021b2 193 AliFatalClass("Cannot return AliMp::StationType value.");
4e51cfd2 194 return AliMp::kStation12;
32f6e426 195 }
196
4af021b2 197 return GetDetElement(detElemId)->GetStationType();
198}
199
4e51cfd2 200//______________________________________________________________________________
201AliMq::Station12Type AliMpDEManager::GetStation12Type(Int_t detElemId)
202{
203/// Return station12 type \n
204/// Failure causes Fatal error - as AliMp::StationNumber has no possibility
205/// to return undefined value
206
207 if ( ! IsValidDetElemId(detElemId, true) ) {
208 AliFatalClass("Cannot return AliMp::Station12Type value.");
209 return AliMq::kNotSt12;
210 }
211
212 return GetDetElement(detElemId)->GetStation12Type();
213}
214
4af021b2 215//______________________________________________________________________________
216AliMp::CathodType
217AliMpDEManager::GetCathod(Int_t detElemId, AliMp::PlaneType planeType)
218{
219/// Return cathod number for given detElemId and planeType
220
221 if ( ! IsValidDetElemId(detElemId, true) ) {
222 AliFatalClass("Cannot return AliMp::CathodType value.");
223 return AliMp::kCath0;
32f6e426 224 }
225
4af021b2 226 return GetDetElement(detElemId)->GetCathodType(planeType);
32f6e426 227}
228
db11901e 229//______________________________________________________________________________
230Int_t AliMpDEManager::GetNofDEInChamber(Int_t chamberId, Bool_t warn)
231{
232/// Return the number of detection elements in the chamber with the given
233/// chamberId
234
4af021b2 235 if ( ! IsValidChamberId(chamberId,warn) ) return 0;
236
237 // Fill array if it is empty
31edb2d7 238 if ( ! GetNofDEPerChamber().GetSize() ) {
239 GetNofDEPerChamber().Set(AliMpConstants::NofChambers());
4af021b2 240 AliMpDEIterator it;
241 for ( Int_t i=0; i<AliMpConstants::NofChambers(); i++ ) {
242 Int_t counter = 0;
243 for ( it.First(i); ! it.IsDone(); it.Next() ) ++counter;
31edb2d7 244 GetNofDEPerChamber()[i] = counter;
4af021b2 245 }
246 }
247
31edb2d7 248 return GetNofDEPerChamber()[chamberId];
4af021b2 249
db11901e 250}
251
fd911297 252//______________________________________________________________________________
168e9c4d 253MpPair_t AliMpDEManager::GetDetElemIdRange(Int_t chamberId)
fd911297 254{
255/// Return the detection element Id range for given chamberId
168e9c4d 256/// es encoded pair
fd911297 257
168e9c4d 258 if ( ! IsValidChamberId(chamberId) ) return 0;
fd911297 259
168e9c4d 260 return AliMp::Pair(
fd911297 261 (chamberId+1)*fgkCoefficient,
262 (chamberId+1)*fgkCoefficient + GetNofDEInChamber(chamberId) - 1);
263
264}
265
31edb2d7 266//
267// ctors, dtor
268//
269
270//______________________________________________________________________________
271AliMpDEManager::~AliMpDEManager()
272{
273/// Destructor
274}
275