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