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