]>
Commit | Line | Data |
---|---|---|
c667f499 | 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 purpeateose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | // $Id$ | |
13985652 | 17 | // $MpId: AliMpTrigger.cxx,v 1.4 2006/05/24 13:58:52 ivana Exp $ |
c667f499 | 18 | |
19 | #include "AliMpTrigger.h" | |
20 | ||
21 | #include "AliLog.h" | |
22 | #include "AliMpSlat.h" | |
23 | ||
24 | #include "Riostream.h" | |
25 | #include "TArrayI.h" | |
26 | #include "TObjArray.h" | |
27 | ||
85fec35d | 28 | /// |
29 | /// \class AliMpTrigger | |
30 | /// | |
31 | /// A trigger 'slat' object. | |
32 | /// It is to be viewed as a superposition of | |
33 | /// virtual layers of AliMpSlat objects. The need for more than one layer | |
34 | /// arise from the fact that a given local board deals with strips | |
35 | /// located in different detelem. So a given strip (pad) can have several | |
36 | /// "locations". | |
37 | /// | |
38 | /// \author Laurent Aphecetche | |
39 | ||
13985652 | 40 | /// \cond CLASSIMP |
c667f499 | 41 | ClassImp(AliMpTrigger) |
13985652 | 42 | /// \endcond |
c667f499 | 43 | |
44 | namespace | |
45 | { | |
46 | Bool_t IsEqual(Double_t a, Double_t b, Double_t precision) | |
47 | { | |
48 | if (b) | |
49 | { | |
50 | Double_t diff = TMath::Abs(b-a)/TMath::Abs(b); | |
51 | if ( diff < precision ) | |
52 | { | |
53 | return kTRUE; | |
54 | } | |
55 | } | |
56 | else | |
57 | { | |
58 | if ( !a ) return kTRUE; | |
59 | } | |
60 | return kFALSE; | |
61 | } | |
62 | } | |
63 | ||
64 | //_____________________________________________________________________________ | |
65 | AliMpTrigger::AliMpTrigger() | |
66 | : TObject(), fId(""), fPlaneType(kNonBendingPlane), | |
67 | fMaxNofPadsY(0), fDX(0), fDY(0) | |
68 | { | |
85fec35d | 69 | // default ctor |
c667f499 | 70 | } |
71 | ||
72 | //_____________________________________________________________________________ | |
73 | AliMpTrigger::AliMpTrigger(const char* slatType, AliMpPlaneType bendingOrNot) | |
74 | : TObject(), fId(slatType), fPlaneType(bendingOrNot), | |
75 | fMaxNofPadsY(0), fDX(0), fDY(0) | |
76 | { | |
85fec35d | 77 | // normal ctor |
c667f499 | 78 | } |
79 | ||
80 | //_____________________________________________________________________________ | |
81 | AliMpTrigger::~AliMpTrigger() | |
82 | { | |
85fec35d | 83 | // dtor |
c667f499 | 84 | AliDebug(1,Form("this=%p before fSlats.Delete()",this)); |
85 | fSlats.Delete(); | |
86 | AliDebug(1,Form("this=%p after fSlats.Delete()",this)); | |
87 | } | |
88 | ||
89 | //_____________________________________________________________________________ | |
90 | Bool_t | |
91 | AliMpTrigger::AdoptLayer(AliMpSlat* slat) | |
92 | { | |
85fec35d | 93 | // Adopt (i.e. we become owner of that pointer) a slat, as |
94 | // a layer of this trigger slat. | |
95 | ||
c667f499 | 96 | AliDebug(1,Form("%s is adopting %s :\n", |
97 | GetID(),slat->GetID())); | |
98 | ||
99 | // Check that we keep our size constant. | |
100 | ||
84aac932 | 101 | const Double_t kPrecision = 1E-3; |
c667f499 | 102 | |
103 | if ( GetSize() > 0 && | |
84aac932 | 104 | ( !::IsEqual(slat->DX(),fDX,kPrecision) || |
105 | !::IsEqual(slat->DY(),fDY,kPrecision) ) | |
c667f499 | 106 | ) |
107 | { | |
108 | AliError(Form("In %s trying to add a layer (%e,%e) of a different size than " | |
109 | "mine (%e,%e)\n",GetID(),slat->DX(),slat->DY(), | |
110 | fDX,fDY)); | |
111 | return kFALSE; | |
112 | } | |
113 | fSlats.Add(slat); | |
114 | fMaxNofPadsY = std::max(slat->GetMaxNofPadsY(),fMaxNofPadsY); | |
115 | fDX = std::max(fDX,slat->DX()); | |
116 | fDY = std::max(fDY,slat->DY()); | |
117 | return kTRUE; | |
118 | } | |
119 | ||
c9da0af9 | 120 | //_____________________________________________________________________________ |
121 | TVector2 | |
122 | AliMpTrigger::Dimensions() const | |
123 | { | |
85fec35d | 124 | // Returns the dimensions (half-sizes) of that slat (cm) |
c9da0af9 | 125 | return TVector2(DX(),DY()); |
126 | } | |
127 | ||
c667f499 | 128 | //_____________________________________________________________________________ |
129 | Double_t | |
130 | AliMpTrigger::DX() const | |
131 | { | |
85fec35d | 132 | // Returns the half-size in X (cm) |
c667f499 | 133 | return fDX; |
134 | } | |
135 | ||
136 | //_____________________________________________________________________________ | |
137 | Double_t | |
138 | AliMpTrigger::DY() const | |
139 | { | |
85fec35d | 140 | // Returns the half-size in Y (cm) |
c667f499 | 141 | return fDY; |
142 | } | |
143 | ||
144 | //_____________________________________________________________________________ | |
145 | void | |
146 | AliMpTrigger::GetAllLocalBoardNumbers(TArrayI& lbn) const | |
147 | { | |
85fec35d | 148 | // Fills lbn with the local board numbers we're dealing with |
c667f499 | 149 | Int_t n(0); |
150 | for ( Int_t i = 0; i < GetSize(); ++i ) | |
151 | { | |
152 | n += GetLayer(i)->GetNofElectronicCards(); | |
153 | } | |
154 | ||
155 | lbn.Set(n); | |
156 | ||
157 | Int_t index(0); | |
158 | ||
159 | for ( Int_t i = 0; i < GetSize(); ++i ) | |
160 | { | |
161 | TArrayI slbn; | |
c9da0af9 | 162 | GetLayer(i)->GetAllMotifPositionsIDs(slbn); |
c667f499 | 163 | for ( Int_t j = 0; j < slbn.GetSize(); ++j ) |
164 | { | |
165 | lbn[index] = slbn[j]; | |
166 | ++index; | |
167 | } | |
168 | } | |
169 | } | |
170 | ||
171 | //_____________________________________________________________________________ | |
172 | const char* | |
173 | AliMpTrigger::GetID() const | |
174 | { | |
85fec35d | 175 | // returns the id of this slat |
c667f499 | 176 | return fId.Data(); |
177 | } | |
178 | ||
179 | //_____________________________________________________________________________ | |
180 | const char* | |
181 | AliMpTrigger::GetName() const | |
182 | { | |
85fec35d | 183 | // returns the name (=id+bending/non-bending) of this slat |
c667f499 | 184 | TString name(GetID()); |
185 | if ( fPlaneType == kBendingPlane ) | |
186 | { | |
187 | name += ".Bending"; | |
188 | } | |
189 | else if ( fPlaneType == kNonBendingPlane ) | |
190 | { | |
191 | name += ".NonBending"; | |
192 | } | |
193 | else | |
194 | { | |
195 | name += ".Invalid"; | |
196 | } | |
197 | return name.Data(); | |
198 | } | |
199 | ||
200 | //_____________________________________________________________________________ | |
201 | AliMpSlat* | |
202 | AliMpTrigger::GetLayer(int layer) const | |
203 | { | |
85fec35d | 204 | // Returns a given layer |
c667f499 | 205 | if ( IsLayerValid(layer) ) |
206 | { | |
207 | return (AliMpSlat*)fSlats.At(layer); | |
208 | } | |
209 | return 0; | |
210 | } | |
211 | ||
212 | //_____________________________________________________________________________ | |
213 | Int_t | |
214 | AliMpTrigger::GetNofPadsX() const | |
215 | { | |
85fec35d | 216 | // Returns the number of pad in x direction |
c667f499 | 217 | if ( !GetSize() ) return -1; |
218 | if ( GetLayer(0) ) | |
219 | { | |
220 | return GetLayer(0)->GetNofPadsX(); | |
221 | } | |
222 | return -1; | |
223 | } | |
224 | ||
225 | //_____________________________________________________________________________ | |
226 | Int_t | |
227 | AliMpTrigger::GetMaxNofPadsY() const | |
228 | { | |
85fec35d | 229 | // Maximum number of pads in y direction |
c667f499 | 230 | return fMaxNofPadsY; |
231 | } | |
232 | ||
233 | //_____________________________________________________________________________ | |
234 | Int_t | |
235 | AliMpTrigger::GetSize() const | |
236 | { | |
85fec35d | 237 | // Number of layers |
c667f499 | 238 | return fSlats.GetEntriesFast(); |
239 | } | |
240 | ||
241 | //_____________________________________________________________________________ | |
242 | Bool_t | |
243 | AliMpTrigger::IsLayerValid(int layer) const | |
244 | { | |
85fec35d | 245 | // Whether a given layer index is valid or not |
c667f499 | 246 | if ( layer >= 0 && layer < GetSize() ) |
247 | { | |
248 | return kTRUE; | |
249 | } | |
250 | return kFALSE; | |
251 | } | |
252 | ||
c9da0af9 | 253 | //_____________________________________________________________________________ |
254 | AliMpPlaneType | |
255 | AliMpTrigger::PlaneType() const | |
256 | { | |
85fec35d | 257 | // Bending or not |
c9da0af9 | 258 | return fPlaneType; |
259 | } | |
260 | ||
c667f499 | 261 | //_____________________________________________________________________________ |
262 | TVector2 | |
263 | AliMpTrigger::Position() const | |
264 | { | |
85fec35d | 265 | // Slat position (cm) |
c667f499 | 266 | return TVector2(DX(),DY()); |
267 | } | |
268 | ||
269 | //_____________________________________________________________________________ | |
270 | void | |
271 | AliMpTrigger::Print(Option_t* opt) const | |
272 | { | |
85fec35d | 273 | // Dump on screen |
c667f499 | 274 | cout << "AliMpTrigger::" << GetID(); |
275 | if ( GetSize() == 0 ) | |
276 | { | |
277 | cout << " Empty"; | |
278 | } | |
279 | else if ( GetSize() > 1 ) | |
280 | { | |
281 | cout << " Number of layers : " << GetSize(); | |
282 | } | |
283 | else | |
284 | { | |
285 | cout << " One layer"; | |
286 | } | |
287 | cout << endl; | |
288 | for ( Int_t i = 0; i < GetSize(); ++i ) | |
289 | { | |
290 | cout << " "; | |
291 | GetLayer(i)->Print(opt); | |
292 | } | |
293 | } | |
294 | ||
295 | //_____________________________________________________________________________ | |
296 | //_____________________________________________________________________________ | |
297 | //_____________________________________________________________________________ | |
298 | //_____________________________________________________________________________ |