]>
Commit | Line | Data |
---|---|---|
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 | #include "AliTRDrecPoint.h" | |
27 | ||
28 | ClassImp(AliTRDcluster) | |
29 | ||
30 | //_____________________________________________________________________________ | |
31 | AliTRDcluster::AliTRDcluster(const AliTRDrecPoint &p):AliCluster() | |
32 | { | |
33 | // | |
34 | // Constructor from AliTRDrecPoint | |
35 | // | |
36 | ||
37 | fDetector = p.GetDetector(); | |
38 | fTimeBin = p.GetLocalTimeBin(); | |
39 | ||
40 | fTracks[0] = p.GetTrackIndex(0); | |
41 | fTracks[1] = p.GetTrackIndex(1); | |
42 | fTracks[2] = p.GetTrackIndex(2); | |
43 | ||
44 | fQ = p.GetEnergy(); | |
45 | ||
46 | fY = p.GetY(); | |
47 | fZ = p.GetZ(); | |
48 | fSigmaY2 = p.GetSigmaY2(); | |
49 | fSigmaZ2 = p.GetSigmaZ2(); | |
50 | ||
51 | fSigmaY2 = 0.2; | |
52 | fSigmaZ2 = 5.; | |
53 | ||
54 | } | |
55 | ||
56 | //_____________________________________________________________________________ | |
57 | AliTRDcluster::AliTRDcluster(const AliTRDcluster &c):AliCluster() | |
58 | { | |
59 | // | |
60 | // Copy constructor | |
61 | // | |
62 | ||
63 | fTracks[0] = c.GetLabel(0); | |
64 | fTracks[1] = c.GetLabel(1); | |
65 | fTracks[2] = c.GetLabel(2); | |
66 | ||
67 | fY = c.GetY(); | |
68 | fZ = c.GetZ(); | |
69 | fSigmaY2 = c.GetSigmaY2(); | |
70 | fSigmaZ2 = c.GetSigmaZ2(); | |
71 | ||
72 | fDetector = c.GetDetector(); | |
73 | fTimeBin = c.GetLocalTimeBin(); | |
74 | fQ = c.GetQ(); | |
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 | ||
92 | Int_t entries[kSize][2], i, j, index; | |
93 | ||
94 | Bool_t indexAdded; | |
95 | ||
96 | for (i=0; i<kSize; i++) { | |
97 | entries[i][0]=-1; | |
98 | entries[i][1]=0; | |
99 | } | |
100 | ||
101 | for (Int_t k=0; k<kSize; k++) { | |
102 | index=track[k]; | |
103 | indexAdded=kFALSE; | |
104 | j=0; | |
105 | if (index >= 0) { | |
106 | while ( (!indexAdded) && ( j < kSize ) ) { | |
107 | if ((entries[j][0]==index) || (entries[j][1]==0)) { | |
108 | entries[j][0]=index; | |
109 | entries[j][1]=entries[j][1]+1; | |
110 | indexAdded=kTRUE; | |
111 | } | |
112 | j++; | |
113 | } | |
114 | } | |
115 | } | |
116 | ||
117 | // sort by number of appearances and index value | |
118 | Int_t swap=1, tmp0, tmp1; | |
119 | while ( swap > 0) { | |
120 | swap=0; | |
121 | for(i=0; i<(kSize-1); i++) { | |
122 | if ((entries[i][0] >= 0) && (entries[i+1][0] >= 0)) { | |
123 | if ((entries[i][1] < entries[i+1][1]) || | |
124 | ((entries[i][1] == entries[i+1][1]) && | |
125 | (entries[i][0] > entries[i+1][0]))) { | |
126 | tmp0=entries[i][0]; | |
127 | tmp1=entries[i][1]; | |
128 | entries[i][0]=entries[i+1][0]; | |
129 | entries[i][1]=entries[i+1][1]; | |
130 | entries[i+1][0]=tmp0; | |
131 | entries[i+1][1]=tmp1; | |
132 | swap++; | |
133 | } | |
134 | } | |
135 | } | |
136 | } | |
137 | ||
138 | // set track indexes | |
139 | for(i=0; i<3; i++) SetLabel(entries[i][0],i); | |
140 | ||
141 | return; | |
142 | ||
143 | } | |
144 |