Import Geant4 10.0.0 source tree
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4AuxiliaryNavServices.cc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4BrentLocator.cc 66872 2013-01-15 01:25:57Z japost $
|
||||
//
|
||||
// Class G4BrentLocator implementation
|
||||
//
|
||||
@@ -154,7 +154,7 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
|
||||
|
||||
// Statistics for substeps
|
||||
//
|
||||
static G4int max_no_seen= -1;
|
||||
static G4ThreadLocal G4int max_no_seen= -1;
|
||||
|
||||
// Counter for restarting Bintermed
|
||||
//
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4DrawVoxels.cc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4DrawVoxels
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4ErrorPropagationNavigator.cc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -1,158 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class source file
|
||||
//
|
||||
// G4GeomTestErrorList
|
||||
//
|
||||
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4GeomTestErrorList.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4TouchableHistoryHandle.hh"
|
||||
|
||||
//
|
||||
// Constructor
|
||||
//
|
||||
G4GeomTestErrorList::G4GeomTestErrorList( const G4VPhysicalVolume *theMother )
|
||||
: mother(theMother)
|
||||
{
|
||||
FindGlobalCoordinateSystem();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Destructor
|
||||
//
|
||||
G4GeomTestErrorList::~G4GeomTestErrorList() {;}
|
||||
|
||||
|
||||
//
|
||||
// AddError
|
||||
//
|
||||
// Add a new Error point to our list, where the point
|
||||
// is given in the coordinate system of the mother
|
||||
//
|
||||
void G4GeomTestErrorList::AddError( const G4ThreeVector &s1,
|
||||
const G4ThreeVector &s2 )
|
||||
{
|
||||
segments.push_back( Segment(s1,s2) );
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Accessors
|
||||
//
|
||||
const G4VPhysicalVolume *G4GeomTestErrorList::GetMother() const
|
||||
{
|
||||
return mother;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Return number of segments
|
||||
//
|
||||
G4int G4GeomTestErrorList::NumError() const
|
||||
{
|
||||
return segments.size();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// GetMotherPoints
|
||||
//
|
||||
// Return start and end points in the coordinate system
|
||||
// of the mother
|
||||
//
|
||||
void G4GeomTestErrorList::GetMotherPoints( G4int i,
|
||||
G4ThreeVector &s1,
|
||||
G4ThreeVector &s2 ) const
|
||||
{
|
||||
s1 = segments[i].GetS1();
|
||||
s2 = segments[i].GetS2();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// GetGlobalPoints
|
||||
//
|
||||
// Return start and end points in the global coordinate system
|
||||
//
|
||||
void G4GeomTestErrorList::GetGlobalPoints( G4int i,
|
||||
G4ThreeVector &s1,
|
||||
G4ThreeVector &s2 ) const
|
||||
{
|
||||
s1 = globalTranslation + globalRotation*segments[i].GetS1();
|
||||
s2 = globalTranslation + globalRotation*segments[i].GetS2();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// GetOneDaughtPoints
|
||||
//
|
||||
// Return start and end points in the coordinate system of
|
||||
// a daughter
|
||||
//
|
||||
void G4GeomTestErrorList::GetOneDaughtPoints( const G4VPhysicalVolume *daught,
|
||||
G4int i,
|
||||
G4ThreeVector &s1,
|
||||
G4ThreeVector &s2 ) const
|
||||
{
|
||||
const G4RotationMatrix *rotation = daught->GetFrameRotation();
|
||||
const G4ThreeVector &translation = daught->GetFrameTranslation();
|
||||
|
||||
if (rotation) {
|
||||
s1 = (*rotation)*(translation + segments[i].GetS1());
|
||||
s2 = (*rotation)*(translation + segments[i].GetS2());
|
||||
}
|
||||
else {
|
||||
s1 = translation + segments[i].GetS1();
|
||||
s2 = translation + segments[i].GetS2();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FindGlobalCoordinateSystem
|
||||
//
|
||||
// Calculate rotation & translation to global coordinates
|
||||
//
|
||||
void G4GeomTestErrorList::FindGlobalCoordinateSystem()
|
||||
{
|
||||
G4TouchableHistoryHandle aTouchable =
|
||||
G4TransportationManager::GetTransportationManager()->
|
||||
GetNavigatorForTracking()->CreateTouchableHistoryHandle();
|
||||
G4AffineTransform globTransform =
|
||||
aTouchable->GetHistory()->GetTopTransform().Inverse();
|
||||
|
||||
globalTranslation = globTransform.NetTranslation();
|
||||
globalRotation = globTransform.NetRotation();
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class source file
|
||||
//
|
||||
// G4GeomTestOverlapList
|
||||
//
|
||||
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4GeomTestOverlapList.hh"
|
||||
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
|
||||
//
|
||||
// Constructor
|
||||
//
|
||||
G4GeomTestOverlapList::G4GeomTestOverlapList(
|
||||
const G4VPhysicalVolume *theMother,
|
||||
G4int theDaughter1,
|
||||
G4int theDaughter2 )
|
||||
: G4GeomTestErrorList(theMother),
|
||||
daughter1(theDaughter1),
|
||||
daughter2(theDaughter2)
|
||||
{}
|
||||
|
||||
|
||||
//
|
||||
// Default constructor
|
||||
//
|
||||
G4GeomTestOverlapList::G4GeomTestOverlapList()
|
||||
: G4GeomTestErrorList(0),
|
||||
daughter1(0),
|
||||
daughter2(0)
|
||||
{}
|
||||
|
||||
|
||||
//
|
||||
// Destructor
|
||||
//
|
||||
G4GeomTestOverlapList::~G4GeomTestOverlapList()
|
||||
{}
|
||||
|
||||
|
||||
//
|
||||
// Comparison operators
|
||||
//
|
||||
G4bool
|
||||
G4GeomTestOverlapList::operator==( const G4GeomTestOverlapList &other ) const
|
||||
{
|
||||
return daughter1==other.daughter1 && daughter2==other.daughter2;
|
||||
}
|
||||
|
||||
G4bool
|
||||
G4GeomTestOverlapList::operator< ( const G4GeomTestOverlapList &other ) const
|
||||
{
|
||||
if (daughter1 > other.daughter1) return false;
|
||||
if (daughter1 < other.daughter1) return true;
|
||||
|
||||
return (daughter2 < other.daughter2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Accessors
|
||||
//
|
||||
const G4VPhysicalVolume *G4GeomTestOverlapList::GetDaughter1() const
|
||||
{
|
||||
return GetMother()->GetLogicalVolume()->GetDaughter(daughter1);
|
||||
}
|
||||
|
||||
const G4VPhysicalVolume *G4GeomTestOverlapList::GetDaughter2() const
|
||||
{
|
||||
return GetMother()->GetLogicalVolume()->GetDaughter(daughter2);
|
||||
}
|
||||
|
||||
G4int G4GeomTestOverlapList::GetDaughter1Index() const
|
||||
{
|
||||
return daughter1;
|
||||
}
|
||||
|
||||
G4int G4GeomTestOverlapList::GetDaughter2Index() const
|
||||
{
|
||||
return daughter2;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// GetDaught1Points
|
||||
//
|
||||
// Return start and end points in the coordinate system of
|
||||
// the first daughter
|
||||
//
|
||||
void G4GeomTestOverlapList::GetDaught1Points( G4int i,
|
||||
G4ThreeVector &s1,
|
||||
G4ThreeVector &s2 ) const
|
||||
{
|
||||
GetOneDaughtPoints( GetDaughter1(), i, s1, s2 );
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// GetDaught2Points
|
||||
//
|
||||
// Return start and end points in the coordinate system of
|
||||
// the second daughter
|
||||
//
|
||||
void G4GeomTestOverlapList::GetDaught2Points( G4int i,
|
||||
G4ThreeVector &s1,
|
||||
G4ThreeVector &s2 ) const
|
||||
{
|
||||
GetOneDaughtPoints( GetDaughter2(), i, s1, s2 );
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class source file
|
||||
//
|
||||
// G4GeomTestOvershootList
|
||||
//
|
||||
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4GeomTestOvershootList.hh"
|
||||
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
|
||||
//
|
||||
// Constructor
|
||||
//
|
||||
G4GeomTestOvershootList::G4GeomTestOvershootList(
|
||||
const G4VPhysicalVolume *theMother,
|
||||
G4int theDaughterIndex )
|
||||
: G4GeomTestErrorList(theMother),
|
||||
daughter(theDaughterIndex)
|
||||
{}
|
||||
|
||||
|
||||
//
|
||||
// Default constructor
|
||||
//
|
||||
G4GeomTestOvershootList::G4GeomTestOvershootList()
|
||||
: G4GeomTestErrorList(0),
|
||||
daughter(0)
|
||||
{}
|
||||
|
||||
|
||||
//
|
||||
// Destructor
|
||||
//
|
||||
G4GeomTestOvershootList::~G4GeomTestOvershootList()
|
||||
{}
|
||||
|
||||
|
||||
//
|
||||
// Comparison operators
|
||||
//
|
||||
G4bool
|
||||
G4GeomTestOvershootList::operator==( const G4GeomTestOvershootList &other ) const
|
||||
{
|
||||
return daughter==other.daughter;
|
||||
}
|
||||
|
||||
G4bool
|
||||
G4GeomTestOvershootList::operator< ( const G4GeomTestOvershootList &other ) const
|
||||
{
|
||||
return (daughter < other.daughter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Accessors
|
||||
//
|
||||
const G4VPhysicalVolume *G4GeomTestOvershootList::GetDaughter() const
|
||||
{
|
||||
return GetMother()->GetLogicalVolume()->GetDaughter(daughter);
|
||||
}
|
||||
|
||||
G4int G4GeomTestOvershootList::GetDaughterIndex() const
|
||||
{
|
||||
return daughter;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// GetDaughtPoints
|
||||
//
|
||||
// Return start and end points in the coordinate system of
|
||||
// the daughter
|
||||
//
|
||||
void G4GeomTestOvershootList::GetDaughtPoints( G4int i,
|
||||
G4ThreeVector &s1,
|
||||
G4ThreeVector &s2 ) const
|
||||
{
|
||||
GetOneDaughtPoints( GetDaughter(), i, s1, s2 );
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class source file
|
||||
//
|
||||
// G4GeomTestPoint
|
||||
//
|
||||
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4GeomTestPoint.hh"
|
||||
|
||||
|
||||
//
|
||||
// Default constructor
|
||||
//
|
||||
G4GeomTestPoint::G4GeomTestPoint()
|
||||
: p(0),
|
||||
s(0),
|
||||
entering(false)
|
||||
{;}
|
||||
|
||||
|
||||
//
|
||||
// Specific constructor
|
||||
//
|
||||
G4GeomTestPoint::G4GeomTestPoint( const G4ThreeVector &thePoint,
|
||||
G4double theS,
|
||||
G4bool isEntering )
|
||||
: p(thePoint),
|
||||
s(theS),
|
||||
entering(isEntering)
|
||||
{;}
|
||||
|
||||
|
||||
//
|
||||
// Copy constructor
|
||||
//
|
||||
G4GeomTestPoint::G4GeomTestPoint( const G4GeomTestPoint &other )
|
||||
: p(other.p),
|
||||
s(other.s),
|
||||
entering(other.entering)
|
||||
{;}
|
||||
|
||||
|
||||
//
|
||||
// Destructor
|
||||
//
|
||||
G4GeomTestPoint::~G4GeomTestPoint() {;}
|
||||
|
||||
//
|
||||
// Assignment operator
|
||||
//
|
||||
G4GeomTestPoint& G4GeomTestPoint::operator=(const G4GeomTestPoint& other)
|
||||
{
|
||||
// Check assignment to self
|
||||
//
|
||||
if (this == &other) { return *this; }
|
||||
|
||||
// Copy data
|
||||
//
|
||||
p = other.p;
|
||||
s = other.s;
|
||||
entering = other.entering;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Equivalence operator
|
||||
//
|
||||
G4bool G4GeomTestPoint::operator==( const G4GeomTestPoint &other ) const
|
||||
{
|
||||
return s == other.s;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Order operators
|
||||
//
|
||||
G4bool G4GeomTestPoint::operator<( const G4GeomTestPoint &other ) const
|
||||
{
|
||||
return s < other.s;
|
||||
}
|
||||
|
||||
G4bool G4GeomTestPoint::operator<=( const G4GeomTestPoint &other ) const
|
||||
{
|
||||
return s <= other.s;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Return position
|
||||
//
|
||||
const G4ThreeVector &G4GeomTestPoint::GetPosition() const
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Return distance
|
||||
//
|
||||
G4double G4GeomTestPoint::GetDistance() const
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Return true if point was entering
|
||||
//
|
||||
G4bool G4GeomTestPoint::Entering() const
|
||||
{
|
||||
return entering;
|
||||
}
|
||||
|
||||
@@ -1,418 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class source file
|
||||
//
|
||||
// G4GeomTestSegment
|
||||
//
|
||||
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4GeomTestSegment.hh"
|
||||
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4GeomTestLogger.hh"
|
||||
#include "G4GeometryTolerance.hh"
|
||||
|
||||
//
|
||||
// Constructor
|
||||
//
|
||||
G4GeomTestSegment::G4GeomTestSegment( const G4VSolid *theSolid,
|
||||
const G4ThreeVector &theP,
|
||||
const G4ThreeVector &theV,
|
||||
G4GeomTestLogger *logger )
|
||||
: solid(theSolid),
|
||||
p0(theP),
|
||||
v(theV)
|
||||
{
|
||||
kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
||||
FindPoints(logger);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Simple accessors
|
||||
//
|
||||
const G4VSolid * G4GeomTestSegment::GetSolid() const { return solid; }
|
||||
|
||||
const G4ThreeVector &G4GeomTestSegment::GetP() const { return p0; }
|
||||
|
||||
const G4ThreeVector &G4GeomTestSegment::GetV() const { return v; }
|
||||
|
||||
|
||||
//
|
||||
// Return number points
|
||||
//
|
||||
G4int G4GeomTestSegment::GetNumberPoints() const
|
||||
{
|
||||
return points.size();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Return ith point
|
||||
//
|
||||
const G4GeomTestPoint &G4GeomTestSegment::GetPoint( G4int i ) const
|
||||
{
|
||||
return points[i];
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FindPoints
|
||||
//
|
||||
// Do the dirty work
|
||||
//
|
||||
void G4GeomTestSegment::FindPoints( G4GeomTestLogger *logger )
|
||||
{
|
||||
FindSomePoints( logger, true );
|
||||
FindSomePoints( logger, false );
|
||||
|
||||
PatchInconsistencies( logger );
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// PatchInconsistencies
|
||||
//
|
||||
// Search for inconsistancies in the hit list and patch
|
||||
// them up, if possible
|
||||
//
|
||||
void G4GeomTestSegment::PatchInconsistencies( G4GeomTestLogger *logger )
|
||||
{
|
||||
if (points.size() == 0) return;
|
||||
|
||||
//
|
||||
// Sort
|
||||
//
|
||||
std::sort( points.begin(), points.end() );
|
||||
|
||||
//
|
||||
// Loop over entering/leaving pairs
|
||||
//
|
||||
std::vector<G4GeomTestPoint>::iterator curr = points.begin();
|
||||
do {
|
||||
|
||||
std::vector<G4GeomTestPoint>::iterator next = curr + 1;
|
||||
|
||||
//
|
||||
// Is the next point close by?
|
||||
//
|
||||
while (next != points.end() &&
|
||||
next->GetDistance()-curr->GetDistance() < kCarTolerance) {
|
||||
//
|
||||
// Yup. If we have an entering/leaving pair, all is okay
|
||||
//
|
||||
if (next->Entering() != curr->Entering()) {
|
||||
curr = next + 1;
|
||||
next = curr + 1;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Otherwise, they are duplicate, and just delete one
|
||||
//
|
||||
next = points.erase(next);
|
||||
curr = next - 1;
|
||||
|
||||
}
|
||||
|
||||
if (curr == points.end()) break;
|
||||
|
||||
//
|
||||
// The next point should be entering...
|
||||
//
|
||||
|
||||
if (!curr->Entering()) {
|
||||
//
|
||||
// Point is out of sequence:
|
||||
// Test solid just before this point
|
||||
//
|
||||
G4double ds = curr->GetDistance();
|
||||
G4ThreeVector p = p0 + ds*v;
|
||||
|
||||
G4ThreeVector p1 = p - 10*kCarTolerance*v;
|
||||
|
||||
if (solid->Inside(p1) == kOutside||(solid->Inside(p1)== kSurface)) {
|
||||
//
|
||||
// We are missing an entrance point near the current
|
||||
// point. Add one.
|
||||
//
|
||||
curr = points.insert(curr, G4GeomTestPoint( p, ds, true ) );
|
||||
++curr;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Test solid just after last point
|
||||
//
|
||||
if (curr != points.begin()) {
|
||||
std::vector<G4GeomTestPoint>::iterator prev = curr - 1;
|
||||
|
||||
ds = prev->GetDistance();
|
||||
p = p0 + ds*v;
|
||||
|
||||
p1 = p + 10*kCarTolerance*v;
|
||||
if ((solid->Inside(p1) == kOutside)||(solid->Inside(p1)== kSurface)) {
|
||||
|
||||
//
|
||||
// We are missing an entrance point near the previous
|
||||
// point. Add one.
|
||||
//
|
||||
curr = points.insert(curr, G4GeomTestPoint( p, ds, true ) );
|
||||
++curr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Oh oh. No solution. Delete the current point and complain.
|
||||
//
|
||||
logger->SolidProblem( solid, "Spurious exiting intersection point", p );
|
||||
curr = points.erase(curr);
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// The following point should be leaving
|
||||
//
|
||||
|
||||
if (next == points.end() || next->Entering() ) {
|
||||
//
|
||||
// But is missing. Check immediately after this point.
|
||||
//
|
||||
G4double ds = curr->GetDistance();
|
||||
G4ThreeVector p = p0 + ds*v;
|
||||
G4ThreeVector p1 = p + 10*kCarTolerance*v;
|
||||
|
||||
if (solid->Inside(p1) == kOutside) {
|
||||
//
|
||||
// We are missing an exit point near the current
|
||||
// point. Add one.
|
||||
//
|
||||
curr = points.insert(next, G4GeomTestPoint( p, ds, false ) );
|
||||
break;
|
||||
}
|
||||
|
||||
if (next != points.end()) {
|
||||
//
|
||||
// Check just before next point
|
||||
//
|
||||
ds = next->GetDistance();
|
||||
p = p0 + ds*v;
|
||||
p1 = p - 10*kCarTolerance*v;
|
||||
if (solid->Inside(p1) == kOutside) {
|
||||
//
|
||||
// We are missing an exit point before the next
|
||||
// point. Add one.
|
||||
//
|
||||
curr = points.insert(next, G4GeomTestPoint( p, ds, false ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Oh oh. Hanging entering point. Delete and complain.
|
||||
//
|
||||
logger->SolidProblem( solid, "Spurious entering intersection point", p );
|
||||
curr = points.erase(curr);
|
||||
}
|
||||
|
||||
if(curr!=points.end()){curr = next + 1;}
|
||||
|
||||
} while( curr != points.end() );
|
||||
|
||||
//
|
||||
// Double check
|
||||
//
|
||||
if (points.size()&1)
|
||||
logger->SolidProblem( solid,
|
||||
"Solid has odd number of intersection points", p0 );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Find intersections either in front or behind the point
|
||||
//
|
||||
void G4GeomTestSegment::FindSomePoints( G4GeomTestLogger *logger,
|
||||
G4bool forward )
|
||||
{
|
||||
G4double sign = forward ? +1 : -1;
|
||||
|
||||
G4ThreeVector p(p0);
|
||||
G4ThreeVector vSearch(sign*v);
|
||||
G4double ds(0);
|
||||
G4bool entering;
|
||||
G4double vSurfN;
|
||||
|
||||
// Look for nearest intersection point in the specified
|
||||
// direction and return if there isn't one
|
||||
//
|
||||
G4double dist;
|
||||
switch(solid->Inside(p)) {
|
||||
case kInside:
|
||||
dist = solid->DistanceToOut(p,vSearch);
|
||||
if (dist >= kInfinity) {
|
||||
logger->SolidProblem( solid,
|
||||
"DistanceToOut(p,v) = kInfinity for point inside", p );
|
||||
return;
|
||||
}
|
||||
ds += sign*dist;
|
||||
entering = false;
|
||||
break;
|
||||
case kOutside:
|
||||
dist = solid->DistanceToIn(p,vSearch);
|
||||
if (dist >= kInfinity) return;
|
||||
ds += sign*dist;
|
||||
entering = true;
|
||||
break;
|
||||
case kSurface:
|
||||
vSurfN=v.dot(solid->SurfaceNormal(p));
|
||||
if(std::fabs(vSurfN)<kCarTolerance)vSurfN=0;
|
||||
entering = (vSurfN < 0);
|
||||
break;
|
||||
default:
|
||||
logger->SolidProblem( solid,
|
||||
"Inside returns illegal enumerated value", p );
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Loop
|
||||
//
|
||||
// nzero = the number of consecutive zeros
|
||||
//
|
||||
G4int nzero=0;
|
||||
|
||||
for(;;) {
|
||||
//
|
||||
// Locate point
|
||||
//
|
||||
p = p0 + ds*v;
|
||||
|
||||
if (nzero > 2) {
|
||||
//
|
||||
// Oops. In a loop. Probably along a spherical or cylindrical surface.
|
||||
// Let's give the tool a little help with a push
|
||||
//
|
||||
G4double push = 1E-6;
|
||||
ds += sign*push;
|
||||
for(;;) {
|
||||
p = p0 + ds*v;
|
||||
EInside inside = solid->Inside(p);
|
||||
if (inside == kInside) {
|
||||
entering = true;
|
||||
break;
|
||||
}
|
||||
else if (inside == kOutside) {
|
||||
entering = false;
|
||||
break;
|
||||
}
|
||||
|
||||
push = 2*push;
|
||||
if (push > 0.1) {
|
||||
logger->SolidProblem( solid,
|
||||
"Push fails to fix geometry inconsistency", p );
|
||||
return;
|
||||
}
|
||||
ds += sign*push;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
//
|
||||
// Record point
|
||||
//
|
||||
points.push_back( G4GeomTestPoint( p, ds, entering==forward ) );
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Find next intersection
|
||||
//
|
||||
if (entering) {
|
||||
dist = solid->DistanceToOut(p,vSearch);
|
||||
if (dist >= kInfinity) {
|
||||
logger->SolidProblem( solid,
|
||||
"DistanceToOut(p,v) = kInfinity for point inside", p );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (dist > kCarTolerance)
|
||||
&& (solid->Inside(p + (dist*0.999)*vSearch) == kOutside) ) {
|
||||
//
|
||||
// This shouldn't have happened
|
||||
//
|
||||
if (solid->Inside(p) == kOutside)
|
||||
logger->SolidProblem(solid,
|
||||
"Entering point is outside (possible roundoff error)",p);
|
||||
else
|
||||
logger->SolidProblem(solid,
|
||||
"DistanceToOut(p,v) brings trajectory well outside solid",p);
|
||||
return;
|
||||
}
|
||||
|
||||
entering = false;
|
||||
}
|
||||
else {
|
||||
dist = solid->DistanceToIn(p,vSearch);
|
||||
if (dist >= kInfinity) return;
|
||||
|
||||
if ( (dist > kCarTolerance)
|
||||
&& (solid->Inside(p + (dist*0.999)*vSearch) == kInside) ) {
|
||||
//
|
||||
// This shouldn't have happened
|
||||
//
|
||||
if (solid->Inside(p) == kInside)
|
||||
logger->SolidProblem(solid,
|
||||
"Exiting point is inside (possible roundoff error)", p);
|
||||
else
|
||||
logger->SolidProblem(solid,
|
||||
"DistanceToIn(p,v) brings trajectory well inside solid", p);
|
||||
return;
|
||||
}
|
||||
|
||||
entering = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Update ds
|
||||
//
|
||||
if (dist <= 0) {
|
||||
nzero++;
|
||||
}
|
||||
else {
|
||||
nzero=0;
|
||||
ds += sign*dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,291 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class source file
|
||||
//
|
||||
// G4GeomTestStreamLogger
|
||||
//
|
||||
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4GeomTestStreamLogger.hh"
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4GeomTestOverlapList.hh"
|
||||
#include "G4GeomTestOvershootList.hh"
|
||||
|
||||
//
|
||||
// Constructor and destructor
|
||||
//
|
||||
G4GeomTestStreamLogger::G4GeomTestStreamLogger( std::ostream &o,
|
||||
G4int theMaxPointsPerError )
|
||||
: out(o), maxPointsPerError(theMaxPointsPerError)
|
||||
{;}
|
||||
|
||||
G4GeomTestStreamLogger::~G4GeomTestStreamLogger()
|
||||
{;}
|
||||
|
||||
//
|
||||
// ::PrintPos
|
||||
//
|
||||
// Utility class for printing a 3 vector position
|
||||
//
|
||||
void G4GeomTestStreamLogger::PrintPos::Print( std::ostream &o ) const
|
||||
{
|
||||
o << std::setprecision(6) << std::setw(14) << p.x()/cm;
|
||||
o << std::setprecision(6) << std::setw(14) << p.y()/cm;
|
||||
o << std::setprecision(6) << std::setw(14) << p.z()/cm;
|
||||
if (unit) o << " cm";
|
||||
}
|
||||
|
||||
std::ostream &operator<<( std::ostream &o,
|
||||
const G4GeomTestStreamLogger::PrintPos &p )
|
||||
{
|
||||
p.Print(o);
|
||||
return o;
|
||||
}
|
||||
|
||||
//
|
||||
// ::VolumeNameAndCopy
|
||||
//
|
||||
// Utility class for printing a volume's name and copy number
|
||||
//
|
||||
void
|
||||
G4GeomTestStreamLogger::VolumeNameAndCopy::Print( std::ostream &o ) const
|
||||
{
|
||||
o << volume->GetName() << "[" << volume->GetCopyNo() << "]";
|
||||
}
|
||||
|
||||
std::ostream &operator<<( std::ostream &o,
|
||||
const G4GeomTestStreamLogger::VolumeNameAndCopy &p )
|
||||
{
|
||||
p.Print(o);
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// SolidProblem
|
||||
//
|
||||
void G4GeomTestStreamLogger::SolidProblem( const G4VSolid *solid,
|
||||
const G4String &message,
|
||||
const G4ThreeVector &point )
|
||||
{
|
||||
out << "GeomTest Error: SolidProblem\n"
|
||||
<< " " << message << "\n"
|
||||
<< " Solid name = " << solid->GetName() << "\n"
|
||||
<< " Local position = " << PrintPos(point) << std::endl;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// NoProblem
|
||||
//
|
||||
void G4GeomTestStreamLogger::NoProblem( const G4String &message )
|
||||
{
|
||||
out << message << std::endl;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// OverlappingDaughters
|
||||
//
|
||||
void
|
||||
G4GeomTestStreamLogger::OverlappingDaughters(const G4GeomTestOverlapList *list)
|
||||
{
|
||||
G4int n = list->NumError();
|
||||
if (n <= 0) return;
|
||||
|
||||
out << "GeomTest Error: Overlapping daughter volumes\n"
|
||||
<< " The volumes " << VolumeNameAndCopy(list->GetDaughter1())
|
||||
<< " and " << VolumeNameAndCopy(list->GetDaughter2()) << ",\n"
|
||||
<< " both daughters of volume " << VolumeNameAndCopy(list->GetMother())
|
||||
<< ",\n"
|
||||
<< " appear to overlap at the following " << (n>1 ? "points" : "point")
|
||||
<< " in global coordinates:";
|
||||
|
||||
G4int nInterval, nStop;
|
||||
|
||||
if (n <= maxPointsPerError) {
|
||||
out << "\n";
|
||||
nInterval = 1;
|
||||
nStop = n;
|
||||
}
|
||||
else {
|
||||
out << " (list truncated)\n";
|
||||
nInterval = n/maxPointsPerError;
|
||||
nStop = maxPointsPerError*nInterval;
|
||||
}
|
||||
|
||||
G4int i;
|
||||
G4ThreeVector s1, s2;
|
||||
|
||||
PrintSegmentListHeader();
|
||||
for(i=0;i<nStop;i+=nInterval) {
|
||||
list->GetGlobalPoints( i, s1, s2 );
|
||||
PrintSegmentListElement( s1, s2 );
|
||||
}
|
||||
|
||||
out << " Which in the mother coordinate system " << IsAre(n) << ":\n";
|
||||
|
||||
PrintSegmentListHeader();
|
||||
for(i=0;i<nStop;i+=nInterval) {
|
||||
list->GetMotherPoints( i, s1, s2 );
|
||||
PrintSegmentListElement( s1, s2 );
|
||||
}
|
||||
|
||||
out << " Which in the coordinate system of "
|
||||
<< VolumeNameAndCopy(list->GetDaughter1()) << " " << IsAre(n) << ":\n";
|
||||
|
||||
PrintSegmentListHeader();
|
||||
for(i=0;i<nStop;i+=nInterval) {
|
||||
list->GetDaught1Points( i, s1, s2 );
|
||||
PrintSegmentListElement( s1, s2 );
|
||||
}
|
||||
|
||||
out << " Which in the coordinate system of "
|
||||
<< VolumeNameAndCopy(list->GetDaughter2()) << " " << IsAre(n) << ":\n";
|
||||
|
||||
PrintSegmentListHeader();
|
||||
for(i=0;i<nStop;i+=nInterval) {
|
||||
list->GetDaught2Points( i, s1, s2 );
|
||||
PrintSegmentListElement( s1, s2 );
|
||||
}
|
||||
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// OvershootingDaughter
|
||||
//
|
||||
void G4GeomTestStreamLogger::
|
||||
OvershootingDaughter( const G4GeomTestOvershootList *list )
|
||||
{
|
||||
G4int n = list->NumError();
|
||||
if (n <= 0) return;
|
||||
|
||||
out << "GeomTest Error: Overshooting daughter volume\n"
|
||||
<< " The volume " << VolumeNameAndCopy(list->GetDaughter())
|
||||
<< " appears to extend outside the mother volume "
|
||||
<< VolumeNameAndCopy(list->GetMother()) << "\n"
|
||||
<< " at the following " << (n>1 ? "points" : "point")
|
||||
<< " in global coordinates:";
|
||||
|
||||
|
||||
G4int nInterval, nStop;
|
||||
|
||||
if (n <= maxPointsPerError) {
|
||||
out << "\n";
|
||||
nInterval = 1;
|
||||
nStop = n;
|
||||
}
|
||||
else {
|
||||
out << " (list truncated)\n";
|
||||
nInterval = n/maxPointsPerError;
|
||||
nStop = maxPointsPerError*nInterval;
|
||||
}
|
||||
|
||||
G4int i;
|
||||
G4ThreeVector s1, s2;
|
||||
|
||||
PrintSegmentListHeader();
|
||||
for(i=0;i<nStop;i+=nInterval) {
|
||||
list->GetGlobalPoints( i, s1, s2 );
|
||||
PrintSegmentListElement( s1, s2 );
|
||||
}
|
||||
|
||||
out << " Which in the mother coordinate system " << IsAre(n) << ":\n";
|
||||
|
||||
PrintSegmentListHeader();
|
||||
for(i=0;i<nStop;i+=nInterval) {
|
||||
list->GetMotherPoints( i, s1, s2 );
|
||||
PrintSegmentListElement( s1, s2 );
|
||||
}
|
||||
|
||||
out << " Which in the coordinate system of "
|
||||
<< VolumeNameAndCopy(list->GetDaughter()) << " " << IsAre(n) << ":\n";
|
||||
|
||||
PrintSegmentListHeader();
|
||||
for(i=0;i<nStop;i+=nInterval) {
|
||||
list->GetDaughtPoints( i, s1, s2 );
|
||||
PrintSegmentListElement( s1, s2 );
|
||||
}
|
||||
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// PrintSegmentListHeader (protected)
|
||||
//
|
||||
// Print out a header for a segment list
|
||||
//
|
||||
void G4GeomTestStreamLogger::PrintSegmentListHeader()
|
||||
{
|
||||
static const char *header =
|
||||
" length (cm) ---------- start position (cm) ----------- ----------- end position (cm) ------------\n";
|
||||
// .............| .............|.............|.............| .............|.............|.............|
|
||||
// 1234 1234 123
|
||||
|
||||
out << header;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// PrintSegmentListElement (protected)
|
||||
//
|
||||
// Print out one segment value
|
||||
//
|
||||
void G4GeomTestStreamLogger::PrintSegmentListElement( const G4ThreeVector &s1,
|
||||
const G4ThreeVector &s2 )
|
||||
{
|
||||
out << " " << std::setprecision(6) << std::setw(14)
|
||||
<< (s1-s2).mag()/cm
|
||||
<< " " << PrintPos(s1,false) << " " << PrintPos(s2,false) << "\n";
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// IsAre (protected)
|
||||
//
|
||||
// Return a pointer to the string "is" if the argument
|
||||
// is equal to 1, otherwise return a pointer to "are"
|
||||
//
|
||||
const char *G4GeomTestStreamLogger::IsAre( G4int n )
|
||||
{
|
||||
const char *is = "is";
|
||||
const char *are = "are";
|
||||
|
||||
return n > 1 ? are : is;
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class source file
|
||||
//
|
||||
// G4GeomTestVolPoint
|
||||
//
|
||||
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4GeomTestVolPoint.hh"
|
||||
|
||||
//
|
||||
// Constructor (specific)
|
||||
//
|
||||
G4GeomTestVolPoint::G4GeomTestVolPoint( const G4ThreeVector &thePoint,
|
||||
G4double theS,
|
||||
G4bool isEntering,
|
||||
G4int theDaughterIndex )
|
||||
: G4GeomTestPoint( thePoint, theS, isEntering ),
|
||||
daughterIndex(theDaughterIndex)
|
||||
{;}
|
||||
|
||||
|
||||
//
|
||||
// Constructor (from base)
|
||||
//
|
||||
G4GeomTestVolPoint::G4GeomTestVolPoint( const G4GeomTestPoint &base,
|
||||
G4int theDaughterIndex )
|
||||
: G4GeomTestPoint( base ), daughterIndex(theDaughterIndex)
|
||||
{;}
|
||||
|
||||
|
||||
//
|
||||
// Constructor (from base, with coordinate transformation)
|
||||
//
|
||||
G4GeomTestVolPoint::G4GeomTestVolPoint( const G4GeomTestPoint &base,
|
||||
G4int theDaughterIndex,
|
||||
const G4ThreeVector &translation,
|
||||
const G4RotationMatrix *rotation )
|
||||
: G4GeomTestPoint( base ), daughterIndex(theDaughterIndex)
|
||||
{
|
||||
//
|
||||
// Rotate point
|
||||
//
|
||||
if (rotation)
|
||||
p = rotation->inverse()*p - translation;
|
||||
else
|
||||
p = p - translation;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Constructor (copy)
|
||||
//
|
||||
G4GeomTestVolPoint::G4GeomTestVolPoint( const G4GeomTestVolPoint &other )
|
||||
: G4GeomTestPoint( other ), daughterIndex(other.daughterIndex)
|
||||
{;}
|
||||
|
||||
|
||||
//
|
||||
// Constructor (default)
|
||||
//
|
||||
G4GeomTestVolPoint::G4GeomTestVolPoint()
|
||||
: daughterIndex(-1)
|
||||
{;}
|
||||
|
||||
|
||||
//
|
||||
// Destructor
|
||||
//
|
||||
G4GeomTestVolPoint::~G4GeomTestVolPoint() {;}
|
||||
|
||||
|
||||
//
|
||||
// Assignment operator
|
||||
//
|
||||
G4GeomTestVolPoint&
|
||||
G4GeomTestVolPoint::operator=(const G4GeomTestVolPoint& other)
|
||||
{
|
||||
// Check assignment to self
|
||||
//
|
||||
if (this == &other) { return *this; }
|
||||
|
||||
// Copy base class data
|
||||
//
|
||||
G4GeomTestPoint::operator=(other);
|
||||
|
||||
// Copy data
|
||||
//
|
||||
daughterIndex = other.daughterIndex;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Volume accessor
|
||||
//
|
||||
G4int G4GeomTestVolPoint::GetDaughterIndex() const
|
||||
{
|
||||
return daughterIndex;
|
||||
}
|
||||
@@ -24,28 +24,21 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4GeomTestVolume.cc 73253 2013-08-22 13:24:02Z gcosmo $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class source file
|
||||
//
|
||||
// G4GeomTestVolume
|
||||
//
|
||||
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
|
||||
// Author: G.Cosmo, CERN
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
|
||||
#include "G4GeomTestVolume.hh"
|
||||
|
||||
#include "G4PhysicalConstants.hh"
|
||||
#include "G4GeomTestLogger.hh"
|
||||
#include "G4GeomTestVolPoint.hh"
|
||||
#include "G4GeomTestSegment.hh"
|
||||
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4VSolid.hh"
|
||||
@@ -53,13 +46,12 @@
|
||||
//
|
||||
// Constructor
|
||||
//
|
||||
G4GeomTestVolume::G4GeomTestVolume( const G4VPhysicalVolume *theTarget,
|
||||
G4GeomTestLogger *theLogger,
|
||||
G4double theTolerance )
|
||||
: target(theTarget),
|
||||
logger(theLogger),
|
||||
tolerance(theTolerance),
|
||||
extent(theTarget->GetLogicalVolume()->GetSolid()->GetExtent())
|
||||
G4GeomTestVolume::G4GeomTestVolume( G4VPhysicalVolume *theTarget,
|
||||
G4double theTolerance,
|
||||
G4int numberOfPoints,
|
||||
G4bool theVerbosity )
|
||||
: target(theTarget), tolerance(theTolerance),
|
||||
resolution(numberOfPoints), maxErr(1), verbosity(theVerbosity)
|
||||
{;}
|
||||
|
||||
//
|
||||
@@ -78,53 +70,63 @@ G4double G4GeomTestVolume::GetTolerance() const
|
||||
//
|
||||
// Set error tolerance
|
||||
//
|
||||
void G4GeomTestVolume::SetTolerance(G4double val)
|
||||
void G4GeomTestVolume::SetTolerance(G4double tol)
|
||||
{
|
||||
tolerance = val;
|
||||
tolerance = tol;
|
||||
}
|
||||
|
||||
//
|
||||
// TestCartGridXYZ
|
||||
// Get number of points to check (resolution)
|
||||
//
|
||||
void G4GeomTestVolume::TestCartGridXYZ( G4int nx, G4int ny, G4int nz )
|
||||
G4int G4GeomTestVolume::GetResolution() const
|
||||
{
|
||||
TestCartGridX( ny, nz );
|
||||
TestCartGridY( nz, nx );
|
||||
TestCartGridZ( nx, ny );
|
||||
return resolution;
|
||||
}
|
||||
|
||||
//
|
||||
// TestCartGridX
|
||||
// Set number of points to check (resolution)
|
||||
//
|
||||
void G4GeomTestVolume::TestCartGridX( G4int ny, G4int nz )
|
||||
void G4GeomTestVolume::SetResolution(G4int np)
|
||||
{
|
||||
TestCartGrid( G4ThreeVector(0,1,0), G4ThreeVector(0,0,1),
|
||||
G4ThreeVector(1,0,0), ny, nz );
|
||||
resolution = np;
|
||||
}
|
||||
|
||||
//
|
||||
// TestCartGridY
|
||||
// Get verbosity
|
||||
//
|
||||
void G4GeomTestVolume::TestCartGridY( G4int nz, G4int nx )
|
||||
G4bool G4GeomTestVolume::GetVerbosity() const
|
||||
{
|
||||
TestCartGrid( G4ThreeVector(0,0,1), G4ThreeVector(1,0,0),
|
||||
G4ThreeVector(0,1,0), nz, nx );
|
||||
return verbosity;
|
||||
}
|
||||
|
||||
//
|
||||
// TestCartGridZ
|
||||
// Set verbosity
|
||||
//
|
||||
void G4GeomTestVolume::TestCartGridZ( G4int nx, G4int ny )
|
||||
void G4GeomTestVolume::SetVerbosity(G4bool verb)
|
||||
{
|
||||
TestCartGrid( G4ThreeVector(1,0,0), G4ThreeVector(0,1,0),
|
||||
G4ThreeVector(0,0,1), nx, ny );
|
||||
verbosity = verb;
|
||||
}
|
||||
|
||||
//
|
||||
// TestRecursiveCartGrid
|
||||
// Get errors reporting threshold
|
||||
//
|
||||
void G4GeomTestVolume::TestRecursiveCartGrid( G4int nx, G4int ny, G4int nz,
|
||||
G4int slevel, G4int depth )
|
||||
G4int G4GeomTestVolume::GetErrorsThreshold() const
|
||||
{
|
||||
return maxErr;
|
||||
}
|
||||
|
||||
//
|
||||
// Set maximum number of errors to report
|
||||
//
|
||||
void G4GeomTestVolume::SetErrorsThreshold(G4int max)
|
||||
{
|
||||
maxErr = max;
|
||||
}
|
||||
|
||||
//
|
||||
// TestRecursiveOverlap
|
||||
//
|
||||
void G4GeomTestVolume::TestRecursiveOverlap( G4int slevel, G4int depth )
|
||||
{
|
||||
// If reached requested level of depth (i.e. set to 0), exit.
|
||||
// If not depth specified (i.e. set to -1), visit the whole tree.
|
||||
@@ -135,13 +137,12 @@ void G4GeomTestVolume::TestRecursiveCartGrid( G4int nx, G4int ny, G4int nz,
|
||||
if (slevel != 0) slevel--;
|
||||
|
||||
//
|
||||
// As long as we aren't a replica and we reached the requested
|
||||
// As long as we reached the requested
|
||||
// initial level of depth, test ourselves
|
||||
//
|
||||
if ( (!target->IsReplicated()) && (slevel==0) )
|
||||
if ( slevel==0 )
|
||||
{
|
||||
TestCartGridXYZ( nx, ny, nz );
|
||||
ReportErrors();
|
||||
target->CheckOverlaps(resolution, tolerance, verbosity, maxErr);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -154,538 +155,22 @@ void G4GeomTestVolume::TestRecursiveCartGrid( G4int nx, G4int ny, G4int nz,
|
||||
G4int iDaughter;
|
||||
for( iDaughter=0; iDaughter<nDaughter; ++iDaughter )
|
||||
{
|
||||
const G4VPhysicalVolume *daughter =
|
||||
logical->GetDaughter(iDaughter);
|
||||
G4VPhysicalVolume *daughter = logical->GetDaughter(iDaughter);
|
||||
const G4LogicalVolume *daughterLogical =
|
||||
daughter->GetLogicalVolume();
|
||||
|
||||
//
|
||||
// Skip empty daughters
|
||||
//
|
||||
if (daughterLogical->GetNoDaughters() == 0) continue;
|
||||
|
||||
//
|
||||
// Tested already?
|
||||
//
|
||||
std::pair<std::set<const G4LogicalVolume *>::iterator,G4bool>
|
||||
std::pair<std::set<const G4LogicalVolume *>::iterator, G4bool>
|
||||
there = tested.insert(daughterLogical);
|
||||
if (!there.second) continue;
|
||||
|
||||
//
|
||||
// Recurse
|
||||
//
|
||||
G4GeomTestVolume vTest( daughter, logger, tolerance );
|
||||
vTest.TestRecursiveCartGrid( nx,ny,nz,slevel,depth );
|
||||
G4GeomTestVolume vTest( daughter, tolerance, resolution, verbosity );
|
||||
vTest.SetErrorsThreshold(maxErr);
|
||||
vTest.TestRecursiveOverlap( slevel,depth );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// TestRecursiveCylinder
|
||||
//
|
||||
void
|
||||
G4GeomTestVolume::TestRecursiveCylinder( G4int nPhi, G4int nZ, G4int nRho,
|
||||
G4double fracZ, G4double fracRho,
|
||||
G4bool usePhi,
|
||||
G4int slevel, G4int depth )
|
||||
{
|
||||
// If reached requested level of depth (i.e. set to 0), exit.
|
||||
// If not depth specified (i.e. set to -1), visit the whole tree.
|
||||
// If requested initial level of depth is not zero, visit from beginning
|
||||
//
|
||||
if (depth == 0) return;
|
||||
if (depth != -1) depth--;
|
||||
if (slevel != 0) slevel--;
|
||||
|
||||
//
|
||||
// As long as we aren't a replica and we reached the requested
|
||||
// initial level of depth, test ourselves
|
||||
//
|
||||
if ( (!target->IsReplicated()) && (slevel==0) )
|
||||
{
|
||||
TestCylinder( nPhi, nZ, nRho, fracZ, fracRho, usePhi );
|
||||
ReportErrors();
|
||||
}
|
||||
|
||||
//
|
||||
// Loop over unique daughters
|
||||
//
|
||||
std::set<const G4LogicalVolume *> tested;
|
||||
|
||||
const G4LogicalVolume *logical = target->GetLogicalVolume();
|
||||
G4int nDaughter = logical->GetNoDaughters();
|
||||
G4int iDaughter;
|
||||
for( iDaughter=0; iDaughter<nDaughter; ++iDaughter )
|
||||
{
|
||||
const G4VPhysicalVolume *daughter =
|
||||
logical->GetDaughter(iDaughter);
|
||||
const G4LogicalVolume *daughterLogical =
|
||||
daughter->GetLogicalVolume();
|
||||
|
||||
//
|
||||
// Skip empty daughters
|
||||
//
|
||||
if (daughterLogical->GetNoDaughters() == 0) continue;
|
||||
|
||||
//
|
||||
// Tested already?
|
||||
//
|
||||
std::pair<std::set<const G4LogicalVolume *>::iterator,G4bool>
|
||||
there = tested.insert(daughterLogical);
|
||||
if (!there.second) continue;
|
||||
|
||||
//
|
||||
// Recurse
|
||||
//
|
||||
G4GeomTestVolume vTest( daughter, logger, tolerance );
|
||||
vTest.TestRecursiveCylinder( nPhi, nZ, nRho,
|
||||
fracZ, fracRho, usePhi,
|
||||
slevel, depth );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// TestCylinder
|
||||
//
|
||||
void G4GeomTestVolume::TestCylinder( G4int nPhi, G4int nZ, G4int nRho,
|
||||
G4double fracZ, G4double fracRho,
|
||||
G4bool usePhi )
|
||||
{
|
||||
//
|
||||
// Get size of our volume
|
||||
//
|
||||
G4double xMax = std::max(extent.GetXmax(),-extent.GetXmin());
|
||||
G4double yMax = std::max(extent.GetYmax(),-extent.GetYmin());
|
||||
G4double rhoMax = std::sqrt(xMax*xMax + yMax*yMax);
|
||||
|
||||
G4double zMax = extent.GetZmax();
|
||||
G4double zMin = extent.GetZmin();
|
||||
G4double zHalfLength = 0.5*(zMax-zMin);
|
||||
G4double z0 = 0.5*(zMax+zMin);
|
||||
|
||||
//
|
||||
// Loop over phi
|
||||
//
|
||||
G4double deltaPhi = 2*pi/G4double(nPhi);
|
||||
|
||||
G4double phi = 0;
|
||||
G4int iPhi = nPhi;
|
||||
if ((iPhi&1) == 0) iPhi++; // Also use odd number phi slices
|
||||
do
|
||||
{
|
||||
G4double cosPhi = std::cos(phi);
|
||||
G4double sinPhi = std::sin(phi);
|
||||
G4ThreeVector vPhi1(sinPhi,-cosPhi,0);
|
||||
|
||||
//
|
||||
// Loop over rho
|
||||
//
|
||||
G4double rho = rhoMax;
|
||||
G4int iRho = nRho;
|
||||
do
|
||||
{
|
||||
G4ThreeVector p(rho*cosPhi,rho*sinPhi,0);
|
||||
static G4ThreeVector v(0,0,1);
|
||||
|
||||
TestOneLine( p, v );
|
||||
|
||||
if (usePhi)
|
||||
{
|
||||
//
|
||||
// Loop over z
|
||||
//
|
||||
G4double zScale = 1.0;
|
||||
G4int iZ=nZ;
|
||||
do
|
||||
{
|
||||
p.setZ( z0 + zScale*zHalfLength );
|
||||
TestOneLine(p,vPhi1);
|
||||
p.setZ( z0 - zScale*zHalfLength );
|
||||
TestOneLine(p,vPhi1);
|
||||
} while( zScale *= fracZ, --iZ );
|
||||
}
|
||||
} while( rho *= fracRho, --iRho );
|
||||
|
||||
//
|
||||
// Loop over z
|
||||
//
|
||||
G4ThreeVector p(0,0,0);
|
||||
G4ThreeVector vPhi2(cosPhi,sinPhi,0);
|
||||
|
||||
G4double zScale = 1.0;
|
||||
G4int iZ=nZ;
|
||||
do
|
||||
{
|
||||
p.setZ( z0 + zScale*zHalfLength );
|
||||
|
||||
TestOneLine(p,vPhi2);
|
||||
|
||||
p.setZ( z0 - zScale*zHalfLength );
|
||||
|
||||
TestOneLine(p,vPhi2);
|
||||
} while( zScale *= fracZ, --iZ );
|
||||
|
||||
} while( phi += deltaPhi, --iPhi );
|
||||
}
|
||||
|
||||
//
|
||||
// TestCartGrid
|
||||
//
|
||||
void G4GeomTestVolume::TestCartGrid( const G4ThreeVector &theG1,
|
||||
const G4ThreeVector &theG2,
|
||||
const G4ThreeVector &theV,
|
||||
G4int n1, G4int n2 )
|
||||
{
|
||||
if (n1 <= 0 || n2 <= 0)
|
||||
G4Exception( "G4GeomTestVolume::TestCartGrid()", "GeomNav0002",
|
||||
FatalException, "Arguments n1 and n2 must be >= 1" );
|
||||
|
||||
G4ThreeVector xMin( extent.GetXmin(), extent.GetYmin(),
|
||||
extent.GetZmin() );
|
||||
G4ThreeVector xMax( extent.GetXmax(), extent.GetYmax(),
|
||||
extent.GetZmax() );
|
||||
|
||||
G4ThreeVector g1(theG1.unit());
|
||||
G4ThreeVector g2(theG2.unit());
|
||||
G4ThreeVector v(theV.unit());
|
||||
|
||||
G4double gMin1 = g1.dot(xMin);
|
||||
G4double gMax1 = g1.dot(xMax);
|
||||
|
||||
G4double gMin2 = g2.dot(xMin);
|
||||
G4double gMax2 = g2.dot(xMax);
|
||||
|
||||
G4double delta1 = (gMax1-gMin1)/G4double(n1);
|
||||
G4double delta2 = (gMax2-gMin2)/G4double(n2);
|
||||
|
||||
G4int i1, i2;
|
||||
|
||||
for(i1=0;i1<=n1;++i1)
|
||||
{
|
||||
G4ThreeVector p1 = (gMin1 + G4double(i1)*delta1)*g1;
|
||||
|
||||
for(i2=0;i2<=n2;++i2)
|
||||
{
|
||||
G4ThreeVector p2 = (gMin2 + G4double(i2)*delta2)*g2;
|
||||
|
||||
TestOneLine( p1+p2, v );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// TestRecursiveLine
|
||||
//
|
||||
void
|
||||
G4GeomTestVolume::TestRecursiveLine( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v,
|
||||
G4int slevel, G4int depth )
|
||||
{
|
||||
// If reached requested level of depth (i.e. set to 0), exit.
|
||||
// If not depth specified (i.e. set to -1), visit the whole tree.
|
||||
// If requested initial level of depth is not zero, visit from beginning
|
||||
//
|
||||
if (depth == 0) return;
|
||||
if (depth != -1) depth--;
|
||||
if (slevel != 0) slevel--;
|
||||
|
||||
//
|
||||
// As long as we aren't a replica and we reached the requested
|
||||
// initial level of depth, test ourselves
|
||||
//
|
||||
if ( (!target->IsReplicated()) && (slevel==0) )
|
||||
{
|
||||
TestOneLine( p, v );
|
||||
ReportErrors();
|
||||
}
|
||||
|
||||
//
|
||||
// Loop over unique daughters
|
||||
//
|
||||
std::set<const G4LogicalVolume *> tested;
|
||||
|
||||
const G4LogicalVolume *logical = target->GetLogicalVolume();
|
||||
G4int nDaughter = logical->GetNoDaughters();
|
||||
G4int iDaughter;
|
||||
for( iDaughter=0; iDaughter<nDaughter; ++iDaughter )
|
||||
{
|
||||
const G4VPhysicalVolume *daughter =
|
||||
logical->GetDaughter(iDaughter);
|
||||
const G4LogicalVolume *daughterLogical =
|
||||
daughter->GetLogicalVolume();
|
||||
|
||||
//
|
||||
// Skip empty daughters
|
||||
//
|
||||
if (daughterLogical->GetNoDaughters() == 0) continue;
|
||||
|
||||
//
|
||||
// Tested already?
|
||||
//
|
||||
std::pair<std::set<const G4LogicalVolume *>::iterator,G4bool>
|
||||
there = tested.insert(daughterLogical);
|
||||
if (!there.second) continue;
|
||||
|
||||
//
|
||||
// Recurse
|
||||
//
|
||||
G4GeomTestVolume vTest( daughter, logger, tolerance );
|
||||
vTest.TestRecursiveLine( p, v, slevel, depth );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// TestOneLine
|
||||
//
|
||||
// Test geometry consistency along a single line
|
||||
//
|
||||
void G4GeomTestVolume::TestOneLine( const G4ThreeVector &p,
|
||||
const G4ThreeVector &v )
|
||||
{
|
||||
//
|
||||
// Keep track of intersection points
|
||||
//
|
||||
std::vector<G4GeomTestVolPoint> points;
|
||||
|
||||
//
|
||||
// Calculate intersections with the mother volume
|
||||
//
|
||||
G4GeomTestSegment targetSegment( target->GetLogicalVolume()->GetSolid(),
|
||||
p, v, logger );
|
||||
|
||||
//
|
||||
// Add them to our list
|
||||
//
|
||||
G4int n = targetSegment.GetNumberPoints();
|
||||
G4int i;
|
||||
for(i=0;i<n;++i)
|
||||
{
|
||||
points.push_back( G4GeomTestVolPoint( targetSegment.GetPoint(i), -1 ) );
|
||||
}
|
||||
|
||||
//
|
||||
// Loop over daughter volumes
|
||||
//
|
||||
const G4LogicalVolume *logical = target->GetLogicalVolume();
|
||||
G4int nDaughter = logical->GetNoDaughters();
|
||||
G4int iDaughter;
|
||||
for( iDaughter=0; iDaughter<nDaughter; ++iDaughter)
|
||||
{
|
||||
const G4VPhysicalVolume *daughter =
|
||||
logical->GetDaughter(iDaughter);
|
||||
|
||||
//
|
||||
// Convert coordinates to daughter local coordinates
|
||||
//
|
||||
const G4RotationMatrix *rotation = daughter->GetFrameRotation();
|
||||
const G4ThreeVector &translation = daughter->GetFrameTranslation();
|
||||
|
||||
G4ThreeVector pLocal = translation + p;
|
||||
G4ThreeVector vLocal = v;
|
||||
|
||||
if (rotation)
|
||||
{
|
||||
pLocal = (*rotation)*pLocal;
|
||||
vLocal = (*rotation)*vLocal;
|
||||
}
|
||||
|
||||
//
|
||||
// Find intersections
|
||||
//
|
||||
G4GeomTestSegment
|
||||
daughterSegment( daughter->GetLogicalVolume()->GetSolid(),
|
||||
pLocal, vLocal, logger );
|
||||
|
||||
//
|
||||
// Add them to the list
|
||||
//
|
||||
n = daughterSegment.GetNumberPoints();
|
||||
for(i=0;i<n;++i)
|
||||
{
|
||||
points.push_back( G4GeomTestVolPoint( daughterSegment.GetPoint(i),
|
||||
iDaughter, translation, rotation ) );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Now sort the list of intersection points
|
||||
//
|
||||
std::sort( points.begin(), points.end() );
|
||||
|
||||
//
|
||||
// Search for problems:
|
||||
// 1. Overlap daughters will be indicated by intersecting
|
||||
// points that lie within another daughter
|
||||
// 2. Daughter extending outside the mother will be
|
||||
// indicated by intersecting points outside the mother
|
||||
//
|
||||
// The search method is always looking forward when
|
||||
// resolving discrepencies due to roundoff error. Once
|
||||
// one instance of a daughter intersection is analyzed,
|
||||
// it is removed from further consideration
|
||||
//
|
||||
n = points.size();
|
||||
|
||||
//
|
||||
// Set true if this point has been analyzed
|
||||
//
|
||||
std::vector<G4bool> checked( n, false );
|
||||
|
||||
for(i=0;i<n;++i)
|
||||
{
|
||||
if (checked[i]) continue;
|
||||
|
||||
G4int iDaug = points[i].GetDaughterIndex();
|
||||
if (iDaug < 0) continue;
|
||||
|
||||
//
|
||||
// Intersection found. Find matching pair.
|
||||
//
|
||||
G4double iS = points[i].GetDistance();
|
||||
G4int j = i;
|
||||
while(++j<n)
|
||||
{
|
||||
if (iDaug == points[j].GetDaughterIndex()) break;
|
||||
}
|
||||
if (j>=n)
|
||||
{
|
||||
//
|
||||
// Unmatched? This shouldn't happen
|
||||
//
|
||||
logger->SolidProblem( logical->GetDaughter(iDaug)->
|
||||
GetLogicalVolume()->GetSolid(),
|
||||
"Unmatched intersection point",
|
||||
points[i].GetPosition() );
|
||||
continue;
|
||||
}
|
||||
|
||||
checked[j] = true;
|
||||
|
||||
G4double jS = points[j].GetDistance();
|
||||
|
||||
//
|
||||
// Otherwise, we could have a problem
|
||||
//
|
||||
G4int k = i;
|
||||
while(++k<j)
|
||||
{
|
||||
if (checked[k]) continue;
|
||||
|
||||
G4bool kEntering = points[k].Entering();
|
||||
G4double kS = points[k].GetDistance();
|
||||
|
||||
|
||||
//
|
||||
// Problem found: catagorize
|
||||
//
|
||||
G4int kDaug = points[k].GetDaughterIndex();
|
||||
if (kDaug < 0)
|
||||
{
|
||||
//
|
||||
// Ignore small overshoots if they are within tolerance
|
||||
//
|
||||
if (kS-iS < tolerance && kEntering ) continue;
|
||||
if (jS-kS < tolerance && (!kEntering)) continue;
|
||||
|
||||
//
|
||||
// We appear to extend outside the mother volume
|
||||
//
|
||||
std::map<G4long,G4GeomTestOvershootList>::iterator overshoot =
|
||||
overshoots.find(iDaug);
|
||||
if (overshoot == overshoots.end())
|
||||
{
|
||||
std::pair<std::map<G4long,G4GeomTestOvershootList>::iterator,G4bool>
|
||||
result =
|
||||
overshoots.insert( std::pair<const G4long,G4GeomTestOvershootList>
|
||||
(iDaug,G4GeomTestOvershootList(target,iDaug)) );
|
||||
overshoot = result.first;
|
||||
}
|
||||
|
||||
if (kEntering)
|
||||
(*overshoot).second.AddError( points[i].GetPosition(),
|
||||
points[k].GetPosition() );
|
||||
else
|
||||
(*overshoot).second.AddError( points[k].GetPosition(),
|
||||
points[j].GetPosition() );
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Ignore small overlaps if they are within tolerance
|
||||
//
|
||||
if (kS-iS < tolerance && (!kEntering)) continue;
|
||||
if (jS-kS < tolerance && kEntering ) continue;
|
||||
|
||||
//
|
||||
// We appear to overlap with another daughter
|
||||
//
|
||||
G4long key = iDaug < kDaug ?
|
||||
(iDaug*nDaughter + kDaug) : (kDaug*nDaughter + iDaug);
|
||||
|
||||
std::map<G4long,G4GeomTestOverlapList>::iterator overlap =
|
||||
overlaps.find(key);
|
||||
if (overlap == overlaps.end())
|
||||
{
|
||||
std::pair<std::map<G4long,G4GeomTestOverlapList>::iterator,G4bool>
|
||||
result =
|
||||
overlaps.insert( std::pair<const G4long,G4GeomTestOverlapList>
|
||||
(key,G4GeomTestOverlapList(target,iDaug,kDaug)) );
|
||||
overlap = result.first;
|
||||
}
|
||||
|
||||
if (points[k].Entering())
|
||||
(*overlap).second.AddError( points[k].GetPosition(),
|
||||
points[j].GetPosition() );
|
||||
else
|
||||
(*overlap).second.AddError( points[i].GetPosition(),
|
||||
points[k].GetPosition() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// ReportErrors
|
||||
//
|
||||
void G4GeomTestVolume::ReportErrors()
|
||||
{
|
||||
//
|
||||
// Report overshoots
|
||||
//
|
||||
if (overshoots.empty())
|
||||
logger->NoProblem("GeomTest: no daughter volume extending outside mother detected.");
|
||||
else
|
||||
{
|
||||
std::map<G4long,G4GeomTestOvershootList>::iterator overshoot =
|
||||
overshoots.begin();
|
||||
while( overshoot != overshoots.end() )
|
||||
{
|
||||
logger->OvershootingDaughter( &(*overshoot).second );
|
||||
++overshoot;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Report overlaps
|
||||
//
|
||||
if (overlaps.empty())
|
||||
logger->NoProblem("GeomTest: no overlapping daughters detected.");
|
||||
else
|
||||
{
|
||||
std::map<G4long,G4GeomTestOverlapList>::iterator overlap =
|
||||
overlaps.begin();
|
||||
while( overlap != overlaps.end() )
|
||||
{
|
||||
logger->OverlappingDaughters( &(*overlap).second );
|
||||
++overlap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// ClearErrors
|
||||
//
|
||||
void G4GeomTestVolume::ClearErrors()
|
||||
{
|
||||
overshoots.clear();
|
||||
overlaps.clear();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4GeometryMessenger.cc 73253 2013-08-22 13:24:02Z gcosmo $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class source file
|
||||
@@ -36,6 +36,7 @@
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
#include "G4GeometryMessenger.hh"
|
||||
|
||||
#include "G4TransportationManager.hh"
|
||||
@@ -45,24 +46,18 @@
|
||||
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIcmdWith3VectorAndUnit.hh"
|
||||
#include "G4UIcmdWith3Vector.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIcmdWithABool.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithADouble.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
|
||||
#include "G4GeomTestStreamLogger.hh"
|
||||
#include "G4GeomTestVolume.hh"
|
||||
|
||||
//
|
||||
// Constructor
|
||||
//
|
||||
G4GeometryMessenger::G4GeometryMessenger(G4TransportationManager* tman)
|
||||
: x(0,0,0), p(0,0,1), grdRes(100,100,100), cylRes(90,50,50),
|
||||
cylfZ(0.8), cylfR(0.8), newtol(false), tol(1E-4), // mm
|
||||
recLevel(0), recDepth(-1), tmanager(tman), tlogger(0), tvolume(0)
|
||||
: tol(0.0), recLevel(0), recDepth(-1), tmanager(tman), tvolume(0)
|
||||
{
|
||||
geodir = new G4UIdirectory( "/geometry/" );
|
||||
geodir->SetGuidance( "Geometry control commands." );
|
||||
@@ -124,90 +119,26 @@ G4GeometryMessenger::G4GeometryMessenger(G4TransportationManager* tman)
|
||||
testdir->SetGuidance( "Helps in detecting possible overlapping regions." );
|
||||
|
||||
tolCmd = new G4UIcmdWithADoubleAndUnit( "/geometry/test/tolerance",this );
|
||||
tolCmd->SetGuidance( "Set error tolerance value." );
|
||||
tolCmd->SetGuidance( "Initial default value: 1E-4*mm." );
|
||||
tolCmd->SetGuidance( "Define tolerance (in mm) by which overlaps reports" );
|
||||
tolCmd->SetGuidance( "should be reported. By default, all overlaps are" );
|
||||
tolCmd->SetGuidance( "reported, i.e. tolerance is set to: 0*mm." );
|
||||
tolCmd->SetParameterName( "Tolerance", true, true );
|
||||
tolCmd->SetDefaultValue( 1E-4 );
|
||||
tolCmd->SetDefaultValue( 0 );
|
||||
tolCmd->SetDefaultUnit( "mm" );
|
||||
tolCmd->SetUnitCategory( "Length" );
|
||||
|
||||
posCmd = new G4UIcmdWith3VectorAndUnit( "/geometry/test/position", this );
|
||||
posCmd->SetGuidance( "Set starting position for the line_test." );
|
||||
posCmd->SetParameterName( "X", "Y", "Z", true, true );
|
||||
posCmd->SetDefaultUnit( "cm" );
|
||||
verCmd = new G4UIcmdWithABool( "/geometry/test/verbosity", this );
|
||||
verCmd->SetGuidance( "Specify if running in verbosity mode or not." );
|
||||
verCmd->SetGuidance( "By default verbosity is set to ON (TRUE)." );
|
||||
verCmd->SetParameterName("verbosity",true);
|
||||
verCmd->SetDefaultValue(true);
|
||||
verCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
dirCmd = new G4UIcmdWith3VectorAndUnit( "/geometry/test/direction", this );
|
||||
dirCmd->SetGuidance( "Set momentum direction for the line_test." );
|
||||
dirCmd->SetGuidance( "Direction needs not to be a unit vector." );
|
||||
dirCmd->SetParameterName( "Px", "Py", "Pz", true, true );
|
||||
dirCmd->SetRange( "Px != 0 || Py != 0 || Pz != 0" );
|
||||
|
||||
linCmd = new G4UIcmdWithABool( "/geometry/test/line_test", this );
|
||||
linCmd->SetGuidance( "Performs test along a single specified direction/position." );
|
||||
linCmd->SetGuidance( "Use position and direction commands to change default." );
|
||||
linCmd->SetGuidance( "Initial default: position(0,0,0), direction(0,0,1)." );
|
||||
linCmd->SetGuidance( "If recursion flag is set to TRUE, the intersection checks" );
|
||||
linCmd->SetGuidance( "will be performed recursively in the geometry tree." );
|
||||
linCmd->SetParameterName("recursionFlag",true);
|
||||
linCmd->SetDefaultValue(false);
|
||||
linCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
grzCmd = new G4UIcmdWith3Vector( "/geometry/test/grid_cells", this );
|
||||
grzCmd->SetGuidance( "Define resolution of grid geometry as number of cells," );
|
||||
grzCmd->SetGuidance( "specifying them for each dimension, X, Y and Z." );
|
||||
grzCmd->SetGuidance( "Will be applied to grid_test and recursive_test commands." );
|
||||
grzCmd->SetGuidance( "Initial default values: X=100, Y=100, Z=100." );
|
||||
grzCmd->SetParameterName( "X", "Y", "Z", true, true );
|
||||
grzCmd->SetDefaultValue( G4ThreeVector(100, 100, 100) );
|
||||
|
||||
grdCmd = new G4UIcmdWithABool( "/geometry/test/grid_test", this );
|
||||
grdCmd->SetGuidance( "Start running the default grid test." );
|
||||
grdCmd->SetGuidance( "A grid of lines parallel to a cartesian axis is used;" );
|
||||
grdCmd->SetGuidance( "By default, only direct daughters of the mother volumes are checked." );
|
||||
grdCmd->SetGuidance( "If recursion flag is set to TRUE, the intersection checks" );
|
||||
grdCmd->SetGuidance( "will be performed recursively in the geometry tree." );
|
||||
grdCmd->SetGuidance( "NOTE: the recursion may take a very long time," );
|
||||
grdCmd->SetGuidance( " depending on the geometry complexity !");
|
||||
grdCmd->SetParameterName("recursionFlag",true);
|
||||
grdCmd->SetDefaultValue(false);
|
||||
grdCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
cyzCmd = new G4UIcmdWith3Vector( "/geometry/test/cylinder_geometry", this );
|
||||
cyzCmd->SetGuidance( "Define details of the cylinder geometry, specifying:" );
|
||||
cyzCmd->SetGuidance( " nPhi - number of lines per Phi" );
|
||||
cyzCmd->SetGuidance( " nZ - number of Z points" );
|
||||
cyzCmd->SetGuidance( " nRho - number of Rho points" );
|
||||
cyzCmd->SetGuidance( "Will be applied to the cylinder_test command." );
|
||||
cyzCmd->SetGuidance( "Initial default values: nPhi=90, nZ=50, nRho=50." );
|
||||
cyzCmd->SetParameterName( "nPhi", "nZ", "nRho", true, true );
|
||||
cyzCmd->SetDefaultValue( G4ThreeVector(90, 50, 50) );
|
||||
|
||||
cfzCmd = new G4UIcmdWithADouble( "/geometry/test/cylinder_scaleZ", this );
|
||||
cfzCmd->SetGuidance( "Define the resolution of the cylinder geometry, specifying" );
|
||||
cfzCmd->SetGuidance( "the fraction scale for points along Z." );
|
||||
cfzCmd->SetGuidance( "Initial default values: fracZ=0.8" );
|
||||
cfzCmd->SetParameterName("fracZ",true);
|
||||
cfzCmd->SetDefaultValue(0.8);
|
||||
|
||||
cfrCmd = new G4UIcmdWithADouble( "/geometry/test/cylinder_scaleRho", this );
|
||||
cfrCmd->SetGuidance( "Define the resolution of the cylinder geometry, specifying" );
|
||||
cfrCmd->SetGuidance( "the fraction scale for points along Rho." );
|
||||
cfrCmd->SetGuidance( "Initial default values: fracRho=0.8" );
|
||||
cfrCmd->SetParameterName("fracRho",true);
|
||||
cfrCmd->SetDefaultValue(0.8);
|
||||
|
||||
cylCmd = new G4UIcmdWithABool( "/geometry/test/cylinder_test", this );
|
||||
cylCmd->SetGuidance( "Start running the cylinder test." );
|
||||
cylCmd->SetGuidance( "A set of lines in a cylindrical pattern of gradually" );
|
||||
cylCmd->SetGuidance( "increasing mesh size." );
|
||||
cylCmd->SetGuidance( "By default, only direct daughters of the mother volumes are checked." );
|
||||
cylCmd->SetGuidance( "If recursion flag is set to TRUE, the intersection checks" );
|
||||
cylCmd->SetGuidance( "will be performed recursively in the geometry tree." );
|
||||
cylCmd->SetGuidance( "NOTE: the recursion may take a very long time," );
|
||||
cylCmd->SetGuidance( " depending on the geometry complexity !");
|
||||
cylCmd->SetParameterName("recursionFlag",true);
|
||||
cylCmd->SetDefaultValue(false);
|
||||
cylCmd->AvailableForStates(G4State_Idle);
|
||||
rslCmd = new G4UIcmdWithAnInteger( "/geometry/test/resolution", this );
|
||||
rslCmd->SetGuidance( "Set the number of points on surface to be generated for" );
|
||||
rslCmd->SetGuidance( "checking overlaps." );
|
||||
rslCmd->SetParameterName("resolution",true);
|
||||
rslCmd->SetDefaultValue(10000);
|
||||
|
||||
rcsCmd = new G4UIcmdWithAnInteger( "/geometry/test/recursion_start", this );
|
||||
rcsCmd->SetGuidance( "Set the initial level in the geometry tree for recursion." );
|
||||
@@ -222,23 +153,21 @@ G4GeometryMessenger::G4GeometryMessenger(G4TransportationManager* tman)
|
||||
rcdCmd->SetParameterName("recursion_depth",true);
|
||||
rcdCmd->SetDefaultValue(-1);
|
||||
|
||||
// Obsolete verification commands ...
|
||||
errCmd = new G4UIcmdWithAnInteger( "/geometry/test/maximum_errors", this );
|
||||
errCmd->SetGuidance( "Set the maximum number of overlap errors to report" );
|
||||
errCmd->SetGuidance( "for each single volume being checked." );
|
||||
errCmd->SetGuidance( "Once reached the maximum number specified, overlaps" );
|
||||
errCmd->SetGuidance( "affecting that volume further than that are simply ignored." );
|
||||
errCmd->SetParameterName("maximum_errors",true);
|
||||
errCmd->SetDefaultValue(1);
|
||||
|
||||
runCmd = new G4UIcmdWithABool( "/geometry/test/run", this );
|
||||
runCmd->SetGuidance( "Start running the default grid test." );
|
||||
runCmd->SetGuidance( "Same as the grid_test command." );
|
||||
runCmd->SetGuidance( "If recursion flag is set to TRUE, the intersection checks" );
|
||||
runCmd->SetGuidance( "will be performed recursively in the geometry tree." );
|
||||
runCmd->SetGuidance( "NOTE: the recursion may take a very long time," );
|
||||
runCmd->SetGuidance( " depending on the geometry complexity !");
|
||||
runCmd->SetParameterName("recursionFlag",true);
|
||||
runCmd->SetDefaultValue(false);
|
||||
runCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
recCmd = new G4UIcmdWithoutParameter( "/geometry/test/recursive_test", this );
|
||||
recCmd->SetGuidance( "Start running the recursive grid test." );
|
||||
recCmd->SetGuidance( "A grid of lines along a cartesian axis is recursively" );
|
||||
recCmd->SetGuidance( "to all daughters and daughters of daughters, etc." );
|
||||
recCmd = new G4UIcmdWithoutParameter( "/geometry/test/run", this );
|
||||
recCmd->SetGuidance( "Start running the recursive overlap check." );
|
||||
recCmd->SetGuidance( "Volumes are recursively asked to verify for overlaps" );
|
||||
recCmd->SetGuidance( "for points generated on the surface against their" );
|
||||
recCmd->SetGuidance( "respective mother volume and sisters at the same" );
|
||||
recCmd->SetGuidance( "level, performing for all daughters and daughters of" );
|
||||
recCmd->SetGuidance( "daughters, etc." );
|
||||
recCmd->SetGuidance( "NOTE: it may take a very long time," );
|
||||
recCmd->SetGuidance( " depending on the geometry complexity !");
|
||||
recCmd->AvailableForStates(G4State_Idle);
|
||||
@@ -249,14 +178,12 @@ G4GeometryMessenger::G4GeometryMessenger(G4TransportationManager* tman)
|
||||
//
|
||||
G4GeometryMessenger::~G4GeometryMessenger()
|
||||
{
|
||||
delete linCmd; delete posCmd; delete dirCmd;
|
||||
delete grzCmd; delete grdCmd; delete recCmd; delete runCmd;
|
||||
delete rcsCmd; delete rcdCmd;
|
||||
delete cyzCmd; delete cfzCmd; delete cfrCmd; delete cylCmd;
|
||||
delete verCmd; delete recCmd; delete rslCmd;
|
||||
delete resCmd; delete rcsCmd; delete rcdCmd; delete errCmd;
|
||||
delete tolCmd;
|
||||
delete resCmd; delete verbCmd; delete pchkCmd; delete chkCmd;
|
||||
delete verbCmd; delete pchkCmd; delete chkCmd;
|
||||
delete geodir; delete navdir; delete testdir;
|
||||
delete tvolume; delete tlogger;
|
||||
delete tvolume;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -265,23 +192,19 @@ G4GeometryMessenger::~G4GeometryMessenger()
|
||||
void
|
||||
G4GeometryMessenger::Init()
|
||||
{
|
||||
// Clean old allocated loggers...
|
||||
// Create checker...
|
||||
//
|
||||
if (tlogger) delete tlogger;
|
||||
if (tvolume) delete tvolume;
|
||||
if (!tvolume)
|
||||
{
|
||||
// Get the world volume
|
||||
//
|
||||
G4VPhysicalVolume* world =
|
||||
tmanager->GetNavigatorForTracking()->GetWorldVolume();
|
||||
|
||||
// Create a logger to send errors/output to cout
|
||||
//
|
||||
tlogger = new G4GeomTestStreamLogger(std::cout);
|
||||
|
||||
// Get the world volume
|
||||
//
|
||||
G4VPhysicalVolume* world =
|
||||
tmanager->GetNavigatorForTracking()->GetWorldVolume();
|
||||
|
||||
// Test the actual detector...
|
||||
//
|
||||
tvolume = new G4GeomTestVolume(world, tlogger);
|
||||
// Test the actual detector...
|
||||
//
|
||||
tvolume = new G4GeomTestVolume(world);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -299,49 +222,19 @@ G4GeometryMessenger::SetNewValue( G4UIcommand* command, G4String newValues )
|
||||
else if (command == chkCmd) {
|
||||
SetCheckMode( newValues );
|
||||
}
|
||||
else if (command == posCmd) {
|
||||
x = posCmd->GetNew3VectorValue( newValues );
|
||||
}
|
||||
else if (command == dirCmd) {
|
||||
p = dirCmd->GetNew3VectorValue( newValues );
|
||||
if (p.mag() < DBL_MIN) {
|
||||
G4cerr << "Please specify non-zero momentum!" << G4endl;
|
||||
p = G4ThreeVector(0,0,1);
|
||||
}
|
||||
}
|
||||
else if (command == tolCmd) {
|
||||
tol = tolCmd->GetNewDoubleValue( newValues );
|
||||
newtol = true;
|
||||
}
|
||||
else if (command == linCmd) {
|
||||
Init();
|
||||
if (linCmd->GetNewBoolValue( newValues ))
|
||||
RecursiveLineTest();
|
||||
else
|
||||
LineTest();
|
||||
tol = tolCmd->GetNewDoubleValue( newValues )
|
||||
* tolCmd->GetNewUnitValue( newValues );
|
||||
tvolume->SetTolerance(tol);
|
||||
}
|
||||
else if ((command == grdCmd) || (command == runCmd)){
|
||||
else if (command == verCmd) {
|
||||
Init();
|
||||
if (grdCmd->GetNewBoolValue( newValues ) || runCmd->GetNewBoolValue( newValues ))
|
||||
RecursiveGridTest();
|
||||
else
|
||||
GridTest();
|
||||
tvolume->SetVerbosity(verCmd->GetNewBoolValue( newValues ));
|
||||
}
|
||||
else if (command == grzCmd) {
|
||||
grdRes = grzCmd->GetNew3VectorValue( newValues );
|
||||
if (grdRes.mag() < DBL_MIN) {
|
||||
G4cerr << "Please specify non-zero resolution!" << G4endl;
|
||||
grdRes = G4ThreeVector(100,100,100);
|
||||
}
|
||||
}
|
||||
else if (command == cyzCmd) {
|
||||
cylRes = cyzCmd->GetNew3VectorValue( newValues );
|
||||
}
|
||||
else if (command == cfzCmd) {
|
||||
cylfZ = cfzCmd->GetNewDoubleValue( newValues );
|
||||
}
|
||||
else if (command == cfrCmd) {
|
||||
cylfR = cfrCmd->GetNewDoubleValue( newValues );
|
||||
else if (command == rslCmd) {
|
||||
Init();
|
||||
tvolume->SetResolution(rslCmd->GetNewIntValue( newValues ));
|
||||
}
|
||||
else if (command == rcsCmd) {
|
||||
recLevel = rcsCmd->GetNewIntValue( newValues );
|
||||
@@ -349,16 +242,15 @@ G4GeometryMessenger::SetNewValue( G4UIcommand* command, G4String newValues )
|
||||
else if (command == rcdCmd) {
|
||||
recDepth = rcdCmd->GetNewIntValue( newValues );
|
||||
}
|
||||
else if (command == errCmd) {
|
||||
Init();
|
||||
tvolume->SetErrorsThreshold(errCmd->GetNewIntValue( newValues ));
|
||||
}
|
||||
else if (command == recCmd) {
|
||||
Init();
|
||||
RecursiveGridTest();
|
||||
}
|
||||
else if (command == cylCmd) {
|
||||
Init();
|
||||
if (cylCmd->GetNewBoolValue( newValues ))
|
||||
RecursiveCylinderTest();
|
||||
else
|
||||
CylinderTest();
|
||||
G4cout << "Running geometry overlaps check..." << G4endl;
|
||||
RecursiveOverlapTest();
|
||||
G4cout << "Geometry overlaps check completed !" << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,15 +261,9 @@ G4String
|
||||
G4GeometryMessenger::GetCurrentValue(G4UIcommand* command )
|
||||
{
|
||||
G4String cv = "";
|
||||
if (command == posCmd) {
|
||||
cv = posCmd->ConvertToString( x, "cm" );
|
||||
}
|
||||
else if (command == tolCmd) {
|
||||
if (command == tolCmd) {
|
||||
cv = tolCmd->ConvertToString( tol, "mm" );
|
||||
}
|
||||
else if (command == dirCmd) {
|
||||
cv = dirCmd->ConvertToString( p, "GeV" );
|
||||
}
|
||||
return cv;
|
||||
}
|
||||
|
||||
@@ -447,153 +333,16 @@ G4GeometryMessenger::SetPushFlag(G4String input)
|
||||
}
|
||||
|
||||
//
|
||||
// LineTest
|
||||
// Recursive Overlap Test
|
||||
//
|
||||
void
|
||||
G4GeometryMessenger::LineTest()
|
||||
G4GeometryMessenger::RecursiveOverlapTest()
|
||||
{
|
||||
// Close geometry if necessary
|
||||
//
|
||||
CheckGeometry();
|
||||
|
||||
// Verify if error tolerance has changed
|
||||
//
|
||||
if (newtol) tvolume->SetTolerance(tol);
|
||||
|
||||
// Make test on single line supplied by user
|
||||
//
|
||||
tvolume->TestOneLine( x, p );
|
||||
|
||||
// Print out any errors, if found
|
||||
//
|
||||
tvolume->ReportErrors();
|
||||
}
|
||||
|
||||
//
|
||||
// RecursiveLineTest
|
||||
//
|
||||
void
|
||||
G4GeometryMessenger::RecursiveLineTest()
|
||||
{
|
||||
// Close geometry if necessary
|
||||
//
|
||||
CheckGeometry();
|
||||
|
||||
// Verify if error tolerance has changed
|
||||
//
|
||||
if (newtol) tvolume->SetTolerance(tol);
|
||||
|
||||
// Make test on single line supplied by user recursively
|
||||
//
|
||||
tvolume->TestRecursiveLine( x, p, recLevel, recDepth );
|
||||
|
||||
// Print out any errors, if found
|
||||
//
|
||||
tvolume->ReportErrors();
|
||||
}
|
||||
|
||||
//
|
||||
// GridTest
|
||||
//
|
||||
void
|
||||
G4GeometryMessenger::GridTest()
|
||||
{
|
||||
// Close geometry if necessary
|
||||
//
|
||||
CheckGeometry();
|
||||
|
||||
// Verify if error tolerance has changed
|
||||
//
|
||||
if (newtol) tvolume->SetTolerance(tol);
|
||||
|
||||
// Apply set of trajectories in a 3D grid pattern
|
||||
//
|
||||
tvolume->TestCartGridXYZ( G4int(grdRes.x()),
|
||||
G4int(grdRes.y()),
|
||||
G4int(grdRes.z()) );
|
||||
|
||||
// Print out any errors, if found
|
||||
//
|
||||
tvolume->ReportErrors();
|
||||
}
|
||||
|
||||
//
|
||||
// RecursiveGridTest
|
||||
//
|
||||
void
|
||||
G4GeometryMessenger::RecursiveGridTest()
|
||||
{
|
||||
// Close geometry if necessary
|
||||
//
|
||||
CheckGeometry();
|
||||
|
||||
// Verify if error tolerance has changed
|
||||
//
|
||||
if (newtol) tvolume->SetTolerance(tol);
|
||||
|
||||
// Apply set of trajectories in a 3D grid pattern recursively
|
||||
//
|
||||
tvolume->TestRecursiveCartGrid( G4int(grdRes.x()),
|
||||
G4int(grdRes.y()),
|
||||
G4int(grdRes.z()),
|
||||
recLevel, recDepth );
|
||||
|
||||
// Print out any errors, if found
|
||||
//
|
||||
tvolume->ReportErrors();
|
||||
}
|
||||
|
||||
//
|
||||
// CylinderTest
|
||||
//
|
||||
void
|
||||
G4GeometryMessenger::CylinderTest()
|
||||
{
|
||||
// Close geometry if necessary
|
||||
//
|
||||
CheckGeometry();
|
||||
|
||||
// Verify if error tolerance has changed
|
||||
//
|
||||
if (newtol) tvolume->SetTolerance(tol);
|
||||
|
||||
// Apply default set of lines in a cylindrical pattern of gradually
|
||||
// increasing mesh size of trajectories in a 3D grid pattern
|
||||
//
|
||||
tvolume->TestCylinder(G4int(cylRes.x()),
|
||||
G4int(cylRes.y()),
|
||||
G4int(cylRes.z()),
|
||||
cylfZ, cylfR, true);
|
||||
|
||||
// Print out any errors, if found
|
||||
//
|
||||
tvolume->ReportErrors();
|
||||
}
|
||||
|
||||
//
|
||||
// RecursiveCylinderTest
|
||||
//
|
||||
void
|
||||
G4GeometryMessenger::RecursiveCylinderTest()
|
||||
{
|
||||
// Close geometry if necessary
|
||||
//
|
||||
CheckGeometry();
|
||||
|
||||
// Verify if error tolerance has changed
|
||||
//
|
||||
if (newtol) tvolume->SetTolerance(tol);
|
||||
|
||||
// Apply default set of lines in a cylindrical pattern of gradually
|
||||
// increasing mesh size of trajectories in a 3D grid pattern recursively
|
||||
//
|
||||
tvolume->TestRecursiveCylinder(G4int(cylRes.x()),
|
||||
G4int(cylRes.y()),
|
||||
G4int(cylRes.z()),
|
||||
cylfZ, cylfR, true,
|
||||
recLevel, recDepth );
|
||||
|
||||
// Print out any errors, if found
|
||||
//
|
||||
tvolume->ReportErrors();
|
||||
tvolume->TestRecursiveOverlap( recLevel, recDepth );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4GlobalMagFieldMessenger.cc 66536 2012-12-19 14:32:36Z ihrivnac $
|
||||
//
|
||||
// class G4GlobalMagFieldMessenger
|
||||
//
|
||||
// Implementation
|
||||
//
|
||||
// Implementation of the G4GlobalMagFieldMessenger class
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 28/08/2013 (ivana@ipno.in2p3.fr)
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4GlobalMagFieldMessenger.hh"
|
||||
#include "G4UniformMagField.hh"
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWith3VectorAndUnit.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
//______________________________________________________________________________
|
||||
|
||||
G4GlobalMagFieldMessenger::G4GlobalMagFieldMessenger(const G4ThreeVector& value)
|
||||
: G4UImessenger(),
|
||||
fMagField(0),
|
||||
fVerboseLevel(0),
|
||||
fDirectory(0),
|
||||
fSetValueCmd(0),
|
||||
fSetVerboseCmd(0)
|
||||
{
|
||||
fDirectory = new G4UIdirectory("/globalField/");
|
||||
fDirectory->SetGuidance("Global uniform magnetic field UI commands");
|
||||
|
||||
fSetValueCmd = new G4UIcmdWith3VectorAndUnit("/globalField/setValue",this);
|
||||
fSetValueCmd->SetGuidance("Set uniform magnetic field value.");
|
||||
fSetValueCmd->SetParameterName("Bx", "By", "By", false);
|
||||
fSetValueCmd->SetUnitCategory("Magnetic flux density");
|
||||
fSetValueCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
fSetVerboseCmd = new G4UIcmdWithAnInteger("/globalField/verbose",this);
|
||||
fSetVerboseCmd->SetGuidance("Set verbose level: ");
|
||||
fSetVerboseCmd->SetGuidance(" 0: no output");
|
||||
fSetVerboseCmd->SetGuidance(" 1: printing new field value");
|
||||
fSetVerboseCmd->SetParameterName("globalFieldVerbose", false);
|
||||
fSetVerboseCmd->SetRange("globalFieldVerbose>=0");
|
||||
fSetVerboseCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
// Create field
|
||||
fMagField = new G4UniformMagField(value);
|
||||
|
||||
// Set field value (the field is not activated if value is zero)
|
||||
SetField(value, "G4GlobalMagFieldMessenger::G4GlobalMagFieldMessenger");
|
||||
|
||||
}
|
||||
|
||||
//______________________________________________________________________________
|
||||
|
||||
G4GlobalMagFieldMessenger::~G4GlobalMagFieldMessenger()
|
||||
{
|
||||
delete fMagField;
|
||||
delete fSetValueCmd;
|
||||
delete fSetVerboseCmd;
|
||||
delete fDirectory;
|
||||
}
|
||||
|
||||
//______________________________________________________________________________
|
||||
|
||||
void G4GlobalMagFieldMessenger::SetField(const G4ThreeVector& value,
|
||||
const G4String& /*inFunction*/)
|
||||
{
|
||||
// Check if G4TransportationManager is available
|
||||
//if ( ! G4TransportationManager::GetTransportationManager() ) {
|
||||
// G4ExceptionDescription description;
|
||||
// description << "G4TransportationManager instance does not exist.";
|
||||
// G4Exception(inFunction, "GeomField004", FatalException, description);
|
||||
//}
|
||||
|
||||
// Get field manager (or create it if it does not yet exist)
|
||||
G4FieldManager* fieldManager
|
||||
= G4TransportationManager::GetTransportationManager()->GetFieldManager();
|
||||
|
||||
// Inactivate field if its value is zero
|
||||
if ( value == G4ThreeVector() ) {
|
||||
fieldManager->SetDetectorField(0);
|
||||
fieldManager->CreateChordFinder(0);
|
||||
|
||||
if ( fVerboseLevel > 0 ) {
|
||||
G4cout << "Magnetic field is inactive, fieldValue = (0,0,0)." << G4endl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fMagField->SetFieldValue(value);
|
||||
fieldManager->SetDetectorField(fMagField);
|
||||
fieldManager->CreateChordFinder(fMagField);
|
||||
|
||||
if ( fVerboseLevel > 0 ) {
|
||||
G4cout << "Magnetic field is active, fieldValue = ("
|
||||
<< G4BestUnit(value, "Magnetic flux density")
|
||||
<< ")." << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//______________________________________________________________________________
|
||||
|
||||
void G4GlobalMagFieldMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
{
|
||||
if ( command == fSetValueCmd ) {
|
||||
SetField(fSetValueCmd->GetNew3VectorValue(newValue),
|
||||
"G4GlobalMagFieldMessenger::SetNewValue");
|
||||
}
|
||||
else if ( command == fSetVerboseCmd ) {
|
||||
SetVerboseLevel(fSetVerboseCmd->GetNewIntValue(newValue));
|
||||
}
|
||||
}
|
||||
|
||||
//______________________________________________________________________________
|
||||
|
||||
void G4GlobalMagFieldMessenger::SetFieldValue(const G4ThreeVector& value)
|
||||
{
|
||||
SetField(value, "G4GlobalMagFieldMessenger::SetFieldValue");
|
||||
}
|
||||
|
||||
//______________________________________________________________________________
|
||||
|
||||
G4ThreeVector G4GlobalMagFieldMessenger::GetFieldValue() const
|
||||
{
|
||||
if ( fMagField ) return fMagField->GetConstantFieldValue();
|
||||
|
||||
return G4ThreeVector();
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4MultiLevelLocator.cc 66872 2013-01-15 01:25:57Z japost $
|
||||
//
|
||||
// Class G4MultiLevelLocator implementation
|
||||
//
|
||||
@@ -132,7 +132,7 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
|
||||
// Statistics for substeps
|
||||
//
|
||||
static G4int max_no_seen= -1;
|
||||
static G4ThreadLocal G4int max_no_seen= -1;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Algorithm for the case if progress in founding intersection is too slow.
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4MultiNavigator.cc 70934 2013-06-07 13:29:05Z gcosmo $
|
||||
// GEANT4 tag $ Name: $
|
||||
//
|
||||
// class G4PathFinder Implementation
|
||||
@@ -543,7 +543,7 @@ G4MultiNavigator::PrintLimited()
|
||||
{
|
||||
// Report results -- for checking
|
||||
|
||||
static G4String StrDoNot("DoNot"), StrUnique("Unique"),
|
||||
static const G4String StrDoNot("DoNot"), StrUnique("Unique"),
|
||||
StrUndefined("Undefined"),
|
||||
StrSharedTransport("SharedTransport"),
|
||||
StrSharedOther("SharedOther");
|
||||
@@ -716,7 +716,7 @@ G4MultiNavigator::GetGlobalExitNormal(const G4ThreeVector &argPoint,
|
||||
for ( register int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
|
||||
{
|
||||
G4ThreeVector oneNormal;
|
||||
if( fLimitedStep[ num ] )
|
||||
if( fLimitTruth[ num ] ) // Did this geometry limit the step ?
|
||||
{
|
||||
G4ThreeVector newNormal= (*pNavIter)-> GetGlobalExitNormal( argPoint, &oneObtained );
|
||||
if( oneObtained )
|
||||
@@ -795,7 +795,7 @@ G4MultiNavigator::GetLocalExitNormal(G4bool* argpObtained)
|
||||
normalGlobalCrd= fpNavigator[ fIdNavLimiting ]->GetLocalExitNormal( &isObtained);
|
||||
*argpObtained= isObtained;
|
||||
|
||||
G4int static numberWarnings= 0;
|
||||
static G4ThreadLocal G4int numberWarnings= 0;
|
||||
G4int noWarningsStart= 10, noModuloWarnings=100;
|
||||
numberWarnings++;
|
||||
if( (numberWarnings < noWarningsStart ) || (numberWarnings%noModuloWarnings==0) )
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4NavigationLogger.cc 66872 2013-01-15 01:25:57Z japost $
|
||||
//
|
||||
//
|
||||
// class G4NavigationLogger Implementation
|
||||
@@ -103,7 +103,7 @@ G4NavigationLogger::PreComputeStepLog(const G4VPhysicalVolume* motherPhysical,
|
||||
//
|
||||
if ( fVerbose > 1 )
|
||||
{
|
||||
static G4int precVerf= 20; // Precision
|
||||
static G4ThreadLocal G4int precVerf= 20; // Precision
|
||||
G4int oldprec = G4cout.precision(precVerf);
|
||||
G4cout << " - Information on mother / key daughters ..." << G4endl;
|
||||
G4cout << " Type " << std::setw(12) << "Solid-Name" << " "
|
||||
@@ -223,7 +223,7 @@ G4NavigationLogger::AlongComputeStepLog(const G4VSolid* sampleSolid,
|
||||
//
|
||||
if ( fVerbose > 1 )
|
||||
{
|
||||
static G4int precVerf= 20; // Precision
|
||||
static G4ThreadLocal G4int precVerf= 20; // Precision
|
||||
G4int oldprec = G4cout.precision(precVerf);
|
||||
G4cout << "Daughter "
|
||||
<< std::setw(12) << sampleSolid->GetName() << " "
|
||||
@@ -272,7 +272,7 @@ G4NavigationLogger::PostComputeStepLog(const G4VSolid* motherSolid,
|
||||
}
|
||||
if ( fVerbose > 1 )
|
||||
{
|
||||
static G4int precVerf= 20; // Precision
|
||||
static G4ThreadLocal G4int precVerf= 20; // Precision
|
||||
G4int oldprec = G4cout.precision(precVerf);
|
||||
G4cout << " Mother " << std::setw(12) << motherSolid->GetName() << " "
|
||||
<< std::setw(4+precVerf) << localPoint << " "
|
||||
|
||||
@@ -71,6 +71,8 @@ G4Navigator::G4Navigator()
|
||||
|
||||
fStepEndPoint = G4ThreeVector( kInfinity, kInfinity, kInfinity );
|
||||
fLastStepEndPointLocal = G4ThreeVector( kInfinity, kInfinity, kInfinity );
|
||||
|
||||
fpVoxelSafety= new G4VoxelSafety();
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
@@ -78,7 +80,7 @@ G4Navigator::G4Navigator()
|
||||
// ********************************************************************
|
||||
//
|
||||
G4Navigator::~G4Navigator()
|
||||
{;}
|
||||
{ delete fpVoxelSafety; }
|
||||
|
||||
// ********************************************************************
|
||||
// ResetHierarchyAndLocate
|
||||
@@ -716,7 +718,7 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector &pGlobalpoint,
|
||||
fCalculatedExitNormal = false;
|
||||
// Reset for new step
|
||||
|
||||
static G4int sNavCScalls=0;
|
||||
static G4ThreadLocal G4int sNavCScalls=0;
|
||||
sNavCScalls++;
|
||||
|
||||
fLastTriedStepComputation= true;
|
||||
@@ -1589,7 +1591,7 @@ G4Navigator::GetGlobalExitNormal(const G4ThreeVector& IntersectPointGlobal,
|
||||
}
|
||||
|
||||
// To make the new Voxel Safety the default, uncomment the next line
|
||||
// #define G4NEW_SAFETY 1
|
||||
#define G4NEW_SAFETY 1
|
||||
|
||||
// ********************************************************************
|
||||
// ComputeSafety
|
||||
@@ -1663,54 +1665,8 @@ G4double G4Navigator::ComputeSafety( const G4ThreeVector &pGlobalpoint,
|
||||
if ( pVoxelHeader )
|
||||
{
|
||||
#ifdef G4NEW_SAFETY
|
||||
static G4VoxelSafety sfVoxelSafety;
|
||||
G4double safetyTwo = sfVoxelSafety.ComputeSafety(localPoint,
|
||||
G4double safetyTwo = fpVoxelSafety->ComputeSafety(localPoint,
|
||||
*motherPhysical, pMaxLength);
|
||||
#ifdef G4DEBUG_NAVIGATION
|
||||
G4double safetyNormal=
|
||||
fnormalNav.ComputeSafety(localPoint, fHistory, pMaxLength);
|
||||
|
||||
G4double diffSafety= (safetyTwo - safetyNormal);
|
||||
if( std::fabs(diffSafety) > CLHEP::perMillion
|
||||
* std::fabs(safetyNormal) )
|
||||
{
|
||||
G4ExceptionDescription exd;
|
||||
exd << " ERROR in G4Navigator::ComputeStep " << G4endl;
|
||||
exd << " Error> DIFFERENCE in Safety from G4VoxelSafety "
|
||||
<< " - compared to value from Normal. Diff = " << diffSafety << G4endl;
|
||||
exd << " New Voxel Safety= " << safetyTwo
|
||||
<< " Value from Normal= " << safetyNormal << G4endl;
|
||||
exd << " Location: Local coordinates = " << localPoint
|
||||
<< " mother Volume= " << *motherPhysical->GetName()
|
||||
<< " Copy# = " << motherPhysical->GetCopyNo() << G4endl;
|
||||
exd << " : Global coordinates = " << pGlobalpoint
|
||||
<< G4endl;
|
||||
G4Exception("G4Navigator::ComputeSafety()",
|
||||
"GeomNav0003", JustWarning, exd);
|
||||
}
|
||||
G4double safetyOldVoxel;
|
||||
safetyOldVoxel =
|
||||
fvoxelNav.ComputeSafety(localPoint,fHistory,pMaxLength);
|
||||
|
||||
G4double diffBetterToApprox= safetyTwo - safetyOldVoxel;
|
||||
if( diffBetterToApprox < 0.0 )
|
||||
{
|
||||
G4ExceptionDescription exd;
|
||||
exd << "SMALLER Safety from call G4VoxelSafety compared to value "
|
||||
<< " from Normal. Diff = " << diffSafety << G4endl;
|
||||
exd << " New Voxel Safety= " << safetyTwo
|
||||
<< " Old value from Normal= " << newSafety << G4endl;
|
||||
exd << " Location: Local coordinates = " << localPoint
|
||||
<< " mother Volume= " << *motherPhysical->GetName()
|
||||
<< " Copy# = " << motherPhysical->GetCopyNo() << G4endl;
|
||||
exd << " : Global coordinates = " << pGlobalpoint
|
||||
<< G4endl;
|
||||
G4Exception("G4Navigator::ComputeSafety()",
|
||||
"GeomNav0003", JustWarning, exd);
|
||||
}
|
||||
#endif
|
||||
|
||||
// newSafety= safetyOldVoxel;
|
||||
newSafety= safetyTwo; // Faster and best available
|
||||
#else
|
||||
G4double safetyOldVoxel;
|
||||
@@ -1901,7 +1857,7 @@ void G4Navigator::ComputeStepLog(const G4ThreeVector& pGlobalpoint,
|
||||
<< fAccuracyForException/mm << " mm.";
|
||||
|
||||
suggestion << " ";
|
||||
static G4int warnNow = 0;
|
||||
static G4ThreadLocal G4int warnNow = 0;
|
||||
if( ((++warnNow % 100) == 1) )
|
||||
{
|
||||
message << G4endl
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4NormalNavigation.cc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4NormalNavigation Implementation
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4ParameterisedNavigation.cc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4ParameterisedNavigation Implementation
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4PartialPhantomParameterisation.cc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4PartialPhantomParameterisation implementation
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4PathFinder.cc 73734 2013-09-09 15:01:46Z gcosmo $
|
||||
// GEANT4 tag $ Name: $
|
||||
//
|
||||
// class G4PathFinder Implementation
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
// Initialise the static instance of the singleton
|
||||
//
|
||||
G4PathFinder* G4PathFinder::fpPathFinder=0;
|
||||
G4ThreadLocal G4PathFinder* G4PathFinder::fpPathFinder=0;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// GetInstance()
|
||||
@@ -56,10 +56,9 @@ G4PathFinder* G4PathFinder::fpPathFinder=0;
|
||||
//
|
||||
G4PathFinder* G4PathFinder::GetInstance()
|
||||
{
|
||||
static G4PathFinder theInstance;
|
||||
if( ! fpPathFinder )
|
||||
{
|
||||
fpPathFinder = &theInstance;
|
||||
fpPathFinder = new G4PathFinder;
|
||||
}
|
||||
return fpPathFinder;
|
||||
}
|
||||
@@ -115,7 +114,8 @@ G4PathFinder::G4PathFinder()
|
||||
//
|
||||
G4PathFinder::~G4PathFinder()
|
||||
{
|
||||
delete fpMultiNavigator;
|
||||
delete fpMultiNavigator;
|
||||
if (fpPathFinder) { delete fpPathFinder; fpPathFinder=0; }
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -468,7 +468,7 @@ G4PathFinder::Locate( const G4ThreeVector& position,
|
||||
G4ThreeVector moveVec = (position - lastEndPosition );
|
||||
G4double moveLenSq= moveVec.mag2();
|
||||
if( (!fNewTrack) && (!fRelocatedPoint)
|
||||
&& ( moveLenSq> kCarTolerance*kCarTolerance ) )
|
||||
&& ( moveLenSq> 10*kCarTolerance*kCarTolerance ) )
|
||||
{
|
||||
ReportMove( position, lastEndPosition, "Position" );
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4PhantomParameterisation.cc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
// GEANT4 tag $ Name:$
|
||||
//
|
||||
// class G4PhantomParameterisation implementation
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
// 14.10.96 John Apostolakis, design and implementation
|
||||
// 17.03.97 John Apostolakis, renaming new set functions being added
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4PropagatorInField.cc 69711 2013-05-13 09:22:17Z gcosmo $
|
||||
// GEANT4 tag $ Name: $
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -68,7 +68,6 @@ G4PropagatorInField::G4PropagatorInField( G4Navigator *theNavigator,
|
||||
fNavigator(theNavigator),
|
||||
fCurrentFieldMgr(detectorFieldMgr),
|
||||
fSetFieldMgr(false),
|
||||
fCharge(0.0), fInitialMomentumModulus(0.0), fMass(0.0),
|
||||
End_PointAndTangent(G4ThreeVector(0.,0.,0.),
|
||||
G4ThreeVector(0.,0.,0.),0.0,0.0,0.0,0.0,0.0),
|
||||
fParticleIsLooping(false),
|
||||
@@ -169,8 +168,6 @@ G4PropagatorInField::ComputeStep(
|
||||
// For the next call, the field manager must again be set
|
||||
fSetFieldMgr= false;
|
||||
|
||||
GetChordFinder()->SetChargeMomentumMass(fCharge,fInitialMomentumModulus,fMass);
|
||||
|
||||
// Values for Intersection Locator has to be updated on each call for the
|
||||
// case that CurrentFieldManager has changed from the one of previous step
|
||||
RefreshIntersectionLocator();
|
||||
@@ -444,10 +441,7 @@ G4PropagatorInField::ComputeStep(
|
||||
<< " Zero progress for " << fNoZeroStep << " attempted steps."
|
||||
<< G4endl
|
||||
<< " Proposed Step is " << CurrentProposedStepLength
|
||||
<< " but Step Taken is "<< fFull_CurveLen_of_LastAttempt << G4endl
|
||||
<< " For Particle with Charge = " << fCharge
|
||||
<< " Momentum = "<< fInitialMomentumModulus
|
||||
<< " Mass = " << fMass << G4endl;
|
||||
<< " but Step Taken is "<< fFull_CurveLen_of_LastAttempt << G4endl;
|
||||
if( pPhysVol )
|
||||
message << " in volume " << pPhysVol->GetName() ;
|
||||
else
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4RegularNavigation.cc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
// GEANT4 tag $ Name:$
|
||||
//
|
||||
// class G4RegularNavigation implementation
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4RegularNavigationHelper.cc 68709 2013-04-05 09:03:07Z gcosmo $
|
||||
// GEANT4 tag $ Name:$
|
||||
//
|
||||
// class G4RegularNavigationHelper implementation
|
||||
@@ -35,14 +35,14 @@
|
||||
|
||||
#include "G4RegularNavigationHelper.hh"
|
||||
|
||||
G4RegularNavigationHelper * G4RegularNavigationHelper::theInstance = 0;
|
||||
G4ThreadLocal G4RegularNavigationHelper*
|
||||
G4RegularNavigationHelper::theInstance = 0;
|
||||
|
||||
G4RegularNavigationHelper* G4RegularNavigationHelper::Instance()
|
||||
{
|
||||
if(theInstance == 0)
|
||||
if(!theInstance)
|
||||
{
|
||||
static G4RegularNavigationHelper helper;
|
||||
theInstance = &helper;
|
||||
theInstance = new G4RegularNavigationHelper;
|
||||
}
|
||||
return theInstance;
|
||||
}
|
||||
@@ -57,6 +57,7 @@ G4RegularNavigationHelper::G4RegularNavigationHelper()
|
||||
//
|
||||
G4RegularNavigationHelper::~G4RegularNavigationHelper()
|
||||
{
|
||||
if (theInstance) { delete theInstance; theInstance=0; }
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4ReplicaNavigation.cc 66872 2013-01-15 01:25:57Z japost $
|
||||
//
|
||||
//
|
||||
// class G4ReplicaNavigation Implementation
|
||||
@@ -258,10 +258,10 @@ G4ReplicaNavigation::DistanceToOut(const G4VPhysicalVolume *pVol,
|
||||
|
||||
static const G4ThreeVector VecCartAxes[3]=
|
||||
{ G4ThreeVector(1.,0.,0.),G4ThreeVector(0.,1.,0.),G4ThreeVector(0.,0.,1.) };
|
||||
static G4ExitNormal::ESide SideCartAxesPlus [3]=
|
||||
{ G4ExitNormal::kPX, G4ExitNormal::kPY, G4ExitNormal::kPZ };
|
||||
static G4ExitNormal::ESide SideCartAxesMinus[3]=
|
||||
{ G4ExitNormal::kMX, G4ExitNormal::kMY, G4ExitNormal::kMZ };
|
||||
static G4ThreadLocal G4ExitNormal::ESide *SideCartAxesPlus = 0 ; if (!SideCartAxesPlus) {SideCartAxesPlus = new G4ExitNormal::ESide [3] ;
|
||||
SideCartAxesPlus[0]= G4ExitNormal::kPX;SideCartAxesPlus[1]= G4ExitNormal::kPY;SideCartAxesPlus[2]= G4ExitNormal::kPZ ;};
|
||||
static G4ThreadLocal G4ExitNormal::ESide *SideCartAxesMinus = 0 ; if (!SideCartAxesMinus) {SideCartAxesMinus = new G4ExitNormal::ESide [3] ;
|
||||
SideCartAxesMinus[0]= G4ExitNormal::kMX;SideCartAxesMinus[1]= G4ExitNormal::kMY;SideCartAxesMinus[2]= G4ExitNormal::kMZ ;};
|
||||
|
||||
pVol->GetReplicationData(axis, nReplicas, width, offset, consuming);
|
||||
switch(axis)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4SafetyHelper.cc 72309 2013-07-15 15:52:17Z gcosmo $
|
||||
// GEANT4 tag $ Name: $
|
||||
//
|
||||
// class G4SafetyHelper Implementation
|
||||
@@ -44,8 +44,8 @@ G4SafetyHelper::G4SafetyHelper()
|
||||
fFirstCall(true),
|
||||
fVerbose(0),
|
||||
fLastSafetyPosition(0.0,0.0,0.0),
|
||||
fLastSafety(0.0),
|
||||
fRecomputeFactor(0.0)
|
||||
fLastSafety(0.0)
|
||||
// fRecomputeFactor(0.0)
|
||||
{
|
||||
fpPathFinder= 0; // Cannot initialise this yet - a loop results
|
||||
|
||||
@@ -119,34 +119,33 @@ G4double G4SafetyHelper::ComputeSafety( const G4ThreeVector& position, G4double
|
||||
// is *not* the safety location and has moved 'significantly'
|
||||
//
|
||||
G4double moveLengthSq = (position-fLastSafetyPosition).mag2();
|
||||
G4double safeDistance = fRecomputeFactor*fLastSafety;
|
||||
if( (moveLengthSq > 0.0 )
|
||||
&& (moveLengthSq >= safeDistance*safeDistance))
|
||||
if( (moveLengthSq > 0.0 ) )
|
||||
{
|
||||
fLastSafetyPosition = position;
|
||||
|
||||
if( !fUseParallelGeometries )
|
||||
{
|
||||
// Safety for mass geometry
|
||||
fLastSafety = fpMassNavigator->ComputeSafety(position, maxLength, true);
|
||||
newSafety = fpMassNavigator->ComputeSafety(position, maxLength, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Safety for all geometries
|
||||
fLastSafety = fpPathFinder->ComputeSafety(position);
|
||||
newSafety = fpPathFinder->ComputeSafety(position);
|
||||
}
|
||||
newSafety = fLastSafety;
|
||||
|
||||
// We can only store a 'true' safety - one that was not restricted by maxLength
|
||||
if( newSafety < maxLength )
|
||||
{
|
||||
fLastSafety= newSafety;
|
||||
fLastSafetyPosition = position;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// return last value if position is not significantly changed
|
||||
// return last value if position is not (significantly) changed
|
||||
//
|
||||
G4double moveLength = 0;
|
||||
if( moveLengthSq > 0.0 )
|
||||
{
|
||||
moveLength= std::sqrt(moveLengthSq);
|
||||
}
|
||||
newSafety = fLastSafety-moveLength;
|
||||
// G4double moveLength = 0;
|
||||
// if( moveLengthSq > 0.0 ) { moveLength= std::sqrt(moveLengthSq); }
|
||||
newSafety = fLastSafety; // -moveLength;
|
||||
}
|
||||
return newSafety;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4SimpleLocator.cc 66872 2013-01-15 01:25:57Z japost $
|
||||
//
|
||||
// Class G4SimpleLocator implementation
|
||||
//
|
||||
@@ -115,7 +115,7 @@ G4bool G4SimpleLocator::EstimateIntersectionPoint(
|
||||
|
||||
// Statistics for substeps
|
||||
//
|
||||
static G4int max_no_seen= -1;
|
||||
static G4ThreadLocal G4int max_no_seen= -1;
|
||||
|
||||
NormalAtEntry = GetSurfaceNormal( CurrentE_Point, validNormalAtE);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4TransportationManager.cc 68709 2013-04-05 09:03:07Z gcosmo $
|
||||
//
|
||||
//
|
||||
// G4TransportationManager
|
||||
@@ -47,7 +47,8 @@
|
||||
|
||||
// Initialise the static instance of the singleton
|
||||
//
|
||||
G4TransportationManager* G4TransportationManager::fTransportationManager=0;
|
||||
G4ThreadLocal G4TransportationManager*
|
||||
G4TransportationManager::fTransportationManager=0;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Constructor
|
||||
@@ -85,6 +86,10 @@ G4TransportationManager::~G4TransportationManager()
|
||||
ClearNavigators();
|
||||
delete fGeomMessenger;
|
||||
delete fSafetyHelper;
|
||||
if (fTransportationManager)
|
||||
{
|
||||
delete fTransportationManager; fTransportationManager=0;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -94,10 +99,10 @@ G4TransportationManager::~G4TransportationManager()
|
||||
//
|
||||
G4TransportationManager* G4TransportationManager::GetTransportationManager()
|
||||
{
|
||||
static G4TransportationManager theInstance;
|
||||
if (!fTransportationManager)
|
||||
fTransportationManager = &theInstance;
|
||||
|
||||
{
|
||||
fTransportationManager = new G4TransportationManager;
|
||||
}
|
||||
return fTransportationManager;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4VIntersectionLocator.cc 66872 2013-01-15 01:25:57Z japost $
|
||||
//
|
||||
// Class G4VIntersectionLocator implementation
|
||||
//
|
||||
@@ -267,8 +267,8 @@ ReEstimateEndpoint( const G4FieldTrack& CurrentStateA,
|
||||
#else
|
||||
// Statistics on the RMS value of the corrections
|
||||
|
||||
static G4int noCorrections=0;
|
||||
static G4double sumCorrectionsSq = 0;
|
||||
static G4ThreadLocal G4int noCorrections=0;
|
||||
static G4ThreadLocal G4double sumCorrectionsSq = 0;
|
||||
noCorrections++;
|
||||
if( goodAdvance )
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4VoxelNavigation.cc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4VoxelNavigation Implementation
|
||||
@@ -575,10 +575,10 @@ G4VoxelNavigation::ComputeSafety(const G4ThreeVector& localPoint,
|
||||
|
||||
if( motherSafety == 0.0 )
|
||||
{
|
||||
#ifdef G4DEBUG_NAVIGATION
|
||||
// Check that point is inside mother volume
|
||||
EInside insideMother= motherSolid->Inside(localPoint);
|
||||
|
||||
#if 1 // def G4DEBUG_NAVIGATION
|
||||
if( insideMother == kOutside )
|
||||
{
|
||||
G4ExceptionDescription message;
|
||||
@@ -597,10 +597,10 @@ G4VoxelNavigation::ComputeSafety(const G4ThreeVector& localPoint,
|
||||
JustWarning, // FatalException,
|
||||
message);
|
||||
}
|
||||
#endif
|
||||
#if 1 // def G4DEBUG_NAVIGATION
|
||||
|
||||
// Following check is NOT for an issue - it is only for information
|
||||
// It is allowed that a solid gives approximate safety - even zero.
|
||||
//
|
||||
if( insideMother == kInside ) // && fVerbose )
|
||||
{
|
||||
G4ExceptionDescription messageIn;
|
||||
|
||||
@@ -345,7 +345,8 @@ G4VoxelSafety::SafetyForVoxelHeader( const G4SmartVoxelHeader* pHeader,
|
||||
sampleProxy = targetVoxelHeader->GetSlice(targetNodeNo);
|
||||
|
||||
#ifdef G4DEBUG_NAVIGATION
|
||||
if( fVerbose > 2 )
|
||||
assert( sampleProxy != 0);
|
||||
if( fVerbose > 2 )
|
||||
{
|
||||
G4cout << " -Checking node " << targetNodeNo
|
||||
<< " is proxy with address " << sampleProxy << G4endl;
|
||||
@@ -429,12 +430,15 @@ G4VoxelSafety::SafetyForVoxelHeader( const G4SmartVoxelHeader* pHeader,
|
||||
//
|
||||
if( targetNodeNo >= pointNodeNo )
|
||||
{
|
||||
nextUp = trialUp;
|
||||
distUp = targetHeaderMax-localCrd ;
|
||||
if( distUp < 0.0 )
|
||||
{
|
||||
distUp = DBL_MAX; // On the wrong side - must not be considered
|
||||
}
|
||||
nextUp = trialUp;
|
||||
// distUp = std::max( targetHeaderMax-localCrd, 0.0 );
|
||||
G4double lowerEdgeOfNext = targetHeaderMin
|
||||
+ nextUp * targetHeaderNodeWidth;
|
||||
distUp = lowerEdgeOfNext-localCrd ;
|
||||
if( distUp < 0.0 )
|
||||
{
|
||||
distUp = DBL_MAX; // On the wrong side - must not be considered
|
||||
}
|
||||
#ifdef G4DEBUG_NAVIGATION
|
||||
if( fVerbose > 2 )
|
||||
{
|
||||
@@ -445,12 +449,15 @@ G4VoxelSafety::SafetyForVoxelHeader( const G4SmartVoxelHeader* pHeader,
|
||||
|
||||
if( targetNodeNo <= pointNodeNo )
|
||||
{
|
||||
nextDown = trialDown;
|
||||
distDown = localCrd-targetHeaderMin;
|
||||
if( distDown < 0.0 )
|
||||
{
|
||||
distDown= DBL_MAX; // On the wrong side - must not be considered
|
||||
}
|
||||
nextDown = trialDown;
|
||||
// distDown = std::max( localCrd-targetHeaderMin, 0.0);
|
||||
G4double upperEdgeOfNext = targetHeaderMin
|
||||
+ (nextDown+1) * targetHeaderNodeWidth;
|
||||
distDown = localCrd-upperEdgeOfNext;
|
||||
if( distDown < 0.0 )
|
||||
{
|
||||
distDown= DBL_MAX; // On the wrong side - must not be considered
|
||||
}
|
||||
#ifdef G4DEBUG_NAVIGATION
|
||||
if( fVerbose > 2 )
|
||||
{
|
||||
@@ -479,7 +486,8 @@ G4VoxelSafety::SafetyForVoxelHeader( const G4SmartVoxelHeader* pHeader,
|
||||
G4bool UpIsClosest;
|
||||
UpIsClosest= distUp < distDown;
|
||||
|
||||
if( UpIsClosest || (nextDown < 0) )
|
||||
if( (nextUp < targetHeaderNoSlices)
|
||||
&& (UpIsClosest || (nextDown < 0)) )
|
||||
{
|
||||
nextNodeNo=nextUp;
|
||||
distAxis = distUp;
|
||||
@@ -516,6 +524,7 @@ G4VoxelSafety::SafetyForVoxelHeader( const G4SmartVoxelHeader* pHeader,
|
||||
targetNodeNo= nextNodeNo;
|
||||
|
||||
#ifdef G4DEBUG_NAVIGATION
|
||||
assert( targetVoxelHeader->GetSlice(nextNodeNo) != 0 );
|
||||
G4bool bContinue= (distAxis<minSafety);
|
||||
if( !bContinue )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user