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