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