20#include "BDSException.hh"
21#include "BDSGlobalConstants.hh"
22#include "BDSMaterials.hh"
23#include "BDSSamplerRegistry.hh"
24#include "BDSScreenLayer.hh"
25#include "BDSSDManager.hh"
26#include "BDSSDSampler.hh"
27#include "BDSUtilities.hh"
31#include "G4LogicalBorderSurface.hh"
32#include "G4LogicalVolume.hh"
33#include "G4MaterialPropertiesTable.hh"
34#include "G4OpticalSurface.hh"
35#include "G4PVPlacement.hh"
36#include "G4ThreeVector.hh"
37#include "G4VisAttributes.hh"
45 G4double grooveWidthIn,
46 G4double grooveSpatialFrequencyIn):
50 grooveWidth(grooveWidthIn),
51 grooveSpatialFrequency(grooveSpatialFrequencyIn)
54 {
throw BDSException(__METHOD_NAME__,
"Insufficent length for screen layer \"" + name +
"\"");}
55 colour=G4Colour(0.1,0.8,0.1,0.3);
59void BDSScreenLayer::Build()
66void BDSScreenLayer::BuildGroove()
72 grooveSolid =
new G4Box((name+
"_grooveSolid").c_str(),
76 grooveLog =
new G4LogicalVolume(grooveSolid,
78 (name+
"_grooveLog").c_str());
81void BDSScreenLayer::BuildScreen()
84 G4double tinyLenSaf = 1e-3*CLHEP::nm;
85 solid =
new G4Box((name+
"_solid").c_str(),
88 size.z()/2.0-tinyLenSaf);
89 log =
new G4LogicalVolume(solid,
91 (name+
"_log").c_str());
97void BDSScreenLayer::CutGrooves()
101 for(G4double xPosition=-size.x()/2.0+grooveWidth/2.0;
102 xPosition<((size.x()/2.0)-grooveWidth/2.0);
103 xPosition+=grooveSpatialFrequency)
104 { CutGroove(xPosition);}
108void BDSScreenLayer::CutGroove(G4double xPosition)
112 G4ThreeVector pos(xPosition, 0, 0);
115 new G4PVPlacement(
nullptr,
118 (G4String)(name+
"_groove"),
127void BDSScreenLayer::SetVisAttributes()
129 G4VisAttributes* visAtt=
new G4VisAttributes(colour);
130 visAtt->SetForceSolid(
true);
131 G4VisAttributes* visAttGroove=
new G4VisAttributes(G4Colour(0.0,0.0,0.0));
132 visAttGroove->SetForceSolid(
true);
133 log->SetVisAttributes(visAtt);
135 {grooveLog->SetVisAttributes(visAttGroove);}
138void BDSScreenLayer::SetPhys(G4PVPlacement* physIn)
140 if (physIn->GetLogicalVolume() !=
GetLog())
141 {
throw BDSException(__METHOD_NAME__,
"physical volume placement does not match logical volume.");}
145void BDSScreenLayer::SetColour(G4Colour col)
154 G4String samplerName = name;
155 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())