1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // $MpId: AliMpBusPatch.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
19 //-----------------------------------------------------------------------------
20 // Class AliMpBusPatch
21 // --------------------
22 // The class defines the properties of BusPatch
23 // Author: Ivana Hrivnacova, IPN Orsay
24 //-----------------------------------------------------------------------------
26 #include "AliMpBusPatch.h"
29 #include "AliMpConstants.h"
30 #include "AliMpDEManager.h"
31 #include "AliMpSegmentation.h"
32 #include "AliMpSlat.h"
34 #include "AliMpMotifPosition.h"
38 #include <Riostream.h>
43 ClassImp(AliMpBusPatch)
46 const Int_t AliMpBusPatch::fgkOffset = 100;
51 //____________________________________________________________________
52 Int_t AliMpBusPatch::GetGlobalBusID(Int_t localID, Int_t ddlID)
54 /// return global bus id from local bus and ddl id
56 return ddlID*fgkOffset + localID;
59 //____________________________________________________________________
60 Int_t AliMpBusPatch::GetLocalBusID(Int_t globalID, Int_t ddlID)
62 /// return local bus id from local bus id
64 return globalID - ddlID*fgkOffset;
68 //______________________________________________________________________________
69 AliMpBusPatch::AliMpBusPatch(Int_t id, Int_t detElemId, Int_t ddlId)
75 fNofManusPerModule(false),
81 /// Standard constructor
84 //______________________________________________________________________________
85 AliMpBusPatch::AliMpBusPatch(TRootIOCtor* /*ioCtor*/)
91 fNofManusPerModule(false),
97 /// Root IO constructor
100 //______________________________________________________________________________
101 AliMpBusPatch::~AliMpBusPatch()
110 //______________________________________________________________________________
111 Bool_t AliMpBusPatch::AddManu(Int_t manuId)
113 /// Add detection element with given detElemId.
114 /// Return true if the detection element was added
116 if ( HasManu(manuId) ) {
118 << "Manu with manuId=" << manuId << " already present."
127 //______________________________________________________________________________
128 Bool_t AliMpBusPatch::SetNofManusPerModule(Int_t manuNumber)
130 /// Set the number of manus per patch module (PCB):
131 /// - for stations 1 all manus are connected to one PCB,
132 /// - for stations 2 there maximum two PCBs per buspatch,
133 /// - for slat stations there are maximum three PCBs per buspatch
135 if ( AliMpDEManager::GetStation12Type(fDEId) == AliMq::kStation1) {
137 // simply fill the number of manus, no bridge for station 1
139 fNofManusPerModule.Add(GetNofManus());
143 if ( AliMpDEManager::GetStation12Type(fDEId) == AliMq::kStation2) {
145 // there is max two patch modules per buspatch
147 fNofManusPerModule.Add(manuNumber);
148 if (manuNumber != GetNofManus())
149 fNofManusPerModule.Add(GetNofManus() - manuNumber);
154 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation345 ) {
156 const AliMpSlat* kSlat0
157 = AliMpSegmentation::Instance()->GetSlat(fDEId, AliMp::kCath0);
159 const AliMpSlat* kSlat1
160 = AliMpSegmentation::Instance()->GetSlat(fDEId, AliMp::kCath1);
164 Int_t manuPerPcb = 0;
167 Double_t length = 0.;
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);
175 if ( !motifPos0 && !motifPos1 ) {
176 // should never happen
178 << "Motif position for manuId = " << manuId << "not found" << endl;
184 x = motifPos0->GetPositionX();
185 length = kSlat0->GetPCB(0)->DX()*2.;
188 x = motifPos1->GetPositionX();
189 length = kSlat1->GetPCB(0)->DX()*2.;
192 iPcb = Int_t(x/length + AliMpConstants::LengthTolerance());
194 // check when going to next PCB
195 if ( iPcb == iPcbPrev )
197 else if ( iPcbPrev != -1 ) {
198 //vec.Set(vec.GetSize()+1);
199 //vec[vec.GetSize()-1] = manuPerPcb+1;
200 fNofManusPerModule.Add(manuPerPcb+1);
207 //vec.Set(vec.GetSize()+1);
208 //vec[vec.GetSize()-1] = manuPerPcb+1;
209 fNofManusPerModule.Add(manuPerPcb+1);
216 //______________________________________________________________________________
217 void AliMpBusPatch::RevertReadout()
219 /// Revert order of manus
224 //______________________________________________________________________________
225 void AliMpBusPatch::ResetReadout()
227 /// Revert order of manus
232 //______________________________________________________________________________
233 Int_t AliMpBusPatch::GetNofManus() const
235 /// Return the number of detection elements connected to this DDL
237 return fManus.GetSize();
240 //______________________________________________________________________________
241 Int_t AliMpBusPatch::GetManuId(Int_t index) const
243 /// Return the detection element by index (in loop)
245 return fManus.GetValue(index);
248 //______________________________________________________________________________
249 Bool_t AliMpBusPatch::HasManu(Int_t manuId) const
251 /// Return true if bus patch has manu with given manuId
253 return fManus.HasValue(manuId);
256 //______________________________________________________________________________
257 Int_t AliMpBusPatch::GetNofPatchModules() const
259 /// Return the number of patch modules (PCB) connected to this bus patch.
261 return fNofManusPerModule.GetSize();
264 //______________________________________________________________________________
266 AliMpBusPatch::GetFRTPosition() const
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));
273 //______________________________________________________________________________
274 Int_t AliMpBusPatch::GetNofManusPerModule(Int_t patchModule) const
276 /// Return the number of manus per patch module (PCB)
278 if ( patchModule < 0 || patchModule >= GetNofPatchModules() ) {
279 AliErrorStream() << "Invalid patch module number = " << patchModule << endl;
283 return fNofManusPerModule.GetValue(patchModule);
286 //______________________________________________________________________________
288 AliMpBusPatch::Print(Option_t* opt) const
292 cout << Form("BusPatch %04d DDL %d : %s <> %s / %s",
294 AliDAQ::DdlID("MUONTRK",fDdlId),
295 GetFRTPosition().Data(),
297 fTranslatorLabel.Data()) << endl;
302 if ( sopt.Contains("FULL") )
304 cout << Form("Nof of PCBs (i.e. patch modules) = %d",fNofManusPerModule.GetSize()) << endl;
306 for ( Int_t i = 0; i < fNofManusPerModule.GetSize(); ++i )
308 cout << Form("\t\t %d manus in patch module %d",fNofManusPerModule.GetValue(i),i) << endl;
311 if ( sopt.Contains("MANU") )
313 cout << "Manus of that buspatch=" << endl;
315 for ( Int_t i = 0; i < fManus.GetSize(); ++i )
317 cout << Form("%4d,",fManus.GetValue(i));
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