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 **************************************************************************/
18 Revision 1.4 2000/10/05 16:17:27 kowal2
19 New class replacing AliCluster
21 Revision 1.3 2000/06/30 12:07:49 kowal2
22 Updated from the TPC-PreRelease branch
24 Revision 1.2.4.2 2000/06/14 16:45:13 kowal2
25 Improved algorithms. Compiler warnings removed.
27 Revision 1.2.4.1 2000/06/09 07:09:29 kowal2
29 Clustering and tracking classes are splitted from the simulation ones
31 Revision 1.2 2000/04/17 09:37:33 kowal2
32 removed obsolete AliTPCDigitsDisplay.C
34 Revision 1.1.4.2 2000/04/10 11:34:02 kowal2
36 Clusters handling in a new data structure
40 ///////////////////////////////////////////////////////////////////////////////
42 // Time Projection Chamber clusters objects //
44 // Origin: Marian Ivanov , GSI Darmstadt
48 ///////////////////////////////////////////////////////////////////////////////
52 #include "AliComplexCluster.h"
53 #include "AliClusters.h"
57 const Int_t kDefSize = 1; //defalut size
62 //*****************************************************************************
64 //_____________________________________________________________________________
65 AliClusters::AliClusters()
75 //________________________________________________________________________
76 AliClusters::~AliClusters()
81 if (fClusters !=0) fClusters->Clear();
85 //_________________________________________________________________________
87 Bool_t AliClusters::SetClass(const Text_t *classname)
90 //set class of stored object
97 ::Fatal("AliClusters::SetClass", "ROOT system not initialized");
99 fClass = gROOT->GetClass(classname);
101 Error("AliClusters", "%s is not a valid class name", classname);
104 if (!fClass->InheritsFrom(TObject::Class())) {
105 Error("AliClusters", "%s does not inherit from TObject", classname);
111 //_____________________________________________________________________________
112 void AliClusters::SetArray(Int_t length)
115 // construct Clones array of object
117 if (fClusters!=0) delete fClusters;
119 Error("AliClusters", "cluster type not initialised \n SetClass before!");
122 fClusters = new TClonesArray(fClass->GetName(),length);
127 //_____________________________________________________________________________
128 const TObject* AliClusters::operator[](Int_t i)
131 // return cluster at internal position i
133 if (fClusters==0) return 0;
134 return fClusters->UncheckedAt(i);
136 //_____________________________________________________________________________
137 void AliClusters::Sort()
140 if (fClusters!=0) fClusters->Sort();
143 //_____________________________________________________________________________
144 TObject * AliClusters::InsertCluster( const TObject * c)
147 // Add a simulated cluster copy to the list
150 Error("AliClusters", "class type not specified");
153 if(!fClusters) fClusters=new TClonesArray(fClass->GetName(),1000);
154 TClonesArray &lclusters = *fClusters;
155 return new(lclusters[fNclusters++]) AliComplexCluster(*((AliComplexCluster*)c));
158 //_____________________________________________________________________________
159 Int_t AliClusters::Find(Double_t y) const
162 // return index of cluster nearest to given y position
164 AliComplexCluster* cl;
165 cl=(AliComplexCluster*)fClusters->UncheckedAt(0);
166 if (y <= cl->fY) return 0;
167 cl=(AliComplexCluster*)fClusters->UncheckedAt(fNclusters-1);
168 if (y > cl->fY) return fNclusters;
169 Int_t b=0, e=fNclusters-1, m=(b+e)/2;
170 for (; b<e; m=(b+e)/2) {
171 cl = (AliComplexCluster*)fClusters->UncheckedAt(m);
172 if (y > cl->fY) b=m+1;
179 //_____________________________________________________________________________
181 void AliClusters::DrawClusters(Float_t shiftx, Float_t shifty,
182 Int_t color, Int_t size, Int_t style)
185 if (fClusters==0) return;
186 //draw marker for each of cluster
187 Int_t ncl=fClusters->GetEntriesFast();
188 for (Int_t i=0;i<ncl;i++){
189 AliComplexCluster *cl = (AliComplexCluster*)fClusters->UncheckedAt(i);
190 TMarker * marker = new TMarker;
191 marker->SetX(cl->fX+shiftx);
192 marker->SetY(cl->fY+shifty);
193 marker->SetMarkerSize(size);
194 marker->SetMarkerStyle(style);
195 marker->SetMarkerColor(color);