KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVTrieurBloc.cpp
Go to the documentation of this file.
1 #include <math.h>
2 #include <stdio.h>
3 #include "KVTrieurBloc.h"
4 
5 using namespace std;
6 
8 
12 
13 //_____________________________________________________
14 
20 
22 {
23 //
24 // Initialisation des champs de KVTrieurBloc
25 // Cette methode privee n'est appelee par les createurs
26 //
27  nb++;
28  nb_crea++;
29  sprintf(nomVar, "Variable");
30 }
31 
32 
33 
34 
39 
41 {
42 //
43 // On affecte les noms des cases
44 //
45  if (noms_cases) {
46  for (Int_t i = 0; i < nb_cases; i++) {
47  TNamed* nom = (TNamed*) noms_cases->At(i);
48  nom->SetTitle(Form("%f #leq %s #leq %f", xmin(i), nomVar, xmax(i)));
49  }
50  }
51 }
52 
53 
54 
59 
61 {
62 //
63 // Createur par default
64 //
65  TString nom;
66 
68  nom.Form("KVTrieurBloc_%d", nb_crea);
69  SetName(nom);
70  SetTitle(nom);
71 #ifdef DEBUG_KVTrieurBloc
72  cout << nb << " crees...(defaut) " << endl;
73 #endif
74 }
75 
76 
77 
82 
84 {
85 //
86 // Constructeur avec un nom
87 //
89  SetName(nom);
90  SetTitle(nom);
91 #ifdef DEBUG_KVTrieurBloc
92  cout << nb << " crees...(nom) " << endl;
93 #endif
94 }
95 
96 
97 
102 
104  nom)
105 {
106 //
107 // Constructeur avec un nombre de cases et un nom
108 //
110  xmin.ResizeTo(nbcases);
111  xmax.ResizeTo(nbcases);
112 #ifdef DEBUG_KVTrieurBloc
113  cout << nb << " crees...(nom) " << endl;
114 #endif
115 }
116 
117 
118 
123 
125 {
126 //
127 // Contructeur par copie
128 //
130 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
131  a.Copy(*this);
132 #else
133  ((KVTrieurBloc&) a).Copy(*this);
134 #endif
135 #ifdef DEBUG_KVTrieurBloc
136  cout << nb << " crees...(copie) " << endl;
137 #endif
138 }
139 
140 
141 
146 
147 KVTrieurBloc::~KVTrieurBloc(void)
148 {
149 //
150 // Destructeur
151 //
152 #ifdef DEBUG_KVTrieurBloc
153  cout << "Destruction de " << GetName() << "..." << endl;
154 #endif
155  nb--;
156  nb_dest++;
157 }
158 
159 
160 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
161 
163 
165 {
166 #else
168 {
169 #endif
170 //
171 // Methode de copie
172 //
173 #ifdef DEBUG_KVTrieurBloc
174  cout << "Copie de " << this->GetName() << "..." << endl;
175 #endif
176  KVTrieur::Copy(a);
177  ((KVTrieurBloc&) a).xmin.ResizeTo(this->nb_cases);
178  ((KVTrieurBloc&) a).xmax.ResizeTo(this->nb_cases);
179  ((KVTrieurBloc&) a).xmin = this->xmin;
180  ((KVTrieurBloc&) a).xmax = this->xmax;
181  sprintf(((KVTrieurBloc&) a).nomVar, "%s", this->nomVar);
182 #ifdef DEBUG_KVTrieurBloc
183  cout << "Nom de la copie (arguement): " << this->nomVar << endl;
184  cout << "Nom de la copie (resultat) : " << ((KVTrieurBloc&)
185  a.)GetName() << endl;
186 #endif
187 }
188 
189 
190 
195 
197 {
198 //
199 // Operateur =
200 //
201 #ifdef DEBUG_KVTrieurBloc
202  cout << "Copie par egalite de " << a.GetName() << "..." << endl;
203 #endif
204 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
205  a.Copy(*this);
206 #else
207  ((KVTrieurBloc&) a).Copy(*this);
208 #endif
209 #ifdef DEBUG_KVTrieurBloc
210  cout << "Nom de la copie par egalite: " << GetName() << endl;
211 #endif
212  return *this;
213 }
214 
215 
216 
221 
223 {
224 //
225 // On retourne le numero de case
226 //
227  cout << "Utiliser KVTrieurBloc::GetNumCase(Double_t x)" << endl;
228  return -1;
229 }
230 
231 
232 
237 
239 {
240 //
241 // On retourne le numero de case
242 //
243  Int_t i = 0;
244  while ((i < nb_cases) && (x < xmin(i) || x > xmax(i)))
245  i++;
246  if (i >= nb_cases)
247  i = -1;
248  return i + 1;
249 }
250 
251 
252 
257 
259 {
260 //
261 // On met la valeur de Xmin
262 //
263  xmin(i - 1) = x;
264  SetNomsCases();
265 }
266 
267 
268 
272 
274 {
275 //
276 // On retourne la vaelur de xmin
277  return xmin(i - 1);
278 }
279 
280 
281 
286 
288 {
289 //
290 // On met la valeur de Xmin
291 //
292  xmax(i - 1) = x;
293  SetNomsCases();
294 }
295 
296 
297 
301 
303 {
304 //
305 // On retourne la vaelur de xmin
306  return xmax(i - 1);
307 }
308 
309 
310 
315 
317 {
318 //
319 // On met la valeur de Xmin
320 //
321  sprintf(nomVar, "%s", x);
322  SetNomsCases();
323 }
324 
325 
326 
330 
331 const Char_t* KVTrieurBloc::GetNomVar(void)
332 {
333 //
334 // On retourne la vaelur de xmin
335  return nomVar;
336 }
337 
338 
339 
344 
346 {
347 //
348 // On ajuste le nombre de cases
349 //
350  if (n != nb_cases) {
352  xmin.ResizeTo(n);
353  xmax.ResizeTo(n);
354  SetNomsCases();
355  }
356 }
357 
358 
int Int_t
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
char Char_t
double Double_t
float xmin
float xmax
char * Form(const char *fmt,...)
Class for a sorting with detached cells.
Definition: KVTrieurBloc.h:102
static Int_t nb_dest
Definition: KVTrieurBloc.h:107
virtual void SetNbCases(Int_t n)
Retourne le nom d'une case.
void initKVTrieurBloc(void)
Methodes.
virtual void SetNomVar(Char_t *x)
KVTrieurBloc(void)
virtual void Copy(TObject &obj) const
Make a copy of this object.
void SetNomsCases(void)
static Int_t nb_crea
Definition: KVTrieurBloc.h:106
virtual void SetXmin(Int_t i, Double_t x)
TVector xmin
Definition: KVTrieurBloc.h:109
virtual Double_t GetXmax(Int_t i)
virtual Double_t GetXmin(Int_t i)
Char_t nomVar[80]
Definition: KVTrieurBloc.h:111
virtual const Char_t * GetNomVar(void)
static Int_t nb
Champs Statiques:
Definition: KVTrieurBloc.h:105
TVector xmax
Definition: KVTrieurBloc.h:110
virtual Int_t GetNumCase(void *argus ...)
virtual void SetXmax(Int_t i, Double_t x)
KVTrieurBloc & operator=(const KVTrieurBloc &a)
Base class for Sorting purposes.
Definition: KVTrieur.h:36
virtual void SetNbCases(Int_t n)
Retourne le nom d'une case.
Definition: KVTrieur.cpp:306
Int_t nb_cases
Champs publics:
Definition: KVTrieur.h:44
virtual void Copy(TObject &obj) const
Make a copy of this object.
Definition: KVTrieur.cpp:163
virtual const char * GetName() const
virtual void SetTitle(const char *title="")
virtual void SetName(const char *name)
void Form(const char *fmt,...)
TVectorT< Element > & ResizeTo(const TVectorT< Element > &v)
Double_t x[n]
const Int_t n
auto * a