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