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 "AliMpSlatSegmentation.h"
33 #include "AliMpSlat.h"
35 #include "AliMpMotifPosition.h"
39 #include <Riostream.h>
42 ClassImp(AliMpBusPatch)
45 const Int_t AliMpBusPatch::fgkOffset = 100;
50 //____________________________________________________________________
51 Int_t AliMpBusPatch::GetGlobalBusID(Int_t localID, Int_t ddlID)
53 /// return global bus id from local bus and ddl id
55 return ddlID*fgkOffset + localID;
58 //____________________________________________________________________
59 Int_t AliMpBusPatch::GetLocalBusID(Int_t globalID, Int_t ddlID)
61 /// return local bus id from local bus id
63 return globalID - ddlID*fgkOffset;
67 //______________________________________________________________________________
68 AliMpBusPatch::AliMpBusPatch(Int_t id, Int_t detElemId, Int_t ddlId)
74 fNofManusPerModule(false),
80 /// Standard constructor
83 //______________________________________________________________________________
84 AliMpBusPatch::AliMpBusPatch(TRootIOCtor* /*ioCtor*/)
90 fNofManusPerModule(false),
96 /// Root IO constructor
99 //______________________________________________________________________________
100 AliMpBusPatch::~AliMpBusPatch()
109 //______________________________________________________________________________
110 Bool_t AliMpBusPatch::AddManu(Int_t manuId)
112 /// Add detection element with given detElemId.
113 /// Return true if the detection element was added
115 if ( HasManu(manuId) ) {
117 << "Manu with manuId=" << manuId << " already present."
126 //______________________________________________________________________________
127 Bool_t AliMpBusPatch::SetNofManusPerModule(Int_t manuNumber)
129 /// Set the number of manus per patch module (PCB):
130 /// - for stations 1 all manus are connected to one PCB,
131 /// - for stations 2 there maximum two PCBs per buspatch,
132 /// - for slat stations there are maximum three PCBs per buspatch
134 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation1) {
136 // simply fill the number of manus, no bridge for station 1
138 fNofManusPerModule.Add(GetNofManus());
142 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation2) {
144 // there is max two patch modules per buspatch
146 fNofManusPerModule.Add(manuNumber);
147 if (manuNumber != GetNofManus())
148 fNofManusPerModule.Add(GetNofManus() - manuNumber);
153 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation345 ) {
155 const AliMpSlatSegmentation* seg0
156 = static_cast<const AliMpSlatSegmentation*>(
157 AliMpSegmentation::Instance()->GetMpSegmentation(fDEId, AliMp::kCath0));
159 const AliMpSlatSegmentation* seg1
160 = static_cast<const AliMpSlatSegmentation*>(
161 AliMpSegmentation::Instance()->GetMpSegmentation(fDEId, AliMp::kCath1));
163 const AliMpSlat* slat0 = seg0->Slat();
164 const AliMpSlat* slat1 = seg1->Slat();
169 Int_t manuPerPcb = 0;
172 Double_t length = 0.;
175 for (Int_t iManu = 0; iManu < GetNofManus(); ++iManu) {
176 Int_t manuId = GetManuId(iManu);
177 AliMpMotifPosition* motifPos0 = slat0->FindMotifPosition(manuId);
178 AliMpMotifPosition* motifPos1 = slat1->FindMotifPosition(manuId);
180 if ( !motifPos0 && !motifPos1 ) {
181 // should never happen
183 << "Motif position for manuId = " << manuId << "not found" << endl;
189 x = motifPos0->Position().X();
190 length = slat0->GetPCB(0)->DX()*2.;
193 x = motifPos1->Position().X();
194 length = slat1->GetPCB(0)->DX()*2.;
197 iPcb = Int_t(x/length + AliMpConstants::LengthTolerance());
199 // check when going to next PCB
200 if ( iPcb == iPcbPrev )
202 else if ( iPcbPrev != -1 ) {
203 //vec.Set(vec.GetSize()+1);
204 //vec[vec.GetSize()-1] = manuPerPcb+1;
205 fNofManusPerModule.Add(manuPerPcb+1);
212 //vec.Set(vec.GetSize()+1);
213 //vec[vec.GetSize()-1] = manuPerPcb+1;
214 fNofManusPerModule.Add(manuPerPcb+1);
221 //______________________________________________________________________________
222 void AliMpBusPatch::RevertReadout()
224 /// Revert order of manus
229 //______________________________________________________________________________
230 void AliMpBusPatch::ResetReadout()
232 /// Revert order of manus
237 //______________________________________________________________________________
238 Int_t AliMpBusPatch::GetNofManus() const
240 /// Return the number of detection elements connected to this DDL
242 return fManus.GetSize();
245 //______________________________________________________________________________
246 Int_t AliMpBusPatch::GetManuId(Int_t index) const
248 /// Return the detection element by index (in loop)
250 return fManus.GetValue(index);
253 //______________________________________________________________________________
254 Bool_t AliMpBusPatch::HasManu(Int_t manuId) const
256 /// Return true if bus patch has manu with given manuId
258 return fManus.HasValue(manuId);
261 //______________________________________________________________________________
262 Int_t AliMpBusPatch::GetNofPatchModules() const
264 /// Return the number of patch modules (PCB) connected to this bus patch.
266 return fNofManusPerModule.GetSize();
269 //______________________________________________________________________________
271 AliMpBusPatch::GetFRTPosition() const
273 /// Return CRXX-Y-Z where XX is the Crocus number, Y the FRT number
274 /// and Z the local bus patch number.
275 return Form("CR%2d-%d-%d",fDdlId,fFrtId+1,GetLocalBusID(fId,fDdlId));
278 //______________________________________________________________________________
279 Int_t AliMpBusPatch::GetNofManusPerModule(Int_t patchModule) const
281 /// Return the number of manus per patch module (PCB)
283 if ( patchModule < 0 || patchModule >= GetNofPatchModules() ) {
284 AliErrorStream() << "Invalid patch module number = " << patchModule << endl;
288 return fNofManusPerModule.GetValue(patchModule);
291 //______________________________________________________________________________
293 AliMpBusPatch::Print(Option_t* opt) const
297 cout << Form("BusPatch %04d DDL %d : %s <> %s / %s",
299 AliDAQ::DdlID("MUONTRK",fDdlId),
300 GetFRTPosition().Data(),
302 fTranslatorLabel.Data()) << endl;
307 if ( sopt.Contains("FULL") )
309 cout << Form("Nof of PCBs (i.e. patch modules) = %d",fNofManusPerModule.GetSize()) << endl;
311 for ( Int_t i = 0; i < fNofManusPerModule.GetSize(); ++i )
313 cout << Form("\t\t %d manus in patch module %d",fNofManusPerModule.GetValue(i),i) << endl;
316 if ( sopt.Contains("MANU") )
318 cout << "Manus of that buspatch=" << endl;
320 for ( Int_t i = 0; i < fManus.GetSize(); ++i )
322 cout << Form("%4d,",fManus.GetValue(i));
328 // Int_t fId; ///< Identifier (unique)
329 // Int_t fDEId; ///< Detection element to which this bus patch is connected
330 // Int_t fDdlId; ///< DDL to which this bus patch is connected
331 // AliMpArrayI fManus; ///< Manu Ids connected to this bus patch
332 // AliMpArrayI fNofManusPerModule; ///< Nof Manus per patch modules (PCBs)
333 // Float_t fCableLength; ///< length of the buspatch cable
334 // TString fCableLabel; ///< label of the buspatch cable
335 // TString fTranslatorLabel; ///< label of the translator board
336 // Int_t fFrtId; ///< FRT Ids connected to this bus patch