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"
27 #include "AliMpConstants.h"
28 #include "AliMpDEManager.h"
29 #include "AliMpSegmentation.h"
30 #include "AliMpSlatSegmentation.h"
31 #include "AliMpSlat.h"
33 #include "AliMpMotifPosition.h"
37 #include <Riostream.h>
40 ClassImp(AliMpBusPatch)
43 const Int_t AliMpBusPatch::fgkOffset = 100;
48 //____________________________________________________________________
49 Int_t AliMpBusPatch::GetGlobalBusID(Int_t localID, Int_t ddlID)
51 /// return global bus id from local bus and ddl id
53 return ddlID*fgkOffset + localID;
56 //____________________________________________________________________
57 Int_t AliMpBusPatch::GetLocalBusID(Int_t globalID, Int_t ddlID)
59 /// return local bus id from local bus id
61 return globalID - ddlID*fgkOffset;
65 //______________________________________________________________________________
66 AliMpBusPatch::AliMpBusPatch(Int_t id, Int_t detElemId, Int_t ddlId)
72 fNofManusPerModule(false),
75 /// Standard constructor
78 //______________________________________________________________________________
79 AliMpBusPatch::AliMpBusPatch(TRootIOCtor* /*ioCtor*/)
85 fNofManusPerModule(false),
88 /// Root IO constructor
91 //______________________________________________________________________________
92 AliMpBusPatch::~AliMpBusPatch()
101 //______________________________________________________________________________
102 Bool_t AliMpBusPatch::AddManu(Int_t manuId)
104 /// Add detection element with given detElemId.
105 /// Return true if the detection element was added
107 if ( HasManu(manuId) ) {
109 << "Manu with manuId=" << manuId << " already present."
118 //______________________________________________________________________________
119 Bool_t AliMpBusPatch::SetNofManusPerModule(Int_t manuNumber)
121 /// Set the number of manus per patch module (PCB):
122 /// - for stations 1 all manus are connected to one PCB,
123 /// - for stations 2 there maximum two PCBs per buspatch,
124 /// - for slat stations there are maximum three PCBs per buspatch
126 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation1) {
128 // simply fill the number of manus, no bridge for station 1
130 fNofManusPerModule.Add(GetNofManus());
134 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation2) {
136 // there is max two patch modules per buspatch
138 fNofManusPerModule.Add(manuNumber);
139 if (manuNumber != GetNofManus())
140 fNofManusPerModule.Add(GetNofManus() - manuNumber);
145 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation345 ) {
147 const AliMpSlatSegmentation* seg0
148 = static_cast<const AliMpSlatSegmentation*>(
149 AliMpSegmentation::Instance()->GetMpSegmentation(fDEId, AliMp::kCath0));
151 const AliMpSlatSegmentation* seg1
152 = static_cast<const AliMpSlatSegmentation*>(
153 AliMpSegmentation::Instance()->GetMpSegmentation(fDEId, AliMp::kCath1));
155 const AliMpSlat* slat0 = seg0->Slat();
156 const AliMpSlat* slat1 = seg1->Slat();
161 Int_t manuPerPcb = 0;
164 Double_t length = 0.;
167 for (Int_t iManu = 0; iManu < GetNofManus(); ++iManu) {
168 Int_t manuId = GetManuId(iManu);
169 AliMpMotifPosition* motifPos0 = slat0->FindMotifPosition(manuId);
170 AliMpMotifPosition* motifPos1 = slat1->FindMotifPosition(manuId);
172 if ( !motifPos0 && !motifPos1 ) {
173 // should never happen
175 << "Motif position for manuId = " << manuId << "not found" << endl;
181 x = motifPos0->Position().X();
182 length = slat0->GetPCB(0)->DX()*2.;
185 x = motifPos1->Position().X();
186 length = slat1->GetPCB(0)->DX()*2.;
189 iPcb = Int_t(x/length + AliMpConstants::LengthTolerance());
191 // check when going to next PCB
192 if ( iPcb == iPcbPrev )
194 else if ( iPcbPrev != -1 ) {
195 //vec.Set(vec.GetSize()+1);
196 //vec[vec.GetSize()-1] = manuPerPcb+1;
197 fNofManusPerModule.Add(manuPerPcb+1);
204 //vec.Set(vec.GetSize()+1);
205 //vec[vec.GetSize()-1] = manuPerPcb+1;
206 fNofManusPerModule.Add(manuPerPcb+1);
213 //______________________________________________________________________________
214 Int_t AliMpBusPatch::GetNofManus() const
216 /// Return the number of detection elements connected to this DDL
218 return fManus.GetSize();
221 //______________________________________________________________________________
222 Int_t AliMpBusPatch::GetManuId(Int_t index) const
224 /// Return the detection element by index (in loop)
226 return fManus.GetValue(index);
229 //______________________________________________________________________________
230 Bool_t AliMpBusPatch::HasManu(Int_t manuId) const
232 /// Return true if bus patch has manu with given manuId
234 return fManus.HasValue(manuId);
237 //______________________________________________________________________________
238 Int_t AliMpBusPatch::GetNofPatchModules() const
240 /// Return the number of patch modules (PCB) connected to this bus patch.
242 return fNofManusPerModule.GetSize();
245 //______________________________________________________________________________
246 Int_t AliMpBusPatch::GetNofManusPerModule(Int_t patchModule) const
248 /// Return the number of manus per patch module (PCB)
250 if ( patchModule < 0 || patchModule >= GetNofPatchModules() ) {
251 AliErrorStream() << "Invalid patch module number = " << patchModule << endl;
255 return fNofManusPerModule.GetValue(patchModule);