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 "KVTreeAnalyzer.h"
17 #include <KVHistogram.h>
18 #include "KVTestIDGridDialog.h"
19 #include "KVItvFinderDialog.h"
20 #include "TFrame.h"
21 
22 using namespace std;
23 
25 
26 
27 KVIDGridEditor* gIDGridEditor = nullptr;
28 
29 
32 
34 {
35  // Default constructor
36  fSpiderOption = "DRLF";
37  gStyle->SetPalette(55);
38 
39  // Style
42  gStyle->SetPadTopMargin(0.1);
44  gStyle->SetPadTickX(1);
45  gStyle->SetPadTickY(1);
46  gStyle->SetNdivisions(310, "xyz");
47  gStyle->SetLabelSize(0.05, "xyz");
48  gStyle->SetTitleSize(0.05, "xyz");
49  gStyle->SetTitleOffset(1., "xzy");
50  gStyle->SetTitleFont(42, "xyz");
51  gStyle->SetLabelFont(42, "xyz");
52  gStyle->SetOptStat(0);
53  gStyle->SetOptTitle(0);
54  gROOT->ForceStyle();
55 
56  fPointStyle = 4;
57  fPointSize = 0.8;
58 
59  gIDGridEditor = this;
60 
61  SetName("gIDGridEditor");
62  SetDefault();
63 
64  fListOfMethods = "";
65  fDefaultMethod = "";
66 
67  AddMethod("AutoFit");
68  AddMethod("SaveCurrentGrid");
69  AddMethod("SpiderIdentification");
70  AddMethod("ChangeMasses");
71  AddMethod("ChangeCharges");
72  AddMethod("SelectLinesByZ");
73  AddMethod("MakeScaleX");
74  AddMethod("MakeScaleY");
75  AddMethod("SetSelectedColor");
76  AddMethod("SetPointStyle");
77  AddMethod("SetPointSize");
78  AddMethod("SetVarXVarY");
79  AddMethod("SetRunList");
80  AddMethod("AddParameter");
81  AddMethod("SetXScaleFactor");
82  AddMethod("SetYScaleFactor");
83  AddMethod("SetSVGMode");
84 
85  ft = new TF1("tranlation", "(x+[0])", 0, 50000);
86  fs = new TF1("scale", "(x-[0])*[1]+[0]", 0, 50000);
87  fsy = new TF1("scale_y", "(x-[0])*[1]+[0]", 0, 50000);
88 
89  frx = new TF2("rotation_x", "(x-[0])*TMath::Cos([2])-(y-[1])*TMath::Sin([2])+[0]", 0, 50000);
90  fry = new TF2("rotation_y", "(x-[0])*TMath::Sin([2])+(y-[1])*TMath::Cos([2])+[1]", 0, 50000);
91 
92  ListOfLines = new KVList;
93  ListOfLines->SetOwner(kFALSE);
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  lplabel->Execute("SetTextSize", "0.625");
262  lplabel->Execute("SetFillColor", "kWhite");
263  lplabel2->Execute("SetTextSize", "0.625");
264  lplabel2->Execute("SetFillColor", "kWhite");
265  lplabel3->Execute("SetTextSize", "0.6");
266  lplabel3->Execute("SetFillColor", "kWhite");
267  lplabel4->Execute("SetTextSize", "0.6");
268  lplabel4->Execute("SetFillColor", "kWhite");
269 
270  lplabel->Execute("SetBorderSize", "1");
271  lplabel2->Execute("SetBorderSize", "1");
272  lplabel3->Execute("SetBorderSize", "1");
273  lplabel4->Execute("SetBorderSize", "1");
274  lplabel5->Execute("SetBorderSize", "1");
275 
276  DrawAtt(true);
277  UpdateViewer();
278 }
279 
280 
281 
283 
285 {
286  if (!IsClosed()) {
287  fPad->Modified();
288  fPad->Update();
289  if (fSVGMode) {
290  TString dir("$SVGDOC");
291  if (gSystem->ExpandPathName(dir)) dir = ".";
292  fCanvas->SaveAs(Form("%s/gIDGridEditorPrint-%d.png", dir.Data(), fSVGIndex));
293  // gROOT->ProcessLine(Form(".! import -window root %s/gIDGridEditorPrint-%d.png",dir.Data(),fSVGIndex));
294  if (!gSystem->AccessPathName(Form("%s/gIDGridEditorPrint-%d.png", dir.Data(), fSVGIndex))) fSVGIndex++;
295  }
296  }
297 }
298 
299 
300 
307 
309 {
310  // Copy constructor
311  // This ctor is used to make a copy of an existing object (for example
312  // when a method returns an object), and it is always a good idea to
313  // implement it.
314  // If your class allocates memory in its constructor(s) then it is ESSENTIAL :-)
315 
316  obj.Copy(*this);
317 }
318 
319 
320 
323 
325 {
326  // Destructor
327 
328  if (ownhisto) delete TheHisto;
329  if (fCanvas) delete fCanvas;
330  if (lplabel) {
331  lplabel->Delete("all");
332  delete lplabel;
333  }
334  if (lplabel2) {
335  lplabel2->Delete("all");
336  delete lplabel2;
337  }
338  if (lplabel3) {
339  lplabel3->Delete("all");
340  delete lplabel3;
341  }
342  if (lplabel4) {
343  lplabel4->Delete("all");
344  delete lplabel4;
345  }
346  if (lplabel5) {
347  lplabel5->Delete("all");
348  delete lplabel5;
349  }
350  if (gIDGridEditor == this) gIDGridEditor = 0x0;
351  dynamic_cast<TGMainFrame*>(fCanvas->GetCanvasImp())->Disconnect("CloseWindow()", "KVIDGridEditor", this, "CanvasWasClosed()");
352 
353 }
354 
355 
356 
364 
366 {
367  // This method copies the current state of 'this' object Int_to 'obj'
368  // You should add here any member variables, for example:
369  // (supposing a member variable KVIDGridEditor::fToto)
370  // CastedObj.fToto = fToto;
371  // or
372  // CastedObj.SetToto( GetToto() );
373 
374  KVBase::Copy(obj);
375  //KVIDGridEditor& CastedObj = (KVIDGridEditor&)obj;
376 }
377 
378 
379 
381 
383 {
384  AddTransformation("T_{X}");
385  AddTransformation("T_{Y}");
386  AddTransformation("R_{Z}");
387  AddTransformation("S_{X}");
388  AddTransformation("S_{Y}");
389  AddTransformation("S_{XY}");
390  AddTransformation("S_{C}");
391 
392  AddAction("#odot");
393  // AddAction("0");
394  AddAction("#Leftarrow");
395  AddAction("Lz");
396  AddAction("Ly");
397  AddAction("Lx");
398 
399  // AddGridOption("All",lplabel3);
400  AddGridOption("Select", lplabel3);
401 
402  AddGridOption("Edit", lplabel4);
403  AddGridOption("Delete", lplabel4);
404  AddGridOption("Line", lplabel4);
405  AddGridOption("Cut", lplabel4);
406  AddGridOption("Info", lplabel4);
407  AddGridOption("Fit", lplabel4);
408  AddGridOption("Test", lplabel4);
409  AddGridOption("Mass", lplabel4);
410  AddGridOption("More", lplabel4);
411 
413 
414  gStyle->SetOptTitle(0);
415  gStyle->SetOptStat(0);
416  fCanvas->Clear();
417 
418  SetPivot(0., 0.);
419  SetPiedestal(0., 0.);
420  Clear("ALL");
421  ready = true;
422 
423  return;
424 }
425 
426 
427 
429 
431 {
432  Int_t i = 0;
433 
434  Double_t x1 = 0.92;
435  Double_t x2 = 0.99;
436 
437  Double_t y1 = 0.90 - i * 0.06;
438  Double_t y2 = y1 - 0.05;
439 
440  TPaveLabel* templabel = 0;
441 
442  templabel = new TPaveLabel(x1, y1, x2, y2, "+", "NDC");
443  templabel->SetName(templabel->GetTitle());
444  templabel->SetFillColor(kWhite);
445  lplabel5->Add(templabel);
446 
447  i++;
448  y1 = 0.90 - i * 0.06;
449  y2 = y1 - 0.05;
450 
451  modulator = new TPaveLabel(x1, y1, x2, y2, Form("%d", imod), "NDC");
452  modulator->SetName(templabel->GetTitle());
455 
456  i++;
457  y1 = 0.90 - i * 0.06;
458  y2 = y1 - 0.05;
459 
460  templabel = new TPaveLabel(x1, y1, x2, y2, "-", "NDC");
461  templabel->SetName(templabel->GetTitle());
462  templabel->SetFillColor(kWhite);
463  lplabel5->Add(templabel);
464 
465  lplabel5->Execute("SetTextSize", "0.625");
466 }
467 
468 
469 
471 
473 {
474  Double_t y1 = 0.92;
475  Double_t y2 = 0.99;
476 
477  Double_t x1 = 0.10 + itrans * 0.06;
478  Double_t x2 = x1 + 0.05;
479 
480  TPaveLabel* templabel = 0;
481 
482  templabel = new TPaveLabel(x1, y1, x2, y2, label.Data(), "NDC");
483  templabel->SetName(templabel->GetTitle());
484  lplabel->Add(templabel);
485 
486  itrans++;
487  return;
488 }
489 
490 
491 
493 
495 {
496  Double_t y1 = 0.92;
497  Double_t y2 = 0.99;
498 
499  Double_t x2 = 0.90 - iact * 0.06;
500  Double_t x1 = x2 - 0.05;
501 
502  TPaveLabel* templabel = 0;
503 
504  templabel = new TPaveLabel(x1, y1, x2, y2, label.Data(), "NDC");
505  templabel->SetName(templabel->GetTitle());
506  lplabel2->Add(templabel);
507 
508  iact++;
509  return;
510 }
511 
512 
513 
515 
517 {
518  Double_t x1 = 0.92;
519  Double_t x2 = 0.99;
520 
521  Double_t y1 = 0.10 + iopt * 0.06;
522  Double_t y2 = y1 + 0.05;
523 
524  TPaveLabel* templabel = 0;
525 
526  templabel = new TPaveLabel(x1, y1, x2, y2, label.Data(), "NDC");
527  templabel->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 
2308 
2310 {
2311  if (!TheGrid) return;
2312  if (!ListOfLines) return;
2313  if (ListOfLines->IsEmpty()) return;
2314 
2315  x0 = fPivot->GetX()[0];
2316 
2317  fs->SetParameters(x0, scaleFactor);
2318  ListOfLines->R__FOR_EACH(KVIDentifier, Scale)(fs, 0);
2319 
2320  UpdateViewer();
2321 
2322  fAx *= scaleFactor;
2323  fBx = fs->Eval(fBx);
2324 
2325  return;
2326 }
2327 
2328 
2329 
2330 
2332 
2334 {
2335  if (!TheGrid) return;
2336  if (!ListOfLines) return;
2337  if (ListOfLines->IsEmpty()) return;
2338 
2339  y0 = fPivot->GetY()[0];
2340 
2341  fs->SetParameters(y0, scaleFactor);
2342  ListOfLines->R__FOR_EACH(KVIDentifier, Scale)(0, fs);
2343 
2344  UpdateViewer();
2345 
2346  fAy *= scaleFactor;
2347  fBy = fs->Eval(fBy);
2348 
2349  return;
2350 }
2351 
2352 
2353 
2354 
2356 
2358 {
2359  if (!TheGrid) return;
2360  if (!ListOfLines) return;
2361  if (ListOfLines->IsEmpty()) return;
2362 
2363  Double_t step = 0.05 * (imod / 100.);
2364  Double_t factor = 1. + Sign * step;
2365  MakeScaleX(factor);
2366 
2367  x0 = fPivot->GetX()[0];
2368 
2369  fs->SetParameters(x0, factor);
2370  ListOfLines->R__FOR_EACH(KVIDentifier, Scale)(fs, 0);
2371 
2372  UpdateViewer();
2373  if (fDebug) Info("ScaleX", "scaling on the X axis (*%f) !", factor);
2374  return;
2375 }
2376 
2377 
2378 
2380 
2382 {
2383  if (!TheGrid) return;
2384  if (!ListOfLines) return;
2385  if (ListOfLines->IsEmpty()) return;
2386 
2387  Double_t step = 0.05 * (imod / 100.);
2388  Double_t factor = 1. + Sign * step;
2389  MakeScaleY(factor);
2390 
2391  y0 = fPivot->GetY()[0];
2392 
2393  fs->SetParameters(y0, factor);
2394  ListOfLines->R__FOR_EACH(KVIDentifier, Scale)(0, fs);
2395 
2396  UpdateViewer();
2397  if (fDebug) Info("ScaleY", "scaling on the Y axis (*%f) !", factor);
2398  return;
2399 }
2400 
2401 
2402 
2404 
2406 {
2407  if (!TheGrid) return;
2408  if (!ListOfLines) return;
2409  if (ListOfLines->IsEmpty()) return;
2410 
2411  Double_t step = 0.05 * (imod / 100.);
2412  Double_t factor = 1. + Sign * step;
2413 
2414  x0 = fPivot->GetX()[0];
2415  y0 = fPivot->GetY()[0];
2416 
2417  fs->SetParameters(x0, factor);
2418  fsy->SetParameters(y0, factor);
2419 
2420  ListOfLines->R__FOR_EACH(KVIDentifier, Scale)(fs, fsy);
2421 
2422  UpdateViewer();
2423 
2424  fAx *= factor;
2425  fBx = fs->Eval(fBx);
2426  fAy *= factor;
2427  fBy = fsy->Eval(fBy);
2428 
2429  if (fDebug) Info("ScaleXY", "scaling (*%f) !", factor);
2430  return;
2431 }
2432 
2433 
2434 
2436 
2438 {
2439  if (!TheGrid) return;
2440  if (!ListOfLines) return;
2441  if (ListOfLines->IsEmpty()) return;
2442 
2443  Double_t step = 0.05 * (imod / 100.);
2444  Double_t factor = 1. + Sign * step;
2445 
2446  KVIDentifier* idd = 0;
2447  TIter nextidd(ListOfLines);
2448 
2449  while ((idd = (KVIDentifier*)nextidd())) {
2450  Double_t x1 = idd->GetX()[0];
2451  Double_t x2 = idd->GetX()[idd->GetN() - 1];
2452  Double_t y1 = idd->GetY()[0];
2453  Double_t y2 = idd->GetY()[idd->GetN() - 1];
2454 
2455  Double_t a = (y2 - y1) / (x2 - x1);
2456  // Double_t b = y1 - a*x1;
2457  Double_t theta = TMath::ATan(a);
2458 
2459  frx->SetParameters(x1, y1, -theta);
2460  fry->SetParameters(x1, y1, -theta);
2461  idd->Scale(frx, fry);
2462 
2463  fs->SetParameters(y1, factor);
2464  idd->Scale(0, fs);
2465 
2466  frx->SetParameters(x1, y1, theta);
2467  fry->SetParameters(x1, y1, theta);
2468  idd->Scale(frx, fry);
2469  }
2470 
2471  UpdateViewer();
2472  return;
2473 
2474 }
2475 
2476 
2477 
2479 
2481 {
2482  if (!TheGrid) return;
2483  if (TheGrid->GetIdentifiers()->Contains(Ident)) {
2484  Ident->SetLineColor(fBlackMode ? kBlue : kBlack);
2485  Ident->SetMarkerColor(fBlackMode ? kRed : kBlack);
2486  }
2487  else if (TheGrid->GetCuts()->Contains(Ident)) {
2488  Ident->SetLineColor(kRed);
2489  Ident->SetMarkerColor(kRed);
2490  }
2491  else if (TheGrid->GetInfos()->Contains(Ident)) {
2492  Ident->SetLineColor(kBlue);
2493  Ident->SetMarkerColor(kBlue);
2494  }
2495  return;
2496 }
2497 
2498 
2499 
2501 
2503 {
2504  KVIDentifier* idd = 0;
2505  TIter nextidd(IdentList);
2506  while ((idd = (KVIDentifier*)nextidd())) {
2507  ResetColor(idd);
2508  }
2509 }
2510 
2511 
2512 
2514 
2516 {
2517  if (IsClosed()) return;
2518  fCanvas->cd();
2519  fCanvas->Clear();
2520  if (TheHisto) {
2521  TheHisto->Draw("col");
2522  }
2523  if (TheGrid) {
2524  TheGrid->Draw();
2525  }
2526  if (fPivot) fPivot->Draw("P");
2527  DrawAtt(false);
2528 
2529  fPad->Modified();
2530  fPad->Update();
2531  if (fDebug) cout << "INFO: KVIDGridEditor::ForceUpdate(): Canvas and Co has been updated !" << endl;
2532 }
2533 
2534 
2535 
2538 
2540 {
2541  // Handle keys
2542 
2543  char tmp[3];
2544  // UInt_t keysym;
2545  // gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
2546  TPaveLabel* label = 0;
2547  Int_t color;
2548 
2549  if (fSVGMode) {
2550  TString tmpStr(tmp);
2551  // if((keysym>=4144)&&(keysym<=4155)) tmpStr.Form("f%d",keysym-4143);
2552  tmpStr.ToUpper();
2553  fKeyShow = new TPaveText(0.8, 0.8, 0.9, 0.9, "brNDC");
2554  fKeyShow->SetBorderSize(0);
2555  fKeyShow->SetFillColor(kGray + 3);
2556  fKeyShow->SetTextColor(0);
2557  fKeyShow->AddText(tmpStr.Data());
2558  fKeyShow->Draw();
2559  UpdateViewer();
2560  }
2561  // if (event->fType == kGKeyPress) {
2562  // switch ((EKeySym)keysym) {
2563  switch ((EKeySym)py) {
2564  case kKey_F1:
2565  label = (TPaveLabel*)lplabel->At(0);
2566  SelectTrans(label);
2567  UpdateViewer();
2568  break;
2569 
2570  case kKey_F2:
2571  label = (TPaveLabel*)lplabel->At(1);
2572  SelectTrans(label);
2573  UpdateViewer();
2574  break;
2575 
2576  case kKey_F3:
2577  label = (TPaveLabel*)lplabel->At(2);
2578  SelectTrans(label);
2579  UpdateViewer();
2580  break;
2581 
2582  case kKey_F4:
2583  label = (TPaveLabel*)lplabel->At(3);
2584  SelectTrans(label);
2585  UpdateViewer();
2586  break;
2587 
2588  case kKey_F5:
2589  label = (TPaveLabel*)lplabel->At(4);
2590  SelectTrans(label);
2591  UpdateViewer();
2592  break;
2593 
2594  case kKey_F6:
2595  label = (TPaveLabel*)lplabel->At(5);
2596  SelectTrans(label);
2597  UpdateViewer();
2598  break;
2599 
2600  case kKey_F7:
2601  label = (TPaveLabel*)lplabel->At(6);
2602  SelectTrans(label);
2603  UpdateViewer();
2604  break;
2605 
2606  case kKey_F8:
2607  SetLogy();
2608  UpdateViewer();
2609  break;
2610 
2611  case kKey_F9:
2612  SetLogz();
2613  UpdateViewer();
2614  break;
2615 
2616  case kKey_F12:
2617  Unzoom();
2618  UpdateViewer();
2619  break;
2620 
2621  case kKey_s:
2622  SaveCurrentGrid();
2623  UpdateViewer();
2624  break;
2625 
2626  case kKey_l:
2627  label = (TPaveLabel*)lplabel4->FindObject("Line");
2628  DispatchOrder(label);
2629  UpdateViewer();
2630  break;
2631 
2632  case kKey_u:
2633  UpdateViewer();
2634  break;
2635 
2636  case kKey_e:
2637  label = (TPaveLabel*)lplabel4->FindObject("Edit");
2638  SetEditable(label);
2639  UpdateViewer();
2640  break;
2641 
2642  case kKey_o:
2643  DynamicZoom(-1, 0, 0, 0.1);
2644 // x0 = 0.;
2645 // y0 = 0.;
2646 // SetPivot(x0, y0);
2647 // SetPiedestal(0.0, 0.0);
2648 // UpdateViewer();
2649  break;
2650 
2651  case kKey_i:
2652  DynamicZoom(1, 0, 0, 0.1);
2653  break;
2654 
2655  case kKey_b:
2656  if (fBlackMode) {
2657  fBlackMode = false;
2658  if (fJoelMode) {
2659  fPad->SetFillStyle(1001);
2660  fPad->GetFrame()->SetFillStyle(1001);
2661  }
2665  gROOT->ForceStyle();
2666  gStyle->SetPalette(55);
2671 
2672  SelectedColor = kOrange + 1;
2673 
2674  lplabel->Execute("SetFillColor", "kWhite");
2675  lplabel->Execute("SetTextColor", "kBlack");
2676  lplabel->Execute("SetLineColor", "kBlack");
2677 
2678  lplabel2->Execute("SetFillColor", "kWhite");
2679  lplabel2->Execute("SetTextColor", "kBlack");
2680  lplabel2->Execute("SetLineColor", "kBlack");
2681 
2682  lplabel3->Execute("SetFillColor", "kWhite");
2683  lplabel3->Execute("SetTextColor", "kBlack");
2684  lplabel3->Execute("SetLineColor", "kBlack");
2685 
2686  lplabel4->Execute("SetFillColor", "kWhite");
2687  lplabel4->Execute("SetTextColor", "kBlack");
2688  lplabel4->Execute("SetLineColor", "kBlack");
2689 
2690  TIter it(lplabel5);
2691  TPaveLabel* dummy = 0;
2692  while ((dummy = (TPaveLabel*)it()))
2693  if (dummy != modulator) {
2694  dummy->SetFillColor(kWhite);
2695  dummy->SetTextColor(kBlack);
2696  dummy->SetLineColor(kBlack);
2697  }
2698 
2699  }
2700  else {
2701  fBlackMode = true;
2702  if (fJoelMode) {
2703  fPad->SetFillStyle(3905);
2705  fPad->GetFrame()->SetFillStyle(3905);
2707  gStyle->SetHatchesSpacing(1.5);
2709  }
2710  else {
2714  gROOT->ForceStyle();
2715  gStyle->SetPalette(56);
2720 
2722 
2723  lplabel->Execute("SetFillColor", "kBlack");
2724  lplabel->Execute("SetTextColor", "kWhite");
2725  lplabel->Execute("SetLineColor", "kWhite");
2726 
2727  lplabel2->Execute("SetFillColor", "kBlack");
2728  lplabel2->Execute("SetTextColor", "kWhite");
2729  lplabel2->Execute("SetLineColor", "kWhite");
2730 
2731  lplabel3->Execute("SetFillColor", "kBlack");
2732  lplabel3->Execute("SetTextColor", "kWhite");
2733  lplabel3->Execute("SetLineColor", "kWhite");
2734 
2735  lplabel4->Execute("SetFillColor", "kBlack");
2736  lplabel4->Execute("SetTextColor", "kWhite");
2737  lplabel4->Execute("SetLineColor", "kWhite");
2738 
2739  TIter it(lplabel5);
2740  TPaveLabel* dummy = 0;
2741  while ((dummy = (TPaveLabel*)it()))
2742  if (dummy != modulator) {
2743  dummy->SetFillColor(kBlack);
2744  dummy->SetTextColor(kWhite);
2745  dummy->SetLineColor(kWhite);
2746  }
2747 
2748  }
2749  }
2751  UpdateViewer();
2752  break;
2753 
2754  case kKey_d:
2755  label = (TPaveLabel*)lplabel4->FindObject("Delete");
2756  DispatchOrder(label);
2757  UpdateViewer();
2758  break;
2759 
2760  case kKey_f:
2761 // ZoomOnMouser();
2763  break;
2764 
2765  case kKey_a:
2766  lplabel3->Execute("SetFillColor", "kGreen");
2767  SelectLines("All");
2768  UpdateViewer();
2769  break;
2770 
2771  case kKey_x:
2772  ChangeZoomRatio(-1);
2773  UpdateViewer();
2774  break;
2775 
2776  case kKey_y:
2777  ChangeZoomRatio(1);
2778  UpdateViewer();
2779  break;
2780 
2781  case kKey_m:
2782  if (fPointStyle == 4) {
2783  fPointStyle = 20;
2784  fPointSize = 1.;
2785  }
2786  else {
2787  fPointStyle = 4;
2788  fPointSize = .8;
2789  }
2790  TheGrid->GetIdentifiers()->Execute("SetMarkerStyle", Form("%d", fPointStyle));
2791  TheGrid->GetCuts()->Execute("SetMarkerStyle", Form("%d", fPointStyle));
2792  TheGrid->GetInfos()->Execute("SetMarkerStyle", Form("%d", fPointStyle));
2793  TheGrid->GetIdentifiers()->Execute("SetMarkerSize", Form("%lf", fPointSize));
2794  TheGrid->GetCuts()->Execute("SetMarkerSize", Form("%lf", fPointSize));
2795  TheGrid->GetInfos()->Execute("SetMarkerSize", Form("%lf", fPointSize));
2796  UpdateViewer();
2797  break;
2798 
2799  case kKey_z:
2800  label = (TPaveLabel*)lplabel3->FindObject("Select");
2801  color = label->GetFillColor();
2802  lplabel3->Execute("SetFillColor", fBlackMode ? "kBlack" : "kWhite");
2803  if (color == kWhite || color == kBlack) label->SetFillColor(kGreen);
2804  if (color == kGreen) label->SetFillColor(fBlackMode ? kBlack : kWhite);
2805  SelectLines("Select");
2806  UpdateViewer();
2807  break;
2808 
2809  case kKey_w:
2810  aoemode = !aoemode;
2811  break;
2812 
2813  case kKey_v:
2814  venermode = !venermode;
2815  break;
2816 
2817  case kKey_Plus:
2818  if (TheHisto) {
2820  UpdateViewer();
2821  }
2822  break;
2823  case kKey_Minus:
2824  if (TheHisto) {
2825  TheHisto->SetMinimum(TMath::Max(0, (int)TheHisto->GetMinimum() - 1));
2826  UpdateViewer();
2827  }
2828  break;
2829 
2830  case kKey_c:
2831  SetLogz();
2832  UpdateViewer();
2833  break;
2834 
2835  case kKey_t:
2836  MoveHor(1, .2, false);
2837  break;
2838 
2839  case kKey_Left:
2840  case kKey_4:
2841  MoveHor(1, 0.1);
2842  break;
2843 
2844  case kKey_r:
2845  MoveHor(-1, .2, false);
2846  break;
2847 
2848 
2849  case kKey_Right:
2850  case kKey_6:
2851  MoveHor(-1, 0.1);
2852  break;
2853 
2854  case kKey_n:
2855  MoveVert(1, .25, false);
2856  break;
2857 
2858  case kKey_Down:
2859  case kKey_2:
2860  MoveVert(1, 0.1);
2861  break;
2862 
2863  case kKey_p:
2864  MoveVert(-1, .25, false);
2865  break;
2866 
2867  case kKey_Up:
2868  case kKey_8:
2869  MoveVert(-1, 0.1);
2870  break;
2871 
2872  case kKey_Space:
2873  break;
2874  default:
2875  return kTRUE;
2876  }
2877  //}
2878  if (fSVGMode && fKeyShow) {
2879  delete fKeyShow;
2880  fKeyShow = 0;
2881  UpdateViewer();
2882  }
2883  return kTRUE;
2884 }
2885 
2886 
2887 
2889 
2891 {
2892  if (!TheHisto) return;
2893 
2894  TAxis* xAxis = TheHisto->GetXaxis();
2895 
2896  Int_t XX1 = xAxis->GetFirst();
2897  Int_t XX2 = xAxis->GetLast();
2898 
2899  if ((XX1 == 1) && (sign == 1)) return;
2900  if ((XX2 == xAxis->GetNbins() - 1) && (sign == -1)) return;
2901 
2902  Int_t dX = (Int_t)sign * (XX1 - XX2) * 0.25 * speed;
2903 
2904  xAxis->SetRange(XX1 + dX, XX2 + dX);
2905  if (update) UpdateViewer();
2906 }
2907 
2908 
2909 
2911 
2913 {
2914  if (!TheHisto) return;
2915 
2916  TAxis* axis = 0;
2917  if (sign < 0) axis = TheHisto->GetXaxis();
2918  else axis = TheHisto->GetYaxis();
2919 
2920  Int_t XX1 = axis->GetFirst();
2921  Int_t XX2 = axis->GetLast();
2922 
2923  Int_t dX = (Int_t) - 1 * (XX1 - XX2) * 0.1 * speed;
2924 
2925  axis->SetRange(XX1 + dX, XX2 - dX);
2926  UpdateViewer();
2927 }
2928 
2929 
2930 
2931 
2933 
2935 {
2936  if (!TheHisto) return;
2937 
2938  TAxis* yAxis = TheHisto->GetYaxis();
2939 
2940  Int_t XX1 = yAxis->GetFirst();
2941  Int_t XX2 = yAxis->GetLast();
2942 
2943  if ((XX1 == 1) && (sign == 1)) return;
2944  if ((XX2 == yAxis->GetNbins() - 1) && (sign == -1)) return;
2945 
2946  Int_t dX = (Int_t)sign * (XX1 - XX2) * 0.25 * speed;
2947 
2948  yAxis->SetRange(XX1 + dX, XX2 + dX);
2949  if (update) UpdateViewer();
2950 }
2951 
2952 
2953 
2955 
2957 {
2958 
2959 }
2960 
2961 
2962 
2963 
2965 
2967 {
2968  if (!label) return;
2969 
2970  Int_t color = label->GetFillColor();
2971  lplabel->Execute("SetFillColor", fBlackMode ? "kBlack" : "kWhite");
2972  if (color == kWhite || color == kBlack) label->SetFillColor(kRed);
2973  else if (color == kRed) label->SetFillColor(fBlackMode ? kBlack : kWhite);
2974 
2975  return;
2976 }
2977 
2978 
2979 
2981 
2983 {
2984  fPointStyle = pstyle;
2985  TheGrid->GetIdentifiers()->Execute("SetMarkerStyle", Form("%d", fPointStyle));
2986  TheGrid->GetCuts()->Execute("SetMarkerStyle", Form("%d", fPointStyle));
2987  fPad->Modified();
2988  fPad->Update();
2989 }
2990 
2991 
2992 
2994 
2996 {
2997  fPointSize = psize;
2998  TheGrid->GetIdentifiers()->Execute("SetMarkerSize", Form("%lf", fPointSize));
2999  TheGrid->GetCuts()->Execute("SetMarkerSize", Form("%lf", fPointSize));
3000  fPad->Modified();
3001  fPad->Update();
3002 }
3003 
3004 
3005 
3007 
3009 {
3010  if ((!TheHisto) || (!TheGrid)) return;
3011 
3012  if (TheGrid->InheritsFrom("KVIDZAFromZGrid")) new KVItvFinderDialog((KVIDZAFromZGrid*)TheGrid, TheHisto);
3013  else new KVZAFinderDialog(TheGrid, TheHisto);
3014  // KVZALineFinder toto((KVIDZAGrid*)TheGrid, TheHisto);
3015  // toto.SetAList(A);
3016  // toto.SetNbinsByZ(binByZ);
3017  // toto.ProcessIdentification(zmin,zmax);
3018  //
3019  // SetHisto(toto.GetHisto());
3020  // SetGrid(toto.GetGrid(),kFALSE);
3021  // UpdateViewer();
3022 }
3023 
3024 
3025 
3027 
3029 {
3030  KVNumberList ZL(Zl);
3031  ZL.Begin();
3032  while (!ZL.End()) {
3033  Int_t Z = ZL.Next();
3034  KVList* ll = (KVList*) TheGrid->GetIdentifiers()->GetSubListWithMethod(Form("%d", Z), "GetZ");
3035  Info("ChangeMasses", "%d lines found for Z=%d", ll->GetSize(), Z);
3036 
3037  KVIDentifier* id = 0;
3038  TIter next(ll);
3039  while ((id = (KVIDentifier*)next())) {
3040  Info("ChangeMasses", "A=%d -> A=%d", id->GetA(), id->GetA() + dA);
3041  id->SetA(id->GetA() + dA);
3042  }
3043  delete ll;
3044  }
3045 }
3046 
3047 
3048 
3050 
3052 {
3053  KVNumberList ZL(Zl);
3054 
3055  IntArray ztab = ZL.GetArray();
3056  Int_t n = ztab.size();
3057  if (!n) return;
3058 
3059  for (int i = n - 1; i > 0; i--) {
3060  Int_t Z = ztab[i];
3061  KVList* ll = (KVList*) TheGrid->GetIdentifiers()->GetSubListWithMethod(Form("%d", Z), "GetZ");
3062  Info("ChangeMasses", "%d lines found for Z=%d", ll->GetSize(), Z);
3063 
3064  KVIDentifier* id = 0;
3065  TIter next(ll);
3066  while ((id = (KVIDentifier*)next())) {
3067  Info("ChangeMasses", "Z=%d -> Z=%d", id->GetZ(), id->GetZ() + dZ);
3068  id->SetZ(id->GetZ() + dZ);
3069  }
3070  delete ll;
3071 
3072  }
3073 }
3074 
3075 
3076 
3078 
3079 void KVIDGridEditor::AddMethod(const char* theMethod)
3080 {
3081  if (fListOfMethods.IsNull()) fDefaultMethod += theMethod;
3082  fListOfMethods += theMethod;
3083  fListOfMethods += " ";
3084  return;
3085 }
3086 
3087 
3088 
3092 
3094 {
3095  // Print a summary of X and Y scaling transformations (Sx, Sy, Sxy)
3096  // made since the last call of ResetScalingRecap();
3097  Info("PrintScalingRecap",
3098  "Scaling recap:\n X --> %f X + %f\n Y --> %f Y + %f"
3099  , fAx, fBx, fAy, fBy);
3100 }
3101 
3102 
kMouseMotion
kWheelUp
kButton1Double
kButton1Shift
kButton1Motion
kButton1Up
kWheelDown
kButton1Down
kESC
int Int_t
EKeySym
kKey_Right
kKey_Down
kKey_o
kKey_Space
kKey_F1
kKey_f
kKey_F9
kKey_F4
kKey_F5
kKey_F12
kKey_F6
kKey_F8
kKey_Up
kKey_r
kKey_v
kKey_l
kKey_2
kKey_x
kKey_p
kKey_F3
kKey_Left
kKey_6
kKey_4
kKey_y
kKey_z
kKey_s
kKey_e
kKey_w
kKey_8
kKey_c
kKey_u
kKey_Plus
kKey_t
kKey_i
kKey_a
kKey_F2
kKey_Minus
kKey_d
kKey_b
kKey_F7
kKey_m
kKey_n
#define f(i)
size_t size(const MatrixT &matrix)
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
const char Option_t
kGray
kRed
kOrange
kBlack
kGreen
kMagenta
kWhite
kCyan
kBlue
kYellow
R__EXTERN TEnv * gEnv
#define gFile
#define gClient
kFDOpen
kFDSave
kMBNo
kMBYes
kMBCancel
kMBOk
kMBIconExclamation
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t SetLineColor
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t g
Option_t Option_t TPoint TPoint percent
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
Option_t Option_t TPoint TPoint const char y1
#define gROOT
char * Form(const char *fmt,...)
char * StrDup(const char *str)
R__EXTERN TStyle * gStyle
R__EXTERN TSystem * gSystem
Base class for KaliVeda framework.
Definition: KVBase.h:139
virtual Bool_t IsType(const Char_t *typ) const
Definition: KVBase.h:184
void Copy(TObject &) const override
Make a copy of this object.
Definition: KVBase.cpp:373
Bool_t IsLogy()
Definition: KVCanvas.cpp:106
Bool_t IsLogz()
Definition: KVCanvas.cpp:97
Bool_t IsLogx()
Definition: KVCanvas.cpp:115
Ask user to choose between several options in a drop-down list.
Extended version of ROOT THashList.
Definition: KVHashList.h:29
Wrapper for histograms and graphical cuts used by KVTreeAnalyzer.
Definition: KVHistogram.h:20
TH1 * GetHisto() const
Definition: KVHistogram.h:37
Base class for particle identification in a 2D map.
Definition: KVIDGraph.h:32
Axis_t GetYmax() const
Definition: KVIDGraph.h:397
void Draw(Option_t *opt="") override
Definition: KVIDGraph.cpp:888
void RemoveIdentifier(KVIDentifier *)
Remove and destroy identifier.
Definition: KVIDGraph.cpp:335
void SetEditable(Bool_t editable=kTRUE) override
Definition: KVIDGraph.cpp:1582
void UpdateLastSavedVersion()
update last saved version. mkae copy of current state of graph.
Definition: KVIDGraph.cpp:534
Axis_t GetXmax() const
Definition: KVIDGraph.h:393
void RemoveInfo(KVIDentifier *)
Remove and destroy cut.
Definition: KVIDGraph.cpp:363
const KVList * GetCuts() const
Definition: KVIDGraph.h:308
TVirtualPad * GetPad() const
Definition: KVIDGraph.h:133
const KVList * GetInfos() const
Definition: KVIDGraph.h:318
void RevertToLastSavedVersion()
Definition: KVIDGraph.cpp:555
void UnDraw()
Definition: KVIDGraph.cpp:966
virtual void Identify(Double_t, Double_t, KVIdentificationResult *) const =0
const Char_t * GetName() const override
Definition: KVIDGraph.cpp:1332
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:389
virtual void DrawAndAdd(const Char_t *type="ID", const Char_t *classname="KVIDentifier")
Definition: KVIDGraph.cpp:1174
void WriteAsciiFile(const Char_t *filename)
Open, write and close ascii file containing this grid.
Definition: KVIDGraph.cpp:404
Axis_t GetXmin() const
Definition: KVIDGraph.h:385
virtual void Initialize()=0
void RemoveCut(KVIDentifier *)
Remove and destroy cut.
Definition: KVIDGraph.cpp:350
const KVList * GetIdentifiers() const
Definition: KVIDGraph.h:298
Extended version of KVCanvas used by KVIDGridEditor.
Identification grid editor GUI ,.
Bool_t drawmode
true si mode draw (line, cut)
void SelectLinesByZ(const Char_t *ListOfZ)
Int_t imod
utilise pour le placement des boutons
void DrawAtt(Bool_t piv)
void AddTransformation(TString label)
void DynamicZoom(Int_t Sign, Int_t px=0, Int_t py=0, Double_t speed=.5)
Zoom in or out of histogram with mouse wheel.
void SelectLines(const Char_t *label)
void RotateZ(Int_t Sign)
KVIDGridEditor()
Default constructor.
void ScaleY(Int_t Sign)
TF2 * frx
rotation
KVHashList * lplabel5
contient la liste des TPaveLabel pour moduler les pas (vert)
KVHashList * lplabel4
contient la liste des TPaveLabel pour editer la grille (rouge)
void SetGrid(KVIDGraph *gg, Bool_t histo=true)
TString fSpiderOption
void SetPiedestal(Double_t ppdx, Double_t ppdy)
piedestal used during SpiderIdentification
KVString fListOfMethods
void MoveHor(Int_t sign, Double_t speed=1, Bool_t update=true)
TVirtualPad * fPad
Bool_t aoemode
true si mode age of empire
void ResetScalingRecap()
void RecurseFileStructureFindHistos(TString &hist_names, TDirectory *the_directory)
TString ListOfHistogramInMemory()
void ChangeZoomRatio(Int_t sign, Double_t speed=.5)
TString PreselectHistogram(TString ListOfName, Int_t ipert=0)
void TranslateX(Int_t Sign)
void ScaleX(Int_t Sign)
void ScaleCurvature(Int_t Sign)
void ChangeCharges(const Char_t *Zl, Int_t dZ)
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 Clear(const Option_t *opt="") override
void SelectTrans(TPaveLabel *label)
void ResetColor(KVIDentifier *Ident)
KVIDGridEditorCanvas * fCanvas
void AddMethod(const char *theMethod)
KVIDGraph * TheGrid
pointeur sur la grille courante
Bool_t HandleKey(Int_t px, Int_t py)
Handle keys.
TPaveText * fKeyShow
KVHashList * lplabel2
contient la liste des TPaveLabel pour les actions (rouge)
void SetHisto(TH2 *hh)
KVString fDefaultMethod
KVHashList * lplabel3
contient la liste des TPaveLabel pour les selections de lignes (vert)
void MoveVert(Int_t sign, Double_t speed=1, Bool_t update=true)
TF1 * ft
translation
void SetPointSize(double psize)
void ChangeMasses(const Char_t *Zl, Int_t dA)
Int_t SelectedColor
couleur des lignes selectionnees
Bool_t venermode
true si mode select
TF2 * fry
rotation
TPaveLabel * modulator
Bool_t ownhisto
true si histo par defaut
void SetPivot(Double_t xx0, Double_t yy0)
void SetEditable(TPaveLabel *label)
Bool_t selectmode
true si mode vener
Double_t fBy
scaling recap for current grid
Double_t ymax
utilises pour les differents zooms
KVHashList * lplabel
contient la liste des TPaveLabel pour les transformations (rouge)
Double_t x0
coordonne x du pivot
void DeleteObject(KVIDentifier *obj)
void Copy(TObject &) const override
Double_t fSpiderFactor
Double_t y0
coordonne y du pivot
Bool_t dlmode
true si mode delete
void AddAction(TString label)
Double_t fPointSize
KVList * GetGrids()
Hybrid charge & mass identification grid.
Identification grid with lines corresponding to different nuclear isotopes (KVIDZALine)
Definition: KVIDZAGrid.h:66
Base class for identification ridge lines corresponding to different nuclear species.
Definition: KVIDZALine.h:33
Base class for graphical cuts used in particle identification.
Definition: KVIDentifier.h:28
void Scale(Double_t sx=-1, Double_t sy=-1)
Full result of one attempted particle identification.
Int_t A
A of particle found (if Aident==kTRUE)
Int_t Z
Z of particle found (if Zident==kTRUE)
General purpose dialog box asking for some input in the form of a string.
Definition: KVInputDialog.h:24
GUI for finding/fixing mass identification intervals.
Extended TList class which owns its objects by default.
Definition: KVList.h:28
void Sort(Bool_t order=kSortAscending)
Definition: KVList.h:35
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:85
Bool_t End(void) const
Definition: KVNumberList.h:199
void Begin(void) const
IntArray GetArray() const
Int_t Next(void) const
void Execute(const char *method, const char *params, Int_t *error=0) override
KVSeqCollection * GetSubListWithMethod(const Char_t *retvalue, const Char_t *method) const
TObject * Remove(TObject *obj) override
Remove object from list.
void Add(TObject *obj) override
TObject * FindObject(const char *name) const override
void AddLast(TObject *obj) override
Int_t GetSize() const override
void Clear(Option_t *option="") override
void SetOwner(Bool_t enable=kTRUE) override
TObject * At(Int_t idx) const override
void Delete(Option_t *option="") override
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
void Begin(TString delim) const
Definition: KVString.cpp:565
Bool_t End() const
Definition: KVString.cpp:634
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition: KVString.cpp:695
GUI for testing identification grids.
const KVList * GetHistoList() const
TH1 * GetHistogram(const Char_t *name) const
Return histogram with given name.
ABC for fitting ID grids with functionals.
static KVVirtualIDFitter * GetDefaultFitter()
void SetPad(TVirtualPad *p)
void SetGrid(KVIDGraph *g)
Dialog box for KVZALineFinder class.
virtual void SetAxisColor(Color_t color=1, Float_t alpha=1.)
virtual void SetLabelColor(Color_t color=1, Float_t alpha=1.)
virtual Color_t GetFillColor() const
virtual void SetFillColor(Color_t fcolor)
virtual void SetFillStyle(Style_t fstyle)
virtual void SetLineColor(Color_t lcolor)
virtual void SetMarkerColor(Color_t mcolor=1)
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual void SetMarkerSize(Size_t msize=1)
virtual void SetTextAlign(Short_t align=11)
virtual void SetTextColor(Color_t tcolor=1)
virtual 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 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)