AliRoot Core  v5-06-30 (35d6c57)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliClusters.cxx
Go to the documentation of this file.
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 
20 
21 #include "TError.h"
22 #include "TClass.h"
23 #include <TROOT.h>
24 #include "AliComplexCluster.h"
25 #include "AliClusters.h"
26 #include "TMarker.h"
27 
28 const Int_t kDefSize = 1;
29 
33 
35  :AliSegmentID(),
36  fClusters(0),
37  fNclusters(0),
38  fClass(0)
39 {
41 }
42 
44  :AliSegmentID(),
45  fClusters(0),
46  fNclusters(0),
47  fClass(0)
48 {
50 
51  fNclusters = param.fNclusters;
52 }
53 
54 AliClusters::AliClusters(const char *classname)
55  :AliSegmentID(),
56  fClusters(0),
57  fNclusters(0),
58  fClass(0)
59 {
61 
62  fClass = gROOT->GetClass(classname);
63 
64  if (!fClass)
65  Error("AliClusters", "%s is not a valid class name", classname);
66  if (!fClass->InheritsFrom(TObject::Class()))
67  Error("AliClusters", "%s does not inherit from TObject", classname);
68 
69  fClusters = new TClonesArray(fClass->GetName(),100);
70 }
71 
73 {
75 
76  if (this == &param) return (*this);
77  fNclusters=param.fNclusters;
78  return (*this);
79 }
80 
82 {
84 
85  if (fClusters !=0) fClusters->Delete();
86  delete fClusters;
87 }
88 
89 Bool_t AliClusters::SetClass(const Text_t *classname)
90 {
92 
93  if ( fClass !=0 ) {
94  // delete fClass;
95  fClass = 0;
96  }
97 
98  if (!gROOT)
99  ::Fatal("AliClusters::SetClass", "ROOT system not initialized");
100 
101  fClass = gROOT->GetClass(classname);
102  if (!fClass) {
103  Error("AliClusters", "%s is not a valid class name", classname);
104  return kFALSE;
105  }
106  if (!fClass->InheritsFrom(TObject::Class())) {
107  Error("AliClusters", "%s does not inherit from TObject", classname);
108  return kFALSE;
109  }
110  return kTRUE;
111 }
112 
113 void AliClusters::SetArray(Int_t length)
114 {
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 const TObject* AliClusters::operator[](Int_t i)
126 {
128 
129  if (fClusters==0) return 0;
130  return fClusters->UncheckedAt(i);
131 }
132 
134 {
136 
137  if (fClusters!=0) fClusters->Sort();
138 }
139 
140 TObject * AliClusters::InsertCluster( const TObject * c)
141 {
143 
144  if (fClass==0) {
145  Error("AliClusters", "class type not specified");
146  return 0;
147  }
148  if(!fClusters) fClusters=new TClonesArray(fClass->GetName(),100);
149  TClonesArray &lclusters = *fClusters;
150  return new(lclusters[fNclusters++]) AliComplexCluster(*((AliComplexCluster*)c));
151 }
152 
153 Int_t AliClusters::Find(Double_t y) const
154 {
156 
157  AliComplexCluster* cl;
158  cl=(AliComplexCluster*)fClusters->UncheckedAt(0);
159  if (y <= cl->GetY()) return 0;
160  cl=(AliComplexCluster*)fClusters->UncheckedAt(fNclusters-1);
161  if (y > cl->GetY()) return fNclusters;
162  Int_t b=0, e=fNclusters-1, m=(b+e)/2;
163  for (; b<e; m=(b+e)/2) {
164  cl = (AliComplexCluster*)fClusters->UncheckedAt(m);
165  if (y > cl->GetY()) b=m+1;
166  else e=m;
167  }
168  return m;
169 }
170 
171 
172 void AliClusters::DrawClusters(Float_t shiftx, Float_t shifty,
173  Int_t color, Int_t size, Int_t style)
174 {
175 
176  if (fClusters==0) return;
177  //draw marker for each of cluster
178  Int_t ncl=fClusters->GetEntriesFast();
179  for (Int_t i=0;i<ncl;i++){
180  AliComplexCluster *cl = (AliComplexCluster*)fClusters->UncheckedAt(i);
181  TMarker * marker = new TMarker;
182  marker->SetX(cl->GetX()+shiftx);
183  marker->SetY(cl->GetY()+shifty);
184  marker->SetMarkerSize(size);
185  marker->SetMarkerStyle(style);
186  marker->SetMarkerColor(color);
187  marker->Draw();
188  }
189 }
const Int_t kDefSize
defalut size
Definition: AliClusters.cxx:28
AliSegmentID object.
Definition: AliSegmentID.h:15
Int_t fNclusters
Definition: AliClusters.h:35
TROOT * gROOT
void SetArray(Int_t length)
virtual Int_t Find(Double_t y) const
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
TClonesArray * fClusters
array of clusters
Definition: AliClusters.h:34
TClass * fClass
! type of cluster class
Definition: AliClusters.h:36
Float_t GetY() const
const TObject * operator[](Int_t i)
void DrawClusters(Float_t shiftx, Float_t shifty, Int_t color, Int_t size, Int_t style)
Bool_t SetClass(const Text_t *classname)
Definition: AliClusters.cxx:89
Time Projection Chamber clusters objects.
Definition: AliClusters.h:17
virtual TObject * InsertCluster(const TObject *c)
Float_t GetX() const
AliClusters & operator=(const AliClusters &param)
Definition: AliClusters.cxx:72