Logo ROOT   6.08/07
Reference Guide
TGeoPatternFinder.cxx
Go to the documentation of this file.
1 // @(#)root/geom:$Id$
2 // Author: Andrei Gheata 30/10/01
3 
4 /** \class TGeoPatternFinder
5 \ingroup Geometry_classes
6 
7 Base finder class for patterns.
8 
9  A pattern is specifying a division type which applies only to a given
10 shape type. The implemented patterns are for the moment equidistant slices
11 on different axis. Implemented patterns are:
12 
13  - TGeoPatternX - a X axis divison pattern
14  - TGeoPatternY - a Y axis divison pattern
15  - TGeoPatternZ - a Z axis divison pattern
16  - TGeoPatternParaX - a X axis divison pattern for PARA shape
17  - TGeoPatternParaY - a Y axis divison pattern for PARA shape
18  - TGeoPatternParaZ - a Z axis divison pattern for PARA shape
19  - TGeoPatternTrapZ - a Z axis divison pattern for TRAP or GTRA shapes
20  - TGeoPatternCylR - a cylindrical R divison pattern
21  - TGeoPatternCylPhi - a cylindrical phi divison pattern
22  - TGeoPatternSphR - a spherical R divison pattern
23  - TGeoPatternSphTheta - a spherical theta divison pattern
24  - TGeoPatternSphPhi - a spherical phi divison pattern
25  - TGeoPatternHoneycomb - a divison pattern specialized for honeycombs
26 */
27 
28 #include "TGeoPatternFinder.h"
29 
30 #include "Riostream.h"
31 #include "TBuffer.h"
32 #include "TObject.h"
33 #include "TThread.h"
34 #include "TGeoMatrix.h"
35 #include "TGeoPara.h"
36 #include "TGeoArb8.h"
37 #include "TGeoNode.h"
38 #include "TGeoManager.h"
39 #include "TMath.h"
40 
55 
56 
57 ////////////////////////////////////////////////////////////////////////////////
58 /// Constructor.
59 
61  fMatrix(0), fCurrent(-1), fNextIndex(-1)
62 {
63 }
64 
65 ////////////////////////////////////////////////////////////////////////////////
66 /// Destructor.
67 
69 {
70 // if (fMatrix != gGeoIdentity) delete fMatrix;
71 }
72 
73 ////////////////////////////////////////////////////////////////////////////////
74 
76 {
78 /*
79  if (tid >= fThreadSize) {
80  Error("GetThreadData", "Thread id=%d bigger than maximum declared thread number %d. \nUse TGeoManager::SetMaxThreads properly !!!",
81  tid, fThreadSize);
82  }
83 
84  TThread::Lock();
85  if (tid >= fThreadSize)
86  {
87  fThreadData.resize(tid + 1);
88  fThreadSize = tid + 1;
89  }
90  if (fThreadData[tid] == 0)
91  {
92  fThreadData[tid] = new ThreadData_t;
93  fThreadData[tid]->fMatrix = CreateMatrix();
94  }
95  TThread::UnLock();
96 */
97  return *fThreadData[tid];
98 }
99 
100 ////////////////////////////////////////////////////////////////////////////////
101 
103 {
104  TThread::Lock();
105  std::vector<ThreadData_t*>::iterator i = fThreadData.begin();
106  while (i != fThreadData.end())
107  {
108  delete *i;
109  ++i;
110  }
111  fThreadData.clear();
112  fThreadSize = 0;
113  TThread::UnLock();
114 }
115 
116 ////////////////////////////////////////////////////////////////////////////////
117 /// Create thread data for n threads max.
118 
120 {
121  TThread::Lock();
122  fThreadData.resize(nthreads);
123  fThreadSize = nthreads;
124  for (Int_t tid=0; tid<nthreads; tid++) {
125  if (fThreadData[tid] == 0) {
126  fThreadData[tid] = new ThreadData_t;
127  fThreadData[tid]->fMatrix = CreateMatrix();
128  }
129  }
130  TThread::UnLock();
131 }
132 
133 ////////////////////////////////////////////////////////////////////////////////
134 /// Default constructor
135 
137 {
138  fNdivisions = 0;
139  fDivIndex = 0;
140  fStep = 0;
141  fStart = 0;
142  fEnd = 0;
143  fVolume = 0;
144  fThreadSize = 0;
145 }
146 
147 ////////////////////////////////////////////////////////////////////////////////
148 /// Default constructor
149 
151 {
152  fVolume = vol;
153  fNdivisions = ndiv;
154  fDivIndex = 0;
155  fStep = 0;
156  fStart = 0;
157  fEnd = 0;
158  fThreadSize = 0;
159 }
160 
161 ////////////////////////////////////////////////////////////////////////////////
162 ///copy constructor
163 
165  TObject(pf),
166  fStep(pf.fStep),
167  fStart(pf.fStart),
168  fEnd(pf.fEnd),
170  fDivIndex(pf.fDivIndex),
171  fVolume(pf.fVolume)
172 {
173 }
174 
175 ////////////////////////////////////////////////////////////////////////////////
176 ///assignment operator
177 
179 {
180  if(this!=&pf) {
181  TObject::operator=(pf);
182  fStep=pf.fStep;
183  fStart=pf.fStart;
184  fEnd=pf.fEnd;
186  fDivIndex=pf.fDivIndex;
187  fVolume=pf.fVolume;
188  }
189  return *this;
190 }
191 
192 ////////////////////////////////////////////////////////////////////////////////
193 /// Destructor
194 
196 {
197  ClearThreadData();
198 }
199 
200 ////////////////////////////////////////////////////////////////////////////////
201 /// Return current index.
202 
204 {
205  return GetThreadData().fCurrent;
206 }
207 
208 ////////////////////////////////////////////////////////////////////////////////
209 /// Return current matrix.
210 
212 {
213  return GetThreadData().fMatrix;
214 }
215 
216 ////////////////////////////////////////////////////////////////////////////////
217 /// Get index of next division.
218 
220 {
221  return GetThreadData().fNextIndex;
222 }
223 
224 ////////////////////////////////////////////////////////////////////////////////
225 /// Set index of next division.
226 
228 {
229  GetThreadData().fNextIndex = index;
230 }
231 
232 ////////////////////////////////////////////////////////////////////////////////
233 /// Make next node (if any) current.
234 
236 {
237  ThreadData_t& td = GetThreadData();
238  if (td.fNextIndex < 0) return NULL;
239  cd(td.fNextIndex);
240  return GetNodeOffset(td.fCurrent);
241 }
242 
243 ////////////////////////////////////////////////////////////////////////////////
244 /// Set division range. Use this method only when dividing an assembly.
245 
246 void TGeoPatternFinder::SetRange(Double_t start, Double_t step, Int_t ndivisions)
247 {
248  fStart = start;
249  fEnd = fStart + ndivisions*step;
250  fStep = step;
251  fNdivisions = ndivisions;
252 }
253 
254 //______________________________________________________________________________
255 // TGeoPatternX - a X axis divison pattern
256 //______________________________________________________________________________
257 
258 ////////////////////////////////////////////////////////////////////////////////
259 /// Default constructor
260 
262 {
263  CreateThreadData(1);
264 }
265 
266 ////////////////////////////////////////////////////////////////////////////////
267 /// constructor
268 
270  :TGeoPatternFinder(vol, ndivisions)
271 {
272  Double_t dx = ((TGeoBBox*)vol->GetShape())->GetDX();
273  fStart = -dx;
274  fEnd = dx;
275  fStep = 2*dx/ndivisions;
276  CreateThreadData(1);
277 }
278 
279 ////////////////////////////////////////////////////////////////////////////////
280 /// constructor
281 
283  :TGeoPatternFinder(vol, ndivisions)
284 {
285  Double_t dx = ((TGeoBBox*)vol->GetShape())->GetDX();
286  fStart = -dx;
287  fEnd = fStart + ndivisions*step;
288  fStep = step;
289  CreateThreadData(1);
290 }
291 
292 ////////////////////////////////////////////////////////////////////////////////
293 /// constructor
294 
296  :TGeoPatternFinder(vol, ndivisions)
297 {
298  fStart = start;
299  fEnd = end;
300  fStep = (end - start)/ndivisions;
301  CreateThreadData(1);
302 }
303 
304 ////////////////////////////////////////////////////////////////////////////////
305 ///copy constructor
306 
309 {
310  CreateThreadData(1);
311 }
312 
313 ////////////////////////////////////////////////////////////////////////////////
314 ///assignment operator
315 
317 {
318  if(this!=&pf) {
320  CreateThreadData(1);
321  }
322  return *this;
323 }
324 
325 ////////////////////////////////////////////////////////////////////////////////
326 /// Destructor
327 
329 {
330 }
331 
332 ////////////////////////////////////////////////////////////////////////////////
333 /// Update current division index and global matrix to point to a given slice.
334 
336 {
337  ThreadData_t& td = GetThreadData();
338  td.fCurrent=idiv;
339  td.fMatrix->SetDx(fStart+idiv*fStep+0.5*fStep);
340 }
341 
342 ////////////////////////////////////////////////////////////////////////////////
343 /// Return new matrix of type used by this finder.
344 
346 {
347  if (!IsReflected()) {
348  TGeoMatrix *matrix = new TGeoTranslation(0.,0.,0.);
349  matrix->RegisterYourself();
350  return matrix;
351  }
352  TGeoCombiTrans *combi = new TGeoCombiTrans();
353  combi->RegisterYourself();
354  combi->ReflectZ(kTRUE);
355  combi->ReflectZ(kFALSE);
356  return combi;
357 }
358 
359 ////////////////////////////////////////////////////////////////////////////////
360 /// Fills external matrix with the local one corresponding to the given division
361 /// index.
362 
364 {
365  matrix.Clear();
366  matrix.SetDx(fStart+idiv*fStep+0.5*fStep);
367 }
368 
369 ////////////////////////////////////////////////////////////////////////////////
370 /// Checks if the current point is on division boundary
371 
373 {
374  Double_t seg = (point[0]-fStart)/fStep;
375  Double_t diff = seg - Int_t(seg);
376  if (diff>0.5) diff = 1.-diff;
377  if (diff<1e-8) return kTRUE;
378  return kFALSE;
379 }
380 
381 ////////////////////////////////////////////////////////////////////////////////
382 /// Find the cell corresponding to point and next cell along dir (if asked)
383 
385 {
386  ThreadData_t& td = GetThreadData();
387  TGeoNode *node = 0;
388  Int_t ind = (Int_t)(1.+(point[0]-fStart)/fStep) - 1;
389  if (dir) {
390  td.fNextIndex = ind;
391  if (dir[0]>0) td.fNextIndex++;
392  else td.fNextIndex--;
393  if ((td.fNextIndex<0) || (td.fNextIndex>=fNdivisions)) td.fNextIndex = -1;
394  }
395  if ((ind<0) || (ind>=fNdivisions)) return node;
396  node = GetNodeOffset(ind);
397  cd(ind);
398  return node;
399 }
400 
401 ////////////////////////////////////////////////////////////////////////////////
402 /// Compute distance to next division layer returning the index of next section.
403 /// Point is in the frame of the divided volume.
404 
406 {
407  ThreadData_t& td = GetThreadData();
408  indnext = -1;
410  if (TMath::Abs(dir[0])<TGeoShape::Tolerance()) return dist;
411  if (td.fCurrent<0) {
412  Error("FindNextBoundary", "Must call FindNode first");
413  return dist;
414  }
415  Int_t inc = (dir[0]>0)?1:0;
416  dist = (fStep*(td.fCurrent+inc)-point[0])/dir[0];
417  if (dist<0.) Error("FindNextBoundary", "Negative distance d=%g",dist);
418  if (!inc) inc = -1;
419  indnext = td.fCurrent+inc;
420  return dist;
421 }
422 
423 ////////////////////////////////////////////////////////////////////////////////
424 /// Make a copy of this finder. Reflect by Z if required.
425 
427 {
428  TGeoPatternX *finder = new TGeoPatternX(*this);
429  if (!reflect) return finder;
430  finder->Reflect();
431  return finder;
432 }
433 
434 ////////////////////////////////////////////////////////////////////////////////
435 /// Save a primitive as a C++ statement(s) on output stream "out".
436 
437 void TGeoPatternX::SavePrimitive(std::ostream &out, Option_t * /*option*/ /*= ""*/)
438 {
439  Int_t iaxis = 1;
440  out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
441 }
442 
443 //______________________________________________________________________________
444 // TGeoPatternY - a Y axis divison pattern
445 //______________________________________________________________________________
446 
447 
448 ////////////////////////////////////////////////////////////////////////////////
449 /// Default constructor
450 
452 {
453  CreateThreadData(1);
454 }
455 
456 ////////////////////////////////////////////////////////////////////////////////
457 /// constructor
458 
460  :TGeoPatternFinder(vol, ndivisions)
461 {
462  Double_t dy = ((TGeoBBox*)vol->GetShape())->GetDY();
463  fStart = -dy;
464  fEnd = dy;
465  fStep = 2*dy/ndivisions;
466  CreateThreadData(1);
467 }
468 
469 ////////////////////////////////////////////////////////////////////////////////
470 /// constructor
471 
473  :TGeoPatternFinder(vol, ndivisions)
474 {
475  Double_t dy = ((TGeoBBox*)vol->GetShape())->GetDY();
476  fStart = -dy;
477  fEnd = fStart + ndivisions*step;
478  fStep = step;
479  CreateThreadData(1);
480 }
481 
482 ////////////////////////////////////////////////////////////////////////////////
483 /// constructor
484 
486  :TGeoPatternFinder(vol, ndivisions)
487 {
488  fStart = start;
489  fEnd = end;
490  fStep = (end - start)/ndivisions;
491  CreateThreadData(1);
492 }
493 
494 ////////////////////////////////////////////////////////////////////////////////
495 ///copy constructor
496 
499 {
500  CreateThreadData(1);
501 }
502 
503 ////////////////////////////////////////////////////////////////////////////////
504 ///assignment operator
505 
507 {
508  if(this!=&pf) {
510  CreateThreadData(1);
511  }
512  return *this;
513 }
514 
515 ////////////////////////////////////////////////////////////////////////////////
516 /// Destructor
517 
519 {
520 }
521 
522 ////////////////////////////////////////////////////////////////////////////////
523 /// Update current division index and global matrix to point to a given slice.
524 
526 {
527  ThreadData_t& td = GetThreadData();
528  td.fCurrent=idiv;
529  td.fMatrix->SetDy(fStart+idiv*fStep+0.5*fStep);
530 }
531 
532 ////////////////////////////////////////////////////////////////////////////////
533 /// Return new matrix of type used by this finder.
534 
536 {
537  if (!IsReflected()) {
538  TGeoMatrix *matrix = new TGeoTranslation(0.,0.,0.);
539  matrix->RegisterYourself();
540  return matrix;
541  }
542  TGeoCombiTrans *combi = new TGeoCombiTrans();
543  combi->RegisterYourself();
544  combi->ReflectZ(kTRUE);
545  combi->ReflectZ(kFALSE);
546  return combi;
547 }
548 
549 ////////////////////////////////////////////////////////////////////////////////
550 /// Fills external matrix with the local one corresponding to the given division
551 /// index.
552 
554 {
555  matrix.Clear();
556  matrix.SetDy(fStart+idiv*fStep+0.5*fStep);
557 }
558 
559 ////////////////////////////////////////////////////////////////////////////////
560 /// Checks if the current point is on division boundary
561 
563 {
564  Double_t seg = (point[1]-fStart)/fStep;
565  Double_t diff = seg - Int_t(seg);
566  if (diff>0.5) diff = 1.-diff;
567  if (diff<1e-8) return kTRUE;
568  return kFALSE;
569 }
570 
571 ////////////////////////////////////////////////////////////////////////////////
572 /// Find the cell corresponding to point and next cell along dir (if asked)
573 
575 {
576  ThreadData_t& td = GetThreadData();
577  TGeoNode *node = 0;
578  Int_t ind = (Int_t)(1.+(point[1]-fStart)/fStep) - 1;
579  if (dir) {
580  td.fNextIndex = ind;
581  if (dir[1]>0) td.fNextIndex++;
582  else td.fNextIndex--;
583  if ((td.fNextIndex<0) || (td.fNextIndex>=fNdivisions)) td.fNextIndex = -1;
584  }
585  if ((ind<0) || (ind>=fNdivisions)) return node;
586  node = GetNodeOffset(ind);
587  cd(ind);
588  return node;
589 }
590 
591 ////////////////////////////////////////////////////////////////////////////////
592 /// Compute distance to next division layer returning the index of next section.
593 /// Point is in the frame of the divided volume.
594 
596 {
597  ThreadData_t& td = GetThreadData();
598  indnext = -1;
600  if (TMath::Abs(dir[1])<TGeoShape::Tolerance()) return dist;
601  if (td.fCurrent<0) {
602  Error("FindNextBoundary", "Must call FindNode first");
603  return dist;
604  }
605  Int_t inc = (dir[1]>0)?1:0;
606  dist = (fStep*(td.fCurrent+inc)-point[1])/dir[1];
607  if (dist<0.) Error("FindNextBoundary", "Negative distance d=%g",dist);
608  if (!inc) inc = -1;
609  indnext = td.fCurrent+inc;
610  return dist;
611 }
612 
613 ////////////////////////////////////////////////////////////////////////////////
614 /// Make a copy of this finder. Reflect by Z if required.
615 
617 {
618  TGeoPatternY *finder = new TGeoPatternY(*this);
619  if (!reflect) return finder;
620  finder->Reflect();
621  return finder;
622 }
623 
624 ////////////////////////////////////////////////////////////////////////////////
625 /// Save a primitive as a C++ statement(s) on output stream "out".
626 
627 void TGeoPatternY::SavePrimitive(std::ostream &out, Option_t * /*option*/ /*= ""*/)
628 {
629  Int_t iaxis = 2;
630  out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
631 }
632 
633 //______________________________________________________________________________
634 // TGeoPatternZ - a Z axis divison pattern
635 //______________________________________________________________________________
636 
637 
638 ////////////////////////////////////////////////////////////////////////////////
639 /// Default constructor
640 
642 {
643  CreateThreadData(1);
644 }
645 ////////////////////////////////////////////////////////////////////////////////
646 /// constructor
647 
649  :TGeoPatternFinder(vol, ndivisions)
650 {
651  Double_t dz = ((TGeoBBox*)vol->GetShape())->GetDZ();
652  fStart = -dz;
653  fEnd = dz;
654  fStep = 2*dz/ndivisions;
655  CreateThreadData(1);
656 }
657 ////////////////////////////////////////////////////////////////////////////////
658 /// constructor
659 
661  :TGeoPatternFinder(vol, ndivisions)
662 {
663  Double_t dz = ((TGeoBBox*)vol->GetShape())->GetDZ();
664  fStart = -dz;
665  fEnd = fStart + ndivisions*step;
666  fStep = step;
667  CreateThreadData(1);
668 }
669 ////////////////////////////////////////////////////////////////////////////////
670 /// constructor
671 
673  :TGeoPatternFinder(vol, ndivisions)
674 {
675  fStart = start;
676  fEnd = end;
677  fStep = (end - start)/ndivisions;
678  CreateThreadData(1);
679 }
680 
681 ////////////////////////////////////////////////////////////////////////////////
682 ///copy constructor
683 
686 {
687  CreateThreadData(1);
688 }
689 
690 ////////////////////////////////////////////////////////////////////////////////
691 ///assignment operator
692 
694 {
695  if(this!=&pf) {
697  CreateThreadData(1);
698  }
699  return *this;
700 }
701 
702 ////////////////////////////////////////////////////////////////////////////////
703 /// Destructor
704 
706 {
707 }
708 ////////////////////////////////////////////////////////////////////////////////
709 /// Update current division index and global matrix to point to a given slice.
710 
712 {
713  ThreadData_t& td = GetThreadData();
714  td.fCurrent=idiv;
715  td.fMatrix->SetDz(((IsReflected())?-1.:1.)*(fStart+idiv*fStep+0.5*fStep));
716 }
717 
718 ////////////////////////////////////////////////////////////////////////////////
719 /// Return new matrix of type used by this finder.
720 
722 {
723  if (!IsReflected()) {
724  TGeoMatrix *matrix = new TGeoTranslation(0.,0.,0.);
725  matrix->RegisterYourself();
726  return matrix;
727  }
728  TGeoCombiTrans *combi = new TGeoCombiTrans();
729  combi->RegisterYourself();
730  combi->ReflectZ(kTRUE);
731  combi->ReflectZ(kFALSE);
732  return combi;
733 }
734 
735 ////////////////////////////////////////////////////////////////////////////////
736 /// Fills external matrix with the local one corresponding to the given division
737 /// index.
738 
740 {
741  matrix.Clear();
742  matrix.SetDz(((IsReflected())?-1.:1.)*(fStart+idiv*fStep+0.5*fStep));
743 }
744 
745 ////////////////////////////////////////////////////////////////////////////////
746 /// Checks if the current point is on division boundary
747 
749 {
750  Double_t seg = (point[2]-fStart)/fStep;
751  Double_t diff = seg - Int_t(seg);
752  if (diff>0.5) diff = 1.-diff;
753  if (diff<1e-8) return kTRUE;
754  return kFALSE;
755 }
756 
757 ////////////////////////////////////////////////////////////////////////////////
758 /// Find the cell corresponding to point and next cell along dir (if asked)
759 
761 {
762  ThreadData_t& td = GetThreadData();
763  TGeoNode *node = 0;
764  Int_t ind = (Int_t)(1.+(point[2]-fStart)/fStep) - 1;
765  if (dir) {
766  td.fNextIndex = ind;
767  if (dir[2]>0) td.fNextIndex++;
768  else td.fNextIndex--;
769  if ((td.fNextIndex<0) || (td.fNextIndex>=fNdivisions)) td.fNextIndex = -1;
770  }
771  if ((ind<0) || (ind>=fNdivisions)) return node;
772  node = GetNodeOffset(ind);
773  cd(ind);
774  return node;
775 }
776 
777 ////////////////////////////////////////////////////////////////////////////////
778 /// Compute distance to next division layer returning the index of next section.
779 /// Point is in the frame of the divided volume.
780 
782 {
783  indnext = -1;
784  ThreadData_t& td = GetThreadData();
786  if (TMath::Abs(dir[2])<TGeoShape::Tolerance()) return dist;
787  if (td.fCurrent<0) {
788  Error("FindNextBoundary", "Must call FindNode first");
789  return dist;
790  }
791  Int_t inc = (dir[2]>0)?1:0;
792  dist = (fStep*(td.fCurrent+inc)-point[2])/dir[2];
793  if (dist<0.) Error("FindNextBoundary", "Negative distance d=%g",dist);
794  if (!inc) inc = -1;
795  indnext = td.fCurrent+inc;
796  return dist;
797 }
798 
799 ////////////////////////////////////////////////////////////////////////////////
800 /// Make a copy of this finder. Reflect by Z if required.
801 
803 {
804  TGeoPatternZ *finder = new TGeoPatternZ(*this);
805  if (!reflect) return finder;
806  finder->Reflect();
807  return finder;
808 }
809 
810 ////////////////////////////////////////////////////////////////////////////////
811 /// Save a primitive as a C++ statement(s) on output stream "out".
812 
813 void TGeoPatternZ::SavePrimitive(std::ostream &out, Option_t * /*option*/ /*= ""*/)
814 {
815  Int_t iaxis = 3;
816  out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
817 }
818 
819 //______________________________________________________________________________
820 // TGeoPatternParaX - a X axis divison pattern for PARA shape
821 //______________________________________________________________________________
822 
823 ////////////////////////////////////////////////////////////////////////////////
824 /// Default constructor
825 
827 {
828  CreateThreadData(1);
829 }
830 ////////////////////////////////////////////////////////////////////////////////
831 /// constructor
832 
834  :TGeoPatternFinder(vol, ndivisions)
835 {
836  Double_t dx = ((TGeoPara*)vol->GetShape())->GetX();
837  fStart = -dx;
838  fEnd = dx;
839  fStep = 2*dx/ndivisions;
840  CreateThreadData(1);
841 }
842 ////////////////////////////////////////////////////////////////////////////////
843 /// constructor
844 
846  :TGeoPatternFinder(vol, ndivisions)
847 {
848  Double_t dx = ((TGeoPara*)vol->GetShape())->GetX();
849  fStart = -dx;
850  fEnd = fStart + ndivisions*step;
851  fStep = step;
852  CreateThreadData(1);
853 }
854 ////////////////////////////////////////////////////////////////////////////////
855 /// constructor
856 
858  :TGeoPatternFinder(vol, ndivisions)
859 {
860  fStart = start;
861  fEnd = end;
862  fStep = (end - start)/ndivisions;
863  CreateThreadData(1);
864 }
865 
866 ////////////////////////////////////////////////////////////////////////////////
867 ///copy constructor
868 
871 {
872  CreateThreadData(1);
873 }
874 
875 ////////////////////////////////////////////////////////////////////////////////
876 ///assignment operator
877 
879 {
880  if(this!=&pf) {
882  CreateThreadData(1);
883  }
884  return *this;
885 }
886 
887 ////////////////////////////////////////////////////////////////////////////////
888 /// Destructor
889 
891 {
892 }
893 ////////////////////////////////////////////////////////////////////////////////
894 /// Update current division index and global matrix to point to a given slice.
895 
897 {
898  ThreadData_t& td = GetThreadData();
899  td.fCurrent=idiv;
900  td.fMatrix->SetDx(fStart+idiv*fStep+0.5*fStep);
901 }
902 
903 ////////////////////////////////////////////////////////////////////////////////
904 /// Checks if the current point is on division boundary
905 
907 {
908  Double_t txy = ((TGeoPara*)fVolume->GetShape())->GetTxy();
909  Double_t txz = ((TGeoPara*)fVolume->GetShape())->GetTxz();
910  Double_t tyz = ((TGeoPara*)fVolume->GetShape())->GetTyz();
911  Double_t xt = point[0]-txz*point[2]-txy*(point[1]-tyz*point[2]);
912  Double_t seg = (xt-fStart)/fStep;
913  Double_t diff = seg - Int_t(seg);
914  if (diff>0.5) diff = 1.-diff;
915  if (diff<1e-8) return kTRUE;
916  return kFALSE;
917 }
918 
919 ////////////////////////////////////////////////////////////////////////////////
920 /// get the node division containing the query point
921 
923 {
924  ThreadData_t& td = GetThreadData();
925  TGeoNode *node = 0;
926  Double_t txy = ((TGeoPara*)fVolume->GetShape())->GetTxy();
927  Double_t txz = ((TGeoPara*)fVolume->GetShape())->GetTxz();
928  Double_t tyz = ((TGeoPara*)fVolume->GetShape())->GetTyz();
929  Double_t xt = point[0]-txz*point[2]-txy*(point[1]-tyz*point[2]);
930  Int_t ind = (Int_t)(1.+(xt-fStart)/fStep)-1;
931  if (dir) {
932  Double_t ttsq = txy*txy + (txz-txy*tyz)*(txz-txy*tyz);
933  Double_t divdirx = 1./TMath::Sqrt(1.+ttsq);
934  Double_t divdiry = -txy*divdirx;
935  Double_t divdirz = -(txz-txy*tyz)*divdirx;
936  Double_t dot = dir[0]*divdirx + dir[1]*divdiry + dir[2]*divdirz;
937  td.fNextIndex = ind;
938  if (dot>0) td.fNextIndex++;
939  else td.fNextIndex--;
940  if ((td.fNextIndex<0) || (td.fNextIndex>=fNdivisions)) td.fNextIndex = -1;
941  }
942  if ((ind<0) || (ind>=fNdivisions)) return node;
943  node = GetNodeOffset(ind);
944  cd(ind);
945  return node;
946 }
947 
948 ////////////////////////////////////////////////////////////////////////////////
949 /// Make a copy of this finder. Reflect by Z if required.
950 
952 {
953  TGeoPatternParaX *finder = new TGeoPatternParaX(*this);
954  if (!reflect) return finder;
955  finder->Reflect();
956  return finder;
957 }
958 
959 ////////////////////////////////////////////////////////////////////////////////
960 /// Save a primitive as a C++ statement(s) on output stream "out".
961 
962 void TGeoPatternParaX::SavePrimitive(std::ostream &out, Option_t * /*option*/ /*= ""*/)
963 {
964  Int_t iaxis = 1;
965  out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
966 }
967 
968 ////////////////////////////////////////////////////////////////////////////////
969 /// Return new matrix of type used by this finder.
970 
972 {
973  if (!IsReflected()) {
974  TGeoMatrix *matrix = new TGeoTranslation(0.,0.,0.);
975  matrix->RegisterYourself();
976  return matrix;
977  }
978  TGeoCombiTrans *combi = new TGeoCombiTrans();
979  combi->RegisterYourself();
980  combi->ReflectZ(kTRUE);
981  combi->ReflectZ(kFALSE);
982  return combi;
983 }
984 
985 ////////////////////////////////////////////////////////////////////////////////
986 /// Fills external matrix with the local one corresponding to the given division
987 /// index.
988 
990 {
991  matrix.Clear();
992  matrix.SetDx(fStart+idiv*fStep+0.5*fStep);
993 }
994 
995 //______________________________________________________________________________
996 // TGeoPatternParaY - a Y axis divison pattern for PARA shape
997 //______________________________________________________________________________
998 
999 ////////////////////////////////////////////////////////////////////////////////
1000 /// Default constructor
1001 
1003 {
1004  fTxy = 0;
1005  CreateThreadData(1);
1006 }
1007 ////////////////////////////////////////////////////////////////////////////////
1008 /// constructor
1009 
1011  :TGeoPatternFinder(vol, ndivisions)
1012 {
1013  fTxy = ((TGeoPara*)vol->GetShape())->GetTxy();
1014  Double_t dy = ((TGeoPara*)vol->GetShape())->GetY();
1015  fStart = -dy;
1016  fEnd = dy;
1017  fStep = 2*dy/ndivisions;
1018  CreateThreadData(1);
1019 }
1020 ////////////////////////////////////////////////////////////////////////////////
1021 /// constructor
1022 
1024  :TGeoPatternFinder(vol, ndivisions)
1025 {
1026  fTxy = ((TGeoPara*)vol->GetShape())->GetTxy();
1027  Double_t dy = ((TGeoPara*)vol->GetShape())->GetY();
1028  fStart = -dy;
1029  fEnd = fStart + ndivisions*step;
1030  fStep = step;
1031  CreateThreadData(1);
1032 }
1033 ////////////////////////////////////////////////////////////////////////////////
1034 /// constructor
1035 
1037  :TGeoPatternFinder(vol, ndivisions)
1038 {
1039  fTxy = ((TGeoPara*)vol->GetShape())->GetTxy();
1040  fStart = start;
1041  fEnd = end;
1042  fStep = (end - start)/ndivisions;
1043  CreateThreadData(1);
1044 }
1045 ////////////////////////////////////////////////////////////////////////////////
1046 ///copy constructor
1047 
1049  TGeoPatternFinder(pf)
1050 {
1051  CreateThreadData(1);
1052 }
1053 
1054 ////////////////////////////////////////////////////////////////////////////////
1055 ///assignment operator
1056 
1058 {
1059  if(this!=&pf) {
1061  CreateThreadData(1);
1062  }
1063  return *this;
1064 }
1065 
1066 ////////////////////////////////////////////////////////////////////////////////
1067 /// Destructor
1068 
1070 {
1071 }
1072 ////////////////////////////////////////////////////////////////////////////////
1073 /// Update current division index and global matrix to point to a given slice.
1074 
1076 {
1077  ThreadData_t& td = GetThreadData();
1078  td.fCurrent = idiv;
1079  Double_t dy = fStart+idiv*fStep+0.5*fStep;
1080  td.fMatrix->SetDx(fTxy*dy);
1081  td.fMatrix->SetDy(dy);
1082 }
1083 
1084 ////////////////////////////////////////////////////////////////////////////////
1085 /// Checks if the current point is on division boundary
1086 
1088 {
1089  Double_t tyz = ((TGeoPara*)fVolume->GetShape())->GetTyz();
1090  Double_t yt = point[1]-tyz*point[2];
1091  Double_t seg = (yt-fStart)/fStep;
1092  Double_t diff = seg - Int_t(seg);
1093  if (diff>0.5) diff = 1.-diff;
1094  if (diff<1e-8) return kTRUE;
1095  return kFALSE;
1096 }
1097 
1098 ////////////////////////////////////////////////////////////////////////////////
1099 /// get the node division containing the query point
1100 
1102 {
1103  ThreadData_t& td = GetThreadData();
1104  TGeoNode *node = 0;
1105  Double_t tyz = ((TGeoPara*)fVolume->GetShape())->GetTyz();
1106  Double_t yt = point[1]-tyz*point[2];
1107  Int_t ind = (Int_t)(1.+(yt-fStart)/fStep) - 1;
1108  if (dir) {
1109  Double_t divdiry = 1./TMath::Sqrt(1.+tyz*tyz);
1110  Double_t divdirz = -tyz*divdiry;
1111  Double_t dot = dir[1]*divdiry + dir[2]*divdirz;
1112  td.fNextIndex = ind;
1113  if (dot>0) td.fNextIndex++;
1114  else td.fNextIndex--;
1115  if ((td.fNextIndex<0) || (td.fNextIndex>=fNdivisions)) td.fNextIndex = -1;
1116  }
1117  if ((ind<0) || (ind>=fNdivisions)) return node;
1118  node = GetNodeOffset(ind);
1119  cd(ind);
1120  return node;
1121 }
1122 
1123 ////////////////////////////////////////////////////////////////////////////////
1124 /// Make a copy of this finder. Reflect by Z if required.
1125 
1127 {
1128  TGeoPatternParaY *finder = new TGeoPatternParaY(*this);
1129  if (!reflect) return finder;
1130  finder->Reflect();
1131  return finder;
1132 }
1133 
1134 ////////////////////////////////////////////////////////////////////////////////
1135 /// Save a primitive as a C++ statement(s) on output stream "out".
1136 
1137 void TGeoPatternParaY::SavePrimitive(std::ostream &out, Option_t * /*option*/ /*= ""*/)
1138 {
1139  Int_t iaxis = 2;
1140  out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
1141 }
1142 
1143 ////////////////////////////////////////////////////////////////////////////////
1144 /// Return new matrix of type used by this finder.
1145 
1147 {
1148  if (!IsReflected()) {
1149  TGeoMatrix *matrix = new TGeoTranslation(0.,0.,0.);
1150  matrix->RegisterYourself();
1151  return matrix;
1152  }
1153  TGeoCombiTrans *combi = new TGeoCombiTrans();
1154  combi->RegisterYourself();
1155  combi->ReflectZ(kTRUE);
1156  combi->ReflectZ(kFALSE);
1157  return combi;
1158 }
1159 
1160 ////////////////////////////////////////////////////////////////////////////////
1161 /// Fills external matrix with the local one corresponding to the given division
1162 /// index.
1163 
1165 {
1166  matrix.Clear();
1167  Double_t dy = fStart+idiv*fStep+0.5*fStep;
1168  matrix.SetDx(fTxy*dy);
1169  matrix.SetDy(dy);
1170 }
1171 
1172 //______________________________________________________________________________
1173 // TGeoPatternParaZ - a Z axis divison pattern for PARA shape
1174 //______________________________________________________________________________
1175 
1176 ////////////////////////////////////////////////////////////////////////////////
1177 /// Default constructor
1178 
1180 {
1181  fTxz = 0;
1182  fTyz = 0;
1183  CreateThreadData(1);
1184 }
1185 ////////////////////////////////////////////////////////////////////////////////
1186 /// constructor
1187 
1189  :TGeoPatternFinder(vol, ndivisions)
1190 {
1191  fTxz = ((TGeoPara*)vol->GetShape())->GetTxz();
1192  fTyz = ((TGeoPara*)vol->GetShape())->GetTyz();
1193  Double_t dz = ((TGeoPara*)vol->GetShape())->GetZ();
1194  fStart = -dz;
1195  fEnd = dz;
1196  fStep = 2*dz/ndivisions;
1197  CreateThreadData(1);
1198 }
1199 ////////////////////////////////////////////////////////////////////////////////
1200 /// constructor
1201 
1203  :TGeoPatternFinder(vol, ndivisions)
1204 {
1205  fTxz = ((TGeoPara*)vol->GetShape())->GetTxz();
1206  fTyz = ((TGeoPara*)vol->GetShape())->GetTyz();
1207  Double_t dz = ((TGeoPara*)vol->GetShape())->GetZ();
1208  fStart = -dz;
1209  fEnd = fStart + ndivisions*step;
1210  fStep = step;
1211  CreateThreadData(1);
1212 }
1213 
1214 ////////////////////////////////////////////////////////////////////////////////
1215 /// constructor
1216 
1218  :TGeoPatternFinder(vol, ndivisions)
1219 {
1220  fTxz = ((TGeoPara*)vol->GetShape())->GetTxz();
1221  fTyz = ((TGeoPara*)vol->GetShape())->GetTyz();
1222  fStart = start;
1223  fEnd = end;
1224  fStep = (end - start)/ndivisions;
1225  CreateThreadData(1);
1226 }
1227 
1228 ////////////////////////////////////////////////////////////////////////////////
1229 ///copy constructor
1230 
1232  TGeoPatternFinder(pf)
1233 {
1234  CreateThreadData(1);
1235 }
1236 
1237 ////////////////////////////////////////////////////////////////////////////////
1238 ///assignment operator
1239 
1241 {
1242  if(this!=&pf) {
1244  CreateThreadData(1);
1245  }
1246  return *this;
1247 }
1248 
1249 ////////////////////////////////////////////////////////////////////////////////
1250 /// Destructor
1251 
1253 {
1254 }
1255 
1256 ////////////////////////////////////////////////////////////////////////////////
1257 /// Update current division index and global matrix to point to a given slice.
1258 
1260 {
1261  ThreadData_t& td = GetThreadData();
1262  td.fCurrent = idiv;
1263  Double_t dz = fStart+idiv*fStep+0.5*fStep;
1264  td.fMatrix->SetDx(fTxz*dz);
1265  td.fMatrix->SetDy(fTyz*dz);
1266  td.fMatrix->SetDz((IsReflected())?-dz:dz);
1267 }
1268 
1269 ////////////////////////////////////////////////////////////////////////////////
1270 /// Checks if the current point is on division boundary
1271 
1273 {
1274  Double_t seg = (point[2]-fStart)/fStep;
1275  Double_t diff = seg - Int_t(seg);
1276  if (diff>0.5) diff = 1.-diff;
1277  if (diff<1e-8) return kTRUE;
1278  return kFALSE;
1279 }
1280 
1281 ////////////////////////////////////////////////////////////////////////////////
1282 /// get the node division containing the query point
1283 
1285 {
1286  ThreadData_t& td = GetThreadData();
1287  TGeoNode *node = 0;
1288  Double_t zt = point[2];
1289  Int_t ind = (Int_t)(1.+(zt-fStart)/fStep) - 1;
1290  if (dir) {
1291  td.fNextIndex = ind;
1292  if (dir[2]>0) td.fNextIndex++;
1293  else td.fNextIndex--;
1294  if ((td.fNextIndex<0) || (td.fNextIndex>=fNdivisions)) td.fNextIndex = -1;
1295  }
1296  if ((ind<0) || (ind>=fNdivisions)) return node;
1297  node = GetNodeOffset(ind);
1298  cd(ind);
1299  return node;
1300 }
1301 
1302 ////////////////////////////////////////////////////////////////////////////////
1303 /// Make a copy of this finder. Reflect by Z if required.
1304 
1306 {
1307  TGeoPatternParaZ *finder = new TGeoPatternParaZ(*this);
1308  if (!reflect) return finder;
1309  finder->Reflect();
1310  return finder;
1311 }
1312 
1313 ////////////////////////////////////////////////////////////////////////////////
1314 /// Save a primitive as a C++ statement(s) on output stream "out".
1315 
1316 void TGeoPatternParaZ::SavePrimitive(std::ostream &out, Option_t * /*option*/ /*= ""*/)
1317 {
1318  Int_t iaxis = 3;
1319  out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
1320 }
1321 
1322 ////////////////////////////////////////////////////////////////////////////////
1323 /// Return new matrix of type used by this finder.
1324 
1326 {
1327  if (!IsReflected()) {
1328  TGeoMatrix *matrix = new TGeoTranslation(0.,0.,0.);
1329  matrix->RegisterYourself();
1330  return matrix;
1331  }
1332  TGeoCombiTrans *combi = new TGeoCombiTrans();
1333  combi->RegisterYourself();
1334  combi->ReflectZ(kTRUE);
1335  combi->ReflectZ(kFALSE);
1336  return combi;
1337 }
1338 
1339 ////////////////////////////////////////////////////////////////////////////////
1340 /// Fills external matrix with the local one corresponding to the given division
1341 /// index.
1342 
1344 {
1345  matrix.Clear();
1346  Double_t dz = fStart+idiv*fStep+0.5*fStep;
1347  matrix.SetDx(fTxz*dz);
1348  matrix.SetDy(fTyz*dz);
1349  matrix.SetDz((IsReflected())?-dz:dz);
1350 }
1351 
1352 //______________________________________________________________________________
1353 // TGeoPatternTrapZ - a Z axis divison pattern for TRAP or GTRA shapes
1354 //______________________________________________________________________________
1355 
1356 ////////////////////////////////////////////////////////////////////////////////
1357 /// Default constructor
1358 
1360 {
1361  fTxz = 0;
1362  fTyz = 0;
1363  CreateThreadData(1);
1364 }
1365 ////////////////////////////////////////////////////////////////////////////////
1366 /// constructor
1367 
1369  :TGeoPatternFinder(vol, ndivisions)
1370 {
1371  Double_t theta = ((TGeoTrap*)vol->GetShape())->GetTheta();
1372  Double_t phi = ((TGeoTrap*)vol->GetShape())->GetPhi();
1375  Double_t dz = ((TGeoArb8*)vol->GetShape())->GetDz();
1376  fStart = -dz;
1377  fEnd = dz;
1378  fStep = 2*dz/ndivisions;
1379  CreateThreadData(1);
1380 }
1381 ////////////////////////////////////////////////////////////////////////////////
1382 /// constructor
1383 
1385  :TGeoPatternFinder(vol, ndivisions)
1386 {
1387  Double_t theta = ((TGeoTrap*)vol->GetShape())->GetTheta();
1388  Double_t phi = ((TGeoTrap*)vol->GetShape())->GetPhi();
1391  Double_t dz = ((TGeoArb8*)vol->GetShape())->GetDz();
1392  fStart = -dz;
1393  fEnd = fStart + ndivisions*step;
1394  fStep = step;
1395  CreateThreadData(1);
1396 }
1397 ////////////////////////////////////////////////////////////////////////////////
1398 /// constructor
1399 
1401  :TGeoPatternFinder(vol, ndivisions)
1402 {
1403  Double_t theta = ((TGeoTrap*)vol->GetShape())->GetTheta();
1404  Double_t phi = ((TGeoTrap*)vol->GetShape())->GetPhi();
1407  fStart = start;
1408  fEnd = end;
1409  fStep = (end - start)/ndivisions;
1410  CreateThreadData(1);
1411 }
1412 
1413 ////////////////////////////////////////////////////////////////////////////////
1414 ///copy constructor
1415 
1417  TGeoPatternFinder(pf),
1418  fTxz(pf.fTxz),
1419  fTyz(pf.fTyz)
1420 {
1421  CreateThreadData(1);
1422 }
1423 
1424 ////////////////////////////////////////////////////////////////////////////////
1425 ///assignment operator
1426 
1428 {
1429  if(this!=&pf) {
1431  fTxz = pf.fTxz;
1432  fTyz = pf.fTyz;
1433  CreateThreadData(1);
1434  }
1435  return *this;
1436 }
1437 
1438 ////////////////////////////////////////////////////////////////////////////////
1439 /// Destructor
1440 
1442 {
1443 }
1444 ////////////////////////////////////////////////////////////////////////////////
1445 /// Update current division index and global matrix to point to a given slice.
1446 
1448 {
1449  ThreadData_t& td = GetThreadData();
1450  td.fCurrent = idiv;
1451  Double_t dz = fStart+idiv*fStep+0.5*fStep;
1452  td.fMatrix->SetDx(fTxz*dz);
1453  td.fMatrix->SetDy(fTyz*dz);
1454  td.fMatrix->SetDz((IsReflected())?-dz:dz);
1455 }
1456 
1457 ////////////////////////////////////////////////////////////////////////////////
1458 /// Checks if the current point is on division boundary
1459 
1461 {
1462  Double_t seg = (point[2]-fStart)/fStep;
1463  Double_t diff = seg - Int_t(seg);
1464  if (diff>0.5) diff = 1.-diff;
1465  if (diff<1e-8) return kTRUE;
1466  return kFALSE;
1467 }
1468 
1469 ////////////////////////////////////////////////////////////////////////////////
1470 /// get the node division containing the query point
1471 
1473 {
1474  ThreadData_t& td = GetThreadData();
1475  TGeoNode *node = 0;
1476  Double_t zt = point[2];
1477  Int_t ind = (Int_t)(1. + (zt-fStart)/fStep) - 1;
1478  if (dir) {
1479  td.fNextIndex = ind;
1480  if (dir[2]>0) td.fNextIndex++;
1481  else td.fNextIndex--;
1482  if ((td.fNextIndex<0) || (td.fNextIndex>=fNdivisions)) td.fNextIndex = -1;
1483  }
1484  if ((ind<0) || (ind>=fNdivisions)) return node;
1485  node = GetNodeOffset(ind);
1486  cd(ind);
1487  return node;
1488 }
1489 
1490 ////////////////////////////////////////////////////////////////////////////////
1491 /// Make a copy of this finder. Reflect by Z if required.
1492 
1494 {
1495  TGeoPatternTrapZ *finder = new TGeoPatternTrapZ(*this);
1496  if (!reflect) return finder;
1497  finder->Reflect();
1498  return finder;
1499 }
1500 
1501 ////////////////////////////////////////////////////////////////////////////////
1502 /// Save a primitive as a C++ statement(s) on output stream "out".
1503 
1504 void TGeoPatternTrapZ::SavePrimitive(std::ostream &out, Option_t * /*option*/ /*= ""*/)
1505 {
1506  Int_t iaxis = 3;
1507  out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
1508 }
1509 
1510 ////////////////////////////////////////////////////////////////////////////////
1511 /// Return new matrix of type used by this finder.
1512 
1514 {
1515  if (!IsReflected()) {
1516  TGeoMatrix *matrix = new TGeoTranslation(0.,0.,0.);
1517  matrix->RegisterYourself();
1518  return matrix;
1519  }
1520  TGeoCombiTrans *combi = new TGeoCombiTrans();
1521  combi->RegisterYourself();
1522  combi->ReflectZ(kTRUE);
1523  combi->ReflectZ(kFALSE);
1524  return combi;
1525 }
1526 
1527 ////////////////////////////////////////////////////////////////////////////////
1528 /// Fills external matrix with the local one corresponding to the given division
1529 /// index.
1530 
1532 {
1533  matrix.Clear();
1534  Double_t dz = fStart+idiv*fStep+0.5*fStep;
1535  matrix.SetDx(fTxz*dz);
1536  matrix.SetDy(fTyz*dz);
1537  matrix.SetDz((IsReflected())?-dz:dz);
1538 }
1539 
1540 //______________________________________________________________________________
1541 // TGeoPatternCylR - a cylindrical R divison pattern
1542 //______________________________________________________________________________
1543 
1544 ////////////////////////////////////////////////////////////////////////////////
1545 /// Default constructor
1546 
1548 {
1549  CreateThreadData(1);
1550 }
1551 ////////////////////////////////////////////////////////////////////////////////
1552 /// constructor
1553 
1555  :TGeoPatternFinder(vol, ndivisions)
1556 {
1557  CreateThreadData(1);
1558 }
1559 ////////////////////////////////////////////////////////////////////////////////
1560 /// constructor
1561 
1563  :TGeoPatternFinder(vol, ndivisions)
1564 {
1565  fStep = step;
1566  CreateThreadData(1);
1567 // compute start, end
1568 }
1569 ////////////////////////////////////////////////////////////////////////////////
1570 /// constructor
1571 
1573  :TGeoPatternFinder(vol, ndivisions)
1574 {
1575  fStart = start;
1576  fEnd = end;
1577  fStep = (end - start)/ndivisions;
1578  CreateThreadData(1);
1579 }
1580 ////////////////////////////////////////////////////////////////////////////////
1581 ///copy constructor
1582 
1584  TGeoPatternFinder(pf)
1585 {
1586  CreateThreadData(1);
1587 }
1588 
1589 ////////////////////////////////////////////////////////////////////////////////
1590 ///assignment operator
1591 
1593 {
1594  if(this!=&pf) {
1596  CreateThreadData(1);
1597  }
1598  return *this;
1599 }
1600 
1601 ////////////////////////////////////////////////////////////////////////////////
1602 /// Destructor
1603 
1605 {
1606 }
1607 
1608 ////////////////////////////////////////////////////////////////////////////////
1609 /// Checks if the current point is on division boundary
1610 
1612 {
1613  Double_t r = TMath::Sqrt(point[0]*point[0]+point[1]*point[1]);
1614  Double_t seg = (r-fStart)/fStep;
1615  Double_t diff = seg - Int_t(seg);
1616  if (diff>0.5) diff = 1.-diff;
1617  if (diff<1e-8) return kTRUE;
1618  return kFALSE;
1619 }
1620 
1621 ////////////////////////////////////////////////////////////////////////////////
1622 /// Update current division index and global matrix to point to a given slice.
1623 
1625 {
1626  ThreadData_t& td = GetThreadData();
1627  td.fCurrent=idiv;
1628 }
1629 
1630 ////////////////////////////////////////////////////////////////////////////////
1631 /// find the node containing the query point
1632 
1634 {
1635  ThreadData_t& td = GetThreadData();
1636  if (!td.fMatrix) td.fMatrix = gGeoIdentity;
1637  TGeoNode *node = 0;
1638  Double_t r = TMath::Sqrt(point[0]*point[0]+point[1]*point[1]);
1639  Int_t ind = (Int_t)(1. + (r-fStart)/fStep) - 1;
1640  if (dir) {
1641  td.fNextIndex = ind;
1642  Double_t dot = point[0]*dir[0] + point[1]*dir[1];
1643  if (dot>0) td.fNextIndex++;
1644  else td.fNextIndex--;
1645  if ((td.fNextIndex<0) || (td.fNextIndex>=fNdivisions)) td.fNextIndex = -1;
1646  }
1647  if ((ind<0) || (ind>=fNdivisions)) return node;
1648  node = GetNodeOffset(ind);
1649  cd(ind);
1650  return node;
1651 }
1652 
1653 ////////////////////////////////////////////////////////////////////////////////
1654 /// Make a copy of this finder. Reflect by Z if required.
1655 
1657 {
1658  TGeoPatternCylR *finder = new TGeoPatternCylR(*this);
1659  if (!reflect) return finder;
1660  finder->Reflect();
1661  return finder;
1662 }
1663 
1664 ////////////////////////////////////////////////////////////////////////////////
1665 /// Save a primitive as a C++ statement(s) on output stream "out".
1666 
1667 void TGeoPatternCylR::SavePrimitive(std::ostream &out, Option_t * /*option*/ /*= ""*/)
1668 {
1669  Int_t iaxis = 1;
1670  out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
1671 }
1672 
1673 ////////////////////////////////////////////////////////////////////////////////
1674 /// Return new matrix of type used by this finder.
1675 
1677 {
1678  return gGeoIdentity;
1679 }
1680 
1681 ////////////////////////////////////////////////////////////////////////////////
1682 /// Fills external matrix with the local one corresponding to the given division
1683 /// index.
1684 
1686 {
1687  matrix.Clear();
1688 }
1689 
1690 //______________________________________________________________________________
1691 // TGeoPatternCylPhi - a cylindrical phi divison pattern
1692 //______________________________________________________________________________
1693 
1694 ////////////////////////////////////////////////////////////////////////////////
1695 /// Default constructor
1696 
1698 {
1699  fSinCos = 0;
1700  CreateThreadData(1);
1701 }
1702 ////////////////////////////////////////////////////////////////////////////////
1703 /// constructor
1704 /// compute step, start, end
1705 
1707  :TGeoPatternFinder(vol, ndivisions)
1708 {
1709  fStart = 0;
1710  fEnd = 0;
1711  fStep = 0;
1712  fSinCos = new Double_t[2*fNdivisions];
1713  for (Int_t i = 0; i<fNdivisions; i++) {
1714  fSinCos[2*i] = TMath::Sin(TMath::DegToRad()*(fStart+0.5*fStep+i*fStep));
1715  fSinCos[2*i+1] = TMath::Cos(TMath::DegToRad()*(fStart+0.5*fStep+i*fStep));
1716  }
1717  CreateThreadData(1);
1718 }
1719 ////////////////////////////////////////////////////////////////////////////////
1720 /// constructor
1721 
1723  :TGeoPatternFinder(vol, ndivisions)
1724 {
1725  fStep = step;
1726  fSinCos = new Double_t[2*ndivisions];
1727  for (Int_t i = 0; i<fNdivisions; i++) {
1728  fSinCos[2*i] = TMath::Sin(TMath::DegToRad()*(fStart+0.5*fStep+i*fStep));
1729  fSinCos[2*i+1] = TMath::Cos(TMath::DegToRad()*(fStart+0.5*fStep+i*fStep));
1730  }
1731  CreateThreadData(1);
1732 // compute start, end
1733 }
1734 ////////////////////////////////////////////////////////////////////////////////
1735 /// constructor
1736 
1738  :TGeoPatternFinder(vol, ndivisions)
1739 {
1740  fStart = start;
1741  if (fStart<0) fStart+=360;
1742  fEnd = end;
1743  if (fEnd<0) fEnd+=360;
1744  if ((end-start)<0)
1745  fStep = (end-start+360)/ndivisions;
1746  else
1747  fStep = (end-start)/ndivisions;
1748  fSinCos = new Double_t[2*ndivisions];
1749  for (Int_t idiv = 0; idiv<ndivisions; idiv++) {
1750  fSinCos[2*idiv] = TMath::Sin(TMath::DegToRad()*(start+0.5*fStep+idiv*fStep));
1751  fSinCos[2*idiv+1] = TMath::Cos(TMath::DegToRad()*(start+0.5*fStep+idiv*fStep));
1752  }
1753  CreateThreadData(1);
1754 }
1755 ////////////////////////////////////////////////////////////////////////////////
1756 /// Destructor
1757 
1759 {
1760  if (fSinCos) delete [] fSinCos;
1761 }
1762 ////////////////////////////////////////////////////////////////////////////////
1763 /// Update current division index and global matrix to point to a given slice.
1764 
1766 {
1767  ThreadData_t& td = GetThreadData();
1768  td.fCurrent = idiv;
1769  ((TGeoRotation*)td.fMatrix)->FastRotZ(&fSinCos[2*idiv]);
1770 }
1771 
1772 ////////////////////////////////////////////////////////////////////////////////
1773 /// Checks if the current point is on division boundary
1774 
1776 {
1777  Double_t phi = TMath::ATan2(point[1], point[0])*TMath::RadToDeg();
1778  if (phi<0) phi += 360;
1779  Double_t ddp = phi - fStart;
1780  if (ddp<0) ddp+=360;
1781  Double_t seg = ddp/fStep;
1782  Double_t diff = seg - Int_t(seg);
1783  if (diff>0.5) diff = 1.-diff;
1784  if (diff<1e-8) return kTRUE;
1785  return kFALSE;
1786 }
1787 
1788 ////////////////////////////////////////////////////////////////////////////////
1789 /// find the node containing the query point
1790 
1792 {
1793  ThreadData_t& td = GetThreadData();
1794  TGeoNode *node = 0;
1795  Double_t phi = TMath::ATan2(point[1], point[0])*TMath::RadToDeg();
1796  if (phi<0) phi += 360;
1797 // Double_t dphi = fStep*fNdivisions;
1798  Double_t ddp = phi - fStart;
1799  if (ddp<0) ddp+=360;
1800 // if (ddp>360) ddp-=360;
1801  Int_t ind = (Int_t)(1. + ddp/fStep) - 1;
1802  if (dir) {
1803  td.fNextIndex = ind;
1804  Double_t dot = point[0]*dir[1]-point[1]*dir[0];
1805  if (dot>0) td.fNextIndex++;
1806  else td.fNextIndex--;
1807  if ((td.fNextIndex<0) || (td.fNextIndex>=fNdivisions)) td.fNextIndex = -1;
1808  }
1809  if ((ind<0) || (ind>=fNdivisions)) return node;
1810  node = GetNodeOffset(ind);
1811  cd(ind);
1812  return node;
1813 }
1814 
1815 ////////////////////////////////////////////////////////////////////////////////
1816 /// Make a copy of this finder. Reflect by Z if required.
1817 
1819 {
1820  TGeoPatternCylPhi *finder = new TGeoPatternCylPhi(*this);
1821  if (!reflect) return finder;
1822  finder->Reflect();
1823  return finder;
1824 }
1825 
1826 ////////////////////////////////////////////////////////////////////////////////
1827 /// Save a primitive as a C++ statement(s) on output stream "out".
1828 
1829 void TGeoPatternCylPhi::SavePrimitive(std::ostream &out, Option_t * /*option*/ /*= ""*/)
1830 {
1831  Int_t iaxis = 2;
1832  out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
1833 }
1834 
1835 ////////////////////////////////////////////////////////////////////////////////
1836 /// Stream an object of class TGeoVolume.
1837 
1838 void TGeoPatternCylPhi::Streamer(TBuffer &R__b)
1839 {
1840  if (R__b.IsReading()) {
1842  if (fNdivisions) {
1843  fSinCos = new Double_t[2*fNdivisions];
1844  for (Int_t idiv = 0; idiv<fNdivisions; idiv++) {
1845  fSinCos[2*idiv] = TMath::Sin(TMath::DegToRad()*(fStart+0.5*fStep+idiv*fStep));
1846  fSinCos[2*idiv+1] = TMath::Cos(TMath::DegToRad()*(fStart+0.5*fStep+idiv*fStep));
1847  }
1848  }
1849  } else {
1851  }
1852 }
1853 
1854 ////////////////////////////////////////////////////////////////////////////////
1855 /// Return new matrix of type used by this finder.
1856 
1858 {
1859  if (!IsReflected()) {
1860  TGeoRotation *matrix = new TGeoRotation();
1861  matrix->RegisterYourself();
1862  return matrix;
1863  }
1864  TGeoRotation *rot = new TGeoRotation();
1865  rot->RegisterYourself();
1866  rot->ReflectZ(kTRUE);
1867  rot->ReflectZ(kFALSE);
1868  return rot;
1869 }
1870 
1871 ////////////////////////////////////////////////////////////////////////////////
1872 /// Fills external matrix with the local one corresponding to the given division
1873 /// index.
1874 
1876 {
1877  matrix.Clear();
1878  matrix.FastRotZ(&fSinCos[2*idiv]);
1879 }
1880 
1881 //______________________________________________________________________________
1882 // TGeoPatternSphR - a spherical R divison pattern
1883 //______________________________________________________________________________
1884 
1885 ////////////////////////////////////////////////////////////////////////////////
1886 /// Default constructor
1887 
1889 {
1890  CreateThreadData(1);
1891 }
1892 ////////////////////////////////////////////////////////////////////////////////
1893 /// constructor
1894 /// compute step, start, end
1895 
1897  :TGeoPatternFinder(vol, ndivisions)
1898 {
1899  CreateThreadData(1);
1900 }
1901 ////////////////////////////////////////////////////////////////////////////////
1902 /// constructor
1903 
1905  :TGeoPatternFinder(vol, ndivisions)
1906 {
1907  fStep = step;
1908  CreateThreadData(1);
1909 // compute start, end
1910 }
1911 ////////////////////////////////////////////////////////////////////////////////
1912 /// constructor
1913 
1915  :TGeoPatternFinder(vol, ndivisions)
1916 {
1917  fStart = start;
1918  fEnd = end;
1919  fStep = (end - start)/ndivisions;
1920  CreateThreadData(1);
1921 }
1922 ////////////////////////////////////////////////////////////////////////////////
1923 ///copy constructor
1924 
1926  TGeoPatternFinder(pf)
1927 {
1928  CreateThreadData(1);
1929 }
1930 
1931 ////////////////////////////////////////////////////////////////////////////////
1932 ///assignment operator
1933 
1935 {
1936  if(this!=&pf) {
1938  CreateThreadData(1);
1939  }
1940  return *this;
1941 }
1942 
1943 ////////////////////////////////////////////////////////////////////////////////
1944 /// Destructor
1945 
1947 {
1948 }
1949 ////////////////////////////////////////////////////////////////////////////////
1950 /// Update current division index and global matrix to point to a given slice.
1951 
1953 {
1954  ThreadData_t& td = GetThreadData();
1955  td.fCurrent = idiv;
1956 }
1957 ////////////////////////////////////////////////////////////////////////////////
1958 /// find the node containing the query point
1959 
1960 TGeoNode *TGeoPatternSphR::FindNode(Double_t * /*point*/, const Double_t * /*dir*/)
1961 {
1962  return 0;
1963 }
1964 
1965 ////////////////////////////////////////////////////////////////////////////////
1966 /// Make a copy of this finder. Reflect by Z if required.
1967 
1969 {
1970  TGeoPatternSphR *finder = new TGeoPatternSphR(*this);
1971  return finder;
1972 }
1973 
1974 ////////////////////////////////////////////////////////////////////////////////
1975 /// Save a primitive as a C++ statement(s) on output stream "out".
1976 
1977 void TGeoPatternSphR::SavePrimitive(std::ostream &out, Option_t * /*option*/ /*= ""*/)
1978 {
1979  Int_t iaxis = 1;
1980  out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
1981 }
1982 
1983 ////////////////////////////////////////////////////////////////////////////////
1984 /// Return new matrix of type used by this finder.
1985 
1987 {
1988  return gGeoIdentity;
1989 }
1990 
1991 ////////////////////////////////////////////////////////////////////////////////
1992 /// Fills external matrix with the local one corresponding to the given division
1993 /// index.
1994 
1996 {
1997  matrix.Clear();
1998 }
1999 
2000 //______________________________________________________________________________
2001 // TGeoPatternSphTheta - a spherical theta divison pattern
2002 //______________________________________________________________________________
2003 
2004 ////////////////////////////////////////////////////////////////////////////////
2005 /// Default constructor
2006 
2008 {
2009  CreateThreadData(1);
2010 }
2011 ////////////////////////////////////////////////////////////////////////////////
2012 /// constructor
2013 /// compute step, start, end
2014 
2016  :TGeoPatternFinder(vol, ndivisions)
2017 {
2018  CreateThreadData(1);
2019 }
2020 ////////////////////////////////////////////////////////////////////////////////
2021 /// constructor
2022 
2024  :TGeoPatternFinder(vol, ndivisions)
2025 {
2026  fStep = step;
2027  CreateThreadData(1);
2028 // compute start, end
2029 }
2030 ////////////////////////////////////////////////////////////////////////////////
2031 /// constructor
2032 
2034  :TGeoPatternFinder(vol, ndivisions)
2035 {
2036  fStart = start;
2037  fEnd = end;
2038  fStep = (end - start)/ndivisions;
2039  CreateThreadData(1);
2040 }
2041 ////////////////////////////////////////////////////////////////////////////////
2042 ///copy constructor
2043 
2045  TGeoPatternFinder(pf)
2046 {
2047  CreateThreadData(1);
2048 }
2049 ////////////////////////////////////////////////////////////////////////////////
2050 ///assignment operator
2051 
2053 {
2054  if(this!=&pf) {
2056  CreateThreadData(1);
2057  }
2058  return *this;
2059 }
2060 ////////////////////////////////////////////////////////////////////////////////
2061 /// Destructor
2062 
2064 {
2065 }
2066 ////////////////////////////////////////////////////////////////////////////////
2067 /// Update current division index and global matrix to point to a given slice.
2068 
2070 {
2071  ThreadData_t& td = GetThreadData();
2072  td.fCurrent=idiv;
2073 }
2074 ////////////////////////////////////////////////////////////////////////////////
2075 /// find the node containing the query point
2076 
2078 {
2079  return 0;
2080 }
2081 
2082 ////////////////////////////////////////////////////////////////////////////////
2083 /// Make a copy of this finder. Reflect by Z if required.
2084 
2086 {
2087  TGeoPatternSphTheta *finder = new TGeoPatternSphTheta(*this);
2088  return finder;
2089 }
2090 
2091 ////////////////////////////////////////////////////////////////////////////////
2092 /// Save a primitive as a C++ statement(s) on output stream "out".
2093 
2094 void TGeoPatternSphTheta::SavePrimitive(std::ostream &out, Option_t * /*option*/ /*= ""*/)
2095 {
2096  Int_t iaxis = 2;
2097  out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
2098 }
2099 
2100 ////////////////////////////////////////////////////////////////////////////////
2101 /// Return new matrix of type used by this finder.
2102 
2104 {
2105  return gGeoIdentity;
2106 }
2107 
2108 ////////////////////////////////////////////////////////////////////////////////
2109 /// Fills external matrix with the local one corresponding to the given division
2110 /// index.
2111 
2113 {
2114  matrix.Clear();
2115 }
2116 
2117 //______________________________________________________________________________
2118 // TGeoPatternSphPhi - a spherical phi divison pattern
2119 //______________________________________________________________________________
2120 
2121 ////////////////////////////////////////////////////////////////////////////////
2122 /// Default constructor
2123 
2125 {
2126  fSinCos = 0;
2127  CreateThreadData(1);
2128 }
2129 ////////////////////////////////////////////////////////////////////////////////
2130 /// constructor
2131 /// compute step, start, end
2132 
2134  :TGeoPatternFinder(vol, ndivisions)
2135 {
2136  fStart = 0;
2137  fEnd = 360.;
2138  fStep = 360./ndivisions;
2139  CreateSinCos();
2140  CreateThreadData(1);
2141 }
2142 ////////////////////////////////////////////////////////////////////////////////
2143 /// constructor
2144 /// compute start, end
2145 
2147  :TGeoPatternFinder(vol, ndivisions)
2148 {
2149  fStep = step;
2150  CreateSinCos();
2151  CreateThreadData(1);
2152 }
2153 ////////////////////////////////////////////////////////////////////////////////
2154 /// constructor
2155 /// compute step
2156 
2158  :TGeoPatternFinder(vol, ndivisions)
2159 {
2160  fStart = start;
2161  if (fStart<0) fStart+=360;
2162  fEnd = end;
2163  if (fEnd<0) fEnd+=360;
2164  if ((end-start)<0)
2165  fStep = (end-start+360)/ndivisions;
2166  else
2167  fStep = (end-start)/ndivisions;
2168  CreateSinCos();
2169  CreateThreadData(1);
2170 }
2171 
2172 ////////////////////////////////////////////////////////////////////////////////
2173 /// Destructor
2174 
2176 {
2177  delete [] fSinCos;
2178 }
2179 
2180 ////////////////////////////////////////////////////////////////////////////////
2181 /// Create the sincos table if it does not exist
2182 
2184 {
2185  fSinCos = new Double_t[2*fNdivisions];
2186  for (Int_t idiv = 0; idiv<fNdivisions; idiv++) {
2187  fSinCos[2*idiv] = TMath::Sin(TMath::DegToRad()*(fStart+0.5*fStep+idiv*fStep));
2188  fSinCos[2*idiv+1] = TMath::Cos(TMath::DegToRad()*(fStart+0.5*fStep+idiv*fStep));
2189  }
2190  return fSinCos;
2191 }
2192 
2193 ////////////////////////////////////////////////////////////////////////////////
2194 /// Update current division index and global matrix to point to a given slice.
2195 
2197 {
2198  ThreadData_t& td = GetThreadData();
2199  td.fCurrent = idiv;
2200  if (!fSinCos) CreateSinCos();
2201  ((TGeoRotation*)td.fMatrix)->FastRotZ(&fSinCos[2*idiv]);
2202 }
2203 
2204 ////////////////////////////////////////////////////////////////////////////////
2205 /// Checks if the current point is on division boundary
2206 
2208 {
2209  Double_t phi = TMath::ATan2(point[1], point[0])*TMath::RadToDeg();
2210  if (phi<0) phi += 360;
2211  Double_t ddp = phi - fStart;
2212  if (ddp<0) ddp+=360;
2213  Double_t seg = ddp/fStep;
2214  Double_t diff = seg - Int_t(seg);
2215  if (diff>0.5) diff = 1.-diff;
2216  if (diff<1e-8) return kTRUE;
2217  return kFALSE;
2218 }
2219 ////////////////////////////////////////////////////////////////////////////////
2220 /// find the node containing the query point
2221 
2223 {
2224  ThreadData_t& td = GetThreadData();
2225  TGeoNode *node = 0;
2226  Double_t phi = TMath::ATan2(point[1], point[0])*TMath::RadToDeg();
2227  if (phi<0) phi += 360;
2228 // Double_t dphi = fStep*fNdivisions;
2229  Double_t ddp = phi - fStart;
2230  if (ddp<0) ddp+=360;
2231 // if (ddp>360) ddp-=360;
2232  Int_t ind = (Int_t)(1. + ddp/fStep) - 1;
2233  if (dir) {
2234  td.fNextIndex = ind;
2235  Double_t dot = point[0]*dir[1]-point[1]*dir[0];
2236  if (dot>0) td.fNextIndex++;
2237  else td.fNextIndex--;
2238  if ((td.fNextIndex<0) || (td.fNextIndex>=fNdivisions)) td.fNextIndex = -1;
2239  }
2240  if ((ind<0) || (ind>=fNdivisions)) return node;
2241  node = GetNodeOffset(ind);
2242  cd(ind);
2243  return node;
2244 }
2245 ////////////////////////////////////////////////////////////////////////////////
2246 /// Make a copy of this finder. Reflect by Z if required.
2247 
2249 {
2251  if (!reflect) return finder;
2252  finder->Reflect();
2253  return finder;
2254 }
2255 
2256 ////////////////////////////////////////////////////////////////////////////////
2257 /// Save a primitive as a C++ statement(s) on output stream "out".
2258 
2259 void TGeoPatternSphPhi::SavePrimitive(std::ostream &out, Option_t * /*option*/ /*= ""*/)
2260 {
2261  Int_t iaxis = 2;
2262  out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
2263 }
2264 ////////////////////////////////////////////////////////////////////////////////
2265 /// Return new matrix of type used by this finder.
2266 
2268 {
2269  if (!IsReflected()) {
2270  TGeoRotation *matrix = new TGeoRotation();
2271  matrix->RegisterYourself();
2272  return matrix;
2273  }
2274  TGeoRotation *rot = new TGeoRotation();
2275  rot->RegisterYourself();
2276  rot->ReflectZ(kTRUE);
2277  rot->ReflectZ(kFALSE);
2278  return rot;
2279 }
2280 ////////////////////////////////////////////////////////////////////////////////
2281 /// Fills external matrix with the local one corresponding to the given division
2282 /// index.
2283 
2285 {
2286  if (!fSinCos) ((TGeoPatternSphPhi*)this)->CreateSinCos();
2287  matrix.Clear();
2288  matrix.FastRotZ(&fSinCos[2*idiv]);
2289 }
2290 
2291 //______________________________________________________________________________
2292 // TGeoPatternHoneycomb - a divison pattern specialized for honeycombs
2293 //______________________________________________________________________________
2294 
2295 ////////////////////////////////////////////////////////////////////////////////
2296 /// Default constructor
2297 
2299 {
2300  fNrows = 0;
2301  fAxisOnRows = 0;
2302  fNdivisions = 0;
2303  fStart = 0;
2304  CreateThreadData(1);
2305 }
2306 ////////////////////////////////////////////////////////////////////////////////
2307 /// Default constructor
2308 
2310  :TGeoPatternFinder(vol, nrows)
2311 {
2312  fNrows = nrows;
2313  fAxisOnRows = 0;
2314  fNdivisions = 0;
2315  fStart = 0;
2316  CreateThreadData(1);
2317 // compute everything else
2318 }
2319 ////////////////////////////////////////////////////////////////////////////////
2320 ///copy constructor
2321 
2323  TGeoPatternFinder(pfh),
2324  fNrows(pfh.fNrows),
2325  fAxisOnRows(pfh.fAxisOnRows),
2326  fNdivisions(pfh.fNdivisions),
2327  fStart(pfh.fStart)
2328 {
2329  CreateThreadData(1);
2330 }
2331 
2332 ////////////////////////////////////////////////////////////////////////////////
2333 ///assignment operator
2334 
2336 {
2337  if(this!=&pfh) {
2339  fNrows=pfh.fNrows;
2342  fStart=pfh.fStart;
2343  CreateThreadData(1);
2344  }
2345  return *this;
2346 }
2347 ////////////////////////////////////////////////////////////////////////////////
2348 /// destructor
2349 
2351 {
2352 }
2353 ////////////////////////////////////////////////////////////////////////////////
2354 /// Update current division index and global matrix to point to a given slice.
2355 
2357 {
2358  ThreadData_t& td = GetThreadData();
2359  td.fCurrent=idiv;
2360 }
2361 ////////////////////////////////////////////////////////////////////////////////
2362 /// find the node containing the query point
2363 
2365 {
2366  return 0;
2367 }
2368 
2369 ////////////////////////////////////////////////////////////////////////////////
2370 /// Return new matrix of type used by this finder.
2371 
2373 {
2374  return gGeoIdentity;
2375 }
2376 
2377 ////////////////////////////////////////////////////////////////////////////////
2378 /// Fills external matrix with the local one corresponding to the given division
2379 /// index.
2380 
2382 {
2383  matrix.Clear();
2384 }
void CreateThreadData(Int_t nthreads)
Create thread data for n threads max.
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const
Fills external matrix with the local one corresponding to the given division index.
TGeoPatternParaX & operator=(const TGeoPatternParaX &)
assignment operator
Bool_t IsReading() const
Definition: TBuffer.h:83
virtual Bool_t IsOnBoundary(const Double_t *point) const
Checks if the current point is on division boundary.
virtual TGeoPatternFinder * MakeCopy(Bool_t reflect=kFALSE)
Make a copy of this finder. Reflect by Z if required.
virtual Bool_t IsOnBoundary(const Double_t *point) const
Checks if the current point is on division boundary.
virtual TGeoNode * FindNode(Double_t *point, const Double_t *dir=0)
get the node division containing the query point
virtual TGeoNode * FindNode(Double_t *point, const Double_t *dir=0)
Find the cell corresponding to point and next cell along dir (if asked)
double dist(Rotation3D const &r1, Rotation3D const &r2)
Definition: 3DDistances.cxx:48
virtual TGeoMatrix * CreateMatrix() const
Return new matrix of type used by this finder.
virtual TGeoNode * FindNode(Double_t *point, const Double_t *dir=0)
get the node division containing the query point
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual Bool_t IsOnBoundary(const Double_t *point) const
Checks if the current point is on division boundary.
Box class.
Definition: TGeoBBox.h:19
virtual void cd(Int_t idiv)
Update current division index and global matrix to point to a given slice.
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const
Fills external matrix with the local one corresponding to the given division index.
void FastRotZ(const Double_t *sincos)
Perform a rotation about Z having the sine/cosine of the rotation angle.
virtual ~TGeoPatternCylPhi()
Destructor.
virtual ~TGeoPatternTrapZ()
Destructor.
virtual Double_t FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext)
Compute distance to next division layer returning the index of next section.
virtual Double_t FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext)
Compute distance to next division layer returning the index of next section.
const char Option_t
Definition: RtypesCore.h:62
Geometrical transformation package.
Definition: TGeoMatrix.h:40
virtual TGeoNode * FindNode(Double_t *point, const Double_t *dir=0)
get the node division containing the query point
virtual TGeoNode * FindNode(Double_t *point, const Double_t *dir=0)
find the node containing the query point
virtual void cd(Int_t idiv)
Update current division index and global matrix to point to a given slice.
virtual ~TGeoPatternZ()
Destructor.
virtual TGeoNode * FindNode(Double_t *point, const Double_t *dir=0)
Find the cell corresponding to point and next cell along dir (if asked)
TGeoPatternParaY & operator=(const TGeoPatternParaY &)
assignment operator
Double_t DegToRad()
Definition: TMath.h:50
virtual TGeoPatternFinder * MakeCopy(Bool_t reflect=kFALSE)
Make a copy of this finder. Reflect by Z if required.
virtual void ReflectZ(Bool_t leftside, Bool_t rotonly=kFALSE)
Multiply by a reflection respect to XY.
TGeoNode * GetNodeOffset(Int_t idiv)
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:61
virtual Bool_t IsOnBoundary(const Double_t *point) const
Checks if the current point is on division boundary.
virtual TGeoPatternFinder * MakeCopy(Bool_t reflect=kFALSE)
Make a copy of this finder. Reflect by Z if required.
virtual void cd(Int_t idiv)
Update current division index and global matrix to point to a given slice.
virtual TGeoPatternFinder * MakeCopy(Bool_t reflect=kFALSE)
Make a copy of this finder. Reflect by Z if required.
TGeoPatternX & operator=(const TGeoPatternX &)
assignment operator
Buffer base class used for serializing objects.
Definition: TBuffer.h:42
TGeoPatternFinder & operator=(const TGeoPatternFinder &)
assignment operator
virtual void SetDz(Double_t)
Definition: TGeoMatrix.h:116
TGeoPatternParaX()
Default constructor.
ThreadData_t & GetThreadData() const
Class describing translations.
Definition: TGeoMatrix.h:131
TGeoPatternZ()
Default constructor.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const
Fills external matrix with the local one corresponding to the given division index.
Double_t RadToDeg()
Definition: TMath.h:49
Matrix class used for computing global transformations Should NOT be used for node definition...
Definition: TGeoMatrix.h:410
virtual void SetDx(Double_t)
Definition: TGeoMatrix.h:114
virtual void SetDx(Double_t dx)
Definition: TGeoMatrix.h:445
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual TGeoMatrix * CreateMatrix() const
Return new matrix of type used by this finder.
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const
Fills external matrix with the local one corresponding to the given division index.
Int_t GetCurrent()
Return current index.
const char * Class
Definition: TXMLSetup.cxx:64
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const
Fills external matrix with the local one corresponding to the given division index.
virtual void cd(Int_t idiv)
Update current division index and global matrix to point to a given slice.
Short_t Abs(Short_t d)
Definition: TMathBase.h:110
virtual Bool_t IsOnBoundary(const Double_t *point) const
Checks if the current point is on division boundary.
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const
Fills external matrix with the local one corresponding to the given division index.
virtual TGeoPatternFinder * MakeCopy(Bool_t reflect=kFALSE)
Make a copy of this finder. Reflect by Z if required.
virtual ~TGeoPatternSphPhi()
Destructor.
virtual void cd(Int_t idiv)
Update current division index and global matrix to point to a given slice.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual ~TGeoPatternParaZ()
Destructor.
virtual Bool_t IsOnBoundary(const Double_t *point) const
Checks if the current point is on division boundary.
static Double_t Tolerance()
Definition: TGeoShape.h:93
virtual TGeoNode * FindNode(Double_t *point, const Double_t *dir=0)
Find the cell corresponding to point and next cell along dir (if asked)
TGeoPatternParaZ()
Default constructor.
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const
Fills external matrix with the local one corresponding to the given division index.
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const
Fills external matrix with the local one corresponding to the given division index.
TGeoPatternSphR()
Default constructor.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
TGeoPatternY()
Default constructor.
virtual TGeoMatrix * CreateMatrix() const
Return new matrix of type used by this finder.
virtual Bool_t IsOnBoundary(const Double_t *point) const
Checks if the current point is on division boundary.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
TGeoPatternSphPhi()
Default constructor.
TGeoPatternCylR()
Default constructor.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Int_t fThreadSize
Vector of thread private transient data.
TRAP is a general trapezoid, i.e.
Definition: TGeoArb8.h:91
TObject & operator=(const TObject &rhs)
TObject assignment operator.
Definition: TObject.cxx:103
Double_t ATan2(Double_t, Double_t)
Definition: TMath.h:454
virtual Bool_t IsOnBoundary(const Double_t *point) const
Checks if the current point is on division boundary.
virtual TGeoMatrix * CreateMatrix() const
Return new matrix of type used by this finder.
virtual TGeoMatrix * CreateMatrix() const
Return new matrix of type used by this finder.
TGeoPatternFinder()
Default constructor.
virtual TGeoNode * FindNode(Double_t *point, const Double_t *dir=0)
find the node containing the query point
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual TGeoMatrix * CreateMatrix() const
Return new matrix of type used by this finder.
virtual TGeoPatternFinder * MakeCopy(Bool_t reflect=kFALSE)
Make a copy of this finder. Reflect by Z if required.
TGeoVolume * fVolume
virtual ~TGeoPatternCylR()
Destructor.
virtual void cd(Int_t idiv)
Update current division index and global matrix to point to a given slice.
virtual void cd(Int_t idiv)
Update current division index and global matrix to point to a given slice.
void SetRange(Double_t start, Double_t step, Int_t ndivisions)
Set division range. Use this method only when dividing an assembly.
Base finder class for patterns.
TGeoPatternParaY()
Default constructor.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
TGeoPatternHoneycomb()
Default constructor.
virtual void cd(Int_t idiv)
Update current division index and global matrix to point to a given slice.
virtual TGeoMatrix * CreateMatrix() const
Return new matrix of type used by this finder.
Parallelepiped class.
Definition: TGeoPara.h:19
virtual TGeoNode * FindNode(Double_t *point, const Double_t *dir=0)
find the node containing the query point
TRandom2 r(17)
virtual void RegisterYourself()
Register the matrix in the current manager, which will become the owner.
TGeoPatternSphR & operator=(const TGeoPatternSphR &)
assignment operator
virtual TGeoMatrix * CreateMatrix() const
Return new matrix of type used by this finder.
void Clear(Option_t *option="")
clear the data for this matrix
virtual TGeoPatternFinder * MakeCopy(Bool_t reflect=kFALSE)
Make a copy of this finder. Reflect by Z if required.
Class describing rotation + translation.
Definition: TGeoMatrix.h:285
virtual TGeoMatrix * CreateMatrix() const
Return new matrix of type used by this finder.
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const
Fills external matrix with the local one corresponding to the given division index.
TGeoPatternY & operator=(const TGeoPatternY &)
assignment operator
TGeoPatternX()
Default constructor.
Int_t fNextIndex
current division element
virtual ~TGeoPatternSphR()
Destructor.
TGeoPatternParaZ & operator=(const TGeoPatternParaZ &)
assignment operator
TGeoPatternHoneycomb & operator=(const TGeoPatternHoneycomb &)
assignment operator
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:925
virtual TGeoPatternFinder * MakeCopy(Bool_t reflect=kFALSE)
Make a copy of this finder. Reflect by Z if required.
virtual void RegisterYourself()
Register the matrix in the current manager, which will become the owner.
Definition: TGeoMatrix.cxx:575
virtual void cd(Int_t idiv)
Update current division index and global matrix to point to a given slice.
TGeoPatternSphTheta & operator=(const TGeoPatternSphTheta &)
assignment operator
virtual TGeoPatternFinder * MakeCopy(Bool_t reflect=kFALSE)
Make a copy of this finder. Reflect by Z if required.
static Int_t Lock()
Static method to lock the main thread mutex.
Definition: TThread.cxx:758
virtual void cd(Int_t idiv)
Update current division index and global matrix to point to a given slice.
virtual TGeoMatrix * CreateMatrix() const
Return new matrix of type used by this finder.
virtual ~TGeoPatternY()
Destructor.
virtual TGeoMatrix * CreateMatrix() const =0
Double_t Cos(Double_t)
Definition: TMath.h:424
virtual TGeoMatrix * CreateMatrix() const
Return new matrix of type used by this finder.
Class describing rotations.
Definition: TGeoMatrix.h:180
virtual void SetDy(Double_t dy)
Definition: TGeoMatrix.h:446
virtual TGeoNode * FindNode(Double_t *point, const Double_t *dir=0)
find the node containing the query point
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const
Fills external matrix with the local one corresponding to the given division index.
TGeoPatternTrapZ & operator=(const TGeoPatternTrapZ &)
assignment operator
static Int_t UnLock()
Static method to unlock the main thread mutex.
Definition: TThread.cxx:774
Bool_t IsReflected() const
#define ClassImp(name)
Definition: Rtypes.h:279
double Double_t
Definition: RtypesCore.h:55
virtual TGeoNode * FindNode(Double_t *point, const Double_t *dir=0)
get the node division containing the query point
virtual ~TGeoPatternHoneycomb()
destructor
virtual TGeoMatrix * GetMatrix()
Return current matrix.
virtual void ReflectZ(Bool_t leftside, Bool_t rotonly=kFALSE)
Multiply by a reflection respect to XY.
virtual ~TGeoPatternX()
Destructor.
virtual void cd(Int_t idiv)
Update current division index and global matrix to point to a given slice.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
virtual Bool_t IsOnBoundary(const Double_t *point) const
Checks if the current point is on division boundary.
An arbitrary trapezoid with less than 8 vertices standing on.
Definition: TGeoArb8.h:19
virtual Double_t FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext)
Compute distance to next division layer returning the index of next section.
TGeoPatternCylPhi()
Default constructor.
virtual ~TGeoPatternParaY()
Destructor.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
static Double_t Big()
Definition: TGeoShape.h:90
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const
Fills external matrix with the local one corresponding to the given division index.
TGeoPatternSphTheta()
Default constructor.
Mother of all ROOT objects.
Definition: TObject.h:37
virtual TGeoPatternFinder * MakeCopy(Bool_t reflect=kFALSE)
Make a copy of this finder. Reflect by Z if required.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition: TGeoNode.h:51
TGeoPatternZ & operator=(const TGeoPatternZ &)
assignment operator
virtual TGeoNode * FindNode(Double_t *point, const Double_t *dir=0)
find the node containing the query point
R__EXTERN TGeoIdentity * gGeoIdentity
Definition: TGeoMatrix.h:464
Double_t * CreateSinCos()
Create the sincos table if it does not exist.
static Int_t ThreadId()
Translates the current thread id to an ordinal number.
virtual void SetDy(Double_t)
Definition: TGeoMatrix.h:115
virtual TGeoNode * FindNode(Double_t *point, const Double_t *dir=0)
find the node containing the query point
virtual Bool_t IsOnBoundary(const Double_t *point) const
Checks if the current point is on division boundary.
TGeoPatternCylR & operator=(const TGeoPatternCylR &)
assignment operator
virtual void cd(Int_t idiv)
Update current division index and global matrix to point to a given slice.
virtual ~TGeoPatternFinder()
Destructor.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual void cd(Int_t idiv)
Update current division index and global matrix to point to a given slice.
virtual ~TGeoPatternSphTheta()
Destructor.
virtual TGeoMatrix * CreateMatrix() const
Return new matrix of type used by this finder.
Double_t Sin(Double_t)
Definition: TMath.h:421
#define NULL
Definition: Rtypes.h:82
virtual TGeoNode * CdNext()
Make next node (if any) current.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual void cd(Int_t)
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const
Fills external matrix with the local one corresponding to the given division index.
void ClearThreadData() const
Double_t Sqrt(Double_t x)
Definition: TMath.h:464
Int_t GetNext() const
Get index of next division.
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const
Fills external matrix with the local one corresponding to the given division index.
TGeoShape * GetShape() const
Definition: TGeoVolume.h:204
virtual TGeoMatrix * CreateMatrix() const
Return new matrix of type used by this finder.
const Bool_t kTRUE
Definition: Rtypes.h:91
void SetNext(Int_t index)
Set index of next division.
std::vector< ThreadData_t * > fThreadData
virtual void SetDz(Double_t dz)
Definition: TGeoMatrix.h:447
virtual TGeoPatternFinder * MakeCopy(Bool_t reflect=kFALSE)
Make a copy of this finder. Reflect by Z if required.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Double_t Tan(Double_t)
Definition: TMath.h:427
void Reflect(Bool_t flag=kTRUE)
virtual ~TGeoPatternParaX()
Destructor.
virtual TGeoPatternFinder * MakeCopy(Bool_t reflect=kFALSE)
Make a copy of this finder. Reflect by Z if required.
TGeoPatternTrapZ()
Default constructor.