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