]>
Commit | Line | Data |
---|---|---|
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 | ||
88cb7938 | 16 | /* $Id$ */ |
cc80f89e | 17 | |
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // Time Projection Chamber clusters objects // | |
21 | // | |
22 | // Origin: Marian Ivanov , GSI Darmstadt | |
23 | // // | |
24 | // // | |
25 | // // | |
26 | /////////////////////////////////////////////////////////////////////////////// | |
27 | #include "TError.h" | |
28 | #include "TClass.h" | |
29 | #include <TROOT.h> | |
c9787763 | 30 | #include "AliComplexCluster.h" |
cc80f89e | 31 | #include "AliClusters.h" |
cc80f89e | 32 | #include "TMarker.h" |
33 | ||
34 | ||
35 | const Int_t kDefSize = 1; //defalut size | |
36 | ||
37 | ||
38 | ClassImp(AliClusters) | |
39 | ||
40 | //***************************************************************************** | |
41 | // | |
42 | //_____________________________________________________________________________ | |
179c6296 | 43 | AliClusters::AliClusters() |
44 | :AliSegmentID(), | |
45 | fClusters(0), | |
46 | fNclusters(0), | |
47 | fClass(0) | |
cc80f89e | 48 | { |
49 | // | |
50 | //default constructor | |
73042f01 | 51 | // |
cc80f89e | 52 | |
179c6296 | 53 | } |
54 | //________________________________________________________________________ | |
55 | AliClusters::AliClusters(const AliClusters ¶m) | |
56 | :AliSegmentID(), | |
57 | fClusters(0), | |
58 | fNclusters(0), | |
59 | fClass(0) | |
60 | { | |
61 | // | |
62 | // copy constructor - dummy | |
63 | // | |
64 | fNclusters = param.fNclusters; | |
65 | } | |
e7de6656 | 66 | |
67 | //________________________________________________________________________ | |
68 | AliClusters::AliClusters(const char *classname) | |
69 | :AliSegmentID(), | |
70 | fClusters(0), | |
71 | fNclusters(0), | |
72 | fClass(0) | |
73 | { | |
74 | // | |
75 | // Special constructor | |
76 | // | |
77 | fClass = gROOT->GetClass(classname); | |
78 | ||
79 | if (!fClass) | |
80 | Error("AliClusters", "%s is not a valid class name", classname); | |
81 | if (!fClass->InheritsFrom(TObject::Class())) | |
82 | Error("AliClusters", "%s does not inherit from TObject", classname); | |
83 | ||
84 | fClusters = new TClonesArray(fClass->GetName(),100); | |
85 | } | |
86 | ||
87 | //______________________________________________________________________ | |
179c6296 | 88 | AliClusters & AliClusters::operator =(const AliClusters & param) |
89 | { | |
90 | // | |
91 | // assignment operator - dummy | |
92 | // | |
04420071 | 93 | if (this == ¶m) return (*this); |
179c6296 | 94 | fNclusters=param.fNclusters; |
95 | return (*this); | |
96 | } | |
73042f01 | 97 | //________________________________________________________________________ |
98 | AliClusters::~AliClusters() | |
99 | { | |
100 | // | |
101 | //default destructor | |
102 | // | |
a0f67dc8 | 103 | if (fClusters !=0) fClusters->Delete(); |
73042f01 | 104 | delete fClusters; |
105 | } | |
106 | ||
107 | //_________________________________________________________________________ | |
108 | ||
cc80f89e | 109 | Bool_t AliClusters::SetClass(const Text_t *classname) |
110 | { | |
111 | // | |
112 | //set class of stored object | |
113 | if ( fClass !=0 ) { | |
bb5e9dae | 114 | // delete fClass; |
cc80f89e | 115 | fClass = 0; |
116 | } | |
117 | ||
118 | if (!gROOT) | |
119 | ::Fatal("AliClusters::SetClass", "ROOT system not initialized"); | |
120 | ||
121 | fClass = gROOT->GetClass(classname); | |
122 | if (!fClass) { | |
123 | Error("AliClusters", "%s is not a valid class name", classname); | |
124 | return kFALSE; | |
125 | } | |
73042f01 | 126 | if (!fClass->InheritsFrom(TObject::Class())) { |
127 | Error("AliClusters", "%s does not inherit from TObject", classname); | |
128 | return kFALSE; | |
129 | } | |
cc80f89e | 130 | return kTRUE; |
131 | } | |
132 | ||
133 | //_____________________________________________________________________________ | |
134 | void AliClusters::SetArray(Int_t length) | |
135 | { | |
136 | // | |
137 | // construct Clones array of object | |
138 | // | |
139 | if (fClusters!=0) delete fClusters; | |
140 | if (fClass==0){ | |
141 | Error("AliClusters", "cluster type not initialised \n SetClass before!"); | |
142 | return; | |
143 | } | |
144 | fClusters = new TClonesArray(fClass->GetName(),length); | |
145 | } | |
146 | ||
147 | ||
148 | ||
149 | //_____________________________________________________________________________ | |
73042f01 | 150 | const TObject* AliClusters::operator[](Int_t i) |
cc80f89e | 151 | { |
152 | // | |
153 | // return cluster at internal position i | |
154 | // | |
155 | if (fClusters==0) return 0; | |
73042f01 | 156 | return fClusters->UncheckedAt(i); |
cc80f89e | 157 | } |
158 | //_____________________________________________________________________________ | |
159 | void AliClusters::Sort() | |
160 | { | |
161 | // sort cluster | |
162 | if (fClusters!=0) fClusters->Sort(); | |
163 | } | |
164 | ||
165 | //_____________________________________________________________________________ | |
73042f01 | 166 | TObject * AliClusters::InsertCluster( const TObject * c) |
cc80f89e | 167 | { |
168 | // | |
169 | // Add a simulated cluster copy to the list | |
170 | // | |
171 | if (fClass==0) { | |
172 | Error("AliClusters", "class type not specified"); | |
173 | return 0; | |
174 | } | |
e7de6656 | 175 | if(!fClusters) fClusters=new TClonesArray(fClass->GetName(),100); |
cc80f89e | 176 | TClonesArray &lclusters = *fClusters; |
c9787763 | 177 | return new(lclusters[fNclusters++]) AliComplexCluster(*((AliComplexCluster*)c)); |
cc80f89e | 178 | } |
179 | ||
180 | //_____________________________________________________________________________ | |
181 | Int_t AliClusters::Find(Double_t y) const | |
182 | { | |
183 | // | |
184 | // return index of cluster nearest to given y position | |
185 | // | |
c9787763 | 186 | AliComplexCluster* cl; |
187 | cl=(AliComplexCluster*)fClusters->UncheckedAt(0); | |
b9671574 | 188 | if (y <= cl->GetY()) return 0; |
c9787763 | 189 | cl=(AliComplexCluster*)fClusters->UncheckedAt(fNclusters-1); |
b9671574 | 190 | if (y > cl->GetY()) return fNclusters; |
cc80f89e | 191 | Int_t b=0, e=fNclusters-1, m=(b+e)/2; |
192 | for (; b<e; m=(b+e)/2) { | |
c9787763 | 193 | cl = (AliComplexCluster*)fClusters->UncheckedAt(m); |
b9671574 | 194 | if (y > cl->GetY()) b=m+1; |
cc80f89e | 195 | else e=m; |
196 | } | |
197 | return m; | |
198 | } | |
199 | ||
200 | ||
201 | //_____________________________________________________________________________ | |
202 | ||
73042f01 | 203 | void AliClusters::DrawClusters(Float_t shiftx, Float_t shifty, |
cc80f89e | 204 | Int_t color, Int_t size, Int_t style) |
205 | { | |
206 | ||
207 | if (fClusters==0) return; | |
208 | //draw marker for each of cluster | |
209 | Int_t ncl=fClusters->GetEntriesFast(); | |
210 | for (Int_t i=0;i<ncl;i++){ | |
c9787763 | 211 | AliComplexCluster *cl = (AliComplexCluster*)fClusters->UncheckedAt(i); |
cc80f89e | 212 | TMarker * marker = new TMarker; |
b9671574 | 213 | marker->SetX(cl->GetX()+shiftx); |
214 | marker->SetY(cl->GetY()+shifty); | |
cc80f89e | 215 | marker->SetMarkerSize(size); |
216 | marker->SetMarkerStyle(style); | |
217 | marker->SetMarkerColor(color); | |
218 | marker->Draw(); | |
219 | } | |
220 | } | |
221 |