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