Fixing a backward compatibility issue
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpDDL.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: AliMpDDL.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
18// Category: management
3d1463c8 19
20//-----------------------------------------------------------------------------
f0c62051 21// Class AliMpDDL
22// --------------------
23// The class defines electronics properties of DDL
24// Authors: Ivana Hrivnacova, IPN Orsay
25// Christian Finck, SUBATECH Nantes
3d1463c8 26//-----------------------------------------------------------------------------
f0c62051 27
28#include "AliMpDDL.h"
29#include "AliMpDEManager.h"
30#include "AliMpDetElement.h"
31
32#include "AliLog.h"
33
34#include <Riostream.h>
35
36
37/// \cond CLASSIMP
38ClassImp(AliMpDDL)
39/// \endcond
40
41//______________________________________________________________________________
42AliMpDDL::AliMpDDL(Int_t id)
43 : TObject(),
44 fId(id),
45 fDEIds(),
59754717 46 fFrtIds(false),
11b2fd04 47 fBusPatchIds(),
48 fTriggerCrateIds(false)
49
f0c62051 50{
51/// Standard constructor
52}
53
54//______________________________________________________________________________
55AliMpDDL::AliMpDDL(TRootIOCtor* /*ioCtor*/)
56 : TObject(),
57 fId(0),
58 fDEIds(),
59754717 59 fFrtIds(false),
11b2fd04 60 fBusPatchIds(),
61 fTriggerCrateIds()
f0c62051 62{
63/// Root IO constructor
64}
65
66//______________________________________________________________________________
67AliMpDDL::~AliMpDDL()
68{
69/// Destructor
70}
71
72//
73// private methods
74//
75
76//______________________________________________________________________________
77void AliMpDDL::FillBusPatchIds()
78{
79/// Fill array with bus patch Ids
80
81 for ( Int_t i=0; i<GetNofDEs(); i++ ) {
82 AliMpDetElement* detElement
83 = AliMpDEManager::GetDetElement(GetDEId(i));
84
85 for ( Int_t j=0; j<detElement->GetNofBusPatches(); j++ )
86 fBusPatchIds.Add(detElement->GetBusPatchId(j));
87 }
88}
89
90//
91// public methods
92//
93
94//______________________________________________________________________________
95Bool_t AliMpDDL::AddDE(Int_t detElemId)
96{
97/// Add detection element with given detElemId.
98/// Return true if the detection element was added
99
100 if ( ! AliMpDEManager::IsValidDetElemId(detElemId) ) return false;
101
102 if ( HasDEId(detElemId) ) {
103 AliWarningStream()
104 << "Detection element Id = " << detElemId << " already present."
105 << endl;
106 return false;
107 }
108
109 AliDebugStream(3) << "Adding detElemId " << detElemId << endl;
110
111 fDEIds.Add(detElemId);
112 return true;
113}
114
115//______________________________________________________________________________
11b2fd04 116Bool_t AliMpDDL::AddTriggerCrate(Int_t crateId)
117{
118/// Add trigger crate with given crateId.
119/// Return true if the trigger crate was added
120
121 if ( HasTriggerCrateId(crateId) ) {
122 AliWarningStream()
123 << "Trigger crate Id = " << crateId << " already present."
124 << endl;
125 return false;
126 }
127
128 fTriggerCrateIds.Add(crateId);
129
130 return true;
131}
132
133//______________________________________________________________________________
59754717 134Bool_t AliMpDDL::AddFrt(Int_t frtId)
135{
136/// Add FRT with given frtId.
137/// Return true if the FRT was added
138
139 if ( HasFrtId(frtId) ) {
140 AliWarningStream()
141 << "FRT Id = " << frtId << " already present."
142 << endl;
143 return false;
144 }
145
146 fFrtIds.Add(frtId);
147
148 return true;
149}
150
151
152//______________________________________________________________________________
f0c62051 153Int_t AliMpDDL::GetNofDEs() const
154{
155/// Return the number of detection elements connected to this DDL
156
157 return fDEIds.GetSize();
158}
159
160//______________________________________________________________________________
161Int_t AliMpDDL::GetDEId(Int_t index) const
162{
163/// Return the detection element by index (in loop)
164
165 return fDEIds.GetValue(index);
166}
167
168//______________________________________________________________________________
169Bool_t AliMpDDL::HasDEId(Int_t detElemId) const
170{
171/// Return true if the detection element Id is present
172
173 return fDEIds.HasValue(detElemId);;
174}
175
176//______________________________________________________________________________
59754717 177Int_t AliMpDDL::GetNofFrts() const
178{
179/// Return the number of FRT connected to this DDL
180
181 return fFrtIds.GetSize();
182}
183
184//______________________________________________________________________________
185Int_t AliMpDDL::GetFrtId(Int_t index) const
186{
187/// Return the FRT by index (in loop)
188
189 return fFrtIds.GetValue(index);
190}
191
192//______________________________________________________________________________
193Bool_t AliMpDDL::HasFrtId(Int_t frtId) const
194{
195/// Return true if the FRT Id is present
196
197 return fFrtIds.HasValue(frtId);;
198}
199
200
201//______________________________________________________________________________
f0c62051 202Int_t AliMpDDL::GetNofBusPatches() const
203{
204/// Return the number of detection elements connected to this DDL
205
206 return fBusPatchIds.GetSize();
207}
208
209//______________________________________________________________________________
210Int_t AliMpDDL::GetBusPatchId(Int_t index) const
211{
212/// Return the detection element by index (in loop)
213
214 return fBusPatchIds.GetValue(index);
215}
216
217//______________________________________________________________________________
218Bool_t AliMpDDL::HasBusPatchId(Int_t busPatchId) const
219{
220/// Return true if the detection element Id is present
221
222 return fBusPatchIds.HasValue(busPatchId);;
223}
224
11b2fd04 225//______________________________________________________________________________
226Int_t AliMpDDL::GetNofTriggerCrates() const
227{
228/// Return the number of trigger crate connected to this DDL
229
230 return fTriggerCrateIds.GetSize();
231}
232
233//______________________________________________________________________________
234Int_t AliMpDDL::GetTriggerCrateId(Int_t index) const
235{
236/// Return the trigger crate by index (in loop)
237
238 return fTriggerCrateIds.GetValue(index);
239}
240
241//______________________________________________________________________________
242Bool_t AliMpDDL::HasTriggerCrateId(Int_t triggerCrateId) const
243{
244/// Return true if the trigger crate Id is present
245
246 return fTriggerCrateIds.HasValue(triggerCrateId);
247}
248
f0c62051 249//____________________________________________________________________
250Int_t AliMpDDL::GetMaxDsp() const
251{
252/// calculates the number of DSP
253
254 Int_t iBusPerBlk = fBusPatchIds.GetSize()/2; //per block
255
256 Int_t iDspMax = iBusPerBlk/5; //number max of DSP per block
257 if (iBusPerBlk % 5 != 0)
258 iDspMax += 1;
259
260 return iDspMax;
261}
262
263//____________________________________________________________________
264void AliMpDDL::GetBusPerDsp(Int_t* iBusPerDSP)
265const
266{
267/// calculates buspatch per block
268
269 Int_t iBusPerBlk = fBusPatchIds.GetSize()/2; //per block
270
271 for (Int_t i = 0; i < GetMaxDsp(); i++) {
272 if ((iBusPerBlk -= 5) > 0)
273 iBusPerDSP[i] = 5;
274 else
275 iBusPerDSP[i] = iBusPerBlk + 5;
276 }
277}
278