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
25 #include "AliMpBusPatch.h"
26 #include "AliMpConstants.h"
27 #include "AliMpDEManager.h"
28 #include "AliMpSegmentation.h"
29 #include "AliMpSlatSegmentation.h"
30 #include "AliMpSlat.h"
32 #include "AliMpMotifPosition.h"
36 #include <Riostream.h>
39 ClassImp(AliMpBusPatch)
42 const Int_t AliMpBusPatch::fgkOffset = 100;
47 //____________________________________________________________________
48 Int_t AliMpBusPatch::GetGlobalBusID(Int_t localID, Int_t ddlID)
50 /// return global bus id from local bus and ddl id
52 return ddlID*fgkOffset + localID;
55 //____________________________________________________________________
56 Int_t AliMpBusPatch::GetLocalBusID(Int_t globalID, Int_t ddlID)
58 /// return local bus id from local bus id
60 return globalID - ddlID*fgkOffset;
64 //______________________________________________________________________________
65 AliMpBusPatch::AliMpBusPatch(Int_t id, Int_t detElemId, Int_t ddlId)
71 fNofManusPerModule(false),
74 /// Standard constructor
77 //______________________________________________________________________________
78 AliMpBusPatch::AliMpBusPatch(TRootIOCtor* /*ioCtor*/)
84 fNofManusPerModule(false),
87 /// Root IO constructor
90 //______________________________________________________________________________
91 AliMpBusPatch::~AliMpBusPatch()
100 //______________________________________________________________________________
101 Bool_t AliMpBusPatch::AddManu(Int_t manuId)
103 /// Add detection element with given detElemId.
104 /// Return true if the detection element was added
106 if ( HasManu(manuId) ) {
108 << "Manu with manuId=" << manuId << " already present."
117 //______________________________________________________________________________
118 Bool_t AliMpBusPatch::SetNofManusPerModule(Int_t manuNumber)
120 /// Set the number of manus per patch module (PCB):
121 /// - for stations 1 all manus are connected to one PCB,
122 /// - for stations 2 there maximum two PCBs per buspatch,
123 /// - for slat stations there are maximum three PCBs per buspatch
125 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation1) {
127 // simply fill the number of manus, no bridge for station 1
129 fNofManusPerModule.Add(GetNofManus());
133 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation2) {
135 // there is max two patch modules per buspatch
137 fNofManusPerModule.Add(manuNumber);
138 if (manuNumber != GetNofManus())
139 fNofManusPerModule.Add(GetNofManus() - manuNumber);
144 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation345 ) {
146 const AliMpSlatSegmentation* seg0
147 = static_cast<const AliMpSlatSegmentation*>(
148 AliMpSegmentation::Instance()->GetMpSegmentation(fDEId, AliMp::kCath0));
150 const AliMpSlatSegmentation* seg1
151 = static_cast<const AliMpSlatSegmentation*>(
152 AliMpSegmentation::Instance()->GetMpSegmentation(fDEId, AliMp::kCath1));
154 const AliMpSlat* slat0 = seg0->Slat();
155 const AliMpSlat* slat1 = seg1->Slat();
160 Int_t manuPerPcb = 0;
163 Double_t length = 0.;
166 for (Int_t iManu = 0; iManu < GetNofManus(); ++iManu) {
167 Int_t manuId = GetManuId(iManu);
168 AliMpMotifPosition* motifPos0 = slat0->FindMotifPosition(manuId);
169 AliMpMotifPosition* motifPos1 = slat1->FindMotifPosition(manuId);
171 if ( !motifPos0 && !motifPos1 ) {
172 // should never happen
174 << "Motif position for manuId = " << manuId << "not found" << endl;
180 x = motifPos0->Position().X();
181 length = slat0->GetPCB(0)->DX()*2.;
184 x = motifPos1->Position().X();
185 length = slat1->GetPCB(0)->DX()*2.;
188 iPcb = Int_t(x/length + AliMpConstants::LengthTolerance());
190 // check when going to next PCB
191 if ( iPcb == iPcbPrev )
193 else if ( iPcbPrev != -1 ) {
194 //vec.Set(vec.GetSize()+1);
195 //vec[vec.GetSize()-1] = manuPerPcb+1;
196 fNofManusPerModule.Add(manuPerPcb+1);
203 //vec.Set(vec.GetSize()+1);
204 //vec[vec.GetSize()-1] = manuPerPcb+1;
205 fNofManusPerModule.Add(manuPerPcb+1);
212 //______________________________________________________________________________
213 Int_t AliMpBusPatch::GetNofManus() const
215 /// Return the number of detection elements connected to this DDL
217 return fManus.GetSize();
220 //______________________________________________________________________________
221 Int_t AliMpBusPatch::GetManuId(Int_t index) const
223 /// Return the detection element by index (in loop)
225 return fManus.GetValue(index);
228 //______________________________________________________________________________
229 Bool_t AliMpBusPatch::HasManu(Int_t manuId) const
231 /// Return true if bus patch has manu with given manuId
233 return fManus.HasValue(manuId);
236 //______________________________________________________________________________
237 Int_t AliMpBusPatch::GetNofPatchModules() const
239 /// Return the number of patch modules (PCB) connected to this bus patch.
241 return fNofManusPerModule.GetSize();
244 //______________________________________________________________________________
245 Int_t AliMpBusPatch::GetNofManusPerModule(Int_t patchModule) const
247 /// Return the number of manus per patch module (PCB)
249 if ( patchModule < 0 || patchModule >= GetNofPatchModules() ) {
250 AliErrorStream() << "Invalid patch module number = " << patchModule << endl;
254 return fNofManusPerModule.GetValue(patchModule);