1#include "KVIDGridManagerGUI.h"
3#include "KVIDGridManager.h"
13#include <KVTestIDGridDialog.h>
15#include <KVIDGUITelescopeChooserDialog.h>
16#include <KVDropDownDialog.h>
17#include <KVIdentificationResult.h>
18#include <KVReconstructedNucleus.h>
20#include "KVInputDialog.h"
21#include "KVIDCutLine.h"
22#include "KVIDCutContour.h"
23#include "KVVirtualIDFitter.h"
38 fLastSelectedGrid = 0;
47 gIDGridManager->Connect(
"Modified()",
"KVIDGridManagerGUI",
this,
48 "UpdateListOfGrids()");
56 sgm->
AddEntry(
"Selected", M_GRIDS_SAVE_SEL);
57 sgm->
AddEntry(
"Tab", M_GRIDS_SAVE_TAB);
58 sgm->
AddEntry(
"All", M_GRIDS_SAVE_ALL);
59 fMenuFile->AddPopup(
"Save...", sgm);
61 fMenuFile->AddSeparator();
64 sgm->
AddEntry(
"Selected", M_GRIDS_DEL_SEL);
65 sgm->
AddEntry(
"Tab", M_GRIDS_DEL_TAB);
66 sgm->
AddEntry(
"All", M_GRIDS_DEL_ALL);
67 fMenuFile->AddPopup(
"Delete...", sgm);
68 fMenuFile->AddSeparator();
69 fMenuFile->AddEntry(
"&Quit", M_QUIT);
71 fMenuFile->Connect(
"Activated(Int_t)",
"KVIDGridManagerGUI",
this,
72 "HandleGridsMenu(Int_t)");
80 sgm->
AddEntry(
"Runlist", M_GRIDS_SET_RUNLIST);
81 sgm->
AddEntry(
"X Variable", M_GRIDS_SET_VARX);
82 sgm->
AddEntry(
"Y Variable", M_GRIDS_SET_VARY);
84 sgm->
AddEntry(
"Z ID Only", M_GRIDS_SET_ZID);
85 fMenuEdit->AddPopup(
"Set...", sgm);
86 fMenuEdit->AddEntry(
"Clear", M_GRIDS_CLEAR);
87 fMenuEdit->Connect(
"Activated(Int_t)",
"KVIDGridManagerGUI",
this,
88 "HandleGridsMenu(Int_t)");
94 fMenuBar->AddPopup(
"&File", fMenuFile, fMenuBarItemLayout);
95 fMenuBar->AddPopup(
"&Edit", fMenuEdit, fMenuBarItemLayout);
108 const char* xpms[] = {
121 const char* tips[] = {
122 "Open file containing grids",
123 "Save all grids in current file",
126 "Delete selected grid(s)",
127 "Set ID telescopes for grid",
157 const char* method[] = {
162 "DeleteSelectedGrids()",
166 "UpdateListOfGrids()",
181 *buttons[i] = fToolBar->AddButton(
this, &t[i], spacing[i]);
182 (*buttons[i])->Connect(
"Clicked()",
"KVIDGridManagerGUI",
this, method[i]);
183 fTBbuttons[i] = *buttons[i];
208 fGridListTabs =
new TGTab(fHframe, 550, 400);
209 fGridListTabs->Connect(
"Selected(Int_t)",
"KVIDGridManagerGUI",
this,
"TabSelect(Int_t)");
214 fHframe->AddFrame(fGridListTabs,
219 TGLabel* lab1 =
new TGLabel(line_frame,
"CURRENT GRID IDENTIFIERS");
224 fIDLineList->SetDataColumns(5);
225 fIDLineList->SetDataColumn(0,
"Name",
"",
kTextLeft);
228 fIDLineList->SetDataColumn(3,
"OnlyZId",
"OnlyZId",
kTextCenterX);
229 fIDLineList->SetDataColumn(4,
"MassFormula",
"",
kTextCenterX);
230 fIDLineList->GetDataColumn(3)->SetIsBoolean();
231 fIDLineList->ActivateSortButtons();
232 fIDLineList->AllowBrowse(
kFALSE);
237 lab1 =
new TGLabel(line_frame,
"Cuts");
241 fCUTList->SetDataColumns(3);
242 fCUTList->SetDataColumn(0,
"Name",
"",
kTextLeft);
243 fCUTList->SetDataColumn(1,
"# Points",
"GetN",
kTextCenterX);
244 fCUTList->SetDataColumn(2,
"Class",
"ClassName",
kTextCenterX);
246 fCUTList->ActivateSortButtons();
247 fCUTList->AllowBrowse(
kFALSE);
252 lab1 =
new TGLabel(line_frame,
"Infos");
256 fCUTInfoList->SetDataColumns(3);
257 fCUTInfoList->SetDataColumn(0,
"Name",
"",
kTextLeft);
258 fCUTInfoList->SetDataColumn(1,
"# Points",
"GetN",
kTextCenterX);
259 fCUTInfoList->SetDataColumn(2,
"Class",
"ClassName",
kTextCenterX);
262 fCUTInfoList->ActivateSortButtons();
263 fCUTInfoList->AllowBrowse(
kFALSE);
274 SetWindowName(
"ID Grid Manager");
278 Resize(GetDefaultSize());
280 SetWMSize(1200, 600);
296 gIDGridManager->Disconnect(
"Modified()",
this,
"UpdateListOfGrids()");
343 static TString dir(
"$HISTOROOT");
348 const char* filetypes[] = {
"Root files",
"*.root",
"All files",
"*", 0, 0};
379 cout <<
"Add new grid" << endl;
411 "This will delete all grids in the current tab. Are you sure ?",
413 if (ret_val &
kMBOk) {
424 "This will delete all grids. Are you sure ?",
426 if (ret_val &
kMBOk) {
427 gIDGridManager->
Clear();
442 new KVInputDialog(
this,
"Enter list of runs for grid(s):", &runs, &ok_pressed,
443 "Example: 1-10, 13, 22-657");
444 if (!ok_pressed)
break;
458 new KVInputDialog(
this,
"Enter X variable for grid(s):", &runs, &ok_pressed,
460 if (!ok_pressed)
break;
474 new KVInputDialog(
this,
"Enter Y variable for grid(s):", &runs, &ok_pressed,
476 if (!ok_pressed)
break;
524 "This will delete the selected grids. Are you sure ?",
526 if (ret_val &
kMBOk) {
538 const char* filetypes[] = {
539 "ID Grid files",
"*.dat",
694 if (cancel || !telescopes.
GetEntries())
return;
721 Clist->R__FOR_EACH(
TCanvas, Modified)();
722 Clist->R__FOR_EACH(
TCanvas, Update)();
733 gIDGridManager->Disconnect(
"Modified()",
this,
"UpdateListOfGrids()");
740 gIDGridManager->Connect(
"Modified()",
"KVIDGridManagerGUI",
this,
"UpdateListOfGrids()");
763 Info(
"NewGrid",
"There are %d grids in the manager", gIDGridManager->
GetGrids()->
GetSize());
764 TString default_class =
"KVIDZAGrid";
766 if (gMultiDetArray) {
770 if (cancel || !telescopes->
At(0)) {
771 Info(
"NewGrid",
"No ID telescopes chosen. Grid creation cancelled.");
775 default_class = ((
KVIDTelescope*)telescopes->
At(0))->GetDefaultIDGridClass();
784 choice.
Data(), default_class.
Data(), &id_grid_class, &ok_pressed);
786 Info(
"NewGrid",
"No ID grid class chosen. Grid creation cancelled.");
789 gIDGridManager->Disconnect(
"Modified()",
this,
"UpdateListOfGrids()");
793 gIDGridManager->Connect(
"Modified()",
"KVIDGridManagerGUI",
this,
"UpdateListOfGrids()");
827 const char* filetypes[] = {
828 "ID Grid files",
"*.dat",
851 Form(
"Could not write file %s", filenam.
Data()), 0,
893 "SelectionChanged()");
904 while (! labels.
End()) {
923 "SelectionChanged()");
987 "SelectionChanged()");
1002 cout <<
"cf = 0x0 : label=Grids tab name=" <<
1018 while (! labels.
End()) {
1041 "SelectionChanged()");
1056 cout <<
"cf = 0x0 : label=" << lab.
Data() <<
" tab name=" <<
1071 if (grids)
delete grids;
1096 for (
Int_t itab = 0; itab < ntabs; itab++) {
1178 fSelectedGrid->Connect(
"Modified()",
"KVIDGridManagerGUI",
this,
"UpdateListOfLines()");
1260 "Choose class of new identifier :",
1265 if (!okpressed)
return;
1268 cut_class = cut_choices;
1309 TString cut_types = cut_choices;
1314 "Choose class of new cut :",
1319 if (!okpressed)
return;
1322 cut_class = cut_types;
1348 TIter next(
gPad->GetListOfPrimitives());
1350 while ((o = next())) {
1358 SetStatus(
"No TH2 found in current pad. Select pad containing 2D histo with data to identify.");
1384 TIter next(
gPad->GetListOfPrimitives());
1386 while ((o = next())) {
1394 SetStatus(
"No TH2 found in current pad. Select pad containing 2D histo with data to identify.");
1402 SetStatus(
"There was a problem with the test ???");
1406 TH2*
id = (
TH2*)tmpfiles->
Get(
"idcode_map");
1430TFile* KVIDGridManagerGUI::TestIdentificationWithTree(
KVIDGraph* gr,
const Char_t* name_of_data_histo)
1448 printf(
" KVIDGraph::TestIdentificationWithTree l histo %s n existe pas\n",
name_of_data_histo);
1460 if ((tid = (
TTree*)
gROOT->FindObject(
"tree_idresults"))) {
1461 printf(
" KVIDGraph::TestIdentificationWithTree effacemenent de l arbre existant\n");
1465 TString fn(
"IDtestTree.root");
1467 TFile* tmpfile =
new TFile(fn.Data(),
"recreate");
1470 tid =
new TTree(
"tree_idresults",
"pid");
1471 Float_t br_xxx, br_yyy, br_stat, br_pid;
1472 Int_t br_idcode, br_isid;
1474 tid->
Branch(
"X", &br_xxx,
"br_xxx/F");
1475 tid->
Branch(
"Y", &br_yyy,
"br_yyy/F");
1476 tid->
Branch(
"Stat", &br_stat,
"br_stat/F");
1478 tid->
Branch(
"PID", &br_pid,
"br_pid/F");
1479 tid->
Branch(
"IDcode", &br_idcode,
"br_idcode/I");
1480 tid->
Branch(
"IsIdentified", &br_isid,
"br_isid/I");
1483 Int_t events_read = 0;
1487 for (
int i = 1; i <=
data->GetNbinsX(); i++) {
1488 for (
int j = 1; j <=
data->GetNbinsY(); j++) {
1495 Axis_t x0 =
data->GetXaxis()->GetBinCenter(i);
1496 Axis_t y0 =
data->GetYaxis()->GetBinCenter(j);
1497 Axis_t wx =
data->GetXaxis()->GetBinWidth(i);
1498 Axis_t wy =
data->GetYaxis()->GetBinWidth(j);
1510 for (
int k = 0; k < kmax; k++) {
1514 if (
gr->IsIdentifiable(x, y)) {
1516 gr->Identify(x, y, idr);
1519 br_idcode =
gr->GetQualityCode();
1530 events_read += (
Int_t) poids;
1531 percent = (1. * events_read / tot_events) * 100.;
1533 if (percent >= cumul) {
1534 cout << (
Int_t) percent <<
"\% processed" << endl;
1561 cm->Action(fitter,
m);
const Bool_t kIterBackward
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize MapSubwindows
Option_t Option_t TPoint TPoint percent
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
char * StrDup(const char *str)
R__EXTERN TSystem * gSystem
static const Char_t * GetListOfPlugins(const Char_t *base)
static void GetTempFileName(TString &base)
static const Char_t * GetKVVersion()
Returns KaliVeda version string.
Ask user to choose between several options in a drop-down list.
ID Grid Manager dialog for choice of ID telescope(s)
Base class for particle identification in a 2D map.
void SetRunList(const char *runlist)
virtual void SetVarX(const char *v)
const TList * GetIDTelescopes() const
void UpdateLastSavedVersion()
update last saved version. mkae copy of current state of graph.
virtual void Copy(TObject &) const
Copy this to 'obj'.
virtual Bool_t HasMassIDCapability() const
TVirtualPad * GetPad() const
const KVList * GetIdentifiers() const
virtual void SetVarY(const char *v)
virtual void DrawAndAdd(const Char_t *type="ID", const Char_t *classname="KVIDentifier")
const Char_t * GetName() const
const KVList * GetInfos() const
void AddIDTelescopes(const TList *)
Associate this graph with all ID telescopes in list.
static KVIDGraph * MakeIDGraph(const Char_t *)
const KVList * GetCuts() const
virtual void Clear(Option_t *opt="")
virtual void SetOnlyZId(Bool_t yes=kTRUE)
void ClearListOfTelescopes()
const Char_t * GetRunList() const
Identification grid editor GUI ,.
void SetGrid(KVIDGraph *gg, Bool_t histo=true)
void StartViewer()
Close();.
Graphical interface tool for managing, creating, testing and fitting identification grids.
void TabSelect(Int_t)
called when a new tab is selected
Int_t GetNSelected()
returns current number of selected items in grid list
void SaveGridsAs(const TCollection *=0)
KVListView * fCUTInfoList
list of lines in currently selected grid
void DeleteSelectedGrids()
warning message and confirmation
void HandleGridsMenu(Int_t id)
Receive signals emitted by items selected in Grids menu.
void DeleteAllGridsInTab()
delete the all grids in currently selected tab
void SetIDTelescopes()
Set ID telescopes for selected grid.
void ActivateToolbarButtons()
disable all buttons
KVIDGraph * fLastSelectedGrid
virtual ~KVIDGridManagerGUI()
close window
void DeleteGrids()
delete the current selected grid, or all currently selected grids if there are more than one
KVListView * fIDGridList
list of grids in current tab
TGTab * fGridListTabs
tabs with lists of grids
KVListView * fIDLineList
list of lines in currently selected grid
const Char_t * name_of_data_histo
TCollection * GetAllGridsInTab()
void CloseWindow()
close viewer
void ClearGrid()
deletes all lines in currently selected grid(s)
void SetStatus(const Char_t *text="")
TGButton * fTBbuttons[50]
void RemoveEmptyTabs()
Recursively remove any empty tabs.
KVIDGridEditor * fIDGridEditor
ID grid editor.
KVListView * fCUTList
list of lines in currently selected grid
KVIDGraph * fSelectedGrid
TGButton * fTBStartEditor
std::unique_ptr< TList > fSelectedEntries
void GetListOfIDTelescopeLabels(KVString &)
void DeleteGrid(KVIDGraph *, Bool_t update=kTRUE)
void Clear(Option_t *opt="")
Delete all grids and empty list, ready to start anew.
Int_t WriteAsciiFile(const Char_t *filename, const TCollection *selection=0)
Bool_t ReadAsciiFile(const Char_t *filename)
KVList * GetGridsForIDTelescope(const Char_t *label)
Base class for all detectors or associations of detectors in array which can identify charged particl...
Full result of one attempted particle identification.
virtual void SetIsBoolean(Bool_t isit=kTRUE)
Enhanced version of ROOT TGListView widget.
virtual void ActivateSortButtons()
virtual void SetDataColumns(Int_t ncolumns)
virtual void Sort(Int_t column)
void SetDoubleClickAction(const char *receiver_class, void *receiver, const char *slot)
virtual void Display(const TCollection *l)
TObject * GetLastSelectedObject() const
TList * GetSelectedObjects() const
virtual void SetDataColumn(Int_t index, const Char_t *name, const Char_t *method="", Int_t mode=kTextCenterX)
virtual KVLVColumnData * GetDataColumn(Int_t index) const
Extended TList class which owns its objects by default.
void Sort(Bool_t order=kSortAscending)
Bool_t ReadGridsFromAsciiFile(const Char_t *) const
Nuclei reconstructed from data measured by a detector array .
void SetIdentification(KVIdentificationResult *, KVIDTelescope *)
virtual Float_t GetPID() const
virtual Int_t GetSize() const
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.
ABC for fitting ID grids with functionals.
static KVVirtualIDFitter * GetDefaultFitter()
void SetPad(TVirtualPad *p)
void SetGrid(KVIDGraph *g)
TMethod * GetMethodAny(const char *method)
virtual void AddAll(const TCollection *col)
virtual Int_t GetEntries() const
virtual Int_t GetSize() const
const char * GetVarX() const
const char * GetVarY() const
T * Get(const char *namecycle)
virtual const char * GetValue(const char *name, const char *dflt) const
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
const TGWindow * GetDefaultRoot() const
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
virtual TList * GetList() const
void MapSubwindows() override
void ChangeOptions(UInt_t options) override
virtual void DeleteWindow()
void UnmapWindow() override
virtual void SelectionChanged()
const char * GetString() const
const char * GetString() const
const TGString * GetText() const
virtual TGCompositeFrame * AddTab(const char *text)
TGCompositeFrame * GetCurrentContainer() const
TGTabElement * GetTabTab(const char *name) const
TGCompositeFrame * GetTabContainer(const char *name) const
Int_t GetNumberOfTabs() const
virtual void RemoveTab(Int_t tabIndex=-1, Bool_t storeRemoved=kTRUE)
virtual Bool_t SetTab(const char *name, Bool_t emit=kTRUE)
void Reset(Option_t *option="") override
void SetBinContent(Int_t bin, Double_t content) override
TObject * At(Int_t idx) const override
const char * GetName() const override
TClass * IsA() const override
virtual const char * ClassName() const
virtual Bool_t InheritsFrom(const char *classname) const
virtual void Info(const char *method, const char *msgfmt,...) const
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
virtual Double_t Uniform(Double_t x1, Double_t x2)
const char * Data() const
TString & Prepend(char c, Ssiz_t rep=1)
void Form(const char *fmt,...)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TString & ReplaceAll(const char *s1, const char *s2)
Bool_t cd(const char *path)
virtual const char * BaseName(const char *pathname)
virtual char * ExpandPathName(const char *path)
virtual Int_t Branch(const char *folder, Int_t bufsize=32000, Int_t splitlevel=99)
virtual void StartViewer()
Double_t Min(Double_t a, Double_t b)