diff --git a/CMakeLists.txt b/CMakeLists.txt index 74533c8bdd27a3dd97f6ac389ca914492ee2a0f0..2ae7646ae5b682a5028c7a14754a4d9f62b0fa2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,7 @@ set(lightGuide_SCRIPTS vis.mac run1.mac beam.mac - geom.mac + geometry.mac ) foreach(_script ${lightGuide_SCRIPTS}) @@ -75,7 +75,7 @@ endforeach() install(TARGETS lightGuide DESTINATION bin ) install(TARGETS plotHisto DESTINATION bin ) install(FILES run1.mac DESTINATION bin ) -install(FILES geom.mac DESTINATION bin ) +install(FILES geometry.mac DESTINATION bin ) install(FILES beam.mac DESTINATION bin ) install(FILES vis.mac DESTINATION bin) install(FILES hist.mac DESTINATION bin) diff --git a/beam.mac b/beam.mac index 638b8d57d450ec96da73d82837730f8b4fb317e9..dfe1ba063c3ee774013af747299311d3a754bf60 100644 --- a/beam.mac +++ b/beam.mac @@ -9,17 +9,17 @@ #----- Set the beam geometry ----- # Circular beam source. Simulates a single fiber optic -/gps/pos/type Beam -/gps/pos/shape Circle +#/gps/pos/type Beam +#/gps/pos/shape Circle #/gps/pos/radius 0.75 mm -/gps/pos/radius 102 mm +#/gps/pos/radius 102 mm #/gps/pos/sigma_r 0.002 mm # Rectangular plane for infinite resolution -#/gps/pos/type Plane -#/gps/pos/shape Rectangle -#/gps/pos/halfx 40 mm -#/gps/pos/halfy 68 mm +/gps/pos/type Plane +/gps/pos/shape Rectangle +/gps/pos/halfx 40 mm +/gps/pos/halfy 68 mm # the incident surface is in the x-z plane just below the gas /gps/pos/rot1 1 0 0 diff --git a/geom.mac b/geometry.mac similarity index 78% rename from geom.mac rename to geometry.mac index 6870add8946974a8fb8b6dd177b5e594d6aa6f8b..8a6b9ceee828f2af110b9edd535aa8f49991f684 100644 --- a/geom.mac +++ b/geometry.mac @@ -1,3 +1,13 @@ + +/lightGuide/worldVolume 0.25 0.25 0.25 m +/lightGuide/envelope 89.75 113. 165. mm + +/lightGuide/model/PMTDiameter 53 mm +/lightGuide/model/nSegmentsX 2 +/lightGuide/model/nSegmentsZ 2 + + + #----- Set the light guide to be used and position it ----- #If no model is selected, the program will default to a #simplified version of the 2018 testbeam light guide @@ -22,10 +32,10 @@ #/lightGuide/model/translate 0 -250 -200 mm #/lightGuide/model/translatePMT 0 131 0 mm -/lightGuide/model/CADmodel ../models/run2.stl -/lightGuide/model/rotate 0 0 0 -/lightGuide/model/translate 200 -250 0 mm -/lightGuide/model/translatePMT 0 -119 0 mm +#/lightGuide/model/CADmodel ../models/run2.stl +#/lightGuide/model/rotate 0 0 0 +#/lightGuide/model/translate 200 -250 0 mm +#/lightGuide/model/translatePMT 0 -119 0 mm #/lightGuide/model/CADmodel ../models/run3wc.stl #/lightGuide/model/rotate 0 0 90 @@ -44,9 +54,9 @@ #----- Set surface properties of the light guide ----- -/lightGuide/surface/Model unified -/lightGuide/surface/Type dielectric_metal -/lightGuide/surface/Finish ground +#/lightGuide/surface/Model unified +#/lightGuide/surface/Type dielectric_metal +#/lightGuide/surface/Finish ground #/lightGuide/surface/SigmaAlpha .1 #/lightGuide/surface/Property SPECULARLOBECONSTANT 0.000002 .4 0.000008 .4 #/lightGuide/surface/Property SPECULARSPIKECONSTANT 0.000002 .1 0.000008 .1 diff --git a/include/DetectorConstruction.hh b/include/DetectorConstruction.hh index 07918c27b4494d6a52bd501373f31a5fdbc8e08c..dc3ac3177f0a6eac686f783b728b607ad7ed46b0 100644 --- a/include/DetectorConstruction.hh +++ b/include/DetectorConstruction.hh @@ -37,6 +37,7 @@ #include "G4Box.hh" #include "G4LogicalVolume.hh" #include "G4VUserDetectorConstruction.hh" +#include "G4SubtractionSolid.hh" #include "G4GDMLParser.hh" #include "G4RunManager.hh" @@ -57,21 +58,42 @@ class DetectorConstruction : public G4VUserDetectorConstruction public: virtual G4VPhysicalVolume* Construct(); - void UseCADModel (G4String fileName); - void OutputToGDML (G4String name); + void BuildWorld (); + void BuildTrapezoidLG (); + void BuildPMT (); + void PlaceGeometry (); + void SetWorldVolume (G4ThreeVector arg); + void SetEnvelope (G4ThreeVector arg); void SetRotation (G4ThreeVector arg); void SetTranslation (G4ThreeVector arg); void SetPMTTranslation (G4ThreeVector arg); void SetPMTDiameter (G4double arg); + void SetLGthickness (G4double arg); + void UseCADModel (G4String fileName); + void OutputToGDML (G4String name); + void SetNSegmentsX (G4int arg); + void SetNSegmentsZ (G4int arg); - void SetSurfaceSigmaAlpha (G4double v); + void SetSurfaceModel (const G4OpticalSurfaceModel model); void SetSurfaceFinish (const G4OpticalSurfaceFinish finish); void SetSurfaceType (const G4SurfaceType type); - void SetSurfaceModel (const G4OpticalSurfaceModel model); + void SetSurfaceSigmaAlpha (G4double v); void AddSurfaceMPV (const char* c, G4MaterialPropertyVector* mpv); void AddGasMPV (const char* c, G4MaterialPropertyVector* mpv); private: + G4ThreeVector* m_worldDim; + G4ThreeVector* m_LGenvelope; + G4ThreeVector* m_LGpos; + G4ThreeVector* m_pmtPos; + G4RotationMatrix* m_rotation; + G4double m_pmtDia; + G4double m_PMTthickness; + G4double m_thickness; + G4int m_nSegmentsX; + G4int m_nSegmentsZ; + G4bool m_ConstructionHasBeenDone; + G4bool m_UsingCADmodel; G4Box* m_solidWorld; G4LogicalVolume* m_logicWorld; @@ -85,30 +107,25 @@ class DetectorConstruction : public G4VUserDetectorConstruction CADMesh* m_mesh; #endif - G4LogicalVolume* m_logicLightGuide; - G4VPhysicalVolume* m_physLightGuide; + G4Trd* m_inner; + G4Trd* m_outter; + G4SubtractionSolid* m_LightGuide; + G4LogicalVolume* m_logicLightGuide; + std::vector< G4VPhysicalVolume* > m_physLightGuide; - G4Tubs* m_solidPMT; - G4LogicalVolume* m_logicPMT; - G4VPhysicalVolume* m_physPMT; + G4Tubs* m_solidPMT; + G4LogicalVolume* m_logicPMT; + std::vector< G4VPhysicalVolume* > m_physPMT; - G4LogicalBorderSurface* m_SurfLGtoWorld; - G4LogicalBorderSurface* m_SurfLGtoInner; - - G4double m_WorldSizeX; - G4double m_WorldSizeY; - G4double m_WorldSizeZ; - - G4ThreeVector m_translation; - G4RotationMatrix* m_rotation; + std::vector< G4LogicalBorderSurface* > m_Surfvec; - Materials* materials; - G4Material* m_filler; - G4MaterialPropertiesTable* m_GasMPT; + Materials* materials; + G4Material* m_filler; + G4MaterialPropertiesTable* m_GasMPT; - G4GDMLParser m_Parser; - G4RunManager* m_runMan; - DetectorMessenger* m_DetectorMessenger; + G4GDMLParser m_Parser; + G4RunManager* m_runMan; + DetectorMessenger* m_DetectorMessenger; }; #endif /*DetectorConstruction_h*/ diff --git a/include/DetectorMessenger.hh b/include/DetectorMessenger.hh index 213687907b289f14893af947031d114b8caf1417..1bbc683fe0547e6e9a1b82263243df315f293304 100644 --- a/include/DetectorMessenger.hh +++ b/include/DetectorMessenger.hh @@ -61,24 +61,28 @@ class DetectorMessenger: public G4UImessenger{ G4UIdirectory* fSurfaceDir; G4UIdirectory* fModelDir; - // the surface - G4UIcmdWithAString* fSurfaceTypeCmd; - G4UIcmdWithAString* fSurfaceFinishCmd; - G4UIcmdWithAString* fSurfaceModelCmd; - G4UIcmdWithADouble* fSurfaceSigmaAlphaCmd; - G4UIcmdWithAString* fSurfaceMatPropVectorCmd; - - // the gas - G4UIcmdWithAString* fGasPropVectorCmd; - // the model G4UIcmdWithAString* fModelCmd; + G4UIcmdWith3VectorAndUnit* fWorldVolumeCmd; + G4UIcmdWith3VectorAndUnit* fEnvelopeCmd; G4UIcmdWith3VectorAndUnit* fModelRotationCmd; G4UIcmdWith3VectorAndUnit* fModelTranslationCmd; G4UIcmdWith3VectorAndUnit* fPMTTranslationCmd; G4UIcmdWithADoubleAndUnit* fPMTDiameterCmd; + G4UIcmdWithADoubleAndUnit* fLGThicknessCmd; G4UIcmdWithAString* fOutputModelCmd; + G4UIcmdWithAnInteger* fNsegmentsXCmd; + G4UIcmdWithAnInteger* fNsegmentsZCmd; + // the surface + G4UIcmdWithAString* fSurfaceModelCmd; + G4UIcmdWithAString* fSurfaceFinishCmd; + G4UIcmdWithAString* fSurfaceTypeCmd; + G4UIcmdWithADouble* fSurfaceSigmaAlphaCmd; + G4UIcmdWithAString* fSurfaceMatPropVectorCmd; + + // the gas + G4UIcmdWithAString* fGasPropVectorCmd; }; #endif diff --git a/include/SteppingAction.hh b/include/SteppingAction.hh index 231833259118122f4f68b77052956f2908572207..702e1ba22d6c12b4e65411a2f296986d44dae84c 100644 --- a/include/SteppingAction.hh +++ b/include/SteppingAction.hh @@ -46,9 +46,7 @@ class SteppingAction : public G4UserSteppingAction virtual void UserSteppingAction(const G4Step*); private: - G4int fScintillationCounter; - G4int fCerenkovCounter; - G4int fEventNumber; + }; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/run1.mac b/run1.mac index 0df87e19d7662dd11018e38d24ebd2a5c4ea6efb..f2cd4b942e36ff090207ae726208d0ae0bd97b66 100644 --- a/run1.mac +++ b/run1.mac @@ -14,23 +14,16 @@ /hits/verbose 0 -#Lightguide selection and properties can be set with geom.mac -/control/execute geom.mac - - - ############################################################## ############################################################## #Uncomment to generate events from ASCII file, set the file path here. #make sure /run/beamOn is commented out below -/Input/FileName Out_target1.txt +#/Input/FileName Out_target1.txt #Uncomment to use gps style of setting the beam profile -#/control/execute beam.mac -#set number of photons per event -#/gps/number 10 +/control/execute beam.mac # number of events -#/run/beamOn 1 +/run/beamOn 100 ############################################################## ############################################################## diff --git a/src/DetectorConstruction.cc b/src/DetectorConstruction.cc index afeb43eaf911682bc57d659d97b960a3a4724054..d1c8e246bde9e9fb9c3b31bda418c37a8562a03a 100644 --- a/src/DetectorConstruction.cc +++ b/src/DetectorConstruction.cc @@ -63,16 +63,36 @@ * */ DetectorConstruction::DetectorConstruction() - : G4VUserDetectorConstruction(),m_DetectorMessenger(nullptr){ + : G4VUserDetectorConstruction(), + m_worldDim( new G4ThreeVector(0.25*m,0.5*m,0.25*m) ), + m_LGenvelope( new G4ThreeVector(89.75*mm,113.*mm,165.*mm) ), + m_LGpos( new G4ThreeVector() ), + m_pmtPos( new G4ThreeVector() ), + m_rotation( new G4RotationMatrix() ), + m_pmtDia(65.*mm), + m_PMTthickness(0.25*mm), + m_thickness(1.0*mm), + m_nSegmentsX(1), + m_nSegmentsZ(1), + m_ConstructionHasBeenDone(false), + m_UsingCADmodel(false), + m_logicWorld(0), + m_DetectorMessenger(nullptr) +{ materials = Materials::getInstance(); + materials->UseOpticalMaterials(true); + materials->DefineOpticalProperties(); + m_DetectorMessenger = new DetectorMessenger(this); m_runMan = G4RunManager::GetRunManager(); - m_WorldSizeX = m_WorldSizeZ = 0.25*m; - m_WorldSizeY = 0.5*m; + //Set default values + G4double PhotonEnergy[2] = {0.5*eV,8.0*eV}; + G4double RefractiveIndexAir[2] = {1.0,1.0}; m_filler = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR"); m_GasMPT = new G4MaterialPropertiesTable(); + m_GasMPT->AddProperty("RINDEX", PhotonEnergy, RefractiveIndexAir, 2); m_filler->SetMaterialPropertiesTable(m_GasMPT); #ifdef CADMESH @@ -88,33 +108,50 @@ DetectorConstruction::~DetectorConstruction(){ delete m_DetectorMessenger; } -/* Default geometry (2018 testbeam) is created here - * The user is able to modify geometry via messenger commands +/* + * Execute geometry.mac here and construct the world according + * to what it contains */ G4VPhysicalVolume* DetectorConstruction::Construct(){ - //Set up the materials - materials->UseOpticalMaterials(true); - materials->DefineOpticalProperties(); - G4Material* Air = materials->Air; - G4Material* Al = materials->Al; + if ( m_ConstructionHasBeenDone ) { + G4GeometryManager::GetInstance()->OpenGeometry(); + G4PhysicalVolumeStore::GetInstance()->Clean(); + G4LogicalVolumeStore::GetInstance()->Clean(); + G4SolidStore::GetInstance()->Clean(); + G4LogicalSkinSurface::CleanSurfaceTable(); + G4LogicalBorderSurface::CleanSurfaceTable(); + } else { + G4UImanager* UImanager = G4UImanager::GetUIpointer(); + UImanager->ApplyCommand("/control/execute geometry.mac"); + BuildPMT(); + } + + if(!m_logicWorld) BuildWorld(); + if(!m_logicLightGuide) BuildTrapezoidLG(); + PlaceGeometry(); + + m_ConstructionHasBeenDone = true; + return m_physWorld; - //Set the lightguide height. Hardcoded for now, - //should be determined by the model dimensions - G4double lgHeight = 339.*mm/2; +} +/* + * + */ +void DetectorConstruction::BuildWorld(){ bool checkOverlaps = false; //----------------- Define the world volume -----------------// m_solidWorld = new G4Box("World", //name - m_WorldSizeX, //sizeX - m_WorldSizeY, //sizeY - m_WorldSizeZ); //sizeZ + m_worldDim->x(), //sizeX + m_worldDim->y(), //sizeY + m_worldDim->z()); //sizeZ m_logicWorld = new G4LogicalVolume(m_solidWorld, //solid - Air, //material + materials->Air, //material "World"); //name m_physWorld = @@ -137,10 +174,10 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){ // and PMT m_solidHalfWorld = - new G4Box("HalfWorld", //name - m_WorldSizeX, //sizeX - m_WorldSizeY/2, //sizeY - m_WorldSizeZ); //sizeZ + new G4Box("HalfWorld", //name + m_worldDim->x(), //sizeX + m_worldDim->y()/2, //sizeY + m_worldDim->z()); //sizeZ m_logicHalfWorld = new G4LogicalVolume(m_solidHalfWorld, //solid @@ -148,86 +185,69 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){ "HalfWorld"); //name m_physHalfWorld = - new G4PVPlacement(0, //no rotation - G4ThreeVector(0,m_WorldSizeY/2,0), //at (0,0,0) - m_logicHalfWorld, //logical volume - "HalfWorld", //name - m_logicWorld, //mother volume - false, //no boolean operation - 0, //copy number - checkOverlaps); //overlaps checking + new G4PVPlacement(0, //no rotation + G4ThreeVector(0,m_worldDim->y()/2,0), //at (0,0,0) + m_logicHalfWorld, //logical volume + "HalfWorld", //name + m_logicWorld, //mother volume + false, //no boolean operation + 0, //copy number + checkOverlaps); //overlaps checking G4VisAttributes* boxVisAtt_half_world = new G4VisAttributes(G4Colour(0.0,0.0,1.0,0.1)); // or G4Colour(0.0,0.0,1.0,0.1) m_logicHalfWorld ->SetVisAttributes(boxVisAtt_half_world); +} - //----------------- Make the light guide -----------------// - //Make this one by default and allow the user to replace it later - //Create a trapezoidal air light guide made of aluminum sheet - G4double thickness = 1.0*mm; - G4double LengthX = 89.75*mm/2; - G4double LengthY = 164.*mm/2; - G4double PMTwindow = 45.969*mm/2; - G4double HeightZ = lgHeight; - G4RotationMatrix* rot = new G4RotationMatrix(); - rot->rotateX(90*deg); +/* + * Make the trapezoidal light guide logical volume + */ +void DetectorConstruction::BuildTrapezoidLG( ){ + //Divide the light guide envelope (cumulative) by the number + //of light guides that will occupy it + G4double xSize = (m_LGenvelope->x()/2.)/m_nSegmentsX; + G4double zSize = (m_LGenvelope->z()/2.)/m_nSegmentsZ; + + //Determine the size of the top of the trapezoid so the + //square opening will be inscribed in the window of the PMT + G4double PMTwindow = .707*m_pmtDia/2.; + m_rotation->rotateX(90*deg); //Aluminum outter - G4Trd* outter = + m_outter = new G4Trd("BasicLightGuide", - LengthX+thickness, - PMTwindow+thickness, - LengthY+thickness, - PMTwindow+thickness, - HeightZ); + xSize, + PMTwindow + m_thickness, + zSize, + PMTwindow + m_thickness, + m_LGenvelope->y()/2.); //Air inner - G4Trd* inner = + m_inner = new G4Trd("AirVolume", - LengthX, + xSize - m_thickness, PMTwindow, - LengthY, + zSize - m_thickness, PMTwindow, - HeightZ+2.0*mm); + m_LGenvelope->y()/2. + 0.1*mm); //Subtract material to hollow out the light guide - G4SubtractionSolid* LightGuide = + m_LightGuide = new G4SubtractionSolid("BasicLightGuide", - outter, - inner); + m_outter, + m_inner); m_logicLightGuide = - new G4LogicalVolume(LightGuide, - Al, + new G4LogicalVolume(m_LightGuide, + materials->Al, "BasicLightGuide"); - m_physLightGuide = - new G4PVPlacement(rot, - G4ThreeVector(0, HeightZ - m_WorldSizeY/2, 0), - m_logicLightGuide, - "BasicLightGuide", - m_logicHalfWorld, - false, - 0); - - //----------------- Define Optical Borders -----------------// - - m_SurfLGtoWorld = - new G4LogicalBorderSurface("AlSurface", - m_physLightGuide, - m_physHalfWorld, - materials->AlSurface ); - m_SurfLGtoInner = - new G4LogicalBorderSurface("AlSurface", - m_physHalfWorld, - m_physLightGuide, - materials->AlSurface ); - - - //----------------- Define PMT window -----------------// - double PMTradius = 65.0/2*mm; - double PMTthickness = 0.5/2*mm; - G4RotationMatrix * PMTrot = new G4RotationMatrix(); - PMTrot->rotateX(90*deg); +} + + +/* + * Make the PMT logical volume and Sensitvie Detector + */ +void DetectorConstruction::BuildPMT(){ G4SDManager* SDman = G4SDManager::GetSDMpointer(); PMTSD* PMT = new PMTSD("MyPMT"); @@ -236,8 +256,8 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){ m_solidPMT = new G4Tubs("PMT", //name 0.0*mm, //Inner radius - PMTradius, //Outter radius - PMTthickness, //Height + m_pmtDia/2.0, //Outter radius + m_PMTthickness, //Height 0.0*deg, //Rotation start 360.0*deg); //Sweep @@ -246,41 +266,227 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){ m_filler, //material "PMT"); //name - m_physPMT = - new G4PVPlacement(PMTrot, - G4ThreeVector(0, 2*lgHeight + PMTthickness - m_WorldSizeY/2, 0), - m_logicPMT, - "PMT", - m_logicHalfWorld, - false, - 0); - G4VisAttributes* VisAtt_PMT = new G4VisAttributes(G4Colour(1.0,1.0,0.6,0.7)); m_logicPMT->SetVisAttributes(VisAtt_PMT); m_logicPMT->SetSensitiveDetector( PMT ); - return m_physWorld; } /* - * +* +*/ +void DetectorConstruction::PlaceGeometry(){ + G4double xPos = 0.; + G4double yPos = m_LGenvelope->y()/2. + m_LGpos->y() - m_worldDim->y()/2.; + G4double zPos = 0.; + + G4double PMTx = 0.; + G4double PMTy = m_LGenvelope->y() + m_pmtPos->y() + m_PMTthickness - m_worldDim->y()/2.; + G4double PMTz = 0.; + + G4RotationMatrix * PMTrot = new G4RotationMatrix(); + PMTrot->rotateX(90*deg); + + char name[40]; + + + for(G4int xIndex = 0; xIndex < m_nSegmentsX; xIndex++ ){ + //Start from -x, add user specified offset, add 1/2 the width of one LG, then a full width for each + xPos = - m_LGenvelope->x()/2. + m_LGpos->x() + (0.5 + xIndex)*m_LGenvelope->x()/m_nSegmentsX; + + //Centered on the light guide plus any user specified offset + PMTx = xPos + m_pmtPos->x(); + + for(G4int zIndex = 0; zIndex < m_nSegmentsZ; zIndex++ ){ + //Start from -z, add user specified offset, add 1/2 the length of one LG, then a full length for each + zPos = - m_LGenvelope->z()/2. + m_LGpos->z() + (0.5 + zIndex)*m_LGenvelope->z()/m_nSegmentsZ; + + //Centered on the light guide plus any user specified offset + PMTz = zPos + m_pmtPos->z(); + //----------------- Place the LightGuide -----------------// + + sprintf(name,"LightGuide%d_%d",xIndex,zIndex); + m_physLightGuide.push_back( + new G4PVPlacement(m_rotation, + G4ThreeVector(xPos, yPos, zPos), + m_logicLightGuide, + name, + m_logicHalfWorld, + false, + 0) ); + + //----------------- Place the PMT -----------------// + + sprintf(name,"PMT%d_%d",xIndex,zIndex); + m_physPMT.push_back( + new G4PVPlacement(PMTrot, + G4ThreeVector(PMTx, PMTy, PMTz), + m_logicPMT, + name, + m_logicHalfWorld, + false, + 0) ); + + //----------------- Define Optical Borders -----------------// + + sprintf(name,"AlSurface%d_%d",xIndex,zIndex); + m_Surfvec.push_back( + new G4LogicalBorderSurface(name, + m_physLightGuide.back(), + m_physHalfWorld, + materials->AlSurface ) ); + m_Surfvec.push_back( + new G4LogicalBorderSurface(name, + m_physHalfWorld, + m_physLightGuide.back(), + materials->AlSurface ) ); + }//end y loop + }//end x loop +} + +/* + * Set the dimensions of the world volume. + * If the volume exists modify it, otherwise build it. */ -void DetectorConstruction::SetSurfaceSigmaAlpha(G4double v){ - materials->AlSurface->SetSigmaAlpha(v); - G4RunManager::GetRunManager()->GeometryHasBeenModified(); +void DetectorConstruction::SetWorldVolume(G4ThreeVector arg){ + if(m_ConstructionHasBeenDone){ + m_solidWorld->SetXHalfLength( arg.x() ); + m_solidWorld->SetYHalfLength( arg.y() ); + m_solidWorld->SetZHalfLength( arg.z() ); + m_runMan->GeometryHasBeenModified(); + G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild"); + } else { + delete m_worldDim; + m_worldDim = new G4ThreeVector(arg); + BuildWorld(); + } +} - G4cout << "Surface sigma alpha set to: " << materials->AlSurface->GetSigmaAlpha() << G4endl; +/* + * Sets the envelope the light guide is constructed in + * If the geometry has already been constructed, reconstruct + * it with the new envelope + */ +void DetectorConstruction::SetEnvelope(G4ThreeVector arg){ + if(m_LGenvelope) delete m_LGenvelope; + m_LGenvelope = new G4ThreeVector(arg); + + if(m_ConstructionHasBeenDone){ + Construct(); + m_runMan->GeometryHasBeenModified(); + G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild"); + } } /* - * + * If the world already exists, rotate the light guide + * otherwise set the rotation for the light guide that will be built + */ +void DetectorConstruction::SetRotation(G4ThreeVector arg){ + if(m_rotation) delete m_rotation; + m_rotation = new G4RotationMatrix(); + + m_rotation->rotateX(arg.x()); + m_rotation->rotateY(arg.y()); + m_rotation->rotateZ(arg.z()); + + if(m_ConstructionHasBeenDone){ + for(uint i = 0; i < m_physLightGuide.size(); i++){ + m_physLightGuide[i]->SetRotation(m_rotation); + } + m_runMan->GeometryHasBeenModified(); + G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild"); + } +} + +/* + * If the world already exists, move the light guide. If there is more + * than one light guide, set the position and rebuild. + * otherwise set the location for the light guide that will be built + */ +void DetectorConstruction::SetTranslation(G4ThreeVector arg){ + if(m_ConstructionHasBeenDone){ + if(m_physLightGuide.size() == 1){ + m_physLightGuide.back()->SetTranslation(arg); + } else { + m_LGpos = new G4ThreeVector(arg); + Construct(); + } + m_runMan->GeometryHasBeenModified(); + G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild"); + } else { + m_LGpos = new G4ThreeVector(arg); + } +} + + +/* + * If the world already exists, move the PMT. If there is more + * than one PMT, set the position and rebuild. + * otherwise set the location for the PMT that will be built + */ +void DetectorConstruction::SetPMTTranslation(G4ThreeVector arg){ + if(m_ConstructionHasBeenDone){ + if(m_physLightGuide.size() == 1){ + m_physLightGuide.back()->SetTranslation(arg); + } else { + m_LGpos = new G4ThreeVector(arg); + Construct(); + } + m_runMan->GeometryHasBeenModified(); + G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild"); + } else { + m_pmtPos = new G4ThreeVector(arg); + } +} + +/* + * If the world already exists, modify the PMT + * otherwise set the diameter for PMT that will be built + */ +void DetectorConstruction::SetPMTDiameter(G4double arg){ + if(m_ConstructionHasBeenDone){ + m_solidPMT->SetOuterRadius(arg/2.0); + m_runMan->GeometryHasBeenModified(); + G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild"); + } else { + m_pmtDia = arg; + } +} + +/* + * Set the thickness of the trapezoidal light guide shell + * If the geometry has already been constructed, reconstruct + * it with the new thickness + */ +void DetectorConstruction::SetLGthickness(G4double arg){ + m_thickness = arg; + + if(m_ConstructionHasBeenDone){ + Construct(); + m_runMan->GeometryHasBeenModified(); + G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild"); + } +} + + +/* + * Builds a light guide logical volume from CAD model file */ void DetectorConstruction::UseCADModel(G4String fileName){ //Delete anything we are going to redefine - if(m_SurfLGtoWorld) delete m_SurfLGtoWorld; - if(m_SurfLGtoInner) delete m_SurfLGtoInner; if(m_logicLightGuide) delete m_logicLightGuide; - if(m_physLightGuide) delete m_physLightGuide; + + for(uint i = 0; i < m_physLightGuide.size(); i++){ + delete m_physLightGuide[i]; + delete m_physPMT[i]; + delete m_Surfvec[2*i]; + delete m_Surfvec[2*i+1]; + } + m_physLightGuide.clear(); + m_physPMT.clear(); + m_Surfvec.clear(); + G4String fileType = fileName.substr( fileName.last('.') + 1, fileName.size() - fileName.last('.')); @@ -319,43 +525,27 @@ void DetectorConstruction::UseCADModel(G4String fileName){ sprintf(message,"Zmin = %04.2f, Zmax = %04.2f: Depth = %04.2f", extent.GetZmin(), extent.GetZmax(), extent.GetZmax() - extent.GetZmin() ); G4cout << message << G4endl; - m_physLightGuide = - new G4PVPlacement(0, - G4ThreeVector(0,0,0), - m_logicLightGuide, - "physLightGuide", - m_logicHalfWorld, - false, - 0); - } - //----------------- Define Optical Borders -----------------// - m_SurfLGtoWorld = - new G4LogicalBorderSurface("AlSurface", - m_physLightGuide, - m_physHalfWorld, - materials->AlSurface ); - m_SurfLGtoInner = - new G4LogicalBorderSurface("AlSurface", - m_physHalfWorld, - m_physLightGuide, - materials->AlSurface ); - - - m_runMan->GeometryHasBeenModified(); - G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild"); - G4cout << "Replaced default light guide with CAD model" << G4endl; + if(m_pmtPos == 0) m_pmtPos = new G4ThreeVector(); + + if(m_ConstructionHasBeenDone){ + PlaceGeometry(); + m_runMan->GeometryHasBeenModified(); + G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild"); + } + G4cout << "Using " << fileName << " for CAD model" << G4endl; } + /* - * + * Output the model of the light guide to GDML */ void DetectorConstruction::OutputToGDML(G4String fileName){ - if(m_physLightGuide != 0){ + if(m_physLightGuide[0] != 0){ //For some reason this only works as a pointer G4GDMLParser* gdml = new G4GDMLParser(); - gdml->Write(fileName.c_str(),m_physLightGuide); + gdml->Write(fileName.c_str(),m_physLightGuide.back()); delete gdml; }else{ G4cout << "No physical light guide defined..." << G4endl; @@ -364,94 +554,92 @@ void DetectorConstruction::OutputToGDML(G4String fileName){ } /* - * + * Set the segmentation of the light guide envelope in x + * Reconstruct the geometry if necessary */ -void DetectorConstruction::SetSurfaceFinish(const G4OpticalSurfaceFinish finish){ - materials->AlSurface->SetFinish(finish); - m_runMan->GeometryHasBeenModified(); +void DetectorConstruction::SetNSegmentsX(G4int arg){ + m_nSegmentsX = arg; + if(m_ConstructionHasBeenDone){ + Construct(); + } } /* - * + * Set the segmentation of the light guide envelope in Z + * Reconstruct the geometry if necessary */ -void DetectorConstruction::SetSurfaceType(const G4SurfaceType type){ - materials->AlSurface->SetType(type); - m_runMan->GeometryHasBeenModified(); +void DetectorConstruction::SetNSegmentsZ(G4int arg){ + m_nSegmentsZ = arg; + if(m_ConstructionHasBeenDone){ + Construct(); + } } -/* - * - */ -void DetectorConstruction::AddSurfaceMPV(const char* c, G4MaterialPropertyVector* mpv){ - mpv->SetSpline(true); - materials->GetMPTArray().at(1)->AddProperty(c, mpv); - materials->AlSurface->SetMaterialPropertiesTable(materials->GetMPTArray().at(1)); - G4cout << "The MPT for the surface is now: " << G4endl; - materials->GetMPTArray().at(1)->DumpTable(); - G4cout << "............." << G4endl; -} /* - * + * Set the surface model for the light guide */ -void DetectorConstruction::AddGasMPV(const char* c, G4MaterialPropertyVector* mpv){ - mpv->SetSpline(true); - m_GasMPT->AddProperty(c, mpv); - G4cout << "The MPT for the gas is now: " << G4endl; - m_GasMPT->DumpTable(); - G4cout << "............." << G4endl; +void DetectorConstruction::SetSurfaceModel(const G4OpticalSurfaceModel model){ + materials->AlSurface->SetModel(model); + if(m_ConstructionHasBeenDone){ + m_runMan->GeometryHasBeenModified(); + } } /* * */ -void DetectorConstruction::SetSurfaceModel(const G4OpticalSurfaceModel model){ - materials->AlSurface->SetModel(model); - m_runMan->GeometryHasBeenModified(); +void DetectorConstruction::SetSurfaceFinish(const G4OpticalSurfaceFinish finish){ + materials->AlSurface->SetFinish(finish); + if(m_ConstructionHasBeenDone){ + m_runMan->GeometryHasBeenModified(); + } } /* * */ -void DetectorConstruction::SetRotation(G4ThreeVector arg){ - if(m_rotation) delete m_rotation; - m_rotation = new G4RotationMatrix(); - - m_rotation->rotateX(arg.x()); - m_rotation->rotateY(arg.y()); - m_rotation->rotateZ(arg.z()); - m_physLightGuide->SetRotation(m_rotation); - - m_runMan->GeometryHasBeenModified(); - G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild"); +void DetectorConstruction::SetSurfaceType(const G4SurfaceType type){ + materials->AlSurface->SetType(type); + if(m_ConstructionHasBeenDone){ + m_runMan->GeometryHasBeenModified(); + } } /* * */ -void DetectorConstruction::SetTranslation(G4ThreeVector arg){ - m_physLightGuide->SetTranslation(arg); +void DetectorConstruction::SetSurfaceSigmaAlpha(G4double v){ + materials->AlSurface->SetSigmaAlpha(v); - m_runMan->GeometryHasBeenModified(); - G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild"); + if(m_ConstructionHasBeenDone){ + G4RunManager::GetRunManager()->GeometryHasBeenModified(); + } + + G4cout << "Surface sigma alpha set to: " << materials->AlSurface->GetSigmaAlpha() << G4endl; } /* - * + * Set the material property table of the surface + * of the light guide */ -void DetectorConstruction::SetPMTTranslation(G4ThreeVector arg){ - m_physPMT->SetTranslation(arg); - - m_runMan->GeometryHasBeenModified(); - G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild"); +void DetectorConstruction::AddSurfaceMPV(const char* c, G4MaterialPropertyVector* mpv){ + mpv->SetSpline(true); + materials->GetMPTArray().at(1)->AddProperty(c, mpv); + materials->AlSurface->SetMaterialPropertiesTable(materials->GetMPTArray().at(1)); + G4cout << "The MPT for the surface is now: " << G4endl; + materials->GetMPTArray().at(1)->DumpTable(); + G4cout << "............." << G4endl; } /* - * + * Set the material property table of the volume + * which contains the light guide */ -void DetectorConstruction::SetPMTDiameter(G4double arg){ - m_solidPMT->SetOuterRadius(arg/2.0); - - m_runMan->GeometryHasBeenModified(); - G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild"); +void DetectorConstruction::AddGasMPV(const char* c, G4MaterialPropertyVector* mpv){ + mpv->SetSpline(true); + m_GasMPT->AddProperty(c, mpv); + G4cout << "The MPT for the gas is now: " << G4endl; + m_GasMPT->DumpTable(); + G4cout << "............." << G4endl; } diff --git a/src/DetectorMessenger.cc b/src/DetectorMessenger.cc index d9a363db4a8a9ec4168e5d057ca0a58133f5bee2..5e72f47cbfff81f4eb31c52f1263e5c872344215 100644 --- a/src/DetectorMessenger.cc +++ b/src/DetectorMessenger.cc @@ -50,6 +50,7 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det) :G4UImessenger(),fDetector(Det) { + //Directories flightGuideDir = new G4UIdirectory("/lightGuide/"); flightGuideDir->SetGuidance("Parameters for optical simulation."); @@ -59,52 +60,35 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det) fModelDir = new G4UIdirectory("/lightGuide/model/"); fModelDir->SetGuidance("Model source, translation and rotation"); - fSurfaceTypeCmd = new G4UIcmdWithAString("/lightGuide/surface/Type", this); - fSurfaceTypeCmd->SetGuidance("Surface type."); - fSurfaceTypeCmd->AvailableForStates(G4State_PreInit, G4State_Idle); - fSurfaceTypeCmd->SetToBeBroadcasted(false); - - fSurfaceFinishCmd = new G4UIcmdWithAString("/lightGuide/surface/Finish", this); - fSurfaceFinishCmd->SetGuidance("Surface finish."); - fSurfaceFinishCmd->AvailableForStates(G4State_PreInit, G4State_Idle); - fSurfaceFinishCmd->SetToBeBroadcasted(false); - - fSurfaceModelCmd = - new G4UIcmdWithAString("/lightGuide/surface/Model", this); - fSurfaceModelCmd->SetGuidance("surface model."); - fSurfaceModelCmd->AvailableForStates(G4State_PreInit, G4State_Idle); - fSurfaceModelCmd->SetToBeBroadcasted(false); - - fSurfaceSigmaAlphaCmd = - new G4UIcmdWithADouble("/lightGuide/surface/SigmaAlpha", this); - fSurfaceSigmaAlphaCmd->SetGuidance("surface sigma alpha"); - fSurfaceSigmaAlphaCmd->SetGuidance(" parameter."); - fSurfaceSigmaAlphaCmd->AvailableForStates(G4State_PreInit, G4State_Idle); - fSurfaceSigmaAlphaCmd->SetToBeBroadcasted(false); + fWorldVolumeCmd = + new G4UIcmdWith3VectorAndUnit("/lightGuide/worldVolume", this); + fWorldVolumeCmd->SetGuidance("Set the size of the world volume"); + fWorldVolumeCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle); + fWorldVolumeCmd->SetToBeBroadcasted(false); + fWorldVolumeCmd->SetParameterName("X","Y","Z",true); + fWorldVolumeCmd->SetDefaultValue(G4ThreeVector(0.25,0.25,0.5)); + fWorldVolumeCmd->SetDefaultUnit("m"); - fSurfaceMatPropVectorCmd = - new G4UIcmdWithAString("/lightGuide/surface/Property", this); - fSurfaceMatPropVectorCmd->SetGuidance("Set material property vector"); - fSurfaceMatPropVectorCmd->SetGuidance(" for the surface."); - fSurfaceMatPropVectorCmd->AvailableForStates(G4State_PreInit, G4State_Idle); - fSurfaceMatPropVectorCmd->SetToBeBroadcasted(false); - - fGasPropVectorCmd = - new G4UIcmdWithAString("/lightGuide/gasProperty", this); - fGasPropVectorCmd->SetGuidance("Set fill gas property vector"); - fGasPropVectorCmd->AvailableForStates(G4State_PreInit, G4State_Idle); - fGasPropVectorCmd->SetToBeBroadcasted(false); + fEnvelopeCmd = + new G4UIcmdWith3VectorAndUnit("/lightGuide/envelope", this); + fEnvelopeCmd->SetGuidance("Set the size light guide envelope"); + fEnvelopeCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle); + fEnvelopeCmd->SetToBeBroadcasted(false); + fEnvelopeCmd->SetParameterName("X","Y","Z",true); + fEnvelopeCmd->SetDefaultValue(G4ThreeVector(89.75*mm,113.*mm,339.*mm)); + fEnvelopeCmd->SetDefaultUnit("m"); + //Model commands fModelCmd = new G4UIcmdWithAString("/lightGuide/model/CADmodel", this); fModelCmd->SetGuidance("CAD model to be used"); - fModelCmd->AvailableForStates(G4State_PreInit, G4State_Idle); + fModelCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle); fModelCmd->SetToBeBroadcasted(false); fModelCmd->SetDefaultValue("models/Winston_cone.stl"); fModelRotationCmd = new G4UIcmdWith3VectorAndUnit("/lightGuide/model/rotate", this); fModelRotationCmd->SetGuidance("Set light guide first rotation"); - fModelRotationCmd->AvailableForStates(G4State_PreInit, G4State_Idle); + fModelRotationCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle); fModelRotationCmd->SetToBeBroadcasted(false); fModelRotationCmd->SetParameterName("rotationX","rotationY","rotationZ",true); fModelRotationCmd->SetDefaultValue(G4ThreeVector(0.,0.,0.)); @@ -113,7 +97,7 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det) fModelTranslationCmd = new G4UIcmdWith3VectorAndUnit("/lightGuide/model/translate", this); fModelTranslationCmd->SetGuidance("Set light guide translation"); - fModelTranslationCmd->AvailableForStates(G4State_PreInit, G4State_Idle); + fModelTranslationCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle); fModelTranslationCmd->SetToBeBroadcasted(false); fModelTranslationCmd->SetParameterName("X","Y","Z",true); fModelTranslationCmd->SetDefaultValue(G4ThreeVector(0.,0.,0.)); @@ -122,7 +106,7 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det) fPMTTranslationCmd = new G4UIcmdWith3VectorAndUnit("/lightGuide/model/translatePMT", this); fPMTTranslationCmd->SetGuidance("Set PMT translation"); - fPMTTranslationCmd->AvailableForStates(G4State_PreInit, G4State_Idle); + fPMTTranslationCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle); fPMTTranslationCmd->SetToBeBroadcasted(false); fPMTTranslationCmd->SetParameterName("X","Y","Z",true); fPMTTranslationCmd->SetDefaultValue(G4ThreeVector(0.,0.,0.)); @@ -131,35 +115,103 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det) fPMTDiameterCmd = new G4UIcmdWithADoubleAndUnit("/lightGuide/model/PMTDiameter",this); fPMTDiameterCmd->SetGuidance("Set PMT diameter"); - fPMTDiameterCmd->AvailableForStates(G4State_PreInit, G4State_Idle); + fPMTDiameterCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle); fPMTDiameterCmd->SetToBeBroadcasted(false); fPMTDiameterCmd->SetParameterName("dia",true); fPMTDiameterCmd->SetDefaultValue( 65.0*mm ); fPMTDiameterCmd->SetDefaultUnit("mm"); + fLGThicknessCmd = + new G4UIcmdWithADoubleAndUnit("/lightGuide/model/SkinThickness",this); + fLGThicknessCmd->SetGuidance("Set thickness of the light guide skin"); + fLGThicknessCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle); + fLGThicknessCmd->SetToBeBroadcasted(false); + fLGThicknessCmd->SetParameterName("thickness",true); + fLGThicknessCmd->SetDefaultValue( 1.0*mm ); + fLGThicknessCmd->SetDefaultUnit("mm"); + fOutputModelCmd = new G4UIcmdWithAString("/lightGuide/model/OutputModel",this); fOutputModelCmd->SetGuidance("Creates a .gdml file of the light guide with the given name"); - fOutputModelCmd->AvailableForStates(G4State_PreInit, G4State_Idle); + fOutputModelCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle); fOutputModelCmd->SetToBeBroadcasted(false); + fNsegmentsXCmd = + new G4UIcmdWithAnInteger("/lightGuide/model/nSegmentsX",this); + fNsegmentsXCmd->SetGuidance("Set segmentation of the light guide envelope in x"); + fNsegmentsXCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle); + fNsegmentsXCmd->SetToBeBroadcasted(false); + fNsegmentsXCmd->SetParameterName("nSegmentsX",true); + fNsegmentsXCmd->SetDefaultValue( 1 ); + + fNsegmentsZCmd = + new G4UIcmdWithAnInteger("/lightGuide/model/nSegmentsZ",this); + fNsegmentsZCmd->SetGuidance("Set segmentation of the light guide envelope in z"); + fNsegmentsZCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle); + fNsegmentsZCmd->SetToBeBroadcasted(false); + fNsegmentsZCmd->SetParameterName("nSegmentsZ",true); + fNsegmentsZCmd->SetDefaultValue( 1 ); + + //Surface commands + fSurfaceTypeCmd = new G4UIcmdWithAString("/lightGuide/surface/Type", this); + fSurfaceTypeCmd->SetGuidance("Surface type."); + fSurfaceTypeCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle); + fSurfaceTypeCmd->SetToBeBroadcasted(false); + + fSurfaceFinishCmd = new G4UIcmdWithAString("/lightGuide/surface/Finish", this); + fSurfaceFinishCmd->SetGuidance("Surface finish."); + fSurfaceFinishCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle); + fSurfaceFinishCmd->SetToBeBroadcasted(false); + + fSurfaceModelCmd = + new G4UIcmdWithAString("/lightGuide/surface/Model", this); + fSurfaceModelCmd->SetGuidance("surface model."); + fSurfaceModelCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle); + fSurfaceModelCmd->SetToBeBroadcasted(false); + + fSurfaceSigmaAlphaCmd = + new G4UIcmdWithADouble("/lightGuide/surface/SigmaAlpha", this); + fSurfaceSigmaAlphaCmd->SetGuidance("surface sigma alpha"); + fSurfaceSigmaAlphaCmd->SetGuidance(" parameter."); + fSurfaceSigmaAlphaCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle); + fSurfaceSigmaAlphaCmd->SetToBeBroadcasted(false); + + fSurfaceMatPropVectorCmd = + new G4UIcmdWithAString("/lightGuide/surface/Property", this); + fSurfaceMatPropVectorCmd->SetGuidance("Set material property vector"); + fSurfaceMatPropVectorCmd->SetGuidance(" for the surface."); + fSurfaceMatPropVectorCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle); + fSurfaceMatPropVectorCmd->SetToBeBroadcasted(false); + + //Gas commands + fGasPropVectorCmd = + new G4UIcmdWithAString("/lightGuide/gasProperty", this); + fGasPropVectorCmd->SetGuidance("Set fill gas property vector"); + fGasPropVectorCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle); + fGasPropVectorCmd->SetToBeBroadcasted(false); + } /* * */ DetectorMessenger::~DetectorMessenger(){ - delete fSurfaceFinishCmd; - delete fSurfaceTypeCmd; - delete fSurfaceModelCmd; - delete fSurfaceSigmaAlphaCmd; - delete fSurfaceMatPropVectorCmd; - delete fGasPropVectorCmd; delete fModelCmd; + delete fWorldVolumeCmd; + delete fEnvelopeCmd; delete fModelRotationCmd; delete fModelTranslationCmd; delete fPMTTranslationCmd; delete fPMTDiameterCmd; + delete fLGThicknessCmd; delete fOutputModelCmd; + delete fNsegmentsXCmd; + delete fNsegmentsZCmd; + delete fSurfaceModelCmd; + delete fSurfaceFinishCmd; + delete fSurfaceTypeCmd; + delete fSurfaceSigmaAlphaCmd; + delete fSurfaceMatPropVectorCmd; + delete fGasPropVectorCmd; } /* @@ -167,8 +219,52 @@ DetectorMessenger::~DetectorMessenger(){ */ void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) { + // MODEL FILE + if(command == fModelCmd){ + fDetector->UseCADModel(newValue); + } + // WORLD VOLUME + else if(command == fWorldVolumeCmd){ + fDetector->SetWorldVolume(fWorldVolumeCmd->GetNew3VectorValue(newValue)); + } + // LIGHT GUIDE ENVELOPE + else if(command == fEnvelopeCmd){ + fDetector->SetEnvelope(fEnvelopeCmd->GetNew3VectorValue(newValue)); + } + // MODEL ROTATION + else if(command == fModelRotationCmd){ + fDetector->SetRotation(fModelRotationCmd->GetNew3VectorValue(newValue)); + } + // MODEL TRANSLATION + else if(command == fModelTranslationCmd){ + fDetector->SetTranslation(fModelTranslationCmd->GetNew3VectorValue(newValue)); + } + // PMT TRANSLATION + else if(command == fPMTTranslationCmd){ + fDetector->SetPMTTranslation(fPMTTranslationCmd->GetNew3VectorValue(newValue)); + } + // PMT DIAMETER + else if(command == fPMTDiameterCmd){ + fDetector->SetPMTDiameter(fPMTDiameterCmd->GetNewDoubleValue(newValue)); + } + // PMT DIAMETER + else if(command == fLGThicknessCmd){ + fDetector->SetLGthickness(fLGThicknessCmd->GetNewDoubleValue(newValue)); + } + // OUTPUT GEOMETRY TO GDML + else if(command == fOutputModelCmd){ + fDetector->OutputToGDML(newValue); + } + // X SEGMENTATION + else if(command == fNsegmentsXCmd){ + fDetector->SetNSegmentsX(fNsegmentsXCmd->GetNewIntValue(newValue)); + } + // Z SEGMENTATION + else if(command == fNsegmentsZCmd){ + fDetector->SetNSegmentsZ(fNsegmentsZCmd->GetNewIntValue(newValue)); + } // FINISH - if (command == fSurfaceFinishCmd) { + else if (command == fSurfaceFinishCmd) { if (newValue == "polished") { fDetector->SetSurfaceFinish(polished); } @@ -365,7 +461,7 @@ void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) fDetector->SetSurfaceSigmaAlpha( G4UIcmdWithADouble::GetNewDoubleValue(newValue)); } - // SURFACE PROPERTY + // Gas property else if (command == fGasPropVectorCmd) { // Convert string to physics vector // string format is property name, then pairs of energy, value @@ -388,28 +484,4 @@ void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) const char* c = prop.c_str(); fDetector->AddGasMPV(c, mpv); } - // MODEL LOCATION - else if(command == fModelCmd){ - fDetector->UseCADModel(newValue); - } - // MODEL ROTATION - else if(command == fModelRotationCmd){ - fDetector->SetRotation(fModelRotationCmd->GetNew3VectorValue(newValue)); - } - // MODEL TRANSLATION - else if(command == fModelTranslationCmd){ - fDetector->SetTranslation(fModelTranslationCmd->GetNew3VectorValue(newValue)); - } - // PMT TRANSLATION - else if(command == fPMTTranslationCmd){ - fDetector->SetPMTTranslation(fPMTTranslationCmd->GetNew3VectorValue(newValue)); - } - // PMT Diameter - else if(command == fPMTDiameterCmd){ - fDetector->SetPMTDiameter(fPMTDiameterCmd->GetNewDoubleValue(newValue)); - } - // PMT Diameter - else if(command == fOutputModelCmd){ - fDetector->OutputToGDML(newValue); - } } diff --git a/src/SteppingAction.cc b/src/SteppingAction.cc index 25e089665df68951f9f2e2d9f66da2002c07dcb3..a16c385c2c8cc8eb4d3aa04cb7d7e57603ac7d0d 100644 --- a/src/SteppingAction.cc +++ b/src/SteppingAction.cc @@ -41,50 +41,19 @@ SteppingAction::SteppingAction() : G4UserSteppingAction() { - fScintillationCounter = 0; - fCerenkovCounter = 0; - fEventNumber = -1; + } /* */ SteppingAction::~SteppingAction() -{ ; } +{ + +} /* */ void SteppingAction::UserSteppingAction(const G4Step* step) { - G4int eventNumber = G4RunManager::GetRunManager()-> - GetCurrentEvent()->GetEventID(); - - if (eventNumber != fEventNumber) { - fEventNumber = eventNumber; - fScintillationCounter = 0; - fCerenkovCounter = 0; - } - - G4Track* track = step->GetTrack(); - - G4String ParticleName = track->GetDynamicParticle()-> - GetParticleDefinition()->GetParticleName(); - - if (ParticleName == "opticalphoton") return; - - const std::vector<const G4Track*>* secondaries = - step->GetSecondaryInCurrentStep(); - if (secondaries->size()>0) { - for(unsigned int i=0; i<secondaries->size(); ++i) { - if (secondaries->at(i)->GetParentID()>0) { - if(secondaries->at(i)->GetDynamicParticle()->GetParticleDefinition() - == G4OpticalPhoton::OpticalPhotonDefinition()){ - if (secondaries->at(i)->GetCreatorProcess()->GetProcessName() - == "Scintillation")fScintillationCounter++; - if (secondaries->at(i)->GetCreatorProcess()->GetProcessName() - == "Cerenkov")fCerenkovCounter++; - } - } - } - } }