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
41 for (Int_t i = 0;i<7; i++) fSignals[i]=0;
43 //_____________________________________________________________________________
44 AliTRDcluster::AliTRDcluster(const AliTRDrecPoint &p):AliCluster()
47 // Constructor from AliTRDrecPoint
50 fDetector = p.GetDetector();
51 fTimeBin = p.GetLocalTimeBin();
53 fTracks[0] = p.GetTrackIndex(0);
54 fTracks[1] = p.GetTrackIndex(1);
55 fTracks[2] = p.GetTrackIndex(2);
61 fSigmaY2 = p.GetSigmaY2();
62 fSigmaZ2 = p.GetSigmaZ2();
70 //_____________________________________________________________________________
71 AliTRDcluster::AliTRDcluster(const AliTRDcluster &c):AliCluster()
77 fTracks[0] = c.GetLabel(0);
78 fTracks[1] = c.GetLabel(1);
79 fTracks[2] = c.GetLabel(2);
84 fSigmaY2 = c.GetSigmaY2();
85 fSigmaZ2 = c.GetSigmaZ2();
87 fDetector = c.GetDetector();
88 fTimeBin = c.GetLocalTimeBin();
92 for (Int_t i=0;i<7;i++) fSignals[i] = c.fSignals[i];
95 //_____________________________________________________________________________
96 void AliTRDcluster::AddTrackIndex(Int_t *track)
99 // Adds track index. Currently assumed that track is an array of
100 // size 9, and up to 3 track indexes are stored in fTracks[3].
101 // Indexes are sorted according to:
102 // 1) index of max number of appearances is stored first
103 // 2) if two or more indexes appear equal number of times, the lowest
104 // ones are stored first;
107 const Int_t kSize = 9;
109 Int_t entries[kSize][2], i, j, index;
113 for (i=0; i<kSize; i++) {
118 for (Int_t k=0; k<kSize; k++) {
123 while ( (!indexAdded) && ( j < kSize ) ) {
124 if ((entries[j][0]==index) || (entries[j][1]==0)) {
126 entries[j][1]=entries[j][1]+1;
134 // sort by number of appearances and index value
135 Int_t swap=1, tmp0, tmp1;
138 for(i=0; i<(kSize-1); i++) {
139 if ((entries[i][0] >= 0) && (entries[i+1][0] >= 0)) {
140 if ((entries[i][1] < entries[i+1][1]) ||
141 ((entries[i][1] == entries[i+1][1]) &&
142 (entries[i][0] > entries[i+1][0]))) {
145 entries[i][0]=entries[i+1][0];
146 entries[i][1]=entries[i+1][1];
147 entries[i+1][0]=tmp0;
148 entries[i+1][1]=tmp1;
156 for(i=0; i<3; i++) SetLabel(entries[i][0],i);
162 void AliTRDcluster::SetSignals(Short_t*signals){
164 // write signals in the cluster
166 for (Int_t i = 0;i<7;i++) fSignals[i]=signals[i];
169 Float_t AliTRDcluster::GetSumS() const
172 // return total charge in non unfolded cluster
175 for (Int_t i = 0;i<7;i++) sum+=fSignals[i];
178 Float_t AliTRDcluster::GetCenterS() const
185 for (Int_t i = 0;i<7;i++) {
189 if (sum>0) return sum2/sum-2;