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>
41 ClassImp(AliMpBusPatch)
44 const Int_t AliMpBusPatch::fgkOffset = 100;
49 //____________________________________________________________________
50 Int_t AliMpBusPatch::GetGlobalBusID(Int_t localID, Int_t ddlID)
52 /// return global bus id from local bus and ddl id
54 return ddlID*fgkOffset + localID;
57 //____________________________________________________________________
58 Int_t AliMpBusPatch::GetLocalBusID(Int_t globalID, Int_t ddlID)
60 /// return local bus id from local bus id
62 return globalID - ddlID*fgkOffset;
66 //______________________________________________________________________________
67 AliMpBusPatch::AliMpBusPatch(Int_t id, Int_t detElemId, Int_t ddlId)
73 fNofManusPerModule(false),
79 /// Standard constructor
82 //______________________________________________________________________________
83 AliMpBusPatch::AliMpBusPatch(TRootIOCtor* /*ioCtor*/)
89 fNofManusPerModule(false),
95 /// Root IO constructor
98 //______________________________________________________________________________
99 AliMpBusPatch::~AliMpBusPatch()
108 //______________________________________________________________________________
109 Bool_t AliMpBusPatch::AddManu(Int_t manuId)
111 /// Add detection element with given detElemId.
112 /// Return true if the detection element was added
114 if ( HasManu(manuId) ) {
116 << "Manu with manuId=" << manuId << " already present."
125 //______________________________________________________________________________
126 Bool_t AliMpBusPatch::SetNofManusPerModule(Int_t manuNumber)
128 /// Set the number of manus per patch module (PCB):
129 /// - for stations 1 all manus are connected to one PCB,
130 /// - for stations 2 there maximum two PCBs per buspatch,
131 /// - for slat stations there are maximum three PCBs per buspatch
133 if ( AliMpDEManager::GetStation12Type(fDEId) == AliMq::kStation1) {
135 // simply fill the number of manus, no bridge for station 1
137 fNofManusPerModule.Add(GetNofManus());
141 if ( AliMpDEManager::GetStation12Type(fDEId) == AliMq::kStation2) {
143 // there is max two patch modules per buspatch
145 fNofManusPerModule.Add(manuNumber);
146 if (manuNumber != GetNofManus())
147 fNofManusPerModule.Add(GetNofManus() - manuNumber);
152 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation345 ) {
154 const AliMpSlat* kSlat0
155 = AliMpSegmentation::Instance()->GetSlat(fDEId, AliMp::kCath0);
157 const AliMpSlat* kSlat1
158 = AliMpSegmentation::Instance()->GetSlat(fDEId, AliMp::kCath1);
162 Int_t manuPerPcb = 0;
165 Double_t length = 0.;
168 for (Int_t iManu = 0; iManu < GetNofManus(); ++iManu) {
169 Int_t manuId = GetManuId(iManu);
170 AliMpMotifPosition* motifPos0 = kSlat0->FindMotifPosition(manuId);
171 AliMpMotifPosition* motifPos1 = kSlat1->FindMotifPosition(manuId);
173 if ( !motifPos0 && !motifPos1 ) {
174 // should never happen
176 << "Motif position for manuId = " << manuId << "not found" << endl;
182 x = motifPos0->Position().X();
183 length = kSlat0->GetPCB(0)->DX()*2.;
186 x = motifPos1->Position().X();
187 length = kSlat1->GetPCB(0)->DX()*2.;
190 iPcb = Int_t(x/length + AliMpConstants::LengthTolerance());
192 // check when going to next PCB
193 if ( iPcb == iPcbPrev )
195 else if ( iPcbPrev != -1 ) {
196 //vec.Set(vec.GetSize()+1);
197 //vec[vec.GetSize()-1] = manuPerPcb+1;
198 fNofManusPerModule.Add(manuPerPcb+1);
205 //vec.Set(vec.GetSize()+1);
206 //vec[vec.GetSize()-1] = manuPerPcb+1;
207 fNofManusPerModule.Add(manuPerPcb+1);
214 //______________________________________________________________________________
215 void AliMpBusPatch::RevertReadout()
217 /// Revert order of manus
222 //______________________________________________________________________________
223 void AliMpBusPatch::ResetReadout()
225 /// Revert order of manus
230 //______________________________________________________________________________
231 Int_t AliMpBusPatch::GetNofManus() const
233 /// Return the number of detection elements connected to this DDL
235 return fManus.GetSize();
238 //______________________________________________________________________________
239 Int_t AliMpBusPatch::GetManuId(Int_t index) const
241 /// Return the detection element by index (in loop)
243 return fManus.GetValue(index);
246 //______________________________________________________________________________
247 Bool_t AliMpBusPatch::HasManu(Int_t manuId) const
249 /// Return true if bus patch has manu with given manuId
251 return fManus.HasValue(manuId);
254 //______________________________________________________________________________
255 Int_t AliMpBusPatch::GetNofPatchModules() const
257 /// Return the number of patch modules (PCB) connected to this bus patch.
259 return fNofManusPerModule.GetSize();
262 //______________________________________________________________________________
264 AliMpBusPatch::GetFRTPosition() const
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));
271 //______________________________________________________________________________
272 Int_t AliMpBusPatch::GetNofManusPerModule(Int_t patchModule) const
274 /// Return the number of manus per patch module (PCB)
276 if ( patchModule < 0 || patchModule >= GetNofPatchModules() ) {
277 AliErrorStream() << "Invalid patch module number = " << patchModule << endl;
281 return fNofManusPerModule.GetValue(patchModule);
284 //______________________________________________________________________________
286 AliMpBusPatch::Print(Option_t* opt) const
290 cout << Form("BusPatch %04d DDL %d : %s <> %s / %s",
292 AliDAQ::DdlID("MUONTRK",fDdlId),
293 GetFRTPosition().Data(),
295 fTranslatorLabel.Data()) << endl;
300 if ( sopt.Contains("FULL") )
302 cout << Form("Nof of PCBs (i.e. patch modules) = %d",fNofManusPerModule.GetSize()) << endl;
304 for ( Int_t i = 0; i < fNofManusPerModule.GetSize(); ++i )
306 cout << Form("\t\t %d manus in patch module %d",fNofManusPerModule.GetValue(i),i) << endl;
309 if ( sopt.Contains("MANU") )
311 cout << "Manus of that buspatch=" << endl;
313 for ( Int_t i = 0; i < fManus.GetSize(); ++i )
315 cout << Form("%4d,",fManus.GetValue(i));
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