AliRoot Core  edcc906 (edcc906)
AliMpBusPatch.cxx
Go to the documentation of this file.
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: AliMpBusPatch.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
18 
19 //-----------------------------------------------------------------------------
20 // Class AliMpBusPatch
21 // --------------------
22 // The class defines the properties of BusPatch
23 // Author: Ivana Hrivnacova, IPN Orsay
24 //-----------------------------------------------------------------------------
25 
26 #include "AliMpBusPatch.h"
27 
28 #include "AliDAQ.h"
29 #include "AliMpConstants.h"
30 #include "AliMpDEManager.h"
31 #include "AliMpSegmentation.h"
32 #include "AliMpSlat.h"
33 #include "AliMpPCB.h"
34 #include "AliMpMotifPosition.h"
35 
36 #include "AliLog.h"
37 
38 #include <Riostream.h>
39 
40 using std::cout;
41 using std::endl;
43 ClassImp(AliMpBusPatch)
45 
46 const Int_t AliMpBusPatch::fgkOffset = 100;
47 //
48 // static methods
49 //
50 
51 //____________________________________________________________________
52 Int_t AliMpBusPatch::GetGlobalBusID(Int_t localID, Int_t ddlID)
53 {
55 
56  return ddlID*fgkOffset + localID;
57 
58 }
59 //____________________________________________________________________
60 Int_t AliMpBusPatch::GetLocalBusID(Int_t globalID, Int_t ddlID)
61 {
63 
64  return globalID - ddlID*fgkOffset;
65 
66 }
67 
68 //______________________________________________________________________________
69 AliMpBusPatch::AliMpBusPatch(Int_t id, Int_t detElemId, Int_t ddlId)
70  : TObject(),
71  fId(id),
72  fDEId(detElemId),
73  fDdlId(ddlId),
74  fManus(false),
75  fNofManusPerModule(false),
76  fCableLength(-1),
77  fCableLabel(),
79  fFrtId(0)
80 {
82 }
83 
84 //______________________________________________________________________________
85 AliMpBusPatch::AliMpBusPatch(TRootIOCtor* /*ioCtor*/)
86  : TObject(),
87  fId(),
88  fDEId(),
89  fDdlId(),
90  fManus(false),
91  fNofManusPerModule(false),
92  fCableLength(-1),
93  fCableLabel(),
95  fFrtId(0)
96 {
98 }
99 
100 //______________________________________________________________________________
102 {
104 }
105 
106 //
107 // public methods
108 //
109 
110 //______________________________________________________________________________
111 Bool_t AliMpBusPatch::AddManu(Int_t manuId)
112 {
115 
116  if ( HasManu(manuId) ) {
118  << "Manu with manuId=" << manuId << " already present."
119  << endl;
120  return false;
121  }
122 
123  fManus.Add(manuId);
124  return true;
125 }
126 
127 //______________________________________________________________________________
128 Bool_t AliMpBusPatch::SetNofManusPerModule(Int_t manuNumber)
129 {
134 
136 
137  // simply fill the number of manus, no bridge for station 1
138 
140  return true;
141  }
142 
144 
145  // there is max two patch modules per buspatch
146 
147  fNofManusPerModule.Add(manuNumber);
148  if (manuNumber != GetNofManus())
149  fNofManusPerModule.Add(GetNofManus() - manuNumber);
150 
151  return true;
152  }
153 
155 
156  const AliMpSlat* kSlat0
158 
159  const AliMpSlat* kSlat1
161 
162  Int_t iPcb = 0;
163  Int_t iPcbPrev = -1;
164  Int_t manuPerPcb = 0;
165 
166  Double_t x = 0.;
167  Double_t length = 0.;
168 
169  // Loop over manu
170  for (Int_t iManu = 0; iManu < GetNofManus(); ++iManu) {
171  Int_t manuId = GetManuId(iManu);
172  AliMpMotifPosition* motifPos0 = kSlat0->FindMotifPosition(manuId);
173  AliMpMotifPosition* motifPos1 = kSlat1->FindMotifPosition(manuId);
174 
175  if ( !motifPos0 && !motifPos1 ) {
176  // should never happen
177  AliErrorStream()
178  << "Motif position for manuId = " << manuId << "not found" << endl;
179  return false;
180  }
181 
182  // find PCB id
183  if ( motifPos0 ) {
184  x = motifPos0->GetPositionX();
185  length = kSlat0->GetPCB(0)->DX()*2.;
186  }
187  if ( motifPos1 ) {
188  x = motifPos1->GetPositionX();
189  length = kSlat1->GetPCB(0)->DX()*2.;
190  }
191 
192  iPcb = Int_t(x/length + AliMpConstants::LengthTolerance());
193 
194  // check when going to next PCB
195  if ( iPcb == iPcbPrev )
196  manuPerPcb++;
197  else if ( iPcbPrev != -1 ) {
198  //vec.Set(vec.GetSize()+1);
199  //vec[vec.GetSize()-1] = manuPerPcb+1;
200  fNofManusPerModule.Add(manuPerPcb+1);
201  manuPerPcb = 0;
202  }
203  iPcbPrev = iPcb;
204  }
205 
206  // store last PCB
207  //vec.Set(vec.GetSize()+1);
208  //vec[vec.GetSize()-1] = manuPerPcb+1;
209  fNofManusPerModule.Add(manuPerPcb+1);
210  return true;
211  }
212 
213  return false;
214 }
215 
216 //______________________________________________________________________________
218 {
220 
221  fManus.Revert();
222 }
223 
224 //______________________________________________________________________________
226 {
228 
229  fManus.Reset();
230 }
231 
232 //______________________________________________________________________________
234 {
236 
237  return fManus.GetSize();
238 }
239 
240 //______________________________________________________________________________
241 Int_t AliMpBusPatch::GetManuId(Int_t index) const
242 {
244 
245  return fManus.GetValue(index);
246 }
247 
248 //______________________________________________________________________________
249 Bool_t AliMpBusPatch::HasManu(Int_t manuId) const
250 {
252 
253  return fManus.HasValue(manuId);
254 }
255 
256 //______________________________________________________________________________
258 {
260 
261  return fNofManusPerModule.GetSize();
262 }
263 
264 //______________________________________________________________________________
265 TString
267 {
270  return Form("CR%2d-%d-%d",fDdlId,fFrtId+1,GetLocalBusID(fId,fDdlId));
271 }
272 
273 //______________________________________________________________________________
274 Int_t AliMpBusPatch::GetNofManusPerModule(Int_t patchModule) const
275 {
277 
278  if ( patchModule < 0 || patchModule >= GetNofPatchModules() ) {
279  AliErrorStream() << "Invalid patch module number = " << patchModule << endl;
280  return 0;
281  }
282 
283  return fNofManusPerModule.GetValue(patchModule);
284 }
285 
286 //______________________________________________________________________________
287 void
288 AliMpBusPatch::Print(Option_t* opt) const
289 {
291 
292  cout << Form("BusPatch %04d DDL %d : %s <> %s / %s",
293  fId,
294  AliDAQ::DdlID("MUONTRK",fDdlId),
295  GetFRTPosition().Data(),
296  fCableLabel.Data(),
297  fTranslatorLabel.Data()) << endl;
298 
299  TString sopt(opt);
300  sopt.ToUpper();
301 
302  if ( sopt.Contains("FULL") )
303  {
304  cout << Form("Nof of PCBs (i.e. patch modules) = %d",fNofManusPerModule.GetSize()) << endl;
305 
306  for ( Int_t i = 0; i < fNofManusPerModule.GetSize(); ++i )
307  {
308  cout << Form("\t\t %d manus in patch module %d",fNofManusPerModule.GetValue(i),i) << endl;
309  }
310 
311  if ( sopt.Contains("MANU") )
312  {
313  cout << "Manus of that buspatch=" << endl;
314 
315  for ( Int_t i = 0; i < fManus.GetSize(); ++i )
316  {
317  cout << Form("%4d,",fManus.GetValue(i));
318  }
319  cout << endl;
320  }
321  }
322 
323 // Int_t fId; ///< Identifier (unique)
324 // Int_t fDEId; ///< Detection element to which this bus patch is connected
325 // Int_t fDdlId; ///< DDL to which this bus patch is connected
326 // AliMpArrayI fManus; ///< Manu Ids connected to this bus patch
327 // AliMpArrayI fNofManusPerModule; ///< Nof Manus per patch modules (PCBs)
328 // Float_t fCableLength; ///< length of the buspatch cable
329 // TString fCableLabel; ///< label of the buspatch cable
330 // TString fTranslatorLabel; ///< label of the translator board
331 // Int_t fFrtId; ///< FRT Ids connected to this bus patch
332 
333 }
Int_t GetNofManus() const
static AliMq::Station12Type GetStation12Type(Int_t detElemId)
Double_t DX() const
Definition: AliMpPCB.cxx:454
virtual ~AliMpBusPatch()
#define AliErrorStream()
Definition: AliLog.h:630
Int_t GetSize() const
static AliMpSegmentation * Instance(Bool_t warn=true)
Int_t GetNofManusPerModule(Int_t patchModule) const
Bool_t HasManu(Int_t manuId) const
const AliMpSlat * GetSlat(const AliMpVSegmentation *kSegmentation, Bool_t warn=true) const
Float_t fCableLength
length of the buspatch cable
Definition: AliMpBusPatch.h:78
station 3,4,5 (slats)
Bool_t HasValue(Int_t value) const
Int_t fId
Identifier (unique)
Definition: AliMpBusPatch.h:73
static const Int_t fgkOffset
Offset for conversion global/local ID.
Definition: AliMpBusPatch.h:70
Int_t fDdlId
DDL to which this bus patch is connected.
Definition: AliMpBusPatch.h:75
Bool_t Add(Int_t value, Bool_t warn=kTRUE)
Definition: AliMpArrayI.cxx:97
Int_t GetManuId(Int_t index) const
A slat (building block of stations 3, 4 and 5)
Definition: AliMpSlat.h:51
Int_t fDEId
Detection element to which this bus patch is connected.
Definition: AliMpBusPatch.h:74
AliMpMotifPosition * FindMotifPosition(Double_t x, Double_t y) const
Returns the MotifPosition containing location (x,y).
Definition: AliMpSlat.cxx:210
static Double_t LengthTolerance()
Return the length precision for tests.
A placed motif.
TString fCableLabel
label of the buspatch cable
Definition: AliMpBusPatch.h:79
AliMpArrayI fManus
Manu Ids connected to this bus patch.
Definition: AliMpBusPatch.h:76
AliMpPCB * GetPCB(Int_t i) const
Returns the i-th PCB of this slat.
Definition: AliMpSlat.cxx:435
Bool_t Revert()
Bool_t SetNofManusPerModule(Int_t manuNumber=0)
Int_t fFrtId
FRT Ids connected to this bus patch.
Definition: AliMpBusPatch.h:81
static AliMp::StationType GetStationType(Int_t detElemId)
TString fTranslatorLabel
label of the translator board
Definition: AliMpBusPatch.h:80
Int_t GetNofPatchModules() const
static Int_t GetLocalBusID(Int_t globalID, Int_t ddlID)
The class defines the properties of BusPatch.
Definition: AliMpBusPatch.h:21
AliMpBusPatch()
Not implemented.
#define AliWarningStream()
Definition: AliLog.h:581
Double_t GetPositionX() const
Return x position.
Int_t GetValue(Int_t index) const
AliMpArrayI fNofManusPerModule
Nof Manus per patch modules (PCBs)
Definition: AliMpBusPatch.h:77
Bool_t AddManu(Int_t manuId)
TString GetFRTPosition() const
static Int_t DdlID(const char *detectorName, Int_t ddlIndex)
Definition: AliDAQ.cxx:298
virtual void Print(Option_t *opt="") const