]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpDetElement.cxx
Separating run-dependent mapping data from data, which are not
[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"
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
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.");
163 return AliMp::kStation1;
164 }
165
166 if ( chamberId == 0 || chamberId == 1 ) return AliMp::kStation1;
167 if ( chamberId == 2 || chamberId == 3 ) return AliMp::kStation2;
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.");
173 return AliMp::kStation1;
174}
175
176//______________________________________________________________________________
177Int_t AliMpDetElement::GetNofBusPatches() const
178{
179/// Return the number of bus patches in this detection element
180
181 return fBusPatchIds.GetSize();
182}
183
184//______________________________________________________________________________
185Int_t AliMpDetElement::GetBusPatchId(Int_t index) const
186{
187/// Return the index-th bus patch
188
189 if ( index < 0 || index > GetNofBusPatches() ) {
190 AliErrorStream()
191 << "In DE = " << fId << ": Index " << index << " outside limits." << endl;
192 return 0;
193 }
194
195 return fBusPatchIds.GetValue(index);
196}
197
198
199//______________________________________________________________________________
200Bool_t AliMpDetElement::HasBusPatchId(Int_t busPatchId) const
201{
202/// Return true if the bus patch Id is present
203
204 return fBusPatchIds.HasValue(busPatchId);;
205}
206
61845859 207//______________________________________________________________________________
208Int_t
209AliMpDetElement::NofChannelsInManu(Int_t manuId) const
210{
211 /// Return the number of channels in a given manu
212
213 Long_t uid = AliMpManuUID::BuildUniqueID(fId,manuId);
214
215 return (Int_t)(fManuList.GetValue(uid));
216}
217
218//______________________________________________________________________________
219Bool_t
220AliMpDetElement::IsExistingChannel(Int_t manuId, Int_t manuChannel) const
221{
222 /// Whether or not the channel is a valid one (does not tell if it is
223 /// connected or not
224
225 if ( NofChannelsInManu(manuId) > 0 &&
226 manuChannel >= 0 &&
227 manuChannel < AliMpConstants::ManuNofChannels() )
228 {
229 return kTRUE;
230 }
231 else
232 {
233 return kFALSE;
234 }
235}
236
237//______________________________________________________________________________
238Bool_t
239AliMpDetElement::IsConnectedChannel(Int_t manuId, Int_t manuChannel) const
240{
241 /// Whether or not the channel is a *connected* one (i.e. it is valid plus
242 /// it corresponds to a real pad)
243
244 return ( fTrackerChannels.GetValue(AliMpPadUID::BuildUniqueID(fId,manuId,manuChannel)) > 0 );
245}
246
247//______________________________________________________________________________
248void
249AliMpDetElement::AddManu(Int_t manuId)
250{
251 /// Fills the fManuList and fTrackerChannels
252 AliMp::StationType stationType = AliMpDEManager::GetStationType(fId);
253
254 if ( stationType == AliMp::kStationTrigger ) return;
255
256 AliCodeTimerAuto("")
257
258 AliDebug(1,Form("DE %4d Manu %4d",fId,manuId));
259
260 AliCodeTimerStart(Form("%s",AliMp::StationTypeName(stationType).Data()));
261
262 if ( fHVmanus.GetSize() == 0 )
263 {
264 fHVmanus.SetOwner(kTRUE); // to be 100% explicit
265
266 // get the size, to avoid resizing when adding later on
267 Int_t nmanus(0);
268
269 AliMp::CathodType cathodes[] = { AliMp::kCath0, AliMp::kCath1 };
270
271 for ( Int_t i = 0; i < 2; ++i )
272 {
273 const AliMpVSegmentation* seg =
274 AliMpSegmentation::Instance()->GetMpSegmentation(fId,cathodes[i]);
275
276 TArrayI manus;
277
278 seg->GetAllElectronicCardIDs(manus);
279
280 nmanus += manus.GetSize();
281 }
282
283 fHVmanus.SetSize(nmanus);
284 }
285
286 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(fId,manuId);
287
288 Int_t n(0);
289
290 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
291 {
292 if ( seg->PadByLocation(AliMpIntPair(manuId,i),kFALSE).IsValid() )
293 {
294 ++n;
295 fTrackerChannels.Add((Long_t)AliMpPadUID::BuildUniqueID(fId,manuId,i),
296 (Long_t)1);
297 }
298 }
299
300 fManuList.Add(AliMpManuUID::BuildUniqueID(fId,manuId),(Long_t)n);
630711ed 301
302 fNofChannels += n;
61845859 303
304 AliMpHVNamer hvNamer;
305
306 Int_t index = hvNamer.ManuId2Index(fId,manuId);
307
308 UInt_t hvuid = AliMpHVUID::BuildUniqueID(fId,index);
309
310 AliMpArrayI* hv = static_cast<AliMpArrayI*>(fHVmanus.GetValue(hvuid));
311
312 if (!hv)
313 {
314 Bool_t sort(kFALSE);
315 hv = new AliMpArrayI(sort);
316 fHVmanus.Add(hvuid,hv);
317 }
318
319 hv->Add(manuId,kFALSE);
320
321 AliCodeTimerStop(Form("%s",AliMp::StationTypeName(stationType).Data()));
322}
323
324//______________________________________________________________________________
325const AliMpArrayI*
326AliMpDetElement::ManusForHV(Int_t hvIndex) const
327{
328 /// Return the list of manus sharing a hv channel
329 return static_cast<AliMpArrayI*>(fHVmanus.GetValue(AliMpHVUID::BuildUniqueID(fId,hvIndex)));
330}
331
61845859 332//______________________________________________________________________________
333Int_t
334AliMpDetElement::NofManus() const
335{
336 /// Return the number of manus in this detection element
337 return fManuList.GetSize();
338}
339