]>
Commit | Line | Data |
---|---|---|
f0c62051 | 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: AliMpDetElement.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $ | |
18 | // Category: management | |
3d1463c8 | 19 | |
20 | //----------------------------------------------------------------------------- | |
f0c62051 | 21 | // Class AliMpDetElement |
22 | // -------------------- | |
23 | // The class defines the electronics properties of detection element | |
24 | // Authors: Ivana Hrivnacova, IPN Orsay | |
25 | // Laurent Aphecetche, Christian Finck, SUBATECH Nantes | |
3d1463c8 | 26 | //----------------------------------------------------------------------------- |
f0c62051 | 27 | |
28 | #include "AliMpDetElement.h" | |
f0c62051 | 29 | |
61845859 | 30 | #include "AliMpArrayI.h" |
969fa94b | 31 | #include "AliMpConstants.h" |
32 | #include "AliMpDEManager.h" | |
61845859 | 33 | #include "AliMpHVNamer.h" |
34 | #include "AliMpHVUID.h" | |
35 | #include "AliMpManuUID.h" | |
36 | #include "AliMpPadUID.h" | |
37 | #include "AliMpSegmentation.h" | |
38 | #include "AliMpVSegmentation.h" | |
39 | ||
40 | #include "AliCodeTimer.h" | |
f0c62051 | 41 | #include "AliLog.h" |
61845859 | 42 | |
f0c62051 | 43 | #include <Riostream.h> |
44 | ||
45 | /// \cond CLASSIMP | |
46 | ClassImp(AliMpDetElement) | |
47 | /// \endcond | |
48 | ||
49 | const char AliMpDetElement::fgkNameSeparator = '_'; | |
50 | ||
51 | //______________________________________________________________________________ | |
52 | AliMpDetElement::AliMpDetElement(Int_t id, const TString& name, | |
53 | const TString& segType, AliMp::PlaneType planeType) | |
54 | : TObject(), | |
55 | fId(id), | |
56 | fDdlId(-1), | |
57 | fName(name), | |
58 | fSegType(segType), | |
59 | fPlaneType(planeType), | |
d2261d03 | 60 | fBusPatchIds(false), |
f0c62051 | 61 | fManuToSerialNbs(1700), |
61845859 | 62 | fSerialNbToManus(1700), |
63 | fManuList(1700), | |
64 | fTrackerChannels(1700*AliMpConstants::ManuNofChannels()), | |
65 | fHVmanus(true) | |
f0c62051 | 66 | { |
67 | /// Standard constructor | |
f0c62051 | 68 | } |
69 | ||
70 | //______________________________________________________________________________ | |
71 | AliMpDetElement::AliMpDetElement(TRootIOCtor* /*ioCtor*/) | |
72 | : TObject(), | |
73 | fId(0), | |
74 | fDdlId(-1), | |
75 | fName(), | |
76 | fSegType(), | |
77 | fPlaneType(), | |
78 | fBusPatchIds(), | |
79 | fManuToSerialNbs(), | |
61845859 | 80 | fSerialNbToManus(), |
81 | fManuList(true), | |
82 | fTrackerChannels(true), | |
83 | fHVmanus(true) | |
f0c62051 | 84 | { |
85 | /// Root IO constructor | |
86 | } | |
87 | ||
88 | //______________________________________________________________________________ | |
89 | AliMpDetElement::~AliMpDetElement() | |
90 | { | |
91 | /// Destructor | |
92 | } | |
93 | ||
94 | ||
95 | // | |
96 | // public methods | |
97 | // | |
98 | ||
99 | //______________________________________________________________________________ | |
100 | Bool_t AliMpDetElement::AddBusPatch(Int_t busPatchId) | |
101 | { | |
102 | /// Add bus patch Id if a bus patch with the same Id is not yet present; | |
103 | /// return false if bus patch was not added | |
104 | ||
105 | if ( HasBusPatchId(busPatchId) ) { | |
106 | AliWarningStream() | |
107 | << "Bus patch Id = " << busPatchId << " already present." | |
108 | << endl; | |
109 | return false; | |
110 | } | |
111 | ||
112 | fBusPatchIds.Add(busPatchId); | |
113 | return true; | |
114 | } | |
115 | ||
116 | //______________________________________________________________________________ | |
117 | void AliMpDetElement::AddManuSerial(Int_t manuId, Int_t serialNb) | |
118 | { | |
119 | /// Map the serial manu number | |
120 | /// (Eventually add check if the given pair already present) | |
121 | ||
61845859 | 122 | AliCodeTimerAuto(""); |
123 | ||
124 | AliDebug(1,Form("DE %4d ManuId %4d SerialNB %d", | |
125 | fId,manuId,serialNb)); | |
126 | ||
f0c62051 | 127 | fManuToSerialNbs.Add(Long_t(manuId), Long_t(serialNb)); |
128 | fSerialNbToManus.Add(Long_t(serialNb), Long_t(manuId)); | |
129 | } | |
130 | ||
131 | //______________________________________________________________________________ | |
132 | TString AliMpDetElement::GetSegName(AliMp::CathodType cathType) const | |
133 | { | |
134 | /// Return the segmentation name for the given catod type | |
135 | ||
136 | return fSegType + fgkNameSeparator + PlaneTypeName(GetPlaneType(cathType)); | |
137 | } | |
138 | ||
139 | //______________________________________________________________________________ | |
140 | AliMp::PlaneType AliMpDetElement::GetPlaneType(AliMp::CathodType cath) const | |
141 | { | |
142 | /// Return plane type \n | |
143 | ||
144 | if ( cath == AliMp::kCath0 ) return fPlaneType; | |
145 | else return AliMp::OtherPlaneType(fPlaneType); | |
146 | } | |
147 | ||
148 | //______________________________________________________________________________ | |
149 | AliMp::CathodType AliMpDetElement::GetCathodType(AliMp::PlaneType planeType) const | |
150 | { | |
151 | /// Return cathod type for given planeType | |
152 | ||
153 | if ( fPlaneType == planeType ) return AliMp::kCath0; | |
154 | else return AliMp::kCath1; | |
155 | } | |
156 | ||
969fa94b | 157 | //______________________________________________________________________________ |
158 | AliMp::CathodType AliMpDetElement::GetCathodTypeFromManuId(Int_t manuId) const | |
159 | { | |
160 | /// Return cathod type for given manuId | |
161 | ||
162 | AliMp::PlaneType planeType = AliMp::kBendingPlane; | |
163 | if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) ) | |
164 | { | |
165 | planeType = AliMp::kNonBendingPlane; | |
166 | } | |
167 | return GetCathodType(planeType); | |
168 | } | |
169 | ||
f0c62051 | 170 | //______________________________________________________________________________ |
171 | AliMp::StationType AliMpDetElement::GetStationType() const | |
172 | { | |
173 | /// Return station type \n | |
174 | /// Failure causes Fatal error - as AliMp::StationType has no possibility | |
175 | /// to return undefined value | |
176 | ||
177 | Int_t chamberId = AliMpDEManager::GetChamberId(fId, false); | |
178 | if ( ! AliMpDEManager::IsValidChamberId(chamberId, true) ) { | |
179 | AliFatal("Cannot return AliMp::StationType value."); | |
180 | return AliMp::kStation1; | |
181 | } | |
182 | ||
183 | if ( chamberId == 0 || chamberId == 1 ) return AliMp::kStation1; | |
184 | if ( chamberId == 2 || chamberId == 3 ) return AliMp::kStation2; | |
185 | if ( chamberId >= 4 && chamberId <= 9 ) return AliMp::kStation345; | |
186 | if ( chamberId >= 10 && chamberId <= 13 ) return AliMp::kStationTrigger; | |
187 | ||
188 | // Should never get to this line | |
189 | AliFatal("Cannot return AliMp::StationType value."); | |
190 | return AliMp::kStation1; | |
191 | } | |
192 | ||
193 | //______________________________________________________________________________ | |
194 | Int_t AliMpDetElement::GetNofBusPatches() const | |
195 | { | |
196 | /// Return the number of bus patches in this detection element | |
197 | ||
198 | return fBusPatchIds.GetSize(); | |
199 | } | |
200 | ||
201 | //______________________________________________________________________________ | |
202 | Int_t AliMpDetElement::GetBusPatchId(Int_t index) const | |
203 | { | |
204 | /// Return the index-th bus patch | |
205 | ||
206 | if ( index < 0 || index > GetNofBusPatches() ) { | |
207 | AliErrorStream() | |
208 | << "In DE = " << fId << ": Index " << index << " outside limits." << endl; | |
209 | return 0; | |
210 | } | |
211 | ||
212 | return fBusPatchIds.GetValue(index); | |
213 | } | |
214 | ||
215 | ||
216 | //______________________________________________________________________________ | |
217 | Bool_t AliMpDetElement::HasBusPatchId(Int_t busPatchId) const | |
218 | { | |
219 | /// Return true if the bus patch Id is present | |
220 | ||
221 | return fBusPatchIds.HasValue(busPatchId);; | |
222 | } | |
223 | ||
f0c62051 | 224 | //______________________________________________________________________________ |
225 | Int_t AliMpDetElement::GetManuSerialFromId(Int_t manuId) const | |
226 | { | |
227 | /// Return manu serial number from manuId | |
228 | ||
229 | return (Int_t)fManuToSerialNbs.GetValue(Long_t(manuId)); | |
230 | } | |
231 | ||
232 | //______________________________________________________________________________ | |
233 | Int_t AliMpDetElement::GetManuIdFromSerial(Int_t serialNb) const | |
234 | { | |
235 | /// Return manuId from manu serial number | |
236 | ||
237 | return (Int_t)fSerialNbToManus.GetValue(Long_t(serialNb)); | |
238 | } | |
239 | ||
61845859 | 240 | //______________________________________________________________________________ |
241 | Int_t | |
242 | AliMpDetElement::NofChannelsInManu(Int_t manuId) const | |
243 | { | |
244 | /// Return the number of channels in a given manu | |
245 | ||
246 | Long_t uid = AliMpManuUID::BuildUniqueID(fId,manuId); | |
247 | ||
248 | return (Int_t)(fManuList.GetValue(uid)); | |
249 | } | |
250 | ||
251 | //______________________________________________________________________________ | |
252 | Bool_t | |
253 | AliMpDetElement::IsExistingChannel(Int_t manuId, Int_t manuChannel) const | |
254 | { | |
255 | /// Whether or not the channel is a valid one (does not tell if it is | |
256 | /// connected or not | |
257 | ||
258 | if ( NofChannelsInManu(manuId) > 0 && | |
259 | manuChannel >= 0 && | |
260 | manuChannel < AliMpConstants::ManuNofChannels() ) | |
261 | { | |
262 | return kTRUE; | |
263 | } | |
264 | else | |
265 | { | |
266 | return kFALSE; | |
267 | } | |
268 | } | |
269 | ||
270 | //______________________________________________________________________________ | |
271 | Bool_t | |
272 | AliMpDetElement::IsConnectedChannel(Int_t manuId, Int_t manuChannel) const | |
273 | { | |
274 | /// Whether or not the channel is a *connected* one (i.e. it is valid plus | |
275 | /// it corresponds to a real pad) | |
276 | ||
277 | return ( fTrackerChannels.GetValue(AliMpPadUID::BuildUniqueID(fId,manuId,manuChannel)) > 0 ); | |
278 | } | |
279 | ||
280 | //______________________________________________________________________________ | |
281 | void | |
282 | AliMpDetElement::AddManu(Int_t manuId) | |
283 | { | |
284 | /// Fills the fManuList and fTrackerChannels | |
285 | AliMp::StationType stationType = AliMpDEManager::GetStationType(fId); | |
286 | ||
287 | if ( stationType == AliMp::kStationTrigger ) return; | |
288 | ||
289 | AliCodeTimerAuto("") | |
290 | ||
291 | AliDebug(1,Form("DE %4d Manu %4d",fId,manuId)); | |
292 | ||
293 | AliCodeTimerStart(Form("%s",AliMp::StationTypeName(stationType).Data())); | |
294 | ||
295 | if ( fHVmanus.GetSize() == 0 ) | |
296 | { | |
297 | fHVmanus.SetOwner(kTRUE); // to be 100% explicit | |
298 | ||
299 | // get the size, to avoid resizing when adding later on | |
300 | Int_t nmanus(0); | |
301 | ||
302 | AliMp::CathodType cathodes[] = { AliMp::kCath0, AliMp::kCath1 }; | |
303 | ||
304 | for ( Int_t i = 0; i < 2; ++i ) | |
305 | { | |
306 | const AliMpVSegmentation* seg = | |
307 | AliMpSegmentation::Instance()->GetMpSegmentation(fId,cathodes[i]); | |
308 | ||
309 | TArrayI manus; | |
310 | ||
311 | seg->GetAllElectronicCardIDs(manus); | |
312 | ||
313 | nmanus += manus.GetSize(); | |
314 | } | |
315 | ||
316 | fHVmanus.SetSize(nmanus); | |
317 | } | |
318 | ||
319 | const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(fId,manuId); | |
320 | ||
321 | Int_t n(0); | |
322 | ||
323 | for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i ) | |
324 | { | |
325 | if ( seg->PadByLocation(AliMpIntPair(manuId,i),kFALSE).IsValid() ) | |
326 | { | |
327 | ++n; | |
328 | fTrackerChannels.Add((Long_t)AliMpPadUID::BuildUniqueID(fId,manuId,i), | |
329 | (Long_t)1); | |
330 | } | |
331 | } | |
332 | ||
333 | fManuList.Add(AliMpManuUID::BuildUniqueID(fId,manuId),(Long_t)n); | |
334 | ||
335 | AliMpHVNamer hvNamer; | |
336 | ||
337 | Int_t index = hvNamer.ManuId2Index(fId,manuId); | |
338 | ||
339 | UInt_t hvuid = AliMpHVUID::BuildUniqueID(fId,index); | |
340 | ||
341 | AliMpArrayI* hv = static_cast<AliMpArrayI*>(fHVmanus.GetValue(hvuid)); | |
342 | ||
343 | if (!hv) | |
344 | { | |
345 | Bool_t sort(kFALSE); | |
346 | hv = new AliMpArrayI(sort); | |
347 | fHVmanus.Add(hvuid,hv); | |
348 | } | |
349 | ||
350 | hv->Add(manuId,kFALSE); | |
351 | ||
352 | AliCodeTimerStop(Form("%s",AliMp::StationTypeName(stationType).Data())); | |
353 | } | |
354 | ||
355 | //______________________________________________________________________________ | |
356 | const AliMpArrayI* | |
357 | AliMpDetElement::ManusForHV(Int_t hvIndex) const | |
358 | { | |
359 | /// Return the list of manus sharing a hv channel | |
360 | return static_cast<AliMpArrayI*>(fHVmanus.GetValue(AliMpHVUID::BuildUniqueID(fId,hvIndex))); | |
361 | } | |
362 | ||
363 | //______________________________________________________________________________ | |
364 | Int_t | |
365 | AliMpDetElement::NofManusWithSerialNumber() const | |
366 | { | |
367 | /// Return the number of manus which have a serial number in this detection element | |
368 | return fManuToSerialNbs.GetSize(); | |
369 | } | |
370 | ||
371 | //______________________________________________________________________________ | |
372 | Int_t | |
373 | AliMpDetElement::NofManus() const | |
374 | { | |
375 | /// Return the number of manus in this detection element | |
376 | return fManuList.GetSize(); | |
377 | } | |
378 |