lcdd/src
diff -u -r1.5 -r1.6
--- ReadoutUtil.cc 16 Jun 2005 00:12:33 -0000 1.5
+++ ReadoutUtil.cc 23 Jun 2005 23:42:20 -0000 1.6
@@ -1,6 +1,102 @@
-// $Header: /cvs/lcd/lcdd/src/ReadoutUtil.cc,v 1.5 2005/06/16 00:12:33 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/ReadoutUtil.cc,v 1.6 2005/06/23 23:42:20 jeremy Exp $
#include "ReadoutUtil.hh"
#include <cmath>
const double ReadoutUtil::PI = acos(-1);
+
+G4ThreeVector ReadoutUtil::computeThreeVectorMean(const G4ThreeVector& vec1,
+ const G4ThreeVector& vec2)
+{
+ return (0.5 * (vec1 + vec2 ) );
+}
+
+G4ThreeVector ReadoutUtil::computeMidPos(const G4Step* aStep)
+{
+ return computeThreeVectorMean( aStep->GetPreStepPoint()->GetPosition(),
+ aStep->GetPostStepPoint()->GetPosition() );
+}
+
+G4VSolid* ReadoutUtil::getSolidFromStepPoint(const G4StepPoint* aStepPoint)
+{
+ assert( aStepPoint );
+
+ return aStepPoint->GetTouchableHandle()->GetVolume()->GetLogicalVolume()
+ ->GetSolid();
+}
+
+G4TouchableHandle ReadoutUtil::getTouchableFromStep(const G4Step* aStep)
+{
+ return aStep->GetPreStepPoint()->GetTouchableHandle();
+}
+
+G4ThreeVector ReadoutUtil::getVolumeGlobalPosition(const G4StepPoint* aStepPoint,
+ const G4ThreeVector& pnt )
+{
+ return aStepPoint->GetTouchableHandle()->GetHistory()->GetTopTransform().Inverse().
+ TransformPoint( pnt );
+}
+
+G4ThreeVector ReadoutUtil::getVolumeGlobalPosition(const G4StepPoint* aStepPoint)
+{
+ return getVolumeGlobalPosition( aStepPoint, G4ThreeVector() );
+}
+
+const G4Tubs* ReadoutUtil::getTubs(const G4Step* aStep)
+{
+ const G4Tubs* tubs = 0;
+ G4VSolid* solid = ReadoutUtil::getSolidFromStepPoint( aStep->GetPreStepPoint() );
+ G4String solidType = solid->GetEntityType();
+
+ if ( solidType == "G4Tubs" ) {
+ tubs = static_cast<const G4Tubs*> ( solid );
+ }
+ else {
+ G4Exception("ReadoutUtil::getTubs() - G4VSolid from the step is not a tubs.");
+ }
+ return tubs;
+}
+
+double ReadoutUtil::computeTubsMidRadius(const G4Tubs* tubs)
+{
+ double thickness = getTubsThickness( tubs );
+ double rcyl = tubs->GetInnerRadius() + thickness / 2;
+ return rcyl;
+}
+
+double ReadoutUtil::computeTubsMidRadius(const G4Step* aStep)
+{
+ return computeTubsMidRadius( ReadoutUtil::getTubs( aStep ) );
+}
+
+double ReadoutUtil::getTubsThickness(const G4Tubs* tubs)
+{
+ double irad = tubs->GetInnerRadius();
+ double orad = tubs->GetOuterRadius();
+ double thickness = orad - irad;
+ return thickness;
+}
+
+G4ThreeVector ReadoutUtil::transformLocalToGlobal(const G4Step* aStep,
+ const G4ThreeVector& localPos)
+{
+ // get touchable from PreStepPoint
+ G4TouchableHandle theTouchable = aStep->GetPreStepPoint()->GetTouchableHandle();
+
+ // compute global pos using local point and touchable
+ G4ThreeVector globalPos = theTouchable->GetHistory()->GetTopTransform().Inverse().TransformPoint( localPos );
+
+ return globalPos;
+}
+
+G4ThreeVector ReadoutUtil::transformGlobalToLocal(const G4Step* aStep,
+ const G4ThreeVector& globalPos)
+{
+ // get touchable from PreStepPoint
+ G4TouchableHandle theTouchable = aStep->GetPreStepPoint()->GetTouchableHandle();
+
+ // compute local pos using global point and touchable
+ G4ThreeVector localPos = theTouchable->GetHistory()->GetTopTransform().TransformPoint( globalPos );
+
+ return localPos;
+}
lcdd/include
diff -u -r1.9 -r1.10
--- ReadoutUtil.hh 16 Jun 2005 00:12:32 -0000 1.9
+++ ReadoutUtil.hh 23 Jun 2005 23:42:20 -0000 1.10
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/ReadoutUtil.hh,v 1.9 2005/06/16 00:12:32 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/ReadoutUtil.hh,v 1.10 2005/06/23 23:42:20 jeremy Exp $
#ifndef ReadoutUtil_hh
#define ReadoutUtil_hh 1
@@ -35,102 +35,34 @@
public:
static G4ThreeVector computeThreeVectorMean(const G4ThreeVector& vec1,
- const G4ThreeVector& vec2)
- {
- return (0.5 * (vec1 + vec2 ) );
- }
-
- static G4ThreeVector computeMidPos(const G4Step* aStep)
- {
- return computeThreeVectorMean( aStep->GetPreStepPoint()->GetPosition(),
- aStep->GetPostStepPoint()->GetPosition() );
- }
-
- inline static G4VSolid* getSolidFromStepPoint(const G4StepPoint* aStepPoint)
- {
- assert( aStepPoint );
-
- return aStepPoint->GetTouchableHandle()->GetVolume()->GetLogicalVolume()
- ->GetSolid();
- }
-
- inline static G4TouchableHandle getTouchableFromStep(const G4Step* aStep)
- {
- return aStep->GetPreStepPoint()->GetTouchableHandle();
- }
-
- inline static G4ThreeVector getVolumeGlobalPosition(const G4StepPoint* aStepPoint,
- const G4ThreeVector& pnt )
- {
- return aStepPoint->GetTouchableHandle()->GetHistory()->GetTopTransform().Inverse().
- TransformPoint( pnt );
- }
-
- inline static G4ThreeVector getVolumeGlobalPosition(const G4StepPoint* aStepPoint)
- {
- return getVolumeGlobalPosition( aStepPoint, G4ThreeVector() );
- }
-
- inline static const G4Tubs* getTubs(const G4Step* aStep)
- {
- const G4Tubs* tubs = 0;
- G4VSolid* solid = ReadoutUtil::getSolidFromStepPoint( aStep->GetPreStepPoint() );
- G4String solidType = solid->GetEntityType();
-
- if ( solidType == "G4Tubs" ) {
- tubs = static_cast<const G4Tubs*> ( solid );
- }
- else {
- std::cerr << "Solid is not a tubs!" << std::endl;
- }
- return tubs;
- }
-
- inline static double computeTubsMidRadius(const G4Tubs* tubs)
- {
- double thickness = getTubsThickness( tubs );
- double rcyl = tubs->GetInnerRadius() + thickness / 2;
- return rcyl;
- }
-
- inline static double getTubsThickness(const G4Tubs* tubs)
- {
- double irad = tubs->GetInnerRadius();
- double orad = tubs->GetOuterRadius();
- double thickness = orad - irad;
- return thickness;
- }
-
- inline static G4ThreeVector transformLocalToGlobal(const G4Step* aStep,
- const G4ThreeVector& localPos)
- {
- // get touchable from PreStepPoint
- G4TouchableHandle theTouchable = aStep->GetPreStepPoint()->GetTouchableHandle();
-
- // compute global pos using local point and touchable
- G4ThreeVector globalPos = theTouchable->GetHistory()->GetTopTransform().Inverse().TransformPoint( localPos );
-
- return globalPos;
- }
-
- inline static G4ThreeVector transformGlobalToLocal(const G4Step* aStep,
- const G4ThreeVector& globalPos)
- {
- // get touchable from PreStepPoint
- G4TouchableHandle theTouchable = aStep->GetPreStepPoint()->GetTouchableHandle();
-
- // compute local pos using global point and touchable
- G4ThreeVector localPos = theTouchable->GetHistory()->GetTopTransform().TransformPoint( globalPos );
+ const G4ThreeVector& vec2);
- return localPos;
- }
+ static G4ThreeVector computeMidPos(const G4Step* aStep);
- //static std::vector<int> getPhysVolIdStack( const G4Step* aStep );
+ static G4VSolid* getSolidFromStepPoint(const G4StepPoint* aStepPoint);
- static std::vector<G4VPhysicalVolume*> getPhysVolList( const G4Step* aStep );
+ static G4TouchableHandle getTouchableFromStep(const G4Step* aStep);
- static void printOutPhysVolIds(std::ostream& os, const std::vector<int>& ids);
+ static G4ThreeVector getVolumeGlobalPosition(const G4StepPoint* aStepPoint,
+ const G4ThreeVector& pnt );
+
+ static G4ThreeVector getVolumeGlobalPosition(const G4StepPoint* aStepPoint);
+
+
+ static const G4Tubs* getTubs(const G4Step* aStep);
+
+ static double computeTubsMidRadius(const G4Tubs* tubs);
+
+ static double computeTubsMidRadius(const G4Step* aStep);
+
+ static double getTubsThickness(const G4Tubs* tubs);
+
+ static G4ThreeVector transformLocalToGlobal(const G4Step* aStep,
+ const G4ThreeVector& localPos);
+
+ static G4ThreeVector transformGlobalToLocal(const G4Step* aStep,
+ const G4ThreeVector& globalPos);
public:
static const double PI;