]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONRawClusterV2.cxx
bugfix: corrected defines to use right default algorithms
[u/mrichter/AliRoot.git] / MUON / AliMUONRawClusterV2.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 //-----------------------------------------------------------------------------
19 /// \class AliMUONRawClusterV2
20 ///
21 /// Class for the MUON RecPoint
22 ///
23 /// \author Philippe Pillot, Subatech
24 //-----------------------------------------------------------------------------
25
26
27 #include "AliMUONRawClusterV2.h"
28 #include "AliMUONConstants.h"
29
30 #include "AliLog.h"
31
32 #include "Riostream.h"
33
34 /// \cond CLASSIMP
35 ClassImp(AliMUONRawClusterV2)
36 /// \endcond
37
38
39 //____________________________________________________
40 AliMUONRawClusterV2::AliMUONRawClusterV2() 
41   : AliMUONVCluster(),
42     fX(FLT_MAX),
43     fY(FLT_MAX),
44     fZ(FLT_MAX),
45     fErrX2(AliMUONConstants::DefaultNonBendingReso2()),
46     fErrY2(AliMUONConstants::DefaultBendingReso2()),
47     fQ(0.),
48     fChi2(0.),
49     fNDigits(0),
50     fDigitsId(0x0)
51 {
52   /// Default Constructor
53 }
54
55 //_____________________________________________________________________________
56 AliMUONRawClusterV2::AliMUONRawClusterV2(Int_t chamberId, Int_t detElemId, Int_t clusterIndex)
57   : AliMUONVCluster(chamberId, detElemId, clusterIndex),
58     fX(FLT_MAX),
59     fY(FLT_MAX),
60     fZ(FLT_MAX),
61     fErrX2(AliMUONConstants::DefaultNonBendingReso2()),
62     fErrY2(AliMUONConstants::DefaultBendingReso2()),
63     fQ(0.),
64     fChi2(0.),
65     fNDigits(0),
66     fDigitsId(0x0)
67 {
68   /// Constructor
69 }
70
71 //____________________________________________________
72 AliMUONRawClusterV2::~AliMUONRawClusterV2() 
73 {
74   /// Destructor
75   delete [] fDigitsId;
76 }
77
78 //____________________________________________________
79 AliMUONRawClusterV2::AliMUONRawClusterV2(const AliMUONRawClusterV2& cluster)
80   : AliMUONVCluster(cluster),
81     fX(cluster.fX),
82     fY(cluster.fY),
83     fZ(cluster.fZ),
84     fErrX2(cluster.fErrX2),
85     fErrY2(cluster.fErrY2),
86     fQ(cluster.fQ),
87     fChi2(cluster.fChi2),
88     fNDigits(cluster.fNDigits),
89     fDigitsId(0x0)
90
91 {
92   /// Copy constructor
93   
94   if (cluster.fDigitsId) {
95     fDigitsId = new UInt_t[fNDigits];
96     memcpy(fDigitsId,cluster.fDigitsId, fNDigits*sizeof(UInt_t));
97   }
98 }
99
100   //__________________________________________________________________________
101 AliMUONRawClusterV2 & AliMUONRawClusterV2::operator=(const AliMUONRawClusterV2& cluster)
102 {
103   /// Asignment operator
104   
105   // check assignement to self
106   if (this == &cluster)
107     return *this;
108
109   // base class assignement
110   AliMUONVCluster::operator=(cluster);
111   
112   fX = cluster.fX;
113   fY = cluster.fY;
114   fZ = cluster.fZ;
115   fErrX2 = cluster.fErrX2;
116   fErrY2 = cluster.fErrY2;
117   fQ = cluster.fQ;
118   fChi2 = cluster.fChi2;
119   SetDigitsId(cluster.fNDigits,cluster.fDigitsId);
120
121   return *this;
122 }
123
124 //____________________________________________________
125 void AliMUONRawClusterV2::Clear(Option_t*)
126 {
127   /// Reset this cluster, in particular the internal arrays are deleted.
128   
129   fX = FLT_MAX;
130   fY = FLT_MAX;
131   fZ = FLT_MAX;
132   fErrX2 = AliMUONConstants::DefaultNonBendingReso2();
133   fErrY2 = AliMUONConstants::DefaultBendingReso2();
134   fQ = 0.;
135   fChi2 = 0.;
136   fNDigits = 0;
137   delete [] fDigitsId;
138   fDigitsId = 0x0;
139 }
140
141 //____________________________________________________
142 void AliMUONRawClusterV2::SetDigitsId(Int_t nDigits, const UInt_t *digitsId)
143 {
144   /// Set size of array of digits Id to n ints and set the content
145   /// if digitsId is not given the array is filled with id=0
146   
147   if (fDigitsId && fNDigits != nDigits) {
148     delete [] fDigitsId;
149     fDigitsId = 0;
150   }
151   fNDigits = nDigits;
152   if (fNDigits == 0) return;
153   if (!fDigitsId) fDigitsId = new UInt_t[fNDigits];
154   if (digitsId == 0)
155     for (Int_t i=0; i<fNDigits; i++) fDigitsId[i] = 0;
156   else
157     memcpy(fDigitsId,digitsId, fNDigits*sizeof(UInt_t));
158 }
159
160 //____________________________________________________
161 void AliMUONRawClusterV2::AddDigitId(UInt_t id)
162 {
163   /// Reset size of array of digits Id and add the new id to its content
164   
165   UInt_t *digitsIdNew = new UInt_t[fNDigits+1];
166   memcpy(digitsIdNew,fDigitsId, fNDigits*sizeof(UInt_t));
167   digitsIdNew[fNDigits++] = id;
168   delete fDigitsId;
169   fDigitsId = digitsIdNew;
170 }
171
172 //____________________________________________________
173 Int_t AliMUONRawClusterV2::Compare(const TObject *obj) const
174 {
175 /// Compare
176
177   const AliMUONRawClusterV2* raw = static_cast<const AliMUONRawClusterV2*>(obj);
178   if ( GetCharge() > raw->GetCharge() ) 
179   {
180     return 1;
181   }
182   else if ( GetCharge() < raw->GetCharge() ) 
183   {
184     return -1;
185   }
186   return 0;
187 }