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