#include #include #include #include #include #include #include #include #include using namespace CLHEP; using namespace RAT; EnvelopeConstructor::EnvelopeConstructor( const std::string &prefix, double top, double bottom, double radius, int faces, G4VisAttributes* visAttributes, G4Material* exterior ) { fPrefix = prefix + std::string("_envelope"); fBottom = bottom - PMTGeo::kFaceGap; fTop = top + PMTGeo::kFaceGap; fRadius = radius + PMTGeo::kFaceGap; fXWidth = 0.0; fYWidth = 0.0; fVisAttributes = new G4VisAttributes( *visAttributes ); fExterior = exterior; fEnvelopeLogic = NULL; fNumFaces = faces; assert(radius!=0); } EnvelopeConstructor::EnvelopeConstructor( const std::string &prefix, double top, double bottom, double xWidth, double yWidth, G4VisAttributes* visAttributes, G4Material* exterior ) { fPrefix = prefix + std::string("_envelope"); fBottom = bottom - PMTGeo::kFaceGap; fTop = top + PMTGeo::kFaceGap; fRadius = 0.0; fXWidth = xWidth + PMTGeo::kFaceGap; fYWidth = yWidth + PMTGeo::kFaceGap; fVisAttributes = new G4VisAttributes( *visAttributes ); fExterior = exterior; fEnvelopeLogic = NULL; fNumFaces = -1; } void EnvelopeConstructor::Construct() { const G4int nPoints = 2; G4double z[nPoints], rInner[nPoints], rOuter[nPoints]; z[0] = fTop; z[1] = fBottom; rInner[0] = rInner[1] = 0.0; rOuter[0] = rOuter[1] = fRadius; G4VSolid* envelopeSolid; if( fNumFaces > 0 ) { envelopeSolid = new G4Polyhedra( fPrefix + "_solid", 0, twopi, fNumFaces, nPoints, z, rInner, rOuter ); fOffset = 0.0; } else if( fNumFaces == 0 ) { envelopeSolid = new G4Tubs( fPrefix + "_solid", 0.0, fRadius, ( fTop - fBottom ) / 2.0, 0.0, twopi ); fOffset = fTop - ( fTop - fBottom ) / 2.0; } else // No 'faces' so box { envelopeSolid = new G4Box( fPrefix + "_solid", fXWidth, fYWidth, ( fTop - fBottom ) / 2.0 ); fOffset = fTop - ( fTop - fBottom ) / 2.0; } fEnvelopeLogic = new G4LogicalVolume( envelopeSolid, fExterior, fPrefix + "_logic" ); fVisAttributes->SetColor( 1.0, 1.0, 1.0, 0.5 ); fEnvelopeLogic->SetVisAttributes( fVisAttributes ); } G4LogicalVolume* EnvelopeConstructor::GetLogicalVolume() { if( fEnvelopeLogic == NULL ) Log::Die("EnvelopeConstructor::GetLogicalVolume: Construct has not been called."); return fEnvelopeLogic; } void EnvelopeConstructor::SetLogicalVolume( G4LogicalVolume* envLogic ) { fEnvelopeLogic = envLogic; }