]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONRawClusterV2.cxx
Minor changes
[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
29 #include "AliLog.h"
30
31 #include <TClonesArray.h>
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(FLT_MAX),
46     fErrY2(FLT_MAX),
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(FLT_MAX),
62     fErrY2(FLT_MAX),
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   /// clear memory
128   delete [] fDigitsId;
129   fDigitsId = 0x0;
130   fNDigits = 0;
131 }
132
133 //____________________________________________________
134 void AliMUONRawClusterV2::SetDigitsId(Int_t nDigits, const UInt_t *digitsId)
135 {
136   /// Set size of array of digits Id to n ints and set the content
137   /// if digitsId is not given the array is filled with id=0
138   
139   if (fDigitsId && fNDigits != nDigits) {
140     delete [] fDigitsId;
141     fDigitsId = 0;
142   }
143   fNDigits = nDigits;
144   if (fNDigits == 0) return;
145   if (!fDigitsId) fDigitsId = new UInt_t[fNDigits];
146   if (digitsId == 0)
147     for (Int_t i=0; i<fNDigits; i++) fDigitsId[i] = 0;
148   else
149     memcpy(fDigitsId,digitsId, fNDigits*sizeof(UInt_t));
150 }
151
152 //____________________________________________________
153 void AliMUONRawClusterV2::AddDigitId(UInt_t id)
154 {
155   /// Reset size of array of digits Id and add the new id to its content
156   
157   UInt_t *digitsIdNew = new UInt_t[fNDigits+1];
158   memcpy(digitsIdNew,fDigitsId, fNDigits*sizeof(UInt_t));
159   digitsIdNew[fNDigits++] = id;
160   delete[] fDigitsId;
161   fDigitsId = digitsIdNew;
162 }
163
164 //____________________________________________________
165 Int_t AliMUONRawClusterV2::Compare(const TObject *obj) const
166 {
167 /// Compare
168
169   const AliMUONRawClusterV2* raw = static_cast<const AliMUONRawClusterV2*>(obj);
170   if ( GetCharge() > raw->GetCharge() ) 
171   {
172     return 1;
173   }
174   else if ( GetCharge() < raw->GetCharge() ) 
175   {
176     return -1;
177   }
178   return 0;
179 }