]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDcluster.cxx
Removal of AliMCQA and of TreeH method on AliDetector
[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
203967fc 25#include "AliLog.h"
46d29e70 26#include "AliTRDcluster.h"
46d29e70 27
46d29e70 28ClassImp(AliTRDcluster)
bdb68f8c 29
6d50f529 30//___________________________________________________________________________
31AliTRDcluster::AliTRDcluster()
32 :AliCluster()
af26ce80 33 ,fPadCol(0)
34 ,fPadRow(0)
35 ,fPadTime(0)
f5375dcb 36 ,fLocalTimeBin(0)
37 ,fNPads(0)
38 ,fClusterMasking(0)
39 ,fDetector(0)
40 ,fQ(0)
41 ,fCenter(0)
6d50f529 42{
bdb68f8c 43 //
a6dd11e9 44 // Default constructor
bdb68f8c 45 //
6d50f529 46
47 for (Int_t i = 0; i < 7; i++) {
48 fSignals[i] = 0;
49 }
50
bdb68f8c 51}
6d50f529 52
34eaaa7e 53//___________________________________________________________________________
54AliTRDcluster::AliTRDcluster(Int_t det, Float_t q
55 , Float_t *pos, Float_t *sig
56 , Int_t *tracks, Char_t npads, Short_t *signals
af26ce80 57 , UChar_t col, UChar_t row, UChar_t time
58 , Char_t timebin, Float_t center, UShort_t volid)
59 :AliCluster(volid,pos[0],pos[1],pos[2],sig[0],sig[1],0.0,0x0)
af26ce80 60 ,fPadCol(col)
61 ,fPadRow(row)
62 ,fPadTime(time)
f5375dcb 63 ,fLocalTimeBin(timebin)
64 ,fNPads(npads)
65 ,fClusterMasking(0)
66 ,fDetector(det)
67 ,fQ(q)
68 ,fCenter(center)
34eaaa7e 69{
70 //
71 // Constructor
72 //
73
74 for (Int_t i = 0; i < 7; i++) {
75 fSignals[i] = signals[i];
76 }
77
78 if (tracks) {
79 AddTrackIndex(tracks);
80 }
81
82}
83
bbf92647 84//_____________________________________________________________________________
6d50f529 85AliTRDcluster::AliTRDcluster(const AliTRDcluster &c)
34eaaa7e 86 :AliCluster(c)
af26ce80 87 ,fPadCol(c.fPadCol)
88 ,fPadRow(c.fPadRow)
89 ,fPadTime(c.fPadTime)
f5375dcb 90 ,fLocalTimeBin(c.fLocalTimeBin)
91 ,fNPads(c.fNPads)
92 ,fClusterMasking(c.fClusterMasking)
93 ,fDetector(c.fDetector)
94 ,fQ(c.fQ)
95 ,fCenter(c.fCenter)
bbf92647 96{
97 //
98 // Copy constructor
99 //
100
0ae89c5d 101 SetBit(kInChamber, c.IsInChamber());
75fb37cc 102 SetLabel(c.GetLabel(0),0);
103 SetLabel(c.GetLabel(1),1);
104 SetLabel(c.GetLabel(2),2);
6d50f529 105
75fb37cc 106 SetY(c.GetY());
107 SetZ(c.GetZ());
108 SetSigmaY2(c.GetSigmaY2());
109 SetSigmaZ2(c.GetSigmaZ2());
6d50f529 110
111 for (Int_t i = 0; i < 7; i++) {
112 fSignals[i] = c.fSignals[i];
113 }
114
a2b90f83 115}
116
a2b90f83 117//_____________________________________________________________________________
118void AliTRDcluster::AddTrackIndex(Int_t *track)
119{
120 //
121 // Adds track index. Currently assumed that track is an array of
122 // size 9, and up to 3 track indexes are stored in fTracks[3].
123 // Indexes are sorted according to:
124 // 1) index of max number of appearances is stored first
125 // 2) if two or more indexes appear equal number of times, the lowest
126 // ones are stored first;
127 //
bbf92647 128
88cb7938 129 const Int_t kSize = 9;
6d50f529 130 Int_t entries[kSize][2];
a2b90f83 131
6d50f529 132 Int_t i = 0;
133 Int_t j = 0;
134 Int_t k = 0;
135 Int_t index;
88cb7938 136 Bool_t indexAdded;
a2b90f83 137
6d50f529 138 for (i = 0; i < kSize; i++) {
139 entries[i][0] = -1;
140 entries[i][1] = 0;
5443e65e 141 }
a2b90f83 142
6d50f529 143 for (k = 0; k < kSize; k++) {
144
145 index = track[k];
146 indexAdded = kFALSE;
147
148 j = 0;
a2b90f83 149 if (index >= 0) {
6d50f529 150 while ((!indexAdded) && (j < kSize)) {
151 if ((entries[j][0] == index) ||
152 (entries[j][1] == 0)) {
153 entries[j][0] = index;
154 entries[j][1] = entries[j][1] + 1;
155 indexAdded = kTRUE;
a2b90f83 156 }
157 j++;
158 }
159 }
6d50f529 160
161 }
162
163 // Sort by number of appearances and index value
164 Int_t swap = 1;
165 Int_t tmp0;
166 Int_t tmp1;
167 while (swap > 0) {
168 swap = 0;
169 for (i = 0; i < (kSize - 1); i++) {
170 if ((entries[i][0] >= 0) &&
171 (entries[i+1][0] >= 0)) {
a2b90f83 172 if ((entries[i][1] < entries[i+1][1]) ||
173 ((entries[i][1] == entries[i+1][1]) &&
6d50f529 174 (entries[i][0] > entries[i+1][0]))) {
175 tmp0 = entries[i][0];
176 tmp1 = entries[i][1];
177 entries[i][0] = entries[i+1][0];
178 entries[i][1] = entries[i+1][1];
179 entries[i+1][0] = tmp0;
180 entries[i+1][1] = tmp1;
181 swap++;
a2b90f83 182 }
183 }
184 }
5443e65e 185 }
a2b90f83 186
6d50f529 187 // Set track indexes
188 for (i = 0; i < 3; i++) {
189 SetLabel(entries[i][0],i);
190 }
a2b90f83 191
192 return;
46d29e70 193
5443e65e 194}
46d29e70 195
203967fc 196//_____________________________________________________________________________
197void AliTRDcluster::Clear(Option_t *)
198{
199 //
200 // Reset all member to the default value
201 //
202 fPadCol=0;
203 fPadRow=0;
204 fPadTime=0;
205 fLocalTimeBin=0;
206 fNPads=0;
207 fClusterMasking=0;
208 fDetector=0;
209 for (Int_t i=0; i < 7; i++) fSignals[i]=0;
210 fQ = 0;
211 fCenter = 0;
212 for (Int_t i = 0; i < 3; i++) SetLabel(0,i);
213 SetX(0);
214 SetY(0);
215 SetZ(0);
216 SetSigmaY2(0);
217 SetSigmaZ2(0);
218 SetVolumeId(0);
219}
220
6d50f529 221//_____________________________________________________________________________
bdb68f8c 222Float_t AliTRDcluster::GetSumS() const
223{
224 //
6d50f529 225 // Returns the total charge from a not unfolded cluster
bdb68f8c 226 //
6d50f529 227
228 Float_t sum = 0.0;
229 for (Int_t i = 0; i < 7; i++) {
230 sum += fSignals[i];
bdb68f8c 231 }
6d50f529 232
233 return sum;
bdb68f8c 234
235}
f5375dcb 236
203967fc 237
238//_____________________________________________________________________________
239Bool_t AliTRDcluster::IsEqual(const TObject *o) const
240{
241 //
242 // Compare relevant information of this cluster with another one
243 //
244
245 const AliTRDcluster *inCluster = dynamic_cast<const AliTRDcluster*>(o);
246 if (!o || !inCluster) return kFALSE;
247
248 if ( AliCluster::GetX() != inCluster->GetX() ) return kFALSE;
249 if ( AliCluster::GetY() != inCluster->GetY() ) return kFALSE;
250 if ( AliCluster::GetZ() != inCluster->GetZ() ) return kFALSE;
251 if ( fQ != inCluster->fQ ) return kFALSE;
252 if ( fDetector != inCluster->fDetector ) return kFALSE;
253 if ( fPadCol != inCluster->fPadCol ) return kFALSE;
254 if ( fPadRow != inCluster->fPadRow ) return kFALSE;
255 if ( fPadTime != inCluster->fPadTime ) return kFALSE;
256 if ( fClusterMasking != inCluster->fClusterMasking ) return kFALSE;
257 if ( IsInChamber() != inCluster->IsInChamber() ) return kFALSE;
258 if ( IsShared() != inCluster->IsShared() ) return kFALSE;
259 if ( IsUsed() != inCluster->IsUsed() ) return kFALSE;
260
261 return kTRUE;
262}
263
264//_____________________________________________________________________________
265void AliTRDcluster::Print(Option_t *o) const
266{
267 AliInfo(Form("Det[%3d] LTrC[%7.2f %7.2f %7.2f] Q[%f] Stat[in(%c) use(%c) sh(%c)]",
268 fDetector, GetX(), GetY(), GetZ(), fQ,
269 IsInChamber() ? 'y' : 'n', IsUsed() ? 'y' : 'n', IsShared() ? 'y' : 'n'));
270
271 if(strcmp(o, "a")!=0) return;
272 AliInfo(Form("LChC[c(%3d) r(%2d) t(%2d)] t-t0[%2d] Npad[%d] cen[%5.3f] mask[%d]", fPadCol, fPadRow, fPadTime, fLocalTimeBin, fNPads, fCenter, fClusterMasking));
273 AliInfo(Form("Signals[%3d %3d %3d %3d %3d %3d %3d]", fSignals[0], fSignals[1], fSignals[2], fSignals[3], fSignals[4], fSignals[5], fSignals[6]));
274}
275
276
f5375dcb 277//_____________________________________________________________________________
278void AliTRDcluster::SetPadMaskedPosition(UChar_t position)
279{
280 //
281 // store the pad corruption position code
282 //
283 // Code: 1 = left cluster
284 // 2 = middle cluster;
285 // 4 = right cluster
286 //
287 for(Int_t ipos = 0; ipos < 3; ipos++)
288 if(TESTBIT(position, ipos))
289 SETBIT(fClusterMasking, ipos);
290}
291
292//_____________________________________________________________________________
293void AliTRDcluster::SetPadMaskedStatus(UChar_t status)
294{
295 //
296 // store the status of the corrupted pad
297 //
298 // Code: 2 = noisy
299 // 4 = Bridged Left
300 // 8 = Bridged Right
301 // 32 = Not Connected
302 for(Int_t ipos = 0; ipos < 5; ipos++)
303 if(TESTBIT(status, ipos))
304 SETBIT(fClusterMasking, ipos + 3);
305}