]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDcluster.cxx
Conversion of survey data into alignable objects implemented
[u/mrichter/AliRoot.git] / TRD / AliTRDcluster.cxx
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 #include "AliTRDrecPoint.h"
27
28 ClassImp(AliTRDcluster)
29
30 //___________________________________________________________________________
31 AliTRDcluster::AliTRDcluster() 
32   :AliCluster() 
33   ,fDetector(0)
34   ,fX(0)
35   ,fTimeBin(0)
36   ,fQ(0)
37   ,fNPads(0)
38   ,fCenter(0)
39
40   //
41   // Default constructor
42   //
43
44   for (Int_t i = 0; i < 7; i++) {
45     fSignals[i] = 0;
46   }
47
48 }
49
50 //_____________________________________________________________________________
51 AliTRDcluster::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)
59 {
60   //
61   // Constructor from AliTRDrecPoint
62   //
63
64   SetLabel(p.GetTrackIndex(0),0);
65   SetLabel(p.GetTrackIndex(1),1);
66   SetLabel(p.GetTrackIndex(2),2);
67   SetY(p.GetY());
68   SetZ(p.GetZ());
69
70   //fSigmaY2   = p.GetSigmaY2();
71   //fSigmaZ2   = p.GetSigmaZ2();  
72   // Why is this ????
73   SetSigmaY2(0.2);
74   SetSigmaZ2(5.0);  
75
76 }
77
78 //_____________________________________________________________________________
79 AliTRDcluster::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)
87 {
88   //
89   // Copy constructor 
90   //
91
92   SetLabel(c.GetLabel(0),0);
93   SetLabel(c.GetLabel(1),1);
94   SetLabel(c.GetLabel(2),2);
95
96   SetY(c.GetY());
97   SetZ(c.GetZ());
98   SetSigmaY2(c.GetSigmaY2());
99   SetSigmaZ2(c.GetSigmaZ2());  
100
101   for (Int_t i = 0; i < 7; i++) {
102     fSignals[i] = c.fSignals[i];
103   }
104
105 }
106
107 //_____________________________________________________________________________
108 void 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   //
118
119   const Int_t kSize = 9;
120   Int_t  entries[kSize][2];
121
122   Int_t  i = 0;
123   Int_t  j = 0;
124   Int_t  k = 0;
125   Int_t  index;
126   Bool_t indexAdded;
127
128   for (i = 0; i < kSize; i++) {
129     entries[i][0] = -1;
130     entries[i][1] =  0;
131   }                                 
132
133   for (k = 0; k < kSize; k++) {
134
135     index      = track[k];
136     indexAdded = kFALSE; 
137
138     j = 0;
139     if (index >= 0) {
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;
146         }
147         j++;
148       }
149     }
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)) {
162         if ((entries[i][1] < entries[i+1][1]) ||
163             ((entries[i][1] == entries[i+1][1]) &&
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++;
172         }
173       }
174     }
175   }               
176
177   // Set track indexes
178   for (i = 0; i < 3; i++) {
179     SetLabel(entries[i][0],i);
180   }
181
182   return;
183
184 }          
185
186 //_____________________________________________________________________________
187 void AliTRDcluster::SetSignals(Short_t *signals)
188 {
189   //
190   // Write signals in the cluster
191   //
192
193   for (Int_t i = 0; i < 7; i++) {
194     fSignals[i] = signals[i];
195   }
196
197 }
198
199 //_____________________________________________________________________________
200 Float_t AliTRDcluster::GetSumS() const
201 {
202   //
203   // Returns the total charge from a not unfolded cluster
204   //
205
206   Float_t sum = 0.0;
207   for (Int_t i = 0; i < 7; i++) {
208     sum += fSignals[i];
209   }
210
211   return sum;
212
213 }