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