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