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 ///////////////////////////////////////////////////////////////////////////////
26 #include "AliTRDcluster.h"
28 ClassImp(AliTRDcluster)
30 //___________________________________________________________________________
31 AliTRDcluster::AliTRDcluster()
44 // Default constructor
47 for (Int_t i = 0; i < 7; i++) {
53 //___________________________________________________________________________
54 AliTRDcluster::AliTRDcluster(Int_t det, Float_t q
55 , Float_t *pos, Float_t *sig
56 , Int_t *tracks, Char_t npads, Short_t *signals
57 , UChar_t col, UChar_t row, UChar_t time
58 , Char_t timebin, Float_t center, UShort_t volid)
59 :AliCluster(volid,pos[0],pos[1],pos[2],sig[0],sig[1],0.0,0x0)
63 ,fLocalTimeBin(timebin)
74 for (Int_t i = 0; i < 7; i++) {
75 fSignals[i] = signals[i];
79 AddTrackIndex(tracks);
84 //_____________________________________________________________________________
85 AliTRDcluster::AliTRDcluster(const AliTRDcluster &c)
90 ,fLocalTimeBin(c.fLocalTimeBin)
92 ,fClusterMasking(c.fClusterMasking)
93 ,fDetector(c.fDetector)
101 SetBit(kInChamber, c.IsInChamber());
102 SetLabel(c.GetLabel(0),0);
103 SetLabel(c.GetLabel(1),1);
104 SetLabel(c.GetLabel(2),2);
108 SetSigmaY2(c.GetSigmaY2());
109 SetSigmaZ2(c.GetSigmaZ2());
111 for (Int_t i = 0; i < 7; i++) {
112 fSignals[i] = c.fSignals[i];
117 //_____________________________________________________________________________
118 void AliTRDcluster::AddTrackIndex(Int_t *track)
121 // Adds track index. Currently assumed that track is an array of
122 // size 9, and up to 3 track indexes are stored in fTracks[3].
123 // Indexes are sorted according to:
124 // 1) index of max number of appearances is stored first
125 // 2) if two or more indexes appear equal number of times, the lowest
126 // ones are stored first;
129 const Int_t kSize = 9;
130 Int_t entries[kSize][2];
138 for (i = 0; i < kSize; i++) {
143 for (k = 0; k < kSize; k++) {
150 while ((!indexAdded) && (j < kSize)) {
151 if ((entries[j][0] == index) ||
152 (entries[j][1] == 0)) {
153 entries[j][0] = index;
154 entries[j][1] = entries[j][1] + 1;
163 // Sort by number of appearances and index value
169 for (i = 0; i < (kSize - 1); i++) {
170 if ((entries[i][0] >= 0) &&
171 (entries[i+1][0] >= 0)) {
172 if ((entries[i][1] < entries[i+1][1]) ||
173 ((entries[i][1] == entries[i+1][1]) &&
174 (entries[i][0] > entries[i+1][0]))) {
175 tmp0 = entries[i][0];
176 tmp1 = entries[i][1];
177 entries[i][0] = entries[i+1][0];
178 entries[i][1] = entries[i+1][1];
179 entries[i+1][0] = tmp0;
180 entries[i+1][1] = tmp1;
188 for (i = 0; i < 3; i++) {
189 SetLabel(entries[i][0],i);
196 //_____________________________________________________________________________
197 void AliTRDcluster::Clear(Option_t *)
200 // Reset all member to the default value
209 for (Int_t i=0; i < 7; i++) fSignals[i]=0;
212 for (Int_t i = 0; i < 3; i++) SetLabel(0,i);
221 //_____________________________________________________________________________
222 Float_t AliTRDcluster::GetSumS() const
225 // Returns the total charge from a not unfolded cluster
229 for (Int_t i = 0; i < 7; i++) {
238 //_____________________________________________________________________________
239 Bool_t AliTRDcluster::IsEqual(const TObject *o) const
242 // Compare relevant information of this cluster with another one
245 const AliTRDcluster *inCluster = dynamic_cast<const AliTRDcluster*>(o);
246 if (!o || !inCluster) return kFALSE;
248 if ( AliCluster::GetX() != inCluster->GetX() ) return kFALSE;
249 if ( AliCluster::GetY() != inCluster->GetY() ) return kFALSE;
250 if ( AliCluster::GetZ() != inCluster->GetZ() ) return kFALSE;
251 if ( fQ != inCluster->fQ ) return kFALSE;
252 if ( fDetector != inCluster->fDetector ) return kFALSE;
253 if ( fPadCol != inCluster->fPadCol ) return kFALSE;
254 if ( fPadRow != inCluster->fPadRow ) return kFALSE;
255 if ( fPadTime != inCluster->fPadTime ) return kFALSE;
256 if ( fClusterMasking != inCluster->fClusterMasking ) return kFALSE;
257 if ( IsInChamber() != inCluster->IsInChamber() ) return kFALSE;
258 if ( IsShared() != inCluster->IsShared() ) return kFALSE;
259 if ( IsUsed() != inCluster->IsUsed() ) return kFALSE;
264 //_____________________________________________________________________________
265 void AliTRDcluster::Print(Option_t *o) const
267 AliInfo(Form("Det[%3d] LTrC[%7.2f %7.2f %7.2f] Q[%f] Stat[in(%c) use(%c) sh(%c)]",
268 fDetector, GetX(), GetY(), GetZ(), fQ,
269 IsInChamber() ? 'y' : 'n', IsUsed() ? 'y' : 'n', IsShared() ? 'y' : 'n'));
271 if(strcmp(o, "a")!=0) return;
272 AliInfo(Form("LChC[c(%3d) r(%2d) t(%2d)] t-t0[%2d] Npad[%d] cen[%5.3f] mask[%d]", fPadCol, fPadRow, fPadTime, fLocalTimeBin, fNPads, fCenter, fClusterMasking));
273 AliInfo(Form("Signals[%3d %3d %3d %3d %3d %3d %3d]", fSignals[0], fSignals[1], fSignals[2], fSignals[3], fSignals[4], fSignals[5], fSignals[6]));
277 //_____________________________________________________________________________
278 void AliTRDcluster::SetPadMaskedPosition(UChar_t position)
281 // store the pad corruption position code
283 // Code: 1 = left cluster
284 // 2 = middle cluster;
287 for(Int_t ipos = 0; ipos < 3; ipos++)
288 if(TESTBIT(position, ipos))
289 SETBIT(fClusterMasking, ipos);
292 //_____________________________________________________________________________
293 void AliTRDcluster::SetPadMaskedStatus(UChar_t status)
296 // store the status of the corrupted pad
301 // 32 = Not Connected
302 for(Int_t ipos = 0; ipos < 5; ipos++)
303 if(TESTBIT(status, ipos))
304 SETBIT(fClusterMasking, ipos + 3);