]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpBusPatch.cxx
Adding info abour Frt Crocus mapping:
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpBusPatch.cxx
CommitLineData
1e738c3c 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16// $Id$
b4daf0b2 17// $MpId: AliMpBusPatch.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
3d1463c8 18
19//-----------------------------------------------------------------------------
b4daf0b2 20// Class AliMpBusPatch
21// --------------------
22// The class defines the properties of BusPatch
23// Author: Ivana Hrivnacova, IPN Orsay
3d1463c8 24//-----------------------------------------------------------------------------
1e738c3c 25
26#include "AliMpBusPatch.h"
f00f5bb0 27#include "AliMpConstants.h"
28#include "AliMpDEManager.h"
29#include "AliMpSegmentation.h"
30#include "AliMpSlatSegmentation.h"
31#include "AliMpSlat.h"
32#include "AliMpPCB.h"
33#include "AliMpMotifPosition.h"
b4daf0b2 34
1e738c3c 35#include "AliLog.h"
b4daf0b2 36
37#include <Riostream.h>
1e738c3c 38
13985652 39/// \cond CLASSIMP
1e738c3c 40ClassImp(AliMpBusPatch)
13985652 41/// \endcond
1e738c3c 42
d2892ef5 43const Int_t AliMpBusPatch::fgkOffset = 100;
b4daf0b2 44//
45// static methods
46//
d2892ef5 47
d2892ef5 48//____________________________________________________________________
49Int_t AliMpBusPatch::GetGlobalBusID(Int_t localID, Int_t ddlID)
50{
51 /// return global bus id from local bus and ddl id
52
53 return ddlID*fgkOffset + localID;
54
55}
56//____________________________________________________________________
57Int_t AliMpBusPatch::GetLocalBusID(Int_t globalID, Int_t ddlID)
58{
59 /// return local bus id from local bus id
1e738c3c 60
d2892ef5 61 return globalID - ddlID*fgkOffset;
62
63}
1e738c3c 64
b4daf0b2 65//______________________________________________________________________________
66AliMpBusPatch::AliMpBusPatch(Int_t id, Int_t detElemId, Int_t ddlId)
67 : TObject(),
68 fId(id),
69 fDEId(detElemId),
70 fDdlId(ddlId),
f00f5bb0 71 fManus(false),
bf4bf8d2 72 fNofManusPerModule(false),
59754717 73 fCableLength(-1),
74 fCableLabel(),
75 fTranslatorLabel(),
76 fFrtId(0)
1e738c3c 77{
b4daf0b2 78/// Standard constructor
1e738c3c 79}
80
b4daf0b2 81//______________________________________________________________________________
82AliMpBusPatch::AliMpBusPatch(TRootIOCtor* /*ioCtor*/)
83 : TObject(),
84 fId(),
85 fDEId(),
86 fDdlId(),
ae649dcb 87 fManus(false),
bf4bf8d2 88 fNofManusPerModule(false),
59754717 89 fCableLength(-1),
90 fCableLabel(),
91 fTranslatorLabel(),
92 fFrtId(0)
1e738c3c 93{
b4daf0b2 94/// Root IO constructor
1e738c3c 95}
1e738c3c 96
b4daf0b2 97//______________________________________________________________________________
98AliMpBusPatch::~AliMpBusPatch()
5826f1df 99{
b4daf0b2 100/// Destructor
5826f1df 101}
102
b4daf0b2 103//
104// public methods
105//
5826f1df 106
b4daf0b2 107//______________________________________________________________________________
108Bool_t AliMpBusPatch::AddManu(Int_t manuId)
5826f1df 109{
b4daf0b2 110/// Add detection element with given detElemId.
111/// Return true if the detection element was added
112
113 if ( HasManu(manuId) ) {
114 AliWarningStream()
115 << "Manu with manuId=" << manuId << " already present."
116 << endl;
117 return false;
118 }
119
120 fManus.Add(manuId);
121 return true;
122}
123
f00f5bb0 124//______________________________________________________________________________
bf4bf8d2 125Bool_t AliMpBusPatch::SetNofManusPerModule(Int_t manuNumber)
f00f5bb0 126{
127/// Set the number of manus per patch module (PCB):
bf4bf8d2 128/// - for stations 1 all manus are connected to one PCB,
129/// - for stations 2 there maximum two PCBs per buspatch,
f00f5bb0 130/// - for slat stations there are maximum three PCBs per buspatch
f00f5bb0 131
bf4bf8d2 132 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation1) {
f00f5bb0 133
134 // simply fill the number of manus, no bridge for station 1
f00f5bb0 135
136 fNofManusPerModule.Add(GetNofManus());
137 return true;
138 }
139
bf4bf8d2 140 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation2) {
141
142 // there is max two patch modules per buspatch
143
144 fNofManusPerModule.Add(manuNumber);
145 if (manuNumber != GetNofManus())
146 fNofManusPerModule.Add(GetNofManus() - manuNumber);
147
148 return true;
149 }
150
f00f5bb0 151 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation345 ) {
152
153 const AliMpSlatSegmentation* seg0
154 = static_cast<const AliMpSlatSegmentation*>(
155 AliMpSegmentation::Instance()->GetMpSegmentation(fDEId, AliMp::kCath0));
156
157 const AliMpSlatSegmentation* seg1
158 = static_cast<const AliMpSlatSegmentation*>(
159 AliMpSegmentation::Instance()->GetMpSegmentation(fDEId, AliMp::kCath1));
160
161 const AliMpSlat* slat0 = seg0->Slat();
162 const AliMpSlat* slat1 = seg1->Slat();
163
164
165 Int_t iPcb = 0;
166 Int_t iPcbPrev = -1;
167 Int_t manuPerPcb = 0;
168
169 Double_t x = 0.;
170 Double_t length = 0.;
171
172 // Loop over manu
173 for (Int_t iManu = 0; iManu < GetNofManus(); ++iManu) {
174 Int_t manuId = GetManuId(iManu);
175 AliMpMotifPosition* motifPos0 = slat0->FindMotifPosition(manuId);
176 AliMpMotifPosition* motifPos1 = slat1->FindMotifPosition(manuId);
177
178 if ( !motifPos0 && !motifPos1 ) {
179 // should never happen
180 AliErrorStream()
181 << "Motif position for manuId = " << manuId << "not found" << endl;
182 return false;
183 }
184
185 // find PCB id
186 if ( motifPos0 ) {
187 x = motifPos0->Position().X();
188 length = slat0->GetPCB(0)->DX()*2.;
189 }
190 if ( motifPos1 ) {
191 x = motifPos1->Position().X();
192 length = slat1->GetPCB(0)->DX()*2.;
193 }
194
195 iPcb = Int_t(x/length + AliMpConstants::LengthTolerance());
196
197 // check when going to next PCB
198 if ( iPcb == iPcbPrev )
199 manuPerPcb++;
200 else if ( iPcbPrev != -1 ) {
201 //vec.Set(vec.GetSize()+1);
202 //vec[vec.GetSize()-1] = manuPerPcb+1;
203 fNofManusPerModule.Add(manuPerPcb+1);
204 manuPerPcb = 0;
205 }
206 iPcbPrev = iPcb;
207 }
208
209 // store last PCB
210 //vec.Set(vec.GetSize()+1);
211 //vec[vec.GetSize()-1] = manuPerPcb+1;
212 fNofManusPerModule.Add(manuPerPcb+1);
213 return true;
9ece548f 214 }
215
216 return false;
f00f5bb0 217}
218
ae649dcb 219//______________________________________________________________________________
220void AliMpBusPatch::RevertReadout()
221{
222/// Revert order of manus
223
224 fManus.Revert();
225}
226
227//______________________________________________________________________________
228void AliMpBusPatch::ResetReadout()
229{
230/// Revert order of manus
231
232 fManus.Reset();
233}
234
b4daf0b2 235//______________________________________________________________________________
236Int_t AliMpBusPatch::GetNofManus() const
237{
238/// Return the number of detection elements connected to this DDL
239
240 return fManus.GetSize();
5826f1df 241}
242
b4daf0b2 243//______________________________________________________________________________
244Int_t AliMpBusPatch::GetManuId(Int_t index) const
245{
246/// Return the detection element by index (in loop)
528df1a6 247
b4daf0b2 248 return fManus.GetValue(index);
5826f1df 249}
250
b4daf0b2 251//______________________________________________________________________________
252Bool_t AliMpBusPatch::HasManu(Int_t manuId) const
253{
254/// Return true if bus patch has manu with given manuId
5826f1df 255
b4daf0b2 256 return fManus.HasValue(manuId);
5826f1df 257}
258
f00f5bb0 259//______________________________________________________________________________
260Int_t AliMpBusPatch::GetNofPatchModules() const
261{
262/// Return the number of patch modules (PCB) connected to this bus patch.
5826f1df 263
f00f5bb0 264 return fNofManusPerModule.GetSize();
265}
266
267//______________________________________________________________________________
268Int_t AliMpBusPatch::GetNofManusPerModule(Int_t patchModule) const
269{
270/// Return the number of manus per patch module (PCB)
271
272 if ( patchModule < 0 || patchModule >= GetNofPatchModules() ) {
273 AliErrorStream() << "Invalid patch module number = " << patchModule << endl;
274 return 0;
275 }
276
277 return fNofManusPerModule.GetValue(patchModule);
278}