]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - TRD/AliTRDcluster.cxx
datamember added in AliGeomManager with number of alignable volumes per subdetector...
[u/mrichter/AliRoot.git] / TRD / AliTRDcluster.cxx
... / ...
CommitLineData
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///////////////////////////////////////////////////////////////////////////////
20// //
21// TRD cluster //
22// //
23///////////////////////////////////////////////////////////////////////////////
24
25#include "AliTRDcluster.h"
26
27ClassImp(AliTRDcluster)
28
29//___________________________________________________________________________
30AliTRDcluster::AliTRDcluster()
31 :AliCluster()
32 ,fPadCol(0)
33 ,fPadRow(0)
34 ,fPadTime(0)
35 ,fLocalTimeBin(0)
36 ,fNPads(0)
37 ,fClusterMasking(0)
38 ,fDetector(0)
39 ,fQ(0)
40 ,fCenter(0)
41{
42 //
43 // Default constructor
44 //
45
46 for (Int_t i = 0; i < 7; i++) {
47 fSignals[i] = 0;
48 }
49
50}
51
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
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)
59 ,fPadCol(col)
60 ,fPadRow(row)
61 ,fPadTime(time)
62 ,fLocalTimeBin(timebin)
63 ,fNPads(npads)
64 ,fClusterMasking(0)
65 ,fDetector(det)
66 ,fQ(q)
67 ,fCenter(center)
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
83//_____________________________________________________________________________
84AliTRDcluster::AliTRDcluster(const AliTRDcluster &c)
85 :AliCluster(c)
86 ,fPadCol(c.fPadCol)
87 ,fPadRow(c.fPadRow)
88 ,fPadTime(c.fPadTime)
89 ,fLocalTimeBin(c.fLocalTimeBin)
90 ,fNPads(c.fNPads)
91 ,fClusterMasking(c.fClusterMasking)
92 ,fDetector(c.fDetector)
93 ,fQ(c.fQ)
94 ,fCenter(c.fCenter)
95{
96 //
97 // Copy constructor
98 //
99
100 SetBit(kInChamber, c.IsInChamber());
101 SetLabel(c.GetLabel(0),0);
102 SetLabel(c.GetLabel(1),1);
103 SetLabel(c.GetLabel(2),2);
104
105 SetY(c.GetY());
106 SetZ(c.GetZ());
107 SetSigmaY2(c.GetSigmaY2());
108 SetSigmaZ2(c.GetSigmaZ2());
109
110 for (Int_t i = 0; i < 7; i++) {
111 fSignals[i] = c.fSignals[i];
112 }
113
114}
115
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 //
127
128 const Int_t kSize = 9;
129 Int_t entries[kSize][2];
130
131 Int_t i = 0;
132 Int_t j = 0;
133 Int_t k = 0;
134 Int_t index;
135 Bool_t indexAdded;
136
137 for (i = 0; i < kSize; i++) {
138 entries[i][0] = -1;
139 entries[i][1] = 0;
140 }
141
142 for (k = 0; k < kSize; k++) {
143
144 index = track[k];
145 indexAdded = kFALSE;
146
147 j = 0;
148 if (index >= 0) {
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;
155 }
156 j++;
157 }
158 }
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)) {
171 if ((entries[i][1] < entries[i+1][1]) ||
172 ((entries[i][1] == entries[i+1][1]) &&
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++;
181 }
182 }
183 }
184 }
185
186 // Set track indexes
187 for (i = 0; i < 3; i++) {
188 SetLabel(entries[i][0],i);
189 }
190
191 return;
192
193}
194
195//_____________________________________________________________________________
196Float_t AliTRDcluster::GetSumS() const
197{
198 //
199 // Returns the total charge from a not unfolded cluster
200 //
201
202 Float_t sum = 0.0;
203 for (Int_t i = 0; i < 7; i++) {
204 sum += fSignals[i];
205 }
206
207 return sum;
208
209}
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}