KaliVeda
Toolkit for HIC analysis
KVIDentifier.cpp
1 /*
2 $Id: KVIDentifier.cpp,v 1.8 2009/04/20 12:16:50 ebonnet Exp $
3 $Revision: 1.8 $
4 $Date: 2009/04/20 12:16:50 $
5 */
6 
7 //Created by KVClassFactory on Mon Apr 14 14:25:38 2008
8 //Author: franklan
9 
10 #include "KVIDentifier.h"
11 #include "KVIDGraph.h"
12 #include "TF1.h"
13 #include "TPad.h"
14 #include "TClass.h"
15 
16 using namespace std;
17 
19 
20 
21 
23 void KVIDentifier::SetName(const char* name)
24 {
26  if (GetParent()) GetParent()->Modified();
27 }
28 
29 
30 
37 
39 {
40  // Default initialisations
41  // We set marker size and style for the underlying TGraph,
42  // this way a small circle is drawn at each point.
43  // Also SetEditable(kFALSE) is used to stop it being modified using the mouse.
44 
45 // SetMarkerStyle(kCircle);
46  SetMarkerStyle(20);
47  SetMarkerSize(1);
48  SetLineWidth(2);
49  SetEditable(kFALSE);
50  fParent = 0;
51  fGridOnlyZId = kFALSE;
52 }
53 
54 
55 
58 
60  : TCutG(), fIon(1, 1)
61 {
62  // Default constructor
63  init();
64 }
65 
66 
67 
70 
72 {
73  // Destructor
74 }
75 
76 
77 
80 
82  : TCutG(gr), fIon(1, 1)
83 {
84  //copy a TCutG
85  init();
86 }
87 
88 
89 
92 
94  : TCutG(), fIon(1, 1)
95 {
96  //copy a TGraph
97  init();
98  CopyGraph(gr);
99 }
100 
101 
102 
107 
109  : TCutG(), fIon(1, 1)
110 {
111  // copy constructor
112  // we do not copy the fParent pointer to parent grid,
113  // it is left NULL.
114  init();
115  gr.Copy(*this);
116 }
117 
118 
119 
122 
123 void KVIDentifier::Copy(TObject& obj) const
124 {
125  // Copy attributes of this identifier into 'obj'
126  TNamed::Copy(obj);
127  TAttLine::Copy((TAttLine&)obj);
128  TAttFill::Copy((TAttFill&)obj);
130  ((KVIDentifier&)obj).CopyGraph((TGraph*)this);
131  ((TCutG&)obj).SetVarX(GetVarX());
132  ((TCutG&)obj).SetVarY(GetVarY());
133  ((KVIDentifier&)obj).SetZ(GetZ());
134  ((KVIDentifier&)obj).SetA(GetA());
135  ((KVIDentifier&)obj).SetOnlyZId(OnlyZId());
136  ((KVIDentifier&)obj).SetMassFormula(GetMassFormula());
137 }
138 
139 
140 
143 
145 {
146  // Get pointer to parent ID graph
147  return fParent;
148 }
149 
150 
151 
154 
156 {
157  // Set pointer to parent ID graph
158  fParent = p;
159 }
160 
161 
162 
163 
166 
168 {
169  // Copy coordinates of points from the TGraph
170 
171  Double_t x, y;
172  //change number of points
173  Set(graph->GetN());
174  for (int i = 0; i < GetN(); i++) {
175  graph->GetPoint(i, x, y);
176  SetPoint(i, x, y);
177  }
178 }
179 
180 
181 
182 
185 
187 {
188  // Copy coordinates of points from the TGraph
189 
190  Double_t x, y;
191  //change number of points
192  Set(graph.GetN());
193  for (int i = 0; i < GetN(); i++) {
194  graph.GetPoint(i, x, y);
195  SetPoint(i, x, y);
196  }
197 }
198 
199 
200 
201 
214 
215 void KVIDentifier::WriteAsciiFile(ofstream& file, const Char_t* name_prefix)
216 {
217  //Write name and coordinates of identifier in file buffer stream
218  //Optional string name_prefix will be written just in front of the name of the object.
219  //Format is :
220  //
221  //+classname
222  //name_prefix:name_of_object
223  //number_of_points
224  //x1 y1
225  //x2 y2
226  //...
227  //etc. etc.
228 
229  file << '+' << ClassName() << endl;
230  if (name_prefix)
231  file << name_prefix << ":";
232  file << GetName() << endl;
233  //any extra stuff defined in child class ?
234  WriteAsciiFile_extras(file, name_prefix);
235  file << GetN() << endl;
236  for (Int_t i = 0; i < GetN(); i++) {
237  Double_t x, y;
238  GetPoint(i, x, y);
239  file << x << " " << y << endl;
240  }
241 }
242 
243 
244 
245 
255 
257 {
258  //Read coordinates of identifier in file buffer stream
259  //Format is :
260  //
261  //number_of_points
262  //x1 y1
263  //x2 y2
264  //...
265  //etc. etc.
266 
267  ReadAsciiFile_extras(file);//any extra stuff defined in child class ?
268  Int_t N;
269  file >> N;
270  for (Int_t i = 0; i < N; i++) {
271  Double_t x, y;
272  file >> x >> y;
273  SetPoint(i, x, y);
274  }
275 }
276 
277 
278 
279 
283 
285 {
286  //Dummy method used for sorting, can be redefined in more specific implementations.
287  //A priori we don't know how to "order" the identification cuts.
288 
289  return 0;
290 }
291 
292 
293 
294 
300 
302 {
303  // Print out for identification cut
304  // The optional "opt" string, if given, is printed in parentheses after the line's name
305  // This is used by KVIDGraph in order to show which are "ID" cuts and which are
306  // "OK" cuts (i.e. used to define an identifiable area in a data map).
307 
308  cout << ClassName() << " : " << GetName() << "(" << opt << ")" << endl;
309  TCutG::Print();
310 }
311 
312 
313 
314 
320 
322 {
323  //Scale the coordinates of every point of the cut according to
324  // X_0 ---> sx*X_0
325  // Y_0 ---> sy*Y_0
326  //Default argument value '-1' means leave coordinate unchanged
327  if (TMath::Abs(sx) == 1 && TMath::Abs(sy) == 1)
328  return;
329  for (int i = 0; i < fNpoints; i++) {
330  if (sx > 0.)
331  fX[i] *= sx;
332  if (sy > 0.)
333  fY[i] *= sy;
334  }
335 }
336 
337 
338 
339 
349 
351 {
352  // Apply to the coordinates of every point the transformation
353  // X_0 ---> sx(X_0,Y_0)
354  // Y_0 ---> sy(X_0,Y_0)
355  // if sx & sy are two-dimensional functions (inherits from TF2),
356  // otherwise we apply the transformation
357  // X_0 ---> sx(X_0)
358  // Y_0 ---> sy(Y_0)
359  // for sx & sy one-dimensionsal (TF1) functions.
360 
361  if (!sx && !sy) return; // if the two functions are NULL we leave coordinate unchanged
362  Bool_t sx_2d, sy_2d;
363  sx_2d = (sx && sx->InheritsFrom("TF2"));
364  sy_2d = (sy && sy->InheritsFrom("TF2"));
365  if (sx && sy) {
366  for (Int_t ii = 0; ii < fNpoints; ii++) {
367  Double_t fXp = 0.; // valeur intermediaire pour calculer X' et Y'
368  Double_t fYp = 0.; //a partir des coordonnees initiales
369  if (sx_2d) fXp = sx->Eval(fX[ii], fY[ii]);
370  else fXp = sx->Eval(fX[ii]);
371  if (sy_2d) fYp = sy->Eval(fX[ii], fY[ii]);
372  else fYp = sy->Eval(fY[ii]);
373  fX[ii] = fXp;
374  fY[ii] = fYp;
375  }
376  }
377  else if (sx) {
378  for (Int_t ii = 0; ii < fNpoints; ii++) {
379  if (sx_2d) fX[ii] = sx->Eval(fX[ii], fY[ii]);
380  else fX[ii] = sx->Eval(fX[ii]);
381  }
382  }
383  else {
384  for (Int_t ii = 0; ii < fNpoints; ii++) {
385  if (sy_2d) fY[ii] = sy->Eval(fX[ii], fY[ii]);
386  else fY[ii] = sy->Eval(fY[ii]);
387  }
388  }
389 }
390 
391 
392 
393 
397 
399 {
400  // Method used to draw a new identifier in the active pad
401  // Override in child classes so that gPad->WaitPrimitive has correct arguments
402 
403  if (!gPad) return;
404  TGraph* gr = (TGraph*) gPad->WaitPrimitive("CUTG", "CutG");
405  //copy coordinates of user's line
406  CopyGraph(gr);
407  //remove TGraph and draw the KVIDentifier in its place
408  gPad->GetListOfPrimitives()->Remove(gr);
409  delete gr;
410  Draw("PL");
411 }
412 
413 
414 
415 
424 
426 {
427  // Right-clicking an identifier and selecting this method from the context
428  // menu allows to add a straight-line segment at the end or the beginning
429  // of the line (whichever is closest to the mouse).
430  //
431  // - Direction = "" (default) - continue in the direction of first/last segment
432  // - Direction = "H", "h", "hori", "HORI" etc. - add horizontal segment
433  // - Direction = "v", "V", "vert", "VERT" etc. - add vertical segment
434 
435  if (!GetEditable()) return;
436 
437  // find closest point
438  Int_t px = gPad->GetEventX(); // mouse position
439  Int_t py = gPad->GetEventY(); // mouse position
440  Int_t dpx = px - gPad->XtoAbsPixel(gPad->XtoPad(fX[0])); // first point
441  Int_t dpy = py - gPad->YtoAbsPixel(gPad->XtoPad(fY[0])); // first point
442  Int_t dist_1 = dpx * dpx + dpy * dpy;
443  dpx = px - gPad->XtoAbsPixel(gPad->XtoPad(fX[fNpoints - 1])); // last point
444  dpy = py - gPad->YtoAbsPixel(gPad->XtoPad(fY[fNpoints - 1])); // last point
445  Int_t dist_N = dpx * dpx + dpy * dpy;
446  Int_t ipoint = (dist_N < dist_1 ? fNpoints - 1 : 0);
447 
448  // are we looking at beginning or end of line? (don't assume points are sorted in ascending X)
449  bool first_point = (ipoint == 0 && fX[0] < fX[fNpoints - 1]);
450  ExtendLine(first_point, Limit, Direction);
451 }
452 
453 
454 
461 
462 void KVIDentifier::ExtendLine(bool fromBeginning, Double_t Limit, Option_t* Direction)
463 {
464  // Add a straight-line segment at the end or the beginning of the line depending on fromBeginning.
465  //
466  // - Direction = "" (default) - continue in the direction of first/last segment
467  // - Direction = "H", "h", "hori", "HORI" etc. - add horizontal segment
468  // - Direction = "v", "V", "vert", "VERT" etc. - add vertical segment
469 
470  Int_t ipoint = (fromBeginning && (fX[0] < fX[fNpoints - 1]) ? 0 : fNpoints - 1);
471 
472  TString opt(Direction);// coordinates of new point
473  opt.ToUpper();
474  Double_t newX = fX[ipoint];
475  Double_t newY = fY[ipoint];
476  if (opt.BeginsWith("H")) newX = Limit;
477  else if (opt.BeginsWith("V")) newY = Limit;
478  else {
479  if (fNpoints < 2) {
480  Error("ExtendLine", "Cannot extend line, need at least one segment!");
481  return;
482  }
483  // find equation y = ax+b of last/first segment
484  Double_t u, v, uu, vv;
485  Int_t iipoint = (ipoint == 0 ? 1 : fNpoints - 2);
486  u = fX[ipoint];
487  uu = fX[iipoint];
488  v = fY[ipoint];
489  vv = fY[iipoint];
490  Double_t a = (vv - v) / (uu - u);
491  Double_t b = (uu * v - u * vv) / (uu - u);
492  // Check that 'Limit' the x-coordinate of the new point is larger than the x-coordinate of the
493  // last existing point, or smaller than that of the first, in order to avoid issues
494  if ((fromBeginning && Limit > u) || (!fromBeginning && Limit < u)) {
495  Error("ExtendLine", "Cannot extend line, with x-coordinate wanted %s than the one of the existing %s point!",
496  (fromBeginning ? "greater" : "smaller"), (fromBeginning ? "first" : "last"));
497  return;
498  }
499  //
500  // use 'Limit' as x-coordinate of new point
501  newX = Limit;
502  newY = a * newX + b;
503  }
504 
505  // add point
506  Int_t iend = (ipoint > 0 ? fNpoints : 0);
507  Double_t** ps = ExpandAndCopy(fNpoints + 1, iend);
508  CopyAndRelease(ps, ipoint, fNpoints++, ipoint + 1);
509 
510  // To avoid redefinitions in descendant classes
511  FillZero(iend, iend + 1);
512 
513  if (ipoint > 0) ipoint = fNpoints - 1;
514  fX[ipoint] = newX;
515  fY[ipoint] = newY;
516  if (gPad) {
517  gPad->Modified();
518  gPad->Update();
519  }
520 }
521 
522 
523 
530 
532 {
533  // Create a new line from the selected one
534  // with a new Z and A (optional)
535  // this new line is scale from the selected one with a vertical sy
536  // and horizontal sx (optional) factor
537  // you need to undraw and draw the grid to see its implementation
538 
539  if (!gPad) {
540  Error("CloneScaleStore", "This method should be called using the interactive menu.");
541  return;
542  }
543 
544  TClass* cl = new TClass(this->IsA()->GetName());
545  KVIDentifier* idbis = (KVIDentifier*)cl->New();
546  Double_t xx, yy;
547  for (Int_t nn = 0; nn < this->GetN(); nn += 1) {
548  this->GetPoint(nn, xx, yy);
549  idbis->SetPoint(nn, xx, yy + dy);
550  }
551  idbis->SetOnlyZId(OnlyZId());
552  idbis->SetZ(newzt);
553  idbis->SetMassFormula(GetMassFormula());
554  idbis->SetEditable(IsEditable());
555  if (newar != -1) {
556  idbis->SetA(newar);
557  }
558  if ((sx > 0.) && (sy > 0.)) idbis->Scale(sx, sy);
559  this->GetParent()->AddIdentifier(idbis);
560 
561  this->GetParent()->UnDraw();
562  this->GetParent()->Draw();
563 
564 
565  delete cl;
566 }
567 
568 
569 
572 
574 {
575  // Insert a new point at the mouse position
576  if (!GetEditable()) return -2;
577  if (!gPad) {
578  Error("InsertPoint", "This method should be called using the interactive menu.");
579  return -1;
580  }
581 
582  Int_t px = gPad->GetEventX();
583  //Int_t py = gPad->GetEventY();
584 
585 // Info("InsertPoint", "x=%d y=%d", px, py);
586  Int_t ifound = -1;
587  //while ( gPad->XtoAbsPixel(gPad->XtoPad(fX[ii]))>px && ii<fNpoints-1) ii+=1;
588  //Recherche en pixel absolu
589  //pour trouver le point a partir duquel le TGraph
590  //doit bouger
591 // Print("");
592  for (Int_t ii = 0; ii < fNpoints; ii += 1) {
593 // Info("InsertPoint", "np=%d ii=%d %lf %lf %d\n",
594 // fNpoints,
595 // ii,
596 // fX[ii],
597 // gPad->XtoPad(fX[ii]),
598 // gPad->XtoAbsPixel(gPad->XtoPad(fX[ii]))
599 // );
600  if (gPad->XtoAbsPixel(gPad->XtoPad(fX[ii])) > px) {
601  ifound = ii;
602  break;
603  }
604  }
605 
606 // Info("InsertPoint", "point ifound=%d", ifound);
607 
608  Double_t deltaX = fX[ifound] - fX[ifound - 1];
609  Double_t aa = (fY[ifound] - fY[ifound - 1]) / (deltaX);
610  Double_t bb = fY[ifound] - fX[ifound] * aa;
611  //Conversion du px pour le TGraph et extrapole le new Y
612  Double_t newX = gPad->PadtoX(gPad->AbsPixeltoX(px));
613  Double_t newY = aa * newX + bb;
614 // Info("InsertPoint", "nouveau point %lf %lf", newX, newY);
615 
616  //Dernier point du graph
617  Double_t lastX = fX[fNpoints - 1];
618  Double_t lastY = fY[fNpoints - 1];
619  //Le dernier point est ajoute en fin de graph
620  //fNpoint -> fNpoint+1
621  SetPoint(fNpoints, lastX, lastY);
622  //On deplace les autres points
623  for (Int_t ii = fNpoints - 2; ii >= ifound; ii -= 1)
624  SetPoint(ii, fX[ii - 1], fY[ii - 1]);
625  //Ajout du nouveau point
626  SetPoint(ifound, newX, newY);
627 
628 // Print("");
629 
630  if (gPad) gPad->Modified();
631 
632  return ifound;
633 }
634 
635 
636 
639 
641 {
642  // Insert a new point at the mouse X position using a smooth evaluation of the Y
643  if (!GetEditable()) return -2;
644  if (!gPad) {
645  Error("InsertSmoothPoint", "This method should be called using the interactive menu.");
646  return -1;
647  }
648 
649  Int_t px = gPad->GetEventX();
650 
651  Int_t ifound = -1;
652  for (Int_t ii = 0; ii < fNpoints; ii += 1) {
653  if (gPad->XtoAbsPixel(gPad->XtoPad(fX[ii])) > px) {
654  ifound = ii;
655  break;
656  }
657  }
658 
659  Double_t newX = gPad->PadtoX(gPad->AbsPixeltoX(px));
660  Double_t newY = Eval(newX, 0, "S");
661 
662  Double_t lastX = fX[fNpoints - 1];
663  Double_t lastY = fY[fNpoints - 1];
664  SetPoint(fNpoints, lastX, lastY);
665  for (Int_t ii = fNpoints - 2; ii >= ifound; ii -= 1) SetPoint(ii, fX[ii - 1], fY[ii - 1]);
666 
667  SetPoint(ifound, newX, newY);
668  if (gPad) gPad->Modified();
669 
670  return ifound;
671 }
672 
673 
674 
677 
679 {
680  // Continue to draw an existing the line
681  if (!GetEditable()) return -2;
682  if (!gPad) {
683  Error("ContinueDrawing", "This method should be called using the interactive menu.");
684  return -1;
685  }
686 
687  KVIDentifier* gr = (KVIDentifier*)this->IsA()->New();
688  gr->WaitForPrimitive();
690 
691  Int_t np = gr->GetN();
692 
693  Double_t last, first, yy;
694  gr->GetPoint(np - 1, last, yy);
695  gr->GetPoint(0, first, yy);
696 
697  Double_t xmax = fX[fNpoints - 1];
698  Double_t xmin = fX[0];
699 
700 // Info("ContinueDrawing", "Existing Line %lf %lf, Added line %lf %lf", xmin, xmax, last, first);
701 
702  if (first > xmax) {
703  //A rajouter apres (a droite) de la ligne existante
704  Double_t xx;
705  for (Int_t ii = 0; ii < np; ii += 1) {
706  gr->GetPoint(ii, xx, yy);
707  this->SetPoint(fNpoints, xx, yy);
708  }
709  }
710  else if (last < xmin) {
711  //A rajouter avant (a gauche) la ligne existante
712  Double_t xx;
713  for (Int_t ii = 0; ii < fNpoints; ii += 1) {
714  this->GetPoint(ii, xx, yy);
715  gr->SetPoint(gr->GetN(), xx, yy);
716  }
717 
718  for (Int_t ii = 0; ii < gr->GetN(); ii += 1) {
719  gr->GetPoint(ii, xx, yy);
720  this->SetPoint(ii, xx, yy);
721  }
722  }
723  else {
724 // Info("ContinueDrawing", "Faire une extension a droite ou a gauche\nsans recouvrement avec la ligne existante");
725  }
726 
727  delete gr;
728  gPad->Modified();
729 
730  return np;
731 }
732 
733 
734 
739 
741 {
742  //Check if the line has been draw from left to right
743  //or right to left
744  //In this last case, we invert the filling order
745 
746  Int_t np = gr->GetN();
747  Double_t* xx = gr->GetX();
748  Double_t* yy = gr->GetY();
749  Double_t Delta = xx[np - 1] - xx[0];
750  if (Delta > 0) return;
751 
752  Info("ChechHierarchy", "Invert filling order");
753  Double_t* xp = new Double_t[np];
754  Double_t* yp = new Double_t[np];
755  for (Int_t nn = 0; nn < np; nn += 1) {
756  xp[nn] = xx[nn];
757  yp[nn] = yy[nn];
758  }
759 
760  for (Int_t ii = 1; ii <= np; ii += 1) {
761  gr->SetPoint(ii - 1, xp[np - ii], yp[np - ii]);
762  }
763  delete [] xp;
764  delete [] yp;
765 
766 }
767 
768 
769 
771 
773 {
774  if (!GetEditable()) return -1;
775 
776  if (!gPad) {
777  Error("RemovePoint", "Cannot be used without gPad, requires last mouse position");
778  return -1;
779  }
780 
781  Int_t px = gPad->GetEventX();
782  Int_t py = gPad->GetEventY();
783 
784  //localize closest point to be deleted
785  Int_t ipoint = -2;
786  Int_t mindist = 2147483647;
787 
788  for (Int_t i = 0; i < fNpoints; i++) {
789  Int_t dpx = px - gPad->XtoAbsPixel(gPad->XtoPad(fX[i]));
790  Int_t dpy = py - gPad->YtoAbsPixel(gPad->YtoPad(fY[i]));
791  Int_t dist = dpx * dpx + dpy * dpy;
792  if (dist < mindist) {
793  mindist = dist;
794  ipoint = i;
795  }
796  }
797  return TCutG::RemovePoint(ipoint);
798 }
799 
800 
801 
807 
809 {
810  // Insert a new point at the end
811  // its position is extrapolated from the two last points
812  // assuming linear evolution (yy = a*xx + bb)
813  // The KVIDentifier has to have at least 2 points
814  if (!GetEditable()) return -2;
815  if (fNpoints < 2) return -3;
816 
817  Int_t np = fNpoints;
818  Double_t deltaX = fX[np - 1] - fX[np - 2];
819  Double_t aa = (fY[np - 1] - fY[np - 2]) / (deltaX);
820  Double_t bb = fY[np - 1] - fX[np - 1] * aa;
821  //yy = aa*xx+bb -> bb = yy-aa*xx
822  Double_t newX = fX[np - 1] + deltaX;
823  Double_t newY = aa * newX + bb;
824  SetPoint(np, newX, newY);
825  if (gPad) gPad->Modified();
826  return np + 1;
827 
828 }
829 
830 
834 
836 {
837  // Remove the first point
838  // The KVIDentifier has to have at least 2 points
839  if (!GetEditable()) return -2;
840  if (fNpoints < 2) return -3;
841 
842  RemovePoint(0);
843  if (gPad) gPad->Modified();
844  return fNpoints - 1;
845 
846 }
847 
848 
849 
853 
855 {
856  // Remove the first point
857  // The KVIDentifier has to have at least 2 points
858  if (!GetEditable()) return -2;
859  if (fNpoints < 2) return -3;
860 
861  RemovePoint(GetN() - 1);
862  if (gPad) gPad->Modified();
863  return fNpoints - 1;
864 }
865 
866 
867 
869 
871 {
872  if (!GetEditable()) return -2;
873  if (fNpoints < 2) return -1;
874 
875  Int_t nNpoints = (fNpoints - 1) * 2 + 1;
876  Double_t* nX = new Double_t[nNpoints];
877  Double_t* nY = new Double_t[nNpoints];
878 
879  for (int ii = 0; ii < nNpoints; ii++) {
880  if (!(ii % 2)) {
881  nX[ii] = fX[ii / 2];
882  nY[ii] = fY[ii / 2];
883  }
884  else {
885  nX[ii] = 0.5 * (fX[(ii - 1) / 2] + fX[(ii + 1) / 2]);
886  nY[ii] = Eval(nX[ii], 0, "S");
887  }
888  }
889 
890  Set(0);
891  for (int ii = 0; ii < nNpoints; ii++) SetPoint(ii, nX[ii], nY[ii]);
892 
893  delete[] nX;
894  delete[] nY;
895 
896  if (gPad) gPad->Modified();
897 
898  return fNpoints;
899 }
900 
901 
902 
904 
906 {
907  if (!GetEditable()) return -2;
908  if (fNpoints < 2) return -1;
909 
910  Int_t nNpoints = fNpoints / 2 + 1; //(fNpoints%2)?(fNpoints/2):((fNpoints+1)/2);
911  Double_t* nX = new Double_t[nNpoints];
912  Double_t* nY = new Double_t[nNpoints];
913 
914  nX[0] = fX[0];
915  nY[0] = fY[0];
916 
917  for (int ii = 1; ii < nNpoints - 1; ii++) {
918  nX[ii] = fX[ii * 2];
919  nY[ii] = fY[ii * 2];
920  }
921 
922  nX[nNpoints - 1] = fX[fNpoints - 1];
923  nY[nNpoints - 1] = fY[fNpoints - 1];
924 
925  Set(0);
926  for (int ii = 0; ii < nNpoints; ii++) SetPoint(ii, nX[ii], nY[ii]);
927 
928  delete[] nX;
929  delete[] nY;
930 
931  if (gPad) gPad->Modified();
932 
933  return fNpoints;
934 }
935 
936 
937 
939 
941 {
942  Sort(&TGraph::CompareX, ascending);
943  if (gPad) gPad->Modified();
944  return 0;
945 }
946 
947 
948 
950 
952 {
953  if (OnlyZId()) return (Double_t)GetZ();
954  return (GetZ() + 0.1 * (GetA() - 2.*GetZ()));
955 }
956 
957 
int Int_t
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
double Double_t
const char Option_t
#define N
winID h TVirtualViewer3D TVirtualGLPainter p
winID h TVirtualViewer3D vv
Option_t Option_t SetLineWidth
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 b
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 Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t SetMarkerStyle
char name[80]
float xmin
float xmax
#define gPad
Base class for particle identification in a 2D map.
Definition: KVIDGraph.h:32
void Draw(Option_t *opt="")
Definition: KVIDGraph.cpp:888
void UnDraw()
Definition: KVIDGraph.cpp:966
virtual void AddIdentifier(KVIDentifier *id)
Definition: KVIDGraph.h:340
Base class for graphical cuts used in particle identification.
Definition: KVIDentifier.h:28
virtual void SetOnlyZId(Bool_t onlyz=kTRUE)
Definition: KVIDentifier.h:99
virtual void ReadAsciiFile_extras(std::ifstream &)
Definition: KVIDentifier.h:46
virtual void SetMassFormula(Int_t mf)
Definition: KVIDentifier.h:107
virtual Int_t RemoveFirstPoint()
virtual void Scale(Double_t sx=-1, Double_t sy=-1)
virtual Int_t DecreaseNumberOfPoints()
virtual Double_t GetPID() const
virtual Int_t AddPointAtTheEnd()
KVIDGraph * fParent
parent identification map or grid
Definition: KVIDentifier.h:32
virtual Int_t GetA() const
Definition: KVIDentifier.h:75
virtual void WriteAsciiFile_extras(std::ofstream &, const Char_t *="")
Definition: KVIDentifier.h:42
virtual Int_t RemoveLastPoint()
virtual Int_t InsertSmoothPoint()
Insert a new point at the mouse X position using a smooth evaluation of the Y.
virtual Int_t IncreaseNumberOfPoints()
void ExtendLine(Double_t, Option_t *Direction="")
virtual Int_t InsertPoint()
Insert a new point at the mouse position.
virtual void WaitForPrimitive()
void Copy(TObject &obj) const
Copy attributes of this identifier into 'obj'.
virtual Int_t GetZ() const
Definition: KVIDentifier.h:79
void SetParent(KVIDGraph *)
Set pointer to parent ID graph.
virtual void ChechHierarchy(KVIDentifier *gr)
virtual ~KVIDentifier()
Destructor.
void CopyGraph(TGraph *)
Copy coordinates of points from the TGraph.
virtual Bool_t OnlyZId() const
Definition: KVIDentifier.h:103
virtual Int_t GetMassFormula() const
Definition: KVIDentifier.h:115
virtual void CloneScaleStore(Int_t newzt, Int_t newat, Double_t dy=0., Double_t sx=1., Double_t sy=1.)
virtual void WriteAsciiFile(std::ofstream &, const Char_t *name_prefix="")
virtual Int_t SortPoints(Bool_t ascending=kTRUE)
Int_t Compare(const TObject *) const
virtual void SetA(Int_t atnum)
Definition: KVIDentifier.h:88
KVIDGraph * GetParent() const
Get pointer to parent ID graph.
KVIDentifier()
Default constructor.
virtual void ReadAsciiFile(std::ifstream &)
virtual void Print(Option_t *opt) const
virtual void SetZ(Int_t ztnum)
Definition: KVIDentifier.h:83
virtual Int_t ContinueDrawing()
Continue to draw an existing the line.
virtual Int_t RemovePoint()
void Copy(TAttFill &attfill) const
void Copy(TAttLine &attline) const
void Copy(TAttMarker &attmarker) const
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
const char * GetVarX() const
TClass * IsA() const override
const char * GetVarY() const
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
Int_t fNpoints
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Double_t * GetY() const
virtual Bool_t IsEditable() const
virtual void CopyAndRelease(Double_t **newarrays, Int_t ibegin, Int_t iend, Int_t obegin)
void Print(Option_t *chopt="") const override
static Bool_t CompareX(const TGraph *gr, Int_t left, Int_t right)
Int_t GetN() const
Double_t * fY
virtual void Sort(Bool_t(*greater)(const TGraph *, Int_t, Int_t)=&TGraph::CompareX, Bool_t ascending=kTRUE, Int_t low=0, Int_t high=-1111)
Double_t * GetX() const
virtual Double_t Eval(Double_t x, TSpline *spline=nullptr, Option_t *option="") const
virtual Int_t RemovePoint()
void SetName(const char *name="") override
void Draw(Option_t *chopt="") override
Bool_t GetEditable() const
virtual void FillZero(Int_t begin, Int_t end, Bool_t from_ctor=kTRUE)
Double_t ** ExpandAndCopy(Int_t size, Int_t iend)
Double_t * fX
virtual void Set(Int_t n)
virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y) const
virtual void SetEditable(Bool_t editable=kTRUE)
void Copy(TObject &named) const override
const char * GetName() const override
virtual const char * ClassName() const
virtual Bool_t InheritsFrom(const char *classname) const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
void ToUpper()
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Double_t y[n]
Double_t x[n]
gr SetMarkerSize(1.3)
TGraphErrors * gr
double dist(AxisAngle const &r1, AxisAngle const &r2)
Double_t Abs(Double_t d)
v
TArc a
ClassImp(TPyArg)