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