]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDcluster.cxx
bugfix #38673 (Kenneth): last pad per row was always ignored; corrected cleanup og...
[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()
af26ce80 32 ,fPadCol(0)
33 ,fPadRow(0)
34 ,fPadTime(0)
f5375dcb 35 ,fLocalTimeBin(0)
36 ,fNPads(0)
37 ,fClusterMasking(0)
38 ,fDetector(0)
39 ,fQ(0)
40 ,fCenter(0)
6d50f529 41{
bdb68f8c 42 //
a6dd11e9 43 // Default constructor
bdb68f8c 44 //
6d50f529 45
46 for (Int_t i = 0; i < 7; i++) {
47 fSignals[i] = 0;
48 }
49
bdb68f8c 50}
6d50f529 51
34eaaa7e 52//___________________________________________________________________________
53AliTRDcluster::AliTRDcluster(Int_t det, Float_t q
54 , Float_t *pos, Float_t *sig
55 , Int_t *tracks, Char_t npads, Short_t *signals
af26ce80 56 , UChar_t col, UChar_t row, UChar_t time
57 , Char_t timebin, Float_t center, UShort_t volid)
58 :AliCluster(volid,pos[0],pos[1],pos[2],sig[0],sig[1],0.0,0x0)
af26ce80 59 ,fPadCol(col)
60 ,fPadRow(row)
61 ,fPadTime(time)
f5375dcb 62 ,fLocalTimeBin(timebin)
63 ,fNPads(npads)
64 ,fClusterMasking(0)
65 ,fDetector(det)
66 ,fQ(q)
67 ,fCenter(center)
34eaaa7e 68{
69 //
70 // Constructor
71 //
72
73 for (Int_t i = 0; i < 7; i++) {
74 fSignals[i] = signals[i];
75 }
76
77 if (tracks) {
78 AddTrackIndex(tracks);
79 }
80
81}
82
bbf92647 83//_____________________________________________________________________________
6d50f529 84AliTRDcluster::AliTRDcluster(const AliTRDcluster &c)
34eaaa7e 85 :AliCluster(c)
af26ce80 86 ,fPadCol(c.fPadCol)
87 ,fPadRow(c.fPadRow)
88 ,fPadTime(c.fPadTime)
f5375dcb 89 ,fLocalTimeBin(c.fLocalTimeBin)
90 ,fNPads(c.fNPads)
91 ,fClusterMasking(c.fClusterMasking)
92 ,fDetector(c.fDetector)
93 ,fQ(c.fQ)
94 ,fCenter(c.fCenter)
bbf92647 95{
96 //
97 // Copy constructor
98 //
99
eb38ed55 100 SetBit(1, c.IsInChamber());
75fb37cc 101 SetLabel(c.GetLabel(0),0);
102 SetLabel(c.GetLabel(1),1);
103 SetLabel(c.GetLabel(2),2);
6d50f529 104
75fb37cc 105 SetY(c.GetY());
106 SetZ(c.GetZ());
107 SetSigmaY2(c.GetSigmaY2());
108 SetSigmaZ2(c.GetSigmaZ2());
6d50f529 109
110 for (Int_t i = 0; i < 7; i++) {
111 fSignals[i] = c.fSignals[i];
112 }
113
a2b90f83 114}
115
a2b90f83 116//_____________________________________________________________________________
117void AliTRDcluster::AddTrackIndex(Int_t *track)
118{
119 //
120 // Adds track index. Currently assumed that track is an array of
121 // size 9, and up to 3 track indexes are stored in fTracks[3].
122 // Indexes are sorted according to:
123 // 1) index of max number of appearances is stored first
124 // 2) if two or more indexes appear equal number of times, the lowest
125 // ones are stored first;
126 //
bbf92647 127
88cb7938 128 const Int_t kSize = 9;
6d50f529 129 Int_t entries[kSize][2];
a2b90f83 130
6d50f529 131 Int_t i = 0;
132 Int_t j = 0;
133 Int_t k = 0;
134 Int_t index;
88cb7938 135 Bool_t indexAdded;
a2b90f83 136
6d50f529 137 for (i = 0; i < kSize; i++) {
138 entries[i][0] = -1;
139 entries[i][1] = 0;
5443e65e 140 }
a2b90f83 141
6d50f529 142 for (k = 0; k < kSize; k++) {
143
144 index = track[k];
145 indexAdded = kFALSE;
146
147 j = 0;
a2b90f83 148 if (index >= 0) {
6d50f529 149 while ((!indexAdded) && (j < kSize)) {
150 if ((entries[j][0] == index) ||
151 (entries[j][1] == 0)) {
152 entries[j][0] = index;
153 entries[j][1] = entries[j][1] + 1;
154 indexAdded = kTRUE;
a2b90f83 155 }
156 j++;
157 }
158 }
6d50f529 159
160 }
161
162 // Sort by number of appearances and index value
163 Int_t swap = 1;
164 Int_t tmp0;
165 Int_t tmp1;
166 while (swap > 0) {
167 swap = 0;
168 for (i = 0; i < (kSize - 1); i++) {
169 if ((entries[i][0] >= 0) &&
170 (entries[i+1][0] >= 0)) {
a2b90f83 171 if ((entries[i][1] < entries[i+1][1]) ||
172 ((entries[i][1] == entries[i+1][1]) &&
6d50f529 173 (entries[i][0] > entries[i+1][0]))) {
174 tmp0 = entries[i][0];
175 tmp1 = entries[i][1];
176 entries[i][0] = entries[i+1][0];
177 entries[i][1] = entries[i+1][1];
178 entries[i+1][0] = tmp0;
179 entries[i+1][1] = tmp1;
180 swap++;
a2b90f83 181 }
182 }
183 }
5443e65e 184 }
a2b90f83 185
6d50f529 186 // Set track indexes
187 for (i = 0; i < 3; i++) {
188 SetLabel(entries[i][0],i);
189 }
a2b90f83 190
191 return;
46d29e70 192
5443e65e 193}
46d29e70 194
6d50f529 195//_____________________________________________________________________________
bdb68f8c 196Float_t AliTRDcluster::GetSumS() const
197{
198 //
6d50f529 199 // Returns the total charge from a not unfolded cluster
bdb68f8c 200 //
6d50f529 201
202 Float_t sum = 0.0;
203 for (Int_t i = 0; i < 7; i++) {
204 sum += fSignals[i];
bdb68f8c 205 }
6d50f529 206
207 return sum;
bdb68f8c 208
209}
f5375dcb 210
211//_____________________________________________________________________________
212void AliTRDcluster::SetPadMaskedPosition(UChar_t position)
213{
214 //
215 // store the pad corruption position code
216 //
217 // Code: 1 = left cluster
218 // 2 = middle cluster;
219 // 4 = right cluster
220 //
221 for(Int_t ipos = 0; ipos < 3; ipos++)
222 if(TESTBIT(position, ipos))
223 SETBIT(fClusterMasking, ipos);
224}
225
226//_____________________________________________________________________________
227void AliTRDcluster::SetPadMaskedStatus(UChar_t status)
228{
229 //
230 // store the status of the corrupted pad
231 //
232 // Code: 2 = noisy
233 // 4 = Bridged Left
234 // 8 = Bridged Right
235 // 32 = Not Connected
236 for(Int_t ipos = 0; ipos < 5; ipos++)
237 if(TESTBIT(status, ipos))
238 SETBIT(fClusterMasking, ipos + 3);
239}