]>
Commit | Line | Data |
---|---|---|
99ccb7f7 | 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$ | |
17 | ||
9edefa04 | 18 | #include <Riostream.h> |
19 | #include <TMath.h> | |
20 | #include <TObjArray.h> | |
21 | #include <TVirtualPad.h> | |
22 | #include <TVirtualX.h> | |
23 | ||
99ccb7f7 | 24 | #include "AliMUONCluster.h" |
25 | ||
26 | #include "AliLog.h" | |
27 | #include "AliMUONPad.h" | |
99ccb7f7 | 28 | |
3d1463c8 | 29 | //----------------------------------------------------------------------------- |
99ccb7f7 | 30 | /// \class AliMUONCluster |
31 | /// | |
32 | /// A group of adjacent pads | |
33 | /// | |
34 | /// Besides holding an internal array of AliMUONPads, this object | |
35 | /// also computes some global characteristics for that pad sets. | |
36 | /// | |
37 | /// \author Laurent Aphecetche | |
38 | /// | |
3d1463c8 | 39 | //----------------------------------------------------------------------------- |
99ccb7f7 | 40 | |
41 | /// \cond CLASSIMP | |
42 | ClassImp(AliMUONCluster) | |
43 | /// \endcond | |
44 | ||
45 | namespace | |
46 | { | |
47 | //___________________________________________________________________________ | |
48 | Bool_t | |
49 | ShouldUsePad(const AliMUONPad& pad, | |
50 | Int_t cathode, Int_t statusMask, Bool_t matchMask) | |
51 | { | |
52 | ||
53 | // FIXME : we should only use >=0 status, so we can fully | |
54 | // use masking possibility ? | |
55 | if ( pad.Status() < 0 ) return kFALSE; | |
56 | ||
57 | if ( pad.Cathode() == cathode && pad.IsReal() && !pad.IsSaturated() ) | |
58 | { | |
59 | Bool_t test = ( ( pad.Status() & statusMask ) != 0 ); | |
60 | if ( !statusMask ) | |
61 | { | |
62 | test = ( pad.Status() == 0 ); | |
63 | } | |
64 | if ( ( test && matchMask ) || ( !test && !matchMask ) ) | |
65 | { | |
66 | return kTRUE; | |
67 | } | |
68 | } | |
69 | return kFALSE; | |
70 | } | |
71 | ||
72 | //___________________________________________________________________________ | |
73 | Int_t Unique(Int_t n, Double_t* array, Double_t precision) | |
74 | { | |
75 | /// Return the number of *different* elements in array | |
76 | /// where different is up to precision | |
77 | /// Note that we assume that n is >= 1 | |
78 | ||
79 | Int_t count(1); | |
80 | ||
81 | Int_t* index = new Int_t[n]; | |
82 | ||
83 | TMath::Sort(n,array,index); | |
84 | ||
85 | for ( Int_t i = 1; i < n; ++i ) | |
86 | { | |
87 | if ( array[index[i]] - array[index[i-1]] < -precision ) ++count; | |
88 | } | |
89 | ||
90 | delete[] index; | |
91 | ||
92 | return count; | |
93 | } | |
94 | } | |
95 | ||
96 | //_____________________________________________________________________________ | |
97 | AliMUONCluster::AliMUONCluster() | |
98 | : TObject(), | |
e0de1dd9 | 99 | fPads(), |
99ccb7f7 | 100 | fHasPosition(kFALSE), |
101 | fPosition(1E9,1E9), | |
102 | fPositionError(1E9,1E9), | |
103 | fHasCharge(kFALSE), | |
00de388f | 104 | fChi2(0) |
99ccb7f7 | 105 | { |
106 | /// ctor | |
107 | fMultiplicity[0]=fMultiplicity[1]=0; | |
108 | fRawCharge[0]=fRawCharge[1]=0; | |
109 | fCharge[0]=fCharge[1]=0; | |
110 | fIsSaturated[0]=fIsSaturated[1]=kFALSE; | |
e0de1dd9 | 111 | fPads.SetOwner(kTRUE); |
99ccb7f7 | 112 | } |
113 | ||
114 | //_____________________________________________________________________________ | |
115 | AliMUONCluster::AliMUONCluster(const AliMUONCluster& src) | |
116 | : TObject(src), | |
e0de1dd9 | 117 | fPads(), |
99ccb7f7 | 118 | fHasPosition(kFALSE), |
119 | fPosition(1E9,1E9), | |
120 | fPositionError(1E9,1E9), | |
121 | fHasCharge(kFALSE), | |
00de388f | 122 | fChi2(0) |
99ccb7f7 | 123 | { |
124 | /// copy ctor | |
e0de1dd9 | 125 | fPads.SetOwner(kTRUE); |
99ccb7f7 | 126 | src.Copy(*this); |
127 | } | |
128 | ||
129 | //_____________________________________________________________________________ | |
130 | AliMUONCluster& | |
131 | AliMUONCluster::operator=(const AliMUONCluster& src) | |
132 | { | |
133 | /// assignement operator | |
0c8556b9 | 134 | if ( this != &src ) |
135 | { | |
136 | src.Copy(*this); | |
137 | } | |
99ccb7f7 | 138 | return *this; |
139 | } | |
140 | ||
141 | //_____________________________________________________________________________ | |
142 | AliMUONCluster::~AliMUONCluster() | |
143 | { | |
144 | /// dtor : note that we're owner of our pads | |
99ccb7f7 | 145 | } |
146 | ||
147 | //_____________________________________________________________________________ | |
148 | void | |
00de388f | 149 | AliMUONCluster::Clear(Option_t*) |
150 | { | |
151 | /// Clear our pad array | |
e0de1dd9 | 152 | fPads.Clear(); |
00de388f | 153 | } |
154 | ||
155 | //_____________________________________________________________________________ | |
156 | Bool_t | |
157 | AliMUONCluster::Contains(const AliMUONPad& pad) const | |
158 | { | |
159 | /// Whether this cluster contains the pad | |
e0de1dd9 | 160 | if (fPads.IsEmpty()) return kFALSE; |
161 | ||
00de388f | 162 | for ( Int_t i = 0; i < Multiplicity(); ++i ) |
163 | { | |
164 | AliMUONPad* p = Pad(i); | |
165 | if ( pad.Compare(p) == 0 ) return kTRUE; | |
166 | } | |
167 | return kFALSE; | |
168 | } | |
169 | ||
170 | //_____________________________________________________________________________ | |
171 | void | |
172 | AliMUONCluster::AddCluster(const AliMUONCluster& cluster) | |
173 | { | |
174 | /// Add all the pads for cluster to this one | |
175 | for ( Int_t i = 0; i < cluster.Multiplicity(); ++i ) | |
176 | { | |
177 | AliMUONPad* p = cluster.Pad(i); | |
178 | if ( Contains(*p) ) | |
179 | { | |
180 | AliError("I already got this pad : "); | |
181 | StdoutToAliError(p->Print();); | |
182 | AliFatal(""); | |
183 | } | |
184 | AddPad(*p); | |
185 | } | |
186 | ||
187 | } | |
188 | ||
189 | //_____________________________________________________________________________ | |
190 | AliMUONPad* | |
99ccb7f7 | 191 | AliMUONCluster::AddPad(const AliMUONPad& pad) |
192 | { | |
193 | /// Add a pad to our pad array, and update some internal information | |
194 | /// accordingly. | |
e0de1dd9 | 195 | |
99ccb7f7 | 196 | AliMUONPad* p = new AliMUONPad(pad); |
e0de1dd9 | 197 | fPads.AddLast(p); |
99ccb7f7 | 198 | p->SetClusterId(GetUniqueID()); |
199 | Int_t cathode = p->Cathode(); | |
200 | ++(fMultiplicity[cathode]); | |
201 | fRawCharge[cathode] += p->Charge(); | |
202 | if ( p->IsSaturated() ) | |
203 | { | |
204 | fIsSaturated[p->Cathode()]=kTRUE; | |
205 | } | |
00de388f | 206 | return p; |
207 | } | |
208 | ||
209 | //___________________________________________________________________________ | |
210 | TString | |
211 | AliMUONCluster::AsString() const | |
212 | { | |
213 | /// Return a string containing a compact form of the pad list | |
214 | TString s(Form("NPADS(%d,%d)",Multiplicity(0),Multiplicity(1))); | |
215 | ||
216 | for (Int_t i = 0; i < Multiplicity(); ++i ) | |
217 | { | |
218 | AliMUONPad* p = Pad(i); | |
219 | s += Form(" (%d,%d,%d) ",p->Cathode(),p->Ix(),p->Iy()); | |
220 | } | |
221 | return s; | |
222 | } | |
223 | ||
224 | ||
225 | //___________________________________________________________________________ | |
226 | Bool_t | |
227 | AliMUONCluster::AreOverlapping(const AliMUONCluster& c1, const AliMUONCluster& c2) | |
228 | { | |
229 | /// Whether the two clusters overlap | |
230 | ||
231 | static Double_t precision = 1E-4; // cm | |
232 | static TVector2 precisionAdjustment(precision,precision); | |
233 | ||
234 | for ( Int_t i1 = 0; i1 < c1.Multiplicity(); ++i1 ) | |
235 | { | |
236 | AliMUONPad* p1 = c1.Pad(i1); | |
237 | ||
238 | for ( Int_t i2 = 0; i2 < c2.Multiplicity(); ++i2 ) | |
239 | { | |
240 | AliMUONPad* p2 = c2.Pad(i2); | |
241 | // Note: we use negative precision numbers, meaning | |
242 | // the area of the pads will be *increased* by these small numbers | |
243 | // prior to check the overlap by the AreOverlapping method, | |
244 | // so pads touching only by the corners will be considered as | |
245 | // overlapping. | |
246 | if ( AliMUONPad::AreOverlapping(*p1,*p2,precisionAdjustment) ) | |
247 | { | |
248 | return kTRUE; | |
249 | } | |
250 | } | |
251 | } | |
252 | return kFALSE; | |
99ccb7f7 | 253 | } |
254 | ||
255 | //_____________________________________________________________________________ | |
256 | AliMpArea | |
257 | AliMUONCluster::Area() const | |
258 | { | |
259 | /// Return the geometrical area covered by this cluster | |
260 | ||
261 | // Start by finding the (x,y) limits of this cluster | |
262 | TVector2 lowerLeft(1E9,1E9); | |
263 | TVector2 upperRight(-1E9,-1E9); | |
264 | ||
265 | for ( Int_t i = 0; i < Multiplicity(); ++i ) | |
266 | { | |
267 | AliMUONPad* pad = Pad(i); | |
268 | TVector2 ll = pad->Position() - pad->Dimensions(); | |
269 | TVector2 ur = pad->Position() + pad->Dimensions(); | |
270 | lowerLeft.Set( TMath::Min(ll.X(),lowerLeft.X()), | |
271 | TMath::Min(ll.Y(),lowerLeft.Y()) ); | |
272 | upperRight.Set( TMath::Max(ur.X(),upperRight.X()), | |
273 | TMath::Max(ur.Y(),upperRight.Y()) ); | |
274 | } | |
275 | ||
276 | // then construct the area from those limits | |
277 | return AliMpArea((lowerLeft+upperRight)/2, | |
278 | (upperRight-lowerLeft)/2); | |
279 | } | |
280 | ||
00de388f | 281 | //_____________________________________________________________________________ |
282 | AliMpArea | |
283 | AliMUONCluster::Area(Int_t cathode) const | |
284 | { | |
285 | /// Return the geometrical area covered by this cluster's pads on | |
286 | /// a given cathode | |
287 | ||
288 | // Start by finding the (x,y) limits of this cluster | |
289 | TVector2 lowerLeft(1E9,1E9); | |
290 | TVector2 upperRight(-1E9,-1E9); | |
291 | ||
cd1f0e79 | 292 | for ( Int_t i = 0; i < Multiplicity(); ++i ) |
00de388f | 293 | { |
294 | AliMUONPad* pad = Pad(i); | |
cd1f0e79 | 295 | if ( pad->Cathode() == cathode ) |
296 | { | |
297 | TVector2 ll = pad->Position() - pad->Dimensions(); | |
298 | TVector2 ur = pad->Position() + pad->Dimensions(); | |
299 | lowerLeft.Set( TMath::Min(ll.X(),lowerLeft.X()), | |
300 | TMath::Min(ll.Y(),lowerLeft.Y()) ); | |
301 | upperRight.Set( TMath::Max(ur.X(),upperRight.X()), | |
302 | TMath::Max(ur.Y(),upperRight.Y()) ); | |
303 | } | |
00de388f | 304 | } |
305 | ||
306 | // then construct the area from those limits | |
307 | return AliMpArea((lowerLeft+upperRight)/2, | |
308 | (upperRight-lowerLeft)/2); | |
309 | } | |
310 | ||
311 | //_____________________________________________________________________________ | |
312 | Int_t | |
313 | AliMUONCluster::Cathode() const | |
314 | { | |
315 | /// Return the cathode "number" of this cluster : | |
316 | /// 0 if all its pads are on cathode 0 | |
317 | /// 1 if all its pads are on cathode 1 | |
318 | /// 2 if some pads on cath 0 and some on cath 1 | |
319 | ||
320 | Int_t cathode(-1); | |
321 | if (Multiplicity(0)>0 && Multiplicity(1)>0) | |
322 | { | |
323 | cathode=2; | |
324 | } | |
325 | else if (Multiplicity(0)>0) | |
326 | { | |
327 | cathode=0; | |
328 | } | |
329 | else if (Multiplicity(1)>0) | |
330 | { | |
331 | cathode=1; | |
332 | } | |
333 | ||
334 | return cathode; | |
335 | } | |
336 | ||
99ccb7f7 | 337 | //_____________________________________________________________________________ |
338 | void | |
339 | AliMUONCluster::Copy(TObject& obj) const | |
340 | { | |
71a2d3aa | 341 | /// |
342 | /// Copy this cluster to (cluster&)obj | |
343 | /// | |
99ccb7f7 | 344 | TObject::Copy(obj); |
345 | AliMUONCluster& dest = static_cast<AliMUONCluster&>(obj); | |
e0de1dd9 | 346 | dest.fPads.Delete(); |
347 | dest.fPads = fPads; | |
99ccb7f7 | 348 | dest.fHasPosition = fHasPosition; |
349 | dest.fPosition = fPosition; | |
350 | dest.fPositionError = fPositionError; | |
351 | dest.fHasCharge = fHasCharge; | |
99ccb7f7 | 352 | dest.fChi2 = fChi2; |
353 | for ( Int_t i = 0; i < 2; ++i ) | |
354 | { | |
355 | dest.fRawCharge[i] = fRawCharge[i]; | |
356 | dest.fCharge[i] = fCharge[i]; | |
357 | dest.fMultiplicity[i] = fMultiplicity[i]; | |
358 | dest.fIsSaturated[i] = fIsSaturated[i]; | |
359 | } | |
360 | } | |
361 | ||
362 | //_____________________________________________________________________________ | |
363 | Float_t | |
364 | AliMUONCluster::Charge() const | |
365 | { | |
366 | /// Return the average charge over both cathodes | |
530acd78 | 367 | |
368 | if ( Multiplicity(0) && Multiplicity(1) ) | |
369 | { | |
370 | return (Charge(0)+Charge(1))/2.0; | |
371 | } | |
372 | else if ( Multiplicity(0) ) | |
373 | { | |
374 | return Charge(0); | |
375 | } | |
376 | else if ( Multiplicity(1) ) | |
377 | { | |
378 | return Charge(1); | |
379 | } | |
380 | AliError("Should not be here ?!"); | |
381 | return -1.0; | |
99ccb7f7 | 382 | } |
383 | ||
384 | //_____________________________________________________________________________ | |
385 | Float_t | |
386 | AliMUONCluster::Charge(Int_t cathode) const | |
387 | { | |
388 | /// Returns the charge of a given cathode | |
389 | if ( !fHasCharge ) return RawCharge(cathode); | |
390 | ||
391 | if ( cathode == 0 || cathode == 1 ) | |
392 | { | |
393 | return fCharge[cathode]; | |
394 | } | |
395 | return 0; | |
396 | } | |
397 | ||
398 | //_____________________________________________________________________________ | |
399 | Float_t | |
400 | AliMUONCluster::ChargeAsymmetry() const | |
401 | { | |
402 | /// Returns the charge asymmetry | |
403 | if ( Charge() > 0 ) | |
404 | { | |
405 | return TMath::Abs(Charge(0)-Charge(1))/Charge(); | |
406 | } | |
407 | return 0; | |
408 | } | |
409 | ||
00de388f | 410 | //_____________________________________________________________________________ |
411 | TVector2 | |
412 | AliMUONCluster::MaxPadDimensions(Int_t statusMask, Bool_t matchMask) const | |
413 | { | |
414 | /// Returns the maximum pad dimensions (half sizes), only considering | |
415 | /// pads matching (or not, depending matchMask) a given mask | |
416 | ||
417 | TVector2 cath0(MaxPadDimensions(0,statusMask,matchMask)); | |
418 | TVector2 cath1(MaxPadDimensions(1,statusMask,matchMask)); | |
419 | ||
420 | return TVector2( TMath::Max(cath0.X(),cath1.X()), | |
421 | TMath::Max(cath0.Y(),cath1.Y()) ); | |
422 | } | |
423 | ||
424 | //_____________________________________________________________________________ | |
425 | TVector2 | |
426 | AliMUONCluster::MaxPadDimensions(Int_t cathode, | |
427 | Int_t statusMask, Bool_t matchMask) const | |
428 | { | |
429 | /// Returns the maximum pad dimensions (half sizes), only considering | |
430 | /// pads matching (or not, depending matchMask) a given mask, within a | |
431 | /// given cathode | |
432 | ||
433 | Double_t xmax(0); | |
434 | Double_t ymax(0); | |
435 | ||
436 | for ( Int_t i = 0; i < Multiplicity(); ++i ) | |
437 | { | |
438 | AliMUONPad* pad = Pad(i); | |
439 | if ( ShouldUsePad(*pad,cathode,statusMask,matchMask) ) | |
440 | { | |
441 | xmax = TMath::Max(xmax,pad->DX()); | |
442 | ymax = TMath::Max(ymax,pad->DY()); | |
443 | } | |
444 | } | |
445 | return TVector2(xmax,ymax); | |
446 | } | |
447 | ||
99ccb7f7 | 448 | //_____________________________________________________________________________ |
449 | TVector2 | |
450 | AliMUONCluster::MinPadDimensions(Int_t statusMask, Bool_t matchMask) const | |
451 | { | |
452 | /// Returns the minimum pad dimensions (half sizes), only considering | |
453 | /// pads matching (or not, depending matchMask) a given mask | |
454 | ||
455 | TVector2 cath0(MinPadDimensions(0,statusMask,matchMask)); | |
456 | TVector2 cath1(MinPadDimensions(1,statusMask,matchMask)); | |
457 | ||
458 | return TVector2( TMath::Min(cath0.X(),cath1.X()), | |
459 | TMath::Min(cath0.Y(),cath1.Y()) ); | |
460 | } | |
461 | ||
462 | //_____________________________________________________________________________ | |
463 | TVector2 | |
464 | AliMUONCluster::MinPadDimensions(Int_t cathode, | |
465 | Int_t statusMask, Bool_t matchMask) const | |
466 | { | |
467 | /// Returns the minimum pad dimensions (half sizes), only considering | |
468 | /// pads matching (or not, depending matchMask) a given mask, within a | |
469 | /// given cathode | |
470 | ||
471 | Double_t xmin(1E9); | |
472 | Double_t ymin(1E9); | |
473 | ||
474 | for ( Int_t i = 0; i < Multiplicity(); ++i ) | |
475 | { | |
476 | AliMUONPad* pad = Pad(i); | |
477 | if ( ShouldUsePad(*pad,cathode,statusMask,matchMask) ) | |
478 | { | |
479 | xmin = TMath::Min(xmin,pad->DX()); | |
480 | ymin = TMath::Min(ymin,pad->DY()); | |
481 | } | |
482 | } | |
483 | return TVector2(xmin,ymin); | |
484 | } | |
485 | ||
486 | //_____________________________________________________________________________ | |
487 | Int_t | |
488 | AliMUONCluster::Multiplicity() const | |
489 | { | |
490 | /// Returns the total number of pads in this cluster | |
491 | return Multiplicity(0)+Multiplicity(1); | |
492 | } | |
493 | ||
494 | //_____________________________________________________________________________ | |
495 | Int_t | |
496 | AliMUONCluster::Multiplicity(Int_t cathode) const | |
497 | { | |
498 | /// Returns the number of pads in this cluster, in the given cathode | |
499 | if ( cathode == 0 || cathode == 1 ) | |
500 | { | |
501 | return fMultiplicity[cathode]; | |
502 | } | |
503 | return 0; | |
504 | } | |
505 | ||
506 | //_____________________________________________________________________________ | |
507 | AliMpIntPair | |
508 | AliMUONCluster::NofPads(Int_t statusMask, Bool_t matchMask) const | |
509 | { | |
510 | /// Number of pads satisfying (or not, depending matchMask) a | |
511 | /// given mask | |
512 | ||
513 | Int_t nx, ny; | |
514 | ||
515 | TVector2 dim0(MinPadDimensions(0,statusMask,matchMask)); | |
516 | TVector2 dim1(MinPadDimensions(1,statusMask,matchMask)); | |
517 | ||
518 | AliMpIntPair npad0(NofPads(0,statusMask,matchMask)); | |
519 | AliMpIntPair npad1(NofPads(1,statusMask,matchMask)); | |
520 | ||
521 | if ( TMath::Abs( (dim0-dim1).X() ) < 1E-3 ) | |
522 | { | |
523 | nx = TMath::Max( npad0.GetFirst(), npad1.GetFirst() ); | |
524 | } | |
525 | else | |
526 | { | |
527 | nx = dim0.X() < dim1.X() ? npad0.GetFirst() : npad1.GetFirst(); | |
528 | } | |
529 | ||
530 | if ( TMath::Abs( (dim0-dim1).Y() ) < 1E-3 ) | |
531 | { | |
532 | ny = TMath::Max( npad0.GetSecond(), npad1.GetSecond() ); | |
533 | } | |
534 | else | |
535 | { | |
536 | ny = dim0.Y() < dim1.Y() ? npad0.GetSecond() : npad1.GetSecond(); | |
537 | } | |
538 | ||
539 | return AliMpIntPair(nx,ny); | |
540 | } | |
541 | ||
542 | //_____________________________________________________________________________ | |
543 | AliMpIntPair | |
544 | AliMUONCluster::NofPads(Int_t cathode, | |
545 | Int_t statusMask, Bool_t matchMask) const | |
546 | { | |
547 | /// Number of pads of a given cathode, satisfying (or not, | |
548 | /// depending matchMask) a given mask | |
549 | ||
550 | Int_t n = Multiplicity(cathode); | |
551 | if (!n) | |
552 | { | |
553 | return AliMpIntPair(0,0); | |
554 | } | |
555 | Double_t* x = new Double_t[n]; | |
556 | Double_t* y = new Double_t[n]; | |
557 | Int_t np(0); | |
558 | ||
559 | for ( Int_t i = 0; i < Multiplicity(); ++i ) | |
560 | { | |
561 | AliMUONPad* pad = Pad(i); | |
562 | if ( ShouldUsePad(*pad,cathode,statusMask,matchMask) ) | |
563 | { | |
564 | x[np] = pad->X(); | |
565 | y[np] = pad->Y(); | |
566 | ++np; | |
567 | } | |
568 | } | |
569 | ||
570 | Int_t cx = Unique(np,x,0.01); | |
571 | Int_t cy = Unique(np,y,0.01); | |
572 | ||
573 | delete[] x; | |
574 | delete[] y; | |
575 | ||
576 | return AliMpIntPair(cx,cy); | |
577 | } | |
578 | ||
579 | //_____________________________________________________________________________ | |
580 | AliMUONPad* | |
581 | AliMUONCluster::Pad(Int_t index) const | |
582 | { | |
583 | /// Returns the index-th pad | |
584 | ||
e0de1dd9 | 585 | if (fPads.IsEmpty()) return 0x0; |
586 | if ( index < fPads.GetLast()+1 ) | |
99ccb7f7 | 587 | { |
e0de1dd9 | 588 | return static_cast<AliMUONPad*>(fPads.At(index)); |
99ccb7f7 | 589 | } |
590 | else | |
591 | { | |
00de388f | 592 | AliError(Form("Requested index %d out of bounds (%d) Mult is %d",index, |
e0de1dd9 | 593 | fPads.GetLast(),Multiplicity())); |
00de388f | 594 | DumpMe(); |
99ccb7f7 | 595 | } |
596 | return 0x0; | |
597 | } | |
598 | ||
599 | ||
600 | //_____________________________________________________________________________ | |
601 | void | |
602 | AliMUONCluster::Paint(Option_t*) | |
603 | { | |
604 | /// Paint this cluster | |
605 | if (!Multiplicity()) return; | |
606 | ||
607 | AliMpArea area(Area()); | |
608 | ||
609 | gPad->Range(area.LeftBorder(),area.DownBorder(),area.RightBorder(),area.UpBorder()); | |
610 | ||
611 | gVirtualX->SetFillStyle(0); | |
612 | ||
613 | gVirtualX->SetLineColor(2); | |
614 | gVirtualX->SetLineWidth(4); | |
615 | for ( Int_t i = 0; i < Multiplicity(); ++i) | |
616 | { | |
617 | AliMUONPad* pad = Pad(i); | |
618 | if ( pad->Cathode() == 0 ) pad->Paint(); | |
619 | } | |
620 | ||
621 | gVirtualX->SetLineColor(4); | |
622 | gVirtualX->SetLineWidth(2); | |
623 | for ( Int_t i = 0; i < Multiplicity(); ++i) | |
624 | { | |
625 | AliMUONPad* pad = Pad(i); | |
626 | if ( pad->Cathode() == 1 ) pad->Paint(); | |
627 | } | |
628 | ||
629 | } | |
630 | ||
00de388f | 631 | //_____________________________________________________________________________ |
632 | void | |
633 | AliMUONCluster::DumpMe() const | |
634 | { | |
635 | /// printout | |
636 | cout << "Cluster Id " << GetUniqueID() << " npads=" << Multiplicity() | |
637 | << "(" << Multiplicity(0) << "," << Multiplicity(1) << ") RawCharge=" | |
638 | << RawCharge() << " (" << RawCharge(0) << "," << RawCharge(1) | |
639 | << ") Charge=(" << Charge(0) << "," << Charge(1) <<")"; | |
640 | if ( HasPosition() ) | |
641 | { | |
642 | cout << " (x,y)=(" << Position().X() << "," << Position().Y() << ")"; | |
643 | cout << " (errX,errY)=(" << PositionError().X() << "," << PositionError().Y() << ")"; | |
644 | } | |
645 | cout << endl; | |
646 | // cout << " " << Area() << endl; | |
e0de1dd9 | 647 | for (Int_t i = 0; i < fPads.GetSize(); ++i) |
00de388f | 648 | { |
e0de1dd9 | 649 | cout << Form("fPads[%d]=%x",i,fPads.At(i)) << endl; |
650 | if ( fPads.At(i) ) fPads.At(i)->Print(); | |
651 | } | |
00de388f | 652 | } |
653 | ||
654 | ||
99ccb7f7 | 655 | //_____________________________________________________________________________ |
656 | void | |
657 | AliMUONCluster::Print(Option_t* opt) const | |
658 | { | |
659 | /// printout | |
660 | cout << "Cluster Id " << GetUniqueID() << " npads=" << Multiplicity() | |
661 | << "(" << Multiplicity(0) << "," << Multiplicity(1) << ") RawCharge=" | |
662 | << RawCharge() << " (" << RawCharge(0) << "," << RawCharge(1) | |
97d5019e | 663 | << ") Charge=(" << Charge(0) << "," << Charge(1) <<")"; |
99ccb7f7 | 664 | if ( HasPosition() ) |
665 | { | |
666 | cout << " (x,y)=(" << Position().X() << "," << Position().Y() << ")"; | |
667 | cout << " (errX,errY)=(" << PositionError().X() << "," << PositionError().Y() << ")"; | |
668 | } | |
00de388f | 669 | cout << " " << Area(); |
e0de1dd9 | 670 | |
671 | TObjArray* a = static_cast<TObjArray*>(fPads.Clone()); | |
672 | a->Sort(); | |
673 | a->Print("",opt); | |
674 | delete a; | |
99ccb7f7 | 675 | } |
676 | ||
677 | //_____________________________________________________________________________ | |
00de388f | 678 | //Bool_t |
679 | //AliMUONCluster::IsEqual(const TObject* obj) const | |
680 | //{ | |
681 | // const AliMUONCluster* c = static_cast<const AliMUONCluster*>(obj); | |
682 | // if ( c->Multiplicity() != Multiplicity() ) return kFALSE; | |
683 | // | |
684 | // for ( Int_t i = 0; i < c->Multiplicity(); ++i ) | |
685 | // { | |
686 | // AliMUONPad* p = c->Pad(i); | |
687 | // if ( p->Compare(Pad(i)) ) return kFALSE; | |
688 | // } | |
689 | // return kTRUE; | |
690 | //} | |
691 | ||
692 | //_____________________________________________________________________________ | |
693 | Int_t | |
694 | AliMUONCluster::Compare(const TObject* obj) const | |
99ccb7f7 | 695 | { |
00de388f | 696 | /// Compare two clusters. Comparison is made on position and rawcharge only. |
697 | ||
698 | const AliMUONCluster* cluster = static_cast<const AliMUONCluster*>(obj); | |
699 | ||
700 | AliMpArea carea(cluster->Area()); | |
701 | AliMpArea area(Area()); | |
702 | ||
703 | if ( carea.Position().X() > area.Position().X() ) | |
704 | { | |
705 | return 1; | |
706 | } | |
707 | else if ( carea.Position().X() < area.Position().X() ) | |
708 | { | |
709 | return -1; | |
710 | } | |
711 | else | |
712 | { | |
713 | if ( carea.Position().Y() > area.Position().Y() ) | |
714 | { | |
715 | return 1; | |
716 | } | |
717 | else if ( carea.Position().Y() < area.Position().Y() ) | |
718 | { | |
719 | return -1; | |
720 | } | |
721 | else | |
722 | { | |
723 | if ( cluster->RawCharge() > RawCharge() ) | |
724 | { | |
725 | return 1; | |
726 | } | |
727 | else if ( cluster->RawCharge() < RawCharge() ) | |
728 | { | |
729 | return -1; | |
730 | } | |
731 | } | |
732 | } | |
733 | return 0; | |
99ccb7f7 | 734 | } |
735 | ||
736 | //_____________________________________________________________________________ | |
737 | void | |
738 | AliMUONCluster::RemovePad(AliMUONPad* pad) | |
739 | { | |
740 | /// Remove a pad. | |
741 | /// As a consequence, some internal information must be updated | |
742 | ||
e0de1dd9 | 743 | fPads.Remove(pad); |
744 | fPads.Compress(); | |
99ccb7f7 | 745 | // update cluster's data |
746 | fIsSaturated[0]=fIsSaturated[1]=kFALSE; | |
747 | fMultiplicity[0]=fMultiplicity[1]=0; | |
748 | fRawCharge[0]=fRawCharge[1]=0; | |
e0de1dd9 | 749 | for ( Int_t i = 0; i <= fPads.GetLast(); ++i ) |
99ccb7f7 | 750 | { |
751 | AliMUONPad* p = Pad(i); | |
752 | if ( p->IsSaturated() ) | |
753 | { | |
754 | fIsSaturated[p->Cathode()] = kTRUE; | |
755 | } | |
756 | ++fMultiplicity[p->Cathode()]; | |
757 | fRawCharge[p->Cathode()] += p->Charge(); | |
758 | } | |
99ccb7f7 | 759 | } |
760 | ||
761 | //_____________________________________________________________________________ | |
762 | Float_t | |
763 | AliMUONCluster::RawCharge() const | |
764 | { | |
765 | /// Returns the raw average charge | |
766 | return (RawCharge(0)+RawCharge(1))/2.0; | |
767 | } | |
768 | ||
769 | //_____________________________________________________________________________ | |
770 | Float_t | |
771 | AliMUONCluster::RawCharge(Int_t cathode) const | |
772 | { | |
773 | /// Returns the average charge of a given cathode | |
774 | if ( cathode == 0 || cathode == 1 ) | |
775 | { | |
776 | return fRawCharge[cathode]; | |
777 | } | |
778 | return 0; | |
779 | } | |
780 | ||
781 | //_____________________________________________________________________________ | |
782 | Float_t | |
783 | AliMUONCluster::RawChargeAsymmetry() const | |
784 | { | |
785 | /// Returns the raw charge asymmetry | |
786 | if ( RawCharge() > 0 ) | |
787 | { | |
788 | return TMath::Abs(RawCharge(0)-RawCharge(1))/RawCharge(); | |
789 | } | |
790 | return 0; | |
791 | } |