]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDcluster.cxx
Move pad planes from AliTRDCommomParam to AliTRDgeometry
[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
27 ClassImp(AliTRDcluster)
28
29 //___________________________________________________________________________
30 AliTRDcluster::AliTRDcluster() 
31   :AliCluster() 
32   ,fDetector(0)
33   ,fTimeBin(0)
34   ,fQ(0)
35   ,fNPads(0)
36   ,fCenter(0)
37   ,fPad(0)
38
39   //
40   // Default constructor
41   //
42
43   for (Int_t i = 0; i < 7; i++) {
44     fSignals[i] = 0;
45   }
46
47 }
48
49 //_____________________________________________________________________________
50 AliTRDcluster::AliTRDcluster(const AliTRDcluster &c)
51   :AliCluster()
52   ,fDetector(c.fDetector)
53   ,fTimeBin(c.fTimeBin)
54   ,fQ(c.fQ)
55   ,fNPads(c.fNPads)
56   ,fCenter(c.fCenter)
57   ,fPad(c.fPad)
58 {
59   //
60   // Copy constructor 
61   //
62
63   SetLabel(c.GetLabel(0),0);
64   SetLabel(c.GetLabel(1),1);
65   SetLabel(c.GetLabel(2),2);
66
67   SetY(c.GetY());
68   SetZ(c.GetZ());
69   SetSigmaY2(c.GetSigmaY2());
70   SetSigmaZ2(c.GetSigmaZ2());  
71
72   for (Int_t i = 0; i < 7; i++) {
73     fSignals[i] = c.fSignals[i];
74   }
75
76 }
77
78 //_____________________________________________________________________________
79 void AliTRDcluster::AddTrackIndex(Int_t *track)
80 {
81   //
82   // Adds track index. Currently assumed that track is an array of
83   // size 9, and up to 3 track indexes are stored in fTracks[3].
84   // Indexes are sorted according to:
85   //  1) index of max number of appearances is stored first
86   //  2) if two or more indexes appear equal number of times, the lowest
87   //     ones are stored first;
88   //
89
90   const Int_t kSize = 9;
91   Int_t  entries[kSize][2];
92
93   Int_t  i = 0;
94   Int_t  j = 0;
95   Int_t  k = 0;
96   Int_t  index;
97   Bool_t indexAdded;
98
99   for (i = 0; i < kSize; i++) {
100     entries[i][0] = -1;
101     entries[i][1] =  0;
102   }                                 
103
104   for (k = 0; k < kSize; k++) {
105
106     index      = track[k];
107     indexAdded = kFALSE; 
108
109     j = 0;
110     if (index >= 0) {
111       while ((!indexAdded) && (j < kSize)) {
112         if ((entries[j][0] == index) || 
113             (entries[j][1] ==     0)) {
114           entries[j][0] = index;
115           entries[j][1] = entries[j][1] + 1;
116           indexAdded    = kTRUE;
117         }
118         j++;
119       }
120     }
121
122   }
123
124   // Sort by number of appearances and index value
125   Int_t swap = 1;
126   Int_t tmp0;
127   Int_t tmp1;
128   while (swap > 0) {
129     swap = 0;
130     for (i = 0; i < (kSize - 1); i++) {
131       if ((entries[i][0]   >= 0) && 
132           (entries[i+1][0] >= 0)) {
133         if ((entries[i][1] < entries[i+1][1]) ||
134             ((entries[i][1] == entries[i+1][1]) &&
135              (entries[i][0] >  entries[i+1][0]))) {
136           tmp0            = entries[i][0];
137           tmp1            = entries[i][1];
138           entries[i][0]   = entries[i+1][0];
139           entries[i][1]   = entries[i+1][1];
140           entries[i+1][0] = tmp0;
141           entries[i+1][1] = tmp1;
142           swap++;
143         }
144       }
145     }
146   }               
147
148   // Set track indexes
149   for (i = 0; i < 3; i++) {
150     SetLabel(entries[i][0],i);
151   }
152
153   return;
154
155 }          
156
157 //_____________________________________________________________________________
158 void AliTRDcluster::SetSignals(Short_t *signals)
159 {
160   //
161   // Write signals in the cluster
162   //
163
164   for (Int_t i = 0; i < 7; i++) {
165     fSignals[i] = signals[i];
166   }
167
168 }
169
170 //_____________________________________________________________________________
171 Float_t AliTRDcluster::GetSumS() const
172 {
173   //
174   // Returns the total charge from a not unfolded cluster
175   //
176
177   Float_t sum = 0.0;
178   for (Int_t i = 0; i < 7; i++) {
179     sum += fSignals[i];
180   }
181
182   return sum;
183
184 }