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