8 modified files
lcdd/src
diff -u -r1.3 -r1.4
--- G4GridXYZSegmentation.cc 6 May 2005 21:32:48 -0000 1.3
+++ G4GridXYZSegmentation.cc 1 Apr 2008 19:52:47 -0000 1.4
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4GridXYZSegmentation.cc,v 1.3 2005/05/06 21:32:48 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/G4GridXYZSegmentation.cc,v 1.4 2008/04/01 19:52:47 wenzel Exp $
#include "G4GridXYZSegmentation.hh"
#include "ReadoutUtil.hh"
@@ -58,6 +58,20 @@
return globalCellPos;
}
+G4ThreeVector G4GridXYZSegmentation::getGlobalHitPos(const G4StepPoint* aPreStepPoint)
+{
+ G4ThreeVector globalStepPos = aPreStepPoint->GetPosition();
+ // figure local step pos using touchable and global midpoint
+ G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aPreStepPoint,globalStepPos);
+
+ // local cell pos
+ G4ThreeVector localCellPos = this->getLocalHitPos( localStepPos );
+
+ // global cell pos
+ G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal( aPreStepPoint, localCellPos );
+
+ return globalCellPos;
+}
void G4GridXYZSegmentation::setBins(const G4Step* aStep)
{
@@ -84,7 +98,30 @@
++idx;
// }
}
+void G4GridXYZSegmentation::G4GridXYZSegmentation::setBins(const G4StepPoint* aPreStepPointconst)
+{
+ G4ThreeVector globalStepPos = aPreStepPointconst->GetPosition();
+ int binX = computeBinX( globalStepPos );
+ int binY = computeBinY( globalStepPos );
+ int binZ = computeBinZ( globalStepPos );
+
+ int idx=0;
+ // if ( m_gridSizeX > 0 ) {
+ setBin( idx, binX );
+ ++idx;
+ // }
+
+ // if ( m_gridSizeY > 0 ) {
+ setBin( idx, binY );
+ ++idx;
+ // }
+
+ // if ( m_gridSizeZ > 0 ) {
+ setBin( idx, binZ );
+ ++idx;
+ // }
+}
int G4GridXYZSegmentation::computeBinX(const G4ThreeVector& localStepPos)
{
int ret;
lcdd/src
diff -u -r1.13 -r1.14
--- G4NonprojectiveCylinderSegmentation.cc 27 Jun 2005 20:40:34 -0000 1.13
+++ G4NonprojectiveCylinderSegmentation.cc 1 Apr 2008 19:52:47 -0000 1.14
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4NonprojectiveCylinderSegmentation.cc,v 1.13 2005/06/27 20:40:34 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/G4NonprojectiveCylinderSegmentation.cc,v 1.14 2008/04/01 19:52:47 wenzel Exp $
#include "G4NonprojectiveCylinderSegmentation.hh"
#include "ReadoutUtil.hh"
@@ -35,7 +35,21 @@
return localCellPos;
}
+G4ThreeVector G4NonprojectiveCylinderSegmentation::getGlobalHitPos(const G4StepPoint* aPreStepPoint)
+{
+ // local cell pos
+ G4ThreeVector localCellPos = getLocalHitPos( aPreStepPoint );
+
+ // global cell pos
+ G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal( aPreStepPoint, localCellPos );
+ // DEBUG: print local, global cell pos
+ //G4cout << "localCellPos " << localCellPos << G4endl;
+ //G4cout << "globalCellPos " << globalCellPos << G4endl;
+ //
+
+ return localCellPos;
+}
G4ThreeVector G4NonprojectiveCylinderSegmentation::getLocalHitPos(const G4Step* aStep)
{
G4ThreeVector globalMidPos = ReadoutUtil::computeMidPos( aStep );
@@ -80,6 +94,50 @@
return cellCenter;
}
+G4ThreeVector G4NonprojectiveCylinderSegmentation::getLocalHitPos(const G4StepPoint* aPreStepPoint)
+{
+ G4ThreeVector globalPos = aPreStepPoint->GetPosition() ;
+
+ // retrieve G4Tubs
+ const G4Tubs* tubs = ReadoutUtil::getTubs( aPreStepPoint );
+
+ assert( tubs );
+
+ // rcyl of cell = mid rad of current tubs
+ double rcyl = ReadoutUtil::computeTubsMidRadius( tubs );
+
+ // compute single delta phi in degrees
+ double deltaPhi = computeDeltaPhi( aPreStepPoint );
+
+ // phi index
+ int iphi = computeBinPhi( aPreStepPoint );
+
+ // z index in local
+ int iz = computeBinZ( ReadoutUtil::transformGlobalToLocal( aPreStepPoint, globalPos ) );
+
+ // compute cell Z, phi
+ double cellPhi = computeDim( iphi, deltaPhi );
+ double cellZ = computeDim( iz, m_gridSizeZ);
+
+ // compute X, Y
+ double cellX = rcyl * cos( cellPhi );
+ double cellY = rcyl * sin( cellPhi );
+
+ G4ThreeVector cellCenter( cellX, cellY, cellZ );
+
+ // DEBUG: print all
+ //G4cout << G4endl;
+ //G4cout << "rcyl <" << rcyl << ">" << G4endl;
+ //G4cout << "deltaPhi <" << deltaPhi << ">" << G4endl;
+ //G4cout << "iphi <" << iphi << ">" << G4endl;
+ //G4cout << "iz <" << iz << ">" << G4endl;
+ //G4cout << "cellPhi <" << cellPhi << ">" << G4endl;
+ //G4cout << "cellCenter " << cellCenter << G4endl;
+ //G4cout << G4endl;
+ //
+
+ return cellCenter;
+}
double G4NonprojectiveCylinderSegmentation::computeDeltaPhi(const G4Step* aStep)
{
@@ -97,7 +155,22 @@
return deltaPhi;
}
+double G4NonprojectiveCylinderSegmentation::computeDeltaPhi(const G4StepPoint* aPreStepPoint)
+{
+ // mid radius of current tubs
+ double mid_rad_layer = ReadoutUtil::computeTubsMidRadius( aPreStepPoint );
+
+ // circumference of current tubs
+ double circ = 2.0 * ReadoutUtil::PI * mid_rad_layer;
+ // number of cells along phi in curr layer
+ int nphi = (int)floor( circ / m_gridSizePhi );
+
+ // single phi division in degrees
+ double deltaPhi = ( 360.0 * deg ) / nphi;
+
+ return deltaPhi;
+}
void G4NonprojectiveCylinderSegmentation::setBins(const G4Step* aStep)
{
//G4cout << "G4NonprojectiveCylinderSegmentation::setBins()" << G4endl;
@@ -110,7 +183,18 @@
setBin( 0, bphi );
setBin( 1, bz );
}
+void G4NonprojectiveCylinderSegmentation::setBins(const G4StepPoint* aPreStepPoint)
+{
+ //G4cout << "G4NonprojectiveCylinderSegmentation::setBins()" << G4endl;
+
+ G4ThreeVector globalPos = aPreStepPoint->GetPosition();
+ int bphi = computeBinPhi( aPreStepPoint );
+ int bz = computeBinZ( globalPos );
+
+ setBin( 0, bphi );
+ setBin( 1, bz );
+}
int G4NonprojectiveCylinderSegmentation::computeBinPhi(const G4Step* aStep)
{
G4ThreeVector globalMidPos = ReadoutUtil::computeMidPos( aStep );
@@ -132,6 +216,28 @@
return computeBin( stepPhi, deltaPhi / radian );
}
+int G4NonprojectiveCylinderSegmentation::computeBinPhi(const G4StepPoint* aPreStepPoint)
+{
+ G4ThreeVector globalPos = aPreStepPoint->GetPosition();
+
+ const G4Tubs* tubs = ReadoutUtil::getTubs( aPreStepPoint );
+ assert( tubs );
+
+ // compute single delta phi in degrees
+ double deltaPhi = computeDeltaPhi( aPreStepPoint );
+
+ // step phi
+ double stepPhi = globalPos.phi();
+
+ if ( stepPhi<0 ) {
+ stepPhi += 2.0 * ReadoutUtil::PI;
+ }
+
+ // phi index
+ return computeBin( stepPhi, deltaPhi / radian );
+}
+
+
int G4NonprojectiveCylinderSegmentation::computeBinZ(const G4ThreeVector& localStepPos)
{
//G4cout << "localStepPos.z() <" << localStepPos.z() << ">" << G4endl;
lcdd/src
diff -u -r1.4 -r1.5
--- G4OpticalCalorimeter.cc 18 Feb 2008 20:57:01 -0000 1.4
+++ G4OpticalCalorimeter.cc 1 Apr 2008 19:52:47 -0000 1.5
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4OpticalCalorimeter.cc,v 1.4 2008/02/18 20:57:01 wenzel Exp $
+// $Header: /cvs/lcd/lcdd/src/G4OpticalCalorimeter.cc,v 1.5 2008/04/01 19:52:47 wenzel Exp $
#include "G4OpticalCalorimeterSD.hh"
@@ -89,9 +89,10 @@
aTrack->SetTrackStatus(fStopAndKill);
return false;
}
- G4ThreeVector myPoint = aStep->GetPreStepPoint()->GetPosition();
- G4Navigator* theNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
- G4VPhysicalVolume* myVolume = theNavigator->LocateGlobalPointAndSetup(myPoint);
+ G4ThreeVector myPoint = aStep->GetPreStepPoint()->GetPosition();
+ G4StepPoint* apreStepPoint = aStep->GetPreStepPoint();
+ G4Navigator* theNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
+ G4VPhysicalVolume* myVolume = theNavigator->LocateGlobalPointAndSetup(myPoint);
if ( getVerbose() > 2 ) {
G4cout << "Physical volume = " << myVolume->GetName() << G4endl;
@@ -103,13 +104,13 @@
G4double theEdep = aTrack->GetTotalEnergy();
// get global cell pos from seg
- G4ThreeVector globalCellPos = m_segmentation->getGlobalHitPos( aStep );
+ G4ThreeVector globalCellPos = m_segmentation->getGlobalHitPos( apreStepPoint);
// reset the seg bins
m_segmentation->resetBins();
// set the seg bins
- m_segmentation->setBins(aStep);
+ m_segmentation->setBins(apreStepPoint);
// create id and pack into 64
Id64bit id64 = makeId();
lcdd/src
diff -u -r1.8 -r1.9
--- G4ProjectiveCylinderSegmentation.cc 27 Jun 2005 20:40:34 -0000 1.8
+++ G4ProjectiveCylinderSegmentation.cc 1 Apr 2008 19:52:47 -0000 1.9
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4ProjectiveCylinderSegmentation.cc,v 1.8 2005/06/27 20:40:34 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/G4ProjectiveCylinderSegmentation.cc,v 1.9 2008/04/01 19:52:47 wenzel Exp $
#include "G4ProjectiveCylinderSegmentation.hh"
#include "ReadoutUtil.hh"
@@ -20,7 +20,10 @@
{
return ReadoutUtil::computeTubsMidRadius( ReadoutUtil::getTubs( aStep ) );
}
-
+double G4ProjectiveCylinderSegmentation::getRadius(const G4StepPoint* aPreStepPoint)
+{
+ return ReadoutUtil::computeTubsMidRadius( ReadoutUtil::getTubs( aPreStepPoint ) );
+}
double G4ProjectiveCylinderSegmentation::getZ(const G4Step* aStep)
{
double rcyl = getRadius( aStep );
@@ -34,7 +37,19 @@
return zcell;
}
+double G4ProjectiveCylinderSegmentation::getZ(const G4StepPoint* aPreStepPoint)
+{
+ double rcyl = getRadius( aPreStepPoint );
+
+ double ctheta = getThetaDim( aPreStepPoint );
+
+ // ctheta in 0 to pi ...
+ // ctheta < pi/2 should be negative
+
+ double zcell = rcyl / tan( ctheta );
+ return zcell;
+}
bool G4ProjectiveCylinderSegmentation::isValidSolid(G4VSolid* s)
{
bool valid = G4Segmentation::isValidSolid(s);
lcdd/src
diff -u -r1.9 -r1.10
--- G4ProjectiveSegmentation.cc 8 Feb 2005 03:18:09 -0000 1.9
+++ G4ProjectiveSegmentation.cc 1 Apr 2008 19:52:47 -0000 1.10
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4ProjectiveSegmentation.cc,v 1.9 2005/02/08 03:18:09 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/G4ProjectiveSegmentation.cc,v 1.10 2008/04/01 19:52:47 wenzel Exp $
#include "G4ProjectiveSegmentation.hh"
#include "ReadoutUtil.hh"
@@ -68,15 +68,64 @@
return pos;
}
+G4ThreeVector G4ProjectiveSegmentation::getGlobalHitPos(const G4StepPoint* aPreStepPoint)
+{
+ // DEBUG
+ //G4cout << "G4ProjectiveSegmentation::getGlobalHitPos()" << G4endl;
+ //
+
+ // divide entire theta, phi range into bins; bins always positive
+ // theta, phi coord of step midpoint
+ // compute bin numbers
+ // get dim from bins
+
+ // get radius, z components (probably from subclass function)
+ double rcyl = getRadius( aPreStepPoint );
+ double zcell = getZ( aPreStepPoint );
+
+ // get phi component
+ double cphi = getPhiDim( aPreStepPoint );
+
+ // compute x, y cells
+ double xcell = rcyl * cos( cphi );
+ double ycell = rcyl * sin( cphi );
+
+ G4ThreeVector pos( xcell, ycell, zcell);
+
+ //G4ThreeVector midPos = ReadoutUtil::computeMidPos( aStep );
+
+ // DEBUG: print all
+ //G4cout << "sphi <" << midPos.phi() << ">" << G4endl;
+ //G4cout << "cphi <" << cphi << ">" << G4endl;
+ //G4cout << "sphi - cphi = " << midPos.phi() - cphi << G4endl;
+
+ //G4cout << "stheta <" << midPos.theta() << ">" << G4endl;
+ //G4cout << "ctheta <" << getThetaDim( aStep ) << ">" << G4endl;
+ //G4cout << "stheta - ctheta = " << midPos.theta() - getThetaDim( aStep ) << G4endl;
+ //G4cout << "rcyl <" << rcyl << ">" << G4endl;
+ //G4cout << "zcell <" << zcell << ">" << G4endl;
+ //G4cout << "globalCellPos <" << pos << ">" << G4endl;
+ //
+
+ return pos;
+}
void G4ProjectiveSegmentation::setBins(const G4Step* aStep)
{
G4ThreeVector globalMidPos = ReadoutUtil::computeMidPos( aStep );
-
+
setBin( 0, getThetaBin( globalMidPos ) );
setBin( 1, getPhiBin( globalMidPos ) );
}
+void G4ProjectiveSegmentation::setBins(const G4StepPoint* aPreStepPoint)
+{
+ G4ThreeVector globalPos = aPreStepPoint->GetPosition();
+
+ setBin( 0, getThetaBin( globalPos ) );
+ setBin( 1, getPhiBin( globalPos ) );
+}
+
G4int G4ProjectiveSegmentation::getNtheta() const
{
return m_ntheta;
@@ -125,6 +174,11 @@
return ReadoutUtil::computeMidPos( aStep ).mag();
}
+double G4ProjectiveSegmentation::getRadius(const G4StepPoint* aPreStepPoint)
+{
+ //G4cout << "G4ProjectiveSegmentation::getRadius()" << G4endl;
+ return aPreStepPoint->GetPosition().mag();
+}
// default impl. returns z of pos
double G4ProjectiveSegmentation::getZ(const G4Step* aStep)
@@ -133,6 +187,12 @@
return ReadoutUtil::computeMidPos( aStep ).z();
}
+double G4ProjectiveSegmentation::getZ(const G4StepPoint* aPreStepPoint)
+{
+ //G4cout << "G4ProjectiveSegmentation::getZ()" << G4endl;
+ return aPreStepPoint->GetPosition().z();
+}
+
double G4ProjectiveSegmentation::getThetaDim(const int &thetaBin) const
{
return G4Segmentation::computeDim(thetaBin,
@@ -149,12 +209,19 @@
double G4ProjectiveSegmentation::getThetaDim(const G4Step* aStep)
{
//G4cout << "G4ProjectiveSegmentation::getThetaDim(G4Step*)" << G4endl;
-
G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos( aStep );
double ctheta = getThetaDim( getThetaBin( globalStepPos ) );
return ctheta;
}
+double G4ProjectiveSegmentation::getThetaDim(const G4StepPoint* aPreStepPoint)
+{
+ //G4cout << "G4ProjectiveSegmentation::getThetaDim(G4Step*)" << G4endl;
+ G4ThreeVector globalStepPos = aPreStepPoint->GetPosition();
+ double ctheta = getThetaDim( getThetaBin( globalStepPos ) );
+ return ctheta;
+}
+
double G4ProjectiveSegmentation::getPhiDim(const G4Step* aStep)
{
//G4cout << "G4ProjectiveSegmentation::getPhiDim(G4Step*)" << G4endl;
@@ -163,4 +230,12 @@
double cphi = getPhiDim( getPhiBin( globalStepPos ) );
return cphi;
}
+double G4ProjectiveSegmentation::getPhiDim(const G4StepPoint* aPreStepPoint)
+{
+ //G4cout << "G4ProjectiveSegmentation::getPhiDim(G4Step*)" << G4endl;
+
+ G4ThreeVector globalStepPos = aPreStepPoint->GetPosition();
+ double cphi = getPhiDim( getPhiBin( globalStepPos ) );
+ return cphi;
+}
lcdd/src
diff -u -r1.2 -r1.3
--- G4ProjectiveZPlaneSegmentation.cc 12 Jan 2005 01:32:58 -0000 1.2
+++ G4ProjectiveZPlaneSegmentation.cc 1 Apr 2008 19:52:47 -0000 1.3
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4ProjectiveZPlaneSegmentation.cc,v 1.2 2005/01/12 01:32:58 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/G4ProjectiveZPlaneSegmentation.cc,v 1.3 2008/04/01 19:52:47 wenzel Exp $
#include "G4ProjectiveZPlaneSegmentation.hh"
@@ -24,6 +24,18 @@
return rcyl;
}
+double G4ProjectiveZPlaneSegmentation::getRadius(const G4StepPoint* aPreStepPoint)
+{
+ //G4cout << "G4ProjectiveZPlaneSegmentation::getRadius()" << G4endl;
+
+ double zcell = getZ( aPreStepPoint );
+
+ double ctheta = G4ProjectiveSegmentation::getThetaDim( aPreStepPoint );
+
+ double rcyl = zcell * tan( ctheta );
+
+ return rcyl;
+}
double G4ProjectiveZPlaneSegmentation::getZ(const G4Step* aStep)
{
@@ -33,3 +45,12 @@
G4ThreeVector gpos = ReadoutUtil::getVolumeGlobalPosition( aStep->GetPreStepPoint(), G4ThreeVector() );
return gpos.z();
}
+
+double G4ProjectiveZPlaneSegmentation::getZ(const G4StepPoint* aPreStepPoint)
+{
+
+ //G4cout << "G4ProjectiveZPlaneSegmentation::getZ()" << G4endl;
+
+ G4ThreeVector gpos = ReadoutUtil::getVolumeGlobalPosition( aPreStepPoint, G4ThreeVector() );
+ return gpos.z();
+}
lcdd/src
diff -u -r1.9 -r1.10
--- G4Segmentation.cc 27 Jun 2005 20:40:34 -0000 1.9
+++ G4Segmentation.cc 1 Apr 2008 19:52:47 -0000 1.10
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4Segmentation.cc,v 1.9 2005/06/27 20:40:34 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/G4Segmentation.cc,v 1.10 2008/04/01 19:52:47 wenzel Exp $
#include "G4Segmentation.hh"
#include "ReadoutUtil.hh"
@@ -43,6 +43,12 @@
return ReadoutUtil::computeMidPos( aStep );
}
+G4ThreeVector G4Segmentation::getGlobalHitPos(const G4StepPoint* aPreStepPoint)
+{
+ //dummy routine
+ return aPreStepPoint->GetPosition();
+}
+
void G4Segmentation::resetBins()
{
m_bins.clear();
lcdd/src
diff -u -r1.11 -r1.12
--- ReadoutUtil.cc 6 Oct 2007 00:40:59 -0000 1.11
+++ ReadoutUtil.cc 1 Apr 2008 19:52:47 -0000 1.12
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/ReadoutUtil.cc,v 1.11 2007/10/06 00:40:59 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/ReadoutUtil.cc,v 1.12 2008/04/01 19:52:47 wenzel Exp $
#include "ReadoutUtil.hh"
#include <cmath>
@@ -72,7 +72,20 @@
}
return tubs;
}
+const G4Tubs* ReadoutUtil::getTubs(const G4StepPoint* aPreStepPoint)
+{
+ const G4Tubs* tubs = 0;
+ G4VSolid* solid = ReadoutUtil::getSolidFromStepPoint( aPreStepPoint);
+ 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 );
@@ -84,6 +97,10 @@
{
return computeTubsMidRadius( ReadoutUtil::getTubs( aStep ) );
}
+double ReadoutUtil::computeTubsMidRadius(const G4StepPoint* aPreStepPoint)
+{
+ return computeTubsMidRadius( ReadoutUtil::getTubs( aPreStepPoint ) );
+}
double ReadoutUtil::getTubsThickness(const G4Tubs* tubs)
{
@@ -101,7 +118,17 @@
return globalPos;
}
+G4ThreeVector ReadoutUtil::transformLocalToGlobal(const G4StepPoint* aPreStepPoint,
+ const G4ThreeVector& localPos)
+{
+ // get touchable from PreStepPoint
+ G4TouchableHandle theTouchable = aPreStepPoint->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)
{
@@ -113,6 +140,17 @@
return localPos;
}
+G4ThreeVector ReadoutUtil::transformGlobalToLocal(const G4StepPoint* aPreStepPoint,
+ const G4ThreeVector& globalPos)
+{
+ // get touchable from PreStepPoint
+ G4TouchableHandle theTouchable = aPreStepPoint->GetTouchableHandle();
+
+ // compute local pos using global point and touchable
+ G4ThreeVector localPos = theTouchable->GetHistory()->GetTopTransform().TransformPoint( globalPos );
+
+ return localPos;
+}
std::vector<G4VPhysicalVolume*> ReadoutUtil::getPhysVolList( G4Step* aStep )
{
CVSspam 0.2.8