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