]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - TRD/AliTRDcluster.cxx
AliITSv11GeometrySPD has added missing parts, set up to help with
[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 ,fDetector(0)
33 ,fLocalTimeBin(0)
34 ,fQ(0)
35 ,fNPads(0)
36 ,fCenter(0)
37 ,fPadCol(0)
38 ,fPadRow(0)
39 ,fPadTime(0)
40{
41 //
42 // Default constructor
43 //
44
45 for (Int_t i = 0; i < 7; i++) {
46 fSignals[i] = 0;
47 }
48
49}
50
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
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)
58 ,fDetector(det)
59 ,fLocalTimeBin(timebin)
60 ,fQ(q)
61 ,fNPads(npads)
62 ,fCenter(center)
63 ,fPadCol(col)
64 ,fPadRow(row)
65 ,fPadTime(time)
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
81//_____________________________________________________________________________
82AliTRDcluster::AliTRDcluster(const AliTRDcluster &c)
83 :AliCluster(c)
84 ,fDetector(c.fDetector)
85 ,fLocalTimeBin(c.fLocalTimeBin)
86 ,fQ(c.fQ)
87 ,fNPads(c.fNPads)
88 ,fCenter(c.fCenter)
89 ,fPadCol(c.fPadCol)
90 ,fPadRow(c.fPadRow)
91 ,fPadTime(c.fPadTime)
92{
93 //
94 // Copy constructor
95 //
96
97 SetLabel(c.GetLabel(0),0);
98 SetLabel(c.GetLabel(1),1);
99 SetLabel(c.GetLabel(2),2);
100
101 SetY(c.GetY());
102 SetZ(c.GetZ());
103 SetSigmaY2(c.GetSigmaY2());
104 SetSigmaZ2(c.GetSigmaZ2());
105
106 for (Int_t i = 0; i < 7; i++) {
107 fSignals[i] = c.fSignals[i];
108 }
109
110}
111
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 //
123
124 const Int_t kSize = 9;
125 Int_t entries[kSize][2];
126
127 Int_t i = 0;
128 Int_t j = 0;
129 Int_t k = 0;
130 Int_t index;
131 Bool_t indexAdded;
132
133 for (i = 0; i < kSize; i++) {
134 entries[i][0] = -1;
135 entries[i][1] = 0;
136 }
137
138 for (k = 0; k < kSize; k++) {
139
140 index = track[k];
141 indexAdded = kFALSE;
142
143 j = 0;
144 if (index >= 0) {
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;
151 }
152 j++;
153 }
154 }
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)) {
167 if ((entries[i][1] < entries[i+1][1]) ||
168 ((entries[i][1] == entries[i+1][1]) &&
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++;
177 }
178 }
179 }
180 }
181
182 // Set track indexes
183 for (i = 0; i < 3; i++) {
184 SetLabel(entries[i][0],i);
185 }
186
187 return;
188
189}
190
191//_____________________________________________________________________________
192Float_t AliTRDcluster::GetSumS() const
193{
194 //
195 // Returns the total charge from a not unfolded cluster
196 //
197
198 Float_t sum = 0.0;
199 for (Int_t i = 0; i < 7; i++) {
200 sum += fSignals[i];
201 }
202
203 return sum;
204
205}