71 world( 0 ), gdmlFile( gdmlFile ), validateGDMLFile( validateGDMLFile ),
72 calorimeterRegionInitialized( false ),
73 calorimeterGeometryDataInitialized( false ), monitorVolume( NULL ),
74 vetoCounterVolume( NULL ), calorimeterVolume( NULL ), targetVolume( NULL ),
75 rightVetoCounter( NULL ), rightCalorimeter( NULL )
87 gdmlParser.
Read( gdmlFile, validateGDMLFile );
90 SetupSpecialVolumes( gdmlParser );
92 ReadTransforms( gdmlParser );
102 dynamic_cast< const CexmcPhysicsManager * >(
105 if ( ! physicsManager )
109 const_cast< CexmcPhysicsManager * >( physicsManager ) );
116 void CexmcSetup::SetupSpecialVolumes(
const G4GDMLParser & gdmlParser )
122 for ( std::vector< G4LogicalVolume * >::const_iterator
123 lvIter( lvs->begin() ); lvIter != lvs->end(); ++lvIter )
130 for ( G4GDMLAuxListType::const_iterator pair( auxInfo.begin() );
131 pair != auxInfo.end(); ++pair )
134 G4String detectorName(
"uninitialized" );
137 if ( pair->type ==
"EnergyDepositDetector" )
141 if ( pair->value ==
"MonitorRole" )
143 AssertAndAsignDetectorRole( curDetectorRole,
149 if ( pair->value ==
"VetoCounterRole" )
151 AssertAndAsignDetectorRole( curDetectorRole,
158 if ( pair->value ==
"CalorimeterRole" )
160 AssertAndAsignDetectorRole( curDetectorRole,
170 detectorName <<
"' in volume '" << volumeName <<
174 if ( pair->type ==
"TrackPointsDetector" )
178 if ( pair->value ==
"MonitorRole" )
180 AssertAndAsignDetectorRole( curDetectorRole,
186 if ( pair->value ==
"VetoCounterRole" )
188 AssertAndAsignDetectorRole( curDetectorRole,
195 if ( pair->value ==
"CalorimeterRole" )
197 AssertAndAsignDetectorRole( curDetectorRole,
204 if ( pair->value ==
"TargetRole" )
206 AssertAndAsignDetectorRole( curDetectorRole,
215 detectorName <<
"' in volume '" << volumeName <<
221 scorer->SetFilter(
filter );
225 if ( pair->type ==
"SensitiveRegion" )
229 if ( pair->value ==
"CalorimeterRegion" )
232 if ( calorimeterRegionInitialized )
246 GetUserPhysicsList() );
248 defaultProductionCut =
249 physicsList->GetDefaultCutValue();
250 cuts->SetProductionCut( defaultProductionCut );
251 region->SetProductionCuts( cuts );
252 calorimeterRegionInitialized =
true;
254 region->AddRootLogicalVolume( *lvIter );
259 "volume '" << volumeName <<
"' registered" <<
263 if ( pair->type ==
"SpecialVolume" )
267 if ( pair->value ==
"Monitor" )
269 monitorVolume = *lvIter;
273 if ( pair->value ==
"VetoCounter" )
275 vetoCounterVolume = *lvIter;
279 if ( pair->value ==
"Calorimeter" )
281 calorimeterVolume = *lvIter;
283 ReadCalorimeterGeometryData( *lvIter );
284 calorimeterGeometryDataInitialized =
true;
287 if ( pair->value ==
"Target" )
289 targetVolume = *lvIter;
303 if ( ! detector[ curDetectorRole ] )
305 detector[ curDetectorRole ] =
311 scorer->InitializeMessenger();
316 ( *lvIter )->SetSensitiveDetector(
317 detector[ curDetectorRole ] );
322 if ( ! calorimeterRegionInitialized )
325 if ( ! calorimeterGeometryDataInitialized )
336 void CexmcSetup::ReadTransforms(
const G4GDMLParser & gdmlParser )
342 RotateMatrix( rotation, rm );
347 rotation = gdmlParser.
GetRotation(
"CalorimeterLeftRot" );
349 RotateMatrix( rotation, rm );
354 rotation = gdmlParser.
GetRotation(
"CalorimeterRightRot" );
356 RotateMatrix( rotation, rm );
362 void CexmcSetup::ReadCalorimeterGeometryData(
377 if ( pVolume->IsReplicated() )
379 pVolume->GetReplicationData( axis,
381 width, offset, consuming );
384 lVolume = pVolume->GetLogicalVolume();
394 if ( pVolume->IsReplicated() )
396 pVolume->GetReplicationData( axis, calorimeterGeometry.
nCrystalsInRow,
397 width, offset, consuming );
400 lVolume = pVolume->GetLogicalVolume();
405 G4Box * crystalBox( dynamic_cast< G4Box * >( lVolume->
GetSolid() ) );
410 calorimeterGeometry.
crystalWidth = crystalBox->GetXHalfLength() * 2;
411 calorimeterGeometry.
crystalHeight = crystalBox->GetYHalfLength() * 2;
412 calorimeterGeometry.
crystalLength = crystalBox->GetZHalfLength() * 2;
424 row =
G4int( ( src.
y() + crystalHeight * nCrystalsInColumn / 2 ) /
426 column =
G4int( ( src.
x() + crystalWidth * nCrystalsInRow / 2 ) /
430 crystalWidth + crystalWidth / 2 );
433 crystalHeight + crystalHeight / 2 );
434 dst.
setX( src.
x() - xInCalorimeterOffset );
435 dst.
setY( src.
y() - yInCalorimeterOffset );
439 void CexmcSetup::ReadRightDetectors(
void )
443 for ( std::vector< G4VPhysicalVolume * >::const_iterator k( pvs->begin() );
444 k != pvs->end(); ++k )
456 if ( ( *k )->GetLogicalVolume() == vetoCounterVolume )
458 if ( ( *k )->GetName().contains(
"Right" ) )
459 rightVetoCounter = *k;
462 if ( ( *k )->GetLogicalVolume() == calorimeterVolume )
464 if ( ( *k )->GetName().contains(
"Right" ) )
465 rightCalorimeter = *k;
476 if ( detectorRole != CexmcNumberOfDetectorRoles && detectorRole != value )
479 detectorRole =
value;
G4bool RegisterPrimitive(G4VPrimitiveScorer *)
G4GDMLAuxListType GetVolumeAuxiliaryInformation(G4LogicalVolume *logvol) const
HepRotation & rotateX(double delta)
CLHEP::HepRotation G4RotationMatrix
G4VPhysicalVolume * GetWorldVolume(const G4String &setupName="Default") const
void ConvertToCrystalGeometry(const G4ThreeVector &src, G4int &row, G4int &column, G4ThreeVector &dst) const
void SetupConstructionHook(void)
const G4String CexmcDetectorTypeName[CexmcNumberOfDetectorTypes]
G4VPhysicalVolume * GetDaughter(const G4int i) const
CexmcSetup(const G4String &gdmlFile="default.gdml", G4bool validateGDMLFile=true)
HepRotation & rotateY(double delta)
static G4PhysicalVolumeStore * GetInstance()
static G4RegionStore * GetInstance()
G4GLOB_DLL std::ostream G4cout
static G4LogicalVolumeStore * GetInstance()
const G4String CexmcDetectorRoleName[CexmcNumberOfDetectorRoles]
virtual void SetupConstructionHook(const CexmcSetup *setup)=0
G4int GetNoDaughters() const
void AddNewDetector(G4VSensitiveDetector *aSD)
G4ThreeVector GetRotation(const G4String &name) const
static G4RunManager * GetRunManager()
const G4String CexmcCalorimeterRegionName("Calorimeter")
std::vector< G4GDMLAuxPairType > G4GDMLAuxListType
static G4SDManager * GetSDMpointer()
void Read(const G4String &filename, G4bool Validate=true)
HepRotation & rotateZ(double delta)
const XML_Char int const XML_Char * value
G4VPhysicalVolume * Construct(void)
const G4VUserPhysicsList * GetUserPhysicsList() const
G4VSolid * GetSolid() const
G4ThreeVector GetPosition(const G4String &name) const