lcdd/include
diff -u -r1.1 -r1.2
--- StoreInspector.hh 9 Dec 2005 01:53:14 -0000 1.1
+++ StoreInspector.hh 9 Dec 2005 22:23:24 -0000 1.2
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/StoreInspector.hh,v 1.1 2005/12/09 01:53:14 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/StoreInspector.hh,v 1.2 2005/12/09 22:23:24 jeremy Exp $
#ifndef lcdd_StoreInspector_hh
#define lcdd_StoreInspector_hh 1
@@ -15,6 +15,8 @@
#include <cassert>
#include <cmath>
+using std::endl;
+
/**
* StoreInspector is a templated class for printing the contents
* of a vector or map-based object store using a G4UIcommand.
@@ -101,26 +103,26 @@
/**
* Print out the objects in the store using the stream.
*/
- std::ostream& printStore(std::ostream& os)
- {
- os << "********* " + _name + " store ********" << std::endl << std::endl;
- for ( const_iterator it = _container->begin();
- it != _container->end();
- it++ ) {
- printObject( os, getObjectName( it ), getObject( it ) );
- os << "-------------------------------------" << std::endl;
- }
- return os;
- os << "*************************************" << std::endl << std::endl;
+ std::ostream& printStore(std::ostream& os)
+ {
+ os << "********* " + _name + " store ********" << endl << endl;
+ for ( const_iterator it = _container->begin();
+ it != _container->end();
+ it++ ) {
+ printObject( os, getObjectName( it ), getObject( it ) );
+ os << "-------------------------------------" << endl;
}
+ return os;
+ os << "*************************************" << endl << endl;
+ }
/**
* Print a single object's name and data using the stream operator.
*/
std::ostream& printObject(std::ostream& os, const std::string& name, Object* obj)
{
- os << "name: " << name << std::endl;
- os << (*obj) << std::endl;
+ os << "name: " << name << endl;
+ os << (*obj) << endl;
return os;
}
@@ -149,7 +151,7 @@
printObject( std::cout, name, obj );
}
else {
- std::cerr << "ERROR: Object named " + name + " was not found in the " + _name + " store!" << std::endl;
+ std::cerr << "ERROR: Object named " + name + " was not found in the " + _name + " store!" << endl;
}
}
else {
@@ -164,7 +166,7 @@
G4UIdirectory* _dir;
};
-// FIXME: None of these types/objects should be declared globally.
+// FIXME: None of these inspectors should be declared globally. Put in G4StoreManager.
#include "LCDDProcessor.hh"
@@ -172,25 +174,65 @@
#include "G4MaterialTable.hh"
typedef StoreInspector< G4Material, G4MaterialTable > G4MaterialStoreInspector;
-G4MaterialStoreInspector materialInspector( "material", G4Material::GetMaterialTable() );
+G4MaterialStoreInspector materialInspector( "G4Material", G4Material::GetMaterialTable() );
/* solid */
#include "G4VSolid.hh"
#include "G4SolidStore.hh"
typedef StoreInspector< G4VSolid, G4SolidStore > G4SolidStoreInspector;
-G4SolidStoreInspector solidInspector( "solid", G4SolidStore::GetInstance() );
+G4SolidStoreInspector solidInspector( "G4VSolid", G4SolidStore::GetInstance() );
/* limit set */
#include "G4LimitSet.hh"
+#include "G4UnitsTable.hh"
-std::ostream& operator<<(std::ostream& os, G4LimitSet&)
+std::ostream& operator<<(std::ostream& os, G4LimitSet& limset)
{
+ os << endl;
+ for ( G4LimitSet::LimitSetMap::const_iterator it = limset.getLimitSetMap().begin();
+ it != limset.getLimitSetMap().end();
+ it++ ) {
+
+ const G4LimitSet::LimitNameType& name = it->first;
+ os << name << endl;
+
+ std::string unit = "";
+ if ( name == "ekin_min" ) {
+ unit = "Energy";
+ }
+ else if ( name == "range_min" ) {
+ unit = "Length";
+ }
+ else if ( name == "step_length_max" ) {
+ unit = "Length";
+ }
+ else if ( name == "time_max" ) {
+ unit = "Time";
+ }
+ else if ( name == "track_length_max" ) {
+ unit = "Length";
+ }
+
+ if ( unit != "" ) {
+ const G4LimitSet::LimitMap& limmap = it->second;
+ for ( G4LimitSet::LimitMap::const_iterator iit = limmap.begin();
+ iit != limmap.end();
+ iit++ ) {
+
+ os << '\t' << iit->first << '\t' << G4BestUnit(iit->second, unit) << endl;
+ }
+ }
+ else {
+ os << "Unknown limit type " << name << endl;
+ }
+ }
return os;
}
+
typedef StoreInspector< G4LimitSet, LCDDProcessor::LimitSets > G4LimitSetInspector;
-G4LimitSetInspector limitsetInspector( "limitset", LCDDProcessor::instance()->getLimitSetStore() );
+G4LimitSetInspector limitsetInspector( "G4LimitSet", LCDDProcessor::instance()->getLimitSetStore() );
/* lvolume */
#include "G4LogicalVolume.hh"
@@ -200,55 +242,55 @@
/* G4LogicalVolume stream operator */
std::ostream& operator<<(std::ostream &os, G4LogicalVolume &lv)
{
- os << "solid: " << lv.GetSolid()->GetName() << std::endl;
- os << "material: " << lv.GetMaterial()->GetName() << std::endl;
- os << "# daughters: " << lv.GetNoDaughters() << std::endl;
-
- G4UserLimits* lim = lv.GetUserLimits();
- os << "limits: ";
- if ( 0 != lim ) {
- os << lim->GetType();
- }
- else {
- os << "NONE";
- }
- os << std::endl;
+os << "solid: " << lv.GetSolid()->GetName() << endl;
+os << "material: " << lv.GetMaterial()->GetName() << endl;
+os << "# daughters: " << lv.GetNoDaughters() << endl;
+
+G4UserLimits* lim = lv.GetUserLimits();
+os << "limits: ";
+if ( 0 != lim ) {
+os << lim->GetType();
+}
+else {
+os << "NONE";
+}
+os << endl;
- G4VSensitiveDetector* sd = lv.GetSensitiveDetector();
- os << "SD: ";
- if ( 0 != sd ) {
- os << sd->GetName();
- }
- else {
- os << "NONE";
- }
- os << std::endl;
+G4VSensitiveDetector* sd = lv.GetSensitiveDetector();
+os << "SD: ";
+if ( 0 != sd ) {
+os << sd->GetName();
+}
+else {
+os << "NONE";
+}
+os << endl;
- G4Region* reg = lv.GetRegion();
- os << "region: ";
- if ( 0 != reg ) {
- os << reg->GetName();
- }
- else {
- os << "NONE";
- }
- os << std::endl;
+G4Region* reg = lv.GetRegion();
+os << "region: ";
+if ( 0 != reg ) {
+os << reg->GetName();
+}
+else {
+os << "NONE";
+}
+os << endl;
- const G4VisAttributes* vis = lv.GetVisAttributes();
- os << "visattributes: ";
- if ( 0 != vis ) {
- os << "yes";
- }
- else {
- os << "NONE";
- }
- os << std::endl;
+const G4VisAttributes* vis = lv.GetVisAttributes();
+os << "visattributes: ";
+if ( 0 != vis ) {
+os << "yes";
+}
+else {
+os << "NONE";
+}
+os << endl;
- return os;
+return os;
}
typedef StoreInspector< G4LogicalVolume, G4LogicalVolumeStore > G4LogicalVolumeStoreInspector;
-G4LogicalVolumeStoreInspector lvolumeInspector( "lvolume", G4LogicalVolumeStore::GetInstance() );
+G4LogicalVolumeStoreInspector lvolumeInspector( "G4LogicalVolume", G4LogicalVolumeStore::GetInstance() );
/* pvolume */
#include "G4VPhysicalVolume.hh"
@@ -256,42 +298,62 @@
std::ostream& operator<<(std::ostream &os, G4VPhysicalVolume &pv)
{
- os << "lvolume: " << pv.GetLogicalVolume()->GetName() << std::endl;
- os << "pos: " << pv.GetTranslation() << std::endl;
+ os << "lvolume: " << pv.GetLogicalVolume()->GetName() << endl;
+ os << "pos: " << pv.GetTranslation() << endl;
const G4RotationMatrix* rot = pv.GetRotation();
os << "rot: ";
if ( 0 != rot ) {
rot->print(os);
}
else {
- os << "NONE" << std::endl;
+ os << "NONE" << endl;
}
- os << "copyNo: " << pv.GetCopyNo() << std::endl;
- os << "# copies: " << pv.GetMultiplicity() << std::endl;
+ os << "copyNo: " << pv.GetCopyNo() << endl;
+ os << "# copies: " << pv.GetMultiplicity() << endl;
return os;
}
typedef StoreInspector< G4VPhysicalVolume, G4PhysicalVolumeStore > G4PhysicalVolumeStoreInspector;
-G4PhysicalVolumeStoreInspector pvolumeInspector( "pvolume", G4PhysicalVolumeStore::GetInstance() );
+G4PhysicalVolumeStoreInspector pvolumeInspector( "G4VPhysicalVolume", G4PhysicalVolumeStore::GetInstance() );
+
+/* idspec */
+#include "IdManager.hh"
+
+std::ostream& operator<<(std::ostream& os, IdSpec& id)
+{
+ os << "# fields: " << id.getNumFields() << endl;
+ os << endl;
+ os << "label\tstart\tlength\tsigned" << endl;
+ for ( IdSpec::IdFields::const_iterator it = id.IdFieldsBegin();
+ it != id.IdFieldsEnd();
+ it++ ) {
+ IdField* field = *it;
+ os << field->getLabel() << '\t' << field->getStart() << '\t' << field->getLength() << '\t' << field->getSigned() << endl;
+ }
+ return os;
+}
+
+typedef StoreInspector< IdSpec, IdManager::IdSpecs > IdSpecInspector;
+IdSpecInspector idspecInspector( "IdSpec", IdManager::instance()->getIdSpecStore() );
/* SD */
#include "G4SensitiveDetector.hh" // use LCDD's concrete SD class
std::ostream& operator<<(std::ostream& os, G4SensitiveDetector& sd)
{
- os << "fullPath: " << sd.GetFullPathName() << std::endl;
- os << "HC: " << sd.getHCName() << std::endl;
- os << "HCID: " << sd.getHCID() << std::endl;
- os << "verbose: " << sd.getVerbose() << std::endl;
- os << "ecut: " << sd.getEcut() << std::endl;
- os << "hasIdSpec: " << sd.hasIdSpec() << std::endl;
- os << "isEndcap: " << sd.getEndcapFlag() << std::endl;
- os << "isActive: " << sd.isActive() << std::endl;
+ os << "fullPath: " << sd.GetFullPathName() << endl;
+ os << "HC: " << sd.getHCName() << endl;
+ os << "HCID: " << sd.getHCID() << endl;
+ os << "verbose: " << sd.getVerbose() << endl;
+ os << "ecut: " << sd.getEcut() << endl;
+ os << "hasIdSpec: " << sd.hasIdSpec() << endl;
+ os << "isEndcap: " << sd.getEndcapFlag() << endl;
+ os << "isActive: " << sd.isActive() << endl;
return os;
}
typedef StoreInspector< G4SensitiveDetector, LCDDProcessor::SensitiveDetectors > G4SensitiveDetectorInspector;
-G4SensitiveDetectorInspector sdInspector( "sd", LCDDProcessor::instance()->getSensitiveDetectorStore() );
+G4SensitiveDetectorInspector sdInspector( "G4SensitiveDetector", LCDDProcessor::instance()->getSensitiveDetectorStore() );
/* region */
#include "G4Region.hh"
@@ -303,21 +365,21 @@
/* G4Region stream operator */
std::ostream& operator<<(std::ostream &os, G4Region ®)
{
- os << "prod cut: " << reg.GetProductionCuts()->GetProductionCut(0) << std::endl;
+ os << "prod cut: " << reg.GetProductionCuts()->GetProductionCut(0) << endl;
G4UserRegionInformation* regInfo
= static_cast<G4UserRegionInformation*> ( reg.GetUserInformation() );
if ( 0 != regInfo ) {
- os << "store secondaries: " << regInfo->getStoreSecondaries() << std::endl;
- os << "energy threshold: " << regInfo->getThreshold() << std::endl;
+ os << "store secondaries: " << regInfo->getStoreSecondaries() << endl;
+ os << "energy threshold: " << regInfo->getThreshold() << endl;
}
else {
- os << "NO G4UserRegionInformation" << std::endl;
+ os << "NO G4UserRegionInformation" << endl;
}
return os;
}
typedef StoreInspector< G4Region, G4RegionStore > G4RegionStoreInspector;
-G4RegionStoreInspector regionInspector( "region", G4RegionStore::GetInstance() );
+G4RegionStoreInspector regionInspector( "G4Region", G4RegionStore::GetInstance() );
/* mag field */
#include "G4MagneticField.hh"
@@ -329,7 +391,7 @@
}
typedef StoreInspector< G4MagneticField, LCDDProcessor::MagneticFields > G4MagneticFieldInspector;
-G4MagneticFieldInspector fieldInspector( "field", LCDDProcessor::instance()->getMagneticFieldStore() );
+G4MagneticFieldInspector fieldInspector( "G4MagneticField", LCDDProcessor::instance()->getMagneticFieldStore() );
/* vis attrib */
#include "G4VisAttributes.hh"
@@ -341,10 +403,10 @@
os << "RGB: "
<< color.GetRed() << " "
<< color.GetGreen() << " "
- << color.GetBlue() << std::endl;
- os << "Alpha: " << color.GetAlpha() << std::endl;
- os << "visible: " << vis.IsVisible() << std::endl;
- os << "show daughters: " << !vis.IsDaughtersInvisible() << std::endl;
+ << color.GetBlue() << endl;
+ os << "Alpha: " << color.GetAlpha() << endl;
+ os << "visible: " << vis.IsVisible() << endl;
+ os << "show daughters: " << !vis.IsDaughtersInvisible() << endl;
os << "forced drawing style: ";
if ( vis.IsForceDrawingStyle() ) {
@@ -359,13 +421,13 @@
else {
os << "NONE";
}
- os << std::endl;
+ os << endl;
return os;
}
typedef StoreInspector< G4VisAttributes, LCDDProcessor::VisAttributes > G4VisAttributeInspector;
-G4VisAttributeInspector visInspector( "visattributes", LCDDProcessor::instance()->getVisAttributesStore() );
+G4VisAttributeInspector visInspector( "G4VisAttributes", LCDDProcessor::instance()->getVisAttributesStore() );
/* defines, positions, rotations */
// FIXME: need accessible maps from GDML???