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