]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpDDL.cxx
Adding new libraries
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpDDL.cxx
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
19 //
20 // Class AliMpDDL
21 // --------------------
22 // The class defines electronics properties of DDL
23 // Authors: Ivana Hrivnacova, IPN Orsay
24 //          Christian Finck, SUBATECH Nantes
25
26 #include "AliMpDDL.h"
27 #include "AliMpDEManager.h"
28 #include "AliMpDetElement.h"
29
30 #include "AliLog.h"
31
32 #include <Riostream.h>
33
34
35 /// \cond CLASSIMP
36 ClassImp(AliMpDDL)
37 /// \endcond
38
39 //______________________________________________________________________________
40 AliMpDDL::AliMpDDL(Int_t id)
41   : TObject(),
42     fId(id),
43     fDEIds(),
44     fBusPatchIds()
45 {
46 /// Standard constructor
47 }
48
49 //______________________________________________________________________________
50 AliMpDDL::AliMpDDL(TRootIOCtor* /*ioCtor*/)
51   : TObject(),
52     fId(0),
53     fDEIds(),
54     fBusPatchIds()
55 {
56 /// Root IO constructor
57 }
58
59 //______________________________________________________________________________
60 AliMpDDL::~AliMpDDL()
61 {
62 /// Destructor
63 }
64
65 //
66 // private methods
67 //
68
69 //______________________________________________________________________________
70 void AliMpDDL::FillBusPatchIds()
71 {
72 /// Fill array with bus patch Ids
73
74   for ( Int_t i=0; i<GetNofDEs(); i++ ) {
75     AliMpDetElement* detElement 
76       = AliMpDEManager::GetDetElement(GetDEId(i));
77     
78     for ( Int_t j=0; j<detElement->GetNofBusPatches(); j++ )
79       fBusPatchIds.Add(detElement->GetBusPatchId(j));
80   }
81 }      
82
83 //
84 // public methods
85 //
86
87 //______________________________________________________________________________
88 Bool_t AliMpDDL::AddDE(Int_t detElemId)
89 {
90 /// Add detection element with given detElemId.
91 /// Return true if the detection element was added
92
93   if ( ! AliMpDEManager::IsValidDetElemId(detElemId) ) return false;
94  
95   if ( HasDEId(detElemId) ) {
96     AliWarningStream() 
97       << "Detection element Id = " << detElemId << " already present."
98       << endl;
99     return false;
100   }    
101
102   AliDebugStream(3) << "Adding detElemId " << detElemId << endl;
103
104   fDEIds.Add(detElemId);
105   return true;
106 }   
107
108 //______________________________________________________________________________
109 Int_t AliMpDDL::GetNofDEs() const
110 {  
111 /// Return the number of detection elements connected to this DDL
112
113   return fDEIds.GetSize(); 
114 }
115
116 //______________________________________________________________________________
117 Int_t  AliMpDDL::GetDEId(Int_t index) const
118 {  
119 /// Return the detection element by index (in loop)
120
121   return fDEIds.GetValue(index); 
122 }
123
124 //______________________________________________________________________________
125 Bool_t  AliMpDDL::HasDEId(Int_t detElemId) const
126 {  
127 /// Return true if the detection element Id is present
128
129   return fDEIds.HasValue(detElemId);; 
130 }
131
132 //______________________________________________________________________________
133 Int_t AliMpDDL::GetNofBusPatches() const
134 {  
135 /// Return the number of detection elements connected to this DDL
136
137   return fBusPatchIds.GetSize(); 
138 }
139
140 //______________________________________________________________________________
141 Int_t  AliMpDDL::GetBusPatchId(Int_t index) const
142 {  
143 /// Return the detection element by index (in loop)
144
145   return fBusPatchIds.GetValue(index); 
146 }
147
148 //______________________________________________________________________________
149 Bool_t  AliMpDDL::HasBusPatchId(Int_t busPatchId) const
150 {  
151 /// Return true if the detection element Id is present
152
153   return fBusPatchIds.HasValue(busPatchId);; 
154 }
155
156 //____________________________________________________________________
157 Int_t AliMpDDL::GetMaxDsp() const
158 {
159 /// calculates the number of DSP 
160
161   Int_t iBusPerBlk = fBusPatchIds.GetSize()/2; //per block
162
163   Int_t iDspMax =  iBusPerBlk/5; //number max of DSP per block
164   if (iBusPerBlk % 5 != 0)
165     iDspMax += 1;
166
167   return iDspMax;
168 }
169
170 //____________________________________________________________________
171 void AliMpDDL::GetBusPerDsp(Int_t* iBusPerDSP) 
172 const
173 {
174 /// calculates buspatch per block
175
176   Int_t iBusPerBlk = fBusPatchIds.GetSize()/2; //per block
177
178   for (Int_t i = 0; i < GetMaxDsp(); i++) {
179     if ((iBusPerBlk -= 5) > 0) 
180       iBusPerDSP[i] = 5;
181     else 
182       iBusPerDSP[i] = iBusPerBlk + 5;
183   }
184 }
185