1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 ///////////////////////////////////////////////////////////////////////////////
23 ///////////////////////////////////////////////////////////////////////////////
25 #include "AliTRDcluster.h"
26 #include "AliTRDrecPoint.h"
28 ClassImp(AliTRDcluster)
31 //___________________________________________________________________________
33 AliTRDcluster::AliTRDcluster() : AliCluster() {
35 // default constructor
42 for (Int_t i = 0;i<7; i++) fSignals[i]=0;
44 //_____________________________________________________________________________
45 AliTRDcluster::AliTRDcluster(const AliTRDrecPoint &p):AliCluster()
48 // Constructor from AliTRDrecPoint
51 fDetector = p.GetDetector();
52 fTimeBin = p.GetLocalTimeBin();
54 fTracks[0] = p.GetTrackIndex(0);
55 fTracks[1] = p.GetTrackIndex(1);
56 fTracks[2] = p.GetTrackIndex(2);
62 fSigmaY2 = p.GetSigmaY2();
63 fSigmaZ2 = p.GetSigmaZ2();
71 //_____________________________________________________________________________
72 AliTRDcluster::AliTRDcluster(const AliTRDcluster &c):AliCluster()
78 fTracks[0] = c.GetLabel(0);
79 fTracks[1] = c.GetLabel(1);
80 fTracks[2] = c.GetLabel(2);
85 fSigmaY2 = c.GetSigmaY2();
86 fSigmaZ2 = c.GetSigmaZ2();
88 fDetector = c.GetDetector();
89 fTimeBin = c.GetLocalTimeBin();
93 for (Int_t i=0;i<7;i++) fSignals[i] = c.fSignals[i];
96 //_____________________________________________________________________________
97 void AliTRDcluster::AddTrackIndex(Int_t *track)
100 // Adds track index. Currently assumed that track is an array of
101 // size 9, and up to 3 track indexes are stored in fTracks[3].
102 // Indexes are sorted according to:
103 // 1) index of max number of appearances is stored first
104 // 2) if two or more indexes appear equal number of times, the lowest
105 // ones are stored first;
108 const Int_t kSize = 9;
110 Int_t entries[kSize][2], i, j, index;
114 for (i=0; i<kSize; i++) {
119 for (Int_t k=0; k<kSize; k++) {
124 while ( (!indexAdded) && ( j < kSize ) ) {
125 if ((entries[j][0]==index) || (entries[j][1]==0)) {
127 entries[j][1]=entries[j][1]+1;
135 // sort by number of appearances and index value
136 Int_t swap=1, tmp0, tmp1;
139 for(i=0; i<(kSize-1); i++) {
140 if ((entries[i][0] >= 0) && (entries[i+1][0] >= 0)) {
141 if ((entries[i][1] < entries[i+1][1]) ||
142 ((entries[i][1] == entries[i+1][1]) &&
143 (entries[i][0] > entries[i+1][0]))) {
146 entries[i][0]=entries[i+1][0];
147 entries[i][1]=entries[i+1][1];
148 entries[i+1][0]=tmp0;
149 entries[i+1][1]=tmp1;
157 for(i=0; i<3; i++) SetLabel(entries[i][0],i);
163 void AliTRDcluster::SetSignals(Short_t*signals){
165 // write signals in the cluster
167 for (Int_t i = 0;i<7;i++) fSignals[i]=signals[i];
170 Float_t AliTRDcluster::GetSumS() const
173 // return total charge in non unfolded cluster
176 for (Int_t i = 0;i<7;i++) sum+=fSignals[i];
179 Float_t AliTRDcluster::GetCenterS() const
186 for (Int_t i = 0;i<7;i++) {
190 if (sum>0) return sum2/sum-2;