]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpDDL.cxx
In Print(): added an option to print area borders
[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 //-----------------------------------------------------------------------------
21 // Class AliMpDDL
22 // --------------------
23 // The class defines electronics properties of DDL
24 // Authors: Ivana Hrivnacova, IPN Orsay
25 //          Christian Finck, SUBATECH Nantes
26 //-----------------------------------------------------------------------------
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
38 ClassImp(AliMpDDL)
39 /// \endcond
40
41 //______________________________________________________________________________
42 AliMpDDL::AliMpDDL(Int_t id)
43   : TObject(),
44     fId(id),
45     fDEIds(),
46     fBusPatchIds(),
47     fTriggerCrateIds(false)
48
49 {
50 /// Standard constructor
51 }
52
53 //______________________________________________________________________________
54 AliMpDDL::AliMpDDL(TRootIOCtor* /*ioCtor*/)
55   : TObject(),
56     fId(0),
57     fDEIds(),
58     fBusPatchIds(),
59     fTriggerCrateIds()
60 {
61 /// Root IO constructor
62 }
63
64 //______________________________________________________________________________
65 AliMpDDL::~AliMpDDL()
66 {
67 /// Destructor
68 }
69
70 //
71 // private methods
72 //
73
74 //______________________________________________________________________________
75 void AliMpDDL::FillBusPatchIds()
76 {
77 /// Fill array with bus patch Ids
78
79   for ( Int_t i=0; i<GetNofDEs(); i++ ) {
80     AliMpDetElement* detElement 
81       = AliMpDEManager::GetDetElement(GetDEId(i));
82     
83     for ( Int_t j=0; j<detElement->GetNofBusPatches(); j++ )
84       fBusPatchIds.Add(detElement->GetBusPatchId(j));
85   }
86 }      
87
88 //
89 // public methods
90 //
91
92 //______________________________________________________________________________
93 Bool_t AliMpDDL::AddDE(Int_t detElemId)
94 {
95 /// Add detection element with given detElemId.
96 /// Return true if the detection element was added
97
98   if ( ! AliMpDEManager::IsValidDetElemId(detElemId) ) return false;
99  
100   if ( HasDEId(detElemId) ) {
101     AliWarningStream() 
102       << "Detection element Id = " << detElemId << " already present."
103       << endl;
104     return false;
105   }    
106
107   AliDebugStream(3) << "Adding detElemId " << detElemId << endl;
108
109   fDEIds.Add(detElemId);
110   return true;
111 }   
112
113 //______________________________________________________________________________
114 Bool_t AliMpDDL::AddTriggerCrate(Int_t crateId)
115 {
116 /// Add trigger crate with given crateId.
117 /// Return true if the trigger crate was added
118
119   if ( HasTriggerCrateId(crateId) ) {
120     AliWarningStream() 
121         << "Trigger crate Id = " << crateId << " already present."
122         << endl;
123     return false;
124   }    
125   
126   fTriggerCrateIds.Add(crateId);
127
128   return true;
129 }      
130
131 //______________________________________________________________________________
132 Int_t AliMpDDL::GetNofDEs() const
133 {  
134 /// Return the number of detection elements connected to this DDL
135
136   return fDEIds.GetSize(); 
137 }
138
139 //______________________________________________________________________________
140 Int_t  AliMpDDL::GetDEId(Int_t index) const
141 {  
142 /// Return the detection element by index (in loop)
143
144   return fDEIds.GetValue(index); 
145 }
146
147 //______________________________________________________________________________
148 Bool_t  AliMpDDL::HasDEId(Int_t detElemId) const
149 {  
150 /// Return true if the detection element Id is present
151
152   return fDEIds.HasValue(detElemId);; 
153 }
154
155 //______________________________________________________________________________
156 Int_t AliMpDDL::GetNofBusPatches() const
157 {  
158 /// Return the number of detection elements connected to this DDL
159
160   return fBusPatchIds.GetSize(); 
161 }
162
163 //______________________________________________________________________________
164 Int_t  AliMpDDL::GetBusPatchId(Int_t index) const
165 {  
166 /// Return the detection element by index (in loop)
167
168   return fBusPatchIds.GetValue(index); 
169 }
170
171 //______________________________________________________________________________
172 Bool_t  AliMpDDL::HasBusPatchId(Int_t busPatchId) const
173 {  
174 /// Return true if the detection element Id is present
175
176   return fBusPatchIds.HasValue(busPatchId);; 
177 }
178
179 //______________________________________________________________________________
180 Int_t AliMpDDL::GetNofTriggerCrates() const
181 {  
182 /// Return the number of trigger crate connected to this DDL
183
184   return fTriggerCrateIds.GetSize(); 
185 }
186
187 //______________________________________________________________________________
188 Int_t  AliMpDDL::GetTriggerCrateId(Int_t index) const
189 {  
190 /// Return the trigger crate by index (in loop)
191
192   return fTriggerCrateIds.GetValue(index); 
193 }
194
195 //______________________________________________________________________________
196 Bool_t  AliMpDDL::HasTriggerCrateId(Int_t triggerCrateId) const
197 {  
198 /// Return true if the trigger crate Id is present
199
200   return fTriggerCrateIds.HasValue(triggerCrateId);
201 }
202
203 //____________________________________________________________________
204 Int_t AliMpDDL::GetMaxDsp() const
205 {
206 /// calculates the number of DSP 
207
208   Int_t iBusPerBlk = fBusPatchIds.GetSize()/2; //per block
209
210   Int_t iDspMax =  iBusPerBlk/5; //number max of DSP per block
211   if (iBusPerBlk % 5 != 0)
212     iDspMax += 1;
213
214   return iDspMax;
215 }
216
217 //____________________________________________________________________
218 void AliMpDDL::GetBusPerDsp(Int_t* iBusPerDSP) 
219 const
220 {
221 /// calculates buspatch per block
222
223   Int_t iBusPerBlk = fBusPatchIds.GetSize()/2; //per block
224
225   for (Int_t i = 0; i < GetMaxDsp(); i++) {
226     if ((iBusPerBlk -= 5) > 0) 
227       iBusPerDSP[i] = 5;
228     else 
229       iBusPerDSP[i] = iBusPerBlk + 5;
230   }
231 }
232