]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpBusPatch.cxx
Fix for the problem during PbPb run of Nov 2010 (Indra)
[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
13985652 40/// \cond CLASSIMP
1e738c3c 41ClassImp(AliMpBusPatch)
13985652 42/// \endcond
1e738c3c 43
d2892ef5 44const Int_t AliMpBusPatch::fgkOffset = 100;
b4daf0b2 45//
46// static methods
47//
d2892ef5 48
d2892ef5 49//____________________________________________________________________
50Int_t AliMpBusPatch::GetGlobalBusID(Int_t localID, Int_t ddlID)
51{
52 /// return global bus id from local bus and ddl id
53
54 return ddlID*fgkOffset + localID;
55
56}
57//____________________________________________________________________
58Int_t AliMpBusPatch::GetLocalBusID(Int_t globalID, Int_t ddlID)
59{
60 /// return local bus id from local bus id
1e738c3c 61
d2892ef5 62 return globalID - ddlID*fgkOffset;
63
64}
1e738c3c 65
b4daf0b2 66//______________________________________________________________________________
67AliMpBusPatch::AliMpBusPatch(Int_t id, Int_t detElemId, Int_t ddlId)
68 : TObject(),
69 fId(id),
70 fDEId(detElemId),
71 fDdlId(ddlId),
f00f5bb0 72 fManus(false),
bf4bf8d2 73 fNofManusPerModule(false),
59754717 74 fCableLength(-1),
75 fCableLabel(),
76 fTranslatorLabel(),
77 fFrtId(0)
1e738c3c 78{
b4daf0b2 79/// Standard constructor
1e738c3c 80}
81
b4daf0b2 82//______________________________________________________________________________
83AliMpBusPatch::AliMpBusPatch(TRootIOCtor* /*ioCtor*/)
84 : TObject(),
85 fId(),
86 fDEId(),
87 fDdlId(),
ae649dcb 88 fManus(false),
bf4bf8d2 89 fNofManusPerModule(false),
59754717 90 fCableLength(-1),
91 fCableLabel(),
92 fTranslatorLabel(),
93 fFrtId(0)
1e738c3c 94{
b4daf0b2 95/// Root IO constructor
1e738c3c 96}
1e738c3c 97
b4daf0b2 98//______________________________________________________________________________
99AliMpBusPatch::~AliMpBusPatch()
5826f1df 100{
b4daf0b2 101/// Destructor
5826f1df 102}
103
b4daf0b2 104//
105// public methods
106//
5826f1df 107
b4daf0b2 108//______________________________________________________________________________
109Bool_t AliMpBusPatch::AddManu(Int_t manuId)
5826f1df 110{
b4daf0b2 111/// Add detection element with given detElemId.
112/// Return true if the detection element was added
113
114 if ( HasManu(manuId) ) {
115 AliWarningStream()
116 << "Manu with manuId=" << manuId << " already present."
117 << endl;
118 return false;
119 }
120
121 fManus.Add(manuId);
122 return true;
123}
124
f00f5bb0 125//______________________________________________________________________________
bf4bf8d2 126Bool_t AliMpBusPatch::SetNofManusPerModule(Int_t manuNumber)
f00f5bb0 127{
128/// Set the number of manus per patch module (PCB):
bf4bf8d2 129/// - for stations 1 all manus are connected to one PCB,
130/// - for stations 2 there maximum two PCBs per buspatch,
f00f5bb0 131/// - for slat stations there are maximum three PCBs per buspatch
f00f5bb0 132
4e51cfd2 133 if ( AliMpDEManager::GetStation12Type(fDEId) == AliMq::kStation1) {
f00f5bb0 134
135 // simply fill the number of manus, no bridge for station 1
f00f5bb0 136
137 fNofManusPerModule.Add(GetNofManus());
138 return true;
139 }
140
4e51cfd2 141 if ( AliMpDEManager::GetStation12Type(fDEId) == AliMq::kStation2) {
bf4bf8d2 142
143 // there is max two patch modules per buspatch
144
145 fNofManusPerModule.Add(manuNumber);
146 if (manuNumber != GetNofManus())
147 fNofManusPerModule.Add(GetNofManus() - manuNumber);
148
149 return true;
150 }
151
f00f5bb0 152 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation345 ) {
153
f3ed9a44 154 const AliMpSlat* kSlat0
155 = AliMpSegmentation::Instance()->GetSlat(fDEId, AliMp::kCath0);
f00f5bb0 156
f3ed9a44 157 const AliMpSlat* kSlat1
158 = AliMpSegmentation::Instance()->GetSlat(fDEId, AliMp::kCath1);
f00f5bb0 159
160 Int_t iPcb = 0;
161 Int_t iPcbPrev = -1;
162 Int_t manuPerPcb = 0;
163
164 Double_t x = 0.;
165 Double_t length = 0.;
166
167 // Loop over manu
168 for (Int_t iManu = 0; iManu < GetNofManus(); ++iManu) {
169 Int_t manuId = GetManuId(iManu);
f3ed9a44 170 AliMpMotifPosition* motifPos0 = kSlat0->FindMotifPosition(manuId);
171 AliMpMotifPosition* motifPos1 = kSlat1->FindMotifPosition(manuId);
f00f5bb0 172
173 if ( !motifPos0 && !motifPos1 ) {
174 // should never happen
175 AliErrorStream()
176 << "Motif position for manuId = " << manuId << "not found" << endl;
177 return false;
178 }
179
180 // find PCB id
181 if ( motifPos0 ) {
6e97fbb8 182 x = motifPos0->GetPositionX();
f3ed9a44 183 length = kSlat0->GetPCB(0)->DX()*2.;
f00f5bb0 184 }
185 if ( motifPos1 ) {
6e97fbb8 186 x = motifPos1->GetPositionX();
f3ed9a44 187 length = kSlat1->GetPCB(0)->DX()*2.;
f00f5bb0 188 }
189
190 iPcb = Int_t(x/length + AliMpConstants::LengthTolerance());
191
192 // check when going to next PCB
193 if ( iPcb == iPcbPrev )
194 manuPerPcb++;
195 else if ( iPcbPrev != -1 ) {
196 //vec.Set(vec.GetSize()+1);
197 //vec[vec.GetSize()-1] = manuPerPcb+1;
198 fNofManusPerModule.Add(manuPerPcb+1);
199 manuPerPcb = 0;
200 }
201 iPcbPrev = iPcb;
202 }
203
204 // store last PCB
205 //vec.Set(vec.GetSize()+1);
206 //vec[vec.GetSize()-1] = manuPerPcb+1;
207 fNofManusPerModule.Add(manuPerPcb+1);
208 return true;
9ece548f 209 }
210
211 return false;
f00f5bb0 212}
213
ae649dcb 214//______________________________________________________________________________
215void AliMpBusPatch::RevertReadout()
216{
217/// Revert order of manus
218
219 fManus.Revert();
220}
221
222//______________________________________________________________________________
223void AliMpBusPatch::ResetReadout()
224{
225/// Revert order of manus
226
227 fManus.Reset();
228}
229
b4daf0b2 230//______________________________________________________________________________
231Int_t AliMpBusPatch::GetNofManus() const
232{
233/// Return the number of detection elements connected to this DDL
234
235 return fManus.GetSize();
5826f1df 236}
237
b4daf0b2 238//______________________________________________________________________________
239Int_t AliMpBusPatch::GetManuId(Int_t index) const
240{
241/// Return the detection element by index (in loop)
528df1a6 242
b4daf0b2 243 return fManus.GetValue(index);
5826f1df 244}
245
b4daf0b2 246//______________________________________________________________________________
247Bool_t AliMpBusPatch::HasManu(Int_t manuId) const
248{
249/// Return true if bus patch has manu with given manuId
5826f1df 250
b4daf0b2 251 return fManus.HasValue(manuId);
5826f1df 252}
253
f00f5bb0 254//______________________________________________________________________________
255Int_t AliMpBusPatch::GetNofPatchModules() const
256{
257/// Return the number of patch modules (PCB) connected to this bus patch.
5826f1df 258
f00f5bb0 259 return fNofManusPerModule.GetSize();
260}
261
6a7424c4 262//______________________________________________________________________________
263TString
264AliMpBusPatch::GetFRTPosition() const
265{
266 /// Return CRXX-Y-Z where XX is the Crocus number, Y the FRT number
267 /// and Z the local bus patch number.
268 return Form("CR%2d-%d-%d",fDdlId,fFrtId+1,GetLocalBusID(fId,fDdlId));
269}
270
f00f5bb0 271//______________________________________________________________________________
272Int_t AliMpBusPatch::GetNofManusPerModule(Int_t patchModule) const
273{
274/// Return the number of manus per patch module (PCB)
275
276 if ( patchModule < 0 || patchModule >= GetNofPatchModules() ) {
277 AliErrorStream() << "Invalid patch module number = " << patchModule << endl;
278 return 0;
279 }
280
281 return fNofManusPerModule.GetValue(patchModule);
282}
6a7424c4 283
284//______________________________________________________________________________
285void
286AliMpBusPatch::Print(Option_t* opt) const
287{
288 /// Printout
289
290 cout << Form("BusPatch %04d DDL %d : %s <> %s / %s",
291 fId,
292 AliDAQ::DdlID("MUONTRK",fDdlId),
293 GetFRTPosition().Data(),
294 fCableLabel.Data(),
295 fTranslatorLabel.Data()) << endl;
296
297 TString sopt(opt);
298 sopt.ToUpper();
299
300 if ( sopt.Contains("FULL") )
301 {
302 cout << Form("Nof of PCBs (i.e. patch modules) = %d",fNofManusPerModule.GetSize()) << endl;
303
304 for ( Int_t i = 0; i < fNofManusPerModule.GetSize(); ++i )
305 {
306 cout << Form("\t\t %d manus in patch module %d",fNofManusPerModule.GetValue(i),i) << endl;
307 }
308
309 if ( sopt.Contains("MANU") )
310 {
311 cout << "Manus of that buspatch=" << endl;
312
313 for ( Int_t i = 0; i < fManus.GetSize(); ++i )
314 {
315 cout << Form("%4d,",fManus.GetValue(i));
316 }
317 cout << endl;
318 }
319 }
320
321// Int_t fId; ///< Identifier (unique)
322// Int_t fDEId; ///< Detection element to which this bus patch is connected
323// Int_t fDdlId; ///< DDL to which this bus patch is connected
324// AliMpArrayI fManus; ///< Manu Ids connected to this bus patch
325// AliMpArrayI fNofManusPerModule; ///< Nof Manus per patch modules (PCBs)
326// Float_t fCableLength; ///< length of the buspatch cable
327// TString fCableLabel; ///< label of the buspatch cable
328// TString fTranslatorLabel; ///< label of the translator board
329// Int_t fFrtId; ///< FRT Ids connected to this bus patch
330
331}