KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVItvFinderDialog.cpp
Go to the documentation of this file.
1 //Created by KVClassFactory on Mon Jan 23 10:03:13 2017
2 //Author: Diego Gruyer
3 
4 #include "KVItvFinderDialog.h"
5 #include "KVPIDIntervalPainter.h"
6 #include "TRootEmbeddedCanvas.h"
7 #include "TStyle.h"
8 #include "TSystem.h"
9 #include "TROOT.h"
10 #include "TGMsgBox.h"
11 #include "TGFileDialog.h"
12 #include "KVTestIDGridDialog.h"
13 
14 
15 
16 #include "KVIdentificationResult.h"
17 
18 
20 //ClassImp(interval_painter)
21 
22 
23 
24 
27 {
28  fGrid = gg;
29  fHisto = hh;
30 
31  fPoints = new TGraph;
32  fPoints->SetMarkerStyle(23);
33  fNPoints = 0;
34 
35  gStyle->SetOptStat(0);
36  gStyle->SetOptTitle(0);
37 
38  fMain = new TGTransientFrame(gClient->GetDefaultRoot(), gClient->GetDefaultRoot(), 10, 10);
39 
40  // Default constructor
41  TGHorizontalFrame* fCanvasFrame = new TGHorizontalFrame(fMain, 627, 7000, kHorizontalFrame);
42  // fCanvasFrame->SetBackgroundColor(fColor);
43 
44 
45  TRootEmbeddedCanvas* fRootEmbeddedCanvas615 = new TRootEmbeddedCanvas(0, fCanvasFrame, 800, 440);
46  Int_t wfRootEmbeddedCanvas615 = fRootEmbeddedCanvas615->GetCanvasWindowId();
47  fCanvas = new KVCanvas("c123", 10, 10, wfRootEmbeddedCanvas615);
48  fPad = fCanvas->cd();
49  fCanvas->SetRightMargin(0.02);
50  fCanvas->SetTopMargin(0.02);
51  fCanvas->SetLeftMargin(0.08);
52  fCanvas->SetBottomMargin(0.07);
53 
54  // fCanvas->AddExec("SingleShot","gOscillo->HandleEvents()");
55 
56 
57  fRootEmbeddedCanvas615->AdoptCanvas(fCanvas);
58 
59  fCanvasFrame->AddFrame(fRootEmbeddedCanvas615, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));
60  fMain->AddFrame(fCanvasFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
61 
62  TGVerticalFrame* fControlOscillo = new TGVerticalFrame(fCanvasFrame, 2000, 7000, kVerticalFrame);
63  // fControlOscillo->SetBackgroundColor(fColor);
64 
65 
66  {
67  const char* xpms[] = {
68  "filesaveas.xpm",
69  "ed_new.png",
70  "bld_copy.png",
71  "sm_delete.xpm",
72  "profile_t.xpm",
73  "refresh2.xpm",
74  "bld_colorselect.png",
75  "latex.xpm",
76  "move_cursor.png",
77  0
78  };
79  // toolbar tool tip text
80  const char* tips[] = {
81  "Save intervals in current grid",
82  "Create a new interval",
83  "Create a new interval set",
84  "Remove selected intervals",
85  "Find intervals",
86  "Update list views",
87  "Test the grid",
88  "Set log scale on y axis",
89  "Unzoom the histogram",
90  0
91  };
92  int spacing[] = {
93  5,
94  0,
95  0,
96  0,
97  0,
98  0,
99  0,
100  280,
101  0,
102  0
103  };
104  const char* method[] = {
105  "SaveGrid()",
106  "NewInterval()",
107  "NewIntervalSet()",
108  "RemoveInterval()",
109  "Identify()",
110  "UpdateLists()",
111  "TestIdent()",
112  "SetLogy()",
113  "UnzoomHisto()",
114  0
115  };
116  fNbButtons = 0;
117  ToolBarData_t t[50];
118  fToolBar = new TGToolBar(fControlOscillo, 450, 80);
119  int i = 0;
120  while (xpms[i]) {
121  t[i].fPixmap = xpms[i];
122  t[i].fTipText = tips[i];
123  t[i].fStayDown = kFALSE;
124  t[i].fId = i + 1;
125  t[i].fButton = NULL;
126  TGButton* bb = fToolBar->AddButton(fControlOscillo, &t[i], spacing[i]);
127  bb->Connect("Clicked()", "KVItvFinderDialog", this, method[i]);
128  fNbButtons++;
129  i++;
130  }
131  fControlOscillo->AddFrame(fToolBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
132  }
133 
134  fCustomView = new KVListView(interval_set::Class(), fControlOscillo, 450, 200);
135  fCustomView->SetDataColumns(3);
136  fCustomView->SetDataColumn(0, "Z", "GetZ", kTextLeft);
137  fCustomView->SetDataColumn(1, "PIDs", "GetNPID", kTextCenterX);
138  fCustomView->SetDataColumn(2, "Masses", "GetListOfMasses", kTextLeft);
139  // fCustomView->ActivateSortButtons();
140  fCustomView->Connect("SelectionChanged()", "KVItvFinderDialog", this, "DisplayPIDint()");
141  fCustomView->SetDoubleClickAction("KVItvFinderDialog", this, "ZoomOnCanvas()");
142  fCustomView->AllowContextMenu(kFALSE);
143  // fCustomView->AddContextMenuClassException(FZCustomCard::Class());
144  fControlOscillo->AddFrame(fCustomView, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));
145 
146  fCurrentView = new KVListView(interval::Class(), fControlOscillo, 450, 180);
147  fCurrentView->SetDataColumns(5);
148  fCurrentView->SetDataColumn(0, "Z", "GetZ", kTextLeft);
149  fCurrentView->SetDataColumn(1, "A", "GetA", kTextCenterX);
150  fCurrentView->SetDataColumn(2, "min", "GetPIDmin", kTextCenterX);
151  fCurrentView->SetDataColumn(3, "pid", "GetPID", kTextCenterX);
152  fCurrentView->SetDataColumn(4, "max", "GetPIDmax", kTextCenterX);
153 
154 
155 
156  {
157  const char* xpms[] = {
158  "arrow_down.xpm",
159  "arrow_up.xpm",
160  0
161  };
162  const char* tips[] = {
163  "Decrease A by one",
164  "Increase A by one",
165  0
166  };
167  int spacing[] = {
168  120,
169  0,
170  0
171  };
172  const char* method[] = {
173  "MassesDown()",
174  "MassesUp()",
175  0
176  };
177  fNbButtons = 0;
178  ToolBarData_t t[50];
179  fToolBar2 = new TGToolBar(fControlOscillo, 450, 80);
180  int i = 0;
181  while (xpms[i]) {
182  t[i].fPixmap = xpms[i];
183  t[i].fTipText = tips[i];
184  t[i].fStayDown = kFALSE;
185  t[i].fId = i + 1;
186  t[i].fButton = NULL;
187  TGButton* bb = fToolBar2->AddButton(fControlOscillo, &t[i], spacing[i]);
188  bb->Connect("Clicked()", "KVItvFinderDialog", this, method[i]);
189  fNbButtons++;
190  i++;
191  }
192  fControlOscillo->AddFrame(fToolBar2, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
193  }
194 
195  // fCurrentView->ActivateSortButtons();
196  fCurrentView->Connect("SelectionChanged()", "KVItvFinderDialog", this, "SelectionITVChanged()");
197  // fCurrentView->SetDoubleClickAction("FZCustomFrameManager",this,"ChangeParValue()");
198  fCurrentView->AllowContextMenu(kFALSE);
199 
200  fControlOscillo->AddFrame(fCurrentView, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 2, 2));
201 
202  fCanvasFrame->AddFrame(fControlOscillo, new TGLayoutHints(kLHintsExpandY, 0, 0, 0, 0));
203 
204 
205  //layout and display window
206  fMain->MapSubwindows();
207  fMain->Resize(fMain->GetDefaultSize());
208 
209  // position relative to the parent's window
210  fMain->CenterOnParent();
211 
212  fMain->SetWindowName("Masses Identification");
213  fMain->MapWindow();
214 
215  fCustomView->Display(((KVIDZAFromZGrid*)fGrid)->GetIntervalSets());
216  fPad->cd();
217 
218  LinearizeHisto(100);
219  fLinearHisto->SetLineColor(kBlack);
220  fLinearHisto->SetFillColor(kGreen + 1);
221  fLinearHisto->Draw("hist");
222 
223  int tmp[30] = {3, 3, 3, 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6};
224  for (int ii = 0; ii < 30; ii++) fNpeaks[ii] = tmp[ii];
225 
226  fSig = 0.1;
227  fRat = 0.0001;
228 
229  DrawIntervals();
230 
231 }
232 
233 
234 
235 
238 
240 {
241  // Destructor
242 }
243 
244 
245 
248 
250 {
251  // DrawIntervals();
253  Int_t nSelected = list->GetSize();
254  if (nSelected == 1) {
255  interval_set* itv = (interval_set*)list->At(0);
257  }
258  delete list;
259  // ZoomOnCanvas();
261 }
262 
263 
264 
266 
268 {
269  fPad->cd();
270  fItvPaint.Execute("HighLight", "0");
271 
273  int zz = ((interval*)fCurrentView->GetLastSelectedObject())->GetZ();
274  int aa = ((interval*)fCurrentView->GetLastSelectedObject())->GetA();
275  KVPIDIntervalPainter* painter = (KVPIDIntervalPainter*)fItvPaint.FindObject(Form("%d_%d", zz, aa));
276  if (!painter) Info("SelectionITVChanged", "%d %d not found...", zz, aa);
277  painter->HighLight();
278  }
279  fCanvas->Modified();
280  fCanvas->Update();
281 }
282 
283 
284 
286 
288 {
290  Int_t nSelected = list->GetSize();
291  if (nSelected == 1) {
292  interval_set* itv = (interval_set*)list->At(0);
294  }
295  delete list;
296 }
297 
298 
299 
301 
303 {
304  if (!fCustomView->GetLastSelectedObject()) return;
305  int zz = ((interval_set*)fCustomView->GetLastSelectedObject())->GetZ();
306  fLinearHisto->GetXaxis()->SetRangeUser(zz - 0.5, zz + 0.5);
307  fItvPaint.Execute("SetDisplayLabel", "0");
308 
309  KVList* tmp = (KVList*) fItvPaint.GetSubListWithMethod(Form("%d", zz), "GetZ");
310  tmp->Execute("SetDisplayLabel", "1");
311  delete tmp;
312 
313  fCanvas->Modified();
314  fCanvas->Update();
315 }
316 
317 
318 
321 
323 {
324  // fCanvas->cd();
325  interval_set* itvs = 0;
326  TIter it(fGrid->GetIntervalSets());
327  while ((itvs = (interval_set*)it())) {
328  DrawInterval(itvs);
329  }
330 }
331 
332 
333 
335 
337 {
338  fPad->cd();
339  interval* itv = 0;
340  TIter itt(itvs->GetIntervals());
341  while ((itv = (interval*)itt())) {
343  fCanvas->GetListOfPrimitives()->Add(dummy);
344  dummy->Draw();
345  dummy->SetCanvas(fCanvas);
346  if (label) dummy->SetDisplayLabel();
347  dummy->Connect("IntMod()", "KVItvFinderDialog", this, "UpdatePIDList()");
348  fItvPaint.Add(dummy);
349  }
350 }
351 
352 
353 
355 
357 {
358  for (int ii = 0; ii < itvs->GetNPID(); ii++) {
359  interval* itv = (interval*)itvs->GetIntervals()->At(ii);
360  KVPIDIntervalPainter* pid = (KVPIDIntervalPainter*)fItvPaint.FindObject(Form("%d_%d", itv->GetZ(), itv->GetA()));
361  fItvPaint.Remove(pid);
362  delete pid;
363  }
364  itvs->GetIntervals()->Clear("all");
365 
366 }
367 
368 
369 
371 
373 {
374  Double_t zmin = ((KVIDentifier*)fGrid->GetIdentifiers()->First())->GetPID() - 1.0;
375  Double_t zmax = 0;
376 
377  for (int iz = 1; iz < fGrid->GetIdentifiers()->GetSize() + 1; iz++) {
379  if (tmp && tmp->GetPID() > zmax) zmax = tmp->GetPID();
380  }
381 
382  Int_t zbins = (Int_t)(zmax - zmin) * nbins;
383 
384  fLinearHisto = new TH1F("fLinearHisto", "fLinearHisto", zbins, zmin, zmax);
385 
387  fGrid->SetOnlyZId(1);
388 
389  for (int i = 1; i <= fHisto->GetNbinsX(); i++) {
390  for (int j = 1; j <= fHisto->GetNbinsY(); j++) {
391  Stat_t poids = fHisto->GetBinContent(i, j);
392  if (poids == 0) continue;
393 
394  Axis_t x0 = fHisto->GetXaxis()->GetBinCenter(i);
395  Axis_t y0 = fHisto->GetYaxis()->GetBinCenter(j);
396  Axis_t wx = fHisto->GetXaxis()->GetBinWidth(i);
397  Axis_t wy = fHisto->GetYaxis()->GetBinWidth(j);
398 
399  if (x0 < 4) continue;
400 
401  Double_t x, y;
402  Int_t kmax = (Int_t) TMath::Min(20., poids);
403  Double_t weight = (kmax == 20 ? poids / 20. : 1.);
404  for (int k = 0; k < kmax; k++) {
405  x = gRandom->Uniform(x0 - .5 * wx, x0 + .5 * wx);
406  y = gRandom->Uniform(y0 - .5 * wy, y0 + .5 * wy);
407  if (fGrid->IsIdentifiable(x, y)) {
408  fGrid->KVIDZAGrid::Identify(x, y, &idr);
409  if (idr.HasFlag(fGrid->GetName(), "MassID")) {
410  Float_t PID = idr.PID;
411  fLinearHisto->Fill(PID, weight);
412  }
413  }
414  }
415  }
416  }
417 }
418 
419 
420 
423 
425 {
426  // KVBase::OpenContextMenu("Identify(double,double)",this);
427  Identify(0.1, 0.001);
428 }
429 
430 
431 
433 
434 void KVItvFinderDialog::Identify(double sigma, double ratio)
435 {
436  fSig = sigma;
437  fRat = ratio;
438 
439  fPad->cd();
441  if (!list->GetSize()) {
443  for (int ii = 0; ii < fGrid->GetIntervalSets()->GetSize(); ii++) DrawInterval((interval_set*)fGrid->GetIntervalSets()->At(ii), 0);
444  }
445  else {
446  for (int ii = 0; ii < list->GetSize(); ii++) {
447  interval_set* itvs = (interval_set*) list->At(ii);
448  ProcessIdentification(itvs->GetZ(), itvs->GetZ());
449  DrawInterval(itvs, 0);
450  }
451  }
452 
453  delete list;
454  fCanvas->Modified();
455  fCanvas->Update();
456 
457 }
458 
459 
460 
462 
464 {
465  ExportToGrid();
466 
467  static TString dir(".");
468  const char* filetypes[] = {
469  "ID Grid files", "*.dat",
470  "All files", "*",
471  0, 0
472  };
473  TGFileInfo fi;
474  fi.fFileTypes = filetypes;
475  fi.fIniDir = StrDup(dir);
476  new TGFileDialog(gClient->GetDefaultRoot(), gClient->GetDefaultRoot(), kFDSave, &fi);
477  if (fi.fFilename) {
478  TString filenam(fi.fFilename);
479  if (filenam.Contains("toto")) filenam.ReplaceAll("toto", fGrid->GetName());
480  if (!filenam.Contains('.')) filenam += ".dat";
481  fGrid->WriteAsciiFile(filenam.Data());
482  }
483  dir = fi.fIniDir;
485 
486  fCustomView->Display(((KVIDZAFromZGrid*)fGrid)->GetIntervalSets());
488 
489  fItvPaint.Clear("all");
490  DrawIntervals();
491 }
492 
493 
494 
496 
498 {
500  KVNumberList pids;
501  interval_set* itvs = 0;
502  TIter npid(fGrid->GetIntervalSets());
503  while ((itvs = (interval_set*)npid())) {
504  if (!itvs->GetNPID()) continue;
505  pids.Add(itvs->GetZ());
506  }
507  fGrid->GetParameters()->SetValue("PIDRANGE", pids.AsString());
508 
509  itvs = 0;
510  TIter next(fGrid->GetIntervalSets());
511  while ((itvs = (interval_set*)next())) {
512  if (!itvs->GetNPID()) continue;
513  KVString par = Form("PIDRANGE%d", itvs->GetZ());
514  KVString val = "";
515  interval* itv = 0;
516  TIter ni(itvs->GetIntervals());
517  while ((itv = (interval*)ni())) {
518  val += Form("%d:%lf,%lf,%lf|", itv->GetA(), itv->GetPIDmin(), itv->GetPID(), itv->GetPIDmax());
519  }
520  val.Remove(val.Length() - 1);
521  fGrid->GetParameters()->SetValue(par.Data(), val.Data());
522  }
523 }
524 
525 
526 
528 
530 {
532  if (!list->GetSize()) {
533  delete list;
534  return;
535  }
536 
537  interval_set* itvs = (interval_set*)list->At(0);
538  delete list;
539 
540  fPad->WaitPrimitive("TMarker");
542 
543  double pid = mm->GetX();
544  int aa = 0;
545  int iint = 0;
546 
547  if (!itvs->GetNPID()) {
548  aa = itvs->GetZ() * 2;
549  iint = 0;
550  }
551  else if (pid < ((interval*)itvs->GetIntervals()->First())->GetPID()) {
552  aa = ((interval*)itvs->GetIntervals()->First())->GetA() - 1;
553  iint = 0;
554  }
555  else if (pid > ((interval*)itvs->GetIntervals()->Last())->GetPID()) {
556  aa = ((interval*)itvs->GetIntervals()->Last())->GetA() + 1;
557  iint = itvs->GetNPID();
558  }
559  else {
560  for (int ii = 1; ii < itvs->GetNPID(); ii++) {
561  bool massok = false;
562  if (pid > ((interval*)itvs->GetIntervals()->At(ii - 1))->GetPID() && pid < ((interval*)itvs->GetIntervals()->At(ii))->GetPID()) {
563  aa = ((interval*)itvs->GetIntervals()->At(ii - 1))->GetA() + 1;
564  iint = ii;
565  if (aa <= ((interval*)itvs->GetIntervals()->At(ii))->GetA() - 1) massok = true;
566  }
567  if (aa && !massok)((interval*)itvs->GetIntervals()->At(ii))->SetA(((interval*)itvs->GetIntervals()->At(ii))->GetA() + 1);
568  }
569  }
570 
571  interval* itv = new interval(itvs->GetZ(), aa, mm->GetX(), mm->GetX() - 0.05, mm->GetX() + 0.05);
572  itvs->GetIntervals()->AddAt(itv, iint);
573 
574 
576  fPad->cd();
577  fCanvas->GetListOfPrimitives()->Add(dummy);
578  dummy->Draw();
579  dummy->Connect("IntMod()", "KVItvFinderDialog", this, "UpdatePIDList()");
580  dummy->SetDisplayLabel(1);
581  dummy->SetCanvas(fCanvas);
582  fItvPaint.Add(dummy);
583 
585  delete mm;
586 
588  fItvPaint.Execute("Update", "");
589 
590  fCanvas->Modified();
591  fCanvas->Update();
592 }
593 
594 
595 
597 
599 {
600  if (fGrid->GetIntervalSets()->GetSize() == 0) fNextIntervalZ = 1;
601  else fNextIntervalZ = ((interval_set*)fGrid->GetIntervalSets()->Last())->GetZ() + 1;
602  // KVBase::OpenContextMenu("SetNextIntervalZ()",this);
604 }
605 
606 
607 
609 
611 {
613  Int_t nSelected = list->GetSize();
614  interval_set* itvs = 0;
615  if (nSelected == 1) {
616  itvs = (interval_set*)list->At(0);
617  delete list;
618 
620  nSelected = list->GetSize();
621  if (nSelected >= 1) {
622  for (int ii = 0; ii < nSelected; ii++) {
623  interval* itv = (interval*) list->At(ii);
624  KVPIDIntervalPainter* pid = (KVPIDIntervalPainter*)fItvPaint.FindObject(Form("%d_%d", itv->GetZ(), itv->GetA()));
625  fItvPaint.Remove(pid);
626  delete pid;
627  itvs->GetIntervals()->Remove(itv);
628  }
630  fCanvas->Modified();
631  fCanvas->Update();
632  }
633  else ClearInterval(itvs);
634  delete list;
635  }
636  else if (nSelected > 1) {
637  for (int ii = 0; ii < nSelected; ii++) {
638  itvs = (interval_set*)list->At(ii);
639  ClearInterval(itvs);
640  }
641  }
642  else delete list;
643 
644 }
645 
646 
647 
649 
651 {
653  Int_t nSelected = list->GetSize();
654  interval_set* itvs = 0;
655  if (nSelected == 1) {
656  itvs = (interval_set*)list->At(0);
657  delete list;
658 
660  nSelected = list->GetSize();
661 
662  if (nSelected == 1) {
663  interval* itv = (interval*) list->At(0);
664  itv->SetA(itv->GetA() + 1);
665  fItvPaint.Execute("Update", "");
666  // fCurrentView->Display(itvs->GetIntervals());
667  fCanvas->Modified();
668  fCanvas->Update();
669  }
670  else {
671  KVList* ll = itvs->GetIntervals();
672  nSelected = ll->GetSize();
673  if (nSelected >= 1) {
674  for (int ii = 0; ii < nSelected; ii++) {
675  interval* itv = (interval*) ll->At(ii);
676  itv->SetA(itv->GetA() + 1);
677  }
678  fItvPaint.Execute("Update", "");
679  // fCurrentView->Display(itvs->GetIntervals());
680  fCanvas->Modified();
681  fCanvas->Update();
682  }
683  }
684  }
685  else delete list;
686 }
687 
688 
689 
691 
693 {
695  Int_t nSelected = list->GetSize();
696  interval_set* itvs = 0;
697  if (nSelected == 1) {
698  itvs = (interval_set*)list->At(0);
699  delete list;
701  nSelected = list->GetSize();
702 
703  if (nSelected == 1) {
704  interval* itv = (interval*) list->At(0);
705  itv->SetA(itv->GetA() - 1);
706  fItvPaint.Execute("Update", "");
707  fCanvas->Modified();
708  fCanvas->Update();
709  }
710  else {
711 
712  KVList* ll = itvs->GetIntervals();
713  nSelected = ll->GetSize();
714  if (nSelected >= 1) {
715  for (int ii = 0; ii < nSelected; ii++) {
716  interval* itv = (interval*) ll->At(ii);
717  itv->SetA(itv->GetA() - 1);
718  }
719  fItvPaint.Execute("Update", "");
720  fCanvas->Modified();
721  fCanvas->Update();
722  }
723  }
724  }
725  else delete list;
726 }
727 
728 
729 
731 
733 {
734  fCustomView->Display(((KVIDZAFromZGrid*)fGrid)->GetIntervalSets());
736  Int_t nSelected = list->GetSize();
737  interval_set* itvs = 0;
738  if (nSelected == 1) {
739  itvs = (interval_set*)list->At(0);
741  }
742  delete list;
743 }
744 
745 
746 
749 
751 {
752  //fGrid->SetOnlyZId(0);
753  fGrid->Initialize();
754  ExportToGrid();
755 
757 
758  fCustomView->Display(((KVIDZAFromZGrid*)fGrid)->GetIntervalSets());
760 
761  fItvPaint.Clear("all");
762  DrawIntervals();
763 
764  new KVTestIDGridDialog(gClient->GetDefaultRoot(), gClient->GetDefaultRoot(), 10, 10, fGrid, fHisto);
765 }
766 
767 
768 
770 
772 {
774  fCanvas->Modified();
775  fCanvas->Update();
776 }
777 
778 
779 
781 
783 {
784  fItvPaint.Execute("SetDisplayLabel", "0");
786  fCanvas->Modified();
787  fCanvas->Update();
788 }
789 
790 
791 
792 
794 
796 {
797  interval_set* itvs = fGrid->GetIntervalSet(zz);
798  if (!itvs) {
799  itvs = new interval_set(zz, KVIDZAFromZGrid::kIntType);
800  fGrid->GetIntervalSets()->Add(itvs);
801  }
802  else ClearInterval(itvs);
803 
804 
805  if (zz == 1) fLinearHisto->SetAxisRange(0.9, zz + 0.5, "X");
806  else fLinearHisto->SetAxisRange(zz - 0.5, zz + 0.5, "X");
807 
808  int nfound = fSpectrum.Search(fLinearHisto, fSig, "goff", ((zz == 2) ? 0.1 * fRat : fRat));
809 
810 #if ROOT_VERSION_CODE > ROOT_VERSION(5,99,01)
811  Double_t* xpeaks = fSpectrum.GetPositionX();
812 // Double_t* ypeaks = fSpectrum.GetPositionY();
813 #else
814  Float_t* xpeaks = fSpectrum.GetPositionX();
815 // Float_t* ypeaks = fSpectrum.GetPositionY();
816 #endif
817 
818  nfound = TMath::Min(fNpeaks[zz - 1], nfound);
819 
820  int idx[nfound];
821  TMath::Sort(nfound, xpeaks, idx, 0);
822 
823  int zrefs[] = {1, 4, 7, 9, 11, 12, 15, 16, 19, 21, 23, 25, 27, 29, 31, 34, 35, 38, 40, 42, 44, 47, 49, 51, 53};
824  int zref = zrefs[zz - 1];
825 
826  int idref = -1;
827  for (int p = 0; p < nfound; p++) {
828  if (abs(xpeaks[idx[p]] - xpeaks[0]) < .0001) idref = p;
829  }
830  Info("FindPIDIntervals", "Z=%d : idref = %d ", zz, idref);
831 
832  for (int p = 0; p < nfound; p++) {
833 // Info("FindPIDIntervals","Z=%d : (%.2lf %.2lf) (%d %d) ",zz,xpeaks[p],ypeaks[p],idx[p],p);
834  double pid = xpeaks[idx[p]];//ff->GetParameter(3 * ii + 1);
835  itvs->add(zref + (p - idref), pid, pid - 0.05, pid + 0.05);
836  }
837 
838 
839 }
840 
841 
842 
844 
846 {
847  Double_t result = 0;
848  int np = par[0];
849  for (Int_t p = 0; p < np; p++) {
850  Double_t norm = par[3 * p + 3];
851  Double_t mean = par[3 * p + 1];
852  Double_t sigma = par[3 * p + 2];
853  result += norm * TMath::Gaus(x[0], mean, sigma);
854  }
855  return result;
856 }
857 
858 
860 
862 {
863 
864  if (zmin < 0) zmin = ((KVIDentifier*)fGrid->GetIdentifiers()->First())->GetZ();
865  if (zmax < 0) zmax = ((KVIDentifier*)fGrid->GetIdentifiers()->Last())->GetZ();
866 
867  for (int z = zmin; z <= zmax; z++) FindPIDIntervals(z);
868 
869 }
870 
871 
872 
873 
874 
875 
876 
877 
878 
879 
int Int_t
kVerticalFrame
kHorizontalFrame
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
const Bool_t kFALSE
double Axis_t
double Double_t
double Stat_t
float Float_t
kBlack
kGreen
#define gClient
kFDSave
kLHintsExpandY
kLHintsTop
kLHintsExpandX
kTextCenterX
kTextLeft
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
char * StrDup(const char *str)
R__EXTERN TStyle * gStyle
TCanvas with mouse-controlled dynamic zoom and pan & scan.
Definition: KVCanvas.h:53
virtual Bool_t IsIdentifiable(Double_t, Double_t, TString *rejected_by=nullptr) const
Definition: KVIDGraph.cpp:1257
const Char_t * GetName() const
Definition: KVIDGraph.cpp:1320
void WriteAsciiFile(const Char_t *filename)
Open, write and close ascii file containing this grid.
Definition: KVIDGraph.cpp:421
KVNameValueList * GetParameters() const
Definition: KVIDGraph.h:280
KVList * GetIdentifiers() const
Definition: KVIDGraph.h:285
Hybrid identification grid.
interval_set * GetIntervalSet(int zint) const
void SetOnlyZId(Bool_t=kTRUE)
KVList * GetIntervalSets()
Base class for graphical cuts used in particle identification.
Definition: KVIDentifier.h:27
virtual Double_t GetPID() const
Full result of one attempted particle identification.
Double_t PID
= "real" Z if Zident==kTRUE and Aident==kFALSE, "real" A if Zident==Aident==kTRUE
Bool_t HasFlag(std::string grid_name, TString flag)
GUI for finding/fixing mass identification intervals.
void DrawInterval(interval_set *itvs, bool label=0)
KVIDZAFromZGrid * fGrid
void DisplayPIDint()
DrawIntervals();.
void ClearInterval(interval_set *itvs)
void ProcessIdentification(Int_t zmin=-1, Int_t zmax=-1)
TVirtualPad * fPad
void Identify()
KVBase::OpenContextMenu("Identify(double,double)",this);.
KVListView * fCurrentView
void DrawIntervals()
fCanvas->cd();
void FindPIDIntervals(Int_t zz)
TSpectrum fSpectrum
KVPIDIntervalFinder* fPIDFinder;.
void TestIdent()
fGrid->SetOnlyZId(0);
virtual ~KVItvFinderDialog()
Destructor.
void LinearizeHisto(int nbins)
Double_t fpeaks(Double_t *x, Double_t *par)
KVListView * fCustomView
Enhanced version of ROOT TGListView widget.
Definition: KVListView.h:145
virtual void Display(const TCollection *l)
Definition: KVListView.h:172
TObject * GetLastSelectedObject() const
Definition: KVListView.h:230
TList * GetSelectedObjects() const
Definition: KVListView.h:244
virtual void RemoveAll()
Definition: KVListView.h:189
Extended TList class which owns its objects by default.
Definition: KVList.h:27
void SetValue(const Char_t *name, value_type value)
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:83
const Char_t * AsString(Int_t maxchars=0) const
void Add(Int_t)
Add value 'n' to the list.
Used for mass identification GUI.
virtual void Draw(Option_t *option="")
void SetDisplayLabel(bool dis=true)
void HighLight(bool hi=true)
void SetCanvas(KVCanvas *cc)
KVSeqCollection * GetSubListWithMethod(const Char_t *retvalue, const Char_t *method) const
virtual TObject * Last() const
virtual void Clear(Option_t *option="")
virtual Int_t GetSize() const
virtual TObject * At(Int_t idx) const
virtual TObject * First() const
virtual void Execute(const char *method, const char *params, Int_t *error=0)
virtual void Add(TObject *obj)
virtual void AddAt(TObject *obj, Int_t idx)
virtual TObject * Remove(TObject *obj)
Remove object from list.
virtual TObject * FindObject(const char *name) const
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:72
GUI for testing identification grids.
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual Double_t GetBinCenter(Int_t bin) const
virtual void UnZoom()
virtual void SetRangeUser(Double_t ufirst, Double_t ulast)
virtual Double_t GetBinWidth(Int_t bin) const
void Update() override
virtual Int_t GetSize() const
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
char * fFilename
const char ** fFileTypes
char * fIniDir
virtual Int_t GetNbinsY() const
TAxis * GetXaxis()
TAxis * GetYaxis()
virtual Int_t GetNbinsX() const
virtual Int_t Fill(const char *name, Double_t w)
virtual void SetAxisRange(Double_t xmin, Double_t xmax, Option_t *axis="X")
virtual Double_t GetBinContent(Int_t bin) const
virtual void Add(TObject *obj)
TObject * Remove(const TObjLinkPtr_t &lnk)
virtual TObject * At(Int_t idx) const
virtual TObject * Last() const
void Modified(Bool_t flag=1) override
void SetLogy(Int_t value=1) override
Int_t GetLogy() const override
TList * GetListOfPrimitives() const override
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
virtual Double_t Uniform(Double_t x1, Double_t x2)
void AdoptCanvas(TCanvas *c)
Int_t GetCanvasWindowId() const
virtual Int_t Search(const TH1 *hist, Double_t sigma=2, Option_t *option="", Double_t threshold=0.05)
Double_t * GetPositionX() const
Ssiz_t Length() const
const char * Data() const
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 SetOptStat(Int_t stat=1)
virtual TList * GetListOfPrimitives() const=0
virtual TObject * WaitPrimitive(const char *pname="", const char *emode="")=0
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
void add(int aa, double pid, double pidmin=-1., double pidmax=-1.)
KVList * GetIntervals()
double GetPID()
double GetPIDmin()
void SetA(int aa)
double GetPIDmax()
const Double_t sigma
Double_t y[n]
Double_t x[n]
const long double mm
Definition: KVUnits.h:69
void Info(const char *location, const char *va_(fmt),...)
Double_t Min(Double_t a, Double_t b)
Double_t Gaus(Double_t x, Double_t mean=0, Double_t sigma=1, Bool_t norm=kFALSE)
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
const char * fTipText
TGButton * fButton
Bool_t fStayDown
const char * fPixmap