diff --git a/Analysis/plotHisto.cc b/Analysis/plotHisto.cc index 36e38074f8702ce3ef6bacc388e24404be19c6d4..89e55887c7589b635be16e88f0e6bbcbe64e371a 100644 --- a/Analysis/plotHisto.cc +++ b/Analysis/plotHisto.cc @@ -8,6 +8,7 @@ using namespace std; int main(int argc, char *argv[]){ + if(argc == 0) return 0; TFile *f = new TFile( Form("%s.root",argv[1]) ); if(f->IsZombie()){ cout << Form("%s.root does not exist... exiting",argv[1]) << endl; diff --git a/CMakeLists.txt b/CMakeLists.txt index 104753703c0c7ce456d764625615f2395b09c0ec..8806fc3bedcdb86d8ff57ede6cce52223f4337a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,6 @@ TARGET_LINK_LIBRARIES(plotHisto ${ROOT_LIBRARIES}) set(lightGuide_SCRIPTS vis.mac run1.mac - models.mac ) foreach(_script ${lightGuide_SCRIPTS}) @@ -71,9 +70,7 @@ endforeach() #---------------------------------------------------------------------------- # Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX # -install(TARGETS lightGuide DESTINATION bin) -install(FILES run1.mac DESTINATION . ) -install(FILES run2.mac DESTINATION . ) -install(FILES runAndAnalyze.sh DESTINATION . ) -install(FILES vis.mac DESTINATION . ) +install(TARGETS lightGuide DESTINATION bin ) +install(FILES run1.mac DESTINATION bin ) +install(FILES vis.mac DESTINATION bin) install(DIRECTORY models/ DESTINATION models) diff --git a/README.md b/README.md index b89f865ae17669f4081d3add56dc99dc704cd658..d00bb95bd829d2d43d8ea903713da514b9ea5345 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,12 @@ This simulation is based on OpNovice and OpNovice2 -Build requirements - Geant4 compiled with GDML and additional datasets - ROOT - -CADMesh is required to read CAD models (i.e. stl, step), but is optional for compiling +#### Build requirements + - Geant4 compiled with GDML and additional datasets + + - CERN ROOT + + - CADMesh is required to read CAD models (i.e. stl, step), but is optional for compiling #### main() @@ -15,7 +17,8 @@ define Random Number Engine, initial seed, CAD input and GDML output #### G4VUserPhysicsList - - Define particles; including - *** G4OpticalPhoton *** + - Define particles; including + - *** G4OpticalPhoton *** - Define processes; including - *** G4Cerenkov *** - *** G4Scintillation *** @@ -36,14 +39,28 @@ A light guide is made either by simple G4trd or by importing a model define G4LogicalBorderSurface between the light guide and world volume defines a PMT window sensitive detector at the top of the light guide AlSurface properties can be modified via DetectorMessenger via the following commands +``` + /lightGuide/surface/Model + /lightGuide/surface/Type + /lightGuide/surface/Finish + /lightGuide/surface/SigmaAlpha + /lightGuide/surface/Property +``` - /lightGuide/surfaceModel - /lightGuide/surfaceType - /lightGuide/surfaceFinish - /lightGuide/surfaceSigmaAlpha - /lightGuide/surfaceProperty +CAD models can be imported and positioned via +``` + /lightGuide/model/CADmodel + /lightGuide/model/rotate + /lightGuide/model/translate + /lightGuide/model/translatePMT +``` + +And the optical properties of a sub volume of G4Air which the light guide sits in can be configured via +``` + /lightGuide/gasProperty +``` -examples can be found in run1.mac +examples of all of these can be found in run1.mac #### G4VUserPrimaryGeneratorAction @@ -98,8 +115,6 @@ Records a PMTHit if the photon strikes the PMT window [-t nThreads] [-r seed] [-o outputFileName] - [-c CADmodelName filetype] - [-co GDMLoutFileName] ``` The -t option is available only in multi-threading mode diff --git a/include/RunAction.hh b/include/RunAction.hh index 317238b2392e77e19295d84d1075a2ce34239b28..91f99ab809d280c96e4a9a3262dea431f5d2d43e 100644 --- a/include/RunAction.hh +++ b/include/RunAction.hh @@ -54,7 +54,7 @@ class RunAction : public G4UserRunAction private: G4Timer* fTimer; - G4String ffileName = ""; + G4String m_fileName; }; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/lightGuide.cc b/lightGuide.cc index c57609d69af8917fcba7f9bad835e0a096bba859..603ada7321c770c24d16850deeec0ad5ab5b63da 100644 --- a/lightGuide.cc +++ b/lightGuide.cc @@ -75,7 +75,7 @@ int main(int argc,char** argv) G4String macro; G4String session; - G4String output; + G4String output = ""; #ifdef G4MULTITHREADED G4int nThreads = 0; #endif diff --git a/models.mac b/models.mac deleted file mode 100644 index c0fb7fee0f82b9cf7fd2554b730a9eddc6572633..0000000000000000000000000000000000000000 --- a/models.mac +++ /dev/null @@ -1,2 +0,0 @@ -/lightGuide/model/CADmodel models/Winston_cone.stl -/lightGuide/model/rotate -90 0 90 diff --git a/run1.mac b/run1.mac index c5c23c9692f8a622cae5aa9dbd1e0bc8c6924a70..f3c1b1eaedeb64aa9203a72ed4cdb61bac2a4dec 100644 --- a/run1.mac +++ b/run1.mac @@ -21,22 +21,22 @@ #If no model is selected, the program will default to a #simplified version of the 2018 testbeam light guide -#/lightGuide/model/CADmodel models/LightGuide2018TB.stl +#/lightGuide/model/CADmodel ../models/LightGuide2018TB.stl #/lightGuide/model/rotate 0 90 0 #/lightGuide/model/translate 0 -250 200 mm #/lightGuide/model/translatePMT 0 339 0 mm -#/lightGuide/model/CADmodel models/Winston_cone.stl +#/lightGuide/model/CADmodel ../models/Winston_cone.stl #/lightGuide/model/rotate 0 0 90 #/lightGuide/model/translate 0 -111 0 mm #/lightGuide/model/translatePMT 0 339 0 mm -#/lightGuide/model/CADmodel models/LightGuide2007BigPMT.stl +#/lightGuide/model/CADmodel ../models/LightGuide2007BigPMT.stl #/lightGuide/model/rotate 0 -90 0 #/lightGuide/model/translate 0 -250 -200 mm #/lightGuide/model/translatePMT 0 131 0 mm -#/lightGuide/model/CADmodel models/LightGuide2007SmallPMT.stl +#/lightGuide/model/CADmodel ../models/LightGuide2007SmallPMT.stl #/lightGuide/model/rotate 0 -90 0 #/lightGuide/model/translate 0 -250 -200 mm #/lightGuide/model/translatePMT 0 131 0 mm diff --git a/run2.mac b/run2.mac deleted file mode 100644 index bca9631f81cdb8706db2c0d2922d4f075c89075e..0000000000000000000000000000000000000000 --- a/run2.mac +++ /dev/null @@ -1,67 +0,0 @@ -# Macro file for JZCaPA beam test 2018 -# -# To be run preferably in batch, without graphics: -# -# 31 TeV Pb ion - -# Initialize kernel -/run/initialize - - -/control/verbose 0 -/run/verbose 0 -/run/printProgress 0 -/tracking/verbose 0 -/run/particle/verbose 0 -/hits/verbose 0 - -/gps/particle opticalphoton - -#Set reflective surface properties -/lightGuide/surfaceModel unified -/lightGuide/surfaceType dielectric_metal -/lightGuide/surfaceFinish ground -#/lightGuide/surfaceSigmaAlpha .01 -#/lightGuide/surfaceProperty SPECULARLOBECONSTANT 0.000002 1.0 0.000008 1.0 -#/lightGuide/surfaceProperty SPECULARSPIKECONSTANT 0.000002 0.99 0.000008 0.99 -#/lightGuide/surfaceProperty BACKSCATTERCONSTANT 0.000002 .05 0.000008 .05 -#/lightGuide/surfaceProperty REFLECTIVITY 0.000002 .99 0.000008 .99 - -# the beam energy is in gaussian profile -/gps/ene/type Gauss -/gps/ene/mono 3.4 eV -/gps/ene/sigma 1 eV -/gps/polarization 0 0 0 - -# General particle source, beam -#/gps/pos/type Beam -#/gps/pos/shape Circle -#/gps/pos/centre 0. 0. 0. mm -#/gps/pos/radius 0.75 mm -#/gps/pos/sigma_r 0.002 mm - -# General particle source, rectangular plane -/gps/pos/type Plane -/gps/pos/shape Rectangle -/gps/pos/centre 0. 0. 0. mm -/gps/pos/halfx 44.875 mm -/gps/pos/halfy 82 mm - -# -# the incident surface is in the x-y plane -/gps/pos/rot1 1 0 0 -/gps/pos/rot2 0 1 0 -# -# -# the beam is travelling along the z-axis -/gps/ang/rot1 0 1 0 -/gps/ang/rot2 1 0 0 -/gps/ang/type beam1d -# the beam angular dispersion -# N.A. is 0.22 so acceptance cone is ~25.4 degrees -/gps/ang/sigma_r 25.40 deg -# 1.0milliradians = 0.057 deg -# - -#if using these commands in interactive mode to visualize, use this to allow more events to be displayed (do not use in batch mode) -/vis/ogl/set/displayListLimit 1000000 diff --git a/runAndAnalyze.sh b/runAndAnalyze.sh deleted file mode 100644 index c8649e257942f2b6e5a2102e0d8e1fa92b3a243a..0000000000000000000000000000000000000000 --- a/runAndAnalyze.sh +++ /dev/null @@ -1,16 +0,0 @@ -#/bin/bash! - -cp run2.mac run3.mac - -echo "/lightGuide/surfaceSigmaAlpha 0.${1}" >> run3.mac -echo "/lightGuide/surfaceProperty SPECULARLOBECONSTANT 0.000002 .${2} 0.000008 0.${2}" >> run3.mac -echo "/lightGuide/surfaceProperty SPECULARSPIKECONSTANT 0.000002 0.${3} 0.000008 0.${3}" >> run3.mac -echo '/lightGuide/surfaceProperty BACKSCATTERCONSTANT 0.000002 .05 0.000008 .05' >> run3.mac -echo '/lightGuide/surfaceProperty REFLECTIVITY 0.000002 .99 0.000008 .99' >> run3.mac -echo '/run/beamOn 1000000 ' >> run3.mac - -#./lightGuide -c models/Winston_cone.stl stl -m run3.mac -o Winston_SA0-$1 -./lightGuide -m run3.mac -o SA0-$1 -./plotHisto SA0-$1 - -rm run3.mac diff --git a/src/DetectorConstruction.cc b/src/DetectorConstruction.cc index 44e3f7aaf9d2edef3f220fe9a89bba4e8fbc71ce..1514b46860ba9f63d25e33331b26673f29849af3 100644 --- a/src/DetectorConstruction.cc +++ b/src/DetectorConstruction.cc @@ -284,7 +284,6 @@ void DetectorConstruction::UseCADModel(G4String fileName){ if(m_logicLightGuide) delete m_logicLightGuide; if(m_physLightGuide) delete m_physLightGuide; - G4double lgHeight = 130*mm; G4String fileType = fileName.substr( fileName.last('.') + 1, fileName.size() - fileName.last('.')); #ifdef CADMESH diff --git a/src/Materials.cc b/src/Materials.cc index fd05c2d67b51c6181b3eeefa842c22c1cde6ce20..a54329bedcd2adb2c33dbcebaa4cf712d647a1df 100644 --- a/src/Materials.cc +++ b/src/Materials.cc @@ -62,10 +62,9 @@ void Materials::DefineOpticalProperties(void){ float grease_RI = 1.46; float clad_RI = 1.49; float core_RI = 1.6; - float tile_RI = 1.4585; //quartz optical properties - G4double quartz_RIND[nEntriesWLS], quartz_ABSL[nEntriesWLS],quartz_RFLT[nEntriesWLS],quartz_EFIC[nEntriesWLS], PhotonEnergy[nEntriesWLS]; + G4double quartz_RIND[50], quartz_ABSL[50],quartz_RFLT[50],quartz_EFIC[50], PhotonEnergy[50]; for(int i = 0; i < nEntriesWLS; i++){ PhotonEnergy[i] = 2.00*eV + i*0.03*eV; quartz_RIND[i] = 1.44221 + 5.9e-3*PhotonEnergy[i] + 6.71e-4*pow(PhotonEnergy[i],2) + 2.3e-5*pow(PhotonEnergy[i],3) + 2.745e-5*pow(PhotonEnergy[i],4); //Refractive Index @@ -86,18 +85,18 @@ void Materials::DefineOpticalProperties(void){ //Aluminium optical properties - G4double AllPhotonEnergies[nEntriesWLS] = {2.00*eV, 2.04*eV, 2.07*eV, 2.11*eV, 2.15*eV, 2.18*eV, 2.22*eV, 2.26*eV, 2.29*eV, + G4double AllPhotonEnergies[50] = {2.00*eV, 2.04*eV, 2.07*eV, 2.11*eV, 2.15*eV, 2.18*eV, 2.22*eV, 2.26*eV, 2.29*eV, 2.33*eV, 2.37*eV, 2.40*eV, 2.44*eV, 2.48*eV, 2.51*eV, 2.55*eV, 2.59*eV, 2.62*eV, 2.66*eV, 2.70*eV, 2.74*eV, 2.77*eV, 2.81*eV, 2.85*eV, 2.88*eV, 2.92*eV, 2.96*eV, 2.99*eV, 3.03*eV, 3.07*eV, 3.10*eV, 3.14*eV, 3.18*eV, 3.21*eV, 3.25*eV, 3.29*eV, 3.32*eV, 3.36*eV, 3.40*eV, 3.43*eV, 3.47*eV, 5.0*eV, 25.0*eV,100.0*eV, 1000.00*eV, 10000.0*eV, 25000.0*eV, 50000.0*eV, 250000.*eV, 1000000.*eV}; - G4double Al_refl[nEntriesWLS] = {0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, + G4double Al_refl[50] = {0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.79, 0.69, 0.49, 0.29, 0.19, 0.09}; //"Hard cut" - G4double Al_ABSL[nEntriesWLS] = {0.01*mm, 0.01*mm, 0.01*mm,0.01*mm, 0.01*mm, 0.01*mm,0.01*mm, 0.01*mm, 0.01*mm,0.01*mm, + G4double Al_ABSL[50] = {0.01*mm, 0.01*mm, 0.01*mm,0.01*mm, 0.01*mm, 0.01*mm,0.01*mm, 0.01*mm, 0.01*mm,0.01*mm, 0.01*mm, 0.01*mm, 0.01*mm,0.01*mm, 0.01*mm, 0.01*mm,0.01*mm, 0.01*mm, 0.01*mm,0.01*mm, 0.01*mm, 0.01*mm, 0.01*mm,0.01*mm, 0.01*mm, 0.01*mm,0.01*mm, 0.01*mm, 0.01*mm,0.01*mm, 0.01*mm, 0.01*mm, 0.01*mm,0.01*mm, 0.01*mm, 0.01*mm,0.01*mm, 0.01*mm, 0.01*mm,0.01*mm, @@ -109,7 +108,7 @@ void Materials::DefineOpticalProperties(void){ Al->SetMaterialPropertiesTable(MPT_Array.back()); //Air optical properties - G4double RefractiveIndexAir[nEntriesWLS]; + G4double RefractiveIndexAir[50]; for (int i = 0; i < nEntriesWLS; i++) RefractiveIndexAir[i] = 1.0;// MPT_Array.push_back(new G4MaterialPropertiesTable()); @@ -118,8 +117,8 @@ void Materials::DefineOpticalProperties(void){ //Polyethilene optical properties - G4double RefractiveIndexClad1[nEntriesWLS]; - G4double AbsClad[nEntriesWLS]; + G4double RefractiveIndexClad1[50]; + G4double AbsClad[50]; for (int i = 0; i < nEntriesWLS; i++){ RefractiveIndexClad1[i] = clad_RI;// AbsClad[i] = 20.0*m; @@ -131,14 +130,14 @@ void Materials::DefineOpticalProperties(void){ Polyethylene->SetMaterialPropertiesTable(MPT_Array.back()); //PMMA optical properties - G4double RefractiveIndexWLSfiber[nEntriesWLS]; + G4double RefractiveIndexWLSfiber[50]; for (int i = 0; i < nEntriesWLS; i++) RefractiveIndexWLSfiber[i] = core_RI; - G4double AbsWLSfiber[nEntriesWLS] = { 5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m, + G4double AbsWLSfiber[50] = { 5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m, 5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m, 5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,5.40*m,1.10*m, 1.10*m,1.10*m,1.10*m,1.10*m,1.10*m,1.10*m, 1.*mm, 1.*mm, 1.*mm, 1.*mm, 1.*mm, 1.*mm, 1.*mm, 1.*mm, 1.*mm, 1.*mm, 1.*mm, 1.*mm, 1.*mm, 1.*mm}; - G4double EmissionWLSfiber[nEntriesWLS] = {0.05, 0.10, 0.30, 0.50, 0.75, 1.00, 1.50, 1.85, 2.30, 2.75, + G4double EmissionWLSfiber[50] = {0.05, 0.10, 0.30, 0.50, 0.75, 1.00, 1.50, 1.85, 2.30, 2.75, 3.25, 3.80, 4.50, 5.20, 6.00, 7.00, 8.50, 9.50, 11.1, 12.4, 12.9, 13.0, 12.8, 12.3, 11.1, 11.0, 12.0, 11.0, 17.0, 16.9, 15.0, 9.00, 2.50, 1.00, 0.05, 0.00, 0.00, 0.00, 0.00, 0.00, @@ -152,7 +151,7 @@ void Materials::DefineOpticalProperties(void){ PMMA->SetMaterialPropertiesTable(MPT_Array.back()); //Grease (silicone) optical properties - G4double RefractiveIndexGrease[nEntriesWLS]; + G4double RefractiveIndexGrease[50]; for (int i = 0; i < nEntriesWLS; i++) RefractiveIndexGrease[i] = grease_RI; MPT_Array.push_back(new G4MaterialPropertiesTable()); @@ -181,7 +180,7 @@ void Materials::DefineOpticalProperties(void){ G4MaterialPropertiesTable* TileSurfaceProperty = new G4MaterialPropertiesTable(); TileSurfaceProperty->AddProperty("RINDEX",AllPhotonEnergies,quartz_RIND,nEntriesWLS); - //TileSurfaceProperty->AddProperty("REFLECTIVITY",AllPhotonEnergies,reflectivity,nEntriesWLS); + TileSurfaceProperty->AddProperty("REFLECTIVITY",AllPhotonEnergies,quartz_RFLT,nEntriesWLS); TileSurfaceProperty->AddProperty("EFFICIENCY",AllPhotonEnergies,quartz_EFIC,nEntriesWLS); TileSurface->SetMaterialPropertiesTable(TileSurfaceProperty); diff --git a/src/RunAction.cc b/src/RunAction.cc index 5063fa452047d40282a75b16c01c7409e6f43f92..5c1b4ced27bf6d9057643238d6fbdf25716257aa 100644 --- a/src/RunAction.cc +++ b/src/RunAction.cc @@ -44,9 +44,9 @@ * */ RunAction::RunAction(G4String fileName) - : G4UserRunAction(),ffileName(fileName), - fTimer(0){ + : G4UserRunAction(),fTimer(0){ fTimer = new G4Timer; + m_fileName = fileName; G4RunManager::GetRunManager()->SetPrintProgress(1); @@ -93,8 +93,8 @@ void RunAction::BeginOfRunAction(const G4Run* aRun){ auto analysisManager = G4AnalysisManager::Instance(); // Open an output file - if(ffileName == "") ffileName = "output"; - analysisManager->OpenFile(ffileName); + if(m_fileName == "") m_fileName = "output"; + analysisManager->OpenFile(m_fileName); } /* diff --git a/surface.mac b/surface.mac deleted file mode 100644 index ca2238214ceff431799d0c6a234984a81f96d9d6..0000000000000000000000000000000000000000 --- a/surface.mac +++ /dev/null @@ -1,39 +0,0 @@ -/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