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