]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDcluster.cxx
Updated SDigitizer; Added AliTOFanalyzeSDigits.C macro
[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 /*
17 $Log$
18 Revision 1.4  2001/05/07 08:08:05  cblume
19 Update of TRD code
20
21 Revision 1.3  2000/12/08 16:07:02  cblume
22 Update of the tracking by Sergei
23
24 Revision 1.2  2000/10/06 16:49:46  cblume
25 Made Getters const
26
27 Revision 1.1.2.1  2000/09/22 14:47:52  cblume
28 Add the tracking code
29
30 */
31  
32 ///////////////////////////////////////////////////////////////////////////////
33 //                                                                           //
34 //  TRD cluster                                                              //
35 //                                                                           //
36 /////////////////////////////////////////////////////////////////////////////// 
37
38 #include "AliTRDcluster.h"
39 #include "AliTRDrecPoint.h"
40
41 ClassImp(AliTRDcluster)
42  
43 //_____________________________________________________________________________
44 AliTRDcluster::AliTRDcluster() 
45 {
46   //
47   // Default constructor
48   //
49
50   fDetector  = 0;
51   fTimeBin   = 0;
52   fTracks[0] = 0;
53   fTracks[1] = 0;
54   fTracks[2] = 0; 
55   fY         = 0;
56   fZ         = 0;
57   fQ         = 0;
58   fSigmaY2   = 0;
59   fSigmaZ2   = 0;
60
61 }
62
63 //_____________________________________________________________________________
64 AliTRDcluster::AliTRDcluster(const AliTRDrecPoint &p)
65 {
66   //
67   // Constructor from AliTRDrecPoint
68   //
69
70   fDetector   = p.GetDetector();
71   fTimeBin    = p.GetLocalTimeBin();
72
73   fTracks[0]  = p.GetTrackIndex(0);
74   fTracks[1]  = p.GetTrackIndex(1);
75   fTracks[2]  = p.GetTrackIndex(2);
76
77   fQ          = p.GetEnergy();
78
79   fY          = p.GetY();
80   fZ          = p.GetZ();
81   fSigmaY2    = p.GetSigmaY2();
82   fSigmaZ2    = p.GetSigmaZ2();  
83
84   fSigmaY2    = 0.2;
85   fSigmaZ2    = 5.;  
86
87 }
88
89 //_____________________________________________________________________________
90 AliTRDcluster::AliTRDcluster(const AliTRDcluster &c)
91 {
92   //
93   // Copy constructor 
94   //
95
96   ((AliTRDcluster &) c).Copy(*this);
97
98 }
99
100 //_____________________________________________________________________________
101 AliTRDcluster::~AliTRDcluster()
102 {
103   //
104   // AliTRDcluster destructor
105   //
106
107 }
108
109 //_____________________________________________________________________________
110 AliTRDcluster &AliTRDcluster::operator=(const AliTRDcluster &c)
111 {
112   //
113   // Assignment operator
114   //
115
116   if (this != &c) ((AliTRDcluster &) c).Copy(*this);
117   return *this;
118
119 }
120
121 //_____________________________________________________________________________
122 void AliTRDcluster::Copy(TObject &c)
123 {
124   //
125   // Copy function
126   //
127
128   ((AliTRDcluster &) c).fDetector   = fDetector;
129   ((AliTRDcluster &) c).fTimeBin    = fTimeBin;
130
131   ((AliTRDcluster &) c).fTracks[0]  = fTracks[0];
132   ((AliTRDcluster &) c).fTracks[1]  = fTracks[1];
133   ((AliTRDcluster &) c).fTracks[2]  = fTracks[2];
134
135   ((AliTRDcluster &) c).fQ          = fQ;
136
137   ((AliTRDcluster &) c).fY          = fY;
138   ((AliTRDcluster &) c).fZ          = fZ;
139   ((AliTRDcluster &) c).fSigmaY2    = fSigmaY2;
140   ((AliTRDcluster &) c).fSigmaZ2    = fSigmaZ2;  
141
142 }
143
144
145 //_____________________________________________________________________________
146 void AliTRDcluster::AddTrackIndex(Int_t *track)
147 {
148   //
149   // Adds track index. Currently assumed that track is an array of
150   // size 9, and up to 3 track indexes are stored in fTracks[3].
151   // Indexes are sorted according to:
152   //  1) index of max number of appearances is stored first
153   //  2) if two or more indexes appear equal number of times, the lowest
154   //     ones are stored first;
155   //
156
157   const Int_t kSize = 9;
158
159   Int_t entries[kSize][2], i, j, index;
160
161   Bool_t indexAdded;
162
163   for (i=0; i<kSize; i++) {
164     entries[i][0]=-1;
165     entries[i][1]=0;
166   }
167
168   for (Int_t k=0; k<kSize; k++) {
169     index=track[k];
170     indexAdded=kFALSE; 
171     j=0;
172     if (index >= 0) {
173       while ( (!indexAdded) && ( j < kSize ) ) {
174         if ((entries[j][0]==index) || (entries[j][1]==0)) {
175           entries[j][0]=index;
176           entries[j][1]=entries[j][1]+1;
177           indexAdded=kTRUE;
178         }
179         j++;
180       }
181     }
182   }
183
184   // sort by number of appearances and index value
185   Int_t swap=1, tmp0, tmp1;
186   while ( swap > 0) {
187     swap=0;
188     for(i=0; i<(kSize-1); i++) {
189       if ((entries[i][0] >= 0) && (entries[i+1][0] >= 0)) {
190         if ((entries[i][1] < entries[i+1][1]) ||
191             ((entries[i][1] == entries[i+1][1]) &&
192              (entries[i][0] > entries[i+1][0]))) {
193                tmp0=entries[i][0];
194                tmp1=entries[i][1];
195                entries[i][0]=entries[i+1][0];
196                entries[i][1]=entries[i+1][1];
197                entries[i+1][0]=tmp0;
198                entries[i+1][1]=tmp1;
199                swap++;
200         }
201       }
202     }
203   }
204
205   // set track indexes
206   for(i=0; i<3; i++) {
207     fTracks[i] = entries[i][0];
208   }
209
210   return;
211
212 }
213