4 #include "KVPartitionGenerator.h"
35 void KVPartitionGenerator::init()
48 npar = npar_zt_mt = 0;
50 tname =
"PartitionTree";
114 void KVPartitionGenerator::MakePartitions(
Int_t Ztot,
Int_t Mtot,
Int_t Zinf)
134 SetConditions(Ztot, Mtot, Zinf);
152 void KVPartitionGenerator::SetConditions(
Int_t Ztot,
Int_t Mtot,
Int_t Zinf)
164 kcurrent =
new Int_t[kmt];
179 void KVPartitionGenerator::PreparTree()
188 snom.
Form(
"%sFrom_%s_Zt%d_Mt%d_Zi%d.root", kwriting_path.
Data(), this->Class_Name(), ztot, mtot, kzinf);
193 if (tabz)
delete [] tabz;
195 tabz =
new Int_t[mtot];
197 tree->Branch(
"ztot", &ztot,
"ztot/I");
198 tree->Branch(
"mtot", &mtot,
"mtot/I");
199 tree->Branch(
"tabz", tabz,
"tabz[mtot]/I");
201 if (mshift) tabz[0] = zshift;
217 void KVPartitionGenerator::Process(
void)
229 tabz[0 + mshift] = kzt;
234 Int_t zutilise = (kmt * kzinf);
235 Int_t zdispo = kzt - zutilise;
237 Int_t nb_cassure = kmt - 1;
239 Int_t ncouple[nb_cassure];
240 Int_t niter[nb_cassure];
241 for (
Int_t nc = 0; nc < nb_cassure; nc += 1) {
249 for (nc = 0; nc < nb_cassure; nc += 1) {
252 coup[nc] =
new KVCouple(zdispo, zsup, kmt - nc);
257 if (niter[nc] < ncouple[nc]) {
259 zdispo = coup[nc]->
GetZ2(niter[nc]);
260 zsup = coup[nc]->
GetZ1(niter[nc]);
261 kcurrent[nc] = coup[nc]->
GetZ1(niter[nc]);
262 kcurrent[nc + 1] = coup[nc]->
GetZ2(niter[nc]);
271 while (niter[nc] < ncouple[nc]) {
273 kcurrent[nc] = coup[nc]->
GetZ1(niter[nc]);
274 kcurrent[nc + 1] = coup[nc]->
GetZ2(niter[nc]);
276 for (
Int_t ii = 0; ii < kmt; ii += 1)
277 tabz[ii + mshift] = kcurrent[ii] + kzinf;
280 if (tabz[0] >= tabz[mshift]) {
293 Int_t previous = nc - 1;
294 while (niter[previous] == (ncouple[previous] - 1) && previous >= 0) {
296 delete coup[previous];
300 if (previous < 0)
break;
307 niter[previous] += 1;
308 zdispo = coup[previous]->
GetZ2(niter[previous]);
309 zsup = coup[previous]->
GetZ1(niter[previous]);
311 kcurrent[previous] = coup[previous]->
GetZ1(niter[previous]);
313 for (
Int_t ncbis = previous + 1; ncbis < nb_cassure; ncbis += 1) {
315 coup[ncbis] =
new KVCouple(zdispo, zsup, kmt - ncbis);
321 if (niter[ncbis] < ncouple[ncbis]) {
323 zdispo = coup[ncbis]->
GetZ2(niter[ncbis]);
324 zsup = coup[ncbis]->
GetZ1(niter[ncbis]);
325 kcurrent[ncbis] = coup[ncbis]->
GetZ1(niter[ncbis]);
326 kcurrent[ncbis + 1] = coup[ncbis]->
GetZ2(niter[ncbis]);
332 Info(
"Process",
"ztot:%d en mtot:%d avec zinf:%d donne %lf combinaisons (total %lf)", kzt, kmt, kzinf, npar_zt_mt, npar);
346 void KVPartitionGenerator::BeforeBreak()
368 void KVPartitionGenerator::AfterBreak()
382 while ((tn = (
TNamed*)nf.Next()))
413 if (cname ==
"") cname.
Form(
"Partitions_Zf%d_Zi%d.root", Ztot, Zinf);
417 Int_t mtmax = Ztot / Zinf;
419 if (
min != -1 &&
min <= mtmax)
422 if (
max != -1 && max <= mtmax && max >= mtmin)
425 for (
Int_t Mtot = mtmin; Mtot <= mtmax; Mtot += 1) {
426 MakePartitions(Ztot, Mtot, Zinf);
430 Info(
"BreakUsing_Ztot_Zinf_Criterion",
"%lf partitions crees en %d seconds", npar, GetDeltaTime());
453 if (cname ==
"") cname.
Form(
"Partitions_Zt%d_Mt%d_Zi%d.root", Ztot, Mtot, Zinf);
456 MakePartitions(Ztot, Mtot, Zinf);
459 Info(
"BreakUsing_Ztot_Mtot_Zinf_Criterion",
"%lf partitions crees en %d seconds", npar, GetDeltaTime());
482 if (cname ==
"") cname.
Form(
"Partitions_Zt%d_Zm%d_Zi%d.root", Ztot, Zmax, Zinf);
486 MakePartitions(Ztot, 1, Zinf);
488 else if (Ztot - Zmax >= Zinf) {
498 cp =
new KVCouple(Ztot, Zmax, mfmin);
501 printf(
"a priori mfmin=%d OK\n", mfmin);
503 printf(
"%d %d\n", cp->
GetZ1(ii), cp->
GetZ2(ii));
509 Int_t mfmax = ((Ztot - Zmax) / Zinf) + 1;
511 cp =
new KVCouple(Ztot, Zmax, mfmax);
517 cp =
new KVCouple(Ztot, Zmax, mfmax);
520 printf(
"a priori mfmax=%d OK\n", mfmax);
522 printf(
"%d %d\n", cp->
GetZ1(ii), cp->
GetZ2(ii));
528 for (
Int_t Mtot = mfmin; Mtot <= mfmax; Mtot += 1) {
531 to_be_checked =
kTRUE;
532 MakePartitions(Ztot - zshift, Mtot - mshift, Zinf);
537 printf(
"%d %d ??? \n", Ztot - Zmax, Zinf);
541 Info(
"BreakUsing_Ztot_Zmax_Zinf_Criterion",
"%lf partitions crees en %d seconds", npar, GetDeltaTime());
563 if (cname ==
"") cname.
Form(
"Partitions_Mt%d_Zm%d_Zi%d.root", Mtot, Zmax, Zinf);
566 Int_t ztmin = Zmax + (Mtot - 1) * Zinf;
567 Int_t ztmax = Zmax * Mtot;
569 for (
Int_t Ztot = ztmin; Ztot <= ztmax; Ztot += 1) {
572 to_be_checked =
kTRUE;
573 MakePartitions(Ztot - zshift, Mtot - mshift, Zinf);
577 Info(
"BreakUsing_Mtot_Zmax_Zinf_Criterion",
"%lf partitions crees en %d seconds", npar, GetDeltaTime());
619 Info(
"WriteTreeAndCloseFile",
"Ecriture du fichier:\n%s avec l'arbre:\n %s (%lld entrees)",
gFile->GetName(),
tree->GetName(),
tree->GetEntries());
620 tree->ResetBranchAddresses();
635 void KVPartitionGenerator::Start()
650 void KVPartitionGenerator::Stop()
656 tellapsed = tstop - tstart;
667 Int_t KVPartitionGenerator::GetDeltaTime()
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 np
Handles binary decomposition of an integer.
Permet de determiner numeriquement et exactement un ensemble de partitions d'entrees remplissante cer...
void SetPathForFile(KVString path)
void BreakUsing_Ztot_Zmax_Zinf_Criterion(Int_t Ztot, Int_t Zmax, Int_t Zinf, KVString chain_name="")
virtual ~KVPartitionGenerator()
Destructor.
void BreakUsing_Ztot_Zinf_Criterion(Int_t Ztot, Int_t Zinf, KVString chain_name="", Int_t min=-1, Int_t max=-1)
virtual void WriteTreeAndCloseFile()
void BreakUsing_Ztot_Mtot_Zinf_Criterion(Int_t Ztot, Int_t Mtot, Int_t Zinf, KVString chain_name="")
virtual void TreatePartition()
void BreakUsing_Mtot_Zmax_Zinf_Criterion(Int_t Mtot, Int_t Zmax, Int_t Zinf, KVString chain_name="")
void SetOwner(Bool_t enable=kTRUE) override
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Optimised list in which named objects can only be placed once.
void Add(TObject *obj) override
virtual Int_t AddFile(const char *name, Long64_t nentries=TTree::kMaxEntries, const char *tname="")
const char * GetName() const override
const char * Data() const
void Form(const char *fmt,...)
Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const override
double min(double x, double y)
double max(double x, double y)