KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVTrieurTranche.cpp
Go to the documentation of this file.
1 #include <math.h>
2 #include <stdio.h>
3 #include "KVTrieurTranche.h"
4 
5 using namespace std;
6 
8 
12 
13 //_____________________________________________________
14 
20 
22 {
23 //
24 // Initialisation des champs de KVTrieurTranche
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 < %f", xtranches(i), nomVar,
49  xtranches(i + 1)));
50  }
51  }
52 }
53 
54 
55 
60 
62 {
63 //
64 // Createur par default
65 //
66  TString nom;
67 
69  nom.Form("KVTrieurTranche_%d", nb_crea);
70  SetName(nom);
71  SetTitle(nom);
72 #ifdef DEBUG_KVTrieurTranche
73  cout << nb << " crees...(defaut) " << endl;
74 #endif
75 }
76 
77 
78 
83 
85 {
86 //
87 // Constructeur avec un nom
88 //
90  SetName(nom);
91  SetTitle(nom);
92 #ifdef DEBUG_KVTrieurTranche
93  cout << nb << " crees...(nom) " << endl;
94 #endif
95 }
96 
97 
98 
103 
105  nom)
106 {
107 //
108 // Constructeur avec un nombre de cases et un nom
109 //
112 #ifdef DEBUG_KVTrieurTranche
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  ((KVTrieurTranche&) a).Copy(*this);
134 #endif
135 #ifdef DEBUG_KVTrieurTranche
136  cout << nb << " crees...(copie) " << endl;
137 #endif
138 }
139 
140 
141 
146 
147 KVTrieurTranche::~KVTrieurTranche(void)
148 {
149 //
150 // Destructeur
151 //
152 #ifdef DEBUG_KVTrieurTranche
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_KVTrieurTranche
174  cout << "Copie de " << a.GetName() << "..." << endl;
175 #endif
176  KVTrieur::Copy(a);
177  ((KVTrieurTranche&) a).xtranches.ResizeTo(this->nb_cases + 1);
178  ((KVTrieurTranche&) a).xtranches = this->xtranches;
179  sprintf(((KVTrieurTranche&) a).nomVar, "%s", this->nomVar);
180 #ifdef DEBUG_KVTrieurTranche
181  cout << "Nom de la copie (arguement): " << this->nomVar << endl;
182  cout << "Nom de la copie (resultat) : " << ((KVTrieurTranche&) a).
183  GetName() << endl;
184 #endif
185 }
186 
187 
188 
193 
195 {
196 //
197 // Operateur =
198 //
199 #ifdef DEBUG_KVTrieurTranche
200  cout << "Copie par egalite de " << a.GetName() << "..." << endl;
201 #endif
202 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
203  a.Copy(*this);
204 #else
205  ((KVTrieurTranche&) a).Copy(*this);
206 #endif
207 #ifdef DEBUG_KVTrieurTranche
208  cout << "Nom de la copie par egalite: " << GetName() << endl;
209 #endif
210  return *this;
211 }
212 
213 
214 
219 
221 {
222 //
223 // On retourne le numero de case
224 //
225  cout << "Utiliser KVTrieurTranche::GetNumCase(Double_t x)" << endl;
226  return -1;
227 }
228 
229 
230 
235 
237 {
238 //
239 // On retourne le numero de case
240 //
241  Int_t i = -1;
242  while ((i < nb_cases) && (x >= xtranches(i + 1))) {
243  i++;
244  }
245  if (i >= nb_cases)
246  i = -1;
247  return i + 1;
248 }
249 
250 
251 
256 
258 {
259 //
260 // On met la valeur de Xmin
261 //
262  xtranches(i - 1) = x;
263  SetNomsCases();
264 }
265 
266 
267 
271 
273 {
274 //
275 // On retourne la valeur de xmin
276  return xtranches(i - 1);
277 }
278 
279 
280 
285 
287 {
288 //
289 // On met la valeur de Xmin
290 //
291  xtranches(i) = x;
292  SetNomsCases();
293 }
294 
295 
296 
300 
302 {
303 //
304 // On retourne la vaelur de xmin
305  return xtranches(i);
306 }
307 
308 
309 
314 
316 {
317 //
318 // On met la valeur de Xmin
319 //
320  sprintf(nomVar, "%s", x);
321  SetNomsCases();
322 }
323 
324 
325 
329 
331 {
332 //
333 // On retourne la vaelur de xmin
334  return nomVar;
335 }
336 
337 
338 
343 
345 {
346 //
347 // On ajuste le nombre de cases
348 //
349  if (n != nb_cases) {
351  xtranches.ResizeTo(n + 1);
352  SetNomsCases();
353  }
354 }
355 
356 
int Int_t
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
char Char_t
double Double_t
char * Form(const char *fmt,...)
Class for a sorting with attached cells.
void SetNomsCases(void)
virtual void SetXmin(Int_t i, Double_t x)
virtual Double_t GetXmin(Int_t i)
KVTrieurTranche & operator=(const KVTrieurTranche &a)
virtual void Copy(TObject &obj) const
Make a copy of this object.
void initKVTrieurTranche(void)
Methodes.
virtual Int_t GetNumCase(void *argus ...)
virtual void SetNbCases(Int_t n)
virtual const Char_t * GetNomVar(void)
virtual void SetNomVar(Char_t *x)
static Int_t nb_crea
static Int_t nb_dest
virtual void SetXmax(Int_t i, Double_t x)
virtual Double_t GetXmax(Int_t i)
static Int_t nb
Champs Statiques:
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