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