]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDcluster.cxx
Bugfix in AliPoints2Memory
[u/mrichter/AliRoot.git] / TRD / AliTRDcluster.cxx
CommitLineData
46d29e70 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$
0a29d0f1 18Revision 1.4 2001/05/07 08:08:05 cblume
19Update of TRD code
20
a2b90f83 21Revision 1.3 2000/12/08 16:07:02 cblume
22Update of the tracking by Sergei
23
bbf92647 24Revision 1.2 2000/10/06 16:49:46 cblume
25Made Getters const
26
46d29e70 27Revision 1.1.2.1 2000/09/22 14:47:52 cblume
28Add the tracking code
29
30*/
31
32#include "AliTRDcluster.h"
5443e65e 33#include "AliTRDgeometry.h"
46d29e70 34#include "AliTRDrecPoint.h"
35
46d29e70 36ClassImp(AliTRDcluster)
37
46d29e70 38
39//_____________________________________________________________________________
5443e65e 40 AliTRDcluster::AliTRDcluster(const AliTRDrecPoint &p):AliCluster()
46d29e70 41{
42 //
a2b90f83 43 // Constructor from AliTRDrecPoint
46d29e70 44 //
45
a2b90f83 46 fDetector = p.GetDetector();
47 fTimeBin = p.GetLocalTimeBin();
46d29e70 48
a2b90f83 49 fTracks[0] = p.GetTrackIndex(0);
50 fTracks[1] = p.GetTrackIndex(1);
51 fTracks[2] = p.GetTrackIndex(2);
46d29e70 52
a2b90f83 53 fQ = p.GetEnergy();
46d29e70 54
a2b90f83 55 fY = p.GetY();
56 fZ = p.GetZ();
57 fSigmaY2 = p.GetSigmaY2();
58 fSigmaZ2 = p.GetSigmaZ2();
46d29e70 59
bbf92647 60 fSigmaY2 = 0.2;
61 fSigmaZ2 = 5.;
62
63}
64
65//_____________________________________________________________________________
5443e65e 66AliTRDcluster::AliTRDcluster(const AliTRDcluster &c):AliCluster()
bbf92647 67{
68 //
69 // Copy constructor
70 //
71
5443e65e 72 fTracks[0] = c.GetLabel(0);
73 fTracks[1] = c.GetLabel(1);
74 fTracks[2] = c.GetLabel(2);
a2b90f83 75
5443e65e 76 fY = c.GetY();
77 fZ = c.GetZ();
78 fSigmaY2 = c.GetSigmaY2();
79 fSigmaZ2 = c.GetSigmaZ2();
a2b90f83 80
5443e65e 81 fDetector = c.GetDetector();
82 fTimeBin = c.GetLocalTimeBin();
83 fQ = c.GetQ();
a2b90f83 84
85}
86
a2b90f83 87//_____________________________________________________________________________
88void AliTRDcluster::AddTrackIndex(Int_t *track)
89{
90 //
91 // Adds track index. Currently assumed that track is an array of
92 // size 9, and up to 3 track indexes are stored in fTracks[3].
93 // Indexes are sorted according to:
94 // 1) index of max number of appearances is stored first
95 // 2) if two or more indexes appear equal number of times, the lowest
96 // ones are stored first;
97 //
bbf92647 98
5443e65e 99 const Int_t size = 9;
a2b90f83 100
5443e65e 101 Int_t entries[size][2], i, j, index;
a2b90f83 102
5443e65e 103 Bool_t index_added;
a2b90f83 104
5443e65e 105 for (i=0; i<size; i++) {
a2b90f83 106 entries[i][0]=-1;
107 entries[i][1]=0;
5443e65e 108 }
a2b90f83 109
5443e65e 110 for (Int_t k=0; k<size; k++) {
a2b90f83 111 index=track[k];
5443e65e 112 index_added=kFALSE; j=0;
a2b90f83 113 if (index >= 0) {
5443e65e 114 while ( (!index_added) && ( j < size ) ) {
a2b90f83 115 if ((entries[j][0]==index) || (entries[j][1]==0)) {
116 entries[j][0]=index;
117 entries[j][1]=entries[j][1]+1;
5443e65e 118 index_added=kTRUE;
a2b90f83 119 }
120 j++;
121 }
122 }
5443e65e 123 }
a2b90f83 124
125 // sort by number of appearances and index value
126 Int_t swap=1, tmp0, tmp1;
127 while ( swap > 0) {
128 swap=0;
5443e65e 129 for(i=0; i<(size-1); i++) {
a2b90f83 130 if ((entries[i][0] >= 0) && (entries[i+1][0] >= 0)) {
131 if ((entries[i][1] < entries[i+1][1]) ||
132 ((entries[i][1] == entries[i+1][1]) &&
133 (entries[i][0] > entries[i+1][0]))) {
134 tmp0=entries[i][0];
135 tmp1=entries[i][1];
136 entries[i][0]=entries[i+1][0];
137 entries[i][1]=entries[i+1][1];
138 entries[i+1][0]=tmp0;
139 entries[i+1][1]=tmp1;
140 swap++;
141 }
142 }
143 }
5443e65e 144 }
a2b90f83 145
146 // set track indexes
5443e65e 147 for(i=0; i<3; i++) SetLabel(entries[i][0],i);
a2b90f83 148
149 return;
46d29e70 150
5443e65e 151}
46d29e70 152