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