Logo ROOT   6.10/09
Reference Guide
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TGeoTrack.cxx
Go to the documentation of this file.
1 // @(#)root/geom:$Id$
2 // Author: Andrei Gheata 2003/04/10
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TBrowser.h"
13 #include "TPolyLine3D.h"
14 #include "TPoint.h"
15 #include "TVirtualPad.h"
16 #include "TView.h"
17 
18 #include "TGeoManager.h"
19 #include "TVirtualGeoPainter.h"
20 #include "TGeoTrack.h"
21 
22 //______________________________________________________________________________
23 // TGeoTrack - Class for user-defined tracks attached to a geometry.
24 // Tracks are 3D objects made of points and they store a
25 // pointer to a TParticle. The geometry manager holds a list
26 // of all tracks that will be deleted on destruction of
27 // gGeoManager.
28 //
29 //______________________________________________________________________________
30 
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 ///*-*-*-*-*-*-*-*-*-*-*Tracks default constructor*-*-*-*-*-*-*-*-*
35 ///*-* ==========================
36 
38 {
39  fPointsSize = 0;
40  fNpoints = 0;
41  fPoints = 0;
42 }
43 
44 ////////////////////////////////////////////////////////////////////////////////
45 /// Constructor.
46 
47 TGeoTrack::TGeoTrack(Int_t id, Int_t pdgcode, TVirtualGeoTrack *parent, TObject *particle)
48  :TVirtualGeoTrack(id,pdgcode,parent,particle)
49 {
50  fPointsSize = 0;
51  fNpoints = 0;
52  fPoints = 0;
53  if (fParent==0) {
54  SetMarkerColor(2);
55  SetMarkerStyle(8);
56  SetMarkerSize(0.6);
57  SetLineColor(2);
58  SetLineWidth(2);
59  } else {
60  SetMarkerColor(4);
61  SetMarkerStyle(8);
62  SetMarkerSize(0.6);
63  SetLineColor(4);
64  SetLineWidth(2);
65  }
66 }
67 
68 ////////////////////////////////////////////////////////////////////////////////
69 /// Copy ctor. NOT TO BE CALLED.
70 
72  :TVirtualGeoTrack(other),
73  fPointsSize(other.fPointsSize),
74  fNpoints(other.fNpoints),
75  fPoints(other.fPoints)
76 {
77 }
78 
79 ////////////////////////////////////////////////////////////////////////////////
80 /// Assignment operator. NOT TO BE CALLED.
81 
83 {
84  if(this!=&gv) {
87  fNpoints=gv.fNpoints;
88  fPoints=gv.fPoints;
89  }
90  return *this;
91 }
92 
93 ////////////////////////////////////////////////////////////////////////////////
94 /// Destructor.
95 
97 {
98  if (fPoints) delete [] fPoints;
99 // if (gPad) gPad->GetListOfPrimitives()->Remove(this);
100 }
101 
102 ////////////////////////////////////////////////////////////////////////////////
103 /// Add a daughter track to this.
104 
106 {
107  if (!fTracks) fTracks = new TObjArray(1);
108  Int_t index = fTracks->GetEntriesFast();
109  TGeoTrack *daughter = new TGeoTrack(id,pdgcode,this,particle);
110  fTracks->AddAtAndExpand(daughter,index);
111  return daughter;
112 }
113 
114 ////////////////////////////////////////////////////////////////////////////////
115 /// Add a daughter and return its index.
116 
118 {
119  if (!fTracks) fTracks = new TObjArray(1);
120  Int_t index = fTracks->GetEntriesFast();
121  fTracks->AddAtAndExpand(other,index);
122  other->SetParent(this);
123  return index;
124 }
125 
126 ////////////////////////////////////////////////////////////////////////////////
127 /// Draw animation of this track
128 
129 void TGeoTrack::AnimateTrack(Double_t tmin, Double_t tmax, Double_t nframes, Option_t *option)
130 {
131  if (tmin<0 || tmin>=tmax || nframes<1) return;
134  if (!gPad) {
136  }
137  TList *list = gPad->GetListOfPrimitives();
138  TIter next(list);
139  TObject *obj;
140  while ((obj = next())) {
141  if (!strcmp(obj->ClassName(), "TGeoTrack")) list->Remove(obj);
142  }
143  Double_t dt = (tmax-tmin)/Double_t(nframes);
144  Double_t delt = 2E-9;
145  Double_t t = tmin;
146  Bool_t geomanim = kFALSE;
147  Bool_t issave = kFALSE;
148  TString fname;
149 
150  TString opt(option);
151  if (opt.Contains("/G")) geomanim = kTRUE;
152  if (opt.Contains("/S")) issave = kTRUE;
153 
155  Double_t *box = p->GetViewBox();
156  box[0] = box[1] = box[2] = 0;
157  box[3] = box[4] = box[5] = 100;
158  gGeoManager->SetTminTmax(0,0);
159  Draw(opt.Data());
160  Double_t start[6], end[6];
161  Int_t i, j;
162  Double_t dlat=0, dlong=0, dpsi=0;
163  Double_t dd[6] = {0,0,0,0,0,0};
164  if (geomanim) {
165  p->EstimateCameraMove(tmin+5*dt, tmin+15*dt, start, end);
166  for (i=0; i<3; i++) {
167  start[i+3] = 20 + 1.3*start[i+3];
168  end[i+3] = 20 + 0.9*end[i+3];
169  }
170  for (i=0; i<6; i++) {
171  dd[i] = (end[i]-start[i])/10.;
172  }
173  memcpy(box, start, 6*sizeof(Double_t));
174  p->GetViewAngles(dlong,dlat,dpsi);
175  dlong = (-206-dlong)/Double_t(nframes);
176  dlat = (126-dlat)/Double_t(nframes);
177  dpsi = (75-dpsi)/Double_t(nframes);
178  p->GrabFocus();
179  }
180 
181  for (i=0; i<nframes; i++) {
182  if (t-delt<0) gGeoManager->SetTminTmax(0,t);
183  else gGeoManager->SetTminTmax(t-delt,t);
184  if (geomanim) {
185  for (j=0; j<6; j++) box[j]+=dd[j];
186  p->GrabFocus(1,dlong,dlat,dpsi);
187  } else {
188  gPad->Modified();
189  gPad->Update();
190  }
191  if (issave) {
192  fname = TString::Format("anim%04d.gif", i);
193  gPad->Print(fname);
194  }
195  t += dt;
196  }
198 }
199 
200 ////////////////////////////////////////////////////////////////////////////////
201 /// Add a point on the track.
202 
204 {
205  if (!fPoints) {
206  fPointsSize = 16;
208  } else {
209  if (fNpoints>=fPointsSize) {
210  Double_t *temp = new Double_t[2*fPointsSize];
211  memcpy(temp, fPoints, fNpoints*sizeof(Double_t));
212  fPointsSize *= 2;
213  delete [] fPoints;
214  fPoints = temp;
215  }
216  }
217  fPoints[fNpoints++] = x;
218  fPoints[fNpoints++] = y;
219  fPoints[fNpoints++] = z;
220  fPoints[fNpoints++] = t;
221 }
222 
223 ////////////////////////////////////////////////////////////////////////////////
224 /// How-to-browse for a track.
225 
227 {
228  if (!b) return;
229  Int_t nd = GetNdaughters();
230  if (!nd) {
231  b->Add(this);
232  return;
233  }
234  for (Int_t i=0; i<nd; i++)
235  b->Add(GetDaughter(i));
236 
237 }
238 
239 ////////////////////////////////////////////////////////////////////////////////
240 /// Returns distance to track primitive for picking.
241 
243 {
244  const Int_t inaxis = 7;
245  const Int_t maxdist = 5;
246  Int_t dist = 9999;
247 
248 
249  Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin());
250  Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin());
251  Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax());
252  Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax());
253 
254  // return if point is not in the user area
255  if (px < puxmin - inaxis) return dist;
256  if (py > puymin + inaxis) return dist;
257  if (px > puxmax + inaxis) return dist;
258  if (py < puymax - inaxis) return dist;
259 
260  TView *view = gPad->GetView();
261  if (!view) return dist;
262  Int_t imin, imax;
263  if (TObject::TestBit(kGeoPDrawn) && Size(imin,imax)>=2) {
264  Int_t i, dsegment;
265  Double_t x1,y1,x2,y2;
266  Double_t xndc[3];
267  Int_t np = fNpoints>>2;
268  if (imin<0) imin=0;
269  if (imax>np-1) imax=np-1;
270  for (i=imin;i<imax;i++) {
271  view->WCtoNDC(&fPoints[i<<2], xndc);
272  x1 = xndc[0];
273  y1 = xndc[1];
274  view->WCtoNDC(&fPoints[(i+1)<<2], xndc);
275  x2 = xndc[0];
276  y2 = xndc[1];
277  dsegment = DistancetoLine(px,py,x1,y1,x2,y2);
278 // printf("%i: dseg=%i\n", i, dsegment);
279  if (dsegment < dist) {
280  dist = dsegment;
281  if (dist<maxdist) {
282  gPad->SetSelected(this);
283  return 0;
284  }
285  }
286  }
287  }
288  // check now daughters
289  Int_t nd = GetNdaughters();
290  if (!nd) return dist;
291  TGeoTrack *track;
292  for (Int_t id=0; id<nd; id++) {
293  track = (TGeoTrack*)GetDaughter(id);
294  dist = track->DistancetoPrimitive(px,py);
295  if (dist<maxdist) return 0;
296  }
297  return dist;
298 }
299 
300 ////////////////////////////////////////////////////////////////////////////////
301 /// Draw this track overimposed on a geometry, according to option.
302 /// Options (case sensitive):
303 /// default : track without daughters
304 /// /D : track and first level descendents only
305 /// /* : track and all descendents
306 /// /Ntype
307 /// : descendents of this track with particle name matching input type.
308 /// Options can appear only once but can be combined : e.g. Draw("/D /Npion-")
309 /// Time range for visible track segments can be set via TGeoManager::SetTminTmax()
310 
312 {
313  if (!gPad) gGeoManager->GetMasterVolume()->Draw();
314  char *opt1 = Compress(option); // we will have to delete this ?
315  TString opt(opt1);
316  Bool_t is_default = kTRUE;
317  Bool_t is_onelevel = kFALSE;
318  Bool_t is_all = kFALSE;
319  Bool_t is_type = kFALSE;
320  if (opt.Contains("/D")) {
321  is_onelevel = kTRUE;
322  is_default = kFALSE;
323  }
324  if (opt.Contains("/*")) {
325  is_all = kTRUE;
326  is_default = kFALSE;
327  }
328  if (opt.Contains("/N")) {
329  is_type = kTRUE;
330  Int_t ist = opt.Index("/N")+2;
331  Int_t ilast = opt.Index("/",ist);
332  if (ilast<0) ilast=opt.Length();
333  TString type = opt(ist, ilast-ist);
335  }
336  SetBits(is_default, is_onelevel, is_all, is_type);
337  AppendPad("SAME");
338  if (!gGeoManager->IsAnimatingTracks()) {
339  gPad->Modified();
340  gPad->Update();
341  }
342  delete [] opt1;
343  return;
344 }
345 
346  ///////////////////////////////////////////////////////////////////////////////
347  /// Event treatment.
348 
349 void TGeoTrack::ExecuteEvent(Int_t /*event*/, Int_t /*px*/, Int_t /*py*/)
350 {
351  if (!gPad) return;
352  gPad->SetCursor(kHand);
353 }
354 
355 ////////////////////////////////////////////////////////////////////////////////
356 /// Get some info about the track.
357 
358 char *TGeoTrack::GetObjectInfo(Int_t /*px*/, Int_t /*py*/) const
359 {
360  static TString info;
361  Double_t x=0,y=0,z=0,t=0;
362  GetPoint(0,x,y,z,t);
363  info = TString::Format("%s (%g, %g, %g) tof=%g", GetName(),x,y,z,t);
364  return (char*)info.Data();
365 }
366 
367 ////////////////////////////////////////////////////////////////////////////////
368 /// Get coordinates for point I on the track.
369 
371 {
372  Int_t np = fNpoints>>2;
373  if (i<0 || i>=np) {
374  Error("GetPoint", "no point %i, indmax=%d", i, np-1);
375  return -1;
376  }
377  Int_t icrt = 4*i;
378  x = fPoints[icrt];
379  y = fPoints[icrt+1];
380  z = fPoints[icrt+2];
381  t = fPoints[icrt+3];
382  return i;
383 }
384 
385 ////////////////////////////////////////////////////////////////////////////////
386 /// Return the pointer to the array of points starting with index I.
387 
389 {
390  if (!fNpoints) return 0;
391  return (&fPoints[i<<2]);
392 }
393 
394 ////////////////////////////////////////////////////////////////////////////////
395 /// Return the index of point on track having closest TOF smaller than
396 /// the input value. Output POINT is filled with the interpolated value.
397 
398 Int_t TGeoTrack::GetPoint(Double_t tof, Double_t *point, Int_t istart) const
399 {
400  Int_t np = fNpoints>>2;
401  if (istart>(np-2)) return (np-1);
402  Int_t ip = SearchPoint(tof, istart);
403  if (ip<0 || ip>(np-2)) return ip;
404  // point in segment (ip, ip+1) where 0<=ip<fNpoints-1
405  Int_t i;
406  Int_t j = ip<<2;
407  Int_t k = (ip+1)<<2;
408  Double_t dt = tof-fPoints[j+3];
409  Double_t ddt = fPoints[k+3]-fPoints[j+3];
410  for (i=0; i<3; i++) point[i] = fPoints[j+i] +(fPoints[k+i]-fPoints[j+i])*dt/ddt;
411  return ip;
412 }
413 
414 ////////////////////////////////////////////////////////////////////////////////
415 /// Paint this track (and descendents) with current attributes.
416 
418 {
419  Bool_t is_default = TObject::TestBit(kGeoPDefault);
420  Bool_t is_onelevel = TObject::TestBit(kGeoPOnelevel);
422  Bool_t is_type = TObject::TestBit(kGeoPType);
423  Bool_t match_type = kTRUE;
425  if (is_type) {
426  const char *type = gGeoManager->GetParticleName();
427  if (strlen(type) && strcmp(type, GetName())) match_type=kFALSE;
428  }
429  if (match_type) {
430  if (is_default || is_onelevel || is_all) PaintTrack(option);
431  }
432  // paint now daughters
433  Int_t nd = GetNdaughters();
434  if (!nd || is_default) return;
435  TGeoTrack *track;
436  for (Int_t i=0; i<nd; i++) {
437  track = (TGeoTrack*)GetDaughter(i);
438  if (track->IsInTimeRange()) {
439  track->SetBits(is_default,kFALSE,is_all,is_type);
440  track->Paint(option);
441  }
442  }
443 }
444 
445 ////////////////////////////////////////////////////////////////////////////////
446 /// Paint track and daughters.
447 
449 {
450  Bool_t is_default = TObject::TestBit(kGeoPDefault);
451  Bool_t is_onelevel = TObject::TestBit(kGeoPOnelevel);
453  Bool_t is_type = TObject::TestBit(kGeoPType);
454  Bool_t match_type = kTRUE;
455  if (is_type) {
456  const char *type = gGeoManager->GetParticleName();
457  if (strlen(type) && strcmp(type, GetName())) match_type=kFALSE;
458  }
459  if (match_type) {
460  if (is_default || is_onelevel || is_all) PaintCollectTrack(time, box);
461  }
462  // loop now daughters
463  Int_t nd = GetNdaughters();
464  if (!nd || is_default) return;
465  TGeoTrack *track;
466  for (Int_t i=0; i<nd; i++) {
467  track = (TGeoTrack*)GetDaughter(i);
468  if (track) track->PaintCollect(time, box);
469  }
470 }
471 
472 ////////////////////////////////////////////////////////////////////////////////
473 /// Paint just this track.
474 
476 {
478  if (!painter) return;
479  Int_t np = fNpoints>>2;
480  Double_t point[3], local[3];
482  Int_t ip = GetPoint(time, point);
483  if (ip>=0 && ip<np-1) {
484  if (convert) gGeoManager->MasterToTop(point, local);
485  else memcpy(local, point, 3*sizeof(Double_t));
486  painter->AddTrackPoint(local, box);
487  }
488 }
489 
490 ////////////////////////////////////////////////////////////////////////////////
491 /// Paint current point of the track as marker.
492 
494 {
495  TPoint p;
496  Double_t xndc[3];
497  TView *view = gPad->GetView();
498  if (!view) return;
499  view->WCtoNDC(point, xndc);
500  if (xndc[0] < gPad->GetX1() || xndc[0] > gPad->GetX2()) return;
501  if (xndc[1] < gPad->GetY1() || xndc[1] > gPad->GetY2()) return;
502  p.fX = gPad->XtoPixel(xndc[0]);
503  p.fY = gPad->YtoPixel(xndc[1]);
505  gVirtualX->DrawPolyMarker(1, &p);
506 }
507 
508 ////////////////////////////////////////////////////////////////////////////////
509 /// Paint this track with its current attributes.
510 
512 {
513  // Check whether there is some 3D view class for this TPad
514 // TPadView3D *view3D = (TPadView3D*)gPad->GetView3D();
515 // if (view3D) view3D->PaintGeoTrack(this,option); // to be implemented
516 
517  // Check if option is 'x3d'. NOTE: This is a simple checking
518  // but since there is no other
519  // options yet, this works fine.
520  TString opt(option);
521  opt.ToLower();
523  if (opt.Contains("x")) return;
524  Int_t np = fNpoints>>2;
525  Int_t imin=0;
526  Int_t imax=np-1;
527  Int_t ip;
528  Double_t start[3] = {0.,0.,0.};
529  Double_t end[3] = {0.,0.,0.};
530  Double_t seg[6] = {0.,0.,0.,0.,0.,0.};
532  Double_t tmin=0.,tmax=0.;
533  Bool_t is_time = gGeoManager->GetTminTmax(tmin,tmax);
534  if (is_time) {
535  imin = GetPoint(tmin, start);
536  if (imin>=0 && imin<np-1) {
537  // we have a starting point -> find ending point
538  imax = GetPoint(tmax, end, imin);
539  if (imax<np-1) {
540  // we also have an ending point -> check if on the same segment with imin
541  if (imax==imin) {
542  // paint the virtual segment between the 2 points
544  if (convert) {
545  gGeoManager->MasterToTop(start, &seg[0]);
546  gGeoManager->MasterToTop(end, &seg[3]);
547  gPad->PaintLine3D(&seg[0], &seg[3]);
548  } else {
549  gPad->PaintLine3D(start, end);
550  }
551  } else {
552  // paint the starting, ending and connecting segments
554  if (convert) {
555  gGeoManager->MasterToTop(start, &seg[0]);
556  gGeoManager->MasterToTop(&fPoints[(imin+1)<<2], &seg[3]);
557  gPad->PaintLine3D(&seg[0], &seg[3]);
558  gGeoManager->MasterToTop(&fPoints[imax<<2], &seg[0]);
559  gGeoManager->MasterToTop(end, &seg[3]);
560  gPad->PaintLine3D(&seg[0], &seg[3]);
561  for (ip=imin+1; ip<imax; ip++) {
562  gGeoManager->MasterToTop(&fPoints[ip<<2], &seg[0]);
563  gGeoManager->MasterToTop(&fPoints[(ip+1)<<2], &seg[3]);
564  gPad->PaintLine3D(&seg[0], &seg[3]);
565  }
566  } else {
567  gPad->PaintLine3D(start, &fPoints[(imin+1)<<2]);
568  gPad->PaintLine3D(&fPoints[imax<<2], end);
569  for (ip=imin+1; ip<imax; ip++) {
570  gPad->PaintLine3D(&fPoints[ip<<2], &fPoints[(ip+1)<<2]);
571  }
572  }
573  }
574  if (convert) {
575  gGeoManager->MasterToTop(end, &seg[0]);
576  PaintMarker(&seg[0]);
577  } else {
578  PaintMarker(end);
579  }
580  } else {
582  if (convert) {
583  gGeoManager->MasterToTop(start, &seg[0]);
584  gGeoManager->MasterToTop(&fPoints[(imin+1)<<2], &seg[3]);
585  gPad->PaintLine3D(&seg[0], &seg[3]);
586  for (ip=imin+1; ip<np-2; ip++) {
587  gGeoManager->MasterToTop(&fPoints[ip<<2], &seg[0]);
588  gGeoManager->MasterToTop(&fPoints[(ip+1)<<2], &seg[3]);
589  gPad->PaintLine3D(&seg[0], &seg[3]);
590  }
591  } else {
592  gPad->PaintLine3D(start, &fPoints[(imin+1)<<2]);
593  for (ip=imin+1; ip<np-2; ip++) {
594  gPad->PaintLine3D(&fPoints[ip<<2], &fPoints[(ip+1)<<2]);
595  }
596  }
597  }
598  } else {
599  imax = GetPoint(tmax, end);
600  if (imax<0 || imax>=(np-1)) return;
601  // we have to draw just the end of the track
603  if (convert) {
604  for (ip=0; ip<imax-1; ip++) {
605  gGeoManager->MasterToTop(&fPoints[ip<<2], &seg[0]);
606  gGeoManager->MasterToTop(&fPoints[(ip+1)<<2], &seg[3]);
607  gPad->PaintLine3D(&seg[0], &seg[3]);
608  }
609  } else {
610  for (ip=0; ip<imax-1; ip++) {
611  gPad->PaintLine3D(&fPoints[ip<<2], &fPoints[(ip+1)<<2]);
612  }
613  }
614  if (convert) {
615  gGeoManager->MasterToTop(&fPoints[imax<<2], &seg[0]);
616  gGeoManager->MasterToTop(end, &seg[3]);
617  gPad->PaintLine3D(&seg[0], &seg[3]);
618  PaintMarker(&seg[3]);
619  } else {
620  gPad->PaintLine3D(&fPoints[imax<<2], end);
621  PaintMarker(end);
622  }
623  }
625  return;
626  }
627 
628  // paint all segments from track
630  TAttLine::Modify(); // change attributes if necessary
631  for (ip=imin; ip<imax; ip++) {
632  gPad->PaintLine3D(&fPoints[ip<<2], &fPoints[(ip+1)<<2]);
633  }
634 }
635 
636 ////////////////////////////////////////////////////////////////////////////////
637 /// Print some info about the track.
638 
639 void TGeoTrack::Print(Option_t * /*option*/) const
640 {
641  Int_t np = fNpoints>>2;
642  printf(" TGeoTrack%6i : %s ===============================\n", fId,GetName());
643  printf(" parent =%6i nd =%3i\n", (fParent)?fParent->GetId():-1, GetNdaughters());
644  Double_t x=0,y=0,z=0,t=0;
645  GetPoint(0,x,y,z,t);
646  printf(" production vertex : (%g, %g, %g) at tof=%g\n", x,y,z,t);
647  GetPoint(np-1,x,y,z,t);
648  printf(" Npoints =%6i, last : (%g, %g, %g) at tof=%g\n\n", np,x,y,z,t);
649 }
650 
651 ////////////////////////////////////////////////////////////////////////////////
652 /// Return the number of points within the time interval specified by
653 /// TGeoManager class and the corresponding indices.
654 
656 {
657  Double_t tmin, tmax;
658  Int_t np = fNpoints>>2;
659  imin = 0;
660  imax = np-1;
661  Int_t size = np;
662  if (!gGeoManager->GetTminTmax(tmin, tmax)) return size;
663  imin = SearchPoint(tmin);
664  imax = SearchPoint(tmax, imin);
665  return (imax-imin+1);
666 }
667 
668 ////////////////////////////////////////////////////////////////////////////////
669 /// Search index of track point having the closest time tag smaller than
670 /// TIME. Optional start index can be provided.
671 
673 {
674  Int_t nabove, nbelow, middle, midloc;
675  Int_t np = fNpoints>>2;
676  nabove = np+1;
677  nbelow = istart;
678  while (nabove-nbelow > 1) {
679  middle = (nabove+nbelow)/2;
680  midloc = ((middle-1)<<2)+3;
681  if (time == fPoints[midloc]) return middle-1;
682  if (time < fPoints[midloc]) nabove = middle;
683  else nbelow = middle;
684  }
685  return (nbelow-1);
686 }
687 
688 ////////////////////////////////////////////////////////////////////////////////
689 /// Set drawing bits for this track
690 
691 void TGeoTrack::SetBits(Bool_t is_default, Bool_t is_onelevel,
692  Bool_t is_all, Bool_t is_type)
693 {
694  TObject::SetBit(kGeoPDefault, is_default);
695  TObject::SetBit(kGeoPOnelevel, is_onelevel);
697  TObject::SetBit(kGeoPType, is_type);
698 }
699 
700 ////////////////////////////////////////////////////////////////////////////////
701 /// Returns 3D size for the track.
702 
704 {
705 }
706 
707 ////////////////////////////////////////////////////////////////////////////////
708 /// Reset data for this track.
709 
711 {
712  fNpoints = 0;
713  fPointsSize = 0;
714  if (fTracks) {fTracks->Delete(); delete fTracks;}
715  fTracks = 0;
716  if (fPoints) delete [] fPoints;
717  fPoints = 0;
718 }
719 
void Add(TObject *obj, const char *name=0, Int_t check=-1)
Add object with name to browser.
Definition: TBrowser.cxx:261
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
Int_t SearchPoint(Double_t time, Int_t istart=0) const
Search index of track point having the closest time tag smaller than TIME.
Definition: TGeoTrack.cxx:672
TGeoTrack()
-*-*-*-*-*-*-*-*-*-*Tracks default constructor-*-*-*-*-*-*-*-* *-* ========================== ...
Definition: TGeoTrack.cxx:37
double dist(Rotation3D const &r1, Rotation3D const &r2)
Definition: 3DDistances.cxx:48
An array of TObjects.
Definition: TObjArray.h:37
virtual void GetViewAngles(Double_t &, Double_t &, Double_t &)
Bool_t GetTminTmax(Double_t &tmin, Double_t &tmax) const
Get time cut for drawing tracks.
virtual const char * GetName() const
Get the PDG name.
Bool_t IsInTimeRange() const
True if track TOF range overlaps with time interval of TGeoManager.
char * Compress(const char *str)
Remove all blanks from the string str.
Definition: TString.cxx:2538
virtual Double_t * GetViewBox()=0
virtual void WCtoNDC(const Float_t *pw, Float_t *pn)=0
virtual void PaintCollectTrack(Double_t time, Double_t *box)
Paint just this track.
Definition: TGeoTrack.cxx:475
const char Option_t
Definition: RtypesCore.h:62
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Definition: TObjArray.cxx:329
void SetParticleName(const char *pname)
Definition: TGeoManager.h:236
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:159
virtual void Draw(Option_t *option="")
draw top volume according to option
See TView3D.
Definition: TView.h:25
SCoord_t fX
Definition: TPoint.h:35
virtual void PaintCollect(Double_t time, Double_t *box)
Paint track and daughters.
Definition: TGeoTrack.cxx:448
Int_t fPointsSize
Definition: TGeoTrack.h:43
virtual void Draw(Option_t *option="")
Draw this track overimposed on a geometry, according to option.
Definition: TGeoTrack.cxx:311
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:587
SCoord_t fY
Definition: TPoint.h:36
Basic string class.
Definition: TString.h:129
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1099
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TGeoVolume * GetMasterVolume() const
Definition: TGeoManager.h:495
virtual void Modify()
Change current line attributes if necessary.
Definition: TAttLine.cxx:232
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition: fillpatterns.C:1
virtual void Paint(Option_t *option="")
Paint this track (and descendents) with current attributes.
Definition: TGeoTrack.cxx:417
Int_t GetId() const
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:687
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:112
virtual void ResetTrack()
Reset data for this track.
Definition: TGeoTrack.cxx:710
virtual TVirtualGeoTrack * AddDaughter(Int_t id, Int_t pdgcode, TObject *particle=0)
Add a daughter track to this.
Definition: TGeoTrack.cxx:105
static const double x2[5]
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:135
Double_t x[n]
Definition: legend1.C:17
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition: TString.cxx:2345
virtual void GrabFocus(Int_t nfr=0, Double_t dlong=0, Double_t dlat=0, Double_t dpsi=0)=0
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition: TAttMarker.h:38
Base class for user-defined tracks attached to a geometry.
TGeoTrack & operator=(const TGeoTrack &)
Assignment operator. NOT TO BE CALLED.
Definition: TGeoTrack.cxx:82
Bool_t IsAnimatingTracks() const
Definition: TGeoManager.h:384
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Event treatment.
Definition: TGeoTrack.cxx:349
Definition: TPoint.h:31
A doubly linked list.
Definition: TList.h:43
virtual void PaintTrack(Option_t *option="")
Paint this track with its current attributes.
Definition: TGeoTrack.cxx:511
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
virtual void Print(Option_t *option="") const
Print some info about the track.
Definition: TGeoTrack.cxx:639
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
virtual void Modify()
Change current marker attributes if necessary.
Definition: TAttMarker.cxx:219
virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y, Double_t &z, Double_t &t) const
Get coordinates for point I on the track.
Definition: TGeoTrack.cxx:370
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Returns distance to track primitive for picking.
Definition: TGeoTrack.cxx:242
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
Definition: TObjArray.cxx:222
virtual void AddPoint(Double_t x, Double_t y, Double_t z, Double_t t)
Add a point on the track.
Definition: TGeoTrack.cxx:203
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:679
Int_t Size(Int_t &imin, Int_t &imax)
Return the number of points within the time interval specified by TGeoManager class and the correspon...
Definition: TGeoTrack.cxx:655
virtual void AnimateTrack(Double_t tmin=0, Double_t tmax=5E-8, Double_t nframes=200, Option_t *option="/*")
Draw animation of this track.
Definition: TGeoTrack.cxx:129
Int_t GetEntriesFast() const
Definition: TObjArray.h:64
virtual void EstimateCameraMove(Double_t, Double_t, Double_t *, Double_t *)
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:873
Ssiz_t Length() const
Definition: TString.h:388
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition: TAttMarker.h:40
TVirtualGeoTrack * GetDaughter(Int_t index) const
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition: TAttMarker.h:41
#define gVirtualX
Definition: TVirtualX.h:350
constexpr Double_t E()
Definition: TMath.h:74
Int_t fNpoints
Definition: TGeoTrack.h:44
const Bool_t kFALSE
Definition: RtypesCore.h:92
void convert(R1 const &, R2 const)
Definition: 3DConversions.h:41
Double_t * fPoints
Definition: TGeoTrack.h:45
static const double x1[5]
#define ClassImp(name)
Definition: Rtypes.h:336
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:553
double Double_t
Definition: RtypesCore.h:55
int type
Definition: TGX11.cxx:120
void Browse(TBrowser *b)
How-to-browse for a track.
Definition: TGeoTrack.cxx:226
Double_t y[n]
Definition: legend1.C:17
TVirtualGeoTrack & operator=(const TVirtualGeoTrack &)
Assignment operator. NOT TO BE CALLED.
Int_t DistancetoLine(Int_t px, Int_t py, Double_t xp1, Double_t yp1, Double_t xp2, Double_t yp2)
Compute distance from point px,py to a line.
Definition: TAttLine.cxx:196
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:572
void SetTminTmax(Double_t tmin=0, Double_t tmax=999)
Set time cut interval for drawing tracks.
Mother of all ROOT objects.
Definition: TObject.h:37
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
void MasterToTop(const Double_t *master, Double_t *top) const
Convert coordinates from master volume frame to top.
Abstract class for geometry painters.
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Get some info about the track.
Definition: TGeoTrack.cxx:358
void SetVisLevel(Int_t level=3)
set default level down to which visualization is performed
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
void SetAnimateTracks(Bool_t flag=kTRUE)
Definition: TGeoManager.h:531
TObjArray * fTracks
#define gPad
Definition: TVirtualPad.h:284
virtual void AddTrackPoint(Double_t *point, Double_t *box, Bool_t reset=kFALSE)=0
virtual ~TGeoTrack()
Destructor.
Definition: TGeoTrack.cxx:96
TGeoVolume * GetTopVolume() const
Definition: TGeoManager.h:496
Int_t GetNdaughters() const
const Bool_t kTRUE
Definition: RtypesCore.h:91
TVirtualGeoPainter * GetGeomPainter()
Make a default painter if none present. Returns pointer to it.
virtual void Sizeof3D() const
Returns 3D size for the track.
Definition: TGeoTrack.cxx:703
TVirtualGeoTrack * fParent
void PaintMarker(Double_t *point, Option_t *option="")
Paint current point of the track as marker.
Definition: TGeoTrack.cxx:493
void SetParent(TVirtualGeoTrack *parent)
void SetBits(Bool_t is_default=kTRUE, Bool_t is_onelevel=kFALSE, Bool_t is_all=kFALSE, Bool_t is_type=kFALSE)
Set drawing bits for this track.
Definition: TGeoTrack.cxx:691
const char * GetParticleName() const
Definition: TGeoManager.h:237
const char * Data() const
Definition: TString.h:347