G4GeomTestErrorList.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // --------------------------------------------------------------------
00030 // GEANT 4 class source file
00031 //
00032 // G4GeomTestErrorList
00033 //
00034 // Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
00035 // --------------------------------------------------------------------
00036 
00037 #include "G4GeomTestErrorList.hh"
00038 #include "G4VPhysicalVolume.hh"
00039 #include "G4TransportationManager.hh"
00040 #include "G4TouchableHistoryHandle.hh"
00041 
00042 //
00043 // Constructor
00044 //
00045 G4GeomTestErrorList::G4GeomTestErrorList( const G4VPhysicalVolume *theMother )
00046   : mother(theMother)
00047 {
00048   FindGlobalCoordinateSystem();
00049 }
00050 
00051 
00052 //
00053 // Destructor
00054 //
00055 G4GeomTestErrorList::~G4GeomTestErrorList() {;}
00056 
00057 
00058 //
00059 // AddError
00060 //
00061 // Add a new Error point to our list, where the point
00062 // is given in the coordinate system of the mother
00063 //
00064 void G4GeomTestErrorList::AddError( const G4ThreeVector &s1,
00065                                     const G4ThreeVector &s2  )
00066 {
00067   segments.push_back( Segment(s1,s2) );
00068 }
00069 
00070 
00071 //
00072 // Accessors
00073 //
00074 const G4VPhysicalVolume *G4GeomTestErrorList::GetMother() const
00075 {
00076   return mother;
00077 }
00078 
00079 
00080 //
00081 // Return number of segments
00082 //
00083 G4int G4GeomTestErrorList::NumError() const
00084 {
00085   return segments.size();
00086 }
00087 
00088 
00089 //
00090 // GetMotherPoints
00091 //
00092 // Return start and end points in the coordinate system
00093 // of the mother
00094 //
00095 void G4GeomTestErrorList::GetMotherPoints( G4int i, 
00096                                            G4ThreeVector &s1, 
00097                                            G4ThreeVector &s2 ) const
00098 {
00099   s1 = segments[i].GetS1();
00100   s2 = segments[i].GetS2();
00101 }
00102 
00103 
00104 //
00105 // GetGlobalPoints
00106 //
00107 // Return start and end points in the global coordinate system
00108 //
00109 void G4GeomTestErrorList::GetGlobalPoints( G4int i, 
00110                                            G4ThreeVector &s1, 
00111                                            G4ThreeVector &s2 ) const
00112 {
00113   s1 = globalTranslation + globalRotation*segments[i].GetS1();
00114   s2 = globalTranslation + globalRotation*segments[i].GetS2();
00115 }
00116 
00117 
00118 //
00119 // GetOneDaughtPoints
00120 //
00121 // Return start and end points in the coordinate system of
00122 // a daughter
00123 //
00124 void G4GeomTestErrorList::GetOneDaughtPoints( const G4VPhysicalVolume *daught,
00125                                                     G4int i, 
00126                                                     G4ThreeVector &s1, 
00127                                                     G4ThreeVector &s2 ) const
00128 {
00129   const G4RotationMatrix *rotation = daught->GetFrameRotation();
00130   const G4ThreeVector &translation = daught->GetFrameTranslation();
00131 
00132   if (rotation) {
00133     s1 = (*rotation)*(translation + segments[i].GetS1());
00134     s2 = (*rotation)*(translation + segments[i].GetS2());
00135   }
00136   else {
00137     s1 = translation + segments[i].GetS1();
00138     s2 = translation + segments[i].GetS2();
00139   }
00140 }
00141 
00142 
00143 //
00144 // FindGlobalCoordinateSystem
00145 //
00146 // Calculate rotation & translation to global coordinates
00147 //
00148 void G4GeomTestErrorList::FindGlobalCoordinateSystem()
00149 {
00150   G4TouchableHistoryHandle aTouchable =
00151     G4TransportationManager::GetTransportationManager()->
00152     GetNavigatorForTracking()->CreateTouchableHistoryHandle();
00153   G4AffineTransform globTransform =
00154     aTouchable->GetHistory()->GetTopTransform().Inverse();
00155 
00156   globalTranslation = globTransform.NetTranslation();
00157   globalRotation = globTransform.NetRotation();
00158 }

Generated on Mon May 27 17:48:22 2013 for Geant4 by  doxygen 1.4.7