4 #include "KVIDGridEditor.h"
14 #include <KVSpIdGUI.h>
15 #include <KVZAFinderDialog.h>
17 #include "KVTreeAnalyzer.h"
18 #include <KVHistogram.h>
19 #include "KVTestIDGridDialog.h"
20 #include "KVItvFinderDialog.h"
22 #include "KVIDCutLine.h"
38 fSpiderOption =
"DRLF";
70 AddMethod(
"SaveCurrentGrid");
71 AddMethod(
"SpiderIdentification");
72 AddMethod(
"ChangeMasses");
73 AddMethod(
"ChangeCharges");
74 AddMethod(
"SelectLinesByZ");
75 AddMethod(
"MakeScaleX");
76 AddMethod(
"MakeScaleY");
77 AddMethod(
"SetSelectedColor");
78 AddMethod(
"SetPointStyle");
79 AddMethod(
"SetPointSize");
80 AddMethod(
"SetVarXVarY");
81 AddMethod(
"SetRunList");
82 AddMethod(
"AddParameter");
83 AddMethod(
"SetXScaleFactor");
84 AddMethod(
"SetYScaleFactor");
85 AddMethod(
"SetSVGMode");
87 ft =
new TF1(
"tranlation",
"(x+[0])", 0, 70000);
88 fs =
new TF1(
"scale",
"(x-[0])*[1]+[0]", 0, 70000);
89 fsy =
new TF1(
"scale_y",
"(x-[0])*[1]+[0]", 0, 70000);
91 frx =
new TF2(
"rotation_x",
"(x-[0])*TMath::Cos([2])-(y-[1])*TMath::Sin([2])+[0]", 0, 70000);
92 fry =
new TF2(
"rotation_y",
"(x-[0])*TMath::Sin([2])+(y-[1])*TMath::Cos([2])+[1]", 0, 70000);
97 lplabel->SetOwner(
kTRUE);
99 lplabel2->SetOwner(
kTRUE);
101 lplabel3->SetOwner(
kTRUE);
103 lplabel4->SetOwner(
kTRUE);
105 lplabel5->SetOwner(
kTRUE);
129 dynamic_cast<TGMainFrame*
>(fCanvas->GetCanvasImp())->Connect(
"CloseWindow()",
"KVIDGridEditor",
this,
"CanvasWasClosed()");
130 fPad = fCanvas->cd();
133 if (TheHisto) TheHisto->Draw(
"col");
165 void KVIDGridEditor::SetDefault()
179 itrans = iact = iopt = 0;
218 dynamic_cast<TGMainFrame*
>(fCanvas->GetCanvasImp())->Disconnect(
"CloseWindow()",
"KVIDGridEditor",
this,
"CanvasWasClosed()");
243 ResetColor(ListOfLines);
244 ListOfLines->Clear();
246 if (
option.Contains(
"AL")) {
257 if (!IsClosed()) TheGrid->UnDraw();
281 fCanvas->SaveAs(
Form(
"%s/gIDGridEditorPrint-%d.png", dir.
Data(), fSVGIndex));
317 if (ownhisto)
delete TheHisto;
318 if (fCanvas)
delete fCanvas;
339 if (gIDGridEditor ==
this) gIDGridEditor = 0x0;
340 dynamic_cast<TGMainFrame*
>(fCanvas->
GetCanvasImp())->Disconnect(
"CloseWindow()",
"KVIDGridEditor",
this,
"CanvasWasClosed()");
371 void KVIDGridEditor::init()
373 AddTransformation(
"T_{X}");
374 AddTransformation(
"T_{Y}");
375 AddTransformation(
"R_{Z}");
376 AddTransformation(
"S_{X}");
377 AddTransformation(
"S_{Y}");
378 AddTransformation(
"S_{XY}");
379 AddTransformation(
"S_{C}");
383 AddAction(
"#Leftarrow");
389 AddGridOption(
"Select", lplabel3);
391 AddGridOption(
"Edit", lplabel4);
392 AddGridOption(
"Delete", lplabel4);
393 AddGridOption(
"Line", lplabel4);
394 AddGridOption(
"Cut", lplabel4);
395 AddGridOption(
"Info", lplabel4);
396 AddGridOption(
"Fit", lplabel4);
397 AddGridOption(
"Test", lplabel4);
398 AddGridOption(
"Mass", lplabel4);
399 AddGridOption(
"More", lplabel4);
401 ConstructModulator();
408 SetPiedestal(0., 0.);
419 void KVIDGridEditor::ConstructModulator()
431 templabel =
new TPaveLabel(x1, y1, x2, y2,
"+",
"NDC");
436 lplabel5->
Add(templabel);
439 y1 = 0.90 - i * 0.06;
442 modulator =
new TPaveLabel(x1, y1, x2, y2,
Form(
"%d", imod),
"NDC");
447 lplabel5->
Add(modulator);
450 y1 = 0.90 - i * 0.06;
453 templabel =
new TPaveLabel(x1, y1, x2, y2,
"-",
"NDC");
458 lplabel5->
Add(templabel);
460 lplabel5->
Execute(
"SetTextSize",
"0.625");
467 void KVIDGridEditor::AddTransformation(
TString label)
482 lplabel->
Add(templabel);
492 void KVIDGridEditor::AddAction(
TString label)
507 lplabel2->
Add(templabel);
532 thelist->
Add(templabel);
544 void KVIDGridEditor::RecurseFileStructureFindHistos(
TString& hist_names,
TDirectory* the_directory)
549 if (!the_directory)
return;
552 while ((key = (
TKey*)next_key())) {
573 TString KVIDGridEditor::ListOfHistogramInMemory()
588 while ((obj = nextmem())) {
596 while ((f = (
TFile*)next())) {
601 RecurseFileStructureFindHistos(HistosNames, f);
603 HistosNames.
Begin(
" ");
604 while (!HistosNames.
End()) {
606 if (g !=
"gIDGridEditorDefaultHistogram") histos.
Add(
new TObjString(
g.Data()));
613 while ((canv = (
TCanvas*)nextc())) {
615 if (strcmp(canv->
GetName(),
"gIDGridEditorCanvas")) {
618 while ((obj1 = next_step1())) {
622 TIter next_step2(((
TPad*)obj1)->GetListOfPrimitives());
623 while ((obj2 = next_step2())) {
624 printf(
"%s\n", obj2->
GetName());
661 HistosNames +=
Form(
" %s",
s->GetString().Data());
678 if (!TheGrid)
return "";
685 Iter = str.Next(kTRUE);
694 Iter = str.Next(kTRUE);
712 KVString Listo = ListOfHistogramInMemory();
713 TString Select = PreselectHistogram(Listo);
720 Choices +=
"Current ";
722 else Default =
"Dummy";
726 else if (Select ==
"") {
731 Choices += Select.
Data();
736 while (!Listo.
End()) {
738 if (s != Select) Choices +=
Form(
"%s ", s.Data());
752 else Answer = Default;
754 if (!Answer.
Contains(
"Current") && ownhisto) {
762 if ((TheHistoChoice = (
TH2*)
gROOT->FindObject(Answer.
Data()))) TheHisto = TheHistoChoice;
763 else if (
gFile && (TheHistoChoice = (
TH2*)
gFile->Get(Answer.
Data()))) TheHisto = TheHistoChoice;
764 else if (
gFile && (TheHistoChoice = (
TH2*)
gFile->FindObjectAnyFile(Answer.
Data()))) TheHisto = TheHistoChoice;
765 else if (
gFile && (TheHistoChoice = (
TH2*)
gFile->FindObjectAny(Answer.
Data()))) TheHisto = TheHistoChoice;
766 else if (gTreeAnalyzer && (TheHistoChoice = (
TH2*)gTreeAnalyzer->
GetHistogram(Answer.
Data()))) TheHisto = TheHistoChoice;
767 else if ((TheHistoChoice = FindInCanvases(Answer.
Data()))) TheHisto = TheHistoChoice;
768 else Answer =
"Dummy";
785 if ((TmpH = (
TH2*)
gROOT->FindObject(hname.
Data())))
delete TmpH;
786 TheHisto =
new TH2F(hname.
Data(), hname.
Data(), 2048, 0, Xmax, 2048, 0, Ymax);
791 cout <<
"ERROR: KVIDGridEditor::SetHisto(): '" << hh->
GetName() <<
"' must be a 2D histogram !" << endl;
795 if ((ownhisto) && (TheHisto)) {
804 fPad = fCanvas->
cd();
811 TheHisto->
Draw(
"col");
824 TH2* KVIDGridEditor::FindInCanvases(
const Char_t* histoname)
830 while ((cc = (
TCanvas*)nextc())) {
831 if (strcmp(cc->GetName(),
"gIDGridEditorCanvas")) {
832 if ((obj = cc->FindObject(histoname))) {
845 void KVIDGridEditor::DrawAtt(
Bool_t piv)
855 if (!piv) SetPivot(0., 0.);
856 else fPivot->
Draw(
"P");
858 if (!piv) SetPiedestal(0., 0.);
859 else fPivot->
Draw(
"P");
873 cout <<
"ERROR: KVIDGridEditor::SetHisto(): invalid pointer on the grid !" << endl;
907 if (!strcmp(GridName.
Data(),
"")) {
909 Bool_t proposename =
false;
910 if (TheGrid) Answer = TheGrid->
GetName();
916 new KVInputDialog(
gClient->GetDefaultRoot(),
"Enter the name of your grid :", &Answer, &okpressed);
917 if (!okpressed)
return;
918 GridName = Answer.
Data();
919 if (proposename && (!strcmp(TheHisto->
GetName(), Answer.
Data()))) sethisto =
false;
923 if (!gIDGridManager)
return;
925 cout <<
"WARNING: KVIDGridEditor::SetGrid(): Unknown grid named '" << GridName.
Data() <<
"' !" << endl;
928 else SetGrid(tempgrid, sethisto);
962 fPivot->
SetName(
"ThePiedestal");
964 else fPivot->
SetPoint(1, ppdx, ppdy);
1004 lplabel->
Execute(
"SetFillColor", fBlackMode ?
"kBlack" :
"kWhite");
1009 else if (lplabel2->
Contains(label)) {
1012 DispatchOrder(label);
1014 else if (lplabel4->
Contains(label)) {
1015 DispatchOrder(label);
1017 else if (lplabel3->
Contains(label)) {
1018 lplabel3->
Execute(
"SetFillColor", fBlackMode ?
"kBlack" :
"kWhite");
1022 SelectLines(
"Select");
1025 else if (lplabel5->
Contains(label) && (label != modulator)) {
1036 else if (lplabel5->
Contains(label) && (label != modulator)) {
1042 if (lplabel5->
Contains(label) && (label != modulator)) {
1049 if (lplabel5->
Contains(label) && (label != modulator)) {
1051 ChangeStep(label->
GetTitle(), 100);
1054 else if (lplabel3->
Contains(label)) {
1055 lplabel3->
Execute(
"SetFillColor",
"kGreen");
1102 if (!(aoemode))
return;
1121 Double_t ddX = (X1 + X0) * 0.5 - px;
1123 if (distX >= 0.5)
return;
1131 Double_t ddY = (Y1 + Y0) * 0.5 - py;
1133 if (distY >= 0.5)
return;
1135 if ((distX <=
size) && (distY <=
size))
return;
1137 dX =
TMath::Nint(ddX * (0.05 + 0.05 * venermode));
1138 dY =
TMath::Nint(ddY * (0.05 + 0.05 * venermode));
1145 if ((X0 - dX > 0) && (X1 - dX < NbinsX)) {
1149 if ((Y0 - dY > 0) && (Y1 - dY < NbinsY)) {
1187 SelectLines(
"Select");
1197 if (ListOfLines->
Contains(select))
return;
1202 Int_t zmin, zmax, amin, amax;
1203 if (LastZ == SeleZ) {
1209 else if (LastZ < SeleZ) {
1223 for (
int Z = zmin; Z <= zmax; Z++) {
1230 if ((
line->GetA() > amin) && (
line->GetA() < amax)) {
1236 if ((
line->GetZ() == zmin) && (
line->GetA() > amin)) {
1241 if ((
line->GetZ() == zmax) && (
line->GetA() < amax)) {
1246 if ((
line->GetZ() != zmax) && (
line->GetZ() != zmin)) {
1257 if (drawmode) drawmode =
false;
1278 SetPiedestal(x0, y0);
1285 const char* who = WhoIsSelected();
1289 else if (!strcmp(who,
"T_{X}")) TranslateX(sign);
1290 else if (!strcmp(who,
"T_{Y}")) TranslateY(sign);
1291 else if (!strcmp(who,
"R_{Z}")) RotateZ(sign);
1292 else if (!strcmp(who,
"S_{X}")) ScaleX(sign);
1293 else if (!strcmp(who,
"S_{Y}")) ScaleY(sign);
1294 else if (!strcmp(who,
"S_{XY}")) ScaleXY(sign);
1295 else if (!strcmp(who,
"S_{C}")) ScaleCurvature(sign);
1299 if ((
event ==
kESC) && (TheHisto)) Unzoom();
1308 void KVIDGridEditor::ZoomSelected()
1310 if (!TheHisto)
return;
1316 if ((ratio2 - ratio1 > 0.05)) {
1325 if ((ratio2 - ratio1 > 0.05)) {
1329 xmax = xmin = ymax = ymin = 0.;
1337 void KVIDGridEditor::DispatchOrder(
TPaveLabel* label)
1341 if (commande.Contains(
"#Leftarrow")) Undo();
1342 else if (commande.Contains(
"0")) SetPivot(0, 0);
1343 else if (commande.Contains(
"#odot")) Unzoom();
1344 else if (commande.Contains(
"Lz")) SetLogz();
1345 else if (commande.Contains(
"Ly")) SetLogy();
1346 else if (commande.Contains(
"Lx")) SetLogx();
1347 else if (commande.Contains(
"Cut")) NewCut();
1348 else if (commande.Contains(
"Line")) NewLine();
1349 else if (commande.Contains(
"Edit")) SetEditable(label);
1350 else if (commande.Contains(
"Fit")) {
1357 else if (commande.Contains(
"Test")) {
1364 else if (commande.Contains(
"Mass")) {
1371 else if (commande.Contains(
"Info")) {
1379 else if (commande.Contains(
"More")) {
1382 SuggestMoreAction();
1386 else if (commande.Contains(
"Delete")) {
1387 if (!TheGrid)
return;
1389 if (color == kRed) {
1394 else if (color == kWhite || color == kBlack) {
1400 else cout <<
"WARNING: KVIDGridEditor::DispatchOrder(): unknown order '" << commande <<
"' !" << endl;
1407 void KVIDGridEditor::SetEditable(
TPaveLabel* label)
1412 if (iseditable) label->
SetFillColor(fBlackMode ? kBlack : kWhite);
1415 else label->
SetFillColor(fBlackMode ? kBlack : kWhite);
1425 void KVIDGridEditor::SelectLines(
const Char_t* label)
1427 if (!TheGrid)
return;
1432 if (title.Contains(
"All")) {
1443 ListOfLines->R__FOR_EACH(
KVIDentifier, SetLineColor)(SelectedColor);
1444 ListOfLines->R__FOR_EACH(
KVIDentifier, SetMarkerColor)(SelectedColor);
1448 if (title.Contains(
"Select")) {
1449 if (color == kWhite || color == kBlack) {
1451 ResetColor(ListOfLines);
1452 ListOfLines->
Clear();
1454 if (color == kGreen) {
1455 ListOfLines->R__FOR_EACH(
KVIDentifier, SetLineColor)(SelectedColor);
1467 void KVIDGridEditor::NewLine()
1469 if (!TheGrid)
return;
1486 "Choose class of new identifier :",
1491 if (!okpressed)
return;
1493 else cut_class = cut_choices;
1501 if (fDebug) cout <<
"INFO: KVIDGridEditor::NewLine(): New Line has been added to the current grid..." << endl;
1506 void KVIDGridEditor::NewCut()
1512 if (!TheGrid)
return;
1532 if (!strcmp(cut_default,
"")) {
1533 cut_types.
Begin(
" ");
1534 cut_default = cut_types.
Next();
1537 "Choose class of new cut :",
1549 else cut_class = cut_types;
1558 if (fDebug) cout <<
"INFO: KVIDGridEditor::NewCut(): New Cut has been added to the current grid..." << endl;
1566 void KVIDGridEditor::NewInfo()
1569 if (!TheGrid)
return;
1577 if (info_choices ==
"") info_choices =
gEnv->
GetValue(
Form(
"%s.InfoClass",
"KVIDGraph"),
"");
1580 if (info_choices ==
"") info_choices =
gEnv->
GetValue(
Form(
"%s.DefaultInfoClass",
"KVIDGraph"),
"");
1585 KVString info_types = info_choices;
1590 if (!strcmp(info_default,
"")) {
1591 info_types.
Begin(
" ");
1592 info_default = info_types.
Next();
1595 "Choose class of new info :",
1597 info_default.
Data(),
1607 else info_class = info_types;
1612 Info(
"NewInfo",
"Adding new info contour or line of class '%s'", info_class.
Data());
1617 if (fDebug) cout <<
"INFO: KVIDGridEditor::NewInfo(): New info has been added to the current grid..." << endl;
1627 return fPivot->
GetX()[0];
1636 return fPivot->
GetY()[0];
1646 return fPivot->
GetX()[1];
1656 return fPivot->
GetY()[1];
1666 if (!TheGrid)
return;
1667 if (!TheHisto)
return;
1678 new KVSpIdGUI(TheGrid, TheHisto, x0, y0, pdx, pdy, fSpiderOption.
Data());
1807 void KVIDGridEditor::TestGrid()
1809 if (!TheGrid)
return;
1810 if (!TheHisto)
return;
1814 if (fDebug) cout <<
"INFO: KVIDGridEditor::TestGrid(): testing the current grid..." << endl;
1821 void KVIDGridEditor::FitGrid()
1823 if (!TheGrid)
return;
1830 cm->Action(fitter, m);
1833 if (fDebug) cout <<
"INFO: KVIDGridEditor::FitGrid(): fitting grid '" << TheGrid->
GetName() <<
"'..." << endl;
1840 void KVIDGridEditor::SuggestMoreAction()
1850 if (!okpressed)
return;
1853 if (!TheGrid)
return;
1856 cm->Action(TheGrid, m);
1859 else if ((m =
IsA()->GetMethodAllAny(Answer.
Data()))) {
1861 cm->Action(
this, m);
1864 else cout <<
"INFO: KVIDGridEditor::SuggestMoreAction(): '" << Answer <<
"' not implemented..." << endl;
1875 if (!TheGrid)
return;
1876 if (!ListOfLines)
return;
1878 ResetColor(ListOfLines);
1879 ListOfLines->
Clear();
1887 if ((found == -1) || (!
line))
continue;
1903 if (!TheGrid)
return;
1914 "KVIDGridEditor::SaveCurrentGrid",
Form(
"Do you wat to save the grid here : %s", fn.
Data()),
1918 if (ret_code ==
kMBYes) {
1924 const char* filetypes[] = {
1925 "ID Grid files",
"*.dat",
1938 if (!filenam.
Contains(
'.')) filenam +=
".dat";
1956 TIter it(ListOfLines);
1960 for (
int ii = 0; ii <
id->GetN(); ii++) {
1961 double xx =
id->
GetX()[ii];
1962 double yy =
id->GetY()[ii];
1964 if (ref) dyref =
abs(yy - ref->
Eval(xx)) / 2;
1966 TH1* hh = TheHisto->
ProjectionY(
"toto", xbin - nbin, xbin + nbin,
"goff");
1968 int nfound = spec.
Search(hh, dyref,
"goff", 0.05);
1975 for (
int ip = 0; ip < nfound; ip++) {
1977 TheGrid->
Identify(xx, xpeaks[ip], &idr);
1979 if (ypeaks[ip] > threshold && (idr.
Z ==
id->GetZ() && idr.
A ==
id->GetA())) {}
1982 if (
abs(xpeaks[ip] - yy) < dy) {
1983 dy =
abs(xpeaks[ip] - yy);
1987 if (ygood > 0)
id->GetY()[ii] = ygood;
1997 void KVIDGridEditor::OpenRootFile()
1999 static TString dir(
"$(HISTOROOT)");
2002 if (dir ==
"$(HISTOROOT)" &&
gSystem->
Getenv(
"HISTOROOT")) {
2008 const char* filetypes[] = {
"Root files",
"*.root",
"All files",
"*", 0, 0};
2026 void KVIDGridEditor::ChooseSelectedColor()
2031 Choices +=
"kBlack kGreen kBlue kRed kYellow kCyan kMagenta";
2036 if (!okpressed)
return;
2056 if (!TheGrid)
return;
2076 void KVIDGridEditor::ChangeStep(
const char* title,
Int_t dstep)
2079 if (commande.Contains(
"+")) {
2082 else if (commande.Contains(
"-")) {
2084 if (imod <= 0)imod = 1;
2095 void KVIDGridEditor::SetLogz()
2105 void KVIDGridEditor::SetLogy()
2115 void KVIDGridEditor::SetLogx()
2125 void KVIDGridEditor::Unzoom()
2140 void KVIDGridEditor::Undo()
2146 if (!TheGrid)
return;
2152 Form(
"This will undo all changes to the grid. Are you sure, %s?", username.
Data()),
2153 kMBIconExclamation, kMBOk | kMBCancel, &ret_val);
2155 if (ret_val & kMBOk) {
2156 if (ListOfLines && ListOfLines->
GetEntries()) {
2171 const char* KVIDGridEditor::WhoIsSelected()
2174 TIter nextlabel(lplabel);
2185 void KVIDGridEditor::TranslateX(
Int_t Sign)
2187 if (!TheGrid)
return;
2188 if (!ListOfLines)
return;
2189 if (ListOfLines->
IsEmpty())
return;
2200 if (fDebug) cout <<
"INFO: KVIDGridEditor::TranslateX(): translation on the X axis (" << (
Sign > 0 ?
"+" :
"-") << step <<
") !" << endl;
2208 void KVIDGridEditor::TranslateY(
Int_t Sign)
2210 if (!TheGrid)
return;
2211 if (!ListOfLines)
return;
2212 if (ListOfLines->
IsEmpty())
return;
2223 if (fDebug) cout <<
"INFO: KVIDGridEditor::TranslateY(): translation on the Y axis (" << (
Sign > 0 ?
"+" :
"-") << step <<
") !" << endl;
2236 if (!TheHisto)
return;
2257 if (X0 >= X1) X0 = X1 - 1;
2259 if ((X0 - dX) < 0) ax->
SetRange(0, X1 - X0);
2261 else ax->
SetRange(X0 - dX, X1 - dX);
2271 if (Y0 >= Y1) Y0 = Y1 - 1;
2273 if ((Y0 - dY) < 0) ax->
SetRange(0, Y1 - Y0);
2275 else ax->
SetRange(Y0 - dY, Y1 - dY);
2285 void KVIDGridEditor::RotateZ(
Int_t Sign)
2287 if (!TheGrid)
return;
2288 if (!ListOfLines)
return;
2289 if (ListOfLines->
IsEmpty())
return;
2292 if (step >= 45.) step = 45.;
2295 x0 = fPivot->
GetX()[0];
2296 y0 = fPivot->
GetY()[0];
2301 ListOfLines->R__FOR_EACH(
KVIDentifier, Scale)(frx, fry);
2304 if (fDebug) cout <<
"INFO: KVIDGridEditor::RotateZ(): rotation around the Z axis (" << (
Sign > 0 ?
"+" :
"-") << step <<
") !" << endl;
2355 if (!TheGrid)
return;
2356 if (!ListOfLines)
return;
2357 if (ListOfLines->
IsEmpty())
return;
2359 Double_t step = 0.05 * (imod / 100.);
2363 x0 = fPivot->
GetX()[0];
2373 fBx = fs->
Eval(fBx);
2375 if (fDebug)
Info(
"ScaleX",
"scaling on the X axis (*%f) !", factor);
2376 KVEnv scale_factors(
"KVIDGridEditor_scalings.dat");
2377 scale_factors.AddCommentLine(
"# Cumulative linear scalings applied to grids with KVIDGridEditor");
2378 scale_factors.AddCommentLine(
"# Parameters are a0,a1 of linear transform using pol1 X -> a0 + a1*X");
2379 scale_factors.SetValue(
Form(
"%s.X",TheGrid->
GetName()),
Form(
"%g %g", fBx, fAx));
2380 scale_factors.SaveLevel(kEnvLocal);
2391 if (!TheGrid)
return;
2392 if (!ListOfLines)
return;
2393 if (ListOfLines->
IsEmpty())
return;
2395 Double_t step = 0.05 * (imod / 100.);
2399 y0 = fPivot->
GetY()[0];
2409 fBy = fs->
Eval(fBy);
2411 if (fDebug)
Info(
"ScaleY",
"scaling on the Y axis (*%f) !", factor);
2413 KVEnv scale_factors(
"KVIDGridEditor_scalings.dat");
2414 scale_factors.AddCommentLine(
"# Cumulative linear scalings applied to grids with KVIDGridEditor");
2415 scale_factors.AddCommentLine(
"# Parameters are a0,a1 of linear transform using pol1 X -> a0 + a1*X");
2416 scale_factors.SetValue(
Form(
"%s.Y",TheGrid->
GetName()),
Form(
"%g %g", fBy, fAy));
2417 scale_factors.SaveLevel(kEnvLocal);
2426 void KVIDGridEditor::ScaleXY(
Int_t Sign)
2428 if (!TheGrid)
return;
2429 if (!ListOfLines)
return;
2430 if (ListOfLines->
IsEmpty())
return;
2432 Double_t step = 0.05 * (imod / 100.);
2435 x0 = fPivot->
GetX()[0];
2436 y0 = fPivot->
GetY()[0];
2441 ListOfLines->R__FOR_EACH(
KVIDentifier, Scale)(fs, fsy);
2448 fBx = fs->
Eval(fBx);
2450 fBy = fsy->
Eval(fBy);
2452 if (fDebug)
Info(
"ScaleXY",
"scaling (*%f) !", factor);
2460 void KVIDGridEditor::ScaleCurvature(
Int_t Sign)
2462 if (!TheGrid)
return;
2463 if (!ListOfLines)
return;
2464 if (ListOfLines->
IsEmpty())
return;
2466 Double_t step = 0.05 * (imod / 100.);
2470 TIter nextidd(ListOfLines);
2484 idd->
Scale(frx, fry);
2491 idd->
Scale(frx, fry);
2507 if (!TheGrid)
return;
2510 Ident->
SetLineColor(Ident->
HasMassFits() ? identifier_line_colors_with_mass[(
int)fBlackMode] : identifier_line_colors_no_mass[(
int)fBlackMode]);
2511 Ident->
SetMarkerColor(Ident->
HasMassFits() ? identifier_marker_colors_with_mass[(
int)fBlackMode] : identifier_marker_colors_no_mass[(
int)fBlackMode]);
2514 auto cut_line =
dynamic_cast<KVIDCutLine*
>(Ident);
2516 Ident->
SetLineColor(bad_cut ? kGray : cut_line_colors[(
int)fBlackMode]);
2533 TIter nextidd(IdentList);
2549 TheHisto->
Draw(
"col");
2554 if (fPivot) fPivot->
Draw(
"P");
2559 if (fDebug) cout <<
"INFO: KVIDGridEditor::ForceUpdate(): Canvas and Co has been updated !" << endl;
2581 fKeyShow =
new TPaveText(0.8, 0.8, 0.9, 0.9,
"brNDC");
2585 fKeyShow->
AddText(tmpStr.Data());
2656 DispatchOrder(label);
2662 DispatchOrder(label);
2679 DynamicZoom(-1, 0, 0, 0.1);
2688 DynamicZoom(1, 0, 0, 0.1);
2701 gROOT->ForceStyle();
2710 lplabel->
Execute(
"SetFillColor",
"kWhite");
2711 lplabel->
Execute(
"SetTextColor",
"kBlack");
2712 lplabel->
Execute(
"SetLineColor",
"kBlack");
2714 lplabel2->
Execute(
"SetFillColor",
"kWhite");
2715 lplabel2->
Execute(
"SetTextColor",
"kBlack");
2716 lplabel2->
Execute(
"SetLineColor",
"kBlack");
2718 lplabel3->
Execute(
"SetFillColor",
"kWhite");
2719 lplabel3->
Execute(
"SetTextColor",
"kBlack");
2720 lplabel3->
Execute(
"SetLineColor",
"kBlack");
2722 lplabel4->
Execute(
"SetFillColor",
"kWhite");
2723 lplabel4->
Execute(
"SetTextColor",
"kBlack");
2724 lplabel4->
Execute(
"SetLineColor",
"kBlack");
2729 if (dummy != modulator) {
2750 gROOT->ForceStyle();
2759 lplabel->
Execute(
"SetFillColor",
"kBlack");
2760 lplabel->
Execute(
"SetTextColor",
"kWhite");
2761 lplabel->
Execute(
"SetLineColor",
"kWhite");
2763 lplabel2->
Execute(
"SetFillColor",
"kBlack");
2764 lplabel2->
Execute(
"SetTextColor",
"kWhite");
2765 lplabel2->
Execute(
"SetLineColor",
"kWhite");
2767 lplabel3->
Execute(
"SetFillColor",
"kBlack");
2768 lplabel3->
Execute(
"SetTextColor",
"kWhite");
2769 lplabel3->
Execute(
"SetLineColor",
"kWhite");
2771 lplabel4->
Execute(
"SetFillColor",
"kBlack");
2772 lplabel4->
Execute(
"SetTextColor",
"kWhite");
2773 lplabel4->
Execute(
"SetLineColor",
"kWhite");
2778 if (dummy != modulator) {
2792 DispatchOrder(label);
2798 fAutoZoomMode = !fAutoZoomMode;
2802 lplabel3->
Execute(
"SetFillColor",
"kGreen");
2808 ChangeZoomRatio(-1);
2818 if (fPointStyle == 4) {
2838 lplabel3->
Execute(
"SetFillColor", fBlackMode ?
"kBlack" :
"kWhite");
2839 if (color == kWhite || color == kBlack) label->
SetFillColor(kGreen);
2840 if (color == kGreen) label->
SetFillColor(fBlackMode ? kBlack : kWhite);
2841 SelectLines(
"Select");
2850 venermode = !venermode;
2872 MoveHor(1, .2,
false);
2881 MoveHor(-1, .2,
false);
2891 MoveVert(1, .25,
false);
2900 MoveVert(-1, .25,
false);
2914 if (fSVGMode && fKeyShow) {
2928 if (!TheHisto)
return;
2935 if ((XX1 == 1) && (sign == 1))
return;
2936 if ((XX2 == xAxis->
GetNbins() - 1) && (sign == -1))
return;
2938 Int_t dX = (
Int_t)sign * (XX1 - XX2) * 0.25 * speed;
2940 xAxis->
SetRange(XX1 + dX, XX2 + dX);
2948 void KVIDGridEditor::ChangeZoomRatio(
Int_t sign,
Double_t speed)
2950 if (!TheHisto)
return;
2953 if (sign < 0) axis = TheHisto->
GetXaxis();
2959 Int_t dX = (
Int_t) - 1 * (XX1 - XX2) * 0.1 * speed;
2961 axis->
SetRange(XX1 + dX, XX2 - dX);
2972 if (!TheHisto)
return;
2979 if ((XX1 == 1) && (sign == 1))
return;
2980 if ((XX2 == yAxis->
GetNbins() - 1) && (sign == -1))
return;
2982 Int_t dX = (
Int_t)sign * (XX1 - XX2) * 0.25 * speed;
2984 yAxis->
SetRange(XX1 + dX, XX2 + dX);
2992 void KVIDGridEditor::ZoomOnMouse()
3002 void KVIDGridEditor::SelectTrans(
TPaveLabel* label)
3007 lplabel->
Execute(
"SetFillColor", fBlackMode ?
"kBlack" :
"kWhite");
3008 if (color == kWhite || color == kBlack) label->
SetFillColor(kRed);
3009 else if (color == kRed) label->
SetFillColor(fBlackMode ? kBlack : kWhite);
3020 fPointStyle = pstyle;
3046 if ((!TheHisto) || (!TheGrid))
return;
3071 Info(
"ChangeMasses",
"%d lines found for Z=%d", ll->
GetSize(), Z);
3076 Info(
"ChangeMasses",
"A=%d -> A=%d",
id->GetA(),
id->GetA() + dA);
3077 id->SetA(
id->GetA() + dA);
3095 for (
int i =
n - 1; i > 0; i--) {
3098 Info(
"ChangeMasses",
"%d lines found for Z=%d", ll->
GetSize(), Z);
3103 Info(
"ChangeMasses",
"Z=%d -> Z=%d",
id->GetZ(),
id->GetZ() + dZ);
3104 id->SetZ(
id->GetZ() + dZ);
3115 void KVIDGridEditor::AddMethod(
const char* theMethod)
3117 if (fListOfMethods.
IsNull()) fDefaultMethod += theMethod;
3118 fListOfMethods += theMethod;
3119 fListOfMethods +=
" ";
3133 Info(
"PrintScalingRecap",
3134 "Scaling recap:\n X --> %f X + %f\n Y --> %f Y + %f"
3135 , fAx, fBx, fAy, fBy);
3146 ResetColor(TheGrid->
GetCuts());
size_t size(const MatrixT &matrix)
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 result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
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 g
Option_t Option_t TPoint TPoint percent
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
Option_t Option_t TPoint TPoint const char y1
char * Form(const char *fmt,...)
char * StrDup(const char *str)
R__EXTERN TStyle * gStyle
R__EXTERN TSystem * gSystem
Base class for KaliVeda framework.
Bool_t IsType(const Char_t *typ, bool case_insensitive=false) const
void Copy(TObject &) const override
Make a copy of this object.
Ask user to choose between several options in a drop-down list.
Extension of TEnv to allow the writing of comments in the file.
Extended version of ROOT THashList.
Wrapper for histograms and graphical cuts used by KVTreeAnalyzer.
Line in ID grid used to delimit regions where no identification is possible.
bool IsAcceptedDirectionSet() const
Base class for particle identification in a 2D map.
void Draw(Option_t *opt="") override
void RemoveIdentifier(KVIDentifier *)
Remove and destroy identifier.
void SetEditable(Bool_t editable=kTRUE) override
void UpdateLastSavedVersion()
update last saved version. mkae copy of current state of graph.
void RemoveInfo(KVIDentifier *)
Remove and destroy cut.
const KVList * GetCuts() const
TVirtualPad * GetPad() const
const KVList * GetInfos() const
void RevertToLastSavedVersion()
virtual void Identify(Double_t, Double_t, KVIdentificationResult *) const =0
const Char_t * GetName() const override
virtual void DrawAndAdd(const TString &type="ID", const TString &classname="KVIDentifier")
KVIDentifier * GetIdentifier(Int_t Z, Int_t A) const
void FindAxisLimits()
Calculate X/Y min/max of all objects in graph.
void WriteAsciiFile(const Char_t *filename)
Open, write and close ascii file containing this grid.
virtual void Initialize()=0
void RemoveCut(KVIDentifier *)
Remove and destroy cut.
const KVList * GetIdentifiers() const
Extended version of KVCanvas used by KVIDGridEditor.
Identification grid editor GUI ,.
void SelectLinesByZ(const Char_t *ListOfZ)
KVIDGridEditor()
Default constructor.
void MakeTransformation()
void SetGrid(KVIDGraph *gg, Bool_t histo=true)
void ChangeCharges(const Char_t *Zl, Int_t dZ)
void SetPointStyle(int pstyle)
void StartViewer()
Close();.
virtual ~KVIDGridEditor()
Destructor.
void SetSelectedColor(Int_t color)
void Clear(const Option_t *opt="") override
void SetPointSize(double psize)
void ChangeMasses(const Char_t *Zl, Int_t dA)
void SpiderIdentification()
void Copy(TObject &) const override
const KVSeqCollection * GetGrids() const
Hybrid charge & mass identification grid.
Identification grid with lines corresponding to different nuclear isotopes (KVIDZALine)
Base class for identification ridge lines corresponding to different nuclear species.
Base class for graphical cuts used in particle identification.
virtual Bool_t HasMassFits() const
void Scale(TF1 *sx, TF1 *sy)
Full result of one attempted particle identification.
Int_t A
A of particle found (if Aident==kTRUE)
Int_t Z
Z of particle found (if Zident==kTRUE)
GUI for finding/fixing mass identification intervals.
Extended TList class which owns its objects by default.
void Sort(Bool_t order=kSortAscending)
Strings used to represent a set of ranges of values.
IntArray GetArray() const
KaliVeda extensions to ROOT collection classes.
void Execute(const char *method, const char *params, Int_t *error=0) override
KVSeqCollection * GetSubListWithMethod(const Char_t *retvalue, const Char_t *method) const
TObject * Remove(TObject *obj) override
Remove object from list.
void Add(TObject *obj) override
TObject * FindObject(const char *name) const override
void AddLast(TObject *obj) override
Int_t GetSize() const override
void Clear(Option_t *option="") override
TObject * At(Int_t idx) const override
void Delete(Option_t *option="") override
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
void Begin(TString delim) const
KVString Next(Bool_t strip_whitespace=kFALSE) const
GUI for testing identification grids.
const KVList * GetHistoList() const
TH1 * GetHistogram(const Char_t *name) const
Return histogram with given name.
Extended TList class which does not own its objects by default.
ABC for fitting ID grids with functionals.
static KVVirtualIDFitter * GetDefaultFitter()
void SetPad(TVirtualPad *p)
void SetGrid(KVIDGraph *g)
Dialog box for KVZALineFinder class.
virtual void SetAxisColor(Color_t color=1, Float_t alpha=1.)
virtual void SetLabelColor(Color_t color=1, Float_t alpha=1.)
virtual Color_t GetFillColor() const
virtual void SetFillColor(Color_t fcolor)
virtual void SetFillStyle(Style_t fstyle)
virtual void SetLineColor(Color_t lcolor)
virtual void SetMarkerColor(Color_t mcolor=1)
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual void SetMarkerSize(Size_t msize=1)
virtual void SetTextAlign(Short_t align=11)
virtual void SetTextColor(Color_t tcolor=1)
virtual void SetTextSize(Float_t tsize=1)
virtual Int_t FindBin(const char *label)
virtual void SetRangeUser(Double_t ufirst, Double_t ulast)
virtual void SetRange(Int_t first=0, Int_t last=0)
virtual Double_t GetBinWidth(Int_t bin) const
virtual Int_t IsInside(Double_t x, Double_t y) const
void Clear(Option_t *option="") override
TCanvasImp * GetCanvasImp() const override
TVirtualPad * cd(Int_t subpadnumber=0) override
TMethod * GetMethodAllAny(const char *method)
TMethod * GetMethodAny(const char *method)
virtual void AddAll(const TCollection *col)
virtual Int_t GetEntries() const
virtual void SetOwner(Bool_t enable=kTRUE)
virtual Bool_t IsEmpty() const
Bool_t Contains(const char *name) const
TClass * IsA() const override
virtual TDirectory * GetDirectory(const char *namecycle, Bool_t printError=false, const char *funcname="GetDirectory")
virtual TList * GetListOfKeys() const
virtual const char * GetValue(const char *name, const char *dflt) const
virtual void SetParameters(const Double_t *params)
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
virtual void SetParameter(const TString &name, Double_t value)
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
virtual Bool_t IsEditable() const
virtual Double_t Eval(Double_t x, TSpline *spline=nullptr, Option_t *option="") const
void SetName(const char *name="") override
void Draw(Option_t *chopt="") override
void Draw(Option_t *option="") override
virtual void SetMinimum(Double_t minimum=-1111)
virtual Double_t GetMinimum(Double_t minval=-FLT_MAX) const
TH1D * ProjectionY(const char *name="_py", Int_t firstxbin=0, Int_t lastxbin=-1, Option_t *option="") const
Bool_t IsFolder() const override
virtual const char * GetClassName() const
const char * GetName() const override
TClass * IsA() const override
virtual const char * GetName() const
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual const char * ClassName() const
virtual Bool_t InheritsFrom(const char *classname) const
virtual void Draw(Option_t *option="")
virtual void Info(const char *method, const char *msgfmt,...) const
TList * GetListOfPrimitives() const override
const char * GetName() const override
virtual void SetLabel(const char *label)
const char * GetTitle() const override
virtual TText * AddText(const char *label)
void Draw(Option_t *option="") override
const char * GetName() const override
virtual void SetName(const char *name="")
virtual void SetBorderSize(Int_t bordersize=4)
Double_t * GetPositionY() const
virtual Int_t Search(const TH1 *hist, Double_t sigma=2, Option_t *option="", Double_t threshold=0.05)
Double_t * GetPositionX() const
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
const char * Data() const
Bool_t EqualTo(const char *cs, ECaseCompare cmp=kExact) const
TString & Prepend(char c, Ssiz_t rep=1)
virtual Int_t Sizeof() const
void Form(const char *fmt,...)
TString & Remove(EStripType s, char c)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TString & ReplaceAll(const char *s1, const char *s2)
void SetOptTitle(Int_t tit=1)
void SetPadTopMargin(Float_t margin=0.1)
void SetOptStat(Int_t stat=1)
void SetPadBottomMargin(Float_t margin=0.1)
void SetFrameFillColor(Color_t color=1)
void SetPadRightMargin(Float_t margin=0.1)
void SetTitleFont(Style_t font=62, Option_t *axis="X")
void SetPadTickY(Int_t ticky)
void SetTitleOffset(Float_t offset=1, Option_t *axis="X")
void SetPadTickX(Int_t tickx)
void SetPalette(Int_t ncolors=kBird, Int_t *colors=nullptr, Float_t alpha=1.)
void SetLabelFont(Style_t font=62, Option_t *axis="X")
void SetPadLeftMargin(Float_t margin=0.1)
void SetTitleSize(Float_t size=0.02, Option_t *axis="X")
void SetNdivisions(Int_t n=510, Option_t *axis="X")
void SetHatchesSpacing(Double_t h)
void SetHatchesLineWidth(Int_t l)
void SetLabelSize(Float_t size=0.04, Option_t *axis="X")
Bool_t cd(const char *path)
virtual const char * Getenv(const char *env)
virtual UserGroup_t * GetUserInfo(const char *user=nullptr)
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
virtual const char * BaseName(const char *pathname)
virtual char * ExpandPathName(const char *path)
virtual void Modified(Bool_t flag=1)=0
virtual void SetLogx(Int_t value=1)=0
virtual Double_t GetUymax() const=0
virtual TFrame * GetFrame()=0
virtual Int_t GetEventX() const=0
virtual TObject * GetSelected() const=0
virtual void SetLogz(Int_t value=1)=0
virtual Double_t AbsPixeltoX(Int_t px)=0
virtual Double_t GetUxmax() const=0
virtual Double_t AbsPixeltoY(Int_t py)=0
virtual Double_t GetUymin() const=0
virtual Int_t GetEvent() const=0
virtual Double_t GetUxmin() const=0
virtual void SetLogy(Int_t value=1)=0
virtual Int_t GetEventY() const=0
RVec< PromoteType< T > > abs(const RVec< T > &v)
Double_t Min(Double_t a, Double_t b)
Double_t Sign(Double_t a, Double_t b)
constexpr Double_t DegToRad()
Double_t Max(Double_t a, Double_t b)