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.2.4.2 2000/06/14 16:45:13 kowal2
19 Improved algorithms. Compiler warnings removed.
21 Revision 1.2.4.1 2000/06/09 07:09:29 kowal2
23 Clustering and tracking classes are splitted from the simulation ones
25 Revision 1.2 2000/04/17 09:37:33 kowal2
26 removed obsolete AliTPCDigitsDisplay.C
28 Revision 1.1.4.2 2000/04/10 11:34:02 kowal2
30 Clusters handling in a new data structure
34 ///////////////////////////////////////////////////////////////////////////////
36 // Time Projection Chamber clusters objects //
38 // Origin: Marian Ivanov , GSI Darmstadt
42 ///////////////////////////////////////////////////////////////////////////////
46 #include "AliCluster.h"
47 #include "AliClusters.h"
48 #include "TClonesArray.h"
52 const Int_t kDefSize = 1; //defalut size
57 //*****************************************************************************
59 //_____________________________________________________________________________
60 AliClusters::AliClusters()
70 //________________________________________________________________________
71 AliClusters::~AliClusters()
76 if (fClusters !=0) fClusters->Clear();
80 //_________________________________________________________________________
82 Bool_t AliClusters::SetClass(const Text_t *classname)
85 //set class of stored object
92 ::Fatal("AliClusters::SetClass", "ROOT system not initialized");
94 fClass = gROOT->GetClass(classname);
96 Error("AliClusters", "%s is not a valid class name", classname);
99 if (!fClass->InheritsFrom(TObject::Class())) {
100 Error("AliClusters", "%s does not inherit from TObject", classname);
106 //_____________________________________________________________________________
107 void AliClusters::SetArray(Int_t length)
110 // construct Clones array of object
112 if (fClusters!=0) delete fClusters;
114 Error("AliClusters", "cluster type not initialised \n SetClass before!");
117 fClusters = new TClonesArray(fClass->GetName(),length);
122 //_____________________________________________________________________________
123 const TObject* AliClusters::operator[](Int_t i)
126 // return cluster at internal position i
128 if (fClusters==0) return 0;
129 return fClusters->UncheckedAt(i);
131 //_____________________________________________________________________________
132 void AliClusters::Sort()
135 if (fClusters!=0) fClusters->Sort();
138 //_____________________________________________________________________________
139 TObject * AliClusters::InsertCluster( const TObject * c)
142 // Add a simulated cluster copy to the list
145 Error("AliClusters", "class type not specified");
148 if(!fClusters) fClusters=new TClonesArray(fClass->GetName(),1000);
149 TClonesArray &lclusters = *fClusters;
150 return new(lclusters[fNclusters++]) AliCluster(*((AliCluster*)c));
153 //_____________________________________________________________________________
154 Int_t AliClusters::Find(Double_t y) const
157 // return index of cluster nearest to given y position
160 cl=(AliCluster*)fClusters->UncheckedAt(0);
161 if (y <= cl->fY) return 0;
162 cl=(AliCluster*)fClusters->UncheckedAt(fNclusters-1);
163 if (y > cl->fY) return fNclusters;
164 Int_t b=0, e=fNclusters-1, m=(b+e)/2;
165 for (; b<e; m=(b+e)/2) {
166 cl = (AliCluster*)fClusters->UncheckedAt(m);
167 if (y > cl->fY) b=m+1;
174 //_____________________________________________________________________________
176 void AliClusters::DrawClusters(Float_t shiftx, Float_t shifty,
177 Int_t color, Int_t size, Int_t style)
180 if (fClusters==0) return;
181 //draw marker for each of cluster
182 Int_t ncl=fClusters->GetEntriesFast();
183 for (Int_t i=0;i<ncl;i++){
184 AliCluster *cl = (AliCluster*)fClusters->UncheckedAt(i);
185 TMarker * marker = new TMarker;
186 marker->SetX(cl->fX+shiftx);
187 marker->SetY(cl->fY+shifty);
188 marker->SetMarkerSize(size);
189 marker->SetMarkerStyle(style);
190 marker->SetMarkerColor(color);