]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONPointWithRef.cxx
#102885: Patch for MUON code
[u/mrichter/AliRoot.git] / MUON / AliMUONPointWithRef.cxx
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
18 ///\class AliMUONPointWithRef
19 ///
20 /// A class used to represent a point with an external integer reference
21 /// and with a specific sorting method (see AliMUONContourMaker)
22 ///
23 /// \author Laurent Aphecetche, Subatech
24 ///
25
26 #include "AliMUONPointWithRef.h"
27
28 #include "AliMUONSegment.h"
29 #include "Riostream.h"
30 #include "TString.h"
31
32 using std::cout;
33 using std::endl;
34 //\cond CLASSIMP
35 ClassImp(AliMUONPointWithRef)
36 //\endcond
37
38 //_____________________________________________________________________________
39 AliMUONPointWithRef::AliMUONPointWithRef() : fX(), fY(), fRef(-1)
40 {
41   /// default ctor
42 }
43
44 //_____________________________________________________________________________
45 AliMUONPointWithRef::AliMUONPointWithRef(Double_t x, Double_t y, Int_t ref)
46 : fX(x), fY(y), fRef(ref)
47 {
48   /// ctor
49 }
50
51 //_____________________________________________________________________________
52 Int_t   
53 AliMUONPointWithRef::Compare(const TObject* obj) const
54 {
55   /// Should serve to sort the vertical edges in ascending order, first on absissa, 
56   /// then on ordinate
57   
58   if ( this == obj ) return 0;
59   
60   const AliMUONPointWithRef* rhs = static_cast<const AliMUONPointWithRef*>(obj);
61
62   if ( AliMUONSegment::AreEqual(Y(),rhs->Y()) )
63   {
64     if ( AliMUONSegment::AreEqual(X(),rhs->X()) )
65     {
66       return 0;
67     }
68     else if ( X() > rhs->X() )
69     {
70       return 1;
71     }
72     else 
73       return -1;
74   }
75   else if ( Y() < rhs->Y() )
76   {
77     return -1;
78   }
79   else
80   {
81     return 1;
82   }
83 }
84
85 //_____________________________________________________________________________
86 void 
87 AliMUONPointWithRef::Print(Option_t*) const
88 {
89   /// Printout
90   cout << Form("(%10.5f,%10.5f) [%4d]",X(),Y(),Ref()) << endl;
91 }