Skip to content
Snippets Groups Projects
Commit d9f0accf authored by clantz's avatar clantz
Browse files

Added Messengers from OpNovice2

parent a25d56db
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,7 @@
#include "G4GDMLParser.hh"
#include "Materials.hh"
#include "DetectorMessenger.hh"
class DetectorConstruction : public G4VUserDetectorConstruction
......@@ -53,7 +54,12 @@ class DetectorConstruction : public G4VUserDetectorConstruction
void SetCADFilename (std::string name){filename = name;}
void SetCADFiletype (std::string type){filetype = type;}
void SetGDMLoutName (std::string name){GDMLoutput = name;}
void SetSurfaceRoughness(G4double ruff) {fRoughness = ruff;}
void SetSurfaceFinish(const G4OpticalSurfaceFinish finish);
void SetSurfaceType(const G4SurfaceType type);
void SetSurfaceModel(const G4OpticalSurfaceModel model);
void SetSurfaceSigmaAlpha(G4double v);
private:
G4Box* m_solidWorld;
......@@ -68,9 +74,9 @@ class DetectorConstruction : public G4VUserDetectorConstruction
std::string filename = "";
std::string filetype = "";
std::string GDMLoutput;
G4double fRoughness = 0;
G4GDMLParser fParser;
DetectorMessenger* fDetectorMessenger;
};
#endif /*DetectorConstruction_h*/
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file optical/OpNovice2/include/DetectorMessenger.hh
/// \brief Definition of the DetectorMessenger class
//
//
//
#ifndef DetectorMessenger_h
#define DetectorMessenger_h 1
#include "globals.hh"
#include "G4UImessenger.hh"
class DetectorConstruction;
class G4UIdirectory;
class G4UIcommand;
class G4UIcmdWithAString;
class G4UIcmdWithAnInteger;
class G4UIcmdWithADouble;
class G4UIcmdWithADoubleAndUnit;
class G4UIcmdWithoutParameter;
class DetectorMessenger: public G4UImessenger{
public:
DetectorMessenger(DetectorConstruction* );
~DetectorMessenger();
virtual void SetNewValue(G4UIcommand*, G4String);
private:
DetectorConstruction* fDetector;
G4UIdirectory* flightGuideDir;
// the surface
G4UIcmdWithAString* fSurfaceTypeCmd;
G4UIcmdWithAString* fSurfaceFinishCmd;
G4UIcmdWithAString* fSurfaceModelCmd;
G4UIcmdWithADouble* fSurfaceSigmaAlphaCmd;
G4UIcmdWithAString* fSurfaceMatPropVectorCmd;
};
#endif
......@@ -79,7 +79,6 @@ int main(int argc,char** argv)
G4String CADmodel = "";
G4String filetype;
G4String CADoutFile = "";
G4double roughness = 0;
#ifdef G4MULTITHREADED
G4int nThreads = 0;
#endif
......@@ -92,7 +91,6 @@ int main(int argc,char** argv)
else if ( G4String(argv[i]) == "-c" ){CADmodel = argv[i+1]; filetype = argv[i+2];i++;}
else if ( G4String(argv[i]) == "-co" ) CADoutFile = argv[i+1];
else if ( G4String(argv[i]) == "-r" ) myseed = atoi(argv[i+1]);
else if ( G4String(argv[i]) == "-s" ) roughness = atof(argv[i+1]);
#ifdef G4MULTITHREADED
else if ( G4String(argv[i]) == "-t" ) {
nThreads = G4UIcommand::ConvertToInt(argv[i+1]);
......@@ -158,7 +156,6 @@ int main(int argc,char** argv)
DetConst->SetCADFilename(CADmodel);
DetConst->SetCADFiletype(filetype);
DetConst->SetGDMLoutName(CADoutFile);
DetConst->SetSurfaceRoughness(roughness);
}
runManager-> SetUserInitialization(DetConst);
// Physics list
......@@ -188,8 +185,6 @@ int main(int argc,char** argv)
else // Define UI session for interactive mode
{
UImanager->ApplyCommand("/control/execute vis.mac");
if (ui->IsGUI())
UImanager->ApplyCommand("/control/execute gui.mac");
ui->SessionStart();
delete ui;
}
......
......@@ -29,6 +29,7 @@
// USER //
#include "DetectorConstruction.hh"
#include "DetectorMessenger.hh"
#include "Materials.hh"
#include "PMTSD.hh"
......@@ -37,6 +38,7 @@
// GEANT4 //
#include "G4Element.hh"
#include "G4SDManager.hh"
#include "G4RunManager.hh"
#include "G4LogicalBorderSurface.hh"
#include "G4LogicalSkinSurface.hh"
#include "G4OpticalSurface.hh"
......@@ -60,8 +62,9 @@
*
*/
DetectorConstruction::DetectorConstruction()
: G4VUserDetectorConstruction(){
: G4VUserDetectorConstruction(),fDetectorMessenger(nullptr){
materials = Materials::getInstance();
fDetectorMessenger = new DetectorMessenger(this);
}
......@@ -82,7 +85,7 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){
materials->DefineOpticalProperties();
G4Material* Air = materials->Air;
G4Material* Al = materials->Al;
G4Material* Silica = materials->pQuartz;
//Set the lightguide height. Hardcoded for now,
//should be determined by the model dimensions
......@@ -118,11 +121,6 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){
//----------------- Make the light guide -----------------//
////////////////////This got all sorts of fucked up. I'll probably drop GDML support or make it required
//materials->AlSurface->SetFinish(ground);
//materials->AlSurface->SetPolish(0.1);
//materials->AlSurface->SetSigmaAlpha(2.0);
//If we have defined a CAD file, use it
if(filename != ""){
......@@ -170,10 +168,16 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){
//Make the surface optically reflective
G4LogicalSkinSurface* alumLSS =
/*G4LogicalSkinSurface* alumLSS =
new G4LogicalSkinSurface("AlSkinSurface",
cad_logical,
materials->AlSurface );
materials->AlSurface );*/
G4LogicalBorderSurface* alumLSS =
new G4LogicalBorderSurface("AlSurface",
m_physWorld,
cad_physical,
materials->AlSurface );
(void)alumLSS;
}else{
//Create a trapezoidal air light guide made of aluminum sheet
......@@ -219,11 +223,24 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){
m_logicWorld,
false,
0);
(void)physLightGuide;
G4LogicalSkinSurface* alumLSS =
/*G4LogicalSkinSurface* alumLSS =
new G4LogicalSkinSurface("AlSkinSurface",
logicLightGuide,
materials->AlSurface );
materials->AlSurface );*/
G4LogicalBorderSurface* alumLSS1 =
new G4LogicalBorderSurface("AlSurface",
physLightGuide,
m_physWorld,
materials->AlSurface );
G4LogicalBorderSurface* alumLSS2 =
new G4LogicalBorderSurface("AlSurface",
m_physWorld,
physLightGuide,
materials->AlSurface );
(void)alumLSS1;
(void)alumLSS2;
}//end else
......@@ -255,8 +272,44 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){
m_logicWorld,
false,
0);
(void)physPMT;
logicPMT->SetSensitiveDetector( PMT );
return m_physWorld;
}
/*
*
*/
void DetectorConstruction::SetSurfaceSigmaAlpha(G4double v){
materials->AlSurface->SetSigmaAlpha(v);
G4RunManager::GetRunManager()->GeometryHasBeenModified();
G4cout << "Surface sigma alpha set to: " << materials->AlSurface->GetSigmaAlpha()
<< G4endl;
}
/*
*
*/
void DetectorConstruction::SetSurfaceFinish(const G4OpticalSurfaceFinish finish){
materials->AlSurface->SetFinish(finish);
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
/*
*
*/
void DetectorConstruction::SetSurfaceType(const G4SurfaceType type){
materials->AlSurface->SetType(type);
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
/*
*
*/
void DetectorConstruction::SetSurfaceModel(const G4OpticalSurfaceModel model){
materials->AlSurface->SetModel(model);
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file optical/OpNovice2/src/DetectorMessenger.cc
/// \brief Implementation of the DetectorMessenger class
//
//
#include "DetectorMessenger.hh"
#include <sstream>
#include <iostream>
#include "G4OpticalSurface.hh"
#include "DetectorConstruction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithADouble.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithoutParameter.hh"
DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
:G4UImessenger(),fDetector(Det)
{
flightGuideDir = new G4UIdirectory("/lightGuide/");
flightGuideDir->SetGuidance("Parameters for optical simulation.");
fSurfaceTypeCmd = new G4UIcmdWithAString("/lightGuide/surfaceType", this);
fSurfaceTypeCmd->SetGuidance("Surface type.");
fSurfaceTypeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fSurfaceTypeCmd->SetToBeBroadcasted(false);
fSurfaceFinishCmd = new G4UIcmdWithAString("/lightGuide/surfaceFinish", this);
fSurfaceFinishCmd->SetGuidance("Surface finish.");
fSurfaceFinishCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fSurfaceFinishCmd->SetToBeBroadcasted(false);
fSurfaceModelCmd =
new G4UIcmdWithAString("/lightGuide/surfaceModel", this);
fSurfaceModelCmd->SetGuidance("surface model.");
fSurfaceModelCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fSurfaceModelCmd->SetToBeBroadcasted(false);
fSurfaceSigmaAlphaCmd =
new G4UIcmdWithADouble("/lightGuide/surfaceSigmaAlpha", this);
fSurfaceSigmaAlphaCmd->SetGuidance("surface sigma alpha");
fSurfaceSigmaAlphaCmd->SetGuidance(" parameter.");
fSurfaceSigmaAlphaCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fSurfaceSigmaAlphaCmd->SetToBeBroadcasted(false);
fSurfaceMatPropVectorCmd =
new G4UIcmdWithAString("/lightGuide/surfaceProperty", this);
fSurfaceMatPropVectorCmd->SetGuidance("Set material property vector");
fSurfaceMatPropVectorCmd->SetGuidance(" for the surface.");
fSurfaceMatPropVectorCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fSurfaceMatPropVectorCmd->SetToBeBroadcasted(false);
}
/*
*
*/
DetectorMessenger::~DetectorMessenger(){
delete fSurfaceFinishCmd;
delete fSurfaceTypeCmd;
delete fSurfaceModelCmd;
delete fSurfaceSigmaAlphaCmd;
delete fSurfaceMatPropVectorCmd;
}
/*
*
*/
void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
{
// FINISH
if (command == fSurfaceFinishCmd) {
if (newValue == "polished") {
fDetector->SetSurfaceFinish(polished);
}
else if (newValue == "polishedfrontpainted") {
fDetector->SetSurfaceFinish(polishedfrontpainted);
}
else if (newValue == "polishedbackpainted") {
fDetector->SetSurfaceFinish(polishedbackpainted);
}
else if (newValue == "ground") {
fDetector->SetSurfaceFinish(ground);
}
else if (newValue == "groundfrontpainted") {
fDetector->SetSurfaceFinish(groundfrontpainted);
}
else if (newValue == "groundbackpainted") {
fDetector->SetSurfaceFinish(groundbackpainted);
}
else if (newValue == "polishedlumirrorair") {
fDetector->SetSurfaceFinish(polishedlumirrorair);
}
else if (newValue == "polishedlumirrorglue") {
fDetector->SetSurfaceFinish(polishedlumirrorglue);
}
else if (newValue == "polishedair") {
fDetector->SetSurfaceFinish(polishedair);
}
else if (newValue == "polishedteflonair") {
fDetector->SetSurfaceFinish(polishedteflonair);
}
else if (newValue == "polishedtioair") {
fDetector->SetSurfaceFinish(polishedtioair);
}
else if (newValue == "polishedtyvekair") {
fDetector->SetSurfaceFinish(polishedtyvekair);
}
else if (newValue == "polishedvm2000air") {
fDetector->SetSurfaceFinish(polishedvm2000air);
}
else if (newValue == "polishedvm2000glue") {
fDetector->SetSurfaceFinish(polishedvm2000glue);
}
else if (newValue == "etchedlumirrorair") {
fDetector->SetSurfaceFinish(etchedlumirrorair);
}
else if (newValue == "etchedlumirrorglue") {
fDetector->SetSurfaceFinish(etchedlumirrorglue);
}
else if (newValue == "etchedair") {
fDetector->SetSurfaceFinish(etchedair);
}
else if (newValue == "etchedteflonair") {
fDetector->SetSurfaceFinish(etchedteflonair);
}
else if (newValue == "etchedtioair") {
fDetector->SetSurfaceFinish(etchedtioair);
}
else if (newValue == "etchedtyvekair") {
fDetector->SetSurfaceFinish(etchedtyvekair);
}
else if (newValue == "etchedvm2000air") {
fDetector->SetSurfaceFinish(etchedvm2000air);
}
else if (newValue == "etchedvm2000glue") {
fDetector->SetSurfaceFinish(etchedvm2000glue);
}
else if (newValue == "groundlumirrorair") {
fDetector->SetSurfaceFinish(groundlumirrorair);
}
else if (newValue == "groundlumirrorglue") {
fDetector->SetSurfaceFinish(groundlumirrorglue);
}
else if (newValue == "groundair") {
fDetector->SetSurfaceFinish(groundair);
}
else if (newValue == "groundteflonair") {
fDetector->SetSurfaceFinish(groundteflonair);
}
else if (newValue == "groundtioair") {
fDetector->SetSurfaceFinish(groundtioair);
}
else if (newValue == "groundtyvekair") {
fDetector->SetSurfaceFinish(groundtyvekair);
}
else if (newValue == "groundvm2000air") {
fDetector->SetSurfaceFinish(groundvm2000air);
}
else if (newValue == "groundvm2000glue") {
fDetector->SetSurfaceFinish(groundvm2000glue);
}
// for Davis model
else if (newValue == "Rough_LUT") {
fDetector->SetSurfaceFinish(Rough_LUT);
}
else if (newValue == "RoughTeflon_LUT") {
fDetector->SetSurfaceFinish(RoughTeflon_LUT);
}
else if (newValue == "RoughESR_LUT") {
fDetector->SetSurfaceFinish(RoughESR_LUT);
}
else if (newValue == "RoughESRGrease_LUT") {
fDetector->SetSurfaceFinish(RoughESRGrease_LUT);
}
else if (newValue == "Polished_LUT") {
fDetector->SetSurfaceFinish(Polished_LUT);
}
else if (newValue == "PolishedTeflon_LUT") {
fDetector->SetSurfaceFinish(PolishedTeflon_LUT);
}
else if (newValue == "PolishedESR_LUT") {
fDetector->SetSurfaceFinish(PolishedESR_LUT);
}
else if (newValue == "PolishedESRGrease_LUT") {
fDetector->SetSurfaceFinish(PolishedESRGrease_LUT);
}
else if (newValue == "Detector_LUT") {
fDetector->SetSurfaceFinish(Detector_LUT);
}
else {
G4ExceptionDescription ed;
ed << "Invalid surface finish: " << newValue;
G4Exception("DetectorMessenger", "OpNovice2_003", FatalException,ed);
}
}
// MODEL
else if (command == fSurfaceModelCmd) {
if (newValue == "glisur") {
fDetector->SetSurfaceModel(glisur);
}
else if (newValue == "unified") {
fDetector->SetSurfaceModel(unified);
}
else if (newValue == "LUT") {
fDetector->SetSurfaceModel(LUT);
}
else if (newValue == "DAVIS") {
fDetector->SetSurfaceModel(DAVIS);
}
else if (newValue == "dichroic") {
fDetector->SetSurfaceModel(dichroic);
}
else {
G4ExceptionDescription ed;
ed << "Invalid surface model: " << newValue;
G4Exception("DetectorMessenger", "ONovice2_001",
FatalException,ed);
}
}
// TYPE
else if (command == fSurfaceTypeCmd) {
if (newValue == "dielectric_metal") {
fDetector->SetSurfaceType(dielectric_metal);
}
else if (newValue == "dielectric_dielectric") {
fDetector->SetSurfaceType(dielectric_dielectric);
}
else if (newValue == "dielectric_LUT") {
fDetector->SetSurfaceType(dielectric_LUT);
}
else if (newValue == "dielectric_LUTDAVIS") {
fDetector->SetSurfaceType(dielectric_LUTDAVIS);
}
else {
G4ExceptionDescription ed;
ed << "Invalid surface type: " << newValue;
G4Exception("DetectorMessenger", "OpNovice2_002", FatalException,ed);
}
}
else if (command == fSurfaceSigmaAlphaCmd) {
fDetector->SetSurfaceSigmaAlpha(
G4UIcmdWithADouble::GetNewDoubleValue(newValue));
}
}
/control/verbose 2
/tracking/verbose 0
/opnovice2/boxProperty RINDEX 0.000002 1.3 0.000008 1.4
/opnovice2/boxProperty ABSLENGTH 0.000002 1000000 0.000005 2000000 0.000008 3000000
/opnovice2/worldProperty RINDEX 0.000002 1.01 0.000008 1.01
/opnovice2/worldProperty ABSLENGTH 0.000002 1000000 0.000005 2000000 0.000008 3000000
/opnovice2/surfaceModel unified
/opnovice2/surfaceType dielectric_dielectric
/opnovice2/surfaceFinish ground
/opnovice2/surfaceSigmaAlpha 1.1
/opnovice2/surfaceProperty SPECULARLOBECONSTANT 0.000002 .1 0.000008 .1
/opnovice2/surfaceProperty SPECULARSPIKECONSTANT 0.000002 .01 0.000008 .01
/opnovice2/surfaceProperty BACKSCATTERCONSTANT 0.000002 .05 0.000008 .05
/opnovice2/surfaceProperty REFLECTIVITY 0.000002 .99 0.000008 .99
/run/initialize
#
/gun/particle opticalphoton
/gun/energy 3 eV
/gun/position 0 0 0 cm
/gun/direction 1 0 0
/opnovice2/gun/optPhotonPolar
#
/analysis/h1/set 3 40 -1 39
/analysis/h1/set 4 100 -1.1 1.1
/analysis/h1/set 5 100 -1.1 1.1
/analysis/h1/set 6 100 -1.1 1.1
/analysis/h1/set 7 100 -1.1 1.1
/analysis/h1/set 8 100 -1.1 1.1
/analysis/h1/set 9 100 -1.1 1.1
/analysis/h1/set 10 100 -1.1 1.1
/analysis/h1/set 11 100 -1.1 1.1
/analysis/h1/set 12 100 -1.1 1.1
/run/beamOn 100000
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment