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