KaliVeda
Toolkit for HIC analysis
KVIDGridEditor.cpp
1 //Created by KVClassFactory on Fri Feb 17 11:05:30 2012
2 //Author: dgruyer
3 
4 #include "KVIDGridEditor.h"
5 
6 #include "TObjString.h"
7 #include "TSpectrum.h"
8 #include "TStyle.h"
9 #include "TROOT.h"
10 #include <iostream>
11 #include <sstream>
12 
13 #include <KeySymbols.h>
14 #include <KVSpIdGUI.h>
15 #include <KVZAFinderDialog.h>
16 #include <KVEnv.h>
17 #include "KVTreeAnalyzer.h"
18 #include <KVHistogram.h>
19 #include "KVTestIDGridDialog.h"
20 #include "KVItvFinderDialog.h"
21 #include "TFrame.h"
22 #include "KVIDCutLine.h"
23 
24 using namespace std;
25 
27 
28 
29 KVIDGridEditor* gIDGridEditor = nullptr;
30 
31 
34 
36 {
37  // Default constructor
38  fSpiderOption = "DRLF";
39  gStyle->SetPalette(55);
40 
41  // Style
44  gStyle->SetPadTopMargin(0.1);
46  gStyle->SetPadTickX(1);
47  gStyle->SetPadTickY(1);
48  gStyle->SetNdivisions(310, "xyz");
49  gStyle->SetLabelSize(0.05, "xyz");
50  gStyle->SetTitleSize(0.05, "xyz");
51  gStyle->SetTitleOffset(1., "xzy");
52  gStyle->SetTitleFont(42, "xyz");
53  gStyle->SetLabelFont(42, "xyz");
54  gStyle->SetOptStat(0);
55  gStyle->SetOptTitle(0);
56  gROOT->ForceStyle();
57 
58  fPointStyle = 4;
59  fPointSize = 0.8;
60 
61  gIDGridEditor = this;
62 
63  SetName("gIDGridEditor");
64  SetDefault();
65 
66  fListOfMethods = "";
67  fDefaultMethod = "";
68 
69  AddMethod("AutoFit");
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");
86 
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);
90 
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);
93 
94  ListOfLines = new KVUnownedList;
95 
96  lplabel = new KVHashList();
97  lplabel->SetOwner(kTRUE);
98  lplabel2 = new KVHashList();
99  lplabel2->SetOwner(kTRUE);
100  lplabel3 = new KVHashList();
101  lplabel3->SetOwner(kTRUE);
102  lplabel4 = new KVHashList();
103  lplabel4->SetOwner(kTRUE);
104  lplabel5 = new KVHashList();
105  lplabel5->SetOwner(kTRUE);
106 
107  ResetScalingRecap();
108 
109 // MakeCustomMenuForLines();
110 
111 }
112 
113 
114 
117 
119 {
120  // Close();
121 
122  if (IsClosed()) {
123  fCanvas = new KVIDGridEditorCanvas(Form("%sCanvas", GetName()), Form("%sCanvas", GetName()), 800, 600);
124 // fCanvas->AddExec("transform", "gIDGridEditor->MakeTransformation()");
125 // fCanvas->AddExec("recommence", "gIDGridEditor->SelectLabel()");
126  // connect canvas' Closed() signal to method CanvasWasClosed().
127  // this way we always know if the canvas is closed by user closing the window
128  //fCanvas->Connect("Closed()", "KVIDGridEditor", this, "CanvasWasClosed()");
129  dynamic_cast<TGMainFrame*>(fCanvas->GetCanvasImp())->Connect("CloseWindow()", "KVIDGridEditor", this, "CanvasWasClosed()");
130  fPad = fCanvas->cd();
131 
132  if (!ready) init();
133  if (TheHisto) TheHisto->Draw("col");
134  if (TheGrid) {
135  TheGrid->Draw();
136  ResetGridColors();
137  }
138  DrawAtt(false);
139  }
140 }
141 
142 
143 
148 
150 {
151  // Slot connected to the 'Closed()' signal of the canvas.
152  // If the user closes the canvas window this method gets called.
153 
154  //Info("CanvasWasClosed","now");
155  fCanvas->Close();
156  delete fCanvas;
157  fCanvas = 0;
158  fPad = 0;
159 }
160 
161 
162 
164 
165 void KVIDGridEditor::SetDefault()
166 {
167  TheHisto = 0;
168  TheGrid = 0;
169  fPivot = 0;
170  fPiedestal = 0;
171  fPad = 0;
172  x0 = y0 = 0.;
173  fCanvas = 0;
174  fKeyShow = 0;
175 
176  fSpiderFactor = -1.;
177  fSpiderZp = -1;
178 
179  itrans = iact = iopt = 0;
180  imod = 20;
181 
182  ownhisto = false;
183  dlmode = false;
184  drawmode = false;
185  selectmode = false;
186  aoemode = false;
187  moved = false;
188  venermode = false;
189  fDebug = false;
190  ready = false;
191  is_col = false;
192 
193  fSVGMode = false;
194  fBlackMode = false;
195  fJoelMode = false;
196  fSVGIndex = 0;
197 
198  SelectedColor = kOrange + 1;
199 }
200 
201 
202 
204 
206 {
207  return (!fCanvas);
208 }
209 
210 
211 
213 
215 {
216  if (!IsClosed()) {
217  //fCanvas->Disconnect("Closed()", this, "CanvasWasClosed()");
218  dynamic_cast<TGMainFrame*>(fCanvas->GetCanvasImp())->Disconnect("CloseWindow()", "KVIDGridEditor", this, "CanvasWasClosed()");
219  fCanvas->Close();
220  delete fCanvas;
221  fCanvas = 0;
222  fPad = 0;
223  }
224  return;
225 }
226 
227 
228 
230 
232 {
233  TString option(opt);
234  option.ToUpper();
235 
236  dlmode = false;
237  drawmode = false;
238  selectmode = false;
239  moved = false;
240 
241  SelectedColor = kOrange + 1;
242 
243  ResetColor(ListOfLines);
244  ListOfLines->Clear();
245 
246  if (option.Contains("AL")) {
247  if ((TheHisto)) {
248  if (ownhisto) {
249  //TheHisto->Delete();
250  delete TheHisto;
251  ownhisto = false;
252  }
253  //TheHisto->Delete();
254  TheHisto = nullptr;
255  }
256  if (TheGrid) {
257  if (!IsClosed()) TheGrid->UnDraw();
258  TheGrid = 0;
259  }
260  fPad->Clear();
261  }
262 
263  SetPivot(0., 0.);
264 
265  DrawAtt(true);
266  UpdateViewer();
267 }
268 
269 
270 
272 
274 {
275  if (!IsClosed()) {
276  fPad->Modified();
277  fPad->Update();
278  if (fSVGMode) {
279  TString dir("$SVGDOC");
280  if (gSystem->ExpandPathName(dir)) dir = ".";
281  fCanvas->SaveAs(Form("%s/gIDGridEditorPrint-%d.png", dir.Data(), fSVGIndex));
282  // gROOT->ProcessLine(Form(".! import -window root %s/gIDGridEditorPrint-%d.png",dir.Data(),fSVGIndex));
283  if (!gSystem->AccessPathName(Form("%s/gIDGridEditorPrint-%d.png", dir.Data(), fSVGIndex))) fSVGIndex++;
284  }
285  }
286 }
287 
288 
289 
296 
298 {
299  // Copy constructor
300  // This ctor is used to make a copy of an existing object (for example
301  // when a method returns an object), and it is always a good idea to
302  // implement it.
303  // If your class allocates memory in its constructor(s) then it is ESSENTIAL :-)
304 
305  obj.Copy(*this);
306 }
307 
308 
309 
312 
314 {
315  // Destructor
316 
317  if (ownhisto) delete TheHisto;
318  if (fCanvas) delete fCanvas;
319  if (lplabel) {
320  lplabel->Delete("all");
321  delete lplabel;
322  }
323  if (lplabel2) {
324  lplabel2->Delete("all");
325  delete lplabel2;
326  }
327  if (lplabel3) {
328  lplabel3->Delete("all");
329  delete lplabel3;
330  }
331  if (lplabel4) {
332  lplabel4->Delete("all");
333  delete lplabel4;
334  }
335  if (lplabel5) {
336  lplabel5->Delete("all");
337  delete lplabel5;
338  }
339  if (gIDGridEditor == this) gIDGridEditor = 0x0;
340  dynamic_cast<TGMainFrame*>(fCanvas->GetCanvasImp())->Disconnect("CloseWindow()", "KVIDGridEditor", this, "CanvasWasClosed()");
341 
342 }
343 
344 
345 
353 
355 {
356  // This method copies the current state of 'this' object Int_to 'obj'
357  // You should add here any member variables, for example:
358  // (supposing a member variable KVIDGridEditor::fToto)
359  // CastedObj.fToto = fToto;
360  // or
361  // CastedObj.SetToto( GetToto() );
362 
363  KVBase::Copy(obj);
364  //KVIDGridEditor& CastedObj = (KVIDGridEditor&)obj;
365 }
366 
367 
368 
370 
371 void KVIDGridEditor::init()
372 {
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}");
380 
381  AddAction("#odot");
382  // AddAction("0");
383  AddAction("#Leftarrow");
384  AddAction("Lz");
385  AddAction("Ly");
386  AddAction("Lx");
387 
388  // AddGridOption("All",lplabel3);
389  AddGridOption("Select", lplabel3);
390 
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);
400 
401  ConstructModulator();
402 
403  gStyle->SetOptTitle(0);
404  gStyle->SetOptStat(0);
405  fCanvas->Clear();
406 
407  SetPivot(0., 0.);
408  SetPiedestal(0., 0.);
409  Clear("ALL");
410  ready = true;
411 
412  return;
413 }
414 
415 
416 
418 
419 void KVIDGridEditor::ConstructModulator()
420 {
421  Int_t i = 0;
422 
423  Double_t x1 = 0.92;
424  Double_t x2 = 0.99;
425 
426  Double_t y1 = 0.90 - i * 0.06;
427  Double_t y2 = y1 - 0.05;
428 
429  TPaveLabel* templabel = 0;
430 
431  templabel = new TPaveLabel(x1, y1, x2, y2, "+", "NDC");
432  templabel->SetTextSize(0.6);
433  templabel->SetName(templabel->GetTitle());
434  templabel->SetFillColor(kWhite);
435  templabel->SetBorderSize(1);
436  lplabel5->Add(templabel);
437 
438  i++;
439  y1 = 0.90 - i * 0.06;
440  y2 = y1 - 0.05;
441 
442  modulator = new TPaveLabel(x1, y1, x2, y2, Form("%d", imod), "NDC");
443  modulator->SetTextSize(0.6);
444  modulator->SetName(templabel->GetTitle());
445  modulator->SetBorderSize(1);
446  modulator->SetFillColor(kGreen);
447  lplabel5->Add(modulator);
448 
449  i++;
450  y1 = 0.90 - i * 0.06;
451  y2 = y1 - 0.05;
452 
453  templabel = new TPaveLabel(x1, y1, x2, y2, "-", "NDC");
454  templabel->SetName(templabel->GetTitle());
455  templabel->SetTextSize(0.6);
456  templabel->SetFillColor(kWhite);
457  templabel->SetBorderSize(1);
458  lplabel5->Add(templabel);
459 
460  lplabel5->Execute("SetTextSize", "0.625");
461 }
462 
463 
464 
466 
467 void KVIDGridEditor::AddTransformation(TString label)
468 {
469  Double_t y1 = 0.92;
470  Double_t y2 = 0.99;
471 
472  Double_t x1 = 0.10 + itrans * 0.06;
473  Double_t x2 = x1 + 0.05;
474 
475  TPaveLabel* templabel = 0;
476 
477  templabel = new TPaveLabel(x1, y1, x2, y2, label.Data(), "NDC");
478  templabel->SetTextSize(0.6);
479  templabel->SetFillColor(kWhite);
480  templabel->SetBorderSize(1);
481  templabel->SetName(templabel->GetTitle());
482  lplabel->Add(templabel);
483 
484  itrans++;
485  return;
486 }
487 
488 
489 
491 
492 void KVIDGridEditor::AddAction(TString label)
493 {
494  Double_t y1 = 0.92;
495  Double_t y2 = 0.99;
496 
497  Double_t x2 = 0.90 - iact * 0.06;
498  Double_t x1 = x2 - 0.05;
499 
500  TPaveLabel* templabel = 0;
501 
502  templabel = new TPaveLabel(x1, y1, x2, y2, label.Data(), "NDC");
503  templabel->SetTextSize(0.6);
504  templabel->SetFillColor(kWhite);
505  templabel->SetBorderSize(1);
506  templabel->SetName(templabel->GetTitle());
507  lplabel2->Add(templabel);
508 
509  iact++;
510  return;
511 }
512 
513 
514 
516 
517 void KVIDGridEditor::AddGridOption(TString label, KVHashList* thelist)
518 {
519  Double_t x1 = 0.92;
520  Double_t x2 = 0.99;
521 
522  Double_t y1 = 0.10 + iopt * 0.06;
523  Double_t y2 = y1 + 0.05;
524 
525  TPaveLabel* templabel = 0;
526 
527  templabel = new TPaveLabel(x1, y1, x2, y2, label.Data(), "NDC");
528  templabel->SetTextSize(0.6);
529  templabel->SetFillColor(kWhite);
530  templabel->SetBorderSize(1);
531  templabel->SetName(templabel->GetTitle());
532  thelist->Add(templabel);
533 
534  iopt++;
535  return;
536 }
537 
538 
539 
543 
544 void KVIDGridEditor::RecurseFileStructureFindHistos(TString& hist_names, TDirectory* the_directory)
545 {
546  // Recursively scan folders in a file looking for all TH2-derived objects.
547  // Their names are added to the TString.
548 
549  if (!the_directory) return;
550  TIter next_key(the_directory->GetListOfKeys());
551  TKey* key;
552  while ((key = (TKey*)next_key())) {
553  if (key->IsFolder()) {
554  RecurseFileStructureFindHistos(hist_names, the_directory->GetDirectory(key->GetName()));
555  }
556  else {
557  TString key_class = key->GetClassName();
558  if (key_class.Contains("TH2")) hist_names += Form(" %s", key->GetName());
559  }
560  }
561 }
562 
563 
564 
572 
573 TString KVIDGridEditor::ListOfHistogramInMemory()
574 {
575  // Fill a TString with the names of all histograms in
576  // - ROOT memory (gROOT)
577  // - all open files
578  // - all canvases
579  // - any instance of KVTreeAnalyzer
580  // The list is sorted lexographically
581 
582  KVString HistosNames = "";
583  KVList histos;
584 
585  // histos in memory
586  TIter nextmem(gROOT->GetList());
587  TObject* obj;
588  while ((obj = nextmem())) {
589  //if (obj->InheritsFrom("TH2")) HistosNames += Form(" %s", obj->GetName());
590  if (obj->InheritsFrom("TH2")) histos.Add(new TObjString(obj->GetName()));
591  }
592 
593  // histos in files
594  TFile* f;
595  TIter next(gROOT->GetListOfFiles());
596  while ((f = (TFile*)next())) {
597  // beware KV database file!!!
598  if (TString(gSystem->BaseName(f->GetName())).Contains("DataBase.root")) continue;
599  // beware KVSQLROOTFile file!!!
600  if (!strcmp(gSystem->BaseName(f->GetName()), "objStore.root")) continue;
601  RecurseFileStructureFindHistos(HistosNames, f);
602  }
603  HistosNames.Begin(" ");
604  while (!HistosNames.End()) {
605  KVString g = HistosNames.Next();
606  if (g != "gIDGridEditorDefaultHistogram") histos.Add(new TObjString(g.Data()));
607  }
608  HistosNames = "";
609 
610  // histos in canvases
611  TIter nextc(gROOT->GetListOfCanvases());
612  TCanvas* canv = 0;
613  while ((canv = (TCanvas*)nextc())) {
614  //printf("%s\n",canv->GetName());
615  if (strcmp(canv->GetName(), "gIDGridEditorCanvas")) {
616  TIter next_step1(canv->GetListOfPrimitives());
617  TObject* obj1 = 0;
618  while ((obj1 = next_step1())) {
619  //printf("%s\n",obj1->GetName());
620  if (obj1->InheritsFrom("TPad")) {
621  TObject* obj2 = 0;
622  TIter next_step2(((TPad*)obj1)->GetListOfPrimitives());
623  while ((obj2 = next_step2())) {
624  printf("%s\n", obj2->GetName());
625  if (obj2->InheritsFrom("TH2")) {
626  //HistosNames += Form(" %s", obj2->GetName());
627  histos.Add(new TObjString(obj2->GetName()));
628  }
629  }
630  }
631  else if (obj1->InheritsFrom("TH2")) {
632  //HistosNames += Form(" %s", ((TH2*)obj1)->GetName());
633  histos.Add(new TObjString(obj1->GetName()));
634  }
635  }
636  }
637  }
638 
639  // KVTreeAnalyzer
640  if (gTreeAnalyzer) {
641  // Get all 2-D histograms from current KVTreeAnalyzer instance
642  TIter nexthist(gTreeAnalyzer->GetHistoList());
643  KVHistogram* obj = 0;
644  while ((obj = (KVHistogram*)nexthist())) {
645  if (obj->IsType("Histo") && obj->GetHisto()->InheritsFrom("TH2")) {
646  //HistosNames += Form(" %s", obj->GetName());
647  histos.Add(new TObjString(obj->GetName()));
648  }
649  }
650  }
651  //if (HistosNames.Contains("gIDGridEditorDefaultHistogram")) HistosNames.ReplaceAll("gIDGridEditorDefaultHistogram", "");
652  TObjString* s = (TObjString*)histos.FindObject("gIDGridEditorDefaultHistogram");
653  if (s) {
654  histos.Remove(s);
655  delete s;
656  }
657  // sort list of histograms by name
658  histos.Sort();
659  TIter ith(&histos);
660  while ((s = (TObjString*)ith())) {
661  HistosNames += Form(" %s", s->GetString().Data());
662  }
663 
664  return HistosNames;
665 }
666 
667 
668 
672 
673 TString KVIDGridEditor::PreselectHistogram(TString ListOfName, Int_t)
674 {
675  // Look in list of histogram names for one containing the name of
676  // the current grid. If found, return it.
677 
678  if (!TheGrid) return "";
679  TString result = "";
680  TString Iter;
681 
682  KVString str(ListOfName.Data());
683  str.Begin(" ");
684  while (!str.End()) {
685  Iter = str.Next(kTRUE);
686  if (Iter.EqualTo(TheGrid->GetName())) {
687  result = Iter.Data();
688  return result;
689  }
690  }
691 
692  str.Begin(" ");
693  while (!str.End()) {
694  Iter = str.Next(kTRUE);
695  if (Iter.Contains(TheGrid->GetName())) {
696  result = Iter.Data();
697  return result;
698  }
699  }
700 
701  return result;
702 }
703 
704 
705 
707 
709 {
710 
711  if (!hh) {
712  KVString Listo = ListOfHistogramInMemory();
713  TString Select = PreselectHistogram(Listo);
714 
715  TString Choices;
716  TString Default;
717  Choices = "Dummy ";
718  if (TheHisto) {
719  Default = "Current";
720  Choices += "Current ";
721  }
722  else Default = "Dummy";
723 
724  if (Listo == "") {
725  }
726  else if (Select == "") {
727  Choices += Listo;
728  }
729  else {
730  Default = Select;
731  Choices += Select.Data();
732  Choices += " ";
733  //Choices += Listo.ReplaceAll(Select.Data(), "");
734  Listo.Begin(" ");//in case list contains a histo with a similar name to Select
735  // if Select="SI_CSI_0801" and the list contains "SI_CSI_0801_GG"
736  while (!Listo.End()) {
737  KVString s = Listo.Next();
738  if (s != Select) Choices += Form("%s ", s.Data());
739  }
740  }
741 
742  TString Answer;
743  Bool_t okpressed;
744 
745  if (Choices.Contains(" ")) {
746  new KVDropDownDialog(gClient->GetDefaultRoot(), "Choose a histogram :", Choices.Data(), Default.Data(), &Answer, &okpressed);
747  if (!okpressed) {
748  Answer = "Current";
749  return;
750  }
751  }
752  else Answer = Default;
753 
754  if (!Answer.Contains("Current") && ownhisto) {
755  delete TheHisto;
756  TheHisto = nullptr;
757  ownhisto = false;
758  }
759 
760  if ((!Answer.Contains("Current")) && (!Answer.Contains("Dummy"))) {
761  TheHistoChoice = 0;
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";
769  }
770 
771  if (Answer.Contains("Dummy")) {
772  TString hname = Form("%sDefaultHistogram", GetName());
773  Double_t Xmax = 4096.;
774  Double_t Ymax = 4096;
775  if (TheGrid) {
776  TheGrid->Initialize();
777  // pour pouvoir utiliser un pointeur KVIDGraph* au lieu de KVIDZAGrid*
778  // Xmax = TheGrid->GetZmaxLine()->GetXaxis()->GetXmax();
779  // Ymax = TheGrid->GetZmaxLine()->GetYaxis()->GetXmax();
780  TheGrid->FindAxisLimits();
781  Xmax = TheGrid->GetXmax();
782  Ymax = TheGrid->GetYmax();
783  }
784  TH2* TmpH = 0;
785  if ((TmpH = (TH2*)gROOT->FindObject(hname.Data()))) delete TmpH;
786  TheHisto = new TH2F(hname.Data(), hname.Data(), 2048, 0, Xmax, 2048, 0, Ymax);
787  ownhisto = true;
788  }
789  }
790  else if (!hh->InheritsFrom("TH2")) {
791  cout << "ERROR: KVIDGridEditor::SetHisto(): '" << hh->GetName() << "' must be a 2D histogram !" << endl;
792  return;
793  }
794  else {
795  if ((ownhisto) && (TheHisto)) {
796  delete TheHisto;
797  TheHisto = 0;
798  }
799  TheHisto = hh;
800  ownhisto = false;
801  }
802 
803  if (!IsClosed() && (TheHisto)) {
804  fPad = fCanvas->cd();//au cas ou il y a plusieurs canvas ouverts
805  // set axes range of histo to grid size
806  if (TheGrid) {
807  TheGrid->FindAxisLimits();
808  TheHisto->GetXaxis()->SetRangeUser(TheGrid->GetXmin(), TheGrid->GetXmax());
809  TheHisto->GetYaxis()->SetRangeUser(TheGrid->GetYmin(), TheGrid->GetYmax());
810  }
811  TheHisto->Draw("col");
812  fPad->SetLogz(true);
813  TheHisto->SetMinimum(1);
814  }
815  DrawAtt(true);
816  return;
817 
818 }
819 
820 
821 
823 
824 TH2* KVIDGridEditor::FindInCanvases(const Char_t* histoname)
825 {
826 
827  TIter nextc(gROOT->GetListOfCanvases());
828  TCanvas* cc = 0;
829  TObject* obj = 0;
830  while ((cc = (TCanvas*)nextc())) {
831  if (strcmp(cc->GetName(), "gIDGridEditorCanvas")) {
832  if ((obj = cc->FindObject(histoname))) {
833  return (TH2*)obj;
834  }
835  }
836  }
837  return 0;
838 
839 }
840 
841 
842 
844 
845 void KVIDGridEditor::DrawAtt(Bool_t piv)
846 {
847  if ((!ready) || IsClosed()) return;
848 
849  lplabel->Execute("Draw", "");
850  lplabel2->Execute("Draw", "");
851  lplabel3->Execute("Draw", "");
852  lplabel4->Execute("Draw", "");
853  lplabel5->Execute("Draw", "");
854 
855  if (!piv) SetPivot(0., 0.);
856  else fPivot->Draw("P");
857 
858  if (!piv) SetPiedestal(0., 0.);
859  else fPivot->Draw("P");
860 
861 
862  UpdateViewer();
863  return;
864 }
865 
866 
867 
869 
871 {
872  if (!gg) {
873  cout << "ERROR: KVIDGridEditor::SetHisto(): invalid pointer on the grid !" << endl;
874  return;
875  }
876  if ((TheGrid && TheGrid->TestBit(TObject::kNotDeleted)) && (!IsClosed())) TheGrid->UnDraw();
877 
878  Clear();
879 
880  TheGrid = gg;
881  if (histo) SetHisto(0);
882  if (!IsClosed()) {
883  TheGrid->Draw();
884  ResetGridColors();
885  }
886 
887  fSpiderFactor = -1.;
888  fSpiderZp = -1;
889 
890  // DrawAtt(true);
891 
892  UpdateViewer();
893 
895 
896  return;
897 }
898 
899 
900 
902 
904 {
905  Bool_t sethisto = true;
906 
907  if (!strcmp(GridName.Data(), "")) {
908  TString Answer;
909  Bool_t proposename = false;
910  if (TheGrid) Answer = TheGrid->GetName();
911  else if (TheHisto) {
912  Answer = TheHisto->GetName();
913  proposename = true;
914  }
915  Bool_t okpressed;
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;
920  }
921 
922  KVIDGraph* tempgrid = 0;
923  if (!gIDGridManager) return;
924  if (!(tempgrid = (KVIDGraph*)gIDGridManager->GetGrids()->FindObject(GridName.Data()))) {
925  cout << "WARNING: KVIDGridEditor::SetGrid(): Unknown grid named '" << GridName.Data() << "' !" << endl;
926  return;
927  }
928  else SetGrid(tempgrid, sethisto);
929  return;
930 }
931 
932 
933 
935 
936 void KVIDGridEditor::SetPivot(Double_t xx0, Double_t yy0)
937 {
938 
939  if (!fPivot) {
940  fPivot = new TGraph;
941  fPivot->SetMarkerStyle(2);
942  fPivot->SetMarkerSize(2);
943  fPivot->SetMarkerColor(kRed);
944  fPivot->SetName("ThePivot");
945  }
946  else fPivot->SetPoint(0, xx0, yy0);
947 }
948 
949 
950 
953 
954 void KVIDGridEditor::SetPiedestal(Double_t ppdx, Double_t ppdy)
955 {
956  // piedestal used during SpiderIdentification
957  if (!fPivot) {
958  // fPiedestal = new TGraph;
959  fPivot->SetMarkerStyle(2);
960  fPivot->SetMarkerSize(2);
961  fPivot->SetMarkerColor(kBlack);
962  fPivot->SetName("ThePiedestal");
963  }
964  else fPivot->SetPoint(1, ppdx, ppdy);
965 }
966 
967 
968 
970 
972 {
973  Int_t event = fPad->GetEvent();
974  if (event == kMouseMotion) return;
975  TObject* select = fPad->GetSelected();
976 
977  if (!select) return;
978  if (!select->InheritsFrom("TPaveLabel")) return;
979 
980  if (fSVGMode && ((event == kButton1Down) || (event == kButton1Double) || (event == kButton1Shift))) {
981  TString tmpStr;
982  if (event == kButton1Down) tmpStr = "click";
983  else if (event == kButton1Double) tmpStr = "double click";
984  else if (event == kButton1Shift) tmpStr = "shift click";
985 
986  Int_t px = fPad->AbsPixeltoX(fPad->GetEventX());
987  Int_t py = fPad->AbsPixeltoY(fPad->GetEventY());
988 
989  TLatex* mouse = new TLatex(px, py, tmpStr.Data());
990 
991  if (mouse->GetX() >= 0.5) mouse->SetTextAlign(32);
992  else mouse->SetTextAlign(12);
993 
994  mouse->Draw();
995  UpdateViewer();
996  delete mouse;
997  mouse = 0;
998  }
999 
1000  TPaveLabel* label = (TPaveLabel*)select;
1001  if (event == kButton1Down) {
1002  Int_t color = label->GetFillColor();
1003  if (lplabel->Contains(label)) {
1004  lplabel->Execute("SetFillColor", fBlackMode ? "kBlack" : "kWhite");
1005  if (color == kWhite || color == kBlack) label->SetFillColor(kRed);
1006  else if (color == kRed) label->SetFillColor(fBlackMode ? kBlack : kWhite);
1007  UpdateViewer();
1008  }
1009  else if (lplabel2->Contains(label)) {
1010  label->SetFillColor(kRed);
1011  UpdateViewer();
1012  DispatchOrder(label);
1013  }
1014  else if (lplabel4->Contains(label)) {
1015  DispatchOrder(label);
1016  }
1017  else if (lplabel3->Contains(label)) {
1018  lplabel3->Execute("SetFillColor", fBlackMode ? "kBlack" : "kWhite");
1019  if (color == kWhite || color == kBlack) label->SetFillColor(kGreen);
1020  if (color == kGreen) label->SetFillColor(fBlackMode ? kBlack : kWhite);
1021  // SelectLines(label);
1022  SelectLines("Select");
1023  UpdateViewer();
1024  }
1025  else if (lplabel5->Contains(label) && (label != modulator)) {
1026  label->SetFillColor(kGreen);
1027  ChangeStep(label->GetTitle());
1028  UpdateViewer();
1029  }
1030  }
1031  else if (event == kButton1Up) {
1032  if (lplabel2->Contains(label)) {
1033  label->SetFillColor(fBlackMode ? kBlack : kWhite);
1034  UpdateViewer();
1035  }
1036  else if (lplabel5->Contains(label) && (label != modulator)) {
1037  label->SetFillColor(fBlackMode ? kBlack : kWhite);
1038  UpdateViewer();
1039  }
1040  }
1041  else if (event == kButton1Double) {
1042  if (lplabel5->Contains(label) && (label != modulator)) {
1043  label->SetFillColor(kGreen);
1044  ChangeStep(label->GetTitle(), 9);
1045  UpdateViewer();
1046  }
1047  }
1048  else if (event == kButton1Shift) {
1049  if (lplabel5->Contains(label) && (label != modulator)) {
1050  label->SetFillColor(kGreen);
1051  ChangeStep(label->GetTitle(), 100);
1052  UpdateViewer();
1053  }
1054  else if (lplabel3->Contains(label)) {
1055  lplabel3->Execute("SetFillColor", "kGreen");
1056  // if(color==kWhite) label->SetFillColor(kGreen);
1057  // if(color==kGreen) label->SetFillColor(kWhite);
1058  // SelectLines(label);
1059  SelectLines("All");
1060  UpdateViewer();
1061  }
1062  }
1063 }
1064 
1065 
1066 
1068 
1070 {
1071  Int_t event = fPad->GetEvent();
1072  TObject* select = fPad->GetSelected();
1073  auto realX = fPad->AbsPixeltoX(fPad->GetEventX());
1074  auto realY = fPad->AbsPixeltoY(fPad->GetEventY());
1075  // true for e.g. mouse clicks which occur inside the TFrame where the grid is displayed
1076  auto inside_frame = fPad->GetFrame()->IsInside(realX,realY);
1077 
1078  if (fSVGMode && ((event == kButton1Down) || (event == kButton1Double) || (event == kButton1Shift) || (event == kWheelUp) || (event == kWheelDown))) {
1079  TString tmpStr;
1080  if (event == kButton1Down) tmpStr = "click";
1081  else if (event == kButton1Double) tmpStr = "double click";
1082  else if (event == kButton1Shift) tmpStr = "shift click";
1083  else if (event == kWheelUp) tmpStr = "wheel up";
1084  else if (event == kWheelDown) tmpStr = "wheel down";
1085 
1086  Int_t px = fPad->AbsPixeltoX(fPad->GetEventX());
1087  Int_t py = fPad->AbsPixeltoY(fPad->GetEventY());
1088 
1089  TLatex* mouse = new TLatex(px, py, tmpStr.Data());
1090 
1091  if (mouse->GetX() >= 0.5) mouse->SetTextAlign(32);
1092  else mouse->SetTextAlign(12);
1093 
1094  mouse->Draw();
1095  UpdateViewer();
1096  delete mouse;
1097  mouse = 0;
1098  UpdateViewer();
1099  }
1100 
1101  if (((event == kMouseMotion) || (event == kButton1Motion)) && (TheHisto)) {
1102  if (!(aoemode)) return;
1103 
1104  Double_t size = 0.4 - 0.35 * venermode;
1105 
1106  Int_t dX = 0;
1107  Int_t dY = 0;
1108 
1109  Int_t px = fPad->GetEventX();
1110  Int_t py = fPad->GetEventY();
1111 
1112  Double_t ppx = fPad->AbsPixeltoX(px);
1113  Double_t ppy = fPad->AbsPixeltoY(py);
1114 
1115  TAxis* ax = TheHisto->GetXaxis();
1116  Int_t X0 = ax->GetFirst();
1117  Int_t X1 = ax->GetLast();
1118  Int_t NbinsX = ax->GetNbins();
1119  px = ax->FindBin(ppx);
1120 
1121  Double_t ddX = (X1 + X0) * 0.5 - px;
1122  Double_t distX = TMath::Abs(ddX) / (X1 - X0);
1123  if (distX >= 0.5) return;
1124 
1125  TAxis* ay = TheHisto->GetYaxis();
1126  Int_t Y0 = ay->GetFirst();
1127  Int_t Y1 = ay->GetLast();
1128  Int_t NbinsY = ay->GetNbins();
1129  py = ay->FindBin(ppy);
1130 
1131  Double_t ddY = (Y1 + Y0) * 0.5 - py;
1132  Double_t distY = TMath::Abs(ddY) / (Y1 - Y0);
1133  if (distY >= 0.5) return;
1134 
1135  if ((distX <= size) && (distY <= size)) return;
1136 
1137  dX = TMath::Nint(ddX * (0.05 + 0.05 * venermode));
1138  dY = TMath::Nint(ddY * (0.05 + 0.05 * venermode));
1139 
1140  if (TMath::Abs(dX) < 1) dX = TMath::Sign(1., ddX);
1141  if (TMath::Abs(dY) < 1) dY = TMath::Sign(1., ddY);
1142 
1143  Bool_t up = false;
1144 
1145  if ((X0 - dX > 0) && (X1 - dX < NbinsX)) {
1146  ax->SetRange(X0 - dX, X1 - dX);
1147  up = true;
1148  }
1149  if ((Y0 - dY > 0) && (Y1 - dY < NbinsY)) {
1150  ay->SetRange(Y0 - dY, Y1 - dY);
1151  up = true;
1152  }
1153 
1154  if (up) UpdateViewer();
1155  }
1156 
1157  if (!select) {}
1158  else {
1159  if (select->InheritsFrom("TPaveLabel")) return;
1160  }
1161 
1162  if ((event == kButton1Up) && (dlmode) && (select) && inside_frame) {// lines can only be deleted if we click on them inside the frame,
1163  // not by accident when clicking on a TPaveLabel outside the frame
1164 
1165  if (select->InheritsFrom("KVIDentifier")) DeleteObject((KVIDentifier*)select);
1166 
1167  }
1168  if ((event == kButton1Up) && (select) && (!dlmode) && inside_frame) {// lines can only be (un)selected if we click on them inside the frame,
1169  // not by accident when clicking on a TPaveLabel outside the frame
1170  if (select->InheritsFrom("KVIDentifier")) {
1171  KVIDentifier* line = (KVIDentifier*)select;
1172  if (selectmode) {
1173  if (!ListOfLines->Contains(line)) {
1174  line->SetLineColor(SelectedColor);
1175  ListOfLines->AddLast(line);
1176  UpdateViewer();
1177  }
1178  else {
1179  ListOfLines->Remove(line);
1180  ResetColor(line);
1181  UpdateViewer();
1182  }
1183  }
1184  else if (ListOfLines->Contains(line)) {
1185  ListOfLines->Remove(line);
1186  ResetColor(line);
1187  SelectLines("Select");
1188  UpdateViewer();
1189  }
1190  }
1191  }
1192 
1193  if ((event == kButton1Shift) && (select) && (!dlmode) && inside_frame) {
1194  if (!select->InheritsFrom("KVIDZALine") || ListOfLines->IsEmpty());
1195  else {
1196  KVIDZALine* line = (KVIDZALine*)select;
1197  if (ListOfLines->Contains(select)) return;
1198  Int_t LastZ = ((KVIDZALine*)ListOfLines->At(ListOfLines->GetSize() - 1))->GetZ();
1199  Int_t SeleZ = line->GetZ();
1200  Int_t LastA = ((KVIDZALine*)ListOfLines->At(ListOfLines->GetSize() - 1))->GetA();
1201  Int_t SeleA = line->GetA();
1202  Int_t zmin, zmax, amin, amax;
1203  if (LastZ == SeleZ) {
1204  zmin = LastZ;
1205  zmax = LastZ;
1206  amin = TMath::Min(LastA, SeleA);
1207  amax = TMath::Max(LastA, SeleA);
1208  }
1209  else if (LastZ < SeleZ) {
1210  zmin = LastZ;
1211  amin = LastA;
1212  zmax = SeleZ;
1213  amax = SeleA;
1214  }
1215  else {
1216  zmax = LastZ;
1217  amax = LastA;
1218  zmin = SeleZ;
1219  amin = SeleA;
1220  }
1221 
1222 
1223  for (int Z = zmin; Z <= zmax; Z++) {
1224  KVList* tmpl = (KVList*)TheGrid->GetIdentifiers()->GetSubListWithMethod(Form("%d", Z), "GetZ");
1225  TIter it(tmpl);
1226  line = 0;
1227  while ((line = (KVIDZALine*)it())) {
1228  if (ListOfLines->Contains(line)) continue;
1229  if (zmax == zmin) {
1230  if ((line->GetA() > amin) && (line->GetA() < amax)) {
1231  line->SetLineColor(SelectedColor);
1232  ListOfLines->AddLast(line);
1233  }
1234  continue;
1235  }
1236  if ((line->GetZ() == zmin) && (line->GetA() > amin)) {
1237  line->SetLineColor(SelectedColor);
1238  ListOfLines->AddLast(line);
1239  continue;
1240  }
1241  if ((line->GetZ() == zmax) && (line->GetA() < amax)) {
1242  line->SetLineColor(SelectedColor);
1243  ListOfLines->AddLast(line);
1244  continue;
1245  }
1246  if ((line->GetZ() != zmax) && (line->GetZ() != zmin)) {
1247  line->SetLineColor(SelectedColor);
1248  ListOfLines->AddLast(line);
1249  continue;
1250  }
1251  }
1252  delete tmpl;
1253  }
1254  }
1255  }
1256  if (event == kButton1Double) {
1257  if (drawmode) drawmode = false;
1258  else if (!select->InheritsFrom("KVIDentifier")) {
1259  Int_t xx = fPad->GetEventX();
1260  Int_t yy = fPad->GetEventY();
1261 
1262  x0 = fPad->AbsPixeltoX(xx);
1263  y0 = fPad->AbsPixeltoY(yy);
1264 
1265  SetPivot(x0, y0);
1266  fPivot->Draw("P");
1267  UpdateViewer();
1268  }
1269  }
1270  if ((event == kButton1Shift) && (!drawmode)) {
1271  if (!select->InheritsFrom("KVIDentifier")) {
1272  Int_t xx = fPad->GetEventX();
1273  Int_t yy = fPad->GetEventY();
1274 
1275  x0 = fPad->AbsPixeltoX(xx);
1276  y0 = fPad->AbsPixeltoY(yy);
1277 
1278  SetPiedestal(x0, y0);
1279  fPivot->Draw("P");
1280  UpdateViewer();
1281  }
1282  }
1283  if ((event == kWheelUp) || (event == kWheelDown)) {
1284  Int_t sign = (event == kWheelUp ? 1 : -1);
1285  const char* who = WhoIsSelected();
1286 
1287  if (ListOfLines->IsEmpty()) DynamicZoom(sign, fPad->GetEventX(), fPad->GetEventY());
1288  else if (!strcmp(who, "")) DynamicZoom(sign, fPad->GetEventX(), fPad->GetEventY());
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);
1296  }
1297 
1298  //if(event==kButton2Up) ForceUpdate();
1299  if ((event == kESC) && (TheHisto)) Unzoom();
1300 
1301  return;
1302 }
1303 
1304 
1305 
1307 
1308 void KVIDGridEditor::ZoomSelected()
1309 {
1310  if (!TheHisto) return;
1311  TAxis* ax = TheHisto->GetXaxis();
1312 
1313  Double_t ratio1 = (xmin - fPad->GetUxmin()) / (fPad->GetUxmax() - fPad->GetUxmin());
1314  Double_t ratio2 = (xmax - fPad->GetUxmin()) / (fPad->GetUxmax() - fPad->GetUxmin());
1315 
1316  if ((ratio2 - ratio1 > 0.05)) {
1317  ax->SetRangeUser(xmin, xmax);
1318  }
1319 
1320  ax = TheHisto->GetYaxis();
1321 
1322  ratio1 = (ymin - fPad->GetUymin()) / (fPad->GetUymax() - fPad->GetUymin());
1323  ratio2 = (ymax - fPad->GetUymin()) / (fPad->GetUymax() - fPad->GetUymin());
1324 
1325  if ((ratio2 - ratio1 > 0.05)) {
1326  ax->SetRangeUser(ymin, ymax);
1327  }
1328 
1329  xmax = xmin = ymax = ymin = 0.;
1330  return;
1331 }
1332 
1333 
1334 
1336 
1337 void KVIDGridEditor::DispatchOrder(TPaveLabel* label)
1338 {
1339  TString commande(label->GetName());
1340 
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")) {
1351  label->SetFillColor(kRed);
1352  UpdateViewer();
1353  FitGrid();
1354  label->SetFillColor(fBlackMode ? kBlack : kWhite);
1355  UpdateViewer();
1356  }
1357  else if (commande.Contains("Test")) {
1358  label->SetFillColor(kRed);
1359  UpdateViewer();
1360  TestGrid();
1361  label->SetFillColor(fBlackMode ? kBlack : kWhite);
1362  UpdateViewer();
1363  }
1364  else if (commande.Contains("Mass")) {
1365  label->SetFillColor(kRed);
1366  UpdateViewer();
1367  FindZALines();
1368  label->SetFillColor(fBlackMode ? kBlack : kWhite);
1369  UpdateViewer();
1370  }
1371  else if (commande.Contains("Info")) {
1372  label->SetFillColor(kRed);
1373  NewInfo();
1374 // UpdateViewer();
1375 // SpiderIdentification();
1376 // label->SetFillColor(fBlackMode ? kBlack : kWhite);
1377 // UpdateViewer();
1378  }
1379  else if (commande.Contains("More")) {
1380  label->SetFillColor(kRed);
1381  UpdateViewer();
1382  SuggestMoreAction();
1383  label->SetFillColor(fBlackMode ? kBlack : kWhite);
1384  UpdateViewer();
1385  }
1386  else if (commande.Contains("Delete")) {
1387  if (!TheGrid) return;
1388  Int_t color = label->GetFillColor();
1389  if (color == kRed) {
1390  label->SetFillColor(fBlackMode ? kBlack : kWhite);
1391  dlmode = false;
1392  UpdateViewer();
1393  }
1394  else if (color == kWhite || color == kBlack) {
1395  label->SetFillColor(kRed);
1396  dlmode = true;
1397  UpdateViewer();
1398  }
1399  }
1400  else cout << "WARNING: KVIDGridEditor::DispatchOrder(): unknown order '" << commande << "' !" << endl;
1401 }
1402 
1403 
1404 
1406 
1407 void KVIDGridEditor::SetEditable(TPaveLabel* label)
1408 {
1409  if (TheGrid) {
1410  Bool_t iseditable = TheGrid->IsEditable();
1411  TheGrid->SetEditable(!iseditable);
1412  if (iseditable) label->SetFillColor(fBlackMode ? kBlack : kWhite);
1413  else label->SetFillColor(kRed);
1414  }
1415  else label->SetFillColor(fBlackMode ? kBlack : kWhite);
1416  UpdateViewer();
1417  return;
1418 }
1419 
1420 
1421 //void KVIDGridEditor::SelectLines(TPaveLabel* label)
1422 
1424 
1425 void KVIDGridEditor::SelectLines(const Char_t* label)
1426 {
1427  if (!TheGrid) return;
1428  // TString title(label->GetTitle());
1429  TString title(label);
1430  Int_t color = ((TPaveLabel*)lplabel3->At(0))->GetFillColor();
1431 
1432  if (title.Contains("All")) {
1433  // if(color==kWhite)
1434  // {
1435  // ResetColor(ListOfLines);
1436  // ListOfLines->Clear();
1437  // }
1438  // else if(color==kGreen)
1439  // {
1440  ListOfLines->AddAll(TheGrid->GetIdentifiers());
1441  ListOfLines->AddAll(TheGrid->GetCuts());
1442  ListOfLines->AddAll(TheGrid->GetInfos());
1443  ListOfLines->R__FOR_EACH(KVIDentifier, SetLineColor)(SelectedColor);
1444  ListOfLines->R__FOR_EACH(KVIDentifier, SetMarkerColor)(SelectedColor);
1445  // }
1446  selectmode = false;
1447  }
1448  if (title.Contains("Select")) {
1449  if (color == kWhite || color == kBlack) {
1450  selectmode = false;
1451  ResetColor(ListOfLines);
1452  ListOfLines->Clear();
1453  }
1454  if (color == kGreen) {
1455  ListOfLines->R__FOR_EACH(KVIDentifier, SetLineColor)(SelectedColor);
1456  selectmode = true;
1457  }
1458  }
1459  UpdateViewer();
1460  return;
1461 }
1462 
1463 
1464 
1466 
1467 void KVIDGridEditor::NewLine()
1468 {
1469  if (!TheGrid) return;
1470  TPaveLabel* label = (TPaveLabel*)lplabel4->FindObject("Line");
1471  label->SetFillColor(kRed);
1472  UpdateViewer();
1473 
1474  drawmode = true;
1475 
1476  TString resname;
1477  resname.Form("%s.IDClass", TheGrid->ClassName());
1478  TString cut_choices = gEnv->GetValue(resname.Data(), "");
1479  resname.Form("%s.DefaultIDClass", TheGrid->ClassName());
1480  TString cut_default = gEnv->GetValue(resname.Data(), "");
1481  TString cut_class;
1482  Bool_t okpressed;
1483 
1484  if (cut_choices.Contains(" ")) {
1485  new KVDropDownDialog(gClient->GetDefaultRoot(),
1486  "Choose class of new identifier :",
1487  cut_choices.Data(),
1488  cut_default.Data(),
1489  &cut_class,
1490  &okpressed);
1491  if (!okpressed) return;
1492  }
1493  else cut_class = cut_choices;
1494 
1495  TheGrid->DrawAndAdd("ID", cut_class.Data());
1496 
1497  label->SetFillColor(fBlackMode ? kBlack : kWhite);
1498  if (fBlackMode) ResetGridColors();
1499 
1500  UpdateViewer();
1501  if (fDebug) cout << "INFO: KVIDGridEditor::NewLine(): New Line has been added to the current grid..." << endl;
1502  return;
1503 }
1504 
1505 
1506 void KVIDGridEditor::NewCut()
1507 
1508 
1509 
1511 {
1512  if (!TheGrid) return;
1513  TPaveLabel* label = (TPaveLabel*)lplabel4->FindObject("Cut");
1514  label->SetFillColor(kRed);
1515  UpdateViewer();
1516 
1517  drawmode = true;
1518 
1519  TString resname;
1520  resname.Form("%s.CutClass", TheGrid->ClassName());
1521  TString cut_choices = gEnv->GetValue(resname.Data(), "");
1522  resname.Form("%s.DefaultCutClass", TheGrid->ClassName());
1523  TString cut_default = gEnv->GetValue(resname.Data(), "");
1524  cut_default.ReplaceAll(" ", "");
1525  cut_default.ReplaceAll("KVID", "");
1526  TString cut_class;
1527  KVString cut_types = cut_choices;
1528  cut_types.ReplaceAll("KVID", "");
1529  Bool_t okpressed;
1530 
1531  if (cut_choices.Contains(" ")) {
1532  if (!strcmp(cut_default, "")) {
1533  cut_types.Begin(" ");
1534  cut_default = cut_types.Next();
1535  }
1536  new KVDropDownDialog(gClient->GetDefaultRoot(),
1537  "Choose class of new cut :",
1538  cut_types.Data(),
1539  cut_default.Data(),
1540  &cut_class,
1541  &okpressed);
1542  if (!okpressed) {
1543  label->SetFillColor(kWhite);
1544  UpdateViewer();
1545  drawmode = false;
1546  return;
1547  }
1548  }
1549  else cut_class = cut_types;
1550 
1551  cut_class.Prepend("KVID");
1552  if (!cut_class.Contains("ZoneContour")) TheGrid->DrawAndAdd("CUT", cut_class.Data());
1553  else TheGrid->DrawAndAdd("ID", cut_class.Data());
1554 
1555  label->SetFillColor(fBlackMode ? kBlack : kWhite);
1556  UpdateViewer();
1557 
1558  if (fDebug) cout << "INFO: KVIDGridEditor::NewCut(): New Cut has been added to the current grid..." << endl;
1559  return;
1560 }
1561 
1562 
1563 
1565 
1566 void KVIDGridEditor::NewInfo()
1567 {
1568 
1569  if (!TheGrid) return;
1570  TPaveLabel* label = (TPaveLabel*)lplabel4->FindObject("Info");
1571  label->SetFillColor(kRed);
1572  UpdateViewer();
1573 
1574  drawmode = true;
1575 
1576  TString info_choices = gEnv->GetValue(Form("%s.InfoClass", TheGrid->ClassName()), "");
1577  if (info_choices == "") info_choices = gEnv->GetValue(Form("%s.InfoClass", "KVIDGraph"), "");
1578 
1579  TString info_default = gEnv->GetValue(Form("%s.DefaultInfoClass", TheGrid->ClassName()), "");
1580  if (info_choices == "") info_choices = gEnv->GetValue(Form("%s.DefaultInfoClass", "KVIDGraph"), "");
1581 
1582  info_default.ReplaceAll(" ", "");
1583  info_default.ReplaceAll("KVID", "");
1584  TString info_class;
1585  KVString info_types = info_choices;
1586  info_types.ReplaceAll("KVID", "");
1587  Bool_t okpressed;
1588 
1589  if (info_choices.Contains(" ")) {
1590  if (!strcmp(info_default, "")) {
1591  info_types.Begin(" ");
1592  info_default = info_types.Next();
1593  }
1594  new KVDropDownDialog(gClient->GetDefaultRoot(),
1595  "Choose class of new info :",
1596  info_types.Data(),
1597  info_default.Data(),
1598  &info_class,
1599  &okpressed);
1600  if (!okpressed) {
1601  label->SetFillColor(kWhite);
1602  UpdateViewer();
1603  drawmode = false;
1604  return;
1605  }
1606  }
1607  else info_class = info_types;
1608 
1609  info_class.Prepend("KVID");
1610  TheGrid->DrawAndAdd("INFO", info_class.Data());
1611 
1612  Info("NewInfo", "Adding new info contour or line of class '%s'", info_class.Data());
1613 
1614  label->SetFillColor(fBlackMode ? kBlack : kWhite);
1615  UpdateViewer();
1616 
1617  if (fDebug) cout << "INFO: KVIDGridEditor::NewInfo(): New info has been added to the current grid..." << endl;
1618  return;
1619 }
1620 
1621 
1622 
1624 
1625 Double_t KVIDGridEditor::GetX0()
1626 {
1627  return fPivot->GetX()[0];
1628 }
1629 
1630 
1631 
1633 
1634 Double_t KVIDGridEditor::GetY0()
1635 {
1636  return fPivot->GetY()[0];
1637 
1638 }
1639 
1640 
1641 
1643 
1644 Double_t KVIDGridEditor::GetPdx()
1645 {
1646  return fPivot->GetX()[1];
1647 
1648 }
1649 
1650 
1651 
1653 
1654 Double_t KVIDGridEditor::GetPdy()
1655 {
1656  return fPivot->GetY()[1];
1657 
1658 }
1659 
1660 
1661 
1663 
1665 {
1666  if (!TheGrid) return;
1667  if (!TheHisto) return;
1668 
1669  x0 = GetX0();
1670  y0 = GetY0();
1671 
1672  Double_t pdx = GetPdx();
1673  Double_t pdy = GetPdy();
1674 
1675  // TheGrid->UnDraw();
1676  // TheGrid->Clear();
1677 
1678  new KVSpIdGUI(TheGrid, TheHisto, x0, y0, pdx, pdy, fSpiderOption.Data());
1679 
1680  // fSpiderFactor = Factor;
1681  // fSpiderZp = Zp;
1682  //
1683  // if(TheGrid->GetIdentifiers()->GetSize()!=0)
1684  // {
1685  //
1686  // Int_t ret_val;
1687  // new TGMsgBox(gClient->GetDefaultRoot(), gClient->GetDefaultRoot(), "ID Grid Editor",
1688  // "This will delete all existing lines. Are you sure ?",
1689  // kMBIconExclamation, kMBOk | kMBCancel, &ret_val);
1690  //
1691  // if (ret_val & kMBOk)
1692  // {
1693  // TheGrid->Clear();
1694  // }
1695  // else return;
1696  // }
1697  //
1698  // double ScaleFactorX = TheHisto->GetNbinsX()*1./(TheHisto->GetXaxis()->GetXmax());
1699  // double ScaleFactorY = TheHisto->GetNbinsY()*1/(TheHisto->GetYaxis()->GetXmax());
1700  //
1701  // Double_t factor = fSpiderFactor;
1702  // if(fSpiderZp>0)
1703  // {
1704  // factor = TMath::Sqrt(x0*x0*(ScaleFactorX*ScaleFactorX)+y0*y0*(ScaleFactorY*ScaleFactorY))/(20.*fSpiderZp*12.);
1705  // fSpiderFactor = factor;
1706  // }
1707  //
1708  // if(fDebug) cout << "DEBUG: KVIDGridEditor::SpiderIdentification(): " << fSpiderZp << " " << fSpiderFactor << endl;
1709  // fSpiderZp = -1;
1710  //
1711  // // SetPivot(0.,0.);
1712  // Unzoom();
1713  // UpdateViewer();
1714  //
1715  // KVHistoManipulator hm;
1716  // TF1 RtLt("RtLt",Form("x*%lf",ScaleFactorX),0,TheHisto->GetXaxis()->GetXmax());
1717  // TF1 RtLty("RtLty",Form("x*%lf",ScaleFactorY),0,TheHisto->GetXaxis()->GetXmax());
1718  // TH2F* hh = (TH2F*)hm.ScaleHisto(TheHisto,&RtLt,&RtLty);
1719  //
1720  // KVSpiderIdentificator* tata = 0;
1721  // tata = new KVSpiderIdentificator(hh, x0*ScaleFactorX, y0*ScaleFactorY);
1722  //
1723  // if((tata->GetX0()>100)||(tata->GetY0()>100))
1724  // {
1725  // tata->SetX0(0.);
1726  // tata->SetY0(0.);
1727  // }
1728  //
1729  // if(pdx>=0.) tata->SetX0(pdx*ScaleFactorX);
1730  // if(pdy>=0.) tata->SetY0(pdy*ScaleFactorY);
1731  //
1732  // tata->SetParameters(factor);
1733  // // tata->UseFit(useFit);
1734  // tata->ProcessIdentification();
1735  //
1736  // if(debug) tata->Draw("DRLF");
1737  //
1738  // TList* ll = (TList*)tata->GetListOfLines();
1739  //
1740  // KVIDZALine* TheLine = 0;
1741  // int zmax = 0;
1742  //
1743  // KVSpiderLine* spline = 0;
1744  // TIter next_line(ll);
1745  // while((spline = (KVSpiderLine*)next_line()))
1746  // {
1747  // if((spline->GetN()>10))//&&(spline->GetX(0)<=tata->GetX0()+200.))
1748  // {
1749  // TF1* ff1 = 0;
1750  // if(type==kSiCsI) ff1 =
1751  // spline->GetFunction(tata->GetX0()*0.01,TMath::Max(hh->GetXaxis()->GetXmax()*0.95,spline->GetX(spline->GetN()-1)));
1752  // if(type==kSiSi) ff1 = spline->GetFunction(tata->GetX0()*0.01,TMath::Min(hh->GetXaxis()->GetXmax()*0.99,spline->GetX(spline->GetN()-1)*1.5));
1753  // else ff1 = spline->GetFunction();
1754  // if((type==kSiCsI)&&(ff1->GetParameter(1)>=3000.||(ff1->GetParameter(2)<=0.35)||(ff1->GetParameter(2)>=1.)))
1755  // {
1756  // Info("SpiderIdentification","Z = %d has been rejected (fit parameters)",spline->GetZ());
1757  // continue;
1758  // }
1759  // TheLine = (KVIDZALine*)((KVIDZAGrid*)TheGrid)->NewLine("ID");
1760  // TheLine->SetZ(spline->GetZ());
1761  // double min,max;
1762  // ff1->GetRange(min,max);
1763  // double step = 20.;
1764  // double stepmax = 800.;
1765  // double x = 0.;
1766  // for(x=min+1; x<max+0.0001*step; x+=step)
1767  // {
1768  // if(step<=stepmax) step*=1.3;
1769  // if(ff1->Eval(x)<4000) TheLine->SetPoint(TheLine->GetN(),x,ff1->Eval(x));
1770  // }
1771  // if(max>x)TheLine->SetPoint(TheLine->GetN(),max,ff1->Eval(max));
1772  //
1773  // TheGrid->Add("ID",TheLine);
1774  // if(spline->GetZ()>=zmax) zmax = spline->GetZ();
1775  // }
1776  // else
1777  // {
1778  // Info("SpiderIdentification","Z = %d has been rejected (too few points)",spline->GetZ());
1779  // }
1780  // }
1781  //
1782  // if(fDebug)Info("SpiderIdentification","last line generated : Z = %d.",zmax);
1783  //
1784  // TF1 fx("fx12",Form("x/%lf",ScaleFactorX),0.,hh->GetNbinsX()*1.);
1785  // TF1 fy("fy12",Form("x/%lf",ScaleFactorY),0.,hh->GetNbinsY()*1.);
1786  // TheGrid->Scale(&fx,&fy);
1787  //
1788  // // SetPivot(tata->GetX0(),tata->GetY0());
1789  //
1790  // if(!debug) delete tata;
1791  // if(!debug) delete hh;
1792 
1793  // fPad->cd();
1794  // TheGrid->UnDraw();
1795  // TheGrid->Draw();
1796 
1797  // UpdateViewer();
1798  // cout << "toto " << endl;
1799 
1800  return;
1801 }
1802 
1803 
1804 
1806 
1807 void KVIDGridEditor::TestGrid()
1808 {
1809  if (!TheGrid) return;
1810  if (!TheHisto) return;
1811 
1812  new KVTestIDGridDialog(gClient->GetDefaultRoot(), gClient->GetDefaultRoot(), 10, 10, TheGrid, TheHisto);
1813 
1814  if (fDebug) cout << "INFO: KVIDGridEditor::TestGrid(): testing the current grid..." << endl;
1815 }
1816 
1817 
1818 
1820 
1821 void KVIDGridEditor::FitGrid()
1822 {
1823  if (!TheGrid) return;
1824 
1826  fitter->SetGrid(TheGrid);
1827  fitter->SetPad(TheGrid->GetPad());
1828  TMethod* m = fitter->IsA()->GetMethodAny("FitPanel");
1829  TContextMenu* cm = new TContextMenu("FitPanel", "Context menu for KVVirtualIDFitter::FitPanel");
1830  cm->Action(fitter, m);
1831  delete cm;
1832 
1833  if (fDebug) cout << "INFO: KVIDGridEditor::FitGrid(): fitting grid '" << TheGrid->GetName() << "'..." << endl;
1834 }
1835 
1836 
1837 
1839 
1840 void KVIDGridEditor::SuggestMoreAction()
1841 {
1842  if (fListOfMethods.EndsWith(" ")) fListOfMethods.Remove(fListOfMethods.Sizeof() - 2);
1843 
1844  TString Default = fDefaultMethod.Data();
1845  TString Choices = fListOfMethods.Data();
1846 
1847  TString Answer;
1848  Bool_t okpressed;
1849  new KVDropDownDialog(gClient->GetDefaultRoot(), "Choose an action :", Choices.Data(), Default.Data(), &Answer, &okpressed);
1850  if (!okpressed) return;
1851 
1852  TMethod* m = 0;
1853  if (!TheGrid) return;
1854  else if ((m = TheGrid->IsA()->GetMethodAllAny(Answer.Data()))) {
1855  TContextMenu* cm = new TContextMenu(Answer.Data(), Form("Context menu for KVIDGridEditor::%s", Answer.Data()));
1856  cm->Action(TheGrid, m);
1857  delete cm;
1858  }
1859  else if ((m = IsA()->GetMethodAllAny(Answer.Data()))) {
1860  TContextMenu* cm = new TContextMenu(Answer.Data(), Form("Context menu for KVIDGridEditor::%s", Answer.Data()));
1861  cm->Action(this, m);
1862  delete cm;
1863  }
1864  else cout << "INFO: KVIDGridEditor::SuggestMoreAction(): '" << Answer << "' not implemented..." << endl;
1865 
1866 }
1867 
1868 
1869 
1870 
1872 
1874 {
1875  if (!TheGrid) return;
1876  if (!ListOfLines) return;
1877 
1878  ResetColor(ListOfLines);
1879  ListOfLines->Clear();
1880 
1881  Int_t found;
1882  KVNumberList ZL(ListOfZ);
1883  ZL.Begin();
1884  while (!ZL.End()) {
1885  Int_t Z = ZL.Next();
1886  KVIDZALine* line = ((KVIDZAGrid*)TheGrid)->GetZLine(Z, found);
1887  if ((found == -1) || (!line)) continue;
1888  if (!ListOfLines->Contains(line)) {
1889  line->SetLineColor(SelectedColor);
1890  ListOfLines->AddLast(line);
1891  }
1892  }
1893  return;
1894 }
1895 
1896 
1897 
1898 
1900 
1902 {
1903  if (!TheGrid) return;
1904 
1905  TString currentdir(gSystem->ExpandPathName("."));
1906 
1907  TString fn = TheHisto->GetName();
1908  fn += ".dat";
1909 
1910  Int_t ret_code;
1911  new TGMsgBox(
1912  gClient->GetRoot(),
1913  gClient->GetDefaultRoot(),
1914  "KVIDGridEditor::SaveCurrentGrid", Form("Do you wat to save the grid here : %s", fn.Data()),
1915  kMBIconExclamation, kMBYes | kMBNo, &ret_code
1916  );
1917 
1918  if (ret_code == kMBYes) {
1919  TheGrid->WriteAsciiFile(Form("%s", fn.Data()));
1920  return;
1921  }
1922 
1923  static TString dir(gSystem->ExpandPathName("."));
1924  const char* filetypes[] = {
1925  "ID Grid files", "*.dat",
1926  "All files", "*",
1927  0, 0
1928  };
1929  TGFileInfo fi;
1930  fi.fFileTypes = filetypes;
1931  fi.fIniDir = StrDup(dir);
1932  // fi.fFilename = Form("%s.dat",TheGrid->GetName());
1933  new TGFileDialog(gClient->GetDefaultRoot(), gClient->GetDefaultRoot(), kFDSave, &fi);
1934  if (fi.fFilename) {
1935  //if no ".xxx" ending given, we add ".dat"
1936  TString filenam(fi.fFilename);
1937  if (filenam.Contains("toto")) filenam.ReplaceAll("toto", TheHisto->GetName());
1938  if (!filenam.Contains('.')) filenam += ".dat";
1939  TheGrid->WriteAsciiFile(filenam.Data());
1940  }
1941  dir = fi.fIniDir;
1942  gSystem->cd(currentdir.Data());
1943 }
1944 
1945 
1946 
1948 
1950 {
1951  TheGrid->UpdateLastSavedVersion();
1952  int nbin = 2;
1953  int threshold = 10;
1954  TSpectrum spec;
1955  KVIDentifier* id = 0;
1956  TIter it(ListOfLines);
1957  while ((id = (KVIDentifier*)it())) {
1958  KVIDentifier* ref = TheGrid->GetIdentifier(id->GetZ(), id->GetA() + 1);
1959  if (!ref) ref = TheGrid->GetIdentifier(id->GetZ(), id->GetA() - 1);
1960  for (int ii = 0; ii < id->GetN(); ii++) {
1961  double xx = id->GetX()[ii];
1962  double yy = id->GetY()[ii];
1963  double dyref = .5;
1964  if (ref) dyref = abs(yy - ref->Eval(xx)) / 2;
1965  int xbin = TheHisto->GetXaxis()->FindBin(xx);
1966  TH1* hh = TheHisto->ProjectionY("toto", xbin - nbin, xbin + nbin, "goff");
1967  if (dyref > 0) hh->GetXaxis()->SetRangeUser(yy - dyref * 2, yy + dyref * 2);
1968  int nfound = spec.Search(hh, dyref, "goff", 0.05);
1969  Double_t* xpeaks = spec.GetPositionX();
1970  Double_t* ypeaks = spec.GetPositionY();
1971  TList markers;
1972  markers.SetOwner(kTRUE);
1973  double dy = 1e20;
1974  double ygood = -1.;
1975  for (int ip = 0; ip < nfound; ip++) {
1977  TheGrid->Identify(xx, xpeaks[ip], &idr);
1978 
1979  if (ypeaks[ip] > threshold && (idr.Z == id->GetZ() && idr.A == id->GetA())) {}
1980  else continue;
1981 
1982  if (abs(xpeaks[ip] - yy) < dy) {
1983  dy = abs(xpeaks[ip] - yy);
1984  ygood = xpeaks[ip];
1985  }
1986  }
1987  if (ygood > 0) id->GetY()[ii] = ygood;
1988  delete hh;
1989  }
1990  }
1991 }
1992 
1993 
1994 
1996 
1997 void KVIDGridEditor::OpenRootFile()
1998 {
1999  static TString dir("$(HISTOROOT)");
2000  TString currentdir(gSystem->ExpandPathName("."));
2001 
2002  if (dir == "$(HISTOROOT)" && gSystem->Getenv("HISTOROOT")) {
2003  if (gSystem->ExpandPathName(dir)) dir = ".";
2004  }
2005  else
2006  dir = ".";
2007 
2008  const char* filetypes[] = {"Root files", "*.root", "All files", "*", 0, 0};
2009  TGFileInfo fi;
2010  fi.fFileTypes = filetypes;
2011  fi.fIniDir = StrDup(dir);
2012  new TGFileDialog(gClient->GetDefaultRoot(), gClient->GetDefaultRoot(), kFDOpen, &fi);
2013  if (fi.fFilename) {
2014  if (!(TFile::Open(fi.fFilename))) {
2015  new TGMsgBox(gClient->GetDefaultRoot(), gClient->GetDefaultRoot(), "ID Grid Editor", Form("Could not open file %s", fi.fFilename), 0, kMBOk);
2016  }
2017  }
2018  dir = fi.fIniDir;
2019  gSystem->cd(currentdir.Data());
2020 }
2021 
2022 
2023 
2025 
2026 void KVIDGridEditor::ChooseSelectedColor()
2027 {
2028  TString Default = "kOrange";
2029  TString Choices = Default;
2030  Choices += " ";
2031  Choices += "kBlack kGreen kBlue kRed kYellow kCyan kMagenta";
2032 
2033  TString Answer;
2034  Bool_t okpressed;
2035  new KVDropDownDialog(gClient->GetDefaultRoot(), "Choose an action :", Choices.Data(), Default.Data(), &Answer, &okpressed);
2036  if (!okpressed) return;
2037 
2038  if (!strcmp(Answer.Data(), "kOrange")) SetSelectedColor(kOrange + 1);
2039  else if (!strcmp(Answer.Data(), "kGreen")) SetSelectedColor(kGreen);
2040  else if (!strcmp(Answer.Data(), "kBlack")) SetSelectedColor(kBlack);
2041  else if (!strcmp(Answer.Data(), "kBlue")) SetSelectedColor(kBlue);
2042  else if (!strcmp(Answer.Data(), "kRed")) SetSelectedColor(kRed);
2043  else if (!strcmp(Answer.Data(), "kYellow")) SetSelectedColor(kYellow);
2044  else if (!strcmp(Answer.Data(), "kCyan")) SetSelectedColor(kCyan);
2045  else if (!strcmp(Answer.Data(), "kMagenta")) SetSelectedColor(kMagenta);
2046 
2047  return;
2048 }
2049 
2050 
2051 
2053 
2054 void KVIDGridEditor::DeleteObject(KVIDentifier* obj)
2055 {
2056  if (!TheGrid) return;
2057  if (TheGrid->GetCuts()->Contains(obj)) {
2058  if (ListOfLines->Contains(obj)) ListOfLines->Remove(obj);
2059  TheGrid->RemoveCut(obj);
2060  }
2061  else if (TheGrid->GetIdentifiers()->Contains(obj)) {
2062  if (ListOfLines->Contains(obj)) ListOfLines->Remove(obj);
2063  TheGrid->RemoveIdentifier(obj);
2064  }
2065  else if (TheGrid->GetInfos()->Contains(obj)) {
2066  if (ListOfLines->Contains(obj)) ListOfLines->Remove(obj);
2067  TheGrid->RemoveInfo(obj);
2068 
2069  }
2070 }
2071 
2072 
2073 
2075 
2076 void KVIDGridEditor::ChangeStep(const char* title, Int_t dstep)
2077 {
2078  TString commande(title);
2079  if (commande.Contains("+")) {
2080  imod += dstep;
2081  }
2082  else if (commande.Contains("-")) {
2083  imod -= dstep;
2084  if (imod <= 0)imod = 1;
2085  }
2086  modulator->SetLabel(Form("%d", imod));
2087  UpdateViewer();
2088  return;
2089 }
2090 
2091 
2092 
2094 
2095 void KVIDGridEditor::SetLogz()
2096 {
2097  if (fCanvas->IsLogz()) fPad->SetLogz(0);
2098  else fPad->SetLogz(1);
2099 }
2100 
2101 
2102 
2104 
2105 void KVIDGridEditor::SetLogy()
2106 {
2107  if (fCanvas->IsLogy()) fPad->SetLogy(0);
2108  else fPad->SetLogy(1);
2109 }
2110 
2111 
2112 
2114 
2115 void KVIDGridEditor::SetLogx()
2116 {
2117  if (fCanvas->IsLogx()) fPad->SetLogx(0);
2118  else fPad->SetLogx(1);
2119 }
2120 
2121 
2122 
2124 
2125 void KVIDGridEditor::Unzoom()
2126 {
2127  if (TheHisto) {
2128  TheHisto->GetXaxis()->UnZoom();
2129  TheHisto->GetYaxis()->UnZoom();
2130  }
2131 }
2132 
2133 
2134 
2139 
2140 void KVIDGridEditor::Undo()
2141 {
2142  // Revert current grid to its last saved version
2143  // Normally this will be the state of the grid before starting
2144  // the current editing session
2145 
2146  if (!TheGrid) return;
2147 
2148  TString username = gSystem->GetUserInfo()->fRealName;
2149  username.ReplaceAll(",", "");
2150  Int_t ret_val;
2151  new TGMsgBox(gClient->GetDefaultRoot(), gClient->GetDefaultRoot(), "ID Grid Editor",
2152  Form("This will undo all changes to the grid. Are you sure, %s?", username.Data()),
2153  kMBIconExclamation, kMBOk | kMBCancel, &ret_val);
2154 
2155  if (ret_val & kMBOk) {
2156  if (ListOfLines && ListOfLines->GetEntries()) {
2157  Clear();
2158  }
2159  TheGrid->RevertToLastSavedVersion();
2160  TheGrid->Modified();
2161  }
2162  TPaveLabel* tmplabel = (TPaveLabel*)lplabel2->FindObject("#Leftarrow");
2163  tmplabel->SetFillColor(kWhite);
2164  UpdateViewer();
2165 }
2166 
2167 
2168 
2170 
2171 const char* KVIDGridEditor::WhoIsSelected()
2172 {
2173  TPaveLabel* label = 0;
2174  TIter nextlabel(lplabel);
2175  while ((label = (TPaveLabel*)nextlabel())) {
2176  if (label->GetFillColor() == kRed) return label->GetName();
2177  }
2178  return "";
2179 }
2180 
2181 
2182 
2184 
2185 void KVIDGridEditor::TranslateX(Int_t Sign)
2186 {
2187  if (!TheGrid) return;
2188  if (!ListOfLines) return;
2189  if (ListOfLines->IsEmpty()) return;
2190 
2191  Double_t step = TheHisto->GetXaxis()->GetBinWidth(1) * (imod) * 0.02;
2192  Double_t factor = Sign * step;
2193 
2194  ft->SetParameter(0, factor);
2195  ListOfLines->R__FOR_EACH(KVIDentifier, Scale)(ft, 0);
2196 
2197  TheGrid->Modified();
2198 
2199  UpdateViewer();
2200  if (fDebug) cout << "INFO: KVIDGridEditor::TranslateX(): translation on the X axis (" << (Sign > 0 ? "+" : "-") << step << ") !" << endl;
2201  return;
2202 }
2203 
2204 
2205 
2207 
2208 void KVIDGridEditor::TranslateY(Int_t Sign)
2209 {
2210  if (!TheGrid) return;
2211  if (!ListOfLines) return;
2212  if (ListOfLines->IsEmpty()) return;
2213 
2214  Double_t step = TheHisto->GetXaxis()->GetBinWidth(1) * (imod) * 0.02;
2215  Double_t factor = Sign * step;
2216 
2217  ft->SetParameter(0, factor);
2218  ListOfLines->R__FOR_EACH(KVIDentifier, Scale)(0, ft);
2219 
2220  TheGrid->Modified();
2221 
2222  UpdateViewer();
2223  if (fDebug) cout << "INFO: KVIDGridEditor::TranslateY(): translation on the Y axis (" << (Sign > 0 ? "+" : "-") << step << ") !" << endl;
2224  return;
2225 }
2226 
2227 
2228 
2231 
2232 void KVIDGridEditor::DynamicZoom(Int_t Sign, Int_t px, Int_t py, Double_t speed)
2233 {
2234  // Zoom in or out of histogram with mouse wheel
2235 
2236  if (!TheHisto) return;
2237 
2238  Double_t percent = TMath::Abs(0.15 * speed - Sign * 0.05);
2239 
2240  Int_t dX = 0;
2241  Int_t dY = 0;
2242 
2243  if (px == 0) px = (TheHisto->GetXaxis()->GetFirst() + TheHisto->GetXaxis()->GetLast()) / 2;
2244  else px = fPad->AbsPixeltoX(px);
2245 
2246  if (py == 0) py = (TheHisto->GetYaxis()->GetFirst() + TheHisto->GetYaxis()->GetLast()) / 2;
2247  else py = fPad->AbsPixeltoY(py);
2248 
2249  TAxis* ax = TheHisto->GetXaxis();
2250  Int_t NbinsX = ax->GetNbins();
2251  Int_t X0 = ax->GetFirst();
2252  Int_t X1 = ax->GetLast();
2253  Int_t step = TMath::Min(TMath::Max(1, (Int_t)(percent * (X1 - X0))), NbinsX / 2);
2254  step *= Sign;
2255  X0 = TMath::Min(TMath::Max(X0 + step, 1), X1 - step);
2256  X1 = TMath::Max(TMath::Min(X1 - step, NbinsX), X0);
2257  if (X0 >= X1) X0 = X1 - 1;
2258  if (Sign > 0) dX = (Int_t)(X0 + (X1 - X0) * 0.5 - ax->FindBin(px));
2259  if ((X0 - dX) < 0) ax->SetRange(0, X1 - X0);
2260  else if ((X1 - dX) > ax->GetNbins()) ax->SetRange(ax->GetNbins() - (X1 - X0), ax->GetNbins());
2261  else ax->SetRange(X0 - dX, X1 - dX);
2262 
2263  ax = TheHisto->GetYaxis();
2264  Int_t NbinsY = ax->GetNbins();
2265  Int_t Y0 = ax->GetFirst();
2266  Int_t Y1 = ax->GetLast();
2267  step = TMath::Min(TMath::Max(1, (Int_t)(percent * (Y1 - Y0))), NbinsY / 2);
2268  step *= Sign;
2269  Y0 = TMath::Min(TMath::Max(Y0 + step, 1), Y1 - step);
2270  Y1 = TMath::Max(TMath::Min(Y1 - step, NbinsY), Y0);
2271  if (Y0 >= Y1) Y0 = Y1 - 1;
2272  if (Sign > 0) dY = (Int_t)(Y0 + (Y1 - Y0) * 0.5 - ax->FindBin(py));
2273  if ((Y0 - dY) < 0) ax->SetRange(0, Y1 - Y0);
2274  else if ((Y1 - dY) > ax->GetNbins()) ax->SetRange(ax->GetNbins() - (Y1 - Y0), ax->GetNbins());
2275  else ax->SetRange(Y0 - dY, Y1 - dY);
2276 
2277  UpdateViewer();
2278  return;
2279 }
2280 
2281 
2282 
2284 
2285 void KVIDGridEditor::RotateZ(Int_t Sign)
2286 {
2287  if (!TheGrid) return;
2288  if (!ListOfLines) return;
2289  if (ListOfLines->IsEmpty()) return;
2290 
2291  Double_t step = 1.*(imod / 100.);
2292  if (step >= 45.) step = 45.;
2293  Double_t theta = Sign * step * TMath::DegToRad();
2294 
2295  x0 = fPivot->GetX()[0];
2296  y0 = fPivot->GetY()[0];
2297 
2298  frx->SetParameters(x0, y0, theta);
2299  fry->SetParameters(x0, y0, theta);
2300 
2301  ListOfLines->R__FOR_EACH(KVIDentifier, Scale)(frx, fry);
2302 
2303  UpdateViewer();
2304  if (fDebug) cout << "INFO: KVIDGridEditor::RotateZ(): rotation around the Z axis (" << (Sign > 0 ? "+" : "-") << step << ") !" << endl;
2305  return;
2306 }
2307 
2308 
2309 
2310 //void KVIDGridEditor::MakeScaleX(Double_t scaleFactor)
2311 //{
2312 // if (!TheGrid) return;
2313 // if (!ListOfLines) return;
2314 // if (ListOfLines->IsEmpty()) return;
2315 
2316 // x0 = fPivot->GetX()[0];
2317 
2318 // fs->SetParameters(x0, scaleFactor);
2319 // ListOfLines->R__FOR_EACH(KVIDentifier, Scale)(fs, 0);
2320 
2321 // UpdateViewer();
2322 
2323 // fAx *= scaleFactor;
2324 // fBx = fs->Eval(fBx);
2325 
2326 // return;
2327 //}
2328 
2329 
2330 //void KVIDGridEditor::MakeScaleY(Double_t scaleFactor)
2331 //{
2332 // if (!TheGrid) return;
2333 // if (!ListOfLines) return;
2334 // if (ListOfLines->IsEmpty()) return;
2335 
2336 // y0 = fPivot->GetY()[0];
2337 
2338 // fs->SetParameters(y0, scaleFactor);
2339 // ListOfLines->R__FOR_EACH(KVIDentifier, Scale)(0, fs);
2340 
2341 // UpdateViewer();
2342 
2343 // fAy *= scaleFactor;
2344 // fBy = fs->Eval(fBy);
2345 
2346 // return;
2347 //}
2348 
2349 
2350 
2352 
2353 void KVIDGridEditor::ScaleX(Int_t Sign)
2354 {
2355  if (!TheGrid) return;
2356  if (!ListOfLines) return;
2357  if (ListOfLines->IsEmpty()) return;
2358 
2359  Double_t step = 0.05 * (imod / 100.);
2360  Double_t factor = 1. + Sign * step;
2361  //MakeScaleX(factor);
2362 
2363  x0 = fPivot->GetX()[0];
2364 
2365  fs->SetParameters(x0, factor);
2366  ListOfLines->R__FOR_EACH(KVIDentifier, Scale)(fs, 0);
2367 
2368  TheGrid->Modified();
2369 
2370  UpdateViewer();
2371 
2372  fAx *= factor;
2373  fBx = fs->Eval(fBx);
2374 
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);
2381 
2382  return;
2383 }
2384 
2385 
2386 
2388 
2389 void KVIDGridEditor::ScaleY(Int_t Sign)
2390 {
2391  if (!TheGrid) return;
2392  if (!ListOfLines) return;
2393  if (ListOfLines->IsEmpty()) return;
2394 
2395  Double_t step = 0.05 * (imod / 100.);
2396  Double_t factor = 1. + Sign * step;
2397  //MakeScaleY(factor);
2398 
2399  y0 = fPivot->GetY()[0];
2400 
2401  fs->SetParameters(y0, factor);
2402  ListOfLines->R__FOR_EACH(KVIDentifier, Scale)(0, fs);
2403 
2404  TheGrid->Modified();
2405 
2406  UpdateViewer();
2407 
2408  fAy *= factor;
2409  fBy = fs->Eval(fBy);
2410 
2411  if (fDebug) Info("ScaleY", "scaling on the Y axis (*%f) !", factor);
2412 
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);
2418 
2419  return;
2420 }
2421 
2422 
2423 
2425 
2426 void KVIDGridEditor::ScaleXY(Int_t Sign)
2427 {
2428  if (!TheGrid) return;
2429  if (!ListOfLines) return;
2430  if (ListOfLines->IsEmpty()) return;
2431 
2432  Double_t step = 0.05 * (imod / 100.);
2433  Double_t factor = 1. + Sign * step;
2434 
2435  x0 = fPivot->GetX()[0];
2436  y0 = fPivot->GetY()[0];
2437 
2438  fs->SetParameters(x0, factor);
2439  fsy->SetParameters(y0, factor);
2440 
2441  ListOfLines->R__FOR_EACH(KVIDentifier, Scale)(fs, fsy);
2442 
2443  TheGrid->Modified();
2444 
2445  UpdateViewer();
2446 
2447  fAx *= factor;
2448  fBx = fs->Eval(fBx);
2449  fAy *= factor;
2450  fBy = fsy->Eval(fBy);
2451 
2452  if (fDebug) Info("ScaleXY", "scaling (*%f) !", factor);
2453  return;
2454 }
2455 
2456 
2457 
2459 
2460 void KVIDGridEditor::ScaleCurvature(Int_t Sign)
2461 {
2462  if (!TheGrid) return;
2463  if (!ListOfLines) return;
2464  if (ListOfLines->IsEmpty()) return;
2465 
2466  Double_t step = 0.05 * (imod / 100.);
2467  Double_t factor = 1. + Sign * step;
2468 
2469  KVIDentifier* idd = 0;
2470  TIter nextidd(ListOfLines);
2471 
2472  while ((idd = (KVIDentifier*)nextidd())) {
2473  Double_t x1 = idd->GetX()[0];
2474  Double_t x2 = idd->GetX()[idd->GetN() - 1];
2475  Double_t y1 = idd->GetY()[0];
2476  Double_t y2 = idd->GetY()[idd->GetN() - 1];
2477 
2478  Double_t a = (y2 - y1) / (x2 - x1);
2479  // Double_t b = y1 - a*x1;
2480  Double_t theta = TMath::ATan(a);
2481 
2482  frx->SetParameters(x1, y1, -theta);
2483  fry->SetParameters(x1, y1, -theta);
2484  idd->Scale(frx, fry);
2485 
2486  fs->SetParameters(y1, factor);
2487  idd->Scale(0, fs);
2488 
2489  frx->SetParameters(x1, y1, theta);
2490  fry->SetParameters(x1, y1, theta);
2491  idd->Scale(frx, fry);
2492  }
2493 
2494  TheGrid->Modified();
2495 
2496  UpdateViewer();
2497  return;
2498 
2499 }
2500 
2501 
2502 
2504 
2505 void KVIDGridEditor::ResetColor(KVIDentifier* Ident)
2506 {
2507  if (!TheGrid) return;
2508 
2509  if (TheGrid->GetIdentifiers()->Contains(Ident)) {
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]);
2512  }
2513  else if (TheGrid->GetCuts()->Contains(Ident)) {
2514  auto cut_line = dynamic_cast<KVIDCutLine*>(Ident);
2515  auto bad_cut = cut_line && !cut_line->IsAcceptedDirectionSet();
2516  Ident->SetLineColor(bad_cut ? kGray : cut_line_colors[(int)fBlackMode]);
2517  Ident->SetMarkerColor(cut_marker_colors[(int)fBlackMode]);
2518  }
2519  else if (TheGrid->GetInfos()->Contains(Ident)) {
2520  Ident->SetLineColor(kBlue);
2521  Ident->SetMarkerColor(kBlue);
2522  }
2523  return;
2524 }
2525 
2526 
2527 
2529 
2530 void KVIDGridEditor::ResetColor(KVSeqCollection* IdentList)
2531 {
2532  KVIDentifier* idd = 0;
2533  TIter nextidd(IdentList);
2534  while ((idd = (KVIDentifier*)nextidd())) {
2535  ResetColor(idd);
2536  }
2537 }
2538 
2539 
2540 
2542 
2544 {
2545  if (IsClosed()) return;
2546  fCanvas->cd();
2547  fCanvas->Clear();
2548  if (TheHisto) {
2549  TheHisto->Draw("col");
2550  }
2551  if (TheGrid) {
2552  TheGrid->Draw();
2553  }
2554  if (fPivot) fPivot->Draw("P");
2555  DrawAtt(false);
2556 
2557  fPad->Modified();
2558  fPad->Update();
2559  if (fDebug) cout << "INFO: KVIDGridEditor::ForceUpdate(): Canvas and Co has been updated !" << endl;
2560 }
2561 
2562 
2563 
2566 
2567 Bool_t KVIDGridEditor::HandleKey(Int_t, Int_t py)
2568 {
2569  // Handle keys
2570 
2571  char tmp[3];
2572  // UInt_t keysym;
2573  // gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
2574  TPaveLabel* label = 0;
2575  Int_t color;
2576 
2577  if (fSVGMode) {
2578  TString tmpStr(tmp);
2579  // if((keysym>=4144)&&(keysym<=4155)) tmpStr.Form("f%d",keysym-4143);
2580  tmpStr.ToUpper();
2581  fKeyShow = new TPaveText(0.8, 0.8, 0.9, 0.9, "brNDC");
2582  fKeyShow->SetBorderSize(0);
2583  fKeyShow->SetFillColor(kGray + 3);
2584  fKeyShow->SetTextColor(0);
2585  fKeyShow->AddText(tmpStr.Data());
2586  fKeyShow->Draw();
2587  UpdateViewer();
2588  }
2589  // if (event->fType == kGKeyPress) {
2590  // switch ((EKeySym)keysym) {
2591  switch ((EKeySym)py) {
2592  case kKey_F1:
2593  label = (TPaveLabel*)lplabel->At(0);
2594  SelectTrans(label);
2595  UpdateViewer();
2596  break;
2597 
2598  case kKey_F2:
2599  label = (TPaveLabel*)lplabel->At(1);
2600  SelectTrans(label);
2601  UpdateViewer();
2602  break;
2603 
2604  case kKey_F3:
2605  label = (TPaveLabel*)lplabel->At(2);
2606  SelectTrans(label);
2607  UpdateViewer();
2608  break;
2609 
2610  case kKey_F4:
2611  label = (TPaveLabel*)lplabel->At(3);
2612  SelectTrans(label);
2613  UpdateViewer();
2614  break;
2615 
2616  case kKey_F5:
2617  label = (TPaveLabel*)lplabel->At(4);
2618  SelectTrans(label);
2619  UpdateViewer();
2620  break;
2621 
2622  case kKey_F6:
2623  label = (TPaveLabel*)lplabel->At(5);
2624  SelectTrans(label);
2625  UpdateViewer();
2626  break;
2627 
2628  case kKey_F7:
2629  label = (TPaveLabel*)lplabel->At(6);
2630  SelectTrans(label);
2631  UpdateViewer();
2632  break;
2633 
2634  case kKey_F8:
2635  SetLogy();
2636  UpdateViewer();
2637  break;
2638 
2639  case kKey_F9:
2640  SetLogz();
2641  UpdateViewer();
2642  break;
2643 
2644  case kKey_F12:
2645  Unzoom();
2646  UpdateViewer();
2647  break;
2648 
2649  case kKey_s:
2650  SaveCurrentGrid();
2651  UpdateViewer();
2652  break;
2653 
2654  case kKey_l:
2655  label = (TPaveLabel*)lplabel4->FindObject("Line");
2656  DispatchOrder(label);
2657  UpdateViewer();
2658  break;
2659 
2660  case kKey_k:
2661  label = (TPaveLabel*)lplabel4->FindObject("Cut");
2662  DispatchOrder(label);
2663  ResetGridColors();
2664  UpdateViewer();
2665  break;
2666 
2667  case kKey_u:
2668  ResetGridColors();
2669  UpdateViewer();
2670  break;
2671 
2672  case kKey_e:
2673  label = (TPaveLabel*)lplabel4->FindObject("Edit");
2674  SetEditable(label);
2675  UpdateViewer();
2676  break;
2677 
2678  case kKey_o:
2679  DynamicZoom(-1, 0, 0, 0.1);
2680 // x0 = 0.;
2681 // y0 = 0.;
2682 // SetPivot(x0, y0);
2683 // SetPiedestal(0.0, 0.0);
2684 // UpdateViewer();
2685  break;
2686 
2687  case kKey_i:
2688  DynamicZoom(1, 0, 0, 0.1);
2689  break;
2690 
2691  case kKey_b:
2692  if (fBlackMode) {
2693  fBlackMode = false;
2694  if (fJoelMode) {
2695  fPad->SetFillStyle(1001);
2696  fPad->GetFrame()->SetFillStyle(1001);
2697  }
2698  fPad->SetFillColor(kWhite);
2699  fPad->GetFrame()->SetFillColor(kWhite);
2700  gStyle->SetFrameFillColor(kWhite);
2701  gROOT->ForceStyle();
2702  gStyle->SetPalette(55);
2703  TheHisto->GetXaxis()->SetAxisColor(kBlack);
2704  TheHisto->GetYaxis()->SetAxisColor(kBlack);
2705  TheHisto->GetXaxis()->SetLabelColor(kBlack);
2706  TheHisto->GetYaxis()->SetLabelColor(kBlack);
2707 
2708  SelectedColor = kOrange + 1;
2709 
2710  lplabel->Execute("SetFillColor", "kWhite");
2711  lplabel->Execute("SetTextColor", "kBlack");
2712  lplabel->Execute("SetLineColor", "kBlack");
2713 
2714  lplabel2->Execute("SetFillColor", "kWhite");
2715  lplabel2->Execute("SetTextColor", "kBlack");
2716  lplabel2->Execute("SetLineColor", "kBlack");
2717 
2718  lplabel3->Execute("SetFillColor", "kWhite");
2719  lplabel3->Execute("SetTextColor", "kBlack");
2720  lplabel3->Execute("SetLineColor", "kBlack");
2721 
2722  lplabel4->Execute("SetFillColor", "kWhite");
2723  lplabel4->Execute("SetTextColor", "kBlack");
2724  lplabel4->Execute("SetLineColor", "kBlack");
2725 
2726  TIter it(lplabel5);
2727  TPaveLabel* dummy = 0;
2728  while ((dummy = (TPaveLabel*)it()))
2729  if (dummy != modulator) {
2730  dummy->SetFillColor(kWhite);
2731  dummy->SetTextColor(kBlack);
2732  dummy->SetLineColor(kBlack);
2733  }
2734 
2735  }
2736  else {
2737  fBlackMode = true;
2738  if (fJoelMode) {
2739  fPad->SetFillStyle(3905);
2740  fPad->SetFillColor(kBlack);
2741  fPad->GetFrame()->SetFillStyle(3905);
2742  fPad->GetFrame()->SetFillColor(kBlack);
2743  gStyle->SetHatchesSpacing(1.5);
2745  }
2746  else {
2747  fPad->SetFillColor(kBlack);
2748  fPad->GetFrame()->SetFillColor(kBlack);
2749  gStyle->SetFrameFillColor(kBlack);
2750  gROOT->ForceStyle();
2751  gStyle->SetPalette(56);
2752  TheHisto->GetXaxis()->SetAxisColor(kWhite);
2753  TheHisto->GetYaxis()->SetAxisColor(kWhite);
2754  TheHisto->GetXaxis()->SetLabelColor(kWhite);
2755  TheHisto->GetYaxis()->SetLabelColor(kWhite);
2756 
2757  SelectedColor = kMagenta;
2758 
2759  lplabel->Execute("SetFillColor", "kBlack");
2760  lplabel->Execute("SetTextColor", "kWhite");
2761  lplabel->Execute("SetLineColor", "kWhite");
2762 
2763  lplabel2->Execute("SetFillColor", "kBlack");
2764  lplabel2->Execute("SetTextColor", "kWhite");
2765  lplabel2->Execute("SetLineColor", "kWhite");
2766 
2767  lplabel3->Execute("SetFillColor", "kBlack");
2768  lplabel3->Execute("SetTextColor", "kWhite");
2769  lplabel3->Execute("SetLineColor", "kWhite");
2770 
2771  lplabel4->Execute("SetFillColor", "kBlack");
2772  lplabel4->Execute("SetTextColor", "kWhite");
2773  lplabel4->Execute("SetLineColor", "kWhite");
2774 
2775  TIter it(lplabel5);
2776  TPaveLabel* dummy = 0;
2777  while ((dummy = (TPaveLabel*)it()))
2778  if (dummy != modulator) {
2779  dummy->SetFillColor(kBlack);
2780  dummy->SetTextColor(kWhite);
2781  dummy->SetLineColor(kWhite);
2782  }
2783 
2784  }
2785  }
2786  ResetGridColors();
2787  UpdateViewer();
2788  break;
2789 
2790  case kKey_d:
2791  label = (TPaveLabel*)lplabel4->FindObject("Delete");
2792  DispatchOrder(label);
2793  UpdateViewer();
2794  break;
2795 
2796  case kKey_f:
2797 // ZoomOnMouser();
2798  fAutoZoomMode = !fAutoZoomMode;
2799  break;
2800 
2801  case kKey_a:
2802  lplabel3->Execute("SetFillColor", "kGreen");
2803  SelectLines("All");
2804  UpdateViewer();
2805  break;
2806 
2807  case kKey_x:
2808  ChangeZoomRatio(-1);
2809  UpdateViewer();
2810  break;
2811 
2812  case kKey_y:
2813  ChangeZoomRatio(1);
2814  UpdateViewer();
2815  break;
2816 
2817  case kKey_m:
2818  if (fPointStyle == 4) {
2819  fPointStyle = 20;
2820  fPointSize = 1.;
2821  }
2822  else {
2823  fPointStyle = 4;
2824  fPointSize = .8;
2825  }
2826  TheGrid->GetIdentifiers()->Execute("SetMarkerStyle", Form("%d", fPointStyle));
2827  TheGrid->GetCuts()->Execute("SetMarkerStyle", Form("%d", fPointStyle));
2828  TheGrid->GetInfos()->Execute("SetMarkerStyle", Form("%d", fPointStyle));
2829  TheGrid->GetIdentifiers()->Execute("SetMarkerSize", Form("%lf", fPointSize));
2830  TheGrid->GetCuts()->Execute("SetMarkerSize", Form("%lf", fPointSize));
2831  TheGrid->GetInfos()->Execute("SetMarkerSize", Form("%lf", fPointSize));
2832  UpdateViewer();
2833  break;
2834 
2835  case kKey_z:
2836  label = (TPaveLabel*)lplabel3->FindObject("Select");
2837  color = label->GetFillColor();
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");
2842  UpdateViewer();
2843  break;
2844 
2845  case kKey_w:
2846  aoemode = !aoemode;
2847  break;
2848 
2849  case kKey_v:
2850  venermode = !venermode;
2851  break;
2852 
2853  case kKey_Plus:
2854  if (TheHisto) {
2855  TheHisto->SetMinimum(TheHisto->GetMinimum() + 1);
2856  UpdateViewer();
2857  }
2858  break;
2859  case kKey_Minus:
2860  if (TheHisto) {
2861  TheHisto->SetMinimum(TMath::Max(0, (int)TheHisto->GetMinimum() - 1));
2862  UpdateViewer();
2863  }
2864  break;
2865 
2866  case kKey_c:
2867  SetLogz();
2868  UpdateViewer();
2869  break;
2870 
2871  case kKey_t:
2872  MoveHor(1, .2, false);
2873  break;
2874 
2875  case kKey_Left:
2876  case kKey_4:
2877  MoveHor(1, 0.1);
2878  break;
2879 
2880  case kKey_r:
2881  MoveHor(-1, .2, false);
2882  break;
2883 
2884 
2885  case kKey_Right:
2886  case kKey_6:
2887  MoveHor(-1, 0.1);
2888  break;
2889 
2890  case kKey_n:
2891  MoveVert(1, .25, false);
2892  break;
2893 
2894  case kKey_Down:
2895  case kKey_2:
2896  MoveVert(1, 0.1);
2897  break;
2898 
2899  case kKey_p:
2900  MoveVert(-1, .25, false);
2901  break;
2902 
2903  case kKey_Up:
2904  case kKey_8:
2905  MoveVert(-1, 0.1);
2906  break;
2907 
2908  case kKey_Space:
2909  break;
2910  default:
2911  return kTRUE;
2912  }
2913  //}
2914  if (fSVGMode && fKeyShow) {
2915  delete fKeyShow;
2916  fKeyShow = 0;
2917  UpdateViewer();
2918  }
2919  return kTRUE;
2920 }
2921 
2922 
2923 
2925 
2926 void KVIDGridEditor::MoveHor(Int_t sign, Double_t speed, Bool_t update)
2927 {
2928  if (!TheHisto) return;
2929 
2930  TAxis* xAxis = TheHisto->GetXaxis();
2931 
2932  Int_t XX1 = xAxis->GetFirst();
2933  Int_t XX2 = xAxis->GetLast();
2934 
2935  if ((XX1 == 1) && (sign == 1)) return;
2936  if ((XX2 == xAxis->GetNbins() - 1) && (sign == -1)) return;
2937 
2938  Int_t dX = (Int_t)sign * (XX1 - XX2) * 0.25 * speed;
2939 
2940  xAxis->SetRange(XX1 + dX, XX2 + dX);
2941  if (update) UpdateViewer();
2942 }
2943 
2944 
2945 
2947 
2948 void KVIDGridEditor::ChangeZoomRatio(Int_t sign, Double_t speed)
2949 {
2950  if (!TheHisto) return;
2951 
2952  TAxis* axis = 0;
2953  if (sign < 0) axis = TheHisto->GetXaxis();
2954  else axis = TheHisto->GetYaxis();
2955 
2956  Int_t XX1 = axis->GetFirst();
2957  Int_t XX2 = axis->GetLast();
2958 
2959  Int_t dX = (Int_t) - 1 * (XX1 - XX2) * 0.1 * speed;
2960 
2961  axis->SetRange(XX1 + dX, XX2 - dX);
2962  UpdateViewer();
2963 }
2964 
2965 
2966 
2967 
2969 
2970 void KVIDGridEditor::MoveVert(Int_t sign, Double_t speed, Bool_t update)
2971 {
2972  if (!TheHisto) return;
2973 
2974  TAxis* yAxis = TheHisto->GetYaxis();
2975 
2976  Int_t XX1 = yAxis->GetFirst();
2977  Int_t XX2 = yAxis->GetLast();
2978 
2979  if ((XX1 == 1) && (sign == 1)) return;
2980  if ((XX2 == yAxis->GetNbins() - 1) && (sign == -1)) return;
2981 
2982  Int_t dX = (Int_t)sign * (XX1 - XX2) * 0.25 * speed;
2983 
2984  yAxis->SetRange(XX1 + dX, XX2 + dX);
2985  if (update) UpdateViewer();
2986 }
2987 
2988 
2989 
2991 
2992 void KVIDGridEditor::ZoomOnMouse()
2993 {
2994 
2995 }
2996 
2997 
2998 
2999 
3001 
3002 void KVIDGridEditor::SelectTrans(TPaveLabel* label)
3003 {
3004  if (!label) return;
3005 
3006  Int_t color = label->GetFillColor();
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);
3010 
3011  return;
3012 }
3013 
3014 
3015 
3017 
3019 {
3020  fPointStyle = pstyle;
3021  TheGrid->GetIdentifiers()->Execute("SetMarkerStyle", Form("%d", fPointStyle));
3022  TheGrid->GetCuts()->Execute("SetMarkerStyle", Form("%d", fPointStyle));
3023  fPad->Modified();
3024  fPad->Update();
3025 }
3026 
3027 
3028 
3030 
3032 {
3033  fPointSize = psize;
3034  TheGrid->GetIdentifiers()->Execute("SetMarkerSize", Form("%lf", fPointSize));
3035  TheGrid->GetCuts()->Execute("SetMarkerSize", Form("%lf", fPointSize));
3036  fPad->Modified();
3037  fPad->Update();
3038 }
3039 
3040 
3041 
3043 
3045 {
3046  if ((!TheHisto) || (!TheGrid)) return;
3047 
3048  if (TheGrid->InheritsFrom("KVIDZAFromZGrid")) new KVItvFinderDialog((KVIDZAFromZGrid*)TheGrid, TheHisto);
3049  else new KVZAFinderDialog(TheGrid, TheHisto);
3050  // KVZALineFinder toto((KVIDZAGrid*)TheGrid, TheHisto);
3051  // toto.SetAList(A);
3052  // toto.SetNbinsByZ(binByZ);
3053  // toto.ProcessIdentification(zmin,zmax);
3054  //
3055  // SetHisto(toto.GetHisto());
3056  // SetGrid(toto.GetGrid(),kFALSE);
3057  // UpdateViewer();
3058 }
3059 
3060 
3061 
3063 
3065 {
3066  KVNumberList ZL(Zl);
3067  ZL.Begin();
3068  while (!ZL.End()) {
3069  Int_t Z = ZL.Next();
3070  KVList* ll = (KVList*) TheGrid->GetIdentifiers()->GetSubListWithMethod(Form("%d", Z), "GetZ");
3071  Info("ChangeMasses", "%d lines found for Z=%d", ll->GetSize(), Z);
3072 
3073  KVIDentifier* id = 0;
3074  TIter next(ll);
3075  while ((id = (KVIDentifier*)next())) {
3076  Info("ChangeMasses", "A=%d -> A=%d", id->GetA(), id->GetA() + dA);
3077  id->SetA(id->GetA() + dA);
3078  }
3079  delete ll;
3080  }
3081 }
3082 
3083 
3084 
3086 
3088 {
3089  KVNumberList ZL(Zl);
3090 
3091  IntArray ztab = ZL.GetArray();
3092  Int_t n = ztab.size();
3093  if (!n) return;
3094 
3095  for (int i = n - 1; i > 0; i--) {
3096  Int_t Z = ztab[i];
3097  KVList* ll = (KVList*) TheGrid->GetIdentifiers()->GetSubListWithMethod(Form("%d", Z), "GetZ");
3098  Info("ChangeMasses", "%d lines found for Z=%d", ll->GetSize(), Z);
3099 
3100  KVIDentifier* id = 0;
3101  TIter next(ll);
3102  while ((id = (KVIDentifier*)next())) {
3103  Info("ChangeMasses", "Z=%d -> Z=%d", id->GetZ(), id->GetZ() + dZ);
3104  id->SetZ(id->GetZ() + dZ);
3105  }
3106  delete ll;
3107 
3108  }
3109 }
3110 
3111 
3112 
3114 
3115 void KVIDGridEditor::AddMethod(const char* theMethod)
3116 {
3117  if (fListOfMethods.IsNull()) fDefaultMethod += theMethod;
3118  fListOfMethods += theMethod;
3119  fListOfMethods += " ";
3120  return;
3121 }
3122 
3123 
3124 
3128 
3130 {
3131  // Print a summary of X and Y scaling transformations (Sx, Sy, Sxy)
3132  // made since the last call of ResetScalingRecap();
3133  Info("PrintScalingRecap",
3134  "Scaling recap:\n X --> %f X + %f\n Y --> %f Y + %f"
3135  , fAx, fBx, fAy, fBy);
3136 }
3137 
3138 
3139 
3141 
3143 {
3144  if(TheGrid){
3145  ResetColor(TheGrid->GetIdentifiers());
3146  ResetColor(TheGrid->GetCuts());
3147  ResetColor(TheGrid->GetInfos());
3148  }
3149 }
3150 
3151 
kMouseMotion
kWheelUp
kButton1Double
kButton1Shift
kButton1Motion
kButton1Up
kWheelDown
kButton1Down
kESC
int Int_t
EKeySym
kKey_Right
kKey_Down
kKey_o
kKey_Space
kKey_F1
kKey_f
kKey_F9
kKey_F4
kKey_F5
kKey_F12
kKey_F6
kKey_F8
kKey_Up
kKey_r
kKey_v
kKey_l
kKey_2
kKey_x
kKey_p
kKey_F3
kKey_Left
kKey_6
kKey_4
kKey_y
kKey_z
kKey_s
kKey_e
kKey_w
kKey_8
kKey_c
kKey_k
kKey_u
kKey_Plus
kKey_t
kKey_i
kKey_a
kKey_F2
kKey_Minus
kKey_d
kKey_b
kKey_F7
kKey_m
kKey_n
#define f(i)
size_t size(const MatrixT &matrix)
bool Bool_t
char Char_t
double Double_t
constexpr Bool_t kTRUE
const char Option_t
kRed
kOrange
kBlack
kGreen
kMagenta
kWhite
R__EXTERN TEnv * gEnv
#define gFile
#define gClient
kFDSave
kMBNo
kMBYes
kMBIconExclamation
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 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
#define gROOT
char * Form(const char *fmt,...)
char * StrDup(const char *str)
R__EXTERN TStyle * gStyle
R__EXTERN TSystem * gSystem
Base class for KaliVeda framework.
Definition: KVBase.h:140
Bool_t IsType(const Char_t *typ, bool case_insensitive=false) const
Definition: KVBase.h:185
void Copy(TObject &) const override
Make a copy of this object.
Definition: KVBase.cpp:396
Bool_t IsLogy()
Definition: KVCanvas.cpp:106
Bool_t IsLogz()
Definition: KVCanvas.cpp:97
Bool_t IsLogx()
Definition: KVCanvas.cpp:115
Ask user to choose between several options in a drop-down list.
Extension of TEnv to allow the writing of comments in the file.
Definition: KVEnv.h:18
Extended version of ROOT THashList.
Definition: KVHashList.h:29
Wrapper for histograms and graphical cuts used by KVTreeAnalyzer.
Definition: KVHistogram.h:20
TH1 * GetHisto() const
Definition: KVHistogram.h:37
Line in ID grid used to delimit regions where no identification is possible.
Definition: KVIDCutLine.h:23
bool IsAcceptedDirectionSet() const
Definition: KVIDCutLine.h:62
Base class for particle identification in a 2D map.
Definition: KVIDGraph.h:31
Axis_t GetYmax() const
Definition: KVIDGraph.h:475
void Draw(Option_t *opt="") override
Definition: KVIDGraph.cpp:965
void RemoveIdentifier(KVIDentifier *)
Remove and destroy identifier.
Definition: KVIDGraph.cpp:337
void SetEditable(Bool_t editable=kTRUE) override
Definition: KVIDGraph.cpp:1646
void UpdateLastSavedVersion()
update last saved version. mkae copy of current state of graph.
Definition: KVIDGraph.cpp:541
Axis_t GetXmax() const
Definition: KVIDGraph.h:471
void RemoveInfo(KVIDentifier *)
Remove and destroy cut.
Definition: KVIDGraph.cpp:367
const KVList * GetCuts() const
Definition: KVIDGraph.h:382
TVirtualPad * GetPad() const
Definition: KVIDGraph.h:192
const KVList * GetInfos() const
Definition: KVIDGraph.h:392
void RevertToLastSavedVersion()
Definition: KVIDGraph.cpp:598
void UnDraw()
Definition: KVIDGraph.cpp:1043
virtual void Identify(Double_t, Double_t, KVIdentificationResult *) const =0
const Char_t * GetName() const override
Definition: KVIDGraph.cpp:1416
virtual void DrawAndAdd(const TString &type="ID", const TString &classname="KVIDentifier")
Definition: KVIDGraph.cpp:1254
KVIDentifier * GetIdentifier(Int_t Z, Int_t A) const
Definition: KVIDGraph.cpp:312
void FindAxisLimits()
Calculate X/Y min/max of all objects in graph.
Definition: KVIDGraph.cpp:1150
Axis_t GetYmin() const
Definition: KVIDGraph.h:467
void WriteAsciiFile(const Char_t *filename)
Open, write and close ascii file containing this grid.
Definition: KVIDGraph.cpp:408
Axis_t GetXmin() const
Definition: KVIDGraph.h:463
virtual void Initialize()=0
void RemoveCut(KVIDentifier *)
Remove and destroy cut.
Definition: KVIDGraph.cpp:354
void Modified()
Definition: KVIDGraph.h:313
const KVList * GetIdentifiers() const
Definition: KVIDGraph.h:372
Extended version of KVCanvas used by KVIDGridEditor.
Identification grid editor GUI ,.
void SelectLinesByZ(const Char_t *ListOfZ)
KVIDGridEditor()
Default constructor.
void SetGrid(KVIDGraph *gg, Bool_t histo=true)
void ResetScalingRecap()
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 SetHisto(TH2 *hh)
void SetPointSize(double psize)
void ChangeMasses(const Char_t *Zl, Int_t dA)
void Copy(TObject &) const override
const KVSeqCollection * GetGrids() const
Hybrid charge & mass identification grid.
Identification grid with lines corresponding to different nuclear isotopes (KVIDZALine)
Definition: KVIDZAGrid.h:71
Base class for identification ridge lines corresponding to different nuclear species.
Definition: KVIDZALine.h:33
Base class for graphical cuts used in particle identification.
Definition: KVIDentifier.h:28
virtual Bool_t HasMassFits() const
Definition: KVIDentifier.h:254
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)
General purpose dialog box asking for some input in the form of a string.
Definition: KVInputDialog.h:24
GUI for finding/fixing mass identification intervals.
Extended TList class which owns its objects by default.
Definition: KVList.h:22
void Sort(Bool_t order=kSortAscending)
Definition: KVList.h:40
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:86
Bool_t End(void) const
Definition: KVNumberList.h:206
void Begin(void) const
IntArray GetArray() const
Int_t Next(void) 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....
Definition: KVString.h:73
void Begin(TString delim) const
Definition: KVString.cpp:565
Bool_t End() const
Definition: KVString.cpp:634
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition: KVString.cpp:695
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.
Definition: KVUnownedList.h:20
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 UnZoom()
Int_t GetLast() const
Int_t GetNbins() const
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
Int_t GetFirst() 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)
char * fFilename
const char ** fFileTypes
char * fIniDir
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Double_t * GetY() const
virtual Bool_t IsEditable() const
Int_t GetN() const
Double_t * GetX() 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
TAxis * GetXaxis()
TAxis * GetYaxis()
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
Bool_t IsNull() 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)
Double_t GetX() const
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 void Update()=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
TLine * line
int Sign(const T &x)
RVec< PromoteType< T > > abs(const RVec< T > &v)
gr SetName("gr")
const Int_t n
void init()
Double_t Min(Double_t a, Double_t b)
Int_t Nint(T x)
Double_t Sign(Double_t a, Double_t b)
Double_t ATan(Double_t)
constexpr Double_t DegToRad()
Double_t Abs(Double_t d)
Double_t Max(Double_t a, Double_t b)
const long double cm
Definition: KVUnits.h:69
const long double s
Definition: KVUnits.h:98
TString fRealName
TMarker m
TArc a
ClassImp(TPyArg)