TGeoPatternFinder.cxx

Go to the documentation of this file.
00001 // @(#)root/geom:$Id: TGeoPatternFinder.cxx 34898 2010-08-20 15:53:58Z agheata $
00002 // Author: Andrei Gheata   30/10/01
00003 
00004 //_____________________________________________________________________________
00005 // TGeoPatternFinder - base finder class for patterns. 
00006 //==================
00007 //   A pattern is specifying a division type which applies only to a given
00008 // shape type. The implemented patterns are for the moment equidistant slices
00009 // on different axis. Implemented patterns are:
00010 //
00011 // TGeoPatternX - a X axis divison pattern
00012 // TGeoPatternY - a Y axis divison pattern
00013 // TGeoPatternZ - a Z axis divison pattern
00014 // TGeoPatternParaX - a X axis divison pattern for PARA shape
00015 // TGeoPatternParaY - a Y axis divison pattern for PARA shape
00016 // TGeoPatternParaZ - a Z axis divison pattern for PARA shape
00017 // TGeoPatternTrapZ - a Z axis divison pattern for TRAP or GTRA shapes
00018 // TGeoPatternCylR - a cylindrical R divison pattern
00019 // TGeoPatternCylPhi - a cylindrical phi divison pattern
00020 // TGeoPatternSphR - a spherical R divison pattern
00021 // TGeoPatternSphTheta - a spherical theta divison pattern
00022 // TGeoPatternSphPhi - a spherical phi divison pattern
00023 // TGeoPatternHoneycomb - a divison pattern specialized for honeycombs
00024 //_____________________________________________________________________________
00025 
00026 #include "Riostream.h"
00027 #include "TObject.h"
00028 #include "TGeoMatrix.h"
00029 #include "TGeoPara.h"
00030 #include "TGeoArb8.h"
00031 #include "TGeoNode.h"
00032 #include "TGeoManager.h"
00033 #include "TMath.h"
00034 
00035 #include "TGeoPatternFinder.h"
00036 
00037 ClassImp(TGeoPatternFinder)
00038 ClassImp(TGeoPatternX)
00039 ClassImp(TGeoPatternY)
00040 ClassImp(TGeoPatternZ)
00041 ClassImp(TGeoPatternParaX)
00042 ClassImp(TGeoPatternParaY)
00043 ClassImp(TGeoPatternParaZ)
00044 ClassImp(TGeoPatternTrapZ)
00045 ClassImp(TGeoPatternCylR)
00046 ClassImp(TGeoPatternCylPhi)
00047 ClassImp(TGeoPatternSphR)
00048 ClassImp(TGeoPatternSphTheta)
00049 ClassImp(TGeoPatternSphPhi)
00050 ClassImp(TGeoPatternHoneycomb)
00051    
00052 
00053 //_____________________________________________________________________________
00054 TGeoPatternFinder::TGeoPatternFinder()
00055 {
00056 // Default constructor
00057    fMatrix     = 0;
00058    fCurrent    = -1;
00059    fNdivisions = 0;
00060    fDivIndex   = 0;
00061    fStep       = 0;
00062    fStart      = 0;
00063    fEnd        = 0;
00064    fVolume     = 0;
00065    fNextIndex = -1;
00066 }
00067 
00068 //_____________________________________________________________________________
00069 TGeoPatternFinder::TGeoPatternFinder(TGeoVolume *vol, Int_t ndiv)
00070 {
00071 // Default constructor
00072    fVolume     = vol;
00073    fMatrix     = 0;
00074    fCurrent    = -1;
00075    fNdivisions = ndiv;
00076    fDivIndex   = 0;
00077    fStep       = 0;
00078    fStart      = 0;
00079    fEnd        = 0;
00080    fNextIndex = -1;
00081 }
00082 
00083 //_____________________________________________________________________________
00084 TGeoPatternFinder::TGeoPatternFinder(const TGeoPatternFinder& pf) :
00085   TObject(pf),
00086   fStep(pf.fStep),
00087   fStart(pf.fStart),
00088   fEnd(pf.fEnd),
00089   fCurrent(pf.fCurrent),
00090   fNdivisions(pf.fNdivisions),
00091   fDivIndex(pf.fDivIndex),
00092   fMatrix(pf.fMatrix),
00093   fVolume(pf.fVolume),
00094   fNextIndex(pf.fNextIndex)
00095 { 
00096    //copy constructor
00097 }
00098 
00099 //_____________________________________________________________________________
00100 TGeoPatternFinder& TGeoPatternFinder::operator=(const TGeoPatternFinder& pf)
00101 {
00102    //assignment operator
00103    if(this!=&pf) {
00104       TObject::operator=(pf);
00105       fStep=pf.fStep;
00106       fStart=pf.fStart;
00107       fEnd=pf.fEnd;
00108       fCurrent=pf.fCurrent;
00109       fNdivisions=pf.fNdivisions;
00110       fDivIndex=pf.fDivIndex;
00111       fMatrix=pf.fMatrix;
00112       fVolume=pf.fVolume;
00113       fNextIndex = pf.fNextIndex;
00114    } 
00115    return *this;
00116 }
00117 
00118 //_____________________________________________________________________________
00119 TGeoPatternFinder::~TGeoPatternFinder()
00120 {
00121 // Destructor
00122 }
00123 
00124 //______________________________________________________________________________
00125 TGeoNode *TGeoPatternFinder::CdNext()
00126 {
00127 // Make next node (if any) current.
00128    if (fNextIndex < 0) return NULL;
00129    cd(fNextIndex);
00130    return GetNodeOffset(fCurrent);
00131 }   
00132 
00133 //______________________________________________________________________________
00134 TGeoPatternFinder *TGeoPatternFinder::MakeCopy(Bool_t)
00135 {
00136 // Make a copy of this finder. Has to be overwritten by derived classes.
00137    return NULL;
00138 }
00139 
00140 //______________________________________________________________________________
00141 // TGeoPatternX - a X axis divison pattern
00142 //______________________________________________________________________________
00143 
00144 //_____________________________________________________________________________
00145 TGeoPatternX::TGeoPatternX()
00146 {
00147 // Default constructor
00148 }
00149 
00150 //_____________________________________________________________________________
00151 TGeoPatternX::TGeoPatternX(TGeoVolume *vol, Int_t ndivisions)
00152              :TGeoPatternFinder(vol, ndivisions)
00153 {   
00154 // constructor
00155    Double_t dx = ((TGeoBBox*)vol->GetShape())->GetDX();
00156    fStart = -dx;
00157    fEnd = dx;
00158    fStep = 2*dx/ndivisions;
00159    fMatrix     = new TGeoTranslation(0,0,0);
00160    fMatrix->RegisterYourself();
00161 }
00162 
00163 //_____________________________________________________________________________
00164 TGeoPatternX::TGeoPatternX(TGeoVolume *vol, Int_t ndivisions, Double_t step)
00165              :TGeoPatternFinder(vol, ndivisions)
00166 {   
00167 // constructor
00168    Double_t dx = ((TGeoBBox*)vol->GetShape())->GetDX();
00169    fStart = -dx;
00170    fEnd = fStart + ndivisions*step;
00171    fStep       = step;
00172    fMatrix     = new TGeoTranslation(0,0,0);
00173    fMatrix->RegisterYourself();
00174 }
00175 
00176 //_____________________________________________________________________________
00177 TGeoPatternX::TGeoPatternX(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
00178              :TGeoPatternFinder(vol, ndivisions)
00179 {   
00180 // constructor
00181    fStart      = start;
00182    fEnd        = end;
00183    fStep       = (end - start)/ndivisions;
00184    fMatrix     = new TGeoTranslation(0,0,0);
00185    fMatrix->RegisterYourself();
00186 }
00187 
00188 //_____________________________________________________________________________
00189 void TGeoPatternX::cd(Int_t idiv)
00190 {
00191 // Update current division index and global matrix to point to a given slice.
00192    fCurrent=idiv; 
00193    fMatrix->SetDx(fStart+idiv*fStep+0.5*fStep);
00194 }
00195 
00196 //_____________________________________________________________________________
00197 TGeoPatternX::~TGeoPatternX()
00198 {
00199 // Destructor
00200 }
00201 
00202 //_____________________________________________________________________________
00203 Bool_t TGeoPatternX::IsOnBoundary(const Double_t *point) const
00204 {
00205 // Checks if the current point is on division boundary
00206    Double_t seg = (point[0]-fStart)/fStep;
00207    Double_t diff = seg - Int_t(seg);
00208    if (diff>0.5) diff = 1.-diff;
00209    if (diff<1e-8) return kTRUE;
00210    return kFALSE;
00211 }   
00212 
00213 //_____________________________________________________________________________
00214 TGeoNode *TGeoPatternX::FindNode(Double_t *point, const Double_t *dir)
00215 {
00216 // Find the cell corresponding to point and next cell along dir (if asked)
00217    TGeoNode *node = 0;
00218    Int_t ind = (Int_t)(1.+(point[0]-fStart)/fStep) - 1;
00219    if (dir) {
00220       fNextIndex = ind;
00221       if (dir[0]>0) fNextIndex++;
00222       else fNextIndex--;
00223       if ((fNextIndex<0) || (fNextIndex>=fNdivisions)) fNextIndex = -1;
00224    }   
00225    if ((ind<0) || (ind>=fNdivisions)) return node; 
00226    node = GetNodeOffset(ind);
00227    cd(ind);
00228    return node;
00229 }
00230 
00231 //______________________________________________________________________________
00232 Double_t TGeoPatternX::FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext)
00233 {
00234 // Compute distance to next division layer returning the index of next section.
00235 // Point is in the frame of the divided volume.
00236    indnext = -1;
00237    Double_t dist = TGeoShape::Big();
00238    if (TMath::Abs(dir[0])<TGeoShape::Tolerance()) return dist;
00239    if (fCurrent<0) {
00240       Error("FindNextBoundary", "Must call FindNode first");
00241       return dist;
00242    }   
00243    Int_t inc = (dir[0]>0)?1:0;
00244    dist = (fStep*(fCurrent+inc)-point[0])/dir[0];
00245    if (dist<0.) Error("FindNextBoundary", "Negative distance d=%g",dist);
00246    if (!inc) inc = -1;
00247    indnext = fCurrent+inc;
00248    return dist;   
00249 }   
00250 
00251 //______________________________________________________________________________
00252 TGeoPatternFinder *TGeoPatternX::MakeCopy(Bool_t reflect)
00253 {
00254 // Make a copy of this finder. Reflect by Z if required.
00255    TGeoPatternX *finder = new TGeoPatternX(*this);
00256    if (!reflect) return finder;
00257    Reflect();
00258    TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
00259    combi->ReflectZ(kTRUE);
00260    combi->ReflectZ(kFALSE);
00261    combi->RegisterYourself();
00262    fMatrix = combi;
00263    return finder;
00264 }
00265    
00266 //______________________________________________________________________________
00267 void TGeoPatternX::SavePrimitive(ostream &out, Option_t * /*option*/ /*= ""*/)
00268 {
00269    // Save a primitive as a C++ statement(s) on output stream "out".
00270    Int_t iaxis = 1;
00271    out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep; 
00272 }
00273 
00274 //______________________________________________________________________________
00275 // TGeoPatternY - a Y axis divison pattern
00276 //______________________________________________________________________________
00277 
00278 
00279 //_____________________________________________________________________________
00280 TGeoPatternY::TGeoPatternY()
00281 {
00282 // Default constructor
00283 }
00284 
00285 //_____________________________________________________________________________
00286 TGeoPatternY::TGeoPatternY(TGeoVolume *vol, Int_t ndivisions)
00287              :TGeoPatternFinder(vol, ndivisions)
00288 {   
00289 // constructor
00290    Double_t dy = ((TGeoBBox*)vol->GetShape())->GetDY();
00291    fStart = -dy;
00292    fEnd = dy;
00293    fStep = 2*dy/ndivisions;
00294    fMatrix     = new TGeoTranslation(0,0,0);
00295    fMatrix->RegisterYourself();
00296 }
00297 
00298 //_____________________________________________________________________________
00299 TGeoPatternY::TGeoPatternY(TGeoVolume *vol, Int_t ndivisions, Double_t step)
00300              :TGeoPatternFinder(vol, ndivisions)
00301 {   
00302 // constructor
00303    Double_t dy = ((TGeoBBox*)vol->GetShape())->GetDY();
00304    fStart = -dy;
00305    fEnd = fStart + ndivisions*step;
00306    fStep       = step;
00307    fMatrix     = new TGeoTranslation(0,0,0);
00308    fMatrix->RegisterYourself();
00309 }
00310 
00311 //_____________________________________________________________________________
00312 TGeoPatternY::TGeoPatternY(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
00313              :TGeoPatternFinder(vol, ndivisions)
00314 {   
00315 // constructor
00316    fStart      = start;
00317    fEnd        = end;
00318    fStep       = (end - start)/ndivisions;
00319    fMatrix     = new TGeoTranslation(0,0,0);
00320    fMatrix->RegisterYourself();
00321 }
00322 
00323 //_____________________________________________________________________________
00324 TGeoPatternY::~TGeoPatternY()
00325 {
00326 // Destructor
00327 }
00328 
00329 //_____________________________________________________________________________
00330 void TGeoPatternY::cd(Int_t idiv)
00331 {
00332 // Update current division index and global matrix to point to a given slice.
00333    fCurrent=idiv; 
00334    fMatrix->SetDy(fStart+idiv*fStep+0.5*fStep);
00335 }
00336 
00337 //_____________________________________________________________________________
00338 Bool_t TGeoPatternY::IsOnBoundary(const Double_t *point) const
00339 {
00340 // Checks if the current point is on division boundary
00341    Double_t seg = (point[1]-fStart)/fStep;
00342    Double_t diff = seg - Int_t(seg);
00343    if (diff>0.5) diff = 1.-diff;
00344    if (diff<1e-8) return kTRUE;
00345    return kFALSE;
00346 }   
00347 
00348 //_____________________________________________________________________________
00349 TGeoNode *TGeoPatternY::FindNode(Double_t *point, const Double_t *dir)
00350 {
00351 // Find the cell corresponding to point and next cell along dir (if asked)
00352    TGeoNode *node = 0;
00353    Int_t ind = (Int_t)(1.+(point[1]-fStart)/fStep) - 1;
00354    if (dir) {
00355       fNextIndex = ind;
00356       if (dir[1]>0) fNextIndex++;
00357       else fNextIndex--;
00358       if ((fNextIndex<0) || (fNextIndex>=fNdivisions)) fNextIndex = -1;
00359    }   
00360    if ((ind<0) || (ind>=fNdivisions)) return node; 
00361    node = GetNodeOffset(ind);
00362    cd(ind);
00363    return node;
00364 }
00365 
00366 //______________________________________________________________________________
00367 Double_t TGeoPatternY::FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext)
00368 {
00369 // Compute distance to next division layer returning the index of next section.
00370 // Point is in the frame of the divided volume.
00371    indnext = -1;
00372    Double_t dist = TGeoShape::Big();
00373    if (TMath::Abs(dir[1])<TGeoShape::Tolerance()) return dist;
00374    if (fCurrent<0) {
00375       Error("FindNextBoundary", "Must call FindNode first");
00376       return dist;
00377    }   
00378    Int_t inc = (dir[1]>0)?1:0;
00379    dist = (fStep*(fCurrent+inc)-point[1])/dir[1];
00380    if (dist<0.) Error("FindNextBoundary", "Negative distance d=%g",dist);
00381    if (!inc) inc = -1;
00382    indnext = fCurrent+inc;
00383    return dist;   
00384 }   
00385    
00386 //______________________________________________________________________________
00387 TGeoPatternFinder *TGeoPatternY::MakeCopy(Bool_t reflect)
00388 {
00389 // Make a copy of this finder. Reflect by Z if required.
00390    TGeoPatternY *finder = new TGeoPatternY(*this);
00391    if (!reflect) return finder;
00392    Reflect();
00393    TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
00394    combi->ReflectZ(kTRUE);
00395    combi->ReflectZ(kFALSE);
00396    combi->RegisterYourself();
00397    fMatrix = combi;
00398    return finder;
00399 }
00400    
00401 //______________________________________________________________________________
00402 void TGeoPatternY::SavePrimitive(ostream &out, Option_t * /*option*/ /*= ""*/)
00403 {
00404    // Save a primitive as a C++ statement(s) on output stream "out".
00405    Int_t iaxis = 2;
00406    out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
00407 }
00408 
00409 //______________________________________________________________________________
00410 // TGeoPatternZ - a Z axis divison pattern
00411 //______________________________________________________________________________
00412 
00413 
00414 //_____________________________________________________________________________
00415 TGeoPatternZ::TGeoPatternZ()
00416 {
00417 // Default constructor
00418 }
00419 //_____________________________________________________________________________
00420 TGeoPatternZ::TGeoPatternZ(TGeoVolume *vol, Int_t ndivisions)
00421              :TGeoPatternFinder(vol, ndivisions)
00422 {   
00423 // constructor
00424    Double_t dz = ((TGeoBBox*)vol->GetShape())->GetDZ();
00425    fStart = -dz;
00426    fEnd = dz;
00427    fStep = 2*dz/ndivisions;
00428    fMatrix     = new TGeoTranslation(0,0,0);
00429    fMatrix->RegisterYourself();
00430 }
00431 //_____________________________________________________________________________
00432 TGeoPatternZ::TGeoPatternZ(TGeoVolume *vol, Int_t ndivisions, Double_t step)
00433              :TGeoPatternFinder(vol, ndivisions)
00434 {   
00435 // constructor
00436    Double_t dz = ((TGeoBBox*)vol->GetShape())->GetDZ();
00437    fStart = -dz;
00438    fEnd = fStart + ndivisions*step;
00439    fStep       = step;
00440    fMatrix     = new TGeoTranslation(0,0,0);
00441    fMatrix->RegisterYourself();
00442 }
00443 //_____________________________________________________________________________
00444 TGeoPatternZ::TGeoPatternZ(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
00445              :TGeoPatternFinder(vol, ndivisions)
00446 {   
00447 // constructor
00448    fStart      = start;
00449    fEnd        = end;
00450    fStep       = (end - start)/ndivisions;
00451    fMatrix     = new TGeoTranslation(0,0,0);
00452    fMatrix->RegisterYourself();
00453 }
00454 //_____________________________________________________________________________
00455 TGeoPatternZ::~TGeoPatternZ()
00456 {
00457 // Destructor
00458 }
00459 //_____________________________________________________________________________
00460 void TGeoPatternZ::cd(Int_t idiv)
00461 {
00462 // Update current division index and global matrix to point to a given slice.
00463    fCurrent=idiv; 
00464    fMatrix->SetDz(((IsReflected())?-1.:1.)*(fStart+idiv*fStep+0.5*fStep));
00465 }
00466 
00467 //_____________________________________________________________________________
00468 Bool_t TGeoPatternZ::IsOnBoundary(const Double_t *point) const
00469 {
00470 // Checks if the current point is on division boundary
00471    Double_t seg = (point[2]-fStart)/fStep;
00472    Double_t diff = seg - Int_t(seg);
00473    if (diff>0.5) diff = 1.-diff;
00474    if (diff<1e-8) return kTRUE;
00475    return kFALSE;
00476 }   
00477 
00478 //_____________________________________________________________________________
00479 TGeoNode *TGeoPatternZ::FindNode(Double_t *point, const Double_t *dir)
00480 {
00481 // Find the cell corresponding to point and next cell along dir (if asked)
00482    TGeoNode *node = 0;
00483    Int_t ind = (Int_t)(1.+(point[2]-fStart)/fStep) - 1;
00484    if (dir) {
00485       fNextIndex = ind;
00486       if (dir[2]>0) fNextIndex++;
00487       else fNextIndex--;
00488       if ((fNextIndex<0) || (fNextIndex>=fNdivisions)) fNextIndex = -1;
00489    }   
00490    if ((ind<0) || (ind>=fNdivisions)) return node; 
00491    node = GetNodeOffset(ind);
00492    cd(ind);
00493    return node;
00494 }
00495 
00496 //______________________________________________________________________________
00497 Double_t TGeoPatternZ::FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext)
00498 {
00499 // Compute distance to next division layer returning the index of next section.
00500 // Point is in the frame of the divided volume.
00501    indnext = -1;
00502    Double_t dist = TGeoShape::Big();
00503    if (TMath::Abs(dir[2])<TGeoShape::Tolerance()) return dist;
00504    if (fCurrent<0) {
00505       Error("FindNextBoundary", "Must call FindNode first");
00506       return dist;
00507    }   
00508    Int_t inc = (dir[2]>0)?1:0;
00509    dist = (fStep*(fCurrent+inc)-point[2])/dir[2];
00510    if (dist<0.) Error("FindNextBoundary", "Negative distance d=%g",dist);
00511    if (!inc) inc = -1;
00512    indnext = fCurrent+inc;
00513    return dist;   
00514 }   
00515 
00516 //______________________________________________________________________________
00517 TGeoPatternFinder *TGeoPatternZ::MakeCopy(Bool_t reflect)
00518 {
00519 // Make a copy of this finder. Reflect by Z if required.
00520    TGeoPatternZ *finder = new TGeoPatternZ(*this);
00521    if (!reflect) return finder;
00522    Reflect();
00523    TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
00524    combi->ReflectZ(kTRUE);
00525    combi->ReflectZ(kFALSE);
00526    combi->RegisterYourself();
00527    fMatrix = combi;
00528    return finder;
00529 }
00530    
00531 //______________________________________________________________________________
00532 void TGeoPatternZ::SavePrimitive(ostream &out, Option_t * /*option*/ /*= ""*/)
00533 {
00534    // Save a primitive as a C++ statement(s) on output stream "out".
00535    Int_t iaxis = 3;
00536    out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep; 
00537 }
00538 
00539 //______________________________________________________________________________
00540 // TGeoPatternParaX - a X axis divison pattern for PARA shape
00541 //______________________________________________________________________________
00542 
00543 //_____________________________________________________________________________
00544 TGeoPatternParaX::TGeoPatternParaX()
00545 {
00546 // Default constructor
00547 }
00548 //_____________________________________________________________________________
00549 TGeoPatternParaX::TGeoPatternParaX(TGeoVolume *vol, Int_t ndivisions)
00550              :TGeoPatternFinder(vol, ndivisions)
00551 {   
00552 // constructor
00553    Double_t dx = ((TGeoPara*)vol->GetShape())->GetX();
00554    fStart = -dx;
00555    fEnd = dx;
00556    fStep = 2*dx/ndivisions;
00557    fMatrix     = new TGeoTranslation(0,0,0);
00558    fMatrix->RegisterYourself();
00559 }
00560 //_____________________________________________________________________________
00561 TGeoPatternParaX::TGeoPatternParaX(TGeoVolume *vol, Int_t ndivisions, Double_t step)
00562              :TGeoPatternFinder(vol, ndivisions)
00563 {   
00564 // constructor
00565    Double_t dx = ((TGeoPara*)vol->GetShape())->GetX();
00566    fStart = -dx;
00567    fEnd = fStart + ndivisions*step;
00568    fStep       = step;
00569    fMatrix     = new TGeoTranslation(0,0,0);
00570    fMatrix->RegisterYourself();
00571 }
00572 //_____________________________________________________________________________
00573 TGeoPatternParaX::TGeoPatternParaX(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
00574              :TGeoPatternFinder(vol, ndivisions)
00575 {   
00576 // constructor
00577    fStart      = start;
00578    fEnd        = end;
00579    fStep       = (end - start)/ndivisions;
00580    fMatrix     = new TGeoTranslation(0,0,0);
00581    fMatrix->RegisterYourself();
00582 }
00583 //_____________________________________________________________________________
00584 TGeoPatternParaX::~TGeoPatternParaX()
00585 {
00586 // Destructor
00587 }
00588 //_____________________________________________________________________________
00589 void TGeoPatternParaX::cd(Int_t idiv)
00590 {
00591 // Update current division index and global matrix to point to a given slice.
00592    fCurrent=idiv; 
00593    fMatrix->SetDx(fStart+idiv*fStep+0.5*fStep);
00594 }
00595 
00596 //_____________________________________________________________________________
00597 Bool_t TGeoPatternParaX::IsOnBoundary(const Double_t *point) const
00598 {
00599 // Checks if the current point is on division boundary
00600    Double_t txy = ((TGeoPara*)fVolume->GetShape())->GetTxy();
00601    Double_t txz = ((TGeoPara*)fVolume->GetShape())->GetTxz();
00602    Double_t tyz = ((TGeoPara*)fVolume->GetShape())->GetTyz();
00603    Double_t xt = point[0]-txz*point[2]-txy*(point[1]-tyz*point[2]);
00604    Double_t seg = (xt-fStart)/fStep;
00605    Double_t diff = seg - Int_t(seg);
00606    if (diff>0.5) diff = 1.-diff;
00607    if (diff<1e-8) return kTRUE;
00608    return kFALSE;
00609 }   
00610 
00611 //_____________________________________________________________________________
00612 TGeoNode *TGeoPatternParaX::FindNode(Double_t *point, const Double_t *dir)
00613 {
00614 // get the node division containing the query point
00615    TGeoNode *node = 0;
00616    Double_t txy = ((TGeoPara*)fVolume->GetShape())->GetTxy();
00617    Double_t txz = ((TGeoPara*)fVolume->GetShape())->GetTxz();
00618    Double_t tyz = ((TGeoPara*)fVolume->GetShape())->GetTyz();
00619    Double_t xt = point[0]-txz*point[2]-txy*(point[1]-tyz*point[2]);
00620    Int_t ind = (Int_t)(1.+(xt-fStart)/fStep)-1;
00621    if (dir) {
00622       Double_t ttsq = txy*txy + (txz-txy*tyz)*(txz-txy*tyz);
00623       Double_t divdirx = 1./TMath::Sqrt(1.+ttsq);
00624       Double_t divdiry = -txy*divdirx;
00625       Double_t divdirz = -(txz-txy*tyz)*divdirx;
00626       Double_t dot = dir[0]*divdirx + dir[1]*divdiry + dir[2]*divdirz;
00627       fNextIndex = ind;
00628       if (dot>0) fNextIndex++;
00629       else fNextIndex--;
00630       if ((fNextIndex<0) || (fNextIndex>=fNdivisions)) fNextIndex = -1;
00631    }
00632    if ((ind<0) || (ind>=fNdivisions)) return node; 
00633    node = GetNodeOffset(ind);
00634    cd(ind);
00635    return node;
00636 }
00637 
00638 //______________________________________________________________________________
00639 TGeoPatternFinder *TGeoPatternParaX::MakeCopy(Bool_t reflect)
00640 {
00641 // Make a copy of this finder. Reflect by Z if required.
00642    TGeoPatternParaX *finder = new TGeoPatternParaX(*this);
00643    if (!reflect) return finder;
00644    Reflect();
00645    TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
00646    combi->ReflectZ(kTRUE);
00647    combi->ReflectZ(kFALSE);
00648    combi->RegisterYourself();
00649    fMatrix = combi;
00650    return finder;
00651 }
00652    
00653 //______________________________________________________________________________
00654 void TGeoPatternParaX::SavePrimitive(ostream &out, Option_t * /*option*/ /*= ""*/)
00655 {
00656    // Save a primitive as a C++ statement(s) on output stream "out".
00657    Int_t iaxis = 1;
00658    out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep; 
00659 }
00660 
00661 //______________________________________________________________________________
00662 // TGeoPatternParaY - a Y axis divison pattern for PARA shape
00663 //______________________________________________________________________________
00664 
00665 //_____________________________________________________________________________
00666 TGeoPatternParaY::TGeoPatternParaY()
00667 {
00668 // Default constructor
00669    fTxy = 0;
00670 }
00671 //_____________________________________________________________________________
00672 TGeoPatternParaY::TGeoPatternParaY(TGeoVolume *vol, Int_t ndivisions)
00673              :TGeoPatternFinder(vol, ndivisions)
00674 {   
00675 // constructor
00676    fTxy = ((TGeoPara*)vol->GetShape())->GetTxy();
00677    Double_t dy = ((TGeoPara*)vol->GetShape())->GetY();
00678    fStart = -dy;
00679    fEnd = dy;
00680    fStep = 2*dy/ndivisions;
00681    fMatrix     = new TGeoTranslation(0,0,0);
00682    fMatrix->RegisterYourself();
00683 }
00684 //_____________________________________________________________________________
00685 TGeoPatternParaY::TGeoPatternParaY(TGeoVolume *vol, Int_t ndivisions, Double_t step)
00686              :TGeoPatternFinder(vol, ndivisions)
00687 {   
00688 // constructor
00689    fTxy = ((TGeoPara*)vol->GetShape())->GetTxy();
00690    Double_t dy = ((TGeoPara*)vol->GetShape())->GetY();
00691    fStart = -dy;
00692    fEnd = fStart + ndivisions*step;
00693    fStep       = step;
00694    fMatrix     = new TGeoTranslation(0,0,0);
00695    fMatrix->RegisterYourself();
00696 }
00697 //_____________________________________________________________________________
00698 TGeoPatternParaY::TGeoPatternParaY(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
00699              :TGeoPatternFinder(vol, ndivisions)
00700 {   
00701 // constructor
00702    fTxy = ((TGeoPara*)vol->GetShape())->GetTxy();
00703    fStart      = start;
00704    fEnd        = end;
00705    fStep       = (end - start)/ndivisions;
00706    fMatrix     = new TGeoTranslation(0,0,0);
00707    fMatrix->RegisterYourself();
00708 }
00709 //_____________________________________________________________________________
00710 TGeoPatternParaY::~TGeoPatternParaY()
00711 {
00712 // Destructor
00713 }
00714 //_____________________________________________________________________________
00715 void TGeoPatternParaY::cd(Int_t idiv)
00716 {
00717 // Update current division index and global matrix to point to a given slice.
00718    fCurrent = idiv;
00719    Double_t dy = fStart+idiv*fStep+0.5*fStep;
00720    fMatrix->SetDx(fTxy*dy);
00721    fMatrix->SetDy(dy);
00722 }
00723 
00724 //_____________________________________________________________________________
00725 Bool_t TGeoPatternParaY::IsOnBoundary(const Double_t *point) const
00726 {
00727 // Checks if the current point is on division boundary
00728    Double_t tyz = ((TGeoPara*)fVolume->GetShape())->GetTyz();
00729    Double_t yt = point[1]-tyz*point[2];
00730    Double_t seg = (yt-fStart)/fStep;
00731    Double_t diff = seg - Int_t(seg);
00732    if (diff>0.5) diff = 1.-diff;
00733    if (diff<1e-8) return kTRUE;
00734    return kFALSE;
00735 }   
00736 
00737 //_____________________________________________________________________________
00738 TGeoNode *TGeoPatternParaY::FindNode(Double_t *point, const Double_t *dir)
00739 {
00740 // get the node division containing the query point
00741    TGeoNode *node = 0;
00742    Double_t tyz = ((TGeoPara*)fVolume->GetShape())->GetTyz();
00743    Double_t yt = point[1]-tyz*point[2];
00744    Int_t ind = (Int_t)(1.+(yt-fStart)/fStep) - 1;
00745    if (dir) {
00746       Double_t divdiry = 1./TMath::Sqrt(1.+tyz*tyz);
00747       Double_t divdirz = -tyz*divdiry;
00748       Double_t dot = dir[1]*divdiry + dir[2]*divdirz;
00749       fNextIndex = ind;
00750       if (dot>0) fNextIndex++;
00751       else fNextIndex--;
00752       if ((fNextIndex<0) || (fNextIndex>=fNdivisions)) fNextIndex = -1;
00753    }
00754    if ((ind<0) || (ind>=fNdivisions)) return node; 
00755    node = GetNodeOffset(ind);
00756    cd(ind);
00757    return node;
00758 }
00759 
00760 //______________________________________________________________________________
00761 TGeoPatternFinder *TGeoPatternParaY::MakeCopy(Bool_t reflect)
00762 {
00763 // Make a copy of this finder. Reflect by Z if required.
00764    TGeoPatternParaY *finder = new TGeoPatternParaY(*this);
00765    if (!reflect) return finder;
00766    Reflect();
00767    TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
00768    combi->ReflectZ(kTRUE);
00769    combi->ReflectZ(kFALSE);
00770    combi->RegisterYourself();
00771    fMatrix = combi;
00772    return finder;
00773 }
00774    
00775 //______________________________________________________________________________
00776 void TGeoPatternParaY::SavePrimitive(ostream &out, Option_t * /*option*/ /*= ""*/)
00777 {
00778    // Save a primitive as a C++ statement(s) on output stream "out".
00779    Int_t iaxis = 2;
00780    out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep; 
00781 }
00782 
00783 //______________________________________________________________________________
00784 // TGeoPatternParaZ - a Z axis divison pattern for PARA shape
00785 //______________________________________________________________________________
00786 
00787 //_____________________________________________________________________________
00788 TGeoPatternParaZ::TGeoPatternParaZ()
00789 {
00790 // Default constructor
00791    fTxz = 0;
00792    fTyz = 0;
00793 }
00794 //_____________________________________________________________________________
00795 TGeoPatternParaZ::TGeoPatternParaZ(TGeoVolume *vol, Int_t ndivisions)
00796              :TGeoPatternFinder(vol, ndivisions)
00797 {   
00798 // constructor
00799    fTxz = ((TGeoPara*)vol->GetShape())->GetTxz();
00800    fTyz = ((TGeoPara*)vol->GetShape())->GetTyz();
00801    Double_t dz = ((TGeoPara*)vol->GetShape())->GetZ();
00802    fStart = -dz;
00803    fEnd = dz;
00804    fStep = 2*dz/ndivisions;
00805    fMatrix     = new TGeoTranslation(0,0,0);
00806    fMatrix->RegisterYourself();
00807 }
00808 //_____________________________________________________________________________
00809 TGeoPatternParaZ::TGeoPatternParaZ(TGeoVolume *vol, Int_t ndivisions, Double_t step)
00810              :TGeoPatternFinder(vol, ndivisions)
00811 {   
00812 // constructor
00813    fTxz = ((TGeoPara*)vol->GetShape())->GetTxz();
00814    fTyz = ((TGeoPara*)vol->GetShape())->GetTyz();
00815    Double_t dz = ((TGeoPara*)vol->GetShape())->GetZ();
00816    fStart = -dz;
00817    fEnd = fStart + ndivisions*step;
00818    fStep       = step;
00819    fMatrix     = new TGeoTranslation(0,0,0);
00820    fMatrix->RegisterYourself();
00821 }
00822 
00823 //_____________________________________________________________________________
00824 TGeoPatternParaZ::TGeoPatternParaZ(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
00825              :TGeoPatternFinder(vol, ndivisions)
00826 {   
00827 // constructor
00828    fTxz = ((TGeoPara*)vol->GetShape())->GetTxz();
00829    fTyz = ((TGeoPara*)vol->GetShape())->GetTyz();
00830    fStart      = start;
00831    fEnd        = end;
00832    fStep       = (end - start)/ndivisions;
00833    fMatrix     = new TGeoTranslation(0,0,0);
00834    fMatrix->RegisterYourself();
00835 }
00836 
00837 //_____________________________________________________________________________
00838 TGeoPatternParaZ::~TGeoPatternParaZ()
00839 {
00840 // Destructor
00841 }
00842 
00843 //_____________________________________________________________________________
00844 void TGeoPatternParaZ::cd(Int_t idiv)
00845 {
00846 // Update current division index and global matrix to point to a given slice.
00847    fCurrent = idiv;
00848    Double_t dz = fStart+idiv*fStep+0.5*fStep;
00849    fMatrix->SetDx(fTxz*dz);
00850    fMatrix->SetDy(fTyz*dz);
00851    fMatrix->SetDz((IsReflected())?-dz:dz);
00852 }
00853 
00854 //_____________________________________________________________________________
00855 Bool_t TGeoPatternParaZ::IsOnBoundary(const Double_t *point) const
00856 {
00857 // Checks if the current point is on division boundary
00858    Double_t seg = (point[2]-fStart)/fStep;
00859    Double_t diff = seg - Int_t(seg);
00860    if (diff>0.5) diff = 1.-diff;
00861    if (diff<1e-8) return kTRUE;
00862    return kFALSE;
00863 }   
00864 
00865 //_____________________________________________________________________________
00866 TGeoNode *TGeoPatternParaZ::FindNode(Double_t *point, const Double_t *dir)
00867 {
00868 // get the node division containing the query point
00869    TGeoNode *node = 0;
00870    Double_t zt = point[2];
00871    Int_t ind = (Int_t)(1.+(zt-fStart)/fStep) - 1;
00872    if (dir) {
00873       fNextIndex = ind;
00874       if (dir[2]>0) fNextIndex++;
00875       else fNextIndex--;
00876       if ((fNextIndex<0) || (fNextIndex>=fNdivisions)) fNextIndex = -1;
00877    }   
00878    if ((ind<0) || (ind>=fNdivisions)) return node; 
00879    node = GetNodeOffset(ind);
00880    cd(ind);
00881    return node;
00882 }
00883 
00884 //______________________________________________________________________________
00885 TGeoPatternFinder *TGeoPatternParaZ::MakeCopy(Bool_t reflect)
00886 {
00887 // Make a copy of this finder. Reflect by Z if required.
00888    TGeoPatternParaZ *finder = new TGeoPatternParaZ(*this);
00889    if (!reflect) return finder;
00890    Reflect();
00891    TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
00892    combi->ReflectZ(kTRUE);
00893    combi->ReflectZ(kFALSE);
00894    combi->RegisterYourself();
00895    fMatrix = combi;
00896    return finder;
00897 }
00898    
00899 //______________________________________________________________________________
00900 void TGeoPatternParaZ::SavePrimitive(ostream &out, Option_t * /*option*/ /*= ""*/)
00901 {
00902    // Save a primitive as a C++ statement(s) on output stream "out".
00903    Int_t iaxis = 3;
00904    out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep; 
00905 }
00906 
00907 //______________________________________________________________________________
00908 // TGeoPatternTrapZ - a Z axis divison pattern for TRAP or GTRA shapes
00909 //______________________________________________________________________________
00910 
00911 //_____________________________________________________________________________
00912 TGeoPatternTrapZ::TGeoPatternTrapZ()
00913 {
00914 // Default constructor
00915    fTxz = 0;
00916    fTyz = 0;
00917 }
00918 //_____________________________________________________________________________
00919 TGeoPatternTrapZ::TGeoPatternTrapZ(TGeoVolume *vol, Int_t ndivisions)
00920              :TGeoPatternFinder(vol, ndivisions)
00921 {   
00922 // constructor
00923    Double_t theta = ((TGeoTrap*)vol->GetShape())->GetTheta();
00924    Double_t phi   = ((TGeoTrap*)vol->GetShape())->GetPhi();
00925    fTxz = TMath::Tan(theta*TMath::DegToRad())*TMath::Cos(phi*TMath::DegToRad());
00926    fTyz = TMath::Tan(theta*TMath::DegToRad())*TMath::Sin(phi*TMath::DegToRad());
00927    Double_t dz = ((TGeoArb8*)vol->GetShape())->GetDz();
00928    fStart = -dz;
00929    fEnd = dz;
00930    fStep = 2*dz/ndivisions;
00931    fMatrix     = new TGeoTranslation(0,0,0);
00932    fMatrix->RegisterYourself();
00933 }
00934 //_____________________________________________________________________________
00935 TGeoPatternTrapZ::TGeoPatternTrapZ(TGeoVolume *vol, Int_t ndivisions, Double_t step)
00936              :TGeoPatternFinder(vol, ndivisions)
00937 {   
00938 // constructor
00939    Double_t theta = ((TGeoTrap*)vol->GetShape())->GetTheta();
00940    Double_t phi   = ((TGeoTrap*)vol->GetShape())->GetPhi();
00941    fTxz = TMath::Tan(theta*TMath::DegToRad())*TMath::Cos(phi*TMath::DegToRad());
00942    fTyz = TMath::Tan(theta*TMath::DegToRad())*TMath::Sin(phi*TMath::DegToRad());
00943    Double_t dz = ((TGeoArb8*)vol->GetShape())->GetDz();
00944    fStart = -dz;
00945    fEnd = fStart + ndivisions*step;
00946    fStep       = step;
00947    fMatrix     = new TGeoTranslation(0,0,0);
00948    fMatrix->RegisterYourself();
00949 }
00950 //_____________________________________________________________________________
00951 TGeoPatternTrapZ::TGeoPatternTrapZ(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
00952              :TGeoPatternFinder(vol, ndivisions)
00953 {   
00954 // constructor
00955    Double_t theta = ((TGeoTrap*)vol->GetShape())->GetTheta();
00956    Double_t phi   = ((TGeoTrap*)vol->GetShape())->GetPhi();
00957    fTxz = TMath::Tan(theta*TMath::DegToRad())*TMath::Cos(phi*TMath::DegToRad());
00958    fTyz = TMath::Tan(theta*TMath::DegToRad())*TMath::Sin(phi*TMath::DegToRad());
00959    fStart      = start;
00960    fEnd        = end;
00961    fStep       = (end - start)/ndivisions;
00962    fMatrix     = new TGeoTranslation(0,0,0);
00963    fMatrix->RegisterYourself();
00964 }
00965 //_____________________________________________________________________________
00966 TGeoPatternTrapZ::~TGeoPatternTrapZ()
00967 {
00968 // Destructor
00969 }
00970 //_____________________________________________________________________________
00971 void TGeoPatternTrapZ::cd(Int_t idiv)
00972 {
00973 // Update current division index and global matrix to point to a given slice.
00974    fCurrent = idiv;
00975    Double_t dz = fStart+idiv*fStep+0.5*fStep;
00976    fMatrix->SetDx(fTxz*dz);
00977    fMatrix->SetDy(fTyz*dz);
00978    fMatrix->SetDz((IsReflected())?-dz:dz);
00979 }
00980 
00981 //_____________________________________________________________________________
00982 Bool_t TGeoPatternTrapZ::IsOnBoundary(const Double_t *point) const
00983 {
00984 // Checks if the current point is on division boundary
00985    Double_t seg = (point[2]-fStart)/fStep;
00986    Double_t diff = seg - Int_t(seg);
00987    if (diff>0.5) diff = 1.-diff;
00988    if (diff<1e-8) return kTRUE;
00989    return kFALSE;
00990 }   
00991 
00992 //_____________________________________________________________________________
00993 TGeoNode *TGeoPatternTrapZ::FindNode(Double_t *point, const Double_t *dir)
00994 {
00995 // get the node division containing the query point
00996    TGeoNode *node = 0;
00997    Double_t zt = point[2];
00998    Int_t ind = (Int_t)(1. + (zt-fStart)/fStep) - 1;
00999    if (dir) {
01000       fNextIndex = ind;
01001       if (dir[2]>0) fNextIndex++;
01002       else fNextIndex--;
01003       if ((fNextIndex<0) || (fNextIndex>=fNdivisions)) fNextIndex = -1;
01004    }   
01005    if ((ind<0) || (ind>=fNdivisions)) return node; 
01006    node = GetNodeOffset(ind);
01007    cd(ind);
01008    return node;
01009 }
01010 
01011 //______________________________________________________________________________
01012 TGeoPatternFinder *TGeoPatternTrapZ::MakeCopy(Bool_t reflect)
01013 {
01014 // Make a copy of this finder. Reflect by Z if required.
01015    TGeoPatternTrapZ *finder = new TGeoPatternTrapZ(*this);
01016    if (!reflect) return finder;
01017    Reflect();
01018    TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
01019    combi->ReflectZ(kTRUE);
01020    combi->ReflectZ(kFALSE);
01021    combi->RegisterYourself();
01022    fMatrix = combi;
01023    return finder;
01024 }
01025    
01026 //______________________________________________________________________________
01027 void TGeoPatternTrapZ::SavePrimitive(ostream &out, Option_t * /*option*/ /*= ""*/)
01028 {
01029    // Save a primitive as a C++ statement(s) on output stream "out".
01030    Int_t iaxis = 3;
01031    out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep; 
01032 }
01033 
01034 
01035 //______________________________________________________________________________
01036 // TGeoPatternCylR - a cylindrical R divison pattern
01037 //______________________________________________________________________________ 
01038 
01039 //_____________________________________________________________________________
01040 TGeoPatternCylR::TGeoPatternCylR()
01041 {
01042 // Default constructor
01043    fMatrix = 0;
01044 }
01045 //_____________________________________________________________________________
01046 TGeoPatternCylR::TGeoPatternCylR(TGeoVolume *vol, Int_t ndivisions)
01047                 :TGeoPatternFinder(vol, ndivisions)
01048 {   
01049 // constructor
01050    fMatrix     = gGeoIdentity;
01051 // compute step, start, end
01052 }
01053 //_____________________________________________________________________________
01054 TGeoPatternCylR::TGeoPatternCylR(TGeoVolume *vol, Int_t ndivisions, Double_t step)
01055                 :TGeoPatternFinder(vol, ndivisions)
01056 {   
01057 // constructor
01058    fStep       = step;
01059    fMatrix     = gGeoIdentity;
01060 // compute start, end
01061 }
01062 //_____________________________________________________________________________
01063 TGeoPatternCylR::TGeoPatternCylR(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
01064                 :TGeoPatternFinder(vol, ndivisions)
01065 {   
01066 // constructor
01067    fStart      = start;
01068    fEnd        = end;
01069    fStep       = (end - start)/ndivisions;
01070    fMatrix     = gGeoIdentity;
01071 }
01072 //_____________________________________________________________________________
01073 TGeoPatternCylR::~TGeoPatternCylR()
01074 {
01075 // Destructor
01076 }
01077 
01078 //_____________________________________________________________________________
01079 Bool_t TGeoPatternCylR::IsOnBoundary(const Double_t *point) const
01080 {
01081 // Checks if the current point is on division boundary
01082    Double_t r = TMath::Sqrt(point[0]*point[0]+point[1]*point[1]);
01083    Double_t seg = (r-fStart)/fStep;
01084    Double_t diff = seg - Int_t(seg);
01085    if (diff>0.5) diff = 1.-diff;
01086    if (diff<1e-8) return kTRUE;
01087    return kFALSE;
01088 }   
01089 
01090 //_____________________________________________________________________________
01091 TGeoNode *TGeoPatternCylR::FindNode(Double_t *point, const Double_t *dir)
01092 {
01093 // find the node containing the query point
01094    if (!fMatrix) fMatrix = gGeoIdentity;
01095    TGeoNode *node = 0;
01096    Double_t r = TMath::Sqrt(point[0]*point[0]+point[1]*point[1]);
01097    Int_t ind = (Int_t)(1. + (r-fStart)/fStep) - 1;
01098    if (dir) {
01099       fNextIndex = ind;
01100       Double_t dot = point[0]*dir[0] + point[1]*dir[1];
01101       if (dot>0) fNextIndex++;
01102       else fNextIndex--;
01103       if ((fNextIndex<0) || (fNextIndex>=fNdivisions)) fNextIndex = -1;
01104    }   
01105    if ((ind<0) || (ind>=fNdivisions)) return node; 
01106    node = GetNodeOffset(ind);
01107    cd(ind);
01108    return node;
01109 }
01110 
01111 //______________________________________________________________________________
01112 TGeoPatternFinder *TGeoPatternCylR::MakeCopy(Bool_t reflect)
01113 {
01114 // Make a copy of this finder. Reflect by Z if required.
01115    TGeoPatternCylR *finder = new TGeoPatternCylR(*this);
01116    if (!reflect) return finder;
01117    Reflect();
01118    TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
01119    combi->ReflectZ(kTRUE);
01120    combi->ReflectZ(kFALSE);
01121    combi->RegisterYourself();
01122    fMatrix = combi;
01123    return finder;
01124 }
01125    
01126 //______________________________________________________________________________
01127 void TGeoPatternCylR::SavePrimitive(ostream &out, Option_t * /*option*/ /*= ""*/)
01128 {
01129    // Save a primitive as a C++ statement(s) on output stream "out".
01130    Int_t iaxis = 1;
01131    out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep; 
01132 }
01133 
01134 //______________________________________________________________________________
01135 // TGeoPatternCylPhi - a cylindrical phi divison pattern
01136 //______________________________________________________________________________ 
01137 
01138 //_____________________________________________________________________________
01139 TGeoPatternCylPhi::TGeoPatternCylPhi()
01140 {
01141 // Default constructor
01142    fSinCos = 0;
01143 }
01144 //_____________________________________________________________________________
01145 TGeoPatternCylPhi::TGeoPatternCylPhi(TGeoVolume *vol, Int_t ndivisions)
01146                   :TGeoPatternFinder(vol, ndivisions)
01147 {   
01148 // constructor
01149 // compute step, start, end
01150    fStart = 0;
01151    fEnd = 0;
01152    fStep = 0;
01153    fMatrix = 0;
01154    fSinCos = 0;
01155 }
01156 //_____________________________________________________________________________
01157 TGeoPatternCylPhi::TGeoPatternCylPhi(TGeoVolume *vol, Int_t ndivisions, Double_t step)
01158                   :TGeoPatternFinder(vol, ndivisions)
01159 {   
01160 // constructor
01161    fStep       = step;
01162    fSinCos = 0;
01163 // compute start, end
01164 }
01165 //_____________________________________________________________________________
01166 TGeoPatternCylPhi::TGeoPatternCylPhi(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
01167                   :TGeoPatternFinder(vol, ndivisions)
01168 {   
01169 // constructor
01170    fStart      = start;
01171    if (fStart<0) fStart+=360;
01172    fEnd        = end;
01173    if (fEnd<0) fEnd+=360;
01174    if ((end-start)<0)
01175       fStep       = (end-start+360)/ndivisions;
01176    else
01177       fStep       = (end-start)/ndivisions;
01178    fMatrix     = new TGeoRotation();
01179    fMatrix->RegisterYourself();
01180    fSinCos     = new Double_t[2*ndivisions];
01181    for (Int_t idiv = 0; idiv<ndivisions; idiv++) {
01182       fSinCos[2*idiv] = TMath::Sin(TMath::DegToRad()*(start+0.5*fStep+idiv*fStep));
01183       fSinCos[2*idiv+1] = TMath::Cos(TMath::DegToRad()*(start+0.5*fStep+idiv*fStep));
01184    }
01185 }
01186 //_____________________________________________________________________________
01187 TGeoPatternCylPhi::~TGeoPatternCylPhi()
01188 {
01189 // Destructor
01190    if (fSinCos) delete [] fSinCos;
01191 }
01192 //_____________________________________________________________________________
01193 void TGeoPatternCylPhi::cd(Int_t idiv)
01194 {
01195 // Update current division index and global matrix to point to a given slice.
01196    fCurrent = idiv;
01197    if (!fSinCos) {
01198       fSinCos     = new Double_t[2*fNdivisions];
01199       for (Int_t i = 0; i<fNdivisions; i++) {
01200          fSinCos[2*i] = TMath::Sin(TMath::DegToRad()*(fStart+0.5*fStep+i*fStep));
01201          fSinCos[2*i+1] = TMath::Cos(TMath::DegToRad()*(fStart+0.5*fStep+i*fStep));
01202       }
01203    }      
01204    ((TGeoRotation*)fMatrix)->FastRotZ(&fSinCos[2*idiv]);
01205 }
01206 
01207 //_____________________________________________________________________________
01208 Bool_t TGeoPatternCylPhi::IsOnBoundary(const Double_t *point) const
01209 {
01210 // Checks if the current point is on division boundary
01211    Double_t phi = TMath::ATan2(point[1], point[0])*TMath::RadToDeg();
01212    if (phi<0) phi += 360;
01213    Double_t ddp = phi - fStart;
01214    if (ddp<0) ddp+=360;
01215    Double_t seg = ddp/fStep;
01216    Double_t diff = seg - Int_t(seg);
01217    if (diff>0.5) diff = 1.-diff;
01218    if (diff<1e-8) return kTRUE;
01219    return kFALSE;
01220 }   
01221 
01222 //_____________________________________________________________________________
01223 TGeoNode *TGeoPatternCylPhi::FindNode(Double_t *point, const Double_t *dir)
01224 {
01225 // find the node containing the query point
01226    TGeoNode *node = 0;
01227    Double_t phi = TMath::ATan2(point[1], point[0])*TMath::RadToDeg();
01228    if (phi<0) phi += 360;
01229 //   Double_t dphi = fStep*fNdivisions;
01230    Double_t ddp = phi - fStart;
01231    if (ddp<0) ddp+=360;
01232 //   if (ddp>360) ddp-=360;
01233    Int_t ind = (Int_t)(1. + ddp/fStep) - 1;
01234    if (dir) {
01235       fNextIndex = ind;
01236       Double_t dot = point[0]*dir[1]-point[1]*dir[0];
01237       if (dot>0) fNextIndex++;
01238       else fNextIndex--;
01239       if ((fNextIndex<0) || (fNextIndex>=fNdivisions)) fNextIndex = -1;
01240    }   
01241    if ((ind<0) || (ind>=fNdivisions)) return node; 
01242    node = GetNodeOffset(ind);
01243    cd(ind);
01244    return node;
01245 }
01246 
01247 //______________________________________________________________________________
01248 TGeoPatternFinder *TGeoPatternCylPhi::MakeCopy(Bool_t reflect)
01249 {
01250 // Make a copy of this finder. Reflect by Z if required.
01251    TGeoPatternCylPhi *finder = new TGeoPatternCylPhi(*this);
01252    if (!reflect) return finder;
01253    Reflect();
01254    TGeoRotation *rot = new TGeoRotation(*fMatrix);
01255    rot->ReflectZ(kTRUE);
01256    rot->ReflectZ(kFALSE);
01257    rot->RegisterYourself();
01258    fMatrix = rot;
01259    return finder;
01260 }
01261    
01262 //______________________________________________________________________________
01263 void TGeoPatternCylPhi::SavePrimitive(ostream &out, Option_t * /*option*/ /*= ""*/)
01264 {
01265    // Save a primitive as a C++ statement(s) on output stream "out".
01266    Int_t iaxis = 2;
01267    out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep; 
01268 }
01269 
01270 //______________________________________________________________________________
01271 // TGeoPatternSphR - a spherical R divison pattern
01272 //______________________________________________________________________________
01273 
01274 //_____________________________________________________________________________
01275 TGeoPatternSphR::TGeoPatternSphR()
01276 {
01277 // Default constructor
01278 }
01279 //_____________________________________________________________________________
01280 TGeoPatternSphR::TGeoPatternSphR(TGeoVolume *vol, Int_t ndivisions)
01281                 :TGeoPatternFinder(vol, ndivisions)
01282 {   
01283 // constructor
01284 // compute step, start, end
01285 }
01286 //_____________________________________________________________________________
01287 TGeoPatternSphR::TGeoPatternSphR(TGeoVolume *vol, Int_t ndivisions, Double_t step)
01288                 :TGeoPatternFinder(vol, ndivisions)
01289 {   
01290 // constructor
01291    fStep       = step;
01292 // compute start, end
01293 }
01294 //_____________________________________________________________________________
01295 TGeoPatternSphR::TGeoPatternSphR(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
01296                 :TGeoPatternFinder(vol, ndivisions)
01297 {   
01298 // constructor
01299    fStart      = start;
01300    fEnd        = end;
01301    fStep       = (end - start)/ndivisions;
01302 }
01303 //_____________________________________________________________________________
01304 TGeoPatternSphR::~TGeoPatternSphR()
01305 {
01306 // Destructor
01307 }
01308 //_____________________________________________________________________________
01309 TGeoNode *TGeoPatternSphR::FindNode(Double_t * /*point*/, const Double_t * /*dir*/)
01310 {
01311 // find the node containing the query point
01312    return 0;
01313 }
01314 
01315 //______________________________________________________________________________
01316 TGeoPatternFinder *TGeoPatternSphR::MakeCopy(Bool_t reflect)
01317 {
01318 // Make a copy of this finder. Reflect by Z if required.
01319    TGeoPatternSphR *finder = new TGeoPatternSphR(*this);
01320    if (!reflect) return finder;
01321    Reflect();
01322    TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
01323    combi->ReflectZ(kTRUE);
01324    combi->ReflectZ(kFALSE);
01325    combi->RegisterYourself();
01326    fMatrix = combi;
01327    return finder;
01328 }
01329    
01330 //______________________________________________________________________________
01331 void TGeoPatternSphR::SavePrimitive(ostream &out, Option_t * /*option*/ /*= ""*/)
01332 {
01333    // Save a primitive as a C++ statement(s) on output stream "out".
01334    Int_t iaxis = 1;
01335    out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep; 
01336 }
01337 
01338 //______________________________________________________________________________
01339 // TGeoPatternSphTheta - a spherical theta divison pattern
01340 //______________________________________________________________________________
01341 
01342 //_____________________________________________________________________________
01343 TGeoPatternSphTheta::TGeoPatternSphTheta()
01344 {
01345 // Default constructor
01346 }
01347 //_____________________________________________________________________________
01348 TGeoPatternSphTheta::TGeoPatternSphTheta(TGeoVolume *vol, Int_t ndivisions)
01349                     :TGeoPatternFinder(vol, ndivisions)
01350 {   
01351 // constructor
01352 // compute step, start, end
01353 }
01354 //_____________________________________________________________________________
01355 TGeoPatternSphTheta::TGeoPatternSphTheta(TGeoVolume *vol, Int_t ndivisions, Double_t step)
01356                     :TGeoPatternFinder(vol, ndivisions)
01357 {   
01358 // constructor
01359    fStep       = step;
01360 // compute start, end
01361 }
01362 //_____________________________________________________________________________
01363 TGeoPatternSphTheta::TGeoPatternSphTheta(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
01364                     :TGeoPatternFinder(vol, ndivisions)
01365 {   
01366 // constructor
01367    fStart      = start;
01368    fEnd        = end;
01369    fStep       = (end - start)/ndivisions;
01370 }
01371 //_____________________________________________________________________________
01372 TGeoPatternSphTheta::~TGeoPatternSphTheta()
01373 {
01374 // Destructor
01375 }
01376 //_____________________________________________________________________________
01377 TGeoNode *TGeoPatternSphTheta::FindNode(Double_t * /*point*/, const Double_t * /*dir*/)
01378 {
01379 // find the node containing the query point
01380    return 0;
01381 }
01382 
01383 //______________________________________________________________________________
01384 TGeoPatternFinder *TGeoPatternSphTheta::MakeCopy(Bool_t reflect)
01385 {
01386 // Make a copy of this finder. Reflect by Z if required.
01387    TGeoPatternSphTheta *finder = new TGeoPatternSphTheta(*this);
01388    if (!reflect) return finder;
01389    Reflect();
01390    TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
01391    combi->ReflectZ(kTRUE);
01392    combi->ReflectZ(kFALSE);
01393    combi->RegisterYourself();
01394    fMatrix = combi;
01395    return finder;
01396 }
01397    
01398 //______________________________________________________________________________
01399 void TGeoPatternSphTheta::SavePrimitive(ostream &out, Option_t * /*option*/ /*= ""*/)
01400 {
01401    // Save a primitive as a C++ statement(s) on output stream "out".
01402    Int_t iaxis = 2;
01403    out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep; 
01404 }
01405 
01406 //______________________________________________________________________________
01407 // TGeoPatternSphPhi - a spherical phi divison pattern
01408 //______________________________________________________________________________
01409 
01410 //_____________________________________________________________________________
01411 TGeoPatternSphPhi::TGeoPatternSphPhi()
01412 {
01413 // Default constructor
01414 }
01415 //_____________________________________________________________________________
01416 TGeoPatternSphPhi::TGeoPatternSphPhi(TGeoVolume *vol, Int_t ndivisions)
01417                   :TGeoPatternFinder(vol, ndivisions)
01418 {   
01419 // constructor
01420 // compute step, start, end
01421 }
01422 //_____________________________________________________________________________
01423 TGeoPatternSphPhi::TGeoPatternSphPhi(TGeoVolume *vol, Int_t ndivisions, Double_t step)
01424                   :TGeoPatternFinder(vol, ndivisions)
01425 {   
01426 // constructor
01427    fStep       = step;
01428 // compute start, end
01429 }
01430 //_____________________________________________________________________________
01431 TGeoPatternSphPhi::TGeoPatternSphPhi(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
01432                   :TGeoPatternFinder(vol, ndivisions)
01433 {   
01434 // constructor
01435    fStart      = start;
01436    fEnd        = end;
01437    fStep       = (end - start)/ndivisions;
01438 }
01439 //_____________________________________________________________________________
01440 TGeoPatternSphPhi::~TGeoPatternSphPhi()
01441 {
01442 // Destructor
01443 }
01444 //_____________________________________________________________________________
01445 TGeoNode *TGeoPatternSphPhi::FindNode(Double_t * /*point*/, const Double_t * /*dir*/)
01446 {
01447 // find the node containing the query point
01448    return 0;
01449 }
01450 
01451 //______________________________________________________________________________
01452 TGeoPatternFinder *TGeoPatternSphPhi::MakeCopy(Bool_t reflect)
01453 {
01454 // Make a copy of this finder. Reflect by Z if required.
01455    TGeoPatternSphPhi *finder = new TGeoPatternSphPhi(*this);
01456    if (!reflect) return finder;
01457    Reflect();
01458    TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
01459    combi->ReflectZ(kTRUE);
01460    combi->ReflectZ(kFALSE);
01461    combi->RegisterYourself();
01462    fMatrix = combi;
01463    return finder;
01464 }
01465    
01466 //______________________________________________________________________________
01467 void TGeoPatternSphPhi::SavePrimitive(ostream &out, Option_t * /*option*/ /*= ""*/)
01468 {
01469    // Save a primitive as a C++ statement(s) on output stream "out".
01470    Int_t iaxis = 3;
01471    out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep; 
01472 }
01473 
01474 //______________________________________________________________________________
01475 // TGeoPatternHoneycomb - a divison pattern specialized for honeycombs
01476 //______________________________________________________________________________   
01477 
01478 //_____________________________________________________________________________
01479 TGeoPatternHoneycomb::TGeoPatternHoneycomb()
01480 {
01481 // Default constructor
01482    fNrows       = 0;                 
01483    fAxisOnRows  = 0;            
01484    fNdivisions  = 0;             
01485    fStart       = 0;                 
01486 }
01487 //_____________________________________________________________________________
01488 TGeoPatternHoneycomb::TGeoPatternHoneycomb(TGeoVolume *vol, Int_t nrows)
01489                      :TGeoPatternFinder(vol, nrows)
01490 {
01491 // Default constructor
01492    fNrows = nrows;
01493    fAxisOnRows  = 0;            
01494    fNdivisions  = 0;             
01495    fStart       = 0;                 
01496 // compute everything else
01497 }
01498 //_____________________________________________________________________________
01499 TGeoPatternHoneycomb::TGeoPatternHoneycomb(const TGeoPatternHoneycomb& pfh) :
01500   TGeoPatternFinder(pfh),
01501   fNrows(pfh.fNrows),
01502   fAxisOnRows(pfh.fAxisOnRows),
01503   fNdivisions(pfh.fNdivisions),
01504   fStart(pfh.fStart)
01505 { 
01506    //copy constructor
01507 }
01508 //_____________________________________________________________________________
01509 TGeoPatternHoneycomb& TGeoPatternHoneycomb::operator=(const TGeoPatternHoneycomb& pfh) 
01510 {
01511    //assignment operator
01512    if(this!=&pfh) {
01513       TGeoPatternFinder::operator=(pfh);
01514       fNrows=pfh.fNrows;
01515       fAxisOnRows=pfh.fAxisOnRows;
01516       fNdivisions=pfh.fNdivisions;
01517       fStart=pfh.fStart;
01518    } 
01519    return *this;
01520 }
01521 //_____________________________________________________________________________
01522 TGeoPatternHoneycomb::~TGeoPatternHoneycomb()
01523 {
01524 // destructor
01525 }
01526 //_____________________________________________________________________________
01527 TGeoNode *TGeoPatternHoneycomb::FindNode(Double_t * /*point*/, const Double_t * /*dir*/)
01528 {
01529 // find the node containing the query point
01530    return 0;
01531 }

Generated on Tue Jul 5 14:12:57 2011 for ROOT_528-00b_version by  doxygen 1.5.1