]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpBusPatch.cxx
In Print(): added an option to print area borders
[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),
73 fCableLength(-1)
1e738c3c 74{
b4daf0b2 75/// Standard constructor
1e738c3c 76}
77
b4daf0b2 78//______________________________________________________________________________
79AliMpBusPatch::AliMpBusPatch(TRootIOCtor* /*ioCtor*/)
80 : TObject(),
81 fId(),
82 fDEId(),
83 fDdlId(),
f00f5bb0 84 fManus(),
bf4bf8d2 85 fNofManusPerModule(false),
86 fCableLength(-1)
1e738c3c 87{
b4daf0b2 88/// Root IO constructor
1e738c3c 89}
1e738c3c 90
b4daf0b2 91//______________________________________________________________________________
92AliMpBusPatch::~AliMpBusPatch()
5826f1df 93{
b4daf0b2 94/// Destructor
5826f1df 95}
96
b4daf0b2 97//
98// public methods
99//
5826f1df 100
b4daf0b2 101//______________________________________________________________________________
102Bool_t AliMpBusPatch::AddManu(Int_t manuId)
5826f1df 103{
b4daf0b2 104/// Add detection element with given detElemId.
105/// Return true if the detection element was added
106
107 if ( HasManu(manuId) ) {
108 AliWarningStream()
109 << "Manu with manuId=" << manuId << " already present."
110 << endl;
111 return false;
112 }
113
114 fManus.Add(manuId);
115 return true;
116}
117
f00f5bb0 118//______________________________________________________________________________
bf4bf8d2 119Bool_t AliMpBusPatch::SetNofManusPerModule(Int_t manuNumber)
f00f5bb0 120{
121/// Set the number of manus per patch module (PCB):
bf4bf8d2 122/// - for stations 1 all manus are connected to one PCB,
123/// - for stations 2 there maximum two PCBs per buspatch,
f00f5bb0 124/// - for slat stations there are maximum three PCBs per buspatch
f00f5bb0 125
bf4bf8d2 126 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation1) {
f00f5bb0 127
128 // simply fill the number of manus, no bridge for station 1
f00f5bb0 129
130 fNofManusPerModule.Add(GetNofManus());
131 return true;
132 }
133
bf4bf8d2 134 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation2) {
135
136 // there is max two patch modules per buspatch
137
138 fNofManusPerModule.Add(manuNumber);
139 if (manuNumber != GetNofManus())
140 fNofManusPerModule.Add(GetNofManus() - manuNumber);
141
142 return true;
143 }
144
f00f5bb0 145 if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation345 ) {
146
147 const AliMpSlatSegmentation* seg0
148 = static_cast<const AliMpSlatSegmentation*>(
149 AliMpSegmentation::Instance()->GetMpSegmentation(fDEId, AliMp::kCath0));
150
151 const AliMpSlatSegmentation* seg1
152 = static_cast<const AliMpSlatSegmentation*>(
153 AliMpSegmentation::Instance()->GetMpSegmentation(fDEId, AliMp::kCath1));
154
155 const AliMpSlat* slat0 = seg0->Slat();
156 const AliMpSlat* slat1 = seg1->Slat();
157
158
159 Int_t iPcb = 0;
160 Int_t iPcbPrev = -1;
161 Int_t manuPerPcb = 0;
162
163 Double_t x = 0.;
164 Double_t length = 0.;
165
166 // Loop over manu
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);
171
172 if ( !motifPos0 && !motifPos1 ) {
173 // should never happen
174 AliErrorStream()
175 << "Motif position for manuId = " << manuId << "not found" << endl;
176 return false;
177 }
178
179 // find PCB id
180 if ( motifPos0 ) {
181 x = motifPos0->Position().X();
182 length = slat0->GetPCB(0)->DX()*2.;
183 }
184 if ( motifPos1 ) {
185 x = motifPos1->Position().X();
186 length = slat1->GetPCB(0)->DX()*2.;
187 }
188
189 iPcb = Int_t(x/length + AliMpConstants::LengthTolerance());
190
191 // check when going to next PCB
192 if ( iPcb == iPcbPrev )
193 manuPerPcb++;
194 else if ( iPcbPrev != -1 ) {
195 //vec.Set(vec.GetSize()+1);
196 //vec[vec.GetSize()-1] = manuPerPcb+1;
197 fNofManusPerModule.Add(manuPerPcb+1);
198 manuPerPcb = 0;
199 }
200 iPcbPrev = iPcb;
201 }
202
203 // store last PCB
204 //vec.Set(vec.GetSize()+1);
205 //vec[vec.GetSize()-1] = manuPerPcb+1;
206 fNofManusPerModule.Add(manuPerPcb+1);
207 return true;
9ece548f 208 }
209
210 return false;
f00f5bb0 211}
212
b4daf0b2 213//______________________________________________________________________________
214Int_t AliMpBusPatch::GetNofManus() const
215{
216/// Return the number of detection elements connected to this DDL
217
218 return fManus.GetSize();
5826f1df 219}
220
b4daf0b2 221//______________________________________________________________________________
222Int_t AliMpBusPatch::GetManuId(Int_t index) const
223{
224/// Return the detection element by index (in loop)
528df1a6 225
b4daf0b2 226 return fManus.GetValue(index);
5826f1df 227}
228
b4daf0b2 229//______________________________________________________________________________
230Bool_t AliMpBusPatch::HasManu(Int_t manuId) const
231{
232/// Return true if bus patch has manu with given manuId
5826f1df 233
b4daf0b2 234 return fManus.HasValue(manuId);
5826f1df 235}
236
f00f5bb0 237//______________________________________________________________________________
238Int_t AliMpBusPatch::GetNofPatchModules() const
239{
240/// Return the number of patch modules (PCB) connected to this bus patch.
5826f1df 241
f00f5bb0 242 return fNofManusPerModule.GetSize();
243}
244
245//______________________________________________________________________________
246Int_t AliMpBusPatch::GetNofManusPerModule(Int_t patchModule) const
247{
248/// Return the number of manus per patch module (PCB)
249
250 if ( patchModule < 0 || patchModule >= GetNofPatchModules() ) {
251 AliErrorStream() << "Invalid patch module number = " << patchModule << endl;
252 return 0;
253 }
254
255 return fNofManusPerModule.GetValue(patchModule);
256}