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