Update of clusterizer
[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#include "AliTRDrecPoint.h"
27
46d29e70 28ClassImp(AliTRDcluster)
bdb68f8c 29
6d50f529 30//___________________________________________________________________________
31AliTRDcluster::AliTRDcluster()
32 :AliCluster()
33 ,fDetector(0)
34 ,fX(0)
35 ,fTimeBin(0)
36 ,fQ(0)
37 ,fNPads(0)
38 ,fCenter(0)
39{
bdb68f8c 40 //
a6dd11e9 41 // Default constructor
bdb68f8c 42 //
6d50f529 43
44 for (Int_t i = 0; i < 7; i++) {
45 fSignals[i] = 0;
46 }
47
bdb68f8c 48}
6d50f529 49
46d29e70 50//_____________________________________________________________________________
6d50f529 51AliTRDcluster::AliTRDcluster(const AliTRDrecPoint &p)
52 :AliCluster()
53 ,fDetector(p.GetDetector())
54 ,fX(0)
55 ,fTimeBin(p.GetLocalTimeBin())
56 ,fQ(p.GetEnergy())
57 ,fNPads(0)
58 ,fCenter(0)
46d29e70 59{
60 //
a2b90f83 61 // Constructor from AliTRDrecPoint
46d29e70 62 //
63
6d50f529 64 fTracks[0] = p.GetTrackIndex(0);
65 fTracks[1] = p.GetTrackIndex(1);
66 fTracks[2] = p.GetTrackIndex(2);
67 fY = p.GetY();
68 fZ = p.GetZ();
46d29e70 69
6d50f529 70 //fSigmaY2 = p.GetSigmaY2();
71 //fSigmaZ2 = p.GetSigmaZ2();
72 // Why is this ????
73 fSigmaY2 = 0.2;
74 fSigmaZ2 = 5.0;
46d29e70 75
bbf92647 76}
77
78//_____________________________________________________________________________
6d50f529 79AliTRDcluster::AliTRDcluster(const AliTRDcluster &c)
80 :AliCluster()
81 ,fDetector(c.fDetector)
82 ,fX(c.fX)
83 ,fTimeBin(c.fTimeBin)
84 ,fQ(c.fQ)
85 ,fNPads(c.fNPads)
86 ,fCenter(c.fCenter)
bbf92647 87{
88 //
89 // Copy constructor
90 //
91
6d50f529 92 fTracks[0] = c.GetLabel(0);
93 fTracks[1] = c.GetLabel(1);
94 fTracks[2] = c.GetLabel(2);
95
96 fY = c.GetY();
97 fZ = c.GetZ();
98 fSigmaY2 = c.GetSigmaY2();
99 fSigmaZ2 = c.GetSigmaZ2();
100
101 for (Int_t i = 0; i < 7; i++) {
102 fSignals[i] = c.fSignals[i];
103 }
104
a2b90f83 105}
106
a2b90f83 107//_____________________________________________________________________________
108void AliTRDcluster::AddTrackIndex(Int_t *track)
109{
110 //
111 // Adds track index. Currently assumed that track is an array of
112 // size 9, and up to 3 track indexes are stored in fTracks[3].
113 // Indexes are sorted according to:
114 // 1) index of max number of appearances is stored first
115 // 2) if two or more indexes appear equal number of times, the lowest
116 // ones are stored first;
117 //
bbf92647 118
88cb7938 119 const Int_t kSize = 9;
6d50f529 120 Int_t entries[kSize][2];
a2b90f83 121
6d50f529 122 Int_t i = 0;
123 Int_t j = 0;
124 Int_t k = 0;
125 Int_t index;
88cb7938 126 Bool_t indexAdded;
a2b90f83 127
6d50f529 128 for (i = 0; i < kSize; i++) {
129 entries[i][0] = -1;
130 entries[i][1] = 0;
5443e65e 131 }
a2b90f83 132
6d50f529 133 for (k = 0; k < kSize; k++) {
134
135 index = track[k];
136 indexAdded = kFALSE;
137
138 j = 0;
a2b90f83 139 if (index >= 0) {
6d50f529 140 while ((!indexAdded) && (j < kSize)) {
141 if ((entries[j][0] == index) ||
142 (entries[j][1] == 0)) {
143 entries[j][0] = index;
144 entries[j][1] = entries[j][1] + 1;
145 indexAdded = kTRUE;
a2b90f83 146 }
147 j++;
148 }
149 }
6d50f529 150
151 }
152
153 // Sort by number of appearances and index value
154 Int_t swap = 1;
155 Int_t tmp0;
156 Int_t tmp1;
157 while (swap > 0) {
158 swap = 0;
159 for (i = 0; i < (kSize - 1); i++) {
160 if ((entries[i][0] >= 0) &&
161 (entries[i+1][0] >= 0)) {
a2b90f83 162 if ((entries[i][1] < entries[i+1][1]) ||
163 ((entries[i][1] == entries[i+1][1]) &&
6d50f529 164 (entries[i][0] > entries[i+1][0]))) {
165 tmp0 = entries[i][0];
166 tmp1 = entries[i][1];
167 entries[i][0] = entries[i+1][0];
168 entries[i][1] = entries[i+1][1];
169 entries[i+1][0] = tmp0;
170 entries[i+1][1] = tmp1;
171 swap++;
a2b90f83 172 }
173 }
174 }
5443e65e 175 }
a2b90f83 176
6d50f529 177 // Set track indexes
178 for (i = 0; i < 3; i++) {
179 SetLabel(entries[i][0],i);
180 }
a2b90f83 181
182 return;
46d29e70 183
5443e65e 184}
46d29e70 185
6d50f529 186//_____________________________________________________________________________
187void AliTRDcluster::SetSignals(Short_t *signals)
188{
bdb68f8c 189 //
6d50f529 190 // Write signals in the cluster
bdb68f8c 191 //
6d50f529 192
193 for (Int_t i = 0; i < 7; i++) {
194 fSignals[i] = signals[i];
195 }
196
bdb68f8c 197}
198
6d50f529 199//_____________________________________________________________________________
bdb68f8c 200Float_t AliTRDcluster::GetSumS() const
201{
202 //
6d50f529 203 // Returns the total charge from a not unfolded cluster
bdb68f8c 204 //
6d50f529 205
206 Float_t sum = 0.0;
207 for (Int_t i = 0; i < 7; i++) {
208 sum += fSignals[i];
bdb68f8c 209 }
6d50f529 210
211 return sum;
bdb68f8c 212
213}