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)
73 /// Standard constructor
76 //______________________________________________________________________________
77 AliMpBusPatch::AliMpBusPatch(TRootIOCtor* /*ioCtor*/)
83 fNofManusPerModule(false)
85 /// Root IO constructor
88 //______________________________________________________________________________
89 AliMpBusPatch::~AliMpBusPatch()
98 //______________________________________________________________________________
99 Bool_t AliMpBusPatch::AddManu(Int_t manuId)
101 /// Add detection element with given detElemId.
102 /// Return true if the detection element was added
104 if ( HasManu(manuId) ) {
106 << "Manu with manuId=" << manuId << " already present."
115 //______________________________________________________________________________
116 Bool_t AliMpBusPatch::SetNofManusPerModule()
118 /// Set the number of manus per patch module (PCB):
119 /// - for stations 12 all manus are connected to one PCB,
120 /// - for slat stations there are maximum three PCBs per buspatch
121 /// Not correct for station 2
123 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation1 ||
124 AliMpDEManager::GetStationType(fDEId) == AliMp::kStation2 ) {
126 // simply fill the number of manus, no bridge for station 1
127 // not the case for station 2.
129 fNofManusPerModule.Add(GetNofManus());
133 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation345 ) {
135 const AliMpSlatSegmentation* seg0
136 = static_cast<const AliMpSlatSegmentation*>(
137 AliMpSegmentation::Instance()->GetMpSegmentation(fDEId, AliMp::kCath0));
139 const AliMpSlatSegmentation* seg1
140 = static_cast<const AliMpSlatSegmentation*>(
141 AliMpSegmentation::Instance()->GetMpSegmentation(fDEId, AliMp::kCath1));
143 const AliMpSlat* slat0 = seg0->Slat();
144 const AliMpSlat* slat1 = seg1->Slat();
149 Int_t manuPerPcb = 0;
152 Double_t length = 0.;
155 for (Int_t iManu = 0; iManu < GetNofManus(); ++iManu) {
156 Int_t manuId = GetManuId(iManu);
157 AliMpMotifPosition* motifPos0 = slat0->FindMotifPosition(manuId);
158 AliMpMotifPosition* motifPos1 = slat1->FindMotifPosition(manuId);
160 if ( !motifPos0 && !motifPos1 ) {
161 // should never happen
163 << "Motif position for manuId = " << manuId << "not found" << endl;
169 x = motifPos0->Position().X();
170 length = slat0->GetPCB(0)->DX()*2.;
173 x = motifPos1->Position().X();
174 length = slat1->GetPCB(0)->DX()*2.;
177 iPcb = Int_t(x/length + AliMpConstants::LengthTolerance());
179 // check when going to next PCB
180 if ( iPcb == iPcbPrev )
182 else if ( iPcbPrev != -1 ) {
183 //vec.Set(vec.GetSize()+1);
184 //vec[vec.GetSize()-1] = manuPerPcb+1;
185 fNofManusPerModule.Add(manuPerPcb+1);
192 //vec.Set(vec.GetSize()+1);
193 //vec[vec.GetSize()-1] = manuPerPcb+1;
194 fNofManusPerModule.Add(manuPerPcb+1);
201 //______________________________________________________________________________
202 Int_t AliMpBusPatch::GetNofManus() const
204 /// Return the number of detection elements connected to this DDL
206 return fManus.GetSize();
209 //______________________________________________________________________________
210 Int_t AliMpBusPatch::GetManuId(Int_t index) const
212 /// Return the detection element by index (in loop)
214 return fManus.GetValue(index);
217 //______________________________________________________________________________
218 Bool_t AliMpBusPatch::HasManu(Int_t manuId) const
220 /// Return true if bus patch has manu with given manuId
222 return fManus.HasValue(manuId);
225 //______________________________________________________________________________
226 Int_t AliMpBusPatch::GetNofPatchModules() const
228 /// Return the number of patch modules (PCB) connected to this bus patch.
230 return fNofManusPerModule.GetSize();
233 //______________________________________________________________________________
234 Int_t AliMpBusPatch::GetNofManusPerModule(Int_t patchModule) const
236 /// Return the number of manus per patch module (PCB)
238 if ( patchModule < 0 || patchModule >= GetNofPatchModules() ) {
239 AliErrorStream() << "Invalid patch module number = " << patchModule << endl;
243 return fNofManusPerModule.GetValue(patchModule);