5 added + 10 modified, total 15 files
lcdd/include
diff -N G4GlobalGridXYSegmentation.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4GlobalGridXYSegmentation.hh 30 Oct 2009 23:16:59 -0000 1.1
@@ -0,0 +1,61 @@
+// $Header: /cvs/lcd/lcdd/include/G4GlobalGridXYSegmentation.hh,v 1.1 2009/10/30 23:16:59 jeremy Exp $
+#ifndef LCDD_G4GLOBALGRIDXYSEGMENTATION_HH
+#define LCDD_G4GLOBALGRIDXYSEGMENTATION_HH 1
+
+#include "G4Segmentation.hh"
+
+#include "globals.hh"
+
+/**
+ * @class G4GridXYSegmentation
+ * @brief Uniform 3D grid segmentation class.
+ * @note Version of grid segmentation with binning on global coordinates, not local.
+*/
+class G4GlobalGridXYSegmentation : public G4Segmentation
+{
+
+ public:
+
+ G4GlobalGridXYSegmentation(double gridSizeX,
+ double gridSizeY);
+
+ virtual ~G4GlobalGridXYSegmentation();
+
+ public:
+
+ // from par class
+ virtual G4ThreeVector getGlobalHitPos(const G4Step* aStep);
+
+ // hit position from step position
+ G4ThreeVector getLocalHitPos(const G4ThreeVector& localStepPos);
+
+ virtual void setBins(const G4Step* aStep);
+
+ virtual void setBinNames()
+ {
+ addBinName("x");
+ addBinName("y");
+ addBinName("z");
+ }
+
+
+ protected:
+
+ // compute signed int bin values with base at local origin
+ int computeBinX(const G4ThreeVector& localStepPos);
+ int computeBinY(const G4ThreeVector& localStepPos);
+ int computeBinZ(const G4ThreeVector& localStepPos);
+
+ // individual position dim from bin
+ double computeDimX(int bin);
+ double computeDimY(int bin);
+ double computeDimZ(int bin);
+
+ private:
+
+ double m_gridSizeX;
+ double m_gridSizeY;
+ double m_gridSizeZ;
+};
+
+#endif
lcdd/include
diff -N GlobalGridXYSegmentationType.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ GlobalGridXYSegmentationType.hh 30 Oct 2009 23:16:59 -0000 1.1
@@ -0,0 +1,65 @@
+// $Header: /cvs/lcd/lcdd/include/GlobalGridXYSegmentationType.hh,v 1.1 2009/10/30 23:16:59 jeremy Exp $
+
+#ifndef LCDD_GLOBALGRIDXYSEGMENTATIONTYPE_HH
+#define LCDD_GLOBALGRIDXYSEGMENTATIONTYPE_HH 1
+
+#include "SegmentationType.hh"
+
+#include <string>
+
+#include "Saxana/SAXObject.h"
+
+/**
+ * @class GlobalGridXYSegmentationType
+ * @brief GlobalGridXYSegmentation from schema.
+ */
+class GlobalGridXYSegmentationType : public SegmentationType
+{
+ public:
+
+ GlobalGridXYSegmentationType()
+ {}
+
+ virtual ~GlobalGridXYSegmentationType()
+ {}
+
+ public:
+
+ void set_gridSizeX(const std::string& gsx)
+ {
+ m_gridSizeX = gsx;
+ }
+
+ void set_gridSizeY(const std::string& gsy)
+ {
+ m_gridSizeY = gsy;
+ }
+
+ void set_lunit( const std::string& lunit)
+ {
+ m_lunit = lunit;
+ }
+
+ const std::string& get_gridSizeX()
+ {
+ return m_gridSizeX;
+ }
+
+ const std::string& get_gridSizeY()
+ {
+ return m_gridSizeY;
+ }
+
+ const std::string& get_lunit()
+ {
+ return m_lunit;
+ }
+
+ protected:
+
+ std::string m_gridSizeX;
+ std::string m_gridSizeY;
+ std::string m_lunit;
+};
+
+#endif
lcdd/include
diff -N global_grid_xy.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ global_grid_xy.hh 30 Oct 2009 23:16:59 -0000 1.1
@@ -0,0 +1,33 @@
+// $Header: /cvs/lcd/lcdd/include/global_grid_xy.hh,v 1.1 2009/10/30 23:16:59 jeremy Exp $
+#ifndef LCDD_GLOBAL_GRID_XY_HH
+#define LCDD_GLOBAL_GRID_XY_HH 1
+
+#include "GlobalGridXYSegmentationType.hh"
+
+#include <string>
+
+#include "Saxana/SAXObject.h"
+
+/**
+ @class GlobalGridXYSegmentationType
+ @brief GlobalGridXYSegmentation from schema.
+ */
+class global_grid_xy : public SAXObject, public GlobalGridXYSegmentationType
+{
+ public:
+
+ global_grid_xy()
+ {}
+
+ virtual ~global_grid_xy()
+ {}
+
+ public:
+
+ virtual SAXObject::Type type()
+ {
+ return SAXObject::element;
+ }
+};
+
+#endif
lcdd/include
diff -u -r1.8 -r1.9
--- G4GridXYZSegmentation.hh 24 Sep 2009 17:47:20 -0000 1.8
+++ G4GridXYZSegmentation.hh 30 Oct 2009 23:16:59 -0000 1.9
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/G4GridXYZSegmentation.hh,v 1.8 2009/09/24 17:47:20 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/G4GridXYZSegmentation.hh,v 1.9 2009/10/30 23:16:59 jeremy Exp $
#ifndef LCDD_G4GRIDXYZSEGMENTATION_HH
#define LCDD_G4GRIDXYZSEGMENTATION_HH 1
@@ -27,13 +27,15 @@
// from par class
virtual G4ThreeVector getGlobalHitPos(const G4Step* aStep);
- // hit position from step position
- virtual G4ThreeVector getGlobalHitPos(const G4StepPoint* aPreStepPoint);
- // hit position from step position
- G4ThreeVector getLocalHitPos(const G4ThreeVector& localStepPos);
-
+
virtual void setBins(const G4Step* aStep);
- virtual void setBins(const G4StepPoint* aPreStepPoint);
+
+ // DEPRECATED
+ virtual G4ThreeVector getGlobalHitPosPreStep(const G4StepPoint* aPreStepPoint);
+
+ // DEPRECATED
+ virtual G4ThreeVector getLocalHitPos(const G4ThreeVector& localStepPos);
+
virtual void setBinNames()
{
addBinName("x");
lcdd/include
diff -u -r1.16 -r1.17
--- G4Segmentation.hh 1 Apr 2008 19:53:02 -0000 1.16
+++ G4Segmentation.hh 30 Oct 2009 23:16:59 -0000 1.17
@@ -10,125 +10,133 @@
#include <vector>
/**
- @class G4Segmentation
- @brief Segmentation base class.
+ * @class G4Segmentation
+ * @brief Segmentation base class.
*/
class G4Segmentation
{
-public:
+ public:
+ enum EType { eProjective=1, eNonprojective };
+ typedef std::vector<std::string> BinNames;
+
+ public:
+ G4Segmentation(EType segType, int nbins = 2);
+ virtual ~G4Segmentation();
+
+ public:
+
+ /**
+ * Compute the global hit position from a step.
+ */
+ virtual G4ThreeVector getGlobalHitPos(const G4Step* aStep);
+
+ /**
+ * Set the identifier bin values from a step.
+ */
+ virtual void setBins(const G4Step*) = 0;
+
+ /**
+ * Add valid bin names to this segmentation.
+ */
+ virtual void setBinNames() = 0;
+
+ /**
+ * Compute the bin given a coordinate in one dimension.
+ */
+ static int computeBin(double localDim, double gridDim)
+ {
+ return int(floor(localDim / gridDim ) );
+
+ }
+
+ /**
+ * Compute the coordinate in one dimension given a bin value.
+ */
+ static double computeDim(const int &bin, const double &incr)
+ {
+ return (double(bin) + .5) * incr;
+ }
+
+ // DEPRECATED
+ // Used by G4OpticalCalorimeter only.
+ virtual G4ThreeVector getGlobalHitPosPreStep(const G4StepPoint* aPreStepPoint);
+
+ // DEPRECATED
+ // Used by G4OpticalCalorimeter only.
+ G4ThreeVector getLocalHitPos(const G4ThreeVector& localStepPos);
+
+ void resetBins();
+
+ EType getType();
+
+ inline const G4String& getTypeString()
+ {
+ static G4String typestr;
+ if ( m_type == eProjective ) {
+ typestr = "Projective";
+ }
+ else if ( m_type == eNonprojective ) {
+ typestr = "Nonprojective";
+ }
+ else {
+ typestr = "Unknown";
+ }
+
+ return typestr;
+ }
+
+ inline int getBin(int idx)
+ {
+ return m_bins.at( idx );
+ }
+
+ inline const std::string& getBinName(int idx)
+ {
+ return m_binNames.at(idx);
+ }
+
+ inline void addBinName(const std::string& binName)
+ {
+ m_binNames.push_back(binName);
+ }
+
+ void setBin(int binIdx, int binVal);
+
+ int getNumberOfBins();
+
+ const std::vector<int>& getBins();
+
+ const std::vector<std::string>& getBinNames()
+ {
+ return m_binNames;
+ }
+
+ // Print the bins.
+ void printOutBins(std::ostream& os)
+ {
+ printOutBins( os, m_bins );
+ }
+
+ static void printOutBins(std::ostream& os, const std::vector<int>& bins);
+
+ /*
+ * Check whether the solid is valid for this segmentation.
+ */
+ virtual bool isValidSolid(G4VSolid*);
+
+ private:
+
+ // bin values
+ std::vector<int> m_bins;
- enum EType { eProjective=1, eNonprojective };
+ // bin names
+ BinNames m_binNames;
- typedef std::vector<std::string> BinNames;
+ // number of numbers
+ int m_numBins;
-public:
- G4Segmentation(EType segType, int nbins = 2);
- virtual ~G4Segmentation();
-
-public:
-
- // default = return step midpoint
- virtual G4ThreeVector getGlobalHitPos(const G4Step* aStep);
- virtual G4ThreeVector getGlobalHitPos(const G4StepPoint* aPreStepPoint);
- // default = no op
- virtual void setBins(const G4Step*) {}
- virtual void setBins(const G4StepPoint*) {}
- // call in child class ctors to setup bin name vec
- virtual void setBinNames()
- {}
-
-public:
-
- void resetBins();
-
- EType getType();
-
- const G4String& getTypeString()
- {
- static G4String typestr;
- if ( m_type == eProjective ) {
- typestr = "Projective";
- }
- else if ( m_type == eNonprojective ) {
- typestr = "Nonprojective";
- }
- else {
- typestr = "Unknown";
- }
-
- return typestr;
- }
-
- int getBin(int idx)
- {
- return m_bins.at( idx );
- }
-
- const std::string& getBinName(int)
- {
- std::cerr << "WARNING: returning blank bin name." << std::endl;
- static const std::string blank_name("");
- return blank_name;
- }
-
- void addBinName(const std::string& binName)
- {
- m_binNames.push_back(binName);
- }
-
- void setBin(int binIdx, int binVal);
-
- int getNumberOfBins();
-
- const std::vector<int>& getBins();
-
- const std::vector<std::string>& getBinNames() {
- return m_binNames;
- }
-
- // bin computation utility
- static int computeBin(double localDim, double gridDim)
- {
- return int(floor(localDim / gridDim ) );
-
- }
-
- // dimension computation from a bin
- static double computeDim(const int &bin,
- const double &incr)
- {
- return (double(bin) + .5) * incr;
- }
-
- // print bins
- void printOutBins(std::ostream& os)
- {
- printOutBins( os, m_bins );
- }
-
- static void printOutBins(std::ostream& os, const std::vector<int>& bins);
-
- /*
- * Check whether the solid is valid for this segmentation.
- *
- * Returns false if solid is not valid.
- *
- */
- virtual bool isValidSolid(G4VSolid*);
-
-private:
-
- // bin values
- std::vector<int> m_bins;
-
- // bin names
- BinNames m_binNames;
-
- // number of numbers
- int m_numBins;
-
- // type of segmentation
- EType m_type;
+ // type of segmentation
+ EType m_type;
};
#endif
lcdd/src
diff -N G4GlobalGridXYSegmentation.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4GlobalGridXYSegmentation.cc 30 Oct 2009 23:16:59 -0000 1.1
@@ -0,0 +1,72 @@
+// $Header: /cvs/lcd/lcdd/src/G4GlobalGridXYSegmentation.cc,v 1.1 2009/10/30 23:16:59 jeremy Exp $
+#include "G4GlobalGridXYSegmentation.hh"
+
+#include "ReadoutUtil.hh"
+
+#include "G4NavigationHistory.hh"
+
+G4GlobalGridXYSegmentation::G4GlobalGridXYSegmentation(
+ double gridSizeX,
+ double gridSizeY )
+ : G4Segmentation(G4Segmentation::eNonprojective),
+ m_gridSizeX(gridSizeX),
+ m_gridSizeY(gridSizeY)
+{
+ setBinNames();
+}
+
+G4GlobalGridXYSegmentation::~G4GlobalGridXYSegmentation()
+{}
+
+G4ThreeVector G4GlobalGridXYSegmentation::getGlobalHitPos(const G4Step* aStep)
+{
+ // Compute the midpoint of the global step.
+ G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
+
+ // Create 3vec for cell position.
+ G4ThreeVector globalCellPos;
+
+ // Set binned coordinates of cell position.
+ globalCellPos.setX(computeDimX(computeBinX(globalStepPos)));
+ globalCellPos.setY(computeDimY(computeBinY(globalStepPos)));
+
+ // Set Z coordinate of cell position from the volume's Z center position.
+ G4ThreeVector vpos = ReadoutUtil::getVolumeGlobalPosition(aStep->GetPreStepPoint());
+ globalCellPos.setZ(vpos.z());
+
+ return globalCellPos;
+}
+
+void G4GlobalGridXYSegmentation::setBins(const G4Step* aStep)
+{
+ // Compute the midpoint of the step.
+ G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos( aStep );
+
+ // Compute the bin values.
+ int binX = computeBinX( globalStepPos );
+ int binY = computeBinY( globalStepPos );
+
+ // Set the bin values.
+ setBin( 0, binX );
+ setBin( 1, binY );
+}
+
+int G4GlobalGridXYSegmentation::computeBinX(const G4ThreeVector& stepPos)
+{
+ return G4Segmentation::computeBin(stepPos.x(), m_gridSizeX);
+}
+
+int G4GlobalGridXYSegmentation::computeBinY(const G4ThreeVector& stepPos)
+{
+ return G4Segmentation::computeBin(stepPos.y(), m_gridSizeY);
+}
+
+double G4GlobalGridXYSegmentation::computeDimX(int bin)
+{
+ return G4Segmentation::computeDim(bin, m_gridSizeX);
+}
+
+double G4GlobalGridXYSegmentation::computeDimY(int bin)
+{
+ return G4Segmentation::computeDim(bin, m_gridSizeY);
+}
lcdd/src
diff -N global_grid_xyProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ global_grid_xyProcess.cc 30 Oct 2009 23:16:59 -0000 1.1
@@ -0,0 +1,71 @@
+// $Header: /cvs/lcd/lcdd/src/global_grid_xyProcess.cc,v 1.1 2009/10/30 23:16:59 jeremy Exp $
+#include "Saxana/ProcessingConfigurator.h"
+#include "Saxana/ProcessingContext.h"
+#include "Saxana/SAXProcessor.h"
+#include "Saxana/StateStack.h"
+#include "Saxana/SAXProcessingState.h"
+#include "Saxana/SAXStateProcess.h"
+#include "Saxana/SAXComponentFactory.h"
+
+#include "global_grid_xy.hh"
+
+#include <iostream>
+
+/**
+ @class grid_xyzProcess
+ @brief SAX process for grid_xyz element.
+*/
+class global_grid_xyProcess : public SAXStateProcess
+{
+
+ public:
+
+ global_grid_xyProcess(const ProcessingContext* context = 0)
+ : SAXStateProcess(context),
+ m_obj(0)
+ {}
+
+ virtual ~global_grid_xyProcess()
+ {}
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ SAXObject** obj = Context()->GetTopObject();
+
+ global_grid_xy* np = new global_grid_xy;
+
+ np->set_lunit( attrs.getValue( "lunit" ) );
+
+ np->set_gridSizeX( attrs.getValue( "grid_size_x" ) );
+ np->set_gridSizeY( attrs.getValue( "grid_size_y" ) );
+
+ m_obj = np;
+ *obj = np;
+ }
+
+ virtual void EndElement(const std::string&)
+ {;}
+
+ virtual void Characters(const std::string&)
+ {;}
+
+ virtual void StackPopNotify(const std::string&)
+ {;}
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "global_grid_xy";
+ return tag;
+ }
+
+ private:
+
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(global_grid_xyProcess)
lcdd/src
diff -u -r1.6 -r1.7
--- G4GridXYZSegmentation.cc 24 Sep 2009 17:47:20 -0000 1.6
+++ G4GridXYZSegmentation.cc 30 Oct 2009 23:16:59 -0000 1.7
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4GridXYZSegmentation.cc,v 1.6 2009/09/24 17:47:20 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/G4GridXYZSegmentation.cc,v 1.7 2009/10/30 23:16:59 jeremy Exp $
#include "G4GridXYZSegmentation.hh"
#include "ReadoutUtil.hh"
@@ -19,25 +19,6 @@
G4GridXYZSegmentation::~G4GridXYZSegmentation()
{}
-G4ThreeVector G4GridXYZSegmentation::getLocalHitPos(const G4ThreeVector& localStepPos)
-{
- G4ThreeVector localHitPos;
-
- if (m_gridSizeX > 0) {
- localHitPos.setX( computeDimX( computeBinX( localStepPos ) ) );
- }
-
- if (m_gridSizeY > 0) {
- localHitPos.setY( computeDimY( computeBinY( localStepPos ) ) );
- }
-
- if (m_gridSizeZ > 0) {
- localHitPos.setZ( computeDimZ( computeBinZ( localStepPos ) ) );
- }
-
- return localHitPos;
-}
-
G4ThreeVector G4GridXYZSegmentation::getGlobalHitPos(const G4Step* aStep)
{
// compute midpoint
@@ -55,21 +36,6 @@
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)
{
// Compute the midpoint of the step.
@@ -96,36 +62,6 @@
++idx;
}
-void G4GridXYZSegmentation::G4GridXYZSegmentation::setBins(const G4StepPoint* aPreStepPointconst)
-{
- return;
-}
-
-/*
- 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;
@@ -176,3 +112,38 @@
{
return G4Segmentation::computeDim(bin, m_gridSizeZ);
}
+
+G4ThreeVector G4GridXYZSegmentation::getGlobalHitPosPreStep(const G4StepPoint* aPreStepPoint)
+{
+ G4ThreeVector globalStepPos = aPreStepPoint->GetPosition();
+
+ // Figure out local step pos using touchable and global midpoint.
+ G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aPreStepPoint,globalStepPos);
+
+ // Compute local cell pos.
+ G4ThreeVector localCellPos = this->getLocalHitPos( localStepPos );
+
+ // Compute global cell pos.
+ G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal( aPreStepPoint, localCellPos );
+
+ return globalCellPos;
+}
+
+G4ThreeVector G4GridXYZSegmentation::getLocalHitPos(const G4ThreeVector& localStepPos)
+{
+ G4ThreeVector localHitPos;
+
+ if (m_gridSizeX > 0) {
+ localHitPos.setX( computeDimX( computeBinX( localStepPos ) ) );
+ }
+
+ if (m_gridSizeY > 0) {
+ localHitPos.setY( computeDimY( computeBinY( localStepPos ) ) );
+ }
+
+ if (m_gridSizeZ > 0) {
+ localHitPos.setZ( computeDimZ( computeBinZ( localStepPos ) ) );
+ }
+
+ return localHitPos;
+}
lcdd/src
diff -u -r1.6 -r1.7
--- G4OpticalCalorimeter.cc 30 Dec 2008 02:44:09 -0000 1.6
+++ G4OpticalCalorimeter.cc 30 Oct 2009 23:16:59 -0000 1.7
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4OpticalCalorimeter.cc,v 1.6 2008/12/30 02:44:09 wenzel Exp $
+// $Header: /cvs/lcd/lcdd/src/G4OpticalCalorimeter.cc,v 1.7 2009/10/30 23:16:59 jeremy Exp $
#include "G4OpticalCalorimeterSD.hh"
@@ -89,13 +89,13 @@
G4double theEdep = aTrack->GetTotalEnergy();
// get global cell pos from seg
- G4ThreeVector globalCellPos = m_segmentation->getGlobalHitPos( apreStepPoint);
+ G4ThreeVector globalCellPos = m_segmentation->getGlobalHitPosPreStep(apreStepPoint);
// reset the seg bins
m_segmentation->resetBins();
// set the seg bins
- m_segmentation->setBins(apreStepPoint);
+ m_segmentation->setBins(aStep);
// create id and pack into 64
Id64bit id64 = makeId();
lcdd/src
diff -u -r1.10 -r1.11
--- G4Segmentation.cc 1 Apr 2008 19:52:47 -0000 1.10
+++ G4Segmentation.cc 30 Oct 2009 23:16:59 -0000 1.11
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4Segmentation.cc,v 1.10 2008/04/01 19:52:47 wenzel Exp $
+// $Header: /cvs/lcd/lcdd/src/G4Segmentation.cc,v 1.11 2009/10/30 23:16:59 jeremy Exp $
#include "G4Segmentation.hh"
#include "ReadoutUtil.hh"
@@ -39,14 +39,13 @@
G4ThreeVector G4Segmentation::getGlobalHitPos(const G4Step* aStep)
{
- //G4cout << "G4Segmentation::getGlobalHitPos()" << G4endl;
return ReadoutUtil::computeMidPos( aStep );
}
-G4ThreeVector G4Segmentation::getGlobalHitPos(const G4StepPoint* aPreStepPoint)
+G4ThreeVector G4Segmentation::getGlobalHitPosPreStep(const G4StepPoint* aPreStepPoint)
{
- //dummy routine
- return aPreStepPoint->GetPosition();
+ G4Exception("Do not use this method!");
+ return aPreStepPoint->GetPosition();
}
void G4Segmentation::resetBins()
lcdd/src
diff -u -r1.7 -r1.8
--- G4SegmentationFactory.cc 30 Mar 2006 19:43:58 -0000 1.7
+++ G4SegmentationFactory.cc 30 Oct 2009 23:16:59 -0000 1.8
@@ -1,21 +1,24 @@
-// $Header: /cvs/lcd/lcdd/src/G4SegmentationFactory.cc,v 1.7 2006/03/30 19:43:58 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/G4SegmentationFactory.cc,v 1.8 2009/10/30 23:16:59 jeremy Exp $
+// GDML
#include "Saxana/SAXObject.h"
-
-#include "G4SegmentationFactory.hh"
-
#include "G4Processor/GDMLProcessor.h"
#include "G4Evaluator/GDMLExpressionEvaluator.h"
+// LCDD
+#include "G4SegmentationFactory.hh"
+
// LCDD segmentation elements
#include "grid_xyz.hh"
+#include "global_grid_xy.hh"
#include "nonprojective_cylinder.hh"
#include "projective_cylinder.hh"
#include "projective_zplane.hh"
-// LCDD G4 segmentation classes
+// LCDD G4 segmentation bindings
#include "G4Segmentation.hh"
#include "G4GridXYZSegmentation.hh"
+#include "G4GlobalGridXYSegmentation.hh"
#include "G4ProjectiveCylinderSegmentation.hh"
#include "G4ProjectiveZPlaneSegmentation.hh"
#include "G4NonprojectiveCylinderSegmentation.hh"
@@ -24,125 +27,151 @@
G4Segmentation* G4SegmentationFactory::createSegmentation(SAXObject* obj, const std::string& tag)
{
- G4Segmentation* seg = 0;
- GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
-
- if ( tag == "projective_cylinder" ) {
- //std::cout << "add projective_cylinder here" << std::endl;
-
- projective_cylinder* prj = dynamic_cast<projective_cylinder*> ( obj );
+ G4Segmentation* seg = 0;
+ GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
- if (prj) {
- int ntheta, nphi;
- std::string sval = prj->get_ntheta();
- ntheta = (int)calc->Eval( sval );
- sval = prj->get_nphi();
- nphi = (int)calc->Eval( sval );
-
- seg = new G4ProjectiveCylinderSegmentation(ntheta, nphi);
- } // prj exists
- else {
- std::cerr << "Failed cast to projective_cylinder!" << std::endl;
-
- } // prj no exist
-
- } // projective_cylinder
-
- // handle grid_xyz
- else if ( tag == "grid_xyz" ) {
- //std::cout << "add grid_xyz here" << std::endl;
-
- grid_xyz* np = dynamic_cast<grid_xyz*> ( obj );
- if (np) {
- //std::cout << "got grid_xyz..." << std::endl;
-
- double gsx, gsy, gsz;
- gsx = gsy = gsz = 0.;
- //int nbx, nby, nbz;
- //nbz = nby = nbz = 0;
- std::string lunit = np->get_lunit();
-
- std::string sval = np->get_gridSizeX();
- sval += "*" + lunit;
- gsx = calc->Eval( sval );
-
- sval = np->get_gridSizeY();
- sval += "*" + lunit;
- gsy = calc->Eval( sval );
-
- sval = np->get_gridSizeZ();
- sval += "*" + lunit;
- gsz = calc->Eval( sval );
-
- //std::cout << "grid x, y, z: " << gsx << ", " << gsy << ", " << gsz << std::endl;
-
- seg = new G4GridXYZSegmentation(gsx,
- gsy,
- gsz);
- } // np exists
- else {
- std::cerr << "Failed cast to grid_xyz!" << std::endl;
- } // np no exist
- } // grid_xyz
-
- // handle NP cylinder
- else if ( tag == "nonprojective_cylinder" ) {
+ if ( tag == "projective_cylinder" )
+ {
+ //std::cout << "add projective_cylinder here" << std::endl;
+
+ projective_cylinder* prj = dynamic_cast<projective_cylinder*> ( obj );
+
+ if (prj) {
+ int ntheta, nphi;
+ std::string sval = prj->get_ntheta();
+ ntheta = (int)calc->Eval( sval );
+ sval = prj->get_nphi();
+ nphi = (int)calc->Eval( sval );
+
+ seg = new G4ProjectiveCylinderSegmentation(ntheta, nphi);
+ }
+ else
+ {
+ std::cerr << "Failed cast to projective_cylinder!" << std::endl;
+ }
+ }
+ // GridXYZ
+ else if ( tag == "grid_xyz" )
+ {
+ grid_xyz* np = dynamic_cast<grid_xyz*> ( obj );
+ if (np)
+ {
+ double gsx, gsy, gsz;
+ gsx = gsy = gsz = 0.;
+ std::string lunit = np->get_lunit();
+
+ std::string sval = np->get_gridSizeX();
+ sval += "*" + lunit;
+ gsx = calc->Eval( sval );
+
+ sval = np->get_gridSizeY();
+ sval += "*" + lunit;
+ gsy = calc->Eval( sval );
+
+ sval = np->get_gridSizeZ();
+ sval += "*" + lunit;
+ gsz = calc->Eval( sval );
+
+ //std::cout << "grid x, y, z: " << gsx << ", " << gsy << ", " << gsz << std::endl;
+
+ seg = new G4GridXYZSegmentation(gsx,
+ gsy,
+ gsz);
+ }
+ else
+ {
+ std::cerr << "Failed cast to grid_xyz!" << std::endl;
+ }
+ }
+ // GlobalGridXY
+ else if ( tag == "global_grid_xy" )
+ {
+ global_grid_xy* gridxy = dynamic_cast<global_grid_xy*> ( obj );
+ if (gridxy)
+ {
+ double gsx, gsy;
+ gsx = gsy = 0.;
+ std::string lunit = gridxy->get_lunit();
+
+ std::string sval = gridxy->get_gridSizeX();
+ sval += "*" + lunit;
+ gsx = calc->Eval( sval );
+
+ sval = gridxy->get_gridSizeY();
+ sval += "*" + lunit;
+ gsy = calc->Eval( sval );
+
+ seg = new G4GlobalGridXYSegmentation(gsx, gsy);
+ }
+ else
+ {
+ std::cerr << "Failed cast to global_grid_xy!" << std::endl;
+ }
+ }
+ // handle NP cylinder
+ else if ( tag == "nonprojective_cylinder" ) {
- //std::cout << "add nonprojective_cylinder here" << std::endl;
+ //std::cout << "add nonprojective_cylinder here" << std::endl;
- nonprojective_cylinder* np = dynamic_cast<nonprojective_cylinder*> ( obj );
- if (np) {
+ nonprojective_cylinder* np = dynamic_cast<nonprojective_cylinder*> ( obj );
+ if (np) {
- double gsp = 0;
- double gsz = 0;
+ double gsp = 0;
+ double gsz = 0;
- std::string lunit = np->get_lunit();
+ std::string lunit = np->get_lunit();
- std::string sval = np->get_gridSizePhi();
- sval += "*" + lunit;
- gsp = calc->Eval( sval );
+ std::string sval = np->get_gridSizePhi();
+ sval += "*" + lunit;
+ gsp = calc->Eval( sval );
- sval = np->get_gridSizeZ();
- sval += "*" + lunit;
- gsz = calc->Eval( sval );
+ sval = np->get_gridSizeZ();
+ sval += "*" + lunit;
+ gsz = calc->Eval( sval );
- seg = new G4NonprojectiveCylinderSegmentation( gsp, gsz );
- }
- else {
- std::cerr << "Failed cast to nonprojective_cylinder!" << std::endl;
+ seg = new G4NonprojectiveCylinderSegmentation( gsp, gsz );
+ }
+ else {
+ std::cerr << "Failed cast to nonprojective_cylinder!" << std::endl;
+ }
}
- }
-
- // handle projective_zplane
- else if ( tag == "projective_zplane" ) {
+ // handle projective_zplane
+ else if ( tag == "projective_zplane" )
+ {
- //std::cout << "add projective_zplane here" << std::endl;
+ //std::cout << "add projective_zplane here" << std::endl;
- projective_zplane* prj = dynamic_cast<projective_zplane*> ( obj );
+ projective_zplane* prj = dynamic_cast<projective_zplane*> ( obj );
- if ( prj ) {
+ if ( prj ) {
- int ntheta, nphi;
- std::string sval = prj->get_ntheta();
- ntheta = (int)calc->Eval( sval );
- sval = prj->get_nphi();
- nphi = (int)calc->Eval( sval );
+ int ntheta, nphi;
+ std::string sval = prj->get_ntheta();
+ ntheta = (int)calc->Eval( sval );
+ sval = prj->get_nphi();
+ nphi = (int)calc->Eval( sval );
- //std::cout << "ntheta, nphi : "
- // << ntheta << ", "
- // << nphi << std::endl;
+ //std::cout << "ntheta, nphi : "
+ // << ntheta << ", "
+ // << nphi << std::endl;
- seg = new G4ProjectiveZPlaneSegmentation(ntheta, nphi);
- } // prj exists
- else {
- std::cerr << "Failed cast to projective_zplane!" << std::endl;
- } // prj no exist
- } // projective_zplane
-
+ seg = new G4ProjectiveZPlaneSegmentation(ntheta, nphi);
+ } // prj exists
+ else
+ {
+ std::cerr << "Failed cast to projective_zplane!" << std::endl;
+ } // prj no exist
+ } // projective_zplane
// bad segmentation tag
- else {
- std::cerr << "Unknown child tag for calorimeter: " << tag << "." << std::endl;
- }
+ else
+ {
+ std::cerr << "Unknown child tag for calorimeter: " << tag << "." << std::endl;
+ }
+
+ if (seg == 0)
+ {
+ G4Exception("Failed to create segmentation!");
+ }
- return seg;
+ return seg;
}
lcdd/src
diff -u -r1.25 -r1.26
--- LCDDLibLoad.cc 5 Jul 2007 22:27:35 -0000 1.25
+++ LCDDLibLoad.cc 30 Oct 2009 23:16:59 -0000 1.26
@@ -29,6 +29,7 @@
LOAD_COMPONENT(projective_cylinderProcess);
LOAD_COMPONENT(projective_zplaneProcess);
LOAD_COMPONENT(nonprojective_cylinderProcess);
+ LOAD_COMPONENT(global_grid_xyProcess);
// Ids
LOAD_COMPONENT(idspecProcess);
lcdd/src
diff -u -r1.10 -r1.11
--- LCDDParser.cc 17 Jun 2008 23:16:17 -0000 1.10
+++ LCDDParser.cc 30 Oct 2009 23:16:59 -0000 1.11
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/LCDDParser.cc,v 1.10 2008/06/17 23:16:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/LCDDParser.cc,v 1.11 2009/10/30 23:16:59 jeremy Exp $
#include "LCDDParser.hh"
// lcdd
@@ -46,16 +46,9 @@
}
void LCDDParser::setupParserConfig(const std::string& URI,
- const std::string& setupName,
+ const std::string&,
const std::string& version)
{
- //static const G4String DefaultSetupName("Default");
-
- //if (setupName == std::string("") ) {
- // G4cout << "Using default SetupName <" << DefaultSetupName << ">" << G4endl;
- // m_setupName = DefaultSetupName;
- //}
-
// settings from messenger commands
std::cout << "LCDD URI <" << m_URI << ">" << std::endl;
//std::cout << "SetupName <" << m_setupName << ">" << std::endl;
lcdd/src
diff -u -r1.12 -r1.13
--- ReadoutUtil.cc 1 Apr 2008 19:52:47 -0000 1.12
+++ ReadoutUtil.cc 30 Oct 2009 23:16:59 -0000 1.13
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/ReadoutUtil.cc,v 1.12 2008/04/01 19:52:47 wenzel Exp $
+// $Header: /cvs/lcd/lcdd/src/ReadoutUtil.cc,v 1.13 2009/10/30 23:16:59 jeremy Exp $
#include "ReadoutUtil.hh"
#include <cmath>
@@ -49,8 +49,7 @@
G4ThreeVector ReadoutUtil::getVolumeGlobalPosition(const G4StepPoint* aStepPoint,
const G4ThreeVector& pnt )
{
- return aStepPoint->GetTouchableHandle()->GetHistory()->GetTopTransform().Inverse().
- TransformPoint( pnt );
+ return aStepPoint->GetTouchableHandle()->GetHistory()->GetTopTransform().Inverse().TransformPoint( pnt );
}
G4ThreeVector ReadoutUtil::getVolumeGlobalPosition(const G4StepPoint* aStepPoint)
lcdd/src
diff -u -r1.19 -r1.20
--- SensitiveDetectorFactory.cc 22 Feb 2008 20:24:11 -0000 1.19
+++ SensitiveDetectorFactory.cc 30 Oct 2009 23:16:59 -0000 1.20
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/SensitiveDetectorFactory.cc,v 1.19 2008/02/22 20:24:11 wenzel Exp $
+// $Header: /cvs/lcd/lcdd/src/SensitiveDetectorFactory.cc,v 1.20 2009/10/30 23:16:59 jeremy Exp $
#include "SensitiveDetectorFactory.hh"
// lcdd
@@ -13,285 +13,304 @@
G4SensitiveDetector* SensitiveDetectorFactory::createSensitiveDetector(const SAXObject* object)
{
- G4SensitiveDetector* sd = 0;
+ G4SensitiveDetector* sd = 0;
- const SensitiveDetectorType* sdt = dynamic_cast<const SensitiveDetectorType*> ( object );
+ const SensitiveDetectorType* sdt = dynamic_cast<const SensitiveDetectorType*> ( object );
- if ( sdt ) {
+ if ( sdt ) {
- std::string sd_type = sdt->get_type();
+ std::string sd_type = sdt->get_type();
- /* create calorimeter */
- if ( sd_type == "calorimeter" || sd_type == "optical_calorimeter" ) {
- sd = createCalorimeterSD( object );
- }
- /* create tracker */
- else if ( sd_type == "tracker" ) {
- sd = createTrackerSD( object );
- }
- /* create scorer */
- else if ( sd_type == "scorer" ) {
- sd = createScorerSD( object );
+ /* create calorimeter */
+ if ( sd_type == "calorimeter" || sd_type == "optical_calorimeter" ) {
+ sd = createCalorimeterSD( object );
+ }
+ /* create tracker */
+ else if ( sd_type == "tracker" ) {
+ sd = createTrackerSD( object );
+ }
+ /* create scorer */
+ else if ( sd_type == "scorer" ) {
+ sd = createScorerSD( object );
+ }
+ /* invalid type */
+ else {
+ G4cerr << "Invalid sd_type <" << sd_type << ">." << G4endl;
+ G4Exception( "Unknown SD type. Check the LCDD file." );
+ }
+
+ // set ecut and verbose
+ setBaseSensitiveDetectorAttributes(sd, sdt);
+
+ // find idspec
+ IdSpec* idspec = findIdSpec(sdt);
+
+ // set idspec, if exists (null is ok)
+ if ( idspec != 0 ) {
+ sd->setIdSpec(idspec);
+ }
+
+ // register the SD
+ std::string sdName = sd->GetName();
+ LCDDProcessor::instance()->addSensitiveDetector(sdName,
+ sd);
+ }
+ else
+ {
+ G4Exception( "Failed cast to SensitiveDetectorType." );
}
- /* invalid type */
- else {
- G4cerr << "Invalid sd_type <" << sd_type << ">." << G4endl;
- G4Exception( "Unknown SD type. Check the LCDD file." );
- }
-
- // set ecut and verbose
- setBaseSensitiveDetectorAttributes(sd, sdt);
-
- // find idspec
- IdSpec* idspec = findIdSpec(sdt);
- // set idspec, if exists (null is ok)
- if ( idspec != 0 ) {
- sd->setIdSpec(idspec);
- }
-
- // register the SD
- std::string sdName = sd->GetName();
- LCDDProcessor::instance()->addSensitiveDetector(sdName,
- sd);
- }
- else {
- G4Exception( "Failed cast to SensitiveDetectorType." );
- }
-
- return sd;
+ return sd;
}
G4CalorimeterSD* SensitiveDetectorFactory::createCalorimeterSD(const SAXObject* object)
{
- G4CalorimeterSD* sd = 0;
- G4Segmentation* seg = 0;
+ G4CalorimeterSD* sd = 0;
+ G4Segmentation* seg = 0;
- //const calorimeter* cal = dynamic_cast<const calorimeter*>( object );
- const SensitiveDetectorType* sdt = dynamic_cast<const SensitiveDetectorType*>( object );
+ const SensitiveDetectorType* sdt = dynamic_cast<const SensitiveDetectorType*>( object );
- std::string sd_type = sdt->get_type();
+ std::string sd_type = sdt->get_type();
- // first create segmentation
- ContentSequence* seq = const_cast<ContentSequence*> ( sdt->get_content() );
- size_t count = seq->size();
-
- // child tag loop for segmentation
- bool fnd_seg = false;
- for( size_t i = 0; i < count; i++) {
-
- std::string child_tag = seq->content(i).tag;
- const ContentGroup::ContentItem& segitem = seq->content(i);
-
- // create segmentation using factory
- if ( isSegmentationTag( child_tag ) ) {
-
- seg = G4SegmentationFactory::createSegmentation( segitem.object, segitem.tag );
-// G4cout<<"bins: "<< seg->getNumberOfBins()<<G4endl;
- fnd_seg = true;
- break;
- }
- }
-
- if ( !fnd_seg ) {
- G4Exception("FATAL ERROR: segmentation tag is required to create a calorimeter.");
- }
-
- const calorimeter* cal = dynamic_cast<const calorimeter*>( object );
-
- const std::string& hitCompareStr = cal->get_compare();
-
- // Comparison algorithm to be used for combining hits, to be determined
- // from attributes on sensitive detector.
- HitComparator* hitCompare = 0;
-
- // Find the IdSpec.
- IdSpec* idspec = findIdSpec( sdt );
-
- if ( hitCompareStr != "id" && hitCompareStr != "position" ) {
- G4Exception("Invalid selection for hit comparison <" + hitCompareStr + ">, for calorimeter <" + sdt->get_name() + ">.");
- }
-
- // Compare on IDs.
- if ( hitCompareStr == "id" ) {
- if ( idspec ) {
- hitCompare = new IdComparator();
- }
- else {
- std::cerr << "WARNING: IdSpec for <" << sdt->get_name() << "> does not exist! Position comparison will be used for hit aggregation instead of id." << std::endl;
- }
- }
-
- // Compare on position.
- if ( !hitCompare ) {
- hitCompare = new PositionComparator();
- }
-
- // create SD with seg and comparator
- if ( seg ) {
-
- if ( sd_type == "calorimeter" ) {
- sd = new G4CalorimeterSD(sdt->get_name(),
- sdt->get_hitsCollectionName(),
- seg,
- hitCompare);
- }
- else if ( sd_type == "optical_calorimeter" ) {
- //
- // in case of optical alorimeter there are 2 hit collections
- //
- //G4String hcnames[2];
- std::vector<G4String> hcnames;
- hcnames.push_back("Edep_"+sdt->get_hitsCollectionName());
- hcnames.push_back("Ceren_"+sdt->get_hitsCollectionName());
- //std::cout<< " now creating optical calorimeter"<<std::endl;
- sd = new G4OpticalCalorimeterSD(sdt->get_name(),
- hcnames,
- seg,
- hitCompare);
- }
- else {
- G4Exception("SensitiveDetectorFactory - Unknown sensitive detector type: " + sd_type);
- }
- }
- // shouldn't happen if fnd_seg fails...
- else {
- G4Exception( "FATAL ERROR: G4SegmentationFactory returned a NULL pointer!" );
- }
+ // Create the segmentation.
+ ContentSequence* seq = const_cast<ContentSequence*> ( sdt->get_content() );
+ size_t count = seq->size();
+
+ // Look for segmentation tag.
+ bool fnd_seg = false;
+ for( size_t i = 0; i < count; i++)
+ {
+ std::string child_tag = seq->content(i).tag;
+ const ContentGroup::ContentItem& segitem = seq->content(i);
+
+ // Create segmentation using factory.
+ if ( isSegmentationTag( child_tag ) )
+ {
+ seg = G4SegmentationFactory::createSegmentation( segitem.object, segitem.tag );
+ fnd_seg = true;
+ break;
+ }
+ }
+
+ if ( !fnd_seg )
+ {
+ G4Exception("FATAL ERROR: Segmentation tag is required to create a calorimeter.");
+ }
+
+ const calorimeter* cal = dynamic_cast<const calorimeter*>( object );
+
+ const std::string& hitCompareStr = cal->get_compare();
+
+ // Comparison algorithm to be used for combining hits, to be determined from SD.
+ HitComparator* hitCompare = 0;
+
+ // Find the IdSpec.
+ IdSpec* idspec = findIdSpec( sdt );
+
+ if ( hitCompareStr != "id" && hitCompareStr != "position" )
+ {
+ G4Exception("Invalid selection for hit comparison <" + hitCompareStr + ">, for calorimeter <" + sdt->get_name() + ">.");
+ }
+
+ // Compare on IDs.
+ if ( hitCompareStr == "id" )
+ {
+ if ( idspec )
+ {
+ hitCompare = new IdComparator();
+ }
+ else
+ {
+ std::cerr << "WARNING: IdSpec for <" << sdt->get_name() << "> does not exist! Position comparison will be used for hit aggregation instead of id." << std::endl;
+ }
+ }
+
+ // Compare on position.
+ if ( !hitCompare )
+ {
+ hitCompare = new PositionComparator();
+ }
+
+ // create SD with seg and comparator
+ if ( seg )
+ {
+
+ if ( sd_type == "calorimeter" )
+ {
+ sd = new G4CalorimeterSD(sdt->get_name(),
+ sdt->get_hitsCollectionName(),
+ seg,
+ hitCompare);
+ }
+ else if ( sd_type == "optical_calorimeter" )
+ {
+ //
+ // in case of optical alorimeter there are 2 hit collections
+ //
+ //G4String hcnames[2];
+ std::vector<G4String> hcnames;
+ hcnames.push_back("Edep_"+sdt->get_hitsCollectionName());
+ hcnames.push_back("Ceren_"+sdt->get_hitsCollectionName());
+ //std::cout<< " now creating optical calorimeter"<<std::endl;
+ sd = new G4OpticalCalorimeterSD(sdt->get_name(),
+ hcnames,
+ seg,
+ hitCompare);
+ }
+ else
+ {
+ G4Exception("SensitiveDetectorFactory - Unknown sensitive detector type: " + sd_type);
+ }
+ }
+ // shouldn't happen if fnd_seg fails...
+ else
+ {
+ G4Exception( "FATAL ERROR: G4SegmentationFactory returned a NULL pointer!" );
+ }
- return sd;
+ return sd;
}
G4TrackerSD* SensitiveDetectorFactory::createTrackerSD(const SAXObject* object)
{
- const tracker* trk = dynamic_cast<const tracker*>( object );
+ const tracker* trk = dynamic_cast<const tracker*>( object );
- bool combineHits = StringUtil::toBool( trk->get_combine_hits() );
+ bool combineHits = StringUtil::toBool( trk->get_combine_hits() );
- G4TrackerSD* sd = 0;
+ G4TrackerSD* sd = 0;
- std::string nm = trk->get_name();
- std::string hc = trk->get_hitsCollectionName();
+ std::string nm = trk->get_name();
+ std::string hc = trk->get_hitsCollectionName();
- if (checkHCName(hc)) {
- G4Exception("SensitiveDetectorFactory - There was a problem with the name of the hits collection.");
- }
-
- /* tracker that aggregates hits */
- if ( combineHits ) {
- sd = new G4TrackerCombineSD(nm,
- hc);
- }
- /* regular tracker */
- else {
- sd = new G4TrackerSD(nm,
- hc);
- }
+ if (checkHCName(hc))
+ {
+ G4Exception("SensitiveDetectorFactory - There was a problem with the name of the hits collection.");
+ }
- return sd;
+ /* tracker that aggregates hits */
+ if ( combineHits )
+ {
+ sd = new G4TrackerCombineSD(nm,
+ hc);
+ }
+ /* regular tracker */
+ else
+ {
+ sd = new G4TrackerSD(nm,
+ hc);
+ }
+
+ return sd;
}
G4ScorerSD* SensitiveDetectorFactory::createScorerSD(const SAXObject* object)
{
- const scorer * scr = dynamic_cast<const scorer*>( object );
+ const scorer * scr = dynamic_cast<const scorer*>( object );
- G4ScorerSD* sd = 0;
+ G4ScorerSD* sd = 0;
- std::string nm = scr->get_name();
- std::string hc = scr->get_hitsCollectionName();
+ std::string nm = scr->get_name();
+ std::string hc = scr->get_hitsCollectionName();
- if ( checkHCName(hc) ) {
- G4Exception("SensitiveDetectorFactory - There was a problem with the name of the hits collection.");
- }
+ if ( checkHCName(hc) )
+ {
+ G4Exception("SensitiveDetectorFactory - There was a problem with the name of the hits collection.");
+ }
- sd = new G4ScorerSD(nm,
- hc);
- return sd;
+ sd = new G4ScorerSD(nm,
+ hc);
+ return sd;
}
IdSpec* SensitiveDetectorFactory::findIdSpec(const SensitiveDetectorType* sdt)
{
- IdSpec* idspec = 0;
- ContentSequence* seq = const_cast<ContentSequence*> ( sdt->get_content() );
- size_t count = seq->size();
- for( size_t i = 0; i < count; i++) {
-
- std::string child_tag = seq->content(i).tag;
-
- // find idspec
- if ( child_tag == "idspecref" ) {
-
- IdSpecType::idspecref* id_ref =
- dynamic_cast<IdSpecType::idspecref*> ( seq->content(i).object );
-
- idspec = IdManager::instance()->getIdSpec( id_ref->get_ref() );
-
- if (idspec == 0) {
- G4Exception("The IdSpec <" + id_ref->get_ref() + "> referenced by detector <" + sdt->get_name() + "> does not exist!");
- }
+ IdSpec* idspec = 0;
+ ContentSequence* seq = const_cast<ContentSequence*> ( sdt->get_content() );
+ size_t count = seq->size();
+ for( size_t i = 0; i < count; i++)
+ {
+
+ std::string child_tag = seq->content(i).tag;
+
+ // find idspec
+ if ( child_tag == "idspecref" )
+ {
+ IdSpecType::idspecref* id_ref =
+ dynamic_cast<IdSpecType::idspecref*> ( seq->content(i).object );
+
+ idspec = IdManager::instance()->getIdSpec( id_ref->get_ref() );
+
+ if (idspec == 0)
+ {
+ G4Exception("The IdSpec <" + id_ref->get_ref() + "> referenced by detector <" + sdt->get_name() + "> does not exist!");
+ }
- break;
+ break;
+ }
}
- }
- return idspec;
+ return idspec;
}
void SensitiveDetectorFactory::setBaseSensitiveDetectorAttributes(G4SensitiveDetector* sd, const SensitiveDetectorType* sdt)
{
- sd->setEcut( SensitiveDetectorFactory::computeEcut( sdt ) );
- sd->setVerbose( SensitiveDetectorFactory::convertVerbose( sdt ) );
- sd->setEndcapFlag( StringUtil::toBool( sdt->get_endcap_flag() ) );
+ sd->setEcut( SensitiveDetectorFactory::computeEcut( sdt ) );
+ sd->setVerbose( SensitiveDetectorFactory::convertVerbose( sdt ) );
+ sd->setEndcapFlag( StringUtil::toBool( sdt->get_endcap_flag() ) );
}
double SensitiveDetectorFactory::computeEcut(const SensitiveDetectorType* sdt)
{
- GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
- std::string sval = sdt->get_ecut();
- sval += "*" + sdt->get_eunit();
- double ecut = calc->Eval( sval );
- return ecut;
+ GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
+ std::string sval = sdt->get_ecut();
+ sval += "*" + sdt->get_eunit();
+ double ecut = calc->Eval( sval );
+ return ecut;
}
int SensitiveDetectorFactory::convertVerbose(const SensitiveDetectorType* sdt)
{
- GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
- std::string sval = sdt->get_verbose();
- int verbose = (int)calc->Eval( sval );
- return verbose;
+ GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
+ std::string sval = sdt->get_verbose();
+ int verbose = (int)calc->Eval( sval );
+ return verbose;
}
+// NOTE: New segmentations must appear here!
bool SensitiveDetectorFactory::isSegmentationTag(const std::string& s)
{
- // new segmentations must appear here!
- // @todo Fix this to know all segmentation types somehow.
- return ( s == "projective_cylinder" ||
- s == "grid_xyz" ||
- s == "nonprojective_cylinder" ||
- s == "projective_zplane" );
+ // @todo Fix this to know all segmentation types automatically somehow. (schema?)
+ return ( s == "projective_cylinder" ||
+ s == "grid_xyz" ||
+ s == "global_grid_xy" ||
+ s == "nonprojective_cylinder" ||
+ s == "projective_zplane" );
}
bool SensitiveDetectorFactory::checkHCName(const std::string& s)
{
- bool bad = false;
+ bool bad = false;
- // is size <= 1 ?
- if ( s.size() <= 1 ) {
- bad = true;
- //std::cerr << "HCName <" << s << "> is not enough characters." << std::endl;
- }
- else {
-
- LCDDProcessor* proc = LCDDProcessor::instance();
- for ( LCDDProcessor::SensitiveDetectors::const_iterator iter = proc->getSensitiveDetectorsBegin();
- iter != proc->getSensitiveDetectorsBegin();
- iter++ ) {
- if (iter->second->getHCName() == s ) {
- bad = true;
- //std::cerr << "HCName <" << s << "> already assigned to SD <" << iter->second->GetName() << ">." << std::endl;
- break;
- }
+ // is size <= 1 ?
+ if ( s.size() <= 1 )
+ {
+ bad = true;
+ //std::cerr << "HCName <" << s << "> is not enough characters." << std::endl;
+ }
+ else
+ {
+ LCDDProcessor* proc = LCDDProcessor::instance();
+ for ( LCDDProcessor::SensitiveDetectors::const_iterator iter = proc->getSensitiveDetectorsBegin();
+ iter != proc->getSensitiveDetectorsBegin();
+ iter++ )
+ {
+ if (iter->second->getHCName() == s )
+ {
+ bad = true;
+ //std::cerr << "HCName <" << s << "> already assigned to SD <" << iter->second->GetName() << ">." << std::endl;
+ break;
+ }
+ }
}
- }
- return bad;
+ return bad;
}
CVSspam 0.2.8