]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliClusters.cxx
Changes due to a new class AliComplexCluster. Forward declarations.
[u/mrichter/AliRoot.git] / TPC / AliClusters.cxx
CommitLineData
cc80f89e 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/*
17$Log$
73042f01 18Revision 1.2.4.2 2000/06/14 16:45:13 kowal2
19Improved algorithms. Compiler warnings removed.
20
21Revision 1.2.4.1 2000/06/09 07:09:29 kowal2
22
23Clustering and tracking classes are splitted from the simulation ones
24
25Revision 1.2 2000/04/17 09:37:33 kowal2
26removed obsolete AliTPCDigitsDisplay.C
27
cc80f89e 28Revision 1.1.4.2 2000/04/10 11:34:02 kowal2
29
30Clusters handling in a new data structure
31
32*/
33
34///////////////////////////////////////////////////////////////////////////////
35// //
36// Time Projection Chamber clusters objects //
37//
38// Origin: Marian Ivanov , GSI Darmstadt
39// //
40// //
41// //
42///////////////////////////////////////////////////////////////////////////////
43#include "TError.h"
44#include "TClass.h"
45#include <TROOT.h>
46#include "AliCluster.h"
47#include "AliClusters.h"
48#include "TClonesArray.h"
49#include "TMarker.h"
50
51
52const Int_t kDefSize = 1; //defalut size
53
54
55ClassImp(AliClusters)
56
57//*****************************************************************************
58//
59//_____________________________________________________________________________
60AliClusters::AliClusters()
61{
62 //
63 //default constructor
73042f01 64 //
cc80f89e 65 fNclusters=0;
66 fClusters =0;
67 fClass =0;
68}
69
73042f01 70//________________________________________________________________________
71AliClusters::~AliClusters()
72{
73 //
74 //default destructor
75 //
76 if (fClusters !=0) fClusters->Clear();
77 delete fClusters;
78}
79
80//_________________________________________________________________________
81
cc80f89e 82Bool_t AliClusters::SetClass(const Text_t *classname)
83{
84 //
85 //set class of stored object
86 if ( fClass !=0 ) {
87 delete fClass;
88 fClass = 0;
89 }
90
91 if (!gROOT)
92 ::Fatal("AliClusters::SetClass", "ROOT system not initialized");
93
94 fClass = gROOT->GetClass(classname);
95 if (!fClass) {
96 Error("AliClusters", "%s is not a valid class name", classname);
97 return kFALSE;
98 }
73042f01 99 if (!fClass->InheritsFrom(TObject::Class())) {
100 Error("AliClusters", "%s does not inherit from TObject", classname);
101 return kFALSE;
102 }
cc80f89e 103 return kTRUE;
104}
105
106//_____________________________________________________________________________
107void AliClusters::SetArray(Int_t length)
108{
109 //
110 // construct Clones array of object
111 //
112 if (fClusters!=0) delete fClusters;
113 if (fClass==0){
114 Error("AliClusters", "cluster type not initialised \n SetClass before!");
115 return;
116 }
117 fClusters = new TClonesArray(fClass->GetName(),length);
118}
119
120
121
122//_____________________________________________________________________________
73042f01 123const TObject* AliClusters::operator[](Int_t i)
cc80f89e 124{
125 //
126 // return cluster at internal position i
127 //
128 if (fClusters==0) return 0;
73042f01 129 return fClusters->UncheckedAt(i);
cc80f89e 130}
131//_____________________________________________________________________________
132void AliClusters::Sort()
133{
134 // sort cluster
135 if (fClusters!=0) fClusters->Sort();
136}
137
138//_____________________________________________________________________________
73042f01 139TObject * AliClusters::InsertCluster( const TObject * c)
cc80f89e 140{
141 //
142 // Add a simulated cluster copy to the list
143 //
144 if (fClass==0) {
145 Error("AliClusters", "class type not specified");
146 return 0;
147 }
148 if(!fClusters) fClusters=new TClonesArray(fClass->GetName(),1000);
149 TClonesArray &lclusters = *fClusters;
73042f01 150 return new(lclusters[fNclusters++]) AliCluster(*((AliCluster*)c));
cc80f89e 151}
152
153//_____________________________________________________________________________
154Int_t AliClusters::Find(Double_t y) const
155{
156 //
157 // return index of cluster nearest to given y position
158 //
159 AliCluster* cl;
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;
168 else e=m;
169 }
170 return m;
171}
172
173
174//_____________________________________________________________________________
175
73042f01 176void AliClusters::DrawClusters(Float_t shiftx, Float_t shifty,
cc80f89e 177 Int_t color, Int_t size, Int_t style)
178{
179
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);
191 marker->Draw();
192 }
193}
194