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