19#include "BDSException.hh"
20#include "BDSGlobalConstants.hh"
21#include "BDSMaterials.hh"
22#include "BDSSamplerRegistry.hh"
23#include "BDSScreenLayer.hh"
24#include "BDSSDManager.hh"
25#include "BDSSDSampler.hh"
26#include "BDSUtilities.hh"
30#include "G4LogicalBorderSurface.hh"
31#include "G4LogicalVolume.hh"
32#include "G4MaterialPropertiesTable.hh"
33#include "G4OpticalSurface.hh"
34#include "G4PVPlacement.hh"
35#include "G4ThreeVector.hh"
36#include "G4VisAttributes.hh"
44 G4double grooveWidthIn,
45 G4double grooveSpatialFrequencyIn):
49 grooveWidth(grooveWidthIn),
50 grooveSpatialFrequency(grooveSpatialFrequencyIn)
53 {
throw BDSException(__METHOD_NAME__,
"Insufficent length for screen layer \"" + name +
"\"");}
54 colour=G4Colour(0.1,0.8,0.1,0.3);
58void BDSScreenLayer::Build()
65void BDSScreenLayer::BuildGroove()
71 grooveSolid =
new G4Box((name+
"_grooveSolid").c_str(),
75 grooveLog =
new G4LogicalVolume(grooveSolid,
77 (name+
"_grooveLog").c_str());
80void BDSScreenLayer::BuildScreen()
83 G4double tinyLenSaf = 1e-3*CLHEP::nm;
84 solid =
new G4Box((name+
"_solid").c_str(),
87 size.z()/2.0-tinyLenSaf);
88 log =
new G4LogicalVolume(solid,
90 (name+
"_log").c_str());
96void BDSScreenLayer::CutGrooves()
100 for(G4double xPosition=-size.x()/2.0+grooveWidth/2.0;
101 xPosition<((size.x()/2.0)-grooveWidth/2.0);
102 xPosition+=grooveSpatialFrequency)
103 { CutGroove(xPosition);}
107void BDSScreenLayer::CutGroove(G4double xPosition)
111 G4ThreeVector pos(xPosition, 0, 0);
114 new G4PVPlacement(
nullptr,
117 (G4String)(name+
"_groove"),
126void BDSScreenLayer::SetVisAttributes()
128 G4VisAttributes* visAtt=
new G4VisAttributes(colour);
129 visAtt->SetForceSolid(
true);
130 G4VisAttributes* visAttGroove=
new G4VisAttributes(G4Colour(0.0,0.0,0.0));
131 visAttGroove->SetForceSolid(
true);
132 log->SetVisAttributes(visAtt);
134 {grooveLog->SetVisAttributes(visAttGroove);}
137void BDSScreenLayer::SetPhys(G4PVPlacement* physIn)
139 if (physIn->GetLogicalVolume() !=
GetLog())
140 {
throw BDSException(__METHOD_NAME__,
"physical volume placement does not match logical volume.");}
144void BDSScreenLayer::SetColour(G4Colour col)
153 G4String samplerName = name;
154 log->SetSensitiveDetector(BDSSDManager::Instance()->SamplerPlane());
General exception with possible name of object and message.
static BDSGlobalConstants * Instance()
Access method.
static BDSMaterials * Instance()
Singleton pattern access.
static BDSSamplerRegistry * Instance()
Accessor for registry.
G4int RegisterSampler(const G4String &name, BDSSampler *sampler, const G4Transform3D &transform=G4Transform3D(), G4double S=-1000, const BDSBeamlineElement *element=nullptr, BDSSamplerType type=BDSSamplerType::plane, G4double radius=0)
G4LogicalVolume * GetLog() const
Accessor.
void AssignSampler()
Make this plane a sampling plane.
G4int nGrooves
Counter for the number of grooves etched into the screen.
BDSScreenLayer()
Used in modules/AWAKE/include/BDSMultiFacetLayer.hh.
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())