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