KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVPartitionList.cpp
1//Created by KVClassFactory on Fri Oct 8 14:27:07 2010
2//Author: bonnet
3
4#include "KVPartitionList.h"
5#include "KVPartition.h"
6#include "KVIntegerList.h"
7#include "TTree.h"
8
10
11
12//_______________________________________________________
13
14
16
18{
19 //Initialisation
21 knbre_diff = 0;
22 knbre_tot = 0;
23 SetOwner(kTRUE);
24 mult_range = new KVPartition();
25
26}
27
28
29
32
34{
35 // Default constructor
36 init();
37}
38
39
40
43
45{
46 // constructor with name
47 init();
49}
50
51
52
55
57{
58 // Destructor
59 delete mult_range;
60 mult_range = 0;
61}
62
63
64
67
69{
70 //Mise a zero de la liste
73 knbre_diff = 0;
74 knbre_tot = 0;
75
76}
77
78
83
85{
86 // retourne un booléen indiquant si la dernière partition
87 // utilisée dans les méthodes Add...()
88 // était déjà dans la liste (kTRUE) ou non (kFALSE)
89 return atrouve;
90
91}
92
93
94
100
102{
103 //Retourne le nombre de partitions totales ie le nombre de fois ou la methode
104 //Fill a été appelée
105 //Exemple: si 3 partitions differentes et pop(i) leur population associée
106 //knbre_tot = pop(1) + pop(2) + pop(3)
107 return knbre_tot;
108
109}
110
111
112
118
120{
121 //Retourne le nombre de partitions différentes
122 //
123 //Exemple: si 3 partitions differentes et pop(i) leur population associée
124 //knbre_diff = 3
125 return knbre_diff;
126
127}
128
129
130
135
137{
138 //Incrémente le nombre totale de partitions
139 //retourne kTRUE si une partition identique est déjà dans la liste
140 //
141 knbre_tot += 1.;
142
143 Add(par);
144
145 return IsInTheList();
146
147}
148
149
150
156
158{
159 // Add an object to the list if it is not already in it
160 // (no object with same name in list)
161 //
162 // if it is in, the population of it is incremented
163
164 TObject* find = 0;
165 //Test la présence d'une partition identique
166 if (!(find = FindObject(obj->GetName()))) {
167 //Ajout de la partition
168 KVHashList::Add(obj);
170 }
171 else {
172 //une partition identique existe deja
173 atrouve = kTRUE;
174 //on incremente la population de celle ci
175 ((KVIntegerList*)find)->AddPopulation(1);
176 }
177}
178
179
180
184
186{
187 //Protected methode
188 //appelée dans le cas ou il y a une nouvelle partition
189 atrouve = kFALSE;
190 knbre_diff += 1; //on incremente le nombre de partitions differentes
191 //on incremente egalement la liste contenant les multiplicités
192 mult_range->Add(il->GetNbre());
193}
194
195
196
201
203{
204 // Add an object to the list if it is not already in it
205 // (no object with same name in list)
206 // if it is in, the population of it is incremented
207
208 TObject* find = 0;
209 if (!(find = FindObject(obj->GetName()))) {
212 }
213 else {
214 atrouve = kTRUE;
215 ((KVIntegerList*)find)->AddPopulation(1);
216 }
217}
218
219
220
225
227{
228 // Add an object to the list if it is not already in it
229 // (no object with same name in list)
230 // if it is in, the population of it is incremented
231
232 TObject* find = 0;
233 if (!(find = FindObject(obj->GetName()))) {
236 }
237 else {
238 atrouve = kTRUE;
239 ((KVIntegerList*)find)->AddPopulation(1);
240 }
241}
242
243
244
249
251{
252 // Add an object to the list if it is not already in it
253 // (no object with same name in list)
254 // if it is in, the population of it is incremented
255
256 TObject* find = 0;
257 if (!(find = FindObject(obj->GetName()))) {
258 KVHashList::AddAt(obj, idx);
260 }
261 else {
262 atrouve = kTRUE;
263 ((KVIntegerList*)find)->AddPopulation(1);
264 }
265}
266
267
268
273
275{
276 // Add an object to the list if it is not already in it
277 // (no object with same name in list)
278 // if it is in, the population of it is incremented
279
280 TObject* find = 0;
281 if (!(find = FindObject(obj->GetName()))) {
282 KVHashList::AddAfter(after, obj);
284 }
285 else {
286 atrouve = kTRUE;
287 ((KVIntegerList*)find)->AddPopulation(1);
288 }
289}
290
291
292
297
299{
300 // Add an object to the list if it is not already in it
301 // (no object with same name in list)
302 // if it is in, the population of it is incremented
303
304 TObject* find = 0;
305 if (!(find = FindObject(obj->GetName()))) {
306 KVHashList::AddBefore(before, obj);
308 }
309 else {
310 atrouve = kTRUE;
311 ((KVIntegerList*)find)->AddPopulation(1);
312 }
313}
314
315
316
319
321{
322 //Met a jour l'intervalle de multiplicité associées aux partitions dans la liste
324 mult_range->Print("Partitions");
325
326}
327
328
329
333
335{
336 //Protected method
337 //Creation de l'arbre et remplissage de toutes les partitions
338 if (GetEntries() == 0) return 0;
339
340 Update();
341
342 Int_t mmax = Int_t(mult_range->GetZmax(0)); //Multiplicité max enregistrée
343 Info("GenereTree", "Multiplicite max entregistree %d", mmax);
344 Int_t* tabz = new Int_t[mmax];
345 Int_t mtot;
346 Int_t pop;
347 Info("GenereTree", "Nbre de partitions entregistrees %d", GetEntries());
348
349 TTree* tree = new TTree(treename, Class_Name());
350 //Declaration des branches
351 tree->Branch("mtot", &mtot, "mtot/I"); //multiplicité
352 tree->Branch("tabz", tabz, "tabz[mtot]/I"); //partition sous forme de tableau d'entiers
353 if (Compress)
354 tree->Branch("pop", &pop, "pop/I"); //Si Compress==kTRUE, la branche population
355 //associée à chaue partition
356 KVIntegerList* par;
357 TArrayI* table = 0;
358 for (Int_t kk = 0; kk < GetEntries(); kk += 1) {
359 par = (KVIntegerList*)At(kk);
360 table = par->CreateTArrayI();
361
362 mtot = par->GetNbre();
363 if (kk % 5000 == 0)
364 Info("GenereTree", "%d partitions traitees", kk);
365 pop = par->GetPopulation();
366
367 for (Int_t mm = 0; mm < mtot; mm += 1)
368 tabz[mm] = table->At(mm);
369
370 //Si Compress==kTRUE, on remplie une fois avec la population (pop) associée
371 //sinon on rempli pop fois cette partition
372 if (Compress) {
373 tree->Fill();
374 }
375 else {
376 for (Int_t pp = 0; pp < pop; pp += 1) tree->Fill();
377 }
378 delete table;
379 }
380 Info("GenereTree", "Fin du remplissage");
381
382 tree->ResetBranchAddresses();
383 delete [] tabz;
384
385 return tree;
386
387}
388
389
390
398
399void KVPartitionList::SaveAsTree(const Char_t* filename, const Char_t* treename, Bool_t, Option_t* option)
400{
401 //Open a file, save all the registered partitions in a tree format, and close the file
402 //filename -> name of the root file where the tree is stored
403 //treename -> name of the tree
404 //Compress -> if kTRUE : a branch associated to the population of the partition is created
405 // -> if kFALSE : all the partitions are written one by one
406 //option -> option for the file
407
408 TFile* file = new TFile(filename, option);
409 TTree* tt = 0;
410 if ((tt = GenereTree(treename))) tt->Write();
411 file->Close();
412}
413
414
415
int Int_t
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
const char Option_t
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
char name[80]
char * Compress(const char *str)
Handle a list of positive integers (partition)
void Add(TArrayI *tab)
void Fill(Double_t* tab,Int_t mult);
Int_t GetNbre() const
Int_t GetPopulation() const
TArrayI * CreateTArrayI()
Manage a list of partitions.
void SaveAsTree(const Char_t *filename, const Char_t *treename, Bool_t Compress=kTRUE, Option_t *option="recreate")
void ValidateEntrance(KVIntegerList *il)
virtual void AddAt(TObject *obj, Int_t idx)
virtual void AddBefore(const TObject *before, TObject *obj)
KVPartitionList()
Default constructor.
Double_t knbre_tot
Nbre de partitions totales.
TTree * GenereTree(const Char_t *treename, Bool_t Compress=kTRUE)
virtual Bool_t Fill(KVIntegerList *par)
virtual void AddLast(TObject *obj)
virtual void AddAfter(const TObject *after, TObject *obj)
void Update()
Met a jour l'intervalle de multiplicité associées aux partitions dans la liste.
virtual ~KVPartitionList()
Destructor.
void Clear(Option_t *option="")
Mise a zero de la liste.
virtual void Add(TObject *obj)
virtual void AddFirst(TObject *obj)
KVPartition * mult_range
Permet d'extraire la gamme en multiplicité
Double_t knbre_diff
Nbre de partitions differentes.
Handle partitions.
Definition KVPartition.h:31
void Clear(Option_t *option="")
Methode dérivée de KVIntegerList, Reinitialisation de l'object.
void Print(Option_t *option="") const
Double_t GetZmax(Int_t rang=0) const
virtual TObject * FindObject(const char *name) const
virtual void SetOwner(Bool_t enable=kTRUE)
virtual void Clear(Option_t *option="")
virtual TObject * At(Int_t idx) const
void SetName(const char *name)
virtual Int_t GetEntries() const
virtual void Add(TObject *obj)=0
virtual const char * GetName() const
virtual void Info(const char *method, const char *msgfmt,...) const
virtual void AddLast(TObject *obj)=0
virtual void AddBefore(const TObject *before, TObject *obj)=0
virtual void AddAt(TObject *obj, Int_t idx)=0
virtual void AddAfter(const TObject *after, TObject *obj)=0
static const char * Class_Name()
virtual void AddFirst(TObject *obj)=0
Table in an SQLite database.
auto * tt
ClassImp(TPyArg)