KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVTrieurLin.cpp
Go to the documentation of this file.
1 #include <math.h>
2 #include <stdio.h>
3 #include "KVTrieurLin.h"
4 
5 using namespace std;
6 
8 
12 
13 //_____________________________________________________
14 
20 
22 {
23 //
24 // Initialisation des champs de KVTrieurLin
25 // Cette methode privee n'est appelee par les createurs
26 //
27  nb++;
28  nb_crea++;
29  xmin = 0.;
30  xmax = 0.;
31  sprintf(nom_var, "Variable");
32 }
33 
34 
35 
36 
41 
43 {
44 //
45 // On affecte les noms aux cases
46 //
47  TString nomt;
48  if (noms_cases) {
49  Double_t xpas = (xmax - xmin) / nb_cases;
50  for (Int_t i = 0; i < nb_cases; i++) {
51  if (i == 0) {
52  nomt.Form("%s < %f", nom_var, xmin + (i + 1) * xpas);
53  }
54  else if (i == nb_cases - 1) {
55  nomt.Form("%f #leq %s", xmin + i * xpas, nom_var);
56  }
57  else {
58  nomt.Form("%f #leq %s < %f", xmin + i * xpas, nom_var,
59  xmin + (i + 1) * xpas);
60  }
61  TNamed* nom = (TNamed*) noms_cases->At(i);
62  nom->SetTitle(nomt);
63  }
64  }
65 }
66 
67 
68 
73 
75 {
76 //
77 // Createur par default
78 //
79  TString nom;
80 
82  nom.Form("KVTrieurLin_%d", nb_crea);
83  SetName(nom);
84  SetTitle(nom);
85 #ifdef DEBUG_KVTrieurLin
86  cout << nb << " crees...(defaut) " << endl;
87 #endif
88 }
89 
90 
91 
96 
98 {
99 //
100 // Constructeur avec un nom
101 //
102  initKVTrieurLin();
103  SetName(nom);
104  SetTitle(nom);
105 #ifdef DEBUG_KVTrieurLin
106  cout << nb << " crees...(nom) " << endl;
107 #endif
108 }
109 
110 
111 
116 
117 KVTrieurLin::KVTrieurLin(Int_t nbcases, Char_t* nom): KVTrieur(nbcases, nom)
118 {
119 //
120 // Constructeur avec un nombre de cases et un nom
121 //
122  initKVTrieurLin();
123 #ifdef DEBUG_KVTrieurLin
124  cout << nb << " crees...(nom) " << endl;
125 #endif
126 }
127 
128 
129 
134 
136 {
137 //
138 // Contructeur par copie
139 //
140  initKVTrieurLin();
141 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
142  a.Copy(*this);
143 #else
144  ((KVTrieurLin&) a).Copy(*this);
145 #endif
146 #ifdef DEBUG_KVTrieurLin
147  cout << nb << " crees...(copie) " << endl;
148 #endif
149 }
150 
151 
152 
157 
158 KVTrieurLin::~KVTrieurLin(void)
159 {
160 //
161 // Destructeur
162 //
163 #ifdef DEBUG_KVTrieurLin
164  cout << "Destruction de " << GetName() << "..." << endl;
165 #endif
166  nb--;
167  nb_dest++;
168 }
169 
170 
171 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
172 
174 
176 {
177 #else
179 {
180 #endif
181 //
182 // Methode de copie
183 //
184 #ifdef DEBUG_KVTrieurLin
185  cout << "Copie de " << this->GetName() << "..." << endl;
186 #endif
187  KVTrieur::Copy(a);
188  ((KVTrieurLin&) a).xmin = this->xmin;
189  ((KVTrieurLin&) a).xmax = this->xmax;
190  sprintf(((KVTrieurLin&) a).nom_var, "%s", this->nom_var);
191 #ifdef DEBUG_KVTrieurLin
192  cout << "Nom de la copie (arguement): " << ((KVTrieurLin&) a).
193  nom_var << endl;
194  cout << "Nom de la copie (resultat) : " << ((KVTrieurLin&) a).
195  GetName() << endl;
196 #endif
197 }
198 
199 
200 
205 
207 {
208 //
209 // Operateur =
210 //
211 #ifdef DEBUG_KVTrieurLin
212  cout << "Copie par egalite de " << a.GetName() << "..." << endl;
213 #endif
214 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
215  a.Copy(*this);
216 #else
217  ((KVTrieurLin&) a).Copy(*this);
218 #endif
219 #ifdef DEBUG_KVTrieurLin
220  cout << "Nom de la copie par egalite: " << GetName() << endl;
221 #endif
222  return *this;
223 }
224 
225 
226 //
227 // On retourne le numero de case
228 //
229 
231 
233 {
234  cout << "Utiliser KVTrieurLin::GetNum_Case(Double_t x)" << endl;
235  return -1;
236 }
237 
238 
239 
244 
246 {
247 //
248 // On retourne le numero de case
249 //
250  Int_t i = 0;
251  if (xmax > xmin) {
252  i = (Int_t)((x - xmin) / (xmax - xmin) * nb_cases) + 1;
253  if (i < 1)
254  i = 1;
255  if (i > nb_cases)
256  i = nb_cases;
257  }
258  else {
259  Warning("GetNumCase(Double_t x)", "Xmin >= Xmax !");
260  i = 0;
261  }
262  return i;
263 }
264 
265 
266 
271 
273 {
274 //
275 // On met la valeur de Xmin
276 //
277  xmin = x;
278  SetNomsCases();
279 }
280 
281 
282 
286 
288 {
289 //
290 // On retourne la vaelur de xmin
291  return xmin;
292 }
293 
294 
295 
300 
302 {
303 //
304 // On met la valeur de Xmin
305 //
306  xmax = x;
307  SetNomsCases();
308 }
309 
310 
311 
315 
317 {
318 //
319 // On retourne la vaelur de xmin
320  return xmax;
321 }
322 
323 
324 
329 
331 {
332 //
333 // On met la valeur de Xmin
334 //
335  sprintf(nom_var, "%s", x);
336  SetNomsCases();
337 }
338 
339 
340 
344 
346 {
347 //
348 // On retourne la vaelur de xmin
349  return nom_var;
350 }
351 
352 
353 
358 
360 {
361 //
362 // On ajuste le nombre de cases
363 //
364  if (n != nb_cases) {
366  SetNomsCases();
367  }
368 }
369 
370 
int Int_t
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
char Char_t
double Double_t
float xmin
float xmax
Class for a linear sorting.
Definition: KVTrieurLin.h:84
static Int_t nb_crea
Definition: KVTrieurLin.h:88
virtual void SetXmax(Double_t x)
virtual Int_t GetNumCase(void *argus ...)
KVTrieurLin(void)
Definition: KVTrieurLin.cpp:74
Double_t xmin
Definition: KVTrieurLin.h:91
Double_t xmax
Definition: KVTrieurLin.h:92
Char_t nom_var[80]
Definition: KVTrieurLin.h:93
virtual void Copy(TObject &obj) const
Make a copy of this object.
virtual void SetXmin(Double_t x)
static Int_t nb_dest
Definition: KVTrieurLin.h:89
static Int_t nb
Champs Statiques:
Definition: KVTrieurLin.h:87
virtual Double_t GetXmin(void)
virtual void SetNbCases(Int_t n)
KVTrieurLin & operator=(const KVTrieurLin &a)
virtual void SetNomVar(Char_t *x)
void SetNomsCases(void)
Definition: KVTrieurLin.cpp:42
virtual const Char_t * GetNomVar(void)
virtual Double_t GetXmax(void)
void initKVTrieurLin(void)
Methodes.
Definition: KVTrieurLin.cpp:21
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)
virtual void Warning(const char *method, const char *msgfmt,...) const
void Form(const char *fmt,...)
Double_t x[n]
const Int_t n
auto * a