]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDcluster.cxx
fix for 64bit architectures after last commit
[u/mrichter/AliRoot.git] / TRD / AliTRDcluster.cxx
CommitLineData
46d29e70 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
88cb7938 16/* $Id$ */
b9d0a01d 17
88cb7938 18
19///////////////////////////////////////////////////////////////////////////////
20// //
21// TRD cluster //
22// //
23///////////////////////////////////////////////////////////////////////////////
46d29e70 24
25#include "AliTRDcluster.h"
46d29e70 26
46d29e70 27ClassImp(AliTRDcluster)
bdb68f8c 28
6d50f529 29//___________________________________________________________________________
30AliTRDcluster::AliTRDcluster()
31 :AliCluster()
32 ,fDetector(0)
af26ce80 33 ,fLocalTimeBin(0)
6d50f529 34 ,fQ(0)
35 ,fNPads(0)
36 ,fCenter(0)
af26ce80 37 ,fPadCol(0)
38 ,fPadRow(0)
39 ,fPadTime(0)
6d50f529 40{
bdb68f8c 41 //
a6dd11e9 42 // Default constructor
bdb68f8c 43 //
6d50f529 44
45 for (Int_t i = 0; i < 7; i++) {
46 fSignals[i] = 0;
47 }
48
bdb68f8c 49}
6d50f529 50
34eaaa7e 51//___________________________________________________________________________
52AliTRDcluster::AliTRDcluster(Int_t det, Float_t q
53 , Float_t *pos, Float_t *sig
54 , Int_t *tracks, Char_t npads, Short_t *signals
af26ce80 55 , UChar_t col, UChar_t row, UChar_t time
56 , Char_t timebin, Float_t center, UShort_t volid)
57 :AliCluster(volid,pos[0],pos[1],pos[2],sig[0],sig[1],0.0,0x0)
34eaaa7e 58 ,fDetector(det)
af26ce80 59 ,fLocalTimeBin(timebin)
34eaaa7e 60 ,fQ(q)
61 ,fNPads(npads)
62 ,fCenter(center)
af26ce80 63 ,fPadCol(col)
64 ,fPadRow(row)
65 ,fPadTime(time)
34eaaa7e 66{
67 //
68 // Constructor
69 //
70
71 for (Int_t i = 0; i < 7; i++) {
72 fSignals[i] = signals[i];
73 }
74
75 if (tracks) {
76 AddTrackIndex(tracks);
77 }
78
79}
80
bbf92647 81//_____________________________________________________________________________
6d50f529 82AliTRDcluster::AliTRDcluster(const AliTRDcluster &c)
34eaaa7e 83 :AliCluster(c)
6d50f529 84 ,fDetector(c.fDetector)
af26ce80 85 ,fLocalTimeBin(c.fLocalTimeBin)
6d50f529 86 ,fQ(c.fQ)
87 ,fNPads(c.fNPads)
88 ,fCenter(c.fCenter)
af26ce80 89 ,fPadCol(c.fPadCol)
90 ,fPadRow(c.fPadRow)
91 ,fPadTime(c.fPadTime)
bbf92647 92{
93 //
94 // Copy constructor
95 //
96
75fb37cc 97 SetLabel(c.GetLabel(0),0);
98 SetLabel(c.GetLabel(1),1);
99 SetLabel(c.GetLabel(2),2);
6d50f529 100
75fb37cc 101 SetY(c.GetY());
102 SetZ(c.GetZ());
103 SetSigmaY2(c.GetSigmaY2());
104 SetSigmaZ2(c.GetSigmaZ2());
6d50f529 105
106 for (Int_t i = 0; i < 7; i++) {
107 fSignals[i] = c.fSignals[i];
108 }
109
a2b90f83 110}
111
a2b90f83 112//_____________________________________________________________________________
113void AliTRDcluster::AddTrackIndex(Int_t *track)
114{
115 //
116 // Adds track index. Currently assumed that track is an array of
117 // size 9, and up to 3 track indexes are stored in fTracks[3].
118 // Indexes are sorted according to:
119 // 1) index of max number of appearances is stored first
120 // 2) if two or more indexes appear equal number of times, the lowest
121 // ones are stored first;
122 //
bbf92647 123
88cb7938 124 const Int_t kSize = 9;
6d50f529 125 Int_t entries[kSize][2];
a2b90f83 126
6d50f529 127 Int_t i = 0;
128 Int_t j = 0;
129 Int_t k = 0;
130 Int_t index;
88cb7938 131 Bool_t indexAdded;
a2b90f83 132
6d50f529 133 for (i = 0; i < kSize; i++) {
134 entries[i][0] = -1;
135 entries[i][1] = 0;
5443e65e 136 }
a2b90f83 137
6d50f529 138 for (k = 0; k < kSize; k++) {
139
140 index = track[k];
141 indexAdded = kFALSE;
142
143 j = 0;
a2b90f83 144 if (index >= 0) {
6d50f529 145 while ((!indexAdded) && (j < kSize)) {
146 if ((entries[j][0] == index) ||
147 (entries[j][1] == 0)) {
148 entries[j][0] = index;
149 entries[j][1] = entries[j][1] + 1;
150 indexAdded = kTRUE;
a2b90f83 151 }
152 j++;
153 }
154 }
6d50f529 155
156 }
157
158 // Sort by number of appearances and index value
159 Int_t swap = 1;
160 Int_t tmp0;
161 Int_t tmp1;
162 while (swap > 0) {
163 swap = 0;
164 for (i = 0; i < (kSize - 1); i++) {
165 if ((entries[i][0] >= 0) &&
166 (entries[i+1][0] >= 0)) {
a2b90f83 167 if ((entries[i][1] < entries[i+1][1]) ||
168 ((entries[i][1] == entries[i+1][1]) &&
6d50f529 169 (entries[i][0] > entries[i+1][0]))) {
170 tmp0 = entries[i][0];
171 tmp1 = entries[i][1];
172 entries[i][0] = entries[i+1][0];
173 entries[i][1] = entries[i+1][1];
174 entries[i+1][0] = tmp0;
175 entries[i+1][1] = tmp1;
176 swap++;
a2b90f83 177 }
178 }
179 }
5443e65e 180 }
a2b90f83 181
6d50f529 182 // Set track indexes
183 for (i = 0; i < 3; i++) {
184 SetLabel(entries[i][0],i);
185 }
a2b90f83 186
187 return;
46d29e70 188
5443e65e 189}
46d29e70 190
6d50f529 191//_____________________________________________________________________________
bdb68f8c 192Float_t AliTRDcluster::GetSumS() const
193{
194 //
6d50f529 195 // Returns the total charge from a not unfolded cluster
bdb68f8c 196 //
6d50f529 197
198 Float_t sum = 0.0;
199 for (Int_t i = 0; i < 7; i++) {
200 sum += fSignals[i];
bdb68f8c 201 }
6d50f529 202
203 return sum;
bdb68f8c 204
205}