Line data Source code
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$
17 : // $MpId: AliMpDEManager.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
18 : // Category: management
19 :
20 : //-----------------------------------------------------------------------------
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
26 : //-----------------------------------------------------------------------------
27 :
28 : #include "AliMpDEManager.h"
29 : #include "AliMpDEStore.h"
30 : #include "AliMpDetElement.h"
31 : #include "AliMpConstants.h"
32 : #include "AliMpCathodType.h"
33 : #include "AliMpEncodePair.h"
34 :
35 : #include "AliLog.h"
36 :
37 : #include <Riostream.h>
38 : #include <TClass.h>
39 :
40 : using std::endl;
41 : /// \cond CLASSIMP
42 18 : ClassImp(AliMpDEManager)
43 : /// \endcond
44 :
45 : const Int_t AliMpDEManager::fgkCoefficient = 100;
46 :
47 : //
48 : // static private methods
49 : //
50 : //______________________________________________________________________________
51 : TArrayI& AliMpDEManager::GetNofDEPerChamber()
52 : {
53 : /// number of detElemId per chamber
54 4866 : static TArrayI nofDEPerChamber;
55 2430 : return nofDEPerChamber;
56 0 : }
57 :
58 : //
59 : // static public methods
60 : //
61 :
62 : //______________________________________________________________________________
63 : AliMpDetElement* AliMpDEManager::GetDetElement(Int_t detElemId, Bool_t warn)
64 : {
65 : /// Return det element for given detElemId
66 :
67 1859263 : return AliMpDEStore::Instance()->GetDetElement(detElemId, warn);
68 : }
69 :
70 : //______________________________________________________________________________
71 : AliMpDetElement* AliMpDEManager::GetDetElement(const TString& deName, Bool_t warn)
72 : {
73 : /// Return det element for given deName
74 :
75 0 : return AliMpDEStore::Instance()->GetDetElement(deName, warn);
76 : }
77 :
78 : //
79 : // static public methods
80 : //
81 :
82 : //______________________________________________________________________________
83 : Bool_t AliMpDEManager::IsValidDetElemId(Int_t detElemId, Bool_t warn)
84 : {
85 : /// Return true if detElemId is valid
86 : /// (is present in the DE map)
87 :
88 2575614 : if ( GetDetElement(detElemId, warn) ) return true;
89 :
90 0 : return false;
91 1287807 : }
92 :
93 : //______________________________________________________________________________
94 : Bool_t AliMpDEManager::IsValidChamberId(Int_t chamberId, Bool_t warn)
95 : {
96 : /// Return true if chamberId is valid
97 :
98 729422 : if ( chamberId >= 0 && chamberId < AliMpConstants::NofChambers() )
99 364711 : return true;
100 :
101 0 : if (warn)
102 0 : AliErrorClassStream() << "Wrong chamber Id " << chamberId << endl;
103 :
104 0 : return false;
105 364711 : }
106 :
107 : //______________________________________________________________________________
108 : Bool_t AliMpDEManager::IsValidGeomModuleId(Int_t moduleId, Bool_t warn)
109 : {
110 : /// Return true if moduleId is valid
111 :
112 0 : if ( moduleId >= 0 && moduleId < AliMpConstants::NofGeomModules() )
113 0 : return true;
114 :
115 0 : if (warn)
116 0 : AliErrorClassStream() << "Wrong module Id " << moduleId << endl;
117 :
118 0 : return false;
119 0 : }
120 :
121 : //______________________________________________________________________________
122 : Int_t AliMpDEManager::GetChamberId(Int_t detElemId, Bool_t warn)
123 : {
124 : /// Return chamber Id for given detElemId
125 :
126 683284 : if ( ! IsValidDetElemId(detElemId, warn) ) return -1;
127 :
128 683284 : return detElemId/fgkCoefficient - 1;
129 683284 : }
130 :
131 : //______________________________________________________________________________
132 : Int_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 35659 : if ( ! IsValidDetElemId(detElemId, warn) ) return -1;
160 :
161 71318 : return detElemId/fgkCoefficient
162 106819 : + ((detElemId >= 505 && detElemId <= 513) || detElemId >= 600 )
163 106814 : + ((detElemId >= 605 && detElemId <= 613) || detElemId >= 700 )
164 106746 : + ((detElemId >= 707 && detElemId <= 719) || detElemId >= 800 )
165 106743 : + ((detElemId >= 807 && detElemId <= 819) || detElemId >= 900 )
166 106736 : + ((detElemId >= 907 && detElemId <= 919) || detElemId >= 1000 )
167 106736 : + ((detElemId >= 1007 && detElemId <= 1019) || detElemId >= 1100 ) - 1;
168 35659 : }
169 :
170 : //______________________________________________________________________________
171 : AliMp::PlaneType AliMpDEManager::GetPlaneType(Int_t detElemId, AliMp::CathodType cath)
172 : {
173 : /// Return plane type \n
174 : /// Failure causes Fatal error - as AliMp::PlaneType has no possibility
175 : /// to return undefined value
176 :
177 0 : if ( ! IsValidDetElemId(detElemId, true) ) {
178 0 : AliFatalClass("Cannot return AliMp::PlaneType value.");
179 0 : return AliMp::kBendingPlane;
180 : }
181 :
182 0 : return GetDetElement(detElemId)->GetPlaneType(cath);
183 0 : }
184 :
185 : //______________________________________________________________________________
186 : AliMp::StationType AliMpDEManager::GetStationType(Int_t detElemId)
187 : {
188 : /// Return station type \n
189 : /// Failure causes Fatal error - as AliMp::StationType has no possibility
190 : /// to return undefined value
191 :
192 598762 : if ( ! IsValidDetElemId(detElemId, true) ) {
193 0 : AliFatalClass("Cannot return AliMp::StationType value.");
194 0 : return AliMp::kStation12;
195 : }
196 :
197 299381 : return GetDetElement(detElemId)->GetStationType();
198 299381 : }
199 :
200 : //______________________________________________________________________________
201 : AliMq::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 59232 : if ( ! IsValidDetElemId(detElemId, true) ) {
208 0 : AliFatalClass("Cannot return AliMp::Station12Type value.");
209 0 : return AliMq::kNotSt12;
210 : }
211 :
212 29616 : return GetDetElement(detElemId)->GetStation12Type();
213 29616 : }
214 :
215 : //______________________________________________________________________________
216 : AliMp::CathodType
217 : AliMpDEManager::GetCathod(Int_t detElemId, AliMp::PlaneType planeType)
218 : {
219 : /// Return cathod number for given detElemId and planeType
220 :
221 8 : if ( ! IsValidDetElemId(detElemId, true) ) {
222 0 : AliFatalClass("Cannot return AliMp::CathodType value.");
223 0 : return AliMp::kCath0;
224 : }
225 :
226 4 : return GetDetElement(detElemId)->GetCathodType(planeType);
227 4 : }
228 :
229 : //______________________________________________________________________________
230 : Int_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 :
235 1200 : if ( ! IsValidChamberId(chamberId,warn) ) return 0;
236 :
237 : // Fill array if it is empty
238 1200 : if ( ! GetNofDEPerChamber().GetSize() ) {
239 2 : GetNofDEPerChamber().Set(AliMpConstants::NofChambers());
240 2 : AliMpDEIterator it;
241 60 : for ( Int_t i=0; i<AliMpConstants::NofChambers(); i++ ) {
242 : Int_t counter = 0;
243 1452 : for ( it.First(i); ! it.IsDone(); it.Next() ) ++counter;
244 84 : GetNofDEPerChamber()[i] = counter;
245 : }
246 2 : }
247 :
248 1200 : return GetNofDEPerChamber()[chamberId];
249 :
250 1200 : }
251 :
252 : //______________________________________________________________________________
253 : MpPair_t AliMpDEManager::GetDetElemIdRange(Int_t chamberId)
254 : {
255 : /// Return the detection element Id range for given chamberId
256 : /// es encoded pair
257 :
258 0 : if ( ! IsValidChamberId(chamberId) ) return 0;
259 :
260 0 : return AliMp::Pair(
261 0 : (chamberId+1)*fgkCoefficient,
262 0 : (chamberId+1)*fgkCoefficient + GetNofDEInChamber(chamberId) - 1);
263 :
264 0 : }
265 :
266 : //
267 : // ctors, dtor
268 : //
269 :
270 : //______________________________________________________________________________
271 : AliMpDEManager::~AliMpDEManager()
272 0 : {
273 : /// Destructor
274 0 : }
275 :
|