]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliClusters.cxx
Remove compilation of grndmq
[u/mrichter/AliRoot.git] / TPC / AliClusters.cxx
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$
18 Revision 1.4  2000/10/05 16:17:27  kowal2
19 New class replacing AliCluster
20
21 Revision 1.3  2000/06/30 12:07:49  kowal2
22 Updated from the TPC-PreRelease branch
23
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
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>
52 #include "AliComplexCluster.h"
53 #include "AliClusters.h"
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
69   //
70   fNclusters=0;
71   fClusters =0;
72   fClass =0;
73 }
74
75 //________________________________________________________________________
76 AliClusters::~AliClusters()
77 {
78    //
79    //default destructor
80   //
81    if (fClusters !=0) fClusters->Clear();
82    delete fClusters;
83 }
84
85 //_________________________________________________________________________
86
87 Bool_t AliClusters::SetClass(const Text_t *classname)
88 {
89   //
90   //set class of stored object
91   if ( fClass !=0 ) {
92     //    delete fClass;
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    }
104    if (!fClass->InheritsFrom(TObject::Class())) {
105       Error("AliClusters", "%s does not inherit from TObject", classname);
106       return kFALSE; 
107    } 
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 //_____________________________________________________________________________
128 const  TObject* AliClusters::operator[](Int_t i)
129 {
130   //
131   // return cluster at internal position i
132   //
133   if (fClusters==0) return 0;
134   return fClusters->UncheckedAt(i);
135 }
136 //_____________________________________________________________________________
137 void  AliClusters::Sort()
138 {
139   // sort cluster 
140   if (fClusters!=0) fClusters->Sort();
141 }
142
143 //_____________________________________________________________________________
144 TObject * AliClusters::InsertCluster( const TObject * c) 
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;
155   return new(lclusters[fNclusters++]) AliComplexCluster(*((AliComplexCluster*)c));
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   //
164   AliComplexCluster* cl;
165   cl=(AliComplexCluster*)fClusters->UncheckedAt(0);
166   if (y <= cl->fY) return 0;  
167   cl=(AliComplexCluster*)fClusters->UncheckedAt(fNclusters-1);
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) {
171     cl = (AliComplexCluster*)fClusters->UncheckedAt(m);
172     if (y > cl->fY) b=m+1;
173     else e=m; 
174   }
175   return m;
176 }
177
178
179 //_____________________________________________________________________________
180
181 void AliClusters::DrawClusters(Float_t shiftx, Float_t shifty, 
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++){
189     AliComplexCluster *cl = (AliComplexCluster*)fClusters->UncheckedAt(i);
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