11 modified files
lcdd/include
diff -u -r1.5 -r1.6
--- G4CalorimeterSD.hh 6 May 2005 20:40:28 -0000 1.5
+++ G4CalorimeterSD.hh 27 Jun 2005 20:40:33 -0000 1.6
@@ -28,6 +28,8 @@
public:
+ virtual bool isValidVolume(G4LogicalVolume* lv);
+
virtual void Initialize(G4HCofThisEvent *);
virtual void EndOfEvent(G4HCofThisEvent *);
lcdd/include
diff -u -r1.4 -r1.5
--- G4NonprojectiveCylinderSegmentation.hh 4 Mar 2005 22:51:00 -0000 1.4
+++ G4NonprojectiveCylinderSegmentation.hh 27 Jun 2005 20:40:34 -0000 1.5
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/G4NonprojectiveCylinderSegmentation.hh,v 1.4 2005/03/04 22:51:00 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/G4NonprojectiveCylinderSegmentation.hh,v 1.5 2005/06/27 20:40:34 jeremy Exp $
#include "G4Segmentation.hh"
/**
@@ -25,6 +25,8 @@
G4ThreeVector getLocalHitPos(const G4Step* aStep);
+ virtual bool isValidSolid(G4VSolid*);
+
private:
double computeDeltaPhi(const G4Step* aStep);
lcdd/include
diff -u -r1.5 -r1.6
--- G4ProjectiveCylinderSegmentation.hh 4 Mar 2005 22:51:00 -0000 1.5
+++ G4ProjectiveCylinderSegmentation.hh 27 Jun 2005 20:40:34 -0000 1.6
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/G4ProjectiveCylinderSegmentation.hh,v 1.5 2005/03/04 22:51:00 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/G4ProjectiveCylinderSegmentation.hh,v 1.6 2005/06/27 20:40:34 jeremy Exp $
#ifndef G4ProjectiveCylinderSegmentation_hh
#define G4ProjectiveCylinderSegmentation_hh 1
@@ -19,6 +19,8 @@
virtual ~G4ProjectiveCylinderSegmentation();
+ virtual bool isValidSolid(G4VSolid* s);
+
protected:
virtual double getRadius(const G4Step* aStep);
lcdd/include
diff -u -r1.11 -r1.12
--- G4Segmentation.hh 4 Mar 2005 22:51:00 -0000 1.11
+++ G4Segmentation.hh 27 Jun 2005 20:40:34 -0000 1.12
@@ -20,7 +20,7 @@
enum EType { eProjective=1, eNonprojective };
typedef std::vector<std::string> BinNames;
-
+
public:
G4Segmentation(EType segType, int nbins = 2);
virtual ~G4Segmentation();
@@ -92,6 +92,14 @@
static void printOutBins(std::ostream& os, const std::vector<int>& bins);
+ /*
+ * Check whether the solid is valid for this segmentation.
+ *
+ * Returns false if solid is not valid.
+ *
+ */
+ virtual bool isValidSolid(G4VSolid*);
+
private:
// bin values
lcdd/include
diff -u -r1.9 -r1.10
--- G4SensitiveDetector.hh 6 May 2005 18:24:43 -0000 1.9
+++ G4SensitiveDetector.hh 27 Jun 2005 20:40:34 -0000 1.10
@@ -14,7 +14,7 @@
* @class G4SensitiveDetector
* @brief Basic implementation of G4VSensitiveDetector.
* @note Primary settings include verbosity, energy cut,
- * IdSpec, and HC ID.
+ * IdSpec, and HC ID.
*/
class G4SensitiveDetector : public G4VSensitiveDetector, protected G4StepReadout
{
@@ -40,6 +40,8 @@
EType getType() const;
G4int getHCID() const;
+ virtual bool isValidVolume(G4LogicalVolume* lv);
+
const std::string& getHCName()
{
return collectionName[0];
lcdd/src
diff -u -r1.23 -r1.24
--- G4CalorimeterSD.cc 6 May 2005 20:40:28 -0000 1.23
+++ G4CalorimeterSD.cc 27 Jun 2005 20:40:34 -0000 1.24
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4CalorimeterSD.cc,v 1.23 2005/05/06 20:40:28 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/G4CalorimeterSD.cc,v 1.24 2005/06/27 20:40:34 jeremy Exp $
#include "G4CalorimeterSD.hh"
// LCDD
@@ -30,6 +30,17 @@
G4CalorimeterSD::~G4CalorimeterSD()
{}
+bool G4CalorimeterSD::isValidVolume(G4LogicalVolume* lv)
+{
+ bool valid = G4SensitiveDetector::isValidVolume(lv);
+
+ if ( valid ) {
+ valid = m_segmentation->isValidSolid( lv->GetSolid() );
+ }
+
+ return valid;
+}
+
void G4CalorimeterSD::Initialize(G4HCofThisEvent *HCE)
{
// new cal hits collection
@@ -37,12 +48,12 @@
// set HCID
if ( getHCID() < 0) {
- setHCID( GetCollectionID(0) );
+ setHCID( GetCollectionID(0) );
}
// add collection to HC of event
HCE->AddHitsCollection( getHCID(), m_HC );
-
+
#ifdef G4VERBOSE
if ( getVerbose() > 1 ) {
std::cout << "HCID <" << getHCID() << ">" << std::endl;
@@ -100,10 +111,10 @@
// create id and pack into 64
Id64bit id64 = makeId();
- // compute step midpoint and compare to cell pos for debugging
-#ifdef G4DEBUG
+ // compute step midpoint and compare to cell pos for debugging
+#ifdef G4DEBUG
#ifdef G4VERBOSE
- if ( verbose > 1 ) {
+ if ( verbose > 1 ) {
G4ThreeVector globalMidPos = midPosition();
std::cout << "globalMidPos " << globalMidPos << std::endl;
std::cout << "globalCellPos - globalMidPos = " << globalCellPos - globalMidPos << std::endl;
@@ -151,7 +162,7 @@
// for setting contrib
thisHit = fndHit;
- }
+ }
// add McpHitContrib to this hit, setting info from step info
thisHit->addMcpHitContrib( McpHitContrib( aStep ) );
@@ -169,7 +180,7 @@
fndHit = *iter;
break;
}
- }
+ }
return fndHit;
}
@@ -186,8 +197,8 @@
{
#ifdef G4VERBOSE
if ( getVerbose() > 0 ) {
- std::cout << "Calorimeter <" << GetName() << "> has nhits <"
- << m_HC->GetSize() << ">." << std::endl;
+ std::cout << "Calorimeter <" << GetName() << "> has nhits <"
+ << m_HC->GetSize() << ">." << std::endl;
}
if ( getVerbose() > 2 ) {
lcdd/src
diff -u -r1.12 -r1.13
--- G4NonprojectiveCylinderSegmentation.cc 23 Jun 2005 23:42:45 -0000 1.12
+++ G4NonprojectiveCylinderSegmentation.cc 27 Jun 2005 20:40:34 -0000 1.13
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4NonprojectiveCylinderSegmentation.cc,v 1.12 2005/06/23 23:42:45 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/G4NonprojectiveCylinderSegmentation.cc,v 1.13 2005/06/27 20:40:34 jeremy Exp $
#include "G4NonprojectiveCylinderSegmentation.hh"
#include "ReadoutUtil.hh"
@@ -139,3 +139,16 @@
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 -u -r1.7 -r1.8
--- G4ProjectiveCylinderSegmentation.cc 19 Apr 2005 04:19:06 -0000 1.7
+++ G4ProjectiveCylinderSegmentation.cc 27 Jun 2005 20:40:34 -0000 1.8
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4ProjectiveCylinderSegmentation.cc,v 1.7 2005/04/19 04:19:06 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/G4ProjectiveCylinderSegmentation.cc,v 1.8 2005/06/27 20:40:34 jeremy Exp $
#include "G4ProjectiveCylinderSegmentation.hh"
#include "ReadoutUtil.hh"
@@ -35,3 +35,15 @@
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 -u -r1.8 -r1.9
--- G4Segmentation.cc 19 Apr 2005 04:19:06 -0000 1.8
+++ G4Segmentation.cc 27 Jun 2005 20:40:34 -0000 1.9
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4Segmentation.cc,v 1.8 2005/04/19 04:19:06 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/G4Segmentation.cc,v 1.9 2005/06/27 20:40:34 jeremy Exp $
#include "G4Segmentation.hh"
#include "ReadoutUtil.hh"
@@ -25,7 +25,7 @@
int G4Segmentation::getNumberOfBins()
{
return m_numBins;
-}
+}
const std::vector<int>& G4Segmentation::getBins()
{
@@ -58,3 +58,14 @@
}
os << std::endl;
}
+
+bool G4Segmentation::isValidSolid(G4VSolid* s)
+{
+ bool valid = true;
+
+ if ( 0 == s ) {
+ valid = false;
+ }
+
+ return valid;
+}
lcdd/src
diff -u -r1.7 -r1.8
--- G4SensitiveDetector.cc 19 Apr 2005 23:08:47 -0000 1.7
+++ G4SensitiveDetector.cc 27 Jun 2005 20:40:35 -0000 1.8
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4SensitiveDetector.cc,v 1.7 2005/04/19 23:08:47 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/G4SensitiveDetector.cc,v 1.8 2005/06/27 20:40:35 jeremy Exp $
#include "G4SensitiveDetector.hh"
// LCDD
@@ -31,6 +31,17 @@
G4SensitiveDetector::~G4SensitiveDetector()
{}
+bool G4SensitiveDetector::isValidVolume(G4LogicalVolume* lv)
+{
+ bool valid = true;
+
+ if ( 0 == lv ) {
+ valid = false;
+ }
+
+ return valid;
+}
+
void G4SensitiveDetector::Initialize(G4HCofThisEvent *)
{
// no-op
@@ -74,15 +85,15 @@
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() );
- }
+ id64 = IdFactory::createId64bit( ids, getIdSpec() );
+ }
return id64;
}
lcdd/src
diff -u -r1.24 -r1.25
--- volumeExtendedSubscriber.cc 26 Apr 2005 01:30:08 -0000 1.24
+++ volumeExtendedSubscriber.cc 27 Jun 2005 20:40:35 -0000 1.25
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/volumeExtendedSubscriber.cc,v 1.24 2005/04/26 01:30:08 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/volumeExtendedSubscriber.cc,v 1.25 2005/06/27 20:40:35 jeremy Exp $
// GDML
#include "Saxana/SAXSubscriber.h"
@@ -43,31 +43,31 @@
}
public:
- volumeExtendedSubscriber()
+ volumeExtendedSubscriber()
{
Subscribe( "volume" );
}
- virtual ~volumeExtendedSubscriber()
+ virtual ~volumeExtendedSubscriber()
{}
virtual void Activate( const SAXObject* object)
- {
+ {
LCDDProcessor* proc = LCDDProcessor::instance();
- const volume* vobj = 0;
+ 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() ) );
+ lv = const_cast<G4LogicalVolume*>
+ ( GDMLProcessor::GetInstance()->GetLogicalVolume(vobj->get_name() ) );
if ( lv ) {
@@ -83,12 +83,17 @@
// handle sdref tag
if ( seq->content(i).tag == "sdref" ) {
- SensitiveDetectorType::sdref* sd =
+ SensitiveDetectorType::sdref* sd =
dynamic_cast<SensitiveDetectorType::sdref*> ( seq->content(i).object );
- g4sd = proc->getSensitiveDetector( sd->get_ref() );
+ 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() + ">.");
+ }
+
lv->SetSensitiveDetector(g4sd);
}
else {
@@ -100,11 +105,11 @@
else if ( seq->content(i).tag == "regionref" ) {
// get regionref object
- RegionType::regionref* regref =
+ RegionType::regionref* regref =
dynamic_cast<RegionType::regionref*> ( seq->content(i).object );
-
+
// get region from store
- G4Region* reg =
+ G4Region* reg =
dynamic_cast<G4Region*> ( proc->getRegion( regref->get_ref() ) );
// add LV to region
@@ -119,7 +124,7 @@
// handle limitref
else if ( seq->content(i).tag == "limitref" ) {
- LimitType::limitref* limitref =
+ LimitType::limitref* limitref =
dynamic_cast<LimitType::limitref*> ( seq->content(i).object );
G4UserLimits* ulim =
@@ -139,12 +144,12 @@
//std::cout << "handling visref" << std::endl;
- VisType::visref* visref =
+ VisType::visref* visref =
dynamic_cast<VisType::visref*> ( seq->content(i).object );
- G4VisAttributes* vis =
+ G4VisAttributes* vis =
dynamic_cast<G4VisAttributes*> ( proc->getVisAttributes( visref->get_ref() ) );
-
+
if ( vis ) {
//std::cout << "assigning vis: " << visref->get_ref() << std::endl;
lv->SetVisAttributes( vis );
@@ -154,7 +159,7 @@
G4Exception("vis element not found.");
}
}
- // handle physvols to look for physvolids
+ // handle physvols to look for physvolids
if ( seq->content(i).tag == "physvol" ) {
++nchildren;
@@ -164,25 +169,25 @@
const ContentSequence* pv_seq = pv->get_content();
size_t ccount = pv_seq->size();
- // iterate over physvol content
+ // 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 =
+ const ContentChoice* pv_choice =
dynamic_cast<const ContentChoice*>( pv_seq->content(pvidx).object );
-
- // found a physvolid?
+
+ // found a physvolid?
if ( pv_choice->content().tag == "physvolid" ) {
// add the physvolid...
- physvolidElem* pvid_elem =
+ physvolidElem* pvid_elem =
dynamic_cast<physvolidElem*>( pv_choice->content().object );
if ( pvid_elem == 0 ) {
- G4Exception("Failed cast to physvolidElem.");
+ G4Exception("Failed cast to physvolidElem.");
}
GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
@@ -200,10 +205,10 @@
nchildren - 1, // child idx in mom
pvid ); // PhysVolId
}
-
+
}
}
- }
+ }
}
}
else {
@@ -213,10 +218,10 @@
else {
G4Exception("Failed cast to volume!");
}
- }
-
+ }
+
//delete object;
- }
+ }
};
DECLARE_SUBSCRIBER_FACTORY(volumeExtendedSubscriber)
CVSspam 0.2.8