]>
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() | |
1657f946 | 66 | : TObject(), |
67 | fId(""), | |
68 | fPlaneType(kNonBendingPlane), | |
69 | fSlats(0), | |
70 | fMaxNofPadsY(0), | |
71 | fDX(0), | |
72 | fDY(0) | |
c667f499 | 73 | { |
85fec35d | 74 | // default ctor |
c667f499 | 75 | } |
76 | ||
77 | //_____________________________________________________________________________ | |
78 | AliMpTrigger::AliMpTrigger(const char* slatType, AliMpPlaneType bendingOrNot) | |
1657f946 | 79 | : TObject(), |
80 | fId(slatType), | |
81 | fPlaneType(bendingOrNot), | |
82 | fSlats(0), | |
83 | fMaxNofPadsY(0), | |
84 | fDX(0), | |
85 | fDY(0) | |
c667f499 | 86 | { |
85fec35d | 87 | // normal ctor |
c667f499 | 88 | } |
89 | ||
90 | //_____________________________________________________________________________ | |
91 | AliMpTrigger::~AliMpTrigger() | |
92 | { | |
85fec35d | 93 | // dtor |
c667f499 | 94 | AliDebug(1,Form("this=%p before fSlats.Delete()",this)); |
95 | fSlats.Delete(); | |
96 | AliDebug(1,Form("this=%p after fSlats.Delete()",this)); | |
97 | } | |
98 | ||
99 | //_____________________________________________________________________________ | |
100 | Bool_t | |
101 | AliMpTrigger::AdoptLayer(AliMpSlat* slat) | |
102 | { | |
85fec35d | 103 | // Adopt (i.e. we become owner of that pointer) a slat, as |
104 | // a layer of this trigger slat. | |
105 | ||
c667f499 | 106 | AliDebug(1,Form("%s is adopting %s :\n", |
107 | GetID(),slat->GetID())); | |
108 | ||
109 | // Check that we keep our size constant. | |
110 | ||
84aac932 | 111 | const Double_t kPrecision = 1E-3; |
c667f499 | 112 | |
113 | if ( GetSize() > 0 && | |
84aac932 | 114 | ( !::IsEqual(slat->DX(),fDX,kPrecision) || |
115 | !::IsEqual(slat->DY(),fDY,kPrecision) ) | |
c667f499 | 116 | ) |
117 | { | |
118 | AliError(Form("In %s trying to add a layer (%e,%e) of a different size than " | |
119 | "mine (%e,%e)\n",GetID(),slat->DX(),slat->DY(), | |
120 | fDX,fDY)); | |
121 | return kFALSE; | |
122 | } | |
123 | fSlats.Add(slat); | |
124 | fMaxNofPadsY = std::max(slat->GetMaxNofPadsY(),fMaxNofPadsY); | |
125 | fDX = std::max(fDX,slat->DX()); | |
126 | fDY = std::max(fDY,slat->DY()); | |
127 | return kTRUE; | |
128 | } | |
129 | ||
c9da0af9 | 130 | //_____________________________________________________________________________ |
131 | TVector2 | |
132 | AliMpTrigger::Dimensions() const | |
133 | { | |
85fec35d | 134 | // Returns the dimensions (half-sizes) of that slat (cm) |
c9da0af9 | 135 | return TVector2(DX(),DY()); |
136 | } | |
137 | ||
c667f499 | 138 | //_____________________________________________________________________________ |
139 | Double_t | |
140 | AliMpTrigger::DX() const | |
141 | { | |
85fec35d | 142 | // Returns the half-size in X (cm) |
c667f499 | 143 | return fDX; |
144 | } | |
145 | ||
146 | //_____________________________________________________________________________ | |
147 | Double_t | |
148 | AliMpTrigger::DY() const | |
149 | { | |
85fec35d | 150 | // Returns the half-size in Y (cm) |
c667f499 | 151 | return fDY; |
152 | } | |
153 | ||
154 | //_____________________________________________________________________________ | |
155 | void | |
156 | AliMpTrigger::GetAllLocalBoardNumbers(TArrayI& lbn) const | |
157 | { | |
85fec35d | 158 | // Fills lbn with the local board numbers we're dealing with |
c667f499 | 159 | Int_t n(0); |
160 | for ( Int_t i = 0; i < GetSize(); ++i ) | |
161 | { | |
162 | n += GetLayer(i)->GetNofElectronicCards(); | |
163 | } | |
164 | ||
165 | lbn.Set(n); | |
166 | ||
167 | Int_t index(0); | |
168 | ||
169 | for ( Int_t i = 0; i < GetSize(); ++i ) | |
170 | { | |
171 | TArrayI slbn; | |
c9da0af9 | 172 | GetLayer(i)->GetAllMotifPositionsIDs(slbn); |
c667f499 | 173 | for ( Int_t j = 0; j < slbn.GetSize(); ++j ) |
174 | { | |
175 | lbn[index] = slbn[j]; | |
176 | ++index; | |
177 | } | |
178 | } | |
179 | } | |
180 | ||
181 | //_____________________________________________________________________________ | |
182 | const char* | |
183 | AliMpTrigger::GetID() const | |
184 | { | |
85fec35d | 185 | // returns the id of this slat |
c667f499 | 186 | return fId.Data(); |
187 | } | |
188 | ||
189 | //_____________________________________________________________________________ | |
190 | const char* | |
191 | AliMpTrigger::GetName() const | |
192 | { | |
85fec35d | 193 | // returns the name (=id+bending/non-bending) of this slat |
c667f499 | 194 | TString name(GetID()); |
195 | if ( fPlaneType == kBendingPlane ) | |
196 | { | |
197 | name += ".Bending"; | |
198 | } | |
199 | else if ( fPlaneType == kNonBendingPlane ) | |
200 | { | |
201 | name += ".NonBending"; | |
202 | } | |
203 | else | |
204 | { | |
205 | name += ".Invalid"; | |
206 | } | |
207 | return name.Data(); | |
208 | } | |
209 | ||
210 | //_____________________________________________________________________________ | |
211 | AliMpSlat* | |
212 | AliMpTrigger::GetLayer(int layer) const | |
213 | { | |
85fec35d | 214 | // Returns a given layer |
c667f499 | 215 | if ( IsLayerValid(layer) ) |
216 | { | |
217 | return (AliMpSlat*)fSlats.At(layer); | |
218 | } | |
219 | return 0; | |
220 | } | |
221 | ||
222 | //_____________________________________________________________________________ | |
223 | Int_t | |
224 | AliMpTrigger::GetNofPadsX() const | |
225 | { | |
85fec35d | 226 | // Returns the number of pad in x direction |
c667f499 | 227 | if ( !GetSize() ) return -1; |
228 | if ( GetLayer(0) ) | |
229 | { | |
230 | return GetLayer(0)->GetNofPadsX(); | |
231 | } | |
232 | return -1; | |
233 | } | |
234 | ||
235 | //_____________________________________________________________________________ | |
236 | Int_t | |
237 | AliMpTrigger::GetMaxNofPadsY() const | |
238 | { | |
85fec35d | 239 | // Maximum number of pads in y direction |
c667f499 | 240 | return fMaxNofPadsY; |
241 | } | |
242 | ||
243 | //_____________________________________________________________________________ | |
244 | Int_t | |
245 | AliMpTrigger::GetSize() const | |
246 | { | |
85fec35d | 247 | // Number of layers |
c667f499 | 248 | return fSlats.GetEntriesFast(); |
249 | } | |
250 | ||
251 | //_____________________________________________________________________________ | |
252 | Bool_t | |
253 | AliMpTrigger::IsLayerValid(int layer) const | |
254 | { | |
85fec35d | 255 | // Whether a given layer index is valid or not |
c667f499 | 256 | if ( layer >= 0 && layer < GetSize() ) |
257 | { | |
258 | return kTRUE; | |
259 | } | |
260 | return kFALSE; | |
261 | } | |
262 | ||
c9da0af9 | 263 | //_____________________________________________________________________________ |
264 | AliMpPlaneType | |
265 | AliMpTrigger::PlaneType() const | |
266 | { | |
85fec35d | 267 | // Bending or not |
c9da0af9 | 268 | return fPlaneType; |
269 | } | |
270 | ||
c667f499 | 271 | //_____________________________________________________________________________ |
272 | TVector2 | |
273 | AliMpTrigger::Position() const | |
274 | { | |
85fec35d | 275 | // Slat position (cm) |
c667f499 | 276 | return TVector2(DX(),DY()); |
277 | } | |
278 | ||
279 | //_____________________________________________________________________________ | |
280 | void | |
281 | AliMpTrigger::Print(Option_t* opt) const | |
282 | { | |
85fec35d | 283 | // Dump on screen |
c667f499 | 284 | cout << "AliMpTrigger::" << GetID(); |
285 | if ( GetSize() == 0 ) | |
286 | { | |
287 | cout << " Empty"; | |
288 | } | |
289 | else if ( GetSize() > 1 ) | |
290 | { | |
291 | cout << " Number of layers : " << GetSize(); | |
292 | } | |
293 | else | |
294 | { | |
295 | cout << " One layer"; | |
296 | } | |
297 | cout << endl; | |
298 | for ( Int_t i = 0; i < GetSize(); ++i ) | |
299 | { | |
300 | cout << " "; | |
301 | GetLayer(i)->Print(opt); | |
302 | } | |
303 | } | |
304 | ||
305 | //_____________________________________________________________________________ | |
306 | //_____________________________________________________________________________ | |
307 | //_____________________________________________________________________________ | |
308 | //_____________________________________________________________________________ |