18 #include <Riostream.h>
20 #include <TObjArray.h>
21 #include <TVirtualPad.h>
22 #include <TVirtualX.h>
54 Int_t cathode, Int_t statusMask, Bool_t matchMask)
59 if ( pad.
Status() < 0 )
return kFALSE;
63 Bool_t test = ( ( pad.
Status() & statusMask ) != 0 );
66 test = ( pad.
Status() == 0 );
68 if ( ( test && matchMask ) || ( !test && !matchMask ) )
77 Int_t Unique(Int_t n, Double_t*
array, Double_t precision)
85 Int_t* index =
new Int_t[n];
87 TMath::Sort(n,array,index);
89 for ( Int_t i = 1; i < n; ++i )
91 if ( array[index[i]] - array[index[i-1]] < -precision ) ++count;
104 fHasPosition(kFALSE),
106 fPositionError(1E9,1E9),
115 fPads.SetOwner(kTRUE);
122 fHasPosition(kFALSE),
124 fPositionError(1E9,1E9),
129 fPads.SetOwner(kTRUE);
166 if (
fPads.IsEmpty())
return kFALSE;
171 if ( pad.
Compare(p) == 0 )
return kTRUE;
186 AliError(
"I already got this pad : ");
187 StdoutToAliError(p->
Print(););
225 s += Form(
" (%d,%d,%d) ",p->
Cathode(),p->
Ix(),p->
Iy());
237 static Double_t precision = 1E-4;
238 static TVector2 precisionAdjustment(precision,precision);
268 TVector2 lowerLeft(1E9,1E9);
269 TVector2 upperRight(-1E9,-1E9);
276 lowerLeft.Set( TMath::Min(ll.X(),lowerLeft.X()),
277 TMath::Min(ll.Y(),lowerLeft.Y()) );
278 upperRight.Set( TMath::Max(ur.X(),upperRight.X()),
279 TMath::Max(ur.Y(),upperRight.Y()) );
283 return AliMpArea((lowerLeft+upperRight).X()/2,(lowerLeft+upperRight).Y()/2,
284 (upperRight-lowerLeft).X()/2, (upperRight-lowerLeft).Y()/2);
295 TVector2 lowerLeft(1E9,1E9);
296 TVector2 upperRight(-1E9,-1E9);
301 if ( pad->
Cathode() == cathode )
305 lowerLeft.Set( TMath::Min(ll.X(),lowerLeft.X()),
306 TMath::Min(ll.Y(),lowerLeft.Y()) );
307 upperRight.Set( TMath::Max(ur.X(),upperRight.X()),
308 TMath::Max(ur.Y(),upperRight.Y()) );
313 return AliMpArea((lowerLeft+upperRight).X()/2,(lowerLeft+upperRight).Y()/2,
314 (upperRight-lowerLeft).X()/2, (upperRight-lowerLeft).Y()/2);
364 for ( Int_t i = 0; i <=
fPads.GetLast(); ++i )
374 for ( Int_t i = 0; i < 2; ++i )
401 AliError(
"Should not be here ?!");
412 if ( cathode == 0 || cathode == 1 )
441 return TVector2( TMath::Max(cath0.X(),cath1.X()),
442 TMath::Max(cath0.Y(),cath1.Y()) );
448 Int_t statusMask, Bool_t matchMask)
const
460 if ( ShouldUsePad(*pad,cathode,statusMask,matchMask) )
462 xmax = TMath::Max(xmax,pad->
DX());
463 ymax = TMath::Max(ymax,pad->
DY());
466 return TVector2(xmax,ymax);
479 return TVector2( TMath::Min(cath0.X(),cath1.X()),
480 TMath::Min(cath0.Y(),cath1.Y()) );
486 Int_t statusMask, Bool_t matchMask)
const
498 if ( ShouldUsePad(*pad,cathode,statusMask,matchMask) )
500 xmin = TMath::Min(xmin,pad->
DX());
501 ymin = TMath::Min(ymin,pad->
DY());
504 return TVector2(xmin,ymin);
520 if ( cathode == 0 || cathode == 1 )
539 Long_t npad0(
NofPads(0,statusMask,matchMask));
540 Long_t npad1(
NofPads(1,statusMask,matchMask));
542 if ( TMath::Abs( (dim0-dim1).X() ) < 1E-3 )
551 if ( TMath::Abs( (dim0-dim1).Y() ) < 1E-3 )
566 Int_t statusMask, Bool_t matchMask)
const
576 Double_t* x =
new Double_t[n];
577 Double_t* y =
new Double_t[n];
583 if ( ShouldUsePad(*pad,cathode,statusMask,matchMask) )
591 Int_t cx = Unique(np,x,0.01);
592 Int_t cy = Unique(np,y,0.01);
606 if (
fPads.IsEmpty())
return 0x0;
607 if ( index <
fPads.GetLast()+1 )
613 AliError(Form(
"Requested index %d out of bounds (%d) Mult is %d",index,
632 gVirtualX->SetFillStyle(0);
634 gVirtualX->SetLineColor(2);
635 gVirtualX->SetLineWidth(4);
642 gVirtualX->SetLineColor(4);
643 gVirtualX->SetLineWidth(2);
657 cout <<
"Cluster Id " << GetUniqueID() <<
" npads=" <<
Multiplicity()
668 for (Int_t i = 0; i <
fPads.GetSize(); ++i)
670 cout << Form(
"fPads[%d]=%p",i,
fPads.At(i)) << endl;
681 cout <<
"Cluster Id " << GetUniqueID() <<
" npads=" <<
Multiplicity()
690 cout <<
" " <<
Area();
724 if ( carea.GetPositionX() > area.GetPositionX() )
728 else if ( carea.GetPositionX() < area.GetPositionX() )
734 if ( carea.GetPositionY() > area.GetPositionY() )
738 else if ( carea.GetPositionY() < area.GetPositionY() )
771 for ( Int_t i = 0; i <=
fPads.GetLast(); ++i )
796 if ( cathode == 0 || cathode == 1 )
static Bool_t AreOverlapping(const AliMUONPad &d1, const AliMUONPad &d2, const TVector2 &precision, AliMpArea &overlapArea)
Bool_t HasPosition() const
Return false for pre-cluster.
Bool_t IsReal() const
Return info whether this is a real pad or a virtual one.
static Bool_t AreOverlapping(const AliMUONCluster &c1, const AliMUONCluster &c2)
TVector2 MaxPadDimensions(Int_t cathode, Int_t statusMask, Bool_t matchMask) const
Return the biggest pad dimensions for a given cathode.
Float_t RawCharge() const
By default, return the average of both cathode RawCharges.
Bool_t IsSaturated() const
Return info whether this pad is saturated or not.
Double_t LeftBorder() const
Float_t fCharge[2]
cathode (re)computed charges
A group of adjacent pads.
virtual Int_t Compare(const TObject *obj) const
Float_t fChi2
chi2 of the RawCharge fit (if any)
TVector2 PositionError() const
Return errors on (x,y)
TVector2 Dimensions() const
Return half dimensions in x and y (cm)
virtual void Print(Option_t *opt="") const
MpPair_t Pair(Int_t first, Int_t second)
Encode the pair of integers to another integer.
A rectangle area positioned in plane..
virtual Int_t Compare(const TObject *obj) const
Double_t DY() const
Return half dimensions in y (cm)
Float_t fRawCharge[2]
cathode RawCharges
void Clear(Option_t *opt="")
AliMUONCluster & operator=(const AliMUONCluster &rhs)
Int_t Multiplicity() const
Bool_t fHasPosition
false for pre-cluster (i.e. not yet computed)
Double_t Y() const
Return position in y (cm)
Bool_t IsMonoCathode() const
Bool_t Contains(const AliMUONPad &pad) const
Int_t Iy() const
Return y-index.
virtual void Paint(Option_t *opt="")
TVector2 fPosition
(x,y) of that cluster (only valid if fHasPosition is kTRUE)
Double_t X() const
Return position in x (cm)
TVector2 fPositionError
errors on (x,y)
Int_t Cathode() const
Return cathode number.
Double_t UpBorder() const
Bool_t fIsSaturated[2]
saturation status of cathodes
void RemovePad(AliMUONPad *pad)
Int_t fMultiplicity[2]
number of pads in each cathode
TVector2 Position() const
Return (x,y) of that cluster.
AliMUONPad * AddPad(const AliMUONPad &pad)
Double_t DownBorder() const
TVector2 Position() const
Return positions in x and y (cm)
Long_t NofPads(Int_t cathode, Int_t statusMask, Bool_t matchMask) const
Compute number of pads in X and Y direction for a given cathode.
Int_t Ix() const
Return x-index.
AliMpArea Area() const
Area that contains all the pads (whatever the cathode)
virtual void Paint(Option_t *opt="")
Int_t PairFirst(MpPair_t pair)
Decode the first integer from encoded pair.
void Print(Option_t *opt="") const
Double_t Charge() const
Return pad charge.
void SetClusterId(Int_t id)
Set cluster id this pad belongs to -1 if not attached to a cluster.
Float_t ChargeAsymmetry() const
Return the cathode's charges asymmetry.
virtual void Copy(TObject &obj) const
Int_t PairSecond(MpPair_t pair)
Decode the second integer from encoded pair.
TVector2 MinPadDimensions(Int_t cathode, Int_t statusMask, Bool_t matchMask) const
Return the smallest pad dimensions for a given cathode.
Int_t Status() const
Return status word.
AliMUONPad * Pad(Int_t index) const
Float_t RawChargeAsymmetry() const
Return the cathode's raw charges asymmetry.
Double_t RightBorder() const
Combination of digit and mppad informations.
virtual ~AliMUONCluster()
TObjArray fPads
AliMUONPad(s) composing this cluster.
void AddCluster(const AliMUONCluster &cluster)
Double_t DX() const
Return half dimensions in x (cm)
Bool_t fHasCharge
false if SetCharge has not been called