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