72 world( 0 ), gdmlFile( gdmlFile ), validateGDMLFile( validateGDMLFile ),
73 calorimeterRegionInitialized( false ),
74 calorimeterGeometryDataInitialized( false ), monitorVolume( NULL ),
75 vetoCounterVolume( NULL ), calorimeterVolume( NULL ), targetVolume( NULL ),
76 rightVetoCounter( NULL ), rightCalorimeter( NULL )
88 gdmlParser.
Read( gdmlFile, validateGDMLFile );
91 SetupSpecialVolumes( gdmlParser );
93 ReadTransforms( gdmlParser );
103 dynamic_cast< const CexmcPhysicsManager * >(
106 if ( ! physicsManager )
110 const_cast< CexmcPhysicsManager * >( physicsManager ) );
117 void CexmcSetup::SetupSpecialVolumes(
const G4GDMLParser & gdmlParser )
123 for ( std::vector< G4LogicalVolume * >::const_iterator
124 lvIter( lvs->begin() ); lvIter != lvs->end(); ++lvIter )
131 for ( G4GDMLAuxListType::const_iterator pair( auxInfo.begin() );
132 pair != auxInfo.end(); ++pair )
135 G4String detectorName(
"uninitialized" );
138 if ( pair->type ==
"EnergyDepositDetector" )
142 if ( pair->value ==
"MonitorRole" )
144 AssertAndAsignDetectorRole( curDetectorRole,
150 if ( pair->value ==
"VetoCounterRole" )
152 AssertAndAsignDetectorRole( curDetectorRole,
159 if ( pair->value ==
"CalorimeterRole" )
161 AssertAndAsignDetectorRole( curDetectorRole,
171 detectorName <<
"' in volume '" << volumeName <<
175 if ( pair->type ==
"TrackPointsDetector" )
179 if ( pair->value ==
"MonitorRole" )
181 AssertAndAsignDetectorRole( curDetectorRole,
187 if ( pair->value ==
"VetoCounterRole" )
189 AssertAndAsignDetectorRole( curDetectorRole,
196 if ( pair->value ==
"CalorimeterRole" )
198 AssertAndAsignDetectorRole( curDetectorRole,
205 if ( pair->value ==
"TargetRole" )
207 AssertAndAsignDetectorRole( curDetectorRole,
216 detectorName <<
"' in volume '" << volumeName <<
222 scorer->SetFilter(
filter );
226 if ( pair->type ==
"SensitiveRegion" )
230 if ( pair->value ==
"CalorimeterRegion" )
233 if ( calorimeterRegionInitialized )
247 GetUserPhysicsList() );
249 defaultProductionCut =
250 physicsList->GetDefaultCutValue();
251 cuts->SetProductionCut( defaultProductionCut );
252 region->SetProductionCuts( cuts );
253 calorimeterRegionInitialized =
true;
255 region->AddRootLogicalVolume( *lvIter );
260 "volume '" << volumeName <<
"' registered" <<
264 if ( pair->type ==
"SpecialVolume" )
268 if ( pair->value ==
"Monitor" )
270 monitorVolume = *lvIter;
274 if ( pair->value ==
"VetoCounter" )
276 vetoCounterVolume = *lvIter;
280 if ( pair->value ==
"Calorimeter" )
282 calorimeterVolume = *lvIter;
284 ReadCalorimeterGeometryData( *lvIter );
285 calorimeterGeometryDataInitialized =
true;
288 if ( pair->value ==
"Target" )
290 targetVolume = *lvIter;
304 if ( ! detector[ curDetectorRole ] )
306 detector[ curDetectorRole ] =
312 scorer->InitializeMessenger();
317 ( *lvIter )->SetSensitiveDetector(
318 detector[ curDetectorRole ] );
323 if ( ! calorimeterRegionInitialized )
326 if ( ! calorimeterGeometryDataInitialized )
337 void CexmcSetup::ReadTransforms(
const G4GDMLParser & gdmlParser )
343 RotateMatrix( rotation, rm );
348 rotation = gdmlParser.
GetRotation(
"CalorimeterLeftRot" );
350 RotateMatrix( rotation, rm );
355 rotation = gdmlParser.
GetRotation(
"CalorimeterRightRot" );
357 RotateMatrix( rotation, rm );
363 void CexmcSetup::ReadCalorimeterGeometryData(
378 if ( pVolume->IsReplicated() )
380 pVolume->GetReplicationData( axis,
382 width, offset, consuming );
385 lVolume = pVolume->GetLogicalVolume();
395 if ( pVolume->IsReplicated() )
397 pVolume->GetReplicationData( axis, calorimeterGeometry.
nCrystalsInRow,
398 width, offset, consuming );
401 lVolume = pVolume->GetLogicalVolume();
406 G4Box * crystalBox( dynamic_cast< G4Box * >( lVolume->
GetSolid() ) );
411 calorimeterGeometry.
crystalWidth = crystalBox->GetXHalfLength() * 2;
412 calorimeterGeometry.
crystalHeight = crystalBox->GetYHalfLength() * 2;
413 calorimeterGeometry.
crystalLength = crystalBox->GetZHalfLength() * 2;
425 row =
G4int( ( src.
y() + crystalHeight * nCrystalsInColumn / 2 ) /
427 column =
G4int( ( src.
x() + crystalWidth * nCrystalsInRow / 2 ) /
431 crystalWidth + crystalWidth / 2 );
434 crystalHeight + crystalHeight / 2 );
435 dst.
setX( src.
x() - xInCalorimeterOffset );
436 dst.
setY( src.
y() - yInCalorimeterOffset );
440 void CexmcSetup::ReadRightDetectors(
void )
444 for ( std::vector< G4VPhysicalVolume * >::const_iterator k( pvs->begin() );
445 k != pvs->end(); ++k )
457 if ( ( *k )->GetLogicalVolume() == vetoCounterVolume )
459 if ( ( *k )->GetName().contains(
"Right" ) )
460 rightVetoCounter = *k;
463 if ( ( *k )->GetLogicalVolume() == calorimeterVolume )
465 if ( ( *k )->GetName().contains(
"Right" ) )
466 rightCalorimeter = *k;
477 if ( detectorRole != CexmcNumberOfDetectorRoles && detectorRole != value )
480 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