109 added + 109 removed, total 218 files
lcdd/src
diff -N CalorimeterHitProcessor.cc
--- CalorimeterHitProcessor.cc 26 Jun 2013 01:36:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,75 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/CalorimeterHitProcessor.cc,v 1.3 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/CalorimeterHitProcessor.hh"
-
-// STL
-#include <iostream>
-
-// Geant4
-#include "G4NavigationHistory.hh"
-
-CalorimeterHitProcessor::CalorimeterHitProcessor(CellReadout* readout) :
- m_readout(readout)
-{
-}
-
-CalorimeterHitProcessor::~CalorimeterHitProcessor()
-{
-}
-
-bool CalorimeterHitProcessor::processHits(G4Step* step)
-{
- // Compute step mid-point.
- G4ThreeVector midpoint = (0.5 * (step->GetPreStepPoint()->GetPosition() + step->GetPostStepPoint()->GetPosition()));
-
- // DEBUG
- //std::cout << "midpoint(x,y,z) = " << midpoint.x() << ", " << midpoint.y() << ", " << midpoint.z() << std::endl;
-
- // Get the touchable handle from the step.
- G4TouchableHandle touchable = step->GetPreStepPoint()->GetTouchableHandle();
-
- // Compute local position using global position and touchable.
- G4ThreeVector localPosition = touchable->GetHistory()->GetTopTransform().TransformPoint(midpoint);
-
- // DEBUG
- //std::cout << "localPosition(x,y,z) = " << localPosition.x() << ", " << localPosition.y() << ", " << localPosition.z() << std::endl;
-
- // Get the cell ID from the position.
- CellReadout::Position2D readoutPosition;
- readoutPosition.first = localPosition.x();
- readoutPosition.second = localPosition.y();
- CellReadout::CellId cellId = m_readout->cellId(readoutPosition);
-
- // DEBUG: print neighbors
- //CellReadout::Neighbors neighbors = m_readout->neighbors(cellId);
- //std::cout << "# neighbors = " << neighbors.size() << std::endl;
- //for (CellReadout::Neighbors::iterator it = neighbors.begin(); it != neighbors.end(); ++it) {
- // CellReadout::CellId neighborId = *it;
- // std::cout << "neighbor(x,y) = " << neighborId[0] << ", " << neighborId[1] << std::endl;
- //}
-
- // DEBUG: print cell ID
- //std::cout << "cellId(x,y) = " << cellId[0] << ", " << cellId[1] << std::endl;
-
- // Get the local cell position from the cell ID.
- CellReadout::Position2D cellPosition = m_readout->position(cellId);
-
- // DEBUG: print local cell position
- //std::cout << "cellPosition = " << cellPosition.first << ", " << cellPosition.second << std::endl;
-
- // Transform local cell position to global.
- G4ThreeVector cellVec(cellPosition.first, cellPosition.second, 0);
-
- // Compute global position using local point and touchable.
- G4ThreeVector globalPos = touchable->GetHistory()->GetTopTransform().Inverse().TransformPoint(cellVec);
-
- // DEBUG: print global position
- //std::cout << "globalPosition(x,y,z) = " << globalPos.x() << ", " << globalPos.x() << ", " << globalPos.z() << std::endl;
- //std::cout << std::endl;
-
- // TODO: make and return or store hit data from id, position, energy, & time
- //G4CalorimeterHit* hit = new G4CalorimeterHit();
-
- return true;
-}
lcdd/src
diff -N Cartesian3DMagneticFieldMap.cc
--- Cartesian3DMagneticFieldMap.cc 26 Jun 2013 01:36:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,231 +0,0 @@
-//
-// Original PurgMagTabulatedField3D code developed by:
-// S.Larsson and J. Generowicz.
-//
-
-// LCDD
-#include "lcdd/bfield/Cartesian3DMagneticFieldMap.hh"
-
-// STL
-#include <fstream>
-#include <iostream>
-#include <cmath>
-
-using namespace std;
-
-Cartesian3DMagneticFieldMap::Cartesian3DMagneticFieldMap( const char* filename, double xOffset, double yOffset, double zOffset )
- :_xOffset(xOffset),_yOffset(yOffset),_zOffset(zOffset),_invertX(false),_invertY(false),_invertZ(false)
-{
- //cout << "\n-----------------------------------------------------------"
- // << "\n Magnetic field"
- // << "\n-----------------------------------------------------------";
-
- //cout << "\n ---> " "Reading the field grid from " << filename << " ... " << endl;
- ifstream file( filename ); // Open the file for reading.
-
- // Ignore first blank line
- char buffer[256];
- file.getline(buffer,256);
-
- // Read table dimensions
- file >> _nx >> _ny >> _nz; // Note dodgy order
-
- //cout << " [ Number of values x,y,z: "
- // << _nx << " " << _ny << " " << _nz << " ] "
- // << endl;
-
- // Set up storage space for table
- _xField.resize( _nx );
- _yField.resize( _nx );
- _zField.resize( _nx );
- int ix, iy, iz;
- for (ix=0; ix<_nx; ix++) {
- _xField[ix].resize(_ny);
- _yField[ix].resize(_ny);
- _zField[ix].resize(_ny);
- for (iy=0; iy<_ny; iy++) {
- _xField[ix][iy].resize(_nz);
- _yField[ix][iy].resize(_nz);
- _zField[ix][iy].resize(_nz);
- }
- }
-
- // Ignore other header information
- // The first line whose second character is '0' is considered to
- // be the last line of the header.
- do {
- file.getline(buffer,256);
- } while ( buffer[1]!='0');
-
- // Read in the data
- double xval,yval,zval,bx,by,bz;
- for (ix=0; ix<_nx; ix++) {
- for (iy=0; iy<_ny; iy++) {
- for (iz=0; iz<_nz; iz++) {
- file >> xval >> yval >> zval >> bx >> by >> bz;
- if ( ix==0 && iy==0 && iz==0 ) {
- _minx = xval;
- _miny = yval;
- _minz = zval;
- }
- _xField[ix][iy][iz] = bx;
- _yField[ix][iy][iz] = by;
- _zField[ix][iy][iz] = bz;
- }
- }
- }
- file.close();
-
- _maxx = xval;
- _maxy = yval;
- _maxz = zval;
-
- //cout << "\n ---> ... done reading " << endl;
-
- // cout << " Read values of field from file " << filename << endl;
- //cout << " ---> assumed the order: x, y, z, Bx, By, Bz "
- // << "\n ---> Min values x,y,z: "
- // << _minx << " " << _miny << " " << _minz << " cm "
- // << "\n ---> Max values x,y,z: "
- // << _maxx << " " << _maxy << " " << _maxz << " cm "
- // << "\n ---> The field will be offset by " << _xOffset << " " << _yOffset << " " << _zOffset << " cm " << endl;
-
- // Should really check that the limits are not the wrong way around.
- if (_maxx < _minx) {swap(_maxx,_minx); _invertX = true;}
- if (_maxy < _miny) {swap(_maxy,_miny); _invertY = true;}
- if (_maxz < _minz) {swap(_maxz,_minz); _invertZ = true;}
- //cout << "\nAfter reordering if necessary"
- // << "\n ---> Min values x,y,z: "
- // << _minx << " " << _miny << " " << _minz << " cm "
- // << " \n ---> Max values x,y,z: "
- // << _maxx << " " << _maxy << " " << _maxz << " cm ";
-
- _dx = _maxx - _minx;
- _dy = _maxy - _miny;
- _dz = _maxz - _minz;
- //cout << "\n ---> Range of values x,y,z: "
- // << _dx << " " << _dy << " " << _dz << " cm in z "
- // << "\n-----------------------------------------------------------" << endl;
-}
-
-void Cartesian3DMagneticFieldMap::GetFieldValue(const double point[4],
- double *Bfield ) const
-{
-
- double x = point[0];
- double y = point[1];
- double z = point[2] + _zOffset;
-
- // Check that the point is within the defined region
- if ( x>=_minx && x<=_maxx &&
- y>=_miny && y<=_maxy &&
- z>=_minz && z<=_maxz ) {
-
- // Position of given point within region, normalized to the range
- // [0,1]
- double xfraction = (x - _minx) / _dx;
- double yfraction = (y - _miny) / _dy;
- double zfraction = (z - _minz) / _dz;
-
- if (_invertX) { xfraction = 1 - xfraction;}
- if (_invertY) { yfraction = 1 - yfraction;}
- if (_invertZ) { zfraction = 1 - zfraction;}
-
- // Need addresses of these to pass to modf below.
- // modf uses its second argument as an OUTPUT argument.
- double xdindex, ydindex, zdindex;
-
- // Position of the point within the cuboid defined by the
- // nearest surrounding tabulated points
- double xlocal = ( std::modf(xfraction*(_nx-1), &xdindex));
- double ylocal = ( std::modf(yfraction*(_ny-1), &ydindex));
- double zlocal = ( std::modf(zfraction*(_nz-1), &zdindex));
-
- // The indices of the nearest tabulated point whose coordinates
- // are all less than those of the given point
- int xindex = static_cast<int>(xdindex);
- int yindex = static_cast<int>(ydindex);
- int zindex = static_cast<int>(zdindex);
-
-
-#ifdef DEBUG_INTERPOLATING_FIELD
- cout << "Local x,y,z: " << xlocal << " " << ylocal << " " << zlocal << endl;
- cout << "Index x,y,z: " << xindex << " " << yindex << " " << zindex << endl;
- double valx0z0, mulx0z0, valx1z0, mulx1z0;
- double valx0z1, mulx0z1, valx1z1, mulx1z1;
- valx0z0= table[xindex ][0][zindex]; mulx0z0= (1-xlocal) * (1-zlocal);
- valx1z0= table[xindex+1][0][zindex]; mulx1z0= xlocal * (1-zlocal);
- valx0z1= table[xindex ][0][zindex+1]; mulx0z1= (1-xlocal) * zlocal;
- valx1z1= table[xindex+1][0][zindex+1]; mulx1z1= xlocal * zlocal;
-#endif
-
- // Full 3-dimensional version
- Bfield[0] =
- _xField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) +
- _xField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal +
- _xField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) +
- _xField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal +
- _xField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) +
- _xField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal +
- _xField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) +
- _xField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal ;
- Bfield[1] =
- _yField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) +
- _yField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal +
- _yField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) +
- _yField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal +
- _yField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) +
- _yField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal +
- _yField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) +
- _yField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal ;
- Bfield[2] =
- _zField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) +
- _zField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal +
- _zField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) +
- _zField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal +
- _zField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) +
- _zField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal +
- _zField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) +
- _zField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal ;
-
- } else {
- Bfield[0] = 0.0;
- Bfield[1] = 0.0;
- Bfield[2] = 0.0;
- }
-}
-
-/*
-int main()
-{
- Cartesian3DMagneticFieldMap field("C:/work/magfield/magfield3DMap/ThreeDFieldMap.dat", 0.,0.,0.);
- double pos[4];
- pos[0]=0.;
- pos[1]=0.;
- pos[2]=0.;
- pos[3]=0.;
- double B[3];
-
- for(double x=-0.05; x<=0.05; x+=.005)
- {
- for(double y=-0.05; y<=0.17; y+=.005)
- {
- for(double z=-0.26; z<=0.1; z+=.05)
- {
- pos[0]=x;
- pos[1] =y;
- pos[2] = z;
- field.GetFieldValue(pos, B);
- //cout << pos[0] << " " << pos[1] << " " << pos[2] << " " << B[0] << " " << B[1] << " " << B[2] << endl;
- }
- }
- }
-
- pos[0]=-0.01;
- pos[1]=0.038;
- pos[2]=-0.02;
- field.GetFieldValue(pos, B);
- //cout << pos[0] << " " << pos[1] << " " << pos[2] << " " << B[0] << " " << B[1] << " " << B[2] << endl;
- return 0;
-}
-*/
lcdd/src
diff -N CellReadout.cc
--- CellReadout.cc 26 Jun 2013 01:36:23 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/CellReadout.cc,v 1.2 2013/06/26 01:36:23 jeremy Exp $
-
-#include "lcdd/detectors/CellReadout.hh"
-
-CellReadout::CellReadout()
-{
-}
-
-CellReadout::~CellReadout()
-{
-}
-
-/**
- * Get the list of field names.
- */
-const CellReadout::FieldNames& CellReadout::fieldNames()
-{
- return m_fieldNames;
-}
lcdd/src
diff -N CellReadout2D.cc
--- CellReadout2D.cc 26 Jun 2013 01:36:23 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,167 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/CellReadout2D.cc,v 1.5 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/CellReadout2D.hh"
-
-// STL
-#include <cmath>
-#include <iostream>
-#include <stdexcept>
-
-CellReadout2D::CellReadout2D(double cellSizeX, double cellSizeY)
-{
- m_cellSizeX = cellSizeX;
- m_cellSizeY = cellSizeY;
-
- m_fieldNames.push_back("ix");
- m_fieldNames.push_back("iy");
-}
-
-CellReadout2D::~CellReadout2D()
-{
-}
-
-CellReadout2D::Position2D CellReadout2D::position(CellReadout2D::CellId cellId)
-{
- Position2D pos;
- pos.first = getCellPositionX(cellId[0]);
- pos.second = getCellPositionY(cellId[1]);
- return pos;
-}
-
-CellReadout::CellId CellReadout2D::cellId(Position2D pos)
-{
- return createCell(getXIndex(pos.first), getYIndex(pos.second));
-}
-
-/**
- * Create a list of neighbor cells from a cell ID.
- */
-CellReadout::Neighbors CellReadout2D::neighbors(CellId cellId)
-{
- Neighbors neighbors;
- int ix, iy;
-
- // top left
- ix = cellId[0] - 1;
- if (ix == 0)
- ix = -1;
- iy = cellId[1] + 1;
- if (iy == 0)
- iy = 1;
- neighbors.push_back(createCell(ix, iy));
-
- // top middle
- ix = cellId[0];
- iy = cellId[1] + 1;
- if (iy == 0)
- iy = 1;
- neighbors.push_back(createCell(ix, iy));
-
- // top right
- ix = cellId[0];
- if (ix == 0)
- ix = 1;
- iy = cellId[1] + 1;
- if (iy == 0)
- iy = 1;
- neighbors.push_back(createCell(ix, iy));
-
- // middle left
- ix = cellId[0] - 1;
- if (ix == 0)
- ix = -1;
- iy = cellId[1];
- neighbors.push_back(createCell(ix, iy));
-
- // middle right
- ix = cellId[0] + 1;
- if (ix == 0)
- ix = 1;
- iy = cellId[1];
- neighbors.push_back(createCell(ix, iy));
-
- // bottom left
- ix = cellId[0] - 1;
- if (ix == 0)
- ix = -1;
- iy = cellId[1] - 1;
- if (iy == 0)
- iy = -1;
- neighbors.push_back(createCell(ix - 1, iy - 1));
-
- // bottom middle
- ix = cellId[0];
- iy = cellId[1] - 1;
- if (iy == 0)
- iy = -1;
- neighbors.push_back(createCell(ix, iy - 1));
-
- // bottom right
- ix = cellId[0] + 1;
- if (ix == 0)
- ix = 1;
- iy = cellId[1] - 1;
- if (iy == 0)
- iy = -1;
- neighbors.push_back(createCell(ix, iy - 1));
-
- return neighbors;
-
-}
-
-double CellReadout2D::getCellSizeX()
-{
- return m_cellSizeX;
-}
-
-double CellReadout2D::getCellSizeY()
-{
- return m_cellSizeY;
-}
-
-int CellReadout2D::getXIndex(double x)
-{
- return getCellIndex(x, m_cellSizeX);
-}
-
-int CellReadout2D::getYIndex(double y)
-{
- return getCellIndex(y, m_cellSizeY);
-}
-
-double CellReadout2D::getCellCoordinate(int i, double cellSize)
-{
- double v = i * cellSize;
- if (v > 0)
- v -= cellSize / 2;
- else
- v += cellSize / 2;
- return v;
-}
-
-int CellReadout2D::getCellIndex(double c, double cellSize)
-{
- int v = std::ceil(c / cellSize);
- if (v == 0)
- v -= 1;
- return v;
-}
-
-double CellReadout2D::getCellPositionX(int ix)
-{
- return getCellCoordinate(ix, m_cellSizeX);
-}
-
-double CellReadout2D::getCellPositionY(int iy)
-{
- return getCellCoordinate(iy, m_cellSizeY);
-}
-
-CellReadout2D::CellId CellReadout2D::createCell(int x, int y)
-{
- CellId cell;
- cell.push_back(x);
- cell.push_back(y);
- return cell;
-}
lcdd/src
diff -N CellReadout2DSegmentation.cc
--- CellReadout2DSegmentation.cc 26 Jun 2013 01:36:23 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,82 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/CellReadout2DSegmentation.cc,v 1.5 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/CellReadout2DSegmentation.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-
-// Geant4
-#include "G4Step.hh"
-#include "G4Box.hh"
-
-// STL
-#include <cmath>
-
-CellReadout2DSegmentation::CellReadout2DSegmentation(double cellSizeX, double cellSizeY) :
- G4Segmentation(G4Segmentation::eNonprojective, 2)
-{
- m_readout = new CellReadout2D(cellSizeX, cellSizeY);
- setBinNames();
-}
-
-CellReadout2DSegmentation::~CellReadout2DSegmentation()
-{
- delete m_readout;
-}
-
-G4ThreeVector CellReadout2DSegmentation::getGlobalHitPos(const G4Step* aStep)
-{
- // TODO: implement me
-}
-
-void CellReadout2DSegmentation::setBins(const G4Step* aStep)
-{
- // Set state from current step.
- setup(aStep);
-
- // Compute the global mid-point of the step.
- G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
-
- // Compute the local step position from the global mid-point.
- G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aStep, globalStepPos);
-
- // Compute the X and Y readout coordinates from the local position.
- CellReadout2D::Position2D localXY;
- localXY.first = localStepPos.x();
- localXY.second = localStepPos.y();
- CellReadout2D::Position2D xy;
- //= m_readout->localToReadoutCoordinates(localXY);
-
- // Get the cell for the position.
- CellReadout2D::CellId cell = m_readout->cellId(xy);
-
- // Set bin values.
- this->setBin(0, xy.first);
- this->setBin(1, xy.second);
-}
-
-void CellReadout2DSegmentation::setBinNames()
-{
- addBinName("ix");
- addBinName("iy");
-}
-
-void CellReadout2DSegmentation::setup(const G4Step* aStep)
-{
- // Set dimensions from box volume.
- G4VSolid* solid = ReadoutUtil::getSolidFromStepPoint(aStep->GetPreStepPoint());
- G4Box* box = dynamic_cast<G4Box*>(solid);
- if (0 == box) {
- std::cerr << "Volume is not a box" << std::endl;
- G4Exception("", "", FatalException, "CellReadout2D points to shape that is not a box.");
- }
- //m_readout->setReadoutDimensionX(box->GetXHalfLength() * 2);
- //m_readout->setReadoutDimensionY(box->GetYHalfLength() * 2);
-}
-
-CellReadout2D::Position2D CellReadout2DSegmentation::localToReadoutCoordinates(G4ThreeVector& vec)
-{
- CellReadout2D::Position2D xy;
- //xy.first = vec.x() + m_readout->getReadoutDimensionX() / 2.0;
- //xy.second = vec.y() + m_readout->getReadoutDimensionY() / 2.0;
- return xy;
-}
lcdd/src
diff -N Cerenkov.cc
--- Cerenkov.cc 26 Jun 2013 01:36:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,161 +0,0 @@
-///////////////////////////////////////////////////////////////////////
-// Class to calculate Number of photons created by Cerenkov Radiation
-////////////////////////////////////////////////////////////////////////
-// Hans Wenzel
-//
-// The algorithm is stripped from the geant 4 class
-// G4Cerenkov.cc
-// but since we are only interested in the number of photons created don't need to
-// actually create optical phtons and put them on the stack.
-//--------------------------------------------------------------------------------------
-
-// LCDD
-#include "lcdd/detectors/Cerenkov.hh"
-
-// Geant4
-#include "G4Step.hh"
-#include "G4ThreeVector.hh"
-
-#include <iomanip>
-
-Cerenkov::Cerenkov()
-{
- Initialize();
-}
-//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-
-Cerenkov::~Cerenkov()
-{
-
-}
-
-//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-
-void Cerenkov::Initialize()
-{
- //
- // now get the Cerenkov Angle Integrals for all materials that have the refraction index defined
- //
- const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
- G4int numOfMaterials = G4Material::GetNumberOfMaterials();
- for (G4int i = 0; i < numOfMaterials; i++) {
- // Retrieve vector of refraction indices for the material
- // from the material's optical properties table
- G4Material* aMaterial = (*theMaterialTable)[i];
- G4MaterialPropertiesTable* aMaterialPropertiesTable = aMaterial->GetMaterialPropertiesTable();
- G4PhysicsOrderedFreeVector* CerAngleIntegrals = new G4PhysicsOrderedFreeVector();
- if (aMaterialPropertiesTable) {
- G4MaterialPropertyVector* theRefractionIndexVector = aMaterialPropertiesTable->GetProperty("RINDEX");
- if (theRefractionIndexVector) {
- // Retrieve the first refraction index in vector
- // of (photon energy, refraction index) pairs
- G4double currentRI = (*theRefractionIndexVector)[0];
- if (currentRI > 1.0) {
- // Create first (photon energy, Cerenkov Integral) pair
- G4double currentPM = theRefractionIndexVector->Energy(0);
- G4double currentCAI = 0.0;
- CerAngleIntegrals->InsertValues(currentPM, currentCAI);
- // Set previous values to current ones prior to loop
- G4double prevPM = currentPM;
- G4double prevCAI = currentCAI;
- G4double prevRI = currentRI;
- // loop over all (photon energy, refraction index)
- // pairs stored for this material
- for (size_t ii = 1; ii < theRefractionIndexVector->GetVectorLength(); ii++) {
- currentRI = (*theRefractionIndexVector)[ii];
- currentPM = theRefractionIndexVector->Energy(ii);
- currentCAI = 0.5 * (1.0 / (prevRI * prevRI) + 1.0 / (currentRI * currentRI));
- currentCAI = prevCAI + (currentPM - prevPM) * currentCAI;
- CerAngleIntegrals->InsertValues(currentPM, currentCAI);
- prevPM = currentPM;
- prevCAI = currentCAI;
- prevRI = currentRI;
- }
- }
- G4cout << "Material: " << aMaterial->GetName() << G4endl;
- G4cout << "Refraction Index: " << G4endl;
- G4cout << "=================" << G4endl;
- theRefractionIndexVector->DumpValues();
- G4cout << "Cerenkov angle Integrals: " << G4endl;
- G4cout << "=========================" << G4endl;
- CerAngleIntegrals->DumpValues();
- CAI.push_back(aMaterial->GetName());
- CerenkovAngleIntegrals.push_back(CerAngleIntegrals);
- RefractionIndeces.push_back(theRefractionIndexVector);
- }
- }
- }
-}
-
-//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-// This routine computes the number of Cerenkov photons produced per
-// GEANT-unit (millimeter) in the current medium.
-// ^^^^^^^^^^
-
-G4double Cerenkov::GetAverageNumberOfPhotons(const G4double charge, const G4double beta, const G4String Material) const
-{
- G4bool Ceren = false;
- G4int MaterialIndex = -1;
- //
- // check if optical properties are defined for this material:
- //
- for (unsigned int ii = 0; ii < CAI.size(); ii++) {
- if (CAI[ii] == Material) {
- MaterialIndex = ii;
- Ceren = true;
- break;
- }
- }
- if (!Ceren)
- return 0.0;
- const G4double Rfact = 369.81 / (eV * cm);
- if (beta <= 0.0)
- return 0.0;
- if (abs(charge) == 0.0)
- return 0.0;
-
- G4double BetaInverse = 1. / beta;
- // Min and Max photon energies
- G4double Pmin = RefractionIndeces[MaterialIndex]->GetMinLowEdgeEnergy();
- G4double Pmax = RefractionIndeces[MaterialIndex]->GetMaxLowEdgeEnergy();
-
- // Min and Max Refraction Indices
- G4double nMin = RefractionIndeces[MaterialIndex]->GetMinValue();
- G4double nMax = RefractionIndeces[MaterialIndex]->GetMaxValue();
-
- // Max Cerenkov Angle Integral
- G4double CAImax = CerenkovAngleIntegrals[MaterialIndex]->GetMaxValue();
- G4double dp, ge;
-
- // If n(Pmax) < 1/Beta -- no photons generated
-
- if (nMax < BetaInverse) {
- dp = 0;
- ge = 0;
- } // otherwise if n(Pmin) >= 1/Beta -- photons generated
-
- else if (nMin > BetaInverse) {
- dp = Pmax - Pmin;
- ge = CAImax;
- } // If n(Pmin) < 1/Beta, and n(Pmax) >= 1/Beta, then
- // we need to find a P such that the value of n(P) == 1/Beta.
- // Interpolation is performed by the GetEnergy() and
- // Value() methods of the G4MaterialPropertiesTable and
- // the GetValue() method of G4PhysicsVector.
-
- else {
- Pmin = RefractionIndeces[MaterialIndex]->GetEnergy(BetaInverse);
- dp = Pmax - Pmin;
-
- // need boolean for current implementation of G4PhysicsVector
- // ==> being phased out
- G4bool isOutRange;
- G4double CAImin = CerenkovAngleIntegrals[MaterialIndex]->GetValue(Pmin, isOutRange);
- ge = CAImax - CAImin;
- }
-
- // Calculate number of photons
- G4double NumPhotons = Rfact * charge / eplus * charge / eplus * (dp - ge * BetaInverse * BetaInverse);
- return NumPhotons;
-}
-
lcdd/src
diff -N G4BoxDipole.cc
--- G4BoxDipole.cc 26 Jun 2013 01:36:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,32 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4BoxDipole.cc,v 1.3 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/bfield/G4BoxDipole.hh"
-
-G4BoxDipole::G4BoxDipole(double x, double y, double z, double dx, double dy, double dz, double bx, double by, double bz) :
- _x(x), _y(y), _z(z), _dx(dx), _dy(dy), _dz(dz), _bx(bx), _by(by), _bz(bz)
-{
- _maxx = x + dx;
- _maxy = y + dy;
- _maxz = z + dz;
-
- _minx = x - dx;
- _miny = y - dy;
- _minz = z - dz;
-}
-
-void G4BoxDipole::GetFieldValue(const double point[3], double* bfield) const
-{
- if (point[0] < _minx || point[0] > _maxx)
- return;
- if (point[1] < _miny || point[1] > _maxy)
- return;
- if (point[2] < _minz || point[2] > _maxz)
- return;
-
- bfield[0] += _bx;
- bfield[1] += _by;
- bfield[2] += _bz;
-
- //std::cout << point[0] << ", " << point[1] << ", " << point[2] << " --> " << bfield[0] << ", " << bfield[1] << ", " << bfield[2] << std::endl;
-}
lcdd/src
diff -N G4CalorimeterHit.cc
--- G4CalorimeterHit.cc 26 Jun 2013 01:36:23 -0000 1.15
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,99 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4CalorimeterHit.cc,v 1.15 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/hits/G4CalorimeterHit.hh"
-
-// Geant4
-#ifdef G4VIS_USE
-#include "G4VVisManager.hh"
-#include "G4VisAttributes.hh"
-#include "G4Circle.hh"
-#include "G4Point3D.hh"
-#include "G4Transform3D.hh"
-#endif
-
-G4Allocator<G4CalorimeterHit> G4CalorimeterHitAllocator;
-
-G4CalorimeterHit::G4CalorimeterHit() :
- G4VHit(), m_edep(0)
-{
- ;
-}
-
-G4CalorimeterHit::G4CalorimeterHit(G4double edep, G4ThreeVector globalCellPos) :
- G4VHit(), m_edep(edep), m_pos(globalCellPos)
-{
- ;
-}
-
-G4CalorimeterHit::~G4CalorimeterHit()
-{
- ;
-}
-
-G4CalorimeterHit::G4CalorimeterHit(const G4CalorimeterHit &right) :
- G4VHit()
-{
- m_edep = right.m_edep;
- m_pos = right.m_pos;
-}
-
-const G4CalorimeterHit& G4CalorimeterHit::operator=(const G4CalorimeterHit &right)
-{
- m_edep = right.m_edep;
- m_pos = right.m_pos;
-
- return *this;
-}
-
-bool G4CalorimeterHit::operator==(const G4CalorimeterHit &right)
-{
- return (m_pos == right.m_pos);
-}
-
-#ifdef G4VIS_USE
-void G4CalorimeterHit::Draw()
-{
- G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
-
- if(pVVisManager)
- {
- G4Point3D p3D = G4Point3D( m_pos );
- G4Circle chit(p3D);
- chit.SetScreenDiameter(3.0);
- chit.SetFillStyle(G4Circle::filled);
-
- G4Colour col(1.0,0.,1.0);
-
- chit.SetVisAttributes(G4VisAttributes( col ) );
- pVVisManager->Draw( chit );
- }
-}
-#endif
-
-void G4CalorimeterHit::printMcpHitContribs(std::ostream& os)
-{
- printMcpHitContribsHeader(os);
-
- for (McpHitContribList::iterator iter = m_particleList.begin(); iter != m_particleList.end(); iter++) {
- (*iter).printOut(os);
- }
-}
-
-void G4CalorimeterHit::printMcpHitContribsHeader(std::ostream& os)
-{
- os << "McpHitContribs" << std::endl;
- os << "trackID" << '\t' << "edep" << '\t' << '\t' << "PdgId" << '\t' << "time" << std::endl;
-}
-
-void G4CalorimeterHit::Print()
-{
- std::cout << *this << std::endl;
-}
-
-std::ostream& operator<<(std::ostream &os, const G4CalorimeterHit& hit)
-{
- os << hit.getPos() << " " << G4BestUnit(hit.getEdep(), "Energy") << std::endl;
- return os;
-}
-
lcdd/src
diff -N G4CalorimeterSD.cc
--- G4CalorimeterSD.cc 26 Jun 2013 01:36:23 -0000 1.42
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,278 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4CalorimeterSD.cc,v 1.42 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/G4CalorimeterSD.hh"
-#include "lcdd/detectors/G4Segmentation.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-#include "lcdd/detectors/PositionComparator.hh"
-#include "lcdd/hits/McpHitContrib.hh"
-#include "lcdd/id/IdFactory.hh"
-#include "lcdd/id/IdManager.hh"
-
-// Geant4
-#include "G4Track.hh"
-#include "G4StepPoint.hh"
-#include "G4Timer.hh"
-#include "G4Geantino.hh"
-
-// STL
-#include <iostream>
-#include <string>
-#include <vector>
-
-using std::vector;
-
-G4CalorimeterSD::G4CalorimeterSD(G4String sdName, G4String hcName, G4Segmentation* sdSeg, HitComparator* compare) :
- G4SensitiveDetector(sdName, hcName, G4SensitiveDetector::eCalorimeter), m_segmentation(sdSeg)
-{
- m_hitsCollections.push_back(m_collection);
- m_hits.clear();
- hits_vector.clear();
- hits_vector.push_back(m_hits);
- if (compare == 0)
- m_hitCompare = new PositionComparator();
- else
- m_hitCompare = compare;
-}
-
-G4CalorimeterSD::G4CalorimeterSD(G4String sdName, const vector<G4String>& hcNames, G4Segmentation* sdSeg, HitComparator* compare) :
- G4SensitiveDetector(sdName, hcNames, G4SensitiveDetector::eCalorimeter), m_segmentation(sdSeg)
-{
- m_hits.clear();
- hits_vector.clear();
- hits_vector.push_back(m_hits);
- for (int i = 0; i < (int) hcNames.size(); i++) {
- hits_vector.push_back(m_hits);
- hits_vector[i].clear();
- m_hitsCollections.push_back(m_collection);
- }
-
- if (compare == 0) {
- m_hitCompare = new PositionComparator();
- } else {
- m_hitCompare = compare;
- }
-}
-
-G4CalorimeterSD::~G4CalorimeterSD()
-{
-}
-
-bool G4CalorimeterSD::isValidVolume(G4LogicalVolume* lv)
-{
- bool valid = G4SensitiveDetector::isValidVolume(lv);
-
- if (valid && m_segmentation != 0) {
- valid = m_segmentation->isValidSolid(lv->GetSolid());
- }
-
- return valid;
-}
-
-void G4CalorimeterSD::Initialize(G4HCofThisEvent *HCE)
-{
- clearHits();
-
- // new cal hits collection
- for (int i = 0; i < getNumberOfHitsCollections(); i++) {
- m_hitsCollections[i] = new G4CalorimeterHitsCollection(GetName(), collectionName[i]);
-
- // set HCID
- if (getHCID(i) < 0) {
- setHCID(GetCollectionID(i), i);
- }
-
- // add collection to HC of event
- HCE->AddHitsCollection(getHCID(i), m_hitsCollections[i]);
- }
-}
-
-G4Segmentation* G4CalorimeterSD::getSegmentation() const
-{
- return m_segmentation;
-}
-
-G4bool G4CalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
-{
-#ifdef G4VERBOSE
- if (getVerbose() > 0)
- {
- std::cout << "G4CalorimeterSD::ProcessHits - " << this->GetName() << std::endl;
- }
-#endif
-
- // set cached step
- G4SensitiveDetector::ProcessHits(aStep, 0);
-
- // get the edep
- G4double theEdep = edep();
-
- // This needs to be a <= comparison for cutting on 0,
- // Geantinos, which always have 0 edep, are allowed.
- if (theEdep <= getEcut() && !isGeantino()) {
-#ifdef G4VERBOSE
- if (getVerbose() > 2) {
- std::cout << "G4CalorimeterSD::ProcessHits - cut on edep " << theEdep << std::endl;
- }
-#endif
- return false;
- }
-
- // Get global cell pos from segmentation.
- G4ThreeVector globalCellPos = m_segmentation->getGlobalHitPos(aStep);
-
- // Reset the segmentation bin values.
- m_segmentation->resetBins();
-
- // Set the segmentation bin values from the step.
- m_segmentation->setBins(aStep);
-
- // Create a 64-bit ID.
- Id64bit id64 = makeId();
-
- // DEBUG: Compute step midpoint and compare to the cell pos
-#ifdef G4VERBOSE
- if ( getVerbose() > 2 ) {
- G4ThreeVector globalMidPos = midPosition();
- std::cout << "globalMidPos " << globalMidPos << std::endl;
- std::cout << "globalCellPos - globalMidPos = " << globalCellPos - globalMidPos << std::endl;
- }
-#endif
-
- // find hit by simple lkp of new hit with above info
- G4CalorimeterHit* thisHit = new G4CalorimeterHit(theEdep, globalCellPos);
- thisHit->setId64bit(id64.getId0(), id64.getId1());
- G4CalorimeterHit* fndHit = 0;
-
- // hit is not found?
- if (!(fndHit = findHit(thisHit))) {
-
-#ifdef G4VERBOSE
- if (getVerbose() > 1) {
- std::cout << "G4CalorimeterSD::ProcessHits - new hit" << std::endl;
- }
-#endif
- // add it to lkp map
- hits_vector[0].push_back(thisHit);
-
- // add to the HC
- m_hitsCollections[0]->insert(thisHit);
- }
- // found a hit
- else {
-
-#ifdef G4VERBOSE
- if ( getVerbose() > 2 ) {
- std::cout << "G4CalorimeterSD::ProcessHits - existing hit" << std::endl;
- }
-#endif
-
- // don't need to insert thisHit, so delete it
- delete thisHit;
- thisHit = 0;
-
- // incr total edep of the hit
- fndHit->incrEdep(theEdep);
-
- // for setting contrib
- thisHit = fndHit;
- }
-
- // add McpHitContrib to this hit, setting info from step info
- thisHit->addMcpHitContrib(McpHitContrib(aStep));
-
- return true;
-}
-
-G4CalorimeterHit* G4CalorimeterSD::findHit(G4CalorimeterHit* aHit) const
-{
- G4CalorimeterHit* fndHit = 0;
- for (G4CalorimeterHitList::const_iterator iter = hits_vector[0].begin(); iter != hits_vector[0].end(); iter++) {
- if (m_hitCompare->compare(**iter, *aHit)) {
- fndHit = *iter;
- break;
- }
- }
- return fndHit;
-}
-
-G4CalorimeterHit* G4CalorimeterSD::findHit(G4CalorimeterHit* aHit, G4int nHC) const
-{
- G4CalorimeterHit* fndHit = 0;
- for (G4CalorimeterHitList::const_iterator iter = hits_vector[nHC].begin(); iter != hits_vector[nHC].end(); iter++) {
- if (m_hitCompare->compare(**iter, *aHit)) {
- fndHit = *iter;
- break;
- }
- }
- return fndHit;
-}
-
-std::ostream& G4CalorimeterSD::printHits(std::ostream& os)
-{
- for (int i = 0; i < getNumberOfHitsCollections(); i++) {
- os << getHitsCollection(i)->GetName() << std::endl;
- for (G4CalorimeterHitList::const_iterator iter = hits_vector[i].begin(); iter != hits_vector[i].end(); iter++) {
- os << " " << **iter;
- }
- }
- os << std::endl;
- return os;
-}
-
-void G4CalorimeterSD::EndOfEvent(G4HCofThisEvent *)
-{
-#ifdef G4VERBOSE
- if ( getVerbose() > 1 ) {
- printHits( std::cout );
- }
-#endif
-}
-
-std::ostream& G4CalorimeterSD::printBasicInfo(std::ostream& os)
-{
- G4SensitiveDetector::printBasicInfo(os);
- os << "segmentation type: " << m_segmentation->getTypeString() << std::endl;
- os << "segmentation bins:";
- for (std::vector<std::string>::const_iterator it = m_segmentation->getBinNames().begin(); it != m_segmentation->getBinNames().end(); it++) {
- os << " " << *it;
- }
- os << std::endl;
- return os;
-}
-
-double G4CalorimeterSD::getEdep() const
-{
- double edep = 0.0;
- for (G4CalorimeterHitList::const_iterator it = hits_vector[0].begin(); it != hits_vector[0].end(); it++) {
- edep += (*it)->getEdep();
- }
- return edep;
-}
-
-double G4CalorimeterSD::getEdep(G4int nHC) const
-{
- double edep = 0.0;
- for (G4CalorimeterHitList::const_iterator it = hits_vector[nHC].begin(); it != hits_vector[nHC].end(); it++) {
- edep += (*it)->getEdep();
- }
- return edep;
-}
-
-void G4CalorimeterSD::clearHits()
-{
- for (int i = 0; i < getNumberOfHitsCollections(); i++) {
- hits_vector[i].clear();
- }
-}
-
-G4CalorimeterSD::G4CalorimeterHitList G4CalorimeterSD::getCalorimeterHitList()
-{
- return hits_vector[0];
-}
-
-G4CalorimeterSD::G4CalorimeterHitList G4CalorimeterSD::getCalorimeterHitList(G4int nHC)
-{
- return hits_vector[nHC];
-}
-
lcdd/src
diff -N G4Dipole.cc
--- G4Dipole.cc 26 Jun 2013 01:36:23 -0000 1.7
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,114 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4Dipole.cc,v 1.7 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/bfield/G4Dipole.hh"
-
-// STL
-#include <iostream>
-#include <cmath>
-
-/**
- * Apply polynomial fit of dipole field, with variable number of coefficients
- * read from the input XML file.
- */
-void G4Dipole::GetFieldValue(const double Point[3], double* Bfield) const
-{
- //std::cout << "G4Dipole::GetFieldValue" << std::endl;
-
- //std::cout << "point = " << Point[0] << " " << Point[1] << " " << Point[2] << std::endl;
- //std::cout << "BEFORE --> bfield = " << Bfield[0] << " " << Bfield[1] << " " << Bfield[2] << std::endl;
-
- double bx = 0;
- double z = Point[2];
- double r = sqrt(Point[0] * Point[0] + Point[1] * Point[1]);
-
- // Check if z coordinate is within dipole z bounds.
- if (z > m_zmin && z < m_zmax && r < m_rmax) {
-
- // Convert to absolute value z and apply specified length unit.
- double zc = fabs(z) / m_lunit;
-
- //std::cout << "zc = " << zc << std::endl;
-
- // Apply all coefficients to this z coordinate.
- for (size_t i = 0; i < m_coeffs.size(); ++i) {
- bx += m_coeffs[i] * pow(zc, i);
- }
-
- // Convert to specified field unit.
- bx *= m_funit;
-
- // Flip sign for negative z.
- if (z < 0) {
- bx = -bx;
- }
-
- // Add Bx to the input Bfield.
- Bfield[0] += bx;
- }
-
- //std::cout << "AFTER --> bfield = " << Bfield[0] << " " << Bfield[1] << " " << Bfield[2] << std::endl << std::endl;
- //std::cout << Point[2] << " " << Bfield[0] << std::endl;
-
- return;
-}
-
-void G4Dipole::setZMax(double zmax)
-{
- m_zmax = zmax;
-}
-
-double G4Dipole::getZMax()
-{
- return m_zmax;
-}
-
-void G4Dipole::setZMin(double zmin)
-{
- m_zmin = zmin;
-}
-
-double G4Dipole::getZMin()
-{
- return m_zmin;
-}
-
-void G4Dipole::setRMax(double rmax)
-{
- m_rmax = rmax;
-}
-
-double G4Dipole::getRMax()
-{
- return m_rmax;
-}
-
-void G4Dipole::addCoeff(double coeff)
-{
- m_coeffs.push_back(coeff);
-}
-
-const std::vector<double>& G4Dipole::getCoeffs()
-{
- return m_coeffs;
-}
-
-void G4Dipole::setFieldUnit(double unit)
-{
- m_funit = unit;
-}
-
-double G4Dipole::getFieldUnit()
-{
- return m_funit;
-}
-
-void G4Dipole::setLengthUnit(double unit)
-{
- m_lunit = unit;
-}
-
-double G4Dipole::getLengthUnit()
-{
- return m_lunit;
-}
lcdd/src
diff -N G4GlobalGridXYSegmentation.cc
--- G4GlobalGridXYSegmentation.cc 26 Jun 2013 01:36:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,71 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4GlobalGridXYSegmentation.cc,v 1.3 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/G4GlobalGridXYSegmentation.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-
-// Geant4
-#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 G4GridXYZSegmentation.cc
--- G4GridXYZSegmentation.cc 26 Jun 2013 01:36:23 -0000 1.9
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,144 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4GridXYZSegmentation.cc,v 1.9 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/G4GridXYZSegmentation.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-
-// Geant4
-#include "G4NavigationHistory.hh"
-
-G4GridXYZSegmentation::G4GridXYZSegmentation(double gridSizeX, double gridSizeY, double gridSizeZ) :
- G4Segmentation(G4Segmentation::eNonprojective), m_gridSizeX(gridSizeX), m_gridSizeY(gridSizeY), m_gridSizeZ(gridSizeZ)
-{
- setBinNames();
-}
-
-G4GridXYZSegmentation::~G4GridXYZSegmentation()
-{
-}
-
-G4ThreeVector G4GridXYZSegmentation::getGlobalHitPos(const G4Step* aStep)
-{
- // compute midpoint
- G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
-
- // figure local step pos using touchable and global midpoint
- G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aStep, globalStepPos);
-
- // local cell pos
- G4ThreeVector localCellPos = this->getLocalHitPos(localStepPos);
-
- // global cell pos
- G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal(aStep, localCellPos);
-
- return globalCellPos;
-}
-
-void G4GridXYZSegmentation::setBins(const G4Step* aStep)
-{
- // Compute the midpoint of the step.
- G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
-
- // Transform from global coordinate system to local coordinate system of volume pointed to by this step.
- G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aStep, globalStepPos);
-
- // Compute the bin values.
- int binX = computeBinX(localStepPos);
- int binY = computeBinY(localStepPos);
- int binZ = computeBinZ(localStepPos);
-
- // Set the bins.
- int idx = 0;
-
- setBin(idx, binX);
- ++idx;
-
- setBin(idx, binY);
- ++idx;
-
- setBin(idx, binZ);
- ++idx;
-}
-
-int G4GridXYZSegmentation::computeBinX(const G4ThreeVector& localStepPos)
-{
- int ret;
- if (m_gridSizeX != 0) {
- ret = G4Segmentation::computeBin(localStepPos.x(), m_gridSizeX);
- } else {
- ret = 0;
- }
- return ret;
-}
-
-int G4GridXYZSegmentation::computeBinY(const G4ThreeVector& localStepPos)
-{
- int ret;
- if (m_gridSizeY != 0) {
- ret = G4Segmentation::computeBin(localStepPos.y(), m_gridSizeY);
- } else {
- ret = 0;
- }
- return ret;
-}
-
-int G4GridXYZSegmentation::computeBinZ(const G4ThreeVector& localStepPos)
-{
- int ret;
- if (m_gridSizeZ != 0) {
- ret = G4Segmentation::computeBin(localStepPos.z(), m_gridSizeZ);
- } else {
- ret = 0;
- }
- return ret;
-}
-
-double G4GridXYZSegmentation::computeDimX(int bin)
-{
- return G4Segmentation::computeDim(bin, m_gridSizeX);
-}
-
-double G4GridXYZSegmentation::computeDimY(int bin)
-{
- return G4Segmentation::computeDim(bin, m_gridSizeY);
-}
-
-double G4GridXYZSegmentation::computeDimZ(int bin)
-{
- 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 -N G4LimitSet.cc
--- G4LimitSet.cc 26 Jun 2013 01:36:23 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,123 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4LimitSet.cc,v 1.4 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/geant4/G4LimitSet.hh"
-
-// Geant4
-#include "G4Track.hh"
-
-/* Code for any particle. */
-const G4LimitSet::ParticleType G4LimitSet::ANY_PARTICLE = "*";
-
-/* Code for no limit, as -1 is never a valid limit. */
-const G4LimitSet::LimitValueType G4LimitSet::LIMIT_NOT_SET = -1;
-
-/* Keys to limit value maps for each parameter. */
-const G4LimitSet::LimitNameKeyType G4LimitSet::STEP_LENGTH_MAX_KEY = "step_length_max";
-const G4LimitSet::LimitNameKeyType G4LimitSet::TRACK_LENGTH_MAX_KEY = "track_length_max";
-const G4LimitSet::LimitNameKeyType G4LimitSet::TIME_MAX_KEY = "time_max";
-const G4LimitSet::LimitNameKeyType G4LimitSet::EKIN_MIN_KEY = "ekin_min";
-const G4LimitSet::LimitNameKeyType G4LimitSet::RANGE_MIN_KEY = "range_min";
-
-/* Default values for limits. Taken from G4UserLimit ctor default args. */
-const G4LimitSet::LimitValueType G4LimitSet::STEP_LENGTH_MAX_DEFAULT = DBL_MAX;
-const G4LimitSet::LimitValueType G4LimitSet::TRACK_LENGTH_MAX_DEFAULT = DBL_MAX;
-const G4LimitSet::LimitValueType G4LimitSet::TIME_MAX_DEFAULT = DBL_MAX;
-const G4LimitSet::LimitValueType G4LimitSet::EKIN_MIN_DEFAULT = 0.;
-const G4LimitSet::LimitValueType G4LimitSet::RANGE_MIN_DEFAULT = 0.;
-
-G4LimitSet::G4LimitSet(const G4String& name) :
- G4UserLimits("G4LimitSet"), m_name(name)
-{
- m_limitsMap[STEP_LENGTH_MAX_KEY] = LimitMap();
- m_limitsMap[TRACK_LENGTH_MAX_KEY] = LimitMap();
- m_limitsMap[TIME_MAX_KEY] = LimitMap();
- m_limitsMap[EKIN_MIN_KEY] = LimitMap();
- m_limitsMap[RANGE_MIN_KEY] = LimitMap();
-}
-
-G4LimitSet::~G4LimitSet()
-{
-}
-
-G4double G4LimitSet::GetMaxAllowedStep(const G4Track& aTrack)
-{
- double maxStepLength = getLimitForParticle(STEP_LENGTH_MAX_KEY, aTrack);
- return maxStepLength == LIMIT_NOT_SET ? STEP_LENGTH_MAX_DEFAULT : maxStepLength;
-}
-
-G4double G4LimitSet::GetUserMaxTrackLength(const G4Track& aTrack)
-{
- double maxTrackLength = getLimitForParticle(TRACK_LENGTH_MAX_KEY, aTrack);
- return maxTrackLength == LIMIT_NOT_SET ? TRACK_LENGTH_MAX_DEFAULT : maxTrackLength;
-}
-
-G4double G4LimitSet::GetUserMaxTime(const G4Track& aTrack)
-{
- double maxTime = getLimitForParticle(TIME_MAX_KEY, aTrack);
- return maxTime == LIMIT_NOT_SET ? TIME_MAX_DEFAULT : maxTime;
-}
-
-G4double G4LimitSet::GetUserMinEkine(const G4Track& aTrack)
-{
- double minEkine = getLimitForParticle(EKIN_MIN_KEY, aTrack);
- return minEkine == LIMIT_NOT_SET ? EKIN_MIN_DEFAULT : minEkine;
-}
-
-G4double G4LimitSet::GetUserMinRange(const G4Track& aTrack)
-{
- double minRange = getLimitForParticle(RANGE_MIN_KEY, aTrack);
- return minRange == LIMIT_NOT_SET ? RANGE_MIN_DEFAULT : minRange;
-}
-
-const G4LimitSet::ParticleType G4LimitSet::getParticleType(const G4Track& aTrack)
-{
- return aTrack.GetDefinition()->GetParticleName();
-}
-
-void G4LimitSet::setLimitForParticle(LimitNameType limitName, ParticleType particleType, LimitValueType limitValue)
-{
- if (m_limitsMap.find(limitName) != m_limitsMap.end()) {
- m_limitsMap[limitName][particleType] = limitValue;
- } else {
- G4Exception("", "", FatalException, "Invalid limits map.");
- }
-}
-
-G4LimitSet::LimitValueType G4LimitSet::getLimitForParticle(LimitNameType limitName, ParticleType particleType)
-{
- //std::cout << "G4LimitSet::getLimitForParticle()" << std::endl;
- //std::cout << "limitName, particleType: " << limitName << " " << particleType << std::endl;
- LimitValueType limitValue = 0;
- if (m_limitsMap.find(limitName) != m_limitsMap.end()) {
- if (m_limitsMap[limitName].find(particleType) != m_limitsMap[limitName].end()) {
- limitValue = m_limitsMap[limitName][particleType];
- } else {
- if ((m_limitsMap[limitName].find(ANY_PARTICLE) != m_limitsMap[limitName].end())) {
- limitValue = m_limitsMap[limitName][ANY_PARTICLE];
- } else {
- limitValue = LIMIT_NOT_SET;
- }
- }
- } else {
- G4Exception("", "", FatalException, "Invalid limits map.");
- }
- //std::cout << "limitValue: " << limitValue << std::endl;
- return limitValue;
-}
-
-G4LimitSet::LimitValueType G4LimitSet::getLimitForParticle(LimitNameType limitName, const G4Track& aTrack)
-{
- return getLimitForParticle(limitName, getParticleType(aTrack));
-}
-
-void G4LimitSet::setName(const G4String& n)
-{
- m_name = n;
-}
-
-G4String& G4LimitSet::getName()
-{
- return m_name;
-}
-
lcdd/src
diff -N G4NonprojectiveCylinderSegmentation.cc
--- G4NonprojectiveCylinderSegmentation.cc 26 Jun 2013 01:36:23 -0000 1.16
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,260 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4NonprojectiveCylinderSegmentation.cc,v 1.16 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/G4NonprojectiveCylinderSegmentation.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-
-// Geant4
-#include "G4Tubs.hh"
-
-// STL
-#include <cmath>
-
-G4NonprojectiveCylinderSegmentation::G4NonprojectiveCylinderSegmentation(double gridSizePhi, double gridSizeZ) :
- G4Segmentation(G4Segmentation::eNonprojective), m_gridSizePhi(gridSizePhi), m_gridSizeZ(gridSizeZ)
-
-{
- setBinNames();
-}
-
-G4NonprojectiveCylinderSegmentation::~G4NonprojectiveCylinderSegmentation()
-{
-}
-
-G4ThreeVector G4NonprojectiveCylinderSegmentation::getGlobalHitPos(const G4Step* aStep)
-{
- // local cell pos
- G4ThreeVector localCellPos = getLocalHitPos(aStep);
-
- // global cell pos
- G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal(aStep, localCellPos);
-
- // DEBUG: print local, global cell pos
- //G4cout << "localCellPos " << localCellPos << G4endl;
- //G4cout << "globalCellPos " << globalCellPos << G4endl;
- //
-
- 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);
-
- // retrieve G4Tubs
- const G4Tubs* tubs = ReadoutUtil::getTubs(aStep);
-
- assert(tubs);
-
- // rcyl of cell = mid rad of current tubs
- double rcyl = ReadoutUtil::computeTubsMidRadius(tubs);
-
- // compute single delta phi in degrees
- double deltaPhi = computeDeltaPhi(aStep);
-
- // phi index
- int iphi = computeBinPhi(aStep);
-
- // z index in local
- int iz = computeBinZ(ReadoutUtil::transformGlobalToLocal(aStep, globalMidPos));
-
- // 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;
-}
-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)
-{
- // mid radius of current tubs
- double mid_rad_layer = ReadoutUtil::computeTubsMidRadius(aStep);
-
- // 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;
-}
-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;
-
- G4ThreeVector globalMidPos = ReadoutUtil::computeMidPos(aStep);
-
- int bphi = computeBinPhi(aStep);
- int bz = computeBinZ(globalMidPos);
-
- 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);
-
- const G4Tubs* tubs = ReadoutUtil::getTubs(aStep);
- assert(tubs);
-
- // compute single delta phi in degrees
- double deltaPhi = computeDeltaPhi(aStep);
-
- // step phi
- double stepPhi = globalMidPos.phi();
-
- if (stepPhi < 0) {
- stepPhi += 2.0 * ReadoutUtil::PI;
- }
-
- // phi index
- 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;
- //G4cout << "m_gridSizeZ <" << m_gridSizeZ << ">" << G4endl;
-
- return computeBin(localStepPos.z(), m_gridSizeZ);
-}
-
-bool G4NonprojectiveCylinderSegmentation::isValidSolid(G4VSolid* s)
-{
- bool valid = G4Segmentation::isValidSolid(s);
-
- if (valid) {
- if (s->GetEntityType() != "G4Tubs") {
- valid = false;
- }
- }
-
- return valid;
-}
lcdd/src
diff -N G4OpticalCalorimeter.cc
--- G4OpticalCalorimeter.cc 26 Jun 2013 01:36:23 -0000 1.10
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,116 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4OpticalCalorimeter.cc,v 1.10 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/G4OpticalCalorimeterSD.hh"
-#include "lcdd/detectors/G4Segmentation.hh"
-#include "lcdd/detectors/Cerenkov.hh"
-
-// Geant4
-#include "G4OpticalPhoton.hh"
-#include "G4TransportationManager.hh"
-#include "G4VProcess.hh"
-#include "G4Poisson.hh"
-
-using std::vector;
-
-/**
- * Constructor for the case only one Hit Collection is given.
- * In this case the only the energy deposited by aborbed Cerenkov
- * photons is stored. Probably this will be dropped in the
- * near future.
- */
-G4OpticalCalorimeterSD::G4OpticalCalorimeterSD(G4String sdName, G4String hcName, G4Segmentation* sdSeg, HitComparator* compare) :
- G4CalorimeterSD(sdName, hcName, sdSeg, compare)
-{
- CerenGenerator = 0;
-}
-
-/**
- * Constructor for multiple Hit Collections.
- *
- * The current implementation uses the first Hit Collection for the
- * Cerenkov Photons and the second Collection to store the ionization losses.
- * If more than 2 collections are given the additional Hit collections will
- * be ignored.
- */
-G4OpticalCalorimeterSD::G4OpticalCalorimeterSD(G4String sdName, const vector<G4String>& hcNames, G4Segmentation* sdSeg, HitComparator* compare) :
- G4CalorimeterSD(sdName, hcNames, sdSeg, compare)
-{
- CerenGenerator = 0;
-}
-
-G4OpticalCalorimeterSD::~G4OpticalCalorimeterSD()
-{
-}
-
-G4bool G4OpticalCalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory* tahis)
-{
- if (!CerenGenerator)
- CerenGenerator = new Cerenkov();
- G4int NCerenPhotons = 0;
- G4Track* theTrack = aStep->GetTrack();
- const G4double charge = theTrack->GetDefinition()->GetPDGCharge();
- G4StepPoint* pPreStepPoint = aStep->GetPreStepPoint();
- G4StepPoint* pPostStepPoint = aStep->GetPostStepPoint();
- G4double beta = 0.5 * (pPreStepPoint->GetBeta() + pPostStepPoint->GetBeta());
- const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
- G4String thematerial = touch->GetVolume()->GetLogicalVolume()->GetMaterial()->GetName();
- G4double MeanNumberOfPhotons = CerenGenerator->GetAverageNumberOfPhotons(charge, beta, thematerial);
- if (MeanNumberOfPhotons > 0.0) {
- G4double step_length = aStep->GetStepLength();
- MeanNumberOfPhotons = MeanNumberOfPhotons * step_length;
- NCerenPhotons = (G4int) G4Poisson(MeanNumberOfPhotons);
- } else {
- NCerenPhotons = 0;
- }
-
- if (NCerenPhotons <= 0) {
- return G4CalorimeterSD::ProcessHits(aStep, tahis);
- } else {
- G4SensitiveDetector::ProcessHits(aStep, 0);
- 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;
- G4cout << "Point of interaction = " << myPoint<< G4endl;
- G4cout << "sdname " << GetName() << " hcname " <<collectionName[0]<< G4endl;
- }
- // total photon energy
- // G4double theEdep = aTrack->GetTotalEnergy();
- G4double theEdep = double(NCerenPhotons);
- // get global cell pos from seg
- G4ThreeVector globalCellPos = m_segmentation->getGlobalHitPosPreStep(apreStepPoint);
- // reset the seg bins
- m_segmentation->resetBins();
- // set the seg bins
- m_segmentation->setBins(aStep);
- // create id and pack into 64
- Id64bit id64 = makeId();
- // find hit by simple lkp of new hit with above info
- G4CalorimeterHit* thisHit = new G4CalorimeterHit(theEdep, globalCellPos);
- thisHit->setId64bit(id64.getId0(), id64.getId1());
- G4CalorimeterHit* fndHit = 0;
- // hit is not found?
- if (!(fndHit = findHit(thisHit, eCerenkov))) {
- // add it to lkp map
- hits_vector[eCerenkov].push_back(thisHit);
- // add to the HC
- m_hitsCollections[eCerenkov]->insert(thisHit);
- } else {
- // found a hit
- // don't need to insert thisHit, so delete it
- delete thisHit;
- thisHit = 0;
- // incr total edep of the hit
- fndHit->incrEdep(theEdep);
- // for setting contrib
- thisHit = fndHit;
- }
- // add McpHitContrib to this hit, setting info from step info
- thisHit->addMcpHitContrib(McpHitContrib(aStep));
- // aTrack->SetTrackStatus(fStopAndKill); // don't step photon any further
- return true;
- } // end Cerenkov photon treatment
-}
lcdd/src
diff -N G4ProjectiveCylinderSegmentation.cc
--- G4ProjectiveCylinderSegmentation.cc 26 Jun 2013 01:36:23 -0000 1.11
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,68 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4ProjectiveCylinderSegmentation.cc,v 1.11 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/G4ProjectiveCylinderSegmentation.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-
-// Geant4
-#include "G4StepPoint.hh"
-#include "G4NavigationHistory.hh"
-#include "G4VPhysicalVolume.hh"
-#include "G4LogicalVolume.hh"
-#include "G4Tubs.hh"
-
-G4ProjectiveCylinderSegmentation::G4ProjectiveCylinderSegmentation(G4int ntheta, G4int nphi) :
- G4ProjectiveSegmentation(ntheta, nphi)
-{
-}
-
-G4ProjectiveCylinderSegmentation::~G4ProjectiveCylinderSegmentation()
-{
-}
-
-double G4ProjectiveCylinderSegmentation::getRadius(const G4Step* aStep)
-{
- 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);
-
- double ctheta = getThetaDim(aStep);
-
- // ctheta in 0 to pi ...
- // ctheta < pi/2 should be negative
-
- double zcell = rcyl / tan(ctheta);
-
- 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);
-
- if (valid) {
- if (s->GetEntityType() != "G4Tubs") {
- valid = false;
- }
- }
-
- return valid;
-}
lcdd/src
diff -N G4ProjectiveSegmentation.cc
--- G4ProjectiveSegmentation.cc 26 Jun 2013 01:36:23 -0000 1.12
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,238 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4ProjectiveSegmentation.cc,v 1.12 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/G4ProjectiveSegmentation.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-
-// Geant4
-#include "G4StepPoint.hh"
-#include "G4NavigationHistory.hh"
-#include "G4VPhysicalVolume.hh"
-#include "G4LogicalVolume.hh"
-#include "G4Tubs.hh"
-
-G4ProjectiveSegmentation::G4ProjectiveSegmentation(G4int ntheta, G4int nphi) :
- G4Segmentation(G4Segmentation::eProjective), m_ntheta(ntheta), m_nphi(nphi)
-{
- //G4cout << "G4ProjectiveSegmentation" << G4endl;
- //G4cout << "ntheta, nphi: " << ntheta << ", " << nphi << G4endl;
-
- computeDivisions();
-
- setBinNames();
-}
-
-G4ProjectiveSegmentation::~G4ProjectiveSegmentation()
-{
-}
-
-G4ThreeVector G4ProjectiveSegmentation::getGlobalHitPos(const G4Step* aStep)
-{
- // 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(aStep);
- double zcell = getZ(aStep);
-
- // get phi component
- double cphi = getPhiDim(aStep);
-
- // 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;
-}
-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;
-}
-
-G4int G4ProjectiveSegmentation::getNphi() const
-{
- return m_nphi;
-}
-
-void G4ProjectiveSegmentation::computeDivisions()
-{
- m_divTheta = (180.0 * deg) / m_ntheta;
- m_divPhi = (360.0 * deg) / m_nphi;
-}
-
-int G4ProjectiveSegmentation::getThetaBin(const G4ThreeVector& globalStepPos)
-{
- // theta needs to be in range 0 - PI
- return G4Segmentation::computeBin(globalStepPos.theta(), m_divTheta / radian);
-}
-
-int G4ProjectiveSegmentation::getPhiBin(const G4ThreeVector& globalStepPos)
-{
-
- // adjust phi for < 0
- double sphi = globalStepPos.phi();
-
- if (sphi < 0.0) {
- sphi += 360.0 * deg;
- }
-
- // needs more checks, for phi in range 0 - TWOPI
- // if > TWOPI, then subtract TWOPI
- //
- // OR use X, Y for phi calc
-
- // compute and return bin
- return G4Segmentation::computeBin(sphi, m_divPhi / radian);
-}
-
-// default impl. returns mag of pos
-double G4ProjectiveSegmentation::getRadius(const G4Step* aStep)
-{
- //G4cout << "G4ProjectiveSegmentation::getRadius()" << G4endl;
-
- 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)
-{
- //G4cout << "G4ProjectiveSegmentation::getZ()" << G4endl;
- 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, m_divTheta);
-}
-
-double G4ProjectiveSegmentation::getPhiDim(const int &phiBin) const
-{
- return G4Segmentation::computeDim(phiBin, m_divPhi);
-}
-
-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;
-
- G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
- 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 -N G4ProjectiveZPlaneSegmentation.cc
--- G4ProjectiveZPlaneSegmentation.cc 26 Jun 2013 01:36:23 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,41 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4ProjectiveZPlaneSegmentation.cc,v 1.5 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/G4ProjectiveZPlaneSegmentation.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-
-G4ProjectiveZPlaneSegmentation::G4ProjectiveZPlaneSegmentation(G4int ntheta, G4int nphi) :
- G4ProjectiveSegmentation(ntheta, nphi)
-{
-}
-
-G4ProjectiveZPlaneSegmentation::~G4ProjectiveZPlaneSegmentation()
-{
-}
-
-double G4ProjectiveZPlaneSegmentation::getRadius(const G4Step* aStep)
-{
- double zcell = getZ(aStep);
- double ctheta = G4ProjectiveSegmentation::getThetaDim(aStep);
- double rcyl = zcell * tan(ctheta);
- return rcyl;
-}
-double G4ProjectiveZPlaneSegmentation::getRadius(const G4StepPoint* aPreStepPoint)
-{
- double zcell = getZ(aPreStepPoint);
- double ctheta = G4ProjectiveSegmentation::getThetaDim(aPreStepPoint);
- double rcyl = zcell * tan(ctheta);
- return rcyl;
-}
-
-double G4ProjectiveZPlaneSegmentation::getZ(const G4Step* aStep)
-{
- G4ThreeVector gpos = ReadoutUtil::getVolumeGlobalPosition(aStep->GetPreStepPoint(), G4ThreeVector());
- return gpos.z();
-}
-
-double G4ProjectiveZPlaneSegmentation::getZ(const G4StepPoint* aPreStepPoint)
-{
- G4ThreeVector gpos = ReadoutUtil::getVolumeGlobalPosition(aPreStepPoint, G4ThreeVector());
- return gpos.z();
-}
lcdd/src
diff -N G4RZFieldMap.cc
--- G4RZFieldMap.cc 26 Jun 2013 01:36:23 -0000 1.13
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,275 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4RZFieldMap.cc,v 1.13 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/bfield/G4RZFieldMap.hh"
-
-// Geant4
-#include "globals.hh"
-
-// STL
-#include <cmath>
-
-// Set this preprocessor symbol for lots of debugging output.
-//#define FIELD_MAP_DEBUG 1
-
-#ifdef FIELD_MAP_DEBUG
-#include <iostream>
-using std::cout;
-using std::endl;
-#endif
-
-G4RZFieldMap::G4RZFieldMap(int numBinsR, int numBinsZ, double gridSizeR, double gridSizeZ, std::vector<RZBData> fieldData) :
- m_numBinsR(numBinsR), m_numBinsZ(numBinsZ), m_gridSizeR(gridSizeR), m_gridSizeZ(gridSizeZ), m_BrArray(0), m_BzArray(0)
-{
-
-#ifdef FIELD_MAP_DEBUG
- cout << "numBinsR=" << numBinsR << endl;
- cout << "numBinsZ=" << numBinsZ << endl;
- cout << "gridSizeR=" << gridSizeR << endl;
- cout << "gridSizeZ=" << gridSizeZ << endl;
-#endif
-
- if (numBinsR < 2) {
- G4Exception("", "", FatalException, "numBinsR must be >= 2");
- }
-
- if (numBinsZ < 2) {
- G4Exception("", "", FatalException, "numBinsZ must be >= 2");
- }
-
- if (gridSizeR <= 0) {
- G4Exception("", "", FatalException, "gridSizeR must be >= 0");
- }
-
- if (gridSizeZ <= 0) {
- G4Exception("", "", FatalException, "gridSizeZ must be >= 0");
- }
-
- m_maxR = (numBinsR - 1) * m_gridSizeR;
- m_maxZ = (numBinsZ - 1) * m_gridSizeZ;
-
- initializeArrays();
- fillArrays(fieldData);
-}
-
-void G4RZFieldMap::initializeArrays()
-{
- // Make two 2D arrays of numBinsZ x numBinsR
- m_BrArray = new double*[m_numBinsZ];
- m_BzArray = new double*[m_numBinsZ];
-
- for (int i = 0; i < m_numBinsZ; i++) {
- m_BrArray[i] = new double[m_numBinsR];
- m_BzArray[i] = new double[m_numBinsR];
- }
-
- // Initialize arrays to all 0's.
- for (int i = 0; i < m_numBinsZ; i++) {
- for (int j = 0; j < m_numBinsR; j++) {
- m_BrArray[i][j] = 0;
- m_BzArray[i][j] = 0;
- }
- }
-}
-
-void G4RZFieldMap::fillArrays(std::vector<RZBData> fieldData)
-{
- for (std::vector<RZBData>::iterator iter = fieldData.begin(); iter != fieldData.end(); iter++) {
- RZBData rzb = *iter;
-
- int iz = (int) ((rzb.z() + 0.0001) / m_gridSizeZ);
- iz = iz;
- int ir = (int) ((rzb.r() + 0.0001) / m_gridSizeR);
- ir = ir;
-
- m_BzArray[iz][ir] = rzb.Bz();
- m_BrArray[iz][ir] = rzb.Br();
-
-#ifdef FIELD_MAP_DEBUG
- cout << "ir iz = " << ir << " " << iz << endl;
- cout << "Br Bz = " << m_BrArray[iz][ir] << " " << m_BzArray[iz][ir] << endl;
- cout << endl;
-#endif
- }
-}
-
-G4RZFieldMap::~G4RZFieldMap()
-{
- deleteArrays();
-}
-
-void G4RZFieldMap::deleteArrays()
-{
- for (int i = 0; i < m_numBinsZ; i++) {
- delete[] m_BrArray[i];
- delete[] m_BzArray[i];
- }
- delete[] m_BrArray;
- delete[] m_BzArray;
-}
-
-/**
- * Compute B field at given point using the arrays of Br and Bz field strengths.
- *
- * This function is based on Takashi's FORTRAN code at
- *
- * /afs/slac/www/accel/nlc/local/systems/beamdelivery/geant/SDNEW/solenoid.f
- *
- * via the RZBFieldProvider.cpp test code provided by Norman.
- *
- */
-void G4RZFieldMap::GetFieldValue(const double Point[3], double *Bfield) const
-{
-#ifdef FIELD_MAP_DEBUG
- cout << "Point = " << Point[0] << " " << Point[1] << " " << Point[2] << endl;
-#endif
-
- double r = sqrt((Point[0] * Point[0]) + (Point[1] * Point[1]));
- double z = Point[2];
-
- double hz = 0;
- double hr = 0;
-
- // Check for z or r out of range.
- if (fabs(z) >= m_maxZ || r >= m_maxR) {
-#ifdef FIELD_MAP_DEBUG
- cout << "OUT OF RANGE: z r = " << fabs(z) << " " << r << endl;
- cout << "MAX: maxZ maxR " << m_maxZ << " " << m_maxR << endl;
-#endif
- return;
- }
-
- // Compute z bin.
- int iz = (int) ((fabs(z) + 0.001) / m_gridSizeZ);
-
- // Compute r bin.
- int ir = (int) ((r + 0.001) / m_gridSizeR);
-
- // Adjust for iz out of range.
-// int izfar = 0;
-// if( iz >= m_numBinsZ-1 ) {
-// izfar = 1;
-// iz = m_numBinsZ - 1;
-// }
-
-// Check for iz < 0.
- if (iz < 0) {
-#ifdef FIELD_MAP_DEBUG
- cout << "ERROR: iz < 0" << endl;
- cout << "iz=" << iz << endl;
- cout << "returning" << endl;
-#endif
- }
-
-// Check for Z overflow on iz+1.
- if (iz + 1 >= m_numBinsZ) {
-#ifdef FIELD_MAP_DEBUG
- cout << "ERROR: iz overflow" << endl;
- cout << "iz=" << iz << endl;
- cout << "returning" << endl;
-#endif
- return;
- }
-
- // Check for R overflow on ir+1.
- if (ir + 1 >= m_numBinsR) {
-#ifdef FIELD_MAP_DEBUG
- cout << "ERROR: ir overflow" << endl;
- cout << "ir=" << ir << endl;
- cout << "returning" << endl;
-#endif
- return;
- }
-
-#ifdef FIELD_MAP_DEBUG
- cout << "dz " << m_gridSizeZ << " dr " << m_gridSizeR << endl;
- cout << "z " << z << " r " << r << endl;
- cout << "iz " << iz << " ir " << ir << endl;
-#endif
-
- double bz0 = m_BzArray[iz][ir];
- double br0 = m_BrArray[iz][ir];
-
-#ifdef FIELD_MAP_DEBUG
- cout << "bz0 " << bz0 << " br0 " << br0 << endl;
-#endif
-
- double delz = 0.;
- double delr = 0.;
-
- double brdz = 0.;
- double brdr = 0.;
-
- if (r > 0.0) {
- delr = r - float(ir) * m_gridSizeR;
-
-#ifdef FIELD_MAP_DEBUG
- if ( iz+1 == m_gridSizeZ-1 ) {
- cout << "WARNING: iz+1 == gridSizeZ-1" << endl;
- }
-
- if ( ir+1 == m_gridSizeR-1 ) {
- cout << "WARNING: ir+1 == gridSizeR-1" << endl;
- }
-#endif
-
-#ifdef FIELD_MAP_DEBUG
- cout << "checking brarray access ..." << endl;
- cout << "iz+1=" << iz+1 << endl;
- cout << "ir=" << ir << endl;
- cout << m_BrArray[iz+1][ir] << endl;
- cout << "m_BrArray[iz+1][ir] is ok" << endl;
- cout << "iz=" << iz << endl;
- cout << "ir+1=" << ir+1 << endl;
- cout << m_BrArray[iz][ir+1] << endl;
- cout << "m_BrArray[iz][ir+1] is ok" << endl;
- cout << "done" << endl;
-#endif
-
- brdz = (m_BrArray[iz + 1][ir] - br0) / m_gridSizeZ;
- brdr = (m_BrArray[iz][ir + 1] - br0) / m_gridSizeR;
-#ifdef FIELD_MAP_DEBUG
- cout << "br= " << m_BrArray[iz+1][ir] << " " << m_BrArray[iz][ir+1] << endl;
-#endif
- }
-
- delz = fabs(z) - float(iz) * m_gridSizeZ;
-
-#ifdef FIELD_MAP_DEBUG
- cout << " z " << z << " abs(z) " << fabs(z) << " iz " << iz << endl;
- cout << " float(iz-1) " << float(iz-1) << " dz " << m_gridSizeZ << endl;
- cout << " delz " << delz << endl;
-#endif
-
- double bzdz = (m_BzArray[iz + 1][ir] - bz0) / m_gridSizeZ;
- double bzdr = (m_BzArray[iz][ir + 1] - bz0) / m_gridSizeR;
-
-#ifdef FIELD_MAP_DEBUG
- cout << "bz= " << m_BzArray[iz+1][ir] << " " << m_BzArray[iz][ir+1] << endl;
-#endif
-
-// if(izfar==1) {
-// hz = bz0+bzdr*delr;
-// hr = br0+brdr*delr;
-// }
-// else {
- hz = bz0 + bzdz * delz + bzdr * delr;
- hr = br0 + brdz * delz + brdr * delr;
-// }
-
- if (z < 0.0)
- hr = -hr;
-
- double theta = atan2(Point[1], Point[0]);
- double hx = hr * cos(theta);
- double hy = hr * sin(theta);
-
- Bfield[0] += hx;
- Bfield[1] += hy;
- Bfield[2] += hz;
-
-#ifdef FIELD_MAP_DEBUG
- cout << "Bfield XYZ = " << Bfield[0] << " " << Bfield[1] << " " << Bfield[2] << endl;
- cout << endl;
-#endif
-}
lcdd/src
diff -N G4ScorerSD.cc
--- G4ScorerSD.cc 26 Jun 2013 01:36:23 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,98 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4ScorerSD.cc,v 1.5 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/G4ScorerSD.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-#include "lcdd/hits/TrackInformation.hh"
-
-G4ScorerSD::G4ScorerSD(G4String sdName, G4String hcName) :
- G4TrackerSD(sdName, hcName), m_currentTrackID(-1)
-{
-}
-
-G4bool G4ScorerSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
-{
-#ifdef G4VERBOSE
- if ( m_verbose > 1 ) {
- std::cout << "G4ScorerSD::ProcessHits() - " << this->GetName() << std::endl;
- }
-#endif
-
- G4SensitiveDetector::ProcessHits(aStep, 0);
-
- bool sameTrack = false;
-
-#ifdef G4VERBOSE
- if ( m_verbose > 3 ) {
- std::cout << "current trackID <" << m_currentTrackID << ">" << std::endl;
- }
-#endif
-
- if ((m_currentTrackID == -1) || (m_currentTrackID != trackID())) {
-
-#ifdef G4VERBOSE
- if ( m_verbose > 2 ) {
- std::cout << "new track <" << trackID() << ">" << std::endl;
- }
-#endif
-
- m_currentTrackID = trackID();
- } else {
-#ifdef G4VERBOSE
- if ( m_verbose > 2 ) {
- std::cout << "old track <" << trackID() << ">" << std::endl;
- }
-#endif
-
- sameTrack = true;
- }
-
- if (!sameTrack) {
-
-#ifdef G4VERBOSE
- if ( m_verbose > 2 ) {
- std::cout << "writing hit" << std::endl;
- }
-#endif
-
- // edep
- G4double e = edep();
-
- // get track information
- TrackInformation* trkInfo = trackInformation();
-
- // set hit flag in trk info
- trkInfo->setHasTrackerHit(true);
-
- // hit data
- G4int trkID = trackID();
- G4double tdep = globalTime();
- G4ThreeVector prepos = prePosition();
- G4ThreeVector meanmom = meanMomentum();
-
- // create hit
- G4TrackerHit* trkHit = new G4TrackerHit();
-
- // create id vector
- Id64bit id64 = makeId();
-
- // set track hit info
- trkHit->setTrackID(trkID);
- trkHit->setEdep(e);
- trkHit->setPos(prepos);
- trkHit->setMomentum(meanmom);
- trkHit->setTdep(tdep);
- trkHit->setId(id64.getId0());
- trkHit->setLength(ReadoutUtil::computeDistance(aStep));
-
- // add to HC
- m_HC->insert(trkHit);
- } else {
-#ifdef G4VERBOSE
- if ( m_verbose > 0 ) {
- std::cout << "Skipping hit from track <" << m_currentTrackID << ">." << std::endl;
- }
-#endif
- }
- return true;
-}
lcdd/src
diff -N G4Segmentation.cc
--- G4Segmentation.cc 26 Jun 2013 01:36:23 -0000 1.14
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,75 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4Segmentation.cc,v 1.14 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/G4Segmentation.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-
-G4Segmentation::G4Segmentation(EType segType, int nbins) :
- m_numBins(nbins), m_type(segType)
-{
- // reserve nbins
- m_bins.reserve(m_numBins);
-
- // fill in 0 vals
- resetBins();
-}
-
-G4Segmentation::~G4Segmentation()
-{
-}
-
-void G4Segmentation::setBin(int binIdx, int binVal)
-{
- m_bins.insert(m_bins.begin() + binIdx, binVal);
-}
-
-int G4Segmentation::getNumberOfBins()
-{
- return m_numBins;
-}
-
-const std::vector<int>& G4Segmentation::getBins()
-{
- return m_bins;
-}
-
-G4Segmentation::EType G4Segmentation::getType()
-{
- return m_type;
-}
-
-G4ThreeVector G4Segmentation::getGlobalHitPos(const G4Step* aStep)
-{
- return ReadoutUtil::computeMidPos(aStep);
-}
-
-G4ThreeVector G4Segmentation::getGlobalHitPosPreStep(const G4StepPoint* aPreStepPoint)
-{
- //G4Exception("Do not use this method!");
- return aPreStepPoint->GetPosition();
-}
-
-void G4Segmentation::resetBins()
-{
- m_bins.clear();
-}
-
-void G4Segmentation::printOutBins(std::ostream& os, const std::vector<int>& bins)
-{
- os << "segmentationBins <" << bins.size() << "> :: ";
- for (std::vector<int>::const_iterator iter = bins.begin(); iter != bins.end(); iter++) {
- os << *iter << " ";
- }
- os << std::endl;
-}
-
-bool G4Segmentation::isValidSolid(G4VSolid* s)
-{
- bool valid = true;
-
- if (0 == s) {
- valid = false;
- }
-
- return valid;
-}
lcdd/src
diff -N G4SegmentationFactory.cc
--- G4SegmentationFactory.cc 26 Jun 2013 01:36:23 -0000 1.13
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,172 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4SegmentationFactory.cc,v 1.13 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/G4SegmentationFactory.hh"
-#include "lcdd/schema/grid_xyz.hh"
-#include "lcdd/schema/global_grid_xy.hh"
-#include "lcdd/schema/nonprojective_cylinder.hh"
-#include "lcdd/schema/projective_cylinder.hh"
-#include "lcdd/schema/projective_zplane.hh"
-#include "lcdd/schema/cell_readout_2d.hh"
-#include "lcdd/detectors/G4Segmentation.hh"
-#include "lcdd/detectors/G4GridXYZSegmentation.hh"
-#include "lcdd/detectors/G4GlobalGridXYSegmentation.hh"
-#include "lcdd/detectors/G4ProjectiveCylinderSegmentation.hh"
-#include "lcdd/detectors/G4ProjectiveZPlaneSegmentation.hh"
-#include "lcdd/detectors/G4NonprojectiveCylinderSegmentation.hh"
-#include "lcdd/detectors/CellReadout2DSegmentation.hh"
-
-// GDML
-#include "Saxana/SAXObject.h"
-#include "G4Processor/GDMLProcessor.h"
-#include "G4Evaluator/GDMLExpressionEvaluator.h"
-
-// STL
-#include <iostream>
-
-G4Segmentation* G4SegmentationFactory::createSegmentation(SAXObject* obj, const std::string& tag)
-{
- G4Segmentation* seg = 0;
- GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
-
- if (tag == "projective_cylinder") {
- 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;
- }
-
- } else if (tag == "grid_xyz") {
- // GridXYZ
- 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;
- }
- } else if (tag == "nonprojective_cylinder") {
- // handle NP cylinder
-
- //std::cout << "add nonprojective_cylinder here" << std::endl;
-
- nonprojective_cylinder* np = dynamic_cast<nonprojective_cylinder*>(obj);
- if (np) {
-
- double gsp = 0;
- double gsz = 0;
-
- std::string lunit = np->get_lunit();
-
- std::string sval = np->get_gridSizePhi();
- sval += "*" + lunit;
- gsp = 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;
- }
- } else if (tag == "projective_zplane") {
- // handle projective_zplane
-
- //std::cout << "add projective_zplane here" << std::endl;
-
- projective_zplane* prj = dynamic_cast<projective_zplane*>(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);
-
- //std::cout << "ntheta, nphi : "
- // << ntheta << ", "
- // << nphi << std::endl;
-
- seg = new G4ProjectiveZPlaneSegmentation(ntheta, nphi);
- } else {
- std::cerr << "Failed cast to projective_zplane!" << std::endl;
- } // prj no exist
- } else if (tag == "cell_readout_2d") {
-
- //std::cout << "building cell_readout_2d" << std::endl;
-
- cell_readout_2d* elem = dynamic_cast<cell_readout_2d*>(obj);
- if (0 != elem) {
- double cellSizeX, cellSizeY;
- cellSizeX = cellSizeY = 0;
- std::string lengthUnit = elem->getLengthUnit();
-
- std::string val = elem->getCellSizeX();
- val += "*" + lengthUnit;
- cellSizeX = calc->Eval(val);
-
- val = elem->getCellSizeY();
- val += "*" + lengthUnit;
- cellSizeY = calc->Eval(val);
-
- //std::cout << "G4SegmentationFactory creating CellReadout2DSegmentation(x,y): " << cellSizeX << " " << cellSizeY << std::endl;
-
- seg = new CellReadout2DSegmentation(cellSizeX, cellSizeY);
- }
- } else {
- // bad segmentation tag
- std::cerr << "Unknown child tag for calorimeter: " << tag << "." << std::endl;
- }
-
- if (seg == 0) {
- G4Exception("", "", FatalException, "Failed to create segmentation.");
- }
-
- return seg;
-}
lcdd/src
diff -N G4SensitiveDetector.cc
--- G4SensitiveDetector.cc 26 Jun 2013 01:36:23 -0000 1.20
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,186 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4SensitiveDetector.cc,v 1.20 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/G4SensitiveDetector.hh"
-#include "lcdd/id/IdManager.hh"
-#include "lcdd/id/IdFactory.hh"
-#include "lcdd/detectors/SensitiveDetectorMessenger.hh"
-#include "lcdd/hits/TrackInformation.hh"
-
-// Geant4
-#include "G4EventManager.hh"
-#include "G4Event.hh"
-#include "G4SDManager.hh"
-#include "G4UImessenger.hh"
-#include "G4VHitsCollection.hh"
-#include "G4LogicalVolumeStore.hh"
-#include "G4UnitsTable.hh"
-
-// STL
-#include <iostream>
-#include <vector>
-
-using std::vector;
-
-const std::string& G4SensitiveDetector::trackerStr = "tracker";
-const std::string& G4SensitiveDetector::calorimeterStr = "calorimeter";
-const std::string& G4SensitiveDetector::noneStr = "none";
-
-G4SensitiveDetector::G4SensitiveDetector(G4String sdName, G4String hcName, EType sdType) :
- G4VSensitiveDetector(sdName), m_idspec(0), m_type(sdType)
-{
- // insert hits collection name into SD's name vector
- collectionName.insert(hcName);
-
- // register detector with G4SDManager
- G4SDManager::GetSDMpointer()->AddNewDetector(this);
-
- // Create the command messenger.
- m_messenger = new SensitiveDetectorMessenger(this);
-
- // Only one HC
- m_hcids.clear();
- m_hcids.push_back(-1);
-}
-
-G4SensitiveDetector::G4SensitiveDetector(G4String sdName, const vector<G4String>& hcNames, EType sdType) :
- G4VSensitiveDetector(sdName), m_idspec(0), m_type(sdType)
-{
- m_hcids.clear();
-
- for (int i = 0; i < (int) hcNames.size(); i++) {
- // insert hits collection name into SD's name vector
- collectionName.insert(hcNames[i]);
- m_hcids.push_back(-1);
- }
-
- // register detector with G4SDManager
- G4SDManager::GetSDMpointer()->AddNewDetector(this);
-
- // Create the command messenger.
- m_messenger = new SensitiveDetectorMessenger(this);
-}
-
-G4SensitiveDetector::~G4SensitiveDetector()
-{
-}
-
-void G4SensitiveDetector::Initialize(G4HCofThisEvent *)
-{
- // no-op
-}
-
-void G4SensitiveDetector::EndOfEvent(G4HCofThisEvent *)
-{
- // no-op
-}
-
-G4bool G4SensitiveDetector::ProcessHits(G4Step* aStep, G4TouchableHistory*)
-{
- // set cached step
- setStep(aStep);
-
- // doesn't write a hit
- return false;
-}
-
-const std::string& G4SensitiveDetector::getTypeString() const
-{
- if (m_type == eTracker) {
- return trackerStr;
- } else if (m_type == eCalorimeter) {
- return calorimeterStr;
- }
- return noneStr;
-}
-
-std::ostream& G4SensitiveDetector::printBasicInfo(std::ostream& os)
-{
- os << "name: " << GetName() << std::endl;
- os << "type: " << m_type << std::endl;
- os << "hits collection: " << this->getHCName() << std::endl;
- os << "hits collection ID: " << m_hcids[0] << std::endl;
- os << "energy cut: " << G4BestUnit(m_ecut, "Energy") << std::endl;
- os << "endcap flag: " << m_endcap << std::endl;
- os << "verbose level: " << m_verbose << std::endl;
-
- if (m_idspec != 0) {
- os << "id spec: " << m_idspec->getName() << std::endl;
- os << "id fields:";
- for (IdSpec::IdFields::const_iterator it = m_idspec->IdFieldsBegin(); it != m_idspec->IdFieldsEnd(); it++) {
- os << " " << (*it)->getLabel();
- }
- os << std::endl;
- } else {
- os << "idspec points to null!" << std::endl;
- }
-
- return os;
-}
-
-Id64bit G4SensitiveDetector::makeId() const
-{
- Id64bit id64;
- if (hasIdSpec()) {
-
- // get idvec ordered by this idspec
- const IdVec ids = IdFactory::createOrderedIdVec(step(), this);
-
- // pack into 64 bit cell id
- id64 = IdFactory::createId64bit(ids, getIdSpec());
- }
- return id64;
-}
-
-G4VHitsCollection* G4SensitiveDetector::getHitsCollection() const
-{
- G4VHitsCollection* hc = 0;
- if (this->getHCID() != -1) {
- hc = G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetHCofThisEvent()->GetHC(this->getHCID());
- }
- return hc;
-}
-
-G4VHitsCollection* G4SensitiveDetector::getHitsCollection(G4int nHC) const
-{
- G4VHitsCollection* hc = 0;
- if (this->getHCID(nHC) != -1) {
- hc = G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetHCofThisEvent()->GetHC(this->getHCID(nHC));
- }
- return hc;
-}
-
-std::ostream& G4SensitiveDetector::printNumberOfHits(std::ostream& os)
-{
- for (int i = 0; i < getNumberOfHitsCollections(); i++) {
- os << getHitsCollection(i)->GetName() << " " << getHitsCollection(i)->GetSize() << std::endl;
- }
- return os;
-}
-
-std::ostream& G4SensitiveDetector::printEdep(std::ostream& os)
-{
- os << "total edep: " << G4BestUnit(this->getEdep(), "Energy") << std::endl;
- return os;
-}
-
-std::vector<G4LogicalVolume*> G4SensitiveDetector::getLogicalVolumes() const
-{
- std::vector<G4LogicalVolume*> volumes;
- for (G4LogicalVolumeStore::const_iterator it = G4LogicalVolumeStore::GetInstance()->begin(); it != G4LogicalVolumeStore::GetInstance()->end(); it++) {
- if ((*it)->GetSensitiveDetector() == this) {
- volumes.push_back(*it);
- }
- }
- return volumes;
-}
-
-std::ostream& G4SensitiveDetector::printVolumes(std::ostream& os)
-{
- std::vector<G4LogicalVolume*> volumes = this->getLogicalVolumes();
-
- for (std::vector<G4LogicalVolume*>::const_iterator it = volumes.begin(); it != volumes.end(); it++) {
- std::cout << (*it)->GetName() << std::endl;
- }
- return os;
-}
lcdd/src
diff -N G4Solenoid.cc
--- G4Solenoid.cc 26 Jun 2013 01:36:23 -0000 1.10
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,49 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4Solenoid.cc,v 1.10 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/bfield/G4Solenoid.hh"
-
-// Geant4
-#include "globals.hh"
-
-G4Solenoid::G4Solenoid() :
- _innerField(0), _outerField(0), _innerR(0), _outerR(0), _innerZ(0), _outerZ(0)
-{
-}
-
-G4Solenoid::~G4Solenoid()
-{
-}
-
-/**
- * Apply simple solenoid magnetic field to the given Point.
- */
-// TODO: use inner/outer Z
-void G4Solenoid::GetFieldValue(const double Point[3], double* Bfield) const
-{
- //std::cout << "G4Solenoid::GetFieldValue" << std::endl;
- //std::cout << "point: " << Point[0] << " " << Point[1] << " " << Point[2] << std::endl;
- //std::cout << "BEFORE --> bfield " << Bfield[0] << " " << Bfield[1] << " " << Bfield[2] << std::endl;
-
- double this_radius = sqrt(Point[0] * Point[0] + Point[1] * Point[1]);
-
- if (this_radius < _innerR) {
- Bfield[2] += _innerField;
- } else if (this_radius < _outerR) {
- Bfield[2] += _outerField;
- }
-
- //std::cout << "AFTER --> bfield = " << Bfield[0] << " " << Bfield[1] << " " << Bfield[2] << std::endl << std::endl;
-
- return;
-}
-
-void G4Solenoid::printOut(std::ostream& os)
-{
- os << "innerField <" << _innerField << ">" << std::endl;
- os << "outerField <" << _outerField << ">" << std::endl;
- os << "outerR <" << _outerR << ">" << std::endl;
- os << "innerZ <" << _innerZ << ">" << std::endl;
- os << "outerZ <" << _outerZ << ">" << std::endl;
- os << std::endl;
-}
lcdd/src
diff -N G4StoreManager.cc
--- G4StoreManager.cc 26 Jun 2013 01:36:23 -0000 1.8
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,31 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4StoreManager.cc,v 1.8 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/core/G4StoreManager.hh"
-
-// Geant4
-#include "G4UIdirectory.hh"
-
-G4StoreManager *G4StoreManager::_instance = 0;
-
-G4StoreManager::G4StoreManager()
-{
- G4UIdirectory* m_storesDir;
- m_storesDir = new G4UIdirectory("/stores/");
- m_storesDir->SetGuidance("Commands to inspect the Geant4 object stores. [LCDD]");
-}
-
-G4StoreManager::~G4StoreManager()
-{
-}
-
-G4StoreManager* G4StoreManager::instance()
-{
- static G4StoreManager mgr;
-
- if (!_instance) {
- _instance = &mgr;
- }
-
- return _instance;
-}
lcdd/src
diff -N G4TrackerCombineSD.cc
--- G4TrackerCombineSD.cc 26 Jun 2013 01:36:23 -0000 1.14
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,260 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4TrackerCombineSD.cc,v 1.14 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/G4TrackerCombineSD.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-#include "lcdd/hits/TrackInformation.hh"
-
-G4TrackerCombineSD::G4TrackerCombineSD(G4String sdName, G4String hcName) :
- G4TrackerSD(sdName, hcName), m_combineHits(false), m_currentTrackID(-1), m_currentPV(0), m_edepTotal(0), m_minTime(0), m_startedHit(false), m_currentTrack(false)
-{
-}
-
-G4TrackerCombineSD::~G4TrackerCombineSD()
-{
-}
-
-void G4TrackerCombineSD::EndOfEvent(G4HCofThisEvent *hce)
-{
- G4TrackerSD::EndOfEvent(hce);
- clear();
-}
-
-G4bool G4TrackerCombineSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
-{
- // set cached step
- G4SensitiveDetector::ProcessHits(aStep, 0);
-
-#ifdef G4VERBOSE
- if (getVerbose() > 0) {
- G4cout << "G4TrackerCombineSD::ProcessHits - " << GetName() << G4endl;
- G4cout << "trackID - " << trackID() << G4endl;
- G4cout << "particle - " << track()->GetDefinition()->GetParticleName() << G4endl;
- G4cout << "edep - " << step()->GetTotalEnergyDeposit() << G4endl;
- G4cout << "pre-physvol=" << aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName() << G4endl;
- G4cout << "post-physvol=" << aStep->GetPostStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName() << G4endl;
- if ( prePV() != postPV() ) {
- G4cout << "post-pv != pre-pv" << G4endl;
- }
- }
-#endif
-
- // Return value indicating whether a hit was inserted.
- bool r = false;
-
- // Started a hit already?
- if (!m_startedHit) {
-
- // If no hit, then start a new hit on the pre-step.
- startHit(pre());
- }
-
- // Check if the cached trackID is valid.
- if (m_currentTrackID != -1) {
-
- // Is this step's trackID different from the cached trackID?
- if (trackID() != m_currentTrackID) {
-
-#ifdef G4VERBOSE
- if ( getVerbose() > 0 ) {
- G4cout << "new track ID this step!" << G4endl;
- }
-#endif
-
- // Insert the hit on the old track.
- r = insertHit();
-
- // Start a new hit on the pre-step.
- startHit(pre());
- }
- }
-#ifdef G4DEBUG
- else {
- std::cout << GetName() << "::WARNING : current TrackID == -1" << std::endl;
- }
-#endif
-
- // Update the hit, checking if the call to this function is applicable.
- updateHit();
-
- // Entering a new PV on this step?
- if (prePV() != postPV()) {
-
-#ifdef G4VERBOSE
- if ( getVerbose() > 0 ) {
- G4cerr << "new physvol this step!" << G4endl;
- }
-#endif
-
- // Insert the current hit.
- r = insertHit();
-
- // Check if pre and post steps have the same detector.
- if (hasSameSD()) {
-
- // Start a new hit for the adjacent tracker layer.
- startHit(post());
- }
- }
- // Special case where the track status is StopAndKill.
- // If so, we won't see it again, so need to insert the hit.
- else if (m_currentTrack->GetTrackStatus() == fStopAndKill) {
- r = insertHit();
- }
-
-#ifdef G4VERBOSE
- if ( getVerbose() > 0 ) {
- G4cerr << "----" << G4endl;
- }
-#endif
-
- return r;
-}
-
-void G4TrackerCombineSD::updateHit()
-{
-
-#ifdef G4VERBOSE
- if ( getVerbose() > 1 ) {
- G4cout << "updateHit" << G4endl;
- }
-#endif
-
- // can only update if started hit
- if (m_startedHit) {
-
- // incr edep
- m_edepTotal += edep();
-
- // first time only
- if (m_minTime == 0) {
- m_minTime = globalTime();
- }
-
- // exit point and momentum
- m_exitPoint = postPosition();
- m_exitMomentum = postMomentum();
- }
-}
-
-void G4TrackerCombineSD::clear()
-{
-#ifdef G4VERBOSE
- if ( getVerbose() > 1 ) {
- G4cout << "clear" << G4endl;
- }
-#endif
-
- m_minTime = 0;
- m_edepTotal = 0;
- m_currentPV = 0;
- m_currentTrackID = -1;
- m_startedHit = false;
-}
-
-bool G4TrackerCombineSD::insertHit()
-{
-#ifdef G4VERBOSE
- if ( getVerbose() > 1 ) {
- G4cout << "insertHit" << G4endl;
- }
-#endif
-
- // never started another hit after clearing
- if (!m_startedHit) {
- G4cerr << "never started hit!" << G4endl;
- return false;
- }
-
- // total energy below cut
- if ( m_edepTotal <= getEcut() && !isGeantino() ) {
-#ifdef G4VERBOSE
- if ( getVerbose() > 0 ) {
- std::cout << GetName() << " : cut this edep " << m_edepTotal << std::endl;
- }
-
-#endif
- clear();
- return false;
- }
-
- // compute mid point
- G4ThreeVector midPoint =
- ReadoutUtil::computeThreeVectorMean(m_entryPoint, m_exitPoint);
-
- // compute mean momentum
- G4ThreeVector meanMom =
- ReadoutUtil::computeThreeVectorMean(m_entryMomentum, m_exitMomentum);
-
- // compute distance from start to entry
- G4double pathlength = ReadoutUtil::computeDistance(m_entryPoint, m_exitPoint);
-
- // hit data
- G4TrackerHit* trkhit = new G4TrackerHit();
- trkhit->setTdep(m_minTime);
- trkhit->setEdep(m_edepTotal);
- trkhit->setPos(midPoint);
- trkhit->setMomentum(meanMom);
- trkhit->setTrackID(m_currentTrackID);
- trkhit->setLength(pathlength);
-
- // set id
- Id64bit id64 = makeId();
- trkhit->setId(id64.getId0());
-
-#ifdef G4VERBOSE
- if ( getVerbose() > 1 ) {
- std::cout << GetName() << " : inserting new tracker hit" << std::endl;
- std::cout << *trkhit << std::endl;
- std::cout << "entryPoint = " << m_entryPoint << std::endl;
- std::cout << "entryPointR = " << m_entryPoint.mag() << std::endl;
- std::cout << "midPoint = " << midPoint << std::endl;
- std::cout << "midPointR = " << midPoint.mag() << std::endl;
- std::cout << "exitPoint = " << m_exitPoint << std::endl;
- std::cout << "exitPointR = " << m_exitPoint.mag() << std::endl;
- std::cout << "(exitPointR - entryPointR) / 2 = " << (m_exitPoint.mag() - m_entryPoint.mag()) / 2 << std::endl;
- std::cout << std::endl;
- }
-#endif
-
- m_HC->insert(trkhit);
-
- TrackInformation::getTrackInformation( m_currentTrack )->setHasTrackerHit( true );
-
- // clear cached data
- clear();
-
-#ifdef G4VERBOSE
- if ( getVerbose() > 0 ) {
- G4cout << G4endl;
- }
-#endif
-
- return true;
- }
-
-void G4TrackerCombineSD::startHit(G4StepPoint* aStepPoint)
-{
-#ifdef G4VERBOSE
- if ( getVerbose() > 0 ) {
- G4cout << "startHit" << G4endl;
- }
-#endif
-
- m_currentTrack = step()->GetTrack();
- m_currentPV = aStepPoint->GetPhysicalVolume();
- m_entryPoint = m_exitPoint = aStepPoint->GetPosition();
- m_entryMomentum = m_exitMomentum = aStepPoint->GetMomentum();
- m_currentTrackID = trackID();
- m_startedHit = true;
-
-#ifdef G4VERBOSE
- if ( getVerbose() > 2 ) {
- std::cout << GetName() << " : starting new hit" << std::endl;
- std::cout << "volume = " << m_currentPV->GetName() << std::endl;
- std::cout << "trackID = " << m_currentTrackID << std::endl;
- std::cout << "entry point = " << m_entryPoint << std::endl;
- }
-#endif
-}
-
lcdd/src
diff -N G4TrackerHit.cc
--- G4TrackerHit.cc 26 Jun 2013 01:36:23 -0000 1.10
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,55 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4TrackerHit.cc,v 1.10 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/hits/G4TrackerHit.hh"
-
-// for Draw() method
-#ifdef G4VIS_USE
-#include "G4VVisManager.hh"
-#include "G4VisAttributes.hh"
-#include "G4Circle.hh"
-#include "G4Point3D.hh"
-#include "G4Transform3D.hh"
-#endif
-
-G4Allocator<G4TrackerHit> G4TrackerHitAllocator;
-
-G4TrackerHit::G4TrackerHit() :
- G4VHit(), m_edep(0), m_tdep(0), m_trkID(-1), m_length(0)
-{
-}
-
-G4TrackerHit::~G4TrackerHit()
-{
-}
-
-#ifdef G4VIS_USE
-void G4TrackerHit::Draw()
-{
- G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
-
- if(pVVisManager) {
-
- G4Point3D p3D = G4Point3D( m_pos );
- G4Circle chit(p3D);
- chit.SetScreenDiameter(3.0);
- chit.SetFillStyle(G4Circle::filled);
-
- G4Colour col(1.0, 0.0, 1.0);
-
- chit.SetVisAttributes(G4VisAttributes( col ) );
- pVVisManager->Draw( chit );
- }
-}
-#endif
-
-void G4TrackerHit::Print()
-{
- std::cout << *this << std::endl;
-}
-
-std::ostream& operator<<(std::ostream &os, const G4TrackerHit& hit)
-{
- std::cout << hit.getTrackID() << " " << hit.getPos() << " " << G4BestUnit(hit.getEdep(), "Energy") << " " << hit.getMomentum() << " " << G4BestUnit(hit.getLength(), "Length") << " " << G4BestUnit(hit.getTdep(), "Time") << " " << hit.getPDG() << " " << std::endl;
- return os;
-}
lcdd/src
diff -N G4TrackerSD.cc
--- G4TrackerSD.cc 26 Jun 2013 01:36:23 -0000 1.42
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,141 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/G4TrackerSD.cc,v 1.42 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/id/IdManager.hh"
-#include "lcdd/id/IdFactory.hh"
-#include "lcdd/id/IdVec.hh"
-#include "lcdd/detectors/G4TrackerSD.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-#include "lcdd/hits/G4TrackerHit.hh"
-#include "lcdd/hits/TrackInformation.hh"
-
-// Geant4
-#include "G4Geantino.hh"
-
-// STL
-#include <iostream>
-
-G4TrackerSD::G4TrackerSD(G4String sdName, G4String hcName) :
- G4SensitiveDetector(sdName, hcName, G4SensitiveDetector::eTracker), m_HC(0)
-{
- m_hits.clear();
-}
-
-G4TrackerSD::~G4TrackerSD()
-{
-}
-
-void G4TrackerSD::Initialize(G4HCofThisEvent *HCE)
-{
- clearHits();
-
- // create tracker hits coll
- m_HC = new G4TrackerHitsCollection(GetName(), collectionName[0]);
-
- // set HCID
- if (getHCID() < 0) {
- setHCID(GetCollectionID(0));
- }
-
- // add collection to HC of event
- HCE->AddHitsCollection(getHCID(), m_HC);
-}
-
-G4bool G4TrackerSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
-{
- // set cached step
- G4SensitiveDetector::ProcessHits(aStep, 0);
-
- // edep
- G4double e = edep();
-
- // check edep < cut
- if (e <= getEcut() && !isGeantino()) {
- return false;
- }
-
- // get track information
- TrackInformation* trkInfo = trackInformation();
-
- // set hit flag in trk info
- trkInfo->setHasTrackerHit(true);
-
- // hit data
- G4int trkID = trackID();
- G4double tdep = globalTime();
- G4ThreeVector midPos = midPosition();
- G4ThreeVector prePos = aStep->GetPreStepPoint()->GetPosition();
- G4ThreeVector postPos = aStep->GetPostStepPoint()->GetPosition();
- double avgMom = (pre()->GetMomentum().mag() + post()->GetMomentum().mag()) / 2;
- G4ThreeVector mom = (postPos - prePos);
- if (mom.mag() > 0) {
- mom.setMag(avgMom);
- } else {
- std::cerr << "prePos - postPos = 0 --> " << prePos << " | " << postPos << std::endl;
- }
-
- G4double pathLength = ReadoutUtil::computeDistance(aStep);
-
- // create hit
- G4TrackerHit* trkHit = new G4TrackerHit();
-
- // create id vector
- Id64bit id64 = makeId();
-
- // set track hit info
- trkHit->setTrackID(trkID);
- trkHit->setEdep(e);
- trkHit->setPos(midPos);
- trkHit->setMomentum(mom);
- trkHit->setTdep(tdep);
- trkHit->setId(id64.getId0());
- trkHit->setLength(pathLength);
-
- // add to HC
- m_HC->insert(trkHit);
-
- m_hits.push_back(trkHit);
-
- return true;
-}
-
-std::ostream& G4TrackerSD::printHits(std::ostream& os)
-{
- for (G4TrackerHitList::const_iterator iter = m_hits.begin(); iter != m_hits.end(); iter++) {
- os << (*(const_cast<const G4TrackerHit*>(*iter)));
- }
- os << std::endl;
- return os;
-}
-
-void G4TrackerSD::EndOfEvent(G4HCofThisEvent *)
-{
-#ifdef G4VERBOSE
- if ( getVerbose() > 0 ) {
- std::cout << GetName() << " has " << m_HC->GetSize() << " hits." << std::endl;
- }
-
- if ( getVerbose() > 1 ) {
- printHits ( std::cout );
- }
-#endif
-}
-
-double G4TrackerSD::getEdep() const
-{
- double edep = 0.0;
- for (G4TrackerHitList::const_iterator it = m_hits.begin(); it != m_hits.end(); it++) {
- edep += (*it)->getEdep();
- }
- return edep;
-}
-
-void G4TrackerSD::clearHits()
-{
- m_hits.clear();
-}
-
-G4TrackerSD::G4TrackerHitList G4TrackerSD::getTrackerHitList()
-{
- return m_hits;
-}
lcdd/src
diff -N G4UnsegmentedCalorimeterSD.cc
--- G4UnsegmentedCalorimeterSD.cc 26 Jun 2013 01:36:23 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,69 +0,0 @@
-// $Id: G4UnsegmentedCalorimeterSD.cc,v 1.6 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/G4UnsegmentedCalorimeterSD.hh"
-
-G4UnsegmentedCalorimeterSD::G4UnsegmentedCalorimeterSD(G4String sdName, G4String hcName, G4Segmentation* seg) :
- G4CalorimeterSD(sdName, hcName, seg)
-{
-}
-
-G4bool G4UnsegmentedCalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
-{
-#ifdef G4VERBOSE
- if ( getVerbose() > 0 )
- {
- std::cout << "G4UnsegmentedCalorimeterSD::ProcessHits - " << this->GetName() << std::endl;
- }
-#endif
-
- /* Cache the step information. */
- G4SensitiveDetector::ProcessHits(aStep, 0);
-
- /* Get the energy deposition. */
- G4double theEdep = edep();
-
- /*
- * This needs to be a <= comparison for cutting on 0,
- * but it allows geantinos, which always have 0 edep.
- */
- if (theEdep <= getEcut() && !isGeantino()) {
-#ifdef G4VERBOSE
- if ( getVerbose() > 2 )
- {
- std::cout << "G4UnsegmentedCalorimeterSD::ProcessHits - cut on edep " << theEdep << std::endl;
- }
-#endif
- return false;
- }
-
- /* Get the step mid position. */
- G4ThreeVector hitPos = midPosition();
-
- //std::cout << "hit at " << hitPos << std::endl;
-
- /* Reset the segmentation bins. */
- //m_segmentation->resetBins();
- /* Set the segmentation bins. */
- //m_segmentation->setBins( aStep );
- /* Create a 64-bit ID. */
- Id64bit id64 = makeId();
-
- /* Create a new hit. */
- G4CalorimeterHit* thisHit = new G4CalorimeterHit(theEdep, hitPos);
-
- /* Set the 64-bit ID. */
- thisHit->setId64bit(id64.getId0(), id64.getId1());
-
- /* Add hit to lookup map. */
- hits_vector[0].push_back(thisHit);
-
- /* Add hit to the HC. */
- m_hitsCollections[0]->insert(thisHit);
-
- /* Add an MCParticle contribution for this hit. */
- thisHit->addMcpHitContrib(McpHitContrib(aStep));
-
- /* Success. */
- return true;
-}
lcdd/src
diff -N GDMLWriter.cc
--- GDMLWriter.cc 26 Jun 2013 01:36:23 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,39 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/GDMLWriter.cc,v 1.5 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/util/GDMLWriter.hh"
-
-// GDML
-#include "G4Writer/G4GDMLWriter.h"
-
-// Geant4
-#include "G4VPhysicalVolume.hh"
-#include "G4TransportationManager.hh"
-
-void GDMLWriter::writeCurrentGeometry(const std::string& fileName, std::vector<std::string> volumes)
-{
- G4VPhysicalVolume* world = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
- G4GDMLWriter g4writer("http://www.lcsim.org/schemas/gdml/1.0/gdml.xsd", fileName);
- try {
- g4writer.DumpGeometryInfo(world, volumes);
- } catch (std::exception &err) {
- G4cerr << "problem writing geometry: " << err.what() << std::endl;
- }
-}
-
-void GDMLWriter::writeCurrentGeometry(const std::string& fileName)
-{
- G4cout << "Dumping current geometry to file <" << fileName << ">" << G4endl;
-
- G4VPhysicalVolume* world =
- G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
-
- G4GDMLWriter g4writer("http://www.lcsim.org/schemas/gdml/1.0/gdml.xsd", fileName);
-
- try {
- g4writer.DumpGeometryInfo(world);
- }
- catch(std::exception &lerr) {
- G4cerr << "problem writing geometry: " << lerr.what () << std::endl;
- }
-}
lcdd/src
diff -N GDMLWriterMessenger.cc
--- GDMLWriterMessenger.cc 26 Jun 2013 01:36:23 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,46 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/GDMLWriterMessenger.cc,v 1.5 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/util/GDMLWriterMessenger.hh"
-#include "lcdd/util/GDMLWriter.hh"
-
-// Geant4
-#include "G4UIcmdWithAString.hh"
-
-GDMLWriterMessenger::GDMLWriterMessenger()
-{
- defineCommands();
-}
-
-GDMLWriterMessenger::~GDMLWriterMessenger()
-{
-}
-
-void GDMLWriterMessenger::SetNewValue(G4UIcommand *, G4String newVals)
-{
- std::string volume;
- std::string fileName;
- std::istringstream is(newVals);
-
- is >> fileName >> volume;
-
- if (volume.length() > 1) {
- std::vector<std::string> volumes;
- volumes.push_back(volume);
- GDMLWriter::writeCurrentGeometry(fileName, volumes);
- } else {
- GDMLWriter::writeCurrentGeometry(fileName);
- }
-}
-
-void GDMLWriterMessenger::defineCommands()
-{
- m_dumpGDMLCmd = new G4UIcommand("/lcdd/dumpGDML", this);
- m_dumpGDMLCmd->SetGuidance("Dump current geometry to GDML output file.");
- G4UIparameter* p = new G4UIparameter("outputFile", 's', false);
- m_dumpGDMLCmd->SetParameter(p);
- p = new G4UIparameter("topVolume", 's', true);
- m_dumpGDMLCmd->SetParameter(p);
- m_dumpGDMLCmd->AvailableForStates(G4State_Idle);
-}
-
lcdd/src
diff -N GeometryManager.cc
--- GeometryManager.cc 26 Jun 2013 01:36:23 -0000 1.14
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,123 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/GeometryManager.cc,v 1.14 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/core/GeometryManager.hh"
-
-// LCDD
-#include "lcdd/geant4/G4UserRegionInformation.hh"
-#include "lcdd/core/G4StoreManager.hh"
-
-// GDML
-#include "G4Processor/GDMLProcessor.h"
-
-// Geant4
-#include "G4Run.hh"
-#include "G4LogicalVolume.hh"
-#include "G4VisAttributes.hh"
-#include "G4PVPlacement.hh"
-#include "G4LogicalVolumeStore.hh"
-#include "G4TransportationManager.hh"
-#include "G4Navigator.hh"
-
-GeometryManager* GeometryManager::m_instance = 0;
-
-GeometryManager::GeometryManager() :
- m_worldRegionIsSetup(false)
-{
- G4StoreManager::instance();
-}
-
-GeometryManager::~GeometryManager()
-{
-}
-
-GeometryManager* GeometryManager::instance()
-{
- if (m_instance == 0) {
- m_instance = new GeometryManager();
- }
-
- return m_instance;
-}
-
-void GeometryManager::beginRun(const G4Run*)
-{
- // only setup world region info on first run
- if (!m_worldRegionIsSetup) {
- setupWorldRegionInformation();
- }
-}
-
-G4LogicalVolume* GeometryManager::getWorldLogicalVolume() const
-{
- //return GDMLProcessor::GetInstance()->GetWorldVolume()->GetLogicalVolume();
- return getWorldPhysicalVolume()->GetLogicalVolume();
-}
-
-G4VPhysicalVolume* GeometryManager::getWorldPhysicalVolume() const
-{
- return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
-}
-
-void GeometryManager::setupWorldRegionInformation()
-{
- G4LogicalVolume* worldLV = getWorldLogicalVolume();
-
- assert(worldLV);
-
- G4UserRegionInformation* regInfo = new G4UserRegionInformation();
- regInfo->setStoreSecondaries(false);
- regInfo->setThreshold(0.0);
-
- worldLV->GetRegion()->SetUserInformation(regInfo);
- m_worldRegionIsSetup = true;
-}
-
-#ifdef HAVE_G4PVPLACEMENT_CHECKOVERLAPS
-
-void GeometryManager::checkOverlaps() const
-{
- checkOverlaps(getWorldLogicalVolume(), true);
-}
-
-void GeometryManager::checkOverlaps(G4LogicalVolume* lvolume, bool recurse) const
-{
- if (lvolume==0) return;
-
- for (G4int i=0; i<lvolume->GetNoDaughters(); i++) {
-
- G4PVPlacement* dau = static_cast<G4PVPlacement*>(lvolume->GetDaughter(i));
-
- if (dau) {
- // Check overlaps of daughters in mother.
- dau->CheckOverlaps();
-
- // Recursively check overlaps of daughters.
- if (recurse) {
- checkOverlaps(dau->GetLogicalVolume(), true);
- }
- }
- }
-}
-
-void GeometryManager::checkOverlaps(const G4String& name, bool recurse) const
-{
- G4LogicalVolumeStore* store = G4LogicalVolumeStore::GetInstance();
- bool found=false;
- for (std::vector<G4LogicalVolume*>::iterator it = store->begin();
- it != store->end();
- it++) {
- G4LogicalVolume* vol = (*it);
- if (vol->GetName() == name) {
- checkOverlaps(vol, recurse);
- found=true;
- break;
- }
- }
- if (!found) {
- G4cerr << "WARNING: The logical volume named <" << name << "> was not found in the G4LogicalVolumeStore!" << std::endl;
- }
-}
-
-#endif
-
lcdd/src
diff -N IdFactory.cc
--- IdFactory.cc 26 Jun 2013 01:36:23 -0000 1.30
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,382 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/IdFactory.cc,v 1.30 2013/06/26 01:36:23 jeremy Exp $
-
-// Uncomment to enable verbose debug output from this class.
-//#define ID_DEBUG 1
-
-// LCDD
-#include "lcdd/detectors/G4SensitiveDetector.hh"
-#include "lcdd/detectors/G4CalorimeterSD.hh"
-#include "lcdd/detectors/G4Segmentation.hh"
-#include "lcdd/id/IdManager.hh"
-#include "lcdd/id/IdFactory.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-
-// Geant4
-#include "G4Step.hh"
-#include "G4VPhysicalVolume.hh"
-#include "G4NavigationHistory.hh"
-
-using namespace std;
-
-IdFactory::Bits const IdFactory::MASK_ON = 0xFFFFFFFF;
-
-Id64bit IdFactory::createId64bit(const IdVec& idvec, IdSpec* idspec)
-{
-#ifdef ID_DEBUG
- G4cout << G4endl;
- G4cout.setf( ios::hex );
- G4cout << "IdFactory::createId64bit()" << G4endl;
- G4cout << "idvec size: " << idvec.size() << G4endl;
- G4cout << "idspec numFields: " << idspec->getNumFields() << G4endl;
- G4cout << "idspec bitLength: " << idspec->getBitLength() << G4endl;
-#endif
-
- /* IdVec (expanded id) size must equal IdSpec size or die. */
- if (idvec.size() != idspec->getNumFields()) {
- G4Exception("", "", FatalException, "idspec size != idvec size.");
- }
-
- /* Make a 64-bit id to return. */
- Id64bit id64;
-
- /* A 2 member array for cell ids 1 & 2 (2x32-bit int). */
- Bits id64_val[2] = { 0, 0 };
- size_t id64_val_idx = 0;
-
- /* Ptr to value of current idx. */
- Bits* id64_val_ptr = &id64_val[id64_val_idx];
-
- /* Ptr to the current idfield. */
- IdField* id_field = 0;
-
- /* Flag indicating that next 32-bit id has been reached. */
- bool next_id = false;
-
- /* loop vars */
- IdField::SizeType field_bit_len = 0;
- Bits curr_bit = 0;
- IdSpec::SizeType idspec_idx = 0;
-
- /* Loop over the IdVec, packing its values into the 64-bit Id
- using information from the IdSpec. */
- for (IdVec::ElementVector::const_iterator iter = idvec.getFieldsBegin(); iter != idvec.getFieldsEnd(); iter++) {
-
- /* field ptr from idspec */
- id_field = idspec->getIdField(idspec_idx);
- assert(id_field);
-
- /* id value of field */
- Id64bit::ElementType field_val = (Id64bit::ElementType) *iter;
-
- /* field length */
- field_bit_len = id_field->getLength();
-
- /* field start */
- Bits field_start = id_field->getStart();
-
- /* Don't allow crossing of 32-bit boundary.
- FIXME: See http://jira.slac.stanford.edu/browse/LCDD-21
- */
- if ((field_start < 32) && (field_start + field_bit_len > 32)) {
- G4cerr << "Field <" << id_field->getLabel() << "> crosses the 32-bit boundary." << G4endl;
- G4Exception("", "", FatalException, "Fields are not allowed to cross the 32-bit boundary.");
- }
- /* check if on 2nd dbl word. */
- else if (field_start >= 32) {
-
- /* If 1st time, set id val pntr. */
- if (!next_id) {
-#ifdef ID_DEBUG
- G4cout << "setting ptr to next id" << G4endl;
-#endif
- ++id64_val_idx;
- id64_val_ptr = &id64_val[id64_val_idx];
- next_id = true;
- }
-
- /* Adjust start idx for position in next 32-bit id. */
- field_start -= 32;
- }
-
- Bits field_mask = makeBitMask(field_bit_len);
-
-#ifdef ID_DEBUG
- G4cout << "idspec_idx: " << dec << idspec_idx << G4endl;
- G4cout << "shifting left: " << dec << field_bit_len << G4endl;
- G4cout << "curr_bit: " << dec << curr_bit << G4endl;
- G4cout << "field_label: " << id_field->getLabel() << G4endl;
- G4cout << "field_start: " << field_start << G4endl;
- G4cout << "field_val (dec): " << dec << field_val << G4endl;
- G4cout << "field_val (hex): " << hex << field_val << G4endl;
- G4cout << "field_bit_len: " << dec << field_bit_len << G4endl;
- G4cout << "field_mask: " << hex << field_mask << G4endl;
-#endif
-
- /* For positive values, check that this value doesn't overflow the assigned length. */
- // if ( field_val > 0 ) {
- if (checkOverflow(field_val, field_mask) != 0) {
- G4cerr << "Value <" << field_val << "> is too big for the field <" << id_field->getLabel() << ">, len <" << field_bit_len << ">." << G4endl;
- G4Exception("", "", FatalException, "Value too large for field.");
- }
- // }
- // else {
- // }
-
-#ifdef ID_DEBUG
- G4cout << "field_mask: " << hex << field_mask << G4endl;
-#endif
-
- /* Apply bit mask and shift to proper left pos. */
- Bits field_val_shifted_masked = (field_val & field_mask) << field_start;
-
- /* AND into the current id val. */
- (*id64_val_ptr) = (*id64_val_ptr) | field_val_shifted_masked;
-
- /* Set current bit to next start pos. */
- curr_bit += id_field->getLength();
-
-#ifdef ID_DEBUG
- G4cout << "id64_val (hex): " << hex << *id64_val_ptr << G4endl;
- G4cout << G4endl;
-#endif
-
- /* Increment the idspec idx. */
- ++idspec_idx;
- }
-
-#ifdef ID_DEBUG
- G4cout << "end curr_bit: " << dec << curr_bit << G4endl;
- G4cout << "end id64[0]: " << hex << id64_val[0] << G4endl;
- G4cout << "end id64[1]: " << hex << id64_val[1] << G4endl;
- G4cout.unsetf( ios::hex );
- G4cout << G4endl << G4endl;
-#endif
-
- /* Set the two 32-bit ids in the packed id to return. */
- id64.setId0(id64_val[0]);
- id64.setId1(id64_val[1]);
-
- return id64;
-}
-
-inline IdFactory::Bits IdFactory::makeBitMask(IdField::SizeType len)
-{
- return (Bits) ((1 << len) - 1);
-}
-
-inline IdFactory::Bits IdFactory::checkOverflow(Id64bit::ElementType val, Bits mask)
-{
- Bits xbits = 0x0;
-
- /* get flipped mask of all 1's in positions that should be masked off for this val */
- Bits flipMask = mask ^ MASK_ON;
-
- /* mask off all the valid bits, leaving overflow bits */
- Id64bit::ElementType overflow = (val & flipMask);
-
- /* for pos vals, check that no bits past max bit are = 1 */
- if (val >= 0) {
- xbits = (Bits) ((flipMask) & overflow);
- }
- /* for neg vals, check that no bits past max bit are = 0 */
- else {
- xbits = (Bits) ((flipMask) ^ overflow);
- }
-
-#ifdef ID_DEBUG
- G4cout << "flipMask: " << hex << flipMask << G4endl;
- G4cout << "overflow: " << hex << overflow << G4endl;
- G4cout << "overflow bits (hex): " << hex << xbits << G4endl;
-#endif
-
- return xbits;
-}
-
-IdVec IdFactory::createOrderedIdVec(G4Step* aStep, const G4SensitiveDetector* sd)
-{
- //std::cout << "createOrderedIdVec" << std::endl;
-
- assert(aStep);
- assert(sd);
-
- IdSpec* idspec = sd->getIdSpec();
- IdVec ids;
-
- G4Segmentation* seg = 0;
- if (sd->getType() == G4SensitiveDetector::eCalorimeter) {
- seg = (dynamic_cast<const G4CalorimeterSD*>(sd))->getSegmentation();
- }
-
- if (idspec) {
- for (IdSpec::IdFields::const_iterator iter = idspec->IdFieldsBegin(); iter != idspec->IdFieldsEnd(); iter++) {
-
- IdField* f = *iter;
-
- int bin_val = 0;
- bool fnd_it = false;
-
-#ifdef ID_DEBUG
- G4cout << "handling field: " << f->getLabel() << G4endl;
-#endif
-
- // look in seg, if exists
- if (seg) {
- int bin_idx = IdFactory::findFieldIdxInSegmentation(seg, f->getLabel());
-
- if (bin_idx != -1) {
- std::cout << "getting bin: " << bin_idx << std::endl;
- bin_val = seg->getBin(bin_idx);
- std::cout << "got bin val: " << bin_val << std::endl;
- fnd_it = true;
- }
-#ifdef ID_DEBUG
- else {
- G4cout << "not in segmentation" << G4endl;
- }
-#endif
- }
-
- // find in PV ids
- if (!fnd_it) {
- std::vector<G4VPhysicalVolume*> pv_list = ReadoutUtil::getPhysVolList(aStep);
-
- if (hasPhysVolId(pv_list, f->getLabel())) {
- fnd_it = true;
- bin_val = findIdInPhysVols(pv_list, f->getLabel());
- }
-#ifdef ID_DEBUG
- else {
- G4cout << "not in physvolids" << G4endl;
- }
-#endif
-
- }
-
- /* Find in copy numbers of the volume. */
- if (!fnd_it && f->getLabel() == "volume") {
- bin_val = ReadoutUtil::getVolumeNumber(aStep->GetPreStepPoint()->GetTouchableHandle());
-
- if (-1 == bin_val) {
- G4Exception("", "", FatalException, "Valid copy number not found for PV.");
- } else {
- fnd_it = true;
- }
- }
-#ifdef ID_DEBUG
- else {
- G4cout << "not in volume (copyNum)" << G4endl;
- }
-#endif
-
- // Push back zero as the default value for field not found.
- ids.push_back(bin_val);
-
-#ifdef ID_DEBUG
- G4cout << "set bin val: " << bin_val << G4endl << G4endl;
-#endif
- }
- }
-
- return ids;
-}
-
-int IdFactory::findFieldIdxInSegmentation(G4Segmentation* seg, const std::string& field_name)
-{
- const std::vector<std::string>& bin_names = seg->getBinNames();
-
- int bin_count = 0;
- bool fnd = false;
- for (std::vector<std::string>::const_iterator iter = bin_names.begin(); iter != bin_names.end(); iter++) {
- if (*iter == field_name) {
- fnd = true;
- break;
- }
- ++bin_count;
- }
-
- if (!fnd) {
- bin_count = -1;
- }
-
- return bin_count;
-}
-
-int IdFactory::findIdInPhysVols(const std::vector<G4VPhysicalVolume*>& pvs, const std::string& field_name)
-{
- IdManager* id_mgr = IdManager::instance();
-
-#ifdef ID_DEBUG
- G4cout << "looking for field_name match on <" << field_name << ">" << G4endl;
-#endif
-
- int id = 0;
- G4VPhysicalVolume* pv = 0;
- bool fnd = false;
-
- for (std::vector<G4VPhysicalVolume*>::const_iterator iter_pv = pvs.begin(); iter_pv != pvs.end(); iter_pv++) {
- pv = *iter_pv;
-
-#ifdef ID_DEBUG
- G4cout << "searching in ids of PV <" << pv->GetName() << ">" << G4endl;
-#endif
-
- if (id_mgr->hasPhysVolIds(pv)) {
- PhysVolId::PhysVolIds pvids = id_mgr->getPhysVolIds(pv);
- for (PhysVolId::PhysVolIds::const_iterator iter = pvids.begin(); iter != pvids.end(); iter++) {
-
-#ifdef ID_DEBUG
- G4cout << "current field <" << (*iter).getFieldName() << ">" << G4endl;
-#endif
-
- if ((*iter).getFieldName() == field_name) {
-#ifdef ID_DEBUG
- G4cout << "found a match" << G4endl;
-#endif
- id = (*iter).getValue();
- fnd = true;
- break;
- }
-#ifdef ID_DEBUG
- else {
- G4cout << "no match on this PV" << G4endl;
- }
-#endif
- }
- }
-
- if (fnd) {
- break;
- }
- }
-
- return id;
-}
-
-bool IdFactory::hasPhysVolId(const std::vector<G4VPhysicalVolume*>& pvs, const std::string& field_name)
-{
- IdManager* id_mgr = IdManager::instance();
-
- G4VPhysicalVolume* pv = 0;
- bool fnd = false;
-
- for (std::vector<G4VPhysicalVolume*>::const_iterator iter_pv = pvs.begin(); iter_pv != pvs.end(); iter_pv++) {
- pv = *iter_pv;
-
- if (id_mgr->hasPhysVolIds(pv)) {
- PhysVolId::PhysVolIds pvids = id_mgr->getPhysVolIds(pv);
- for (PhysVolId::PhysVolIds::const_iterator iter = pvids.begin(); iter != pvids.end(); iter++) {
-
- if ((*iter).getFieldName() == field_name) {
- fnd = true;
- break;
- }
- }
- }
-
- if (fnd) {
- break;
- }
- }
-
- return fnd;
-}
lcdd/src
diff -N IdFieldProcess.cc
--- IdFieldProcess.cc 26 Jun 2013 01:36:23 -0000 1.8
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,77 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/IdFieldProcess.cc,v 1.8 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#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"
-
-// LCDD
-#include "lcdd/schema/idfieldElem.hh"
-
-// std
-#include <iostream>
-
-/**
- @class idfieldProcess
- @brief SAX process to create the idfield element.
- */
-class idfieldProcess: public SAXStateProcess
-{
-public:
-
- idfieldProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~idfieldProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- SAXObject** obj = Context()->GetTopObject();
-
- idfieldElem* idfield = new idfieldElem;
-
- idfield->set_label(attrs.getValue("label"));
- idfield->set_start(attrs.getValue("start"));
- idfield->set_length(attrs.getValue("length"));
- idfield->set_signed(attrs.getValue("signed"));
-
- m_obj = idfield;
- *obj = idfield;
- }
- 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 = "idfield";
- return tag;
- }
-
-private:
-
- SAXObject* m_obj;
-};
-
-DECLARE_PROCESS_FACTORY(idfieldProcess)
lcdd/src
diff -N IdManager.cc
--- IdManager.cc 26 Jun 2013 01:36:23 -0000 1.8
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,88 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/IdManager.cc,v 1.8 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/id/IdManager.hh"
-
-// Geant4
-#include "G4LogicalVolume.hh"
-
-IdManager* IdManager::m_instance = 0;
-
-IdManager::IdManager()
-{
-}
-
-IdManager::~IdManager()
-{
-}
-
-IdManager* IdManager::instance()
-{
- if (m_instance == 0) {
- m_instance = new IdManager;
- }
-
- return m_instance;
-}
-
-void IdManager::addIdSpec(const std::string& name, IdSpec* spec)
-{
- m_idSpecs[name] = spec;
-}
-
-IdSpec* IdManager::getIdSpec(const char* name)
-{
- std::string key = name;
- return getIdSpec(key);
-}
-
-IdSpec* IdManager::getIdSpec(const std::string& name)
-{
- return m_idSpecs[name];
-}
-
-IdManager::IdSpecs::const_iterator IdManager::getIdSpecsBegin()
-{
- return m_idSpecs.begin();
-}
-
-IdManager::IdSpecs::const_iterator IdManager::getIdSpecsEnd()
-{
- return m_idSpecs.end();
-}
-
-void IdManager::addPhysVolId(G4LogicalVolume* lvMom, int childIdx, PhysVolId childId)
-{
- // DEBUG
- //std::cout << std::endl << "assigning physvolid..." << std::endl;
- //std::cout << "lvMom <" << lvMom->GetName() << ">" << std::endl;
- //std::cout << "childIdx <" << childIdx << ">" << std::endl;
- //std::cout << "childId field: " << childId.getFieldName() << std::endl;
- //std::cout << "childId <" << childId.getValue() << ">" << std::endl;
- //
-
- G4VPhysicalVolume* dau = lvMom->GetDaughter(childIdx);
-
- if (dau) {
-
- //std::cout << "found daughter <" << dau->GetName() << ">" << std::endl;
- //std::cout << "dau ptr <" << dau << ">" << std::endl;
-
- m_physVolIdMap.addPhysVolId(dau, childId);
- } else {
- std::cerr << "IdManager::assignPhysVolId() - childIdx <" << childIdx << "> does not exist!" << std::endl;
- }
-
- //std::cout << std::endl;
-}
-
-void IdManager::printIds(std::ostream& os, const IdVec& ids)
-{
- os << "id stack:";
-
- for (std::vector<int>::const_iterator iter = ids.getFieldsBegin(); iter != ids.getFieldsEnd(); iter++) {
- os << " " << *iter;
- }
-
- os << std::endl;
-}
lcdd/src
diff -N IdSpec.cc
--- IdSpec.cc 26 Jun 2013 01:36:23 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,89 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/IdSpec.cc,v 1.6 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/id/IdSpec.hh"
-
-// STL
-#include <sstream>
-
-using namespace std;
-
-void IdSpec::printOut(std::ostream& os) const
-{
- os << std::endl;
-
- os << "IdSpec: " << m_name << std::endl;
- os << "bitLength: " << m_bitLength << std::endl;
-
- static const int def_width = 15;
-
- os.width(def_width);
- os << left << "label";
-
- os.width(def_width);
- os << left << "start";
-
- os.width(def_width);
- os << left << "end";
-
- os.width(def_width);
- os << left << "size";
-
- os.width(def_width);
- os << left << "signed";
-
- os << std::endl;
-
- os.fill('-');
- os.width(66);
- os << left << "-" << std::endl;
-
- os.fill(' ');
-
- for (IdFields::const_iterator iter = IdFieldsBegin(); iter != IdFieldsEnd(); iter++) {
-
- IdField* f = *iter;
-
- os.width(def_width);
- os << left << f->getLabel();
-
- os.width(def_width);
- os << left << f->getStart();
-
- os.width(def_width);
- os << left << f->getStart() + f->getLength() - 1;
-
- os.width(def_width);
- os << left << f->getLength();
-
- os.width(def_width);
- os << left << f->getSigned();
-
- os.width(def_width);
- os << left << std::endl;
- }
-
- os << std::endl;
-}
-
-std::string IdSpec::getFieldDescription()
-{
- std::stringstream enc;
-
- // Loop over the fields in the IdSpec.
- for (IdSpec::IdFields::const_iterator it = this->IdFieldsBegin(); it != this->IdFieldsEnd(); it++) {
-
- // Get the IdField.
- IdField* field = (*it);
-
- // Encode the field information into the LCIO / compact format.
- enc << field->getLabel() << ":" << field->getStart() << ":";
- if (field->getSigned()) {
- enc << "-";
- }
- enc << field->getLength() << ",";
- }
-
- // Return the id description string, eliminating last comma.
- return enc.str().substr(0, enc.str().length() - 1);
-}
lcdd/src
diff -N IdVec.cc
--- IdVec.cc 26 Jun 2013 01:36:23 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,47 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/IdVec.cc,v 1.4 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/id/IdVec.hh"
-
-IdVec::IdVec()
-{
-}
-
-IdVec::~IdVec()
-{
-}
-
-void IdVec::clear()
-{
- m_fields.clear();
-}
-
-void IdVec::push_back(ElementType et)
-{
- m_fields.push_back(et);
-}
-
-IdVec::ElementType IdVec::getFieldValue(SizeType idx) const
-{
- return m_fields.at(idx);
-}
-
-void IdVec::setFieldValue(SizeType idx, ElementType et)
-{
- m_fields.insert(m_fields.begin() + idx, et);
-}
-
-IdVec::ElementType IdVec::operator [](SizeType idx) const
-{
- return getFieldValue(idx);
-}
-
-IdVec::ElementVector::const_iterator IdVec::getFieldsBegin() const
-{
- return m_fields.begin();
-}
-
-IdVec::ElementVector::const_iterator IdVec::getFieldsEnd() const
-{
- return m_fields.end();
-}
lcdd/src
diff -N LCDDDetectorConstruction.cc
--- LCDDDetectorConstruction.cc 26 Jun 2013 01:36:23 -0000 1.16
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,79 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/LCDDDetectorConstruction.cc,v 1.16 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/core/LCDDDetectorConstruction.hh"
-#include "lcdd/core/LCDDParser.hh"
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/core/LCDDMessenger.hh"
-#include "lcdd/core/LCDDObjectStoreInspector.hh"
-#include "lcdd/util/GDMLWriterMessenger.hh"
-#include "lcdd/core/GeometryManager.hh"
-
-// Geant4
-#include "G4VPhysicalVolume.hh"
-#include "G4UImanager.hh"
-#include "G4Timer.hh"
-
-// std
-#include <cassert>
-
-LCDDDetectorConstruction::LCDDDetectorConstruction() :
- m_world(0)
-{
- // LCDD messenger
- m_messenger = new LCDDMessenger();
-
- // writer messenger
- m_writerMessenger = new GDMLWriterMessenger();
-
- // setup geo manager
- GeometryManager::instance();
-
- // setup parser if not already
- LCDDParser::instance();
-
- m_inspector = new LCDDObjectStoreInspector();
-}
-
-LCDDDetectorConstruction::~LCDDDetectorConstruction()
-{
- delete m_inspector;
- delete m_writerMessenger;
- delete m_messenger;
-}
-
-G4VPhysicalVolume* LCDDDetectorConstruction::Construct()
-{
- // start build timer
- G4Timer geoTimer;
- geoTimer.Start();
-
- G4cout << "Started geometry construction timer." << G4endl;
-
- // get geometry from the global parser instance, which will die on failure
- G4VPhysicalVolume* pv = LCDDParser::instance()->construct();
-
- // set world ptr
- setWorldVolume(pv);
-
- // stop build timer and print
- geoTimer.Stop();
- G4cout << "Geometry construction time: " << geoTimer << G4endl;
-
- return pv;
-}
-
-void LCDDDetectorConstruction::setWorldVolume(G4VPhysicalVolume *pv)
-{
- if (pv == 0) {
- G4Exception("", "", FatalException, "PhysVol points to null.");
- }
-
- m_world = pv;
-}
-
-G4VPhysicalVolume* LCDDDetectorConstruction::getWorldVolume()
-{
- return m_world;
-}
-
lcdd/src
diff -N LCDDFieldManager.cc
--- LCDDFieldManager.cc 26 Jun 2013 01:36:23 -0000 1.7
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,95 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/LCDDFieldManager.cc,v 1.7 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/bfield/LCDDFieldManager.hh"
-#include "lcdd/core/LCDDProcessor.hh"
-
-LCDDFieldManager* LCDDFieldManager::m_instance = 0;
-
-LCDDFieldManager::~LCDDFieldManager()
-{
-}
-
-LCDDFieldManager* LCDDFieldManager::instance()
-{
- if (m_instance == 0) {
- m_instance = new LCDDFieldManager();
- }
- return m_instance;
-}
-
-MagneticFieldOverlay* LCDDFieldManager::makeOverlay(std::vector<G4MagneticField*> fields)
-{
- MagneticFieldOverlay* overlay = new MagneticFieldOverlay();
- for (std::vector<G4MagneticField*>::const_iterator iter = fields.begin(); iter != fields.end(); iter++) {
- overlay->addMagneticField(*iter);
- }
- return overlay;
-}
-
-void LCDDFieldManager::setup()
-{
- // Pointer to the field which will be passed to Geant4.
- G4MagneticField* field = 0;
-
- // Setup only the global fields specified in global_field.
- if (m_globalfields.size() != 0) {
- // Use specific list of global fields registered with LCDDFieldManager.
- field = setup(m_globalfields);
- }
- // No global fields, so treat all fields registered with LCDDProcessor
- // as global.
- else {
-
- // Build a list of fields that were registered with the LCDDProcessor.
- std::vector<G4MagneticField*> fields;
- LCDDProcessor* proc = LCDDProcessor::instance();
- for (LCDDProcessor::MagneticFields::const_iterator iter = proc->getMagneticFieldsBegin(); iter != proc->getMagneticFieldsEnd(); iter++) {
- fields.push_back(iter->second);
- }
-
- // Setup fields from LCDDProcessor.
- field = setup(fields);
- }
-
- // Initialize the single or overlay field with Geant4.
- initialize(field);
-}
-
-G4MagneticField* LCDDFieldManager::setup(std::vector<G4MagneticField*> fields)
-{
- G4MagneticField* field = 0;
- //if (fields.size() == 0) {
- // G4cerr << "LCDDFieldManager - No magnetic fields to setup." << G4endl;
- //}
- //else if (fields.size() == 1) {
- // field = fields[0];
- //}
- //else {
- field = makeOverlay(fields);
- //}
- return field;
-}
-
-void LCDDFieldManager::initialize(G4MagneticField* field)
-{
- if (field != 0) {
- G4FieldManager* fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager();
- fieldMgr->SetDetectorField(field);
- fieldMgr->CreateChordFinder(field);
- }
-}
-
-void LCDDFieldManager::addGlobalField(G4MagneticField* f)
-{
- m_globalfields.push_back(f);
-}
-
-void LCDDFieldManager::addField(G4MagneticField* f)
-{
- m_allfields.push_back(f);
-}
-
-LCDDFieldManager::LCDDFieldManager()
-{
-}
lcdd/src
diff -N LCDDLibLoad.cc
--- LCDDLibLoad.cc 24 Jun 2013 22:10:36 -0000 1.31
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,110 +0,0 @@
-#include "Saxana/SAXComponentFactory.h"
-
-#include <iostream>
-
-extern "C"
-{
-
-void LCDDLoadProcesses()
-{
-
- // header
- LOAD_COMPONENT(headerProcess);
- LOAD_COMPONENT(detectorProcess);
- LOAD_COMPONENT(authorProcess);
- LOAD_COMPONENT(generatorProcess);
- LOAD_COMPONENT(commentProcess);
-
- // volume extended
- LOAD_COMPONENT(volumeExtendedProcess);
- LOAD_COMPONENT(physvolidProcess);
-
- // SDs
- LOAD_COMPONENT(calorimeterProcess);
- LOAD_COMPONENT(optical_calorimeterProcess);
- LOAD_COMPONENT(unsegmented_calorimeterProcess);
- LOAD_COMPONENT(trackerProcess);
- LOAD_COMPONENT(scorerProcess);
- LOAD_COMPONENT(sdrefProcess);
-
- // segmentations
- LOAD_COMPONENT(grid_xyzProcess);
- LOAD_COMPONENT(projective_cylinderProcess);
- LOAD_COMPONENT(projective_zplaneProcess);
- LOAD_COMPONENT(nonprojective_cylinderProcess);
- LOAD_COMPONENT(global_grid_xyProcess);
- LOAD_COMPONENT(cell_readout_2dProcess);
-
- // Ids
- LOAD_COMPONENT(idspecProcess);
- LOAD_COMPONENT(idfieldProcess);
- LOAD_COMPONENT(idspecrefProcess);
-
- // field
- LOAD_COMPONENT(fieldrefProcess);
- LOAD_COMPONENT(global_fieldProcess);
- LOAD_COMPONENT(solenoidProcess);
- LOAD_COMPONENT(rz_field_mapProcess);
- LOAD_COMPONENT(rzbProcess);
- LOAD_COMPONENT(dipoleProcess);
- LOAD_COMPONENT(dipole_coeffProcess);
- LOAD_COMPONENT(box_dipoleProcess);
- LOAD_COMPONENT(field_map_3dProcess)
-
- // region
- LOAD_COMPONENT(regionProcess);
- LOAD_COMPONENT(regionrefProcess);
-
- // display
- LOAD_COMPONENT(visProcess);
- LOAD_COMPONENT(visrefProcess);
- LOAD_COMPONENT(colorProcess);
-
- // limit
- LOAD_COMPONENT(limitsetProcess);
- LOAD_COMPONENT(limitsetrefProcess);
- LOAD_COMPONENT(limitProcess);
-}
-
-void LCDDLoadSubscribers()
-{
- // subscribers
- LOAD_COMPONENT(headerSubscriber);
-
- // volume extended
- //LOAD_COMPONENT(volumeExtendedSubscriber);
-
- // SDs
- LOAD_COMPONENT(calorimeterSubscriber);
- LOAD_COMPONENT(optical_calorimeterSubscriber);
- LOAD_COMPONENT(unsegmented_calorimeterSubscriber);
- LOAD_COMPONENT(trackerSubscriber);
- LOAD_COMPONENT(scorerSubscriber);
-
- // Ids
- LOAD_COMPONENT(idspecSubscriber);
-
- // field
- LOAD_COMPONENT(solenoidSubscriber);
- LOAD_COMPONENT(rz_field_mapSubscriber);
- LOAD_COMPONENT(dipoleSubscriber);
- LOAD_COMPONENT(box_dipoleSubscriber);
- LOAD_COMPONENT(global_fieldSubscriber);
- LOAD_COMPONENT(field_map_3dSubscriber);
-
- // region
- LOAD_COMPONENT(regionSubscriber);
-
- // display
- LOAD_COMPONENT(visSubscriber);
-
- // limit
- LOAD_COMPONENT(limitsetSubscriber);
-}
-
-void LCDDLibLoad()
-{
- LCDDLoadProcesses();
- LCDDLoadSubscribers();
-}
-}
lcdd/src
diff -N LCDDMessenger.cc
--- LCDDMessenger.cc 26 Jun 2013 01:36:23 -0000 1.11
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,167 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/LCDDMessenger.cc,v 1.11 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/core/LCDDMessenger.hh"
-#include "lcdd/core/LCDDParser.hh"
-#include "lcdd/core/GeometryManager.hh"
-#include "lcdd/util/NistElementsDump.hh"
-#include "lcdd/util/StringUtil.hh"
-
-// Geant4
-#include "G4UImessenger.hh"
-#include "G4UIcommand.hh"
-#include "G4UIdirectory.hh"
-
-// STL
-#include <cassert>
-
-LCDDMessenger::LCDDMessenger()
-{
- // define UI commands
- defineCommands();
-}
-
-LCDDMessenger::~LCDDMessenger()
-{
- delete m_setupCmd;
- delete m_setURICmd;
- delete m_setSetupNameCmd;
- delete m_setVersionCmd;
- delete m_lcddDir;
-}
-
-void LCDDMessenger::SetNewValue(G4UIcommand *cmd, G4String newVals)
-{
- LCDDParser* parser = LCDDParser::instance();
-
- G4String singleArg = newVals;
- std::istringstream is((const char*) newVals);
-
- if (cmd == m_setURICmd) {
- parser->setURI(singleArg);
- } else if (cmd == m_setSetupNameCmd) {
- parser->setSetupName(singleArg);
- } else if (cmd == m_setVersionCmd) {
- parser->setVersion(singleArg);
- } else if (cmd == m_setupCmd) {
- G4String uri, setup, version;
-
- is >> uri >> setup >> version;
-
- parser->setURI(uri);
- parser->setSetupName(setup);
- parser->setVersion(version);
- } else if (cmd == m_dumpCmd) {
- //std::cout<<"arg: "<<singleArg<<std::endl;
- NistElementsDump::writeXml(singleArg);
- }
-#ifdef HAVE_G4PVPLACEMENT_CHECKOVERLAPS
- else if (cmd==m_checkOverlapsCmd || cmd==m_checkOverlapsRecurseCmd)
- {
-
- bool recurse=false;
-
- if (cmd == m_checkOverlapsRecurseCmd)
- {
- recurse=true;
- }
-
- G4String vol("");
- is >> vol;
-
- G4cout << "vol=" << vol << G4endl;
- G4cout << "recurse=" << recurse << G4endl;
-
- if (newVals != "")
- {
- // Check the named volume with optional recursion.
- GeometryManager::instance()->checkOverlaps(vol, recurse);
- }
- else
- {
- // No volume. Check the world, which is always done recursively!
- GeometryManager::instance()->checkOverlaps();
- }
- }
-#endif
- else {
- G4cerr << "WARNING: Unknown cmd to LCDDMessenger - " << cmd << G4endl;
- }
-}
-
-G4String LCDDMessenger::GetCurrentValue(G4UIcommand *)
-{
- return G4String("");
-}
-
-void LCDDMessenger::defineCommands()
-{
- G4UIparameter *p;
-
- // LCDD directory
- m_lcddDir = new G4UIdirectory("/lcdd/");
- m_lcddDir->SetGuidance("XML detector description and geometry commands. [LCDD]");
-
- // set URL for input geometry file
- m_setURICmd = new G4UIcommand("/lcdd/url", this);
- m_setURICmd->SetGuidance("Set the Uniform Resource Locator (URL) for the input geometry file.");
- m_setURICmd->AvailableForStates(G4State_PreInit);
-
- p = new G4UIparameter("URI", 's', false);
- m_setURICmd->SetParameter(p);
-
- // set name of GDML setup
- m_setSetupNameCmd = new G4UIcommand("/lcdd/setupName", this);
- m_setSetupNameCmd->SetGuidance("Set GDML setup name.");
- m_setSetupNameCmd->AvailableForStates(G4State_PreInit);
-
- p = new G4UIparameter("SetupName", 's', false);
- m_setSetupNameCmd->SetParameter(p);
-
- // set version of GDML setup
- m_setVersionCmd = new G4UIcommand("/lcdd/version", this);
- m_setVersionCmd->SetGuidance("Set GDML version tag.");
- m_setVersionCmd->AvailableForStates(G4State_PreInit);
-
- p = new G4UIparameter("Version", 's', false);
- m_setVersionCmd->SetParameter(p);
-
- // setup URI, Setup and Version in one command
- m_setupCmd = new G4UIcommand("/lcdd/setup", this);
- m_setupCmd->SetGuidance("Set URI, SetupName and Version with a single command.");
- m_setupCmd->AvailableForStates(G4State_PreInit);
-
- p = new G4UIparameter("URI", 's', false);
- p->SetGuidance("URI is a URL to the input file. It MUST NOT contain unescaped spaces.");
- m_setupCmd->SetParameter(p);
-
- p = new G4UIparameter("SetupName", 's', true);
- m_setupCmd->SetParameter(p);
-
- p = new G4UIparameter("Version", 's', true);
- m_setupCmd->SetParameter(p);
-
- m_dumpCmd = new G4UIcommand("/lcdd/dumpNistElements", this);
- m_dumpCmd->SetGuidance("Dump NIST elements to file as GDML fragment, including lambda and X0.");
- p = new G4UIparameter("Filename", 's', true);
- p->SetDefaultValue("NistElements.xml");
- m_dumpCmd->SetParameter(p);
-
-#ifdef HAVE_G4PVPLACEMENT_CHECKOVERLAPS
- // Check overlaps.
- m_checkOverlapsCmd = new G4UIcommand("/lcdd/checkOverlaps",this);
- m_checkOverlapsCmd->SetGuidance("Call CheckOverlaps on a given volume or the world volume (no arguments).");
-
- p = new G4UIparameter("Volume",'s',true);
- p->SetDefaultValue("");
- m_checkOverlapsCmd->SetParameter(p);
-
- // Check overlaps with recursion to daughters.
- m_checkOverlapsRecurseCmd = new G4UIcommand("/lcdd/checkOverlapsRecurse",this);
- m_checkOverlapsRecurseCmd->SetGuidance("Call CheckOverlaps on a given volume and recursively check daughters.");
-
- p = new G4UIparameter("Volume",'s',true);
- p->SetDefaultValue("");
- m_checkOverlapsRecurseCmd->SetParameter(p);
-#endif
-}
lcdd/src
diff -N LCDDParser.cc
--- LCDDParser.cc 26 Jun 2013 01:36:23 -0000 1.14
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,172 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/LCDDParser.cc,v 1.14 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/core/LCDDParser.hh"
-#include "lcdd/bfield/LCDDFieldManager.hh"
-#include "lcdd/subscribers/volumeExtendedSubscriber.hh"
-
-// GDML
-#include "G4Processor/GDMLProcessor.h"
-#include "Saxana/SAXComponentFactoryTable.h"
-#include "Saxana/RCObjectHandle.h"
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXSubscriberPool.h"
-
-// Geant4
-#include "G4VPhysicalVolume.hh"
-
-extern "C" void LCDDLibLoad();
-
-LCDDParser* LCDDParser::m_instance = 0;
-
-LCDDParser::LCDDParser() :
- m_URI(""), m_setupName(""), m_version(""), m_initialized(false), m_constructed(false), m_setURI(false)
-{
-}
-
-LCDDParser* LCDDParser::instance()
-{
- if (m_instance == 0) {
- m_instance = new LCDDParser();
- }
-
- return m_instance;
-}
-
-LCDDParser::~LCDDParser()
-{
- finalize();
-}
-
-void LCDDParser::setupParserConfig()
-{
- setupParserConfig(m_URI, m_setupName, m_version);
-}
-
-void LCDDParser::setupParserConfig(const std::string& URI, const std::string&, const std::string& version)
-{
- // settings from messenger commands
- std::cout << "LCDD URI <" << m_URI << ">" << std::endl;
- //std::cout << "SetupName <" << m_setupName << ">" << std::endl;
- std::cout << "Version <" << m_version << ">" << std::endl;
-
- // set configuration vals
- m_config.SetURI(URI);
- //m_config.SetSetupName(setupName);
- m_config.SetSetupVersion(version);
-
- // set config in parser
- m_sxp.Configure(&m_config);
-}
-
-void LCDDParser::initializeParser()
-{
- // standard SAX parser init
- m_sxp.Initialize();
-
- // load custom LCDD tag handlers
- LCDDLibLoad();
-
- addVolumeExtendedSubscriber();
-}
-
-void LCDDParser::initialize()
-{
- if (!m_initialized) {
- initializeParser();
- m_initialized = true;
- }
-}
-
-G4VPhysicalVolume* LCDDParser::construct()
-{
- if (!m_constructed) {
-
- // initialize
- initialize();
-
- // set GDML parser params from inst vars
- setupParserConfig();
-
- // run the parser
- m_sxp.Run();
-
- // get world volume from GDML
- try {
- m_world = (G4VPhysicalVolume*) GDMLProcessor::GetInstance()->GetWorldVolume();
- } catch (std::exception& e) {
- G4Exception("", "", FatalException, "Failed to get the world volume.");
- }
-
- // Setup magnetic field.
- LCDDFieldManager::instance()->setup();
-
- // This method should only be called once.
- m_constructed = true;
- } else {
- std::cerr << "LCDD geometry was already constructed." << std::endl;
- }
-
- return m_world;
-}
-
-void LCDDParser::finalize()
-{
- m_sxp.Finalize();
-}
-
-void LCDDParser::setURI(std::string URI)
-{
- m_URI = URI;
- m_setURI = true;
-}
-
-void LCDDParser::setSetupName(std::string setupName)
-{
- m_setupName = setupName;
-}
-
-void LCDDParser::setVersion(std::string version)
-{
- m_version = version;
-}
-
-const std::string& LCDDParser::URI()
-{
- return m_URI;
-}
-
-const std::string& LCDDParser::setupName()
-{
- return m_setupName;
-}
-
-const std::string& LCDDParser::version()
-{
- return m_version;
-}
-
-void LCDDParser::setWorld(G4VPhysicalVolume *world)
-{
- m_world = world;
-}
-
-bool LCDDParser::isValidSetup()
-{
- bool valid = true;
-
- if (!m_setURI) {
- valid = false;
- }
-
- return valid;
-}
-
-void LCDDParser::addVolumeExtendedSubscriber()
-{
- RCObjectHandle<SAXSubscriber> obj;
- obj = new volumeExtendedSubscriber();
- SAXSubscriberPool* pool = const_cast<SAXSubscriberPool*>(m_sxp.GetSubscriberPool());
- pool->AddSubscriber("volume", obj);
-}
-
lcdd/src
diff -N LCDDProcessor.cc
--- LCDDProcessor.cc 26 Jun 2013 01:36:23 -0000 1.19
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,220 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/LCDDProcessor.cc,v 1.19 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/bfield/LCDDFieldManager.hh"
-#include "lcdd/bfield/MagneticFieldOverlay.hh"
-
-// Geant4
-#include "G4TransportationManager.hh"
-#include "G4FieldManager.hh"
-#include "G4EventManager.hh"
-#include "G4Event.hh"
-#include "G4SDManager.hh"
-#include "G4HCtable.hh"
-
-LCDDProcessor* LCDDProcessor::sInstance = 0;
-
-LCDDProcessor::LCDDProcessor() :
- m_header(0)
-{
-}
-
-LCDDProcessor::~LCDDProcessor()
-{
- if (m_header != 0) {
- delete m_header;
- }
-}
-
-LCDDProcessor* LCDDProcessor::instance()
-{
- if (sInstance == 0) {
- sInstance = new LCDDProcessor;
- }
-
- return sInstance;
-}
-
-void LCDDProcessor::addSensitiveDetector(std::string& name, G4SensitiveDetector* sd)
-{
- //std::cout << "adding SD: " << name << std::endl;
- m_sensitiveDetectors[name] = sd;
-}
-
-G4SensitiveDetector* LCDDProcessor::getSensitiveDetector(const std::string& name)
-{
- return m_sensitiveDetectors[name];
-}
-
-G4SensitiveDetector* LCDDProcessor::getSensitiveDetector(const char* name)
-{
- std::string key = name;
- return getSensitiveDetector(key);
-}
-
-LCDDProcessor::SensitiveDetectors::const_iterator LCDDProcessor::getSensitiveDetectorsBegin()
-{
- return m_sensitiveDetectors.begin();
-}
-
-LCDDProcessor::SensitiveDetectors::const_iterator LCDDProcessor::getSensitiveDetectorsEnd()
-{
- return m_sensitiveDetectors.end();
-}
-
-void LCDDProcessor::addMagneticField(std::string& name, G4MagneticField* mag)
-{
- m_magneticFields[name] = mag;
-}
-
-void LCDDProcessor::addGlobalField(G4MagneticField* mag)
-{
- LCDDFieldManager::instance()->addGlobalField(mag);
-}
-
-G4MagneticField* LCDDProcessor::getMagneticField(const std::string& name)
-{
- return m_magneticFields[name];
-}
-
-G4MagneticField* LCDDProcessor::getMagneticField(const char* name)
-{
- std::string key = name;
- return getMagneticField(key);
-}
-
-LCDDProcessor::MagneticFields::const_iterator LCDDProcessor::getMagneticFieldsBegin()
-{
- return m_magneticFields.begin();
-}
-
-LCDDProcessor::MagneticFields::const_iterator LCDDProcessor::getMagneticFieldsEnd()
-{
- return m_magneticFields.end();
-}
-
-void LCDDProcessor::addRegion(std::string& name, G4Region* reg)
-{
- m_regions[name] = reg;
-}
-
-G4Region* LCDDProcessor::getRegion(const std::string& name)
-{
- return m_regions[name];
-}
-
-G4Region* LCDDProcessor::getRegion(const char* name)
-{
- std::string key = name;
- return getRegion(name);
-}
-
-LCDDProcessor::Regions::const_iterator LCDDProcessor::getRegionsBegin()
-{
- return m_regions.begin();
-}
-
-LCDDProcessor::Regions::const_iterator LCDDProcessor::getRegionsEnd()
-{
- return m_regions.end();
-}
-
-void LCDDProcessor::addVisAttributes(std::string& name, G4VisAttributes* vis)
-{
- m_visAttributes[name] = vis;
-}
-
-G4VisAttributes* LCDDProcessor::getVisAttributes(const std::string& name)
-{
- return m_visAttributes[name];
-}
-
-G4VisAttributes* LCDDProcessor::getVisAttributes(const char* name)
-{
- std::string key = name;
- return getVisAttributes(key);
-}
-
-LCDDProcessor::VisAttributes::const_iterator LCDDProcessor::getVisAttributesBegin()
-{
- return m_visAttributes.begin();
-}
-
-LCDDProcessor::VisAttributes::const_iterator LCDDProcessor::getVisAttributesEnd()
-{
- return m_visAttributes.end();
-}
-
-void LCDDProcessor::addLimitSet(std::string& name, G4LimitSet* lim)
-{
- m_limitSets[name] = lim;
-}
-
-G4LimitSet* LCDDProcessor::getLimitSet(const std::string& name)
-{
- return m_limitSets[name];
-}
-
-G4LimitSet* LCDDProcessor::getLimitSet(const char* name)
-{
- std::string key = name;
- return getLimitSet(key);
-}
-
-LCDDProcessor::LimitSets::const_iterator LCDDProcessor::getLimitSetsBegin()
-{
- return m_limitSets.begin();
-}
-
-LCDDProcessor::LimitSets::const_iterator LCDDProcessor::getLimitSetsEnd()
-{
- return m_limitSets.end();
-}
-
-const LCDDHeaderRecord* LCDDProcessor::getHeader() const
-{
- return m_header;
-}
-
-void LCDDProcessor::setHeader(LCDDHeaderRecord* h)
-{
- assert(h);
- m_header = h;
-}
-
-std::string LCDDProcessor::getDetectorName() const
-{
- std::string detTag;
- if (m_header == 0) {
- detTag = "UNKNOWN";
- } else {
- detTag = m_header->getDetectorName();
- }
- return detTag;
-}
-
-const LCDDProcessor::VisAttributes* LCDDProcessor::getVisAttributesStore() const
-{
- return &m_visAttributes;
-}
-
-const LCDDProcessor::SensitiveDetectors* LCDDProcessor::getSensitiveDetectorStore() const
-{
- return &m_sensitiveDetectors;
-}
-
-const LCDDProcessor::MagneticFields* LCDDProcessor::getMagneticFieldStore() const
-{
- return &m_magneticFields;
-}
-
-const LCDDProcessor::Regions* LCDDProcessor::getRegionStore() const
-{
- return &m_regions;
-}
-
-const LCDDProcessor::LimitSets* LCDDProcessor::getLimitSetStore() const
-{
- return &m_limitSets;
-}
lcdd/src
diff -N MagneticFieldOverlay.cc
--- MagneticFieldOverlay.cc 26 Jun 2013 01:36:23 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,38 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/MagneticFieldOverlay.cc,v 1.6 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/bfield/MagneticFieldOverlay.hh"
-
-// STL
-#include <iostream>
-
-MagneticFieldOverlay::MagneticFieldOverlay()
-{
-}
-
-MagneticFieldOverlay::~MagneticFieldOverlay()
-{
-}
-
-void MagneticFieldOverlay::addMagneticField(G4MagneticField* field)
-{
- if (field != 0) {
- m_fields.push_back(field);
- }
-}
-
-/**
- * Call GetFieldValue of all G4MagneticField objects registered with this MagneticFieldOverlay.
- */
-void MagneticFieldOverlay::GetFieldValue(const double Point[3], double *Bfield) const
-{
- //std::cout << "MagneticFieldOverlay::GetFieldValue" << std::endl;
-
- Bfield[0] = Bfield[1] = Bfield[2] = 0.;
- for (std::vector<G4MagneticField*>::const_iterator iter = m_fields.begin(); iter != m_fields.end(); iter++) {
- (*iter)->GetFieldValue(Point, Bfield);
- }
-
- //std::cout << "x y z: " << Point[0] << " " << Point[1] << " " << Point[2] << std::endl;
- //std::cout << "bx, by, bz: " << Bfield[0] << " " << Bfield[1] << " " << Bfield[2] << std::endl << std::endl;
-}
lcdd/src
diff -N McpHitContrib.cc
--- McpHitContrib.cc 26 Jun 2013 01:36:23 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,64 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/McpHitContrib.cc,v 1.6 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/hits/McpHitContrib.hh"
-#include "lcdd/hits/TrackInformation.hh"
-
-// Geant4
-#include "G4Track.hh"
-#include "G4Step.hh"
-#include "G4ParticleDefinition.hh"
-#include "G4ParticleTypes.hh"
-
-McpHitContrib::McpHitContrib() :
- m_trackID(-1), m_edep(0), m_PdgId(9999999), m_globalTime(0)
-{
- ;
-}
-
-McpHitContrib::McpHitContrib(G4int trackID, G4double edep, G4int PDGID, G4double globalTime) :
- m_trackID(trackID), m_edep(edep), m_PdgId(PDGID), m_globalTime(globalTime)
-{
- ;
-}
-
-McpHitContrib::~McpHitContrib()
-{
- ;
-}
-
-McpHitContrib::McpHitContrib(const G4Step* aStep)
-{
- // Get the track.
- const G4Track* aTrack = aStep->GetTrack();
-
- // Get the track information.
- TrackInformation* trkInfo = static_cast<TrackInformation*>(aTrack->GetUserInformation());
-
- // Get the track ID.
- m_trackID = trkInfo->getOriginalTrackID();
-
- // Set edep according to type of track.
- if (aTrack->GetDefinition() == G4OpticalPhoton::OpticalPhotonDefinition()) {
- m_edep = aTrack->GetTotalEnergy();
- } else {
- m_edep = aStep->GetTotalEnergyDeposit();
- }
-
- // PDG ID.
- m_PdgId = aTrack->GetDefinition()->GetPDGEncoding();
-
- // Global time.
- m_globalTime = aTrack->GetGlobalTime();
-
- // Compute the step midpoint.
- G4ThreeVector posVec = (0.5 * (aStep->GetPreStepPoint()->GetPosition() + aStep->GetPostStepPoint()->GetPosition()));
- m_position[0] = posVec[0];
- m_position[1] = posVec[1];
- m_position[2] = posVec[2];
-}
-
-void McpHitContrib::printOut(std::ostream& os)
-{
- os << m_trackID << '\t' << m_edep << '\t' << m_PdgId << '\t' << m_globalTime << std::endl;
-}
lcdd/src
diff -N NistElementsDump.cc
--- NistElementsDump.cc 26 Jun 2013 01:36:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,130 +0,0 @@
-// $Id: NistElementsDump.cc,v 1.3 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/util/NistElementsDump.hh"
-#include "lcdd/util/StringUtil.hh"
-
-// GDML
-#include "Writer/Element.h"
-
-// Geant4
-#include "G4String.hh"
-#include "G4NistManager.hh"
-
-// STL
-#include <vector>
-#include <fstream>
-
-using gdml::writer::Element;
-
-using namespace std;
-
-#include "lcdd/util/ElementNames.icc"
-
-void NistElementsDump::writeXml(const std::string& filename)
-{
- ofstream fstr;
- fstr.open(filename.c_str(), fstream::out);
- printXml(fstr);
- fstr.close();
-}
-
-void NistElementsDump::printXml(std::ostream& out)
-{
- // Get the NIST manager from G4.
- G4NistManager* mgr = G4NistManager::Instance();
-
- // Create the XML root node.
- Element* materials = new Element("materials");
-
- // Loop over chemical elements array.
- for (int i = 0; i < nelements; i++) {
- // Get the element abbreviation and name.
- const std::string& elemAbbrev = abbrevs[i];
- const std::string& elemName = names[i];
-
- // Get element and material from G4.
- G4Element* elem = mgr->FindOrBuildElement(elemAbbrev);
- if (elem == 0) {
- std::cout << elemAbbrev << " not found." << std::endl;
- continue;
- }
- const std::string& g4mat = "G4_" + elemAbbrev;
- G4Material* mat = mgr->FindOrBuildMaterial(g4mat);
- if (mat == 0) {
- std::cout << g4mat << " not found." << std::endl;
- continue;
- }
-
- // Create new element.
- Element* elemNode = new Element("element");
- elemNode->addAttribute("name", elem->GetName());
- elemNode->addAttribute("formula", elem->GetSymbol());
- elemNode->addAttribute("Z", StringUtil::toString(elem->GetZ()));
-
- // Setup atom.
- Element* atomNode = new Element("atom");
- atomNode->addAttribute("type", "A");
- atomNode->addAttribute("unit", "g/mol");
- atomNode->addAttribute("value", StringUtil::toString((elem->GetA() * mole / g)));
-
- // Append atom node to element.
- elemNode->appendChild(*atomNode);
-
- // Append element node to top.
- materials->appendChild(*elemNode);
-
- // Create material node.
- Element* matNode = new Element("material");
- matNode->addAttribute("name", elemName);
- matNode->addAttribute("formula", elem->GetName());
-
- // Set material state.
- G4State g4state = mat->GetState();
- std::string state;
- if (g4state == kStateSolid) {
- state = "solid";
- } else if (g4state == kStateLiquid) {
- state = "liquid";
- } else if (g4state == kStateGas) {
- state = "gas";
- } else {
- state = "unknown";
- }
- matNode->addAttribute("state", state);
-
- // Add radlen node.
- Element* radlNode = new Element("RL");
- radlNode->addAttribute("unit", "cm");
- radlNode->addAttribute("type", "X0");
- radlNode->addAttribute("value", StringUtil::toString(mat->GetRadlen() / cm));
- matNode->appendChild(*radlNode);
-
- // Add nuclear interaction length node.
- Element* nilNode = new Element("NIL");
- nilNode->addAttribute("unit", "cm");
- nilNode->addAttribute("type", "lambda");
- nilNode->addAttribute("value", StringUtil::toString(mat->GetNuclearInterLength() / cm));
- matNode->appendChild((*nilNode));
-
- // Add density node.
- Element* densNode = new Element("D");
- densNode->addAttribute("type", "density");
- densNode->addAttribute("unit", "g/cm3");
- double matDens = mat->GetDensity() / (g / cm3);
- densNode->addAttribute("value", StringUtil::toString(matDens));
- matNode->appendChild(*densNode);
-
- // Add composition node.
- Element* compNode = new Element("composite");
- compNode->addAttribute("n", "1");
- compNode->addAttribute("ref", elem->GetName());
- matNode->appendChild(*compNode);
-
- // Add material node to root.
- materials->appendChild((*matNode));
- }
-
- // Write root node to output stream.
- materials->toXml(out, true, true);
-}
lcdd/src
diff -N ReadoutUtil.cc
--- ReadoutUtil.cc 26 Jun 2013 01:36:23 -0000 1.16
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,200 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/ReadoutUtil.cc,v 1.16 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/ReadoutUtil.hh"
-
-// Geant4
-#include "G4ParticleDefinition.hh"
-#include "G4Geantino.hh"
-#include "G4ChargedGeantino.hh"
-
-// STL
-#include <cmath>
-
-const double ReadoutUtil::PI = acos(-1);
-
-G4ThreeVector ReadoutUtil::computeThreeVectorMean(const G4ThreeVector& vec1, const G4ThreeVector& vec2)
-{
- return (0.5 * (vec1 + vec2));
-}
-
-G4double ReadoutUtil::computeDistance(const G4ThreeVector& vec1, const G4ThreeVector& vec2)
-{
- return (sqrt(pow(vec1.x() - vec2.x(), 2) + pow(vec1.y() - vec2.y(), 2) + pow(vec1.z() - vec2.z(), 2)));
-}
-
-G4double ReadoutUtil::computeDistance(const G4Step* aStep)
-{
- return computeDistance(aStep->GetPreStepPoint()->GetPosition(), aStep->GetPostStepPoint()->GetPosition());
-}
-
-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());
- tubs = static_cast<const G4Tubs*>(solid);
- return tubs;
-}
-const G4Tubs* ReadoutUtil::getTubs(const G4StepPoint* aPreStepPoint)
-{
- const G4Tubs* tubs = 0;
- G4VSolid* solid = ReadoutUtil::getSolidFromStepPoint(aPreStepPoint);
- tubs = static_cast<const G4Tubs*>(solid);
- 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::computeTubsMidRadius(const G4StepPoint* aPreStepPoint)
-{
- return computeTubsMidRadius(ReadoutUtil::getTubs(aPreStepPoint));
-}
-
-double ReadoutUtil::getTubsThickness(const G4Tubs* tubs)
-{
- return tubs->GetOuterRadius() - tubs->GetInnerRadius();
-}
-
-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::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)
-{
- // 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;
-}
-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)
-{
- std::vector<G4VPhysicalVolume*> physVols;
-
- // get touchable from PreStepPoint
- G4TouchableHandle theTouchable = aStep->GetPreStepPoint()->GetTouchableHandle();
-
- G4int hdepth = theTouchable->GetHistoryDepth();
-
- const G4NavigationHistory* theTouchableHistory = theTouchable->GetHistory();
-
- for (int i = hdepth; i > 0; i--) {
- G4VPhysicalVolume* pv = theTouchableHistory->GetVolume(i);
- physVols.push_back(pv);
-
-#ifdef ID_DEBUG
- G4cout << "pushed back <" << pv->GetName() << ">" << G4endl;
-#endif
- }
-
- return physVols;
-}
-
-int ReadoutUtil::getVolumeNumber(G4TouchableHandle theTouchable, int historyDepth)
-{
- bool no_depth = false;
-
- if (historyDepth == -1) {
- no_depth = true;
- }
-
- G4VPhysicalVolume *pv = 0;
-
- // pv only with depth arg
- if (!no_depth) {
- pv = theTouchable->GetHistory()->GetVolume(historyDepth);
- }
-
- int vnum = -1;
-
- // rep num: no pv, replicated, parameterised
- if (!pv || pv->IsReplicated() || pv->IsParameterised()) {
-
- // no depth
- if (no_depth) {
- vnum = theTouchable->GetReplicaNumber();
- }
- // use history depth
- else {
- vnum = theTouchable->GetReplicaNumber(historyDepth);
- }
- } else {
- // copy num: placement
- vnum = pv->GetCopyNo();
- }
-
- return vnum;
-}
-
-bool ReadoutUtil::isGeantino(G4Step* aStep)
-{
- G4ParticleDefinition* def = aStep->GetTrack()->GetDefinition();
- if (def == G4Geantino::Definition() || def == G4ChargedGeantino::Definition())
- return true;
- else
- return false;
-}
lcdd/src
diff -N SensitiveDetectorFactory.cc
--- SensitiveDetectorFactory.cc 26 Jun 2013 01:36:23 -0000 1.26
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,267 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/SensitiveDetectorFactory.cc,v 1.26 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/SensitiveDetectorFactory.hh"
-#include "lcdd/detectors/G4TrackerCombineSD.hh"
-#include "lcdd/detectors/G4ScorerSD.hh"
-#include "lcdd/detectors/G4TrackerSD.hh"
-#include "lcdd/detectors/G4OpticalCalorimeterSD.hh"
-#include "lcdd/detectors/G4UnsegmentedCalorimeterSD.hh"
-#include "lcdd/detectors/PositionComparator.hh"
-#include "lcdd/id/IdComparator.hh"
-#include "lcdd/util/StringUtil.hh"
-
-G4SensitiveDetector* SensitiveDetectorFactory::createSensitiveDetector(const SAXObject* object)
-{
- //std::cout << "create SD" << std::endl;
-
- G4SensitiveDetector* sd = 0;
-
- const SensitiveDetectorType* sdt = dynamic_cast<const SensitiveDetectorType*>(object);
-
- if (sdt) {
-
- std::string sd_type = sdt->get_type();
-
- /* Create calorimeter subdetector. */
- // TODO Check if "calorimeter" in the sd_type.
- if (sd_type == "calorimeter" || sd_type == "optical_calorimeter" || sd_type == "unsegmented_calorimeter") {
- //std::cout << "creating calorimeter" << std::endl;
- sd = createCalorimeterSD(object);
- }
- /* Create tracker subdetector. */
- else if (sd_type == "tracker") {
- sd = createTrackerSD(object);
- }
- /* Create scorer subdetector. */
- else if (sd_type == "scorer") {
- sd = createScorerSD(object);
- } else {
- /* Type not recognized. */
- G4cerr << "Invalid sd_type <" << sd_type << ">." << G4endl;
- G4Exception("", "", FatalException, "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("", "", FatalException, "Failed cast to SensitiveDetectorType.");
- }
-
- return sd;
-}
-
-G4CalorimeterSD* SensitiveDetectorFactory::createCalorimeterSD(const SAXObject* object)
-{
- G4CalorimeterSD* sd = 0;
- G4Segmentation* seg = 0;
-
- const SensitiveDetectorType* sdt = dynamic_cast<const SensitiveDetectorType*>(object);
-
- std::string sd_type = sdt->get_type();
-
- // 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;
- }
- }
-
- // Get the calorimeter XML object.
- const calorimeter* cal = dynamic_cast<const calorimeter*>(object);
-
- // Find out hit aggregation algorithm.
- 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") {
- G4cerr << "Invalid selection for hit comparison <" << hitCompareStr << ">, for calorimeter <" << sdt->get_name() << ">." << G4endl;
- G4Exception("", "", FatalException, "Invalid selection for hit comparison.");
- }
-
- // 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();
- }
-
- 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];
- // TODO Fix hardcoded collection names.
- 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 if (sd_type == "unsegmented_calorimeter") {
- // Segmentation could be null but that is fine for this type of calorimeter.
- sd = new G4UnsegmentedCalorimeterSD(sdt->get_name(), sdt->get_hitsCollectionName(), seg);
- } else {
- G4cerr << "Unknown sensitive detector type: " << sd_type << G4endl;
- G4Exception("SensitiveDetectorFactory", "", FatalException, "Unknown sensitive detector type.");
- }
-
- return sd;
-}
-
-G4TrackerSD* SensitiveDetectorFactory::createTrackerSD(const SAXObject* object)
-{
- const tracker* trk = dynamic_cast<const tracker*>(object);
-
- bool combineHits = StringUtil::toBool(trk->get_combine_hits());
-
- G4TrackerSD* sd = 0;
-
- std::string nm = trk->get_name();
- std::string hc = trk->get_hitsCollectionName();
-
- if (checkHCName(hc)) {
- G4Exception("SensitiveDetectorFactory", "", FatalException, "Name of the hits collection is invalid.");
- }
-
- /* tracker that aggregates hits */
- if (combineHits) {
- sd = new G4TrackerCombineSD(nm, hc);
- } else {
- /* regular tracker */
- sd = new G4TrackerSD(nm, hc);
- }
-
- return sd;
-}
-
-G4ScorerSD* SensitiveDetectorFactory::createScorerSD(const SAXObject* object)
-{
- const scorer * scr = dynamic_cast<const scorer*>(object);
-
- G4ScorerSD* sd = 0;
-
- std::string nm = scr->get_name();
- std::string hc = scr->get_hitsCollectionName();
-
- if (checkHCName(hc)) {
- G4Exception("SensitiveDetectorFactory", "", FatalException, "Name of the hits collections is invalid.");
- }
-
- 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) {
- G4cerr << "IdSpec <" << id_ref->get_ref() << "> referenced by detector <" << sdt->get_name() << "> does not exist." << G4endl;
- G4Exception("", "", FatalException, "IdSpec does not exist.");
- }
-
- break;
- }
- }
- 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()));
-}
-
-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;
-}
-
-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;
-}
-
-// NOTE: New segmentations must appear here!
-bool SensitiveDetectorFactory::isSegmentationTag(const std::string& s)
-{
- // @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" || s == "cell_readout_2d");
-}
-
-bool SensitiveDetectorFactory::checkHCName(const std::string& s)
-{
- 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;
- }
- }
- }
- return bad;
-}
lcdd/src
diff -N SensitiveDetectorMessenger.cc
--- SensitiveDetectorMessenger.cc 26 Jun 2013 01:36:23 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,109 +0,0 @@
-// $Id: SensitiveDetectorMessenger.cc,v 1.4 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/SensitiveDetectorMessenger.hh"
-
-// Geant4
-#include "G4UIcommand.hh"
-#include "G4UIcmdWithAnInteger.hh"
-#include "G4UIcmdWithABool.hh"
-#include "G4UIcmdWithADoubleAndUnit.hh"
-#include "G4UIdirectory.hh"
-#include "G4VSensitiveDetector.hh"
-
-G4UIdirectory* SensitiveDetectorMessenger::m_detectorsDir = 0;
-
-SensitiveDetectorMessenger::SensitiveDetectorMessenger(G4SensitiveDetector* detector) :
- m_detector(detector)
-{
- if (m_detectorsDir == 0) {
- makeDetectorsDir();
- }
-
- defineCommands(m_detector);
-}
-
-SensitiveDetectorMessenger::~SensitiveDetectorMessenger()
-{
- // TODO: put command deletes here
-}
-
-void SensitiveDetectorMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals)
-{
- if (cmd == m_printInfoCmd) {
- m_detector->printBasicInfo(std::cout);
- } else if (cmd == m_printNHitsCmd) {
- m_detector->printNumberOfHits(std::cout);
- } else if (cmd == m_printTotalEdepCmd) {
- m_detector->printEdep(std::cout);
- } else if (cmd == m_printVolumesCmd) {
- m_detector->printVolumes(std::cout);
- } else if (cmd == m_printHitsCmd) {
- m_detector->printHits(std::cout);
- } else if (cmd == m_verboseCmd) {
- m_detector->setVerbose(m_verboseCmd->GetNewIntValue(newVals));
- } else if (cmd == m_activateCmd) {
- m_detector->Activate(m_activateCmd->GetNewBoolValue(newVals));
- } else if (cmd == m_ecutCmd) {
- m_detector->setEcut(m_ecutCmd->GetNewDoubleValue(newVals));
- }
-
-}
-
-void SensitiveDetectorMessenger::makeDetectorsDir()
-{
- m_detectorsDir = new G4UIdirectory("/detectors/");
- m_detectorsDir->SetGuidance("Commands for sensitive detectors. [LCDD]");
-}
-
-void SensitiveDetectorMessenger::defineCommands(G4VSensitiveDetector* sd)
-{
- // Name of the sensitive detector.
- const G4String& name = sd->GetName();
-
- // Name of the sensitive detector's command directory.
- const G4String& dirName = G4String("/detectors/" + name + "/");
-
- // Create the sensitive detector's Geant4 macro command directory.
- m_detectorDir = new G4UIdirectory(dirName.c_str());
- m_detectorDir->SetGuidance(G4String("Commands for the sensitive detector " + name).c_str());
-
- // Print command.
- m_printInfoCmd = new G4UIcommand(G4String(dirName + "print").c_str(), this);
- m_printInfoCmd->SetGuidance(G4String("Print basic information about the sensitive detector " + name).c_str());
-
- // Print number of hits command.
- m_printNHitsCmd = new G4UIcommand(G4String(dirName + "printNumberOfHits").c_str(), this);
- m_printInfoCmd->SetGuidance(G4String("Print the number of hits from the detector " + name).c_str());
-
- // Print energy deposition.
- m_printTotalEdepCmd = new G4UIcommand(G4String(dirName + "printEdep").c_str(), this);
- m_printTotalEdepCmd->SetGuidance(G4String("Print the total energy deposition from the detector " + name).c_str());
-
- // Print energy deposition.
- m_printVolumesCmd = new G4UIcommand(G4String(dirName + "printVolumes").c_str(), this);
- m_printVolumesCmd->SetGuidance(G4String("Print a list of logical volume names associated with the detector " + name).c_str());
-
- // Print energy deposition.
- m_printHitsCmd = new G4UIcommand(G4String(dirName + "printHits").c_str(), this);
- m_printHitsCmd->SetGuidance(G4String("Print a list of hits from the detector " + name).c_str());
-
- // Set the verbosity.
- m_verboseCmd = new G4UIcmdWithAnInteger(G4String(dirName + "setVerbose").c_str(), this);
- m_verboseCmd->SetGuidance(G4String("Set the verbosity of the detector " + name).c_str());
- m_verboseCmd->SetDefaultValue(2);
- m_verboseCmd->SetParameterName("verbose", true, true);
-
- // Activate or deactive this detector.
- m_activateCmd = new G4UIcmdWithABool(G4String(dirName + "setActive").c_str(), this);
- m_activateCmd->SetGuidance(G4String("Set whether the detector " + name + " is active.").c_str());
- m_activateCmd->SetDefaultValue(true);
- m_activateCmd->SetParameterName("active", true, true);
-
- // Set the ecut with unit.
- m_ecutCmd = new G4UIcmdWithADoubleAndUnit(G4String(dirName + "setHitEnergyCut").c_str(), this);
- m_ecutCmd->SetGuidance(G4String("Set the single hit energy cut for detector " + name).c_str());
- m_ecutCmd->SetDefaultValue(0.0);
- m_ecutCmd->SetDefaultUnit("GeV");
- m_ecutCmd->SetParameterName("cut", true, true);
-}
lcdd/src
diff -N StepReadout.cc
--- StepReadout.cc 26 Jun 2013 01:36:23 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,213 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/StepReadout.cc,v 1.5 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/detectors/StepReadout.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-#include "lcdd/hits/TrackInformation.hh"
-
-// G4
-#include "G4Step.hh"
-#include "G4StepPoint.hh"
-#include "G4Track.hh"
-#include "G4VSolid.hh"
-#include "G4VPhysicalVolume.hh"
-#include "G4VSensitiveDetector.hh"
-#include "G4TouchableHandle.hh"
-#include "G4Region.hh"
-#include "G4Material.hh"
-#include "G4LogicalVolume.hh"
-
-StepReadout::StepReadout() :
- m_step(0)
-{
-}
-
-StepReadout::~StepReadout()
-{
-}
-
-void StepReadout::setStep(G4Step* s)
-{
- m_step = s;
-}
-
-G4Step* StepReadout::step() const
-{
- return m_step;
-}
-
-bool StepReadout::hasStep() const
-{
- return (0 != m_step);
-}
-
-G4StepPoint* StepReadout::pre() const
-{
- return step()->GetPreStepPoint();
-}
-
-G4StepPoint* StepReadout::post() const
-{
- return step()->GetPostStepPoint();
-}
-
-G4VPhysicalVolume* StepReadout::prePV() const
-{
- return preTouchableHandle()->GetVolume();
-}
-
-G4VPhysicalVolume* StepReadout::postPV() const
-{
- return postTouchableHandle()->GetVolume();
-}
-
-G4VSolid* StepReadout::preSolid() const
-{
- return preLV()->GetSolid();
-}
-
-G4VSolid* StepReadout::postSolid() const
-{
- return postLV()->GetSolid();
-}
-
-G4LogicalVolume* StepReadout::preLV() const
-{
- return prePV()->GetLogicalVolume();
-}
-
-G4LogicalVolume* StepReadout::postLV() const
-{
- return postPV()->GetLogicalVolume();
-}
-
-G4Material* StepReadout::preMaterial() const
-{
- return pre()->GetMaterial();
-}
-
-G4Material* StepReadout::postMaterial() const
-{
- return post()->GetMaterial();
-}
-
-G4VSensitiveDetector* StepReadout::preSD() const
-{
- return getSD(pre());
-}
-
-G4VSensitiveDetector* StepReadout::postSD() const
-{
- return getSD(post());
-}
-
-G4VSensitiveDetector* StepReadout::getSD(G4StepPoint* stepPoint) const
-{
- return stepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetSensitiveDetector();
-}
-
-bool StepReadout::hasSameSD() const
-{
- bool r = false;
-
- // post vol has an SD
- if (0 != postSD()) {
-
- // post SD same as pre SD
- if (preSD() == postSD()) {
- r = true;
- }
- }
-
- return r;
-}
-
-G4ThreeVector StepReadout::volumePosition(G4TouchableHandle theTouchable) const
-{
- return theTouchable->GetHistory()->GetTopTransform().Inverse().TransformPoint(m_origin);
-}
-
-G4ThreeVector StepReadout::preVolumePosition() const
-{
- return volumePosition(preTouchableHandle());
-}
-
-G4ThreeVector StepReadout::postVolumePosition() const
-{
- return volumePosition(postTouchableHandle());
-}
-
-double StepReadout::edep() const
-{
- return step()->GetTotalEnergyDeposit();
-}
-
-G4Track* StepReadout::track() const
-{
- return step()->GetTrack();
-}
-
-double StepReadout::globalTime() const
-{
- return track()->GetGlobalTime();
-}
-
-int StepReadout::trackID() const
-{
- return track()->GetTrackID();
-}
-
-G4ThreeVector StepReadout::momentum() const
-{
- return track()->GetMomentum();
-}
-
-TrackInformation* StepReadout::trackInformation() const
-{
- return TrackInformation::getTrackInformation(track());
-}
-
-G4ThreeVector StepReadout::prePosition() const
-{
- return pre()->GetPosition();
-}
-
-G4ThreeVector StepReadout::midPosition() const
-{
- return ReadoutUtil::computeThreeVectorMean(prePosition(), postPosition());
-}
-
-G4ThreeVector StepReadout::postPosition() const
-{
- return post()->GetPosition();
-}
-
-G4ThreeVector StepReadout::preMomentum() const
-{
- return pre()->GetMomentum();
-}
-
-G4ThreeVector StepReadout::postMomentum() const
-{
- return post()->GetMomentum();
-}
-
-G4ThreeVector StepReadout::meanMomentum() const
-{
- return ReadoutUtil::computeThreeVectorMean(preMomentum(), postMomentum());
-}
-
-G4TouchableHandle StepReadout::preTouchableHandle() const
-{
- return pre()->GetTouchableHandle();
-}
-
-G4TouchableHandle StepReadout::postTouchableHandle() const
-{
- return post()->GetTouchableHandle();
-}
-
-bool StepReadout::isGeantino()
-{
- return ReadoutUtil::isGeantino(step());
-}
lcdd/src
diff -N StringUtil.cc
--- StringUtil.cc 26 Jun 2013 01:36:23 -0000 1.12
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,145 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/StringUtil.cc,v 1.12 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/util/StringUtil.hh"
-
-// STL
-#include <cctype>
-#include <iostream>
-#include <algorithm>
-#include <sstream>
-#include <vector>
-
-const std::string StringUtil::ALPHA_STR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
-const std::string StringUtil::NUM_STR = "1234567890";
-const std::string StringUtil::WS_STR = "\x20\x09\x0A\x0B\x0C\x0D";
-const std::string StringUtil::NULL_STR = "";
-
-using std::string;
-using std::stringstream;
-using std::istringstream;
-using std::vector;
-
-string StringUtil::toString(double d)
-{
- stringstream ostr;
- ostr << d;
- return ostr.str();
-}
-
-string StringUtil::toString(float f)
-{
- stringstream ostr;
- ostr << f;
- return ostr.str();
-}
-
-string StringUtil::toString(bool b)
-{
- if (b) {
- return "1";
- }
-
- return "0";
-}
-
-string StringUtil::toString(int i)
-{
- stringstream ostr;
- ostr << i;
- return ostr.str();
-}
-
-string& StringUtil::toLower(string& s)
-{
- std::transform(s.begin(), s.end(), s.begin(), tolower);
- return s;
-}
-
-string& StringUtil::toLower(const string& s)
-{
- return StringUtil::toLower(const_cast<string&>(s));
-}
-
-double StringUtil::toDouble(string& s)
-{
- std::istringstream is(s.c_str());
- double d;
- is >> d;
- return d;
-}
-
-int StringUtil::toInt(string& s)
-{
- std::istringstream is(s.c_str());
- int i;
- is >> i;
- return i;
-}
-
-bool StringUtil::toBool(string& s)
-{
- if (StringUtil::toLower(s) == "true" || s == "1") {
- return true;
- } else {
- return false;
- }
-}
-
-bool StringUtil::toBool(const string& s)
-{
- return StringUtil::toBool(const_cast<string&>(s));
-}
-
-double StringUtil::toDouble(const string& s)
-{
- return StringUtil::toDouble(const_cast<string&>(s));
-}
-
-void StringUtil::trim(string& str)
-{
- string::size_type pos = str.find_last_not_of(' ');
- if (pos != string::npos) {
- str.erase(pos + 1);
- pos = str.find_first_not_of(' ');
- if (pos != string::npos)
- str.erase(0, pos);
- } else
- str.erase(str.begin(), str.end());
-}
-
-string StringUtil::concatStrVec(const vector<string>& s_vec, const string& sep)
-{
- string r;
-
- // concat w/ a space in between
- for (vector<string>::const_iterator iter = s_vec.begin(); iter != s_vec.end(); iter++) {
- r += (*iter) + string(sep);
- }
-
- // lop off dangling space
- r.erase(r.end() - 1, r.end());
-
- return r;
-}
-
-void StringUtil::split(const string& str, const string& delimiters, vector<string>& tokens)
-{
- // Skip delimiters at beginning.
- string::size_type lastPos = str.find_first_not_of(delimiters, 0);
-
- // Find first "non-delimiter".
- string::size_type pos = str.find_first_of(delimiters, lastPos);
-
- while (string::npos != pos || string::npos != lastPos) {
-
- // Found a token, add it to the vector.
- tokens.push_back(str.substr(lastPos, pos - lastPos));
-
- // Skip delimiters. Note the "not_of"
- lastPos = str.find_first_not_of(delimiters, pos);
-
- // Find next "non-delimiter"
- pos = str.find_first_of(delimiters, lastPos);
- }
-}
lcdd/src
diff -N TrackInformation.cc
--- TrackInformation.cc 26 Jun 2013 01:36:23 -0000 1.10
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,82 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/TrackInformation.cc,v 1.10 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/hits/TrackInformation.hh"
-
-G4Allocator<TrackInformation> TrackInformationAllocator;
-
-TrackInformation::TrackInformation()
-{
- setDefaults();
-}
-
-TrackInformation::TrackInformation(const G4Track* aTrack)
-{
- setDefaults();
-
- m_originalTrackID = aTrack->GetTrackID();
-}
-
-TrackInformation::TrackInformation(const TrackInformation* aTrackInfo)
-{
- assert(aTrackInfo);
-
- setFromTrackInformation(aTrackInfo, this);
-}
-
-TrackInformation::~TrackInformation()
-{
-}
-
-TrackInformation& TrackInformation::operator =(const TrackInformation& right)
-{
- setFromTrackInformation(&right, this);
- return *this;
-}
-
-void TrackInformation::setDefaults()
-{
- // default to invalid trackID
- m_originalTrackID = -1;
-
- // default to tracking region in both current and orig
- m_originalTrackingStatus = TrackInformation::eInTrackingRegion;
- m_trackingStatus = TrackInformation::eInTrackingRegion;
-
- // default flag vals
- m_hasTrackerHit = false;
- m_vertexIsNotEndpointOfParent = false;
- m_backscatter = false;
- m_belowThreshold = false;
-}
-
-void TrackInformation::setFromTrackInformation(const TrackInformation* srcTrkInfo, TrackInformation* trgtTrkInfo)
-{
- trgtTrkInfo->setTrackID(srcTrkInfo->m_originalTrackID);
-
- trgtTrkInfo->setOriginalTrackingStatus(srcTrkInfo->m_originalTrackingStatus);
- trgtTrkInfo->setTrackingStatus(srcTrkInfo->m_trackingStatus);
-
- trgtTrkInfo->setHasTrackerHit(false);
- trgtTrkInfo->setVertexIsNotEndpointOfParent(false);
- trgtTrkInfo->setBackscatter(srcTrkInfo->getBackscatter());
- trgtTrkInfo->setBelowThreshold(srcTrkInfo->getBelowThreshold());
-}
-
-const std::string& TrackInformation::getTrackingStatusString(ETrackingStatus ts)
-{
- static const std::string str_none = "None";
- static const std::string str_tracking = "InTrackingRegion";
- static const std::string str_nontracking = "InNontrackingRegion";
- static const std::string str_invalid = "Invalid";
-
- if (ts == eNone) {
- return str_none;
- } else if (ts == eInTrackingRegion) {
- return str_tracking;
- } else if (ts == eInNontrackingRegion) {
- return str_nontracking;
- }
-
- return str_invalid;
-}
lcdd/src
diff -N Verbose.cc
--- Verbose.cc 26 Jun 2013 01:36:23 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,6 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/Verbose.cc,v 1.2 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/util/Verbose.hh"
-
-const Verbose::LevelType Verbose::m_defaultLevel = 0;
lcdd/src
diff -N authorProcess.cc
--- authorProcess.cc 26 Jun 2013 01:36:23 -0000 1.8
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,77 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/authorProcess.cc,v 1.8 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/author.hh"
-
-// GDML
-#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"
-
-// STL
-#include <iostream>
-
-/**
- * @brief SAX process for author element.
- */
-class authorProcess: public SAXStateProcess
-{
-
-public:
-
- authorProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~authorProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- //std::cout << "authorProcess::StartElement" << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- author* a = new author;
-
- a->set_name(attrs.getValue("name"));
- a->set_email(attrs.getValue("email"));
-
- m_obj = a;
- *obj = a;
- }
-
- 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 = "author";
- return tag;
- }
-
-private:
- SAXObject* m_obj;
-};
-
-DECLARE_PROCESS_FACTORY(authorProcess)
lcdd/src
diff -N box_dipoleProcess.cc
--- box_dipoleProcess.cc 26 Jun 2013 01:36:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,74 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/box_dipoleProcess.cc,v 1.3 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#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"
-
-// LCDD
-#include "lcdd/schema/box_dipole.hh"
-#include "lcdd/schema/FieldTypeProcess.hh"
-
-// STL
-#include <iostream>
-
-class box_dipoleProcess: public FieldTypeProcess
-{
-public:
-
- box_dipoleProcess(const ProcessingContext* context = 0) :
- FieldTypeProcess(context)
- {
- }
-
- virtual ~box_dipoleProcess()
- {
- }
-
- void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
- {
- SAXObject** obj = Context()->GetTopObject();
-
- box_dipole* x = new box_dipole;
-
- x->set_x(attrs.getValue("x"));
- x->set_y(attrs.getValue("y"));
- x->set_z(attrs.getValue("z"));
- x->set_dx(attrs.getValue("dx"));
- x->set_dy(attrs.getValue("dy"));
- x->set_dz(attrs.getValue("dz"));
- x->set_bx(attrs.getValue("bx"));
- x->set_by(attrs.getValue("by"));
- x->set_bz(attrs.getValue("bz"));
-
- m_obj = x;
- *obj = x;
-
- FieldTypeProcess::StartElement(name, attrs);
- }
-
- void EndElement(const std::string&)
- {
- }
-
- void Characters(const std::string&)
- {
- }
-
- void StackPopNotify(const std::string&)
- {
- }
-
- const std::string& State() const
- {
- static std::string tag = "box_dipole";
- return tag;
- }
-};
-
-DECLARE_PROCESS_FACTORY(box_dipoleProcess)
-
lcdd/src
diff -N box_dipoleSubscriber.cc
--- box_dipoleSubscriber.cc 26 Jun 2013 01:36:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,92 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/box_dipoleSubscriber.cc,v 1.3 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/bfield/G4BoxDipole.hh"
-#include "lcdd/schema/box_dipole.hh"
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentFactory.h"
-#include "G4Processor/GDMLProcessor.h"
-#include "G4Evaluator/GDMLExpressionEvaluator.h"
-
-class box_dipoleSubscriber: virtual public SAXSubscriber
-{
-
-public:
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
-
- box_dipoleSubscriber()
- {
- Subscribe("box_dipole");
- }
-
- virtual ~box_dipoleSubscriber()
- {
- }
-
- virtual void Activate(const SAXObject* object)
- {
- GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
-
- if (object != 0) {
- const box_dipole* dipoleElement = dynamic_cast<const box_dipole*>(object);
-
- double x, y, z, dx, dy, dz, bx, by, bz;
- x = y = z = dx = dy = dz = bx = by = bz = 0;
-
- std::string lunit = dipoleElement->get_lunit();
- std::string funit = dipoleElement->get_funit();
-
- std::string val = dipoleElement->get_x();
- val += "*" + lunit;
- x = calc->Eval(val);
-
- val = dipoleElement->get_y();
- val += "*" + lunit;
- y = calc->Eval(val);
-
- val = dipoleElement->get_z();
- val += "*" + lunit;
- z = calc->Eval(val);
-
- val = dipoleElement->get_dx();
- val += "*" + lunit;
- dx = calc->Eval(val);
-
- val = dipoleElement->get_dy();
- val += "*" + lunit;
- dy = calc->Eval(val);
-
- val = dipoleElement->get_dz();
- val += "*" + lunit;
- dz = calc->Eval(val);
-
- val = dipoleElement->get_bx();
- val += "*" + funit;
- bx = calc->Eval(val);
-
- val = dipoleElement->get_by();
- val += "*" + funit;
- by = calc->Eval(val);
-
- val = dipoleElement->get_bz();
- val += "*" + funit;
- bz = calc->Eval(val);
-
- G4BoxDipole* boxDipole = new G4BoxDipole(x, y, z, dx, dy, dz, bx, by, bz);
-
- std::string fieldName = dipoleElement->get_name();
- LCDDProcessor::instance()->addMagneticField(fieldName, boxDipole);
- }
- }
-};
-
-DECLARE_SUBSCRIBER_FACTORY(box_dipoleSubscriber)
lcdd/src
diff -N calorimeterProcess.cc
--- calorimeterProcess.cc 26 Jun 2013 01:36:23 -0000 1.9
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,48 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/calorimeterProcess.cc,v 1.9 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/calorimeterProcess.hh"
-
-calorimeterProcess::calorimeterProcess(const ProcessingContext* context) :
- SensitiveDetectorTypeProcess(context)
-{
-}
-
-calorimeterProcess::~calorimeterProcess()
-{
-}
-
-void calorimeterProcess::StartElement(const std::string& name, const ASCIIAttributeList& attrs)
-{
- SAXObject** obj = Context()->GetTopObject();
- calorimeter* cal = new calorimeter;
-
- cal->set_compare(attrs.getValue("hit_aggregation"));
-
- m_obj = cal;
- *obj = cal;
-
- // parent type to set name and hitsCollectionName
- SensitiveDetectorTypeProcess::StartElement(name, attrs);
-}
-
-void calorimeterProcess::EndElement(const std::string&)
-{
-}
-
-void calorimeterProcess::Characters(const std::string&)
-{
-}
-
-void calorimeterProcess::StackPopNotify(const std::string& name)
-{
- SensitiveDetectorTypeProcess::StackPopNotify(name);
-}
-
-const std::string& calorimeterProcess::State() const
-{
- static std::string tag = "calorimeter";
- return tag;
-}
-
-DECLARE_PROCESS_FACTORY(calorimeterProcess)
lcdd/src
diff -N calorimeterSubscriber.cc
--- calorimeterSubscriber.cc 26 Jun 2013 01:36:23 -0000 1.17
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,51 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/calorimeterSubscriber.cc,v 1.17 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentFactory.h"
-#include "G4Processor/GDMLProcessor.h"
-
-// LCDD
-#include "lcdd/schema/calorimeter.hh"
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/detectors/G4CalorimeterSD.hh"
-#include "lcdd/detectors/G4SegmentationFactory.hh"
-#include "lcdd/detectors/SensitiveDetectorFactory.hh"
-#include "lcdd/id/IdManager.hh"
-#include "lcdd/id/IdSpec.hh"
-
-// STL
-#include <iostream>
-#include <sstream>
-
-/**
- @class calorimeterSubscriber
- @brief SAX subscriber for calorimeter element.
- @note Delegates to SensitiveDetectorFactory to create G4CalorimeterSD object.
- */
-class calorimeterSubscriber: virtual public SAXSubscriber
-{
-public:
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
- calorimeterSubscriber()
- {
- Subscribe("calorimeter");
- }
-
- virtual ~calorimeterSubscriber()
- {
- }
-
- virtual void Activate(const SAXObject* object)
- {
- // use factory to create this SD
- SensitiveDetectorFactory::createSensitiveDetector(object);
- }
-};
-
-DECLARE_SUBSCRIBER_FACTORY(calorimeterSubscriber)
lcdd/src
diff -N cell_readout_2dProcess.cc
--- cell_readout_2dProcess.cc 26 Jun 2013 01:36:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,77 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/cell_readout_2dProcess.cc,v 1.3 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#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"
-
-// LCDD
-#include "lcdd/schema/cell_readout_2d.hh"
-
-// STL
-#include <iostream>
-
-class cell_readout_2dProcess: public SAXStateProcess
-{
-
-public:
-
- cell_readout_2dProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~cell_readout_2dProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
- {
- std::cout << "cell_readout_2dProcess::StartElement: " << name << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- cell_readout_2d* np = new cell_readout_2d;
-
- np->setLengthUnit(attrs.getValue("lunit"));
-
- np->setCellSizeX(attrs.getValue("cell_size_x"));
- np->setCellSizeY(attrs.getValue("cell_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 = "cell_readout_2d";
- return tag;
- }
-
-private:
-
- SAXObject* m_obj;
-};
-
-DECLARE_PROCESS_FACTORY(cell_readout_2dProcess)
lcdd/src
diff -N colorProcess.cc
--- colorProcess.cc 26 Jun 2013 01:36:23 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,80 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/colorProcess.cc,v 1.6 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/color.hh"
-
-// GDML
-#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"
-
-// STL
-#include <iostream>
-
-/**
- @class colorProcess
- @brief SAX process for color element.
- */
-class colorProcess: public SAXStateProcess
-{
-public:
-
- colorProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~colorProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- //std::cout << "color::StartElement()" << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- color* c = new color;
-
- c->set_R(attrs.getValue("R"));
- c->set_G(attrs.getValue("G"));
- c->set_B(attrs.getValue("B"));
- c->set_alpha(attrs.getValue("alpha"));
-
- m_obj = c;
- *obj = c;
- }
-
- 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 = "color";
- return tag;
- }
-
-private:
-
- SAXObject* m_obj;
-};
-
-DECLARE_PROCESS_FACTORY(colorProcess)
lcdd/src
diff -N commentProcess.cc
--- commentProcess.cc 26 Jun 2013 01:36:23 -0000 1.7
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,75 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/commentProcess.cc,v 1.7 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#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"
-
-// LCDD
-#include "lcdd/schema/comment.hh"
-
-// STL
-#include <iostream>
-
-/**
- @class commentProcess
- @brief SAX process for comment element.
- */
-class commentProcess: public SAXStateProcess
-{
-public:
- commentProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
- virtual ~commentProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList&)
- {
- //std::cout << "commentProcess::StartElement" << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- comment* c = new comment;
-
- m_obj = c;
- *obj = c;
- }
-
- virtual void EndElement(const std::string&)
- {
- }
-
- virtual void Characters(const std::string& cdata)
- {
- //std::cout << "commentProcess::Characters() - <" << cdata << ">" << std::endl;
- comment* c = dynamic_cast<comment*>(m_obj);
- c->set_comment(cdata);
- }
-
- virtual void StackPopNotify(const std::string&)
- {
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "comment";
- return tag;
- }
-
-private:
- SAXObject* m_obj;
-};
-
-DECLARE_PROCESS_FACTORY(commentProcess)
lcdd/src
diff -N detectorProcess.cc
--- detectorProcess.cc 26 Jun 2013 01:36:23 -0000 1.7
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,74 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/detectorProcess.cc,v 1.7 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/detector.hh"
-
-// GDML
-#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"
-
-// STL
-#include <iostream>
-
-/**
- * @brief SAX process for detector element.
- */
-class detectorProcess: public SAXStateProcess
-{
-public:
- detectorProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~detectorProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- SAXObject** obj = Context()->GetTopObject();
-
- detector* d = new detector;
-
- d->set_name(attrs.getValue("name"));
- d->set_version(attrs.getValue("version"));
- d->set_url(attrs.getValue("url"));
-
- m_obj = d;
- *obj = d;
- }
-
- 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 = "detector";
- return tag;
- }
-
-private:
- SAXObject* m_obj;
-};
-
-DECLARE_PROCESS_FACTORY(detectorProcess)
lcdd/src
diff -N dipoleProcess.cc
--- dipoleProcess.cc 26 Jun 2013 01:36:23 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,77 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/dipoleProcess.cc,v 1.5 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/dipole.hh"
-
-// GDML
-#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"
-
-/**
- * @brief SAX process for the dipole element.
- */
-class dipoleProcess: public SAXStateProcess
-{
-public:
-
- dipoleProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~dipoleProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- SAXObject** obj = Context()->GetTopObject();
-
- dipole* d = new dipole;
- d->set_name(attrs.getValue("name"));
- d->set_lunit(attrs.getValue("lunit"));
- d->set_funit(attrs.getValue("funit"));
- d->set_zmax(attrs.getValue("zmax"));
- d->set_zmin(attrs.getValue("zmin"));
- d->set_rmax(attrs.getValue("rmax"));
-
- m_obj = d;
- *obj = d;
- }
-
- virtual void EndElement(const std::string&)
- {
- }
-
- virtual void Characters(const std::string&)
- {
- }
-
- virtual void StackPopNotify(const std::string& name)
- {
- SAXObject** so = Context()->GetTopObject();
- dipole* d = dynamic_cast<dipole*>(m_obj);
- d->add_content(name, *so);
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "dipole";
- return tag;
- }
-
-private:
- SAXObject* m_obj;
-};
-
-DECLARE_PROCESS_FACTORY(dipoleProcess)
lcdd/src
diff -N dipoleSubscriber.cc
--- dipoleSubscriber.cc 26 Jun 2013 01:36:23 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,103 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/dipoleSubscriber.cc,v 1.6 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentFactory.h"
-#include "G4Processor/GDMLProcessor.h"
-#include "G4Evaluator/GDMLExpressionEvaluator.h"
-
-// LCDD
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/schema/dipole.hh"
-#include "lcdd/schema/dipole_coeff.hh"
-#include "lcdd/bfield/G4Dipole.hh"
-
-/**
- * @brief Creates G4Dipole runtime objects in Geant4 from dipole elements.
- */
-class dipoleSubscriber: virtual public SAXSubscriber
-{
-
-public:
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
- dipoleSubscriber()
- {
- Subscribe("dipole");
- }
-
- virtual ~dipoleSubscriber()
- {
- }
-
- virtual void Activate(const SAXObject* object)
- {
- GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
-
- if (object) {
- const dipole* d = dynamic_cast<const dipole*>(object);
-
- if (d) {
- double zmin, zmax, rmax;
-
- std::string lunit = d->get_lunit();
- std::string funit = d->get_funit();
-
- // Evaluate zmin with lunit.
- std::string sval = d->get_zmin();
- sval += "*" + lunit;
- zmin = calc->Eval(sval);
-
- // Evaluate zmax with lunit.
- sval = d->get_zmax();
- sval += "*" + lunit;
- zmax = calc->Eval(sval);
-
- // Evaluate rmax with lunit.
- sval = d->get_rmax();
- sval += "*" + lunit;
- rmax = calc->Eval(sval);
-
- // Create the Geant4 dipole object.
- G4Dipole* g4d = new G4Dipole();
-
- // Set the field unit's value.
- g4d->setFieldUnit(calc->Eval(funit));
-
- // Set the length unit's value.
- g4d->setLengthUnit(calc->Eval(lunit));
-
- // Set zmin and zmax.
- g4d->setZMax(zmax);
- g4d->setZMin(zmin);
- g4d->setRMax(rmax);
-
- // Add the dipole coefficients.
- ContentSequence* seq = const_cast<ContentSequence*>(d->get_content());
- size_t count = seq->size();
- for (size_t i = 0; i < count; i++) {
- const ContentGroup::ContentItem& elem = seq->content(i);
- if (elem.tag == "dipole_coeff") {
- dipole_coeff* coeff = dynamic_cast<dipole_coeff*>(elem.object);
- g4d->addCoeff(calc->Eval(coeff->get_value()));
- } else {
- std::cerr << "dipoleSubscriber :: Activate - The child element " << elem.tag << " is not a dipole_coeff!" << std::endl;
- }
- }
-
- // Add the G4Dipole to the magnetic field store.
- std::string field_name = d->get_name();
- LCDDProcessor::instance()->addMagneticField(field_name, g4d);
- } else {
- std::cerr << "dipoleSubscriber :: Activate - Failed cast to dipole!" << std::endl;
- }
- }
- }
- ;
-};
-
-DECLARE_SUBSCRIBER_FACTORY(dipoleSubscriber)
lcdd/src
diff -N dipole_coeffProcess.cc
--- dipole_coeffProcess.cc 26 Jun 2013 01:36:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,74 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/dipole_coeffProcess.cc,v 1.3 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#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"
-
-// LCDD
-#include "lcdd/schema/dipole_coeff.hh"
-
-// STL
-#include <iostream>
-
-/**
- * @class dipole_coeffProcess
- * @brief SAX process to create the dipole_coeff element.
- */
-class dipole_coeffProcess: public SAXStateProcess
-{
-public:
-
- dipole_coeffProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~dipole_coeffProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- SAXObject** obj = Context()->GetTopObject();
-
- dipole_coeff* dpc = new dipole_coeff;
-
- dpc->set_value(attrs.getValue("value"));
-
- m_obj = dpc;
- *obj = dpc;
- }
- 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 = "dipole_coeff";
- return tag;
- }
-
-private:
-
- SAXObject* m_obj;
-};
-
-DECLARE_PROCESS_FACTORY(dipole_coeffProcess)
lcdd/src
diff -N field_map_3dProcess.cc
--- field_map_3dProcess.cc 26 Jun 2013 01:36:23 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,68 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/field_map_3dProcess.cc,v 1.5 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/FieldMapTypeProcess.hh"
-#include "lcdd/schema/field_map_3d.hh"
-
-// STL
-#include <iostream>
-
-// Geant4
-#include "globals.hh"
-
-/**
- * @brief
- */
-class field_map_3dProcess: public FieldMapTypeProcess
-{
-
-public:
-
- field_map_3dProcess(const ProcessingContext* context = 0) :
- FieldMapTypeProcess(context)
- {
- }
-
- virtual ~field_map_3dProcess()
- {
- }
-
- virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
- {
-
- SAXObject** obj = Context()->GetTopObject();
-
- field_map_3d* fmap = new field_map_3d;
-
- fmap->set_filename(attrs.getValue("filename"));
-
- // Top-level caller needs to setup the SAXObject references.
- m_obj = fmap;
- *obj = fmap;
-
- // Call next process UP in inheritance chain, after the SAXObject is set.
- FieldMapTypeProcess::StartElement(name, attrs);
- }
-
- virtual void EndElement(const std::string&)
- {
- }
-
- virtual void Characters(const std::string&)
- {
- }
-
- virtual void StackPopNotify(const std::string& name)
- {
- //std::cout << "field_map_3d::StackPopNotify" << std::endl;
- FieldMapTypeProcess::StackPopNotify(name);
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "field_map_3d";
- return tag;
- }
-};
-
-DECLARE_PROCESS_FACTORY(field_map_3dProcess)
lcdd/src
diff -N field_map_3dSubscriber.cc
--- field_map_3dSubscriber.cc 26 Jun 2013 01:36:23 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,69 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/field_map_3dSubscriber.cc,v 1.4 2013/06/26 01:36:23 jeremy Exp $
-
-// lcdd
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/schema/field_map_3d.hh"
-#include "lcdd/bfield/Cartesian3DMagneticFieldMap.hh"
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentObject.h"
-#include "Saxana/SAXComponentFactory.h"
-
-// Geant4
-#include "G4Processor/GDMLProcessor.h"
-
-/*
- * @class
- * @brief
- */
-class field_map_3dSubscriber: virtual public SAXSubscriber
-{
-
-public:
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
-
- field_map_3dSubscriber()
- {
- Subscribe("field_map_3d");
- }
-
- virtual ~field_map_3dSubscriber()
- {
- }
-
- virtual void Activate(const SAXObject* object)
- {
-
- //std::cout << "field_map_3d::Subscriber" << std::endl;
-
- const field_map_3d* obj = dynamic_cast<const field_map_3d*>(object);
-
- if (object != 0) {
-
- if (obj) {
-
- if (obj) {
-
- //GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
- //std::string lunit = obj->get_lunit();
- //std::string funit = obj->get_funit();
-
- std::string name = obj->get_name();
- std::string field_name = obj->get_filename();
-
- Cartesian3DMagneticFieldMap* fmap = new Cartesian3DMagneticFieldMap(field_name.c_str(), 0, 0, 0);
- LCDDProcessor::instance()->addMagneticField(name, fmap);
- }
- }
- }
- }
-};
-
-DECLARE_SUBSCRIBER_FACTORY(field_map_3dSubscriber)
lcdd/src
diff -N fieldrefProcess.cc
--- fieldrefProcess.cc 26 Jun 2013 01:36:23 -0000 1.7
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,48 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/fieldrefProcess.cc,v 1.7 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#include "Processes/ReferenceTypeProcess.h"
-
-// LCDD
-#include "lcdd/schema/FieldType.hh"
-
-/**
- * @brief SAX process for fieldref element.
- */
-class fieldrefProcess: public ReferenceTypeProcess
-{
-public:
- fieldrefProcess(const ProcessingContext* context = 0) :
- ReferenceTypeProcess(context)
- {
- }
-
- virtual ~fieldrefProcess()
- {
- }
-
- virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
- {
- SAXObject** obj = Context()->GetTopObject();
-
- FieldType::fieldref* fref = new FieldType::fieldref;
-
- *obj = fref;
- m_obj = fref;
-
- ReferenceTypeProcess::StartElement(name, attrs);
- }
-
- virtual void EndElement(const std::string& name)
- {
- ReferenceTypeProcess::EndElement(name);
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "fieldref";
- return tag;
- }
-};
-
-DECLARE_PROCESS_FACTORY(fieldrefProcess)
lcdd/src
diff -N generatorProcess.cc
--- generatorProcess.cc 26 Jun 2013 01:36:23 -0000 1.8
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,75 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/generatorProcess.cc,v 1.8 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/generator.hh"
-
-// GDML
-#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"
-
-// STL
-#include <iostream>
-
-/**
- * @brief SAX process for generator element.
- */
-class generatorProcess: public SAXStateProcess
-{
-public:
- generatorProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~generatorProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- SAXObject** obj = Context()->GetTopObject();
-
- generator* g = new generator;
-
- g->set_name(attrs.getValue("name"));
- g->set_version(attrs.getValue("version"));
- g->set_file(attrs.getValue("file"));
- g->set_checksum(attrs.getValue("checksum"));
-
- m_obj = g;
- *obj = g;
- }
-
- 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 = "generator";
- return tag;
- }
-
-private:
- SAXObject* m_obj;
-};
-
-DECLARE_PROCESS_FACTORY(generatorProcess)
lcdd/src
diff -N global_fieldProcess.cc
--- global_fieldProcess.cc 26 Jun 2013 01:36:23 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,76 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/global_fieldProcess.cc,v 1.5 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#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"
-
-// LCDD
-#include "lcdd/schema/global_field.hh"
-#include "lcdd/schema/SensitiveDetectorTypeProcess.hh"
-
-// STL
-#include <iostream>
-
-/**
- * @brief SAX process for global_field element.
- */
-class global_fieldProcess: public SAXStateProcess
-{
-public:
- global_fieldProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~global_fieldProcess()
- {
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList&)
- {
- //std::cout << "global_fieldProcess::StartElement: " << name << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- global_field* cal = new global_field;
-
- m_obj = cal;
- *obj = cal;
- }
-
- virtual void EndElement(const std::string&)
- {
- //std::cout << "global_fieldProcess::EndElement: " << name << " " << std::endl;
- }
-
- virtual void Characters(const std::string&)
- {
- }
-
- virtual void StackPopNotify(const std::string& name)
- {
- //std::cout << "global_fieldProcess::StackPopNotify: " << name << std::endl;
-
- SAXObject** so = Context()->GetTopObject();
- global_field* fobj = dynamic_cast<global_field*>(m_obj);
-
- fobj->add_content(name, *so);
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "global_field";
- return tag;
- }
-
-protected:
- SAXObject* m_obj;
-
-};
-
-DECLARE_PROCESS_FACTORY(global_fieldProcess)
lcdd/src
diff -N global_fieldSubscriber.cc
--- global_fieldSubscriber.cc 26 Jun 2013 01:36:23 -0000 1.12
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,75 +0,0 @@
-// $Id: global_fieldSubscriber.cc,v 1.12 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/schema/global_field.hh"
-#include "lcdd/schema/FieldType.hh"
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentFactory.h"
-#include "G4Processor/GDMLProcessor.h"
-
-// Geant4
-#include "G4MagneticField.hh"
-
-// STL
-#include <iostream>
-
-/**
- * @brief SAX subscriber for global_field element.
- * @note Resolves fieldref and sets global field in LCDDProcessor.
- */
-class global_fieldSubscriber: virtual public SAXSubscriber
-{
-public:
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
- global_fieldSubscriber()
- {
- Subscribe("global_field");
- }
-
- virtual ~global_fieldSubscriber()
- {
- }
-
- virtual void Activate(const SAXObject* object)
- {
- const global_field* fobj = 0;
- G4MagneticField* mag = 0;
- LCDDProcessor* proc = LCDDProcessor::instance();
-
- if (object != 0) {
- fobj = dynamic_cast<const global_field*>(object);
-
- if (fobj) {
- const ContentSequence* seq = fobj->get_content();
-
- size_t count = seq->size();
-
- for (size_t i = 0; i < count; i++) {
- if (seq->content(i).tag == "fieldref") {
- FieldType::fieldref* fref = dynamic_cast<FieldType::fieldref*>(seq->content(i).object);
-
- mag = proc->getMagneticField(fref->get_ref());
-
- if (mag != 0) {
- LCDDProcessor::instance()->addGlobalField(mag);
- }
- }
- }
-
- } else {
- std::cerr << "Failed cast to global_field!" << std::endl;
- }
- }
- }
-};
-
-DECLARE_SUBSCRIBER_FACTORY(global_fieldSubscriber)
-
lcdd/src
diff -N global_grid_xyProcess.cc
--- global_grid_xyProcess.cc 26 Jun 2013 01:36:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,82 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/global_grid_xyProcess.cc,v 1.3 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#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"
-
-// LCDD
-#include "lcdd/schema/global_grid_xy.hh"
-
-// STL
-#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 -N grid_xyzProcess.cc
--- grid_xyzProcess.cc 26 Jun 2013 01:36:23 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,83 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/grid_xyzProcess.cc,v 1.4 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/grid_xyz.hh"
-
-// GDML
-#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"
-
-// STL
-#include <iostream>
-
-/**
- * @brief SAX process for grid_xyz element.
- */
-class grid_xyzProcess: public SAXStateProcess
-{
-
-public:
-
- grid_xyzProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~grid_xyzProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- //std::cout << "grid_xyzProcess::StartElement: " << name << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- grid_xyz* np = new grid_xyz;
-
- np->set_lunit(attrs.getValue("lunit"));
-
- np->set_gridSizeX(attrs.getValue("grid_size_x"));
- np->set_gridSizeY(attrs.getValue("grid_size_y"));
- np->set_gridSizeZ(attrs.getValue("grid_size_z"));
-
- m_obj = np;
- *obj = np;
- }
-
- virtual void EndElement(const std::string&)
- {
- //std::cout << "PROCESS::END OF TAG : " << name << " " << std::endl;
- }
-
- virtual void Characters(const std::string&)
- {
- }
-
- virtual void StackPopNotify(const std::string&)
- {
- //std::cout << "PROCESS::NOTIFIED AFTER THE TAG: " << name << std::endl;
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "grid_xyz";
- return tag;
- }
-
-private:
-
- SAXObject* m_obj;
-};
-
-DECLARE_PROCESS_FACTORY(grid_xyzProcess)
lcdd/src
diff -N headerProcess.cc
--- headerProcess.cc 26 Jun 2013 01:36:23 -0000 1.7
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,79 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/headerProcess.cc,v 1.7 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/header.hh"
-
-// GDML
-#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"
-
-// STL
-#include <iostream>
-
-/**
- * @brief SAX process for header element.
- */
-class headerProcess: public SAXStateProcess
-{
-public:
- headerProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~headerProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList&)
- {
- //std::cout << "headerProcess::StartElement" << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- header* h = new header;
-
- m_obj = h;
- *obj = h;
- }
-
- virtual void EndElement(const std::string&)
- {
- }
-
- virtual void Characters(const std::string&)
- {
- }
-
- virtual void StackPopNotify(const std::string& name)
- {
- //std::cout << "headerProcess::StackPopNotify" << std::endl;
-
- SAXObject** so = Context()->GetTopObject();
- header* h = dynamic_cast<header*>(m_obj);
-
- h->add_content(name, *so);
-
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "header";
- return tag;
- }
-
-private:
- SAXObject* m_obj;
-};
-
-DECLARE_PROCESS_FACTORY(headerProcess)
lcdd/src
diff -N headerSubscriber.cc
--- headerSubscriber.cc 26 Jun 2013 01:36:23 -0000 1.11
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,100 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/headerSubscriber.cc,v 1.11 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentFactory.h"
-#include "G4Processor/GDMLProcessor.h"
-
-// LCDD
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/geant4/LCDDHeaderRecord.hh"
-#include "lcdd/schema/header.hh"
-#include "lcdd/schema/detector.hh"
-#include "lcdd/schema/generator.hh"
-#include "lcdd/schema/comment.hh"
-#include "lcdd/schema/author.hh"
-
-// std
-#include <iostream>
-
-/**
- @class headerSubscriber
- @brief SAX subscriber for header element.
- @note Creates the LCDDHeaderRecord and sets in LCDDProcessor.
- */
-class headerSubscriber: virtual public SAXSubscriber
-{
-public:
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
- headerSubscriber()
- {
- Subscribe("header");
- }
-
- virtual ~headerSubscriber()
- {
- }
-
- virtual void Activate(const SAXObject* object)
- {
- LCDDProcessor* proc = LCDDProcessor::instance();
- const header* obj = dynamic_cast<const header*>(object);
- LCDDHeaderRecord* hdr = new LCDDHeaderRecord();
-
- // handle child element content
- ContentSequence* seq = const_cast<ContentSequence*>(obj->get_content());
- size_t count = seq->size();
- for (size_t i = 0; i < count; i++) {
-
- const ContentGroup::ContentItem& citem = seq->content(i);
- const std::string& tag = citem.tag;
- SAXObject* cobj = citem.object;
-
- if (tag == "detector") {
-
- const detector* d = dynamic_cast<detector*>(cobj);
-
- hdr->setDetectorName(d->get_name());
- hdr->setDetectorVersion(d->get_version());
- hdr->setDetectorUrl(d->get_url());
- } else if (tag == "generator") {
-
- const generator* g = dynamic_cast<generator*>(cobj);
-
- hdr->setGeneratorName(g->get_name());
- hdr->setGeneratorVersion(g->get_version());
- hdr->setGeneratorFile(g->get_file());
- hdr->setGeneratorChecksum(g->get_checksum());
- } else if (tag == "author") {
-
- const author* a = dynamic_cast<author*>(cobj);
-
- hdr->setAuthorName(a->get_name());
- hdr->setAuthorEmail(a->get_email());
-
- } else if (tag == "comment") {
-
- const comment* c = dynamic_cast<comment*>(cobj);
- hdr->setComment(c->get_comment());
- } else {
- std::cerr << "Unknown content for header element." << std::endl;
- }
- }
-
- // set header in LCDDProc
- proc->setHeader(hdr);
-
- // print header
- hdr->printOut(std::cout);
-
- //delete object;
- }
-
-};
-
-DECLARE_SUBSCRIBER_FACTORY(headerSubscriber)
lcdd/src
diff -N idspecProcess.cc
--- idspecProcess.cc 26 Jun 2013 01:36:23 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,80 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/idspecProcess.cc,v 1.4 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/idspecElem.hh"
-
-// GDML
-#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"
-
-// STL
-#include <iostream>
-
-/**
- * @brief SAX process for idspec element.
- */
-class idspecProcess: public SAXStateProcess
-{
-public:
-
- idspecProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~idspecProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- //std::cout << "idspecProcess::StartElement() - " << name << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- idspecElem* idspec = new idspecElem;
-
- idspec->set_name(attrs.getValue("name"));
- idspec->set_length(attrs.getValue("length"));
-
- m_obj = idspec;
- *obj = idspec;
- }
- virtual void EndElement(const std::string&)
- {
- }
-
- virtual void Characters(const std::string&)
- {
- }
-
- virtual void StackPopNotify(const std::string& name)
- {
- SAXObject** so = Context()->GetTopObject();
- idspecElem* idspec = dynamic_cast<idspecElem*>(m_obj);
- idspec->add_content(name, *so);
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "idspec";
- return tag;
- }
-
-private:
-
- SAXObject* m_obj;
-};
-
-DECLARE_PROCESS_FACTORY(idspecProcess)
-
lcdd/src
diff -N idspecSubscriber.cc
--- idspecSubscriber.cc 26 Jun 2013 01:36:23 -0000 1.10
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,120 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/idspecSubscriber.cc,v 1.10 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentFactory.h"
-#include "G4Processor/GDMLProcessor.h"
-
-// LCDD
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/id/IdSpec.hh"
-#include "lcdd/schema/idspecElem.hh"
-#include "lcdd/schema/idfieldElem.hh"
-#include "lcdd/id/IdManager.hh"
-#include "lcdd/util/StringUtil.hh"
-
-/**
- @class idspecSubscriber
- @brief SAX subscriber for idspec element.
- @note Creates an IdSpec object and registers with IdManager.
- @note Also creates IdField objects from idfield child elements.
- */
-class idspecSubscriber: virtual public SAXSubscriber
-{
-public:
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
- idspecSubscriber()
- {
- Subscribe("idspec");
- }
-
- virtual ~idspecSubscriber()
- {
- }
-
- virtual void Activate(const SAXObject* object)
- {
- //std::cout << "idspecSubscriber::Activate()" << std::endl;
-
- if (object) {
- const idspecElem* idspec_elem = dynamic_cast<const idspecElem*>(object);
-
- if (idspec_elem) {
-
- std::string name = idspec_elem->get_name();
-
- std::string length = idspec_elem->get_length();
- IdSpec::SizeType length_s = (IdSpec::SizeType) StringUtil::toInt(length);
-
- // @todo support lengths over 64
- if (length_s > 64) {
- std::cerr << "Number of bits cannot be greater than 64 at this time." << std::endl;
- assert(0);
- }
-
- IdSpec* idspec = new IdSpec;
- idspec->setName(name);
- idspec->setBitLength(length_s);
-
- IdManager::instance()->addIdSpec(name, idspec);
-
- // create fields
- ContentSequence* seq = const_cast<ContentSequence*>(idspec_elem->get_content());
- size_t count = seq->size();
-
- for (size_t i = 0; i < count; i++) {
- const ContentGroup::ContentItem& segitem = seq->content(i);
- if (segitem.tag == "idfield") {
- idfieldElem* idfield_elem = dynamic_cast<idfieldElem*>(segitem.object);
-
- if (idfield_elem) {
-
- IdField* idfield = new IdField;
-
- // label
- std::string label = idfield_elem->get_label();
-
- // start
- std::string start = idfield_elem->get_start();
- IdField::SizeType start_s = (IdField::SizeType) StringUtil::toInt(start);
-
- // signed
- std::string signed_str = idfield_elem->get_signed();
- bool signed_bool = StringUtil::toBool(signed_str);
-
- // length
- std::string length = idfield_elem->get_length();
- IdField::SizeType length_s = (IdField::SizeType) StringUtil::toInt(length);
-
- // set in G4 object
- idfield->setLabel(label);
- idfield->setSigned(signed_bool);
- idfield->setStart(start_s);
- idfield->setLength(length_s);
-
- // add to spec
- idspec->addIdField(idfield);
- } else {
- G4Exception("", "", FatalException, "Failed cast to idfieldElem.");
- }
- } else {
- std::cerr << "Ignoring unknown child - " << segitem.tag << std::endl;
- }
- }
- } else {
- G4Exception("", "", FatalException, "Failed cast to idspecElem.");
- }
- } else {
- G4Exception("", "", FatalException, "SAXObject is null!");
- }
-
- //delete object;
- }
-};
-
-DECLARE_SUBSCRIBER_FACTORY(idspecSubscriber)
lcdd/src
diff -N idspecrefProcess.cc
--- idspecrefProcess.cc 26 Jun 2013 01:36:23 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,51 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/idspecrefProcess.cc,v 1.5 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#include "Processes/ReferenceTypeProcess.h"
-
-// LCDD
-#include "lcdd/schema/IdSpecType.hh"
-
-// STL
-#include <iostream>
-
-/**
- * @brief SAX process for idspecref element.
- * @note Extends ReferenceTypeProcess for reference to idspec element.
- */
-class idspecrefProcess: public ReferenceTypeProcess
-{
-public:
- idspecrefProcess(const ProcessingContext* context = 0) :
- ReferenceTypeProcess(context)
- {
- }
-
- virtual ~idspecrefProcess()
- {
- }
-
- virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
- {
- SAXObject** obj = Context()->GetTopObject();
- IdSpecType::idspecref* s = new IdSpecType::idspecref;
-
- *obj = s;
- m_obj = s;
-
- ReferenceTypeProcess::StartElement(name, attrs);
- }
-
- virtual void EndElement(const std::string& name)
- {
- ReferenceTypeProcess::EndElement(name);
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "idspecref";
- return tag;
- }
-};
-
-DECLARE_PROCESS_FACTORY(idspecrefProcess)
lcdd/src
diff -N limitProcess.cc
--- limitProcess.cc 26 Jun 2013 01:36:23 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,77 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/limitProcess.cc,v 1.6 2013/06/26 01:36:23 jeremy Exp $
-
-
-// GDML
-#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"
-
-// LCDD
-#include "lcdd/schema/limit.hh"
-
-/**
- *
- */
-
-class limitProcess: public SAXStateProcess
-{
-
-public:
- limitProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~limitProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- SAXObject** obj = Context()->GetTopObject();
-
- limit* lim = new limit;
-
- lim->set_name(attrs.getValue("name"));
- lim->set_value(attrs.getValue("value"));
- lim->set_particles(attrs.getValue("particles"));
- lim->set_unit(attrs.getValue("unit"));
-
- m_obj = lim;
- *obj = lim;
- }
-
- virtual void EndElement(const std::string&)
- {
- }
-
- virtual void StackPopNotify(const std::string&)
- {
- }
-
- virtual void Characters(const std::string&)
- {
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "limit";
- return tag;
- }
-
-private:
-
- SAXObject* m_obj;
-
-};
-
-DECLARE_PROCESS_FACTORY(limitProcess)
lcdd/src
diff -N limitrefProcess.cc
--- limitrefProcess.cc 26 Jun 2013 01:36:23 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,50 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/limitrefProcess.cc,v 1.5 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#include "Processes/ReferenceTypeProcess.h"
-
-// LCDD
-#include "lcdd/schema/LimitType.hh"
-
-/**
- * @brief SAX process for limitref element.
- */
-class limitrefProcess: public ReferenceTypeProcess
-{
-public:
- limitrefProcess(const ProcessingContext* context = 0) :
- ReferenceTypeProcess(context)
- {
- }
-
- virtual ~limitrefProcess()
- {
- }
-
- virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
- {
- //std::cout << "limitrefProcess" << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- LimitType::limitref* lref = new LimitType::limitref;
-
- *obj = lref;
- m_obj = lref;
-
- ReferenceTypeProcess::StartElement(name, attrs);
- }
-
- virtual void EndElement(const std::string& name)
- {
- ReferenceTypeProcess::EndElement(name);
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "limitref";
- return tag;
- }
-};
-
-//DECLARE_PROCESS_FACTORY(limitrefProcess);
lcdd/src
diff -N limitsetProcess.cc
--- limitsetProcess.cc 26 Jun 2013 01:36:23 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,83 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/limitsetProcess.cc,v 1.5 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/limitset.hh"
-#include "lcdd/schema/limit.hh"
-
-// GDML
-#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"
-
-// Geant4
-#include "globals.hh"
-
-class limitsetProcess: public SAXStateProcess
-{
-public:
- limitsetProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~limitsetProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- SAXObject** obj = Context()->GetTopObject();
-
- limitset* lim = new limitset;
- lim->set_name(attrs.getValue("name"));
-
- m_obj = lim;
- *obj = lim;
- }
-
- virtual void EndElement(const std::string&)
- {
- }
-
- virtual void Characters(const std::string&)
- {
- }
-
- virtual void StackPopNotify(const std::string& name)
- {
- if (name == "limit") {
- SAXObject** so = Context()->GetTopObject();
- limitset* lim = dynamic_cast<limitset*>(m_obj);
-
- if (lim != 0) {
- lim->add_content(name, *so);
- } else {
- G4Exception("limitsetProcess::StackPopNotify()", "", FatalException, "Failed cast to limitset.");
- }
- } else {
- std::cerr << "limitsetProcess::StackPopNotify() - Got limitset content that wasn't limit." << std::endl;
- }
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "limitset";
- return tag;
- }
-
-private:
-
- SAXObject* m_obj;
-
-};
-
-DECLARE_PROCESS_FACTORY(limitsetProcess)
lcdd/src
diff -N limitsetSubscriber.cc
--- limitsetSubscriber.cc 26 Jun 2013 01:36:23 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,100 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/limitsetSubscriber.cc,v 1.6 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentFactory.h"
-#include "G4Processor/GDMLProcessor.h"
-
-// LCDD
-#include "lcdd/schema/limit.hh"
-#include "lcdd/schema/limitset.hh"
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/geant4/G4LimitSet.hh"
-#include "lcdd/util/StringUtil.hh"
-
-#include <string>
-#include <iostream>
-
-using std::string;
-using std::vector;
-
-/**
- */
-class limitsetSubscriber: virtual public SAXSubscriber
-{
-public:
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
-
- limitsetSubscriber()
- {
- Subscribe("limitset");
- }
-
- virtual void Activate(const SAXObject* object)
- {
- //std::cout << "limitsetSubscriber::Activate()" << std::endl;
- if (object != 0) {
-
- GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
- const limitset* lsobj = dynamic_cast<const limitset*>(object);
-
- if (lsobj != 0) {
- //std::cout << "got limitset: " << lsobj->get_name() << std::endl;
-
- G4LimitSet* ls = new G4LimitSet(lsobj->get_name());
-
- const ContentSequence* seq = lsobj->get_content();
- size_t count = seq->size();
- for (size_t i = 0; i < count; i++) {
- if (seq->content(i).tag == "limit") {
- limit* param = dynamic_cast<limit*>(seq->content(i).object);
-
- if (param != 0) {
- //std::cout << "got limit: " << param->get_name() << std::endl;
-
- string unit = param->get_unit();
- string particles = param->get_particles();
- string limitName = param->get_name();
-
- string sval = param->get_value();
- sval += "*" + unit;
- double value = calc->Eval(sval);
-
- /* Process the comma-delimited list of particles. */
- vector<string> particleList;
- StringUtil::split(particles, ",", particleList);
-
- /* No specific particles so make an entry for all particles. */
- if (particleList.end() == particleList.begin()) {
- //std::cout << "adding limit with name, particle, value: <" << limitName << "> <" << G4LimitSet::ANY_PARTICLE << "> <" << value << ">" << std::endl;
- ls->setLimitForParticle(limitName, G4LimitSet::ANY_PARTICLE, value);
- }
- /* Insert the limit once for each particle. */
- else {
- for (vector<string>::iterator iter = particleList.begin(); iter != particleList.end(); iter++) {
- string particle = (*iter);
- StringUtil::trim(particle);
- //std::cout << "adding limit with name, particle, value: <" << limitName << "> <" << particle << "> <" << value << ">" << std::endl;
- ls->setLimitForParticle(limitName, particle, value);
- }
- }
- } else {
- G4Exception("", "", FatalException, "Failed cast to limit.");
- }
- }
- }
-
- LCDDProcessor::instance()->addLimitSet(ls->getName(), ls);
- } else {
- G4Exception("", "", FatalException, "Failed cast to limitset.");
- }
- }
- }
-};
-
-DECLARE_SUBSCRIBER_FACTORY(limitsetSubscriber)
lcdd/src
diff -N limitsetrefProcess.cc
--- limitsetrefProcess.cc 26 Jun 2013 01:36:23 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,50 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/limitsetrefProcess.cc,v 1.4 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#include "Processes/ReferenceTypeProcess.h"
-
-// LCDD
-#include "lcdd/schema/LimitSetType.hh"
-
-/**
- * @brief SAX process for limitsetref element.
- */
-class limitsetrefProcess: public ReferenceTypeProcess
-{
-public:
- limitsetrefProcess(const ProcessingContext* context = 0) :
- ReferenceTypeProcess(context)
- {
- }
-
- virtual ~limitsetrefProcess()
- {
- }
-
- virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
- {
- //std::cout << "limitsetrefProcess" << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- LimitSetType::limitsetref* lref = new LimitSetType::limitsetref;
-
- *obj = lref;
- m_obj = lref;
-
- ReferenceTypeProcess::StartElement(name, attrs);
- }
-
- virtual void EndElement(const std::string& name)
- {
- ReferenceTypeProcess::EndElement(name);
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "limitsetref";
- return tag;
- }
-};
-
-DECLARE_PROCESS_FACTORY(limitsetrefProcess)
lcdd/src
diff -N nonprojective_cylinderProcess.cc
--- nonprojective_cylinderProcess.cc 26 Jun 2013 01:36:23 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,80 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/nonprojective_cylinderProcess.cc,v 1.4 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#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"
-
-// LCDD
-#include "lcdd/schema/nonprojective_cylinder.hh"
-
-// STL
-#include <iostream>
-
-/**
- @class nonprojective_cylinderProcess
- @brief SAX process for nonprojective_cylinder element.
- */
-class nonprojective_cylinderProcess: public SAXStateProcess
-{
-
-public:
-
- nonprojective_cylinderProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~nonprojective_cylinderProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- //std::cout << "nonprojective_cylinderProcess::StartElement: " << name << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- nonprojective_cylinder* np = new nonprojective_cylinder;
-
- np->set_gridSizeZ(attrs.getValue("grid_size_z"));
- np->set_gridSizePhi(attrs.getValue("grid_size_phi"));
- np->set_lunit(attrs.getValue("lunit"));
-
- 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 = "nonprojective_cylinder";
- return tag;
- }
-
-private:
-
- SAXObject* m_obj;
-};
-
-DECLARE_PROCESS_FACTORY(nonprojective_cylinderProcess)
lcdd/src
diff -N optical_calorimeterProcess.cc
--- optical_calorimeterProcess.cc 26 Jun 2013 01:36:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,43 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/optical_calorimeterProcess.cc,v 1.3 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#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"
-
-// LCDD
-#include "lcdd/schema/optical_calorimeter.hh"
-#include "lcdd/schema/calorimeterProcess.hh"
-
-// STL
-#include <iostream>
-
-/**
- @class optical_calorimeterProcess
- @brief SAX process for optical_calorimeter element.
- @note Calls SAX processor for SensitiveDetectorTypeProcess parent class.
- */
-class optical_calorimeterProcess: public calorimeterProcess
-{
-public:
- optical_calorimeterProcess(const ProcessingContext* context = 0) :
- calorimeterProcess(context)
- {
- }
-
- virtual ~optical_calorimeterProcess()
- {
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "optical_calorimeter";
- return tag;
- }
-};
-
-DECLARE_PROCESS_FACTORY(optical_calorimeterProcess)
lcdd/src
diff -N optical_calorimeterSubscriber.cc
--- optical_calorimeterSubscriber.cc 26 Jun 2013 01:36:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,49 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/optical_calorimeterSubscriber.cc,v 1.3 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentFactory.h"
-#include "G4Processor/GDMLProcessor.h"
-
-// LCDD
-#include "lcdd/schema/calorimeter.hh"
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/detectors/G4CalorimeterSD.hh"
-#include "lcdd/detectors/G4SegmentationFactory.hh"
-#include "lcdd/detectors/SensitiveDetectorFactory.hh"
-#include "lcdd/id/IdManager.hh"
-#include "lcdd/id/IdSpec.hh"
-
-// STL
-#include <iostream>
-#include <sstream>
-
-/**
- * @brief SAX subscriber for calorimeter element.
- * @note Delegates to SensitiveDetectorFactory for creation of G4CalorimeterSD objects.
- */
-class optical_calorimeterSubscriber: virtual public SAXSubscriber
-{
-public:
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
- optical_calorimeterSubscriber()
- {
- Subscribe("optical_calorimeter");
- }
-
- virtual ~optical_calorimeterSubscriber()
- {
- }
-
- virtual void Activate(const SAXObject* object)
- {
- SensitiveDetectorFactory::createSensitiveDetector(object);
- }
-};
-
-DECLARE_SUBSCRIBER_FACTORY(optical_calorimeterSubscriber)
lcdd/src
diff -N physvolidProcess.cc
--- physvolidProcess.cc 26 Jun 2013 01:36:23 -0000 1.9
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,69 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/physvolidProcess.cc,v 1.9 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/physvolidElem.hh"
-
-// GDML
-#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"
-
-// STL
-#include <iostream>
-
-/**
- * @brief SAX process for physvolid element.
- */
-class physvolidProcess: public SAXStateProcess
-{
-public:
- physvolidProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~physvolidProcess()
- {
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- SAXObject** obj = Context()->GetTopObject();
-
- physvolidElem* pvid = new physvolidElem;
-
- pvid->set_value(attrs.getValue("value"));
- pvid->set_field_name(attrs.getValue("field_name"));
-
- m_obj = pvid;
- *obj = pvid;
- }
-
- 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 = "physvolid";
- return tag;
- }
-
-private:
-
- SAXObject* m_obj;
-};
-
-DECLARE_PROCESS_FACTORY(physvolidProcess)
lcdd/src
diff -N projective_cylinderProcess.cc
--- projective_cylinderProcess.cc 26 Jun 2013 01:36:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,79 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/projective_cylinderProcess.cc,v 1.3 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/projective_cylinder.hh"
-
-// GDML
-#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"
-
-// STL
-#include <iostream>
-
-/**
- * @brief SAX process for projective_cylinder element.
- */
-class projective_cylinderProcess: public SAXStateProcess
-{
-
-public:
-
- projective_cylinderProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~projective_cylinderProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- //std::cout << "projective_cylinderProcess::StartElement: " << name << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- projective_cylinder* prj = new projective_cylinder;
-
- prj->set_ntheta(attrs.getValue("ntheta"));
- prj->set_nphi(attrs.getValue("nphi"));
-
- m_obj = prj;
- *obj = prj;
- }
-
- 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 = "projective_cylinder";
- return tag;
- }
-
-private:
-
- SAXObject* m_obj;
-};
-
-DECLARE_PROCESS_FACTORY(projective_cylinderProcess)
-
lcdd/src
diff -N projective_zplaneProcess.cc
--- projective_zplaneProcess.cc 26 Jun 2013 01:36:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,80 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/projective_zplaneProcess.cc,v 1.3 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#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"
-
-// LCDD
-#include "lcdd/schema/projective_zplane.hh"
-
-// STL
-#include <iostream>
-
-/**
- @class projective_zplaneProcess
- @brief SAX process for projective_zplane element.
- */
-class projective_zplaneProcess: public SAXStateProcess
-{
-
-public:
-
- projective_zplaneProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~projective_zplaneProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- //std::cout << "projective_zplaneProcess::StartElement: " << name << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- projective_zplane* prj = new projective_zplane;
-
- prj->set_ntheta(attrs.getValue("ntheta"));
- prj->set_nphi(attrs.getValue("nphi"));
-
- m_obj = prj;
- *obj = prj;
- }
-
- 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 = "projective_zplane";
- return tag;
- }
-
-private:
-
- SAXObject* m_obj;
-};
-
-DECLARE_PROCESS_FACTORY(projective_zplaneProcess)
-
lcdd/src
diff -N regionProcess.cc
--- regionProcess.cc 26 Jun 2013 01:36:23 -0000 1.10
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,84 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/regionProcess.cc,v 1.10 2013/06/26 01:36:23 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/region.hh"
-
-// GDML
-#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"
-
-// STL
-#include <iostream>
-
-/**
- * @brief SAX process for region element.
- */
-class regionProcess: public SAXStateProcess
-{
-
-public:
-
- regionProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~regionProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- SAXObject** obj = Context()->GetTopObject();
-
- region* reg = new region;
-
- reg->set_name(attrs.getValue("name"));
- reg->set_storeSecondaries(attrs.getValue("store_secondaries"));
- reg->set_killTracks(attrs.getValue("kill_tracks"));
- reg->set_cut(attrs.getValue("cut"));
- reg->set_lunit(attrs.getValue("lunit"));
- reg->set_threshold(attrs.getValue("threshold"));
- reg->set_eunit(attrs.getValue("eunit"));
-
- m_obj = reg;
- *obj = reg;
- }
-
- virtual void EndElement(const std::string&)
- {
- }
-
- virtual void Characters(const std::string&)
- {
- }
-
- virtual void StackPopNotify(const std::string& name)
- {
- SAXObject** so = Context()->GetTopObject();
- region* r = dynamic_cast<region*>(m_obj);
- r->add_content(name, *so);
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "region";
- return tag;
- }
-
-private:
-
- SAXObject* m_obj;
-};
-
-DECLARE_PROCESS_FACTORY(regionProcess)
lcdd/src
diff -N regionSubscriber.cc
--- regionSubscriber.cc 26 Jun 2013 01:36:23 -0000 1.19
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,130 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/regionSubscriber.cc,v 1.19 2013/06/26 01:36:23 jeremy Exp $
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentFactory.h"
-#include "G4Processor/GDMLProcessor.h"
-
-// LCDD
-#include "lcdd/schema/region.hh"
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/geant4/G4UserRegionInformation.hh"
-#include "lcdd/schema/LimitSetType.hh"
-#include "lcdd/util/StringUtil.hh"
-
-// Geant4
-#include "G4Region.hh"
-#include "G4ProductionCuts.hh"
-
-// std
-#include <iostream>
-#include <sstream>
-
-/**
- @class regionSubscriber
- @brief SAX subscriber for region element.
- @note Creates a G4Region with user information and registers with LCDDProcessor.
- */
-class regionSubscriber: virtual public SAXSubscriber
-{
-public:
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
- regionSubscriber()
- {
- Subscribe("region");
- }
-
- virtual void Activate(const SAXObject* object)
- {
- if (object != 0) {
-
- LCDDProcessor* proc = LCDDProcessor::instance();
-
- const region* robj = dynamic_cast<const region*>(object);
-
- GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
- G4Region* reg = 0;
- if (robj) {
- std::string name = robj->get_name();
- reg = new G4Region(name);
-
- // compute prod cut
- std::string lunit = robj->get_lunit();
- std::string sval = robj->get_cut();
- sval += "*" + lunit;
- double cut = calc->Eval(sval);
-
- std::string eunit = robj->get_eunit();
- sval = robj->get_threshold();
- sval += "*" + eunit;
- double threshold = calc->Eval(sval);
-
- // set production cut
- std::string store_seco = robj->get_storeSecondaries();
- G4ProductionCuts* prod_cuts = new G4ProductionCuts();
- prod_cuts->SetProductionCut(cut);
- reg->SetProductionCuts(prod_cuts);
-
- // create region info with storeSecondaries flag
- G4UserRegionInformation* reg_info = new G4UserRegionInformation();
-
- // set storeSeco
- reg_info->setStoreSecondaries(StringUtil::toBool(store_seco));
-
- std::string killTracks = robj->get_killTracks();
- //std::cout << "regionSubscriber.killTracks: " << killTracks << std::endl;
- reg_info->setKillTracks(StringUtil::toBool(killTracks));
- //std::cout << "regInfo.killTracsk: " << reg_info << std::endl;
-
- // set threshold
- reg_info->setThreshold(threshold);
-
- // set info in region
- reg->SetUserInformation(reg_info);
-
- // get content
- const ContentSequence* seq = robj->get_content();
-
- // get size of content
- size_t count = seq->size();
-
- // iterate over and process content
- for (size_t i = 0; i < count; i++) {
-
- if (seq->content(i).tag == "limitsetref") {
-
- LimitSetType::limitsetref* limitsetref = dynamic_cast<LimitSetType::limitsetref*>(seq->content(i).object);
-
- G4UserLimits* ulim = dynamic_cast<G4LimitSet*>(proc->getLimitSet(limitsetref->get_ref()));
-
- if (ulim) {
-#ifdef HAVE_G4REGION_SETUSERLIMITS
- reg->SetUserLimits( ulim );
- std::cout << "Set user limits <" << limitsetref->get_ref() << "> on region <" << name << ">" << std::endl;
-#else
- std::cerr << "WARNING: Ignoring limitsetref on region. The method G4Region::SetUserLimits is not supported by your Geant4 version." << std::endl;
-#endif
- } else {
- std::cerr << "FATAL ERROR: limit element not found - " << limitsetref->get_ref() << std::endl;
- G4Exception("", "", FatalException, "limitsetref not found.");
- }
- } else {
- std::cerr << "Bad content to region tag: " << seq->content(i).tag << std::endl;
- }
- }
-
- // register with processor
- LCDDProcessor::instance()->addRegion(name, reg);
- } else {
- std::cerr << "Failed cast to region!" << std::endl;
- }
- }
- }
-};
-
-DECLARE_SUBSCRIBER_FACTORY(regionSubscriber)
lcdd/src
diff -N regionrefProcess.cc
--- regionrefProcess.cc 26 Jun 2013 01:36:24 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,49 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/regionrefProcess.cc,v 1.6 2013/06/26 01:36:24 jeremy Exp $
-
-// GDML
-#include "Processes/ReferenceTypeProcess.h"
-
-// LCDD
-#include "lcdd/schema/RegionType.hh"
-
-/**
- * @brief SAX process for regionref element.
- * @note Extends ReferenceTypeProcess for reference to region element.
- */
-class regionrefProcess: public ReferenceTypeProcess
-{
-public:
- regionrefProcess(const ProcessingContext* context = 0) :
- ReferenceTypeProcess(context)
- {
- }
-
- virtual ~regionrefProcess()
- {
- }
-
- virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
- {
- SAXObject** obj = Context()->GetTopObject();
-
- RegionType::regionref* regref = new RegionType::regionref;
-
- *obj = regref;
- m_obj = regref;
-
- ReferenceTypeProcess::StartElement(name, attrs);
- }
-
- virtual void EndElement(const std::string& name)
- {
- ReferenceTypeProcess::EndElement(name);
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "regionref";
- return tag;
- }
-};
-
-DECLARE_PROCESS_FACTORY(regionrefProcess)
lcdd/src
diff -N rz_field_mapProcess.cc
--- rz_field_mapProcess.cc 26 Jun 2013 01:36:24 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,77 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/rz_field_mapProcess.cc,v 1.6 2013/06/26 01:36:24 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/FieldMapTypeProcess.hh"
-#include "lcdd/schema/rz_field_map.hh"
-
-// Geant4
-#include "globals.hh"
-
-// STL
-#include <iostream>
-
-/**
- * @brief Processor for rz_field_map elements.
- */
-class rz_field_mapProcess: public FieldMapTypeProcess
-{
-public:
- rz_field_mapProcess(const ProcessingContext* context = 0) :
- FieldMapTypeProcess(context)
- {
- }
-
- virtual ~rz_field_mapProcess()
- {
- }
-
- virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
- {
- // std::cout << "rz_field_mapProcess::StartElement - " << name << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- rz_field_map* rzmap = new rz_field_map;
-
- /* set attributes */
- rzmap->set_num_bins_r(attrs.getValue("num_bins_r"));
- rzmap->set_grid_size_r(attrs.getValue("grid_size_r"));
- rzmap->set_num_bins_z(attrs.getValue("num_bins_z"));
- rzmap->set_grid_size_z(attrs.getValue("grid_size_z"));
-
- /* Top-level caller needs to setup the SAXObject references. */
- m_obj = rzmap;
- *obj = rzmap;
-
- /* Call next process UP in inheritance chain, after the SAXObject is set. */
- FieldMapTypeProcess::StartElement(name, attrs);
- }
-
- virtual void EndElement(const std::string&)
- {
- }
-
- virtual void Characters(const std::string&)
- {
- }
-
- virtual void StackPopNotify(const std::string& name)
- {
- // std::cout << "rz_field_mapProcess::StackPopNotify" << std::endl;
-
- if (name != "rzB") {
- std::cerr << name << " is not a valid child element for rz_field_map." << std::endl;
- exit(1);
- }
-
- FieldMapTypeProcess::StackPopNotify(name);
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "rz_field_map";
- return tag;
- }
-};
-
-DECLARE_PROCESS_FACTORY(rz_field_mapProcess)
lcdd/src
diff -N rz_field_mapSubscriber.cc
--- rz_field_mapSubscriber.cc 26 Jun 2013 01:36:24 -0000 1.9
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,123 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/rz_field_mapSubscriber.cc,v 1.9 2013/06/26 01:36:24 jeremy Exp $
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentFactory.h"
-#include "G4Processor/GDMLProcessor.h"
-
-// LCDD
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/schema/rz_field_map.hh"
-#include "lcdd/schema/rzb.hh"
-#include "lcdd/bfield/G4RZFieldMap.hh"
-
-/*
- * @class rz_field_mapSubscriber
- * @brief Subscriber for rz_field_map elements.
- */
-class rz_field_mapSubscriber: virtual public SAXSubscriber
-{
-public:
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
- rz_field_mapSubscriber()
- {
- Subscribe("rz_field_map");
- }
-
- virtual ~rz_field_mapSubscriber()
- {
- }
-
- /** Instantiates a G4RZFieldMap object into Geant4 runtime. */
- virtual void Activate(const SAXObject* object)
- {
- //std::cout << "rz_field_mapSubscriber" << std::endl;
-
- if (object != 0) {
-
- GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
-
- const rz_field_map* obj = dynamic_cast<const rz_field_map*>(object);
-
- if (obj) {
- std::string lunit = obj->get_lunit();
- std::string funit = obj->get_funit();
- std::string name = obj->get_name();
-
- int numBinsR, numBinsZ;
- double gridSizeR, gridSizeZ;
-
- std::string sval = obj->get_num_bins_r();
- numBinsR = (int) calc->Eval(sval);
-
- sval = obj->get_num_bins_z();
- numBinsZ = (int) calc->Eval(sval);
-
- sval = obj->get_grid_size_r();
- sval += "*" + lunit;
- gridSizeR = calc->Eval(sval);
-
- sval = obj->get_grid_size_z();
- sval += "*" + lunit;
- gridSizeZ = calc->Eval(sval);
-
- /* Make list of RZB rows from content. */
- const ContentSequence* seq = obj->get_content();
- size_t count = seq->size();
- std::vector<RZBData> fieldData;
-
- for (size_t i = 0; i < count; i++) {
-
- if (seq->content(i).tag == "rzB") {
-
- rzb* row = dynamic_cast<rzb*>(seq->content(i).object);
-
- if (row != 0) {
-
- std::string sr = row->get_r();
- std::string sz = row->get_z();
- std::string sBr = row->get_Br();
- std::string sBz = row->get_Bz();
-
- std::string sval = sr;
- sval += "*" + lunit;
- double r = calc->Eval(sval);
-
- sval = sz;
- sval += "*" + lunit;
- double z = calc->Eval(sval);
-
- sval = sBr;
- sval += "*" + funit;
- double Br = calc->Eval(sval);
-
- sval = sBz;
- sval += "*" + funit;
- double Bz = calc->Eval(sval);
-
- fieldData.push_back(RZBData(r, z, Br, Bz));
- } else {
- G4Exception("", "", FatalException, "Failed cast to rzB.");
- }
- } else {
- G4cerr << "WARNING: Ignoring unknown element " << seq->content(i).tag << "." << std::endl;
- }
- }
-
- G4RZFieldMap* fmap = new G4RZFieldMap(numBinsR, numBinsZ, gridSizeR, gridSizeZ, fieldData);
- LCDDProcessor::instance()->addMagneticField(name, fmap);
- } else {
- G4Exception("", "", FatalException, "Failed cast to rz_field_map.");
- }
- } else {
- G4Exception("", "", FatalException, "SAXObject is null.");
- }
- }
-};
-
-DECLARE_SUBSCRIBER_FACTORY(rz_field_mapSubscriber)
lcdd/src
diff -N rzbProcess.cc
--- rzbProcess.cc 26 Jun 2013 01:36:24 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,80 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/rzbProcess.cc,v 1.4 2013/06/26 01:36:24 jeremy Exp $
-
-// GDML
-#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"
-
-// LCDD
-#include "lcdd/schema/rzb.hh"
-
-// STL
-#include <iostream>
-
-/**
- * @brief Processor for rzB elements.
- */
-class rzbProcess: public SAXStateProcess
-{
-
-public:
- rzbProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~rzbProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- //std::cout << "rzbProcess::StartElement" << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- rzb* row = new rzb;
-
- row->set_r(attrs.getValue("r"));
- row->set_z(attrs.getValue("z"));
- row->set_Br(attrs.getValue("Br"));
- row->set_Bz(attrs.getValue("Bz"));
-
- m_obj = row;
- *obj = row;
- }
-
- virtual void EndElement(const std::string&)
- {
- }
-
- virtual void StackPopNotify(const std::string&)
- {
- }
-
- virtual void Characters(const std::string&)
- {
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "rzB";
- return tag;
- }
-
-private:
-
- SAXObject* m_obj;
-
-};
-
-DECLARE_PROCESS_FACTORY(rzbProcess)
lcdd/src
diff -N scorerProcess.cc
--- scorerProcess.cc 26 Jun 2013 01:36:24 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,71 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/scorerProcess.cc,v 1.3 2013/06/26 01:36:24 jeremy Exp $
-
-// GDML
-#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"
-
-// LCDD
-#include "lcdd/schema/scorer.hh"
-#include "lcdd/schema/SensitiveDetectorTypeProcess.hh"
-
-// STL
-#include <iostream>
-
-/**
- * @brief SAX process for scorer element.
- */
-class scorerProcess: public SensitiveDetectorTypeProcess
-{
-
-public:
- scorerProcess(const ProcessingContext* context = 0) :
- SensitiveDetectorTypeProcess(context)
- {
- }
-
- virtual ~scorerProcess()
- {
- }
-
- virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
- {
- //std::cout << "PROCESS::START OF TAG : " << name << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- scorer* scr = new scorer;
- /*
- scr->set_kill_tracks(attrs.getValue("kill_tracks") );
- */
-
- m_obj = scr;
- *obj = scr;
-
- SensitiveDetectorTypeProcess::StartElement(name, attrs);
- }
-
- virtual void EndElement(const std::string&)
- {
- //std::cout << "PROCESS::END OF TAG : " << name << " " << std::endl;
-
- //SensitiveDetectorTypeProcess::EndElement( name );
- }
-
- virtual void StackPopNotify(const std::string& name)
- {
- SensitiveDetectorTypeProcess::StackPopNotify(name);
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "scorer";
- return tag;
- }
-};
-
-DECLARE_PROCESS_FACTORY(scorerProcess)
lcdd/src
diff -N scorerSubscriber.cc
--- scorerSubscriber.cc 26 Jun 2013 01:36:24 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,45 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/scorerSubscriber.cc,v 1.4 2013/06/26 01:36:24 jeremy Exp $
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentFactory.h"
-
-// LCDD
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/schema/scorer.hh"
-#include "lcdd/detectors/G4SensitiveDetector.hh"
-#include "lcdd/detectors/G4ScorerSD.hh"
-#include "lcdd/detectors/SensitiveDetectorFactory.hh"
-
-// STL
-#include <iostream>
-
-/**
- * @brief SAX subscriber for scorer element.
- * @note Delegates to SensitiveDetectorFactory to create G4ScorerSD.
- */
-class scorerSubscriber: virtual public SAXSubscriber
-{
-public:
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
- scorerSubscriber()
- {
- Subscribe("scorer");
- }
-
- virtual ~scorerSubscriber()
- {
- }
-
- virtual void Activate(const SAXObject* object)
- {
- SensitiveDetectorFactory::createSensitiveDetector(object);
- }
-};
-
-DECLARE_SUBSCRIBER_FACTORY(scorerSubscriber)
lcdd/src
diff -N sdrefProcess.cc
--- sdrefProcess.cc 26 Jun 2013 01:36:24 -0000 1.7
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,53 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/sdrefProcess.cc,v 1.7 2013/06/26 01:36:24 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/SensitiveDetectorType.hh"
-
-// GDML
-#include "Processes/ReferenceTypeProcess.h"
-
-// STL
-#include <iostream>
-
-/**
- @class sdrefProcess
- @brief SAX process for sdref element.
- @note Extends ReferenceTypeProcess for reference to sd element.
- */
-class sdrefProcess: public ReferenceTypeProcess
-{
-public:
- sdrefProcess(const ProcessingContext* context = 0) :
- ReferenceTypeProcess(context)
- {
- }
-
- virtual ~sdrefProcess()
- {
- }
-
- virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
- {
- SAXObject** obj = Context()->GetTopObject();
-
- SensitiveDetectorType::sdref* s = new SensitiveDetectorType::sdref;
-
- *obj = s;
- m_obj = s;
-
- ReferenceTypeProcess::StartElement(name, attrs);
- }
-
- virtual void EndElement(const std::string& name)
- {
- ReferenceTypeProcess::EndElement(name);
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "sdref";
- return tag;
- }
-};
-
-DECLARE_PROCESS_FACTORY(sdrefProcess)
lcdd/src
diff -N solenoidProcess.cc
--- solenoidProcess.cc 26 Jun 2013 01:36:24 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,77 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/solenoidProcess.cc,v 1.6 2013/06/26 01:36:24 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/solenoid.hh"
-#include "lcdd/schema/FieldTypeProcess.hh"
-
-// GDML
-#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"
-
-// STL
-#include <iostream>
-
-/**
- * @brief SAX process for solenoid element.
- */
-class solenoidProcess: public FieldTypeProcess
-{
-
-public:
- solenoidProcess(const ProcessingContext* context = 0) :
- FieldTypeProcess(context)
- {
- }
-
- virtual ~solenoidProcess()
- {
- }
-
- virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
- {
- //std::cout << "solenoidProcess::StartElement: " << name << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- solenoid* sol = new solenoid;
-
- sol->set_innerField(attrs.getValue("inner_field"));
- sol->set_outerField(attrs.getValue("outer_field"));
- sol->set_zmin(attrs.getValue("zmin"));
- sol->set_zmax(attrs.getValue("zmax"));
- sol->set_innerRadius(attrs.getValue("inner_radius"));
- sol->set_outerRadius(attrs.getValue("outer_radius"));
-
- m_obj = sol;
- *obj = sol;
-
- FieldTypeProcess::StartElement(name, attrs);
- }
-
- virtual void EndElement(const std::string&)
- {
- //std::cout << "solenoidProcess::EndElement: " << name << " " << std::endl;
- }
-
- virtual void Characters(const std::string&)
- {
- }
-
- virtual void StackPopNotify(const std::string&)
- {
- //std::cout << "calorimeterProcess::StackPopNotify: " << name << std::endl;
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "solenoid";
- return tag;
- }
-};
-
-DECLARE_PROCESS_FACTORY(solenoidProcess)
lcdd/src
diff -N solenoidSubscriber.cc
--- solenoidSubscriber.cc 26 Jun 2013 01:36:24 -0000 1.9
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,99 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/solenoidSubscriber.cc,v 1.9 2013/06/26 01:36:24 jeremy Exp $
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentFactory.h"
-#include "G4Processor/GDMLProcessor.h"
-#include "G4Evaluator/GDMLExpressionEvaluator.h"
-
-// processor
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/schema/solenoid.hh"
-#include "lcdd/bfield/G4Solenoid.hh"
-
-/**
- * @brief SAX subscriber for solenoid element.
- * @note Creates a G4Solenoid object and registers with LCDDProcessor.
- */
-class solenoidSubscriber: virtual public SAXSubscriber
-{
-public:
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
- solenoidSubscriber()
- {
- Subscribe("solenoid");
- }
-
- virtual ~solenoidSubscriber()
- {
- }
-
- virtual void Activate(const SAXObject* object)
- {
- //std::cout << "solenoidSubscriber" << std::endl;
-
- GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
- if (object != 0) {
- const solenoid* obj = dynamic_cast<const solenoid*>(object);
-
- if (obj) {
- //std::cout << "GOT SOLENOID: " << obj->get_name() << std::endl;
-
- double outer_field, inner_field;
- double zmin, zmax;
- double inner_radius, outer_radius;
-
- std::string lunit = obj->get_lunit();
- std::string funit = obj->get_funit();
-
- std::string sval = obj->get_innerField();
- sval += "*" + funit;
- inner_field = calc->Eval(sval);
-
- sval = obj->get_outerField();
- sval += "*" + funit;
- outer_field = calc->Eval(sval);
-
- sval = obj->get_zmin();
- sval += "*" + lunit;
- zmin = calc->Eval(sval);
-
- sval = obj->get_zmax();
- sval += "*" + lunit;
- zmax = calc->Eval(sval);
-
- sval = obj->get_innerRadius();
- sval += "*" + lunit;
- inner_radius = calc->Eval(sval);
-
- sval = obj->get_outerRadius();
- sval += "*" + lunit;
- outer_radius = calc->Eval(sval);
-
- G4Solenoid* sol = new G4Solenoid();
-
- sol->setInnerField(inner_field);
- sol->setOuterField(outer_field);
- sol->setInnerZ(zmin);
- sol->setOuterZ(zmax);
- sol->setInnerR(inner_radius);
- sol->setOuterR(outer_radius);
-
- std::string field_name = obj->get_name();
- LCDDProcessor::instance()->addMagneticField(field_name, sol);
- } else {
- std::cerr << "Failed cast to solenoid!" << std::endl;
- }
- }
-
- //delete object;
- }
-};
-
-DECLARE_SUBSCRIBER_FACTORY(solenoidSubscriber)
-
lcdd/src
diff -N trackerProcess.cc
--- trackerProcess.cc 26 Jun 2013 01:36:24 -0000 1.8
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,65 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/trackerProcess.cc,v 1.8 2013/06/26 01:36:24 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/tracker.hh"
-#include "lcdd/schema/SensitiveDetectorTypeProcess.hh"
-
-// GDML
-#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"
-
-// STL
-#include <iostream>
-
-/**
- @class trackerProcess
- @brief SAX process for tracker element.
- */
-class trackerProcess: public SensitiveDetectorTypeProcess
-{
-
-public:
- trackerProcess(const ProcessingContext* context = 0) :
- SensitiveDetectorTypeProcess(context)
- {
- }
-
- virtual ~trackerProcess()
- {
- }
-
- virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
- {
- SAXObject** obj = Context()->GetTopObject();
-
- tracker* trk = new tracker;
- trk->set_combine_hits(attrs.getValue("combine_hits"));
-
- m_obj = trk;
- *obj = trk;
-
- SensitiveDetectorTypeProcess::StartElement(name, attrs);
- }
-
- virtual void EndElement(const std::string&)
- {
- }
-
- virtual void StackPopNotify(const std::string& name)
- {
- SensitiveDetectorTypeProcess::StackPopNotify(name);
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "tracker";
- return tag;
- }
-};
-
-DECLARE_PROCESS_FACTORY(trackerProcess)
lcdd/src
diff -N trackerSubscriber.cc
--- trackerSubscriber.cc 26 Jun 2013 01:36:24 -0000 1.10
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,46 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/trackerSubscriber.cc,v 1.10 2013/06/26 01:36:24 jeremy Exp $
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentFactory.h"
-
-// LCDD
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/schema/tracker.hh"
-#include "lcdd/detectors/G4SensitiveDetector.hh"
-#include "lcdd/detectors/G4TrackerSD.hh"
-#include "lcdd/detectors/SensitiveDetectorFactory.hh"
-
-// STL
-#include <iostream>
-
-/**
- @class trackerSubscriber
- @brief SAX subscriber for tracker element.
- @note Delegates to SensitiveDetectorFactory to create G4TrackerSD.
- */
-class trackerSubscriber: virtual public SAXSubscriber
-{
-public:
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
- trackerSubscriber()
- {
- Subscribe("tracker");
- }
-
- virtual ~trackerSubscriber()
- {
- }
-
- virtual void Activate(const SAXObject* object)
- {
- SensitiveDetectorFactory::createSensitiveDetector(object);
- }
-};
-
-DECLARE_SUBSCRIBER_FACTORY(trackerSubscriber)
lcdd/src
diff -N unsegmented_calorimeterProcess.cc
--- unsegmented_calorimeterProcess.cc 26 Jun 2013 01:36:24 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,35 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/unsegmented_calorimeterProcess.cc,v 1.3 2013/06/26 01:36:24 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/calorimeterProcess.hh"
-#include "lcdd/schema/unsegmented_calorimeter.hh"
-
-// GDML
-#include "Saxana/ProcessingContext.h"
-#include "Saxana/SAXComponentFactory.h"
-
-#include <iostream>
-
-/**
- * @brief SAX process for unsegmented_calorimeter element.@note Calls SAX processor for SensitiveDetectorTypeProcess parent class.
- */
-class unsegmented_calorimeterProcess: public calorimeterProcess
-{
-public:
- unsegmented_calorimeterProcess(const ProcessingContext* context = 0) :
- calorimeterProcess(context)
- {
- }
-
- virtual ~unsegmented_calorimeterProcess()
- {
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "unsegmented_calorimeter";
- return tag;
- }
-};
-
-DECLARE_PROCESS_FACTORY(unsegmented_calorimeterProcess)
lcdd/src
diff -N unsegmented_calorimeterSubscriber.cc
--- unsegmented_calorimeterSubscriber.cc 26 Jun 2013 01:36:24 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,40 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/unsegmented_calorimeterSubscriber.cc,v 1.4 2013/06/26 01:36:24 jeremy Exp $
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentFactory.h"
-
-// LCDD
-#include "lcdd/detectors/SensitiveDetectorFactory.hh"
-
-/**
- * @brief SAX subscriber for calorimeter element.
- * @note Delegates to SensitiveDetectorFactory to create G4CalorimeterSD object.
- */
-class unsegmented_calorimeterSubscriber: virtual public SAXSubscriber
-{
-public:
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
-
- unsegmented_calorimeterSubscriber()
- {
- Subscribe("unsegmented_calorimeter");
- }
-
- virtual ~unsegmented_calorimeterSubscriber()
- {
- }
-
- virtual void Activate(const SAXObject* object)
- {
- SensitiveDetectorFactory::createSensitiveDetector(object);
- }
-};
-
-DECLARE_SUBSCRIBER_FACTORY(unsegmented_calorimeterSubscriber)
lcdd/src
diff -N visProcess.cc
--- visProcess.cc 26 Jun 2013 01:36:24 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,84 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/visProcess.cc,v 1.3 2013/06/26 01:36:24 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/vis.hh"
-
-// GDML
-#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"
-
-// std
-#include <iostream>
-
-/**
- * @brief SAX process for vis element.
- */
-class visProcess: public SAXStateProcess
-{
-public:
-
- visProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~visProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- //std::cout << "visProcess::StartElement()" << std::endl;
-
- SAXObject** obj = Context()->GetTopObject();
-
- vis* v = new vis;
-
- v->set_name(attrs.getValue("name"));
- v->set_visible(attrs.getValue("visible"));
- v->set_show_daughters(attrs.getValue("show_daughters"));
- v->set_line_style(attrs.getValue("line_style"));
- v->set_drawing_style(attrs.getValue("drawing_style"));
-
- m_obj = v;
- *obj = v;
- }
-
- virtual void EndElement(const std::string&)
- {
- }
-
- virtual void Characters(const std::string&)
- {
- }
-
- virtual void StackPopNotify(const std::string& name)
- {
- // add all content
- SAXObject** so = Context()->GetTopObject();
- vis* v = dynamic_cast<vis*>(m_obj);
- v->add_content(name, *so);
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "vis";
- return tag;
- }
-
-private:
-
- SAXObject* m_obj;
-};
-
-DECLARE_PROCESS_FACTORY(visProcess)
lcdd/src
diff -N visSubscriber.cc
--- visSubscriber.cc 26 Jun 2013 01:36:24 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,136 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/visSubscriber.cc,v 1.4 2013/06/26 01:36:24 jeremy Exp $
-
-// LCDD
-#include "lcdd/core/LCDDProcessor.hh"
-#include "lcdd/schema/vis.hh"
-#include "lcdd/schema/color.hh"
-#include "lcdd/util/StringUtil.hh"
-
-// GDML
-#include "Saxana/SAXSubscriber.h"
-#include "Saxana/SAXComponentFactory.h"
-
-// Geant4
-#include "G4VisAttributes.hh"
-
-/**
- @class visSubscriber
- @brief SAX subscriber for vis element.
- @note Creates and registers a G4VisAttributes object with LCDDProcessor.
- */
-class visSubscriber: virtual public SAXSubscriber
-{
-public:
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
-public:
- visSubscriber()
- {
- Subscribe("vis");
- }
-
- virtual ~visSubscriber()
- {
- }
-
- virtual void Activate(const SAXObject* object)
- {
- //std::cout << "visSubscriber::Activate()" << std::endl;
-
- if (object != 0) {
- const vis* vobj = dynamic_cast<const vis*>(object);
-
- if (vobj) {
- G4VisAttributes* g4vis = new G4VisAttributes;
-
- std::string name = vobj->get_name();
- bool visible = StringUtil::toBool(vobj->get_visible());
- bool show_daughters = StringUtil::toBool(vobj->get_show_daughters());
- G4VisAttributes::LineStyle line = convertLineStyle(vobj->get_line_style());
- G4VisAttributes::ForcedDrawingStyle draw = convertDrawingStyle(vobj->get_drawing_style());
-
- g4vis->SetVisibility(visible);
- g4vis->SetDaughtersInvisible(!show_daughters);
- g4vis->SetLineStyle(line);
-
- if (draw == G4VisAttributes::wireframe) {
- g4vis->SetForceWireframe(true);
- } else if (draw == G4VisAttributes::solid) {
- g4vis->SetForceSolid(true);
- }
-
- // set color
- bool color_set = false;
- ContentSequence* seq = const_cast<ContentSequence*>(vobj->get_content());
- size_t count = seq->size();
- for (size_t i = 0; i < count; i++) {
- std::string child_tag = seq->content(i).tag;
- SAXObject* child_obj = seq->content(i).object;
-
- if (child_tag == "color") {
- //std::cout << "handling color" << std::endl;
- color* c = dynamic_cast<color*>(child_obj);
-
- double r = StringUtil::toDouble(c->get_R());
- double g = StringUtil::toDouble(c->get_G());
- double b = StringUtil::toDouble(c->get_B());
- double alpha = StringUtil::toDouble(c->get_alpha());
-
- //std::cout << "r g b alpha: " << r << " " << g << " " << b << " " << alpha << std::endl;
-
- g4vis->SetColor(r, g, b, alpha);
-
- // should be only one
- color_set = true;
- break;
- }
- }
-
- if (!color_set) {
- std::cerr << "WARNING: Color was not explicitly set and got the default value." << std::endl;
- }
-
- // add to proc's map
- LCDDProcessor::instance()->addVisAttributes(name, g4vis);
- }
- }
-
- //delete object;
- }
-
- static G4VisAttributes::LineStyle convertLineStyle(const std::string& s)
- {
- G4VisAttributes::LineStyle l = G4VisAttributes::unbroken;
-
- if (s == "unbroken") {
- l = G4VisAttributes::unbroken;
- } else if (s == "dashed") {
- l = G4VisAttributes::dashed;
- } else if (s == "dotted") {
- l = G4VisAttributes::dotted;
- } else {
- std::cerr << "WARNING: unknown LineStyle - " << s << std::endl;
- }
-
- return l;
- }
-
- static G4VisAttributes::ForcedDrawingStyle convertDrawingStyle(const std::string& s)
- {
- G4VisAttributes::ForcedDrawingStyle d = G4VisAttributes::wireframe;
- if (s == "wireframe") {
- d = G4VisAttributes::wireframe;
- } else if (s == "solid") {
- d = G4VisAttributes::solid;
- } else {
- std::cerr << "WARNING: unknown DrawingStyle - " << d << std::endl;
- }
-
- return d;
- }
-};
-
-DECLARE_SUBSCRIBER_FACTORY(visSubscriber)
lcdd/src
diff -N visrefProcess.cc
--- visrefProcess.cc 26 Jun 2013 01:36:24 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,49 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/visrefProcess.cc,v 1.4 2013/06/26 01:36:24 jeremy Exp $
-
-// LCDD
-#include "lcdd/schema/VisType.hh"
-
-// GDML
-#include "Processes/ReferenceTypeProcess.h"
-
-/**
- * @brief SAX process for visref element.
- * @note Extends ReferenceTypeProcess for referencing the vis elements.
- */
-class visrefProcess: public ReferenceTypeProcess
-{
-public:
- visrefProcess(const ProcessingContext* context = 0) :
- ReferenceTypeProcess(context)
- {
- }
-
- virtual ~visrefProcess()
- {
- }
-
- virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
- {
- SAXObject** obj = Context()->GetTopObject();
-
- VisType::visref* visref = new VisType::visref;
-
- *obj = visref;
- m_obj = visref;
-
- ReferenceTypeProcess::StartElement(name, attrs);
- }
-
- virtual void EndElement(const std::string& name)
- {
- ReferenceTypeProcess::EndElement(name);
- }
-
- virtual const std::string& State() const
- {
- static std::string tag = "visref";
- return tag;
- }
-};
-
-DECLARE_PROCESS_FACTORY(visrefProcess)
lcdd/src
diff -N volumeExtendedProcess.cc
--- volumeExtendedProcess.cc 26 Jun 2013 01:36:24 -0000 1.9
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,85 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/volumeExtendedProcess.cc,v 1.9 2013/06/26 01:36:24 jeremy Exp $
-#ifndef VolumeExtendedProcess_hh
-#define VolumeExtendedProcess_hh 1
-
-#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 "Schema/volume.h"
-
-/**
- * @brief SAX process for the volume element, as extended by LCDD.
- * @note This is mostly a cut and paste job of GDML's volumeProcess class,
- * as this class does not appear to be extendable. It is only defined in a cpp
- * file with no include guards!
- */
-class volumeExtendedProcess: public SAXStateProcess
-{
-public:
- volumeExtendedProcess(const ProcessingContext* context = 0) :
- SAXStateProcess(context), m_obj(0)
- {
- }
-
- virtual ~volumeExtendedProcess()
- {
- }
-
- virtual const SAXComponentObject* Build() const
- {
- return this;
- }
-
- // Analogical to SAX startElement callback
- virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
- {
- SAXObject** obj = Context()->GetTopObject();
-
- volume* vo = new volume;
-
- vo->set_name(attrs.getValue("name"));
-
- m_obj = vo;
- *obj = vo;
- }
-
- virtual void EndElement(const std::string&)
- {
- }
-
- virtual void Characters(const std::string&)
- {
- }
-
- virtual void StackPopNotify(const std::string& name)
- {
- SAXObject** so = Context()->GetTopObject();
- volume* vobj = dynamic_cast<volume*>(m_obj);
- vobj->add_content(name, *so);
- }
-
- // The name of the state this object will process
- virtual const std::string& State() const
- {
- static std::string tag = "volume";
- return tag;
- }
-
-private:
- SAXObject* m_obj;
-
-public:
-
- static SAXObject* m_volumeSaved;
-
-};
-
-DECLARE_PROCESS_FACTORY(volumeExtendedProcess)
-
-#endif
-
lcdd/src
diff -N volumeExtendedSubscriber.cc
--- volumeExtendedSubscriber.cc 26 Jun 2013 01:36:24 -0000 1.32
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,177 +0,0 @@
-// $Header: /cvs/lcd/lcdd/src/Attic/volumeExtendedSubscriber.cc,v 1.32 2013/06/26 01:36:24 jeremy Exp $
-
-// LCDD
-#include "lcdd/subscribers/volumeExtendedSubscriber.hh"
-
-/**
- * @brief SAX subscriber to handle extra LCDD tags on volume element.
- * @note This is the major subscriber extension class for the LCDD package.
- */
-const SAXComponentObject* volumeExtendedSubscriber::Build() const
-{
- return this;
-}
-
-volumeExtendedSubscriber::volumeExtendedSubscriber()
-{
- Subscribe("volume");
-}
-
-volumeExtendedSubscriber::~volumeExtendedSubscriber()
-{
-}
-
-void volumeExtendedSubscriber::Activate(const SAXObject* object)
-{
- LCDDProcessor* proc = LCDDProcessor::instance();
- const volume* vobj = 0;
- G4SensitiveDetector* g4sd = 0;
- G4LogicalVolume* lv;
- int nchildren = 0;
-
- if (object) {
- vobj = dynamic_cast<const volume*>(object);
-
- if (vobj) {
-
- // get LV
- lv = const_cast<G4LogicalVolume*>(GDMLProcessor::GetInstance()->GetLogicalVolume(vobj->get_name()));
-
- if (lv) {
-
- // get content
- const ContentSequence* seq = vobj->get_content();
-
- // get size of content
- size_t count = seq->size();
-
- // iterate over and process content
- for (size_t i = 0; i < count; i++) {
-
- // handle sdref tag
- if (seq->content(i).tag == "sdref") {
-
- SensitiveDetectorType::sdref* sd = dynamic_cast<SensitiveDetectorType::sdref*>(seq->content(i).object);
-
- g4sd = proc->getSensitiveDetector(sd->get_ref());
-
- if (g4sd) {
-
- if (!g4sd->isValidVolume(lv)) {
- //G4Exception("FATAL ERROR: The G4LogicalVolume <" + lv->GetName() + "> is not valid for the SD <" + g4sd->GetName() + ">.");
- G4Exception("", "", FatalException, "LogVol not valid for the SD");
- }
-
- lv->SetSensitiveDetector(g4sd);
- } else {
- G4cerr << "SD not found: " << sd->get_ref() << "." << G4endl;
- G4Exception( "volumeExtendedSubscriber::Activate()", "", FatalException, "Invalid sdref.");
- }
- } else if ( seq->content(i).tag == "regionref" ) {
- // handle regionref
-
- // get regionref object
- RegionType::regionref* regref = dynamic_cast<RegionType::regionref*> ( seq->content(i).object );
-
- // get region from store
- G4Region* reg = dynamic_cast<G4Region*> ( proc->getRegion( regref->get_ref() ) );
-
- // add LV to region
- if ( reg ) {
- reg->AddRootLogicalVolume( lv );
- } else {
- G4cerr << "Failed to fetch and/or cast to region: " << regref->get_ref() << G4endl;
- G4Exception("volumeExtendedSubscriber::Activate()", "", FatalException, "Invalid regionref.");
- }
- } else if ( seq->content(i).tag == "limitsetref" ) {
- // handle limitsetref
-
- LimitSetType::limitsetref* limitsetref = dynamic_cast<LimitSetType::limitsetref*> ( seq->content(i).object );
-
- G4UserLimits* ulim = dynamic_cast<G4LimitSet*> ( proc->getLimitSet( limitsetref->get_ref() ) );
-
- if ( ulim ) {
- lv->SetUserLimits( ulim );
- std::cout << "Set user limits <" << limitsetref->get_ref() << "> on logical volume <" << lv->GetName() << ">" << std::endl;
- } else {
- std::cerr << "FATAL ERROR: limit element not found - " << limitsetref->get_ref() << std::endl;
- G4Exception("", "", FatalException, "limitsetref not found.");
- }
- } else if ( seq->content(i).tag == "visref" ) {
- // handle visref
-
- //std::cout << "handling visref" << std::endl;
-
- VisType::visref* visref = dynamic_cast<VisType::visref*> ( seq->content(i).object );
-
- G4VisAttributes* vis = dynamic_cast<G4VisAttributes*> ( proc->getVisAttributes( visref->get_ref() ) );
-
- if ( vis ) {
- //std::cout << "assigning vis: " << visref->get_ref() << std::endl;
- lv->SetVisAttributes( vis );
- } else {
- std::cerr << "FATAL ERROR: vis element not found - " << visref->get_ref() << std::endl;
- G4Exception("", "", FatalException, "vis element not found.");
- }
- }
-
- if ( seq->content(i).tag == "physvol" ) {
- // handle physvols to look for physvolids
-
- ++nchildren;
-
- // get physvol content sequence
- physvol* pv = dynamic_cast<physvol*>( seq->content(i).object );
- const ContentSequence* pv_seq = pv->get_content();
- size_t ccount = pv_seq->size();
-
- // iterate over physvol content
- for ( size_t pvidx = 0; pvidx < ccount; pvidx++ ) {
-
- // found "choice" tag?
- if( pv_seq->content(pvidx).tag == "choice" ) {
-
- const ContentChoice* pv_choice = dynamic_cast<const ContentChoice*>( pv_seq->content(pvidx).object );
-
- // found a physvolid?
- if ( pv_choice->content().tag == "physvolid" ) {
-
- // add the physvolid...
-
- physvolidElem* pvid_elem =
- dynamic_cast<physvolidElem*>( pv_choice->content().object );
-
- if ( pvid_elem == 0 ) {
- G4Exception("", "", FatalException, "Failed cast to physvolidElem.");
- }
-
- GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
-
- std::string strID = pvid_elem->get_value();
- std::string fld = pvid_elem->get_field_name();
-
- int intID = (int)calc->Eval( strID );
-
- PhysVolId pvid(intID, fld);
-
- // assign physvolid to lv's child by the in-order idx
- IdManager::instance()->addPhysVolId(
- lv, // LV mom
- nchildren - 1, // child idx in mom
- pvid ); // PhysVolId
- }
-
- }
- }
- }
- }
- } else {
- G4Exception("", "", FatalException, "Failed cast to G4LogicalVolume.");
- }
- } else {
- G4Exception("", "", FatalException, "Failed cast to volume.");
- }
- }
-}
-
-//DECLARE_SUBSCRIBER_FACTORY(volumeExtendedSubscriber)
lcdd/src/lcdd/bfield
diff -N Cartesian3DMagneticFieldMap.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Cartesian3DMagneticFieldMap.cc 26 Jun 2013 23:50:59 -0000 1.1
@@ -0,0 +1,231 @@
+//
+// Original PurgMagTabulatedField3D code developed by:
+// S.Larsson and J. Generowicz.
+//
+
+// LCDD
+#include "lcdd/bfield/Cartesian3DMagneticFieldMap.hh"
+
+// STL
+#include <fstream>
+#include <iostream>
+#include <cmath>
+
+using namespace std;
+
+Cartesian3DMagneticFieldMap::Cartesian3DMagneticFieldMap( const char* filename, double xOffset, double yOffset, double zOffset )
+ :_xOffset(xOffset),_yOffset(yOffset),_zOffset(zOffset),_invertX(false),_invertY(false),_invertZ(false)
+{
+ //cout << "\n-----------------------------------------------------------"
+ // << "\n Magnetic field"
+ // << "\n-----------------------------------------------------------";
+
+ //cout << "\n ---> " "Reading the field grid from " << filename << " ... " << endl;
+ ifstream file( filename ); // Open the file for reading.
+
+ // Ignore first blank line
+ char buffer[256];
+ file.getline(buffer,256);
+
+ // Read table dimensions
+ file >> _nx >> _ny >> _nz; // Note dodgy order
+
+ //cout << " [ Number of values x,y,z: "
+ // << _nx << " " << _ny << " " << _nz << " ] "
+ // << endl;
+
+ // Set up storage space for table
+ _xField.resize( _nx );
+ _yField.resize( _nx );
+ _zField.resize( _nx );
+ int ix, iy, iz;
+ for (ix=0; ix<_nx; ix++) {
+ _xField[ix].resize(_ny);
+ _yField[ix].resize(_ny);
+ _zField[ix].resize(_ny);
+ for (iy=0; iy<_ny; iy++) {
+ _xField[ix][iy].resize(_nz);
+ _yField[ix][iy].resize(_nz);
+ _zField[ix][iy].resize(_nz);
+ }
+ }
+
+ // Ignore other header information
+ // The first line whose second character is '0' is considered to
+ // be the last line of the header.
+ do {
+ file.getline(buffer,256);
+ } while ( buffer[1]!='0');
+
+ // Read in the data
+ double xval,yval,zval,bx,by,bz;
+ for (ix=0; ix<_nx; ix++) {
+ for (iy=0; iy<_ny; iy++) {
+ for (iz=0; iz<_nz; iz++) {
+ file >> xval >> yval >> zval >> bx >> by >> bz;
+ if ( ix==0 && iy==0 && iz==0 ) {
+ _minx = xval;
+ _miny = yval;
+ _minz = zval;
+ }
+ _xField[ix][iy][iz] = bx;
+ _yField[ix][iy][iz] = by;
+ _zField[ix][iy][iz] = bz;
+ }
+ }
+ }
+ file.close();
+
+ _maxx = xval;
+ _maxy = yval;
+ _maxz = zval;
+
+ //cout << "\n ---> ... done reading " << endl;
+
+ // cout << " Read values of field from file " << filename << endl;
+ //cout << " ---> assumed the order: x, y, z, Bx, By, Bz "
+ // << "\n ---> Min values x,y,z: "
+ // << _minx << " " << _miny << " " << _minz << " cm "
+ // << "\n ---> Max values x,y,z: "
+ // << _maxx << " " << _maxy << " " << _maxz << " cm "
+ // << "\n ---> The field will be offset by " << _xOffset << " " << _yOffset << " " << _zOffset << " cm " << endl;
+
+ // Should really check that the limits are not the wrong way around.
+ if (_maxx < _minx) {swap(_maxx,_minx); _invertX = true;}
+ if (_maxy < _miny) {swap(_maxy,_miny); _invertY = true;}
+ if (_maxz < _minz) {swap(_maxz,_minz); _invertZ = true;}
+ //cout << "\nAfter reordering if necessary"
+ // << "\n ---> Min values x,y,z: "
+ // << _minx << " " << _miny << " " << _minz << " cm "
+ // << " \n ---> Max values x,y,z: "
+ // << _maxx << " " << _maxy << " " << _maxz << " cm ";
+
+ _dx = _maxx - _minx;
+ _dy = _maxy - _miny;
+ _dz = _maxz - _minz;
+ //cout << "\n ---> Range of values x,y,z: "
+ // << _dx << " " << _dy << " " << _dz << " cm in z "
+ // << "\n-----------------------------------------------------------" << endl;
+}
+
+void Cartesian3DMagneticFieldMap::GetFieldValue(const double point[4],
+ double *Bfield ) const
+{
+
+ double x = point[0];
+ double y = point[1];
+ double z = point[2] + _zOffset;
+
+ // Check that the point is within the defined region
+ if ( x>=_minx && x<=_maxx &&
+ y>=_miny && y<=_maxy &&
+ z>=_minz && z<=_maxz ) {
+
+ // Position of given point within region, normalized to the range
+ // [0,1]
+ double xfraction = (x - _minx) / _dx;
+ double yfraction = (y - _miny) / _dy;
+ double zfraction = (z - _minz) / _dz;
+
+ if (_invertX) { xfraction = 1 - xfraction;}
+ if (_invertY) { yfraction = 1 - yfraction;}
+ if (_invertZ) { zfraction = 1 - zfraction;}
+
+ // Need addresses of these to pass to modf below.
+ // modf uses its second argument as an OUTPUT argument.
+ double xdindex, ydindex, zdindex;
+
+ // Position of the point within the cuboid defined by the
+ // nearest surrounding tabulated points
+ double xlocal = ( std::modf(xfraction*(_nx-1), &xdindex));
+ double ylocal = ( std::modf(yfraction*(_ny-1), &ydindex));
+ double zlocal = ( std::modf(zfraction*(_nz-1), &zdindex));
+
+ // The indices of the nearest tabulated point whose coordinates
+ // are all less than those of the given point
+ int xindex = static_cast<int>(xdindex);
+ int yindex = static_cast<int>(ydindex);
+ int zindex = static_cast<int>(zdindex);
+
+
+#ifdef DEBUG_INTERPOLATING_FIELD
+ cout << "Local x,y,z: " << xlocal << " " << ylocal << " " << zlocal << endl;
+ cout << "Index x,y,z: " << xindex << " " << yindex << " " << zindex << endl;
+ double valx0z0, mulx0z0, valx1z0, mulx1z0;
+ double valx0z1, mulx0z1, valx1z1, mulx1z1;
+ valx0z0= table[xindex ][0][zindex]; mulx0z0= (1-xlocal) * (1-zlocal);
+ valx1z0= table[xindex+1][0][zindex]; mulx1z0= xlocal * (1-zlocal);
+ valx0z1= table[xindex ][0][zindex+1]; mulx0z1= (1-xlocal) * zlocal;
+ valx1z1= table[xindex+1][0][zindex+1]; mulx1z1= xlocal * zlocal;
+#endif
+
+ // Full 3-dimensional version
+ Bfield[0] =
+ _xField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) +
+ _xField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal +
+ _xField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) +
+ _xField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal +
+ _xField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) +
+ _xField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal +
+ _xField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) +
+ _xField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal ;
+ Bfield[1] =
+ _yField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) +
+ _yField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal +
+ _yField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) +
+ _yField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal +
+ _yField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) +
+ _yField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal +
+ _yField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) +
+ _yField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal ;
+ Bfield[2] =
+ _zField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) +
+ _zField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal +
+ _zField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) +
+ _zField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal +
+ _zField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) +
+ _zField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal +
+ _zField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) +
+ _zField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal ;
+
+ } else {
+ Bfield[0] = 0.0;
+ Bfield[1] = 0.0;
+ Bfield[2] = 0.0;
+ }
+}
+
+/*
+int main()
+{
+ Cartesian3DMagneticFieldMap field("C:/work/magfield/magfield3DMap/ThreeDFieldMap.dat", 0.,0.,0.);
+ double pos[4];
+ pos[0]=0.;
+ pos[1]=0.;
+ pos[2]=0.;
+ pos[3]=0.;
+ double B[3];
+
+ for(double x=-0.05; x<=0.05; x+=.005)
+ {
+ for(double y=-0.05; y<=0.17; y+=.005)
+ {
+ for(double z=-0.26; z<=0.1; z+=.05)
+ {
+ pos[0]=x;
+ pos[1] =y;
+ pos[2] = z;
+ field.GetFieldValue(pos, B);
+ //cout << pos[0] << " " << pos[1] << " " << pos[2] << " " << B[0] << " " << B[1] << " " << B[2] << endl;
+ }
+ }
+ }
+
+ pos[0]=-0.01;
+ pos[1]=0.038;
+ pos[2]=-0.02;
+ field.GetFieldValue(pos, B);
+ //cout << pos[0] << " " << pos[1] << " " << pos[2] << " " << B[0] << " " << B[1] << " " << B[2] << endl;
+ return 0;
+}
+*/
lcdd/src/lcdd/bfield
diff -N G4BoxDipole.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4BoxDipole.cc 26 Jun 2013 23:50:59 -0000 1.1
@@ -0,0 +1,32 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/bfield/G4BoxDipole.cc,v 1.1 2013/06/26 23:50:59 jeremy Exp $
+
+// LCDD
+#include "lcdd/bfield/G4BoxDipole.hh"
+
+G4BoxDipole::G4BoxDipole(double x, double y, double z, double dx, double dy, double dz, double bx, double by, double bz) :
+ _x(x), _y(y), _z(z), _dx(dx), _dy(dy), _dz(dz), _bx(bx), _by(by), _bz(bz)
+{
+ _maxx = x + dx;
+ _maxy = y + dy;
+ _maxz = z + dz;
+
+ _minx = x - dx;
+ _miny = y - dy;
+ _minz = z - dz;
+}
+
+void G4BoxDipole::GetFieldValue(const double point[3], double* bfield) const
+{
+ if (point[0] < _minx || point[0] > _maxx)
+ return;
+ if (point[1] < _miny || point[1] > _maxy)
+ return;
+ if (point[2] < _minz || point[2] > _maxz)
+ return;
+
+ bfield[0] += _bx;
+ bfield[1] += _by;
+ bfield[2] += _bz;
+
+ //std::cout << point[0] << ", " << point[1] << ", " << point[2] << " --> " << bfield[0] << ", " << bfield[1] << ", " << bfield[2] << std::endl;
+}
lcdd/src/lcdd/bfield
diff -N G4Dipole.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4Dipole.cc 26 Jun 2013 23:50:59 -0000 1.1
@@ -0,0 +1,114 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/bfield/G4Dipole.cc,v 1.1 2013/06/26 23:50:59 jeremy Exp $
+
+// LCDD
+#include "lcdd/bfield/G4Dipole.hh"
+
+// STL
+#include <iostream>
+#include <cmath>
+
+/**
+ * Apply polynomial fit of dipole field, with variable number of coefficients
+ * read from the input XML file.
+ */
+void G4Dipole::GetFieldValue(const double Point[3], double* Bfield) const
+{
+ //std::cout << "G4Dipole::GetFieldValue" << std::endl;
+
+ //std::cout << "point = " << Point[0] << " " << Point[1] << " " << Point[2] << std::endl;
+ //std::cout << "BEFORE --> bfield = " << Bfield[0] << " " << Bfield[1] << " " << Bfield[2] << std::endl;
+
+ double bx = 0;
+ double z = Point[2];
+ double r = sqrt(Point[0] * Point[0] + Point[1] * Point[1]);
+
+ // Check if z coordinate is within dipole z bounds.
+ if (z > m_zmin && z < m_zmax && r < m_rmax) {
+
+ // Convert to absolute value z and apply specified length unit.
+ double zc = fabs(z) / m_lunit;
+
+ //std::cout << "zc = " << zc << std::endl;
+
+ // Apply all coefficients to this z coordinate.
+ for (size_t i = 0; i < m_coeffs.size(); ++i) {
+ bx += m_coeffs[i] * pow(zc, i);
+ }
+
+ // Convert to specified field unit.
+ bx *= m_funit;
+
+ // Flip sign for negative z.
+ if (z < 0) {
+ bx = -bx;
+ }
+
+ // Add Bx to the input Bfield.
+ Bfield[0] += bx;
+ }
+
+ //std::cout << "AFTER --> bfield = " << Bfield[0] << " " << Bfield[1] << " " << Bfield[2] << std::endl << std::endl;
+ //std::cout << Point[2] << " " << Bfield[0] << std::endl;
+
+ return;
+}
+
+void G4Dipole::setZMax(double zmax)
+{
+ m_zmax = zmax;
+}
+
+double G4Dipole::getZMax()
+{
+ return m_zmax;
+}
+
+void G4Dipole::setZMin(double zmin)
+{
+ m_zmin = zmin;
+}
+
+double G4Dipole::getZMin()
+{
+ return m_zmin;
+}
+
+void G4Dipole::setRMax(double rmax)
+{
+ m_rmax = rmax;
+}
+
+double G4Dipole::getRMax()
+{
+ return m_rmax;
+}
+
+void G4Dipole::addCoeff(double coeff)
+{
+ m_coeffs.push_back(coeff);
+}
+
+const std::vector<double>& G4Dipole::getCoeffs()
+{
+ return m_coeffs;
+}
+
+void G4Dipole::setFieldUnit(double unit)
+{
+ m_funit = unit;
+}
+
+double G4Dipole::getFieldUnit()
+{
+ return m_funit;
+}
+
+void G4Dipole::setLengthUnit(double unit)
+{
+ m_lunit = unit;
+}
+
+double G4Dipole::getLengthUnit()
+{
+ return m_lunit;
+}
lcdd/src/lcdd/bfield
diff -N G4RZFieldMap.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4RZFieldMap.cc 26 Jun 2013 23:50:59 -0000 1.1
@@ -0,0 +1,275 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/bfield/G4RZFieldMap.cc,v 1.1 2013/06/26 23:50:59 jeremy Exp $
+
+// LCDD
+#include "lcdd/bfield/G4RZFieldMap.hh"
+
+// Geant4
+#include "globals.hh"
+
+// STL
+#include <cmath>
+
+// Set this preprocessor symbol for lots of debugging output.
+//#define FIELD_MAP_DEBUG 1
+
+#ifdef FIELD_MAP_DEBUG
+#include <iostream>
+using std::cout;
+using std::endl;
+#endif
+
+G4RZFieldMap::G4RZFieldMap(int numBinsR, int numBinsZ, double gridSizeR, double gridSizeZ, std::vector<RZBData> fieldData) :
+ m_numBinsR(numBinsR), m_numBinsZ(numBinsZ), m_gridSizeR(gridSizeR), m_gridSizeZ(gridSizeZ), m_BrArray(0), m_BzArray(0)
+{
+
+#ifdef FIELD_MAP_DEBUG
+ cout << "numBinsR=" << numBinsR << endl;
+ cout << "numBinsZ=" << numBinsZ << endl;
+ cout << "gridSizeR=" << gridSizeR << endl;
+ cout << "gridSizeZ=" << gridSizeZ << endl;
+#endif
+
+ if (numBinsR < 2) {
+ G4Exception("", "", FatalException, "numBinsR must be >= 2");
+ }
+
+ if (numBinsZ < 2) {
+ G4Exception("", "", FatalException, "numBinsZ must be >= 2");
+ }
+
+ if (gridSizeR <= 0) {
+ G4Exception("", "", FatalException, "gridSizeR must be >= 0");
+ }
+
+ if (gridSizeZ <= 0) {
+ G4Exception("", "", FatalException, "gridSizeZ must be >= 0");
+ }
+
+ m_maxR = (numBinsR - 1) * m_gridSizeR;
+ m_maxZ = (numBinsZ - 1) * m_gridSizeZ;
+
+ initializeArrays();
+ fillArrays(fieldData);
+}
+
+void G4RZFieldMap::initializeArrays()
+{
+ // Make two 2D arrays of numBinsZ x numBinsR
+ m_BrArray = new double*[m_numBinsZ];
+ m_BzArray = new double*[m_numBinsZ];
+
+ for (int i = 0; i < m_numBinsZ; i++) {
+ m_BrArray[i] = new double[m_numBinsR];
+ m_BzArray[i] = new double[m_numBinsR];
+ }
+
+ // Initialize arrays to all 0's.
+ for (int i = 0; i < m_numBinsZ; i++) {
+ for (int j = 0; j < m_numBinsR; j++) {
+ m_BrArray[i][j] = 0;
+ m_BzArray[i][j] = 0;
+ }
+ }
+}
+
+void G4RZFieldMap::fillArrays(std::vector<RZBData> fieldData)
+{
+ for (std::vector<RZBData>::iterator iter = fieldData.begin(); iter != fieldData.end(); iter++) {
+ RZBData rzb = *iter;
+
+ int iz = (int) ((rzb.z() + 0.0001) / m_gridSizeZ);
+ iz = iz;
+ int ir = (int) ((rzb.r() + 0.0001) / m_gridSizeR);
+ ir = ir;
+
+ m_BzArray[iz][ir] = rzb.Bz();
+ m_BrArray[iz][ir] = rzb.Br();
+
+#ifdef FIELD_MAP_DEBUG
+ cout << "ir iz = " << ir << " " << iz << endl;
+ cout << "Br Bz = " << m_BrArray[iz][ir] << " " << m_BzArray[iz][ir] << endl;
+ cout << endl;
+#endif
+ }
+}
+
+G4RZFieldMap::~G4RZFieldMap()
+{
+ deleteArrays();
+}
+
+void G4RZFieldMap::deleteArrays()
+{
+ for (int i = 0; i < m_numBinsZ; i++) {
+ delete[] m_BrArray[i];
+ delete[] m_BzArray[i];
+ }
+ delete[] m_BrArray;
+ delete[] m_BzArray;
+}
+
+/**
+ * Compute B field at given point using the arrays of Br and Bz field strengths.
+ *
+ * This function is based on Takashi's FORTRAN code at
+ *
+ * /afs/slac/www/accel/nlc/local/systems/beamdelivery/geant/SDNEW/solenoid.f
+ *
+ * via the RZBFieldProvider.cpp test code provided by Norman.
+ *
+ */
+void G4RZFieldMap::GetFieldValue(const double Point[3], double *Bfield) const
+{
+#ifdef FIELD_MAP_DEBUG
+ cout << "Point = " << Point[0] << " " << Point[1] << " " << Point[2] << endl;
+#endif
+
+ double r = sqrt((Point[0] * Point[0]) + (Point[1] * Point[1]));
+ double z = Point[2];
+
+ double hz = 0;
+ double hr = 0;
+
+ // Check for z or r out of range.
+ if (fabs(z) >= m_maxZ || r >= m_maxR) {
+#ifdef FIELD_MAP_DEBUG
+ cout << "OUT OF RANGE: z r = " << fabs(z) << " " << r << endl;
+ cout << "MAX: maxZ maxR " << m_maxZ << " " << m_maxR << endl;
+#endif
+ return;
+ }
+
+ // Compute z bin.
+ int iz = (int) ((fabs(z) + 0.001) / m_gridSizeZ);
+
+ // Compute r bin.
+ int ir = (int) ((r + 0.001) / m_gridSizeR);
+
+ // Adjust for iz out of range.
+// int izfar = 0;
+// if( iz >= m_numBinsZ-1 ) {
+// izfar = 1;
+// iz = m_numBinsZ - 1;
+// }
+
+// Check for iz < 0.
+ if (iz < 0) {
+#ifdef FIELD_MAP_DEBUG
+ cout << "ERROR: iz < 0" << endl;
+ cout << "iz=" << iz << endl;
+ cout << "returning" << endl;
+#endif
+ }
+
+// Check for Z overflow on iz+1.
+ if (iz + 1 >= m_numBinsZ) {
+#ifdef FIELD_MAP_DEBUG
+ cout << "ERROR: iz overflow" << endl;
+ cout << "iz=" << iz << endl;
+ cout << "returning" << endl;
+#endif
+ return;
+ }
+
+ // Check for R overflow on ir+1.
+ if (ir + 1 >= m_numBinsR) {
+#ifdef FIELD_MAP_DEBUG
+ cout << "ERROR: ir overflow" << endl;
+ cout << "ir=" << ir << endl;
+ cout << "returning" << endl;
+#endif
+ return;
+ }
+
+#ifdef FIELD_MAP_DEBUG
+ cout << "dz " << m_gridSizeZ << " dr " << m_gridSizeR << endl;
+ cout << "z " << z << " r " << r << endl;
+ cout << "iz " << iz << " ir " << ir << endl;
+#endif
+
+ double bz0 = m_BzArray[iz][ir];
+ double br0 = m_BrArray[iz][ir];
+
+#ifdef FIELD_MAP_DEBUG
+ cout << "bz0 " << bz0 << " br0 " << br0 << endl;
+#endif
+
+ double delz = 0.;
+ double delr = 0.;
+
+ double brdz = 0.;
+ double brdr = 0.;
+
+ if (r > 0.0) {
+ delr = r - float(ir) * m_gridSizeR;
+
+#ifdef FIELD_MAP_DEBUG
+ if ( iz+1 == m_gridSizeZ-1 ) {
+ cout << "WARNING: iz+1 == gridSizeZ-1" << endl;
+ }
+
+ if ( ir+1 == m_gridSizeR-1 ) {
+ cout << "WARNING: ir+1 == gridSizeR-1" << endl;
+ }
+#endif
+
+#ifdef FIELD_MAP_DEBUG
+ cout << "checking brarray access ..." << endl;
+ cout << "iz+1=" << iz+1 << endl;
+ cout << "ir=" << ir << endl;
+ cout << m_BrArray[iz+1][ir] << endl;
+ cout << "m_BrArray[iz+1][ir] is ok" << endl;
+ cout << "iz=" << iz << endl;
+ cout << "ir+1=" << ir+1 << endl;
+ cout << m_BrArray[iz][ir+1] << endl;
+ cout << "m_BrArray[iz][ir+1] is ok" << endl;
+ cout << "done" << endl;
+#endif
+
+ brdz = (m_BrArray[iz + 1][ir] - br0) / m_gridSizeZ;
+ brdr = (m_BrArray[iz][ir + 1] - br0) / m_gridSizeR;
+#ifdef FIELD_MAP_DEBUG
+ cout << "br= " << m_BrArray[iz+1][ir] << " " << m_BrArray[iz][ir+1] << endl;
+#endif
+ }
+
+ delz = fabs(z) - float(iz) * m_gridSizeZ;
+
+#ifdef FIELD_MAP_DEBUG
+ cout << " z " << z << " abs(z) " << fabs(z) << " iz " << iz << endl;
+ cout << " float(iz-1) " << float(iz-1) << " dz " << m_gridSizeZ << endl;
+ cout << " delz " << delz << endl;
+#endif
+
+ double bzdz = (m_BzArray[iz + 1][ir] - bz0) / m_gridSizeZ;
+ double bzdr = (m_BzArray[iz][ir + 1] - bz0) / m_gridSizeR;
+
+#ifdef FIELD_MAP_DEBUG
+ cout << "bz= " << m_BzArray[iz+1][ir] << " " << m_BzArray[iz][ir+1] << endl;
+#endif
+
+// if(izfar==1) {
+// hz = bz0+bzdr*delr;
+// hr = br0+brdr*delr;
+// }
+// else {
+ hz = bz0 + bzdz * delz + bzdr * delr;
+ hr = br0 + brdz * delz + brdr * delr;
+// }
+
+ if (z < 0.0)
+ hr = -hr;
+
+ double theta = atan2(Point[1], Point[0]);
+ double hx = hr * cos(theta);
+ double hy = hr * sin(theta);
+
+ Bfield[0] += hx;
+ Bfield[1] += hy;
+ Bfield[2] += hz;
+
+#ifdef FIELD_MAP_DEBUG
+ cout << "Bfield XYZ = " << Bfield[0] << " " << Bfield[1] << " " << Bfield[2] << endl;
+ cout << endl;
+#endif
+}
lcdd/src/lcdd/bfield
diff -N G4Solenoid.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4Solenoid.cc 26 Jun 2013 23:50:59 -0000 1.1
@@ -0,0 +1,49 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/bfield/G4Solenoid.cc,v 1.1 2013/06/26 23:50:59 jeremy Exp $
+
+// LCDD
+#include "lcdd/bfield/G4Solenoid.hh"
+
+// Geant4
+#include "globals.hh"
+
+G4Solenoid::G4Solenoid() :
+ _innerField(0), _outerField(0), _innerR(0), _outerR(0), _innerZ(0), _outerZ(0)
+{
+}
+
+G4Solenoid::~G4Solenoid()
+{
+}
+
+/**
+ * Apply simple solenoid magnetic field to the given Point.
+ */
+// TODO: use inner/outer Z
+void G4Solenoid::GetFieldValue(const double Point[3], double* Bfield) const
+{
+ //std::cout << "G4Solenoid::GetFieldValue" << std::endl;
+ //std::cout << "point: " << Point[0] << " " << Point[1] << " " << Point[2] << std::endl;
+ //std::cout << "BEFORE --> bfield " << Bfield[0] << " " << Bfield[1] << " " << Bfield[2] << std::endl;
+
+ double this_radius = sqrt(Point[0] * Point[0] + Point[1] * Point[1]);
+
+ if (this_radius < _innerR) {
+ Bfield[2] += _innerField;
+ } else if (this_radius < _outerR) {
+ Bfield[2] += _outerField;
+ }
+
+ //std::cout << "AFTER --> bfield = " << Bfield[0] << " " << Bfield[1] << " " << Bfield[2] << std::endl << std::endl;
+
+ return;
+}
+
+void G4Solenoid::printOut(std::ostream& os)
+{
+ os << "innerField <" << _innerField << ">" << std::endl;
+ os << "outerField <" << _outerField << ">" << std::endl;
+ os << "outerR <" << _outerR << ">" << std::endl;
+ os << "innerZ <" << _innerZ << ">" << std::endl;
+ os << "outerZ <" << _outerZ << ">" << std::endl;
+ os << std::endl;
+}
lcdd/src/lcdd/bfield
diff -N LCDDFieldManager.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ LCDDFieldManager.cc 26 Jun 2013 23:50:59 -0000 1.1
@@ -0,0 +1,95 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/bfield/LCDDFieldManager.cc,v 1.1 2013/06/26 23:50:59 jeremy Exp $
+
+// LCDD
+#include "lcdd/bfield/LCDDFieldManager.hh"
+#include "lcdd/core/LCDDProcessor.hh"
+
+LCDDFieldManager* LCDDFieldManager::m_instance = 0;
+
+LCDDFieldManager::~LCDDFieldManager()
+{
+}
+
+LCDDFieldManager* LCDDFieldManager::instance()
+{
+ if (m_instance == 0) {
+ m_instance = new LCDDFieldManager();
+ }
+ return m_instance;
+}
+
+MagneticFieldOverlay* LCDDFieldManager::makeOverlay(std::vector<G4MagneticField*> fields)
+{
+ MagneticFieldOverlay* overlay = new MagneticFieldOverlay();
+ for (std::vector<G4MagneticField*>::const_iterator iter = fields.begin(); iter != fields.end(); iter++) {
+ overlay->addMagneticField(*iter);
+ }
+ return overlay;
+}
+
+void LCDDFieldManager::setup()
+{
+ // Pointer to the field which will be passed to Geant4.
+ G4MagneticField* field = 0;
+
+ // Setup only the global fields specified in global_field.
+ if (m_globalfields.size() != 0) {
+ // Use specific list of global fields registered with LCDDFieldManager.
+ field = setup(m_globalfields);
+ }
+ // No global fields, so treat all fields registered with LCDDProcessor
+ // as global.
+ else {
+
+ // Build a list of fields that were registered with the LCDDProcessor.
+ std::vector<G4MagneticField*> fields;
+ LCDDProcessor* proc = LCDDProcessor::instance();
+ for (LCDDProcessor::MagneticFields::const_iterator iter = proc->getMagneticFieldsBegin(); iter != proc->getMagneticFieldsEnd(); iter++) {
+ fields.push_back(iter->second);
+ }
+
+ // Setup fields from LCDDProcessor.
+ field = setup(fields);
+ }
+
+ // Initialize the single or overlay field with Geant4.
+ initialize(field);
+}
+
+G4MagneticField* LCDDFieldManager::setup(std::vector<G4MagneticField*> fields)
+{
+ G4MagneticField* field = 0;
+ //if (fields.size() == 0) {
+ // G4cerr << "LCDDFieldManager - No magnetic fields to setup." << G4endl;
+ //}
+ //else if (fields.size() == 1) {
+ // field = fields[0];
+ //}
+ //else {
+ field = makeOverlay(fields);
+ //}
+ return field;
+}
+
+void LCDDFieldManager::initialize(G4MagneticField* field)
+{
+ if (field != 0) {
+ G4FieldManager* fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager();
+ fieldMgr->SetDetectorField(field);
+ fieldMgr->CreateChordFinder(field);
+ }
+}
+
+void LCDDFieldManager::addGlobalField(G4MagneticField* f)
+{
+ m_globalfields.push_back(f);
+}
+
+void LCDDFieldManager::addField(G4MagneticField* f)
+{
+ m_allfields.push_back(f);
+}
+
+LCDDFieldManager::LCDDFieldManager()
+{
+}
lcdd/src/lcdd/bfield
diff -N MagneticFieldOverlay.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MagneticFieldOverlay.cc 26 Jun 2013 23:50:59 -0000 1.1
@@ -0,0 +1,38 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/bfield/MagneticFieldOverlay.cc,v 1.1 2013/06/26 23:50:59 jeremy Exp $
+
+// LCDD
+#include "lcdd/bfield/MagneticFieldOverlay.hh"
+
+// STL
+#include <iostream>
+
+MagneticFieldOverlay::MagneticFieldOverlay()
+{
+}
+
+MagneticFieldOverlay::~MagneticFieldOverlay()
+{
+}
+
+void MagneticFieldOverlay::addMagneticField(G4MagneticField* field)
+{
+ if (field != 0) {
+ m_fields.push_back(field);
+ }
+}
+
+/**
+ * Call GetFieldValue of all G4MagneticField objects registered with this MagneticFieldOverlay.
+ */
+void MagneticFieldOverlay::GetFieldValue(const double Point[3], double *Bfield) const
+{
+ //std::cout << "MagneticFieldOverlay::GetFieldValue" << std::endl;
+
+ Bfield[0] = Bfield[1] = Bfield[2] = 0.;
+ for (std::vector<G4MagneticField*>::const_iterator iter = m_fields.begin(); iter != m_fields.end(); iter++) {
+ (*iter)->GetFieldValue(Point, Bfield);
+ }
+
+ //std::cout << "x y z: " << Point[0] << " " << Point[1] << " " << Point[2] << std::endl;
+ //std::cout << "bx, by, bz: " << Bfield[0] << " " << Bfield[1] << " " << Bfield[2] << std::endl << std::endl;
+}
lcdd/src/lcdd/core
diff -N G4StoreManager.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4StoreManager.cc 26 Jun 2013 23:50:59 -0000 1.1
@@ -0,0 +1,31 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/core/G4StoreManager.cc,v 1.1 2013/06/26 23:50:59 jeremy Exp $
+
+// LCDD
+#include "lcdd/core/G4StoreManager.hh"
+
+// Geant4
+#include "G4UIdirectory.hh"
+
+G4StoreManager *G4StoreManager::_instance = 0;
+
+G4StoreManager::G4StoreManager()
+{
+ G4UIdirectory* m_storesDir;
+ m_storesDir = new G4UIdirectory("/stores/");
+ m_storesDir->SetGuidance("Commands to inspect the Geant4 object stores. [LCDD]");
+}
+
+G4StoreManager::~G4StoreManager()
+{
+}
+
+G4StoreManager* G4StoreManager::instance()
+{
+ static G4StoreManager mgr;
+
+ if (!_instance) {
+ _instance = &mgr;
+ }
+
+ return _instance;
+}
lcdd/src/lcdd/core
diff -N GeometryManager.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ GeometryManager.cc 26 Jun 2013 23:50:59 -0000 1.1
@@ -0,0 +1,123 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/core/GeometryManager.cc,v 1.1 2013/06/26 23:50:59 jeremy Exp $
+
+// LCDD
+#include "lcdd/core/GeometryManager.hh"
+
+// LCDD
+#include "lcdd/geant4/G4UserRegionInformation.hh"
+#include "lcdd/core/G4StoreManager.hh"
+
+// GDML
+#include "G4Processor/GDMLProcessor.h"
+
+// Geant4
+#include "G4Run.hh"
+#include "G4LogicalVolume.hh"
+#include "G4VisAttributes.hh"
+#include "G4PVPlacement.hh"
+#include "G4LogicalVolumeStore.hh"
+#include "G4TransportationManager.hh"
+#include "G4Navigator.hh"
+
+GeometryManager* GeometryManager::m_instance = 0;
+
+GeometryManager::GeometryManager() :
+ m_worldRegionIsSetup(false)
+{
+ G4StoreManager::instance();
+}
+
+GeometryManager::~GeometryManager()
+{
+}
+
+GeometryManager* GeometryManager::instance()
+{
+ if (m_instance == 0) {
+ m_instance = new GeometryManager();
+ }
+
+ return m_instance;
+}
+
+void GeometryManager::beginRun(const G4Run*)
+{
+ // only setup world region info on first run
+ if (!m_worldRegionIsSetup) {
+ setupWorldRegionInformation();
+ }
+}
+
+G4LogicalVolume* GeometryManager::getWorldLogicalVolume() const
+{
+ //return GDMLProcessor::GetInstance()->GetWorldVolume()->GetLogicalVolume();
+ return getWorldPhysicalVolume()->GetLogicalVolume();
+}
+
+G4VPhysicalVolume* GeometryManager::getWorldPhysicalVolume() const
+{
+ return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
+}
+
+void GeometryManager::setupWorldRegionInformation()
+{
+ G4LogicalVolume* worldLV = getWorldLogicalVolume();
+
+ assert(worldLV);
+
+ G4UserRegionInformation* regInfo = new G4UserRegionInformation();
+ regInfo->setStoreSecondaries(false);
+ regInfo->setThreshold(0.0);
+
+ worldLV->GetRegion()->SetUserInformation(regInfo);
+ m_worldRegionIsSetup = true;
+}
+
+#ifdef HAVE_G4PVPLACEMENT_CHECKOVERLAPS
+
+void GeometryManager::checkOverlaps() const
+{
+ checkOverlaps(getWorldLogicalVolume(), true);
+}
+
+void GeometryManager::checkOverlaps(G4LogicalVolume* lvolume, bool recurse) const
+{
+ if (lvolume==0) return;
+
+ for (G4int i=0; i<lvolume->GetNoDaughters(); i++) {
+
+ G4PVPlacement* dau = static_cast<G4PVPlacement*>(lvolume->GetDaughter(i));
+
+ if (dau) {
+ // Check overlaps of daughters in mother.
+ dau->CheckOverlaps();
+
+ // Recursively check overlaps of daughters.
+ if (recurse) {
+ checkOverlaps(dau->GetLogicalVolume(), true);
+ }
+ }
+ }
+}
+
+void GeometryManager::checkOverlaps(const G4String& name, bool recurse) const
+{
+ G4LogicalVolumeStore* store = G4LogicalVolumeStore::GetInstance();
+ bool found=false;
+ for (std::vector<G4LogicalVolume*>::iterator it = store->begin();
+ it != store->end();
+ it++) {
+ G4LogicalVolume* vol = (*it);
+ if (vol->GetName() == name) {
+ checkOverlaps(vol, recurse);
+ found=true;
+ break;
+ }
+ }
+ if (!found) {
+ G4cerr << "WARNING: The logical volume named <" << name << "> was not found in the G4LogicalVolumeStore!" << std::endl;
+ }
+}
+
+#endif
+
lcdd/src/lcdd/core
diff -N LCDDDetectorConstruction.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ LCDDDetectorConstruction.cc 26 Jun 2013 23:50:59 -0000 1.1
@@ -0,0 +1,79 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/core/LCDDDetectorConstruction.cc,v 1.1 2013/06/26 23:50:59 jeremy Exp $
+
+// LCDD
+#include "lcdd/core/LCDDDetectorConstruction.hh"
+#include "lcdd/core/LCDDParser.hh"
+#include "lcdd/core/LCDDProcessor.hh"
+#include "lcdd/core/LCDDMessenger.hh"
+#include "lcdd/core/LCDDObjectStoreInspector.hh"
+#include "lcdd/util/GDMLWriterMessenger.hh"
+#include "lcdd/core/GeometryManager.hh"
+
+// Geant4
+#include "G4VPhysicalVolume.hh"
+#include "G4UImanager.hh"
+#include "G4Timer.hh"
+
+// std
+#include <cassert>
+
+LCDDDetectorConstruction::LCDDDetectorConstruction() :
+ m_world(0)
+{
+ // LCDD messenger
+ m_messenger = new LCDDMessenger();
+
+ // writer messenger
+ m_writerMessenger = new GDMLWriterMessenger();
+
+ // setup geo manager
+ GeometryManager::instance();
+
+ // setup parser if not already
+ LCDDParser::instance();
+
+ m_inspector = new LCDDObjectStoreInspector();
+}
+
+LCDDDetectorConstruction::~LCDDDetectorConstruction()
+{
+ delete m_inspector;
+ delete m_writerMessenger;
+ delete m_messenger;
+}
+
+G4VPhysicalVolume* LCDDDetectorConstruction::Construct()
+{
+ // start build timer
+ G4Timer geoTimer;
+ geoTimer.Start();
+
+ G4cout << "Started geometry construction timer." << G4endl;
+
+ // get geometry from the global parser instance, which will die on failure
+ G4VPhysicalVolume* pv = LCDDParser::instance()->construct();
+
+ // set world ptr
+ setWorldVolume(pv);
+
+ // stop build timer and print
+ geoTimer.Stop();
+ G4cout << "Geometry construction time: " << geoTimer << G4endl;
+
+ return pv;
+}
+
+void LCDDDetectorConstruction::setWorldVolume(G4VPhysicalVolume *pv)
+{
+ if (pv == 0) {
+ G4Exception("", "", FatalException, "PhysVol points to null.");
+ }
+
+ m_world = pv;
+}
+
+G4VPhysicalVolume* LCDDDetectorConstruction::getWorldVolume()
+{
+ return m_world;
+}
+
lcdd/src/lcdd/core
diff -N LCDDLibLoad.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ LCDDLibLoad.cc 26 Jun 2013 23:50:59 -0000 1.1
@@ -0,0 +1,110 @@
+#include "Saxana/SAXComponentFactory.h"
+
+#include <iostream>
+
+extern "C"
+{
+
+void LCDDLoadProcesses()
+{
+
+ // header
+ LOAD_COMPONENT(headerProcess);
+ LOAD_COMPONENT(detectorProcess);
+ LOAD_COMPONENT(authorProcess);
+ LOAD_COMPONENT(generatorProcess);
+ LOAD_COMPONENT(commentProcess);
+
+ // volume extended
+ LOAD_COMPONENT(volumeExtendedProcess);
+ LOAD_COMPONENT(physvolidProcess);
+
+ // SDs
+ LOAD_COMPONENT(calorimeterProcess);
+ LOAD_COMPONENT(optical_calorimeterProcess);
+ LOAD_COMPONENT(unsegmented_calorimeterProcess);
+ LOAD_COMPONENT(trackerProcess);
+ LOAD_COMPONENT(scorerProcess);
+ LOAD_COMPONENT(sdrefProcess);
+
+ // segmentations
+ LOAD_COMPONENT(grid_xyzProcess);
+ LOAD_COMPONENT(projective_cylinderProcess);
+ LOAD_COMPONENT(projective_zplaneProcess);
+ LOAD_COMPONENT(nonprojective_cylinderProcess);
+ LOAD_COMPONENT(global_grid_xyProcess);
+ LOAD_COMPONENT(cell_readout_2dProcess);
+
+ // Ids
+ LOAD_COMPONENT(idspecProcess);
+ LOAD_COMPONENT(idfieldProcess);
+ LOAD_COMPONENT(idspecrefProcess);
+
+ // field
+ LOAD_COMPONENT(fieldrefProcess);
+ LOAD_COMPONENT(global_fieldProcess);
+ LOAD_COMPONENT(solenoidProcess);
+ LOAD_COMPONENT(rz_field_mapProcess);
+ LOAD_COMPONENT(rzbProcess);
+ LOAD_COMPONENT(dipoleProcess);
+ LOAD_COMPONENT(dipole_coeffProcess);
+ LOAD_COMPONENT(box_dipoleProcess);
+ LOAD_COMPONENT(field_map_3dProcess)
+
+ // region
+ LOAD_COMPONENT(regionProcess);
+ LOAD_COMPONENT(regionrefProcess);
+
+ // display
+ LOAD_COMPONENT(visProcess);
+ LOAD_COMPONENT(visrefProcess);
+ LOAD_COMPONENT(colorProcess);
+
+ // limit
+ LOAD_COMPONENT(limitsetProcess);
+ LOAD_COMPONENT(limitsetrefProcess);
+ LOAD_COMPONENT(limitProcess);
+}
+
+void LCDDLoadSubscribers()
+{
+ // subscribers
+ LOAD_COMPONENT(headerSubscriber);
+
+ // volume extended
+ //LOAD_COMPONENT(volumeExtendedSubscriber);
+
+ // SDs
+ LOAD_COMPONENT(calorimeterSubscriber);
+ LOAD_COMPONENT(optical_calorimeterSubscriber);
+ LOAD_COMPONENT(unsegmented_calorimeterSubscriber);
+ LOAD_COMPONENT(trackerSubscriber);
+ LOAD_COMPONENT(scorerSubscriber);
+
+ // Ids
+ LOAD_COMPONENT(idspecSubscriber);
+
+ // field
+ LOAD_COMPONENT(solenoidSubscriber);
+ LOAD_COMPONENT(rz_field_mapSubscriber);
+ LOAD_COMPONENT(dipoleSubscriber);
+ LOAD_COMPONENT(box_dipoleSubscriber);
+ LOAD_COMPONENT(global_fieldSubscriber);
+ LOAD_COMPONENT(field_map_3dSubscriber);
+
+ // region
+ LOAD_COMPONENT(regionSubscriber);
+
+ // display
+ LOAD_COMPONENT(visSubscriber);
+
+ // limit
+ LOAD_COMPONENT(limitsetSubscriber);
+}
+
+void LCDDLibLoad()
+{
+ LCDDLoadProcesses();
+ LCDDLoadSubscribers();
+}
+}
lcdd/src/lcdd/core
diff -N LCDDMessenger.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ LCDDMessenger.cc 26 Jun 2013 23:50:59 -0000 1.1
@@ -0,0 +1,167 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/core/LCDDMessenger.cc,v 1.1 2013/06/26 23:50:59 jeremy Exp $
+
+// LCDD
+#include "lcdd/core/LCDDMessenger.hh"
+#include "lcdd/core/LCDDParser.hh"
+#include "lcdd/core/GeometryManager.hh"
+#include "lcdd/util/NistElementsDump.hh"
+#include "lcdd/util/StringUtil.hh"
+
+// Geant4
+#include "G4UImessenger.hh"
+#include "G4UIcommand.hh"
+#include "G4UIdirectory.hh"
+
+// STL
+#include <cassert>
+
+LCDDMessenger::LCDDMessenger()
+{
+ // define UI commands
+ defineCommands();
+}
+
+LCDDMessenger::~LCDDMessenger()
+{
+ delete m_setupCmd;
+ delete m_setURICmd;
+ delete m_setSetupNameCmd;
+ delete m_setVersionCmd;
+ delete m_lcddDir;
+}
+
+void LCDDMessenger::SetNewValue(G4UIcommand *cmd, G4String newVals)
+{
+ LCDDParser* parser = LCDDParser::instance();
+
+ G4String singleArg = newVals;
+ std::istringstream is((const char*) newVals);
+
+ if (cmd == m_setURICmd) {
+ parser->setURI(singleArg);
+ } else if (cmd == m_setSetupNameCmd) {
+ parser->setSetupName(singleArg);
+ } else if (cmd == m_setVersionCmd) {
+ parser->setVersion(singleArg);
+ } else if (cmd == m_setupCmd) {
+ G4String uri, setup, version;
+
+ is >> uri >> setup >> version;
+
+ parser->setURI(uri);
+ parser->setSetupName(setup);
+ parser->setVersion(version);
+ } else if (cmd == m_dumpCmd) {
+ //std::cout<<"arg: "<<singleArg<<std::endl;
+ NistElementsDump::writeXml(singleArg);
+ }
+#ifdef HAVE_G4PVPLACEMENT_CHECKOVERLAPS
+ else if (cmd==m_checkOverlapsCmd || cmd==m_checkOverlapsRecurseCmd)
+ {
+
+ bool recurse=false;
+
+ if (cmd == m_checkOverlapsRecurseCmd)
+ {
+ recurse=true;
+ }
+
+ G4String vol("");
+ is >> vol;
+
+ G4cout << "vol=" << vol << G4endl;
+ G4cout << "recurse=" << recurse << G4endl;
+
+ if (newVals != "")
+ {
+ // Check the named volume with optional recursion.
+ GeometryManager::instance()->checkOverlaps(vol, recurse);
+ }
+ else
+ {
+ // No volume. Check the world, which is always done recursively!
+ GeometryManager::instance()->checkOverlaps();
+ }
+ }
+#endif
+ else {
+ G4cerr << "WARNING: Unknown cmd to LCDDMessenger - " << cmd << G4endl;
+ }
+}
+
+G4String LCDDMessenger::GetCurrentValue(G4UIcommand *)
+{
+ return G4String("");
+}
+
+void LCDDMessenger::defineCommands()
+{
+ G4UIparameter *p;
+
+ // LCDD directory
+ m_lcddDir = new G4UIdirectory("/lcdd/");
+ m_lcddDir->SetGuidance("XML detector description and geometry commands. [LCDD]");
+
+ // set URL for input geometry file
+ m_setURICmd = new G4UIcommand("/lcdd/url", this);
+ m_setURICmd->SetGuidance("Set the Uniform Resource Locator (URL) for the input geometry file.");
+ m_setURICmd->AvailableForStates(G4State_PreInit);
+
+ p = new G4UIparameter("URI", 's', false);
+ m_setURICmd->SetParameter(p);
+
+ // set name of GDML setup
+ m_setSetupNameCmd = new G4UIcommand("/lcdd/setupName", this);
+ m_setSetupNameCmd->SetGuidance("Set GDML setup name.");
+ m_setSetupNameCmd->AvailableForStates(G4State_PreInit);
+
+ p = new G4UIparameter("SetupName", 's', false);
+ m_setSetupNameCmd->SetParameter(p);
+
+ // set version of GDML setup
+ m_setVersionCmd = new G4UIcommand("/lcdd/version", this);
+ m_setVersionCmd->SetGuidance("Set GDML version tag.");
+ m_setVersionCmd->AvailableForStates(G4State_PreInit);
+
+ p = new G4UIparameter("Version", 's', false);
+ m_setVersionCmd->SetParameter(p);
+
+ // setup URI, Setup and Version in one command
+ m_setupCmd = new G4UIcommand("/lcdd/setup", this);
+ m_setupCmd->SetGuidance("Set URI, SetupName and Version with a single command.");
+ m_setupCmd->AvailableForStates(G4State_PreInit);
+
+ p = new G4UIparameter("URI", 's', false);
+ p->SetGuidance("URI is a URL to the input file. It MUST NOT contain unescaped spaces.");
+ m_setupCmd->SetParameter(p);
+
+ p = new G4UIparameter("SetupName", 's', true);
+ m_setupCmd->SetParameter(p);
+
+ p = new G4UIparameter("Version", 's', true);
+ m_setupCmd->SetParameter(p);
+
+ m_dumpCmd = new G4UIcommand("/lcdd/dumpNistElements", this);
+ m_dumpCmd->SetGuidance("Dump NIST elements to file as GDML fragment, including lambda and X0.");
+ p = new G4UIparameter("Filename", 's', true);
+ p->SetDefaultValue("NistElements.xml");
+ m_dumpCmd->SetParameter(p);
+
+#ifdef HAVE_G4PVPLACEMENT_CHECKOVERLAPS
+ // Check overlaps.
+ m_checkOverlapsCmd = new G4UIcommand("/lcdd/checkOverlaps",this);
+ m_checkOverlapsCmd->SetGuidance("Call CheckOverlaps on a given volume or the world volume (no arguments).");
+
+ p = new G4UIparameter("Volume",'s',true);
+ p->SetDefaultValue("");
+ m_checkOverlapsCmd->SetParameter(p);
+
+ // Check overlaps with recursion to daughters.
+ m_checkOverlapsRecurseCmd = new G4UIcommand("/lcdd/checkOverlapsRecurse",this);
+ m_checkOverlapsRecurseCmd->SetGuidance("Call CheckOverlaps on a given volume and recursively check daughters.");
+
+ p = new G4UIparameter("Volume",'s',true);
+ p->SetDefaultValue("");
+ m_checkOverlapsRecurseCmd->SetParameter(p);
+#endif
+}
lcdd/src/lcdd/core
diff -N LCDDParser.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ LCDDParser.cc 26 Jun 2013 23:50:59 -0000 1.1
@@ -0,0 +1,172 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/core/LCDDParser.cc,v 1.1 2013/06/26 23:50:59 jeremy Exp $
+
+// LCDD
+#include "lcdd/core/LCDDParser.hh"
+#include "lcdd/bfield/LCDDFieldManager.hh"
+#include "lcdd/subscribers/volumeExtendedSubscriber.hh"
+
+// GDML
+#include "G4Processor/GDMLProcessor.h"
+#include "Saxana/SAXComponentFactoryTable.h"
+#include "Saxana/RCObjectHandle.h"
+#include "Saxana/SAXSubscriber.h"
+#include "Saxana/SAXSubscriberPool.h"
+
+// Geant4
+#include "G4VPhysicalVolume.hh"
+
+extern "C" void LCDDLibLoad();
+
+LCDDParser* LCDDParser::m_instance = 0;
+
+LCDDParser::LCDDParser() :
+ m_URI(""), m_setupName(""), m_version(""), m_initialized(false), m_constructed(false), m_setURI(false)
+{
+}
+
+LCDDParser* LCDDParser::instance()
+{
+ if (m_instance == 0) {
+ m_instance = new LCDDParser();
+ }
+
+ return m_instance;
+}
+
+LCDDParser::~LCDDParser()
+{
+ finalize();
+}
+
+void LCDDParser::setupParserConfig()
+{
+ setupParserConfig(m_URI, m_setupName, m_version);
+}
+
+void LCDDParser::setupParserConfig(const std::string& URI, const std::string&, const std::string& version)
+{
+ // settings from messenger commands
+ std::cout << "LCDD URI <" << m_URI << ">" << std::endl;
+ //std::cout << "SetupName <" << m_setupName << ">" << std::endl;
+ std::cout << "Version <" << m_version << ">" << std::endl;
+
+ // set configuration vals
+ m_config.SetURI(URI);
+ //m_config.SetSetupName(setupName);
+ m_config.SetSetupVersion(version);
+
+ // set config in parser
+ m_sxp.Configure(&m_config);
+}
+
+void LCDDParser::initializeParser()
+{
+ // standard SAX parser init
+ m_sxp.Initialize();
+
+ // load custom LCDD tag handlers
+ LCDDLibLoad();
+
+ addVolumeExtendedSubscriber();
+}
+
+void LCDDParser::initialize()
+{
+ if (!m_initialized) {
+ initializeParser();
+ m_initialized = true;
+ }
+}
+
+G4VPhysicalVolume* LCDDParser::construct()
+{
+ if (!m_constructed) {
+
+ // initialize
+ initialize();
+
+ // set GDML parser params from inst vars
+ setupParserConfig();
+
+ // run the parser
+ m_sxp.Run();
+
+ // get world volume from GDML
+ try {
+ m_world = (G4VPhysicalVolume*) GDMLProcessor::GetInstance()->GetWorldVolume();
+ } catch (std::exception& e) {
+ G4Exception("", "", FatalException, "Failed to get the world volume.");
+ }
+
+ // Setup magnetic field.
+ LCDDFieldManager::instance()->setup();
+
+ // This method should only be called once.
+ m_constructed = true;
+ } else {
+ std::cerr << "LCDD geometry was already constructed." << std::endl;
+ }
+
+ return m_world;
+}
+
+void LCDDParser::finalize()
+{
+ m_sxp.Finalize();
+}
+
+void LCDDParser::setURI(std::string URI)
+{
+ m_URI = URI;
+ m_setURI = true;
+}
+
+void LCDDParser::setSetupName(std::string setupName)
+{
+ m_setupName = setupName;
+}
+
+void LCDDParser::setVersion(std::string version)
+{
+ m_version = version;
+}
+
+const std::string& LCDDParser::URI()
+{
+ return m_URI;
+}
+
+const std::string& LCDDParser::setupName()
+{
+ return m_setupName;
+}
+
+const std::string& LCDDParser::version()
+{
+ return m_version;
+}
+
+void LCDDParser::setWorld(G4VPhysicalVolume *world)
+{
+ m_world = world;
+}
+
+bool LCDDParser::isValidSetup()
+{
+ bool valid = true;
+
+ if (!m_setURI) {
+ valid = false;
+ }
+
+ return valid;
+}
+
+void LCDDParser::addVolumeExtendedSubscriber()
+{
+ RCObjectHandle<SAXSubscriber> obj;
+ obj = new volumeExtendedSubscriber();
+ SAXSubscriberPool* pool = const_cast<SAXSubscriberPool*>(m_sxp.GetSubscriberPool());
+ pool->AddSubscriber("volume", obj);
+}
+
lcdd/src/lcdd/core
diff -N LCDDProcessor.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ LCDDProcessor.cc 26 Jun 2013 23:50:59 -0000 1.1
@@ -0,0 +1,220 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/core/LCDDProcessor.cc,v 1.1 2013/06/26 23:50:59 jeremy Exp $
+
+// LCDD
+#include "lcdd/core/LCDDProcessor.hh"
+#include "lcdd/bfield/LCDDFieldManager.hh"
+#include "lcdd/bfield/MagneticFieldOverlay.hh"
+
+// Geant4
+#include "G4TransportationManager.hh"
+#include "G4FieldManager.hh"
+#include "G4EventManager.hh"
+#include "G4Event.hh"
+#include "G4SDManager.hh"
+#include "G4HCtable.hh"
+
+LCDDProcessor* LCDDProcessor::sInstance = 0;
+
+LCDDProcessor::LCDDProcessor() :
+ m_header(0)
+{
+}
+
+LCDDProcessor::~LCDDProcessor()
+{
+ if (m_header != 0) {
+ delete m_header;
+ }
+}
+
+LCDDProcessor* LCDDProcessor::instance()
+{
+ if (sInstance == 0) {
+ sInstance = new LCDDProcessor;
+ }
+
+ return sInstance;
+}
+
+void LCDDProcessor::addSensitiveDetector(std::string& name, G4SensitiveDetector* sd)
+{
+ //std::cout << "adding SD: " << name << std::endl;
+ m_sensitiveDetectors[name] = sd;
+}
+
+G4SensitiveDetector* LCDDProcessor::getSensitiveDetector(const std::string& name)
+{
+ return m_sensitiveDetectors[name];
+}
+
+G4SensitiveDetector* LCDDProcessor::getSensitiveDetector(const char* name)
+{
+ std::string key = name;
+ return getSensitiveDetector(key);
+}
+
+LCDDProcessor::SensitiveDetectors::const_iterator LCDDProcessor::getSensitiveDetectorsBegin()
+{
+ return m_sensitiveDetectors.begin();
+}
+
+LCDDProcessor::SensitiveDetectors::const_iterator LCDDProcessor::getSensitiveDetectorsEnd()
+{
+ return m_sensitiveDetectors.end();
+}
+
+void LCDDProcessor::addMagneticField(std::string& name, G4MagneticField* mag)
+{
+ m_magneticFields[name] = mag;
+}
+
+void LCDDProcessor::addGlobalField(G4MagneticField* mag)
+{
+ LCDDFieldManager::instance()->addGlobalField(mag);
+}
+
+G4MagneticField* LCDDProcessor::getMagneticField(const std::string& name)
+{
+ return m_magneticFields[name];
+}
+
+G4MagneticField* LCDDProcessor::getMagneticField(const char* name)
+{
+ std::string key = name;
+ return getMagneticField(key);
+}
+
+LCDDProcessor::MagneticFields::const_iterator LCDDProcessor::getMagneticFieldsBegin()
+{
+ return m_magneticFields.begin();
+}
+
+LCDDProcessor::MagneticFields::const_iterator LCDDProcessor::getMagneticFieldsEnd()
+{
+ return m_magneticFields.end();
+}
+
+void LCDDProcessor::addRegion(std::string& name, G4Region* reg)
+{
+ m_regions[name] = reg;
+}
+
+G4Region* LCDDProcessor::getRegion(const std::string& name)
+{
+ return m_regions[name];
+}
+
+G4Region* LCDDProcessor::getRegion(const char* name)
+{
+ std::string key = name;
+ return getRegion(name);
+}
+
+LCDDProcessor::Regions::const_iterator LCDDProcessor::getRegionsBegin()
+{
+ return m_regions.begin();
+}
+
+LCDDProcessor::Regions::const_iterator LCDDProcessor::getRegionsEnd()
+{
+ return m_regions.end();
+}
+
+void LCDDProcessor::addVisAttributes(std::string& name, G4VisAttributes* vis)
+{
+ m_visAttributes[name] = vis;
+}
+
+G4VisAttributes* LCDDProcessor::getVisAttributes(const std::string& name)
+{
+ return m_visAttributes[name];
+}
+
+G4VisAttributes* LCDDProcessor::getVisAttributes(const char* name)
+{
+ std::string key = name;
+ return getVisAttributes(key);
+}
+
+LCDDProcessor::VisAttributes::const_iterator LCDDProcessor::getVisAttributesBegin()
+{
+ return m_visAttributes.begin();
+}
+
+LCDDProcessor::VisAttributes::const_iterator LCDDProcessor::getVisAttributesEnd()
+{
+ return m_visAttributes.end();
+}
+
+void LCDDProcessor::addLimitSet(std::string& name, G4LimitSet* lim)
+{
+ m_limitSets[name] = lim;
+}
+
+G4LimitSet* LCDDProcessor::getLimitSet(const std::string& name)
+{
+ return m_limitSets[name];
+}
+
+G4LimitSet* LCDDProcessor::getLimitSet(const char* name)
+{
+ std::string key = name;
+ return getLimitSet(key);
+}
+
+LCDDProcessor::LimitSets::const_iterator LCDDProcessor::getLimitSetsBegin()
+{
+ return m_limitSets.begin();
+}
+
+LCDDProcessor::LimitSets::const_iterator LCDDProcessor::getLimitSetsEnd()
+{
+ return m_limitSets.end();
+}
+
+const LCDDHeaderRecord* LCDDProcessor::getHeader() const
+{
+ return m_header;
+}
+
+void LCDDProcessor::setHeader(LCDDHeaderRecord* h)
+{
+ assert(h);
+ m_header = h;
+}
+
+std::string LCDDProcessor::getDetectorName() const
+{
+ std::string detTag;
+ if (m_header == 0) {
+ detTag = "UNKNOWN";
+ } else {
+ detTag = m_header->getDetectorName();
+ }
+ return detTag;
+}
+
+const LCDDProcessor::VisAttributes* LCDDProcessor::getVisAttributesStore() const
+{
+ return &m_visAttributes;
+}
+
+const LCDDProcessor::SensitiveDetectors* LCDDProcessor::getSensitiveDetectorStore() const
+{
+ return &m_sensitiveDetectors;
+}
+
+const LCDDProcessor::MagneticFields* LCDDProcessor::getMagneticFieldStore() const
+{
+ return &m_magneticFields;
+}
+
+const LCDDProcessor::Regions* LCDDProcessor::getRegionStore() const
+{
+ return &m_regions;
+}
+
+const LCDDProcessor::LimitSets* LCDDProcessor::getLimitSetStore() const
+{
+ return &m_limitSets;
+}
lcdd/src/lcdd/detectors
diff -N CalorimeterHitProcessor.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CalorimeterHitProcessor.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,75 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CalorimeterHitProcessor.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/CalorimeterHitProcessor.hh"
+
+// STL
+#include <iostream>
+
+// Geant4
+#include "G4NavigationHistory.hh"
+
+CalorimeterHitProcessor::CalorimeterHitProcessor(CellReadout* readout) :
+ m_readout(readout)
+{
+}
+
+CalorimeterHitProcessor::~CalorimeterHitProcessor()
+{
+}
+
+bool CalorimeterHitProcessor::processHits(G4Step* step)
+{
+ // Compute step mid-point.
+ G4ThreeVector midpoint = (0.5 * (step->GetPreStepPoint()->GetPosition() + step->GetPostStepPoint()->GetPosition()));
+
+ // DEBUG
+ //std::cout << "midpoint(x,y,z) = " << midpoint.x() << ", " << midpoint.y() << ", " << midpoint.z() << std::endl;
+
+ // Get the touchable handle from the step.
+ G4TouchableHandle touchable = step->GetPreStepPoint()->GetTouchableHandle();
+
+ // Compute local position using global position and touchable.
+ G4ThreeVector localPosition = touchable->GetHistory()->GetTopTransform().TransformPoint(midpoint);
+
+ // DEBUG
+ //std::cout << "localPosition(x,y,z) = " << localPosition.x() << ", " << localPosition.y() << ", " << localPosition.z() << std::endl;
+
+ // Get the cell ID from the position.
+ CellReadout::Position2D readoutPosition;
+ readoutPosition.first = localPosition.x();
+ readoutPosition.second = localPosition.y();
+ CellReadout::CellId cellId = m_readout->cellId(readoutPosition);
+
+ // DEBUG: print neighbors
+ //CellReadout::Neighbors neighbors = m_readout->neighbors(cellId);
+ //std::cout << "# neighbors = " << neighbors.size() << std::endl;
+ //for (CellReadout::Neighbors::iterator it = neighbors.begin(); it != neighbors.end(); ++it) {
+ // CellReadout::CellId neighborId = *it;
+ // std::cout << "neighbor(x,y) = " << neighborId[0] << ", " << neighborId[1] << std::endl;
+ //}
+
+ // DEBUG: print cell ID
+ //std::cout << "cellId(x,y) = " << cellId[0] << ", " << cellId[1] << std::endl;
+
+ // Get the local cell position from the cell ID.
+ CellReadout::Position2D cellPosition = m_readout->position(cellId);
+
+ // DEBUG: print local cell position
+ //std::cout << "cellPosition = " << cellPosition.first << ", " << cellPosition.second << std::endl;
+
+ // Transform local cell position to global.
+ G4ThreeVector cellVec(cellPosition.first, cellPosition.second, 0);
+
+ // Compute global position using local point and touchable.
+ G4ThreeVector globalPos = touchable->GetHistory()->GetTopTransform().Inverse().TransformPoint(cellVec);
+
+ // DEBUG: print global position
+ //std::cout << "globalPosition(x,y,z) = " << globalPos.x() << ", " << globalPos.x() << ", " << globalPos.z() << std::endl;
+ //std::cout << std::endl;
+
+ // TODO: make and return or store hit data from id, position, energy, & time
+ //G4CalorimeterHit* hit = new G4CalorimeterHit();
+
+ return true;
+}
lcdd/src/lcdd/detectors
diff -N CellReadout.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CellReadout.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,19 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CellReadout.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+#include "lcdd/detectors/CellReadout.hh"
+
+CellReadout::CellReadout()
+{
+}
+
+CellReadout::~CellReadout()
+{
+}
+
+/**
+ * Get the list of field names.
+ */
+const CellReadout::FieldNames& CellReadout::fieldNames()
+{
+ return m_fieldNames;
+}
lcdd/src/lcdd/detectors
diff -N CellReadout2D.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CellReadout2D.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,167 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CellReadout2D.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/CellReadout2D.hh"
+
+// STL
+#include <cmath>
+#include <iostream>
+#include <stdexcept>
+
+CellReadout2D::CellReadout2D(double cellSizeX, double cellSizeY)
+{
+ m_cellSizeX = cellSizeX;
+ m_cellSizeY = cellSizeY;
+
+ m_fieldNames.push_back("ix");
+ m_fieldNames.push_back("iy");
+}
+
+CellReadout2D::~CellReadout2D()
+{
+}
+
+CellReadout2D::Position2D CellReadout2D::position(CellReadout2D::CellId cellId)
+{
+ Position2D pos;
+ pos.first = getCellPositionX(cellId[0]);
+ pos.second = getCellPositionY(cellId[1]);
+ return pos;
+}
+
+CellReadout::CellId CellReadout2D::cellId(Position2D pos)
+{
+ return createCell(getXIndex(pos.first), getYIndex(pos.second));
+}
+
+/**
+ * Create a list of neighbor cells from a cell ID.
+ */
+CellReadout::Neighbors CellReadout2D::neighbors(CellId cellId)
+{
+ Neighbors neighbors;
+ int ix, iy;
+
+ // top left
+ ix = cellId[0] - 1;
+ if (ix == 0)
+ ix = -1;
+ iy = cellId[1] + 1;
+ if (iy == 0)
+ iy = 1;
+ neighbors.push_back(createCell(ix, iy));
+
+ // top middle
+ ix = cellId[0];
+ iy = cellId[1] + 1;
+ if (iy == 0)
+ iy = 1;
+ neighbors.push_back(createCell(ix, iy));
+
+ // top right
+ ix = cellId[0];
+ if (ix == 0)
+ ix = 1;
+ iy = cellId[1] + 1;
+ if (iy == 0)
+ iy = 1;
+ neighbors.push_back(createCell(ix, iy));
+
+ // middle left
+ ix = cellId[0] - 1;
+ if (ix == 0)
+ ix = -1;
+ iy = cellId[1];
+ neighbors.push_back(createCell(ix, iy));
+
+ // middle right
+ ix = cellId[0] + 1;
+ if (ix == 0)
+ ix = 1;
+ iy = cellId[1];
+ neighbors.push_back(createCell(ix, iy));
+
+ // bottom left
+ ix = cellId[0] - 1;
+ if (ix == 0)
+ ix = -1;
+ iy = cellId[1] - 1;
+ if (iy == 0)
+ iy = -1;
+ neighbors.push_back(createCell(ix - 1, iy - 1));
+
+ // bottom middle
+ ix = cellId[0];
+ iy = cellId[1] - 1;
+ if (iy == 0)
+ iy = -1;
+ neighbors.push_back(createCell(ix, iy - 1));
+
+ // bottom right
+ ix = cellId[0] + 1;
+ if (ix == 0)
+ ix = 1;
+ iy = cellId[1] - 1;
+ if (iy == 0)
+ iy = -1;
+ neighbors.push_back(createCell(ix, iy - 1));
+
+ return neighbors;
+
+}
+
+double CellReadout2D::getCellSizeX()
+{
+ return m_cellSizeX;
+}
+
+double CellReadout2D::getCellSizeY()
+{
+ return m_cellSizeY;
+}
+
+int CellReadout2D::getXIndex(double x)
+{
+ return getCellIndex(x, m_cellSizeX);
+}
+
+int CellReadout2D::getYIndex(double y)
+{
+ return getCellIndex(y, m_cellSizeY);
+}
+
+double CellReadout2D::getCellCoordinate(int i, double cellSize)
+{
+ double v = i * cellSize;
+ if (v > 0)
+ v -= cellSize / 2;
+ else
+ v += cellSize / 2;
+ return v;
+}
+
+int CellReadout2D::getCellIndex(double c, double cellSize)
+{
+ int v = std::ceil(c / cellSize);
+ if (v == 0)
+ v -= 1;
+ return v;
+}
+
+double CellReadout2D::getCellPositionX(int ix)
+{
+ return getCellCoordinate(ix, m_cellSizeX);
+}
+
+double CellReadout2D::getCellPositionY(int iy)
+{
+ return getCellCoordinate(iy, m_cellSizeY);
+}
+
+CellReadout2D::CellId CellReadout2D::createCell(int x, int y)
+{
+ CellId cell;
+ cell.push_back(x);
+ cell.push_back(y);
+ return cell;
+}
lcdd/src/lcdd/detectors
diff -N CellReadout2DSegmentation.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CellReadout2DSegmentation.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,82 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CellReadout2DSegmentation.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/CellReadout2DSegmentation.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+// Geant4
+#include "G4Step.hh"
+#include "G4Box.hh"
+
+// STL
+#include <cmath>
+
+CellReadout2DSegmentation::CellReadout2DSegmentation(double cellSizeX, double cellSizeY) :
+ G4Segmentation(G4Segmentation::eNonprojective, 2)
+{
+ m_readout = new CellReadout2D(cellSizeX, cellSizeY);
+ setBinNames();
+}
+
+CellReadout2DSegmentation::~CellReadout2DSegmentation()
+{
+ delete m_readout;
+}
+
+G4ThreeVector CellReadout2DSegmentation::getGlobalHitPos(const G4Step* aStep)
+{
+ // TODO: implement me
+}
+
+void CellReadout2DSegmentation::setBins(const G4Step* aStep)
+{
+ // Set state from current step.
+ setup(aStep);
+
+ // Compute the global mid-point of the step.
+ G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
+
+ // Compute the local step position from the global mid-point.
+ G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aStep, globalStepPos);
+
+ // Compute the X and Y readout coordinates from the local position.
+ CellReadout2D::Position2D localXY;
+ localXY.first = localStepPos.x();
+ localXY.second = localStepPos.y();
+ CellReadout2D::Position2D xy;
+ //= m_readout->localToReadoutCoordinates(localXY);
+
+ // Get the cell for the position.
+ CellReadout2D::CellId cell = m_readout->cellId(xy);
+
+ // Set bin values.
+ this->setBin(0, xy.first);
+ this->setBin(1, xy.second);
+}
+
+void CellReadout2DSegmentation::setBinNames()
+{
+ addBinName("ix");
+ addBinName("iy");
+}
+
+void CellReadout2DSegmentation::setup(const G4Step* aStep)
+{
+ // Set dimensions from box volume.
+ G4VSolid* solid = ReadoutUtil::getSolidFromStepPoint(aStep->GetPreStepPoint());
+ G4Box* box = dynamic_cast<G4Box*>(solid);
+ if (0 == box) {
+ std::cerr << "Volume is not a box" << std::endl;
+ G4Exception("", "", FatalException, "CellReadout2D points to shape that is not a box.");
+ }
+ //m_readout->setReadoutDimensionX(box->GetXHalfLength() * 2);
+ //m_readout->setReadoutDimensionY(box->GetYHalfLength() * 2);
+}
+
+CellReadout2D::Position2D CellReadout2DSegmentation::localToReadoutCoordinates(G4ThreeVector& vec)
+{
+ CellReadout2D::Position2D xy;
+ //xy.first = vec.x() + m_readout->getReadoutDimensionX() / 2.0;
+ //xy.second = vec.y() + m_readout->getReadoutDimensionY() / 2.0;
+ return xy;
+}
lcdd/src/lcdd/detectors
diff -N Cerenkov.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Cerenkov.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,161 @@
+///////////////////////////////////////////////////////////////////////
+// Class to calculate Number of photons created by Cerenkov Radiation
+////////////////////////////////////////////////////////////////////////
+// Hans Wenzel
+//
+// The algorithm is stripped from the geant 4 class
+// G4Cerenkov.cc
+// but since we are only interested in the number of photons created don't need to
+// actually create optical phtons and put them on the stack.
+//--------------------------------------------------------------------------------------
+
+// LCDD
+#include "lcdd/detectors/Cerenkov.hh"
+
+// Geant4
+#include "G4Step.hh"
+#include "G4ThreeVector.hh"
+
+#include <iomanip>
+
+Cerenkov::Cerenkov()
+{
+ Initialize();
+}
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+Cerenkov::~Cerenkov()
+{
+
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+void Cerenkov::Initialize()
+{
+ //
+ // now get the Cerenkov Angle Integrals for all materials that have the refraction index defined
+ //
+ const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
+ G4int numOfMaterials = G4Material::GetNumberOfMaterials();
+ for (G4int i = 0; i < numOfMaterials; i++) {
+ // Retrieve vector of refraction indices for the material
+ // from the material's optical properties table
+ G4Material* aMaterial = (*theMaterialTable)[i];
+ G4MaterialPropertiesTable* aMaterialPropertiesTable = aMaterial->GetMaterialPropertiesTable();
+ G4PhysicsOrderedFreeVector* CerAngleIntegrals = new G4PhysicsOrderedFreeVector();
+ if (aMaterialPropertiesTable) {
+ G4MaterialPropertyVector* theRefractionIndexVector = aMaterialPropertiesTable->GetProperty("RINDEX");
+ if (theRefractionIndexVector) {
+ // Retrieve the first refraction index in vector
+ // of (photon energy, refraction index) pairs
+ G4double currentRI = (*theRefractionIndexVector)[0];
+ if (currentRI > 1.0) {
+ // Create first (photon energy, Cerenkov Integral) pair
+ G4double currentPM = theRefractionIndexVector->Energy(0);
+ G4double currentCAI = 0.0;
+ CerAngleIntegrals->InsertValues(currentPM, currentCAI);
+ // Set previous values to current ones prior to loop
+ G4double prevPM = currentPM;
+ G4double prevCAI = currentCAI;
+ G4double prevRI = currentRI;
+ // loop over all (photon energy, refraction index)
+ // pairs stored for this material
+ for (size_t ii = 1; ii < theRefractionIndexVector->GetVectorLength(); ii++) {
+ currentRI = (*theRefractionIndexVector)[ii];
+ currentPM = theRefractionIndexVector->Energy(ii);
+ currentCAI = 0.5 * (1.0 / (prevRI * prevRI) + 1.0 / (currentRI * currentRI));
+ currentCAI = prevCAI + (currentPM - prevPM) * currentCAI;
+ CerAngleIntegrals->InsertValues(currentPM, currentCAI);
+ prevPM = currentPM;
+ prevCAI = currentCAI;
+ prevRI = currentRI;
+ }
+ }
+ G4cout << "Material: " << aMaterial->GetName() << G4endl;
+ G4cout << "Refraction Index: " << G4endl;
+ G4cout << "=================" << G4endl;
+ theRefractionIndexVector->DumpValues();
+ G4cout << "Cerenkov angle Integrals: " << G4endl;
+ G4cout << "=========================" << G4endl;
+ CerAngleIntegrals->DumpValues();
+ CAI.push_back(aMaterial->GetName());
+ CerenkovAngleIntegrals.push_back(CerAngleIntegrals);
+ RefractionIndeces.push_back(theRefractionIndexVector);
+ }
+ }
+ }
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+// This routine computes the number of Cerenkov photons produced per
+// GEANT-unit (millimeter) in the current medium.
+// ^^^^^^^^^^
+
+G4double Cerenkov::GetAverageNumberOfPhotons(const G4double charge, const G4double beta, const G4String Material) const
+{
+ G4bool Ceren = false;
+ G4int MaterialIndex = -1;
+ //
+ // check if optical properties are defined for this material:
+ //
+ for (unsigned int ii = 0; ii < CAI.size(); ii++) {
+ if (CAI[ii] == Material) {
+ MaterialIndex = ii;
+ Ceren = true;
+ break;
+ }
+ }
+ if (!Ceren)
+ return 0.0;
+ const G4double Rfact = 369.81 / (eV * cm);
+ if (beta <= 0.0)
+ return 0.0;
+ if (abs(charge) == 0.0)
+ return 0.0;
+
+ G4double BetaInverse = 1. / beta;
+ // Min and Max photon energies
+ G4double Pmin = RefractionIndeces[MaterialIndex]->GetMinLowEdgeEnergy();
+ G4double Pmax = RefractionIndeces[MaterialIndex]->GetMaxLowEdgeEnergy();
+
+ // Min and Max Refraction Indices
+ G4double nMin = RefractionIndeces[MaterialIndex]->GetMinValue();
+ G4double nMax = RefractionIndeces[MaterialIndex]->GetMaxValue();
+
+ // Max Cerenkov Angle Integral
+ G4double CAImax = CerenkovAngleIntegrals[MaterialIndex]->GetMaxValue();
+ G4double dp, ge;
+
+ // If n(Pmax) < 1/Beta -- no photons generated
+
+ if (nMax < BetaInverse) {
+ dp = 0;
+ ge = 0;
+ } // otherwise if n(Pmin) >= 1/Beta -- photons generated
+
+ else if (nMin > BetaInverse) {
+ dp = Pmax - Pmin;
+ ge = CAImax;
+ } // If n(Pmin) < 1/Beta, and n(Pmax) >= 1/Beta, then
+ // we need to find a P such that the value of n(P) == 1/Beta.
+ // Interpolation is performed by the GetEnergy() and
+ // Value() methods of the G4MaterialPropertiesTable and
+ // the GetValue() method of G4PhysicsVector.
+
+ else {
+ Pmin = RefractionIndeces[MaterialIndex]->GetEnergy(BetaInverse);
+ dp = Pmax - Pmin;
+
+ // need boolean for current implementation of G4PhysicsVector
+ // ==> being phased out
+ G4bool isOutRange;
+ G4double CAImin = CerenkovAngleIntegrals[MaterialIndex]->GetValue(Pmin, isOutRange);
+ ge = CAImax - CAImin;
+ }
+
+ // Calculate number of photons
+ G4double NumPhotons = Rfact * charge / eplus * charge / eplus * (dp - ge * BetaInverse * BetaInverse);
+ return NumPhotons;
+}
+
lcdd/src/lcdd/detectors
diff -N G4CalorimeterSD.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4CalorimeterSD.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,278 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/G4CalorimeterSD.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/G4CalorimeterSD.hh"
+#include "lcdd/detectors/G4Segmentation.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+#include "lcdd/detectors/PositionComparator.hh"
+#include "lcdd/hits/McpHitContrib.hh"
+#include "lcdd/id/IdFactory.hh"
+#include "lcdd/id/IdManager.hh"
+
+// Geant4
+#include "G4Track.hh"
+#include "G4StepPoint.hh"
+#include "G4Timer.hh"
+#include "G4Geantino.hh"
+
+// STL
+#include <iostream>
+#include <string>
+#include <vector>
+
+using std::vector;
+
+G4CalorimeterSD::G4CalorimeterSD(G4String sdName, G4String hcName, G4Segmentation* sdSeg, HitComparator* compare) :
+ G4SensitiveDetector(sdName, hcName, G4SensitiveDetector::eCalorimeter), m_segmentation(sdSeg)
+{
+ m_hitsCollections.push_back(m_collection);
+ m_hits.clear();
+ hits_vector.clear();
+ hits_vector.push_back(m_hits);
+ if (compare == 0)
+ m_hitCompare = new PositionComparator();
+ else
+ m_hitCompare = compare;
+}
+
+G4CalorimeterSD::G4CalorimeterSD(G4String sdName, const vector<G4String>& hcNames, G4Segmentation* sdSeg, HitComparator* compare) :
+ G4SensitiveDetector(sdName, hcNames, G4SensitiveDetector::eCalorimeter), m_segmentation(sdSeg)
+{
+ m_hits.clear();
+ hits_vector.clear();
+ hits_vector.push_back(m_hits);
+ for (int i = 0; i < (int) hcNames.size(); i++) {
+ hits_vector.push_back(m_hits);
+ hits_vector[i].clear();
+ m_hitsCollections.push_back(m_collection);
+ }
+
+ if (compare == 0) {
+ m_hitCompare = new PositionComparator();
+ } else {
+ m_hitCompare = compare;
+ }
+}
+
+G4CalorimeterSD::~G4CalorimeterSD()
+{
+}
+
+bool G4CalorimeterSD::isValidVolume(G4LogicalVolume* lv)
+{
+ bool valid = G4SensitiveDetector::isValidVolume(lv);
+
+ if (valid && m_segmentation != 0) {
+ valid = m_segmentation->isValidSolid(lv->GetSolid());
+ }
+
+ return valid;
+}
+
+void G4CalorimeterSD::Initialize(G4HCofThisEvent *HCE)
+{
+ clearHits();
+
+ // new cal hits collection
+ for (int i = 0; i < getNumberOfHitsCollections(); i++) {
+ m_hitsCollections[i] = new G4CalorimeterHitsCollection(GetName(), collectionName[i]);
+
+ // set HCID
+ if (getHCID(i) < 0) {
+ setHCID(GetCollectionID(i), i);
+ }
+
+ // add collection to HC of event
+ HCE->AddHitsCollection(getHCID(i), m_hitsCollections[i]);
+ }
+}
+
+G4Segmentation* G4CalorimeterSD::getSegmentation() const
+{
+ return m_segmentation;
+}
+
+G4bool G4CalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
+{
+#ifdef G4VERBOSE
+ if (getVerbose() > 0)
+ {
+ std::cout << "G4CalorimeterSD::ProcessHits - " << this->GetName() << std::endl;
+ }
+#endif
+
+ // set cached step
+ G4SensitiveDetector::ProcessHits(aStep, 0);
+
+ // get the edep
+ G4double theEdep = edep();
+
+ // This needs to be a <= comparison for cutting on 0,
+ // Geantinos, which always have 0 edep, are allowed.
+ if (theEdep <= getEcut() && !isGeantino()) {
+#ifdef G4VERBOSE
+ if (getVerbose() > 2) {
+ std::cout << "G4CalorimeterSD::ProcessHits - cut on edep " << theEdep << std::endl;
+ }
+#endif
+ return false;
+ }
+
+ // Get global cell pos from segmentation.
+ G4ThreeVector globalCellPos = m_segmentation->getGlobalHitPos(aStep);
+
+ // Reset the segmentation bin values.
+ m_segmentation->resetBins();
+
+ // Set the segmentation bin values from the step.
+ m_segmentation->setBins(aStep);
+
+ // Create a 64-bit ID.
+ Id64bit id64 = makeId();
+
+ // DEBUG: Compute step midpoint and compare to the cell pos
+#ifdef G4VERBOSE
+ if ( getVerbose() > 2 ) {
+ G4ThreeVector globalMidPos = midPosition();
+ std::cout << "globalMidPos " << globalMidPos << std::endl;
+ std::cout << "globalCellPos - globalMidPos = " << globalCellPos - globalMidPos << std::endl;
+ }
+#endif
+
+ // find hit by simple lkp of new hit with above info
+ G4CalorimeterHit* thisHit = new G4CalorimeterHit(theEdep, globalCellPos);
+ thisHit->setId64bit(id64.getId0(), id64.getId1());
+ G4CalorimeterHit* fndHit = 0;
+
+ // hit is not found?
+ if (!(fndHit = findHit(thisHit))) {
+
+#ifdef G4VERBOSE
+ if (getVerbose() > 1) {
+ std::cout << "G4CalorimeterSD::ProcessHits - new hit" << std::endl;
+ }
+#endif
+ // add it to lkp map
+ hits_vector[0].push_back(thisHit);
+
+ // add to the HC
+ m_hitsCollections[0]->insert(thisHit);
+ }
+ // found a hit
+ else {
+
+#ifdef G4VERBOSE
+ if ( getVerbose() > 2 ) {
+ std::cout << "G4CalorimeterSD::ProcessHits - existing hit" << std::endl;
+ }
+#endif
+
+ // don't need to insert thisHit, so delete it
+ delete thisHit;
+ thisHit = 0;
+
+ // incr total edep of the hit
+ fndHit->incrEdep(theEdep);
+
+ // for setting contrib
+ thisHit = fndHit;
+ }
+
+ // add McpHitContrib to this hit, setting info from step info
+ thisHit->addMcpHitContrib(McpHitContrib(aStep));
+
+ return true;
+}
+
+G4CalorimeterHit* G4CalorimeterSD::findHit(G4CalorimeterHit* aHit) const
+{
+ G4CalorimeterHit* fndHit = 0;
+ for (G4CalorimeterHitList::const_iterator iter = hits_vector[0].begin(); iter != hits_vector[0].end(); iter++) {
+ if (m_hitCompare->compare(**iter, *aHit)) {
+ fndHit = *iter;
+ break;
+ }
+ }
+ return fndHit;
+}
+
+G4CalorimeterHit* G4CalorimeterSD::findHit(G4CalorimeterHit* aHit, G4int nHC) const
+{
+ G4CalorimeterHit* fndHit = 0;
+ for (G4CalorimeterHitList::const_iterator iter = hits_vector[nHC].begin(); iter != hits_vector[nHC].end(); iter++) {
+ if (m_hitCompare->compare(**iter, *aHit)) {
+ fndHit = *iter;
+ break;
+ }
+ }
+ return fndHit;
+}
+
+std::ostream& G4CalorimeterSD::printHits(std::ostream& os)
+{
+ for (int i = 0; i < getNumberOfHitsCollections(); i++) {
+ os << getHitsCollection(i)->GetName() << std::endl;
+ for (G4CalorimeterHitList::const_iterator iter = hits_vector[i].begin(); iter != hits_vector[i].end(); iter++) {
+ os << " " << **iter;
+ }
+ }
+ os << std::endl;
+ return os;
+}
+
+void G4CalorimeterSD::EndOfEvent(G4HCofThisEvent *)
+{
+#ifdef G4VERBOSE
+ if ( getVerbose() > 1 ) {
+ printHits( std::cout );
+ }
+#endif
+}
+
+std::ostream& G4CalorimeterSD::printBasicInfo(std::ostream& os)
+{
+ G4SensitiveDetector::printBasicInfo(os);
+ os << "segmentation type: " << m_segmentation->getTypeString() << std::endl;
+ os << "segmentation bins:";
+ for (std::vector<std::string>::const_iterator it = m_segmentation->getBinNames().begin(); it != m_segmentation->getBinNames().end(); it++) {
+ os << " " << *it;
+ }
+ os << std::endl;
+ return os;
+}
+
+double G4CalorimeterSD::getEdep() const
+{
+ double edep = 0.0;
+ for (G4CalorimeterHitList::const_iterator it = hits_vector[0].begin(); it != hits_vector[0].end(); it++) {
+ edep += (*it)->getEdep();
+ }
+ return edep;
+}
+
+double G4CalorimeterSD::getEdep(G4int nHC) const
+{
+ double edep = 0.0;
+ for (G4CalorimeterHitList::const_iterator it = hits_vector[nHC].begin(); it != hits_vector[nHC].end(); it++) {
+ edep += (*it)->getEdep();
+ }
+ return edep;
+}
+
+void G4CalorimeterSD::clearHits()
+{
+ for (int i = 0; i < getNumberOfHitsCollections(); i++) {
+ hits_vector[i].clear();
+ }
+}
+
+G4CalorimeterSD::G4CalorimeterHitList G4CalorimeterSD::getCalorimeterHitList()
+{
+ return hits_vector[0];
+}
+
+G4CalorimeterSD::G4CalorimeterHitList G4CalorimeterSD::getCalorimeterHitList(G4int nHC)
+{
+ return hits_vector[nHC];
+}
+
lcdd/src/lcdd/detectors
diff -N G4GlobalGridXYSegmentation.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4GlobalGridXYSegmentation.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,71 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/G4GlobalGridXYSegmentation.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/G4GlobalGridXYSegmentation.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+// Geant4
+#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/lcdd/detectors
diff -N G4GridXYZSegmentation.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4GridXYZSegmentation.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,144 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/G4GridXYZSegmentation.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/G4GridXYZSegmentation.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+// Geant4
+#include "G4NavigationHistory.hh"
+
+G4GridXYZSegmentation::G4GridXYZSegmentation(double gridSizeX, double gridSizeY, double gridSizeZ) :
+ G4Segmentation(G4Segmentation::eNonprojective), m_gridSizeX(gridSizeX), m_gridSizeY(gridSizeY), m_gridSizeZ(gridSizeZ)
+{
+ setBinNames();
+}
+
+G4GridXYZSegmentation::~G4GridXYZSegmentation()
+{
+}
+
+G4ThreeVector G4GridXYZSegmentation::getGlobalHitPos(const G4Step* aStep)
+{
+ // compute midpoint
+ G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
+
+ // figure local step pos using touchable and global midpoint
+ G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aStep, globalStepPos);
+
+ // local cell pos
+ G4ThreeVector localCellPos = this->getLocalHitPos(localStepPos);
+
+ // global cell pos
+ G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal(aStep, localCellPos);
+
+ return globalCellPos;
+}
+
+void G4GridXYZSegmentation::setBins(const G4Step* aStep)
+{
+ // Compute the midpoint of the step.
+ G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
+
+ // Transform from global coordinate system to local coordinate system of volume pointed to by this step.
+ G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aStep, globalStepPos);
+
+ // Compute the bin values.
+ int binX = computeBinX(localStepPos);
+ int binY = computeBinY(localStepPos);
+ int binZ = computeBinZ(localStepPos);
+
+ // Set the bins.
+ int idx = 0;
+
+ setBin(idx, binX);
+ ++idx;
+
+ setBin(idx, binY);
+ ++idx;
+
+ setBin(idx, binZ);
+ ++idx;
+}
+
+int G4GridXYZSegmentation::computeBinX(const G4ThreeVector& localStepPos)
+{
+ int ret;
+ if (m_gridSizeX != 0) {
+ ret = G4Segmentation::computeBin(localStepPos.x(), m_gridSizeX);
+ } else {
+ ret = 0;
+ }
+ return ret;
+}
+
+int G4GridXYZSegmentation::computeBinY(const G4ThreeVector& localStepPos)
+{
+ int ret;
+ if (m_gridSizeY != 0) {
+ ret = G4Segmentation::computeBin(localStepPos.y(), m_gridSizeY);
+ } else {
+ ret = 0;
+ }
+ return ret;
+}
+
+int G4GridXYZSegmentation::computeBinZ(const G4ThreeVector& localStepPos)
+{
+ int ret;
+ if (m_gridSizeZ != 0) {
+ ret = G4Segmentation::computeBin(localStepPos.z(), m_gridSizeZ);
+ } else {
+ ret = 0;
+ }
+ return ret;
+}
+
+double G4GridXYZSegmentation::computeDimX(int bin)
+{
+ return G4Segmentation::computeDim(bin, m_gridSizeX);
+}
+
+double G4GridXYZSegmentation::computeDimY(int bin)
+{
+ return G4Segmentation::computeDim(bin, m_gridSizeY);
+}
+
+double G4GridXYZSegmentation::computeDimZ(int bin)
+{
+ 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/lcdd/detectors
diff -N G4NonprojectiveCylinderSegmentation.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4NonprojectiveCylinderSegmentation.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,260 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/G4NonprojectiveCylinderSegmentation.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/G4NonprojectiveCylinderSegmentation.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+// Geant4
+#include "G4Tubs.hh"
+
+// STL
+#include <cmath>
+
+G4NonprojectiveCylinderSegmentation::G4NonprojectiveCylinderSegmentation(double gridSizePhi, double gridSizeZ) :
+ G4Segmentation(G4Segmentation::eNonprojective), m_gridSizePhi(gridSizePhi), m_gridSizeZ(gridSizeZ)
+
+{
+ setBinNames();
+}
+
+G4NonprojectiveCylinderSegmentation::~G4NonprojectiveCylinderSegmentation()
+{
+}
+
+G4ThreeVector G4NonprojectiveCylinderSegmentation::getGlobalHitPos(const G4Step* aStep)
+{
+ // local cell pos
+ G4ThreeVector localCellPos = getLocalHitPos(aStep);
+
+ // global cell pos
+ G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal(aStep, localCellPos);
+
+ // DEBUG: print local, global cell pos
+ //G4cout << "localCellPos " << localCellPos << G4endl;
+ //G4cout << "globalCellPos " << globalCellPos << G4endl;
+ //
+
+ 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);
+
+ // retrieve G4Tubs
+ const G4Tubs* tubs = ReadoutUtil::getTubs(aStep);
+
+ assert(tubs);
+
+ // rcyl of cell = mid rad of current tubs
+ double rcyl = ReadoutUtil::computeTubsMidRadius(tubs);
+
+ // compute single delta phi in degrees
+ double deltaPhi = computeDeltaPhi(aStep);
+
+ // phi index
+ int iphi = computeBinPhi(aStep);
+
+ // z index in local
+ int iz = computeBinZ(ReadoutUtil::transformGlobalToLocal(aStep, globalMidPos));
+
+ // 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;
+}
+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)
+{
+ // mid radius of current tubs
+ double mid_rad_layer = ReadoutUtil::computeTubsMidRadius(aStep);
+
+ // 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;
+}
+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;
+
+ G4ThreeVector globalMidPos = ReadoutUtil::computeMidPos(aStep);
+
+ int bphi = computeBinPhi(aStep);
+ int bz = computeBinZ(globalMidPos);
+
+ 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);
+
+ const G4Tubs* tubs = ReadoutUtil::getTubs(aStep);
+ assert(tubs);
+
+ // compute single delta phi in degrees
+ double deltaPhi = computeDeltaPhi(aStep);
+
+ // step phi
+ double stepPhi = globalMidPos.phi();
+
+ if (stepPhi < 0) {
+ stepPhi += 2.0 * ReadoutUtil::PI;
+ }
+
+ // phi index
+ 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;
+ //G4cout << "m_gridSizeZ <" << m_gridSizeZ << ">" << G4endl;
+
+ return computeBin(localStepPos.z(), m_gridSizeZ);
+}
+
+bool G4NonprojectiveCylinderSegmentation::isValidSolid(G4VSolid* s)
+{
+ bool valid = G4Segmentation::isValidSolid(s);
+
+ if (valid) {
+ if (s->GetEntityType() != "G4Tubs") {
+ valid = false;
+ }
+ }
+
+ return valid;
+}
lcdd/src/lcdd/detectors
diff -N G4OpticalCalorimeter.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4OpticalCalorimeter.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,116 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/G4OpticalCalorimeter.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/G4OpticalCalorimeterSD.hh"
+#include "lcdd/detectors/G4Segmentation.hh"
+#include "lcdd/detectors/Cerenkov.hh"
+
+// Geant4
+#include "G4OpticalPhoton.hh"
+#include "G4TransportationManager.hh"
+#include "G4VProcess.hh"
+#include "G4Poisson.hh"
+
+using std::vector;
+
+/**
+ * Constructor for the case only one Hit Collection is given.
+ * In this case the only the energy deposited by aborbed Cerenkov
+ * photons is stored. Probably this will be dropped in the
+ * near future.
+ */
+G4OpticalCalorimeterSD::G4OpticalCalorimeterSD(G4String sdName, G4String hcName, G4Segmentation* sdSeg, HitComparator* compare) :
+ G4CalorimeterSD(sdName, hcName, sdSeg, compare)
+{
+ CerenGenerator = 0;
+}
+
+/**
+ * Constructor for multiple Hit Collections.
+ *
+ * The current implementation uses the first Hit Collection for the
+ * Cerenkov Photons and the second Collection to store the ionization losses.
+ * If more than 2 collections are given the additional Hit collections will
+ * be ignored.
+ */
+G4OpticalCalorimeterSD::G4OpticalCalorimeterSD(G4String sdName, const vector<G4String>& hcNames, G4Segmentation* sdSeg, HitComparator* compare) :
+ G4CalorimeterSD(sdName, hcNames, sdSeg, compare)
+{
+ CerenGenerator = 0;
+}
+
+G4OpticalCalorimeterSD::~G4OpticalCalorimeterSD()
+{
+}
+
+G4bool G4OpticalCalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory* tahis)
+{
+ if (!CerenGenerator)
+ CerenGenerator = new Cerenkov();
+ G4int NCerenPhotons = 0;
+ G4Track* theTrack = aStep->GetTrack();
+ const G4double charge = theTrack->GetDefinition()->GetPDGCharge();
+ G4StepPoint* pPreStepPoint = aStep->GetPreStepPoint();
+ G4StepPoint* pPostStepPoint = aStep->GetPostStepPoint();
+ G4double beta = 0.5 * (pPreStepPoint->GetBeta() + pPostStepPoint->GetBeta());
+ const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
+ G4String thematerial = touch->GetVolume()->GetLogicalVolume()->GetMaterial()->GetName();
+ G4double MeanNumberOfPhotons = CerenGenerator->GetAverageNumberOfPhotons(charge, beta, thematerial);
+ if (MeanNumberOfPhotons > 0.0) {
+ G4double step_length = aStep->GetStepLength();
+ MeanNumberOfPhotons = MeanNumberOfPhotons * step_length;
+ NCerenPhotons = (G4int) G4Poisson(MeanNumberOfPhotons);
+ } else {
+ NCerenPhotons = 0;
+ }
+
+ if (NCerenPhotons <= 0) {
+ return G4CalorimeterSD::ProcessHits(aStep, tahis);
+ } else {
+ G4SensitiveDetector::ProcessHits(aStep, 0);
+ 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;
+ G4cout << "Point of interaction = " << myPoint<< G4endl;
+ G4cout << "sdname " << GetName() << " hcname " <<collectionName[0]<< G4endl;
+ }
+ // total photon energy
+ // G4double theEdep = aTrack->GetTotalEnergy();
+ G4double theEdep = double(NCerenPhotons);
+ // get global cell pos from seg
+ G4ThreeVector globalCellPos = m_segmentation->getGlobalHitPosPreStep(apreStepPoint);
+ // reset the seg bins
+ m_segmentation->resetBins();
+ // set the seg bins
+ m_segmentation->setBins(aStep);
+ // create id and pack into 64
+ Id64bit id64 = makeId();
+ // find hit by simple lkp of new hit with above info
+ G4CalorimeterHit* thisHit = new G4CalorimeterHit(theEdep, globalCellPos);
+ thisHit->setId64bit(id64.getId0(), id64.getId1());
+ G4CalorimeterHit* fndHit = 0;
+ // hit is not found?
+ if (!(fndHit = findHit(thisHit, eCerenkov))) {
+ // add it to lkp map
+ hits_vector[eCerenkov].push_back(thisHit);
+ // add to the HC
+ m_hitsCollections[eCerenkov]->insert(thisHit);
+ } else {
+ // found a hit
+ // don't need to insert thisHit, so delete it
+ delete thisHit;
+ thisHit = 0;
+ // incr total edep of the hit
+ fndHit->incrEdep(theEdep);
+ // for setting contrib
+ thisHit = fndHit;
+ }
+ // add McpHitContrib to this hit, setting info from step info
+ thisHit->addMcpHitContrib(McpHitContrib(aStep));
+ // aTrack->SetTrackStatus(fStopAndKill); // don't step photon any further
+ return true;
+ } // end Cerenkov photon treatment
+}
lcdd/src/lcdd/detectors
diff -N G4ProjectiveCylinderSegmentation.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4ProjectiveCylinderSegmentation.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,68 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/G4ProjectiveCylinderSegmentation.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/G4ProjectiveCylinderSegmentation.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+// Geant4
+#include "G4StepPoint.hh"
+#include "G4NavigationHistory.hh"
+#include "G4VPhysicalVolume.hh"
+#include "G4LogicalVolume.hh"
+#include "G4Tubs.hh"
+
+G4ProjectiveCylinderSegmentation::G4ProjectiveCylinderSegmentation(G4int ntheta, G4int nphi) :
+ G4ProjectiveSegmentation(ntheta, nphi)
+{
+}
+
+G4ProjectiveCylinderSegmentation::~G4ProjectiveCylinderSegmentation()
+{
+}
+
+double G4ProjectiveCylinderSegmentation::getRadius(const G4Step* aStep)
+{
+ 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);
+
+ double ctheta = getThetaDim(aStep);
+
+ // ctheta in 0 to pi ...
+ // ctheta < pi/2 should be negative
+
+ double zcell = rcyl / tan(ctheta);
+
+ 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);
+
+ if (valid) {
+ if (s->GetEntityType() != "G4Tubs") {
+ valid = false;
+ }
+ }
+
+ return valid;
+}
lcdd/src/lcdd/detectors
diff -N G4ProjectiveSegmentation.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4ProjectiveSegmentation.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,238 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/G4ProjectiveSegmentation.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/G4ProjectiveSegmentation.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+// Geant4
+#include "G4StepPoint.hh"
+#include "G4NavigationHistory.hh"
+#include "G4VPhysicalVolume.hh"
+#include "G4LogicalVolume.hh"
+#include "G4Tubs.hh"
+
+G4ProjectiveSegmentation::G4ProjectiveSegmentation(G4int ntheta, G4int nphi) :
+ G4Segmentation(G4Segmentation::eProjective), m_ntheta(ntheta), m_nphi(nphi)
+{
+ //G4cout << "G4ProjectiveSegmentation" << G4endl;
+ //G4cout << "ntheta, nphi: " << ntheta << ", " << nphi << G4endl;
+
+ computeDivisions();
+
+ setBinNames();
+}
+
+G4ProjectiveSegmentation::~G4ProjectiveSegmentation()
+{
+}
+
+G4ThreeVector G4ProjectiveSegmentation::getGlobalHitPos(const G4Step* aStep)
+{
+ // 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(aStep);
+ double zcell = getZ(aStep);
+
+ // get phi component
+ double cphi = getPhiDim(aStep);
+
+ // 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;
+}
+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;
+}
+
+G4int G4ProjectiveSegmentation::getNphi() const
+{
+ return m_nphi;
+}
+
+void G4ProjectiveSegmentation::computeDivisions()
+{
+ m_divTheta = (180.0 * deg) / m_ntheta;
+ m_divPhi = (360.0 * deg) / m_nphi;
+}
+
+int G4ProjectiveSegmentation::getThetaBin(const G4ThreeVector& globalStepPos)
+{
+ // theta needs to be in range 0 - PI
+ return G4Segmentation::computeBin(globalStepPos.theta(), m_divTheta / radian);
+}
+
+int G4ProjectiveSegmentation::getPhiBin(const G4ThreeVector& globalStepPos)
+{
+
+ // adjust phi for < 0
+ double sphi = globalStepPos.phi();
+
+ if (sphi < 0.0) {
+ sphi += 360.0 * deg;
+ }
+
+ // needs more checks, for phi in range 0 - TWOPI
+ // if > TWOPI, then subtract TWOPI
+ //
+ // OR use X, Y for phi calc
+
+ // compute and return bin
+ return G4Segmentation::computeBin(sphi, m_divPhi / radian);
+}
+
+// default impl. returns mag of pos
+double G4ProjectiveSegmentation::getRadius(const G4Step* aStep)
+{
+ //G4cout << "G4ProjectiveSegmentation::getRadius()" << G4endl;
+
+ 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)
+{
+ //G4cout << "G4ProjectiveSegmentation::getZ()" << G4endl;
+ 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, m_divTheta);
+}
+
+double G4ProjectiveSegmentation::getPhiDim(const int &phiBin) const
+{
+ return G4Segmentation::computeDim(phiBin, m_divPhi);
+}
+
+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;
+
+ G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos(aStep);
+ 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/lcdd/detectors
diff -N G4ProjectiveZPlaneSegmentation.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4ProjectiveZPlaneSegmentation.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,41 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/G4ProjectiveZPlaneSegmentation.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/G4ProjectiveZPlaneSegmentation.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+G4ProjectiveZPlaneSegmentation::G4ProjectiveZPlaneSegmentation(G4int ntheta, G4int nphi) :
+ G4ProjectiveSegmentation(ntheta, nphi)
+{
+}
+
+G4ProjectiveZPlaneSegmentation::~G4ProjectiveZPlaneSegmentation()
+{
+}
+
+double G4ProjectiveZPlaneSegmentation::getRadius(const G4Step* aStep)
+{
+ double zcell = getZ(aStep);
+ double ctheta = G4ProjectiveSegmentation::getThetaDim(aStep);
+ double rcyl = zcell * tan(ctheta);
+ return rcyl;
+}
+double G4ProjectiveZPlaneSegmentation::getRadius(const G4StepPoint* aPreStepPoint)
+{
+ double zcell = getZ(aPreStepPoint);
+ double ctheta = G4ProjectiveSegmentation::getThetaDim(aPreStepPoint);
+ double rcyl = zcell * tan(ctheta);
+ return rcyl;
+}
+
+double G4ProjectiveZPlaneSegmentation::getZ(const G4Step* aStep)
+{
+ G4ThreeVector gpos = ReadoutUtil::getVolumeGlobalPosition(aStep->GetPreStepPoint(), G4ThreeVector());
+ return gpos.z();
+}
+
+double G4ProjectiveZPlaneSegmentation::getZ(const G4StepPoint* aPreStepPoint)
+{
+ G4ThreeVector gpos = ReadoutUtil::getVolumeGlobalPosition(aPreStepPoint, G4ThreeVector());
+ return gpos.z();
+}
lcdd/src/lcdd/detectors
diff -N G4ScorerSD.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4ScorerSD.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,98 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/G4ScorerSD.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/G4ScorerSD.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+#include "lcdd/hits/TrackInformation.hh"
+
+G4ScorerSD::G4ScorerSD(G4String sdName, G4String hcName) :
+ G4TrackerSD(sdName, hcName), m_currentTrackID(-1)
+{
+}
+
+G4bool G4ScorerSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
+{
+#ifdef G4VERBOSE
+ if ( m_verbose > 1 ) {
+ std::cout << "G4ScorerSD::ProcessHits() - " << this->GetName() << std::endl;
+ }
+#endif
+
+ G4SensitiveDetector::ProcessHits(aStep, 0);
+
+ bool sameTrack = false;
+
+#ifdef G4VERBOSE
+ if ( m_verbose > 3 ) {
+ std::cout << "current trackID <" << m_currentTrackID << ">" << std::endl;
+ }
+#endif
+
+ if ((m_currentTrackID == -1) || (m_currentTrackID != trackID())) {
+
+#ifdef G4VERBOSE
+ if ( m_verbose > 2 ) {
+ std::cout << "new track <" << trackID() << ">" << std::endl;
+ }
+#endif
+
+ m_currentTrackID = trackID();
+ } else {
+#ifdef G4VERBOSE
+ if ( m_verbose > 2 ) {
+ std::cout << "old track <" << trackID() << ">" << std::endl;
+ }
+#endif
+
+ sameTrack = true;
+ }
+
+ if (!sameTrack) {
+
+#ifdef G4VERBOSE
+ if ( m_verbose > 2 ) {
+ std::cout << "writing hit" << std::endl;
+ }
+#endif
+
+ // edep
+ G4double e = edep();
+
+ // get track information
+ TrackInformation* trkInfo = trackInformation();
+
+ // set hit flag in trk info
+ trkInfo->setHasTrackerHit(true);
+
+ // hit data
+ G4int trkID = trackID();
+ G4double tdep = globalTime();
+ G4ThreeVector prepos = prePosition();
+ G4ThreeVector meanmom = meanMomentum();
+
+ // create hit
+ G4TrackerHit* trkHit = new G4TrackerHit();
+
+ // create id vector
+ Id64bit id64 = makeId();
+
+ // set track hit info
+ trkHit->setTrackID(trkID);
+ trkHit->setEdep(e);
+ trkHit->setPos(prepos);
+ trkHit->setMomentum(meanmom);
+ trkHit->setTdep(tdep);
+ trkHit->setId(id64.getId0());
+ trkHit->setLength(ReadoutUtil::computeDistance(aStep));
+
+ // add to HC
+ m_HC->insert(trkHit);
+ } else {
+#ifdef G4VERBOSE
+ if ( m_verbose > 0 ) {
+ std::cout << "Skipping hit from track <" << m_currentTrackID << ">." << std::endl;
+ }
+#endif
+ }
+ return true;
+}
lcdd/src/lcdd/detectors
diff -N G4Segmentation.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4Segmentation.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,75 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/G4Segmentation.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/G4Segmentation.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+G4Segmentation::G4Segmentation(EType segType, int nbins) :
+ m_numBins(nbins), m_type(segType)
+{
+ // reserve nbins
+ m_bins.reserve(m_numBins);
+
+ // fill in 0 vals
+ resetBins();
+}
+
+G4Segmentation::~G4Segmentation()
+{
+}
+
+void G4Segmentation::setBin(int binIdx, int binVal)
+{
+ m_bins.insert(m_bins.begin() + binIdx, binVal);
+}
+
+int G4Segmentation::getNumberOfBins()
+{
+ return m_numBins;
+}
+
+const std::vector<int>& G4Segmentation::getBins()
+{
+ return m_bins;
+}
+
+G4Segmentation::EType G4Segmentation::getType()
+{
+ return m_type;
+}
+
+G4ThreeVector G4Segmentation::getGlobalHitPos(const G4Step* aStep)
+{
+ return ReadoutUtil::computeMidPos(aStep);
+}
+
+G4ThreeVector G4Segmentation::getGlobalHitPosPreStep(const G4StepPoint* aPreStepPoint)
+{
+ //G4Exception("Do not use this method!");
+ return aPreStepPoint->GetPosition();
+}
+
+void G4Segmentation::resetBins()
+{
+ m_bins.clear();
+}
+
+void G4Segmentation::printOutBins(std::ostream& os, const std::vector<int>& bins)
+{
+ os << "segmentationBins <" << bins.size() << "> :: ";
+ for (std::vector<int>::const_iterator iter = bins.begin(); iter != bins.end(); iter++) {
+ os << *iter << " ";
+ }
+ os << std::endl;
+}
+
+bool G4Segmentation::isValidSolid(G4VSolid* s)
+{
+ bool valid = true;
+
+ if (0 == s) {
+ valid = false;
+ }
+
+ return valid;
+}
lcdd/src/lcdd/detectors
diff -N G4SegmentationFactory.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4SegmentationFactory.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,172 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/G4SegmentationFactory.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/G4SegmentationFactory.hh"
+#include "lcdd/schema/grid_xyz.hh"
+#include "lcdd/schema/global_grid_xy.hh"
+#include "lcdd/schema/nonprojective_cylinder.hh"
+#include "lcdd/schema/projective_cylinder.hh"
+#include "lcdd/schema/projective_zplane.hh"
+#include "lcdd/schema/cell_readout_2d.hh"
+#include "lcdd/detectors/G4Segmentation.hh"
+#include "lcdd/detectors/G4GridXYZSegmentation.hh"
+#include "lcdd/detectors/G4GlobalGridXYSegmentation.hh"
+#include "lcdd/detectors/G4ProjectiveCylinderSegmentation.hh"
+#include "lcdd/detectors/G4ProjectiveZPlaneSegmentation.hh"
+#include "lcdd/detectors/G4NonprojectiveCylinderSegmentation.hh"
+#include "lcdd/detectors/CellReadout2DSegmentation.hh"
+
+// GDML
+#include "Saxana/SAXObject.h"
+#include "G4Processor/GDMLProcessor.h"
+#include "G4Evaluator/GDMLExpressionEvaluator.h"
+
+// STL
+#include <iostream>
+
+G4Segmentation* G4SegmentationFactory::createSegmentation(SAXObject* obj, const std::string& tag)
+{
+ G4Segmentation* seg = 0;
+ GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
+
+ if (tag == "projective_cylinder") {
+ 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;
+ }
+
+ } else if (tag == "grid_xyz") {
+ // GridXYZ
+ 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;
+ }
+ } else if (tag == "nonprojective_cylinder") {
+ // handle NP cylinder
+
+ //std::cout << "add nonprojective_cylinder here" << std::endl;
+
+ nonprojective_cylinder* np = dynamic_cast<nonprojective_cylinder*>(obj);
+ if (np) {
+
+ double gsp = 0;
+ double gsz = 0;
+
+ std::string lunit = np->get_lunit();
+
+ std::string sval = np->get_gridSizePhi();
+ sval += "*" + lunit;
+ gsp = 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;
+ }
+ } else if (tag == "projective_zplane") {
+ // handle projective_zplane
+
+ //std::cout << "add projective_zplane here" << std::endl;
+
+ projective_zplane* prj = dynamic_cast<projective_zplane*>(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);
+
+ //std::cout << "ntheta, nphi : "
+ // << ntheta << ", "
+ // << nphi << std::endl;
+
+ seg = new G4ProjectiveZPlaneSegmentation(ntheta, nphi);
+ } else {
+ std::cerr << "Failed cast to projective_zplane!" << std::endl;
+ } // prj no exist
+ } else if (tag == "cell_readout_2d") {
+
+ //std::cout << "building cell_readout_2d" << std::endl;
+
+ cell_readout_2d* elem = dynamic_cast<cell_readout_2d*>(obj);
+ if (0 != elem) {
+ double cellSizeX, cellSizeY;
+ cellSizeX = cellSizeY = 0;
+ std::string lengthUnit = elem->getLengthUnit();
+
+ std::string val = elem->getCellSizeX();
+ val += "*" + lengthUnit;
+ cellSizeX = calc->Eval(val);
+
+ val = elem->getCellSizeY();
+ val += "*" + lengthUnit;
+ cellSizeY = calc->Eval(val);
+
+ //std::cout << "G4SegmentationFactory creating CellReadout2DSegmentation(x,y): " << cellSizeX << " " << cellSizeY << std::endl;
+
+ seg = new CellReadout2DSegmentation(cellSizeX, cellSizeY);
+ }
+ } else {
+ // bad segmentation tag
+ std::cerr << "Unknown child tag for calorimeter: " << tag << "." << std::endl;
+ }
+
+ if (seg == 0) {
+ G4Exception("", "", FatalException, "Failed to create segmentation.");
+ }
+
+ return seg;
+}
lcdd/src/lcdd/detectors
diff -N G4SensitiveDetector.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4SensitiveDetector.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,186 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/G4SensitiveDetector.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/G4SensitiveDetector.hh"
+#include "lcdd/id/IdManager.hh"
+#include "lcdd/id/IdFactory.hh"
+#include "lcdd/detectors/SensitiveDetectorMessenger.hh"
+#include "lcdd/hits/TrackInformation.hh"
+
+// Geant4
+#include "G4EventManager.hh"
+#include "G4Event.hh"
+#include "G4SDManager.hh"
+#include "G4UImessenger.hh"
+#include "G4VHitsCollection.hh"
+#include "G4LogicalVolumeStore.hh"
+#include "G4UnitsTable.hh"
+
+// STL
+#include <iostream>
+#include <vector>
+
+using std::vector;
+
+const std::string& G4SensitiveDetector::trackerStr = "tracker";
+const std::string& G4SensitiveDetector::calorimeterStr = "calorimeter";
+const std::string& G4SensitiveDetector::noneStr = "none";
+
+G4SensitiveDetector::G4SensitiveDetector(G4String sdName, G4String hcName, EType sdType) :
+ G4VSensitiveDetector(sdName), m_idspec(0), m_type(sdType)
+{
+ // insert hits collection name into SD's name vector
+ collectionName.insert(hcName);
+
+ // register detector with G4SDManager
+ G4SDManager::GetSDMpointer()->AddNewDetector(this);
+
+ // Create the command messenger.
+ m_messenger = new SensitiveDetectorMessenger(this);
+
+ // Only one HC
+ m_hcids.clear();
+ m_hcids.push_back(-1);
+}
+
+G4SensitiveDetector::G4SensitiveDetector(G4String sdName, const vector<G4String>& hcNames, EType sdType) :
+ G4VSensitiveDetector(sdName), m_idspec(0), m_type(sdType)
+{
+ m_hcids.clear();
+
+ for (int i = 0; i < (int) hcNames.size(); i++) {
+ // insert hits collection name into SD's name vector
+ collectionName.insert(hcNames[i]);
+ m_hcids.push_back(-1);
+ }
+
+ // register detector with G4SDManager
+ G4SDManager::GetSDMpointer()->AddNewDetector(this);
+
+ // Create the command messenger.
+ m_messenger = new SensitiveDetectorMessenger(this);
+}
+
+G4SensitiveDetector::~G4SensitiveDetector()
+{
+}
+
+void G4SensitiveDetector::Initialize(G4HCofThisEvent *)
+{
+ // no-op
+}
+
+void G4SensitiveDetector::EndOfEvent(G4HCofThisEvent *)
+{
+ // no-op
+}
+
+G4bool G4SensitiveDetector::ProcessHits(G4Step* aStep, G4TouchableHistory*)
+{
+ // set cached step
+ setStep(aStep);
+
+ // doesn't write a hit
+ return false;
+}
+
+const std::string& G4SensitiveDetector::getTypeString() const
+{
+ if (m_type == eTracker) {
+ return trackerStr;
+ } else if (m_type == eCalorimeter) {
+ return calorimeterStr;
+ }
+ return noneStr;
+}
+
+std::ostream& G4SensitiveDetector::printBasicInfo(std::ostream& os)
+{
+ os << "name: " << GetName() << std::endl;
+ os << "type: " << m_type << std::endl;
+ os << "hits collection: " << this->getHCName() << std::endl;
+ os << "hits collection ID: " << m_hcids[0] << std::endl;
+ os << "energy cut: " << G4BestUnit(m_ecut, "Energy") << std::endl;
+ os << "endcap flag: " << m_endcap << std::endl;
+ os << "verbose level: " << m_verbose << std::endl;
+
+ if (m_idspec != 0) {
+ os << "id spec: " << m_idspec->getName() << std::endl;
+ os << "id fields:";
+ for (IdSpec::IdFields::const_iterator it = m_idspec->IdFieldsBegin(); it != m_idspec->IdFieldsEnd(); it++) {
+ os << " " << (*it)->getLabel();
+ }
+ os << std::endl;
+ } else {
+ os << "idspec points to null!" << std::endl;
+ }
+
+ return os;
+}
+
+Id64bit G4SensitiveDetector::makeId() const
+{
+ Id64bit id64;
+ if (hasIdSpec()) {
+
+ // get idvec ordered by this idspec
+ const IdVec ids = IdFactory::createOrderedIdVec(step(), this);
+
+ // pack into 64 bit cell id
+ id64 = IdFactory::createId64bit(ids, getIdSpec());
+ }
+ return id64;
+}
+
+G4VHitsCollection* G4SensitiveDetector::getHitsCollection() const
+{
+ G4VHitsCollection* hc = 0;
+ if (this->getHCID() != -1) {
+ hc = G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetHCofThisEvent()->GetHC(this->getHCID());
+ }
+ return hc;
+}
+
+G4VHitsCollection* G4SensitiveDetector::getHitsCollection(G4int nHC) const
+{
+ G4VHitsCollection* hc = 0;
+ if (this->getHCID(nHC) != -1) {
+ hc = G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetHCofThisEvent()->GetHC(this->getHCID(nHC));
+ }
+ return hc;
+}
+
+std::ostream& G4SensitiveDetector::printNumberOfHits(std::ostream& os)
+{
+ for (int i = 0; i < getNumberOfHitsCollections(); i++) {
+ os << getHitsCollection(i)->GetName() << " " << getHitsCollection(i)->GetSize() << std::endl;
+ }
+ return os;
+}
+
+std::ostream& G4SensitiveDetector::printEdep(std::ostream& os)
+{
+ os << "total edep: " << G4BestUnit(this->getEdep(), "Energy") << std::endl;
+ return os;
+}
+
+std::vector<G4LogicalVolume*> G4SensitiveDetector::getLogicalVolumes() const
+{
+ std::vector<G4LogicalVolume*> volumes;
+ for (G4LogicalVolumeStore::const_iterator it = G4LogicalVolumeStore::GetInstance()->begin(); it != G4LogicalVolumeStore::GetInstance()->end(); it++) {
+ if ((*it)->GetSensitiveDetector() == this) {
+ volumes.push_back(*it);
+ }
+ }
+ return volumes;
+}
+
+std::ostream& G4SensitiveDetector::printVolumes(std::ostream& os)
+{
+ std::vector<G4LogicalVolume*> volumes = this->getLogicalVolumes();
+
+ for (std::vector<G4LogicalVolume*>::const_iterator it = volumes.begin(); it != volumes.end(); it++) {
+ std::cout << (*it)->GetName() << std::endl;
+ }
+ return os;
+}
lcdd/src/lcdd/detectors
diff -N G4TrackerCombineSD.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4TrackerCombineSD.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,260 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/G4TrackerCombineSD.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/G4TrackerCombineSD.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+#include "lcdd/hits/TrackInformation.hh"
+
+G4TrackerCombineSD::G4TrackerCombineSD(G4String sdName, G4String hcName) :
+ G4TrackerSD(sdName, hcName), m_combineHits(false), m_currentTrackID(-1), m_currentPV(0), m_edepTotal(0), m_minTime(0), m_startedHit(false), m_currentTrack(false)
+{
+}
+
+G4TrackerCombineSD::~G4TrackerCombineSD()
+{
+}
+
+void G4TrackerCombineSD::EndOfEvent(G4HCofThisEvent *hce)
+{
+ G4TrackerSD::EndOfEvent(hce);
+ clear();
+}
+
+G4bool G4TrackerCombineSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
+{
+ // set cached step
+ G4SensitiveDetector::ProcessHits(aStep, 0);
+
+#ifdef G4VERBOSE
+ if (getVerbose() > 0) {
+ G4cout << "G4TrackerCombineSD::ProcessHits - " << GetName() << G4endl;
+ G4cout << "trackID - " << trackID() << G4endl;
+ G4cout << "particle - " << track()->GetDefinition()->GetParticleName() << G4endl;
+ G4cout << "edep - " << step()->GetTotalEnergyDeposit() << G4endl;
+ G4cout << "pre-physvol=" << aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName() << G4endl;
+ G4cout << "post-physvol=" << aStep->GetPostStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName() << G4endl;
+ if ( prePV() != postPV() ) {
+ G4cout << "post-pv != pre-pv" << G4endl;
+ }
+ }
+#endif
+
+ // Return value indicating whether a hit was inserted.
+ bool r = false;
+
+ // Started a hit already?
+ if (!m_startedHit) {
+
+ // If no hit, then start a new hit on the pre-step.
+ startHit(pre());
+ }
+
+ // Check if the cached trackID is valid.
+ if (m_currentTrackID != -1) {
+
+ // Is this step's trackID different from the cached trackID?
+ if (trackID() != m_currentTrackID) {
+
+#ifdef G4VERBOSE
+ if ( getVerbose() > 0 ) {
+ G4cout << "new track ID this step!" << G4endl;
+ }
+#endif
+
+ // Insert the hit on the old track.
+ r = insertHit();
+
+ // Start a new hit on the pre-step.
+ startHit(pre());
+ }
+ }
+#ifdef G4DEBUG
+ else {
+ std::cout << GetName() << "::WARNING : current TrackID == -1" << std::endl;
+ }
+#endif
+
+ // Update the hit, checking if the call to this function is applicable.
+ updateHit();
+
+ // Entering a new PV on this step?
+ if (prePV() != postPV()) {
+
+#ifdef G4VERBOSE
+ if ( getVerbose() > 0 ) {
+ G4cerr << "new physvol this step!" << G4endl;
+ }
+#endif
+
+ // Insert the current hit.
+ r = insertHit();
+
+ // Check if pre and post steps have the same detector.
+ if (hasSameSD()) {
+
+ // Start a new hit for the adjacent tracker layer.
+ startHit(post());
+ }
+ }
+ // Special case where the track status is StopAndKill.
+ // If so, we won't see it again, so need to insert the hit.
+ else if (m_currentTrack->GetTrackStatus() == fStopAndKill) {
+ r = insertHit();
+ }
+
+#ifdef G4VERBOSE
+ if ( getVerbose() > 0 ) {
+ G4cerr << "----" << G4endl;
+ }
+#endif
+
+ return r;
+}
+
+void G4TrackerCombineSD::updateHit()
+{
+
+#ifdef G4VERBOSE
+ if ( getVerbose() > 1 ) {
+ G4cout << "updateHit" << G4endl;
+ }
+#endif
+
+ // can only update if started hit
+ if (m_startedHit) {
+
+ // incr edep
+ m_edepTotal += edep();
+
+ // first time only
+ if (m_minTime == 0) {
+ m_minTime = globalTime();
+ }
+
+ // exit point and momentum
+ m_exitPoint = postPosition();
+ m_exitMomentum = postMomentum();
+ }
+}
+
+void G4TrackerCombineSD::clear()
+{
+#ifdef G4VERBOSE
+ if ( getVerbose() > 1 ) {
+ G4cout << "clear" << G4endl;
+ }
+#endif
+
+ m_minTime = 0;
+ m_edepTotal = 0;
+ m_currentPV = 0;
+ m_currentTrackID = -1;
+ m_startedHit = false;
+}
+
+bool G4TrackerCombineSD::insertHit()
+{
+#ifdef G4VERBOSE
+ if ( getVerbose() > 1 ) {
+ G4cout << "insertHit" << G4endl;
+ }
+#endif
+
+ // never started another hit after clearing
+ if (!m_startedHit) {
+ G4cerr << "never started hit!" << G4endl;
+ return false;
+ }
+
+ // total energy below cut
+ if ( m_edepTotal <= getEcut() && !isGeantino() ) {
+#ifdef G4VERBOSE
+ if ( getVerbose() > 0 ) {
+ std::cout << GetName() << " : cut this edep " << m_edepTotal << std::endl;
+ }
+
+#endif
+ clear();
+ return false;
+ }
+
+ // compute mid point
+ G4ThreeVector midPoint =
+ ReadoutUtil::computeThreeVectorMean(m_entryPoint, m_exitPoint);
+
+ // compute mean momentum
+ G4ThreeVector meanMom =
+ ReadoutUtil::computeThreeVectorMean(m_entryMomentum, m_exitMomentum);
+
+ // compute distance from start to entry
+ G4double pathlength = ReadoutUtil::computeDistance(m_entryPoint, m_exitPoint);
+
+ // hit data
+ G4TrackerHit* trkhit = new G4TrackerHit();
+ trkhit->setTdep(m_minTime);
+ trkhit->setEdep(m_edepTotal);
+ trkhit->setPos(midPoint);
+ trkhit->setMomentum(meanMom);
+ trkhit->setTrackID(m_currentTrackID);
+ trkhit->setLength(pathlength);
+
+ // set id
+ Id64bit id64 = makeId();
+ trkhit->setId(id64.getId0());
+
+#ifdef G4VERBOSE
+ if ( getVerbose() > 1 ) {
+ std::cout << GetName() << " : inserting new tracker hit" << std::endl;
+ std::cout << *trkhit << std::endl;
+ std::cout << "entryPoint = " << m_entryPoint << std::endl;
+ std::cout << "entryPointR = " << m_entryPoint.mag() << std::endl;
+ std::cout << "midPoint = " << midPoint << std::endl;
+ std::cout << "midPointR = " << midPoint.mag() << std::endl;
+ std::cout << "exitPoint = " << m_exitPoint << std::endl;
+ std::cout << "exitPointR = " << m_exitPoint.mag() << std::endl;
+ std::cout << "(exitPointR - entryPointR) / 2 = " << (m_exitPoint.mag() - m_entryPoint.mag()) / 2 << std::endl;
+ std::cout << std::endl;
+ }
+#endif
+
+ m_HC->insert(trkhit);
+
+ TrackInformation::getTrackInformation( m_currentTrack )->setHasTrackerHit( true );
+
+ // clear cached data
+ clear();
+
+#ifdef G4VERBOSE
+ if ( getVerbose() > 0 ) {
+ G4cout << G4endl;
+ }
+#endif
+
+ return true;
+ }
+
+void G4TrackerCombineSD::startHit(G4StepPoint* aStepPoint)
+{
+#ifdef G4VERBOSE
+ if ( getVerbose() > 0 ) {
+ G4cout << "startHit" << G4endl;
+ }
+#endif
+
+ m_currentTrack = step()->GetTrack();
+ m_currentPV = aStepPoint->GetPhysicalVolume();
+ m_entryPoint = m_exitPoint = aStepPoint->GetPosition();
+ m_entryMomentum = m_exitMomentum = aStepPoint->GetMomentum();
+ m_currentTrackID = trackID();
+ m_startedHit = true;
+
+#ifdef G4VERBOSE
+ if ( getVerbose() > 2 ) {
+ std::cout << GetName() << " : starting new hit" << std::endl;
+ std::cout << "volume = " << m_currentPV->GetName() << std::endl;
+ std::cout << "trackID = " << m_currentTrackID << std::endl;
+ std::cout << "entry point = " << m_entryPoint << std::endl;
+ }
+#endif
+}
+
lcdd/src/lcdd/detectors
diff -N G4TrackerSD.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4TrackerSD.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,141 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/G4TrackerSD.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/id/IdManager.hh"
+#include "lcdd/id/IdFactory.hh"
+#include "lcdd/id/IdVec.hh"
+#include "lcdd/detectors/G4TrackerSD.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+#include "lcdd/hits/G4TrackerHit.hh"
+#include "lcdd/hits/TrackInformation.hh"
+
+// Geant4
+#include "G4Geantino.hh"
+
+// STL
+#include <iostream>
+
+G4TrackerSD::G4TrackerSD(G4String sdName, G4String hcName) :
+ G4SensitiveDetector(sdName, hcName, G4SensitiveDetector::eTracker), m_HC(0)
+{
+ m_hits.clear();
+}
+
+G4TrackerSD::~G4TrackerSD()
+{
+}
+
+void G4TrackerSD::Initialize(G4HCofThisEvent *HCE)
+{
+ clearHits();
+
+ // create tracker hits coll
+ m_HC = new G4TrackerHitsCollection(GetName(), collectionName[0]);
+
+ // set HCID
+ if (getHCID() < 0) {
+ setHCID(GetCollectionID(0));
+ }
+
+ // add collection to HC of event
+ HCE->AddHitsCollection(getHCID(), m_HC);
+}
+
+G4bool G4TrackerSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
+{
+ // set cached step
+ G4SensitiveDetector::ProcessHits(aStep, 0);
+
+ // edep
+ G4double e = edep();
+
+ // check edep < cut
+ if (e <= getEcut() && !isGeantino()) {
+ return false;
+ }
+
+ // get track information
+ TrackInformation* trkInfo = trackInformation();
+
+ // set hit flag in trk info
+ trkInfo->setHasTrackerHit(true);
+
+ // hit data
+ G4int trkID = trackID();
+ G4double tdep = globalTime();
+ G4ThreeVector midPos = midPosition();
+ G4ThreeVector prePos = aStep->GetPreStepPoint()->GetPosition();
+ G4ThreeVector postPos = aStep->GetPostStepPoint()->GetPosition();
+ double avgMom = (pre()->GetMomentum().mag() + post()->GetMomentum().mag()) / 2;
+ G4ThreeVector mom = (postPos - prePos);
+ if (mom.mag() > 0) {
+ mom.setMag(avgMom);
+ } else {
+ std::cerr << "prePos - postPos = 0 --> " << prePos << " | " << postPos << std::endl;
+ }
+
+ G4double pathLength = ReadoutUtil::computeDistance(aStep);
+
+ // create hit
+ G4TrackerHit* trkHit = new G4TrackerHit();
+
+ // create id vector
+ Id64bit id64 = makeId();
+
+ // set track hit info
+ trkHit->setTrackID(trkID);
+ trkHit->setEdep(e);
+ trkHit->setPos(midPos);
+ trkHit->setMomentum(mom);
+ trkHit->setTdep(tdep);
+ trkHit->setId(id64.getId0());
+ trkHit->setLength(pathLength);
+
+ // add to HC
+ m_HC->insert(trkHit);
+
+ m_hits.push_back(trkHit);
+
+ return true;
+}
+
+std::ostream& G4TrackerSD::printHits(std::ostream& os)
+{
+ for (G4TrackerHitList::const_iterator iter = m_hits.begin(); iter != m_hits.end(); iter++) {
+ os << (*(const_cast<const G4TrackerHit*>(*iter)));
+ }
+ os << std::endl;
+ return os;
+}
+
+void G4TrackerSD::EndOfEvent(G4HCofThisEvent *)
+{
+#ifdef G4VERBOSE
+ if ( getVerbose() > 0 ) {
+ std::cout << GetName() << " has " << m_HC->GetSize() << " hits." << std::endl;
+ }
+
+ if ( getVerbose() > 1 ) {
+ printHits ( std::cout );
+ }
+#endif
+}
+
+double G4TrackerSD::getEdep() const
+{
+ double edep = 0.0;
+ for (G4TrackerHitList::const_iterator it = m_hits.begin(); it != m_hits.end(); it++) {
+ edep += (*it)->getEdep();
+ }
+ return edep;
+}
+
+void G4TrackerSD::clearHits()
+{
+ m_hits.clear();
+}
+
+G4TrackerSD::G4TrackerHitList G4TrackerSD::getTrackerHitList()
+{
+ return m_hits;
+}
lcdd/src/lcdd/detectors
diff -N G4UnsegmentedCalorimeterSD.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4UnsegmentedCalorimeterSD.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,69 @@
+// $Id: G4UnsegmentedCalorimeterSD.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/G4UnsegmentedCalorimeterSD.hh"
+
+G4UnsegmentedCalorimeterSD::G4UnsegmentedCalorimeterSD(G4String sdName, G4String hcName, G4Segmentation* seg) :
+ G4CalorimeterSD(sdName, hcName, seg)
+{
+}
+
+G4bool G4UnsegmentedCalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
+{
+#ifdef G4VERBOSE
+ if ( getVerbose() > 0 )
+ {
+ std::cout << "G4UnsegmentedCalorimeterSD::ProcessHits - " << this->GetName() << std::endl;
+ }
+#endif
+
+ /* Cache the step information. */
+ G4SensitiveDetector::ProcessHits(aStep, 0);
+
+ /* Get the energy deposition. */
+ G4double theEdep = edep();
+
+ /*
+ * This needs to be a <= comparison for cutting on 0,
+ * but it allows geantinos, which always have 0 edep.
+ */
+ if (theEdep <= getEcut() && !isGeantino()) {
+#ifdef G4VERBOSE
+ if ( getVerbose() > 2 )
+ {
+ std::cout << "G4UnsegmentedCalorimeterSD::ProcessHits - cut on edep " << theEdep << std::endl;
+ }
+#endif
+ return false;
+ }
+
+ /* Get the step mid position. */
+ G4ThreeVector hitPos = midPosition();
+
+ //std::cout << "hit at " << hitPos << std::endl;
+
+ /* Reset the segmentation bins. */
+ //m_segmentation->resetBins();
+ /* Set the segmentation bins. */
+ //m_segmentation->setBins( aStep );
+ /* Create a 64-bit ID. */
+ Id64bit id64 = makeId();
+
+ /* Create a new hit. */
+ G4CalorimeterHit* thisHit = new G4CalorimeterHit(theEdep, hitPos);
+
+ /* Set the 64-bit ID. */
+ thisHit->setId64bit(id64.getId0(), id64.getId1());
+
+ /* Add hit to lookup map. */
+ hits_vector[0].push_back(thisHit);
+
+ /* Add hit to the HC. */
+ m_hitsCollections[0]->insert(thisHit);
+
+ /* Add an MCParticle contribution for this hit. */
+ thisHit->addMcpHitContrib(McpHitContrib(aStep));
+
+ /* Success. */
+ return true;
+}
lcdd/src/lcdd/detectors
diff -N ReadoutUtil.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ReadoutUtil.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,200 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/ReadoutUtil.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+// Geant4
+#include "G4ParticleDefinition.hh"
+#include "G4Geantino.hh"
+#include "G4ChargedGeantino.hh"
+
+// STL
+#include <cmath>
+
+const double ReadoutUtil::PI = acos(-1);
+
+G4ThreeVector ReadoutUtil::computeThreeVectorMean(const G4ThreeVector& vec1, const G4ThreeVector& vec2)
+{
+ return (0.5 * (vec1 + vec2));
+}
+
+G4double ReadoutUtil::computeDistance(const G4ThreeVector& vec1, const G4ThreeVector& vec2)
+{
+ return (sqrt(pow(vec1.x() - vec2.x(), 2) + pow(vec1.y() - vec2.y(), 2) + pow(vec1.z() - vec2.z(), 2)));
+}
+
+G4double ReadoutUtil::computeDistance(const G4Step* aStep)
+{
+ return computeDistance(aStep->GetPreStepPoint()->GetPosition(), aStep->GetPostStepPoint()->GetPosition());
+}
+
+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());
+ tubs = static_cast<const G4Tubs*>(solid);
+ return tubs;
+}
+const G4Tubs* ReadoutUtil::getTubs(const G4StepPoint* aPreStepPoint)
+{
+ const G4Tubs* tubs = 0;
+ G4VSolid* solid = ReadoutUtil::getSolidFromStepPoint(aPreStepPoint);
+ tubs = static_cast<const G4Tubs*>(solid);
+ 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::computeTubsMidRadius(const G4StepPoint* aPreStepPoint)
+{
+ return computeTubsMidRadius(ReadoutUtil::getTubs(aPreStepPoint));
+}
+
+double ReadoutUtil::getTubsThickness(const G4Tubs* tubs)
+{
+ return tubs->GetOuterRadius() - tubs->GetInnerRadius();
+}
+
+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::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)
+{
+ // 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;
+}
+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)
+{
+ std::vector<G4VPhysicalVolume*> physVols;
+
+ // get touchable from PreStepPoint
+ G4TouchableHandle theTouchable = aStep->GetPreStepPoint()->GetTouchableHandle();
+
+ G4int hdepth = theTouchable->GetHistoryDepth();
+
+ const G4NavigationHistory* theTouchableHistory = theTouchable->GetHistory();
+
+ for (int i = hdepth; i > 0; i--) {
+ G4VPhysicalVolume* pv = theTouchableHistory->GetVolume(i);
+ physVols.push_back(pv);
+
+#ifdef ID_DEBUG
+ G4cout << "pushed back <" << pv->GetName() << ">" << G4endl;
+#endif
+ }
+
+ return physVols;
+}
+
+int ReadoutUtil::getVolumeNumber(G4TouchableHandle theTouchable, int historyDepth)
+{
+ bool no_depth = false;
+
+ if (historyDepth == -1) {
+ no_depth = true;
+ }
+
+ G4VPhysicalVolume *pv = 0;
+
+ // pv only with depth arg
+ if (!no_depth) {
+ pv = theTouchable->GetHistory()->GetVolume(historyDepth);
+ }
+
+ int vnum = -1;
+
+ // rep num: no pv, replicated, parameterised
+ if (!pv || pv->IsReplicated() || pv->IsParameterised()) {
+
+ // no depth
+ if (no_depth) {
+ vnum = theTouchable->GetReplicaNumber();
+ }
+ // use history depth
+ else {
+ vnum = theTouchable->GetReplicaNumber(historyDepth);
+ }
+ } else {
+ // copy num: placement
+ vnum = pv->GetCopyNo();
+ }
+
+ return vnum;
+}
+
+bool ReadoutUtil::isGeantino(G4Step* aStep)
+{
+ G4ParticleDefinition* def = aStep->GetTrack()->GetDefinition();
+ if (def == G4Geantino::Definition() || def == G4ChargedGeantino::Definition())
+ return true;
+ else
+ return false;
+}
lcdd/src/lcdd/detectors
diff -N SensitiveDetectorFactory.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SensitiveDetectorFactory.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,267 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/SensitiveDetectorFactory.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/SensitiveDetectorFactory.hh"
+#include "lcdd/detectors/G4TrackerCombineSD.hh"
+#include "lcdd/detectors/G4ScorerSD.hh"
+#include "lcdd/detectors/G4TrackerSD.hh"
+#include "lcdd/detectors/G4OpticalCalorimeterSD.hh"
+#include "lcdd/detectors/G4UnsegmentedCalorimeterSD.hh"
+#include "lcdd/detectors/PositionComparator.hh"
+#include "lcdd/id/IdComparator.hh"
+#include "lcdd/util/StringUtil.hh"
+
+G4SensitiveDetector* SensitiveDetectorFactory::createSensitiveDetector(const SAXObject* object)
+{
+ //std::cout << "create SD" << std::endl;
+
+ G4SensitiveDetector* sd = 0;
+
+ const SensitiveDetectorType* sdt = dynamic_cast<const SensitiveDetectorType*>(object);
+
+ if (sdt) {
+
+ std::string sd_type = sdt->get_type();
+
+ /* Create calorimeter subdetector. */
+ // TODO Check if "calorimeter" in the sd_type.
+ if (sd_type == "calorimeter" || sd_type == "optical_calorimeter" || sd_type == "unsegmented_calorimeter") {
+ //std::cout << "creating calorimeter" << std::endl;
+ sd = createCalorimeterSD(object);
+ }
+ /* Create tracker subdetector. */
+ else if (sd_type == "tracker") {
+ sd = createTrackerSD(object);
+ }
+ /* Create scorer subdetector. */
+ else if (sd_type == "scorer") {
+ sd = createScorerSD(object);
+ } else {
+ /* Type not recognized. */
+ G4cerr << "Invalid sd_type <" << sd_type << ">." << G4endl;
+ G4Exception("", "", FatalException, "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("", "", FatalException, "Failed cast to SensitiveDetectorType.");
+ }
+
+ return sd;
+}
+
+G4CalorimeterSD* SensitiveDetectorFactory::createCalorimeterSD(const SAXObject* object)
+{
+ G4CalorimeterSD* sd = 0;
+ G4Segmentation* seg = 0;
+
+ const SensitiveDetectorType* sdt = dynamic_cast<const SensitiveDetectorType*>(object);
+
+ std::string sd_type = sdt->get_type();
+
+ // 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;
+ }
+ }
+
+ // Get the calorimeter XML object.
+ const calorimeter* cal = dynamic_cast<const calorimeter*>(object);
+
+ // Find out hit aggregation algorithm.
+ 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") {
+ G4cerr << "Invalid selection for hit comparison <" << hitCompareStr << ">, for calorimeter <" << sdt->get_name() << ">." << G4endl;
+ G4Exception("", "", FatalException, "Invalid selection for hit comparison.");
+ }
+
+ // 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();
+ }
+
+ 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];
+ // TODO Fix hardcoded collection names.
+ 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 if (sd_type == "unsegmented_calorimeter") {
+ // Segmentation could be null but that is fine for this type of calorimeter.
+ sd = new G4UnsegmentedCalorimeterSD(sdt->get_name(), sdt->get_hitsCollectionName(), seg);
+ } else {
+ G4cerr << "Unknown sensitive detector type: " << sd_type << G4endl;
+ G4Exception("SensitiveDetectorFactory", "", FatalException, "Unknown sensitive detector type.");
+ }
+
+ return sd;
+}
+
+G4TrackerSD* SensitiveDetectorFactory::createTrackerSD(const SAXObject* object)
+{
+ const tracker* trk = dynamic_cast<const tracker*>(object);
+
+ bool combineHits = StringUtil::toBool(trk->get_combine_hits());
+
+ G4TrackerSD* sd = 0;
+
+ std::string nm = trk->get_name();
+ std::string hc = trk->get_hitsCollectionName();
+
+ if (checkHCName(hc)) {
+ G4Exception("SensitiveDetectorFactory", "", FatalException, "Name of the hits collection is invalid.");
+ }
+
+ /* tracker that aggregates hits */
+ if (combineHits) {
+ sd = new G4TrackerCombineSD(nm, hc);
+ } else {
+ /* regular tracker */
+ sd = new G4TrackerSD(nm, hc);
+ }
+
+ return sd;
+}
+
+G4ScorerSD* SensitiveDetectorFactory::createScorerSD(const SAXObject* object)
+{
+ const scorer * scr = dynamic_cast<const scorer*>(object);
+
+ G4ScorerSD* sd = 0;
+
+ std::string nm = scr->get_name();
+ std::string hc = scr->get_hitsCollectionName();
+
+ if (checkHCName(hc)) {
+ G4Exception("SensitiveDetectorFactory", "", FatalException, "Name of the hits collections is invalid.");
+ }
+
+ 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) {
+ G4cerr << "IdSpec <" << id_ref->get_ref() << "> referenced by detector <" << sdt->get_name() << "> does not exist." << G4endl;
+ G4Exception("", "", FatalException, "IdSpec does not exist.");
+ }
+
+ break;
+ }
+ }
+ 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()));
+}
+
+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;
+}
+
+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;
+}
+
+// NOTE: New segmentations must appear here!
+bool SensitiveDetectorFactory::isSegmentationTag(const std::string& s)
+{
+ // @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" || s == "cell_readout_2d");
+}
+
+bool SensitiveDetectorFactory::checkHCName(const std::string& s)
+{
+ 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;
+ }
+ }
+ }
+ return bad;
+}
lcdd/src/lcdd/detectors
diff -N SensitiveDetectorMessenger.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SensitiveDetectorMessenger.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,109 @@
+// $Id: SensitiveDetectorMessenger.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/SensitiveDetectorMessenger.hh"
+
+// Geant4
+#include "G4UIcommand.hh"
+#include "G4UIcmdWithAnInteger.hh"
+#include "G4UIcmdWithABool.hh"
+#include "G4UIcmdWithADoubleAndUnit.hh"
+#include "G4UIdirectory.hh"
+#include "G4VSensitiveDetector.hh"
+
+G4UIdirectory* SensitiveDetectorMessenger::m_detectorsDir = 0;
+
+SensitiveDetectorMessenger::SensitiveDetectorMessenger(G4SensitiveDetector* detector) :
+ m_detector(detector)
+{
+ if (m_detectorsDir == 0) {
+ makeDetectorsDir();
+ }
+
+ defineCommands(m_detector);
+}
+
+SensitiveDetectorMessenger::~SensitiveDetectorMessenger()
+{
+ // TODO: put command deletes here
+}
+
+void SensitiveDetectorMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals)
+{
+ if (cmd == m_printInfoCmd) {
+ m_detector->printBasicInfo(std::cout);
+ } else if (cmd == m_printNHitsCmd) {
+ m_detector->printNumberOfHits(std::cout);
+ } else if (cmd == m_printTotalEdepCmd) {
+ m_detector->printEdep(std::cout);
+ } else if (cmd == m_printVolumesCmd) {
+ m_detector->printVolumes(std::cout);
+ } else if (cmd == m_printHitsCmd) {
+ m_detector->printHits(std::cout);
+ } else if (cmd == m_verboseCmd) {
+ m_detector->setVerbose(m_verboseCmd->GetNewIntValue(newVals));
+ } else if (cmd == m_activateCmd) {
+ m_detector->Activate(m_activateCmd->GetNewBoolValue(newVals));
+ } else if (cmd == m_ecutCmd) {
+ m_detector->setEcut(m_ecutCmd->GetNewDoubleValue(newVals));
+ }
+
+}
+
+void SensitiveDetectorMessenger::makeDetectorsDir()
+{
+ m_detectorsDir = new G4UIdirectory("/detectors/");
+ m_detectorsDir->SetGuidance("Commands for sensitive detectors. [LCDD]");
+}
+
+void SensitiveDetectorMessenger::defineCommands(G4VSensitiveDetector* sd)
+{
+ // Name of the sensitive detector.
+ const G4String& name = sd->GetName();
+
+ // Name of the sensitive detector's command directory.
+ const G4String& dirName = G4String("/detectors/" + name + "/");
+
+ // Create the sensitive detector's Geant4 macro command directory.
+ m_detectorDir = new G4UIdirectory(dirName.c_str());
+ m_detectorDir->SetGuidance(G4String("Commands for the sensitive detector " + name).c_str());
+
+ // Print command.
+ m_printInfoCmd = new G4UIcommand(G4String(dirName + "print").c_str(), this);
+ m_printInfoCmd->SetGuidance(G4String("Print basic information about the sensitive detector " + name).c_str());
+
+ // Print number of hits command.
+ m_printNHitsCmd = new G4UIcommand(G4String(dirName + "printNumberOfHits").c_str(), this);
+ m_printInfoCmd->SetGuidance(G4String("Print the number of hits from the detector " + name).c_str());
+
+ // Print energy deposition.
+ m_printTotalEdepCmd = new G4UIcommand(G4String(dirName + "printEdep").c_str(), this);
+ m_printTotalEdepCmd->SetGuidance(G4String("Print the total energy deposition from the detector " + name).c_str());
+
+ // Print energy deposition.
+ m_printVolumesCmd = new G4UIcommand(G4String(dirName + "printVolumes").c_str(), this);
+ m_printVolumesCmd->SetGuidance(G4String("Print a list of logical volume names associated with the detector " + name).c_str());
+
+ // Print energy deposition.
+ m_printHitsCmd = new G4UIcommand(G4String(dirName + "printHits").c_str(), this);
+ m_printHitsCmd->SetGuidance(G4String("Print a list of hits from the detector " + name).c_str());
+
+ // Set the verbosity.
+ m_verboseCmd = new G4UIcmdWithAnInteger(G4String(dirName + "setVerbose").c_str(), this);
+ m_verboseCmd->SetGuidance(G4String("Set the verbosity of the detector " + name).c_str());
+ m_verboseCmd->SetDefaultValue(2);
+ m_verboseCmd->SetParameterName("verbose", true, true);
+
+ // Activate or deactive this detector.
+ m_activateCmd = new G4UIcmdWithABool(G4String(dirName + "setActive").c_str(), this);
+ m_activateCmd->SetGuidance(G4String("Set whether the detector " + name + " is active.").c_str());
+ m_activateCmd->SetDefaultValue(true);
+ m_activateCmd->SetParameterName("active", true, true);
+
+ // Set the ecut with unit.
+ m_ecutCmd = new G4UIcmdWithADoubleAndUnit(G4String(dirName + "setHitEnergyCut").c_str(), this);
+ m_ecutCmd->SetGuidance(G4String("Set the single hit energy cut for detector " + name).c_str());
+ m_ecutCmd->SetDefaultValue(0.0);
+ m_ecutCmd->SetDefaultUnit("GeV");
+ m_ecutCmd->SetParameterName("cut", true, true);
+}
lcdd/src/lcdd/detectors
diff -N StepReadout.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ StepReadout.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,213 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/StepReadout.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/StepReadout.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+#include "lcdd/hits/TrackInformation.hh"
+
+// G4
+#include "G4Step.hh"
+#include "G4StepPoint.hh"
+#include "G4Track.hh"
+#include "G4VSolid.hh"
+#include "G4VPhysicalVolume.hh"
+#include "G4VSensitiveDetector.hh"
+#include "G4TouchableHandle.hh"
+#include "G4Region.hh"
+#include "G4Material.hh"
+#include "G4LogicalVolume.hh"
+
+StepReadout::StepReadout() :
+ m_step(0)
+{
+}
+
+StepReadout::~StepReadout()
+{
+}
+
+void StepReadout::setStep(G4Step* s)
+{
+ m_step = s;
+}
+
+G4Step* StepReadout::step() const
+{
+ return m_step;
+}
+
+bool StepReadout::hasStep() const
+{
+ return (0 != m_step);
+}
+
+G4StepPoint* StepReadout::pre() const
+{
+ return step()->GetPreStepPoint();
+}
+
+G4StepPoint* StepReadout::post() const
+{
+ return step()->GetPostStepPoint();
+}
+
+G4VPhysicalVolume* StepReadout::prePV() const
+{
+ return preTouchableHandle()->GetVolume();
+}
+
+G4VPhysicalVolume* StepReadout::postPV() const
+{
+ return postTouchableHandle()->GetVolume();
+}
+
+G4VSolid* StepReadout::preSolid() const
+{
+ return preLV()->GetSolid();
+}
+
+G4VSolid* StepReadout::postSolid() const
+{
+ return postLV()->GetSolid();
+}
+
+G4LogicalVolume* StepReadout::preLV() const
+{
+ return prePV()->GetLogicalVolume();
+}
+
+G4LogicalVolume* StepReadout::postLV() const
+{
+ return postPV()->GetLogicalVolume();
+}
+
+G4Material* StepReadout::preMaterial() const
+{
+ return pre()->GetMaterial();
+}
+
+G4Material* StepReadout::postMaterial() const
+{
+ return post()->GetMaterial();
+}
+
+G4VSensitiveDetector* StepReadout::preSD() const
+{
+ return getSD(pre());
+}
+
+G4VSensitiveDetector* StepReadout::postSD() const
+{
+ return getSD(post());
+}
+
+G4VSensitiveDetector* StepReadout::getSD(G4StepPoint* stepPoint) const
+{
+ return stepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetSensitiveDetector();
+}
+
+bool StepReadout::hasSameSD() const
+{
+ bool r = false;
+
+ // post vol has an SD
+ if (0 != postSD()) {
+
+ // post SD same as pre SD
+ if (preSD() == postSD()) {
+ r = true;
+ }
+ }
+
+ return r;
+}
+
+G4ThreeVector StepReadout::volumePosition(G4TouchableHandle theTouchable) const
+{
+ return theTouchable->GetHistory()->GetTopTransform().Inverse().TransformPoint(m_origin);
+}
+
+G4ThreeVector StepReadout::preVolumePosition() const
+{
+ return volumePosition(preTouchableHandle());
+}
+
+G4ThreeVector StepReadout::postVolumePosition() const
+{
+ return volumePosition(postTouchableHandle());
+}
+
+double StepReadout::edep() const
+{
+ return step()->GetTotalEnergyDeposit();
+}
+
+G4Track* StepReadout::track() const
+{
+ return step()->GetTrack();
+}
+
+double StepReadout::globalTime() const
+{
+ return track()->GetGlobalTime();
+}
+
+int StepReadout::trackID() const
+{
+ return track()->GetTrackID();
+}
+
+G4ThreeVector StepReadout::momentum() const
+{
+ return track()->GetMomentum();
+}
+
+TrackInformation* StepReadout::trackInformation() const
+{
+ return TrackInformation::getTrackInformation(track());
+}
+
+G4ThreeVector StepReadout::prePosition() const
+{
+ return pre()->GetPosition();
+}
+
+G4ThreeVector StepReadout::midPosition() const
+{
+ return ReadoutUtil::computeThreeVectorMean(prePosition(), postPosition());
+}
+
+G4ThreeVector StepReadout::postPosition() const
+{
+ return post()->GetPosition();
+}
+
+G4ThreeVector StepReadout::preMomentum() const
+{
+ return pre()->GetMomentum();
+}
+
+G4ThreeVector StepReadout::postMomentum() const
+{
+ return post()->GetMomentum();
+}
+
+G4ThreeVector StepReadout::meanMomentum() const
+{
+ return ReadoutUtil::computeThreeVectorMean(preMomentum(), postMomentum());
+}
+
+G4TouchableHandle StepReadout::preTouchableHandle() const
+{
+ return pre()->GetTouchableHandle();
+}
+
+G4TouchableHandle StepReadout::postTouchableHandle() const
+{
+ return post()->GetTouchableHandle();
+}
+
+bool StepReadout::isGeantino()
+{
+ return ReadoutUtil::isGeantino(step());
+}
lcdd/src/lcdd/geant4
diff -N G4LimitSet.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4LimitSet.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,123 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/geant4/G4LimitSet.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/geant4/G4LimitSet.hh"
+
+// Geant4
+#include "G4Track.hh"
+
+/* Code for any particle. */
+const G4LimitSet::ParticleType G4LimitSet::ANY_PARTICLE = "*";
+
+/* Code for no limit, as -1 is never a valid limit. */
+const G4LimitSet::LimitValueType G4LimitSet::LIMIT_NOT_SET = -1;
+
+/* Keys to limit value maps for each parameter. */
+const G4LimitSet::LimitNameKeyType G4LimitSet::STEP_LENGTH_MAX_KEY = "step_length_max";
+const G4LimitSet::LimitNameKeyType G4LimitSet::TRACK_LENGTH_MAX_KEY = "track_length_max";
+const G4LimitSet::LimitNameKeyType G4LimitSet::TIME_MAX_KEY = "time_max";
+const G4LimitSet::LimitNameKeyType G4LimitSet::EKIN_MIN_KEY = "ekin_min";
+const G4LimitSet::LimitNameKeyType G4LimitSet::RANGE_MIN_KEY = "range_min";
+
+/* Default values for limits. Taken from G4UserLimit ctor default args. */
+const G4LimitSet::LimitValueType G4LimitSet::STEP_LENGTH_MAX_DEFAULT = DBL_MAX;
+const G4LimitSet::LimitValueType G4LimitSet::TRACK_LENGTH_MAX_DEFAULT = DBL_MAX;
+const G4LimitSet::LimitValueType G4LimitSet::TIME_MAX_DEFAULT = DBL_MAX;
+const G4LimitSet::LimitValueType G4LimitSet::EKIN_MIN_DEFAULT = 0.;
+const G4LimitSet::LimitValueType G4LimitSet::RANGE_MIN_DEFAULT = 0.;
+
+G4LimitSet::G4LimitSet(const G4String& name) :
+ G4UserLimits("G4LimitSet"), m_name(name)
+{
+ m_limitsMap[STEP_LENGTH_MAX_KEY] = LimitMap();
+ m_limitsMap[TRACK_LENGTH_MAX_KEY] = LimitMap();
+ m_limitsMap[TIME_MAX_KEY] = LimitMap();
+ m_limitsMap[EKIN_MIN_KEY] = LimitMap();
+ m_limitsMap[RANGE_MIN_KEY] = LimitMap();
+}
+
+G4LimitSet::~G4LimitSet()
+{
+}
+
+G4double G4LimitSet::GetMaxAllowedStep(const G4Track& aTrack)
+{
+ double maxStepLength = getLimitForParticle(STEP_LENGTH_MAX_KEY, aTrack);
+ return maxStepLength == LIMIT_NOT_SET ? STEP_LENGTH_MAX_DEFAULT : maxStepLength;
+}
+
+G4double G4LimitSet::GetUserMaxTrackLength(const G4Track& aTrack)
+{
+ double maxTrackLength = getLimitForParticle(TRACK_LENGTH_MAX_KEY, aTrack);
+ return maxTrackLength == LIMIT_NOT_SET ? TRACK_LENGTH_MAX_DEFAULT : maxTrackLength;
+}
+
+G4double G4LimitSet::GetUserMaxTime(const G4Track& aTrack)
+{
+ double maxTime = getLimitForParticle(TIME_MAX_KEY, aTrack);
+ return maxTime == LIMIT_NOT_SET ? TIME_MAX_DEFAULT : maxTime;
+}
+
+G4double G4LimitSet::GetUserMinEkine(const G4Track& aTrack)
+{
+ double minEkine = getLimitForParticle(EKIN_MIN_KEY, aTrack);
+ return minEkine == LIMIT_NOT_SET ? EKIN_MIN_DEFAULT : minEkine;
+}
+
+G4double G4LimitSet::GetUserMinRange(const G4Track& aTrack)
+{
+ double minRange = getLimitForParticle(RANGE_MIN_KEY, aTrack);
+ return minRange == LIMIT_NOT_SET ? RANGE_MIN_DEFAULT : minRange;
+}
+
+const G4LimitSet::ParticleType G4LimitSet::getParticleType(const G4Track& aTrack)
+{
+ return aTrack.GetDefinition()->GetParticleName();
+}
+
+void G4LimitSet::setLimitForParticle(LimitNameType limitName, ParticleType particleType, LimitValueType limitValue)
+{
+ if (m_limitsMap.find(limitName) != m_limitsMap.end()) {
+ m_limitsMap[limitName][particleType] = limitValue;
+ } else {
+ G4Exception("", "", FatalException, "Invalid limits map.");
+ }
+}
+
+G4LimitSet::LimitValueType G4LimitSet::getLimitForParticle(LimitNameType limitName, ParticleType particleType)
+{
+ //std::cout << "G4LimitSet::getLimitForParticle()" << std::endl;
+ //std::cout << "limitName, particleType: " << limitName << " " << particleType << std::endl;
+ LimitValueType limitValue = 0;
+ if (m_limitsMap.find(limitName) != m_limitsMap.end()) {
+ if (m_limitsMap[limitName].find(particleType) != m_limitsMap[limitName].end()) {
+ limitValue = m_limitsMap[limitName][particleType];
+ } else {
+ if ((m_limitsMap[limitName].find(ANY_PARTICLE) != m_limitsMap[limitName].end())) {
+ limitValue = m_limitsMap[limitName][ANY_PARTICLE];
+ } else {
+ limitValue = LIMIT_NOT_SET;
+ }
+ }
+ } else {
+ G4Exception("", "", FatalException, "Invalid limits map.");
+ }
+ //std::cout << "limitValue: " << limitValue << std::endl;
+ return limitValue;
+}
+
+G4LimitSet::LimitValueType G4LimitSet::getLimitForParticle(LimitNameType limitName, const G4Track& aTrack)
+{
+ return getLimitForParticle(limitName, getParticleType(aTrack));
+}
+
+void G4LimitSet::setName(const G4String& n)
+{
+ m_name = n;
+}
+
+G4String& G4LimitSet::getName()
+{
+ return m_name;
+}
+
lcdd/src/lcdd/hits
diff -N G4CalorimeterHit.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4CalorimeterHit.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,99 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/hits/G4CalorimeterHit.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/hits/G4CalorimeterHit.hh"
+
+// Geant4
+#ifdef G4VIS_USE
+#include "G4VVisManager.hh"
+#include "G4VisAttributes.hh"
+#include "G4Circle.hh"
+#include "G4Point3D.hh"
+#include "G4Transform3D.hh"
+#endif
+
+G4Allocator<G4CalorimeterHit> G4CalorimeterHitAllocator;
+
+G4CalorimeterHit::G4CalorimeterHit() :
+ G4VHit(), m_edep(0)
+{
+ ;
+}
+
+G4CalorimeterHit::G4CalorimeterHit(G4double edep, G4ThreeVector globalCellPos) :
+ G4VHit(), m_edep(edep), m_pos(globalCellPos)
+{
+ ;
+}
+
+G4CalorimeterHit::~G4CalorimeterHit()
+{
+ ;
+}
+
+G4CalorimeterHit::G4CalorimeterHit(const G4CalorimeterHit &right) :
+ G4VHit()
+{
+ m_edep = right.m_edep;
+ m_pos = right.m_pos;
+}
+
+const G4CalorimeterHit& G4CalorimeterHit::operator=(const G4CalorimeterHit &right)
+{
+ m_edep = right.m_edep;
+ m_pos = right.m_pos;
+
+ return *this;
+}
+
+bool G4CalorimeterHit::operator==(const G4CalorimeterHit &right)
+{
+ return (m_pos == right.m_pos);
+}
+
+#ifdef G4VIS_USE
+void G4CalorimeterHit::Draw()
+{
+ G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
+
+ if(pVVisManager)
+ {
+ G4Point3D p3D = G4Point3D( m_pos );
+ G4Circle chit(p3D);
+ chit.SetScreenDiameter(3.0);
+ chit.SetFillStyle(G4Circle::filled);
+
+ G4Colour col(1.0,0.,1.0);
+
+ chit.SetVisAttributes(G4VisAttributes( col ) );
+ pVVisManager->Draw( chit );
+ }
+}
+#endif
+
+void G4CalorimeterHit::printMcpHitContribs(std::ostream& os)
+{
+ printMcpHitContribsHeader(os);
+
+ for (McpHitContribList::iterator iter = m_particleList.begin(); iter != m_particleList.end(); iter++) {
+ (*iter).printOut(os);
+ }
+}
+
+void G4CalorimeterHit::printMcpHitContribsHeader(std::ostream& os)
+{
+ os << "McpHitContribs" << std::endl;
+ os << "trackID" << '\t' << "edep" << '\t' << '\t' << "PdgId" << '\t' << "time" << std::endl;
+}
+
+void G4CalorimeterHit::Print()
+{
+ std::cout << *this << std::endl;
+}
+
+std::ostream& operator<<(std::ostream &os, const G4CalorimeterHit& hit)
+{
+ os << hit.getPos() << " " << G4BestUnit(hit.getEdep(), "Energy") << std::endl;
+ return os;
+}
+
lcdd/src/lcdd/hits
diff -N G4TrackerHit.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4TrackerHit.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,55 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/hits/G4TrackerHit.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/hits/G4TrackerHit.hh"
+
+// for Draw() method
+#ifdef G4VIS_USE
+#include "G4VVisManager.hh"
+#include "G4VisAttributes.hh"
+#include "G4Circle.hh"
+#include "G4Point3D.hh"
+#include "G4Transform3D.hh"
+#endif
+
+G4Allocator<G4TrackerHit> G4TrackerHitAllocator;
+
+G4TrackerHit::G4TrackerHit() :
+ G4VHit(), m_edep(0), m_tdep(0), m_trkID(-1), m_length(0)
+{
+}
+
+G4TrackerHit::~G4TrackerHit()
+{
+}
+
+#ifdef G4VIS_USE
+void G4TrackerHit::Draw()
+{
+ G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
+
+ if(pVVisManager) {
+
+ G4Point3D p3D = G4Point3D( m_pos );
+ G4Circle chit(p3D);
+ chit.SetScreenDiameter(3.0);
+ chit.SetFillStyle(G4Circle::filled);
+
+ G4Colour col(1.0, 0.0, 1.0);
+
+ chit.SetVisAttributes(G4VisAttributes( col ) );
+ pVVisManager->Draw( chit );
+ }
+}
+#endif
+
+void G4TrackerHit::Print()
+{
+ std::cout << *this << std::endl;
+}
+
+std::ostream& operator<<(std::ostream &os, const G4TrackerHit& hit)
+{
+ std::cout << hit.getTrackID() << " " << hit.getPos() << " " << G4BestUnit(hit.getEdep(), "Energy") << " " << hit.getMomentum() << " " << G4BestUnit(hit.getLength(), "Length") << " " << G4BestUnit(hit.getTdep(), "Time") << " " << hit.getPDG() << " " << std::endl;
+ return os;
+}
lcdd/src/lcdd/hits
diff -N McpHitContrib.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ McpHitContrib.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,64 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/hits/McpHitContrib.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/hits/McpHitContrib.hh"
+#include "lcdd/hits/TrackInformation.hh"
+
+// Geant4
+#include "G4Track.hh"
+#include "G4Step.hh"
+#include "G4ParticleDefinition.hh"
+#include "G4ParticleTypes.hh"
+
+McpHitContrib::McpHitContrib() :
+ m_trackID(-1), m_edep(0), m_PdgId(9999999), m_globalTime(0)
+{
+ ;
+}
+
+McpHitContrib::McpHitContrib(G4int trackID, G4double edep, G4int PDGID, G4double globalTime) :
+ m_trackID(trackID), m_edep(edep), m_PdgId(PDGID), m_globalTime(globalTime)
+{
+ ;
+}
+
+McpHitContrib::~McpHitContrib()
+{
+ ;
+}
+
+McpHitContrib::McpHitContrib(const G4Step* aStep)
+{
+ // Get the track.
+ const G4Track* aTrack = aStep->GetTrack();
+
+ // Get the track information.
+ TrackInformation* trkInfo = static_cast<TrackInformation*>(aTrack->GetUserInformation());
+
+ // Get the track ID.
+ m_trackID = trkInfo->getOriginalTrackID();
+
+ // Set edep according to type of track.
+ if (aTrack->GetDefinition() == G4OpticalPhoton::OpticalPhotonDefinition()) {
+ m_edep = aTrack->GetTotalEnergy();
+ } else {
+ m_edep = aStep->GetTotalEnergyDeposit();
+ }
+
+ // PDG ID.
+ m_PdgId = aTrack->GetDefinition()->GetPDGEncoding();
+
+ // Global time.
+ m_globalTime = aTrack->GetGlobalTime();
+
+ // Compute the step midpoint.
+ G4ThreeVector posVec = (0.5 * (aStep->GetPreStepPoint()->GetPosition() + aStep->GetPostStepPoint()->GetPosition()));
+ m_position[0] = posVec[0];
+ m_position[1] = posVec[1];
+ m_position[2] = posVec[2];
+}
+
+void McpHitContrib::printOut(std::ostream& os)
+{
+ os << m_trackID << '\t' << m_edep << '\t' << m_PdgId << '\t' << m_globalTime << std::endl;
+}
lcdd/src/lcdd/hits
diff -N TrackInformation.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TrackInformation.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,82 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/hits/TrackInformation.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// LCDD
+#include "lcdd/hits/TrackInformation.hh"
+
+G4Allocator<TrackInformation> TrackInformationAllocator;
+
+TrackInformation::TrackInformation()
+{
+ setDefaults();
+}
+
+TrackInformation::TrackInformation(const G4Track* aTrack)
+{
+ setDefaults();
+
+ m_originalTrackID = aTrack->GetTrackID();
+}
+
+TrackInformation::TrackInformation(const TrackInformation* aTrackInfo)
+{
+ assert(aTrackInfo);
+
+ setFromTrackInformation(aTrackInfo, this);
+}
+
+TrackInformation::~TrackInformation()
+{
+}
+
+TrackInformation& TrackInformation::operator =(const TrackInformation& right)
+{
+ setFromTrackInformation(&right, this);
+ return *this;
+}
+
+void TrackInformation::setDefaults()
+{
+ // default to invalid trackID
+ m_originalTrackID = -1;
+
+ // default to tracking region in both current and orig
+ m_originalTrackingStatus = TrackInformation::eInTrackingRegion;
+ m_trackingStatus = TrackInformation::eInTrackingRegion;
+
+ // default flag vals
+ m_hasTrackerHit = false;
+ m_vertexIsNotEndpointOfParent = false;
+ m_backscatter = false;
+ m_belowThreshold = false;
+}
+
+void TrackInformation::setFromTrackInformation(const TrackInformation* srcTrkInfo, TrackInformation* trgtTrkInfo)
+{
+ trgtTrkInfo->setTrackID(srcTrkInfo->m_originalTrackID);
+
+ trgtTrkInfo->setOriginalTrackingStatus(srcTrkInfo->m_originalTrackingStatus);
+ trgtTrkInfo->setTrackingStatus(srcTrkInfo->m_trackingStatus);
+
+ trgtTrkInfo->setHasTrackerHit(false);
+ trgtTrkInfo->setVertexIsNotEndpointOfParent(false);
+ trgtTrkInfo->setBackscatter(srcTrkInfo->getBackscatter());
+ trgtTrkInfo->setBelowThreshold(srcTrkInfo->getBelowThreshold());
+}
+
+const std::string& TrackInformation::getTrackingStatusString(ETrackingStatus ts)
+{
+ static const std::string str_none = "None";
+ static const std::string str_tracking = "InTrackingRegion";
+ static const std::string str_nontracking = "InNontrackingRegion";
+ static const std::string str_invalid = "Invalid";
+
+ if (ts == eNone) {
+ return str_none;
+ } else if (ts == eInTrackingRegion) {
+ return str_tracking;
+ } else if (ts == eInNontrackingRegion) {
+ return str_nontracking;
+ }
+
+ return str_invalid;
+}
lcdd/src/lcdd/id
diff -N IdFactory.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IdFactory.cc 26 Jun 2013 23:51:00 -0000 1.1
@@ -0,0 +1,382 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/id/IdFactory.cc,v 1.1 2013/06/26 23:51:00 jeremy Exp $
+
+// Uncomment to enable verbose debug output from this class.
+//#define ID_DEBUG 1
+
+// LCDD
+#include "lcdd/detectors/G4SensitiveDetector.hh"
+#include "lcdd/detectors/G4CalorimeterSD.hh"
+#include "lcdd/detectors/G4Segmentation.hh"
+#include "lcdd/id/IdManager.hh"
+#include "lcdd/id/IdFactory.hh"
+#include "lcdd/detectors/ReadoutUtil.hh"
+
+// Geant4
+#include "G4Step.hh"
+#include "G4VPhysicalVolume.hh"
+#include "G4NavigationHistory.hh"
+
+using namespace std;
+
+IdFactory::Bits const IdFactory::MASK_ON = 0xFFFFFFFF;
+
+Id64bit IdFactory::createId64bit(const IdVec& idvec, IdSpec* idspec)
+{
+#ifdef ID_DEBUG
+ G4cout << G4endl;
+ G4cout.setf( ios::hex );
+ G4cout << "IdFactory::createId64bit()" << G4endl;
+ G4cout << "idvec size: " << idvec.size() << G4endl;
+ G4cout << "idspec numFields: " << idspec->getNumFields() << G4endl;
+ G4cout << "idspec bitLength: " << idspec->getBitLength() << G4endl;
+#endif
+
+ /* IdVec (expanded id) size must equal IdSpec size or die. */
+ if (idvec.size() != idspec->getNumFields()) {
+ G4Exception("", "", FatalException, "idspec size != idvec size.");
+ }
+
+ /* Make a 64-bit id to return. */
+ Id64bit id64;
+
+ /* A 2 member array for cell ids 1 & 2 (2x32-bit int). */
+ Bits id64_val[2] = { 0, 0 };
+ size_t id64_val_idx = 0;
+
+ /* Ptr to value of current idx. */
+ Bits* id64_val_ptr = &id64_val[id64_val_idx];
+
+ /* Ptr to the current idfield. */
+ IdField* id_field = 0;
+
+ /* Flag indicating that next 32-bit id has been reached. */
+ bool next_id = false;
+
+ /* loop vars */
+ IdField::SizeType field_bit_len = 0;
+ Bits curr_bit = 0;
+ IdSpec::SizeType idspec_idx = 0;
+
+ /* Loop over the IdVec, packing its values into the 64-bit Id
+ using information from the IdSpec. */
+ for (IdVec::ElementVector::const_iterator iter = idvec.getFieldsBegin(); iter != idvec.getFieldsEnd(); iter++) {
+
+ /* field ptr from idspec */
+ id_field = idspec->getIdField(idspec_idx);
+ assert(id_field);
+
+ /* id value of field */
+ Id64bit::ElementType field_val = (Id64bit::ElementType) *iter;
+
+ /* field length */
+ field_bit_len = id_field->getLength();
+
+ /* field start */
+ Bits field_start = id_field->getStart();
+
+ /* Don't allow crossing of 32-bit boundary.
+ FIXME: See http://jira.slac.stanford.edu/browse/LCDD-21
+ */
+ if ((field_start < 32) && (field_start + field_bit_len > 32)) {
+ G4cerr << "Field <" << id_field->getLabel() << "> crosses the 32-bit boundary." << G4endl;
+ G4Exception("", "", FatalException, "Fields are not allowed to cross the 32-bit boundary.");
+ }
+ /* check if on 2nd dbl word. */
+ else if (field_start >= 32) {
+
+ /* If 1st time, set id val pntr. */
+ if (!next_id) {
+#ifdef ID_DEBUG
+ G4cout << "setting ptr to next id" << G4endl;
+#endif
+ ++id64_val_idx;
+ id64_val_ptr = &id64_val[id64_val_idx];
+ next_id = true;
+ }
+
+ /* Adjust start idx for position in next 32-bit id. */
+ field_start -= 32;
+ }
+
+ Bits field_mask = makeBitMask(field_bit_len);
+
+#ifdef ID_DEBUG
+ G4cout << "idspec_idx: " << dec << idspec_idx << G4endl;
+ G4cout << "shifting left: " << dec << field_bit_len << G4endl;
+ G4cout << "curr_bit: " << dec << curr_bit << G4endl;
+ G4cout << "field_label: " << id_field->getLabel() << G4endl;
+ G4cout << "field_start: " << field_start << G4endl;
+ G4cout << "field_val (dec): " << dec << field_val << G4endl;
+ G4cout << "field_val (hex): " << hex << field_val << G4endl;
+ G4cout << "field_bit_len: " << dec << field_bit_len << G4endl;
+ G4cout << "field_mask: " << hex << field_mask << G4endl;
+#endif
+
+ /* For positive values, check that this value doesn't overflow the assigned length. */
+ // if ( field_val > 0 ) {
+ if (checkOverflow(field_val, field_mask) != 0) {
+ G4cerr << "Value <" << field_val << "> is too big for the field <" << id_field->getLabel() << ">, len <" << field_bit_len << ">." << G4endl;
+ G4Exception("", "", FatalException, "Value too large for field.");
+ }
+ // }
+ // else {
+ // }
+
+#ifdef ID_DEBUG
+ G4cout << "field_mask: " << hex << field_mask << G4endl;
+#endif
+
+ /* Apply bit mask and shift to proper left pos. */
+ Bits field_val_shifted_masked = (field_val & field_mask) << field_start;
+
+ /* AND into the current id val. */
+ (*id64_val_ptr) = (*id64_val_ptr) | field_val_shifted_masked;
+
+ /* Set current bit to next start pos. */
+ curr_bit += id_field->getLength();
+
+#ifdef ID_DEBUG
+ G4cout << "id64_val (hex): " << hex << *id64_val_ptr << G4endl;
+ G4cout << G4endl;
+#endif
+
+ /* Increment the idspec idx. */
+ ++idspec_idx;
+ }
+
+#ifdef ID_DEBUG
+ G4cout << "end curr_bit: " << dec << curr_bit << G4endl;
+ G4cout << "end id64[0]: " << hex << id64_val[0] << G4endl;
+ G4cout << "end id64[1]: " << hex << id64_val[1] << G4endl;
+ G4cout.unsetf( ios::hex );
+ G4cout << G4endl << G4endl;
+#endif
+
+ /* Set the two 32-bit ids in the packed id to return. */
+ id64.setId0(id64_val[0]);
+ id64.setId1(id64_val[1]);
+
+ return id64;
+}
+
+inline IdFactory::Bits IdFactory::makeBitMask(IdField::SizeType len)
+{
+ return (Bits) ((1 << len) - 1);
+}
+
+inline IdFactory::Bits IdFactory::checkOverflow(Id64bit::ElementType val, Bits mask)
+{
+ Bits xbits = 0x0;
+
+ /* get flipped mask of all 1's in positions that should be masked off for this val */
+ Bits flipMask = mask ^ MASK_ON;
+
+ /* mask off all the valid bits, leaving overflow bits */
+ Id64bit::ElementType overflow = (val & flipMask);
+
+ /* for pos vals, check that no bits past max bit are = 1 */
+ if (val >= 0) {
+ xbits = (Bits) ((flipMask) & overflow);
+ }
+ /* for neg vals, check that no bits past max bit are = 0 */
+ else {
+ xbits = (Bits) ((flipMask) ^ overflow);
+ }
+
+#ifdef ID_DEBUG
+ G4cout << "flipMask: " << hex << flipMask << G4endl;
+ G4cout << "overflow: " << hex << overflow << G4endl;
+ G4cout << "overflow bits (hex): " << hex << xbits << G4endl;
+#endif
+
+ return xbits;
+}
+
+IdVec IdFactory::createOrderedIdVec(G4Step* aStep, const G4SensitiveDetector* sd)
+{
+ //std::cout << "createOrderedIdVec" << std::endl;
+
+ assert(aStep);
+ assert(sd);
+
+ IdSpec* idspec = sd->getIdSpec();
+ IdVec ids;
+
+ G4Segmentation* seg = 0;
+ if (sd->getType() == G4SensitiveDetector::eCalorimeter) {
+ seg = (dynamic_cast<const G4CalorimeterSD*>(sd))->getSegmentation();
+ }
+
+ if (idspec) {
+ for (IdSpec::IdFields::const_iterator iter = idspec->IdFieldsBegin(); iter != idspec->IdFieldsEnd(); iter++) {
+
+ IdField* f = *iter;
+
+ int bin_val = 0;
+ bool fnd_it = false;
+
+#ifdef ID_DEBUG
+ G4cout << "handling field: " << f->getLabel() << G4endl;
+#endif
+
+ // look in seg, if exists
+ if (seg) {
+ int bin_idx = IdFactory::findFieldIdxInSegmentation(seg, f->getLabel());
+
+ if (bin_idx != -1) {
+ //std::cout << "getting bin: " << bin_idx << std::endl;
+ bin_val = seg->getBin(bin_idx);
+ //std::cout << "got bin val: " << bin_val << std::endl;
+ fnd_it = true;
+ }
+#ifdef ID_DEBUG
+ else {
+ G4cout << "not in segmentation" << G4endl;
+ }
+#endif
+ }
+
+ // find in PV ids
+ if (!fnd_it) {
+ std::vector<G4VPhysicalVolume*> pv_list = ReadoutUtil::getPhysVolList(aStep);
+
+ if (hasPhysVolId(pv_list, f->getLabel())) {
+ fnd_it = true;
+ bin_val = findIdInPhysVols(pv_list, f->getLabel());
+ }
+#ifdef ID_DEBUG
+ else {
+ G4cout << "not in physvolids" << G4endl;
+ }
+#endif
+
+ }
+
+ /* Find in copy numbers of the volume. */
+ if (!fnd_it && f->getLabel() == "volume") {
+ bin_val = ReadoutUtil::getVolumeNumber(aStep->GetPreStepPoint()->GetTouchableHandle());
+
+ if (-1 == bin_val) {
+ G4Exception("", "", FatalException, "Valid copy number not found for PV.");
+ } else {
+ fnd_it = true;
+ }
+ }
+#ifdef ID_DEBUG
+ else {
+ G4cout << "not in volume (copyNum)" << G4endl;
+ }
+#endif
+
+ // Push back zero as the default value for field not found.
+ ids.push_back(bin_val);
+
+#ifdef ID_DEBUG
+ G4cout << "set bin val: " << bin_val << G4endl << G4endl;
+#endif
+ }
+ }
+
+ return ids;
+}
+
+int IdFactory::findFieldIdxInSegmentation(G4Segmentation* seg, const std::string& field_name)
+{
+ const std::vector<std::string>& bin_names = seg->getBinNames();
+
+ int bin_count = 0;
+ bool fnd = false;
+ for (std::vector<std::string>::const_iterator iter = bin_names.begin(); iter != bin_names.end(); iter++) {
+ if (*iter == field_name) {
+ fnd = true;
+ break;
+ }
+ ++bin_count;
+ }
+
+ if (!fnd) {
+ bin_count = -1;
+ }
+
+ return bin_count;
+}
+
+int IdFactory::findIdInPhysVols(const std::vector<G4VPhysicalVolume*>& pvs, const std::string& field_name)
+{
+ IdManager* id_mgr = IdManager::instance();
+
+#ifdef ID_DEBUG
+ G4cout << "looking for field_name match on <" << field_name << ">" << G4endl;
+#endif
+
+ int id = 0;
+ G4VPhysicalVolume* pv = 0;
+ bool fnd = false;
+
+ for (std::vector<G4VPhysicalVolume*>::const_iterator iter_pv = pvs.begin(); iter_pv != pvs.end(); iter_pv++) {
+ pv = *iter_pv;
+
+#ifdef ID_DEBUG
+ G4cout << "searching in ids of PV <" << pv->GetName() << ">" << G4endl;
+#endif
+
+ if (id_mgr->hasPhysVolIds(pv)) {
+ PhysVolId::PhysVolIds pvids = id_mgr->getPhysVolIds(pv);
+ for (PhysVolId::PhysVolIds::const_iterator iter = pvids.begin(); iter != pvids.end(); iter++) {
+
+#ifdef ID_DEBUG
+ G4cout << "current field <" << (*iter).getFieldName() << ">" << G4endl;
+#endif
+
+ if ((*iter).getFieldName() == field_name) {
+#ifdef ID_DEBUG
+ G4cout << "found a match" << G4endl;
+#endif
+ id = (*iter).getValue();
+ fnd = true;
+ break;
+ }
+#ifdef ID_DEBUG
+ else {
+ G4cout << "no match on this PV" << G4endl;
+ }
+#endif
+ }
+ }
+
+ if (fnd) {
+ break;
+ }
+ }
+
+ return id;
+}
+
+bool IdFactory::hasPhysVolId(const std::vector<G4VPhysicalVolume*>& pvs, const std::string& field_name)
+{
+ IdManager* id_mgr = IdManager::instance();
+
+ G4VPhysicalVolume* pv = 0;
+ bool fnd = false;
+
+ for (std::vector<G4VPhysicalVolume*>::const_iterator iter_pv = pvs.begin(); iter_pv != pvs.end(); iter_pv++) {
+ pv = *iter_pv;
+
+ if (id_mgr->hasPhysVolIds(pv)) {
+ PhysVolId::PhysVolIds pvids = id_mgr->getPhysVolIds(pv);
+ for (PhysVolId::PhysVolIds::const_iterator iter = pvids.begin(); iter != pvids.end(); iter++) {
+
+ if ((*iter).getFieldName() == field_name) {
+ fnd = true;
+ break;
+ }
+ }
+ }
+
+ if (fnd) {
+ break;
+ }
+ }
+
+ return fnd;
+}
lcdd/src/lcdd/id
diff -N IdFieldProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IdFieldProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,77 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/id/IdFieldProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// GDML
+#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"
+
+// LCDD
+#include "lcdd/schema/idfieldElem.hh"
+
+// std
+#include <iostream>
+
+/**
+ @class idfieldProcess
+ @brief SAX process to create the idfield element.
+ */
+class idfieldProcess: public SAXStateProcess
+{
+public:
+
+ idfieldProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~idfieldProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ SAXObject** obj = Context()->GetTopObject();
+
+ idfieldElem* idfield = new idfieldElem;
+
+ idfield->set_label(attrs.getValue("label"));
+ idfield->set_start(attrs.getValue("start"));
+ idfield->set_length(attrs.getValue("length"));
+ idfield->set_signed(attrs.getValue("signed"));
+
+ m_obj = idfield;
+ *obj = idfield;
+ }
+ 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 = "idfield";
+ return tag;
+ }
+
+private:
+
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(idfieldProcess)
lcdd/src/lcdd/id
diff -N IdManager.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IdManager.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,88 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/id/IdManager.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/id/IdManager.hh"
+
+// Geant4
+#include "G4LogicalVolume.hh"
+
+IdManager* IdManager::m_instance = 0;
+
+IdManager::IdManager()
+{
+}
+
+IdManager::~IdManager()
+{
+}
+
+IdManager* IdManager::instance()
+{
+ if (m_instance == 0) {
+ m_instance = new IdManager;
+ }
+
+ return m_instance;
+}
+
+void IdManager::addIdSpec(const std::string& name, IdSpec* spec)
+{
+ m_idSpecs[name] = spec;
+}
+
+IdSpec* IdManager::getIdSpec(const char* name)
+{
+ std::string key = name;
+ return getIdSpec(key);
+}
+
+IdSpec* IdManager::getIdSpec(const std::string& name)
+{
+ return m_idSpecs[name];
+}
+
+IdManager::IdSpecs::const_iterator IdManager::getIdSpecsBegin()
+{
+ return m_idSpecs.begin();
+}
+
+IdManager::IdSpecs::const_iterator IdManager::getIdSpecsEnd()
+{
+ return m_idSpecs.end();
+}
+
+void IdManager::addPhysVolId(G4LogicalVolume* lvMom, int childIdx, PhysVolId childId)
+{
+ // DEBUG
+ //std::cout << std::endl << "assigning physvolid..." << std::endl;
+ //std::cout << "lvMom <" << lvMom->GetName() << ">" << std::endl;
+ //std::cout << "childIdx <" << childIdx << ">" << std::endl;
+ //std::cout << "childId field: " << childId.getFieldName() << std::endl;
+ //std::cout << "childId <" << childId.getValue() << ">" << std::endl;
+ //
+
+ G4VPhysicalVolume* dau = lvMom->GetDaughter(childIdx);
+
+ if (dau) {
+
+ //std::cout << "found daughter <" << dau->GetName() << ">" << std::endl;
+ //std::cout << "dau ptr <" << dau << ">" << std::endl;
+
+ m_physVolIdMap.addPhysVolId(dau, childId);
+ } else {
+ std::cerr << "IdManager::assignPhysVolId() - childIdx <" << childIdx << "> does not exist!" << std::endl;
+ }
+
+ //std::cout << std::endl;
+}
+
+void IdManager::printIds(std::ostream& os, const IdVec& ids)
+{
+ os << "id stack:";
+
+ for (std::vector<int>::const_iterator iter = ids.getFieldsBegin(); iter != ids.getFieldsEnd(); iter++) {
+ os << " " << *iter;
+ }
+
+ os << std::endl;
+}
lcdd/src/lcdd/id
diff -N IdSpec.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IdSpec.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,89 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/id/IdSpec.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/id/IdSpec.hh"
+
+// STL
+#include <sstream>
+
+using namespace std;
+
+void IdSpec::printOut(std::ostream& os) const
+{
+ os << std::endl;
+
+ os << "IdSpec: " << m_name << std::endl;
+ os << "bitLength: " << m_bitLength << std::endl;
+
+ static const int def_width = 15;
+
+ os.width(def_width);
+ os << left << "label";
+
+ os.width(def_width);
+ os << left << "start";
+
+ os.width(def_width);
+ os << left << "end";
+
+ os.width(def_width);
+ os << left << "size";
+
+ os.width(def_width);
+ os << left << "signed";
+
+ os << std::endl;
+
+ os.fill('-');
+ os.width(66);
+ os << left << "-" << std::endl;
+
+ os.fill(' ');
+
+ for (IdFields::const_iterator iter = IdFieldsBegin(); iter != IdFieldsEnd(); iter++) {
+
+ IdField* f = *iter;
+
+ os.width(def_width);
+ os << left << f->getLabel();
+
+ os.width(def_width);
+ os << left << f->getStart();
+
+ os.width(def_width);
+ os << left << f->getStart() + f->getLength() - 1;
+
+ os.width(def_width);
+ os << left << f->getLength();
+
+ os.width(def_width);
+ os << left << f->getSigned();
+
+ os.width(def_width);
+ os << left << std::endl;
+ }
+
+ os << std::endl;
+}
+
+std::string IdSpec::getFieldDescription()
+{
+ std::stringstream enc;
+
+ // Loop over the fields in the IdSpec.
+ for (IdSpec::IdFields::const_iterator it = this->IdFieldsBegin(); it != this->IdFieldsEnd(); it++) {
+
+ // Get the IdField.
+ IdField* field = (*it);
+
+ // Encode the field information into the LCIO / compact format.
+ enc << field->getLabel() << ":" << field->getStart() << ":";
+ if (field->getSigned()) {
+ enc << "-";
+ }
+ enc << field->getLength() << ",";
+ }
+
+ // Return the id description string, eliminating last comma.
+ return enc.str().substr(0, enc.str().length() - 1);
+}
lcdd/src/lcdd/id
diff -N IdVec.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IdVec.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,47 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/id/IdVec.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/id/IdVec.hh"
+
+IdVec::IdVec()
+{
+}
+
+IdVec::~IdVec()
+{
+}
+
+void IdVec::clear()
+{
+ m_fields.clear();
+}
+
+void IdVec::push_back(ElementType et)
+{
+ m_fields.push_back(et);
+}
+
+IdVec::ElementType IdVec::getFieldValue(SizeType idx) const
+{
+ return m_fields.at(idx);
+}
+
+void IdVec::setFieldValue(SizeType idx, ElementType et)
+{
+ m_fields.insert(m_fields.begin() + idx, et);
+}
+
+IdVec::ElementType IdVec::operator [](SizeType idx) const
+{
+ return getFieldValue(idx);
+}
+
+IdVec::ElementVector::const_iterator IdVec::getFieldsBegin() const
+{
+ return m_fields.begin();
+}
+
+IdVec::ElementVector::const_iterator IdVec::getFieldsEnd() const
+{
+ return m_fields.end();
+}
lcdd/src/lcdd/schema
diff -N authorProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ authorProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,77 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/authorProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/author.hh"
+
+// GDML
+#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"
+
+// STL
+#include <iostream>
+
+/**
+ * @brief SAX process for author element.
+ */
+class authorProcess: public SAXStateProcess
+{
+
+public:
+
+ authorProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~authorProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ //std::cout << "authorProcess::StartElement" << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ author* a = new author;
+
+ a->set_name(attrs.getValue("name"));
+ a->set_email(attrs.getValue("email"));
+
+ m_obj = a;
+ *obj = a;
+ }
+
+ 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 = "author";
+ return tag;
+ }
+
+private:
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(authorProcess)
lcdd/src/lcdd/schema
diff -N box_dipoleProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ box_dipoleProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,74 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/box_dipoleProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// GDML
+#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"
+
+// LCDD
+#include "lcdd/schema/box_dipole.hh"
+#include "lcdd/schema/FieldTypeProcess.hh"
+
+// STL
+#include <iostream>
+
+class box_dipoleProcess: public FieldTypeProcess
+{
+public:
+
+ box_dipoleProcess(const ProcessingContext* context = 0) :
+ FieldTypeProcess(context)
+ {
+ }
+
+ virtual ~box_dipoleProcess()
+ {
+ }
+
+ void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+ {
+ SAXObject** obj = Context()->GetTopObject();
+
+ box_dipole* x = new box_dipole;
+
+ x->set_x(attrs.getValue("x"));
+ x->set_y(attrs.getValue("y"));
+ x->set_z(attrs.getValue("z"));
+ x->set_dx(attrs.getValue("dx"));
+ x->set_dy(attrs.getValue("dy"));
+ x->set_dz(attrs.getValue("dz"));
+ x->set_bx(attrs.getValue("bx"));
+ x->set_by(attrs.getValue("by"));
+ x->set_bz(attrs.getValue("bz"));
+
+ m_obj = x;
+ *obj = x;
+
+ FieldTypeProcess::StartElement(name, attrs);
+ }
+
+ void EndElement(const std::string&)
+ {
+ }
+
+ void Characters(const std::string&)
+ {
+ }
+
+ void StackPopNotify(const std::string&)
+ {
+ }
+
+ const std::string& State() const
+ {
+ static std::string tag = "box_dipole";
+ return tag;
+ }
+};
+
+DECLARE_PROCESS_FACTORY(box_dipoleProcess)
+
lcdd/src/lcdd/schema
diff -N calorimeterProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ calorimeterProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,48 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/calorimeterProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/calorimeterProcess.hh"
+
+calorimeterProcess::calorimeterProcess(const ProcessingContext* context) :
+ SensitiveDetectorTypeProcess(context)
+{
+}
+
+calorimeterProcess::~calorimeterProcess()
+{
+}
+
+void calorimeterProcess::StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+{
+ SAXObject** obj = Context()->GetTopObject();
+ calorimeter* cal = new calorimeter;
+
+ cal->set_compare(attrs.getValue("hit_aggregation"));
+
+ m_obj = cal;
+ *obj = cal;
+
+ // parent type to set name and hitsCollectionName
+ SensitiveDetectorTypeProcess::StartElement(name, attrs);
+}
+
+void calorimeterProcess::EndElement(const std::string&)
+{
+}
+
+void calorimeterProcess::Characters(const std::string&)
+{
+}
+
+void calorimeterProcess::StackPopNotify(const std::string& name)
+{
+ SensitiveDetectorTypeProcess::StackPopNotify(name);
+}
+
+const std::string& calorimeterProcess::State() const
+{
+ static std::string tag = "calorimeter";
+ return tag;
+}
+
+DECLARE_PROCESS_FACTORY(calorimeterProcess)
lcdd/src/lcdd/schema
diff -N cell_readout_2dProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ cell_readout_2dProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,77 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/cell_readout_2dProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// GDML
+#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"
+
+// LCDD
+#include "lcdd/schema/cell_readout_2d.hh"
+
+// STL
+#include <iostream>
+
+class cell_readout_2dProcess: public SAXStateProcess
+{
+
+public:
+
+ cell_readout_2dProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~cell_readout_2dProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+ {
+ std::cout << "cell_readout_2dProcess::StartElement: " << name << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ cell_readout_2d* np = new cell_readout_2d;
+
+ np->setLengthUnit(attrs.getValue("lunit"));
+
+ np->setCellSizeX(attrs.getValue("cell_size_x"));
+ np->setCellSizeY(attrs.getValue("cell_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 = "cell_readout_2d";
+ return tag;
+ }
+
+private:
+
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(cell_readout_2dProcess)
lcdd/src/lcdd/schema
diff -N colorProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ colorProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,80 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/colorProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/color.hh"
+
+// GDML
+#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"
+
+// STL
+#include <iostream>
+
+/**
+ @class colorProcess
+ @brief SAX process for color element.
+ */
+class colorProcess: public SAXStateProcess
+{
+public:
+
+ colorProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~colorProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ //std::cout << "color::StartElement()" << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ color* c = new color;
+
+ c->set_R(attrs.getValue("R"));
+ c->set_G(attrs.getValue("G"));
+ c->set_B(attrs.getValue("B"));
+ c->set_alpha(attrs.getValue("alpha"));
+
+ m_obj = c;
+ *obj = c;
+ }
+
+ 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 = "color";
+ return tag;
+ }
+
+private:
+
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(colorProcess)
lcdd/src/lcdd/schema
diff -N commentProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ commentProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,75 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/commentProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// GDML
+#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"
+
+// LCDD
+#include "lcdd/schema/comment.hh"
+
+// STL
+#include <iostream>
+
+/**
+ @class commentProcess
+ @brief SAX process for comment element.
+ */
+class commentProcess: public SAXStateProcess
+{
+public:
+ commentProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+ virtual ~commentProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList&)
+ {
+ //std::cout << "commentProcess::StartElement" << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ comment* c = new comment;
+
+ m_obj = c;
+ *obj = c;
+ }
+
+ virtual void EndElement(const std::string&)
+ {
+ }
+
+ virtual void Characters(const std::string& cdata)
+ {
+ //std::cout << "commentProcess::Characters() - <" << cdata << ">" << std::endl;
+ comment* c = dynamic_cast<comment*>(m_obj);
+ c->set_comment(cdata);
+ }
+
+ virtual void StackPopNotify(const std::string&)
+ {
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "comment";
+ return tag;
+ }
+
+private:
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(commentProcess)
lcdd/src/lcdd/schema
diff -N detectorProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ detectorProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,74 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/detectorProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/detector.hh"
+
+// GDML
+#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"
+
+// STL
+#include <iostream>
+
+/**
+ * @brief SAX process for detector element.
+ */
+class detectorProcess: public SAXStateProcess
+{
+public:
+ detectorProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~detectorProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ SAXObject** obj = Context()->GetTopObject();
+
+ detector* d = new detector;
+
+ d->set_name(attrs.getValue("name"));
+ d->set_version(attrs.getValue("version"));
+ d->set_url(attrs.getValue("url"));
+
+ m_obj = d;
+ *obj = d;
+ }
+
+ 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 = "detector";
+ return tag;
+ }
+
+private:
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(detectorProcess)
lcdd/src/lcdd/schema
diff -N dipoleProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ dipoleProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,77 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/dipoleProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/dipole.hh"
+
+// GDML
+#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"
+
+/**
+ * @brief SAX process for the dipole element.
+ */
+class dipoleProcess: public SAXStateProcess
+{
+public:
+
+ dipoleProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~dipoleProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ SAXObject** obj = Context()->GetTopObject();
+
+ dipole* d = new dipole;
+ d->set_name(attrs.getValue("name"));
+ d->set_lunit(attrs.getValue("lunit"));
+ d->set_funit(attrs.getValue("funit"));
+ d->set_zmax(attrs.getValue("zmax"));
+ d->set_zmin(attrs.getValue("zmin"));
+ d->set_rmax(attrs.getValue("rmax"));
+
+ m_obj = d;
+ *obj = d;
+ }
+
+ virtual void EndElement(const std::string&)
+ {
+ }
+
+ virtual void Characters(const std::string&)
+ {
+ }
+
+ virtual void StackPopNotify(const std::string& name)
+ {
+ SAXObject** so = Context()->GetTopObject();
+ dipole* d = dynamic_cast<dipole*>(m_obj);
+ d->add_content(name, *so);
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "dipole";
+ return tag;
+ }
+
+private:
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(dipoleProcess)
lcdd/src/lcdd/schema
diff -N dipole_coeffProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ dipole_coeffProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,74 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/dipole_coeffProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// GDML
+#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"
+
+// LCDD
+#include "lcdd/schema/dipole_coeff.hh"
+
+// STL
+#include <iostream>
+
+/**
+ * @class dipole_coeffProcess
+ * @brief SAX process to create the dipole_coeff element.
+ */
+class dipole_coeffProcess: public SAXStateProcess
+{
+public:
+
+ dipole_coeffProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~dipole_coeffProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ SAXObject** obj = Context()->GetTopObject();
+
+ dipole_coeff* dpc = new dipole_coeff;
+
+ dpc->set_value(attrs.getValue("value"));
+
+ m_obj = dpc;
+ *obj = dpc;
+ }
+ 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 = "dipole_coeff";
+ return tag;
+ }
+
+private:
+
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(dipole_coeffProcess)
lcdd/src/lcdd/schema
diff -N field_map_3dProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ field_map_3dProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,68 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/field_map_3dProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/FieldMapTypeProcess.hh"
+#include "lcdd/schema/field_map_3d.hh"
+
+// STL
+#include <iostream>
+
+// Geant4
+#include "globals.hh"
+
+/**
+ * @brief
+ */
+class field_map_3dProcess: public FieldMapTypeProcess
+{
+
+public:
+
+ field_map_3dProcess(const ProcessingContext* context = 0) :
+ FieldMapTypeProcess(context)
+ {
+ }
+
+ virtual ~field_map_3dProcess()
+ {
+ }
+
+ virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+ {
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ field_map_3d* fmap = new field_map_3d;
+
+ fmap->set_filename(attrs.getValue("filename"));
+
+ // Top-level caller needs to setup the SAXObject references.
+ m_obj = fmap;
+ *obj = fmap;
+
+ // Call next process UP in inheritance chain, after the SAXObject is set.
+ FieldMapTypeProcess::StartElement(name, attrs);
+ }
+
+ virtual void EndElement(const std::string&)
+ {
+ }
+
+ virtual void Characters(const std::string&)
+ {
+ }
+
+ virtual void StackPopNotify(const std::string& name)
+ {
+ //std::cout << "field_map_3d::StackPopNotify" << std::endl;
+ FieldMapTypeProcess::StackPopNotify(name);
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "field_map_3d";
+ return tag;
+ }
+};
+
+DECLARE_PROCESS_FACTORY(field_map_3dProcess)
lcdd/src/lcdd/schema
diff -N fieldrefProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ fieldrefProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,48 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/fieldrefProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// GDML
+#include "Processes/ReferenceTypeProcess.h"
+
+// LCDD
+#include "lcdd/schema/FieldType.hh"
+
+/**
+ * @brief SAX process for fieldref element.
+ */
+class fieldrefProcess: public ReferenceTypeProcess
+{
+public:
+ fieldrefProcess(const ProcessingContext* context = 0) :
+ ReferenceTypeProcess(context)
+ {
+ }
+
+ virtual ~fieldrefProcess()
+ {
+ }
+
+ virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+ {
+ SAXObject** obj = Context()->GetTopObject();
+
+ FieldType::fieldref* fref = new FieldType::fieldref;
+
+ *obj = fref;
+ m_obj = fref;
+
+ ReferenceTypeProcess::StartElement(name, attrs);
+ }
+
+ virtual void EndElement(const std::string& name)
+ {
+ ReferenceTypeProcess::EndElement(name);
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "fieldref";
+ return tag;
+ }
+};
+
+DECLARE_PROCESS_FACTORY(fieldrefProcess)
lcdd/src/lcdd/schema
diff -N generatorProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ generatorProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,75 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/generatorProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/generator.hh"
+
+// GDML
+#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"
+
+// STL
+#include <iostream>
+
+/**
+ * @brief SAX process for generator element.
+ */
+class generatorProcess: public SAXStateProcess
+{
+public:
+ generatorProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~generatorProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ SAXObject** obj = Context()->GetTopObject();
+
+ generator* g = new generator;
+
+ g->set_name(attrs.getValue("name"));
+ g->set_version(attrs.getValue("version"));
+ g->set_file(attrs.getValue("file"));
+ g->set_checksum(attrs.getValue("checksum"));
+
+ m_obj = g;
+ *obj = g;
+ }
+
+ 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 = "generator";
+ return tag;
+ }
+
+private:
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(generatorProcess)
lcdd/src/lcdd/schema
diff -N global_fieldProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ global_fieldProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,76 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/global_fieldProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// GDML
+#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"
+
+// LCDD
+#include "lcdd/schema/global_field.hh"
+#include "lcdd/schema/SensitiveDetectorTypeProcess.hh"
+
+// STL
+#include <iostream>
+
+/**
+ * @brief SAX process for global_field element.
+ */
+class global_fieldProcess: public SAXStateProcess
+{
+public:
+ global_fieldProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~global_fieldProcess()
+ {
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList&)
+ {
+ //std::cout << "global_fieldProcess::StartElement: " << name << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ global_field* cal = new global_field;
+
+ m_obj = cal;
+ *obj = cal;
+ }
+
+ virtual void EndElement(const std::string&)
+ {
+ //std::cout << "global_fieldProcess::EndElement: " << name << " " << std::endl;
+ }
+
+ virtual void Characters(const std::string&)
+ {
+ }
+
+ virtual void StackPopNotify(const std::string& name)
+ {
+ //std::cout << "global_fieldProcess::StackPopNotify: " << name << std::endl;
+
+ SAXObject** so = Context()->GetTopObject();
+ global_field* fobj = dynamic_cast<global_field*>(m_obj);
+
+ fobj->add_content(name, *so);
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "global_field";
+ return tag;
+ }
+
+protected:
+ SAXObject* m_obj;
+
+};
+
+DECLARE_PROCESS_FACTORY(global_fieldProcess)
lcdd/src/lcdd/schema
diff -N global_grid_xyProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ global_grid_xyProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,82 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/global_grid_xyProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// GDML
+#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"
+
+// LCDD
+#include "lcdd/schema/global_grid_xy.hh"
+
+// STL
+#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/lcdd/schema
diff -N grid_xyzProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ grid_xyzProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,83 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/grid_xyzProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/grid_xyz.hh"
+
+// GDML
+#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"
+
+// STL
+#include <iostream>
+
+/**
+ * @brief SAX process for grid_xyz element.
+ */
+class grid_xyzProcess: public SAXStateProcess
+{
+
+public:
+
+ grid_xyzProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~grid_xyzProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ //std::cout << "grid_xyzProcess::StartElement: " << name << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ grid_xyz* np = new grid_xyz;
+
+ np->set_lunit(attrs.getValue("lunit"));
+
+ np->set_gridSizeX(attrs.getValue("grid_size_x"));
+ np->set_gridSizeY(attrs.getValue("grid_size_y"));
+ np->set_gridSizeZ(attrs.getValue("grid_size_z"));
+
+ m_obj = np;
+ *obj = np;
+ }
+
+ virtual void EndElement(const std::string&)
+ {
+ //std::cout << "PROCESS::END OF TAG : " << name << " " << std::endl;
+ }
+
+ virtual void Characters(const std::string&)
+ {
+ }
+
+ virtual void StackPopNotify(const std::string&)
+ {
+ //std::cout << "PROCESS::NOTIFIED AFTER THE TAG: " << name << std::endl;
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "grid_xyz";
+ return tag;
+ }
+
+private:
+
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(grid_xyzProcess)
lcdd/src/lcdd/schema
diff -N headerProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ headerProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,79 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/headerProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/header.hh"
+
+// GDML
+#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"
+
+// STL
+#include <iostream>
+
+/**
+ * @brief SAX process for header element.
+ */
+class headerProcess: public SAXStateProcess
+{
+public:
+ headerProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~headerProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList&)
+ {
+ //std::cout << "headerProcess::StartElement" << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ header* h = new header;
+
+ m_obj = h;
+ *obj = h;
+ }
+
+ virtual void EndElement(const std::string&)
+ {
+ }
+
+ virtual void Characters(const std::string&)
+ {
+ }
+
+ virtual void StackPopNotify(const std::string& name)
+ {
+ //std::cout << "headerProcess::StackPopNotify" << std::endl;
+
+ SAXObject** so = Context()->GetTopObject();
+ header* h = dynamic_cast<header*>(m_obj);
+
+ h->add_content(name, *so);
+
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "header";
+ return tag;
+ }
+
+private:
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(headerProcess)
lcdd/src/lcdd/schema
diff -N idspecProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ idspecProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,80 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/idspecProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/idspecElem.hh"
+
+// GDML
+#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"
+
+// STL
+#include <iostream>
+
+/**
+ * @brief SAX process for idspec element.
+ */
+class idspecProcess: public SAXStateProcess
+{
+public:
+
+ idspecProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~idspecProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ //std::cout << "idspecProcess::StartElement() - " << name << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ idspecElem* idspec = new idspecElem;
+
+ idspec->set_name(attrs.getValue("name"));
+ idspec->set_length(attrs.getValue("length"));
+
+ m_obj = idspec;
+ *obj = idspec;
+ }
+ virtual void EndElement(const std::string&)
+ {
+ }
+
+ virtual void Characters(const std::string&)
+ {
+ }
+
+ virtual void StackPopNotify(const std::string& name)
+ {
+ SAXObject** so = Context()->GetTopObject();
+ idspecElem* idspec = dynamic_cast<idspecElem*>(m_obj);
+ idspec->add_content(name, *so);
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "idspec";
+ return tag;
+ }
+
+private:
+
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(idspecProcess)
+
lcdd/src/lcdd/schema
diff -N idspecrefProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ idspecrefProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,51 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/idspecrefProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// GDML
+#include "Processes/ReferenceTypeProcess.h"
+
+// LCDD
+#include "lcdd/schema/IdSpecType.hh"
+
+// STL
+#include <iostream>
+
+/**
+ * @brief SAX process for idspecref element.
+ * @note Extends ReferenceTypeProcess for reference to idspec element.
+ */
+class idspecrefProcess: public ReferenceTypeProcess
+{
+public:
+ idspecrefProcess(const ProcessingContext* context = 0) :
+ ReferenceTypeProcess(context)
+ {
+ }
+
+ virtual ~idspecrefProcess()
+ {
+ }
+
+ virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+ {
+ SAXObject** obj = Context()->GetTopObject();
+ IdSpecType::idspecref* s = new IdSpecType::idspecref;
+
+ *obj = s;
+ m_obj = s;
+
+ ReferenceTypeProcess::StartElement(name, attrs);
+ }
+
+ virtual void EndElement(const std::string& name)
+ {
+ ReferenceTypeProcess::EndElement(name);
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "idspecref";
+ return tag;
+ }
+};
+
+DECLARE_PROCESS_FACTORY(idspecrefProcess)
lcdd/src/lcdd/schema
diff -N limitProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ limitProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,77 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/limitProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+
+// GDML
+#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"
+
+// LCDD
+#include "lcdd/schema/limit.hh"
+
+/**
+ *
+ */
+
+class limitProcess: public SAXStateProcess
+{
+
+public:
+ limitProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~limitProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ SAXObject** obj = Context()->GetTopObject();
+
+ limit* lim = new limit;
+
+ lim->set_name(attrs.getValue("name"));
+ lim->set_value(attrs.getValue("value"));
+ lim->set_particles(attrs.getValue("particles"));
+ lim->set_unit(attrs.getValue("unit"));
+
+ m_obj = lim;
+ *obj = lim;
+ }
+
+ virtual void EndElement(const std::string&)
+ {
+ }
+
+ virtual void StackPopNotify(const std::string&)
+ {
+ }
+
+ virtual void Characters(const std::string&)
+ {
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "limit";
+ return tag;
+ }
+
+private:
+
+ SAXObject* m_obj;
+
+};
+
+DECLARE_PROCESS_FACTORY(limitProcess)
lcdd/src/lcdd/schema
diff -N limitrefProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ limitrefProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,50 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/limitrefProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// GDML
+#include "Processes/ReferenceTypeProcess.h"
+
+// LCDD
+#include "lcdd/schema/LimitType.hh"
+
+/**
+ * @brief SAX process for limitref element.
+ */
+class limitrefProcess: public ReferenceTypeProcess
+{
+public:
+ limitrefProcess(const ProcessingContext* context = 0) :
+ ReferenceTypeProcess(context)
+ {
+ }
+
+ virtual ~limitrefProcess()
+ {
+ }
+
+ virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+ {
+ //std::cout << "limitrefProcess" << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ LimitType::limitref* lref = new LimitType::limitref;
+
+ *obj = lref;
+ m_obj = lref;
+
+ ReferenceTypeProcess::StartElement(name, attrs);
+ }
+
+ virtual void EndElement(const std::string& name)
+ {
+ ReferenceTypeProcess::EndElement(name);
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "limitref";
+ return tag;
+ }
+};
+
+//DECLARE_PROCESS_FACTORY(limitrefProcess);
lcdd/src/lcdd/schema
diff -N limitsetProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ limitsetProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,83 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/limitsetProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/limitset.hh"
+#include "lcdd/schema/limit.hh"
+
+// GDML
+#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"
+
+// Geant4
+#include "globals.hh"
+
+class limitsetProcess: public SAXStateProcess
+{
+public:
+ limitsetProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~limitsetProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ SAXObject** obj = Context()->GetTopObject();
+
+ limitset* lim = new limitset;
+ lim->set_name(attrs.getValue("name"));
+
+ m_obj = lim;
+ *obj = lim;
+ }
+
+ virtual void EndElement(const std::string&)
+ {
+ }
+
+ virtual void Characters(const std::string&)
+ {
+ }
+
+ virtual void StackPopNotify(const std::string& name)
+ {
+ if (name == "limit") {
+ SAXObject** so = Context()->GetTopObject();
+ limitset* lim = dynamic_cast<limitset*>(m_obj);
+
+ if (lim != 0) {
+ lim->add_content(name, *so);
+ } else {
+ G4Exception("limitsetProcess::StackPopNotify()", "", FatalException, "Failed cast to limitset.");
+ }
+ } else {
+ std::cerr << "limitsetProcess::StackPopNotify() - Got limitset content that wasn't limit." << std::endl;
+ }
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "limitset";
+ return tag;
+ }
+
+private:
+
+ SAXObject* m_obj;
+
+};
+
+DECLARE_PROCESS_FACTORY(limitsetProcess)
lcdd/src/lcdd/schema
diff -N limitsetrefProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ limitsetrefProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,50 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/limitsetrefProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// GDML
+#include "Processes/ReferenceTypeProcess.h"
+
+// LCDD
+#include "lcdd/schema/LimitSetType.hh"
+
+/**
+ * @brief SAX process for limitsetref element.
+ */
+class limitsetrefProcess: public ReferenceTypeProcess
+{
+public:
+ limitsetrefProcess(const ProcessingContext* context = 0) :
+ ReferenceTypeProcess(context)
+ {
+ }
+
+ virtual ~limitsetrefProcess()
+ {
+ }
+
+ virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+ {
+ //std::cout << "limitsetrefProcess" << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ LimitSetType::limitsetref* lref = new LimitSetType::limitsetref;
+
+ *obj = lref;
+ m_obj = lref;
+
+ ReferenceTypeProcess::StartElement(name, attrs);
+ }
+
+ virtual void EndElement(const std::string& name)
+ {
+ ReferenceTypeProcess::EndElement(name);
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "limitsetref";
+ return tag;
+ }
+};
+
+DECLARE_PROCESS_FACTORY(limitsetrefProcess)
lcdd/src/lcdd/schema
diff -N nonprojective_cylinderProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ nonprojective_cylinderProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,80 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/nonprojective_cylinderProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// GDML
+#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"
+
+// LCDD
+#include "lcdd/schema/nonprojective_cylinder.hh"
+
+// STL
+#include <iostream>
+
+/**
+ @class nonprojective_cylinderProcess
+ @brief SAX process for nonprojective_cylinder element.
+ */
+class nonprojective_cylinderProcess: public SAXStateProcess
+{
+
+public:
+
+ nonprojective_cylinderProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~nonprojective_cylinderProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ //std::cout << "nonprojective_cylinderProcess::StartElement: " << name << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ nonprojective_cylinder* np = new nonprojective_cylinder;
+
+ np->set_gridSizeZ(attrs.getValue("grid_size_z"));
+ np->set_gridSizePhi(attrs.getValue("grid_size_phi"));
+ np->set_lunit(attrs.getValue("lunit"));
+
+ 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 = "nonprojective_cylinder";
+ return tag;
+ }
+
+private:
+
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(nonprojective_cylinderProcess)
lcdd/src/lcdd/schema
diff -N optical_calorimeterProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ optical_calorimeterProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,43 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/optical_calorimeterProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// GDML
+#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"
+
+// LCDD
+#include "lcdd/schema/optical_calorimeter.hh"
+#include "lcdd/schema/calorimeterProcess.hh"
+
+// STL
+#include <iostream>
+
+/**
+ @class optical_calorimeterProcess
+ @brief SAX process for optical_calorimeter element.
+ @note Calls SAX processor for SensitiveDetectorTypeProcess parent class.
+ */
+class optical_calorimeterProcess: public calorimeterProcess
+{
+public:
+ optical_calorimeterProcess(const ProcessingContext* context = 0) :
+ calorimeterProcess(context)
+ {
+ }
+
+ virtual ~optical_calorimeterProcess()
+ {
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "optical_calorimeter";
+ return tag;
+ }
+};
+
+DECLARE_PROCESS_FACTORY(optical_calorimeterProcess)
lcdd/src/lcdd/schema
diff -N physvolidProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ physvolidProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,69 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/physvolidProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/physvolidElem.hh"
+
+// GDML
+#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"
+
+// STL
+#include <iostream>
+
+/**
+ * @brief SAX process for physvolid element.
+ */
+class physvolidProcess: public SAXStateProcess
+{
+public:
+ physvolidProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~physvolidProcess()
+ {
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ SAXObject** obj = Context()->GetTopObject();
+
+ physvolidElem* pvid = new physvolidElem;
+
+ pvid->set_value(attrs.getValue("value"));
+ pvid->set_field_name(attrs.getValue("field_name"));
+
+ m_obj = pvid;
+ *obj = pvid;
+ }
+
+ 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 = "physvolid";
+ return tag;
+ }
+
+private:
+
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(physvolidProcess)
lcdd/src/lcdd/schema
diff -N projective_cylinderProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ projective_cylinderProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,79 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/projective_cylinderProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/projective_cylinder.hh"
+
+// GDML
+#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"
+
+// STL
+#include <iostream>
+
+/**
+ * @brief SAX process for projective_cylinder element.
+ */
+class projective_cylinderProcess: public SAXStateProcess
+{
+
+public:
+
+ projective_cylinderProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~projective_cylinderProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ //std::cout << "projective_cylinderProcess::StartElement: " << name << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ projective_cylinder* prj = new projective_cylinder;
+
+ prj->set_ntheta(attrs.getValue("ntheta"));
+ prj->set_nphi(attrs.getValue("nphi"));
+
+ m_obj = prj;
+ *obj = prj;
+ }
+
+ 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 = "projective_cylinder";
+ return tag;
+ }
+
+private:
+
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(projective_cylinderProcess)
+
lcdd/src/lcdd/schema
diff -N projective_zplaneProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ projective_zplaneProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,80 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/projective_zplaneProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// GDML
+#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"
+
+// LCDD
+#include "lcdd/schema/projective_zplane.hh"
+
+// STL
+#include <iostream>
+
+/**
+ @class projective_zplaneProcess
+ @brief SAX process for projective_zplane element.
+ */
+class projective_zplaneProcess: public SAXStateProcess
+{
+
+public:
+
+ projective_zplaneProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~projective_zplaneProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ //std::cout << "projective_zplaneProcess::StartElement: " << name << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ projective_zplane* prj = new projective_zplane;
+
+ prj->set_ntheta(attrs.getValue("ntheta"));
+ prj->set_nphi(attrs.getValue("nphi"));
+
+ m_obj = prj;
+ *obj = prj;
+ }
+
+ 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 = "projective_zplane";
+ return tag;
+ }
+
+private:
+
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(projective_zplaneProcess)
+
lcdd/src/lcdd/schema
diff -N regionProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ regionProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,84 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/regionProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/region.hh"
+
+// GDML
+#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"
+
+// STL
+#include <iostream>
+
+/**
+ * @brief SAX process for region element.
+ */
+class regionProcess: public SAXStateProcess
+{
+
+public:
+
+ regionProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~regionProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ SAXObject** obj = Context()->GetTopObject();
+
+ region* reg = new region;
+
+ reg->set_name(attrs.getValue("name"));
+ reg->set_storeSecondaries(attrs.getValue("store_secondaries"));
+ reg->set_killTracks(attrs.getValue("kill_tracks"));
+ reg->set_cut(attrs.getValue("cut"));
+ reg->set_lunit(attrs.getValue("lunit"));
+ reg->set_threshold(attrs.getValue("threshold"));
+ reg->set_eunit(attrs.getValue("eunit"));
+
+ m_obj = reg;
+ *obj = reg;
+ }
+
+ virtual void EndElement(const std::string&)
+ {
+ }
+
+ virtual void Characters(const std::string&)
+ {
+ }
+
+ virtual void StackPopNotify(const std::string& name)
+ {
+ SAXObject** so = Context()->GetTopObject();
+ region* r = dynamic_cast<region*>(m_obj);
+ r->add_content(name, *so);
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "region";
+ return tag;
+ }
+
+private:
+
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(regionProcess)
lcdd/src/lcdd/schema
diff -N regionrefProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ regionrefProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,49 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/regionrefProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// GDML
+#include "Processes/ReferenceTypeProcess.h"
+
+// LCDD
+#include "lcdd/schema/RegionType.hh"
+
+/**
+ * @brief SAX process for regionref element.
+ * @note Extends ReferenceTypeProcess for reference to region element.
+ */
+class regionrefProcess: public ReferenceTypeProcess
+{
+public:
+ regionrefProcess(const ProcessingContext* context = 0) :
+ ReferenceTypeProcess(context)
+ {
+ }
+
+ virtual ~regionrefProcess()
+ {
+ }
+
+ virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+ {
+ SAXObject** obj = Context()->GetTopObject();
+
+ RegionType::regionref* regref = new RegionType::regionref;
+
+ *obj = regref;
+ m_obj = regref;
+
+ ReferenceTypeProcess::StartElement(name, attrs);
+ }
+
+ virtual void EndElement(const std::string& name)
+ {
+ ReferenceTypeProcess::EndElement(name);
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "regionref";
+ return tag;
+ }
+};
+
+DECLARE_PROCESS_FACTORY(regionrefProcess)
lcdd/src/lcdd/schema
diff -N rz_field_mapProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ rz_field_mapProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,77 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/rz_field_mapProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/FieldMapTypeProcess.hh"
+#include "lcdd/schema/rz_field_map.hh"
+
+// Geant4
+#include "globals.hh"
+
+// STL
+#include <iostream>
+
+/**
+ * @brief Processor for rz_field_map elements.
+ */
+class rz_field_mapProcess: public FieldMapTypeProcess
+{
+public:
+ rz_field_mapProcess(const ProcessingContext* context = 0) :
+ FieldMapTypeProcess(context)
+ {
+ }
+
+ virtual ~rz_field_mapProcess()
+ {
+ }
+
+ virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+ {
+ // std::cout << "rz_field_mapProcess::StartElement - " << name << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ rz_field_map* rzmap = new rz_field_map;
+
+ /* set attributes */
+ rzmap->set_num_bins_r(attrs.getValue("num_bins_r"));
+ rzmap->set_grid_size_r(attrs.getValue("grid_size_r"));
+ rzmap->set_num_bins_z(attrs.getValue("num_bins_z"));
+ rzmap->set_grid_size_z(attrs.getValue("grid_size_z"));
+
+ /* Top-level caller needs to setup the SAXObject references. */
+ m_obj = rzmap;
+ *obj = rzmap;
+
+ /* Call next process UP in inheritance chain, after the SAXObject is set. */
+ FieldMapTypeProcess::StartElement(name, attrs);
+ }
+
+ virtual void EndElement(const std::string&)
+ {
+ }
+
+ virtual void Characters(const std::string&)
+ {
+ }
+
+ virtual void StackPopNotify(const std::string& name)
+ {
+ // std::cout << "rz_field_mapProcess::StackPopNotify" << std::endl;
+
+ if (name != "rzB") {
+ std::cerr << name << " is not a valid child element for rz_field_map." << std::endl;
+ exit(1);
+ }
+
+ FieldMapTypeProcess::StackPopNotify(name);
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "rz_field_map";
+ return tag;
+ }
+};
+
+DECLARE_PROCESS_FACTORY(rz_field_mapProcess)
lcdd/src/lcdd/schema
diff -N rzbProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ rzbProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,80 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/rzbProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// GDML
+#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"
+
+// LCDD
+#include "lcdd/schema/rzb.hh"
+
+// STL
+#include <iostream>
+
+/**
+ * @brief Processor for rzB elements.
+ */
+class rzbProcess: public SAXStateProcess
+{
+
+public:
+ rzbProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~rzbProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ //std::cout << "rzbProcess::StartElement" << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ rzb* row = new rzb;
+
+ row->set_r(attrs.getValue("r"));
+ row->set_z(attrs.getValue("z"));
+ row->set_Br(attrs.getValue("Br"));
+ row->set_Bz(attrs.getValue("Bz"));
+
+ m_obj = row;
+ *obj = row;
+ }
+
+ virtual void EndElement(const std::string&)
+ {
+ }
+
+ virtual void StackPopNotify(const std::string&)
+ {
+ }
+
+ virtual void Characters(const std::string&)
+ {
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "rzB";
+ return tag;
+ }
+
+private:
+
+ SAXObject* m_obj;
+
+};
+
+DECLARE_PROCESS_FACTORY(rzbProcess)
lcdd/src/lcdd/schema
diff -N scorerProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ scorerProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,71 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/scorerProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// GDML
+#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"
+
+// LCDD
+#include "lcdd/schema/scorer.hh"
+#include "lcdd/schema/SensitiveDetectorTypeProcess.hh"
+
+// STL
+#include <iostream>
+
+/**
+ * @brief SAX process for scorer element.
+ */
+class scorerProcess: public SensitiveDetectorTypeProcess
+{
+
+public:
+ scorerProcess(const ProcessingContext* context = 0) :
+ SensitiveDetectorTypeProcess(context)
+ {
+ }
+
+ virtual ~scorerProcess()
+ {
+ }
+
+ virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+ {
+ //std::cout << "PROCESS::START OF TAG : " << name << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ scorer* scr = new scorer;
+ /*
+ scr->set_kill_tracks(attrs.getValue("kill_tracks") );
+ */
+
+ m_obj = scr;
+ *obj = scr;
+
+ SensitiveDetectorTypeProcess::StartElement(name, attrs);
+ }
+
+ virtual void EndElement(const std::string&)
+ {
+ //std::cout << "PROCESS::END OF TAG : " << name << " " << std::endl;
+
+ //SensitiveDetectorTypeProcess::EndElement( name );
+ }
+
+ virtual void StackPopNotify(const std::string& name)
+ {
+ SensitiveDetectorTypeProcess::StackPopNotify(name);
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "scorer";
+ return tag;
+ }
+};
+
+DECLARE_PROCESS_FACTORY(scorerProcess)
lcdd/src/lcdd/schema
diff -N sdrefProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sdrefProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,53 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/sdrefProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/SensitiveDetectorType.hh"
+
+// GDML
+#include "Processes/ReferenceTypeProcess.h"
+
+// STL
+#include <iostream>
+
+/**
+ @class sdrefProcess
+ @brief SAX process for sdref element.
+ @note Extends ReferenceTypeProcess for reference to sd element.
+ */
+class sdrefProcess: public ReferenceTypeProcess
+{
+public:
+ sdrefProcess(const ProcessingContext* context = 0) :
+ ReferenceTypeProcess(context)
+ {
+ }
+
+ virtual ~sdrefProcess()
+ {
+ }
+
+ virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+ {
+ SAXObject** obj = Context()->GetTopObject();
+
+ SensitiveDetectorType::sdref* s = new SensitiveDetectorType::sdref;
+
+ *obj = s;
+ m_obj = s;
+
+ ReferenceTypeProcess::StartElement(name, attrs);
+ }
+
+ virtual void EndElement(const std::string& name)
+ {
+ ReferenceTypeProcess::EndElement(name);
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "sdref";
+ return tag;
+ }
+};
+
+DECLARE_PROCESS_FACTORY(sdrefProcess)
lcdd/src/lcdd/schema
diff -N solenoidProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ solenoidProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,77 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/solenoidProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/solenoid.hh"
+#include "lcdd/schema/FieldTypeProcess.hh"
+
+// GDML
+#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"
+
+// STL
+#include <iostream>
+
+/**
+ * @brief SAX process for solenoid element.
+ */
+class solenoidProcess: public FieldTypeProcess
+{
+
+public:
+ solenoidProcess(const ProcessingContext* context = 0) :
+ FieldTypeProcess(context)
+ {
+ }
+
+ virtual ~solenoidProcess()
+ {
+ }
+
+ virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+ {
+ //std::cout << "solenoidProcess::StartElement: " << name << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ solenoid* sol = new solenoid;
+
+ sol->set_innerField(attrs.getValue("inner_field"));
+ sol->set_outerField(attrs.getValue("outer_field"));
+ sol->set_zmin(attrs.getValue("zmin"));
+ sol->set_zmax(attrs.getValue("zmax"));
+ sol->set_innerRadius(attrs.getValue("inner_radius"));
+ sol->set_outerRadius(attrs.getValue("outer_radius"));
+
+ m_obj = sol;
+ *obj = sol;
+
+ FieldTypeProcess::StartElement(name, attrs);
+ }
+
+ virtual void EndElement(const std::string&)
+ {
+ //std::cout << "solenoidProcess::EndElement: " << name << " " << std::endl;
+ }
+
+ virtual void Characters(const std::string&)
+ {
+ }
+
+ virtual void StackPopNotify(const std::string&)
+ {
+ //std::cout << "calorimeterProcess::StackPopNotify: " << name << std::endl;
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "solenoid";
+ return tag;
+ }
+};
+
+DECLARE_PROCESS_FACTORY(solenoidProcess)
lcdd/src/lcdd/schema
diff -N trackerProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ trackerProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,65 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/trackerProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/tracker.hh"
+#include "lcdd/schema/SensitiveDetectorTypeProcess.hh"
+
+// GDML
+#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"
+
+// STL
+#include <iostream>
+
+/**
+ @class trackerProcess
+ @brief SAX process for tracker element.
+ */
+class trackerProcess: public SensitiveDetectorTypeProcess
+{
+
+public:
+ trackerProcess(const ProcessingContext* context = 0) :
+ SensitiveDetectorTypeProcess(context)
+ {
+ }
+
+ virtual ~trackerProcess()
+ {
+ }
+
+ virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+ {
+ SAXObject** obj = Context()->GetTopObject();
+
+ tracker* trk = new tracker;
+ trk->set_combine_hits(attrs.getValue("combine_hits"));
+
+ m_obj = trk;
+ *obj = trk;
+
+ SensitiveDetectorTypeProcess::StartElement(name, attrs);
+ }
+
+ virtual void EndElement(const std::string&)
+ {
+ }
+
+ virtual void StackPopNotify(const std::string& name)
+ {
+ SensitiveDetectorTypeProcess::StackPopNotify(name);
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "tracker";
+ return tag;
+ }
+};
+
+DECLARE_PROCESS_FACTORY(trackerProcess)
lcdd/src/lcdd/schema
diff -N unsegmented_calorimeterProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ unsegmented_calorimeterProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,35 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/unsegmented_calorimeterProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/calorimeterProcess.hh"
+#include "lcdd/schema/unsegmented_calorimeter.hh"
+
+// GDML
+#include "Saxana/ProcessingContext.h"
+#include "Saxana/SAXComponentFactory.h"
+
+#include <iostream>
+
+/**
+ * @brief SAX process for unsegmented_calorimeter element.@note Calls SAX processor for SensitiveDetectorTypeProcess parent class.
+ */
+class unsegmented_calorimeterProcess: public calorimeterProcess
+{
+public:
+ unsegmented_calorimeterProcess(const ProcessingContext* context = 0) :
+ calorimeterProcess(context)
+ {
+ }
+
+ virtual ~unsegmented_calorimeterProcess()
+ {
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "unsegmented_calorimeter";
+ return tag;
+ }
+};
+
+DECLARE_PROCESS_FACTORY(unsegmented_calorimeterProcess)
lcdd/src/lcdd/schema
diff -N visProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ visProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,84 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/visProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/vis.hh"
+
+// GDML
+#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"
+
+// std
+#include <iostream>
+
+/**
+ * @brief SAX process for vis element.
+ */
+class visProcess: public SAXStateProcess
+{
+public:
+
+ visProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~visProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ //std::cout << "visProcess::StartElement()" << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ vis* v = new vis;
+
+ v->set_name(attrs.getValue("name"));
+ v->set_visible(attrs.getValue("visible"));
+ v->set_show_daughters(attrs.getValue("show_daughters"));
+ v->set_line_style(attrs.getValue("line_style"));
+ v->set_drawing_style(attrs.getValue("drawing_style"));
+
+ m_obj = v;
+ *obj = v;
+ }
+
+ virtual void EndElement(const std::string&)
+ {
+ }
+
+ virtual void Characters(const std::string&)
+ {
+ }
+
+ virtual void StackPopNotify(const std::string& name)
+ {
+ // add all content
+ SAXObject** so = Context()->GetTopObject();
+ vis* v = dynamic_cast<vis*>(m_obj);
+ v->add_content(name, *so);
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "vis";
+ return tag;
+ }
+
+private:
+
+ SAXObject* m_obj;
+};
+
+DECLARE_PROCESS_FACTORY(visProcess)
lcdd/src/lcdd/schema
diff -N visrefProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ visrefProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,49 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/visrefProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+
+// LCDD
+#include "lcdd/schema/VisType.hh"
+
+// GDML
+#include "Processes/ReferenceTypeProcess.h"
+
+/**
+ * @brief SAX process for visref element.
+ * @note Extends ReferenceTypeProcess for referencing the vis elements.
+ */
+class visrefProcess: public ReferenceTypeProcess
+{
+public:
+ visrefProcess(const ProcessingContext* context = 0) :
+ ReferenceTypeProcess(context)
+ {
+ }
+
+ virtual ~visrefProcess()
+ {
+ }
+
+ virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+ {
+ SAXObject** obj = Context()->GetTopObject();
+
+ VisType::visref* visref = new VisType::visref;
+
+ *obj = visref;
+ m_obj = visref;
+
+ ReferenceTypeProcess::StartElement(name, attrs);
+ }
+
+ virtual void EndElement(const std::string& name)
+ {
+ ReferenceTypeProcess::EndElement(name);
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "visref";
+ return tag;
+ }
+};
+
+DECLARE_PROCESS_FACTORY(visrefProcess)
lcdd/src/lcdd/schema
diff -N volumeExtendedProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ volumeExtendedProcess.cc 26 Jun 2013 23:51:01 -0000 1.1
@@ -0,0 +1,85 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/schema/volumeExtendedProcess.cc,v 1.1 2013/06/26 23:51:01 jeremy Exp $
+#ifndef VolumeExtendedProcess_hh
+#define VolumeExtendedProcess_hh 1
+
+#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 "Schema/volume.h"
+
+/**
+ * @brief SAX process for the volume element, as extended by LCDD.
+ * @note This is mostly a cut and paste job of GDML's volumeProcess class,
+ * as this class does not appear to be extendable. It is only defined in a cpp
+ * file with no include guards!
+ */
+class volumeExtendedProcess: public SAXStateProcess
+{
+public:
+ volumeExtendedProcess(const ProcessingContext* context = 0) :
+ SAXStateProcess(context), m_obj(0)
+ {
+ }
+
+ virtual ~volumeExtendedProcess()
+ {
+ }
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ // Analogical to SAX startElement callback
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ SAXObject** obj = Context()->GetTopObject();
+
+ volume* vo = new volume;
+
+ vo->set_name(attrs.getValue("name"));
+
+ m_obj = vo;
+ *obj = vo;
+ }
+
+ virtual void EndElement(const std::string&)
+ {
+ }
+
+ virtual void Characters(const std::string&)
+ {
+ }
+
+ virtual void StackPopNotify(const std::string& name)
+ {
+ SAXObject** so = Context()->GetTopObject();
+ volume* vobj = dynamic_cast<volume*>(m_obj);
+ vobj->add_content(name, *so);
+ }
+
+ // The name of the state this object will process
+ virtual const std::string& State() const
+ {
+ static std::string tag = "volume";
+ return tag;
+ }
+
+private:
+ SAXObject* m_obj;
+
+public:
+
+ static SAXObject* m_volumeSaved;
+
+};
+
+DECLARE_PROCESS_FACTORY(volumeExtendedProcess)
+
+#endif
+
lcdd/src/lcdd/subscribers
diff -N box_dipoleSubscriber.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ box_dipoleSubscriber.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,92 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/box_dipoleSubscriber.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// LCDD
+#include "lcdd/core/LCDDProcessor.hh"
+#include "lcdd/bfield/G4BoxDipole.hh"
+#include "lcdd/schema/box_dipole.hh"
+
+// GDML
+#include "Saxana/SAXSubscriber.h"
+#include "Saxana/SAXComponentFactory.h"
+#include "G4Processor/GDMLProcessor.h"
+#include "G4Evaluator/GDMLExpressionEvaluator.h"
+
+class box_dipoleSubscriber: virtual public SAXSubscriber
+{
+
+public:
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+public:
+
+ box_dipoleSubscriber()
+ {
+ Subscribe("box_dipole");
+ }
+
+ virtual ~box_dipoleSubscriber()
+ {
+ }
+
+ virtual void Activate(const SAXObject* object)
+ {
+ GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
+
+ if (object != 0) {
+ const box_dipole* dipoleElement = dynamic_cast<const box_dipole*>(object);
+
+ double x, y, z, dx, dy, dz, bx, by, bz;
+ x = y = z = dx = dy = dz = bx = by = bz = 0;
+
+ std::string lunit = dipoleElement->get_lunit();
+ std::string funit = dipoleElement->get_funit();
+
+ std::string val = dipoleElement->get_x();
+ val += "*" + lunit;
+ x = calc->Eval(val);
+
+ val = dipoleElement->get_y();
+ val += "*" + lunit;
+ y = calc->Eval(val);
+
+ val = dipoleElement->get_z();
+ val += "*" + lunit;
+ z = calc->Eval(val);
+
+ val = dipoleElement->get_dx();
+ val += "*" + lunit;
+ dx = calc->Eval(val);
+
+ val = dipoleElement->get_dy();
+ val += "*" + lunit;
+ dy = calc->Eval(val);
+
+ val = dipoleElement->get_dz();
+ val += "*" + lunit;
+ dz = calc->Eval(val);
+
+ val = dipoleElement->get_bx();
+ val += "*" + funit;
+ bx = calc->Eval(val);
+
+ val = dipoleElement->get_by();
+ val += "*" + funit;
+ by = calc->Eval(val);
+
+ val = dipoleElement->get_bz();
+ val += "*" + funit;
+ bz = calc->Eval(val);
+
+ G4BoxDipole* boxDipole = new G4BoxDipole(x, y, z, dx, dy, dz, bx, by, bz);
+
+ std::string fieldName = dipoleElement->get_name();
+ LCDDProcessor::instance()->addMagneticField(fieldName, boxDipole);
+ }
+ }
+};
+
+DECLARE_SUBSCRIBER_FACTORY(box_dipoleSubscriber)
lcdd/src/lcdd/subscribers
diff -N calorimeterSubscriber.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ calorimeterSubscriber.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,51 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/calorimeterSubscriber.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// GDML
+#include "Saxana/SAXSubscriber.h"
+#include "Saxana/SAXComponentFactory.h"
+#include "G4Processor/GDMLProcessor.h"
+
+// LCDD
+#include "lcdd/schema/calorimeter.hh"
+#include "lcdd/core/LCDDProcessor.hh"
+#include "lcdd/detectors/G4CalorimeterSD.hh"
+#include "lcdd/detectors/G4SegmentationFactory.hh"
+#include "lcdd/detectors/SensitiveDetectorFactory.hh"
+#include "lcdd/id/IdManager.hh"
+#include "lcdd/id/IdSpec.hh"
+
+// STL
+#include <iostream>
+#include <sstream>
+
+/**
+ @class calorimeterSubscriber
+ @brief SAX subscriber for calorimeter element.
+ @note Delegates to SensitiveDetectorFactory to create G4CalorimeterSD object.
+ */
+class calorimeterSubscriber: virtual public SAXSubscriber
+{
+public:
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+public:
+ calorimeterSubscriber()
+ {
+ Subscribe("calorimeter");
+ }
+
+ virtual ~calorimeterSubscriber()
+ {
+ }
+
+ virtual void Activate(const SAXObject* object)
+ {
+ // use factory to create this SD
+ SensitiveDetectorFactory::createSensitiveDetector(object);
+ }
+};
+
+DECLARE_SUBSCRIBER_FACTORY(calorimeterSubscriber)
lcdd/src/lcdd/subscribers
diff -N dipoleSubscriber.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ dipoleSubscriber.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,103 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/dipoleSubscriber.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// GDML
+#include "Saxana/SAXSubscriber.h"
+#include "Saxana/SAXComponentFactory.h"
+#include "G4Processor/GDMLProcessor.h"
+#include "G4Evaluator/GDMLExpressionEvaluator.h"
+
+// LCDD
+#include "lcdd/core/LCDDProcessor.hh"
+#include "lcdd/schema/dipole.hh"
+#include "lcdd/schema/dipole_coeff.hh"
+#include "lcdd/bfield/G4Dipole.hh"
+
+/**
+ * @brief Creates G4Dipole runtime objects in Geant4 from dipole elements.
+ */
+class dipoleSubscriber: virtual public SAXSubscriber
+{
+
+public:
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+public:
+ dipoleSubscriber()
+ {
+ Subscribe("dipole");
+ }
+
+ virtual ~dipoleSubscriber()
+ {
+ }
+
+ virtual void Activate(const SAXObject* object)
+ {
+ GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
+
+ if (object) {
+ const dipole* d = dynamic_cast<const dipole*>(object);
+
+ if (d) {
+ double zmin, zmax, rmax;
+
+ std::string lunit = d->get_lunit();
+ std::string funit = d->get_funit();
+
+ // Evaluate zmin with lunit.
+ std::string sval = d->get_zmin();
+ sval += "*" + lunit;
+ zmin = calc->Eval(sval);
+
+ // Evaluate zmax with lunit.
+ sval = d->get_zmax();
+ sval += "*" + lunit;
+ zmax = calc->Eval(sval);
+
+ // Evaluate rmax with lunit.
+ sval = d->get_rmax();
+ sval += "*" + lunit;
+ rmax = calc->Eval(sval);
+
+ // Create the Geant4 dipole object.
+ G4Dipole* g4d = new G4Dipole();
+
+ // Set the field unit's value.
+ g4d->setFieldUnit(calc->Eval(funit));
+
+ // Set the length unit's value.
+ g4d->setLengthUnit(calc->Eval(lunit));
+
+ // Set zmin and zmax.
+ g4d->setZMax(zmax);
+ g4d->setZMin(zmin);
+ g4d->setRMax(rmax);
+
+ // Add the dipole coefficients.
+ ContentSequence* seq = const_cast<ContentSequence*>(d->get_content());
+ size_t count = seq->size();
+ for (size_t i = 0; i < count; i++) {
+ const ContentGroup::ContentItem& elem = seq->content(i);
+ if (elem.tag == "dipole_coeff") {
+ dipole_coeff* coeff = dynamic_cast<dipole_coeff*>(elem.object);
+ g4d->addCoeff(calc->Eval(coeff->get_value()));
+ } else {
+ std::cerr << "dipoleSubscriber :: Activate - The child element " << elem.tag << " is not a dipole_coeff!" << std::endl;
+ }
+ }
+
+ // Add the G4Dipole to the magnetic field store.
+ std::string field_name = d->get_name();
+ LCDDProcessor::instance()->addMagneticField(field_name, g4d);
+ } else {
+ std::cerr << "dipoleSubscriber :: Activate - Failed cast to dipole!" << std::endl;
+ }
+ }
+ }
+ ;
+};
+
+DECLARE_SUBSCRIBER_FACTORY(dipoleSubscriber)
lcdd/src/lcdd/subscribers
diff -N field_map_3dSubscriber.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ field_map_3dSubscriber.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,69 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/field_map_3dSubscriber.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// lcdd
+#include "lcdd/core/LCDDProcessor.hh"
+#include "lcdd/schema/field_map_3d.hh"
+#include "lcdd/bfield/Cartesian3DMagneticFieldMap.hh"
+
+// GDML
+#include "Saxana/SAXSubscriber.h"
+#include "Saxana/SAXComponentObject.h"
+#include "Saxana/SAXComponentFactory.h"
+
+// Geant4
+#include "G4Processor/GDMLProcessor.h"
+
+/*
+ * @class
+ * @brief
+ */
+class field_map_3dSubscriber: virtual public SAXSubscriber
+{
+
+public:
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+public:
+
+ field_map_3dSubscriber()
+ {
+ Subscribe("field_map_3d");
+ }
+
+ virtual ~field_map_3dSubscriber()
+ {
+ }
+
+ virtual void Activate(const SAXObject* object)
+ {
+
+ //std::cout << "field_map_3d::Subscriber" << std::endl;
+
+ const field_map_3d* obj = dynamic_cast<const field_map_3d*>(object);
+
+ if (object != 0) {
+
+ if (obj) {
+
+ if (obj) {
+
+ //GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
+ //std::string lunit = obj->get_lunit();
+ //std::string funit = obj->get_funit();
+
+ std::string name = obj->get_name();
+ std::string field_name = obj->get_filename();
+
+ Cartesian3DMagneticFieldMap* fmap = new Cartesian3DMagneticFieldMap(field_name.c_str(), 0, 0, 0);
+ LCDDProcessor::instance()->addMagneticField(name, fmap);
+ }
+ }
+ }
+ }
+};
+
+DECLARE_SUBSCRIBER_FACTORY(field_map_3dSubscriber)
lcdd/src/lcdd/subscribers
diff -N global_fieldSubscriber.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ global_fieldSubscriber.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,75 @@
+// $Id: global_fieldSubscriber.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// LCDD
+#include "lcdd/core/LCDDProcessor.hh"
+#include "lcdd/schema/global_field.hh"
+#include "lcdd/schema/FieldType.hh"
+
+// GDML
+#include "Saxana/SAXSubscriber.h"
+#include "Saxana/SAXComponentFactory.h"
+#include "G4Processor/GDMLProcessor.h"
+
+// Geant4
+#include "G4MagneticField.hh"
+
+// STL
+#include <iostream>
+
+/**
+ * @brief SAX subscriber for global_field element.
+ * @note Resolves fieldref and sets global field in LCDDProcessor.
+ */
+class global_fieldSubscriber: virtual public SAXSubscriber
+{
+public:
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+public:
+ global_fieldSubscriber()
+ {
+ Subscribe("global_field");
+ }
+
+ virtual ~global_fieldSubscriber()
+ {
+ }
+
+ virtual void Activate(const SAXObject* object)
+ {
+ const global_field* fobj = 0;
+ G4MagneticField* mag = 0;
+ LCDDProcessor* proc = LCDDProcessor::instance();
+
+ if (object != 0) {
+ fobj = dynamic_cast<const global_field*>(object);
+
+ if (fobj) {
+ const ContentSequence* seq = fobj->get_content();
+
+ size_t count = seq->size();
+
+ for (size_t i = 0; i < count; i++) {
+ if (seq->content(i).tag == "fieldref") {
+ FieldType::fieldref* fref = dynamic_cast<FieldType::fieldref*>(seq->content(i).object);
+
+ mag = proc->getMagneticField(fref->get_ref());
+
+ if (mag != 0) {
+ LCDDProcessor::instance()->addGlobalField(mag);
+ }
+ }
+ }
+
+ } else {
+ std::cerr << "Failed cast to global_field!" << std::endl;
+ }
+ }
+ }
+};
+
+DECLARE_SUBSCRIBER_FACTORY(global_fieldSubscriber)
+
lcdd/src/lcdd/subscribers
diff -N headerSubscriber.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ headerSubscriber.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,100 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/headerSubscriber.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// GDML
+#include "Saxana/SAXSubscriber.h"
+#include "Saxana/SAXComponentFactory.h"
+#include "G4Processor/GDMLProcessor.h"
+
+// LCDD
+#include "lcdd/core/LCDDProcessor.hh"
+#include "lcdd/geant4/LCDDHeaderRecord.hh"
+#include "lcdd/schema/header.hh"
+#include "lcdd/schema/detector.hh"
+#include "lcdd/schema/generator.hh"
+#include "lcdd/schema/comment.hh"
+#include "lcdd/schema/author.hh"
+
+// std
+#include <iostream>
+
+/**
+ @class headerSubscriber
+ @brief SAX subscriber for header element.
+ @note Creates the LCDDHeaderRecord and sets in LCDDProcessor.
+ */
+class headerSubscriber: virtual public SAXSubscriber
+{
+public:
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+public:
+ headerSubscriber()
+ {
+ Subscribe("header");
+ }
+
+ virtual ~headerSubscriber()
+ {
+ }
+
+ virtual void Activate(const SAXObject* object)
+ {
+ LCDDProcessor* proc = LCDDProcessor::instance();
+ const header* obj = dynamic_cast<const header*>(object);
+ LCDDHeaderRecord* hdr = new LCDDHeaderRecord();
+
+ // handle child element content
+ ContentSequence* seq = const_cast<ContentSequence*>(obj->get_content());
+ size_t count = seq->size();
+ for (size_t i = 0; i < count; i++) {
+
+ const ContentGroup::ContentItem& citem = seq->content(i);
+ const std::string& tag = citem.tag;
+ SAXObject* cobj = citem.object;
+
+ if (tag == "detector") {
+
+ const detector* d = dynamic_cast<detector*>(cobj);
+
+ hdr->setDetectorName(d->get_name());
+ hdr->setDetectorVersion(d->get_version());
+ hdr->setDetectorUrl(d->get_url());
+ } else if (tag == "generator") {
+
+ const generator* g = dynamic_cast<generator*>(cobj);
+
+ hdr->setGeneratorName(g->get_name());
+ hdr->setGeneratorVersion(g->get_version());
+ hdr->setGeneratorFile(g->get_file());
+ hdr->setGeneratorChecksum(g->get_checksum());
+ } else if (tag == "author") {
+
+ const author* a = dynamic_cast<author*>(cobj);
+
+ hdr->setAuthorName(a->get_name());
+ hdr->setAuthorEmail(a->get_email());
+
+ } else if (tag == "comment") {
+
+ const comment* c = dynamic_cast<comment*>(cobj);
+ hdr->setComment(c->get_comment());
+ } else {
+ std::cerr << "Unknown content for header element." << std::endl;
+ }
+ }
+
+ // set header in LCDDProc
+ proc->setHeader(hdr);
+
+ // print header
+ hdr->printOut(std::cout);
+
+ //delete object;
+ }
+
+};
+
+DECLARE_SUBSCRIBER_FACTORY(headerSubscriber)
lcdd/src/lcdd/subscribers
diff -N idspecSubscriber.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ idspecSubscriber.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,120 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/idspecSubscriber.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// GDML
+#include "Saxana/SAXSubscriber.h"
+#include "Saxana/SAXComponentFactory.h"
+#include "G4Processor/GDMLProcessor.h"
+
+// LCDD
+#include "lcdd/core/LCDDProcessor.hh"
+#include "lcdd/id/IdSpec.hh"
+#include "lcdd/schema/idspecElem.hh"
+#include "lcdd/schema/idfieldElem.hh"
+#include "lcdd/id/IdManager.hh"
+#include "lcdd/util/StringUtil.hh"
+
+/**
+ @class idspecSubscriber
+ @brief SAX subscriber for idspec element.
+ @note Creates an IdSpec object and registers with IdManager.
+ @note Also creates IdField objects from idfield child elements.
+ */
+class idspecSubscriber: virtual public SAXSubscriber
+{
+public:
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+public:
+ idspecSubscriber()
+ {
+ Subscribe("idspec");
+ }
+
+ virtual ~idspecSubscriber()
+ {
+ }
+
+ virtual void Activate(const SAXObject* object)
+ {
+ //std::cout << "idspecSubscriber::Activate()" << std::endl;
+
+ if (object) {
+ const idspecElem* idspec_elem = dynamic_cast<const idspecElem*>(object);
+
+ if (idspec_elem) {
+
+ std::string name = idspec_elem->get_name();
+
+ std::string length = idspec_elem->get_length();
+ IdSpec::SizeType length_s = (IdSpec::SizeType) StringUtil::toInt(length);
+
+ // @todo support lengths over 64
+ if (length_s > 64) {
+ std::cerr << "Number of bits cannot be greater than 64 at this time." << std::endl;
+ assert(0);
+ }
+
+ IdSpec* idspec = new IdSpec;
+ idspec->setName(name);
+ idspec->setBitLength(length_s);
+
+ IdManager::instance()->addIdSpec(name, idspec);
+
+ // create fields
+ ContentSequence* seq = const_cast<ContentSequence*>(idspec_elem->get_content());
+ size_t count = seq->size();
+
+ for (size_t i = 0; i < count; i++) {
+ const ContentGroup::ContentItem& segitem = seq->content(i);
+ if (segitem.tag == "idfield") {
+ idfieldElem* idfield_elem = dynamic_cast<idfieldElem*>(segitem.object);
+
+ if (idfield_elem) {
+
+ IdField* idfield = new IdField;
+
+ // label
+ std::string label = idfield_elem->get_label();
+
+ // start
+ std::string start = idfield_elem->get_start();
+ IdField::SizeType start_s = (IdField::SizeType) StringUtil::toInt(start);
+
+ // signed
+ std::string signed_str = idfield_elem->get_signed();
+ bool signed_bool = StringUtil::toBool(signed_str);
+
+ // length
+ std::string length = idfield_elem->get_length();
+ IdField::SizeType length_s = (IdField::SizeType) StringUtil::toInt(length);
+
+ // set in G4 object
+ idfield->setLabel(label);
+ idfield->setSigned(signed_bool);
+ idfield->setStart(start_s);
+ idfield->setLength(length_s);
+
+ // add to spec
+ idspec->addIdField(idfield);
+ } else {
+ G4Exception("", "", FatalException, "Failed cast to idfieldElem.");
+ }
+ } else {
+ std::cerr << "Ignoring unknown child - " << segitem.tag << std::endl;
+ }
+ }
+ } else {
+ G4Exception("", "", FatalException, "Failed cast to idspecElem.");
+ }
+ } else {
+ G4Exception("", "", FatalException, "SAXObject is null!");
+ }
+
+ //delete object;
+ }
+};
+
+DECLARE_SUBSCRIBER_FACTORY(idspecSubscriber)
lcdd/src/lcdd/subscribers
diff -N limitsetSubscriber.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ limitsetSubscriber.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,100 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/limitsetSubscriber.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// GDML
+#include "Saxana/SAXSubscriber.h"
+#include "Saxana/SAXComponentFactory.h"
+#include "G4Processor/GDMLProcessor.h"
+
+// LCDD
+#include "lcdd/schema/limit.hh"
+#include "lcdd/schema/limitset.hh"
+#include "lcdd/core/LCDDProcessor.hh"
+#include "lcdd/geant4/G4LimitSet.hh"
+#include "lcdd/util/StringUtil.hh"
+
+#include <string>
+#include <iostream>
+
+using std::string;
+using std::vector;
+
+/**
+ */
+class limitsetSubscriber: virtual public SAXSubscriber
+{
+public:
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+public:
+
+ limitsetSubscriber()
+ {
+ Subscribe("limitset");
+ }
+
+ virtual void Activate(const SAXObject* object)
+ {
+ //std::cout << "limitsetSubscriber::Activate()" << std::endl;
+ if (object != 0) {
+
+ GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
+ const limitset* lsobj = dynamic_cast<const limitset*>(object);
+
+ if (lsobj != 0) {
+ //std::cout << "got limitset: " << lsobj->get_name() << std::endl;
+
+ G4LimitSet* ls = new G4LimitSet(lsobj->get_name());
+
+ const ContentSequence* seq = lsobj->get_content();
+ size_t count = seq->size();
+ for (size_t i = 0; i < count; i++) {
+ if (seq->content(i).tag == "limit") {
+ limit* param = dynamic_cast<limit*>(seq->content(i).object);
+
+ if (param != 0) {
+ //std::cout << "got limit: " << param->get_name() << std::endl;
+
+ string unit = param->get_unit();
+ string particles = param->get_particles();
+ string limitName = param->get_name();
+
+ string sval = param->get_value();
+ sval += "*" + unit;
+ double value = calc->Eval(sval);
+
+ /* Process the comma-delimited list of particles. */
+ vector<string> particleList;
+ StringUtil::split(particles, ",", particleList);
+
+ /* No specific particles so make an entry for all particles. */
+ if (particleList.end() == particleList.begin()) {
+ //std::cout << "adding limit with name, particle, value: <" << limitName << "> <" << G4LimitSet::ANY_PARTICLE << "> <" << value << ">" << std::endl;
+ ls->setLimitForParticle(limitName, G4LimitSet::ANY_PARTICLE, value);
+ }
+ /* Insert the limit once for each particle. */
+ else {
+ for (vector<string>::iterator iter = particleList.begin(); iter != particleList.end(); iter++) {
+ string particle = (*iter);
+ StringUtil::trim(particle);
+ //std::cout << "adding limit with name, particle, value: <" << limitName << "> <" << particle << "> <" << value << ">" << std::endl;
+ ls->setLimitForParticle(limitName, particle, value);
+ }
+ }
+ } else {
+ G4Exception("", "", FatalException, "Failed cast to limit.");
+ }
+ }
+ }
+
+ LCDDProcessor::instance()->addLimitSet(ls->getName(), ls);
+ } else {
+ G4Exception("", "", FatalException, "Failed cast to limitset.");
+ }
+ }
+ }
+};
+
+DECLARE_SUBSCRIBER_FACTORY(limitsetSubscriber)
lcdd/src/lcdd/subscribers
diff -N optical_calorimeterSubscriber.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ optical_calorimeterSubscriber.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,49 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/optical_calorimeterSubscriber.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// GDML
+#include "Saxana/SAXSubscriber.h"
+#include "Saxana/SAXComponentFactory.h"
+#include "G4Processor/GDMLProcessor.h"
+
+// LCDD
+#include "lcdd/schema/calorimeter.hh"
+#include "lcdd/core/LCDDProcessor.hh"
+#include "lcdd/detectors/G4CalorimeterSD.hh"
+#include "lcdd/detectors/G4SegmentationFactory.hh"
+#include "lcdd/detectors/SensitiveDetectorFactory.hh"
+#include "lcdd/id/IdManager.hh"
+#include "lcdd/id/IdSpec.hh"
+
+// STL
+#include <iostream>
+#include <sstream>
+
+/**
+ * @brief SAX subscriber for calorimeter element.
+ * @note Delegates to SensitiveDetectorFactory for creation of G4CalorimeterSD objects.
+ */
+class optical_calorimeterSubscriber: virtual public SAXSubscriber
+{
+public:
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+public:
+ optical_calorimeterSubscriber()
+ {
+ Subscribe("optical_calorimeter");
+ }
+
+ virtual ~optical_calorimeterSubscriber()
+ {
+ }
+
+ virtual void Activate(const SAXObject* object)
+ {
+ SensitiveDetectorFactory::createSensitiveDetector(object);
+ }
+};
+
+DECLARE_SUBSCRIBER_FACTORY(optical_calorimeterSubscriber)
lcdd/src/lcdd/subscribers
diff -N regionSubscriber.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ regionSubscriber.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,130 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/regionSubscriber.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// GDML
+#include "Saxana/SAXSubscriber.h"
+#include "Saxana/SAXComponentFactory.h"
+#include "G4Processor/GDMLProcessor.h"
+
+// LCDD
+#include "lcdd/schema/region.hh"
+#include "lcdd/core/LCDDProcessor.hh"
+#include "lcdd/geant4/G4UserRegionInformation.hh"
+#include "lcdd/schema/LimitSetType.hh"
+#include "lcdd/util/StringUtil.hh"
+
+// Geant4
+#include "G4Region.hh"
+#include "G4ProductionCuts.hh"
+
+// std
+#include <iostream>
+#include <sstream>
+
+/**
+ @class regionSubscriber
+ @brief SAX subscriber for region element.
+ @note Creates a G4Region with user information and registers with LCDDProcessor.
+ */
+class regionSubscriber: virtual public SAXSubscriber
+{
+public:
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+public:
+ regionSubscriber()
+ {
+ Subscribe("region");
+ }
+
+ virtual void Activate(const SAXObject* object)
+ {
+ if (object != 0) {
+
+ LCDDProcessor* proc = LCDDProcessor::instance();
+
+ const region* robj = dynamic_cast<const region*>(object);
+
+ GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
+ G4Region* reg = 0;
+ if (robj) {
+ std::string name = robj->get_name();
+ reg = new G4Region(name);
+
+ // compute prod cut
+ std::string lunit = robj->get_lunit();
+ std::string sval = robj->get_cut();
+ sval += "*" + lunit;
+ double cut = calc->Eval(sval);
+
+ std::string eunit = robj->get_eunit();
+ sval = robj->get_threshold();
+ sval += "*" + eunit;
+ double threshold = calc->Eval(sval);
+
+ // set production cut
+ std::string store_seco = robj->get_storeSecondaries();
+ G4ProductionCuts* prod_cuts = new G4ProductionCuts();
+ prod_cuts->SetProductionCut(cut);
+ reg->SetProductionCuts(prod_cuts);
+
+ // create region info with storeSecondaries flag
+ G4UserRegionInformation* reg_info = new G4UserRegionInformation();
+
+ // set storeSeco
+ reg_info->setStoreSecondaries(StringUtil::toBool(store_seco));
+
+ std::string killTracks = robj->get_killTracks();
+ //std::cout << "regionSubscriber.killTracks: " << killTracks << std::endl;
+ reg_info->setKillTracks(StringUtil::toBool(killTracks));
+ //std::cout << "regInfo.killTracsk: " << reg_info << std::endl;
+
+ // set threshold
+ reg_info->setThreshold(threshold);
+
+ // set info in region
+ reg->SetUserInformation(reg_info);
+
+ // get content
+ const ContentSequence* seq = robj->get_content();
+
+ // get size of content
+ size_t count = seq->size();
+
+ // iterate over and process content
+ for (size_t i = 0; i < count; i++) {
+
+ if (seq->content(i).tag == "limitsetref") {
+
+ LimitSetType::limitsetref* limitsetref = dynamic_cast<LimitSetType::limitsetref*>(seq->content(i).object);
+
+ G4UserLimits* ulim = dynamic_cast<G4LimitSet*>(proc->getLimitSet(limitsetref->get_ref()));
+
+ if (ulim) {
+#ifdef HAVE_G4REGION_SETUSERLIMITS
+ reg->SetUserLimits( ulim );
+ std::cout << "Set user limits <" << limitsetref->get_ref() << "> on region <" << name << ">" << std::endl;
+#else
+ std::cerr << "WARNING: Ignoring limitsetref on region. The method G4Region::SetUserLimits is not supported by your Geant4 version." << std::endl;
+#endif
+ } else {
+ std::cerr << "FATAL ERROR: limit element not found - " << limitsetref->get_ref() << std::endl;
+ G4Exception("", "", FatalException, "limitsetref not found.");
+ }
+ } else {
+ std::cerr << "Bad content to region tag: " << seq->content(i).tag << std::endl;
+ }
+ }
+
+ // register with processor
+ LCDDProcessor::instance()->addRegion(name, reg);
+ } else {
+ std::cerr << "Failed cast to region!" << std::endl;
+ }
+ }
+ }
+};
+
+DECLARE_SUBSCRIBER_FACTORY(regionSubscriber)
lcdd/src/lcdd/subscribers
diff -N rz_field_mapSubscriber.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ rz_field_mapSubscriber.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,123 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/rz_field_mapSubscriber.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// GDML
+#include "Saxana/SAXSubscriber.h"
+#include "Saxana/SAXComponentFactory.h"
+#include "G4Processor/GDMLProcessor.h"
+
+// LCDD
+#include "lcdd/core/LCDDProcessor.hh"
+#include "lcdd/schema/rz_field_map.hh"
+#include "lcdd/schema/rzb.hh"
+#include "lcdd/bfield/G4RZFieldMap.hh"
+
+/*
+ * @class rz_field_mapSubscriber
+ * @brief Subscriber for rz_field_map elements.
+ */
+class rz_field_mapSubscriber: virtual public SAXSubscriber
+{
+public:
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+public:
+ rz_field_mapSubscriber()
+ {
+ Subscribe("rz_field_map");
+ }
+
+ virtual ~rz_field_mapSubscriber()
+ {
+ }
+
+ /** Instantiates a G4RZFieldMap object into Geant4 runtime. */
+ virtual void Activate(const SAXObject* object)
+ {
+ //std::cout << "rz_field_mapSubscriber" << std::endl;
+
+ if (object != 0) {
+
+ GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
+
+ const rz_field_map* obj = dynamic_cast<const rz_field_map*>(object);
+
+ if (obj) {
+ std::string lunit = obj->get_lunit();
+ std::string funit = obj->get_funit();
+ std::string name = obj->get_name();
+
+ int numBinsR, numBinsZ;
+ double gridSizeR, gridSizeZ;
+
+ std::string sval = obj->get_num_bins_r();
+ numBinsR = (int) calc->Eval(sval);
+
+ sval = obj->get_num_bins_z();
+ numBinsZ = (int) calc->Eval(sval);
+
+ sval = obj->get_grid_size_r();
+ sval += "*" + lunit;
+ gridSizeR = calc->Eval(sval);
+
+ sval = obj->get_grid_size_z();
+ sval += "*" + lunit;
+ gridSizeZ = calc->Eval(sval);
+
+ /* Make list of RZB rows from content. */
+ const ContentSequence* seq = obj->get_content();
+ size_t count = seq->size();
+ std::vector<RZBData> fieldData;
+
+ for (size_t i = 0; i < count; i++) {
+
+ if (seq->content(i).tag == "rzB") {
+
+ rzb* row = dynamic_cast<rzb*>(seq->content(i).object);
+
+ if (row != 0) {
+
+ std::string sr = row->get_r();
+ std::string sz = row->get_z();
+ std::string sBr = row->get_Br();
+ std::string sBz = row->get_Bz();
+
+ std::string sval = sr;
+ sval += "*" + lunit;
+ double r = calc->Eval(sval);
+
+ sval = sz;
+ sval += "*" + lunit;
+ double z = calc->Eval(sval);
+
+ sval = sBr;
+ sval += "*" + funit;
+ double Br = calc->Eval(sval);
+
+ sval = sBz;
+ sval += "*" + funit;
+ double Bz = calc->Eval(sval);
+
+ fieldData.push_back(RZBData(r, z, Br, Bz));
+ } else {
+ G4Exception("", "", FatalException, "Failed cast to rzB.");
+ }
+ } else {
+ G4cerr << "WARNING: Ignoring unknown element " << seq->content(i).tag << "." << std::endl;
+ }
+ }
+
+ G4RZFieldMap* fmap = new G4RZFieldMap(numBinsR, numBinsZ, gridSizeR, gridSizeZ, fieldData);
+ LCDDProcessor::instance()->addMagneticField(name, fmap);
+ } else {
+ G4Exception("", "", FatalException, "Failed cast to rz_field_map.");
+ }
+ } else {
+ G4Exception("", "", FatalException, "SAXObject is null.");
+ }
+ }
+};
+
+DECLARE_SUBSCRIBER_FACTORY(rz_field_mapSubscriber)
lcdd/src/lcdd/subscribers
diff -N scorerSubscriber.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ scorerSubscriber.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,45 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/scorerSubscriber.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// GDML
+#include "Saxana/SAXSubscriber.h"
+#include "Saxana/SAXComponentFactory.h"
+
+// LCDD
+#include "lcdd/core/LCDDProcessor.hh"
+#include "lcdd/schema/scorer.hh"
+#include "lcdd/detectors/G4SensitiveDetector.hh"
+#include "lcdd/detectors/G4ScorerSD.hh"
+#include "lcdd/detectors/SensitiveDetectorFactory.hh"
+
+// STL
+#include <iostream>
+
+/**
+ * @brief SAX subscriber for scorer element.
+ * @note Delegates to SensitiveDetectorFactory to create G4ScorerSD.
+ */
+class scorerSubscriber: virtual public SAXSubscriber
+{
+public:
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+public:
+ scorerSubscriber()
+ {
+ Subscribe("scorer");
+ }
+
+ virtual ~scorerSubscriber()
+ {
+ }
+
+ virtual void Activate(const SAXObject* object)
+ {
+ SensitiveDetectorFactory::createSensitiveDetector(object);
+ }
+};
+
+DECLARE_SUBSCRIBER_FACTORY(scorerSubscriber)
lcdd/src/lcdd/subscribers
diff -N solenoidSubscriber.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ solenoidSubscriber.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,99 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/solenoidSubscriber.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// GDML
+#include "Saxana/SAXSubscriber.h"
+#include "Saxana/SAXComponentFactory.h"
+#include "G4Processor/GDMLProcessor.h"
+#include "G4Evaluator/GDMLExpressionEvaluator.h"
+
+// processor
+#include "lcdd/core/LCDDProcessor.hh"
+#include "lcdd/schema/solenoid.hh"
+#include "lcdd/bfield/G4Solenoid.hh"
+
+/**
+ * @brief SAX subscriber for solenoid element.
+ * @note Creates a G4Solenoid object and registers with LCDDProcessor.
+ */
+class solenoidSubscriber: virtual public SAXSubscriber
+{
+public:
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+public:
+ solenoidSubscriber()
+ {
+ Subscribe("solenoid");
+ }
+
+ virtual ~solenoidSubscriber()
+ {
+ }
+
+ virtual void Activate(const SAXObject* object)
+ {
+ //std::cout << "solenoidSubscriber" << std::endl;
+
+ GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
+ if (object != 0) {
+ const solenoid* obj = dynamic_cast<const solenoid*>(object);
+
+ if (obj) {
+ //std::cout << "GOT SOLENOID: " << obj->get_name() << std::endl;
+
+ double outer_field, inner_field;
+ double zmin, zmax;
+ double inner_radius, outer_radius;
+
+ std::string lunit = obj->get_lunit();
+ std::string funit = obj->get_funit();
+
+ std::string sval = obj->get_innerField();
+ sval += "*" + funit;
+ inner_field = calc->Eval(sval);
+
+ sval = obj->get_outerField();
+ sval += "*" + funit;
+ outer_field = calc->Eval(sval);
+
+ sval = obj->get_zmin();
+ sval += "*" + lunit;
+ zmin = calc->Eval(sval);
+
+ sval = obj->get_zmax();
+ sval += "*" + lunit;
+ zmax = calc->Eval(sval);
+
+ sval = obj->get_innerRadius();
+ sval += "*" + lunit;
+ inner_radius = calc->Eval(sval);
+
+ sval = obj->get_outerRadius();
+ sval += "*" + lunit;
+ outer_radius = calc->Eval(sval);
+
+ G4Solenoid* sol = new G4Solenoid();
+
+ sol->setInnerField(inner_field);
+ sol->setOuterField(outer_field);
+ sol->setInnerZ(zmin);
+ sol->setOuterZ(zmax);
+ sol->setInnerR(inner_radius);
+ sol->setOuterR(outer_radius);
+
+ std::string field_name = obj->get_name();
+ LCDDProcessor::instance()->addMagneticField(field_name, sol);
+ } else {
+ std::cerr << "Failed cast to solenoid!" << std::endl;
+ }
+ }
+
+ //delete object;
+ }
+};
+
+DECLARE_SUBSCRIBER_FACTORY(solenoidSubscriber)
+
lcdd/src/lcdd/subscribers
diff -N trackerSubscriber.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ trackerSubscriber.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,46 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/trackerSubscriber.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// GDML
+#include "Saxana/SAXSubscriber.h"
+#include "Saxana/SAXComponentFactory.h"
+
+// LCDD
+#include "lcdd/core/LCDDProcessor.hh"
+#include "lcdd/schema/tracker.hh"
+#include "lcdd/detectors/G4SensitiveDetector.hh"
+#include "lcdd/detectors/G4TrackerSD.hh"
+#include "lcdd/detectors/SensitiveDetectorFactory.hh"
+
+// STL
+#include <iostream>
+
+/**
+ @class trackerSubscriber
+ @brief SAX subscriber for tracker element.
+ @note Delegates to SensitiveDetectorFactory to create G4TrackerSD.
+ */
+class trackerSubscriber: virtual public SAXSubscriber
+{
+public:
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+public:
+ trackerSubscriber()
+ {
+ Subscribe("tracker");
+ }
+
+ virtual ~trackerSubscriber()
+ {
+ }
+
+ virtual void Activate(const SAXObject* object)
+ {
+ SensitiveDetectorFactory::createSensitiveDetector(object);
+ }
+};
+
+DECLARE_SUBSCRIBER_FACTORY(trackerSubscriber)
lcdd/src/lcdd/subscribers
diff -N unsegmented_calorimeterSubscriber.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ unsegmented_calorimeterSubscriber.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,40 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/unsegmented_calorimeterSubscriber.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// GDML
+#include "Saxana/SAXSubscriber.h"
+#include "Saxana/SAXComponentFactory.h"
+
+// LCDD
+#include "lcdd/detectors/SensitiveDetectorFactory.hh"
+
+/**
+ * @brief SAX subscriber for calorimeter element.
+ * @note Delegates to SensitiveDetectorFactory to create G4CalorimeterSD object.
+ */
+class unsegmented_calorimeterSubscriber: virtual public SAXSubscriber
+{
+public:
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+public:
+
+ unsegmented_calorimeterSubscriber()
+ {
+ Subscribe("unsegmented_calorimeter");
+ }
+
+ virtual ~unsegmented_calorimeterSubscriber()
+ {
+ }
+
+ virtual void Activate(const SAXObject* object)
+ {
+ SensitiveDetectorFactory::createSensitiveDetector(object);
+ }
+};
+
+DECLARE_SUBSCRIBER_FACTORY(unsegmented_calorimeterSubscriber)
lcdd/src/lcdd/subscribers
diff -N visSubscriber.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ visSubscriber.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,136 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/visSubscriber.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// LCDD
+#include "lcdd/core/LCDDProcessor.hh"
+#include "lcdd/schema/vis.hh"
+#include "lcdd/schema/color.hh"
+#include "lcdd/util/StringUtil.hh"
+
+// GDML
+#include "Saxana/SAXSubscriber.h"
+#include "Saxana/SAXComponentFactory.h"
+
+// Geant4
+#include "G4VisAttributes.hh"
+
+/**
+ @class visSubscriber
+ @brief SAX subscriber for vis element.
+ @note Creates and registers a G4VisAttributes object with LCDDProcessor.
+ */
+class visSubscriber: virtual public SAXSubscriber
+{
+public:
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+public:
+ visSubscriber()
+ {
+ Subscribe("vis");
+ }
+
+ virtual ~visSubscriber()
+ {
+ }
+
+ virtual void Activate(const SAXObject* object)
+ {
+ //std::cout << "visSubscriber::Activate()" << std::endl;
+
+ if (object != 0) {
+ const vis* vobj = dynamic_cast<const vis*>(object);
+
+ if (vobj) {
+ G4VisAttributes* g4vis = new G4VisAttributes;
+
+ std::string name = vobj->get_name();
+ bool visible = StringUtil::toBool(vobj->get_visible());
+ bool show_daughters = StringUtil::toBool(vobj->get_show_daughters());
+ G4VisAttributes::LineStyle line = convertLineStyle(vobj->get_line_style());
+ G4VisAttributes::ForcedDrawingStyle draw = convertDrawingStyle(vobj->get_drawing_style());
+
+ g4vis->SetVisibility(visible);
+ g4vis->SetDaughtersInvisible(!show_daughters);
+ g4vis->SetLineStyle(line);
+
+ if (draw == G4VisAttributes::wireframe) {
+ g4vis->SetForceWireframe(true);
+ } else if (draw == G4VisAttributes::solid) {
+ g4vis->SetForceSolid(true);
+ }
+
+ // set color
+ bool color_set = false;
+ ContentSequence* seq = const_cast<ContentSequence*>(vobj->get_content());
+ size_t count = seq->size();
+ for (size_t i = 0; i < count; i++) {
+ std::string child_tag = seq->content(i).tag;
+ SAXObject* child_obj = seq->content(i).object;
+
+ if (child_tag == "color") {
+ //std::cout << "handling color" << std::endl;
+ color* c = dynamic_cast<color*>(child_obj);
+
+ double r = StringUtil::toDouble(c->get_R());
+ double g = StringUtil::toDouble(c->get_G());
+ double b = StringUtil::toDouble(c->get_B());
+ double alpha = StringUtil::toDouble(c->get_alpha());
+
+ //std::cout << "r g b alpha: " << r << " " << g << " " << b << " " << alpha << std::endl;
+
+ g4vis->SetColor(r, g, b, alpha);
+
+ // should be only one
+ color_set = true;
+ break;
+ }
+ }
+
+ if (!color_set) {
+ std::cerr << "WARNING: Color was not explicitly set and got the default value." << std::endl;
+ }
+
+ // add to proc's map
+ LCDDProcessor::instance()->addVisAttributes(name, g4vis);
+ }
+ }
+
+ //delete object;
+ }
+
+ static G4VisAttributes::LineStyle convertLineStyle(const std::string& s)
+ {
+ G4VisAttributes::LineStyle l = G4VisAttributes::unbroken;
+
+ if (s == "unbroken") {
+ l = G4VisAttributes::unbroken;
+ } else if (s == "dashed") {
+ l = G4VisAttributes::dashed;
+ } else if (s == "dotted") {
+ l = G4VisAttributes::dotted;
+ } else {
+ std::cerr << "WARNING: unknown LineStyle - " << s << std::endl;
+ }
+
+ return l;
+ }
+
+ static G4VisAttributes::ForcedDrawingStyle convertDrawingStyle(const std::string& s)
+ {
+ G4VisAttributes::ForcedDrawingStyle d = G4VisAttributes::wireframe;
+ if (s == "wireframe") {
+ d = G4VisAttributes::wireframe;
+ } else if (s == "solid") {
+ d = G4VisAttributes::solid;
+ } else {
+ std::cerr << "WARNING: unknown DrawingStyle - " << d << std::endl;
+ }
+
+ return d;
+ }
+};
+
+DECLARE_SUBSCRIBER_FACTORY(visSubscriber)
lcdd/src/lcdd/subscribers
diff -N volumeExtendedSubscriber.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ volumeExtendedSubscriber.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,177 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/volumeExtendedSubscriber.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// LCDD
+#include "lcdd/subscribers/volumeExtendedSubscriber.hh"
+
+/**
+ * @brief SAX subscriber to handle extra LCDD tags on volume element.
+ * @note This is the major subscriber extension class for the LCDD package.
+ */
+const SAXComponentObject* volumeExtendedSubscriber::Build() const
+{
+ return this;
+}
+
+volumeExtendedSubscriber::volumeExtendedSubscriber()
+{
+ Subscribe("volume");
+}
+
+volumeExtendedSubscriber::~volumeExtendedSubscriber()
+{
+}
+
+void volumeExtendedSubscriber::Activate(const SAXObject* object)
+{
+ LCDDProcessor* proc = LCDDProcessor::instance();
+ const volume* vobj = 0;
+ G4SensitiveDetector* g4sd = 0;
+ G4LogicalVolume* lv;
+ int nchildren = 0;
+
+ if (object) {
+ vobj = dynamic_cast<const volume*>(object);
+
+ if (vobj) {
+
+ // get LV
+ lv = const_cast<G4LogicalVolume*>(GDMLProcessor::GetInstance()->GetLogicalVolume(vobj->get_name()));
+
+ if (lv) {
+
+ // get content
+ const ContentSequence* seq = vobj->get_content();
+
+ // get size of content
+ size_t count = seq->size();
+
+ // iterate over and process content
+ for (size_t i = 0; i < count; i++) {
+
+ // handle sdref tag
+ if (seq->content(i).tag == "sdref") {
+
+ SensitiveDetectorType::sdref* sd = dynamic_cast<SensitiveDetectorType::sdref*>(seq->content(i).object);
+
+ g4sd = proc->getSensitiveDetector(sd->get_ref());
+
+ if (g4sd) {
+
+ if (!g4sd->isValidVolume(lv)) {
+ //G4Exception("FATAL ERROR: The G4LogicalVolume <" + lv->GetName() + "> is not valid for the SD <" + g4sd->GetName() + ">.");
+ G4Exception("", "", FatalException, "LogVol not valid for the SD");
+ }
+
+ lv->SetSensitiveDetector(g4sd);
+ } else {
+ G4cerr << "SD not found: " << sd->get_ref() << "." << G4endl;
+ G4Exception( "volumeExtendedSubscriber::Activate()", "", FatalException, "Invalid sdref.");
+ }
+ } else if ( seq->content(i).tag == "regionref" ) {
+ // handle regionref
+
+ // get regionref object
+ RegionType::regionref* regref = dynamic_cast<RegionType::regionref*> ( seq->content(i).object );
+
+ // get region from store
+ G4Region* reg = dynamic_cast<G4Region*> ( proc->getRegion( regref->get_ref() ) );
+
+ // add LV to region
+ if ( reg ) {
+ reg->AddRootLogicalVolume( lv );
+ } else {
+ G4cerr << "Failed to fetch and/or cast to region: " << regref->get_ref() << G4endl;
+ G4Exception("volumeExtendedSubscriber::Activate()", "", FatalException, "Invalid regionref.");
+ }
+ } else if ( seq->content(i).tag == "limitsetref" ) {
+ // handle limitsetref
+
+ LimitSetType::limitsetref* limitsetref = dynamic_cast<LimitSetType::limitsetref*> ( seq->content(i).object );
+
+ G4UserLimits* ulim = dynamic_cast<G4LimitSet*> ( proc->getLimitSet( limitsetref->get_ref() ) );
+
+ if ( ulim ) {
+ lv->SetUserLimits( ulim );
+ std::cout << "Set user limits <" << limitsetref->get_ref() << "> on logical volume <" << lv->GetName() << ">" << std::endl;
+ } else {
+ std::cerr << "FATAL ERROR: limit element not found - " << limitsetref->get_ref() << std::endl;
+ G4Exception("", "", FatalException, "limitsetref not found.");
+ }
+ } else if ( seq->content(i).tag == "visref" ) {
+ // handle visref
+
+ //std::cout << "handling visref" << std::endl;
+
+ VisType::visref* visref = dynamic_cast<VisType::visref*> ( seq->content(i).object );
+
+ G4VisAttributes* vis = dynamic_cast<G4VisAttributes*> ( proc->getVisAttributes( visref->get_ref() ) );
+
+ if ( vis ) {
+ //std::cout << "assigning vis: " << visref->get_ref() << std::endl;
+ lv->SetVisAttributes( vis );
+ } else {
+ std::cerr << "FATAL ERROR: vis element not found - " << visref->get_ref() << std::endl;
+ G4Exception("", "", FatalException, "vis element not found.");
+ }
+ }
+
+ if ( seq->content(i).tag == "physvol" ) {
+ // handle physvols to look for physvolids
+
+ ++nchildren;
+
+ // get physvol content sequence
+ physvol* pv = dynamic_cast<physvol*>( seq->content(i).object );
+ const ContentSequence* pv_seq = pv->get_content();
+ size_t ccount = pv_seq->size();
+
+ // iterate over physvol content
+ for ( size_t pvidx = 0; pvidx < ccount; pvidx++ ) {
+
+ // found "choice" tag?
+ if( pv_seq->content(pvidx).tag == "choice" ) {
+
+ const ContentChoice* pv_choice = dynamic_cast<const ContentChoice*>( pv_seq->content(pvidx).object );
+
+ // found a physvolid?
+ if ( pv_choice->content().tag == "physvolid" ) {
+
+ // add the physvolid...
+
+ physvolidElem* pvid_elem =
+ dynamic_cast<physvolidElem*>( pv_choice->content().object );
+
+ if ( pvid_elem == 0 ) {
+ G4Exception("", "", FatalException, "Failed cast to physvolidElem.");
+ }
+
+ GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
+
+ std::string strID = pvid_elem->get_value();
+ std::string fld = pvid_elem->get_field_name();
+
+ int intID = (int)calc->Eval( strID );
+
+ PhysVolId pvid(intID, fld);
+
+ // assign physvolid to lv's child by the in-order idx
+ IdManager::instance()->addPhysVolId(
+ lv, // LV mom
+ nchildren - 1, // child idx in mom
+ pvid ); // PhysVolId
+ }
+
+ }
+ }
+ }
+ }
+ } else {
+ G4Exception("", "", FatalException, "Failed cast to G4LogicalVolume.");
+ }
+ } else {
+ G4Exception("", "", FatalException, "Failed cast to volume.");
+ }
+ }
+}
+
+//DECLARE_SUBSCRIBER_FACTORY(volumeExtendedSubscriber)
lcdd/src/lcdd/util
diff -N GDMLWriter.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ GDMLWriter.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,39 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/util/GDMLWriter.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// LCDD
+#include "lcdd/util/GDMLWriter.hh"
+
+// GDML
+#include "G4Writer/G4GDMLWriter.h"
+
+// Geant4
+#include "G4VPhysicalVolume.hh"
+#include "G4TransportationManager.hh"
+
+void GDMLWriter::writeCurrentGeometry(const std::string& fileName, std::vector<std::string> volumes)
+{
+ G4VPhysicalVolume* world = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
+ G4GDMLWriter g4writer("http://www.lcsim.org/schemas/gdml/1.0/gdml.xsd", fileName);
+ try {
+ g4writer.DumpGeometryInfo(world, volumes);
+ } catch (std::exception &err) {
+ G4cerr << "problem writing geometry: " << err.what() << std::endl;
+ }
+}
+
+void GDMLWriter::writeCurrentGeometry(const std::string& fileName)
+{
+ G4cout << "Dumping current geometry to file <" << fileName << ">" << G4endl;
+
+ G4VPhysicalVolume* world =
+ G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
+
+ G4GDMLWriter g4writer("http://www.lcsim.org/schemas/gdml/1.0/gdml.xsd", fileName);
+
+ try {
+ g4writer.DumpGeometryInfo(world);
+ }
+ catch(std::exception &lerr) {
+ G4cerr << "problem writing geometry: " << lerr.what () << std::endl;
+ }
+}
lcdd/src/lcdd/util
diff -N GDMLWriterMessenger.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ GDMLWriterMessenger.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,46 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/util/GDMLWriterMessenger.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// LCDD
+#include "lcdd/util/GDMLWriterMessenger.hh"
+#include "lcdd/util/GDMLWriter.hh"
+
+// Geant4
+#include "G4UIcmdWithAString.hh"
+
+GDMLWriterMessenger::GDMLWriterMessenger()
+{
+ defineCommands();
+}
+
+GDMLWriterMessenger::~GDMLWriterMessenger()
+{
+}
+
+void GDMLWriterMessenger::SetNewValue(G4UIcommand *, G4String newVals)
+{
+ std::string volume;
+ std::string fileName;
+ std::istringstream is(newVals);
+
+ is >> fileName >> volume;
+
+ if (volume.length() > 1) {
+ std::vector<std::string> volumes;
+ volumes.push_back(volume);
+ GDMLWriter::writeCurrentGeometry(fileName, volumes);
+ } else {
+ GDMLWriter::writeCurrentGeometry(fileName);
+ }
+}
+
+void GDMLWriterMessenger::defineCommands()
+{
+ m_dumpGDMLCmd = new G4UIcommand("/lcdd/dumpGDML", this);
+ m_dumpGDMLCmd->SetGuidance("Dump current geometry to GDML output file.");
+ G4UIparameter* p = new G4UIparameter("outputFile", 's', false);
+ m_dumpGDMLCmd->SetParameter(p);
+ p = new G4UIparameter("topVolume", 's', true);
+ m_dumpGDMLCmd->SetParameter(p);
+ m_dumpGDMLCmd->AvailableForStates(G4State_Idle);
+}
+
lcdd/src/lcdd/util
diff -N NistElementsDump.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ NistElementsDump.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,130 @@
+// $Id: NistElementsDump.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// LCDD
+#include "lcdd/util/NistElementsDump.hh"
+#include "lcdd/util/StringUtil.hh"
+
+// GDML
+#include "Writer/Element.h"
+
+// Geant4
+#include "G4String.hh"
+#include "G4NistManager.hh"
+
+// STL
+#include <vector>
+#include <fstream>
+
+using gdml::writer::Element;
+
+using namespace std;
+
+#include "lcdd/util/ElementNames.icc"
+
+void NistElementsDump::writeXml(const std::string& filename)
+{
+ ofstream fstr;
+ fstr.open(filename.c_str(), fstream::out);
+ printXml(fstr);
+ fstr.close();
+}
+
+void NistElementsDump::printXml(std::ostream& out)
+{
+ // Get the NIST manager from G4.
+ G4NistManager* mgr = G4NistManager::Instance();
+
+ // Create the XML root node.
+ Element* materials = new Element("materials");
+
+ // Loop over chemical elements array.
+ for (int i = 0; i < nelements; i++) {
+ // Get the element abbreviation and name.
+ const std::string& elemAbbrev = abbrevs[i];
+ const std::string& elemName = names[i];
+
+ // Get element and material from G4.
+ G4Element* elem = mgr->FindOrBuildElement(elemAbbrev);
+ if (elem == 0) {
+ std::cout << elemAbbrev << " not found." << std::endl;
+ continue;
+ }
+ const std::string& g4mat = "G4_" + elemAbbrev;
+ G4Material* mat = mgr->FindOrBuildMaterial(g4mat);
+ if (mat == 0) {
+ std::cout << g4mat << " not found." << std::endl;
+ continue;
+ }
+
+ // Create new element.
+ Element* elemNode = new Element("element");
+ elemNode->addAttribute("name", elem->GetName());
+ elemNode->addAttribute("formula", elem->GetSymbol());
+ elemNode->addAttribute("Z", StringUtil::toString(elem->GetZ()));
+
+ // Setup atom.
+ Element* atomNode = new Element("atom");
+ atomNode->addAttribute("type", "A");
+ atomNode->addAttribute("unit", "g/mol");
+ atomNode->addAttribute("value", StringUtil::toString((elem->GetA() * mole / g)));
+
+ // Append atom node to element.
+ elemNode->appendChild(*atomNode);
+
+ // Append element node to top.
+ materials->appendChild(*elemNode);
+
+ // Create material node.
+ Element* matNode = new Element("material");
+ matNode->addAttribute("name", elemName);
+ matNode->addAttribute("formula", elem->GetName());
+
+ // Set material state.
+ G4State g4state = mat->GetState();
+ std::string state;
+ if (g4state == kStateSolid) {
+ state = "solid";
+ } else if (g4state == kStateLiquid) {
+ state = "liquid";
+ } else if (g4state == kStateGas) {
+ state = "gas";
+ } else {
+ state = "unknown";
+ }
+ matNode->addAttribute("state", state);
+
+ // Add radlen node.
+ Element* radlNode = new Element("RL");
+ radlNode->addAttribute("unit", "cm");
+ radlNode->addAttribute("type", "X0");
+ radlNode->addAttribute("value", StringUtil::toString(mat->GetRadlen() / cm));
+ matNode->appendChild(*radlNode);
+
+ // Add nuclear interaction length node.
+ Element* nilNode = new Element("NIL");
+ nilNode->addAttribute("unit", "cm");
+ nilNode->addAttribute("type", "lambda");
+ nilNode->addAttribute("value", StringUtil::toString(mat->GetNuclearInterLength() / cm));
+ matNode->appendChild((*nilNode));
+
+ // Add density node.
+ Element* densNode = new Element("D");
+ densNode->addAttribute("type", "density");
+ densNode->addAttribute("unit", "g/cm3");
+ double matDens = mat->GetDensity() / (g / cm3);
+ densNode->addAttribute("value", StringUtil::toString(matDens));
+ matNode->appendChild(*densNode);
+
+ // Add composition node.
+ Element* compNode = new Element("composite");
+ compNode->addAttribute("n", "1");
+ compNode->addAttribute("ref", elem->GetName());
+ matNode->appendChild(*compNode);
+
+ // Add material node to root.
+ materials->appendChild((*matNode));
+ }
+
+ // Write root node to output stream.
+ materials->toXml(out, true, true);
+}
lcdd/src/lcdd/util
diff -N StringUtil.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ StringUtil.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,145 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/util/StringUtil.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// LCDD
+#include "lcdd/util/StringUtil.hh"
+
+// STL
+#include <cctype>
+#include <iostream>
+#include <algorithm>
+#include <sstream>
+#include <vector>
+
+const std::string StringUtil::ALPHA_STR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+const std::string StringUtil::NUM_STR = "1234567890";
+const std::string StringUtil::WS_STR = "\x20\x09\x0A\x0B\x0C\x0D";
+const std::string StringUtil::NULL_STR = "";
+
+using std::string;
+using std::stringstream;
+using std::istringstream;
+using std::vector;
+
+string StringUtil::toString(double d)
+{
+ stringstream ostr;
+ ostr << d;
+ return ostr.str();
+}
+
+string StringUtil::toString(float f)
+{
+ stringstream ostr;
+ ostr << f;
+ return ostr.str();
+}
+
+string StringUtil::toString(bool b)
+{
+ if (b) {
+ return "1";
+ }
+
+ return "0";
+}
+
+string StringUtil::toString(int i)
+{
+ stringstream ostr;
+ ostr << i;
+ return ostr.str();
+}
+
+string& StringUtil::toLower(string& s)
+{
+ std::transform(s.begin(), s.end(), s.begin(), tolower);
+ return s;
+}
+
+string& StringUtil::toLower(const string& s)
+{
+ return StringUtil::toLower(const_cast<string&>(s));
+}
+
+double StringUtil::toDouble(string& s)
+{
+ std::istringstream is(s.c_str());
+ double d;
+ is >> d;
+ return d;
+}
+
+int StringUtil::toInt(string& s)
+{
+ std::istringstream is(s.c_str());
+ int i;
+ is >> i;
+ return i;
+}
+
+bool StringUtil::toBool(string& s)
+{
+ if (StringUtil::toLower(s) == "true" || s == "1") {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool StringUtil::toBool(const string& s)
+{
+ return StringUtil::toBool(const_cast<string&>(s));
+}
+
+double StringUtil::toDouble(const string& s)
+{
+ return StringUtil::toDouble(const_cast<string&>(s));
+}
+
+void StringUtil::trim(string& str)
+{
+ string::size_type pos = str.find_last_not_of(' ');
+ if (pos != string::npos) {
+ str.erase(pos + 1);
+ pos = str.find_first_not_of(' ');
+ if (pos != string::npos)
+ str.erase(0, pos);
+ } else
+ str.erase(str.begin(), str.end());
+}
+
+string StringUtil::concatStrVec(const vector<string>& s_vec, const string& sep)
+{
+ string r;
+
+ // concat w/ a space in between
+ for (vector<string>::const_iterator iter = s_vec.begin(); iter != s_vec.end(); iter++) {
+ r += (*iter) + string(sep);
+ }
+
+ // lop off dangling space
+ r.erase(r.end() - 1, r.end());
+
+ return r;
+}
+
+void StringUtil::split(const string& str, const string& delimiters, vector<string>& tokens)
+{
+ // Skip delimiters at beginning.
+ string::size_type lastPos = str.find_first_not_of(delimiters, 0);
+
+ // Find first "non-delimiter".
+ string::size_type pos = str.find_first_of(delimiters, lastPos);
+
+ while (string::npos != pos || string::npos != lastPos) {
+
+ // Found a token, add it to the vector.
+ tokens.push_back(str.substr(lastPos, pos - lastPos));
+
+ // Skip delimiters. Note the "not_of"
+ lastPos = str.find_first_not_of(delimiters, pos);
+
+ // Find next "non-delimiter"
+ pos = str.find_first_of(delimiters, lastPos);
+ }
+}
lcdd/src/lcdd/util
diff -N Verbose.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Verbose.cc 26 Jun 2013 23:51:02 -0000 1.1
@@ -0,0 +1,6 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/util/Verbose.cc,v 1.1 2013/06/26 23:51:02 jeremy Exp $
+
+// LCDD
+#include "lcdd/util/Verbose.hh"
+
+const Verbose::LevelType Verbose::m_defaultLevel = 0;
CVSspam 0.2.12