]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpBusPatch.cxx
Compatibility with ROOT trunk
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpBusPatch.cxx
CommitLineData
1e738c3c 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$
b4daf0b2 17// $MpId: AliMpBusPatch.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
3d1463c8 18
19//-----------------------------------------------------------------------------
b4daf0b2 20// Class AliMpBusPatch
21// --------------------
22// The class defines the properties of BusPatch
23// Author: Ivana Hrivnacova, IPN Orsay
3d1463c8 24//-----------------------------------------------------------------------------
1e738c3c 25
26#include "AliMpBusPatch.h"
6a7424c4 27
28#include "AliDAQ.h"
f00f5bb0 29#include "AliMpConstants.h"
30#include "AliMpDEManager.h"
31#include "AliMpSegmentation.h"
f00f5bb0 32#include "AliMpSlat.h"
33#include "AliMpPCB.h"
34#include "AliMpMotifPosition.h"
b4daf0b2 35
1e738c3c 36#include "AliLog.h"
b4daf0b2 37
38#include <Riostream.h>
1e738c3c 39
b80faac0 40using std::cout;
41using std::endl;
13985652 42/// \cond CLASSIMP
1e738c3c 43ClassImp(AliMpBusPatch)
13985652 44/// \endcond
1e738c3c 45
d2892ef5 46const Int_t AliMpBusPatch::fgkOffset = 100;
b4daf0b2 47//
48// static methods
49//
d2892ef5 50
d2892ef5 51//____________________________________________________________________
52Int_t AliMpBusPatch::GetGlobalBusID(Int_t localID, Int_t ddlID)
53{
54 /// return global bus id from local bus and ddl id
55
56 return ddlID*fgkOffset + localID;
57
58}
59//____________________________________________________________________
60Int_t AliMpBusPatch::GetLocalBusID(Int_t globalID, Int_t ddlID)
61{
62 /// return local bus id from local bus id
1e738c3c 63
d2892ef5 64 return globalID - ddlID*fgkOffset;
65
66}
1e738c3c 67
b4daf0b2 68//______________________________________________________________________________
69AliMpBusPatch::AliMpBusPatch(Int_t id, Int_t detElemId, Int_t ddlId)
70 : TObject(),
71 fId(id),
72 fDEId(detElemId),
73 fDdlId(ddlId),
f00f5bb0 74 fManus(false),
bf4bf8d2 75 fNofManusPerModule(false),
59754717 76 fCableLength(-1),
77 fCableLabel(),
78 fTranslatorLabel(),
79 fFrtId(0)
1e738c3c 80{
b4daf0b2 81/// Standard constructor
1e738c3c 82}
83
b4daf0b2 84//______________________________________________________________________________
85AliMpBusPatch::AliMpBusPatch(TRootIOCtor* /*ioCtor*/)
86 : TObject(),
87 fId(),
88 fDEId(),
89 fDdlId(),
ae649dcb 90 fManus(false),
bf4bf8d2 91 fNofManusPerModule(false),
59754717 92 fCableLength(-1),
93 fCableLabel(),
94 fTranslatorLabel(),
95 fFrtId(0)
1e738c3c 96{
b4daf0b2 97/// Root IO constructor
1e738c3c 98}
1e738c3c 99
b4daf0b2 100//______________________________________________________________________________
101AliMpBusPatch::~AliMpBusPatch()
5826f1df 102{
b4daf0b2 103/// Destructor
5826f1df 104}
105
b4daf0b2 106//
107// public methods
108//
5826f1df 109
b4daf0b2 110//______________________________________________________________________________
111Bool_t AliMpBusPatch::AddManu(Int_t manuId)
5826f1df 112{
b4daf0b2 113/// Add detection element with given detElemId.
114/// Return true if the detection element was added
115
116 if ( HasManu(manuId) ) {
117 AliWarningStream()
118 << "Manu with manuId=" << manuId << " already present."
119 << endl;
120 return false;
121 }
122
123 fManus.Add(manuId);
124 return true;
125}
126
f00f5bb0 127//______________________________________________________________________________
bf4bf8d2 128Bool_t AliMpBusPatch::SetNofManusPerModule(Int_t manuNumber)
f00f5bb0 129{
130/// Set the number of manus per patch module (PCB):
bf4bf8d2 131/// - for stations 1 all manus are connected to one PCB,
132/// - for stations 2 there maximum two PCBs per buspatch,
f00f5bb0 133/// - for slat stations there are maximum three PCBs per buspatch
f00f5bb0 134
4e51cfd2 135 if ( AliMpDEManager::GetStation12Type(fDEId) == AliMq::kStation1) {
f00f5bb0 136
137 // simply fill the number of manus, no bridge for station 1
f00f5bb0 138
139 fNofManusPerModule.Add(GetNofManus());
140 return true;
141 }
142
4e51cfd2 143 if ( AliMpDEManager::GetStation12Type(fDEId) == AliMq::kStation2) {
bf4bf8d2 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
f00f5bb0 154 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation345 ) {
155
f3ed9a44 156 const AliMpSlat* kSlat0
157 = AliMpSegmentation::Instance()->GetSlat(fDEId, AliMp::kCath0);
f00f5bb0 158
f3ed9a44 159 const AliMpSlat* kSlat1
160 = AliMpSegmentation::Instance()->GetSlat(fDEId, AliMp::kCath1);
f00f5bb0 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);
f3ed9a44 172 AliMpMotifPosition* motifPos0 = kSlat0->FindMotifPosition(manuId);
173 AliMpMotifPosition* motifPos1 = kSlat1->FindMotifPosition(manuId);
f00f5bb0 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 ) {
6e97fbb8 184 x = motifPos0->GetPositionX();
f3ed9a44 185 length = kSlat0->GetPCB(0)->DX()*2.;
f00f5bb0 186 }
187 if ( motifPos1 ) {
6e97fbb8 188 x = motifPos1->GetPositionX();
f3ed9a44 189 length = kSlat1->GetPCB(0)->DX()*2.;
f00f5bb0 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;
9ece548f 211 }
212
213 return false;
f00f5bb0 214}
215
ae649dcb 216//______________________________________________________________________________
217void AliMpBusPatch::RevertReadout()
218{
219/// Revert order of manus
220
221 fManus.Revert();
222}
223
224//______________________________________________________________________________
225void AliMpBusPatch::ResetReadout()
226{
227/// Revert order of manus
228
229 fManus.Reset();
230}
231
b4daf0b2 232//______________________________________________________________________________
233Int_t AliMpBusPatch::GetNofManus() const
234{
235/// Return the number of detection elements connected to this DDL
236
237 return fManus.GetSize();
5826f1df 238}
239
b4daf0b2 240//______________________________________________________________________________
241Int_t AliMpBusPatch::GetManuId(Int_t index) const
242{
243/// Return the detection element by index (in loop)
528df1a6 244
b4daf0b2 245 return fManus.GetValue(index);
5826f1df 246}
247
b4daf0b2 248//______________________________________________________________________________
249Bool_t AliMpBusPatch::HasManu(Int_t manuId) const
250{
251/// Return true if bus patch has manu with given manuId
5826f1df 252
b4daf0b2 253 return fManus.HasValue(manuId);
5826f1df 254}
255
f00f5bb0 256//______________________________________________________________________________
257Int_t AliMpBusPatch::GetNofPatchModules() const
258{
259/// Return the number of patch modules (PCB) connected to this bus patch.
5826f1df 260
f00f5bb0 261 return fNofManusPerModule.GetSize();
262}
263
6a7424c4 264//______________________________________________________________________________
265TString
266AliMpBusPatch::GetFRTPosition() const
267{
268 /// Return CRXX-Y-Z where XX is the Crocus number, Y the FRT number
269 /// and Z the local bus patch number.
270 return Form("CR%2d-%d-%d",fDdlId,fFrtId+1,GetLocalBusID(fId,fDdlId));
271}
272
f00f5bb0 273//______________________________________________________________________________
274Int_t AliMpBusPatch::GetNofManusPerModule(Int_t patchModule) const
275{
276/// Return the number of manus per patch module (PCB)
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}
6a7424c4 285
286//______________________________________________________________________________
287void
288AliMpBusPatch::Print(Option_t* opt) const
289{
290 /// Printout
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}