diff --git a/Inputs/DetectorConfiguration/Microball.detector b/Inputs/DetectorConfiguration/Microball.detector index e3c409ff13c007a4386b72f2f5cfd1e588a03ffc..58e3e17d0ad1b068b4abcfe73c08bca00acf7c57 100644 --- a/Inputs/DetectorConfiguration/Microball.detector +++ b/Inputs/DetectorConfiguration/Microball.detector @@ -31,4 +31,4 @@ Microball DISABLE_CRYSTAL 46 DISABLE_CRYSTAL 47 DETECTOR_FLIP= 0 - + INCLUDE_CHAMBER= 1 diff --git a/Inputs/DetectorConfiguration/NeutronWall.detector b/Inputs/DetectorConfiguration/NeutronWall.detector index 97998a18d1c2d3d534367c2b63d4669334291195..e6f1d8a92883477bbc9f10f41f6bf3ba2128423d 100644 --- a/Inputs/DetectorConfiguration/NeutronWall.detector +++ b/Inputs/DetectorConfiguration/NeutronWall.detector @@ -17,7 +17,7 @@ Target % Rot= 16.61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NeutronWall - THETA= 30 + THETA= 0 PHI= 0 R= 4000 BARS= 25 diff --git a/Inputs/DetectorConfiguration/hira_8B.detector b/Inputs/DetectorConfiguration/hira_8B.detector deleted file mode 100644 index 0072f92cd6d4bf5d447639e6c8a0cb08fca4d274..0000000000000000000000000000000000000000 --- a/Inputs/DetectorConfiguration/hira_8B.detector +++ /dev/null @@ -1,166 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -GeneralTarget -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -Target - THICKNESS= 50 - ANGLE= 0 - RADIUS= 10 - MATERIAL= CH2 - X= 0 - Y= 0 - Z= 0 -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -HIRAArray -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%% Telescope0 %%%%%%% -HiraTelescope -A= 15.7798 -28.9553 599.987 -B= -38.9578 -64.0962 596.603 -C= -22.5367 -99.4995 593.194 -D= 32.175 -64.3485 596.579 -ThinSi_DE= 1 -ThickSi_E= 1 -CsI= 1 - -%%%%%%% Telescope1 %%%%%%% -HiraTelescope -A= 15.7798 86.0596 594.488 -B= -38.9578 50.9187 597.872 -C= -22.5367 15.5154 601.281 -D= 32.175 50.6664 597.896 -ThinSi_DE= 1 -ThickSi_E= 1 -CsI= 1 - -%%%%%%% Telescope2 %%%%%%% -HiraTelescope -A= 15.7798 -101.859 591.986 -B= -38.9578 -136.326 584.345 -C= -22.5367 -171.05 576.647 -D= 32.175 -136.574 584.29 -ThinSi_DE= 1 -ThickSi_E= 1 -CsI= 1 - -%%%%%%% Telescope3 %%%%%%% -HiraTelescope -A= 15.7798 157.868 579.569 -B= -38.9578 123.401 587.21 -C= -22.5367 88.6775 594.908 -D= 32.175 123.154 587.265 -ThinSi_DE= 1 -ThickSi_E= 1 -CsI= 1 - - -%%%%%%% Telescope4 %%%%%%% -HiraTelescope -A= 88.7838 28.6842 593.605 -B= 34.4542 -6.6192 600.275 -C= 50.7529 -42.1863 598.274 -D= 105.057 -6.87271 591.607 -ThinSi_DE= 1 -ThickSi_E= 1 -CsI= 1 - - -%%%%%%% Telescope5 %%%%%%% -HiraTelescope -A= 88.6648 -44.6512 592.635 -B= 33.8108 -79.6915 595.036 -C= 49.5813 -114.993 588.732 -D= 104.41 -79.9431 586.336 -ThinSi_DE= 1 -ThickSi_E= 1 -CsI= 1 - - -%%%%%%% Telescope6 %%%%%%% -HiraTelescope -A= 87.8127 101.592 585.696 -B= 34.0075 66.5517 596.637 -C= 50.8344 31.2498 598.938 -D= 104.614 66.3001 587.999 -ThinSi_DE= 1 -ThickSi_E= 1 -CsI= 1 - - -%%%%%%% Telescope7 %%%%%%% -HiraTelescope -A= -57.4594 28.6842 597.451 -B= -111.789 -6.6192 590.78 -C= -95.4903 -42.1863 592.781 -D= -41.1864 -6.87271 599.449 -ThinSi_DE= 1 -ThickSi_E= 1 -CsI= 1 - - -%%%%%%% Telescope8 %%%%%%% -HiraTelescope -A= -57.3404 -44.6512 596.481 -B= -111.146 -79.6915 585.54 -C= -94.3187 -114.993 583.239 -D= -40.5393 -79.9431 594.179 -ThinSi_DE= 1 -ThickSi_E= 1 -CsI= 1 - - -%%%%%%% Telescope9 %%%%%%% -HiraTelescope -A= -56.4884 101.592 589.542 -B= -111.342 66.5517 587.142 -C= -95.5718 31.2498 593.445 -D= -40.7435 66.3001 595.841 -ThinSi_DE= 1 -ThickSi_E= 1 -CsI= 1 - - -%%%%%%% Telescope10 %%%%%%% -HiraTelescope -A= 160.617 -7.99843 578.973 -B= 106.984 -43.236 590.124 -C= 122.392 -78.7367 584.045 -D= 176 -43.489 572.901 -ThinSi_DE= 1 -ThickSi_E= 1 -CsI= 1 - - -%%%%%%% Telescope11 %%%%%%% -HiraTelescope -A= 159.77 65.2598 575.575 -B= 107.18 30.0223 590.908 -C= 123.638 -5.47849 589.043 -D= 176.203 29.7692 573.715 -ThinSi_DE= 1 -ThickSi_E= 1 -CsI= 1 - - -%%%%%%% Telescope12 %%%%%%% -HiraTelescope -A= -129.995 -7.99843 586.608 -B= -182.585 -43.236 571.275 -C= -166.127 -78.7367 573.141 -D= -113.562 -43.489 588.468 -ThinSi_DE= 1 -ThickSi_E= 1 -CsI= 1 - - -%%%%%%% Telescope13 %%%%%%% -HiraTelescope -A= -129.148 65.2598 583.21 -B= -182.781 30.0223 572.059 -C= -167.373 -5.47849 578.138 -D= -113.765 29.7692 589.283 -ThinSi_DE= 1 -ThickSi_E= 1 -CsI= 1 - - diff --git a/Inputs/DetectorConfiguration/hira_exp.detector b/Inputs/DetectorConfiguration/hira_exp.detector index 8fa44a5a6be609eb93b7d69a02a5638a9eade86c..4bef23c21d940abc4a0440c5d3d030c84b33ec57 100644 --- a/Inputs/DetectorConfiguration/hira_exp.detector +++ b/Inputs/DetectorConfiguration/hira_exp.detector @@ -155,11 +155,12 @@ Microball DISABLE_CRYSTAL 51 DISABLE_CRYSTAL 52 DETECTOR_FLIP= 0 + INCLUDE_CHAMBER= 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -NeutronWall - THETA= 40 - PHI= 20 +%NeutronWall + THETA= 50 + PHI= 0 R= 4000 BARS= 25 VETOWALL= 1 diff --git a/Inputs/EventGenerator/proton.source b/Inputs/EventGenerator/proton.source index 763ff92847438477048018d8b83cb97642c5e805..6ef37709ff9cb4b076ddb5d30d9557ffe7584ab6 100644 --- a/Inputs/EventGenerator/proton.source +++ b/Inputs/EventGenerator/proton.source @@ -4,14 +4,14 @@ % Energy are given in MeV , Position in mm % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Isotropic - EnergyLow= 10 - EnergyHigh= 250 + EnergyLow= 30 + EnergyHigh= 30 HalfOpenAngleMin= 0 - HalfOpenAngleMax= 10 + HalfOpenAngleMax= 0 x0= 0 y0= 0 z0= 0 - Multiplicity= 5 + Multiplicity= 1 Particle= proton %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Supported particle type: proton, neutron, deuton, triton, He3 , alpha diff --git a/NPSimulation/Core/CMakeLists.txt b/NPSimulation/Core/CMakeLists.txt index 0e1c8623ae2e5ad91659940b0ce83357bfd26a6e..c952ba812956d6d907c3b132e294f6a743dbe06b 100644 --- a/NPSimulation/Core/CMakeLists.txt +++ b/NPSimulation/Core/CMakeLists.txt @@ -1,2 +1,2 @@ -add_library(NPSCore SHARED CalorimeterScorers.cc EventAction.cc EventGeneratorParticleDecay.cc ObsoleteGeneralScorers.cc PrimaryGeneratorAction.cc Target.cc Chamber.cc EventGeneratorBeam.cc EventGeneratorTwoBodyReaction.cc EventGeneratorpBUU.cc Particle.cc PrimaryGeneratorActionMessenger.cc NPSVDetector.cc DetectorConstruction.cc EventGeneratorGammaDecay.cc MaterialManager.cc ParticleStack.cc SiliconScorers.cc PhotoDiodeScorers.cc VEventGenerator.cc DetectorMessenger.cc EventGeneratorIsotropic.cc MyMagneticField.cc PhysicsList.cc SteppingVerbose.cc NPSDetectorFactory.cc RunAction.cc LocalIonIonInelasticPhysic.cc) +add_library(NPSCore SHARED CalorimeterScorers.cc EventAction.cc EventGeneratorParticleDecay.cc ObsoleteGeneralScorers.cc PrimaryGeneratorAction.cc Target.cc Chamber.cc EventGeneratorBeam.cc EventGeneratorTwoBodyReaction.cc EventGeneratorpBUU.cc Particle.cc PrimaryGeneratorActionMessenger.cc NPSVDetector.cc DetectorConstruction.cc EventGeneratorGammaDecay.cc MaterialManager.cc ParticleStack.cc SiliconScorers.cc PhotoDiodeScorers.cc VEventGenerator.cc DetectorMessenger.cc EventGeneratorIsotropic.cc MyMagneticField.cc PhysicsList.cc SteppingVerbose.cc NPSDetectorFactory.cc RunAction.cc NPIonIonInelasticPhysic.cc) target_link_libraries(NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPInitialConditions -lNPInteractionCoordinates) diff --git a/NPSimulation/Core/EventAction.cc b/NPSimulation/Core/EventAction.cc index 5e91c676d7b0956566209e1602c70ff0f1ad82d2..c780da73c1e317d6e1bc57687fcbc96b547a16f2 100644 --- a/NPSimulation/Core/EventAction.cc +++ b/NPSimulation/Core/EventAction.cc @@ -31,6 +31,7 @@ #include "EventAction.hh" #include "DetectorConstruction.hh" #include "RootOutput.h" +#include "ParticleStack.hh" #include<iostream> using namespace std; @@ -38,13 +39,13 @@ using namespace std; EventAction* EventAction::m_EventAction=0; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... EventAction::EventAction(){ - m_EventAction=this; - begin=clock(); - treated=0; - inter=0; - total=0; - mean_rate=0; - displayed=0; + m_EventAction=this; + begin=clock(); + treated=0; + inter=0; + total=0; + mean_rate=0; + displayed=0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -53,76 +54,76 @@ EventAction::~EventAction(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void EventAction::BeginOfEventAction(const G4Event* event){ - treated= event->GetEventID()+1; - ProgressDisplay(); + treated= event->GetEventID()+1; + ProgressDisplay(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void EventAction::EndOfEventAction(const G4Event* event){ - m_detector->ReadAllSensitive(event) ; - static TTree* tree = RootOutput::getInstance()->GetTree(); - tree->Fill(); - if(treated%10000==0){ - tree->AutoSave(); - RootOutput::getInstance()->GetFile()->SaveSelf(kTRUE); - } + m_detector->ReadAllSensitive(event) ; + static TTree* tree = RootOutput::getInstance()->GetTree(); + tree->Fill(); + if(treated%10000==0){ + tree->AutoSave(); + RootOutput::getInstance()->GetFile()->SaveSelf(kTRUE); + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void EventAction::SetDetector(DetectorConstruction* detector){ - m_detector = detector ; + m_detector = detector ; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void EventAction::ProgressDisplay(){ - if(treated==0){ - begin = clock() ; - return; - } - - end = clock(); - if((end-begin)>CLOCKS_PER_SEC||treated>=total ){ - displayed++; - long double elapsed =(long double) (end-begin)/CLOCKS_PER_SEC; - double event_rate = inter/elapsed; - mean_rate += (event_rate-mean_rate)/(displayed); - double percent = 100*treated/total; - double remain = (total-treated)/mean_rate; - - char* timer; - double check ; - check = 0; - if(remain>60) - check = asprintf(&timer,"%dmin",(int)(remain/60.)); - else - check = asprintf(&timer,"%ds",(int)(remain)); - - check++; + if(treated==0){ + begin = clock() ; + return; + } - static char star[]="*******"; - if(displayed%2==0) - sprintf(star,"*******"); - else - sprintf(star,"-------"); - - if(treated!=total && mean_rate >=0 && remain>=0 && displayed>1) - printf("\r \033[1;31m %s Progress: %.1f%% | Rate: %.1fk evt/s | Remain: %s %s\033[0m ", star,percent,mean_rate/1000.,timer,star); - - else if(mean_rate >=0 && remain>=0 && displayed>1){ - printf("\r \033[1;32m %s Progress: %.1f%% | Rate: %.1fk evt/s | Remain: %s %s\033[0m ", star,percent,mean_rate/1000.,timer,star); + end = clock(); + if((end-begin)>CLOCKS_PER_SEC||treated>=total ){ + displayed++; + long double elapsed =(long double) (end-begin)/CLOCKS_PER_SEC; + double event_rate = inter/elapsed; + mean_rate += (event_rate-mean_rate)/(displayed); + double percent = 100*treated/total; + double remain = (total-treated)/mean_rate; + + char* timer; + double check ; + check = 0; + if(remain>60) + check = asprintf(&timer,"%dmin",(int)(remain/60.)); + else + check = asprintf(&timer,"%ds",(int)(remain)); + + check++; + + static char star[]="*******"; + if(displayed%2==0) + sprintf(star,"*******"); + else + sprintf(star,"-------"); + + if(treated!=total && mean_rate >=0 && remain>=0 && displayed>1) + printf("\r \033[1;31m %s Progress: %.1f%% | Rate: %.1fk evt/s | Remain: %s %s\033[0m ", star,percent,mean_rate/1000.,timer,star); + + else if(mean_rate >=0 && remain>=0 && displayed>1){ + printf("\r \033[1;32m %s Progress: %.1f%% | Rate: %.1fk evt/s | Remain: %s %s\033[0m ", star,percent,mean_rate/1000.,timer,star); + } + fflush(stdout); + inter=0; + begin = clock() ; } - fflush(stdout); - inter=0; - begin = clock() ; - } - // treated++; - inter++; + // treated++; + inter++; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void EventAction::SetRunLength(int length){ - total = length; + total = length; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... EventAction* EventAction::GetInstance(){ - return m_EventAction; + return m_EventAction; } diff --git a/NPSimulation/Core/LocalIonIonInelasticPhysic.hh b/NPSimulation/Core/LocalIonIonInelasticPhysic.hh deleted file mode 100755 index 452bc9937af7439e2a9fd80626a6147c112de72b..0000000000000000000000000000000000000000 --- a/NPSimulation/Core/LocalIonIonInelasticPhysic.hh +++ /dev/null @@ -1,59 +0,0 @@ -// -// ******************************************************************** -// * 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. * -// ******************************************************************** -// -// This is the *BASIC* version of Hadrontherapy, a Geant4-based application -// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy -// -// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request -// the *COMPLETE* version of this program, together with its documentation; -// Hadrontherapy (both basic and full version) are supported by the Italian INFN -// Institute in the framework of the MC-INFN Group -// - -#ifndef LOCALIONINELASTICPHYSIC_H -#define LOCALIONIONINELASTICPHYSIC_H 1 - -#include "G4VPhysicsConstructor.hh" -#include "globals.hh" - -class LocalIonIonInelasticPhysic: public G4VPhysicsConstructor -{ - public: - LocalIonIonInelasticPhysic (const G4String& name = "local_ion_ion_inelastic"); - virtual ~LocalIonIonInelasticPhysic(); - - protected: - void ConstructParticle(){}; - void ConstructProcess(); -}; -#endif - - - - - - - - diff --git a/NPSimulation/Core/LocalIonIonInelasticPhysic.cc b/NPSimulation/Core/NPIonIonInelasticPhysic.cc similarity index 61% rename from NPSimulation/Core/LocalIonIonInelasticPhysic.cc rename to NPSimulation/Core/NPIonIonInelasticPhysic.cc index ff6d322b6a85bd28db48d6f583c5eb60a6243f2e..c1be69b9f548d8ae10d725e1a54f6fdaf9e25878 100755 --- a/NPSimulation/Core/LocalIonIonInelasticPhysic.cc +++ b/NPSimulation/Core/NPIonIonInelasticPhysic.cc @@ -1,32 +1,25 @@ -// -// ******************************************************************** -// * 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. * -// ******************************************************************** -// -// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request -// the *COMPLETE* version of this program, together with its documentation; -// Hadrontherapy (both basic and full version) are supported by the Italian INFN -// Institute in the framework of the MC-INFN Group +/***************************************************************************** + * Copyright (C) 2009-2016 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre MORFOUACE contact address: morfouac@nscl.msu.edu * + * * + * Creation Date : August 2016 * + * Last update : August 2016 * + *---------------------------------------------------------------------------* + * Decription: * + * Modular Physics list calling Geant4 reference list * + * * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ // // // In this class the models for ion-ion interactions at intermediate energies (0 - 1 GeV per nucleon) @@ -41,7 +34,7 @@ // suggest to use Binary or QMD. The Binary model is the default and at moment, you can swith beetween models decommenting // the line of code and recompiling -#include "LocalIonIonInelasticPhysic.hh" +#include "NPIonIonInelasticPhysic.hh" #include "G4SystemOfUnits.hh" #include "G4ParticleDefinition.hh" #include "G4ProcessManager.hh" @@ -50,19 +43,27 @@ #include "G4TripathiCrossSection.hh" #include "G4TripathiLightCrossSection.hh" #include "G4IonsShenCrossSection.hh" +#include "G4GlauberGribovCrossSection.hh" +#include "G4BGGNucleonElasticXS.hh" +// Elastic +#include "G4HadronElasticProcess.hh" +#include "G4ElasticHadrNucleusHE.hh" +#include "G4DiffuseElastic.hh" +#include "G4HadronElastic.hh" + +// Inelastic #include "G4ProtonInelasticProcess.hh" #include "G4DeuteronInelasticProcess.hh" #include "G4TritonInelasticProcess.hh" #include "G4AlphaInelasticProcess.hh" #include "G4BinaryLightIonReaction.hh" #include "G4QMDReaction.hh" -//#include "G4WilsonAbrasionModel.hh" #include "G4IonInelasticProcess.hh" #include "G4GeneralSpaceNNCrossSection.hh" ///////////////////////////////////////////////////////////////////////////// -LocalIonIonInelasticPhysic::LocalIonIonInelasticPhysic(const G4String& name): +NPIonIonInelasticPhysic::NPIonIonInelasticPhysic(const G4String& name): G4VPhysicsConstructor(name) { G4cout << G4endl @@ -71,11 +72,11 @@ G4VPhysicsConstructor(name) } ///////////////////////////////////////////////////////////////////////////// -LocalIonIonInelasticPhysic::~LocalIonIonInelasticPhysic() +NPIonIonInelasticPhysic::~NPIonIonInelasticPhysic() {} ///////////////////////////////////////////////////////////////////////////// -void LocalIonIonInelasticPhysic::ConstructProcess() +void NPIonIonInelasticPhysic::ConstructProcess() { G4ParticleDefinition* particle = 0; G4ProcessManager* processManager = 0; @@ -91,23 +92,45 @@ void LocalIonIonInelasticPhysic::ConstructProcess() ligthBinary -> SetMinEnergy(0*MeV); ligthBinary -> SetMaxEnergy(10*GeV); - /*G4WilsonAbrasionModel* WilsonModel = new G4WilsonAbrasionModel(); - WilsonModel -> SetUseAblation(true); - WilsonModel -> SetMinEnergy(0*MeV); - WilsonModel -> SetMaxEnergy(10 *GeV);*/ - G4TripathiCrossSection* TripatiCrossSections = new G4TripathiCrossSection; G4TripathiLightCrossSection* TripatiLightCrossSections = new G4TripathiLightCrossSection; G4IonsShenCrossSection* ShenCrossSections = new G4IonsShenCrossSection; + G4GlauberGribovCrossSection* GlauberGribovCrossSection = new G4GlauberGribovCrossSection; + // ****************** + // **** Elastic **** + // ****************** + particle = G4Proton::Proton(); + //G4ElasticHadrNucleusHE* hadronElasticModel = new G4ElasticHadrNucleusHE(); + //G4HadronElastic* hadronElasticModel1 = new G4HadronElastic(); + G4DiffuseElastic* hadronElasticModel2 = new G4DiffuseElastic(); + hadronElasticModel2->SetPlabLowLimit(0.1*MeV);//Default is 20 MeV + hadronElasticModel2->SetRecoilKinEnergyLimit(10*keV);//Default is 100 keV + hadronElasticModel2->SetLowestEnergyLimit(0.0*keV);//Default value is 0 keV + hadronElasticModel2->SetHEModelLowLimit(0.0*keV);//Default value is 0 keV + hadronElasticModel2->SetQModelLowLimit(0.0*keV);//Default value is 0 keV + + G4HadronElasticProcess* hadronElasticProcess = new G4HadronElasticProcess(); + + hadronElasticProcess->AddDataSet(GlauberGribovCrossSection); + hadronElasticProcess->AddDataSet( new G4BGGNucleonElasticXS(particle)); + + //hadronElasticProcess->RegisterMe(hadronElasticModel1); + hadronElasticProcess->RegisterMe(hadronElasticModel2); + + + processManager = particle -> GetProcessManager(); + processManager -> AddDiscreteProcess(hadronElasticProcess); + // **************** // **** Proton **** // **************** G4ProtonInelasticProcess* protonInelasticProcess = new G4ProtonInelasticProcess; - protonInelasticProcess -> AddDataSet(ShenCrossSections); - protonInelasticProcess -> AddDataSet(TripatiCrossSections); - protonInelasticProcess -> AddDataSet(TripatiLightCrossSections); + //protonInelasticProcess -> AddDataSet(ShenCrossSections); + //protonInelasticProcess -> AddDataSet(TripatiCrossSections); + //protonInelasticProcess -> AddDataSet(TripatiLightCrossSections); + protonInelasticProcess -> AddDataSet(GlauberGribovCrossSection); protonInelasticProcess -> RegisterMe(ligthBinary); //protonInelasticProcess -> RegisterMe(JQMDmodel); diff --git a/NPSimulation/Core/NPIonIonInelasticPhysic.hh b/NPSimulation/Core/NPIonIonInelasticPhysic.hh new file mode 100755 index 0000000000000000000000000000000000000000..611173f595194c2bfcfcc4724db55a501ba10302 --- /dev/null +++ b/NPSimulation/Core/NPIonIonInelasticPhysic.hh @@ -0,0 +1,50 @@ +/***************************************************************************** + * Copyright (C) 2009-2016 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre MORFOUACE contact address: morfouac@nscl.msu.edu * + * * + * Creation Date : August 2016 * + * Last update : August 2016 * + *---------------------------------------------------------------------------* + * Decription: * + * Modular Physics list calling Geant4 reference list * + * * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +// +// + +#ifndef NPIONINELASTICPHYSIC_H +#define NPIONIONINELASTICPHYSIC_H 1 + +#include "G4VPhysicsConstructor.hh" +#include "globals.hh" + +class NPIonIonInelasticPhysic: public G4VPhysicsConstructor +{ + public: + NPIonIonInelasticPhysic (const G4String& name = "npt_ion_ion_inelastic"); + virtual ~NPIonIonInelasticPhysic(); + + protected: + void ConstructParticle(){}; + void ConstructProcess(); +}; +#endif + + + + + + + + diff --git a/NPSimulation/Core/ParticleStack.cc b/NPSimulation/Core/ParticleStack.cc index 09c012db238298ccc6f24a705199e69049fcdda0..d432ceffed6fe0919654a2b8b361408165bc2400 100644 --- a/NPSimulation/Core/ParticleStack.cc +++ b/NPSimulation/Core/ParticleStack.cc @@ -35,237 +35,237 @@ ParticleStack* ParticleStack::instance = 0 ; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... ParticleStack* ParticleStack::getInstance(){ - if (instance == 0) instance = new ParticleStack(); - return instance ; + if (instance == 0) instance = new ParticleStack(); + return instance ; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... ParticleStack::ParticleStack(){ - - m_particleGun = new G4ParticleGun(1); - G4ParticleDefinition* particle - = G4ParticleTable::GetParticleTable()->FindParticle("proton"); - m_particleGun->SetParticleDefinition(particle); - m_particleGun->SetParticleEnergy(10*MeV); - - m_particleGun->SetParticlePosition(G4ThreeVector(0., 0., 0.)); - m_particleGun->SetParticleMomentumDirection(G4ThreeVector(0., 0., 1.)); - - // Instantiate the TInitialConditions object and link it to the RootOutput tree - m_InitialConditions = new TInitialConditions(); - RootOutput::getInstance()->GetTree()->Branch("InitialConditions","TInitialConditions",&m_InitialConditions); - - m_EventZero = true; - m_First=true; - + + m_particleGun = new G4ParticleGun(1); + G4ParticleDefinition* particle + = G4ParticleTable::GetParticleTable()->FindParticle("proton"); + m_particleGun->SetParticleDefinition(particle); + m_particleGun->SetParticleEnergy(10*MeV); + + m_particleGun->SetParticlePosition(G4ThreeVector(0., 0., 0.)); + m_particleGun->SetParticleMomentumDirection(G4ThreeVector(0., 0., 1.)); + + // Instantiate the TInitialConditions object and link it to the RootOutput tree + m_InitialConditions = new TInitialConditions(); + RootOutput::getInstance()->GetTree()->Branch("InitialConditions","TInitialConditions",&m_InitialConditions); + + m_EventZero = true; + m_First=true; + } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... ParticleStack::~ParticleStack(){ - + } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... vector<Particle> ParticleStack::GetParticleStack(){ - return m_ParticleStack; + return m_ParticleStack; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void ParticleStack::SetParticleStack(vector<Particle> particle_stack){ - m_ParticleStack = particle_stack; + m_ParticleStack = particle_stack; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void ParticleStack::AddParticleToStack(Particle& particle){ - - // If the particle is the first one to be added, then the IC are cleared - if(m_First) - m_InitialConditions->Clear(); - - m_ParticleStack.push_back(particle); - - m_First=false; + + // If the particle is the first one to be added, then the IC are cleared + if(m_First) + m_InitialConditions->Clear(); + + m_ParticleStack.push_back(particle); + + m_First=false; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void ParticleStack::AddBeamParticleToStack(Particle& particle){ - // If the particle is the first one to be added, then the IC are cleared - if(m_First) - m_InitialConditions->Clear(); - - m_ParticleStack.push_back(particle); - // Incident beam parameter - m_InitialConditions-> SetIncidentParticleName (particle.GetParticleDefinition()->GetParticleName()); - //m_InitialConditions-> SetIncidentInitialKineticEnergy (particle. GetParticleThetaCM()); + // If the particle is the first one to be added, then the IC are cleared + if(m_First) + m_InitialConditions->Clear(); + + m_ParticleStack.push_back(particle); + // Incident beam parameter + m_InitialConditions-> SetIncidentParticleName (particle.GetParticleDefinition()->GetParticleName()); + //m_InitialConditions-> SetIncidentInitialKineticEnergy (particle. GetParticleThetaCM()); m_InitialConditions-> SetIncidentInitialKineticEnergy (particle. GetParticleKineticEnergy()); - - G4ThreeVector U(1,0,0); - G4ThreeVector V(0,1,0); - - m_InitialConditions-> SetIncidentEmittanceThetaX (particle.GetParticleMomentumDirection().angle(U)/deg); - m_InitialConditions-> SetIncidentEmittancePhiY (particle.GetParticleMomentumDirection().angle(V)/deg); - m_InitialConditions-> SetIncidentEmittanceTheta (particle.GetParticleMomentumDirection().theta()/deg); - m_InitialConditions-> SetIncidentEmittancePhi (particle.GetParticleMomentumDirection().phi()/deg); - - // Beam status at the initial interaction point - m_InitialConditions-> SetIncidentFinalKineticEnergy (particle. GetParticleKineticEnergy()); - m_InitialConditions-> SetIncidentPositionX (particle. GetParticlePosition().x()); - m_InitialConditions-> SetIncidentPositionY (particle. GetParticlePosition().y()); - m_InitialConditions-> SetIncidentPositionZ (particle. GetParticlePosition().z()); - - - // The beam is not shoot most of the time, but the DEDx table are still usefull - if( m_EventZero && particle.GetParticleDefinition()->GetPDGCharge()!=0){ - MaterialManager::getInstance() + + G4ThreeVector U(1,0,0); + G4ThreeVector V(0,1,0); + + m_InitialConditions-> SetIncidentEmittanceThetaX (particle.GetParticleMomentumDirection().angle(U)/deg); + m_InitialConditions-> SetIncidentEmittancePhiY (particle.GetParticleMomentumDirection().angle(V)/deg); + m_InitialConditions-> SetIncidentEmittanceTheta (particle.GetParticleMomentumDirection().theta()/deg); + m_InitialConditions-> SetIncidentEmittancePhi (particle.GetParticleMomentumDirection().phi()/deg); + + // Beam status at the initial interaction point + m_InitialConditions-> SetIncidentFinalKineticEnergy (particle. GetParticleKineticEnergy()); + m_InitialConditions-> SetIncidentPositionX (particle. GetParticlePosition().x()); + m_InitialConditions-> SetIncidentPositionY (particle. GetParticlePosition().y()); + m_InitialConditions-> SetIncidentPositionZ (particle. GetParticlePosition().z()); + + + // The beam is not shoot most of the time, but the DEDx table are still usefull + if( m_EventZero && particle.GetParticleDefinition()->GetPDGCharge()!=0){ + MaterialManager::getInstance() ->WriteDEDXTable(particle.GetParticleDefinition(), 1e-3*eV,particle.GetParticleKineticEnergy()); - m_EventZero = false; + m_EventZero = false; } - - m_First=false; + + m_First=false; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... Particle ParticleStack::SearchAndRemoveParticle(string name){ - - unsigned int size = m_ParticleStack.size(); - - for(unsigned int i = 0 ; i < size ; i++){ - string ParticleName = m_ParticleStack[i].GetParticleDefinition()->GetParticleName(); - if(ParticleName.compare(0, name.length(), name) == 0){ - Particle my_Particule = m_ParticleStack[i]; - m_ParticleStack.erase(m_ParticleStack.begin()+i); - return my_Particule; + + unsigned int size = m_ParticleStack.size(); + + for(unsigned int i = 0 ; i < size ; i++){ + string ParticleName = m_ParticleStack[i].GetParticleDefinition()->GetParticleName(); + if(ParticleName.compare(0, name.length(), name) == 0){ + Particle my_Particule = m_ParticleStack[i]; + m_ParticleStack.erase(m_ParticleStack.begin()+i); + return my_Particule; + } } - } - - return Particle(); + + return Particle(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... string ParticleStack::ChangeNameToG4Standard(string OriginalName){ - string NumberOfMass ; - string Nucleid; - - for (unsigned int i = 0; i < OriginalName.length(); i++) { - ostringstream character; - character << OriginalName[i]; - if (character.str()=="0") NumberOfMass+="0"; - else if (character.str()=="1") NumberOfMass+="1"; - else if (character.str()=="2") NumberOfMass+="2"; - else if (character.str()=="3") NumberOfMass+="3"; - else if (character.str()=="4") NumberOfMass+="4"; - else if (character.str()=="5") NumberOfMass+="5"; - else if (character.str()=="6") NumberOfMass+="6"; - else if (character.str()=="7") NumberOfMass+="7"; - else if (character.str()=="8") NumberOfMass+="8"; - else if (character.str()=="9") NumberOfMass+="9"; + string NumberOfMass ; + string Nucleid; - else if (character.str()=="A") Nucleid+="A"; - else if (character.str()=="B") Nucleid+="B"; - else if (character.str()=="C") Nucleid+="C"; - else if (character.str()=="D") Nucleid+="D"; - else if (character.str()=="E") Nucleid+="E"; - else if (character.str()=="F") Nucleid+="F"; - else if (character.str()=="G") Nucleid+="G"; - else if (character.str()=="H") Nucleid+="H"; - else if (character.str()=="I") Nucleid+="I"; - else if (character.str()=="J") Nucleid+="J"; - else if (character.str()=="K") Nucleid+="K"; - else if (character.str()=="L") Nucleid+="L"; - else if (character.str()=="M") Nucleid+="M"; - else if (character.str()=="N") Nucleid+="N"; - else if (character.str()=="O") Nucleid+="O"; - else if (character.str()=="P") Nucleid+="P"; - else if (character.str()=="Q") Nucleid+="Q"; - else if (character.str()=="R") Nucleid+="R"; - else if (character.str()=="S") Nucleid+="S"; - else if (character.str()=="T") Nucleid+="T"; - else if (character.str()=="U") Nucleid+="U"; - else if (character.str()=="V") Nucleid+="V"; - else if (character.str()=="W") Nucleid+="W"; - else if (character.str()=="X") Nucleid+="X"; - else if (character.str()=="Y") Nucleid+="Y"; - else if (character.str()=="Z") Nucleid+="Z"; + for (unsigned int i = 0; i < OriginalName.length(); i++) { + ostringstream character; + character << OriginalName[i]; + if (character.str()=="0") NumberOfMass+="0"; + else if (character.str()=="1") NumberOfMass+="1"; + else if (character.str()=="2") NumberOfMass+="2"; + else if (character.str()=="3") NumberOfMass+="3"; + else if (character.str()=="4") NumberOfMass+="4"; + else if (character.str()=="5") NumberOfMass+="5"; + else if (character.str()=="6") NumberOfMass+="6"; + else if (character.str()=="7") NumberOfMass+="7"; + else if (character.str()=="8") NumberOfMass+="8"; + else if (character.str()=="9") NumberOfMass+="9"; + + else if (character.str()=="A") Nucleid+="A"; + else if (character.str()=="B") Nucleid+="B"; + else if (character.str()=="C") Nucleid+="C"; + else if (character.str()=="D") Nucleid+="D"; + else if (character.str()=="E") Nucleid+="E"; + else if (character.str()=="F") Nucleid+="F"; + else if (character.str()=="G") Nucleid+="G"; + else if (character.str()=="H") Nucleid+="H"; + else if (character.str()=="I") Nucleid+="I"; + else if (character.str()=="J") Nucleid+="J"; + else if (character.str()=="K") Nucleid+="K"; + else if (character.str()=="L") Nucleid+="L"; + else if (character.str()=="M") Nucleid+="M"; + else if (character.str()=="N") Nucleid+="N"; + else if (character.str()=="O") Nucleid+="O"; + else if (character.str()=="P") Nucleid+="P"; + else if (character.str()=="Q") Nucleid+="Q"; + else if (character.str()=="R") Nucleid+="R"; + else if (character.str()=="S") Nucleid+="S"; + else if (character.str()=="T") Nucleid+="T"; + else if (character.str()=="U") Nucleid+="U"; + else if (character.str()=="V") Nucleid+="V"; + else if (character.str()=="W") Nucleid+="W"; + else if (character.str()=="X") Nucleid+="X"; + else if (character.str()=="Y") Nucleid+="Y"; + else if (character.str()=="Z") Nucleid+="Z"; + + else if (character.str()=="a") Nucleid+="a"; + else if (character.str()=="b") Nucleid+="b"; + else if (character.str()=="c") Nucleid+="c"; + else if (character.str()=="d") Nucleid+="d"; + else if (character.str()=="e") Nucleid+="e"; + else if (character.str()=="f") Nucleid+="f"; + else if (character.str()=="g") Nucleid+="g"; + else if (character.str()=="h") Nucleid+="h"; + else if (character.str()=="i") Nucleid+="i"; + else if (character.str()=="j") Nucleid+="j"; + else if (character.str()=="k") Nucleid+="k"; + else if (character.str()=="l") Nucleid+="l"; + else if (character.str()=="m") Nucleid+="m"; + else if (character.str()=="n") Nucleid+="n"; + else if (character.str()=="o") Nucleid+="o"; + else if (character.str()=="p") Nucleid+="p"; + else if (character.str()=="q") Nucleid+="q"; + else if (character.str()=="r") Nucleid+="r"; + else if (character.str()=="s") Nucleid+="s"; + else if (character.str()=="t") Nucleid+="t"; + else if (character.str()=="u") Nucleid+="u"; + else if (character.str()=="v") Nucleid+="v"; + else if (character.str()=="w") Nucleid+="w"; + else if (character.str()=="x") Nucleid+="x"; + else if (character.str()=="y") Nucleid+="y"; + else if (character.str()=="z") Nucleid+="z"; + } - else if (character.str()=="a") Nucleid+="a"; - else if (character.str()=="b") Nucleid+="b"; - else if (character.str()=="c") Nucleid+="c"; - else if (character.str()=="d") Nucleid+="d"; - else if (character.str()=="e") Nucleid+="e"; - else if (character.str()=="f") Nucleid+="f"; - else if (character.str()=="g") Nucleid+="g"; - else if (character.str()=="h") Nucleid+="h"; - else if (character.str()=="i") Nucleid+="i"; - else if (character.str()=="j") Nucleid+="j"; - else if (character.str()=="k") Nucleid+="k"; - else if (character.str()=="l") Nucleid+="l"; - else if (character.str()=="m") Nucleid+="m"; - else if (character.str()=="n") Nucleid+="n"; - else if (character.str()=="o") Nucleid+="o"; - else if (character.str()=="p") Nucleid+="p"; - else if (character.str()=="q") Nucleid+="q"; - else if (character.str()=="r") Nucleid+="r"; - else if (character.str()=="s") Nucleid+="s"; - else if (character.str()=="t") Nucleid+="t"; - else if (character.str()=="u") Nucleid+="u"; - else if (character.str()=="v") Nucleid+="v"; - else if (character.str()=="w") Nucleid+="w"; - else if (character.str()=="x") Nucleid+="x"; - else if (character.str()=="y") Nucleid+="y"; - else if (character.str()=="z") Nucleid+="z"; - } - - // Special case for light particles - string FinalName=Nucleid+NumberOfMass; - if (FinalName=="H1") FinalName="proton"; -// else if (FinalName=="H2") FinalName="deuteron"; - else if (FinalName=="H3") FinalName="triton"; - else if (FinalName=="He4") FinalName="alpha"; - else if (FinalName=="p") FinalName="proton"; - else if (FinalName=="d") FinalName="deuteron"; - else if (FinalName=="t") FinalName="triton"; - else if (FinalName=="a") FinalName="alpha"; - else if (FinalName=="proton") FinalName="proton"; - else if (FinalName=="deuteron") FinalName="deuteron"; - else if (FinalName=="triton") FinalName="triton"; - else if (FinalName=="alpha") FinalName="alpha"; - else if (FinalName=="n") FinalName="neutron"; - else if (FinalName=="neutron") FinalName="neutron"; - return(FinalName); + // Special case for light particles + string FinalName=Nucleid+NumberOfMass; + if (FinalName=="H1") FinalName="proton"; + // else if (FinalName=="H2") FinalName="deuteron"; + else if (FinalName=="H3") FinalName="triton"; + else if (FinalName=="He4") FinalName="alpha"; + else if (FinalName=="p") FinalName="proton"; + else if (FinalName=="d") FinalName="deuteron"; + else if (FinalName=="t") FinalName="triton"; + else if (FinalName=="a") FinalName="alpha"; + else if (FinalName=="proton") FinalName="proton"; + else if (FinalName=="deuteron") FinalName="deuteron"; + else if (FinalName=="triton") FinalName="triton"; + else if (FinalName=="alpha") FinalName="alpha"; + else if (FinalName=="n") FinalName="neutron"; + else if (FinalName=="neutron") FinalName="neutron"; + return(FinalName); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void ParticleStack::ShootAllParticle(G4Event* anEvent){ - unsigned int size = m_ParticleStack.size(); - - for(unsigned int i = 0 ; i < size ; i++){ + unsigned int size = m_ParticleStack.size(); - if( m_ParticleStack[i].GetShootStatus()){ - // Write the DEDX table for charged particle and - // all material used in the simulation - if( anEvent->GetEventID()==0 - && G4RunManager::GetRunManager()->GetCurrentRun()->GetRunID()==0 - && m_ParticleStack[i].GetParticleDefinition()->GetPDGCharge()!=0){ - MaterialManager::getInstance() - ->WriteDEDXTable(m_ParticleStack[i].GetParticleDefinition(), - 1e-3*eV,m_ParticleStack[i].GetParticleKineticEnergy()); - } - - m_particleGun->SetParticleDefinition(m_ParticleStack[i].GetParticleDefinition()); - m_particleGun->SetParticleEnergy(m_ParticleStack[i].GetParticleKineticEnergy()); - m_particleGun->SetParticleMomentumDirection(m_ParticleStack[i].GetParticleMomentumDirection()); - m_particleGun->SetParticlePosition(m_ParticleStack[i].GetParticlePosition()); - m_particleGun->GeneratePrimaryVertex(anEvent); - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - m_InitialConditions-> SetParticleName ( m_ParticleStack[i].GetParticleDefinition()->GetParticleName()) ; - m_InitialConditions-> SetThetaCM ( m_ParticleStack[i].GetParticleThetaCM()/deg); - m_InitialConditions-> SetKineticEnergy ( m_ParticleStack[i].GetParticleKineticEnergy()); - m_InitialConditions-> SetMomentumDirectionX ( m_ParticleStack[i].GetParticleMomentumDirection().x()); - m_InitialConditions-> SetMomentumDirectionY ( m_ParticleStack[i].GetParticleMomentumDirection().y()); - m_InitialConditions-> SetMomentumDirectionZ ( m_ParticleStack[i].GetParticleMomentumDirection().z()); + for(unsigned int i = 0 ; i < size ; i++){ + + if( m_ParticleStack[i].GetShootStatus()){ + // Write the DEDX table for charged particle and + // all material used in the simulation + if( anEvent->GetEventID()==0 + && G4RunManager::GetRunManager()->GetCurrentRun()->GetRunID()==0 + && m_ParticleStack[i].GetParticleDefinition()->GetPDGCharge()!=0){ + MaterialManager::getInstance() + ->WriteDEDXTable(m_ParticleStack[i].GetParticleDefinition(), + 1e-3*eV,m_ParticleStack[i].GetParticleKineticEnergy()); + } + + m_particleGun->SetParticleDefinition(m_ParticleStack[i].GetParticleDefinition()); + m_particleGun->SetParticleEnergy(m_ParticleStack[i].GetParticleKineticEnergy()); + m_particleGun->SetParticleMomentumDirection(m_ParticleStack[i].GetParticleMomentumDirection()); + m_particleGun->SetParticlePosition(m_ParticleStack[i].GetParticlePosition()); + m_particleGun->GeneratePrimaryVertex(anEvent); + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + m_InitialConditions-> SetParticleName ( m_ParticleStack[i].GetParticleDefinition()->GetParticleName()) ; + m_InitialConditions-> SetThetaCM ( m_ParticleStack[i].GetParticleThetaCM()/deg); + m_InitialConditions-> SetKineticEnergy ( m_ParticleStack[i].GetParticleKineticEnergy()); + m_InitialConditions-> SetMomentumDirectionX ( m_ParticleStack[i].GetParticleMomentumDirection().x()); + m_InitialConditions-> SetMomentumDirectionY ( m_ParticleStack[i].GetParticleMomentumDirection().y()); + m_InitialConditions-> SetMomentumDirectionZ ( m_ParticleStack[i].GetParticleMomentumDirection().z()); + } } - } - m_ParticleStack.clear(); - m_First=true; + m_ParticleStack.clear(); + m_First=true; } diff --git a/NPSimulation/Core/ParticleStack.hh b/NPSimulation/Core/ParticleStack.hh index 89d39886ae97b27950f21fba27efcaf3a0257025..f7727bfe93b8824dbe06cab115c067e9d5f8713d 100644 --- a/NPSimulation/Core/ParticleStack.hh +++ b/NPSimulation/Core/ParticleStack.hh @@ -84,7 +84,7 @@ class ParticleStack{ public: // Getter and Setter vector<Particle> GetParticleStack(); void SetParticleStack(vector<Particle>); - G4ParticleGun GetParticleGun(); + G4ParticleGun* GetParticleGun() {return m_particleGun;}; public: // Particle management and shooting method // EventGenerator use this method to add particle in the stack diff --git a/NPSimulation/Core/PhysicsList.cc b/NPSimulation/Core/PhysicsList.cc index a3f5851e1c90222d835ab28fe7a76f72d5af7f77..c5747773da9e37bba034acc531bdd66e7c8d57d2 100644 --- a/NPSimulation/Core/PhysicsList.cc +++ b/NPSimulation/Core/PhysicsList.cc @@ -26,7 +26,7 @@ // Local physic directly implemented from the Hadronthrapy example // Physic dedicated to the ion-ion inelastic processes -#include "LocalIonIonInelasticPhysic.hh" +#include "NPIonIonInelasticPhysic.hh" // G4 #include "G4SystemOfUnits.hh" @@ -40,7 +40,7 @@ ///////////////////////////////////////////////////////////////////////////// PhysicsList::PhysicsList() : G4VModularPhysicsList(){ m_EmList = "Option4"; - defaultCutValue = 0.2*mm; + defaultCutValue = 0.01*mm;//0.2*mm; opticalPhysicsList = NULL; ReadConfiguration("PhysicsListOption.txt"); @@ -87,10 +87,12 @@ PhysicsList::PhysicsList() : G4VModularPhysicsList(){ if(m_HadronElasticPhysics){ //m_PhysList["G4HadronElasticPhysicsHP"]=new G4HadronElasticPhysicsHP(); m_PhysList["G4HadronElasticPhysics"]=new G4HadronElasticPhysics(); + //m_PhysList["HadronPhysicsFTFP_BERT"]=new G4HadronPhysicsQGSP_BERT(); + m_PhysList["G4IonElasticPhysics"]=new G4IonElasticPhysics(); } - if(m_LocalIonInelasticPhysics) - m_PhysList["LocalIonInelasticPhysics"]=new LocalIonIonInelasticPhysic(); + if(m_NPIonInelasticPhysics) + m_PhysList["NPIonInelasticPhysics"]=new NPIonIonInelasticPhysic(); if(m_StoppingPhysics) m_PhysList["StoppingPhysics"]=new G4StoppingPhysics(); @@ -140,7 +142,7 @@ void PhysicsList::ReadConfiguration(std::string filename){ m_IonBinaryCascadePhysics = 0; m_EmExtraPhysics = 0; m_HadronElasticPhysics = 0; - m_LocalIonInelasticPhysics = 0; + m_NPIonInelasticPhysics = 0; m_StoppingPhysics = 0; m_OpticalPhysics = 0; m_HadronPhysicsQGSP_BIC_HP = 0; @@ -166,8 +168,8 @@ void PhysicsList::ReadConfiguration(std::string filename){ defaultCutValue = value; else if(name == "IonBinaryCascadePhysics") m_IonBinaryCascadePhysics = value; - else if(name == "LocalIonInelasticPhysics") - m_LocalIonInelasticPhysics = value; + else if(name == "NPIonInelasticPhysics") + m_NPIonInelasticPhysics = value; else if (name == "EmExtraPhysics") m_EmExtraPhysics= value; else if (name == "HadronElasticPhysics") @@ -187,7 +189,7 @@ void PhysicsList::ReadConfiguration(std::string filename){ } // Most special process need decay to be activated - if( (m_IonBinaryCascadePhysics || m_EmExtraPhysics || m_HadronElasticPhysics || m_LocalIonInelasticPhysics + if( (m_IonBinaryCascadePhysics || m_EmExtraPhysics || m_HadronElasticPhysics || m_NPIonInelasticPhysics || m_StoppingPhysics || m_HadronPhysicsQGSP_BIC_HP || m_HadronPhysicsINCLXX) && !m_Decay){ m_Decay = true; std::cout << "Information: Selected process require Decay to be activated." << std::endl; diff --git a/NPSimulation/Core/PhysicsList.hh b/NPSimulation/Core/PhysicsList.hh index 08c898a376d6af581ee2c4338367ebf91f6cf54e..774ba38cc0b8fe251c3ae51778fd41fbac513dc4 100644 --- a/NPSimulation/Core/PhysicsList.hh +++ b/NPSimulation/Core/PhysicsList.hh @@ -55,6 +55,7 @@ //Hadronique #include "G4HadronElasticPhysics.hh" #include "G4HadronElasticPhysicsHP.hh" +#include "G4IonElasticPhysics.hh" #include "G4HadronDElasticPhysics.hh" #include "G4HadronInelasticQBBC.hh" #include "G4IonBinaryCascadePhysics.hh" @@ -64,6 +65,8 @@ #include "G4HadronPhysicsQGSP_BIC_HP.hh" #endif #include "G4HadronPhysicsQGSP_BIC.hh" +#include "G4HadronPhysicsQGSP_BERT.hh" + class G4VPhysicsConstructor; class PhysicsList: public G4VModularPhysicsList{ @@ -93,7 +96,7 @@ class PhysicsList: public G4VModularPhysicsList{ private: // Physics option std::string m_EmList; double m_IonBinaryCascadePhysics; - double m_LocalIonInelasticPhysics; + double m_NPIonInelasticPhysics; double m_EmExtraPhysics; double m_HadronElasticPhysics; double m_HadronInelasticPhysics; diff --git a/NPSimulation/Core/PrimaryGeneratorAction.cc b/NPSimulation/Core/PrimaryGeneratorAction.cc index a857be5a17059771749c109e98f61760c8f8b776..4501ea839eaa4186dd6440de78b9f06a4b21e1a2 100644 --- a/NPSimulation/Core/PrimaryGeneratorAction.cc +++ b/NPSimulation/Core/PrimaryGeneratorAction.cc @@ -47,35 +47,34 @@ #include "EventGeneratorGammaDecay.hh" #include "EventGeneratorParticleDecay.hh" - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* det): m_detector(det){ - m_Messenger = new PrimaryGeneratorActionMessenger(this); - m_GenerateEvent = &NPS::VEventGenerator::GenerateEvent; + m_Messenger = new PrimaryGeneratorActionMessenger(this); + m_GenerateEvent = &NPS::VEventGenerator::GenerateEvent; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... PrimaryGeneratorAction::~PrimaryGeneratorAction(){ - unsigned int mysize = m_EventGenerator.size(); - for (unsigned int i = 0 ; i < mysize; i++) { - delete m_EventGenerator[i]; - } - m_EventGenerator.clear(); + unsigned int mysize = m_EventGenerator.size(); + for (unsigned int i = 0 ; i < mysize; i++) { + delete m_EventGenerator[i]; + } + m_EventGenerator.clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent){ - // In case the target has changed - SetTarget(); - unsigned int mysize = m_EventGenerator.size(); - for (unsigned int i = 0 ; i < mysize; i++) { - //m_EventGenerator[i]->GenerateEvent(anEvent); - (m_EventGenerator[i]->*m_GenerateEvent)(anEvent); - } - - ParticleStack::getInstance()->ShootAllParticle(anEvent); - + // In case the target has changed + SetTarget(); + unsigned int mysize = m_EventGenerator.size(); + for (unsigned int i = 0 ; i < mysize; i++) { + //m_EventGenerator[i]->GenerateEvent(anEvent); + (m_EventGenerator[i]->*m_GenerateEvent)(anEvent); + } + + ParticleStack::getInstance()->ShootAllParticle(anEvent); + } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -84,130 +83,131 @@ void PrimaryGeneratorAction::ReadEventGeneratorFile(string Path){ bool check_pBUU = false; bool check_TwoBodyReaction = false; bool check_Beam = false; - - // You can have more than one of those - int alreadyiInstantiate_GammaDecay = 0; - int seenToken_GammaDecay = 0; - int alreadyiInstantiate_ParticleDecay = 0; - int seenToken_ParticleDecay = 0; - - if(NPOptionManager::getInstance()->GetVerboseLevel()==1) G4cout << "/////////////////////////////////////////////////// " << G4endl ; - - string LineBuffer; - ifstream EventGeneratorFile; - EventGeneratorFile.open(Path.c_str()); - - if (EventGeneratorFile.is_open()) { // should always be true - G4cout << "Event Generator file " << Path << " loading " << G4endl ; - } - else { - G4cout << "Error, Event Generator file " << Path << " found" << G4endl; - } - - while (!EventGeneratorFile.eof()) { - //Pick-up next line - getline(EventGeneratorFile, LineBuffer); - - //Search for comment Symbol % - if (LineBuffer.compare(0, 1, "%") == 0) { /*do nothing*/ - ; + + // You can have more than one of those + int alreadyiInstantiate_GammaDecay = 0; + int seenToken_GammaDecay = 0; + int alreadyiInstantiate_ParticleDecay = 0; + int seenToken_ParticleDecay = 0; + + if(NPOptionManager::getInstance()->GetVerboseLevel()==1) G4cout << "/////////////////////////////////////////////////// " << G4endl ; + + string LineBuffer; + ifstream EventGeneratorFile; + EventGeneratorFile.open(Path.c_str()); + + if (EventGeneratorFile.is_open()) { // should always be true + G4cout << "Event Generator file " << Path << " loading " << G4endl ; } - - //Search for Isotropic source - else if (LineBuffer.compare(0, 9, "Isotropic") == 0 && !check_Isotropic) { - check_Isotropic = true; - NPS::VEventGenerator* myEventGenerator = new EventGeneratorIsotropic(); - EventGeneratorFile.close(); - myEventGenerator->ReadConfiguration(Path); - EventGeneratorFile.open(Path.c_str()); - myEventGenerator->InitializeRootOutput(); - m_EventGenerator.push_back(myEventGenerator); + else { + G4cout << "Error, Event Generator file " << Path << " found" << G4endl; } - - //Search for pBUU source - else if (LineBuffer.compare(0, 4, "pBUU") == 0 && !check_pBUU) { - check_pBUU = true; - NPS::VEventGenerator* myEventGenerator = new EventGeneratorpBUU(); - EventGeneratorFile.close(); - myEventGenerator->ReadConfiguration(Path); - EventGeneratorFile.open(Path.c_str()); - myEventGenerator->InitializeRootOutput(); - m_EventGenerator.push_back(myEventGenerator); + + while (!EventGeneratorFile.eof()) { + //Pick-up next line + getline(EventGeneratorFile, LineBuffer); + + //Search for comment Symbol % + if (LineBuffer.compare(0, 1, "%") == 0) { /*do nothing*/ + ; + } + + //Search for Isotropic source + else if (LineBuffer.compare(0, 9, "Isotropic") == 0 && !check_Isotropic) { + check_Isotropic = true; + NPS::VEventGenerator* myEventGenerator = new EventGeneratorIsotropic(); + EventGeneratorFile.close(); + myEventGenerator->ReadConfiguration(Path); + EventGeneratorFile.open(Path.c_str()); + myEventGenerator->InitializeRootOutput(); + m_EventGenerator.push_back(myEventGenerator); + } + + //Search for pBUU source + else if (LineBuffer.compare(0, 4, "pBUU") == 0 && !check_pBUU) { + check_pBUU = true; + NPS::VEventGenerator* myEventGenerator = new EventGeneratorpBUU(); + EventGeneratorFile.close(); + myEventGenerator->ReadConfiguration(Path); + EventGeneratorFile.open(Path.c_str()); + myEventGenerator->InitializeRootOutput(); + m_EventGenerator.push_back(myEventGenerator); + } + + //Search for Beam + else if (LineBuffer.compare(0, 4, "Beam") == 0 && !check_Beam) { + check_Beam = true; + NPS::VEventGenerator* myEventGenerator = new EventGeneratorBeam(); + EventGeneratorFile.close(); + myEventGenerator->ReadConfiguration(Path); + EventGeneratorFile.open(Path.c_str()); + myEventGenerator->InitializeRootOutput(); + myEventGenerator->SetTarget(m_detector->GetTarget()); + m_EventGenerator.push_back(myEventGenerator); + } + + //Search for Two body reaction + else if (LineBuffer.compare(0, 15, "TwoBodyReaction") == 0 && !check_TwoBodyReaction) { + check_TwoBodyReaction = true; + NPS::VEventGenerator* myEventGenerator = new EventGeneratorTwoBodyReaction(); + EventGeneratorFile.close(); + myEventGenerator->ReadConfiguration(Path); + EventGeneratorFile.open(Path.c_str()); + myEventGenerator->InitializeRootOutput(); + myEventGenerator->SetTarget(m_detector->GetTarget()); + m_EventGenerator.push_back(myEventGenerator); + } + + //Search for GammaDecay + else if ( LineBuffer.compare(0, 10, "GammaDecay") == 0 ) { + seenToken_GammaDecay++; + if (seenToken_GammaDecay>alreadyiInstantiate_GammaDecay) { + alreadyiInstantiate_GammaDecay++; + NPS::VEventGenerator* myEventGenerator = new EventGeneratorGammaDecay(); + EventGeneratorFile.close(); + myEventGenerator->ReadConfiguration(Path,alreadyiInstantiate_GammaDecay); + EventGeneratorFile.open(Path.c_str()); + myEventGenerator->InitializeRootOutput(); + myEventGenerator->SetTarget(m_detector->GetTarget()); + m_EventGenerator.push_back(myEventGenerator); + seenToken_GammaDecay=0; + } + + } + + //Search for ParticleDecay + else if ( LineBuffer.compare(0, 13, "ParticleDecay") == 0 ) { + seenToken_ParticleDecay++; + if(seenToken_ParticleDecay>alreadyiInstantiate_ParticleDecay){ + alreadyiInstantiate_ParticleDecay++; + NPS::VEventGenerator* myEventGenerator = new EventGeneratorParticleDecay(); + EventGeneratorFile.close(); + myEventGenerator->ReadConfiguration(Path,alreadyiInstantiate_ParticleDecay); + EventGeneratorFile.open(Path.c_str()); + myEventGenerator->InitializeRootOutput(); + myEventGenerator->SetTarget(m_detector->GetTarget()); + m_EventGenerator.push_back(myEventGenerator); + seenToken_ParticleDecay=0; + } + } } - - //Search for Beam - else if (LineBuffer.compare(0, 4, "Beam") == 0 && !check_Beam) { - check_Beam = true; - NPS::VEventGenerator* myEventGenerator = new EventGeneratorBeam(); - EventGeneratorFile.close(); - myEventGenerator->ReadConfiguration(Path); - EventGeneratorFile.open(Path.c_str()); - myEventGenerator->InitializeRootOutput(); - myEventGenerator->SetTarget(m_detector->GetTarget()); - m_EventGenerator.push_back(myEventGenerator); - } - - //Search for Two body reaction - else if (LineBuffer.compare(0, 15, "TwoBodyReaction") == 0 && !check_TwoBodyReaction) { - check_TwoBodyReaction = true; - NPS::VEventGenerator* myEventGenerator = new EventGeneratorTwoBodyReaction(); - EventGeneratorFile.close(); - myEventGenerator->ReadConfiguration(Path); - EventGeneratorFile.open(Path.c_str()); - myEventGenerator->InitializeRootOutput(); - myEventGenerator->SetTarget(m_detector->GetTarget()); - m_EventGenerator.push_back(myEventGenerator); - } - - //Search for GammaDecay - else if ( LineBuffer.compare(0, 10, "GammaDecay") == 0 ) { - seenToken_GammaDecay++; - if (seenToken_GammaDecay>alreadyiInstantiate_GammaDecay) { - alreadyiInstantiate_GammaDecay++; - NPS::VEventGenerator* myEventGenerator = new EventGeneratorGammaDecay(); - EventGeneratorFile.close(); - myEventGenerator->ReadConfiguration(Path,alreadyiInstantiate_GammaDecay); - EventGeneratorFile.open(Path.c_str()); - myEventGenerator->InitializeRootOutput(); - myEventGenerator->SetTarget(m_detector->GetTarget()); - m_EventGenerator.push_back(myEventGenerator); - seenToken_GammaDecay=0; - } - - } - - //Search for ParticleDecay - else if ( LineBuffer.compare(0, 13, "ParticleDecay") == 0 ) { - seenToken_ParticleDecay++; - if(seenToken_ParticleDecay>alreadyiInstantiate_ParticleDecay){ - alreadyiInstantiate_ParticleDecay++; - NPS::VEventGenerator* myEventGenerator = new EventGeneratorParticleDecay(); - EventGeneratorFile.close(); - myEventGenerator->ReadConfiguration(Path,alreadyiInstantiate_ParticleDecay); - EventGeneratorFile.open(Path.c_str()); - myEventGenerator->InitializeRootOutput(); - myEventGenerator->SetTarget(m_detector->GetTarget()); - m_EventGenerator.push_back(myEventGenerator); - seenToken_ParticleDecay=0; - } - } - } - - EventGeneratorFile.close(); + + EventGeneratorFile.close(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void PrimaryGeneratorAction::ClearEventGenerator(){ - unsigned int mysize = m_EventGenerator.size(); - for (unsigned int i = 0 ; i < mysize; i++) { - delete m_EventGenerator[i]; - } - - m_EventGenerator.clear(); - + unsigned int mysize = m_EventGenerator.size(); + for (unsigned int i = 0 ; i < mysize; i++) { + delete m_EventGenerator[i]; + } + + m_EventGenerator.clear(); + } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void PrimaryGeneratorAction::SetTarget(){ - for (unsigned int i = 0 ; i < m_EventGenerator.size(); i++) { - m_EventGenerator[i]->SetTarget(m_detector->GetTarget()); - } + for (unsigned int i = 0 ; i < m_EventGenerator.size(); i++) { + m_EventGenerator[i]->SetTarget(m_detector->GetTarget()); + } } + diff --git a/NPSimulation/Core/PrimaryGeneratorAction.hh b/NPSimulation/Core/PrimaryGeneratorAction.hh index 6ca3cae854b9503d349f2be70a3d4d636aeb6085..fb2600c857023b131babcfcdf5d52612274e25c8 100644 --- a/NPSimulation/Core/PrimaryGeneratorAction.hh +++ b/NPSimulation/Core/PrimaryGeneratorAction.hh @@ -62,6 +62,7 @@ class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction{ DetectorConstruction* m_detector; vector<NPS::VEventGenerator*> m_EventGenerator; PrimaryGeneratorActionMessenger* m_Messenger; + }; #endif diff --git a/NPSimulation/Core/RunAction.cc b/NPSimulation/Core/RunAction.cc index dcc6b8381f46ffe28028c3a2c9795ce905ffde20..42179050c1188551021b387a27f715d6c0010321 100644 --- a/NPSimulation/Core/RunAction.cc +++ b/NPSimulation/Core/RunAction.cc @@ -23,6 +23,7 @@ #include "RunAction.hh" #include "PrimaryGeneratorAction.hh" #include "EventAction.hh" +#include "ParticleStack.hh" // G4 #include "G4Run.hh" #include "G4RunManager.hh" @@ -30,7 +31,7 @@ #include "RootOutput.h" //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... RunAction::RunAction(): G4UserRunAction(){ - RootOutput::getInstance()->GetTree()->Branch("Run",&m_RunNumber,"Run/I"); + RootOutput::getInstance()->GetTree()->Branch("Run",&m_RunNumber,"Run/I"); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -38,16 +39,16 @@ RunAction::~RunAction(){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void RunAction::BeginOfRunAction(const G4Run* aRun){ - m_RunNumber = aRun->GetRunID()+1; - - //initialize event cumulative quantities - EventAction::GetInstance()->SetRunLength(aRun->GetNumberOfEventToBeProcessed()); +void RunAction::BeginOfRunAction(const G4Run* aRun){ + m_RunNumber = aRun->GetRunID()+1; + + //initialize event cumulative quantities + EventAction::GetInstance()->SetRunLength(aRun->GetNumberOfEventToBeProcessed()); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void RunAction::EndOfRunAction(const G4Run*){ - // Pass a line for nicer presentation when chainning event generator - cout << endl; + // Pass a line for nicer presentation when chainning event generator + cout << endl; } diff --git a/NPSimulation/Core/RunAction.hh b/NPSimulation/Core/RunAction.hh index d92ee95070ef869b2f1dce4d32e8527f5d3bec09..863f9da2d4b7f533f5e105d1995cfd07e4f22bc9 100644 --- a/NPSimulation/Core/RunAction.hh +++ b/NPSimulation/Core/RunAction.hh @@ -21,8 +21,8 @@ * * * * *****************************************************************************/ -// G4 headers +// G4 headers #include "G4UserRunAction.hh" #include "globals.hh" diff --git a/NPSimulation/Detectors/Hira/Hira.cc b/NPSimulation/Detectors/Hira/Hira.cc index ea0b1d6f8213ee9938693877bf8bd4f7586bba2b..8f15c2bf8e473358d275a0d94f6539d853075675 100644 --- a/NPSimulation/Detectors/Hira/Hira.cc +++ b/NPSimulation/Detectors/Hira/Hira.cc @@ -29,7 +29,7 @@ #include "G4Trap.hh" #include "G4Tubs.hh" #include "G4Cons.hh" -#include "G4UnionSolid.hh" +#include "G4UnionSolid.hh" #include "G4ExtrudedSolid.hh" #include "G4TwoVector.hh" //G4 sensitive @@ -65,9 +65,9 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... Hira::Hira(){ - InitializeMaterial(); - m_EventHira = new THiraData(); - + InitializeMaterial(); + m_EventHira = new THiraData(); + // Silicon m_SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.28, 0.3, 0.95)) ; m_SiliconVisAtt2 = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ; @@ -268,7 +268,7 @@ void Hira::ReadConfiguration(string Path){ //Add The previously define telescope //With position method - if (check_A && check_B && check_C && check_D && check_ThickSi && check_ThickSi && check_CsI) { + if (check_A && check_B && check_C && check_D && check_ThinSi && check_ThickSi && check_CsI) { ReadingStatus = false ; check_A = false ; @@ -314,27 +314,27 @@ void Hira::ReadConfiguration(string Path){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void Hira::AddTelescope(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4){ - G4ThreeVector Pos=(Pos1+Pos2+Pos3+Pos4)/4.; - G4ThreeVector u = Pos4-Pos2; - G4ThreeVector w = Pos.unit(); - G4ThreeVector v = w.cross(u); - u = u.unit(); v = v.unit(); w = w.unit(); - Pos = Pos + w*Length*0.5; - - m_Type.push_back(1); - m_Pos.push_back(Pos); - m_Rot.push_back(new G4RotationMatrix(u,v,w)); + G4ThreeVector Pos=(Pos1+Pos2+Pos3+Pos4)/4.; + G4ThreeVector u = Pos4-Pos2; + G4ThreeVector w = Pos.unit(); + G4ThreeVector v = w.cross(u); + u = u.unit(); v = v.unit(); w = w.unit(); + Pos = Pos + w*Length*0.5; + + m_Type.push_back(1); + m_Pos.push_back(Pos); + m_Rot.push_back(new G4RotationMatrix(u,v,w)); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method void Hira::ConstructDetector(G4LogicalVolume* world){ - unsigned int mysize = m_Pos.size(); - - for(unsigned int i = 0 ; i < mysize ; i++){ - VolumeMaker(i + 1, m_Pos[i], m_Rot[i], world); - } + unsigned int mysize = m_Pos.size(); + + for(unsigned int i = 0 ; i < mysize ; i++){ + VolumeMaker(i + 1, m_Pos[i], m_Rot[i], world); + } } @@ -372,7 +372,7 @@ void Hira::ReadSensitive(const G4Event* event){ // Clear Map for next event ThinSiHitMap->clear(); } - + // ThickSi // if(m_build_ThickSi){ G4THitsMap<G4double*>* ThickSiHitMap; @@ -412,7 +412,7 @@ void Hira::ReadSensitive(const G4Event* event){ // Clear Map for next event ThickSiHitMap->clear(); } - + // CsI // if(m_build_CsI){ G4THitsMap<G4double*>* CsIHitMap; @@ -438,53 +438,53 @@ void Hira::ReadSensitive(const G4Event* event){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void Hira::InitializeScorers(){ - //Look for previous definition of the scorer (geometry reload) - bool already_exist = false; - vector<G4int> NestingLevel; - NestingLevel.push_back(0); - NestingLevel.push_back(2); - - m_ThinSiStripScorer = CheckScorer("Hira_ThinSiScorer",already_exist); - m_ThickSiStripScorer = CheckScorer("Hira_ThickSiScorer",already_exist); - m_CsIScorer = CheckScorer("Hira_CsIScorer",already_exist); - - // if the scorer were created previously nothing else need to be made - if(already_exist) return; - - G4VPrimitiveScorer* ThinSiScorer = new SILICONSCORERS::PS_Silicon_Rectangle("ThinSi",0, - SiliconFace, - SiliconFace, - NumberOfStrip, - 1); - - m_ThinSiStripScorer->RegisterPrimitive(ThinSiScorer); - - G4VPrimitiveScorer* ThickSiScorer = new SILICONSCORERS::PS_Silicon_Rectangle("ThickSi",0, - SiliconFace, - SiliconFace, - NumberOfStrip, - NumberOfStrip); - - m_ThickSiStripScorer->RegisterPrimitive(ThickSiScorer); - - G4VPrimitiveScorer* CsIScorer= new CALORIMETERSCORERS::PS_Calorimeter("CsI",NestingLevel); - - m_CsIScorer->RegisterPrimitive(CsIScorer); - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_ThinSiStripScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_ThickSiStripScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_CsIScorer) ; + //Look for previous definition of the scorer (geometry reload) + bool already_exist = false; + vector<G4int> NestingLevel; + NestingLevel.push_back(0); + NestingLevel.push_back(2); + + m_ThinSiStripScorer = CheckScorer("Hira_ThinSiScorer",already_exist); + m_ThickSiStripScorer = CheckScorer("Hira_ThickSiScorer",already_exist); + m_CsIScorer = CheckScorer("Hira_CsIScorer",already_exist); + + // if the scorer were created previously nothing else need to be made + if(already_exist) return; + + G4VPrimitiveScorer* ThinSiScorer = new SILICONSCORERS::PS_Silicon_Rectangle("ThinSi",0, + SiliconFace, + SiliconFace, + NumberOfStrip, + 1); + + m_ThinSiStripScorer->RegisterPrimitive(ThinSiScorer); + + G4VPrimitiveScorer* ThickSiScorer = new SILICONSCORERS::PS_Silicon_Rectangle("ThickSi",0, + SiliconFace, + SiliconFace, + NumberOfStrip, + NumberOfStrip); + + m_ThickSiStripScorer->RegisterPrimitive(ThickSiScorer); + + G4VPrimitiveScorer* CsIScorer= new CALORIMETERSCORERS::PS_Calorimeter("CsI",NestingLevel); + + m_CsIScorer->RegisterPrimitive(CsIScorer); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThinSiStripScorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThickSiStripScorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_CsIScorer) ; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void Hira::InitializeRootOutput(){ - TTree *pTree = RootOutput::getInstance()->GetTree(); - pTree->Branch("Hira", "THiraData", &m_EventHira) ; - - // This insure that the object are correctly bind in case of - // a redifinition of the geometry in the simulation - pTree->SetBranchAddress("Hira", &m_EventHira) ; + TTree *pTree = RootOutput::getInstance()->GetTree(); + pTree->Branch("Hira", "THiraData", &m_EventHira) ; + + // This insure that the object are correctly bind in case of + // a redifinition of the geometry in the simulation + pTree->SetBranchAddress("Hira", &m_EventHira) ; } @@ -494,77 +494,77 @@ void Hira::VolumeMaker(G4int DetectorNumber, G4RotationMatrix* MMrot, G4LogicalVolume* world) { - G4double NbrTelescopes = DetectorNumber ; - G4String DetNumber ; + G4double NbrTelescopes = DetectorNumber ; + G4String DetNumber ; ostringstream Number ; - Number << NbrTelescopes ; + Number << NbrTelescopes ; DetNumber = Number.str() ; - - - //////////////////////////////////////////////////////////////// + + + //////////////////////////////////////////////////////////////// ////////////// Starting Volume Definition ////////////////////// //////////////////////////////////////////////////////////////// G4String Name = "Hira" + DetNumber ; - + // Definition of the volume containing the sensitive detector G4Box* solidMotherVolume = new G4Box(Name, 0.5*FaceFront, 0.5*FaceBack, 0.5*Length); m_logicMotherVolume = new G4LogicalVolume(solidMotherVolume, m_MaterialVacuum, Name, 0, 0, 0); - + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), m_logicMotherVolume, Name, world, false, DetectorNumber); - + G4VisAttributes* MotherVolumeVisAtt = new G4VisAttributes(G4Colour(0.90, 0.90, 0.90)); - MotherVolumeVisAtt->SetForceWireframe(true); + MotherVolumeVisAtt->SetForceWireframe(true); m_logicMotherVolume->SetVisAttributes(G4VisAttributes::Invisible); - - /////////////////////////////////////////////////// - ///////////////////// Thin Si ///////////////////// - /////////////////////////////////////////////////// - G4String NameThinSi = "ThinSi"+DetNumber; - //if(!m_LogicThinSi){ - if(m_build_ThinSi){ - G4Box* solidThinSi = new G4Box(NameThinSi, 0.5*SiliconFace, 0.5*SiliconFace, 0.5*ThinSiThickness); ; - m_LogicThinSi = new G4LogicalVolume(solidThinSi, m_MaterialSilicon, "logicThinSi", 0, 0, 0); - - G4ThreeVector positionThinSi = G4ThreeVector(0, 0, ThinSi_PosZ); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - positionThinSi, - m_LogicThinSi,"ThinSi", - m_logicMotherVolume,false,DetectorNumber); - - // Set ThinSi sensible - m_LogicThinSi->SetSensitiveDetector(m_ThinSiStripScorer); - - // Visualisation of ThinSi - m_LogicThinSi->SetVisAttributes(m_SiliconVisAtt) ; - } - - /////////////////////////////////////////////////// - ///////////////////// Thick Si //////////////////// - /////////////////////////////////////////////////// - G4String NameThickSi = "ThickSi"+DetNumber; - //if(!m_LogicThickSi){ - if(m_build_ThickSi){ - G4Box* solidThickSi = new G4Box(NameThickSi, 0.5*SiliconFace, 0.5*SiliconFace, 0.5*ThickSiThickness); - m_LogicThickSi = new G4LogicalVolume(solidThickSi, m_MaterialSilicon, "logicThickSi", 0, 0, 0); - - G4ThreeVector positionThickSi = G4ThreeVector(0, 0, ThickSi_PosZ); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - positionThickSi, - m_LogicThickSi,"ThickSi", - m_logicMotherVolume,false,DetectorNumber); - - // Set ThickSi sensible - m_LogicThickSi->SetSensitiveDetector(m_ThickSiStripScorer); - - // Visualisation of ThickSi - m_LogicThickSi->SetVisAttributes(m_SiliconVisAtt2) ; - } - - /////////////////////////////////////////////////// - /////////////////////// CsI /////////////////////// - /////////////////////////////////////////////////// + + /////////////////////////////////////////////////// + ///////////////////// Thin Si ///////////////////// + /////////////////////////////////////////////////// + G4String NameThinSi = "ThinSi"+DetNumber; + //if(!m_LogicThinSi){ + if(m_build_ThinSi){ + G4Box* solidThinSi = new G4Box(NameThinSi, 0.5*SiliconFace, 0.5*SiliconFace, 0.5*ThinSiThickness); ; + m_LogicThinSi = new G4LogicalVolume(solidThinSi, m_MaterialSilicon, "logicThinSi", 0, 0, 0); + + G4ThreeVector positionThinSi = G4ThreeVector(0, 0, ThinSi_PosZ); + + new G4PVPlacement(new G4RotationMatrix(0,0,0), + positionThinSi, + m_LogicThinSi,"ThinSi", + m_logicMotherVolume,false,DetectorNumber); + + // Set ThinSi sensible + m_LogicThinSi->SetSensitiveDetector(m_ThinSiStripScorer); + + // Visualisation of ThinSi + m_LogicThinSi->SetVisAttributes(m_SiliconVisAtt) ; + } + + /////////////////////////////////////////////////// + ///////////////////// Thick Si //////////////////// + /////////////////////////////////////////////////// + G4String NameThickSi = "ThickSi"+DetNumber; + //if(!m_LogicThickSi){ + if(m_build_ThickSi){ + G4Box* solidThickSi = new G4Box(NameThickSi, 0.5*SiliconFace, 0.5*SiliconFace, 0.5*ThickSiThickness); + m_LogicThickSi = new G4LogicalVolume(solidThickSi, m_MaterialSilicon, "logicThickSi", 0, 0, 0); + + G4ThreeVector positionThickSi = G4ThreeVector(0, 0, ThickSi_PosZ); + + new G4PVPlacement(new G4RotationMatrix(0,0,0), + positionThickSi, + m_LogicThickSi,"ThickSi", + m_logicMotherVolume,false,DetectorNumber); + + // Set ThickSi sensible + m_LogicThickSi->SetSensitiveDetector(m_ThickSiStripScorer); + + // Visualisation of ThickSi + m_LogicThickSi->SetVisAttributes(m_SiliconVisAtt2) ; + } + + /////////////////////////////////////////////////// + /////////////////////// CsI /////////////////////// + /////////////////////////////////////////////////// G4String NameCsI = "CsI"+DetNumber; double X1 = (CsIXFront-CsIXBack)/2.; @@ -584,33 +584,33 @@ void Hira::VolumeMaker(G4int DetectorNumber, double pAlp2 = 0; G4Trap* solidCsIStage = new G4Trap(NameCsI, pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2); - + m_LogicCsICrystal = new G4LogicalVolume(solidCsIStage, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); - - // Set CsI sensible + + // Set CsI sensible m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); - // Visualisation of CsI + // Visualisation of CsI m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); - - //if(!m_LogicCluster){ - if(m_build_CsI){ - // Sub Mother Volume - G4Trd* solidCluster = new G4Trd("SolidCluster", 0.5*ClusterFaceFront,0.5*ClusterFaceBack,0.5*ClusterFaceFront,0.5*ClusterFaceBack, 0.5*CsIThickness); - m_LogicCluster = new G4LogicalVolume(solidCluster, m_MaterialVacuum, "LogicSolidCluster", 0, 0, 0); + + //if(!m_LogicCluster){ + if(m_build_CsI){ + // Sub Mother Volume + G4Trd* solidCluster = new G4Trd("SolidCluster", 0.5*ClusterFaceFront,0.5*ClusterFaceBack,0.5*ClusterFaceFront,0.5*ClusterFaceBack, 0.5*CsIThickness); + m_LogicCluster = new G4LogicalVolume(solidCluster, m_MaterialVacuum, "LogicSolidCluster", 0, 0, 0); m_LogicCluster->SetVisAttributes(G4VisAttributes::Invisible); G4VisAttributes* TempVisAtt = new G4VisAttributes(G4Colour(0.415686, 0.352941, 0.803922, 0.1)) ; TempVisAtt->SetForceWireframe(true); m_LogicCluster->SetVisAttributes(TempVisAtt); - + G4ThreeVector FramePos(0,0,CsI_PosZ); - + new G4PVPlacement(new G4RotationMatrix(0,0,0), - FramePos, - m_LogicCluster,"Cluster", - m_logicMotherVolume,false,0); - + FramePos, + m_LogicCluster,"Cluster", + m_logicMotherVolume,false,0); + //double alpha = atan((CsIXBack-CsIXFront)/CsIThickness); //double dl = (CsIThickness/2)*tan(alpha); double dl = (CsIXBack-CsIXFront)/4; @@ -624,32 +624,32 @@ void Hira::VolumeMaker(G4int DetectorNumber, const G4double dangle = 90.*deg; // A cluster is a 2 by 2 aggregat of CsI crystal unsigned int CsINbr = 1; - for(unsigned int i = 0 ; i < 2 ; i++){ - for(unsigned int j = 0 ; j < 2 ; j++){ - G4RotationMatrix* rotM = new G4RotationMatrix; - unsigned int CrystalNbr = CsINbr++; - if(i==0 && j==0)rotM->rotateZ(0); - if(i==1 && j==0)rotM->rotateZ(dangle); - if(i==0 && j==1)rotM->rotateZ(-dangle); - if(i==1 && j==1)rotM->rotateZ(2*dangle); - - if(i==0 && j==0) Pos = Origin; - if(i==1 && j==0) Pos = G4ThreeVector((DistInterCsIX),-(DistInterCsIY),0); - if(i==0 && j==1) Pos = G4ThreeVector(-(DistInterCsIX),(DistInterCsIY),0); - if(i==1 && j==1) Pos = G4ThreeVector((DistInterCsIX),(DistInterCsIY),0); - //Pos = Origin + G4ThreeVector(i*(DistInterCsIX),j*(DistInterCsIY),0); - - new G4PVPlacement(G4Transform3D(*rotM,Pos), - m_LogicCsICrystal, - "CsI_Cristal", - m_LogicCluster, - false, - CrystalNbr,true); - delete rotM; - } + for(unsigned int i = 0 ; i < 2 ; i++){ + for(unsigned int j = 0 ; j < 2 ; j++){ + G4RotationMatrix* rotM = new G4RotationMatrix; + unsigned int CrystalNbr = CsINbr++; + if(i==0 && j==0)rotM->rotateZ(0); + if(i==1 && j==0)rotM->rotateZ(dangle); + if(i==0 && j==1)rotM->rotateZ(-dangle); + if(i==1 && j==1)rotM->rotateZ(2*dangle); + + if(i==0 && j==0) Pos = Origin; + if(i==1 && j==0) Pos = G4ThreeVector((DistInterCsIX),-(DistInterCsIY),0); + if(i==0 && j==1) Pos = G4ThreeVector(-(DistInterCsIX),(DistInterCsIY),0); + if(i==1 && j==1) Pos = G4ThreeVector((DistInterCsIX),(DistInterCsIY),0); + //Pos = Origin + G4ThreeVector(i*(DistInterCsIX),j*(DistInterCsIY),0); + + new G4PVPlacement(G4Transform3D(*rotM,Pos), + m_LogicCsICrystal, + "CsI_Cristal", + m_LogicCluster, + false, + CrystalNbr,true); + delete rotM; } } } +} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/NPSimulation/Detectors/Hira/Hira.hh b/NPSimulation/Detectors/Hira/Hira.hh index 3e4b2a6ad2cc81cf7bc950f2b6a82707fb6bb5a8..181d7c7542cdb3270a6e7e773635108887e6ce07 100644 --- a/NPSimulation/Detectors/Hira/Hira.hh +++ b/NPSimulation/Detectors/Hira/Hira.hh @@ -45,27 +45,27 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... namespace HIRA { - - // Resolution + + // Resolution const G4double ResoTime = 0.212765957; // = 500ps // Unit is ns/2.35 const G4double ResoCsI = 0.200/2.35; // = 250 kev of resolution // Unit is MeV/2.35 const G4double ResoThickSi = 0.065/2.35; // = 120keV of Resolution // Unit is MeV/2.35 const G4double ResoThinSi = 0.050/2.35; // = 80keV of Resolution // Unit is MeV/2.35 - + const G4double EnergyThreshold = 0.;//100*keV; - - const G4double FaceFront = 10.*cm ; - const G4double FaceBack = 10*cm ; + + const G4double FaceFront = 10.*cm ; + const G4double FaceBack = 10*cm ; const G4double Length = 15.*cm ; const G4int NumberOfStrip = 32; - + const G4double SiliconFace = 63*mm ; - const G4double AluStripThickness = 0.4*micrometer ; + const G4double AluStripThickness = 0.4*micrometer ; const G4double ThinSiThickness = 65*micrometer ; - const G4double ThickSiThickness = 1500*micrometer ; + const G4double ThickSiThickness = 1500*micrometer ; const G4double DistBetweenSi = 17.04*mm; const G4double VacBoxThickness = 17.04*mm ; - const G4double MylarCsIThickness = 3*micrometer; + const G4double MylarCsIThickness = 3*micrometer; const G4double CsIThickness = 10.*cm;// + 2*MylarCsIThickness ; const G4double CsIXFront = 34.93*mm; @@ -74,156 +74,156 @@ namespace HIRA const G4double CsIYBack = 44.62*mm;//39.*mm const G4double DistInterCsI = 0.05*mm; - const G4double ClusterFaceFront = 2*CsIXFront+2*DistInterCsI; - const G4double ClusterFaceBack = 2*CsIXBack+2*DistInterCsI; - - // Starting at the front and going to CsI - const G4double AluStripFrontThinSi_PosZ = Length* -0.5 + 0.5*AluStripThickness; - const G4double ThinSi_PosZ = AluStripFrontThinSi_PosZ + 0.5*AluStripThickness + 0.5*ThinSiThickness; - const G4double AluStripBackThinSi_PosZ = ThinSi_PosZ + 0.5*ThinSiThickness + 0.5*AluStripThickness; - - const G4double AluStripFrontThickSi_PosZ = AluStripBackThinSi_PosZ + DistBetweenSi + 0.5*AluStripThickness + 0.5*AluStripThickness; - const G4double ThickSi_PosZ = AluStripFrontThickSi_PosZ + 0.5*AluStripThickness + 0.5*ThickSiThickness; - const G4double AluStripBackThickSi_PosZ = ThickSi_PosZ + 0.5*ThickSiThickness + 0.5*AluStripThickness; - - const G4double VacBox_PosZ = AluStripBackThickSi_PosZ + 0.5*AluStripThickness + 0.5* VacBoxThickness; - const G4double CsI_PosZ = VacBox_PosZ + 0.5*VacBoxThickness + 0.5*CsIThickness; - - - - + const G4double ClusterFaceFront = 2*CsIXFront+2*DistInterCsI; + const G4double ClusterFaceBack = 2*CsIXBack+2*DistInterCsI; + + // Starting at the front and going to CsI + const G4double AluStripFrontThinSi_PosZ = Length* -0.5 + 0.5*AluStripThickness; + const G4double ThinSi_PosZ = AluStripFrontThinSi_PosZ + 0.5*AluStripThickness + 0.5*ThinSiThickness; + const G4double AluStripBackThinSi_PosZ = ThinSi_PosZ + 0.5*ThinSiThickness + 0.5*AluStripThickness; + + const G4double AluStripFrontThickSi_PosZ = AluStripBackThinSi_PosZ + DistBetweenSi + 0.5*AluStripThickness + 0.5*AluStripThickness; + const G4double ThickSi_PosZ = AluStripFrontThickSi_PosZ + 0.5*AluStripThickness + 0.5*ThickSiThickness; + const G4double AluStripBackThickSi_PosZ = ThickSi_PosZ + 0.5*ThickSiThickness + 0.5*AluStripThickness; + + const G4double VacBox_PosZ = AluStripBackThickSi_PosZ + 0.5*AluStripThickness + 0.5* VacBoxThickness; + const G4double CsI_PosZ = VacBox_PosZ + 0.5*VacBoxThickness + 0.5*CsIThickness; + + + + } using namespace HIRA ; class Hira : public NPS::VDetector { - //////////////////////////////////////////////////// - /////// Default Constructor and Destructor ///////// - //////////////////////////////////////////////////// + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// public: - Hira() ; - ~Hira() ; - - //////////////////////////////////////////////////// - //////// Specific Function of this Class /////////// - //////////////////////////////////////////////////// + Hira() ; + ~Hira() ; + + //////////////////////////////////////////////////// + //////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// public: - // By Position Method - void AddTelescope( G4ThreeVector Pos1 , - G4ThreeVector Pos2 , - G4ThreeVector Pos3 , - G4ThreeVector Pos4 ); - - // Effectively construct Volume - // Avoid to have two time same code for Angle and Point definition - void VolumeMaker( G4int DetectorNumber , - G4ThreeVector MMpos , - G4RotationMatrix* MMrot , - G4LogicalVolume* world ); - - + // By Position Method + void AddTelescope( G4ThreeVector Pos1 , + G4ThreeVector Pos2 , + G4ThreeVector Pos3 , + G4ThreeVector Pos4 ); + + // Effectively construct Volume + // Avoid to have two time same code for Angle and Point definition + void VolumeMaker( G4int DetectorNumber , + G4ThreeVector MMpos , + G4RotationMatrix* MMrot , + G4LogicalVolume* world ); + + private: bool m_build_ThinSi; bool m_build_ThickSi; bool m_build_CsI; - G4LogicalVolume* m_LogicThinSi; - G4LogicalVolume* m_LogicThickSi; - G4LogicalVolume* m_LogicCsICrystal; - G4LogicalVolume* m_LogicCluster; - G4LogicalVolume* m_logicMotherVolume; - //////////////////////////////////////////////////// - //////// Specific Function of this Class /////////// - //////////////////////////////////////////////////// - - - //////////////////////////////////////////////////// - ///////// Inherite from VDetector class /////////// - //////////////////////////////////////////////////// + G4LogicalVolume* m_LogicThinSi; + G4LogicalVolume* m_LogicThickSi; + G4LogicalVolume* m_LogicCsICrystal; + G4LogicalVolume* m_LogicCluster; + G4LogicalVolume* m_logicMotherVolume; + //////////////////////////////////////////////////// + //////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// + + + //////////////////////////////////////////////////// + ///////// Inherite from VDetector class /////////// + //////////////////////////////////////////////////// public: - // Read stream at Configfile to pick-up parameters of detector (Position,...) - // Called in DetecorConstruction::ReadDetextorConfiguration Method - void ReadConfiguration(string Path) ; - - // Construct detector and inialise sensitive part. - // Called After DetecorConstruction::AddDetector Method - void ConstructDetector(G4LogicalVolume* world) ; - - // Add Detector branch to the EventTree. - // Called After DetecorConstruction::AddDetector Method - void InitializeRootOutput() ; - - // Read sensitive part and fill the Root tree. - // Called at in the EventAction::EndOfEventAvtion - void ReadSensitive(const G4Event* event) ; - - //////////////////////////////////////////////////// - ///////////Event class to store Data//////////////// - //////////////////////////////////////////////////// + // Read stream at Configfile to pick-up parameters of detector (Position,...) + // Called in DetecorConstruction::ReadDetextorConfiguration Method + void ReadConfiguration(string Path) ; + + // Construct detector and inialise sensitive part. + // Called After DetecorConstruction::AddDetector Method + void ConstructDetector(G4LogicalVolume* world) ; + + // Add Detector branch to the EventTree. + // Called After DetecorConstruction::AddDetector Method + void InitializeRootOutput() ; + + // Read sensitive part and fill the Root tree. + // Called at in the EventAction::EndOfEventAvtion + void ReadSensitive(const G4Event* event) ; + + //////////////////////////////////////////////////// + ///////////Event class to store Data//////////////// + //////////////////////////////////////////////////// private: - THiraData* m_EventHira ; - - //////////////////////////////////////////////////// - ///////////////// Scorer Related /////////////////// - //////////////////////////////////////////////////// - + THiraData* m_EventHira ; + + //////////////////////////////////////////////////// + ///////////////// Scorer Related /////////////////// + //////////////////////////////////////////////////// + private: - // Initialize all Scorer - void InitializeScorers() ; - - // Silicon Associate Scorer - G4MultiFunctionalDetector* m_ThinSiStripScorer ; - G4MultiFunctionalDetector* m_ThickSiStripScorer ; - - // CsI Associate Scorer + // Initialize all Scorer + void InitializeScorers() ; + + // Silicon Associate Scorer + G4MultiFunctionalDetector* m_ThinSiStripScorer ; + G4MultiFunctionalDetector* m_ThickSiStripScorer ; + + // CsI Associate Scorer G4MultiFunctionalDetector* m_CsIScorer ; - + private: - // Initialize material used in detector definition - void InitializeMaterial(); - - // List of material - // Si - G4Material* m_MaterialSilicon; - // Al - G4Material* m_MaterialAluminium; - // CsI - G4Material* m_MaterialCsI; - // Vacuum - G4Material* m_MaterialVacuum ; - // Mylar - G4Material* m_MaterialMylar; - // PCB - G4Material* m_MaterialPCB; - - //////////////////////////////////////////////////// - ///////////////Private intern Data////////////////// - //////////////////////////////////////////////////// + // Initialize material used in detector definition + void InitializeMaterial(); + + // List of material + // Si + G4Material* m_MaterialSilicon; + // Al + G4Material* m_MaterialAluminium; + // CsI + G4Material* m_MaterialCsI; + // Vacuum + G4Material* m_MaterialVacuum ; + // Mylar + G4Material* m_MaterialMylar; + // PCB + G4Material* m_MaterialPCB; + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// private: - - // True if the detector is a Cluster, false if a single Phoswich - vector<bool> m_Type; - - // Detector position - vector<G4ThreeVector> m_Pos; - vector<G4RotationMatrix*> m_Rot; - - - // Used for "By Point Definition" - //vector<G4ThreeVector> m_TL ; // Top Left Corner Position Vector - //vector<G4ThreeVector> m_BL ; // Bottom Left Corner Position Vector - //vector<G4ThreeVector> m_BR ; // Bottom Right Corner Position Vector - //vector<G4ThreeVector> m_TR ; // Center Corner Position Vector - - // Used for "By Angle Definition" - //vector<G4double> m_R ; // | - //vector<G4double> m_Theta ; // > Spherical coordinate of Strips Silicium Plate - //vector<G4double> m_Phi ; // | - - vector<G4double> m_beta_u ; // | - vector<G4double> m_beta_v ; // >Tilt angle of the Telescope - vector<G4double> m_beta_w ; // | - - + + // True if the detector is a Cluster, false if a single Phoswich + vector<bool> m_Type; + + // Detector position + vector<G4ThreeVector> m_Pos; + vector<G4RotationMatrix*> m_Rot; + + + // Used for "By Point Definition" + //vector<G4ThreeVector> m_TL ; // Top Left Corner Position Vector + //vector<G4ThreeVector> m_BL ; // Bottom Left Corner Position Vector + //vector<G4ThreeVector> m_BR ; // Bottom Right Corner Position Vector + //vector<G4ThreeVector> m_TR ; // Center Corner Position Vector + + // Used for "By Angle Definition" + //vector<G4double> m_R ; // | + //vector<G4double> m_Theta ; // > Spherical coordinate of Strips Silicium Plate + //vector<G4double> m_Phi ; // | + + vector<G4double> m_beta_u ; // | + vector<G4double> m_beta_v ; // >Tilt angle of the Telescope + vector<G4double> m_beta_w ; // | + + private:/// Visualisation Attribute: G4VisAttributes* m_SiliconVisAtt ; G4VisAttributes* m_SiliconVisAtt2 ; @@ -231,6 +231,6 @@ private:/// Visualisation Attribute: public: static NPS::VDetector* Construct(); - + }; #endif diff --git a/NPSimulation/Detectors/Microball/Microball.cc b/NPSimulation/Detectors/Microball/Microball.cc index 5b446967454a6b90e916a473ae82ade4e79f0f19..16deb596c80f325e3b57f9bd94c5e9a6ffe68c6c 100644 --- a/NPSimulation/Detectors/Microball/Microball.cc +++ b/NPSimulation/Detectors/Microball/Microball.cc @@ -31,6 +31,8 @@ #include "G4Trap.hh" #include "G4Cons.hh" #include "G4Orb.hh" +#include "G4Sphere.hh" +#include "G4Ellipsoid.hh" #include "G4Trd.hh" #include "G4UnionSolid.hh" #include "G4SubtractionSolid.hh" @@ -64,79 +66,80 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... namespace Microball_NS{ - // Energy and time Resolution - const double EnergyThreshold = 0.1*MeV; - const double ResoTime = 4.5*ns ; - const double ResoEnergy = 5.0*MeV ; - const double Radius = 50*mm ; - const double Width = 100*mm ; - const double Thickness = 300*mm ; - const string Scintillator = "BC400"; + // Energy and time Resolution + const double EnergyThreshold = 0.1*MeV; + const double ResoTime = 8.49*ns ; + const double ResoEnergy = 0.102*MeV ; + const double Radius = 50*mm ; + const double Width = 100*mm ; + const double Thickness = 300*mm ; + const string Scintillator = "BC400"; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Microball Specific Method Microball::Microball(){ - m_Event = new TMicroballData() ; - m_MicroballScorer = 0; - m_SquareDetector = 0; - m_CylindricalDetector = 0; - - - // RGB Color + Transparency - m_VisSquare = new G4VisAttributes(G4Colour(0, 1, 0, 0.5)); - m_VisCylinder = new G4VisAttributes(G4Colour(0, 0, 1, 0.5)); - + m_Event = new TMicroballData() ; + m_MicroballScorer = 0; + m_SquareDetector = 0; + m_CylindricalDetector = 0; + + + // RGB Color + Transparency + m_VisSquare = new G4VisAttributes(G4Colour(0, 1, 0, 0.5)); + m_VisCylinder = new G4VisAttributes(G4Colour(0, 0, 1, 0.5)); + } Microball::~Microball(){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Microball::AddMicroball(bool bR1, bool bR2, bool bR3, - bool bR4, bool bR5, bool bR6, - bool bR7, bool bR8, bool bR9, - vector<int> copyNumArray, bool bFlip){ - m_Ring1 = bR1; - m_Ring2 = bR2; - m_Ring3 = bR3; - m_Ring4 = bR4; - m_Ring5 = bR5; - m_Ring6 = bR6; - m_Ring7 = bR7; - m_Ring8 = bR8; - m_Ring9 = bR9; - m_Array = copyNumArray; - m_Flip = bFlip; +void Microball::AddMicroball(bool bR1, bool bR2, bool bR3, + bool bR4, bool bR5, bool bR6, + bool bR7, bool bR8, bool bR9, + vector<int> copyNumArray, bool bFlip, bool bChamber){ + m_Ring1 = bR1; + m_Ring2 = bR2; + m_Ring3 = bR3; + m_Ring4 = bR4; + m_Ring5 = bR5; + m_Ring6 = bR6; + m_Ring7 = bR7; + m_Ring8 = bR8; + m_Ring9 = bR9; + m_Array = copyNumArray; + m_Flip = bFlip; + m_Chamber = bChamber; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4LogicalVolume* Microball::BuildSquareDetector(){ - if(!m_SquareDetector){ - G4Box* box = new G4Box("Microball_Box",Microball_NS::Width*0.5, - Microball_NS::Width*0.5,Microball_NS::Thickness*0.5); - - G4Material* ScintMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Microball_NS::Scintillator); - m_SquareDetector = new G4LogicalVolume(box,ScintMaterial,"logic_Microball_Box",0,0,0); - m_SquareDetector->SetVisAttributes(m_VisSquare); - m_SquareDetector->SetSensitiveDetector(m_MicroballScorer); - } - return m_SquareDetector; + if(!m_SquareDetector){ + G4Box* box = new G4Box("Microball_Box",Microball_NS::Width*0.5, + Microball_NS::Width*0.5,Microball_NS::Thickness*0.5); + + G4Material* ScintMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Microball_NS::Scintillator); + m_SquareDetector = new G4LogicalVolume(box,ScintMaterial,"logic_Microball_Box",0,0,0); + m_SquareDetector->SetVisAttributes(m_VisSquare); + m_SquareDetector->SetSensitiveDetector(m_MicroballScorer); + } + return m_SquareDetector; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4LogicalVolume* Microball::BuildCylindricalDetector(){ - if(!m_CylindricalDetector){ - G4Tubs* tub = new G4Tubs("Microball_Cyl",0,Microball_NS::Radius,Microball_NS::Thickness*0.5,0,360*deg); - - G4Material* ScintMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Microball_NS::Scintillator); - m_CylindricalDetector = new G4LogicalVolume(tub,ScintMaterial,"logic_Microball_tub",0,0,0); - m_CylindricalDetector->SetVisAttributes(m_VisSquare); - m_CylindricalDetector->SetSensitiveDetector(m_MicroballScorer); - - } - return m_CylindricalDetector; + if(!m_CylindricalDetector){ + G4Tubs* tub = new G4Tubs("Microball_Cyl",0,Microball_NS::Radius,Microball_NS::Thickness*0.5,0,360*deg); + + G4Material* ScintMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Microball_NS::Scintillator); + m_CylindricalDetector = new G4LogicalVolume(tub,ScintMaterial,"logic_Microball_tub",0,0,0); + m_CylindricalDetector->SetVisAttributes(m_VisSquare); + m_CylindricalDetector->SetSensitiveDetector(m_MicroballScorer); + + } + return m_CylindricalDetector; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -147,2848 +150,3046 @@ G4LogicalVolume* Microball::BuildCylindricalDetector(){ // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method void Microball::ReadConfiguration(string Path){ - ifstream ConfigFile ; - ConfigFile.open(Path.c_str()) ; - string LineBuffer ; - string DataBuffer ; - - -bool bR1 = false; -bool bR2 = false; -bool bR3 = false; -bool bR4 = false; -bool bR5 = false; -bool bR6 = false; -bool bR7 = false; -bool bR8 = false; -bool bR9 = false; -vector<int> copyNumArray; -bool bFlip = false; - - bool ReadingStatus = false ; - -bool check_Ring1 = false; -bool check_Ring2 = false; -bool check_Ring3 = false; -bool check_Ring4 = false; -bool check_Ring5 = false; -bool check_Ring6 = false; -bool check_Ring7 = false; -bool check_Ring8 = false; -bool check_Ring9 = false; -bool check_Flip = false; - - - while (!ConfigFile.eof()) { - getline(ConfigFile, LineBuffer); - - // If line is a Start Up Microball bloc, Reading toggle to true - string name = "Microball"; - - if (LineBuffer.compare(0, name.length(), name) == 0) { - G4cout << "///" << G4endl ; - G4cout << "Microball found: " << G4endl ; - ReadingStatus = true ; - } - - // Else don't toggle to Reading Block Status - else ReadingStatus = false ; - - // Reading Block - while(ReadingStatus){ - // Pickup Next Word - ConfigFile >> DataBuffer ; - - // Comment Line - if (DataBuffer.compare(0, 1, "%") == 0) { - ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' ); - } - - // Finding another telescope (safety), toggle out - else if (DataBuffer.compare(0, name.length(),name) == 0) { - G4cout << "WARNING: Another Detector is find before standard sequence of Token, Error may occured in Telecope definition" << G4endl ; - ReadingStatus = false ; - } - - //Angle method - else if (DataBuffer.compare(0, 6, "RING1=") == 0) { - check_Ring1 = true; - ConfigFile >> DataBuffer ; - bR1 = atoi(DataBuffer.c_str()) ; - G4cout << "Ring1: " << bR1 << G4endl; - } - - else if (DataBuffer.compare(0, 6, "RING2=") == 0) { - check_Ring2 = true; - ConfigFile >> DataBuffer ; - bR2 = atoi(DataBuffer.c_str()) ; - G4cout << "Ring2: " << bR2 << G4endl; - } - - else if (DataBuffer.compare(0, 6, "RING3=") == 0) { - check_Ring3 = true; - ConfigFile >> DataBuffer ; - bR3 = atoi(DataBuffer.c_str()) ; - G4cout << "Ring3: " << bR3 << G4endl; - } - - else if (DataBuffer.compare(0, 6, "RING4=") == 0) { - check_Ring4 = true; - ConfigFile >> DataBuffer ; - bR4 = atoi(DataBuffer.c_str()) ; - G4cout << "Ring4: " << bR4 << G4endl; - } - - else if (DataBuffer.compare(0, 6, "RING5=") == 0) { - check_Ring5 = true; - ConfigFile >> DataBuffer ; - bR5 = atoi(DataBuffer.c_str()) ; - G4cout << "Ring5: " << bR5 << G4endl; - } - - else if (DataBuffer.compare(0, 6, "RING6=") == 0) { - check_Ring6 = true; - ConfigFile >> DataBuffer ; - bR6 = atoi(DataBuffer.c_str()) ; - G4cout << "Ring6: " << bR6 << G4endl; - } - - else if (DataBuffer.compare(0, 6, "RING7=") == 0) { - check_Ring7 = true; - ConfigFile >> DataBuffer ; - bR7 = atoi(DataBuffer.c_str()) ; - G4cout << "Ring7: " << bR7 << G4endl; - } - - else if (DataBuffer.compare(0, 6, "RING8=") == 0) { - check_Ring8 = true; - ConfigFile >> DataBuffer ; - bR8 = atoi(DataBuffer.c_str()) ; - G4cout << "Ring8: " << bR8 << G4endl; - } - - - else if (DataBuffer.compare(0, 6, "RING9=") == 0) { - check_Ring9 = true; - ConfigFile >> DataBuffer ; - bR9 = atoi(DataBuffer.c_str()) ; - G4cout << "Ring9: " << bR9 << G4endl; - } - - else if (DataBuffer.compare(0, 15, "DISABLE_CRYSTAL") == 0) { - ConfigFile >> DataBuffer ; - int item = atoi(DataBuffer.c_str()); - copyNumArray.push_back(item) ; - G4cout << "Disabled crystal: " << item << G4endl; - } - - else if (DataBuffer.compare(0, 14, "DETECTOR_FLIP=") == 0) { - check_Flip = true; - ConfigFile >> DataBuffer ; - bFlip = atoi(DataBuffer.c_str()) ; - G4cout << "Flip Detector: " << bFlip << G4endl; - } - - - //General - - - /////////////////////////////////////////////////// - // If no Detector Token and no comment, toggle out - else{ - ReadingStatus = false; - G4cout << "Wrong Token Sequence: Getting out " << DataBuffer << G4endl ; - } - if(check_Ring1 && check_Ring2 && check_Ring3 && - check_Ring4 && check_Ring5 && check_Ring6 && - check_Ring7 && check_Ring8 && check_Ring9 && - check_Flip){ - AddMicroball(bR1, bR2, bR3, - bR4, bR5, bR6, - bR7, bR8, bR9, - copyNumArray, bFlip); - - // Reinitialisation of Check Boolean - check_Ring1 = false ; - check_Ring2 = false ; - check_Ring3 = false ; - check_Ring4 = false ; - check_Ring5 = false ; - check_Ring6 = false ; - check_Ring7 = false ; - check_Ring8 = false ; - check_Ring9 = false ; - check_Flip = false ; - - ReadingStatus = false ; - G4cout << "///"<< G4endl ; - } - } - } -} -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - -// Construct detector and inialise sensitive part. -// Called After DetecorConstruction::AddDetector Method -void Microball::ConstructDetector(G4LogicalVolume* world){ - //the below for-loop is commented out, and to be replaced with our detector geometry. - - G4bool checkOverlaps = true; - G4double delrinBool = 1; - G4double crystalBool = 1; - G4double lgBool = 1; - -/*G4double ring1Bool = 1; -G4double ring2Bool = 1; -G4double ring3Bool = 1; -G4double ring4Bool = 1; -G4double ring5Bool = 1; -G4double ring6Bool = 1; -G4double ring7Bool = 1; -G4double ring8Bool = 1; -G4double ring9Bool = 1;*/ - - G4NistManager* nist = G4NistManager::Instance(); - -G4Material* CsI = nist->FindOrBuildMaterial("G4_CESIUM_IODIDE"); -G4VisAttributes* crystalVisAtt = new G4VisAttributes(G4Colour(0.,1.,0., .5)); -G4Material* glass = nist->FindOrBuildMaterial("G4_Pyrex_Glass"); -G4VisAttributes* lightGuideVisAtt = new G4VisAttributes(G4Colour(0.,0.,1.)); -G4Material* delrin = nist->FindOrBuildMaterial("G4_POLYOXYMETHYLENE"); - G4VisAttributes* delrinVisAtt = new G4VisAttributes(G4Colour(1.,0.,0.)); - -if(m_Ring1){ - // Ring 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lg pseudofixed - G4int detNum1 = 6; - G4double distanceFromTargetBack1 = 110.*mm; - G4double theta1 = 9.0*deg; - G4double halfTheta1 = 5.0*deg; - G4double lgThickness1 = 8.0*mm; - G4double detThickness1 = 9.2*mm; - G4double distanceFromTarget1 = distanceFromTargetBack1 - detThickness1; - - //G4double distance1 = distanceFromTarget1*sin(theta1); //this gives the distance from the beam axis. - - // - // Delrin Ring - // - G4double delrinA1 = 5*mm; - G4double delrinB1 = 10*mm; - G4double fdelrinHalfAngle1 = atan(delrinB1/2/(distanceFromTarget1+detThickness1+lgThickness1)); - G4double firs1 = pow(pow(distanceFromTarget1+detThickness1+lgThickness1,2)+pow(delrinB1/2,2),0.5)*sin(theta1-fdelrinHalfAngle1); - G4double firb1 = pow(pow(distanceFromTarget1+detThickness1+lgThickness1,2)+pow(delrinB1/2,2),0.5)*sin(theta1+fdelrinHalfAngle1); - G4double bdelrinHalfAngle1 = atan(delrinB1/2/(distanceFromTarget1+detThickness1+lgThickness1+delrinA1)); - G4double birs1 = pow(pow(distanceFromTarget1+detThickness1+lgThickness1+delrinA1,2)+pow(delrinB1/2,2),0.5)*sin(theta1-bdelrinHalfAngle1); - G4double birb1 = pow(pow(distanceFromTarget1+detThickness1+lgThickness1+delrinA1,2)+pow(delrinB1/2,2),0.5)*sin(theta1+bdelrinHalfAngle1); - - G4double delrin_dz1 = delrinB1/2; - G4double delrin_theta1 = 0; - G4double delrin_phi1 = 0; - G4double delrin_dyab1 = delrinA1/2; - G4double delrin_dxa1 = firs1*tan(180*deg/detNum1); - G4double delrin_dxb1 = birs1*tan(180*deg/detNum1); - G4double delrin_dycd1 = delrinA1/2; - G4double delrin_dxc1 = firb1*tan(180*deg/detNum1); - G4double delrin_dxd1 = birb1*tan(180*deg/detNum1); - G4double delrin_alpab1 = 0; - G4double delrin_alpcd1 = delrin_alpab1; - - - G4ThreeVector delrin_pos1 = G4ThreeVector(0,0,distanceFromTarget1*cos(theta1)); - - G4Trap* solidDelrin1 = - new G4Trap("Delrin1", //its name - delrin_dz1, - delrin_theta1, delrin_phi1, - delrin_dyab1, - delrin_dxa1, delrin_dxb1, - delrin_alpab1, - delrin_dycd1, - delrin_dxc1, delrin_dxd1, - delrin_alpcd1); //its size - - G4LogicalVolume* logicDelrin1 = - new G4LogicalVolume(solidDelrin1, //its solid - delrin, //its material - "Delrin1"); //its name - logicDelrin1->SetVisAttributes(delrinVisAtt); - - // - // CsI Detector - // - G4double coneheight1 = 2*distanceFromTarget1; - G4double flatheight1 = coneheight1-0.01*mm; - G4double coneangle1 = theta1; - G4double crystal_rmina1 = (coneheight1-flatheight1)*tan(coneangle1-halfTheta1); - G4double crystal_rmaxa1 = (coneheight1-flatheight1)*tan(coneangle1+halfTheta1); - G4double crystal_rminb1 = coneheight1*tan(coneangle1-halfTheta1); - G4double crystal_rmaxb1 = coneheight1*tan(coneangle1+halfTheta1); - G4double crystal_hz1 = 0.5*flatheight1;//(crystal_rmaxb1-crystal_rmaxa1)/crystal_rmaxb1*coneheight1; - G4double crystal_phimin1 = 0.*deg, crystal_phimax1 = 360.*deg/detNum1; - G4RotationMatrix tip_rotm1 = G4RotationMatrix(); - G4ThreeVector tip_pos1 = G4ThreeVector(0,0,0.5*flatheight1+(coneheight1-flatheight1)); - G4Transform3D tip_trans1 = G4Transform3D(tip_rotm1, tip_pos1); - G4ThreeVector z1 = G4ThreeVector(0,0,1); - G4ThreeVector d01 = G4ThreeVector(distanceFromTarget1*sin(coneangle1)*cos(0.5*360*deg/detNum1), - distanceFromTarget1*sin(coneangle1)*sin(0.5*360*deg/detNum1), - distanceFromTarget1*cos(coneangle1)); - G4ThreeVector unitAxis1 = z1.cross(d01); - unitAxis1 = unitAxis1/unitAxis1.mag(); - G4double ux1 = unitAxis1.x(); - G4double uy1 = unitAxis1.y(); - G4double uz1 = unitAxis1.z(); - G4ThreeVector top1 = G4ThreeVector(cos(coneangle1)+pow(ux1,2)*(1-cos(coneangle1)), ux1*uy1*(1-cos(coneangle1))-uz1*sin(coneangle1), ux1*uz1*(1-cos(coneangle1))+uy1*sin(coneangle1)); - G4ThreeVector mid1 = G4ThreeVector(uy1*ux1*(1-cos(coneangle1))+uz1*sin(coneangle1), cos(coneangle1)+pow(uy1,2)*(1-cos(coneangle1)), uy1*uz1*(1-cos(coneangle1))-ux1*sin(coneangle1)); - G4ThreeVector bot1 = G4ThreeVector(uz1*ux1*(1-cos(coneangle1))-uy1*sin(coneangle1), uz1*uy1*(1-cos(coneangle1))+ux1*sin(coneangle1), cos(coneangle1)+pow(uz1,2)*(1-cos(coneangle1))); - G4RotationMatrix firstBox_rotm1 = G4RotationMatrix(); - firstBox_rotm1.setRows(top1,mid1,bot1); - G4ThreeVector firstBox_pos1 = G4ThreeVector(0,0,0); - G4Transform3D firstBox_trans1 = G4Transform3D(firstBox_rotm1, firstBox_pos1); - G4RotationMatrix secondBox_rotm1 = G4RotationMatrix(); - secondBox_rotm1.setRows(top1,mid1,bot1); - G4ThreeVector secondBox_pos1 = (2*distanceFromTarget1+detThickness1)/distanceFromTarget1*d01; - G4Transform3D secondBox_trans1 = G4Transform3D(secondBox_rotm1, secondBox_pos1); - - G4Orb* solidTip1 = - new G4Orb("tip1", - .0001*mm); - G4Box* solidSubtractionBox1 = - new G4Box("SubtractionBox1", //its name - distanceFromTarget1, - distanceFromTarget1, - distanceFromTarget1); //its size - G4Cons* solidCone1 = - new G4Cons("Cone1", //its name - crystal_rmina1, crystal_rmaxa1, - crystal_rminb1, crystal_rmaxb1, - crystal_hz1, - crystal_phimin1, crystal_phimax1); //its size - G4UnionSolid* solidTippedCone1 = - new G4UnionSolid("TippedCone1", - solidTip1, - solidCone1, - tip_trans1); - G4SubtractionSolid* solidIntermediate1 = - new G4SubtractionSolid("Intermediate1", - solidTippedCone1, - solidSubtractionBox1, - firstBox_trans1); - G4SubtractionSolid* solidCrystal1 = - new G4SubtractionSolid("Crystal1", - solidIntermediate1, - solidSubtractionBox1, - secondBox_trans1); - - G4LogicalVolume* logicCrystal1 = - new G4LogicalVolume(solidCrystal1, //its solid - CsI, //its material - "CsI Detector1"); //its name - logicCrystal1->SetVisAttributes(crystalVisAtt); - logicCrystal1->SetSensitiveDetector(m_MicroballScorer); - //fScoringVolume = logicCrystal1; - - // - // Light Guide - // - G4double lightGuide_px1 = 10*mm; - G4double lightGuide_py1 = 10*mm; - G4double lightGuide_pz1 = lgThickness1; - G4Box* solidLightGuide1 = - new G4Box("LightGuide1", //its name - 0.5*lightGuide_px1, - 0.5*lightGuide_py1, - 0.5*lightGuide_pz1); //its size - - G4LogicalVolume* logicLightGuide1 = - new G4LogicalVolume(solidLightGuide1, //its solid - glass, //its material - "LightGuide1"); //its name - logicLightGuide1->SetVisAttributes(lightGuideVisAtt); - - for(int i = 1; i <= detNum1; i++) - { - G4RotationMatrix crystal_rotm = G4RotationMatrix(); - G4ThreeVector d0 = G4ThreeVector(distanceFromTarget1*sin(coneangle1)*cos(0.5*360*deg/detNum1), - distanceFromTarget1*sin(coneangle1)*sin(0.5*360*deg/detNum1), - distanceFromTarget1*cos(coneangle1)); - G4ThreeVector df = G4ThreeVector(distanceFromTarget1*sin(theta1)*sin((i-1)*360*deg/detNum1+.001*deg/*+0.5*360*deg/detNum1*/), - distanceFromTarget1*sin(theta1)*cos((i-1)*360*deg/detNum1+.001*deg/*+0.5*360*deg/detNum1*/), - -distanceFromTarget1*cos(theta1)); - G4ThreeVector axis = d0.cross(df); - G4double ax = axis.x(); - G4double ay = axis.y(); - G4double az = axis.z(); - G4double ux = ax/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double uy = ay/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double uz = az/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double j = acos(d0.dot(df)/(d0.mag()*df.mag())); - G4ThreeVector a = G4ThreeVector(cos(j)+pow(ux,2)*(1-cos(j)), ux*uy*(1-cos(j))-uz*sin(j), ux*uz*(1-cos(j))+uy*sin(j)); - G4ThreeVector b = G4ThreeVector(uy*ux*(1-cos(j))+uz*sin(j), cos(j)+pow(uy,2)*(1-cos(j)), uy*uz*(1-cos(j))-ux*sin(j)); - G4ThreeVector c = G4ThreeVector(uz*ux*(1-cos(j))-uy*sin(j), uz*uy*(1-cos(j))+ux*sin(j), cos(j)+pow(uz,2)*(1-cos(j))); - G4RotationMatrix abc = G4RotationMatrix(); - abc.setRows(a,b,c); - G4ThreeVector unitdf = df/df.mag(); - G4double udfx = unitdf.x(); - G4double udfy = unitdf.y(); - G4double udfz = unitdf.z(); - G4double k = 180.*deg; - G4ThreeVector d = G4ThreeVector(cos(k)+pow(udfx,2)*(1-cos(k)), udfx*udfy*(1-cos(k))-udfz*sin(k), udfx*udfz*(1-cos(k))+udfy*sin(k)); - G4ThreeVector e = G4ThreeVector(udfy*udfx*(1-cos(k))+udfz*sin(k), cos(k)+pow(udfy,2)*(1-cos(k)), udfy*udfz*(1-cos(k))-udfx*sin(k)); - G4ThreeVector f = G4ThreeVector(udfz*udfx*(1-cos(k))-udfy*sin(k), udfz*udfy*(1-cos(k))+udfx*sin(k), cos(k)+pow(udfz,2)*(1-cos(k))); - G4RotationMatrix def = G4RotationMatrix(); - def.setRows(d,e,f); - crystal_rotm=def*abc; - if (m_Flip == 0){ - crystal_rotm.rotateY(180*deg); - } - crystal_rotm.rotateZ(180*deg); - G4ThreeVector crystal_pos = G4ThreeVector(0,0,0); - G4Transform3D crystal_trans = G4Transform3D(crystal_rotm, crystal_pos); - G4RotationMatrix lg_rotm = G4RotationMatrix(); - G4ThreeVector lg_Axis = df.cross(z1); - lg_Axis = lg_Axis/lg_Axis.mag(); - lg_Axis.rotateZ(180*deg); - G4double ulgx = lg_Axis.x(); - G4double ulgy = lg_Axis.y(); - G4double ulgz = lg_Axis.z(); - G4ThreeVector p = G4ThreeVector(cos(theta1)+pow(ulgx,2)*(1-cos(theta1)), ulgx*ulgy*(1-cos(theta1))-ulgz*sin(theta1), ulgx*ulgz*(1-cos(theta1))+ulgy*sin(theta1)); - G4ThreeVector q = G4ThreeVector(ulgy*ulgx*(1-cos(theta1))+ulgz*sin(theta1), cos(theta1)+pow(ulgy,2)*(1-cos(theta1)), ulgy*ulgz*(1-cos(theta1))-ulgx*sin(theta1)); - G4ThreeVector r = G4ThreeVector(ulgz*ulgx*(1-cos(theta1))-ulgy*sin(theta1), ulgz*ulgy*(1-cos(theta1))+ulgx*sin(theta1), cos(theta1)+pow(ulgz,2)*(1-cos(theta1))); - G4RotationMatrix pqr = G4RotationMatrix(); - pqr.setRows(p,q,r); - lg_rotm.rotateZ((i-1)*360*deg/detNum1); - lg_rotm.rotateX(180*deg); - lg_rotm=pqr*lg_rotm; - G4ThreeVector lg_pos = (distanceFromTarget1+detThickness1+0.5*lgThickness1)/df.mag()*df; - lg_pos.rotateZ(180*deg); - if (m_Flip == 0){ - lg_pos.rotateY(180*deg); - lg_rotm.rotateY(180*deg); - } - G4Transform3D lg_trans = G4Transform3D(lg_rotm, lg_pos); - G4RotationMatrix delrin_rotm = G4RotationMatrix(); - G4ThreeVector w = G4ThreeVector(sin(theta1)*sin((i-1)*360*deg/detNum1+.001*deg), sin(theta1)*cos((i-1)*360*deg/detNum1+.001*deg), cos(theta1)); - G4ThreeVector delrin_Axis = w.cross(z1); - delrin_Axis = delrin_Axis/delrin_Axis.mag(); - delrin_Axis.rotateX(180*deg); - G4double udx = delrin_Axis.x(); - G4double udy = delrin_Axis.y(); - G4double udz = delrin_Axis.z(); - G4double delAng = 90*deg+theta1; - G4ThreeVector pdel = G4ThreeVector(cos(delAng)+pow(udx,2)*(1-cos(delAng)), udx*udy*(1-cos(delAng))-udz*sin(delAng), udx*udz*(1-cos(delAng))+udy*sin(delAng)); - G4ThreeVector qdel = G4ThreeVector(udy*udx*(1-cos(delAng))+udz*sin(delAng), cos(delAng)+pow(udy,2)*(1-cos(delAng)), udy*udz*(1-cos(delAng))-udx*sin(delAng)); - G4ThreeVector rdel = G4ThreeVector(udz*udx*(1-cos(delAng))-udy*sin(delAng), udz*udy*(1-cos(delAng))+udx*sin(delAng), cos(delAng)+pow(udz,2)*(1-cos(delAng))); - G4RotationMatrix pqrdel = G4RotationMatrix(); - pqrdel.setRows(pdel,qdel,rdel); - delrin_rotm.rotateZ((i-1)*360*deg/detNum1+.001*deg); - delrin_rotm=pqrdel*delrin_rotm; - G4ThreeVector delrin_pos = (distanceFromTarget1+detThickness1+lgThickness1+delrinA1/2+.0003*mm)/df.mag()*df; //the .0003 mm is a fudge factor to prevent overlapping - delrin_pos.rotateZ(180*deg); - delrin_pos.rotateY(180*deg); - if (m_Flip == 1){ - delrin_pos.rotateY(180*deg); - delrin_rotm.rotateY(180*deg); - } - G4Transform3D delrin_trans = G4Transform3D(delrin_rotm, delrin_pos); - bool placeCrystal = true; - for (unsigned int i2=0; i2 < m_Array.size(); i2++){ - if (0 < m_Array[i2] && m_Array[i2] < 7){ - /*if (1+6-m_Array[i2] == 0+i){ - placeCrystal = false; - }*/ - if (m_Array[i2] == 0+i){ - placeCrystal = false; - } - } - } - if (placeCrystal){ - if(crystalBool) {new G4PVPlacement(crystal_trans, //rotation, position - logicCrystal1, //its logical volume - "CsI Detector1", //its name - world, //its mother volume - false, //no boolean operation - 0+i, //copy number - checkOverlaps); //overlaps checking - } - if(lgBool) {new G4PVPlacement(lg_trans, //rotation, position - logicLightGuide1, //its logical volume - "LightGuide1", //its name - world, //its mother volume - false, //no boolean operation - 0+i, //copy number - checkOverlaps); //overlaps checking - } - if(delrinBool) {new G4PVPlacement(delrin_trans, //rotation, position - logicDelrin1, //its logical volume - "Delrin1", //its name - world, //its mother volume - false, //no boolean operation - 0+i, //copy number - checkOverlaps); //overlaps checking - } - } - }} - if(m_Ring2){ - // Ring 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lg pseudofixed - G4int detNum2 = 10; - G4double distanceFromTargetBack2 = 80.*mm; - G4double theta2 = 21.0*deg; - G4double halfTheta2 = 7.0*deg; //+0.1*deg; //0.1 is a fudge factor to make it cover solid angle 4pi - G4double lgThickness2 = 7.5*mm; - G4double detThickness2 = 7.2*mm; - G4double distanceFromTarget2 = distanceFromTargetBack2 - detThickness2; - - //G4double distance2 = distanceFromTarget2*sin(theta2); //this gives the distance from the beam axis. - - // - // Delrin Ring - // - G4double delrinA2 = 5*mm; - G4double delrinB2 = 10*mm; - G4double fdelrinHalfAngle2 = atan(delrinB2/2/(distanceFromTarget2+detThickness2+lgThickness2)); - G4double firs2 = pow(pow(distanceFromTarget2+detThickness2+lgThickness2,2)+pow(delrinB2/2,2),0.5)*sin(theta2-fdelrinHalfAngle2); - G4double firb2 = pow(pow(distanceFromTarget2+detThickness2+lgThickness2,2)+pow(delrinB2/2,2),0.5)*sin(theta2+fdelrinHalfAngle2); - G4double bdelrinHalfAngle2 = atan(delrinB2/2/(distanceFromTarget2+detThickness2+lgThickness2+delrinA2)); - G4double birs2 = pow(pow(distanceFromTarget2+detThickness2+lgThickness2+delrinA2,2)+pow(delrinB2/2,2),0.5)*sin(theta2-bdelrinHalfAngle2); - G4double birb2 = pow(pow(distanceFromTarget2+detThickness2+lgThickness2+delrinA2,2)+pow(delrinB2/2,2),0.5)*sin(theta2+bdelrinHalfAngle2); - - G4double delrin_dz2 = delrinB2/2; - G4double delrin_theta2 = 0; - G4double delrin_phi2 = 0; - G4double delrin_dyab2 = delrinA2/2; - G4double delrin_dxa2 = firs2*tan(180*deg/detNum2); - G4double delrin_dxb2 = birs2*tan(180*deg/detNum2); - G4double delrin_dycd2 = delrinA2/2; - G4double delrin_dxc2 = firb2*tan(180*deg/detNum2); - G4double delrin_dxd2 = birb2*tan(180*deg/detNum2); - G4double delrin_alpab2 = 0; - G4double delrin_alpcd2 = delrin_alpab2; - + ifstream ConfigFile ; + ConfigFile.open(Path.c_str()) ; + string LineBuffer ; + string DataBuffer ; + + + bool bR1 = false; + bool bR2 = false; + bool bR3 = false; + bool bR4 = false; + bool bR5 = false; + bool bR6 = false; + bool bR7 = false; + bool bR8 = false; + bool bR9 = false; + vector<int> copyNumArray; + bool bFlip = false; + bool bChamber = false; + + bool ReadingStatus = false ; + + bool check_Ring1 = false; + bool check_Ring2 = false; + bool check_Ring3 = false; + bool check_Ring4 = false; + bool check_Ring5 = false; + bool check_Ring6 = false; + bool check_Ring7 = false; + bool check_Ring8 = false; + bool check_Ring9 = false; + bool check_Flip = false; + bool check_Chamber = false; + + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + + // If line is a Start Up Microball bloc, Reading toggle to true + string name = "Microball"; + + if (LineBuffer.compare(0, name.length(), name) == 0) { + G4cout << "///" << G4endl ; + G4cout << "Microball found: " << G4endl ; + ReadingStatus = true ; + } + + // Else don't toggle to Reading Block Status + else ReadingStatus = false ; + + // Reading Block + while(ReadingStatus){ + // Pickup Next Word + ConfigFile >> DataBuffer ; - G4ThreeVector delrin_pos2 = G4ThreeVector(0,0,distanceFromTarget2*cos(theta2)); - - G4Trap* solidDelrin2 = - new G4Trap("Delrin2", //its name - delrin_dz2, - delrin_theta2, delrin_phi2, - delrin_dyab2, - delrin_dxa2, delrin_dxb2, - delrin_alpab2, - delrin_dycd2, - delrin_dxc2, delrin_dxd2, - delrin_alpcd2); //its size - - G4LogicalVolume* logicDelrin2 = - new G4LogicalVolume(solidDelrin2, //its solid - delrin, //its material - "Delrin2"); //its name - logicDelrin2->SetVisAttributes(delrinVisAtt); - - - // - // CsI Detector - // - G4double coneheight2 = 2*distanceFromTarget2; - G4double flatheight2 = coneheight2-0.01*mm; - G4double coneangle2 = theta2; - G4double crystal_rmina2 = (coneheight2-flatheight2)*tan(coneangle2-halfTheta2); - G4double crystal_rmaxa2 = (coneheight2-flatheight2)*tan(coneangle2+halfTheta2); - G4double crystal_rminb2 = coneheight2*tan(coneangle2-halfTheta2); - G4double crystal_rmaxb2 = coneheight2*tan(coneangle2+halfTheta2); - G4double crystal_hz2 = 0.5*flatheight2;//(crystal_rmaxb2-crystal_rmaxa2)/crystal_rmaxb2*coneheight2; - G4double crystal_phimin2 = 0.*deg, crystal_phimax2 = 360.*deg/detNum2; - G4RotationMatrix tip_rotm2 = G4RotationMatrix(); - G4ThreeVector tip_pos2 = G4ThreeVector(0,0,0.5*flatheight2+(coneheight2-flatheight2)); - G4Transform3D tip_trans2 = G4Transform3D(tip_rotm2, tip_pos2); - G4ThreeVector z2 = G4ThreeVector(0,0,1); - G4ThreeVector d02 = G4ThreeVector(distanceFromTarget2*sin(coneangle2)*cos(0.5*360*deg/detNum2), - distanceFromTarget2*sin(coneangle2)*sin(0.5*360*deg/detNum2), - distanceFromTarget2*cos(coneangle2)); - G4ThreeVector unitAxis2 = z2.cross(d02); - unitAxis2 = unitAxis2/unitAxis2.mag(); - G4double ux2 = unitAxis2.x(); - G4double uy2 = unitAxis2.y(); - G4double uz2 = unitAxis2.z(); - G4ThreeVector top2 = G4ThreeVector(cos(coneangle2)+pow(ux2,2)*(1-cos(coneangle2)), ux2*uy2*(1-cos(coneangle2))-uz2*sin(coneangle2), ux2*uz2*(1-cos(coneangle2))+uy2*sin(coneangle2)); - G4ThreeVector mid2 = G4ThreeVector(uy2*ux2*(1-cos(coneangle2))+uz2*sin(coneangle2), cos(coneangle2)+pow(uy2,2)*(1-cos(coneangle2)), uy2*uz2*(1-cos(coneangle2))-ux2*sin(coneangle2)); - G4ThreeVector bot2 = G4ThreeVector(uz2*ux2*(1-cos(coneangle2))-uy2*sin(coneangle2), uz2*uy2*(1-cos(coneangle2))+ux2*sin(coneangle2), cos(coneangle2)+pow(uz2,2)*(1-cos(coneangle2))); - G4RotationMatrix firstBox_rotm2 = G4RotationMatrix(); - firstBox_rotm2.setRows(top2,mid2,bot2); - G4ThreeVector firstBox_pos2 = G4ThreeVector(0,0,0); - G4Transform3D firstBox_trans2 = G4Transform3D(firstBox_rotm2, firstBox_pos2); - G4RotationMatrix secondBox_rotm2 = G4RotationMatrix(); - secondBox_rotm2.setRows(top2,mid2,bot2); - G4ThreeVector secondBox_pos2 = (2*distanceFromTarget2+detThickness2)/distanceFromTarget2*d02; - G4Transform3D secondBox_trans2 = G4Transform3D(secondBox_rotm2, secondBox_pos2); - - G4Orb* solidTip2 = - new G4Orb("tip2", - .0001*mm); - G4Box* solidSubtractionBox2 = - new G4Box("SubtractionBox2", //its name - distanceFromTarget2, - distanceFromTarget2, - distanceFromTarget2); //its size - G4Cons* solidCone2 = - new G4Cons("Cone2", //its name - crystal_rmina2, crystal_rmaxa2, - crystal_rminb2, crystal_rmaxb2, - crystal_hz2, - crystal_phimin2, crystal_phimax2); //its size - G4UnionSolid* solidTippedCone2 = - new G4UnionSolid("TippedCone2", - solidTip2, - solidCone2, - tip_trans2); - G4SubtractionSolid* solidIntermediate2 = - new G4SubtractionSolid("Intermediate2", - solidTippedCone2, - solidSubtractionBox2, - firstBox_trans2); - G4SubtractionSolid* solidCrystal2 = - new G4SubtractionSolid("Crystal2", - solidIntermediate2, - solidSubtractionBox2, - secondBox_trans2); - - G4LogicalVolume* logicCrystal2 = - new G4LogicalVolume(solidCrystal2, //its solid - CsI, //its material - "CsI Detector2"); //its name - logicCrystal2->SetVisAttributes(crystalVisAtt); - logicCrystal2->SetSensitiveDetector(m_MicroballScorer); - // - // Light Guide - // - G4double lightGuide_px2 = 10*mm; - G4double lightGuide_py2 = 10*mm; - G4double lightGuide_pz2 = lgThickness2; - G4Box* solidLightGuide2 = - new G4Box("LightGuide2", //its name - 0.5*lightGuide_px2, - 0.5*lightGuide_py2, - 0.5*lightGuide_pz2); //its size - - G4LogicalVolume* logicLightGuide2 = - new G4LogicalVolume(solidLightGuide2, //its solid - glass, //its material - "LightGuide2"); //its name - logicLightGuide2->SetVisAttributes(lightGuideVisAtt); - - for(int i = 1; i <= detNum2; i++) - { - G4RotationMatrix crystal_rotm = G4RotationMatrix(); - G4ThreeVector d0 = G4ThreeVector(distanceFromTarget2*sin(coneangle2)*cos(0.5*360*deg/detNum2), - distanceFromTarget2*sin(coneangle2)*sin(0.5*360*deg/detNum2), - distanceFromTarget2*cos(coneangle2)); - G4ThreeVector df = G4ThreeVector(distanceFromTarget2*sin(theta2)*sin((i-1)*360*deg/detNum2+.001*deg/*+0.5*360*deg/detNum2*/), - distanceFromTarget2*sin(theta2)*cos((i-1)*360*deg/detNum2+.001*deg/*+0.5*360*deg/detNum2*/), - -distanceFromTarget2*cos(theta2)); - G4ThreeVector axis = d0.cross(df); - G4double ax = axis.x(); - G4double ay = axis.y(); - G4double az = axis.z(); - G4double ux = ax/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double uy = ay/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double uz = az/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double j = acos(d0.dot(df)/(d0.mag()*df.mag())); - G4ThreeVector a = G4ThreeVector(cos(j)+pow(ux,2)*(1-cos(j)), ux*uy*(1-cos(j))-uz*sin(j), ux*uz*(1-cos(j))+uy*sin(j)); - G4ThreeVector b = G4ThreeVector(uy*ux*(1-cos(j))+uz*sin(j), cos(j)+pow(uy,2)*(1-cos(j)), uy*uz*(1-cos(j))-ux*sin(j)); - G4ThreeVector c = G4ThreeVector(uz*ux*(1-cos(j))-uy*sin(j), uz*uy*(1-cos(j))+ux*sin(j), cos(j)+pow(uz,2)*(1-cos(j))); - G4RotationMatrix abc = G4RotationMatrix(); - abc.setRows(a,b,c); - G4ThreeVector unitdf = df/df.mag(); - G4double udfx = unitdf.x(); - G4double udfy = unitdf.y(); - G4double udfz = unitdf.z(); - G4double k = 180.*deg; - G4ThreeVector d = G4ThreeVector(cos(k)+pow(udfx,2)*(1-cos(k)), udfx*udfy*(1-cos(k))-udfz*sin(k), udfx*udfz*(1-cos(k))+udfy*sin(k)); - G4ThreeVector e = G4ThreeVector(udfy*udfx*(1-cos(k))+udfz*sin(k), cos(k)+pow(udfy,2)*(1-cos(k)), udfy*udfz*(1-cos(k))-udfx*sin(k)); - G4ThreeVector f = G4ThreeVector(udfz*udfx*(1-cos(k))-udfy*sin(k), udfz*udfy*(1-cos(k))+udfx*sin(k), cos(k)+pow(udfz,2)*(1-cos(k))); - G4RotationMatrix def = G4RotationMatrix(); - def.setRows(d,e,f); - crystal_rotm=def*abc; - if (m_Flip == 0){ - crystal_rotm.rotateY(180*deg); - } - crystal_rotm.rotateZ(180*deg); - G4ThreeVector crystal_pos = G4ThreeVector(0,0,0); - G4Transform3D crystal_trans = G4Transform3D(crystal_rotm, crystal_pos); - G4RotationMatrix lg_rotm = G4RotationMatrix(); - G4ThreeVector lg_Axis = df.cross(z2); - lg_Axis = lg_Axis/lg_Axis.mag(); - lg_Axis.rotateZ(180*deg); - G4double ulgx = lg_Axis.x(); - G4double ulgy = lg_Axis.y(); - G4double ulgz = lg_Axis.z(); - G4ThreeVector p = G4ThreeVector(cos(theta2)+pow(ulgx,2)*(1-cos(theta2)), ulgx*ulgy*(1-cos(theta2))-ulgz*sin(theta2), ulgx*ulgz*(1-cos(theta2))+ulgy*sin(theta2)); - G4ThreeVector q = G4ThreeVector(ulgy*ulgx*(1-cos(theta2))+ulgz*sin(theta2), cos(theta2)+pow(ulgy,2)*(1-cos(theta2)), ulgy*ulgz*(1-cos(theta2))-ulgx*sin(theta2)); - G4ThreeVector r = G4ThreeVector(ulgz*ulgx*(1-cos(theta2))-ulgy*sin(theta2), ulgz*ulgy*(1-cos(theta2))+ulgx*sin(theta2), cos(theta2)+pow(ulgz,2)*(1-cos(theta2))); - G4RotationMatrix pqr = G4RotationMatrix(); - pqr.setRows(p,q,r); - lg_rotm.rotateZ((i-1)*360*deg/detNum2); - lg_rotm.rotateX(180*deg); - lg_rotm=pqr*lg_rotm; - G4ThreeVector lg_pos = (distanceFromTarget2+detThickness2+0.5*lgThickness2)/df.mag()*df; - lg_pos.rotateZ(180*deg); - if (m_Flip == 0){ - lg_pos.rotateY(180*deg); - lg_rotm.rotateY(180*deg); - } - G4Transform3D lg_trans = G4Transform3D(lg_rotm, lg_pos); - G4Transform3D d0_trans = G4Transform3D(G4RotationMatrix(), d0); - G4Transform3D df_trans = G4Transform3D(G4RotationMatrix(), df); - G4RotationMatrix delrin_rotm = G4RotationMatrix(); - G4ThreeVector w = G4ThreeVector(sin(theta2)*sin((i-1)*360*deg/detNum2+.001*deg), sin(theta2)*cos((i-1)*360*deg/detNum2+.001*deg), cos(theta2)); - G4ThreeVector delrin_Axis = w.cross(z2); - delrin_Axis.rotateX(180*deg); - delrin_Axis = delrin_Axis/delrin_Axis.mag(); - G4double udx = delrin_Axis.x(); - G4double udy = delrin_Axis.y(); - G4double udz = delrin_Axis.z(); - G4double delAng = 90*deg+theta2; - G4ThreeVector pdel = G4ThreeVector(cos(delAng)+pow(udx,2)*(1-cos(delAng)), udx*udy*(1-cos(delAng))-udz*sin(delAng), udx*udz*(1-cos(delAng))+udy*sin(delAng)); - G4ThreeVector qdel = G4ThreeVector(udy*udx*(1-cos(delAng))+udz*sin(delAng), cos(delAng)+pow(udy,2)*(1-cos(delAng)), udy*udz*(1-cos(delAng))-udx*sin(delAng)); - G4ThreeVector rdel = G4ThreeVector(udz*udx*(1-cos(delAng))-udy*sin(delAng), udz*udy*(1-cos(delAng))+udx*sin(delAng), cos(delAng)+pow(udz,2)*(1-cos(delAng))); - G4RotationMatrix pqrdel = G4RotationMatrix(); - pqrdel.setRows(pdel,qdel,rdel); - delrin_rotm.rotateZ((i-1)*360*deg/detNum2+.001*deg); - delrin_rotm=pqrdel*delrin_rotm; - delrin_rotm.rotateZ(0*deg); - G4ThreeVector delrin_pos = (distanceFromTarget2+detThickness2+lgThickness2+delrinA2/2+.0003*mm)/df.mag()*df; //the .0003 mm is a fudge factor to prevent overlapping - delrin_pos.rotateZ(180*deg); - delrin_pos.rotateY(180*deg); - if (m_Flip == 1){ - delrin_pos.rotateY(180*deg); - delrin_rotm.rotateY(180*deg); - } - G4Transform3D delrin_trans = G4Transform3D(delrin_rotm, delrin_pos); - bool placeCrystal = true; - for (unsigned int i2=0; i2 < m_Array.size(); i2++){ - if (6 < m_Array[i2] && m_Array[i2] < 17){ - if (m_Array[i2] == 6+i){ - placeCrystal = false; - } - } - } - if (placeCrystal){ - if(crystalBool) {new G4PVPlacement(crystal_trans, //rotation, position - logicCrystal2, //its logical volume - "CsI Detector2", //its name - world, //its mother volume - false, //no boolean operation - 6+i, //copy number - checkOverlaps); //overlaps checking - } - if(lgBool) {new G4PVPlacement(lg_trans, //rotation, position - logicLightGuide2, //its logical volume - "LightGuide2", //its name - world, //its mother volume - false, //no boolean operation - 6+i, //copy number - checkOverlaps); //overlaps checking - } - if(delrinBool) {new G4PVPlacement(delrin_trans, //rotation, position - logicDelrin2, //its logical volume - "Delrin2", //its name - world, //its mother volume - false, //no boolean operation - 6+i, //copy number - checkOverlaps); //overlaps checking - } - } - }} - - if(m_Ring3){ - // Ring 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lg pseudofixed - G4int detNum3 = 12; - G4double distanceFromTargetBack3 = 60.*mm; - G4double theta3 = 36.0*deg; - G4double halfTheta3 = 8.0*deg; - G4double lgThickness3 = 6.0*mm; - G4double detThickness3 = 6.4*mm; - G4double distanceFromTarget3 = distanceFromTargetBack3 - detThickness3; - - //G4double distance3 = distanceFromTarget3*sin(theta3); //this gives the distance from the beam axis. - - // - // Delrin Ring - // - G4double delrinA3 = 5*mm; - G4double delrinB3 = 10*mm; - G4double fdelrinHalfAngle3 = atan(delrinB3/2/(distanceFromTarget3+detThickness3+lgThickness3)); - G4double firs3 = pow(pow(distanceFromTarget3+detThickness3+lgThickness3,2)+pow(delrinB3/2,2),0.5)*sin(theta3-fdelrinHalfAngle3); - G4double firb3 = pow(pow(distanceFromTarget3+detThickness3+lgThickness3,2)+pow(delrinB3/2,2),0.5)*sin(theta3+fdelrinHalfAngle3); - G4double bdelrinHalfAngle3 = atan(delrinB3/2/(distanceFromTarget3+detThickness3+lgThickness3+delrinA3)); - G4double birs3 = pow(pow(distanceFromTarget3+detThickness3+lgThickness3+delrinA3,2)+pow(delrinB3/2,2),0.5)*sin(theta3-bdelrinHalfAngle3); - G4double birb3 = pow(pow(distanceFromTarget3+detThickness3+lgThickness3+delrinA3,2)+pow(delrinB3/2,2),0.5)*sin(theta3+bdelrinHalfAngle3); - - G4double delrin_dz3 = delrinB3/2; - G4double delrin_theta3 = 0; - G4double delrin_phi3 = 0; - G4double delrin_dyab3 = delrinA3/2; - G4double delrin_dxa3 = firs3*tan(180*deg/detNum3); - G4double delrin_dxb3 = birs3*tan(180*deg/detNum3); - G4double delrin_dycd3 = delrinA3/2; - G4double delrin_dxc3 = firb3*tan(180*deg/detNum3); - G4double delrin_dxd3 = birb3*tan(180*deg/detNum3); - G4double delrin_alpab3 = 0; - G4double delrin_alpcd3 = delrin_alpab3; - + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) { + ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' ); + } - G4ThreeVector delrin_pos3 = G4ThreeVector(0,0,distanceFromTarget3*cos(theta3)); - - G4Trap* solidDelrin3 = - new G4Trap("Delrin3", //its name - delrin_dz3, - delrin_theta3, delrin_phi3, - delrin_dyab3, - delrin_dxa3, delrin_dxb3, - delrin_alpab3, - delrin_dycd3, - delrin_dxc3, delrin_dxd3, - delrin_alpcd3); //its size - - G4LogicalVolume* logicDelrin3 = - new G4LogicalVolume(solidDelrin3, //its solid - delrin, //its material - "Delrin3"); //its name - logicDelrin3->SetVisAttributes(delrinVisAtt); - - // - // CsI Detector - // - G4double coneheight3 = distanceFromTarget3; - G4double flatheight3 = coneheight3-0.01*mm; - G4double coneangle3 = theta3; - G4double crystal_rmina3 = (coneheight3-flatheight3)*tan(coneangle3-halfTheta3); - G4double crystal_rmaxa3 = (coneheight3-flatheight3)*tan(coneangle3+halfTheta3); - G4double crystal_rminb3 = coneheight3*tan(coneangle3-halfTheta3); - G4double crystal_rmaxb3 = coneheight3*tan(coneangle3+halfTheta3); - G4double crystal_hz3 = 0.5*flatheight3;//(crystal_rmaxb3-crystal_rmaxa3)/crystal_rmaxb3*coneheight3; - G4double crystal_phimin3 = 0.*deg, crystal_phimax3 = 360.*deg/detNum3; - G4RotationMatrix tip_rotm3 = G4RotationMatrix(); - G4ThreeVector tip_pos3 = G4ThreeVector(0,0,0.5*flatheight3+(coneheight3-flatheight3)); - G4Transform3D tip_trans3 = G4Transform3D(tip_rotm3, tip_pos3); - G4ThreeVector z3 = G4ThreeVector(0,0,1); - G4ThreeVector d03 = G4ThreeVector(distanceFromTarget3*sin(coneangle3)*cos(0.5*360*deg/detNum3), - distanceFromTarget3*sin(coneangle3)*sin(0.5*360*deg/detNum3), - distanceFromTarget3*cos(coneangle3)); - G4ThreeVector unitAxis3 = z3.cross(d03); - unitAxis3 = unitAxis3/unitAxis3.mag(); - G4double ux3 = unitAxis3.x(); - G4double uy3 = unitAxis3.y(); - G4double uz3 = unitAxis3.z(); - G4ThreeVector top3 = G4ThreeVector(cos(coneangle3)+pow(ux3,2)*(1-cos(coneangle3)), ux3*uy3*(1-cos(coneangle3))-uz3*sin(coneangle3), ux3*uz3*(1-cos(coneangle3))+uy3*sin(coneangle3)); - G4ThreeVector mid3 = G4ThreeVector(uy3*ux3*(1-cos(coneangle3))+uz3*sin(coneangle3), cos(coneangle3)+pow(uy3,2)*(1-cos(coneangle3)), uy3*uz3*(1-cos(coneangle3))-ux3*sin(coneangle3)); - G4ThreeVector bot3 = G4ThreeVector(uz3*ux3*(1-cos(coneangle3))-uy3*sin(coneangle3), uz3*uy3*(1-cos(coneangle3))+ux3*sin(coneangle3), cos(coneangle3)+pow(uz3,2)*(1-cos(coneangle3))); - G4RotationMatrix firstBox_rotm3 = G4RotationMatrix(); - firstBox_rotm3.setRows(top3,mid3,bot3); - G4ThreeVector firstBox_pos3 = G4ThreeVector(0,0,0); - G4Transform3D firstBox_trans3 = G4Transform3D(firstBox_rotm3, firstBox_pos3); - G4RotationMatrix secondBox_rotm3 = G4RotationMatrix(); - secondBox_rotm3.setRows(top3,mid3,bot3); - G4ThreeVector secondBox_pos3 = (2*distanceFromTarget3+detThickness3)/distanceFromTarget3*d03; - G4Transform3D secondBox_trans3 = G4Transform3D(secondBox_rotm3, secondBox_pos3); - - G4Orb* solidTip3 = - new G4Orb("tip3", - .0001*mm); - G4Box* solidSubtractionBox3 = - new G4Box("SubtractionBox3", //its name - distanceFromTarget3, - distanceFromTarget3, - distanceFromTarget3); //its size - G4Cons* solidCone3 = - new G4Cons("Cone3", //its name - crystal_rmina3, crystal_rmaxa3, - crystal_rminb3, crystal_rmaxb3, - crystal_hz3, - crystal_phimin3, crystal_phimax3); //its size - G4UnionSolid* solidTippedCone3 = - new G4UnionSolid("TippedCone3", - solidTip3, - solidCone3, - tip_trans3); - G4SubtractionSolid* solidIntermediate3 = - new G4SubtractionSolid("Intermediate3", - solidTippedCone3, - solidSubtractionBox3, - firstBox_trans3); - G4SubtractionSolid* solidCrystal3 = - new G4SubtractionSolid("Crystal3", - solidIntermediate3, - solidSubtractionBox3, - secondBox_trans3); - - G4LogicalVolume* logicCrystal3 = - new G4LogicalVolume(solidCrystal3, //its solid - CsI, //its material - "CsI Detector3"); //its name - logicCrystal3->SetVisAttributes(crystalVisAtt); - logicCrystal3->SetSensitiveDetector(m_MicroballScorer); - - - // - // Light Guide - // - G4double lightGuide_px3 = 10*mm; - G4double lightGuide_py3 = 10*mm; - G4double lightGuide_pz3 = lgThickness3; - G4Box* solidLightGuide3 = - new G4Box("LightGuide3", //its name - 0.5*lightGuide_px3, - 0.5*lightGuide_py3, - 0.5*lightGuide_pz3); //its size - - G4LogicalVolume* logicLightGuide3 = - new G4LogicalVolume(solidLightGuide3, //its solid - glass, //its material - "LightGuide3"); //its name - logicLightGuide3->SetVisAttributes(lightGuideVisAtt); - - - for(int i = 1; i <= detNum3; i++) - { - G4RotationMatrix crystal_rotm = G4RotationMatrix(); - G4ThreeVector d0 = G4ThreeVector(distanceFromTarget3*sin(coneangle3)*cos(0.5*360*deg/detNum3), - distanceFromTarget3*sin(coneangle3)*sin(0.5*360*deg/detNum3), - distanceFromTarget3*cos(coneangle3)); - G4ThreeVector df = G4ThreeVector(distanceFromTarget3*sin(theta3)*sin((i-1)*360*deg/detNum3+.001*deg/*+0.5*360*deg/detNum3*/), - distanceFromTarget3*sin(theta3)*cos((i-1)*360*deg/detNum3+.001*deg/*+0.5*360*deg/detNum3*/), - -distanceFromTarget3*cos(theta3)); - G4ThreeVector axis = d0.cross(df); - G4double ax = axis.x(); - G4double ay = axis.y(); - G4double az = axis.z(); - G4double ux = ax/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double uy = ay/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double uz = az/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double j = acos(d0.dot(df)/(d0.mag()*df.mag())); - G4ThreeVector a = G4ThreeVector(cos(j)+pow(ux,2)*(1-cos(j)), ux*uy*(1-cos(j))-uz*sin(j), ux*uz*(1-cos(j))+uy*sin(j)); - G4ThreeVector b = G4ThreeVector(uy*ux*(1-cos(j))+uz*sin(j), cos(j)+pow(uy,2)*(1-cos(j)), uy*uz*(1-cos(j))-ux*sin(j)); - G4ThreeVector c = G4ThreeVector(uz*ux*(1-cos(j))-uy*sin(j), uz*uy*(1-cos(j))+ux*sin(j), cos(j)+pow(uz,2)*(1-cos(j))); - G4RotationMatrix abc = G4RotationMatrix(); - abc.setRows(a,b,c); - G4ThreeVector unitdf = df/df.mag(); - G4double udfx = unitdf.x(); - G4double udfy = unitdf.y(); - G4double udfz = unitdf.z(); - G4double k = 180.*deg; - G4ThreeVector d = G4ThreeVector(cos(k)+pow(udfx,2)*(1-cos(k)), udfx*udfy*(1-cos(k))-udfz*sin(k), udfx*udfz*(1-cos(k))+udfy*sin(k)); - G4ThreeVector e = G4ThreeVector(udfy*udfx*(1-cos(k))+udfz*sin(k), cos(k)+pow(udfy,2)*(1-cos(k)), udfy*udfz*(1-cos(k))-udfx*sin(k)); - G4ThreeVector f = G4ThreeVector(udfz*udfx*(1-cos(k))-udfy*sin(k), udfz*udfy*(1-cos(k))+udfx*sin(k), cos(k)+pow(udfz,2)*(1-cos(k))); - G4RotationMatrix def = G4RotationMatrix(); - def.setRows(d,e,f); - crystal_rotm=def*abc; - if (m_Flip == 0){ - crystal_rotm.rotateY(180*deg); - } - crystal_rotm.rotateZ(180*deg); - G4ThreeVector crystal_pos = G4ThreeVector(0,0,0); - G4Transform3D crystal_trans = G4Transform3D(crystal_rotm, crystal_pos); - G4RotationMatrix lg_rotm = G4RotationMatrix(); - G4ThreeVector lg_Axis = df.cross(z3); - lg_Axis = lg_Axis/lg_Axis.mag(); - lg_Axis.rotateZ(180*deg); - G4double ulgx = lg_Axis.x(); - G4double ulgy = lg_Axis.y(); - G4double ulgz = lg_Axis.z(); - G4ThreeVector p = G4ThreeVector(cos(theta3)+pow(ulgx,2)*(1-cos(theta3)), ulgx*ulgy*(1-cos(theta3))-ulgz*sin(theta3), ulgx*ulgz*(1-cos(theta3))+ulgy*sin(theta3)); - G4ThreeVector q = G4ThreeVector(ulgy*ulgx*(1-cos(theta3))+ulgz*sin(theta3), cos(theta3)+pow(ulgy,2)*(1-cos(theta3)), ulgy*ulgz*(1-cos(theta3))-ulgx*sin(theta3)); - G4ThreeVector r = G4ThreeVector(ulgz*ulgx*(1-cos(theta3))-ulgy*sin(theta3), ulgz*ulgy*(1-cos(theta3))+ulgx*sin(theta3), cos(theta3)+pow(ulgz,2)*(1-cos(theta3))); - G4RotationMatrix pqr = G4RotationMatrix(); - pqr.setRows(p,q,r); - lg_rotm.rotateZ((i-1)*360*deg/detNum3); - lg_rotm.rotateX(180*deg); - lg_rotm=pqr*lg_rotm; - G4ThreeVector lg_pos = (distanceFromTarget3+detThickness3+0.5*lgThickness3)/df.mag()*df; - lg_pos.rotateZ(180*deg); - if (m_Flip == 0){ - lg_pos.rotateY(180*deg); - lg_rotm.rotateY(180*deg); - } - G4Transform3D lg_trans = G4Transform3D(lg_rotm, lg_pos); - G4RotationMatrix delrin_rotm = G4RotationMatrix(); - G4ThreeVector w = G4ThreeVector(sin(theta3)*sin((i-1)*360*deg/detNum3+.001*deg), sin(theta3)*cos((i-1)*360*deg/detNum3+.001*deg), cos(theta3)); - G4ThreeVector delrin_Axis = w.cross(z3); - delrin_Axis.rotateX(180*deg); - delrin_Axis = delrin_Axis/delrin_Axis.mag(); - G4double udx = delrin_Axis.x(); - G4double udy = delrin_Axis.y(); - G4double udz = delrin_Axis.z(); - G4double delAng = 90*deg+theta3; - G4ThreeVector pdel = G4ThreeVector(cos(delAng)+pow(udx,2)*(1-cos(delAng)), udx*udy*(1-cos(delAng))-udz*sin(delAng), udx*udz*(1-cos(delAng))+udy*sin(delAng)); - G4ThreeVector qdel = G4ThreeVector(udy*udx*(1-cos(delAng))+udz*sin(delAng), cos(delAng)+pow(udy,2)*(1-cos(delAng)), udy*udz*(1-cos(delAng))-udx*sin(delAng)); - G4ThreeVector rdel = G4ThreeVector(udz*udx*(1-cos(delAng))-udy*sin(delAng), udz*udy*(1-cos(delAng))+udx*sin(delAng), cos(delAng)+pow(udz,2)*(1-cos(delAng))); - G4RotationMatrix pqrdel = G4RotationMatrix(); - pqrdel.setRows(pdel,qdel,rdel); - delrin_rotm.rotateZ((i-1)*360*deg/detNum3+.001*deg); - delrin_rotm=pqrdel*delrin_rotm; - delrin_rotm.rotateZ(0*deg); - G4ThreeVector delrin_pos = (distanceFromTarget3+detThickness3+lgThickness3+delrinA3/2+.0003*mm)/df.mag()*df; //the .0003 mm is a fudge factor to prevent overlapping - delrin_pos.rotateZ(180*deg); - delrin_pos.rotateY(180*deg); - if (m_Flip == 1){ - delrin_pos.rotateY(180*deg); - delrin_rotm.rotateY(180*deg); - } - G4Transform3D delrin_trans = G4Transform3D(delrin_rotm, delrin_pos); - //if(i != 1){ - bool placeCrystal = true; - for (unsigned int i2=0; i2 < m_Array.size(); i2++){ - if (16 < m_Array[i2] && m_Array[i2] < 29){ - if (m_Array[i2] == 16+i){ - placeCrystal = false; - } - } - } - if (placeCrystal){ - if(crystalBool) {new G4PVPlacement(crystal_trans, //rotation, position - logicCrystal3, //its logical volume - "CsI Detector3", //its name - world, //its mother volume - false, //no boolean operation - 16+i, //copy number - checkOverlaps); //overlaps checking - } - if(lgBool) {new G4PVPlacement(lg_trans, //rotation, position - logicLightGuide3, //its logical volume - "LightGuide3", //its name - world, //its mother volume - false, //no boolean operation - 16+i, //copy number - checkOverlaps); //overlaps checking - } - if(delrinBool) {new G4PVPlacement(delrin_trans, //rotation, position - logicDelrin3, //its logical volume - "Delrin3", //its name - world, //its mother volume - false, //no boolean operation - 16+i, //copy number - checkOverlaps); //overlaps checking - } - } - //} - }} - - if(m_Ring4){ - // Ring 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - G4int detNum4 = 12; - G4double distanceFromTargetBack4 = 50.*mm; - G4double theta4 = 52.0*deg; - G4double halfTheta4 = 8.0*deg; // fudge factor - G4double lgThickness4 = 6.0*mm; - G4double detThickness4 = 6.0*mm; - G4double distanceFromTarget4 = distanceFromTargetBack4 - detThickness4; - - //G4double distance4 = distanceFromTarget4*sin(theta4); //this gives the distance from the beam axis. - - // - // Delrin Ring - // - G4double delrinA4 = 5*mm; - G4double delrinB4 = 10*mm; - G4double fdelrinHalfAngle4 = atan(delrinB4/2/(distanceFromTarget4+detThickness4+lgThickness4)); - G4double firs4 = pow(pow(distanceFromTarget4+detThickness4+lgThickness4,2)+pow(delrinB4/2,2),0.5)*sin(theta4-fdelrinHalfAngle4); - G4double firb4 = pow(pow(distanceFromTarget4+detThickness4+lgThickness4,2)+pow(delrinB4/2,2),0.5)*sin(theta4+fdelrinHalfAngle4); - G4double bdelrinHalfAngle4 = atan(delrinB4/2/(distanceFromTarget4+detThickness4+lgThickness4+delrinA4)); - G4double birs4 = pow(pow(distanceFromTarget4+detThickness4+lgThickness4+delrinA4,2)+pow(delrinB4/2,2),0.5)*sin(theta4-bdelrinHalfAngle4); - G4double birb4 = pow(pow(distanceFromTarget4+detThickness4+lgThickness4+delrinA4,2)+pow(delrinB4/2,2),0.5)*sin(theta4+bdelrinHalfAngle4); - - G4double delrin_dz4 = delrinB4/2; - G4double delrin_theta4 = 0; - G4double delrin_phi4 = 0; - G4double delrin_dyab4 = delrinA4/2; - G4double delrin_dxa4 = firs4*tan(180*deg/detNum4); - G4double delrin_dxb4 = birs4*tan(180*deg/detNum4); - G4double delrin_dycd4 = delrinA4/2; - G4double delrin_dxc4 = firb4*tan(180*deg/detNum4); - G4double delrin_dxd4 = birb4*tan(180*deg/detNum4); - G4double delrin_alpab4 = 0; - G4double delrin_alpcd4 = delrin_alpab4; - + // Finding another telescope (safety), toggle out + else if (DataBuffer.compare(0, name.length(),name) == 0) { + G4cout << "WARNING: Another Detector is find before standard sequence of Token, Error may occured in Telecope definition" << G4endl ; + ReadingStatus = false ; + } - G4ThreeVector delrin_pos4 = G4ThreeVector(0,0,distanceFromTarget4*cos(theta4)); - - G4Trap* solidDelrin4 = - new G4Trap("Delrin4", //its name - delrin_dz4, - delrin_theta4, delrin_phi4, - delrin_dyab4, - delrin_dxa4, delrin_dxb4, - delrin_alpab4, - delrin_dycd4, - delrin_dxc4, delrin_dxd4, - delrin_alpcd4); //its size - - G4LogicalVolume* logicDelrin4 = - new G4LogicalVolume(solidDelrin4, //its solid - delrin, //its material - "Delrin4"); //its name - logicDelrin4->SetVisAttributes(delrinVisAtt); - - - // - // CsI Detector - // - G4double coneheight4 = distanceFromTarget4; - G4double flatheight4 = coneheight4 - 0.01*mm; - G4double coneangle4 = theta4; - G4double crystal_rmina4 = (coneheight4-flatheight4)*tan(coneangle4-halfTheta4); - G4double crystal_rmaxa4 = (coneheight4-flatheight4)*tan(coneangle4+halfTheta4); - G4double crystal_rminb4 = coneheight4*tan(coneangle4-halfTheta4); - G4double crystal_rmaxb4 = coneheight4*tan(coneangle4+halfTheta4); - G4double crystal_hz4 = 0.5*flatheight4;//(crystal_rmaxb4-crystal_rmaxa4)/crystal_rmaxb4*coneheight4; - G4double crystal_phimin4 = 0.*deg, crystal_phimax4 = 360.*deg/detNum4; - G4RotationMatrix tip_rotm4 = G4RotationMatrix(); - G4ThreeVector tip_pos4 = G4ThreeVector(0,0,0.5*flatheight4+(coneheight4-flatheight4)); - G4Transform3D tip_trans4 = G4Transform3D(tip_rotm4, tip_pos4); - G4ThreeVector z4 = G4ThreeVector(0,0,1); - G4ThreeVector d04 = G4ThreeVector(distanceFromTarget4*sin(coneangle4)*cos(0.5*360*deg/detNum4), - distanceFromTarget4*sin(coneangle4)*sin(0.5*360*deg/detNum4), - distanceFromTarget4*cos(coneangle4)); - G4ThreeVector unitAxis4 = z4.cross(d04); - unitAxis4 = unitAxis4/unitAxis4.mag(); - G4double ux4 = unitAxis4.x(); - G4double uy4 = unitAxis4.y(); - G4double uz4 = unitAxis4.z(); - G4ThreeVector top4 = G4ThreeVector(cos(coneangle4)+pow(ux4,2)*(1-cos(coneangle4)), ux4*uy4*(1-cos(coneangle4))-uz4*sin(coneangle4), ux4*uz4*(1-cos(coneangle4))+uy4*sin(coneangle4)); - G4ThreeVector mid4 = G4ThreeVector(uy4*ux4*(1-cos(coneangle4))+uz4*sin(coneangle4), cos(coneangle4)+pow(uy4,2)*(1-cos(coneangle4)), uy4*uz4*(1-cos(coneangle4))-ux4*sin(coneangle4)); - G4ThreeVector bot4 = G4ThreeVector(uz4*ux4*(1-cos(coneangle4))-uy4*sin(coneangle4), uz4*uy4*(1-cos(coneangle4))+ux4*sin(coneangle4), cos(coneangle4)+pow(uz4,2)*(1-cos(coneangle4))); - G4RotationMatrix firstBox_rotm4 = G4RotationMatrix(); - firstBox_rotm4.setRows(top4,mid4,bot4); - G4ThreeVector firstBox_pos4 = G4ThreeVector(0,0,0); - G4Transform3D firstBox_trans4 = G4Transform3D(firstBox_rotm4, firstBox_pos4); - G4RotationMatrix secondBox_rotm4 = G4RotationMatrix(); - secondBox_rotm4.setRows(top4,mid4,bot4); - G4ThreeVector secondBox_pos4 = (2*distanceFromTarget4+detThickness4)/distanceFromTarget4*d04; - G4Transform3D secondBox_trans4 = G4Transform3D(secondBox_rotm4, secondBox_pos4); - - G4Orb* solidTip4 = - new G4Orb("tip4", - .0001*mm); - G4Box* solidSubtractionBox4 = - new G4Box("SubtractionBox4", //its name - distanceFromTarget4, - distanceFromTarget4, - distanceFromTarget4); //its size - G4Cons* solidCone4 = - new G4Cons("Cone4", //its name - crystal_rmina4, crystal_rmaxa4, - crystal_rminb4, crystal_rmaxb4, - crystal_hz4, - crystal_phimin4, crystal_phimax4); //its size - G4UnionSolid* solidTippedCone4 = - new G4UnionSolid("TippedCone4", - solidTip4, - solidCone4, - tip_trans4); - G4SubtractionSolid* solidIntermediate4 = - new G4SubtractionSolid("Intermediate4", - solidTippedCone4, - solidSubtractionBox4, - firstBox_trans4); - G4SubtractionSolid* solidCrystal4 = - new G4SubtractionSolid("Crystal4", - solidIntermediate4, - solidSubtractionBox4, - secondBox_trans4); - - G4LogicalVolume* logicCrystal4 = - new G4LogicalVolume(solidCrystal4, //its solid - CsI, //its material - "CsI Detector4"); //its name - logicCrystal4->SetVisAttributes(crystalVisAtt); - logicCrystal4->SetSensitiveDetector(m_MicroballScorer); - - // - // Light Guide - // - G4double lightGuide_px4 = 10*mm; - G4double lightGuide_py4 = 10*mm; - G4double lightGuide_pz4 = lgThickness4; - G4Box* solidLightGuide4 = - new G4Box("LightGuide4", //its name - 0.5*lightGuide_px4, - 0.5*lightGuide_py4, - 0.5*lightGuide_pz4); //its size - - G4LogicalVolume* logicLightGuide4 = - new G4LogicalVolume(solidLightGuide4, //its solid - glass, //its material - "LightGuide4"); //its name - logicLightGuide4->SetVisAttributes(lightGuideVisAtt); - - - for(int i = 1; i <= detNum4; i++) - { - G4RotationMatrix crystal_rotm = G4RotationMatrix(); - G4ThreeVector d0 = G4ThreeVector(distanceFromTarget4*sin(coneangle4)*cos(0.5*360*deg/detNum4), - distanceFromTarget4*sin(coneangle4)*sin(0.5*360*deg/detNum4), - distanceFromTarget4*cos(coneangle4)); - G4ThreeVector df = G4ThreeVector(distanceFromTarget4*sin(theta4)*sin((i-1)*360*deg/detNum4+.001*deg/*+0.5*360*deg/detNum4*/), - distanceFromTarget4*sin(theta4)*cos((i-1)*360*deg/detNum4+.001*deg/*+0.5*360*deg/detNum4*/), - -distanceFromTarget4*cos(theta4)); - G4ThreeVector axis = d0.cross(df); - G4double ax = axis.x(); - G4double ay = axis.y(); - G4double az = axis.z(); - G4double ux = ax/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double uy = ay/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double uz = az/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double j = acos(d0.dot(df)/(d0.mag()*df.mag())); - G4ThreeVector a = G4ThreeVector(cos(j)+pow(ux,2)*(1-cos(j)), ux*uy*(1-cos(j))-uz*sin(j), ux*uz*(1-cos(j))+uy*sin(j)); - G4ThreeVector b = G4ThreeVector(uy*ux*(1-cos(j))+uz*sin(j), cos(j)+pow(uy,2)*(1-cos(j)), uy*uz*(1-cos(j))-ux*sin(j)); - G4ThreeVector c = G4ThreeVector(uz*ux*(1-cos(j))-uy*sin(j), uz*uy*(1-cos(j))+ux*sin(j), cos(j)+pow(uz,2)*(1-cos(j))); - G4RotationMatrix abc = G4RotationMatrix(); - abc.setRows(a,b,c); - G4ThreeVector unitdf = df/df.mag(); - G4double udfx = unitdf.x(); - G4double udfy = unitdf.y(); - G4double udfz = unitdf.z(); - G4double k = 180.*deg; - G4ThreeVector d = G4ThreeVector(cos(k)+pow(udfx,2)*(1-cos(k)), udfx*udfy*(1-cos(k))-udfz*sin(k), udfx*udfz*(1-cos(k))+udfy*sin(k)); - G4ThreeVector e = G4ThreeVector(udfy*udfx*(1-cos(k))+udfz*sin(k), cos(k)+pow(udfy,2)*(1-cos(k)), udfy*udfz*(1-cos(k))-udfx*sin(k)); - G4ThreeVector f = G4ThreeVector(udfz*udfx*(1-cos(k))-udfy*sin(k), udfz*udfy*(1-cos(k))+udfx*sin(k), cos(k)+pow(udfz,2)*(1-cos(k))); - G4RotationMatrix def = G4RotationMatrix(); - def.setRows(d,e,f); - crystal_rotm=def*abc; - if (m_Flip == 0){ - crystal_rotm.rotateY(180*deg); - } - crystal_rotm.rotateZ(180*deg); - G4ThreeVector crystal_pos = G4ThreeVector(0,0,0); - G4Transform3D crystal_trans = G4Transform3D(crystal_rotm, crystal_pos); - G4RotationMatrix lg_rotm = G4RotationMatrix(); - G4ThreeVector lg_Axis = df.cross(z4); - lg_Axis = lg_Axis/lg_Axis.mag(); - lg_Axis.rotateZ(180*deg); - G4double ulgx = lg_Axis.x(); - G4double ulgy = lg_Axis.y(); - G4double ulgz = lg_Axis.z(); - G4ThreeVector p = G4ThreeVector(cos(theta4)+pow(ulgx,2)*(1-cos(theta4)), ulgx*ulgy*(1-cos(theta4))-ulgz*sin(theta4), ulgx*ulgz*(1-cos(theta4))+ulgy*sin(theta4)); - G4ThreeVector q = G4ThreeVector(ulgy*ulgx*(1-cos(theta4))+ulgz*sin(theta4), cos(theta4)+pow(ulgy,2)*(1-cos(theta4)), ulgy*ulgz*(1-cos(theta4))-ulgx*sin(theta4)); - G4ThreeVector r = G4ThreeVector(ulgz*ulgx*(1-cos(theta4))-ulgy*sin(theta4), ulgz*ulgy*(1-cos(theta4))+ulgx*sin(theta4), cos(theta4)+pow(ulgz,2)*(1-cos(theta4))); - G4RotationMatrix pqr = G4RotationMatrix(); - pqr.setRows(p,q,r); - lg_rotm.rotateZ((i-1)*360*deg/detNum4); - lg_rotm.rotateX(180*deg); - lg_rotm=pqr*lg_rotm; - G4ThreeVector lg_pos = (distanceFromTarget4+detThickness4+0.5*lgThickness4)/df.mag()*df; - lg_pos.rotateZ(180*deg); - if (m_Flip == 0){ - lg_pos.rotateY(180*deg); - lg_rotm.rotateY(180*deg); - } - G4Transform3D lg_trans = G4Transform3D(lg_rotm, lg_pos); - G4RotationMatrix delrin_rotm = G4RotationMatrix(); - G4ThreeVector w = G4ThreeVector(sin(theta4)*sin((i-1)*360*deg/detNum4+.001*deg), sin(theta4)*cos((i-1)*360*deg/detNum4+.001*deg), cos(theta4)); - G4ThreeVector delrin_Axis = w.cross(z4); - delrin_Axis.rotateX(180*deg); - delrin_Axis = delrin_Axis/delrin_Axis.mag(); - G4double udx = delrin_Axis.x(); - G4double udy = delrin_Axis.y(); - G4double udz = delrin_Axis.z(); - G4double delAng = 90*deg+theta4; - G4ThreeVector pdel = G4ThreeVector(cos(delAng)+pow(udx,2)*(1-cos(delAng)), udx*udy*(1-cos(delAng))-udz*sin(delAng), udx*udz*(1-cos(delAng))+udy*sin(delAng)); - G4ThreeVector qdel = G4ThreeVector(udy*udx*(1-cos(delAng))+udz*sin(delAng), cos(delAng)+pow(udy,2)*(1-cos(delAng)), udy*udz*(1-cos(delAng))-udx*sin(delAng)); - G4ThreeVector rdel = G4ThreeVector(udz*udx*(1-cos(delAng))-udy*sin(delAng), udz*udy*(1-cos(delAng))+udx*sin(delAng), cos(delAng)+pow(udz,2)*(1-cos(delAng))); - G4RotationMatrix pqrdel = G4RotationMatrix(); - pqrdel.setRows(pdel,qdel,rdel); - delrin_rotm.rotateZ((i-1)*360*deg/detNum4+.001*deg); - delrin_rotm=pqrdel*delrin_rotm; - delrin_rotm.rotateZ(0*deg); - G4ThreeVector delrin_pos = (distanceFromTarget4+detThickness4+lgThickness4+delrinA4/2+.0001*mm)/df.mag()*df; //the .0003 mm is a fudge factor to prevent overlapping - delrin_pos.rotateZ(180*deg); - delrin_pos.rotateY(180*deg); - if (m_Flip == 1){ - delrin_pos.rotateY(180*deg); - delrin_rotm.rotateY(180*deg); - } - G4Transform3D delrin_trans = G4Transform3D(delrin_rotm, delrin_pos); - //if(i != 1){ - bool placeCrystal = true; - for (unsigned int i2=0; i2 < m_Array.size(); i2++){ - if (28 < m_Array[i2] && m_Array[i2] < 41){ - if (m_Array[i2] == 28+i){ - placeCrystal = false; - } - } - } - if (placeCrystal){ - if(crystalBool) {new G4PVPlacement(crystal_trans, //rotation, position - logicCrystal4, //its logical volume - "CsI Detector4", //its name - world, //its mother volume - false, //no boolean operation - 28+i, //copy number - checkOverlaps); //overlaps checking - } - if(lgBool) {new G4PVPlacement(lg_trans, //rotation, position - logicLightGuide4, //its logical volume - "LightGuide4", //its name - world, //its mother volume - false, //no boolean operation - 28+i, //copy number - checkOverlaps); //overlaps checking - } - if(delrinBool) {new G4PVPlacement(delrin_trans, //rotation, position - logicDelrin4, //its logical volume - "Delrin4", //its name - world, //its mother volume - false, //no boolean operation - 28+i, //copy number - checkOverlaps); //overlaps checking - } - } - //} - }} - - if(m_Ring5){ - // Ring 5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - G4int detNum5 = 14; - G4double distanceFromTargetBack5 = 50.*mm; - G4double theta5 = 70.0*deg; - G4double halfTheta5 = 10.0*deg;// -0.1*deg; //fudge factor - G4double lgThickness5 = 6.0*mm; - G4double detThickness5 = 5.6*mm; - G4double distanceFromTarget5 = distanceFromTargetBack5 - detThickness5; - - //G4double distance5 = distanceFromTarget5*sin(theta5); //this gives the distance from the beam axis. - - // - // Delrin Ring - // - G4double delrinA5 = 5*mm; - G4double delrinB5 = 10*mm; - G4double fdelrinHalfAngle5 = atan(delrinB5/2/(distanceFromTarget5+detThickness5+lgThickness5)); - G4double firs5 = pow(pow(distanceFromTarget5+detThickness5+lgThickness5,2)+pow(delrinB5/2,2),0.5)*sin(theta5-fdelrinHalfAngle5); - G4double firb5 = pow(pow(distanceFromTarget5+detThickness5+lgThickness5,2)+pow(delrinB5/2,2),0.5)*sin(theta5+fdelrinHalfAngle5); - G4double bdelrinHalfAngle5 = atan(delrinB5/2/(distanceFromTarget5+detThickness5+lgThickness5+delrinA5)); - G4double birs5 = pow(pow(distanceFromTarget5+detThickness5+lgThickness5+delrinA5,2)+pow(delrinB5/2,2),0.5)*sin(theta5-bdelrinHalfAngle5); - G4double birb5 = pow(pow(distanceFromTarget5+detThickness5+lgThickness5+delrinA5,2)+pow(delrinB5/2,2),0.5)*sin(theta5+bdelrinHalfAngle5); - - G4double delrin_dz5 = delrinB5/2; - G4double delrin_theta5 = 0; - G4double delrin_phi5 = 0; - G4double delrin_dyab5 = delrinA5/2; - G4double delrin_dxa5 = firs5*tan(180*deg/detNum5); - G4double delrin_dxb5 = birs5*tan(180*deg/detNum5); - G4double delrin_dycd5 = delrinA5/2; - G4double delrin_dxc5 = firb5*tan(180*deg/detNum5); - G4double delrin_dxd5 = birb5*tan(180*deg/detNum5); - G4double delrin_alpab5 = 0; - G4double delrin_alpcd5 = delrin_alpab5; - + //Angle method + else if (DataBuffer.compare(0, 6, "RING1=") == 0) { + check_Ring1 = true; + ConfigFile >> DataBuffer ; + bR1 = atoi(DataBuffer.c_str()) ; + G4cout << "Ring1: " << bR1 << G4endl; + } - G4ThreeVector delrin_pos5 = G4ThreeVector(0,0,distanceFromTarget5*cos(theta5)); - - G4Trap* solidDelrin5 = - new G4Trap("Delrin5", //its name - delrin_dz5, - delrin_theta5, delrin_phi5, - delrin_dyab5, - delrin_dxa5, delrin_dxb5, - delrin_alpab5, - delrin_dycd5, - delrin_dxc5, delrin_dxd5, - delrin_alpcd5); //its size - - G4LogicalVolume* logicDelrin5 = - new G4LogicalVolume(solidDelrin5, //its solid - delrin, //its material - "Delrin5"); //its name - logicDelrin5->SetVisAttributes(delrinVisAtt); - - - // - // CsI Detector - // - G4double coneheight5 = 0.6*distanceFromTarget5; - G4double flatheight5 = coneheight5 -0.01*mm; - G4double coneangle5 = theta5; - G4double crystal_rmina5 = (coneheight5-flatheight5)*tan(coneangle5-halfTheta5); - G4double crystal_rmaxa5 = (coneheight5-flatheight5)*tan(coneangle5+halfTheta5); - G4double crystal_rminb5 = coneheight5*tan(coneangle5-halfTheta5); - G4double crystal_rmaxb5 = coneheight5*tan(coneangle5+halfTheta5); - G4double crystal_hz5 = 0.5*flatheight5;//(crystal_rmaxb5-crystal_rmaxa5)/crystal_rmaxb5*coneheight5; - G4double crystal_phimin5 = 0.*deg, crystal_phimax5 = 360.*deg/detNum5; - G4RotationMatrix tip_rotm5 = G4RotationMatrix(); - G4ThreeVector tip_pos5 = G4ThreeVector(0,0,0.5*flatheight5+(coneheight5-flatheight5)); //last z term is a fudge - G4Transform3D tip_trans5 = G4Transform3D(tip_rotm5, tip_pos5); - G4ThreeVector z5 = G4ThreeVector(0,0,1); - G4ThreeVector d05 = G4ThreeVector(distanceFromTarget5*sin(coneangle5)*cos(0.5*360*deg/detNum5), - distanceFromTarget5*sin(coneangle5)*sin(0.5*360*deg/detNum5), - distanceFromTarget5*cos(coneangle5)); - G4ThreeVector unitAxis5 = z5.cross(d05); - unitAxis5 = unitAxis5/unitAxis5.mag(); - G4double ux5 = unitAxis5.x(); - G4double uy5 = unitAxis5.y(); - G4double uz5 = unitAxis5.z(); - G4ThreeVector top5 = G4ThreeVector(cos(coneangle5)+pow(ux5,2)*(1-cos(coneangle5)), ux5*uy5*(1-cos(coneangle5))-uz5*sin(coneangle5), ux5*uz5*(1-cos(coneangle5))+uy5*sin(coneangle5)); - G4ThreeVector mid5 = G4ThreeVector(uy5*ux5*(1-cos(coneangle5))+uz5*sin(coneangle5), cos(coneangle5)+pow(uy5,2)*(1-cos(coneangle5)), uy5*uz5*(1-cos(coneangle5))-ux5*sin(coneangle5)); - G4ThreeVector bot5 = G4ThreeVector(uz5*ux5*(1-cos(coneangle5))-uy5*sin(coneangle5), uz5*uy5*(1-cos(coneangle5))+ux5*sin(coneangle5), cos(coneangle5)+pow(uz5,2)*(1-cos(coneangle5))); - G4RotationMatrix firstBox_rotm5 = G4RotationMatrix(); - firstBox_rotm5.setRows(top5,mid5,bot5); - G4ThreeVector firstBox_pos5 = G4ThreeVector(0,0,0); - G4Transform3D firstBox_trans5 = G4Transform3D(firstBox_rotm5, firstBox_pos5); - G4RotationMatrix secondBox_rotm5 = G4RotationMatrix(); - secondBox_rotm5.setRows(top5,mid5,bot5); - G4ThreeVector secondBox_pos5 = (3*distanceFromTarget5+detThickness5)/distanceFromTarget5*d05; - G4Transform3D secondBox_trans5 = G4Transform3D(secondBox_rotm5, secondBox_pos5); - - G4Orb* solidTip5 = - new G4Orb("tip5", - .0001*mm); - G4Box* solidSubtractionBox5 = - new G4Box("SubtractionBox5", //its name - distanceFromTarget5, - distanceFromTarget5, - distanceFromTarget5); //its size - G4Box* solidSecondSubtractionBox5 = - new G4Box("SecondSubtractionBox5", //its name - 2*distanceFromTarget5, - 2*distanceFromTarget5, - 2*distanceFromTarget5); //its size - G4Cons* solidCone5 = - new G4Cons("Cone5", //its name - crystal_rmina5, crystal_rmaxa5, - crystal_rminb5, crystal_rmaxb5, - crystal_hz5, - crystal_phimin5, crystal_phimax5); //its size - G4UnionSolid* solidTippedCone5 = - new G4UnionSolid("TippedCone5", - solidTip5, - solidCone5, - tip_trans5); - G4SubtractionSolid* solidIntermediate5 = - new G4SubtractionSolid("Intermediate5", - solidTippedCone5, - solidSubtractionBox5, - firstBox_trans5); - G4SubtractionSolid* solidCrystal5 = - new G4SubtractionSolid("Crystal5", - solidIntermediate5, - solidSecondSubtractionBox5, - secondBox_trans5); - - G4LogicalVolume* logicCrystal5 = - new G4LogicalVolume(solidCrystal5, //its solid - CsI, //its material - "CsI Detector5"); //its name - logicCrystal5->SetVisAttributes(crystalVisAtt); - logicCrystal5->SetSensitiveDetector(m_MicroballScorer); - - - // - // Light Guide - // - G4double lightGuide_px5 = 10*mm; - G4double lightGuide_py5 = 10*mm; - G4double lightGuide_pz5 = lgThickness5; - G4Box* solidLightGuide5 = - new G4Box("LightGuide5", //its name - 0.5*lightGuide_px5, - 0.5*lightGuide_py5, - 0.5*lightGuide_pz5); //its size - - G4LogicalVolume* logicLightGuide5 = - new G4LogicalVolume(solidLightGuide5, //its solid - glass, //its material - "LightGuide5"); //its name - logicLightGuide5->SetVisAttributes(lightGuideVisAtt); - - - for(int i = 1; i <= detNum5; i++) - { - G4RotationMatrix crystal_rotm = G4RotationMatrix(); - G4ThreeVector d0 = G4ThreeVector(distanceFromTarget5*sin(coneangle5)*cos(0.5*360*deg/detNum5), - distanceFromTarget5*sin(coneangle5)*sin(0.5*360*deg/detNum5), - distanceFromTarget5*cos(coneangle5)); - G4ThreeVector df = G4ThreeVector(distanceFromTarget5*sin(theta5)*sin((i-1)*360*deg/detNum5+.001*deg/*+0.5*360*deg/detNum5*/), - distanceFromTarget5*sin(theta5)*cos((i-1)*360*deg/detNum5+.001*deg/*+0.5*360*deg/detNum5*/), - -distanceFromTarget5*cos(theta5)); - G4ThreeVector axis = d0.cross(df); - G4double ax = axis.x(); - G4double ay = axis.y(); - G4double az = axis.z(); - G4double ux = ax/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double uy = ay/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double uz = az/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double j = acos(d0.dot(df)/(d0.mag()*df.mag())); - G4ThreeVector a = G4ThreeVector(cos(j)+pow(ux,2)*(1-cos(j)), ux*uy*(1-cos(j))-uz*sin(j), ux*uz*(1-cos(j))+uy*sin(j)); - G4ThreeVector b = G4ThreeVector(uy*ux*(1-cos(j))+uz*sin(j), cos(j)+pow(uy,2)*(1-cos(j)), uy*uz*(1-cos(j))-ux*sin(j)); - G4ThreeVector c = G4ThreeVector(uz*ux*(1-cos(j))-uy*sin(j), uz*uy*(1-cos(j))+ux*sin(j), cos(j)+pow(uz,2)*(1-cos(j))); - G4RotationMatrix abc = G4RotationMatrix(); - abc.setRows(a,b,c); - G4ThreeVector unitdf = df/df.mag(); - G4double udfx = unitdf.x(); - G4double udfy = unitdf.y(); - G4double udfz = unitdf.z(); - G4double k = 180.*deg; - G4ThreeVector d = G4ThreeVector(cos(k)+pow(udfx,2)*(1-cos(k)), udfx*udfy*(1-cos(k))-udfz*sin(k), udfx*udfz*(1-cos(k))+udfy*sin(k)); - G4ThreeVector e = G4ThreeVector(udfy*udfx*(1-cos(k))+udfz*sin(k), cos(k)+pow(udfy,2)*(1-cos(k)), udfy*udfz*(1-cos(k))-udfx*sin(k)); - G4ThreeVector f = G4ThreeVector(udfz*udfx*(1-cos(k))-udfy*sin(k), udfz*udfy*(1-cos(k))+udfx*sin(k), cos(k)+pow(udfz,2)*(1-cos(k))); - G4RotationMatrix def = G4RotationMatrix(); - def.setRows(d,e,f); - crystal_rotm=def*abc; - if (m_Flip == 0){ - crystal_rotm.rotateY(180*deg); - } - crystal_rotm.rotateZ(180*deg); - G4ThreeVector crystal_pos = G4ThreeVector(0,0,0); - G4Transform3D crystal_trans = G4Transform3D(crystal_rotm, crystal_pos); - G4RotationMatrix lg_rotm = G4RotationMatrix(); - G4ThreeVector lg_Axis = df.cross(z5); - lg_Axis = lg_Axis/lg_Axis.mag(); - lg_Axis.rotateZ(180*deg); - G4double ulgx = lg_Axis.x(); - G4double ulgy = lg_Axis.y(); - G4double ulgz = lg_Axis.z(); - G4ThreeVector p = G4ThreeVector(cos(theta5)+pow(ulgx,2)*(1-cos(theta5)), ulgx*ulgy*(1-cos(theta5))-ulgz*sin(theta5), ulgx*ulgz*(1-cos(theta5))+ulgy*sin(theta5)); - G4ThreeVector q = G4ThreeVector(ulgy*ulgx*(1-cos(theta5))+ulgz*sin(theta5), cos(theta5)+pow(ulgy,2)*(1-cos(theta5)), ulgy*ulgz*(1-cos(theta5))-ulgx*sin(theta5)); - G4ThreeVector r = G4ThreeVector(ulgz*ulgx*(1-cos(theta5))-ulgy*sin(theta5), ulgz*ulgy*(1-cos(theta5))+ulgx*sin(theta5), cos(theta5)+pow(ulgz,2)*(1-cos(theta5))); - G4RotationMatrix pqr = G4RotationMatrix(); - pqr.setRows(p,q,r); - lg_rotm.rotateZ((i-1)*360*deg/detNum5); - lg_rotm.rotateX(180*deg); - lg_rotm=pqr*lg_rotm; - G4ThreeVector lg_pos = (distanceFromTarget5+detThickness5+0.5*lgThickness5)/df.mag()*df; - lg_pos.rotateZ(180*deg); - if (m_Flip == 0){ - lg_pos.rotateY(180*deg); - lg_rotm.rotateY(180*deg); - } - G4Transform3D lg_trans = G4Transform3D(lg_rotm, lg_pos); - G4RotationMatrix delrin_rotm = G4RotationMatrix(); - G4ThreeVector w = G4ThreeVector(sin(theta5)*sin((i-1)*360*deg/detNum5+.001*deg), sin(theta5)*cos((i-1)*360*deg/detNum5+.001*deg), cos(theta5)); - G4ThreeVector delrin_Axis = w.cross(z5); - delrin_Axis.rotateX(180*deg); - delrin_Axis = delrin_Axis/delrin_Axis.mag(); - G4double udx = delrin_Axis.x(); - G4double udy = delrin_Axis.y(); - G4double udz = delrin_Axis.z(); - G4double delAng = 90*deg+theta5; - G4ThreeVector pdel = G4ThreeVector(cos(delAng)+pow(udx,2)*(1-cos(delAng)), udx*udy*(1-cos(delAng))-udz*sin(delAng), udx*udz*(1-cos(delAng))+udy*sin(delAng)); - G4ThreeVector qdel = G4ThreeVector(udy*udx*(1-cos(delAng))+udz*sin(delAng), cos(delAng)+pow(udy,2)*(1-cos(delAng)), udy*udz*(1-cos(delAng))-udx*sin(delAng)); - G4ThreeVector rdel = G4ThreeVector(udz*udx*(1-cos(delAng))-udy*sin(delAng), udz*udy*(1-cos(delAng))+udx*sin(delAng), cos(delAng)+pow(udz,2)*(1-cos(delAng))); - G4RotationMatrix pqrdel = G4RotationMatrix(); - pqrdel.setRows(pdel,qdel,rdel); - delrin_rotm.rotateZ((i-1)*360*deg/detNum5+.001*deg); - delrin_rotm=pqrdel*delrin_rotm; - delrin_rotm.rotateZ(0*deg); - G4ThreeVector delrin_pos = (distanceFromTarget5+detThickness5+lgThickness5+delrinA5/2+.0004*mm)/df.mag()*df; //the .0003 mm is a fudge factor to prevent overlapping - delrin_pos.rotateZ(180*deg); - delrin_pos.rotateY(180*deg); - if (m_Flip == 1){ - delrin_pos.rotateY(180*deg); - delrin_rotm.rotateY(180*deg); - } - G4Transform3D delrin_trans = G4Transform3D(delrin_rotm, delrin_pos); - //if(i != 1){ - bool placeCrystal = true; - for (unsigned int i2=0; i2 < m_Array.size(); i2++){ - if (40 < m_Array[i2] && m_Array[i2] < 55){ - if (m_Array[i2] == 40+i){ - placeCrystal = false; - } - } - } - if (placeCrystal){ - if(crystalBool) {new G4PVPlacement(crystal_trans, //rotation, position - logicCrystal5, //its logical volume - "CsI Detector5", //its name - world, //its mother volume - false, //no boolean operation - 40+i, //copy number - checkOverlaps); //overlaps checking - } - if(lgBool) {new G4PVPlacement(lg_trans, //rotation, position - logicLightGuide5, //its logical volume - "LightGuide5", //its name - world, //its mother volume - false, //no boolean operation - 40+i, //copy number - checkOverlaps); //overlaps checking - } - //} - if(delrinBool) {new G4PVPlacement(delrin_trans, //rotation, position - logicDelrin5, //its logical volume - "Delrin5", //its name - world, //its mother volume - false, //no boolean operation - 40+i, //copy number - checkOverlaps); //overlaps checking - } - } - }} - - if(m_Ring6){ - // Ring 6 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this ring is weird. - G4int detNum6 = 14; - G4double distanceFromTargetBack6 = 50.*mm; - G4double theta6 = 90.0*deg; - G4double halfTheta6 = 10.0*deg;// -0.1*deg; - G4double lgThickness6 = 7.0*mm; - G4double detThickness6 = 5.2*mm; - G4double distanceFromTarget6 = distanceFromTargetBack6 - detThickness6; - - //G4double distance6 = distanceFromTarget6*sin(theta6); //this gives the distance from the beam axis. - - // - // Delrin Ring - // - G4double delrinA6 = 5*mm; - G4double delrinB6 = 10*mm; - G4double fdelrinHalfAngle6 = atan(delrinB6/2/(distanceFromTarget6+detThickness6+lgThickness6)); - G4double firs6 = pow(pow(distanceFromTarget6+detThickness6+lgThickness6,2)+pow(delrinB6/2,2),0.5)*sin(theta6-fdelrinHalfAngle6); - G4double firb6 = pow(pow(distanceFromTarget6+detThickness6+lgThickness6,2)+pow(delrinB6/2,2),0.5)*sin(theta6+fdelrinHalfAngle6); - G4double bdelrinHalfAngle6 = atan(delrinB6/2/(distanceFromTarget6+detThickness6+lgThickness6+delrinA6)); - G4double birs6 = pow(pow(distanceFromTarget6+detThickness6+lgThickness6+delrinA6,2)+pow(delrinB6/2,2),0.5)*sin(theta6-bdelrinHalfAngle6); - G4double birb6 = pow(pow(distanceFromTarget6+detThickness6+lgThickness6+delrinA6,2)+pow(delrinB6/2,2),0.5)*sin(theta6+bdelrinHalfAngle6); - - G4double delrin_dz6 = delrinB6/2; - G4double delrin_theta6 = 0; - G4double delrin_phi6 = 0; - G4double delrin_dyab6 = delrinA6/2; - G4double delrin_dxa6 = firs6*tan(180*deg/detNum6); - G4double delrin_dxb6 = birs6*tan(180*deg/detNum6); - G4double delrin_dycd6 = delrinA6/2; - G4double delrin_dxc6 = firb6*tan(180*deg/detNum6); - G4double delrin_dxd6 = birb6*tan(180*deg/detNum6); - G4double delrin_alpab6 = 0; - G4double delrin_alpcd6 = delrin_alpab6; - + else if (DataBuffer.compare(0, 6, "RING2=") == 0) { + check_Ring2 = true; + ConfigFile >> DataBuffer ; + bR2 = atoi(DataBuffer.c_str()) ; + G4cout << "Ring2: " << bR2 << G4endl; + } - G4ThreeVector delrin_pos6 = G4ThreeVector(0,0,distanceFromTarget6*cos(theta6)); - - G4Trap* solidDelrin6 = - new G4Trap("Delrin6", //its name - delrin_dz6, - delrin_theta6, delrin_phi6, - delrin_dyab6, - delrin_dxa6, delrin_dxb6, - delrin_alpab6, - delrin_dycd6, - delrin_dxc6, delrin_dxd6, - delrin_alpcd6); //its size - - G4LogicalVolume* logicDelrin6 = - new G4LogicalVolume(solidDelrin6, //its solid - delrin, //its material - "Delrin6"); //its name - logicDelrin6->SetVisAttributes(delrinVisAtt); - - - /* - // - // CsI Detector for deletion - // - G4double crystal_rmina6 = distance6/cos(halfTheta6); - G4double crystal_rmaxa6 = distance6/cos(halfTheta6)+2*distance6*tan(halfTheta6); - G4double crystal_rminb6 = (distance6+detThickness6)/cos(halfTheta6); - G4double crystal_rmaxb6 = (distance6+detThickness6)/cos(halfTheta6)+2*(distance6+detThickness6)*tan(halfTheta6); - G4double crystal_hz6 = 0.5*pow(pow(detThickness6,2)+pow((crystal_rminb6+crystal_rmaxb6-crystal_rmina6-crystal_rmaxa6)/2,2),0.5); - //G4double crystal_hz6 = 0.5*detThickness6; - G4double crystal_phimin6 = 0.*deg, crystal_phimax6 = 360.*deg/detNum6; - - - G4Cons* solidCrystal6 = - new G4Cons("Crystal6", //its name - crystal_rmina6, crystal_rmaxa6, - crystal_rminb6, crystal_rmaxb6, - crystal_hz6, - crystal_phimin6, crystal_phimax6); //its size - - G4LogicalVolume* logicCrystal6 = - new G4LogicalVolume(solidCrystal6, //its solid - CsI, //its material - "CsI Detector6"); //its name - logicCrystal6->SetVisAttributes(crystalVisAtt); - */ - - G4double crystal_dxa6 = distanceFromTarget6*tan(halfTheta6); - G4double crystal_dxb6 = (distanceFromTarget6+detThickness6)*tan(halfTheta6); - G4double crystal_dya6 = distanceFromTarget6*tan(0.5*360*deg/detNum6); - G4double crystal_dyb6 = (distanceFromTarget6+detThickness6)*tan(0.5*360*deg/detNum6); - G4double crystal_dz = 0.5*detThickness6; - - G4Trd* solidCrystal6 = - new G4Trd("Crystal6", //its name - crystal_dxa6, crystal_dxb6, - crystal_dya6, crystal_dyb6, - crystal_dz); //its size - G4LogicalVolume* logicCrystal6 = - new G4LogicalVolume(solidCrystal6, //its solid - CsI, //its material - "CsI Detector6"); //its name - logicCrystal6->SetVisAttributes(crystalVisAtt); - logicCrystal6->SetSensitiveDetector(m_MicroballScorer); - // - // Light Guide - // - G4double lightGuide_px6 = 10*mm; - G4double lightGuide_py6 = 10*mm; - G4double lightGuide_pz6 = lgThickness6; - G4Box* solidLightGuide6 = - new G4Box("LightGuide6", //its name - 0.5*lightGuide_px6, - 0.5*lightGuide_py6, - 0.5*lightGuide_pz6); //its size + else if (DataBuffer.compare(0, 6, "RING3=") == 0) { + check_Ring3 = true; + ConfigFile >> DataBuffer ; + bR3 = atoi(DataBuffer.c_str()) ; + G4cout << "Ring3: " << bR3 << G4endl; + } + + else if (DataBuffer.compare(0, 6, "RING4=") == 0) { + check_Ring4 = true; + ConfigFile >> DataBuffer ; + bR4 = atoi(DataBuffer.c_str()) ; + G4cout << "Ring4: " << bR4 << G4endl; + } + + else if (DataBuffer.compare(0, 6, "RING5=") == 0) { + check_Ring5 = true; + ConfigFile >> DataBuffer ; + bR5 = atoi(DataBuffer.c_str()) ; + G4cout << "Ring5: " << bR5 << G4endl; + } + + else if (DataBuffer.compare(0, 6, "RING6=") == 0) { + check_Ring6 = true; + ConfigFile >> DataBuffer ; + bR6 = atoi(DataBuffer.c_str()) ; + G4cout << "Ring6: " << bR6 << G4endl; + } + + else if (DataBuffer.compare(0, 6, "RING7=") == 0) { + check_Ring7 = true; + ConfigFile >> DataBuffer ; + bR7 = atoi(DataBuffer.c_str()) ; + G4cout << "Ring7: " << bR7 << G4endl; + } + + else if (DataBuffer.compare(0, 6, "RING8=") == 0) { + check_Ring8 = true; + ConfigFile >> DataBuffer ; + bR8 = atoi(DataBuffer.c_str()) ; + G4cout << "Ring8: " << bR8 << G4endl; + } + + + else if (DataBuffer.compare(0, 6, "RING9=") == 0) { + check_Ring9 = true; + ConfigFile >> DataBuffer ; + bR9 = atoi(DataBuffer.c_str()) ; + G4cout << "Ring9: " << bR9 << G4endl; + } + + else if (DataBuffer.compare(0, 15, "DISABLE_CRYSTAL") == 0) { + ConfigFile >> DataBuffer ; + int item = atoi(DataBuffer.c_str()); + copyNumArray.push_back(item) ; + G4cout << "Disabled crystal: " << item << G4endl; + } + + else if (DataBuffer.compare(0, 14, "DETECTOR_FLIP=") == 0) { + check_Flip = true; + ConfigFile >> DataBuffer ; + bFlip = atoi(DataBuffer.c_str()) ; + G4cout << "Flip Detector: " << bFlip << G4endl; + } + + else if (DataBuffer.compare(0, 16, "INCLUDE_CHAMBER=") == 0) { + check_Chamber = true; + ConfigFile >> DataBuffer ; + bChamber = atoi(DataBuffer.c_str()) ; + G4cout << "Include Chamber: " << bChamber << G4endl; + } + + + //General + + + /////////////////////////////////////////////////// + // If no Detector Token and no comment, toggle out + else{ + ReadingStatus = false; + G4cout << "Wrong Token Sequence: Getting out " << DataBuffer << G4endl ; + } + if(check_Ring1 && check_Ring2 && check_Ring3 && + check_Ring4 && check_Ring5 && check_Ring6 && + check_Ring7 && check_Ring8 && check_Ring9 && + check_Flip && check_Chamber){ + AddMicroball(bR1, bR2, bR3, + bR4, bR5, bR6, + bR7, bR8, bR9, + copyNumArray, bFlip, bChamber); - G4LogicalVolume* logicLightGuide6 = - new G4LogicalVolume(solidLightGuide6, //its solid - glass, //its material - "LightGuide6"); //its name - logicLightGuide6->SetVisAttributes(lightGuideVisAtt); - - - for(int i = 1; i <= detNum6; i++) - { - G4RotationMatrix crystal_rotm = G4RotationMatrix(); - /* - G4RotationMatrix abc6 = G4RotationMatrix(); - G4RotationMatrix def6 = G4RotationMatrix(); - G4ThreeVector a6 = G4ThreeVector(pow(sin(i*360*deg/detNum6),2), -sin(i*360*deg/detNum6)*cos(i*360*deg/detNum6), cos(i*360*deg/detNum6)); - G4ThreeVector b6 = G4ThreeVector(-sin(i*360*deg/detNum6)*cos(i*360*deg/detNum6), pow(cos(i*360*deg/detNum6),2), sin(i*360*deg/detNum6)); - G4ThreeVector c6 = G4ThreeVector(-cos(i*360*deg/detNum6), -sin(i*360*deg/detNum6), 0); - abc6.setRows(a6,b6,c6); - G4double k= (i-1)*360*deg/detNum6+0.5*360*deg/detNum6; - G4ThreeVector d6 = G4ThreeVector(cos(k)+pow(cos(i*360*deg/detNum6),2)*(1-cos(k)), - cos(i*360*deg/detNum6)*sin(i*360*deg/detNum6)*(1-cos(k)), - sin(i*360*deg/detNum6)*sin(k)); - G4ThreeVector e6 = G4ThreeVector(cos(i*360*deg/detNum6)*sin(i*360*deg/detNum6)*(1-cos(k)), - cos(k)+pow(sin(i*360*deg/detNum6),2)*(1-cos(k)), - -cos(i*360*deg/detNum6)*sin(k)); - G4ThreeVector f6 = G4ThreeVector(-sin(i*360*deg/detNum6)*sin(k), - cos(i*360*deg/detNum6)*sin(k), - cos(k)); - def6.setRows(d6,e6,f6); - crystal_rotm = def6*abc6; - */ - G4ThreeVector z6 = G4ThreeVector(0,0,1); - G4ThreeVector df6 = G4ThreeVector(cos((i-1)*360*deg/detNum6+0.5*360*deg/detNum6), - sin((i-1)*360*deg/detNum6+0.5*360*deg/detNum6), - 0); - G4ThreeVector unitAxis6 = z6.cross(df6); - unitAxis6 = unitAxis6/unitAxis6.mag(); - G4double ux6 = unitAxis6.x(); - G4double uy6 = unitAxis6.y(); - G4double uz6 = unitAxis6.z(); - G4double angle6 = acos(z6.dot(df6)/(z6.mag()*df6.mag())); - G4ThreeVector a6 = G4ThreeVector(cos(angle6)+pow(ux6,2)*(1-cos(angle6)), ux6*uy6*(1-cos(angle6))-uz6*sin(angle6), ux6*uz6*(1-cos(angle6))+uy6*sin(angle6)); - G4ThreeVector b6 = G4ThreeVector(uy6*ux6*(1-cos(angle6))+uz6*sin(angle6), cos(angle6)+pow(uy6,2)*(1-cos(angle6)), uy6*uz6*(1-cos(angle6))-ux6*sin(angle6)); - G4ThreeVector c6 = G4ThreeVector(uz6*ux6*(1-cos(angle6))-uy6*sin(angle6), uz6*uy6*(1-cos(angle6))+ux6*sin(angle6), cos(angle6)+pow(uz6,2)*(1-cos(angle6))); - G4RotationMatrix abc6 = G4RotationMatrix(); - abc6.setRows(a6,b6,c6); - crystal_rotm.rotateZ((i-1)*360*deg/detNum6+0.5*360*deg/detNum6); - crystal_rotm=abc6*crystal_rotm; - crystal_rotm.rotateZ(0*deg-4*360/14*deg); - G4ThreeVector crystal_pos = G4ThreeVector((distanceFromTarget6+0.5*detThickness6)*cos((i-1)*360*deg/detNum6+0.5*360*deg/detNum6), - (distanceFromTarget6+0.5*detThickness6)*sin((i-1)*360*deg/detNum6+0.5*360*deg/detNum6), - 0)+delrin_pos6; - crystal_pos.rotateZ(0*deg-4*360/14*deg); - if (m_Flip == 1){ - crystal_pos.setX(-crystal_pos.x()); - crystal_rotm.rotateY(180*deg); - } - G4Transform3D crystal_trans = G4Transform3D(crystal_rotm, crystal_pos); - G4RotationMatrix lg_rotm = G4RotationMatrix(); - G4ThreeVector df = G4ThreeVector(distanceFromTarget6*sin(theta6)*sin((i-1)*360*deg/detNum6/*+0.5*360*deg/detNum6*/), - distanceFromTarget6*sin(theta6)*cos((i-1)*360*deg/detNum6/*+0.5*360*deg/detNum6*/), - -distanceFromTarget6*cos(theta6)); - G4ThreeVector lg_Axis = df.cross(z6); - lg_Axis = lg_Axis/lg_Axis.mag(); - lg_Axis.rotateZ(180*deg); - G4double ulgx = lg_Axis.x(); - G4double ulgy = lg_Axis.y(); - G4double ulgz = lg_Axis.z(); - G4ThreeVector p = G4ThreeVector(cos(theta6)+pow(ulgx,2)*(1-cos(theta6)), ulgx*ulgy*(1-cos(theta6))-ulgz*sin(theta6), ulgx*ulgz*(1-cos(theta6))+ulgy*sin(theta6)); - G4ThreeVector q = G4ThreeVector(ulgy*ulgx*(1-cos(theta6))+ulgz*sin(theta6), cos(theta6)+pow(ulgy,2)*(1-cos(theta6)), ulgy*ulgz*(1-cos(theta6))-ulgx*sin(theta6)); - G4ThreeVector r = G4ThreeVector(ulgz*ulgx*(1-cos(theta6))-ulgy*sin(theta6), ulgz*ulgy*(1-cos(theta6))+ulgx*sin(theta6), cos(theta6)+pow(ulgz,2)*(1-cos(theta6))); - G4RotationMatrix pqr = G4RotationMatrix(); - pqr.setRows(p,q,r); - lg_rotm.rotateZ((i-1)*360*deg/detNum6); - lg_rotm.rotateX(180*deg); - lg_rotm=pqr*lg_rotm; - G4ThreeVector lg_pos = (distanceFromTarget6+detThickness6+0.5*lgThickness6+.09*mm)/df.mag()*df; //the .09 mm is a fudge factor to prevent overlapping. - lg_pos.rotateZ(180*deg); - if (m_Flip == 0){ - lg_pos.rotateY(180*deg); - lg_rotm.rotateY(180*deg); - } - G4Transform3D lg_trans = G4Transform3D(lg_rotm, lg_pos); - G4RotationMatrix delrin_rotm = G4RotationMatrix(); - G4ThreeVector w = G4ThreeVector(sin(theta6)*sin((i-1)*360*deg/detNum6+.001*deg), sin(theta6)*cos((i-1)*360*deg/detNum6+.001*deg), cos(theta6)); - G4ThreeVector delrin_Axis = w.cross(z6); - delrin_Axis = delrin_Axis/delrin_Axis.mag(); - G4double udx = delrin_Axis.x(); - G4double udy = delrin_Axis.y(); - G4double udz = delrin_Axis.z(); - G4double delAng = 0*deg;//90*deg+theta6; - G4ThreeVector pdel = G4ThreeVector(cos(delAng)+pow(udx,2)*(1-cos(delAng)), udx*udy*(1-cos(delAng))-udz*sin(delAng), udx*udz*(1-cos(delAng))+udy*sin(delAng)); - G4ThreeVector qdel = G4ThreeVector(udy*udx*(1-cos(delAng))+udz*sin(delAng), cos(delAng)+pow(udy,2)*(1-cos(delAng)), udy*udz*(1-cos(delAng))-udx*sin(delAng)); - G4ThreeVector rdel = G4ThreeVector(udz*udx*(1-cos(delAng))-udy*sin(delAng), udz*udy*(1-cos(delAng))+udx*sin(delAng), cos(delAng)+pow(udz,2)*(1-cos(delAng))); - G4RotationMatrix pqrdel = G4RotationMatrix(); - pqrdel.setRows(pdel,qdel,rdel); - delrin_rotm.rotateZ((i-1)*360*deg/detNum6+.001*deg); - delrin_rotm=pqrdel*delrin_rotm; - delrin_rotm.rotateZ(180*deg); - G4ThreeVector delrin_pos = (distanceFromTarget6+detThickness6+lgThickness6+delrinA6/2+.0904*mm)/df.mag()*df; //the .0003 mm is a fudge factor to prevent overlapping - delrin_pos.rotateZ(180*deg); - delrin_pos.rotateY(180*deg); - if (m_Flip == 1){ - delrin_pos.rotateY(180*deg); - delrin_rotm.rotateY(180*deg); - } - G4Transform3D delrin_trans = G4Transform3D(delrin_rotm, delrin_pos); - bool placeCrystal = true; - for (unsigned int i2=0; i2 < m_Array.size(); i2++){ - /*if(54 < m_Array[i2] && m_Array[i2] < 58){ - if (55+57-m_Array[i2] == 54+i){ - placeCrystal = false; - } - } - if(57 < m_Array[i2] && m_Array[i2] < 69){ - if (58+68-m_Array[i2] == 54+i){ - placeCrystal = false; - } - }*/ - if (54 < m_Array[i2] && m_Array[i2] < 69){ - if (m_Array[i2] == 54+i){ - placeCrystal = false; - } - } - } - if (placeCrystal){ - if(crystalBool) {new G4PVPlacement(crystal_trans, //rotation, position - logicCrystal6, //its logical volume - "CsI Detector6", //its name - world, //its mother volume - false, //no boolean operation - 54+i, //copy number - checkOverlaps); //overlaps checking - } - if(lgBool) {new G4PVPlacement(lg_trans, //rotation, position - logicLightGuide6, //its logical volume - "LightGuide6", //its name - world, //its mother volume - false, //no boolean operation - 54+i, //copy number - checkOverlaps); //overlaps checking - } - if(delrinBool) {new G4PVPlacement(delrin_trans, //rotation, position - logicDelrin6, //its logical volume - "Delrin6", //its name - world, //its mother volume - false, //no boolean operation - 54+i, //copy number - checkOverlaps); //overlaps checking - } - } - }} - - if(m_Ring7){ - // Ring 7 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lg pseudofixed - G4int detNum7 = 12; - G4double distanceFromTargetBack7 = 45.*mm; - G4double theta7 = 111.5*deg; - G4double halfTheta7 = 11.5*deg;//-0.1*deg; //fudge factor - G4double lgThickness7 = 7.0*mm; - G4double detThickness7 = 4.1*mm; - G4double distanceFromTarget7 = distanceFromTargetBack7 - detThickness7; - - //G4double distance7 = distanceFromTarget7*sin(theta7); //this gives the distance from the beam axis. - - /* - // - // Delrin Ring (for deletion) - // - G4double delrin_rmina7 = distance7+detThickness7+lgThickness7, delrin_rmaxa7 = delrin_rmina7+5*mm; - G4double delrin_hz7 = 5*mm; //distance7*tan(halfTheta7); - G4double delrin_phimin7 = 0.*deg, delrin_phimax7 = 360.*deg; - G4ThreeVector delrin_pos7 = G4ThreeVector(0,0,distanceFromTarget7*cos(theta7)); //G4ThreeVector(0,0,distance7+lgThickness7+detThickness7*sin(theta7)); - - G4Tubs* solidDelrin7 = - new G4Tubs("Delrin7", //its name - delrin_rmina7, delrin_rmaxa7, - delrin_hz7, - delrin_phimin7, delrin_phimax7); //its size - - G4LogicalVolume* logicDelrin7 = - new G4LogicalVolume(solidDelrin7, //its solid - delrin, //its material - "Delrin7"); //its name - logicDelrin7->SetVisAttributes(delrinVisAtt); - - if(delrinBool) {new G4PVPlacement(0, //no rotation - delrin_pos7, //its position - logicDelrin7, //its logical volume - "Delrin7", //its name - world, //its mother volume - false, //no boolean operation - 0, //copy number - checkOverlaps); //overlaps checking - } - */ - // - // Delrin Ring - // - G4double delrinA7 = 5*mm; - G4double delrinB7 = 10*mm; - G4double fdelrinHalfAngle7 = atan(delrinB7/2/(distanceFromTarget7+detThickness7+lgThickness7)); - G4double firs7 = pow(pow(distanceFromTarget7+detThickness7+lgThickness7,2)+pow(delrinB7/2,2),0.5)*sin(theta7-fdelrinHalfAngle7); - G4double firb7 = pow(pow(distanceFromTarget7+detThickness7+lgThickness7,2)+pow(delrinB7/2,2),0.5)*sin(theta7+fdelrinHalfAngle7); - G4double bdelrinHalfAngle7 = atan(delrinB7/2/(distanceFromTarget7+detThickness7+lgThickness7+delrinA7)); - G4double birs7 = pow(pow(distanceFromTarget7+detThickness7+lgThickness7+delrinA7,2)+pow(delrinB7/2,2),0.5)*sin(theta7-bdelrinHalfAngle7); - G4double birb7 = pow(pow(distanceFromTarget7+detThickness7+lgThickness7+delrinA7,2)+pow(delrinB7/2,2),0.5)*sin(theta7+bdelrinHalfAngle7); - - G4double delrin_dz7 = delrinB7/2; - G4double delrin_theta7 = 0; - G4double delrin_phi7 = 0; - G4double delrin_dyab7 = delrinA7/2; - G4double delrin_dxa7 = firs7*tan(180*deg/detNum7); - G4double delrin_dxb7 = birs7*tan(180*deg/detNum7); - G4double delrin_dycd7 = delrinA7/2; - G4double delrin_dxc7 = firb7*tan(180*deg/detNum7); - G4double delrin_dxd7 = birb7*tan(180*deg/detNum7); - G4double delrin_alpab7 = 0; - G4double delrin_alpcd7 = delrin_alpab7; - - G4ThreeVector delrin_pos7 = G4ThreeVector(0,0,distanceFromTarget7*cos(theta7)); - - G4Trap* solidDelrin7 = - new G4Trap("Delrin7", //its name - delrin_dz7, - delrin_theta7, delrin_phi7, - delrin_dyab7, - delrin_dxa7, delrin_dxb7, - delrin_alpab7, - delrin_dycd7, - delrin_dxc7, delrin_dxd7, - delrin_alpcd7); //its size - - G4LogicalVolume* logicDelrin7 = - new G4LogicalVolume(solidDelrin7, //its solid - delrin, //its material - "Delrin7"); //its name - logicDelrin7->SetVisAttributes(delrinVisAtt); - - // - // CsI Detector - // - G4double coneheight7 = 0.6*distanceFromTarget7; - G4double flatheight7 = coneheight7 -0.01*mm; - G4double coneangle7 = theta7; - G4double crystal_rmina7 = -(coneheight7-flatheight7)*tan(coneangle7+halfTheta7); - G4double crystal_rmaxa7 = -(coneheight7-flatheight7)*tan(coneangle7-halfTheta7); - G4double crystal_rminb7 = -coneheight7*tan(coneangle7+halfTheta7); - G4double crystal_rmaxb7 = -coneheight7*tan(coneangle7-halfTheta7); - G4double crystal_hz7 = 0.5*flatheight7;//(crystal_rmaxb7-crystal_rmaxa7)/crystal_rmaxb7*coneheight7; - G4double crystal_phimin7 = 0.*deg, crystal_phimax7 = 360.*deg/detNum7; - G4RotationMatrix tip_rotm7 = G4RotationMatrix(); - G4ThreeVector tip_pos7 = G4ThreeVector(0,0,0.5*flatheight7+(coneheight7-flatheight7)); //last term is a fudge - G4Transform3D tip_trans7 = G4Transform3D(tip_rotm7, tip_pos7); - G4ThreeVector z7 = G4ThreeVector(0,0,1); - G4ThreeVector d07 = G4ThreeVector(distanceFromTarget7*sin(coneangle7)*cos(0.5*360*deg/detNum7), - distanceFromTarget7*sin(coneangle7)*sin(0.5*360*deg/detNum7), - -distanceFromTarget7*cos(coneangle7)); - G4ThreeVector unitAxis7 = z7.cross(d07); - unitAxis7 = unitAxis7/unitAxis7.mag(); - G4double ux7 = unitAxis7.x(); - G4double uy7 = unitAxis7.y(); - G4double uz7 = unitAxis7.z(); - G4ThreeVector top7 = G4ThreeVector(cos(-coneangle7)+pow(ux7,2)*(1-cos(-coneangle7)), ux7*uy7*(1-cos(-coneangle7))-uz7*sin(-coneangle7), ux7*uz7*(1-cos(-coneangle7))+uy7*sin(-coneangle7)); - G4ThreeVector mid7 = G4ThreeVector(uy7*ux7*(1-cos(-coneangle7))+uz7*sin(-coneangle7), cos(-coneangle7)+pow(uy7,2)*(1-cos(-coneangle7)), uy7*uz7*(1-cos(-coneangle7))-ux7*sin(-coneangle7)); - G4ThreeVector bot7 = G4ThreeVector(uz7*ux7*(1-cos(-coneangle7))-uy7*sin(-coneangle7), uz7*uy7*(1-cos(-coneangle7))+ux7*sin(-coneangle7), cos(-coneangle7)+pow(uz7,2)*(1-cos(-coneangle7))); - G4RotationMatrix firstBox_rotm7 = G4RotationMatrix(); - firstBox_rotm7.setRows(top7,mid7,bot7); - G4ThreeVector firstBox_pos7 = G4ThreeVector(0,0,0); - G4Transform3D firstBox_trans7 = G4Transform3D(firstBox_rotm7, firstBox_pos7); - G4RotationMatrix secondBox_rotm7 = G4RotationMatrix(); - secondBox_rotm7.setRows(top7,mid7,bot7); - G4ThreeVector secondBox_pos7 = (3*distanceFromTarget7+detThickness7)/distanceFromTarget7*d07; - G4Transform3D secondBox_trans7 = G4Transform3D(secondBox_rotm7, secondBox_pos7); - - G4Orb* solidTip7 = - new G4Orb("tip7", - .0001*mm); - G4Box* solidSubtractionBox7 = - new G4Box("SubtractionBox7", //its name - distanceFromTarget7, - distanceFromTarget7, - distanceFromTarget7); //its size - G4Box* solidSecondSubtractionBox7 = - new G4Box("SecondSubtractionBox7", //its name - 2*distanceFromTarget7, - 2*distanceFromTarget7, - 2*distanceFromTarget7); //its size - G4Cons* solidCone7 = - new G4Cons("Cone7", //its name - crystal_rmina7, crystal_rmaxa7, - crystal_rminb7, crystal_rmaxb7, - crystal_hz7, - crystal_phimin7, crystal_phimax7); //its size - G4UnionSolid* solidTippedCone7 = - new G4UnionSolid("TippedCone7", - solidTip7, - solidCone7, - tip_trans7); - G4SubtractionSolid* solidIntermediate7 = - new G4SubtractionSolid("Intermediate7", - solidTippedCone7, - solidSubtractionBox7, - firstBox_trans7); - G4SubtractionSolid* solidCrystal7 = - new G4SubtractionSolid("Crystal7", - solidIntermediate7, - solidSecondSubtractionBox7, - secondBox_trans7); - - G4LogicalVolume* logicCrystal7 = - new G4LogicalVolume(solidCrystal7, //its solid - CsI, //its material - "CsI Detector7"); //its name - logicCrystal7->SetVisAttributes(crystalVisAtt); - logicCrystal7->SetSensitiveDetector(m_MicroballScorer); - // - // Light Guide - // - G4double lightGuide_px7 = 10*mm; - G4double lightGuide_py7 = 10*mm; - G4double lightGuide_pz7 = lgThickness7; - G4Box* solidLightGuide7 = - new G4Box("LightGuide7", //its name - 0.5*lightGuide_px7, - 0.5*lightGuide_py7, - 0.5*lightGuide_pz7); //its size + // Reinitialisation of Check Boolean + check_Ring1 = false ; + check_Ring2 = false ; + check_Ring3 = false ; + check_Ring4 = false ; + check_Ring5 = false ; + check_Ring6 = false ; + check_Ring7 = false ; + check_Ring8 = false ; + check_Ring9 = false ; + check_Flip = false ; + check_Chamber = false; - G4LogicalVolume* logicLightGuide7 = - new G4LogicalVolume(solidLightGuide7, //its solid - glass, //its material - "LightGuide7"); //its name - logicLightGuide7->SetVisAttributes(lightGuideVisAtt); - - - for(int i = 1; i <= detNum7; i++) - { - G4RotationMatrix crystal_rotm = G4RotationMatrix(); - G4ThreeVector d0 = G4ThreeVector(distanceFromTarget7*sin(coneangle7)*cos(0.5*360*deg/detNum7), - distanceFromTarget7*sin(coneangle7)*sin(0.5*360*deg/detNum7), - distanceFromTarget7*cos(coneangle7)); - G4ThreeVector df = G4ThreeVector(distanceFromTarget7*sin(theta7)*sin((i-1)*360*deg/detNum7+.001*deg/*+0.5*360*deg/detNum7*/), - distanceFromTarget7*sin(theta7)*cos((i-1)*360*deg/detNum7+.001*deg/*+0.5*360*deg/detNum7*/), - -distanceFromTarget7*cos(theta7)); - df.setX(-df.x()); - G4ThreeVector axis = d0.cross(df); - G4double ax = axis.x(); - G4double ay = axis.y(); - G4double az = axis.z(); - G4double ux = ax/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double uy = ay/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double uz = az/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double j = acos(d0.dot(df)/(d0.mag()*df.mag())); - G4ThreeVector a = G4ThreeVector(cos(j)+pow(ux,2)*(1-cos(j)), ux*uy*(1-cos(j))-uz*sin(j), ux*uz*(1-cos(j))+uy*sin(j)); - G4ThreeVector b = G4ThreeVector(uy*ux*(1-cos(j))+uz*sin(j), cos(j)+pow(uy,2)*(1-cos(j)), uy*uz*(1-cos(j))-ux*sin(j)); - G4ThreeVector c = G4ThreeVector(uz*ux*(1-cos(j))-uy*sin(j), uz*uy*(1-cos(j))+ux*sin(j), cos(j)+pow(uz,2)*(1-cos(j))); - G4RotationMatrix abc = G4RotationMatrix(); - abc.setRows(a,b,c); - G4ThreeVector unitdf = df/df.mag(); - G4double udfx = unitdf.x(); - G4double udfy = unitdf.y(); - G4double udfz = unitdf.z(); - G4double k = 180.*deg; - G4ThreeVector d = G4ThreeVector(cos(k)+pow(udfx,2)*(1-cos(k)), udfx*udfy*(1-cos(k))-udfz*sin(k), udfx*udfz*(1-cos(k))+udfy*sin(k)); - G4ThreeVector e = G4ThreeVector(udfy*udfx*(1-cos(k))+udfz*sin(k), cos(k)+pow(udfy,2)*(1-cos(k)), udfy*udfz*(1-cos(k))-udfx*sin(k)); - G4ThreeVector f = G4ThreeVector(udfz*udfx*(1-cos(k))-udfy*sin(k), udfz*udfy*(1-cos(k))+udfx*sin(k), cos(k)+pow(udfz,2)*(1-cos(k))); - G4RotationMatrix def = G4RotationMatrix(); - def.setRows(d,e,f); - crystal_rotm=def*abc; - if (m_Flip == 1){ - crystal_rotm.rotateY(180*deg); - } - crystal_rotm.rotateZ(180*deg); - G4ThreeVector crystal_pos = G4ThreeVector(0,0,0); - G4Transform3D crystal_trans = G4Transform3D(crystal_rotm, crystal_pos); - df.setX(-df.x()); - G4RotationMatrix lg_rotm = G4RotationMatrix(); - G4ThreeVector lg_Axis = df.cross(z7); - lg_Axis = lg_Axis/lg_Axis.mag(); - lg_Axis.rotateZ(180*deg); - G4double ulgx = lg_Axis.x(); - G4double ulgy = lg_Axis.y(); - G4double ulgz = lg_Axis.z(); - G4double lg_ang = theta7; - G4ThreeVector p = G4ThreeVector(cos(lg_ang)+pow(ulgx,2)*(1-cos(lg_ang)), ulgx*ulgy*(1-cos(lg_ang))-ulgz*sin(lg_ang), ulgx*ulgz*(1-cos(lg_ang))+ulgy*sin(lg_ang)); - G4ThreeVector q = G4ThreeVector(ulgy*ulgx*(1-cos(lg_ang))+ulgz*sin(lg_ang), cos(lg_ang)+pow(ulgy,2)*(1-cos(lg_ang)), ulgy*ulgz*(1-cos(lg_ang))-ulgx*sin(lg_ang)); - G4ThreeVector r = G4ThreeVector(ulgz*ulgx*(1-cos(lg_ang))-ulgy*sin(lg_ang), ulgz*ulgy*(1-cos(lg_ang))+ulgx*sin(lg_ang), cos(lg_ang)+pow(ulgz,2)*(1-cos(lg_ang))); - G4RotationMatrix pqr = G4RotationMatrix(); - pqr.setRows(p,q,r); - lg_rotm.rotateZ((i-1)*360*deg/detNum7); - lg_rotm.rotateX(180*deg); - lg_rotm=pqr*lg_rotm; - G4ThreeVector lg_pos = (distanceFromTarget7+detThickness7+0.5*lgThickness7+.0003*mm)/df.mag()*df; - lg_pos.rotateZ(180*deg); - if (m_Flip == 0){ - lg_pos.rotateY(180*deg); - lg_rotm.rotateY(180*deg); - } - G4Transform3D lg_trans = G4Transform3D(lg_rotm, lg_pos); - G4RotationMatrix delrin_rotm = G4RotationMatrix(); - G4ThreeVector w = G4ThreeVector(sin(theta7)*sin((i-1)*360*deg/detNum7+.001*deg), sin(theta7)*cos((i-1)*360*deg/detNum7+.001*deg), cos(theta7)); - G4ThreeVector delrin_Axis = w.cross(z7); - delrin_Axis.rotateX(180*deg); - delrin_Axis = delrin_Axis/delrin_Axis.mag(); - G4double udx = delrin_Axis.x(); - G4double udy = delrin_Axis.y(); - G4double udz = delrin_Axis.z(); - G4double delAng = -90*deg+theta7; - G4ThreeVector pdel = G4ThreeVector(cos(delAng)+pow(udx,2)*(1-cos(delAng)), udx*udy*(1-cos(delAng))-udz*sin(delAng), udx*udz*(1-cos(delAng))+udy*sin(delAng)); - G4ThreeVector qdel = G4ThreeVector(udy*udx*(1-cos(delAng))+udz*sin(delAng), cos(delAng)+pow(udy,2)*(1-cos(delAng)), udy*udz*(1-cos(delAng))-udx*sin(delAng)); - G4ThreeVector rdel = G4ThreeVector(udz*udx*(1-cos(delAng))-udy*sin(delAng), udz*udy*(1-cos(delAng))+udx*sin(delAng), cos(delAng)+pow(udz,2)*(1-cos(delAng))); - G4RotationMatrix pqrdel = G4RotationMatrix(); - pqrdel.setRows(pdel,qdel,rdel); - delrin_rotm.rotateZ((-i+1)*360*deg/detNum7+.001*deg); - delrin_rotm.rotateX(180*deg); - delrin_rotm=pqrdel*delrin_rotm; - delrin_rotm.rotateZ(0*deg); - G4ThreeVector delrin_pos = (distanceFromTarget7+detThickness7+lgThickness7+delrinA7/2+.0005*mm)/df.mag()*df; //the .0003 mm is a fudge factor to prevent overlapping - delrin_pos.rotateZ(180*deg); - delrin_pos.rotateY(180*deg); - if (m_Flip == 1){ - delrin_pos.rotateY(180*deg); - delrin_rotm.rotateY(180*deg); - } - G4Transform3D delrin_trans = G4Transform3D(delrin_rotm, delrin_pos); - bool placeCrystal = true; - for (unsigned int i2=0; i2 < m_Array.size(); i2++){ - if (68 < m_Array[i2] && m_Array[i2] < 81){ - /*if (m_Array[i2] == 69 && 68+i == 80){ - placeCrystal = false; - } - else if(68+m_Array[i2]%69 == 68+i){ - placeCrystal = false; - } - if (m_Array[i2] == 68+i){ - placeDel = false; - }*/ - if (m_Array[i2] == 68+i){ - placeCrystal = false; - } - } - } - if (placeCrystal){ - if(crystalBool) {new G4PVPlacement(crystal_trans, //rotation, position - logicCrystal7, //its logical volume - "CsI Detector7", //its name - world, //its mother volume - false, //no boolean operation - 68+i, //copy number - checkOverlaps); //overlaps checking - } - } - if(placeCrystal){ - if(lgBool) {new G4PVPlacement(lg_trans, //rotation, position - logicLightGuide7, //its logical volume - "LightGuide7", //its name - world, //its mother volume - false, //no boolean operation - 68+i, //copy number - checkOverlaps); //overlaps checking - } - if(delrinBool) {new G4PVPlacement(delrin_trans, //rotation, position - logicDelrin7, //its logical volume - "Delrin7", //its name - world, //its mother volume - false, //no boolean operation - 68+i, //copy number - checkOverlaps); //overlaps checking - } - } - }} - - - if(m_Ring8) { - // Ring 8 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - G4int detNum8 = 10; - G4double distanceFromTargetBack8 = 47*mm; //Its really 47 mm from the target, but at 45.9 we avoid intersection the detectors in ring 9 - G4double theta8 = 135.0*deg; - G4double halfTheta8 = 12.0*deg;// -0.1*deg; //fudge factor - G4double lgThickness8 = 7.5*mm; - G4double detThickness8 = 3.6*mm; - G4double distanceFromTarget8 = distanceFromTargetBack8 - detThickness8; - - //G4double distance8 = distanceFromTarget8*sin(theta8); //this gives the distance from the beam axis. - /* - // - // Delrin Ring (for deletion) - // - G4double delrin_rmina8 = distance8+detThickness8+lgThickness8, delrin_rmaxa8 = delrin_rmina8+5*mm; - G4double delrin_hz8 = 5*mm; //distance8*tan(halfTheta8); - G4double delrin_phimin8 = 0.*deg, delrin_phimax8 = 360.*deg; - G4ThreeVector delrin_pos8 = G4ThreeVector(0,0,distanceFromTarget8*cos(theta8)); //G4ThreeVector(0,0,distance8+lgThickness8+detThickness8*sin(theta8)); - - G4Tubs* solidDelrin8 = - new G4Tubs("Delrin8", //its name - delrin_rmina8, delrin_rmaxa8, - delrin_hz8, - delrin_phimin8, delrin_phimax8); //its size - - G4LogicalVolume* logicDelrin8 = - new G4LogicalVolume(solidDelrin8, //its solid - delrin, //its material - "Delrin8"); //its name - logicDelrin8->SetVisAttributes(delrinVisAtt); - - if(delrinBool) {new G4PVPlacement(0, //no rotation - delrin_pos8, //its position - logicDelrin8, //its logical volume - "Delrin8", //its name - world, //its mother volume - false, //no boolean operation - 0, //copy number - checkOverlaps); //overlaps checking - } - */ - // - // Delrin Ring - // - G4double delrinA8 = 5*mm; - G4double delrinB8 = 10*mm; - G4double fdelrinHalfAngle8 = atan(delrinB8/2/(distanceFromTarget8+detThickness8+lgThickness8)); - G4double firs8 = pow(pow(distanceFromTarget8+detThickness8+lgThickness8,2)+pow(delrinB8/2,2),0.5)*sin(theta8-fdelrinHalfAngle8); - G4double firb8 = pow(pow(distanceFromTarget8+detThickness8+lgThickness8,2)+pow(delrinB8/2,2),0.5)*sin(theta8+fdelrinHalfAngle8); - G4double bdelrinHalfAngle8 = atan(delrinB8/2/(distanceFromTarget8+detThickness8+lgThickness8+delrinA8)); - G4double birs8 = pow(pow(distanceFromTarget8+detThickness8+lgThickness8+delrinA8,2)+pow(delrinB8/2,2),0.5)*sin(theta8-bdelrinHalfAngle8); - G4double birb8 = pow(pow(distanceFromTarget8+detThickness8+lgThickness8+delrinA8,2)+pow(delrinB8/2,2),0.5)*sin(theta8+bdelrinHalfAngle8); - - G4double delrin_dz8 = delrinB8/2; - G4double delrin_theta8 = 0; - G4double delrin_phi8 = 0; - G4double delrin_dyab8 = delrinA8/2; - G4double delrin_dxa8 = firs8*tan(180*deg/detNum8); - G4double delrin_dxb8 = birs8*tan(180*deg/detNum8); - G4double delrin_dycd8 = delrinA8/2; - G4double delrin_dxc8 = firb8*tan(180*deg/detNum8); - G4double delrin_dxd8 = birb8*tan(180*deg/detNum8); - G4double delrin_alpab8 = 0; - G4double delrin_alpcd8 = delrin_alpab8; - - G4ThreeVector delrin_pos8 = G4ThreeVector(0,0,distanceFromTarget8*cos(theta8)); + ReadingStatus = false ; + G4cout << "///"<< G4endl ; + } + } + } +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - G4Trap* solidDelrin8 = - new G4Trap("Delrin8", //its name - delrin_dz8, - delrin_theta8, delrin_phi8, - delrin_dyab8, - delrin_dxa8, delrin_dxb8, - delrin_alpab8, - delrin_dycd8, - delrin_dxc8, delrin_dxd8, - delrin_alpcd8); //its size - - G4LogicalVolume* logicDelrin8 = - new G4LogicalVolume(solidDelrin8, //its solid - delrin, //its material - "Delrin8"); //its name - logicDelrin8->SetVisAttributes(delrinVisAtt); +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void Microball::ConstructDetector(G4LogicalVolume* world){ + //the below for-loop is commented out, and to be replaced with our detector geometry. - // - // CsI Detector - // - G4double coneheight8 = 1.7*distanceFromTarget8; - G4double flatheight8 = coneheight8 -0.01*mm; - G4double coneangle8 = theta8; - G4double crystal_rmina8 = -(coneheight8-flatheight8)*tan(coneangle8+halfTheta8); - G4double crystal_rmaxa8 = -(coneheight8-flatheight8)*tan(coneangle8-halfTheta8); - G4double crystal_rminb8 = -coneheight8*tan(coneangle8+halfTheta8); - G4double crystal_rmaxb8 = -coneheight8*tan(coneangle8-halfTheta8); - G4double crystal_hz8 = 0.5*flatheight8;//(crystal_rmaxb8-crystal_rmaxa8)/crystal_rmaxb8*coneheight8; - G4double crystal_phimin8 = 0.*deg, crystal_phimax8 = 360.*deg/detNum8; - G4RotationMatrix tip_rotm8 = G4RotationMatrix(); - G4ThreeVector tip_pos8 = G4ThreeVector(0,0,0.5*flatheight8+(coneheight8-flatheight8)); //last term is a fudge - G4Transform3D tip_trans8 = G4Transform3D(tip_rotm8, tip_pos8); - G4ThreeVector z8 = G4ThreeVector(0,0,1); - G4ThreeVector d08 = G4ThreeVector(distanceFromTarget8*sin(coneangle8)*cos(0.5*360*deg/detNum8), - distanceFromTarget8*sin(coneangle8)*sin(0.5*360*deg/detNum8), - -distanceFromTarget8*cos(coneangle8)); - G4ThreeVector unitAxis8 = z8.cross(d08); - unitAxis8 = unitAxis8/unitAxis8.mag(); - G4double ux8 = unitAxis8.x(); - G4double uy8 = unitAxis8.y(); - G4double uz8 = unitAxis8.z(); - G4ThreeVector top8 = G4ThreeVector(cos(-coneangle8)+pow(ux8,2)*(1-cos(-coneangle8)), ux8*uy8*(1-cos(-coneangle8))-uz8*sin(-coneangle8), ux8*uz8*(1-cos(-coneangle8))+uy8*sin(-coneangle8)); - G4ThreeVector mid8 = G4ThreeVector(uy8*ux8*(1-cos(-coneangle8))+uz8*sin(-coneangle8), cos(-coneangle8)+pow(uy8,2)*(1-cos(-coneangle8)), uy8*uz8*(1-cos(-coneangle8))-ux8*sin(-coneangle8)); - G4ThreeVector bot8 = G4ThreeVector(uz8*ux8*(1-cos(-coneangle8))-uy8*sin(-coneangle8), uz8*uy8*(1-cos(-coneangle8))+ux8*sin(-coneangle8), cos(-coneangle8)+pow(uz8,2)*(1-cos(-coneangle8))); - G4RotationMatrix firstBox_rotm8 = G4RotationMatrix(); - firstBox_rotm8.setRows(top8,mid8,bot8); - G4ThreeVector firstBox_pos8 = G4ThreeVector(0,0,0); - G4Transform3D firstBox_trans8 = G4Transform3D(firstBox_rotm8, firstBox_pos8); - G4RotationMatrix secondBox_rotm8 = G4RotationMatrix(); - secondBox_rotm8.setRows(top8,mid8,bot8); - G4ThreeVector secondBox_pos8 = (2*distanceFromTarget8+detThickness8)/d08.mag()*d08; - G4Transform3D secondBox_trans8 = G4Transform3D(secondBox_rotm8, secondBox_pos8); - - G4Orb* solidTip8 = - new G4Orb("tip8", - .0001*mm); - G4Box* solidSubtractionBox8 = - new G4Box("SubtractionBox8", //its name - distanceFromTarget8, - distanceFromTarget8, - distanceFromTarget8); //its size - G4Cons* solidCone8 = - new G4Cons("Cone8", //its name - crystal_rmina8, crystal_rmaxa8, - crystal_rminb8, crystal_rmaxb8, - crystal_hz8, - crystal_phimin8, crystal_phimax8); //its size - G4UnionSolid* solidTippedCone8 = - new G4UnionSolid("TippedCone8", - solidTip8, - solidCone8, - tip_trans8); - G4SubtractionSolid* solidIntermediate8 = - new G4SubtractionSolid("Intermediate8", - solidTippedCone8, - solidSubtractionBox8, - firstBox_trans8); - G4SubtractionSolid* solidCrystal8 = - new G4SubtractionSolid("Crystal8", - solidIntermediate8, - solidSubtractionBox8, - secondBox_trans8); - - G4LogicalVolume* logicCrystal8 = - new G4LogicalVolume(solidCrystal8, //its solid - CsI, //its material - "CsI Detector8"); //its name - logicCrystal8->SetVisAttributes(crystalVisAtt); - logicCrystal8->SetSensitiveDetector(m_MicroballScorer); - // - // Light Guide - // - G4double lightGuide_px8 = 10*mm; - G4double lightGuide_py8 = 10*mm; - G4double lightGuide_pz8 = lgThickness8; - G4Box* solidLightGuide8 = - new G4Box("LightGuide8", //its name - 0.5*lightGuide_px8, - 0.5*lightGuide_py8, - 0.5*lightGuide_pz8); //its size - - G4LogicalVolume* logicLightGuide8 = - new G4LogicalVolume(solidLightGuide8, //its solid - glass, //its material - "LightGuide8"); //its name - logicLightGuide8->SetVisAttributes(lightGuideVisAtt); - - - for(int i = 1; i <= detNum8; i++) - { - G4RotationMatrix crystal_rotm = G4RotationMatrix(); - G4ThreeVector d0 = G4ThreeVector(distanceFromTarget8*sin(coneangle8)*cos(0.5*360*deg/detNum8), - distanceFromTarget8*sin(coneangle8)*sin(0.5*360*deg/detNum8), - distanceFromTarget8*cos(coneangle8)); - G4ThreeVector df = G4ThreeVector(distanceFromTarget8*sin(theta8)*sin((i-1)*360*deg/detNum8+.001*deg/*+0.5*360*deg/detNum8*/), - distanceFromTarget8*sin(theta8)*cos((i-1)*360*deg/detNum8+.001*deg/*+0.5*360*deg/detNum8*/), - -distanceFromTarget8*cos(theta8)); - df.setX(-df.x()); - G4ThreeVector axis = d0.cross(df); - G4double ax = axis.x(); - G4double ay = axis.y(); - G4double az = axis.z(); - G4double ux = ax/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double uy = ay/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double uz = az/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double j = acos(d0.dot(df)/(d0.mag()*df.mag())); - G4ThreeVector a = G4ThreeVector(cos(j)+pow(ux,2)*(1-cos(j)), ux*uy*(1-cos(j))-uz*sin(j), ux*uz*(1-cos(j))+uy*sin(j)); - G4ThreeVector b = G4ThreeVector(uy*ux*(1-cos(j))+uz*sin(j), cos(j)+pow(uy,2)*(1-cos(j)), uy*uz*(1-cos(j))-ux*sin(j)); - G4ThreeVector c = G4ThreeVector(uz*ux*(1-cos(j))-uy*sin(j), uz*uy*(1-cos(j))+ux*sin(j), cos(j)+pow(uz,2)*(1-cos(j))); - G4RotationMatrix abc = G4RotationMatrix(); - abc.setRows(a,b,c); - G4ThreeVector unitdf = df/df.mag(); - G4double udfx = unitdf.x(); - G4double udfy = unitdf.y(); - G4double udfz = unitdf.z(); - G4double k = 180.*deg; - G4ThreeVector d = G4ThreeVector(cos(k)+pow(udfx,2)*(1-cos(k)), udfx*udfy*(1-cos(k))-udfz*sin(k), udfx*udfz*(1-cos(k))+udfy*sin(k)); - G4ThreeVector e = G4ThreeVector(udfy*udfx*(1-cos(k))+udfz*sin(k), cos(k)+pow(udfy,2)*(1-cos(k)), udfy*udfz*(1-cos(k))-udfx*sin(k)); - G4ThreeVector f = G4ThreeVector(udfz*udfx*(1-cos(k))-udfy*sin(k), udfz*udfy*(1-cos(k))+udfx*sin(k), cos(k)+pow(udfz,2)*(1-cos(k))); - G4RotationMatrix def = G4RotationMatrix(); - def.setRows(d,e,f); - crystal_rotm=def*abc; - if (m_Flip == 1){ - crystal_rotm.rotateY(180*deg); - } - crystal_rotm.rotateZ(180*deg); - G4ThreeVector crystal_pos = G4ThreeVector(0,0,0); - G4Transform3D crystal_trans = G4Transform3D(crystal_rotm, crystal_pos); - df.setX(-df.x()); - G4RotationMatrix lg_rotm = G4RotationMatrix(); - G4ThreeVector lg_Axis = df.cross(z8); - lg_Axis = lg_Axis/lg_Axis.mag(); - lg_Axis.rotateZ(180*deg); - G4double ulgx = lg_Axis.x(); - G4double ulgy = lg_Axis.y(); - G4double ulgz = lg_Axis.z(); - G4ThreeVector p = G4ThreeVector(cos(theta8)+pow(ulgx,2)*(1-cos(theta8)), ulgx*ulgy*(1-cos(theta8))-ulgz*sin(theta8), ulgx*ulgz*(1-cos(theta8))+ulgy*sin(theta8)); - G4ThreeVector q = G4ThreeVector(ulgy*ulgx*(1-cos(theta8))+ulgz*sin(theta8), cos(theta8)+pow(ulgy,2)*(1-cos(theta8)), ulgy*ulgz*(1-cos(theta8))-ulgx*sin(theta8)); - G4ThreeVector r = G4ThreeVector(ulgz*ulgx*(1-cos(theta8))-ulgy*sin(theta8), ulgz*ulgy*(1-cos(theta8))+ulgx*sin(theta8), cos(theta8)+pow(ulgz,2)*(1-cos(theta8))); - G4RotationMatrix pqr = G4RotationMatrix(); - pqr.setRows(p,q,r); - lg_rotm.rotateZ((i-1)*360*deg/detNum8); - lg_rotm.rotateX(180*deg); - lg_rotm=pqr*lg_rotm; - G4ThreeVector lg_pos = (distanceFromTarget8+detThickness8+0.5*lgThickness8+.0003*mm)/df.mag()*df; - lg_pos.rotateZ(180*deg); - if (m_Flip == 0){ - lg_pos.rotateY(180*deg); - lg_rotm.rotateY(180*deg); - } - G4Transform3D lg_trans = G4Transform3D(lg_rotm, lg_pos); - G4RotationMatrix delrin_rotm = G4RotationMatrix(); - G4ThreeVector w = G4ThreeVector(sin(theta8)*sin((i-1)*360*deg/detNum8+.001*deg), sin(theta8)*cos((i-1)*360*deg/detNum8+.001*deg), cos(theta8)); - G4ThreeVector delrin_Axis = w.cross(z8); - delrin_Axis.rotateX(180*deg); - delrin_Axis = delrin_Axis/delrin_Axis.mag(); - G4double udx = delrin_Axis.x(); - G4double udy = delrin_Axis.y(); - G4double udz = delrin_Axis.z(); - G4double delAng = -90*deg+theta8; - G4ThreeVector pdel = G4ThreeVector(cos(delAng)+pow(udx,2)*(1-cos(delAng)), udx*udy*(1-cos(delAng))-udz*sin(delAng), udx*udz*(1-cos(delAng))+udy*sin(delAng)); - G4ThreeVector qdel = G4ThreeVector(udy*udx*(1-cos(delAng))+udz*sin(delAng), cos(delAng)+pow(udy,2)*(1-cos(delAng)), udy*udz*(1-cos(delAng))-udx*sin(delAng)); - G4ThreeVector rdel = G4ThreeVector(udz*udx*(1-cos(delAng))-udy*sin(delAng), udz*udy*(1-cos(delAng))+udx*sin(delAng), cos(delAng)+pow(udz,2)*(1-cos(delAng))); - G4RotationMatrix pqrdel = G4RotationMatrix(); - pqrdel.setRows(pdel,qdel,rdel); - delrin_rotm.rotateZ((-i+1)*360*deg/detNum8+.001*deg); - delrin_rotm.rotateX(180*deg); - delrin_rotm=pqrdel*delrin_rotm; - delrin_rotm.rotateZ(0*deg); - G4ThreeVector delrin_pos = (distanceFromTarget8+detThickness8+lgThickness8+delrinA8/2+.0005*mm)/df.mag()*df; //the .0003 mm is a fudge factor to prevent overlapping - delrin_pos.rotateZ(180*deg); - delrin_pos.rotateY(180*deg); - if (m_Flip == 1){ - delrin_pos.rotateY(180*deg); - delrin_rotm.rotateY(180*deg); - } - G4Transform3D delrin_trans = G4Transform3D(delrin_rotm, delrin_pos); - bool placeCrystal = true; - for (unsigned int i2=0; i2 < m_Array.size(); i2++){ - if (80 < m_Array[i2] && m_Array[i2] < 91){ - if (m_Array[i2] == 80+i){ - placeCrystal = false; - } - } - } - if (placeCrystal){ - if(crystalBool) {new G4PVPlacement(crystal_trans, //rotation, position - logicCrystal8, //its logical volume - "CsI Detector8", //its name - world, //its mother volume - false, //no boolean operation - 80+i, //copy number - checkOverlaps); //overlaps checking - } - } - if (placeCrystal){ - if(lgBool) {new G4PVPlacement(lg_trans, //rotation, position - logicLightGuide8, //its logical volume - "LightGuide8", //its name - world, //its mother volume - false, //no boolean operation - 80+i, //copy number - checkOverlaps); //overlaps checking - } - if(delrinBool) {new G4PVPlacement(delrin_trans, //rotation, position - logicDelrin8, //its logical volume - "Delrin8", //its name - world, //its mother volume - false, //no boolean operation - 80+i, //copy number - checkOverlaps); //overlaps checking - } - } - }} - - - if(m_Ring9){ - // Ring 9 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - G4int detNum9 = 6; - G4double distanceFromTargetBack9 = 50.*mm; - G4double theta9 = 159.0*deg; - G4double halfTheta9 = 12.0*deg;//-0.1*deg; //fudge factor - G4double lgThickness9 = 8.0*mm; - G4double detThickness9 = 3.5*mm; - G4double distanceFromTarget9 = distanceFromTargetBack9 - detThickness9; - - //G4double distance9 = distanceFromTarget9*sin(theta9); //this gives the distance from the beam axis. - - /* - // - // Delrin Ring (for deletion) - // - G4double delrin_rmina9 = distance9+detThickness9+lgThickness9, delrin_rmaxa9 = delrin_rmina9+5*mm; - G4double delrin_hz9 = 5*mm; //distance9*tan(halfTheta9); - G4double delrin_phimin9 = 0.*deg, delrin_phimax9 = 360.*deg; - G4ThreeVector delrin_pos9 = G4ThreeVector(0,0,distanceFromTarget9*cos(theta9)); //G4ThreeVector(0,0,distance9+lgThickness9+detThickness9*sin(theta9)); - - G4Tubs* solidDelrin9 = - new G4Tubs("Delrin9", //its name - delrin_rmina9, delrin_rmaxa9, - delrin_hz9, - delrin_phimin9, delrin_phimax9); //its size - - G4LogicalVolume* logicDelrin9 = - new G4LogicalVolume(solidDelrin9, //its solid - delrin, //its material - "Delrin9"); //its name - logicDelrin9->SetVisAttributes(delrinVisAtt); - - if(delrinBool) {new G4PVPlacement(0, //no rotation - delrin_pos9, //its position - logicDelrin9, //its logical volume - "Delrin9", //its name - world, //its mother volume - false, //no boolean operation - 0, //copy number - checkOverlaps); //overlaps checking - } -*/ - - // - // Delrin Ring - // - G4double delrinA9 = 5*mm; - G4double delrinB9 = 10*mm; - G4double fdelrinHalfAngle9 = atan(delrinB9/2/(distanceFromTarget9+detThickness9+lgThickness9)); - G4double firs9 = pow(pow(distanceFromTarget9+detThickness9+lgThickness9,2)+pow(delrinB9/2,2),0.5)*sin(theta9-fdelrinHalfAngle9); - G4double firb9 = pow(pow(distanceFromTarget9+detThickness9+lgThickness9,2)+pow(delrinB9/2,2),0.5)*sin(theta9+fdelrinHalfAngle9); - G4double bdelrinHalfAngle9 = atan(delrinB9/2/(distanceFromTarget9+detThickness9+lgThickness9+delrinA9)); - G4double birs9 = pow(pow(distanceFromTarget9+detThickness9+lgThickness9+delrinA9,2)+pow(delrinB9/2,2),0.5)*sin(theta9-bdelrinHalfAngle9); - G4double birb9 = pow(pow(distanceFromTarget9+detThickness9+lgThickness9+delrinA9,2)+pow(delrinB9/2,2),0.5)*sin(theta9+bdelrinHalfAngle9); - - G4double delrin_dz9 = delrinB9/2; - G4double delrin_theta9 = 0; - G4double delrin_phi9 = 0; - G4double delrin_dyab9 = delrinA9/2; - G4double delrin_dxa9 = firs9*tan(180*deg/detNum9); - G4double delrin_dxb9 = birs9*tan(180*deg/detNum9); - G4double delrin_dycd9 = delrinA9/2; - G4double delrin_dxc9 = firb9*tan(180*deg/detNum9); - G4double delrin_dxd9 = birb9*tan(180*deg/detNum9); - G4double delrin_alpab9 = 0; - G4double delrin_alpcd9 = delrin_alpab9; - - G4ThreeVector delrin_pos9 = G4ThreeVector(0,0,distanceFromTarget9*cos(theta9)); - - G4Trap* solidDelrin9 = - new G4Trap("Delrin9", //its name - delrin_dz9, - delrin_theta9, delrin_phi9, - delrin_dyab9, - delrin_dxa9, delrin_dxb9, - delrin_alpab9, - delrin_dycd9, - delrin_dxc9, delrin_dxd9, - delrin_alpcd9); //its size - - G4LogicalVolume* logicDelrin9 = - new G4LogicalVolume(solidDelrin9, //its solid - delrin, //its material - "Delrin9"); //its name - logicDelrin9->SetVisAttributes(delrinVisAtt); - - // - // CsI Detector - // - G4double coneheight9 = 2*distanceFromTarget9; - G4double flatheight9 = coneheight9 -0.01*mm; - G4double coneangle9 = theta9; - G4double crystal_rmina9 = -(coneheight9-flatheight9)*tan(coneangle9+halfTheta9); - G4double crystal_rmaxa9 = -(coneheight9-flatheight9)*tan(coneangle9-halfTheta9); - G4double crystal_rminb9 = -coneheight9*tan(coneangle9+halfTheta9); - G4double crystal_rmaxb9 = -coneheight9*tan(coneangle9-halfTheta9); - G4double crystal_hz9 = 0.5*flatheight9;//(crystal_rmaxb9-crystal_rmaxa9)/crystal_rmaxb9*coneheight9; - G4double crystal_phimin9 = 0.*deg, crystal_phimax9 = 360.*deg/detNum9; - G4RotationMatrix tip_rotm9 = G4RotationMatrix(); - G4ThreeVector tip_pos9 = G4ThreeVector(0,0,0.5*flatheight9+(coneheight9-flatheight9)); //last term is a fudge - G4Transform3D tip_trans9 = G4Transform3D(tip_rotm9, tip_pos9); - G4ThreeVector z9 = G4ThreeVector(0,0,1); - G4ThreeVector d09 = G4ThreeVector(distanceFromTarget9*sin(coneangle9)*cos(0.5*360*deg/detNum9), - distanceFromTarget9*sin(coneangle9)*sin(0.5*360*deg/detNum9), - -distanceFromTarget9*cos(coneangle9)); - G4ThreeVector unitAxis9 = z9.cross(d09); - unitAxis9 = unitAxis9/unitAxis9.mag(); - G4double ux9 = unitAxis9.x(); - G4double uy9 = unitAxis9.y(); - G4double uz9 = unitAxis9.z(); - G4ThreeVector top9 = G4ThreeVector(cos(-coneangle9)+pow(ux9,2)*(1-cos(-coneangle9)), ux9*uy9*(1-cos(-coneangle9))-uz9*sin(-coneangle9), ux9*uz9*(1-cos(-coneangle9))+uy9*sin(-coneangle9)); - G4ThreeVector mid9 = G4ThreeVector(uy9*ux9*(1-cos(-coneangle9))+uz9*sin(-coneangle9), cos(-coneangle9)+pow(uy9,2)*(1-cos(-coneangle9)), uy9*uz9*(1-cos(-coneangle9))-ux9*sin(-coneangle9)); - G4ThreeVector bot9 = G4ThreeVector(uz9*ux9*(1-cos(-coneangle9))-uy9*sin(-coneangle9), uz9*uy9*(1-cos(-coneangle9))+ux9*sin(-coneangle9), cos(-coneangle9)+pow(uz9,2)*(1-cos(-coneangle9))); - G4RotationMatrix firstBox_rotm9 = G4RotationMatrix(); - firstBox_rotm9.setRows(top9,mid9,bot9); - G4ThreeVector firstBox_pos9 = G4ThreeVector(0,0,0); - G4Transform3D firstBox_trans9 = G4Transform3D(firstBox_rotm9, firstBox_pos9); - G4RotationMatrix secondBox_rotm9 = G4RotationMatrix(); - secondBox_rotm9.setRows(top9,mid9,bot9); - G4ThreeVector secondBox_pos9 = (2*distanceFromTarget9+detThickness9)/d09.mag()*d09; - G4Transform3D secondBox_trans9 = G4Transform3D(secondBox_rotm9, secondBox_pos9); - - G4Orb* solidTip9 = - new G4Orb("tip9", - .0001*mm); - G4Box* solidSubtractionBox9 = - new G4Box("SubtractionBox9", //its name - distanceFromTarget9, - distanceFromTarget9, - distanceFromTarget9); //its size - G4Cons* solidCone9 = - new G4Cons("Cone9", //its name - crystal_rmina9, crystal_rmaxa9, - crystal_rminb9, crystal_rmaxb9, - crystal_hz9, - crystal_phimin9, crystal_phimax9); //its size - G4UnionSolid* solidTippedCone9 = - new G4UnionSolid("TippedCone9", - solidTip9, - solidCone9, - tip_trans9); - G4SubtractionSolid* solidIntermediate9 = - new G4SubtractionSolid("Intermediate9", - solidTippedCone9, - solidSubtractionBox9, - firstBox_trans9); - G4SubtractionSolid* solidCrystal9 = - new G4SubtractionSolid("Crystal9", - solidIntermediate9, - solidSubtractionBox9, - secondBox_trans9); - - G4LogicalVolume* logicCrystal9 = - new G4LogicalVolume(solidCrystal9, //its solid - CsI, //its material - "CsI Detector9"); //its name - logicCrystal9->SetVisAttributes(crystalVisAtt); - logicCrystal9->SetSensitiveDetector(m_MicroballScorer); - - // - // Light Guide - // - G4double lightGuide_px9 = 10*mm; - G4double lightGuide_py9 = 10*mm; - G4double lightGuide_pz9 = lgThickness9; - G4Box* solidLightGuide9 = - new G4Box("LightGuide9", //its name - 0.5*lightGuide_px9, - 0.5*lightGuide_py9, - 0.5*lightGuide_pz9); //its size - - G4LogicalVolume* logicLightGuide9 = - new G4LogicalVolume(solidLightGuide9, //its solid - glass, //its material - "LightGuide9"); //its name - logicLightGuide9->SetVisAttributes(lightGuideVisAtt); - - - for(int i = 1; i <= detNum9; i++) - { - G4RotationMatrix crystal_rotm = G4RotationMatrix(); - G4ThreeVector d0 = G4ThreeVector(distanceFromTarget9*sin(coneangle9)*cos(0.5*360*deg/detNum9), - distanceFromTarget9*sin(coneangle9)*sin(0.5*360*deg/detNum9), - distanceFromTarget9*cos(coneangle9)); - G4ThreeVector df = G4ThreeVector(distanceFromTarget9*sin(theta9)*sin((i-1)*360*deg/detNum9+.001*deg/*+0.5*360*deg/detNum9*/), - distanceFromTarget9*sin(theta9)*cos((i-1)*360*deg/detNum9+.001*deg/*+0.5*360*deg/detNum9*/), - -distanceFromTarget9*cos(theta9)); - df.setX(-df.x()); - G4ThreeVector axis = d0.cross(df); - G4double ax = axis.x(); - G4double ay = axis.y(); - G4double az = axis.z(); - G4double ux = ax/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double uy = ay/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double uz = az/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); - G4double j = acos(d0.dot(df)/(d0.mag()*df.mag())); - G4ThreeVector a = G4ThreeVector(cos(j)+pow(ux,2)*(1-cos(j)), ux*uy*(1-cos(j))-uz*sin(j), ux*uz*(1-cos(j))+uy*sin(j)); - G4ThreeVector b = G4ThreeVector(uy*ux*(1-cos(j))+uz*sin(j), cos(j)+pow(uy,2)*(1-cos(j)), uy*uz*(1-cos(j))-ux*sin(j)); - G4ThreeVector c = G4ThreeVector(uz*ux*(1-cos(j))-uy*sin(j), uz*uy*(1-cos(j))+ux*sin(j), cos(j)+pow(uz,2)*(1-cos(j))); - G4RotationMatrix abc = G4RotationMatrix(); - abc.setRows(a,b,c); - G4ThreeVector unitdf = df/df.mag(); - G4double udfx = unitdf.x(); - G4double udfy = unitdf.y(); - G4double udfz = unitdf.z(); - G4double k = 180.*deg; - G4ThreeVector d = G4ThreeVector(cos(k)+pow(udfx,2)*(1-cos(k)), udfx*udfy*(1-cos(k))-udfz*sin(k), udfx*udfz*(1-cos(k))+udfy*sin(k)); - G4ThreeVector e = G4ThreeVector(udfy*udfx*(1-cos(k))+udfz*sin(k), cos(k)+pow(udfy,2)*(1-cos(k)), udfy*udfz*(1-cos(k))-udfx*sin(k)); - G4ThreeVector f = G4ThreeVector(udfz*udfx*(1-cos(k))-udfy*sin(k), udfz*udfy*(1-cos(k))+udfx*sin(k), cos(k)+pow(udfz,2)*(1-cos(k))); - G4RotationMatrix def = G4RotationMatrix(); - def.setRows(d,e,f); - crystal_rotm=def*abc; - if (m_Flip == 1){ - crystal_rotm.rotateY(180*deg); - } - crystal_rotm.rotateZ(180*deg); - G4ThreeVector crystal_pos = G4ThreeVector(0,0,0); - G4Transform3D crystal_trans = G4Transform3D(crystal_rotm, crystal_pos); - df.setX(-df.x()); - G4RotationMatrix lg_rotm = G4RotationMatrix(); - /* - lg_rotm.rotateZ((i-1)*360*deg/detNum9); - G4ThreeVector lg_pos = G4ThreeVector((distance9+detThickness9+0.5*lgThickness9)*cos(i*360*deg/detNum9), - (distance9+detThickness9+0.5*lgThickness9)*sin(i*360*deg/detNum9), - 0)+delrin_pos9; - */ - G4ThreeVector lg_Axis = df.cross(z9); - lg_Axis = lg_Axis/lg_Axis.mag(); - lg_Axis.rotateZ(180*deg); - G4double ulgx = lg_Axis.x(); - G4double ulgy = lg_Axis.y(); - G4double ulgz = lg_Axis.z(); - G4ThreeVector p = G4ThreeVector(cos(theta9)+pow(ulgx,2)*(1-cos(theta9)), ulgx*ulgy*(1-cos(theta9))-ulgz*sin(theta9), ulgx*ulgz*(1-cos(theta9))+ulgy*sin(theta9)); - G4ThreeVector q = G4ThreeVector(ulgy*ulgx*(1-cos(theta9))+ulgz*sin(theta9), cos(theta9)+pow(ulgy,2)*(1-cos(theta9)), ulgy*ulgz*(1-cos(theta9))-ulgx*sin(theta9)); - G4ThreeVector r = G4ThreeVector(ulgz*ulgx*(1-cos(theta9))-ulgy*sin(theta9), ulgz*ulgy*(1-cos(theta9))+ulgx*sin(theta9), cos(theta9)+pow(ulgz,2)*(1-cos(theta9))); - G4RotationMatrix pqr = G4RotationMatrix(); - pqr.setRows(p,q,r); - lg_rotm.rotateZ((i-1)*360*deg/detNum9); - lg_rotm.rotateX(180*deg); - lg_rotm=pqr*lg_rotm; - G4ThreeVector lg_pos = (distanceFromTarget9+detThickness9+0.5*lgThickness9+.0003*mm)/df.mag()*df; - lg_pos.rotateZ(180*deg); - if (m_Flip == 0){ - lg_pos.rotateY(180*deg); - lg_rotm.rotateY(180*deg); - } - G4Transform3D lg_trans = G4Transform3D(lg_rotm, lg_pos); - G4RotationMatrix delrin_rotm = G4RotationMatrix(); - G4ThreeVector w = G4ThreeVector(sin(theta9)*sin((i-1)*360*deg/detNum9+.001*deg), sin(theta9)*cos((i-1)*360*deg/detNum9+.001*deg), cos(theta9)); - G4ThreeVector delrin_Axis = w.cross(z9); - delrin_Axis.rotateX(180*deg); - delrin_Axis = delrin_Axis/delrin_Axis.mag(); - G4double udx = delrin_Axis.x(); - G4double udy = delrin_Axis.y(); - G4double udz = delrin_Axis.z(); - G4double delAng = -90*deg+theta9; - G4ThreeVector pdel = G4ThreeVector(cos(delAng)+pow(udx,2)*(1-cos(delAng)), udx*udy*(1-cos(delAng))-udz*sin(delAng), udx*udz*(1-cos(delAng))+udy*sin(delAng)); - G4ThreeVector qdel = G4ThreeVector(udy*udx*(1-cos(delAng))+udz*sin(delAng), cos(delAng)+pow(udy,2)*(1-cos(delAng)), udy*udz*(1-cos(delAng))-udx*sin(delAng)); - G4ThreeVector rdel = G4ThreeVector(udz*udx*(1-cos(delAng))-udy*sin(delAng), udz*udy*(1-cos(delAng))+udx*sin(delAng), cos(delAng)+pow(udz,2)*(1-cos(delAng))); - G4RotationMatrix pqrdel = G4RotationMatrix(); - pqrdel.setRows(pdel,qdel,rdel); - delrin_rotm.rotateZ((-i+1)*360*deg/detNum9+.001*deg); - delrin_rotm.rotateX(180*deg); - delrin_rotm=pqrdel*delrin_rotm; - delrin_rotm.rotateZ(0*deg); - G4ThreeVector delrin_pos = (distanceFromTarget9+detThickness9+lgThickness9+delrinA9/2+.0005*mm)/df.mag()*df; //the .0003 mm is a fudge factor to prevent overlapping - delrin_pos.rotateZ(180*deg); - delrin_pos.rotateY(180*deg); - if (m_Flip == 1){ - delrin_pos.rotateY(180*deg); - delrin_rotm.rotateY(180*deg); - } - G4Transform3D delrin_trans = G4Transform3D(delrin_rotm, delrin_pos); - bool placeCrystal = true; - for (unsigned int i2=0; i2 < m_Array.size(); i2++){ - if (90 < m_Array[i2] && m_Array[i2] < 97){ - if (m_Array[i2] == 90+i){ - placeCrystal = false; - } - } - } - if (placeCrystal){ - if(crystalBool) {new G4PVPlacement(crystal_trans, //rotation, position - logicCrystal9, //its logical volume - "CsI Detector9", //its name - world, //its mother volume - false, //no boolean operation - 90+i, //copy number - checkOverlaps); //overlaps checking - } - } - if (placeCrystal){ - if(lgBool) {new G4PVPlacement(lg_trans, //rotation, position - logicLightGuide9, //its logical volume - "LightGuide9", //its name - world, //its mother volume - false, //no boolean operation - 90+i, //copy number - checkOverlaps); //overlaps checking - } - if(delrinBool) {new G4PVPlacement(delrin_trans, //rotation, position - logicDelrin9, //its logical volume - "Delrin9", //its name - world, //its mother volume - false, //no boolean operation - 90+i, //copy number - checkOverlaps); //overlaps checking - } - } - }} + G4bool checkOverlaps = false; + G4double delrinBool = 1; + G4double crystalBool = 1; + G4double lgBool = 1; + + G4NistManager* nist = G4NistManager::Instance(); + + G4Material* Al = nist->FindOrBuildMaterial("G4_Al"); + G4VisAttributes* chamberVisAtt = new G4VisAttributes(G4Colour(.7,.7,.7, .1)); + G4Material* CsI = nist->FindOrBuildMaterial("G4_CESIUM_IODIDE"); + G4VisAttributes* crystalVisAtt = new G4VisAttributes(G4Colour(0.,1.,0., .5)); + G4Material* glass = nist->FindOrBuildMaterial("G4_Pyrex_Glass"); + G4VisAttributes* lightGuideVisAtt = new G4VisAttributes(G4Colour(0.,0.,1.)); + G4Material* delrin = nist->FindOrBuildMaterial("G4_POLYOXYMETHYLENE"); + G4VisAttributes* delrinVisAtt = new G4VisAttributes(G4Colour(1.,0.,0.)); + + if(m_Chamber){ + //---------------------------------------------------- + //the specifications for the dimensions of the chamber + //---------------------------------------------------- + + G4double chamberThickness = 7.9375*mm; + G4double beamlineThickness = 10*mm; + + //the empty space in the chamber + G4double subchamber_rmin = 0*mm; + G4double subchamber_rmax = 673.1*mm; + G4double subchamber_hz = (406.4*mm +251.46*mm)/2; //673.1*mm/2; + G4double subchamber_phimin = 0*deg; + G4double subchamber_phimax = 360*deg; + G4RotationMatrix subchamber_rotm1 = G4RotationMatrix(); + G4ThreeVector subchamber_pos1 = G4ThreeVector(0,0,0); + G4Transform3D subchamber_trans1 = G4Transform3D(subchamber_rotm1, subchamber_pos1); + + //the walls of the chamber + G4double chamber_rmin = 0*mm; + G4double chamber_rmax = subchamber_rmax +chamberThickness; + G4double chamber_hz = subchamber_hz -0.1*mm; //fudge factor to make sure the top doesn't show up in the visualizer + G4double chamber_phimin = 0*deg; + G4double chamber_phimax = 360*deg; + G4RotationMatrix chamber_rotm = G4RotationMatrix(); + chamber_rotm.rotateX(90*deg); + G4ThreeVector chamber_pos = G4ThreeVector(0,-(chamber_hz -406.4*mm +76.2*mm),0); + G4Transform3D chamber_trans = G4Transform3D(chamber_rotm, chamber_pos); + + //the top and bottom of the chamber + G4double chambertop_height = 274.32*mm; + G4double chambertop_semix = chamber_rmax; + G4double chambertop_semiy = chamber_rmax; + G4double chambertop_semiz = chambertop_height; + G4double chambertop_bottomcut = 0; + G4double chambertop_topcut = chambertop_semiz; + G4RotationMatrix chambertop_rotm = G4RotationMatrix(); + chambertop_rotm.rotateX(-90*deg); + G4ThreeVector chambertop_pos = G4ThreeVector(0,chamber_pos.getY() +chamber_hz,0); + G4Transform3D chambertop_trans = G4Transform3D(chambertop_rotm, chambertop_pos); + G4RotationMatrix chamberbottom_rotm = G4RotationMatrix(); + chamberbottom_rotm.rotateX(90*deg); + G4ThreeVector chamberbottom_pos = G4ThreeVector(0,chamber_pos.getY() -chamber_hz,0); + G4Transform3D chamberbottom_trans = G4Transform3D(chamberbottom_rotm, chamberbottom_pos); + + //the empty space in the top and bottom of the chamber + G4double subtop_semix = chambertop_semix -chamberThickness; + G4double subtop_semiy = chambertop_semiy -chamberThickness; + G4double subtop_semiz = chambertop_semiz -chamberThickness; + G4double subtop_bottomcut = 0 -0.1*mm; //fudge factor to make sure the bottom doesn't show up in the visualizer + G4double subtop_topcut = subtop_semiz; + G4RotationMatrix subtop_rotm = G4RotationMatrix(); + G4ThreeVector subtop_pos = G4ThreeVector(0,0,0); + G4Transform3D subtop_trans = G4Transform3D(subtop_rotm, subtop_pos); + + //the hole for the beamline + G4double subhole_rmin = 0*mm; + G4double subhole_rmax = 152.4*mm/2; + G4double subhole_hz = 10*(chamber_rmax -subchamber_rmax); + G4double subhole_phimin = 0*deg; + G4double subhole_phimax = 360*deg; + G4RotationMatrix subhole_rotm = G4RotationMatrix(); + subhole_rotm.rotateX(90*deg); + G4ThreeVector subhole_pos = G4ThreeVector(0,-(chamber_rmax +subchamber_rmax)/2,chamber_pos.getY()); + G4Transform3D subhole_trans = G4Transform3D(subhole_rotm, subhole_pos); + + //the beamline + G4double beamline_rmin = subhole_rmax -beamlineThickness; + G4double beamline_rmax = subhole_rmax; + G4double beamline_hz = 500*mm; //the real value is 8760.46*mm; but this makes visualization difficult. + G4double beamline_phimin = 0*deg; + G4double beamline_phimax = 360*deg; + G4RotationMatrix beamline_rotm = G4RotationMatrix(); + G4ThreeVector beamline_pos = G4ThreeVector(0,0,-(subchamber_rmax +beamline_hz -subhole_hz)); + G4Transform3D beamline_trans = G4Transform3D(beamline_rotm, beamline_pos); + G4RotationMatrix subchamber_rotm2 = G4RotationMatrix(); + subchamber_rotm2.rotateX(90*deg); + G4ThreeVector subchamber_pos2 = G4ThreeVector(0,0,-beamline_pos.getZ()); + G4Transform3D subchamber_trans2 = G4Transform3D(subchamber_rotm2, subchamber_pos2); + + //---------------------------------------------------- + //constructing the chamber + //---------------------------------------------------- + //the walls of the chamber + G4Tubs* solidSubchamber = + new G4Tubs("Subchamber", //its name + subchamber_rmin, subchamber_rmax, + subchamber_hz, + subchamber_phimin, subchamber_phimax); //its size + + G4Tubs* solidSubhole = + new G4Tubs("Subhole", //its name + subhole_rmin, subhole_rmax, + subhole_hz, + subhole_phimin, subhole_phimax); //its size + + G4Tubs* solidStartchamber = + new G4Tubs("Startchamber", //its name + chamber_rmin, chamber_rmax, + chamber_hz, + chamber_phimin, chamber_phimax); //its size + + G4SubtractionSolid* solidMidchamber = + new G4SubtractionSolid("Midchamber", + solidStartchamber, + solidSubchamber, + subchamber_trans1); + + G4SubtractionSolid* solidChamber = + new G4SubtractionSolid("Chamber", + solidMidchamber, + solidSubhole, + subhole_trans); + + G4LogicalVolume* logicChamber = + new G4LogicalVolume(solidChamber, //its solid + Al, //its material + "Chamber"); //its name + logicChamber->SetVisAttributes(chamberVisAtt); + + new G4PVPlacement(chamber_trans, //rotation, position + logicChamber, //its logical volume + "Chamber", //its name + world, //its mother volume + false, //no boolean operation + 1, //copy number + checkOverlaps); //overlaps checking + + //the top and bottom of the chamber + G4Ellipsoid* solidStartchambertop = + new G4Ellipsoid("Startchambertop", //its name + chambertop_semix, chambertop_semiy, chambertop_semiz, + chambertop_bottomcut, chambertop_topcut); //its size + + G4Ellipsoid* solidSubtop = + new G4Ellipsoid("Subtop", //its name + subtop_semix, subtop_semiy, subtop_semiz, + subtop_bottomcut, subtop_topcut); //its size + + G4SubtractionSolid* solidChambertop = + new G4SubtractionSolid("Chambertop", + solidStartchambertop, + solidSubtop, + subtop_trans); + + G4LogicalVolume* logicChambertop = + new G4LogicalVolume(solidChambertop, //its solid + Al, //its material + "Chambertop"); //its name + logicChambertop->SetVisAttributes(chamberVisAtt); + + new G4PVPlacement(chambertop_trans, //rotation, position + logicChambertop, //its logical volume + "Chambertop", //its name + world, //its mother volume + false, //no boolean operation + 1, //copy number + checkOverlaps); //overlaps checking + new G4PVPlacement(chamberbottom_trans, //rotation, position + logicChambertop, //its logical volume + "Chamberbottom", //its name + world, //its mother volume + false, //no boolean operation + 1, //copy number + checkOverlaps); //overlaps checking + + //the beamline + G4Tubs* solidStartbeamline = + new G4Tubs("Startbeamline", //its name + beamline_rmin, beamline_rmax, + beamline_hz, + beamline_phimin, beamline_phimax); //its size + + G4SubtractionSolid* solidBeamline = + new G4SubtractionSolid("Beamline", + solidStartbeamline, + solidSubchamber, + subchamber_trans2); + + G4LogicalVolume* logicBeamline = + new G4LogicalVolume(solidBeamline, //its solid + Al, //its material + "Beamline"); //its name + logicBeamline->SetVisAttributes(chamberVisAtt); + + new G4PVPlacement(beamline_trans, //rotation, position + logicBeamline, //its logical volume + "Beamline", //its name + world, //its mother volume + false, //no boolean operation + 1, //copy number + checkOverlaps); //overlaps checking + + + } + + + if(m_Ring1){ + // Ring 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lg pseudofixed + G4int detNum1 = 6; + G4double distanceFromTargetBack1 = 110.*mm; + G4double theta1 = 9.0*deg; + G4double halfTheta1 = 5.0*deg; + G4double lgThickness1 = 8.0*mm; + G4double detThickness1 = 9.2*mm; + G4double distanceFromTarget1 = distanceFromTargetBack1 - detThickness1; + + //G4double distance1 = distanceFromTarget1*sin(theta1); //this gives the distance from the beam axis. + + // + // Delrin Ring + // + G4double delrinA1 = 5*mm; + G4double delrinB1 = 10*mm; + G4double fdelrinHalfAngle1 = atan(delrinB1/2/(distanceFromTarget1+detThickness1+lgThickness1)); + G4double firs1 = pow(pow(distanceFromTarget1+detThickness1+lgThickness1,2)+pow(delrinB1/2,2),0.5)*sin(theta1-fdelrinHalfAngle1); + G4double firb1 = pow(pow(distanceFromTarget1+detThickness1+lgThickness1,2)+pow(delrinB1/2,2),0.5)*sin(theta1+fdelrinHalfAngle1); + G4double bdelrinHalfAngle1 = atan(delrinB1/2/(distanceFromTarget1+detThickness1+lgThickness1+delrinA1)); + G4double birs1 = pow(pow(distanceFromTarget1+detThickness1+lgThickness1+delrinA1,2)+pow(delrinB1/2,2),0.5)*sin(theta1-bdelrinHalfAngle1); + G4double birb1 = pow(pow(distanceFromTarget1+detThickness1+lgThickness1+delrinA1,2)+pow(delrinB1/2,2),0.5)*sin(theta1+bdelrinHalfAngle1); + + G4double delrin_dz1 = delrinB1/2; + G4double delrin_theta1 = 0; + G4double delrin_phi1 = 0; + G4double delrin_dyab1 = delrinA1/2; + G4double delrin_dxa1 = firs1*tan(180*deg/detNum1); + G4double delrin_dxb1 = birs1*tan(180*deg/detNum1); + G4double delrin_dycd1 = delrinA1/2; + G4double delrin_dxc1 = firb1*tan(180*deg/detNum1); + G4double delrin_dxd1 = birb1*tan(180*deg/detNum1); + G4double delrin_alpab1 = 0; + G4double delrin_alpcd1 = delrin_alpab1; + + + G4ThreeVector delrin_pos1 = G4ThreeVector(0,0,distanceFromTarget1*cos(theta1)); + + G4Trap* solidDelrin1 = + new G4Trap("Delrin1", //its name + delrin_dz1, + delrin_theta1, delrin_phi1, + delrin_dyab1, + delrin_dxa1, delrin_dxb1, + delrin_alpab1, + delrin_dycd1, + delrin_dxc1, delrin_dxd1, + delrin_alpcd1); //its size + + G4LogicalVolume* logicDelrin1 = + new G4LogicalVolume(solidDelrin1, //its solid + delrin, //its material + "Delrin1"); //its name + logicDelrin1->SetVisAttributes(delrinVisAtt); + + // + // CsI Detector + // + G4double coneheight1 = 2*distanceFromTarget1; + G4double flatheight1 = coneheight1-0.01*mm; + G4double coneangle1 = theta1; + G4double crystal_rmina1 = (coneheight1-flatheight1)*tan(coneangle1-halfTheta1); + G4double crystal_rmaxa1 = (coneheight1-flatheight1)*tan(coneangle1+halfTheta1); + G4double crystal_rminb1 = coneheight1*tan(coneangle1-halfTheta1); + G4double crystal_rmaxb1 = coneheight1*tan(coneangle1+halfTheta1); + G4double crystal_hz1 = 0.5*flatheight1;//(crystal_rmaxb1-crystal_rmaxa1)/crystal_rmaxb1*coneheight1; + G4double crystal_phimin1 = 0.*deg, crystal_phimax1 = 360.*deg/detNum1; + G4RotationMatrix tip_rotm1 = G4RotationMatrix(); + G4ThreeVector tip_pos1 = G4ThreeVector(0,0,0.5*flatheight1+(coneheight1-flatheight1)); + G4Transform3D tip_trans1 = G4Transform3D(tip_rotm1, tip_pos1); + G4ThreeVector z1 = G4ThreeVector(0,0,1); + G4ThreeVector d01 = G4ThreeVector(distanceFromTarget1*sin(coneangle1)*cos(0.5*360*deg/detNum1), + distanceFromTarget1*sin(coneangle1)*sin(0.5*360*deg/detNum1), + distanceFromTarget1*cos(coneangle1)); + G4ThreeVector unitAxis1 = z1.cross(d01); + unitAxis1 = unitAxis1/unitAxis1.mag(); + G4double ux1 = unitAxis1.x(); + G4double uy1 = unitAxis1.y(); + G4double uz1 = unitAxis1.z(); + G4ThreeVector top1 = G4ThreeVector(cos(coneangle1)+pow(ux1,2)*(1-cos(coneangle1)), ux1*uy1*(1-cos(coneangle1))-uz1*sin(coneangle1), ux1*uz1*(1-cos(coneangle1))+uy1*sin(coneangle1)); + G4ThreeVector mid1 = G4ThreeVector(uy1*ux1*(1-cos(coneangle1))+uz1*sin(coneangle1), cos(coneangle1)+pow(uy1,2)*(1-cos(coneangle1)), uy1*uz1*(1-cos(coneangle1))-ux1*sin(coneangle1)); + G4ThreeVector bot1 = G4ThreeVector(uz1*ux1*(1-cos(coneangle1))-uy1*sin(coneangle1), uz1*uy1*(1-cos(coneangle1))+ux1*sin(coneangle1), cos(coneangle1)+pow(uz1,2)*(1-cos(coneangle1))); + G4RotationMatrix firstBox_rotm1 = G4RotationMatrix(); + firstBox_rotm1.setRows(top1,mid1,bot1); + G4ThreeVector firstBox_pos1 = G4ThreeVector(0,0,0); + G4Transform3D firstBox_trans1 = G4Transform3D(firstBox_rotm1, firstBox_pos1); + G4RotationMatrix secondBox_rotm1 = G4RotationMatrix(); + secondBox_rotm1.setRows(top1,mid1,bot1); + G4ThreeVector secondBox_pos1 = (2*distanceFromTarget1+detThickness1)/distanceFromTarget1*d01; + G4Transform3D secondBox_trans1 = G4Transform3D(secondBox_rotm1, secondBox_pos1); + + G4Orb* solidTip1 = + new G4Orb("tip1", + .0001*mm); + G4Box* solidSubtractionBox1 = + new G4Box("SubtractionBox1", //its name + distanceFromTarget1, + distanceFromTarget1, + distanceFromTarget1); //its size + G4Cons* solidCone1 = + new G4Cons("Cone1", //its name + crystal_rmina1, crystal_rmaxa1, + crystal_rminb1, crystal_rmaxb1, + crystal_hz1, + crystal_phimin1, crystal_phimax1); //its size + G4UnionSolid* solidTippedCone1 = + new G4UnionSolid("TippedCone1", + solidTip1, + solidCone1, + tip_trans1); + G4SubtractionSolid* solidIntermediate1 = + new G4SubtractionSolid("Intermediate1", + solidTippedCone1, + solidSubtractionBox1, + firstBox_trans1); + G4SubtractionSolid* solidCrystal1 = + new G4SubtractionSolid("Crystal1", + solidIntermediate1, + solidSubtractionBox1, + secondBox_trans1); + + G4LogicalVolume* logicCrystal1 = + new G4LogicalVolume(solidCrystal1, //its solid + CsI, //its material + "CsI Detector1"); //its name + logicCrystal1->SetVisAttributes(crystalVisAtt); + logicCrystal1->SetSensitiveDetector(m_MicroballScorer); + //fScoringVolume = logicCrystal1; + + // + // Light Guide + // + G4double lightGuide_px1 = 10*mm; + G4double lightGuide_py1 = 10*mm; + G4double lightGuide_pz1 = lgThickness1; + G4Box* solidLightGuide1 = + new G4Box("LightGuide1", //its name + 0.5*lightGuide_px1, + 0.5*lightGuide_py1, + 0.5*lightGuide_pz1); //its size + + G4LogicalVolume* logicLightGuide1 = + new G4LogicalVolume(solidLightGuide1, //its solid + glass, //its material + "LightGuide1"); //its name + logicLightGuide1->SetVisAttributes(lightGuideVisAtt); + + for(int i = 1; i <= detNum1; i++) + { + G4RotationMatrix crystal_rotm = G4RotationMatrix(); + G4ThreeVector d0 = G4ThreeVector(distanceFromTarget1*sin(coneangle1)*cos(0.5*360*deg/detNum1), + distanceFromTarget1*sin(coneangle1)*sin(0.5*360*deg/detNum1), + distanceFromTarget1*cos(coneangle1)); + G4ThreeVector df = G4ThreeVector(distanceFromTarget1*sin(theta1)*sin((i-1)*360*deg/detNum1+.001*deg/*+0.5*360*deg/detNum1*/), + distanceFromTarget1*sin(theta1)*cos((i-1)*360*deg/detNum1+.001*deg/*+0.5*360*deg/detNum1*/), + -distanceFromTarget1*cos(theta1)); + G4ThreeVector axis = d0.cross(df); + G4double ax = axis.x(); + G4double ay = axis.y(); + G4double az = axis.z(); + G4double ux = ax/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double uy = ay/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double uz = az/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double j = acos(d0.dot(df)/(d0.mag()*df.mag())); + G4ThreeVector a = G4ThreeVector(cos(j)+pow(ux,2)*(1-cos(j)), ux*uy*(1-cos(j))-uz*sin(j), ux*uz*(1-cos(j))+uy*sin(j)); + G4ThreeVector b = G4ThreeVector(uy*ux*(1-cos(j))+uz*sin(j), cos(j)+pow(uy,2)*(1-cos(j)), uy*uz*(1-cos(j))-ux*sin(j)); + G4ThreeVector c = G4ThreeVector(uz*ux*(1-cos(j))-uy*sin(j), uz*uy*(1-cos(j))+ux*sin(j), cos(j)+pow(uz,2)*(1-cos(j))); + G4RotationMatrix abc = G4RotationMatrix(); + abc.setRows(a,b,c); + G4ThreeVector unitdf = df/df.mag(); + G4double udfx = unitdf.x(); + G4double udfy = unitdf.y(); + G4double udfz = unitdf.z(); + G4double k = 180.*deg; + G4ThreeVector d = G4ThreeVector(cos(k)+pow(udfx,2)*(1-cos(k)), udfx*udfy*(1-cos(k))-udfz*sin(k), udfx*udfz*(1-cos(k))+udfy*sin(k)); + G4ThreeVector e = G4ThreeVector(udfy*udfx*(1-cos(k))+udfz*sin(k), cos(k)+pow(udfy,2)*(1-cos(k)), udfy*udfz*(1-cos(k))-udfx*sin(k)); + G4ThreeVector f = G4ThreeVector(udfz*udfx*(1-cos(k))-udfy*sin(k), udfz*udfy*(1-cos(k))+udfx*sin(k), cos(k)+pow(udfz,2)*(1-cos(k))); + G4RotationMatrix def = G4RotationMatrix(); + def.setRows(d,e,f); + crystal_rotm=def*abc; + if (m_Flip == 0){ + crystal_rotm.rotateY(180*deg); + } + crystal_rotm.rotateZ(180*deg); + G4ThreeVector crystal_pos = G4ThreeVector(0,0,0); + G4Transform3D crystal_trans = G4Transform3D(crystal_rotm, crystal_pos); + G4RotationMatrix lg_rotm = G4RotationMatrix(); + G4ThreeVector lg_Axis = df.cross(z1); + lg_Axis = lg_Axis/lg_Axis.mag(); + lg_Axis.rotateZ(180*deg); + G4double ulgx = lg_Axis.x(); + G4double ulgy = lg_Axis.y(); + G4double ulgz = lg_Axis.z(); + G4ThreeVector p = G4ThreeVector(cos(theta1)+pow(ulgx,2)*(1-cos(theta1)), ulgx*ulgy*(1-cos(theta1))-ulgz*sin(theta1), ulgx*ulgz*(1-cos(theta1))+ulgy*sin(theta1)); + G4ThreeVector q = G4ThreeVector(ulgy*ulgx*(1-cos(theta1))+ulgz*sin(theta1), cos(theta1)+pow(ulgy,2)*(1-cos(theta1)), ulgy*ulgz*(1-cos(theta1))-ulgx*sin(theta1)); + G4ThreeVector r = G4ThreeVector(ulgz*ulgx*(1-cos(theta1))-ulgy*sin(theta1), ulgz*ulgy*(1-cos(theta1))+ulgx*sin(theta1), cos(theta1)+pow(ulgz,2)*(1-cos(theta1))); + G4RotationMatrix pqr = G4RotationMatrix(); + pqr.setRows(p,q,r); + lg_rotm.rotateZ((i-1)*360*deg/detNum1); + lg_rotm.rotateX(180*deg); + lg_rotm=pqr*lg_rotm; + G4ThreeVector lg_pos = (distanceFromTarget1+detThickness1+0.5*lgThickness1)/df.mag()*df; + lg_pos.rotateZ(180*deg); + if (m_Flip == 0){ + lg_pos.rotateY(180*deg); + lg_rotm.rotateY(180*deg); + } + G4Transform3D lg_trans = G4Transform3D(lg_rotm, lg_pos); + G4RotationMatrix delrin_rotm = G4RotationMatrix(); + G4ThreeVector w = G4ThreeVector(sin(theta1)*sin((i-1)*360*deg/detNum1+.001*deg), sin(theta1)*cos((i-1)*360*deg/detNum1+.001*deg), cos(theta1)); + G4ThreeVector delrin_Axis = w.cross(z1); + delrin_Axis = delrin_Axis/delrin_Axis.mag(); + delrin_Axis.rotateX(180*deg); + G4double udx = delrin_Axis.x(); + G4double udy = delrin_Axis.y(); + G4double udz = delrin_Axis.z(); + G4double delAng = 90*deg+theta1; + G4ThreeVector pdel = G4ThreeVector(cos(delAng)+pow(udx,2)*(1-cos(delAng)), udx*udy*(1-cos(delAng))-udz*sin(delAng), udx*udz*(1-cos(delAng))+udy*sin(delAng)); + G4ThreeVector qdel = G4ThreeVector(udy*udx*(1-cos(delAng))+udz*sin(delAng), cos(delAng)+pow(udy,2)*(1-cos(delAng)), udy*udz*(1-cos(delAng))-udx*sin(delAng)); + G4ThreeVector rdel = G4ThreeVector(udz*udx*(1-cos(delAng))-udy*sin(delAng), udz*udy*(1-cos(delAng))+udx*sin(delAng), cos(delAng)+pow(udz,2)*(1-cos(delAng))); + G4RotationMatrix pqrdel = G4RotationMatrix(); + pqrdel.setRows(pdel,qdel,rdel); + delrin_rotm.rotateZ((i-1)*360*deg/detNum1+.001*deg); + delrin_rotm=pqrdel*delrin_rotm; + G4ThreeVector delrin_pos = (distanceFromTarget1+detThickness1+lgThickness1+delrinA1/2+.0003*mm)/df.mag()*df; //the .0003 mm is a fudge factor to prevent overlapping + delrin_pos.rotateZ(180*deg); + delrin_pos.rotateY(180*deg); + if (m_Flip == 1){ + delrin_pos.rotateY(180*deg); + delrin_rotm.rotateY(180*deg); + } + G4Transform3D delrin_trans = G4Transform3D(delrin_rotm, delrin_pos); + bool placeCrystal = true; + for (unsigned int i2=0; i2 < m_Array.size(); i2++){ + if (0 < m_Array[i2] && m_Array[i2] < 7){ + /*if (1+6-m_Array[i2] == 0+i){ + placeCrystal = false; + }*/ + if (m_Array[i2] == 0+i){ + placeCrystal = false; + } + } + } + if (placeCrystal){ + if(crystalBool) {new G4PVPlacement(crystal_trans, //rotation, position + logicCrystal1, //its logical volume + "CsI Detector1", //its name + world, //its mother volume + false, //no boolean operation + 0+i, //copy number + checkOverlaps); //overlaps checking + } + if(lgBool) {new G4PVPlacement(lg_trans, //rotation, position + logicLightGuide1, //its logical volume + "LightGuide1", //its name + world, //its mother volume + false, //no boolean operation + 0+i, //copy number + checkOverlaps); //overlaps checking + } + if(delrinBool) {new G4PVPlacement(delrin_trans, //rotation, position + logicDelrin1, //its logical volume + "Delrin1", //its name + world, //its mother volume + false, //no boolean operation + 0+i, //copy number + checkOverlaps); //overlaps checking + } + } + }} + if(m_Ring2){ + // Ring 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lg pseudofixed + G4int detNum2 = 10; + G4double distanceFromTargetBack2 = 80.*mm; + G4double theta2 = 21.0*deg; + G4double halfTheta2 = 7.0*deg; //+0.1*deg; //0.1 is a fudge factor to make it cover solid angle 4pi + G4double lgThickness2 = 7.5*mm; + G4double detThickness2 = 7.2*mm; + G4double distanceFromTarget2 = distanceFromTargetBack2 - detThickness2; + + //G4double distance2 = distanceFromTarget2*sin(theta2); //this gives the distance from the beam axis. + + // + // Delrin Ring + // + G4double delrinA2 = 5*mm; + G4double delrinB2 = 10*mm; + G4double fdelrinHalfAngle2 = atan(delrinB2/2/(distanceFromTarget2+detThickness2+lgThickness2)); + G4double firs2 = pow(pow(distanceFromTarget2+detThickness2+lgThickness2,2)+pow(delrinB2/2,2),0.5)*sin(theta2-fdelrinHalfAngle2); + G4double firb2 = pow(pow(distanceFromTarget2+detThickness2+lgThickness2,2)+pow(delrinB2/2,2),0.5)*sin(theta2+fdelrinHalfAngle2); + G4double bdelrinHalfAngle2 = atan(delrinB2/2/(distanceFromTarget2+detThickness2+lgThickness2+delrinA2)); + G4double birs2 = pow(pow(distanceFromTarget2+detThickness2+lgThickness2+delrinA2,2)+pow(delrinB2/2,2),0.5)*sin(theta2-bdelrinHalfAngle2); + G4double birb2 = pow(pow(distanceFromTarget2+detThickness2+lgThickness2+delrinA2,2)+pow(delrinB2/2,2),0.5)*sin(theta2+bdelrinHalfAngle2); + + G4double delrin_dz2 = delrinB2/2; + G4double delrin_theta2 = 0; + G4double delrin_phi2 = 0; + G4double delrin_dyab2 = delrinA2/2; + G4double delrin_dxa2 = firs2*tan(180*deg/detNum2); + G4double delrin_dxb2 = birs2*tan(180*deg/detNum2); + G4double delrin_dycd2 = delrinA2/2; + G4double delrin_dxc2 = firb2*tan(180*deg/detNum2); + G4double delrin_dxd2 = birb2*tan(180*deg/detNum2); + G4double delrin_alpab2 = 0; + G4double delrin_alpcd2 = delrin_alpab2; + + + G4ThreeVector delrin_pos2 = G4ThreeVector(0,0,distanceFromTarget2*cos(theta2)); + + G4Trap* solidDelrin2 = + new G4Trap("Delrin2", //its name + delrin_dz2, + delrin_theta2, delrin_phi2, + delrin_dyab2, + delrin_dxa2, delrin_dxb2, + delrin_alpab2, + delrin_dycd2, + delrin_dxc2, delrin_dxd2, + delrin_alpcd2); //its size + + G4LogicalVolume* logicDelrin2 = + new G4LogicalVolume(solidDelrin2, //its solid + delrin, //its material + "Delrin2"); //its name + logicDelrin2->SetVisAttributes(delrinVisAtt); + + + // + // CsI Detector + // + G4double coneheight2 = 2*distanceFromTarget2; + G4double flatheight2 = coneheight2-0.01*mm; + G4double coneangle2 = theta2; + G4double crystal_rmina2 = (coneheight2-flatheight2)*tan(coneangle2-halfTheta2); + G4double crystal_rmaxa2 = (coneheight2-flatheight2)*tan(coneangle2+halfTheta2); + G4double crystal_rminb2 = coneheight2*tan(coneangle2-halfTheta2); + G4double crystal_rmaxb2 = coneheight2*tan(coneangle2+halfTheta2); + G4double crystal_hz2 = 0.5*flatheight2;//(crystal_rmaxb2-crystal_rmaxa2)/crystal_rmaxb2*coneheight2; + G4double crystal_phimin2 = 0.*deg, crystal_phimax2 = 360.*deg/detNum2; + G4RotationMatrix tip_rotm2 = G4RotationMatrix(); + G4ThreeVector tip_pos2 = G4ThreeVector(0,0,0.5*flatheight2+(coneheight2-flatheight2)); + G4Transform3D tip_trans2 = G4Transform3D(tip_rotm2, tip_pos2); + G4ThreeVector z2 = G4ThreeVector(0,0,1); + G4ThreeVector d02 = G4ThreeVector(distanceFromTarget2*sin(coneangle2)*cos(0.5*360*deg/detNum2), + distanceFromTarget2*sin(coneangle2)*sin(0.5*360*deg/detNum2), + distanceFromTarget2*cos(coneangle2)); + G4ThreeVector unitAxis2 = z2.cross(d02); + unitAxis2 = unitAxis2/unitAxis2.mag(); + G4double ux2 = unitAxis2.x(); + G4double uy2 = unitAxis2.y(); + G4double uz2 = unitAxis2.z(); + G4ThreeVector top2 = G4ThreeVector(cos(coneangle2)+pow(ux2,2)*(1-cos(coneangle2)), ux2*uy2*(1-cos(coneangle2))-uz2*sin(coneangle2), ux2*uz2*(1-cos(coneangle2))+uy2*sin(coneangle2)); + G4ThreeVector mid2 = G4ThreeVector(uy2*ux2*(1-cos(coneangle2))+uz2*sin(coneangle2), cos(coneangle2)+pow(uy2,2)*(1-cos(coneangle2)), uy2*uz2*(1-cos(coneangle2))-ux2*sin(coneangle2)); + G4ThreeVector bot2 = G4ThreeVector(uz2*ux2*(1-cos(coneangle2))-uy2*sin(coneangle2), uz2*uy2*(1-cos(coneangle2))+ux2*sin(coneangle2), cos(coneangle2)+pow(uz2,2)*(1-cos(coneangle2))); + G4RotationMatrix firstBox_rotm2 = G4RotationMatrix(); + firstBox_rotm2.setRows(top2,mid2,bot2); + G4ThreeVector firstBox_pos2 = G4ThreeVector(0,0,0); + G4Transform3D firstBox_trans2 = G4Transform3D(firstBox_rotm2, firstBox_pos2); + G4RotationMatrix secondBox_rotm2 = G4RotationMatrix(); + secondBox_rotm2.setRows(top2,mid2,bot2); + G4ThreeVector secondBox_pos2 = (2*distanceFromTarget2+detThickness2)/distanceFromTarget2*d02; + G4Transform3D secondBox_trans2 = G4Transform3D(secondBox_rotm2, secondBox_pos2); + + G4Orb* solidTip2 = + new G4Orb("tip2", + .0001*mm); + G4Box* solidSubtractionBox2 = + new G4Box("SubtractionBox2", //its name + distanceFromTarget2, + distanceFromTarget2, + distanceFromTarget2); //its size + G4Cons* solidCone2 = + new G4Cons("Cone2", //its name + crystal_rmina2, crystal_rmaxa2, + crystal_rminb2, crystal_rmaxb2, + crystal_hz2, + crystal_phimin2, crystal_phimax2); //its size + G4UnionSolid* solidTippedCone2 = + new G4UnionSolid("TippedCone2", + solidTip2, + solidCone2, + tip_trans2); + G4SubtractionSolid* solidIntermediate2 = + new G4SubtractionSolid("Intermediate2", + solidTippedCone2, + solidSubtractionBox2, + firstBox_trans2); + G4SubtractionSolid* solidCrystal2 = + new G4SubtractionSolid("Crystal2", + solidIntermediate2, + solidSubtractionBox2, + secondBox_trans2); + + G4LogicalVolume* logicCrystal2 = + new G4LogicalVolume(solidCrystal2, //its solid + CsI, //its material + "CsI Detector2"); //its name + logicCrystal2->SetVisAttributes(crystalVisAtt); + logicCrystal2->SetSensitiveDetector(m_MicroballScorer); + // + // Light Guide + // + G4double lightGuide_px2 = 10*mm; + G4double lightGuide_py2 = 10*mm; + G4double lightGuide_pz2 = lgThickness2; + G4Box* solidLightGuide2 = + new G4Box("LightGuide2", //its name + 0.5*lightGuide_px2, + 0.5*lightGuide_py2, + 0.5*lightGuide_pz2); //its size + + G4LogicalVolume* logicLightGuide2 = + new G4LogicalVolume(solidLightGuide2, //its solid + glass, //its material + "LightGuide2"); //its name + logicLightGuide2->SetVisAttributes(lightGuideVisAtt); + + for(int i = 1; i <= detNum2; i++) + { + G4RotationMatrix crystal_rotm = G4RotationMatrix(); + G4ThreeVector d0 = G4ThreeVector(distanceFromTarget2*sin(coneangle2)*cos(0.5*360*deg/detNum2), + distanceFromTarget2*sin(coneangle2)*sin(0.5*360*deg/detNum2), + distanceFromTarget2*cos(coneangle2)); + G4ThreeVector df = G4ThreeVector(distanceFromTarget2*sin(theta2)*sin((i-1)*360*deg/detNum2+.001*deg/*+0.5*360*deg/detNum2*/), + distanceFromTarget2*sin(theta2)*cos((i-1)*360*deg/detNum2+.001*deg/*+0.5*360*deg/detNum2*/), + -distanceFromTarget2*cos(theta2)); + G4ThreeVector axis = d0.cross(df); + G4double ax = axis.x(); + G4double ay = axis.y(); + G4double az = axis.z(); + G4double ux = ax/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double uy = ay/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double uz = az/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double j = acos(d0.dot(df)/(d0.mag()*df.mag())); + G4ThreeVector a = G4ThreeVector(cos(j)+pow(ux,2)*(1-cos(j)), ux*uy*(1-cos(j))-uz*sin(j), ux*uz*(1-cos(j))+uy*sin(j)); + G4ThreeVector b = G4ThreeVector(uy*ux*(1-cos(j))+uz*sin(j), cos(j)+pow(uy,2)*(1-cos(j)), uy*uz*(1-cos(j))-ux*sin(j)); + G4ThreeVector c = G4ThreeVector(uz*ux*(1-cos(j))-uy*sin(j), uz*uy*(1-cos(j))+ux*sin(j), cos(j)+pow(uz,2)*(1-cos(j))); + G4RotationMatrix abc = G4RotationMatrix(); + abc.setRows(a,b,c); + G4ThreeVector unitdf = df/df.mag(); + G4double udfx = unitdf.x(); + G4double udfy = unitdf.y(); + G4double udfz = unitdf.z(); + G4double k = 180.*deg; + G4ThreeVector d = G4ThreeVector(cos(k)+pow(udfx,2)*(1-cos(k)), udfx*udfy*(1-cos(k))-udfz*sin(k), udfx*udfz*(1-cos(k))+udfy*sin(k)); + G4ThreeVector e = G4ThreeVector(udfy*udfx*(1-cos(k))+udfz*sin(k), cos(k)+pow(udfy,2)*(1-cos(k)), udfy*udfz*(1-cos(k))-udfx*sin(k)); + G4ThreeVector f = G4ThreeVector(udfz*udfx*(1-cos(k))-udfy*sin(k), udfz*udfy*(1-cos(k))+udfx*sin(k), cos(k)+pow(udfz,2)*(1-cos(k))); + G4RotationMatrix def = G4RotationMatrix(); + def.setRows(d,e,f); + crystal_rotm=def*abc; + if (m_Flip == 0){ + crystal_rotm.rotateY(180*deg); + } + crystal_rotm.rotateZ(180*deg); + G4ThreeVector crystal_pos = G4ThreeVector(0,0,0); + G4Transform3D crystal_trans = G4Transform3D(crystal_rotm, crystal_pos); + G4RotationMatrix lg_rotm = G4RotationMatrix(); + G4ThreeVector lg_Axis = df.cross(z2); + lg_Axis = lg_Axis/lg_Axis.mag(); + lg_Axis.rotateZ(180*deg); + G4double ulgx = lg_Axis.x(); + G4double ulgy = lg_Axis.y(); + G4double ulgz = lg_Axis.z(); + G4ThreeVector p = G4ThreeVector(cos(theta2)+pow(ulgx,2)*(1-cos(theta2)), ulgx*ulgy*(1-cos(theta2))-ulgz*sin(theta2), ulgx*ulgz*(1-cos(theta2))+ulgy*sin(theta2)); + G4ThreeVector q = G4ThreeVector(ulgy*ulgx*(1-cos(theta2))+ulgz*sin(theta2), cos(theta2)+pow(ulgy,2)*(1-cos(theta2)), ulgy*ulgz*(1-cos(theta2))-ulgx*sin(theta2)); + G4ThreeVector r = G4ThreeVector(ulgz*ulgx*(1-cos(theta2))-ulgy*sin(theta2), ulgz*ulgy*(1-cos(theta2))+ulgx*sin(theta2), cos(theta2)+pow(ulgz,2)*(1-cos(theta2))); + G4RotationMatrix pqr = G4RotationMatrix(); + pqr.setRows(p,q,r); + lg_rotm.rotateZ((i-1)*360*deg/detNum2); + lg_rotm.rotateX(180*deg); + lg_rotm=pqr*lg_rotm; + G4ThreeVector lg_pos = (distanceFromTarget2+detThickness2+0.5*lgThickness2)/df.mag()*df; + lg_pos.rotateZ(180*deg); + if (m_Flip == 0){ + lg_pos.rotateY(180*deg); + lg_rotm.rotateY(180*deg); + } + G4Transform3D lg_trans = G4Transform3D(lg_rotm, lg_pos); + G4Transform3D d0_trans = G4Transform3D(G4RotationMatrix(), d0); + G4Transform3D df_trans = G4Transform3D(G4RotationMatrix(), df); + G4RotationMatrix delrin_rotm = G4RotationMatrix(); + G4ThreeVector w = G4ThreeVector(sin(theta2)*sin((i-1)*360*deg/detNum2+.001*deg), sin(theta2)*cos((i-1)*360*deg/detNum2+.001*deg), cos(theta2)); + G4ThreeVector delrin_Axis = w.cross(z2); + delrin_Axis.rotateX(180*deg); + delrin_Axis = delrin_Axis/delrin_Axis.mag(); + G4double udx = delrin_Axis.x(); + G4double udy = delrin_Axis.y(); + G4double udz = delrin_Axis.z(); + G4double delAng = 90*deg+theta2; + G4ThreeVector pdel = G4ThreeVector(cos(delAng)+pow(udx,2)*(1-cos(delAng)), udx*udy*(1-cos(delAng))-udz*sin(delAng), udx*udz*(1-cos(delAng))+udy*sin(delAng)); + G4ThreeVector qdel = G4ThreeVector(udy*udx*(1-cos(delAng))+udz*sin(delAng), cos(delAng)+pow(udy,2)*(1-cos(delAng)), udy*udz*(1-cos(delAng))-udx*sin(delAng)); + G4ThreeVector rdel = G4ThreeVector(udz*udx*(1-cos(delAng))-udy*sin(delAng), udz*udy*(1-cos(delAng))+udx*sin(delAng), cos(delAng)+pow(udz,2)*(1-cos(delAng))); + G4RotationMatrix pqrdel = G4RotationMatrix(); + pqrdel.setRows(pdel,qdel,rdel); + delrin_rotm.rotateZ((i-1)*360*deg/detNum2+.001*deg); + delrin_rotm=pqrdel*delrin_rotm; + delrin_rotm.rotateZ(0*deg); + G4ThreeVector delrin_pos = (distanceFromTarget2+detThickness2+lgThickness2+delrinA2/2+.0003*mm)/df.mag()*df; //the .0003 mm is a fudge factor to prevent overlapping + delrin_pos.rotateZ(180*deg); + delrin_pos.rotateY(180*deg); + if (m_Flip == 1){ + delrin_pos.rotateY(180*deg); + delrin_rotm.rotateY(180*deg); + } + G4Transform3D delrin_trans = G4Transform3D(delrin_rotm, delrin_pos); + bool placeCrystal = true; + for (unsigned int i2=0; i2 < m_Array.size(); i2++){ + if (6 < m_Array[i2] && m_Array[i2] < 17){ + if (m_Array[i2] == 6+i){ + placeCrystal = false; + } + } + } + if (placeCrystal){ + if(crystalBool) {new G4PVPlacement(crystal_trans, //rotation, position + logicCrystal2, //its logical volume + "CsI Detector2", //its name + world, //its mother volume + false, //no boolean operation + 6+i, //copy number + checkOverlaps); //overlaps checking + } + if(lgBool) {new G4PVPlacement(lg_trans, //rotation, position + logicLightGuide2, //its logical volume + "LightGuide2", //its name + world, //its mother volume + false, //no boolean operation + 6+i, //copy number + checkOverlaps); //overlaps checking + } + if(delrinBool) {new G4PVPlacement(delrin_trans, //rotation, position + logicDelrin2, //its logical volume + "Delrin2", //its name + world, //its mother volume + false, //no boolean operation + 6+i, //copy number + checkOverlaps); //overlaps checking + } + } + }} + + if(m_Ring3){ + // Ring 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lg pseudofixed + G4int detNum3 = 12; + G4double distanceFromTargetBack3 = 60.*mm; + G4double theta3 = 36.0*deg; + G4double halfTheta3 = 8.0*deg; + G4double lgThickness3 = 6.0*mm; + G4double detThickness3 = 6.4*mm; + G4double distanceFromTarget3 = distanceFromTargetBack3 - detThickness3; + + //G4double distance3 = distanceFromTarget3*sin(theta3); //this gives the distance from the beam axis. + + // + // Delrin Ring + // + G4double delrinA3 = 5*mm; + G4double delrinB3 = 10*mm; + G4double fdelrinHalfAngle3 = atan(delrinB3/2/(distanceFromTarget3+detThickness3+lgThickness3)); + G4double firs3 = pow(pow(distanceFromTarget3+detThickness3+lgThickness3,2)+pow(delrinB3/2,2),0.5)*sin(theta3-fdelrinHalfAngle3); + G4double firb3 = pow(pow(distanceFromTarget3+detThickness3+lgThickness3,2)+pow(delrinB3/2,2),0.5)*sin(theta3+fdelrinHalfAngle3); + G4double bdelrinHalfAngle3 = atan(delrinB3/2/(distanceFromTarget3+detThickness3+lgThickness3+delrinA3)); + G4double birs3 = pow(pow(distanceFromTarget3+detThickness3+lgThickness3+delrinA3,2)+pow(delrinB3/2,2),0.5)*sin(theta3-bdelrinHalfAngle3); + G4double birb3 = pow(pow(distanceFromTarget3+detThickness3+lgThickness3+delrinA3,2)+pow(delrinB3/2,2),0.5)*sin(theta3+bdelrinHalfAngle3); + + G4double delrin_dz3 = delrinB3/2; + G4double delrin_theta3 = 0; + G4double delrin_phi3 = 0; + G4double delrin_dyab3 = delrinA3/2; + G4double delrin_dxa3 = firs3*tan(180*deg/detNum3); + G4double delrin_dxb3 = birs3*tan(180*deg/detNum3); + G4double delrin_dycd3 = delrinA3/2; + G4double delrin_dxc3 = firb3*tan(180*deg/detNum3); + G4double delrin_dxd3 = birb3*tan(180*deg/detNum3); + G4double delrin_alpab3 = 0; + G4double delrin_alpcd3 = delrin_alpab3; + + + G4ThreeVector delrin_pos3 = G4ThreeVector(0,0,distanceFromTarget3*cos(theta3)); + + G4Trap* solidDelrin3 = + new G4Trap("Delrin3", //its name + delrin_dz3, + delrin_theta3, delrin_phi3, + delrin_dyab3, + delrin_dxa3, delrin_dxb3, + delrin_alpab3, + delrin_dycd3, + delrin_dxc3, delrin_dxd3, + delrin_alpcd3); //its size + + G4LogicalVolume* logicDelrin3 = + new G4LogicalVolume(solidDelrin3, //its solid + delrin, //its material + "Delrin3"); //its name + logicDelrin3->SetVisAttributes(delrinVisAtt); + + // + // CsI Detector + // + G4double coneheight3 = distanceFromTarget3; + G4double flatheight3 = coneheight3-0.01*mm; + G4double coneangle3 = theta3; + G4double crystal_rmina3 = (coneheight3-flatheight3)*tan(coneangle3-halfTheta3); + G4double crystal_rmaxa3 = (coneheight3-flatheight3)*tan(coneangle3+halfTheta3); + G4double crystal_rminb3 = coneheight3*tan(coneangle3-halfTheta3); + G4double crystal_rmaxb3 = coneheight3*tan(coneangle3+halfTheta3); + G4double crystal_hz3 = 0.5*flatheight3;//(crystal_rmaxb3-crystal_rmaxa3)/crystal_rmaxb3*coneheight3; + G4double crystal_phimin3 = 0.*deg, crystal_phimax3 = 360.*deg/detNum3; + G4RotationMatrix tip_rotm3 = G4RotationMatrix(); + G4ThreeVector tip_pos3 = G4ThreeVector(0,0,0.5*flatheight3+(coneheight3-flatheight3)); + G4Transform3D tip_trans3 = G4Transform3D(tip_rotm3, tip_pos3); + G4ThreeVector z3 = G4ThreeVector(0,0,1); + G4ThreeVector d03 = G4ThreeVector(distanceFromTarget3*sin(coneangle3)*cos(0.5*360*deg/detNum3), + distanceFromTarget3*sin(coneangle3)*sin(0.5*360*deg/detNum3), + distanceFromTarget3*cos(coneangle3)); + G4ThreeVector unitAxis3 = z3.cross(d03); + unitAxis3 = unitAxis3/unitAxis3.mag(); + G4double ux3 = unitAxis3.x(); + G4double uy3 = unitAxis3.y(); + G4double uz3 = unitAxis3.z(); + G4ThreeVector top3 = G4ThreeVector(cos(coneangle3)+pow(ux3,2)*(1-cos(coneangle3)), ux3*uy3*(1-cos(coneangle3))-uz3*sin(coneangle3), ux3*uz3*(1-cos(coneangle3))+uy3*sin(coneangle3)); + G4ThreeVector mid3 = G4ThreeVector(uy3*ux3*(1-cos(coneangle3))+uz3*sin(coneangle3), cos(coneangle3)+pow(uy3,2)*(1-cos(coneangle3)), uy3*uz3*(1-cos(coneangle3))-ux3*sin(coneangle3)); + G4ThreeVector bot3 = G4ThreeVector(uz3*ux3*(1-cos(coneangle3))-uy3*sin(coneangle3), uz3*uy3*(1-cos(coneangle3))+ux3*sin(coneangle3), cos(coneangle3)+pow(uz3,2)*(1-cos(coneangle3))); + G4RotationMatrix firstBox_rotm3 = G4RotationMatrix(); + firstBox_rotm3.setRows(top3,mid3,bot3); + G4ThreeVector firstBox_pos3 = G4ThreeVector(0,0,0); + G4Transform3D firstBox_trans3 = G4Transform3D(firstBox_rotm3, firstBox_pos3); + G4RotationMatrix secondBox_rotm3 = G4RotationMatrix(); + secondBox_rotm3.setRows(top3,mid3,bot3); + G4ThreeVector secondBox_pos3 = (2*distanceFromTarget3+detThickness3)/distanceFromTarget3*d03; + G4Transform3D secondBox_trans3 = G4Transform3D(secondBox_rotm3, secondBox_pos3); + + G4Orb* solidTip3 = + new G4Orb("tip3", + .0001*mm); + G4Box* solidSubtractionBox3 = + new G4Box("SubtractionBox3", //its name + distanceFromTarget3, + distanceFromTarget3, + distanceFromTarget3); //its size + G4Cons* solidCone3 = + new G4Cons("Cone3", //its name + crystal_rmina3, crystal_rmaxa3, + crystal_rminb3, crystal_rmaxb3, + crystal_hz3, + crystal_phimin3, crystal_phimax3); //its size + G4UnionSolid* solidTippedCone3 = + new G4UnionSolid("TippedCone3", + solidTip3, + solidCone3, + tip_trans3); + G4SubtractionSolid* solidIntermediate3 = + new G4SubtractionSolid("Intermediate3", + solidTippedCone3, + solidSubtractionBox3, + firstBox_trans3); + G4SubtractionSolid* solidCrystal3 = + new G4SubtractionSolid("Crystal3", + solidIntermediate3, + solidSubtractionBox3, + secondBox_trans3); + + G4LogicalVolume* logicCrystal3 = + new G4LogicalVolume(solidCrystal3, //its solid + CsI, //its material + "CsI Detector3"); //its name + logicCrystal3->SetVisAttributes(crystalVisAtt); + logicCrystal3->SetSensitiveDetector(m_MicroballScorer); + + + // + // Light Guide + // + G4double lightGuide_px3 = 10*mm; + G4double lightGuide_py3 = 10*mm; + G4double lightGuide_pz3 = lgThickness3; + G4Box* solidLightGuide3 = + new G4Box("LightGuide3", //its name + 0.5*lightGuide_px3, + 0.5*lightGuide_py3, + 0.5*lightGuide_pz3); //its size + + G4LogicalVolume* logicLightGuide3 = + new G4LogicalVolume(solidLightGuide3, //its solid + glass, //its material + "LightGuide3"); //its name + logicLightGuide3->SetVisAttributes(lightGuideVisAtt); + + + for(int i = 1; i <= detNum3; i++) + { + G4RotationMatrix crystal_rotm = G4RotationMatrix(); + G4ThreeVector d0 = G4ThreeVector(distanceFromTarget3*sin(coneangle3)*cos(0.5*360*deg/detNum3), + distanceFromTarget3*sin(coneangle3)*sin(0.5*360*deg/detNum3), + distanceFromTarget3*cos(coneangle3)); + G4ThreeVector df = G4ThreeVector(distanceFromTarget3*sin(theta3)*sin((i-1)*360*deg/detNum3+.001*deg/*+0.5*360*deg/detNum3*/), + distanceFromTarget3*sin(theta3)*cos((i-1)*360*deg/detNum3+.001*deg/*+0.5*360*deg/detNum3*/), + -distanceFromTarget3*cos(theta3)); + G4ThreeVector axis = d0.cross(df); + G4double ax = axis.x(); + G4double ay = axis.y(); + G4double az = axis.z(); + G4double ux = ax/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double uy = ay/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double uz = az/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double j = acos(d0.dot(df)/(d0.mag()*df.mag())); + G4ThreeVector a = G4ThreeVector(cos(j)+pow(ux,2)*(1-cos(j)), ux*uy*(1-cos(j))-uz*sin(j), ux*uz*(1-cos(j))+uy*sin(j)); + G4ThreeVector b = G4ThreeVector(uy*ux*(1-cos(j))+uz*sin(j), cos(j)+pow(uy,2)*(1-cos(j)), uy*uz*(1-cos(j))-ux*sin(j)); + G4ThreeVector c = G4ThreeVector(uz*ux*(1-cos(j))-uy*sin(j), uz*uy*(1-cos(j))+ux*sin(j), cos(j)+pow(uz,2)*(1-cos(j))); + G4RotationMatrix abc = G4RotationMatrix(); + abc.setRows(a,b,c); + G4ThreeVector unitdf = df/df.mag(); + G4double udfx = unitdf.x(); + G4double udfy = unitdf.y(); + G4double udfz = unitdf.z(); + G4double k = 180.*deg; + G4ThreeVector d = G4ThreeVector(cos(k)+pow(udfx,2)*(1-cos(k)), udfx*udfy*(1-cos(k))-udfz*sin(k), udfx*udfz*(1-cos(k))+udfy*sin(k)); + G4ThreeVector e = G4ThreeVector(udfy*udfx*(1-cos(k))+udfz*sin(k), cos(k)+pow(udfy,2)*(1-cos(k)), udfy*udfz*(1-cos(k))-udfx*sin(k)); + G4ThreeVector f = G4ThreeVector(udfz*udfx*(1-cos(k))-udfy*sin(k), udfz*udfy*(1-cos(k))+udfx*sin(k), cos(k)+pow(udfz,2)*(1-cos(k))); + G4RotationMatrix def = G4RotationMatrix(); + def.setRows(d,e,f); + crystal_rotm=def*abc; + if (m_Flip == 0){ + crystal_rotm.rotateY(180*deg); + } + crystal_rotm.rotateZ(180*deg); + G4ThreeVector crystal_pos = G4ThreeVector(0,0,0); + G4Transform3D crystal_trans = G4Transform3D(crystal_rotm, crystal_pos); + G4RotationMatrix lg_rotm = G4RotationMatrix(); + G4ThreeVector lg_Axis = df.cross(z3); + lg_Axis = lg_Axis/lg_Axis.mag(); + lg_Axis.rotateZ(180*deg); + G4double ulgx = lg_Axis.x(); + G4double ulgy = lg_Axis.y(); + G4double ulgz = lg_Axis.z(); + G4ThreeVector p = G4ThreeVector(cos(theta3)+pow(ulgx,2)*(1-cos(theta3)), ulgx*ulgy*(1-cos(theta3))-ulgz*sin(theta3), ulgx*ulgz*(1-cos(theta3))+ulgy*sin(theta3)); + G4ThreeVector q = G4ThreeVector(ulgy*ulgx*(1-cos(theta3))+ulgz*sin(theta3), cos(theta3)+pow(ulgy,2)*(1-cos(theta3)), ulgy*ulgz*(1-cos(theta3))-ulgx*sin(theta3)); + G4ThreeVector r = G4ThreeVector(ulgz*ulgx*(1-cos(theta3))-ulgy*sin(theta3), ulgz*ulgy*(1-cos(theta3))+ulgx*sin(theta3), cos(theta3)+pow(ulgz,2)*(1-cos(theta3))); + G4RotationMatrix pqr = G4RotationMatrix(); + pqr.setRows(p,q,r); + lg_rotm.rotateZ((i-1)*360*deg/detNum3); + lg_rotm.rotateX(180*deg); + lg_rotm=pqr*lg_rotm; + G4ThreeVector lg_pos = (distanceFromTarget3+detThickness3+0.5*lgThickness3)/df.mag()*df; + lg_pos.rotateZ(180*deg); + if (m_Flip == 0){ + lg_pos.rotateY(180*deg); + lg_rotm.rotateY(180*deg); + } + G4Transform3D lg_trans = G4Transform3D(lg_rotm, lg_pos); + G4RotationMatrix delrin_rotm = G4RotationMatrix(); + G4ThreeVector w = G4ThreeVector(sin(theta3)*sin((i-1)*360*deg/detNum3+.001*deg), sin(theta3)*cos((i-1)*360*deg/detNum3+.001*deg), cos(theta3)); + G4ThreeVector delrin_Axis = w.cross(z3); + delrin_Axis.rotateX(180*deg); + delrin_Axis = delrin_Axis/delrin_Axis.mag(); + G4double udx = delrin_Axis.x(); + G4double udy = delrin_Axis.y(); + G4double udz = delrin_Axis.z(); + G4double delAng = 90*deg+theta3; + G4ThreeVector pdel = G4ThreeVector(cos(delAng)+pow(udx,2)*(1-cos(delAng)), udx*udy*(1-cos(delAng))-udz*sin(delAng), udx*udz*(1-cos(delAng))+udy*sin(delAng)); + G4ThreeVector qdel = G4ThreeVector(udy*udx*(1-cos(delAng))+udz*sin(delAng), cos(delAng)+pow(udy,2)*(1-cos(delAng)), udy*udz*(1-cos(delAng))-udx*sin(delAng)); + G4ThreeVector rdel = G4ThreeVector(udz*udx*(1-cos(delAng))-udy*sin(delAng), udz*udy*(1-cos(delAng))+udx*sin(delAng), cos(delAng)+pow(udz,2)*(1-cos(delAng))); + G4RotationMatrix pqrdel = G4RotationMatrix(); + pqrdel.setRows(pdel,qdel,rdel); + delrin_rotm.rotateZ((i-1)*360*deg/detNum3+.001*deg); + delrin_rotm=pqrdel*delrin_rotm; + delrin_rotm.rotateZ(0*deg); + G4ThreeVector delrin_pos = (distanceFromTarget3+detThickness3+lgThickness3+delrinA3/2+.0003*mm)/df.mag()*df; //the .0003 mm is a fudge factor to prevent overlapping + delrin_pos.rotateZ(180*deg); + delrin_pos.rotateY(180*deg); + if (m_Flip == 1){ + delrin_pos.rotateY(180*deg); + delrin_rotm.rotateY(180*deg); + } + G4Transform3D delrin_trans = G4Transform3D(delrin_rotm, delrin_pos); + //if(i != 1){ + bool placeCrystal = true; + for (unsigned int i2=0; i2 < m_Array.size(); i2++){ + if (16 < m_Array[i2] && m_Array[i2] < 29){ + if (m_Array[i2] == 16+i){ + placeCrystal = false; + } + } + } + if (placeCrystal){ + if(crystalBool) {new G4PVPlacement(crystal_trans, //rotation, position + logicCrystal3, //its logical volume + "CsI Detector3", //its name + world, //its mother volume + false, //no boolean operation + 16+i, //copy number + checkOverlaps); //overlaps checking + } + if(lgBool) {new G4PVPlacement(lg_trans, //rotation, position + logicLightGuide3, //its logical volume + "LightGuide3", //its name + world, //its mother volume + false, //no boolean operation + 16+i, //copy number + checkOverlaps); //overlaps checking + } + if(delrinBool) {new G4PVPlacement(delrin_trans, //rotation, position + logicDelrin3, //its logical volume + "Delrin3", //its name + world, //its mother volume + false, //no boolean operation + 16+i, //copy number + checkOverlaps); //overlaps checking + } + } + //} + }} + + if(m_Ring4){ + // Ring 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + G4int detNum4 = 12; + G4double distanceFromTargetBack4 = 50.*mm; + G4double theta4 = 52.0*deg; + G4double halfTheta4 = 8.0*deg; // fudge factor + G4double lgThickness4 = 6.0*mm; + G4double detThickness4 = 6.0*mm; + G4double distanceFromTarget4 = distanceFromTargetBack4 - detThickness4; + + //G4double distance4 = distanceFromTarget4*sin(theta4); //this gives the distance from the beam axis. + + // + // Delrin Ring + // + G4double delrinA4 = 5*mm; + G4double delrinB4 = 10*mm; + G4double fdelrinHalfAngle4 = atan(delrinB4/2/(distanceFromTarget4+detThickness4+lgThickness4)); + G4double firs4 = pow(pow(distanceFromTarget4+detThickness4+lgThickness4,2)+pow(delrinB4/2,2),0.5)*sin(theta4-fdelrinHalfAngle4); + G4double firb4 = pow(pow(distanceFromTarget4+detThickness4+lgThickness4,2)+pow(delrinB4/2,2),0.5)*sin(theta4+fdelrinHalfAngle4); + G4double bdelrinHalfAngle4 = atan(delrinB4/2/(distanceFromTarget4+detThickness4+lgThickness4+delrinA4)); + G4double birs4 = pow(pow(distanceFromTarget4+detThickness4+lgThickness4+delrinA4,2)+pow(delrinB4/2,2),0.5)*sin(theta4-bdelrinHalfAngle4); + G4double birb4 = pow(pow(distanceFromTarget4+detThickness4+lgThickness4+delrinA4,2)+pow(delrinB4/2,2),0.5)*sin(theta4+bdelrinHalfAngle4); + + G4double delrin_dz4 = delrinB4/2; + G4double delrin_theta4 = 0; + G4double delrin_phi4 = 0; + G4double delrin_dyab4 = delrinA4/2; + G4double delrin_dxa4 = firs4*tan(180*deg/detNum4); + G4double delrin_dxb4 = birs4*tan(180*deg/detNum4); + G4double delrin_dycd4 = delrinA4/2; + G4double delrin_dxc4 = firb4*tan(180*deg/detNum4); + G4double delrin_dxd4 = birb4*tan(180*deg/detNum4); + G4double delrin_alpab4 = 0; + G4double delrin_alpcd4 = delrin_alpab4; + + + G4ThreeVector delrin_pos4 = G4ThreeVector(0,0,distanceFromTarget4*cos(theta4)); + + G4Trap* solidDelrin4 = + new G4Trap("Delrin4", //its name + delrin_dz4, + delrin_theta4, delrin_phi4, + delrin_dyab4, + delrin_dxa4, delrin_dxb4, + delrin_alpab4, + delrin_dycd4, + delrin_dxc4, delrin_dxd4, + delrin_alpcd4); //its size + + G4LogicalVolume* logicDelrin4 = + new G4LogicalVolume(solidDelrin4, //its solid + delrin, //its material + "Delrin4"); //its name + logicDelrin4->SetVisAttributes(delrinVisAtt); + + + // + // CsI Detector + // + G4double coneheight4 = distanceFromTarget4; + G4double flatheight4 = coneheight4 - 0.01*mm; + G4double coneangle4 = theta4; + G4double crystal_rmina4 = (coneheight4-flatheight4)*tan(coneangle4-halfTheta4); + G4double crystal_rmaxa4 = (coneheight4-flatheight4)*tan(coneangle4+halfTheta4); + G4double crystal_rminb4 = coneheight4*tan(coneangle4-halfTheta4); + G4double crystal_rmaxb4 = coneheight4*tan(coneangle4+halfTheta4); + G4double crystal_hz4 = 0.5*flatheight4;//(crystal_rmaxb4-crystal_rmaxa4)/crystal_rmaxb4*coneheight4; + G4double crystal_phimin4 = 0.*deg, crystal_phimax4 = 360.*deg/detNum4; + G4RotationMatrix tip_rotm4 = G4RotationMatrix(); + G4ThreeVector tip_pos4 = G4ThreeVector(0,0,0.5*flatheight4+(coneheight4-flatheight4)); + G4Transform3D tip_trans4 = G4Transform3D(tip_rotm4, tip_pos4); + G4ThreeVector z4 = G4ThreeVector(0,0,1); + G4ThreeVector d04 = G4ThreeVector(distanceFromTarget4*sin(coneangle4)*cos(0.5*360*deg/detNum4), + distanceFromTarget4*sin(coneangle4)*sin(0.5*360*deg/detNum4), + distanceFromTarget4*cos(coneangle4)); + G4ThreeVector unitAxis4 = z4.cross(d04); + unitAxis4 = unitAxis4/unitAxis4.mag(); + G4double ux4 = unitAxis4.x(); + G4double uy4 = unitAxis4.y(); + G4double uz4 = unitAxis4.z(); + G4ThreeVector top4 = G4ThreeVector(cos(coneangle4)+pow(ux4,2)*(1-cos(coneangle4)), ux4*uy4*(1-cos(coneangle4))-uz4*sin(coneangle4), ux4*uz4*(1-cos(coneangle4))+uy4*sin(coneangle4)); + G4ThreeVector mid4 = G4ThreeVector(uy4*ux4*(1-cos(coneangle4))+uz4*sin(coneangle4), cos(coneangle4)+pow(uy4,2)*(1-cos(coneangle4)), uy4*uz4*(1-cos(coneangle4))-ux4*sin(coneangle4)); + G4ThreeVector bot4 = G4ThreeVector(uz4*ux4*(1-cos(coneangle4))-uy4*sin(coneangle4), uz4*uy4*(1-cos(coneangle4))+ux4*sin(coneangle4), cos(coneangle4)+pow(uz4,2)*(1-cos(coneangle4))); + G4RotationMatrix firstBox_rotm4 = G4RotationMatrix(); + firstBox_rotm4.setRows(top4,mid4,bot4); + G4ThreeVector firstBox_pos4 = G4ThreeVector(0,0,0); + G4Transform3D firstBox_trans4 = G4Transform3D(firstBox_rotm4, firstBox_pos4); + G4RotationMatrix secondBox_rotm4 = G4RotationMatrix(); + secondBox_rotm4.setRows(top4,mid4,bot4); + G4ThreeVector secondBox_pos4 = (2*distanceFromTarget4+detThickness4)/distanceFromTarget4*d04; + G4Transform3D secondBox_trans4 = G4Transform3D(secondBox_rotm4, secondBox_pos4); + + G4Orb* solidTip4 = + new G4Orb("tip4", + .0001*mm); + G4Box* solidSubtractionBox4 = + new G4Box("SubtractionBox4", //its name + distanceFromTarget4, + distanceFromTarget4, + distanceFromTarget4); //its size + G4Cons* solidCone4 = + new G4Cons("Cone4", //its name + crystal_rmina4, crystal_rmaxa4, + crystal_rminb4, crystal_rmaxb4, + crystal_hz4, + crystal_phimin4, crystal_phimax4); //its size + G4UnionSolid* solidTippedCone4 = + new G4UnionSolid("TippedCone4", + solidTip4, + solidCone4, + tip_trans4); + G4SubtractionSolid* solidIntermediate4 = + new G4SubtractionSolid("Intermediate4", + solidTippedCone4, + solidSubtractionBox4, + firstBox_trans4); + G4SubtractionSolid* solidCrystal4 = + new G4SubtractionSolid("Crystal4", + solidIntermediate4, + solidSubtractionBox4, + secondBox_trans4); + + G4LogicalVolume* logicCrystal4 = + new G4LogicalVolume(solidCrystal4, //its solid + CsI, //its material + "CsI Detector4"); //its name + logicCrystal4->SetVisAttributes(crystalVisAtt); + logicCrystal4->SetSensitiveDetector(m_MicroballScorer); + + // + // Light Guide + // + G4double lightGuide_px4 = 10*mm; + G4double lightGuide_py4 = 10*mm; + G4double lightGuide_pz4 = lgThickness4; + G4Box* solidLightGuide4 = + new G4Box("LightGuide4", //its name + 0.5*lightGuide_px4, + 0.5*lightGuide_py4, + 0.5*lightGuide_pz4); //its size + + G4LogicalVolume* logicLightGuide4 = + new G4LogicalVolume(solidLightGuide4, //its solid + glass, //its material + "LightGuide4"); //its name + logicLightGuide4->SetVisAttributes(lightGuideVisAtt); + + + for(int i = 1; i <= detNum4; i++) + { + G4RotationMatrix crystal_rotm = G4RotationMatrix(); + G4ThreeVector d0 = G4ThreeVector(distanceFromTarget4*sin(coneangle4)*cos(0.5*360*deg/detNum4), + distanceFromTarget4*sin(coneangle4)*sin(0.5*360*deg/detNum4), + distanceFromTarget4*cos(coneangle4)); + G4ThreeVector df = G4ThreeVector(distanceFromTarget4*sin(theta4)*sin((i-1)*360*deg/detNum4+.001*deg/*+0.5*360*deg/detNum4*/), + distanceFromTarget4*sin(theta4)*cos((i-1)*360*deg/detNum4+.001*deg/*+0.5*360*deg/detNum4*/), + -distanceFromTarget4*cos(theta4)); + G4ThreeVector axis = d0.cross(df); + G4double ax = axis.x(); + G4double ay = axis.y(); + G4double az = axis.z(); + G4double ux = ax/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double uy = ay/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double uz = az/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double j = acos(d0.dot(df)/(d0.mag()*df.mag())); + G4ThreeVector a = G4ThreeVector(cos(j)+pow(ux,2)*(1-cos(j)), ux*uy*(1-cos(j))-uz*sin(j), ux*uz*(1-cos(j))+uy*sin(j)); + G4ThreeVector b = G4ThreeVector(uy*ux*(1-cos(j))+uz*sin(j), cos(j)+pow(uy,2)*(1-cos(j)), uy*uz*(1-cos(j))-ux*sin(j)); + G4ThreeVector c = G4ThreeVector(uz*ux*(1-cos(j))-uy*sin(j), uz*uy*(1-cos(j))+ux*sin(j), cos(j)+pow(uz,2)*(1-cos(j))); + G4RotationMatrix abc = G4RotationMatrix(); + abc.setRows(a,b,c); + G4ThreeVector unitdf = df/df.mag(); + G4double udfx = unitdf.x(); + G4double udfy = unitdf.y(); + G4double udfz = unitdf.z(); + G4double k = 180.*deg; + G4ThreeVector d = G4ThreeVector(cos(k)+pow(udfx,2)*(1-cos(k)), udfx*udfy*(1-cos(k))-udfz*sin(k), udfx*udfz*(1-cos(k))+udfy*sin(k)); + G4ThreeVector e = G4ThreeVector(udfy*udfx*(1-cos(k))+udfz*sin(k), cos(k)+pow(udfy,2)*(1-cos(k)), udfy*udfz*(1-cos(k))-udfx*sin(k)); + G4ThreeVector f = G4ThreeVector(udfz*udfx*(1-cos(k))-udfy*sin(k), udfz*udfy*(1-cos(k))+udfx*sin(k), cos(k)+pow(udfz,2)*(1-cos(k))); + G4RotationMatrix def = G4RotationMatrix(); + def.setRows(d,e,f); + crystal_rotm=def*abc; + if (m_Flip == 0){ + crystal_rotm.rotateY(180*deg); + } + crystal_rotm.rotateZ(180*deg); + G4ThreeVector crystal_pos = G4ThreeVector(0,0,0); + G4Transform3D crystal_trans = G4Transform3D(crystal_rotm, crystal_pos); + G4RotationMatrix lg_rotm = G4RotationMatrix(); + G4ThreeVector lg_Axis = df.cross(z4); + lg_Axis = lg_Axis/lg_Axis.mag(); + lg_Axis.rotateZ(180*deg); + G4double ulgx = lg_Axis.x(); + G4double ulgy = lg_Axis.y(); + G4double ulgz = lg_Axis.z(); + G4ThreeVector p = G4ThreeVector(cos(theta4)+pow(ulgx,2)*(1-cos(theta4)), ulgx*ulgy*(1-cos(theta4))-ulgz*sin(theta4), ulgx*ulgz*(1-cos(theta4))+ulgy*sin(theta4)); + G4ThreeVector q = G4ThreeVector(ulgy*ulgx*(1-cos(theta4))+ulgz*sin(theta4), cos(theta4)+pow(ulgy,2)*(1-cos(theta4)), ulgy*ulgz*(1-cos(theta4))-ulgx*sin(theta4)); + G4ThreeVector r = G4ThreeVector(ulgz*ulgx*(1-cos(theta4))-ulgy*sin(theta4), ulgz*ulgy*(1-cos(theta4))+ulgx*sin(theta4), cos(theta4)+pow(ulgz,2)*(1-cos(theta4))); + G4RotationMatrix pqr = G4RotationMatrix(); + pqr.setRows(p,q,r); + lg_rotm.rotateZ((i-1)*360*deg/detNum4); + lg_rotm.rotateX(180*deg); + lg_rotm=pqr*lg_rotm; + G4ThreeVector lg_pos = (distanceFromTarget4+detThickness4+0.5*lgThickness4)/df.mag()*df; + lg_pos.rotateZ(180*deg); + if (m_Flip == 0){ + lg_pos.rotateY(180*deg); + lg_rotm.rotateY(180*deg); + } + G4Transform3D lg_trans = G4Transform3D(lg_rotm, lg_pos); + G4RotationMatrix delrin_rotm = G4RotationMatrix(); + G4ThreeVector w = G4ThreeVector(sin(theta4)*sin((i-1)*360*deg/detNum4+.001*deg), sin(theta4)*cos((i-1)*360*deg/detNum4+.001*deg), cos(theta4)); + G4ThreeVector delrin_Axis = w.cross(z4); + delrin_Axis.rotateX(180*deg); + delrin_Axis = delrin_Axis/delrin_Axis.mag(); + G4double udx = delrin_Axis.x(); + G4double udy = delrin_Axis.y(); + G4double udz = delrin_Axis.z(); + G4double delAng = 90*deg+theta4; + G4ThreeVector pdel = G4ThreeVector(cos(delAng)+pow(udx,2)*(1-cos(delAng)), udx*udy*(1-cos(delAng))-udz*sin(delAng), udx*udz*(1-cos(delAng))+udy*sin(delAng)); + G4ThreeVector qdel = G4ThreeVector(udy*udx*(1-cos(delAng))+udz*sin(delAng), cos(delAng)+pow(udy,2)*(1-cos(delAng)), udy*udz*(1-cos(delAng))-udx*sin(delAng)); + G4ThreeVector rdel = G4ThreeVector(udz*udx*(1-cos(delAng))-udy*sin(delAng), udz*udy*(1-cos(delAng))+udx*sin(delAng), cos(delAng)+pow(udz,2)*(1-cos(delAng))); + G4RotationMatrix pqrdel = G4RotationMatrix(); + pqrdel.setRows(pdel,qdel,rdel); + delrin_rotm.rotateZ((i-1)*360*deg/detNum4+.001*deg); + delrin_rotm=pqrdel*delrin_rotm; + delrin_rotm.rotateZ(0*deg); + G4ThreeVector delrin_pos = (distanceFromTarget4+detThickness4+lgThickness4+delrinA4/2+.0001*mm)/df.mag()*df; //the .0003 mm is a fudge factor to prevent overlapping + delrin_pos.rotateZ(180*deg); + delrin_pos.rotateY(180*deg); + if (m_Flip == 1){ + delrin_pos.rotateY(180*deg); + delrin_rotm.rotateY(180*deg); + } + G4Transform3D delrin_trans = G4Transform3D(delrin_rotm, delrin_pos); + //if(i != 1){ + bool placeCrystal = true; + for (unsigned int i2=0; i2 < m_Array.size(); i2++){ + if (28 < m_Array[i2] && m_Array[i2] < 41){ + if (m_Array[i2] == 28+i){ + placeCrystal = false; + } + } + } + if (placeCrystal){ + if(crystalBool) {new G4PVPlacement(crystal_trans, //rotation, position + logicCrystal4, //its logical volume + "CsI Detector4", //its name + world, //its mother volume + false, //no boolean operation + 28+i, //copy number + checkOverlaps); //overlaps checking + } + if(lgBool) {new G4PVPlacement(lg_trans, //rotation, position + logicLightGuide4, //its logical volume + "LightGuide4", //its name + world, //its mother volume + false, //no boolean operation + 28+i, //copy number + checkOverlaps); //overlaps checking + } + if(delrinBool) {new G4PVPlacement(delrin_trans, //rotation, position + logicDelrin4, //its logical volume + "Delrin4", //its name + world, //its mother volume + false, //no boolean operation + 28+i, //copy number + checkOverlaps); //overlaps checking + } + } + //} + }} + + if(m_Ring5){ + // Ring 5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + G4int detNum5 = 14; + G4double distanceFromTargetBack5 = 50.*mm; + G4double theta5 = 70.0*deg; + G4double halfTheta5 = 10.0*deg;// -0.1*deg; //fudge factor + G4double lgThickness5 = 6.0*mm; + G4double detThickness5 = 5.6*mm; + G4double distanceFromTarget5 = distanceFromTargetBack5 - detThickness5; + + //G4double distance5 = distanceFromTarget5*sin(theta5); //this gives the distance from the beam axis. + + // + // Delrin Ring + // + G4double delrinA5 = 5*mm; + G4double delrinB5 = 10*mm; + G4double fdelrinHalfAngle5 = atan(delrinB5/2/(distanceFromTarget5+detThickness5+lgThickness5)); + G4double firs5 = pow(pow(distanceFromTarget5+detThickness5+lgThickness5,2)+pow(delrinB5/2,2),0.5)*sin(theta5-fdelrinHalfAngle5); + G4double firb5 = pow(pow(distanceFromTarget5+detThickness5+lgThickness5,2)+pow(delrinB5/2,2),0.5)*sin(theta5+fdelrinHalfAngle5); + G4double bdelrinHalfAngle5 = atan(delrinB5/2/(distanceFromTarget5+detThickness5+lgThickness5+delrinA5)); + G4double birs5 = pow(pow(distanceFromTarget5+detThickness5+lgThickness5+delrinA5,2)+pow(delrinB5/2,2),0.5)*sin(theta5-bdelrinHalfAngle5); + G4double birb5 = pow(pow(distanceFromTarget5+detThickness5+lgThickness5+delrinA5,2)+pow(delrinB5/2,2),0.5)*sin(theta5+bdelrinHalfAngle5); + + G4double delrin_dz5 = delrinB5/2; + G4double delrin_theta5 = 0; + G4double delrin_phi5 = 0; + G4double delrin_dyab5 = delrinA5/2; + G4double delrin_dxa5 = firs5*tan(180*deg/detNum5); + G4double delrin_dxb5 = birs5*tan(180*deg/detNum5); + G4double delrin_dycd5 = delrinA5/2; + G4double delrin_dxc5 = firb5*tan(180*deg/detNum5); + G4double delrin_dxd5 = birb5*tan(180*deg/detNum5); + G4double delrin_alpab5 = 0; + G4double delrin_alpcd5 = delrin_alpab5; + + + G4ThreeVector delrin_pos5 = G4ThreeVector(0,0,distanceFromTarget5*cos(theta5)); + + G4Trap* solidDelrin5 = + new G4Trap("Delrin5", //its name + delrin_dz5, + delrin_theta5, delrin_phi5, + delrin_dyab5, + delrin_dxa5, delrin_dxb5, + delrin_alpab5, + delrin_dycd5, + delrin_dxc5, delrin_dxd5, + delrin_alpcd5); //its size + + G4LogicalVolume* logicDelrin5 = + new G4LogicalVolume(solidDelrin5, //its solid + delrin, //its material + "Delrin5"); //its name + logicDelrin5->SetVisAttributes(delrinVisAtt); + + + // + // CsI Detector + // + G4double coneheight5 = 0.6*distanceFromTarget5; + G4double flatheight5 = coneheight5 -0.01*mm; + G4double coneangle5 = theta5; + G4double crystal_rmina5 = (coneheight5-flatheight5)*tan(coneangle5-halfTheta5); + G4double crystal_rmaxa5 = (coneheight5-flatheight5)*tan(coneangle5+halfTheta5); + G4double crystal_rminb5 = coneheight5*tan(coneangle5-halfTheta5); + G4double crystal_rmaxb5 = coneheight5*tan(coneangle5+halfTheta5); + G4double crystal_hz5 = 0.5*flatheight5;//(crystal_rmaxb5-crystal_rmaxa5)/crystal_rmaxb5*coneheight5; + G4double crystal_phimin5 = 0.*deg, crystal_phimax5 = 360.*deg/detNum5; + G4RotationMatrix tip_rotm5 = G4RotationMatrix(); + G4ThreeVector tip_pos5 = G4ThreeVector(0,0,0.5*flatheight5+(coneheight5-flatheight5)); //last z term is a fudge + G4Transform3D tip_trans5 = G4Transform3D(tip_rotm5, tip_pos5); + G4ThreeVector z5 = G4ThreeVector(0,0,1); + G4ThreeVector d05 = G4ThreeVector(distanceFromTarget5*sin(coneangle5)*cos(0.5*360*deg/detNum5), + distanceFromTarget5*sin(coneangle5)*sin(0.5*360*deg/detNum5), + distanceFromTarget5*cos(coneangle5)); + G4ThreeVector unitAxis5 = z5.cross(d05); + unitAxis5 = unitAxis5/unitAxis5.mag(); + G4double ux5 = unitAxis5.x(); + G4double uy5 = unitAxis5.y(); + G4double uz5 = unitAxis5.z(); + G4ThreeVector top5 = G4ThreeVector(cos(coneangle5)+pow(ux5,2)*(1-cos(coneangle5)), ux5*uy5*(1-cos(coneangle5))-uz5*sin(coneangle5), ux5*uz5*(1-cos(coneangle5))+uy5*sin(coneangle5)); + G4ThreeVector mid5 = G4ThreeVector(uy5*ux5*(1-cos(coneangle5))+uz5*sin(coneangle5), cos(coneangle5)+pow(uy5,2)*(1-cos(coneangle5)), uy5*uz5*(1-cos(coneangle5))-ux5*sin(coneangle5)); + G4ThreeVector bot5 = G4ThreeVector(uz5*ux5*(1-cos(coneangle5))-uy5*sin(coneangle5), uz5*uy5*(1-cos(coneangle5))+ux5*sin(coneangle5), cos(coneangle5)+pow(uz5,2)*(1-cos(coneangle5))); + G4RotationMatrix firstBox_rotm5 = G4RotationMatrix(); + firstBox_rotm5.setRows(top5,mid5,bot5); + G4ThreeVector firstBox_pos5 = G4ThreeVector(0,0,0); + G4Transform3D firstBox_trans5 = G4Transform3D(firstBox_rotm5, firstBox_pos5); + G4RotationMatrix secondBox_rotm5 = G4RotationMatrix(); + secondBox_rotm5.setRows(top5,mid5,bot5); + G4ThreeVector secondBox_pos5 = (3*distanceFromTarget5+detThickness5)/distanceFromTarget5*d05; + G4Transform3D secondBox_trans5 = G4Transform3D(secondBox_rotm5, secondBox_pos5); + + G4Orb* solidTip5 = + new G4Orb("tip5", + .0001*mm); + G4Box* solidSubtractionBox5 = + new G4Box("SubtractionBox5", //its name + distanceFromTarget5, + distanceFromTarget5, + distanceFromTarget5); //its size + G4Box* solidSecondSubtractionBox5 = + new G4Box("SecondSubtractionBox5", //its name + 2*distanceFromTarget5, + 2*distanceFromTarget5, + 2*distanceFromTarget5); //its size + G4Cons* solidCone5 = + new G4Cons("Cone5", //its name + crystal_rmina5, crystal_rmaxa5, + crystal_rminb5, crystal_rmaxb5, + crystal_hz5, + crystal_phimin5, crystal_phimax5); //its size + G4UnionSolid* solidTippedCone5 = + new G4UnionSolid("TippedCone5", + solidTip5, + solidCone5, + tip_trans5); + G4SubtractionSolid* solidIntermediate5 = + new G4SubtractionSolid("Intermediate5", + solidTippedCone5, + solidSubtractionBox5, + firstBox_trans5); + G4SubtractionSolid* solidCrystal5 = + new G4SubtractionSolid("Crystal5", + solidIntermediate5, + solidSecondSubtractionBox5, + secondBox_trans5); + + G4LogicalVolume* logicCrystal5 = + new G4LogicalVolume(solidCrystal5, //its solid + CsI, //its material + "CsI Detector5"); //its name + logicCrystal5->SetVisAttributes(crystalVisAtt); + logicCrystal5->SetSensitiveDetector(m_MicroballScorer); + + + // + // Light Guide + // + G4double lightGuide_px5 = 10*mm; + G4double lightGuide_py5 = 10*mm; + G4double lightGuide_pz5 = lgThickness5; + G4Box* solidLightGuide5 = + new G4Box("LightGuide5", //its name + 0.5*lightGuide_px5, + 0.5*lightGuide_py5, + 0.5*lightGuide_pz5); //its size + + G4LogicalVolume* logicLightGuide5 = + new G4LogicalVolume(solidLightGuide5, //its solid + glass, //its material + "LightGuide5"); //its name + logicLightGuide5->SetVisAttributes(lightGuideVisAtt); + + + for(int i = 1; i <= detNum5; i++) + { + G4RotationMatrix crystal_rotm = G4RotationMatrix(); + G4ThreeVector d0 = G4ThreeVector(distanceFromTarget5*sin(coneangle5)*cos(0.5*360*deg/detNum5), + distanceFromTarget5*sin(coneangle5)*sin(0.5*360*deg/detNum5), + distanceFromTarget5*cos(coneangle5)); + G4ThreeVector df = G4ThreeVector(distanceFromTarget5*sin(theta5)*sin((i-1)*360*deg/detNum5+.001*deg/*+0.5*360*deg/detNum5*/), + distanceFromTarget5*sin(theta5)*cos((i-1)*360*deg/detNum5+.001*deg/*+0.5*360*deg/detNum5*/), + -distanceFromTarget5*cos(theta5)); + G4ThreeVector axis = d0.cross(df); + G4double ax = axis.x(); + G4double ay = axis.y(); + G4double az = axis.z(); + G4double ux = ax/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double uy = ay/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double uz = az/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double j = acos(d0.dot(df)/(d0.mag()*df.mag())); + G4ThreeVector a = G4ThreeVector(cos(j)+pow(ux,2)*(1-cos(j)), ux*uy*(1-cos(j))-uz*sin(j), ux*uz*(1-cos(j))+uy*sin(j)); + G4ThreeVector b = G4ThreeVector(uy*ux*(1-cos(j))+uz*sin(j), cos(j)+pow(uy,2)*(1-cos(j)), uy*uz*(1-cos(j))-ux*sin(j)); + G4ThreeVector c = G4ThreeVector(uz*ux*(1-cos(j))-uy*sin(j), uz*uy*(1-cos(j))+ux*sin(j), cos(j)+pow(uz,2)*(1-cos(j))); + G4RotationMatrix abc = G4RotationMatrix(); + abc.setRows(a,b,c); + G4ThreeVector unitdf = df/df.mag(); + G4double udfx = unitdf.x(); + G4double udfy = unitdf.y(); + G4double udfz = unitdf.z(); + G4double k = 180.*deg; + G4ThreeVector d = G4ThreeVector(cos(k)+pow(udfx,2)*(1-cos(k)), udfx*udfy*(1-cos(k))-udfz*sin(k), udfx*udfz*(1-cos(k))+udfy*sin(k)); + G4ThreeVector e = G4ThreeVector(udfy*udfx*(1-cos(k))+udfz*sin(k), cos(k)+pow(udfy,2)*(1-cos(k)), udfy*udfz*(1-cos(k))-udfx*sin(k)); + G4ThreeVector f = G4ThreeVector(udfz*udfx*(1-cos(k))-udfy*sin(k), udfz*udfy*(1-cos(k))+udfx*sin(k), cos(k)+pow(udfz,2)*(1-cos(k))); + G4RotationMatrix def = G4RotationMatrix(); + def.setRows(d,e,f); + crystal_rotm=def*abc; + if (m_Flip == 0){ + crystal_rotm.rotateY(180*deg); + } + crystal_rotm.rotateZ(180*deg); + G4ThreeVector crystal_pos = G4ThreeVector(0,0,0); + G4Transform3D crystal_trans = G4Transform3D(crystal_rotm, crystal_pos); + G4RotationMatrix lg_rotm = G4RotationMatrix(); + G4ThreeVector lg_Axis = df.cross(z5); + lg_Axis = lg_Axis/lg_Axis.mag(); + lg_Axis.rotateZ(180*deg); + G4double ulgx = lg_Axis.x(); + G4double ulgy = lg_Axis.y(); + G4double ulgz = lg_Axis.z(); + G4ThreeVector p = G4ThreeVector(cos(theta5)+pow(ulgx,2)*(1-cos(theta5)), ulgx*ulgy*(1-cos(theta5))-ulgz*sin(theta5), ulgx*ulgz*(1-cos(theta5))+ulgy*sin(theta5)); + G4ThreeVector q = G4ThreeVector(ulgy*ulgx*(1-cos(theta5))+ulgz*sin(theta5), cos(theta5)+pow(ulgy,2)*(1-cos(theta5)), ulgy*ulgz*(1-cos(theta5))-ulgx*sin(theta5)); + G4ThreeVector r = G4ThreeVector(ulgz*ulgx*(1-cos(theta5))-ulgy*sin(theta5), ulgz*ulgy*(1-cos(theta5))+ulgx*sin(theta5), cos(theta5)+pow(ulgz,2)*(1-cos(theta5))); + G4RotationMatrix pqr = G4RotationMatrix(); + pqr.setRows(p,q,r); + lg_rotm.rotateZ((i-1)*360*deg/detNum5); + lg_rotm.rotateX(180*deg); + lg_rotm=pqr*lg_rotm; + G4ThreeVector lg_pos = (distanceFromTarget5+detThickness5+0.5*lgThickness5)/df.mag()*df; + lg_pos.rotateZ(180*deg); + if (m_Flip == 0){ + lg_pos.rotateY(180*deg); + lg_rotm.rotateY(180*deg); + } + G4Transform3D lg_trans = G4Transform3D(lg_rotm, lg_pos); + G4RotationMatrix delrin_rotm = G4RotationMatrix(); + G4ThreeVector w = G4ThreeVector(sin(theta5)*sin((i-1)*360*deg/detNum5+.001*deg), sin(theta5)*cos((i-1)*360*deg/detNum5+.001*deg), cos(theta5)); + G4ThreeVector delrin_Axis = w.cross(z5); + delrin_Axis.rotateX(180*deg); + delrin_Axis = delrin_Axis/delrin_Axis.mag(); + G4double udx = delrin_Axis.x(); + G4double udy = delrin_Axis.y(); + G4double udz = delrin_Axis.z(); + G4double delAng = 90*deg+theta5; + G4ThreeVector pdel = G4ThreeVector(cos(delAng)+pow(udx,2)*(1-cos(delAng)), udx*udy*(1-cos(delAng))-udz*sin(delAng), udx*udz*(1-cos(delAng))+udy*sin(delAng)); + G4ThreeVector qdel = G4ThreeVector(udy*udx*(1-cos(delAng))+udz*sin(delAng), cos(delAng)+pow(udy,2)*(1-cos(delAng)), udy*udz*(1-cos(delAng))-udx*sin(delAng)); + G4ThreeVector rdel = G4ThreeVector(udz*udx*(1-cos(delAng))-udy*sin(delAng), udz*udy*(1-cos(delAng))+udx*sin(delAng), cos(delAng)+pow(udz,2)*(1-cos(delAng))); + G4RotationMatrix pqrdel = G4RotationMatrix(); + pqrdel.setRows(pdel,qdel,rdel); + delrin_rotm.rotateZ((i-1)*360*deg/detNum5+.001*deg); + delrin_rotm=pqrdel*delrin_rotm; + delrin_rotm.rotateZ(0*deg); + G4ThreeVector delrin_pos = (distanceFromTarget5+detThickness5+lgThickness5+delrinA5/2+.0004*mm)/df.mag()*df; //the .0003 mm is a fudge factor to prevent overlapping + delrin_pos.rotateZ(180*deg); + delrin_pos.rotateY(180*deg); + if (m_Flip == 1){ + delrin_pos.rotateY(180*deg); + delrin_rotm.rotateY(180*deg); + } + G4Transform3D delrin_trans = G4Transform3D(delrin_rotm, delrin_pos); + //if(i != 1){ + bool placeCrystal = true; + for (unsigned int i2=0; i2 < m_Array.size(); i2++){ + if (40 < m_Array[i2] && m_Array[i2] < 55){ + if (m_Array[i2] == 40+i){ + placeCrystal = false; + } + } + } + if (placeCrystal){ + if(crystalBool) {new G4PVPlacement(crystal_trans, //rotation, position + logicCrystal5, //its logical volume + "CsI Detector5", //its name + world, //its mother volume + false, //no boolean operation + 40+i, //copy number + checkOverlaps); //overlaps checking + } + if(lgBool) {new G4PVPlacement(lg_trans, //rotation, position + logicLightGuide5, //its logical volume + "LightGuide5", //its name + world, //its mother volume + false, //no boolean operation + 40+i, //copy number + checkOverlaps); //overlaps checking + } + //} + if(delrinBool) {new G4PVPlacement(delrin_trans, //rotation, position + logicDelrin5, //its logical volume + "Delrin5", //its name + world, //its mother volume + false, //no boolean operation + 40+i, //copy number + checkOverlaps); //overlaps checking + } + } + }} + + if(m_Ring6){ + // Ring 6 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this ring is weird. + G4int detNum6 = 14; + G4double distanceFromTargetBack6 = 50.*mm; + G4double theta6 = 90.0*deg; + G4double halfTheta6 = 10.0*deg;// -0.1*deg; + G4double lgThickness6 = 7.0*mm; + G4double detThickness6 = 5.2*mm; + G4double distanceFromTarget6 = distanceFromTargetBack6 - detThickness6; + + //G4double distance6 = distanceFromTarget6*sin(theta6); //this gives the distance from the beam axis. + + // + // Delrin Ring + // + G4double delrinA6 = 5*mm; + G4double delrinB6 = 10*mm; + G4double fdelrinHalfAngle6 = atan(delrinB6/2/(distanceFromTarget6+detThickness6+lgThickness6)); + G4double firs6 = pow(pow(distanceFromTarget6+detThickness6+lgThickness6,2)+pow(delrinB6/2,2),0.5)*sin(theta6-fdelrinHalfAngle6); + G4double firb6 = pow(pow(distanceFromTarget6+detThickness6+lgThickness6,2)+pow(delrinB6/2,2),0.5)*sin(theta6+fdelrinHalfAngle6); + G4double bdelrinHalfAngle6 = atan(delrinB6/2/(distanceFromTarget6+detThickness6+lgThickness6+delrinA6)); + G4double birs6 = pow(pow(distanceFromTarget6+detThickness6+lgThickness6+delrinA6,2)+pow(delrinB6/2,2),0.5)*sin(theta6-bdelrinHalfAngle6); + G4double birb6 = pow(pow(distanceFromTarget6+detThickness6+lgThickness6+delrinA6,2)+pow(delrinB6/2,2),0.5)*sin(theta6+bdelrinHalfAngle6); + + G4double delrin_dz6 = delrinB6/2; + G4double delrin_theta6 = 0; + G4double delrin_phi6 = 0; + G4double delrin_dyab6 = delrinA6/2; + G4double delrin_dxa6 = firs6*tan(180*deg/detNum6); + G4double delrin_dxb6 = birs6*tan(180*deg/detNum6); + G4double delrin_dycd6 = delrinA6/2; + G4double delrin_dxc6 = firb6*tan(180*deg/detNum6); + G4double delrin_dxd6 = birb6*tan(180*deg/detNum6); + G4double delrin_alpab6 = 0; + G4double delrin_alpcd6 = delrin_alpab6; + + + G4ThreeVector delrin_pos6 = G4ThreeVector(0,0,distanceFromTarget6*cos(theta6)); + + G4Trap* solidDelrin6 = + new G4Trap("Delrin6", //its name + delrin_dz6, + delrin_theta6, delrin_phi6, + delrin_dyab6, + delrin_dxa6, delrin_dxb6, + delrin_alpab6, + delrin_dycd6, + delrin_dxc6, delrin_dxd6, + delrin_alpcd6); //its size + + G4LogicalVolume* logicDelrin6 = + new G4LogicalVolume(solidDelrin6, //its solid + delrin, //its material + "Delrin6"); //its name + logicDelrin6->SetVisAttributes(delrinVisAtt); + + + /* + // + // CsI Detector for deletion + // + G4double crystal_rmina6 = distance6/cos(halfTheta6); + G4double crystal_rmaxa6 = distance6/cos(halfTheta6)+2*distance6*tan(halfTheta6); + G4double crystal_rminb6 = (distance6+detThickness6)/cos(halfTheta6); + G4double crystal_rmaxb6 = (distance6+detThickness6)/cos(halfTheta6)+2*(distance6+detThickness6)*tan(halfTheta6); + G4double crystal_hz6 = 0.5*pow(pow(detThickness6,2)+pow((crystal_rminb6+crystal_rmaxb6-crystal_rmina6-crystal_rmaxa6)/2,2),0.5); + //G4double crystal_hz6 = 0.5*detThickness6; + G4double crystal_phimin6 = 0.*deg, crystal_phimax6 = 360.*deg/detNum6; + + + G4Cons* solidCrystal6 = + new G4Cons("Crystal6", //its name + crystal_rmina6, crystal_rmaxa6, + crystal_rminb6, crystal_rmaxb6, + crystal_hz6, + crystal_phimin6, crystal_phimax6); //its size + + G4LogicalVolume* logicCrystal6 = + new G4LogicalVolume(solidCrystal6, //its solid + CsI, //its material + "CsI Detector6"); //its name + logicCrystal6->SetVisAttributes(crystalVisAtt); + */ + + G4double crystal_dxa6 = distanceFromTarget6*tan(halfTheta6); + G4double crystal_dxb6 = (distanceFromTarget6+detThickness6)*tan(halfTheta6); + G4double crystal_dya6 = distanceFromTarget6*tan(0.5*360*deg/detNum6); + G4double crystal_dyb6 = (distanceFromTarget6+detThickness6)*tan(0.5*360*deg/detNum6); + G4double crystal_dz = 0.5*detThickness6; + + G4Trd* solidCrystal6 = + new G4Trd("Crystal6", //its name + crystal_dxa6, crystal_dxb6, + crystal_dya6, crystal_dyb6, + crystal_dz); //its size + G4LogicalVolume* logicCrystal6 = + new G4LogicalVolume(solidCrystal6, //its solid + CsI, //its material + "CsI Detector6"); //its name + logicCrystal6->SetVisAttributes(crystalVisAtt); + logicCrystal6->SetSensitiveDetector(m_MicroballScorer); + // + // Light Guide + // + G4double lightGuide_px6 = 10*mm; + G4double lightGuide_py6 = 10*mm; + G4double lightGuide_pz6 = lgThickness6; + G4Box* solidLightGuide6 = + new G4Box("LightGuide6", //its name + 0.5*lightGuide_px6, + 0.5*lightGuide_py6, + 0.5*lightGuide_pz6); //its size + + G4LogicalVolume* logicLightGuide6 = + new G4LogicalVolume(solidLightGuide6, //its solid + glass, //its material + "LightGuide6"); //its name + logicLightGuide6->SetVisAttributes(lightGuideVisAtt); + + + for(int i = 1; i <= detNum6; i++) + { + G4RotationMatrix crystal_rotm = G4RotationMatrix(); + /* + G4RotationMatrix abc6 = G4RotationMatrix(); + G4RotationMatrix def6 = G4RotationMatrix(); + G4ThreeVector a6 = G4ThreeVector(pow(sin(i*360*deg/detNum6),2), -sin(i*360*deg/detNum6)*cos(i*360*deg/detNum6), cos(i*360*deg/detNum6)); + G4ThreeVector b6 = G4ThreeVector(-sin(i*360*deg/detNum6)*cos(i*360*deg/detNum6), pow(cos(i*360*deg/detNum6),2), sin(i*360*deg/detNum6)); + G4ThreeVector c6 = G4ThreeVector(-cos(i*360*deg/detNum6), -sin(i*360*deg/detNum6), 0); + abc6.setRows(a6,b6,c6); + G4double k= (i-1)*360*deg/detNum6+0.5*360*deg/detNum6; + G4ThreeVector d6 = G4ThreeVector(cos(k)+pow(cos(i*360*deg/detNum6),2)*(1-cos(k)), + cos(i*360*deg/detNum6)*sin(i*360*deg/detNum6)*(1-cos(k)), + sin(i*360*deg/detNum6)*sin(k)); + G4ThreeVector e6 = G4ThreeVector(cos(i*360*deg/detNum6)*sin(i*360*deg/detNum6)*(1-cos(k)), + cos(k)+pow(sin(i*360*deg/detNum6),2)*(1-cos(k)), + -cos(i*360*deg/detNum6)*sin(k)); + G4ThreeVector f6 = G4ThreeVector(-sin(i*360*deg/detNum6)*sin(k), + cos(i*360*deg/detNum6)*sin(k), + cos(k)); + def6.setRows(d6,e6,f6); + crystal_rotm = def6*abc6; + */ + G4ThreeVector z6 = G4ThreeVector(0,0,1); + G4ThreeVector df6 = G4ThreeVector(cos((i-1)*360*deg/detNum6+0.5*360*deg/detNum6), + sin((i-1)*360*deg/detNum6+0.5*360*deg/detNum6), + 0); + G4ThreeVector unitAxis6 = z6.cross(df6); + unitAxis6 = unitAxis6/unitAxis6.mag(); + G4double ux6 = unitAxis6.x(); + G4double uy6 = unitAxis6.y(); + G4double uz6 = unitAxis6.z(); + G4double angle6 = acos(z6.dot(df6)/(z6.mag()*df6.mag())); + G4ThreeVector a6 = G4ThreeVector(cos(angle6)+pow(ux6,2)*(1-cos(angle6)), ux6*uy6*(1-cos(angle6))-uz6*sin(angle6), ux6*uz6*(1-cos(angle6))+uy6*sin(angle6)); + G4ThreeVector b6 = G4ThreeVector(uy6*ux6*(1-cos(angle6))+uz6*sin(angle6), cos(angle6)+pow(uy6,2)*(1-cos(angle6)), uy6*uz6*(1-cos(angle6))-ux6*sin(angle6)); + G4ThreeVector c6 = G4ThreeVector(uz6*ux6*(1-cos(angle6))-uy6*sin(angle6), uz6*uy6*(1-cos(angle6))+ux6*sin(angle6), cos(angle6)+pow(uz6,2)*(1-cos(angle6))); + G4RotationMatrix abc6 = G4RotationMatrix(); + abc6.setRows(a6,b6,c6); + crystal_rotm.rotateZ((i-1)*360*deg/detNum6+0.5*360*deg/detNum6); + crystal_rotm=abc6*crystal_rotm; + crystal_rotm.rotateZ(0*deg-4*360/14*deg); + G4ThreeVector crystal_pos = G4ThreeVector((distanceFromTarget6+0.5*detThickness6)*cos((i-1)*360*deg/detNum6+0.5*360*deg/detNum6), + (distanceFromTarget6+0.5*detThickness6)*sin((i-1)*360*deg/detNum6+0.5*360*deg/detNum6), + 0)+delrin_pos6; + crystal_pos.rotateZ(0*deg-4*360/14*deg); + if (m_Flip == 1){ + crystal_pos.setX(-crystal_pos.x()); + crystal_rotm.rotateY(180*deg); + } + G4Transform3D crystal_trans = G4Transform3D(crystal_rotm, crystal_pos); + G4RotationMatrix lg_rotm = G4RotationMatrix(); + G4ThreeVector df = G4ThreeVector(distanceFromTarget6*sin(theta6)*sin((i-1)*360*deg/detNum6/*+0.5*360*deg/detNum6*/), + distanceFromTarget6*sin(theta6)*cos((i-1)*360*deg/detNum6/*+0.5*360*deg/detNum6*/), + -distanceFromTarget6*cos(theta6)); + G4ThreeVector lg_Axis = df.cross(z6); + lg_Axis = lg_Axis/lg_Axis.mag(); + lg_Axis.rotateZ(180*deg); + G4double ulgx = lg_Axis.x(); + G4double ulgy = lg_Axis.y(); + G4double ulgz = lg_Axis.z(); + G4ThreeVector p = G4ThreeVector(cos(theta6)+pow(ulgx,2)*(1-cos(theta6)), ulgx*ulgy*(1-cos(theta6))-ulgz*sin(theta6), ulgx*ulgz*(1-cos(theta6))+ulgy*sin(theta6)); + G4ThreeVector q = G4ThreeVector(ulgy*ulgx*(1-cos(theta6))+ulgz*sin(theta6), cos(theta6)+pow(ulgy,2)*(1-cos(theta6)), ulgy*ulgz*(1-cos(theta6))-ulgx*sin(theta6)); + G4ThreeVector r = G4ThreeVector(ulgz*ulgx*(1-cos(theta6))-ulgy*sin(theta6), ulgz*ulgy*(1-cos(theta6))+ulgx*sin(theta6), cos(theta6)+pow(ulgz,2)*(1-cos(theta6))); + G4RotationMatrix pqr = G4RotationMatrix(); + pqr.setRows(p,q,r); + lg_rotm.rotateZ((i-1)*360*deg/detNum6); + lg_rotm.rotateX(180*deg); + lg_rotm=pqr*lg_rotm; + G4ThreeVector lg_pos = (distanceFromTarget6+detThickness6+0.5*lgThickness6+.09*mm)/df.mag()*df; //the .09 mm is a fudge factor to prevent overlapping. + lg_pos.rotateZ(180*deg); + if (m_Flip == 0){ + lg_pos.rotateY(180*deg); + lg_rotm.rotateY(180*deg); + } + G4Transform3D lg_trans = G4Transform3D(lg_rotm, lg_pos); + G4RotationMatrix delrin_rotm = G4RotationMatrix(); + G4ThreeVector w = G4ThreeVector(sin(theta6)*sin((i-1)*360*deg/detNum6+.001*deg), sin(theta6)*cos((i-1)*360*deg/detNum6+.001*deg), cos(theta6)); + G4ThreeVector delrin_Axis = w.cross(z6); + delrin_Axis = delrin_Axis/delrin_Axis.mag(); + G4double udx = delrin_Axis.x(); + G4double udy = delrin_Axis.y(); + G4double udz = delrin_Axis.z(); + G4double delAng = 0*deg;//90*deg+theta6; + G4ThreeVector pdel = G4ThreeVector(cos(delAng)+pow(udx,2)*(1-cos(delAng)), udx*udy*(1-cos(delAng))-udz*sin(delAng), udx*udz*(1-cos(delAng))+udy*sin(delAng)); + G4ThreeVector qdel = G4ThreeVector(udy*udx*(1-cos(delAng))+udz*sin(delAng), cos(delAng)+pow(udy,2)*(1-cos(delAng)), udy*udz*(1-cos(delAng))-udx*sin(delAng)); + G4ThreeVector rdel = G4ThreeVector(udz*udx*(1-cos(delAng))-udy*sin(delAng), udz*udy*(1-cos(delAng))+udx*sin(delAng), cos(delAng)+pow(udz,2)*(1-cos(delAng))); + G4RotationMatrix pqrdel = G4RotationMatrix(); + pqrdel.setRows(pdel,qdel,rdel); + delrin_rotm.rotateZ((i-1)*360*deg/detNum6+.001*deg); + delrin_rotm=pqrdel*delrin_rotm; + delrin_rotm.rotateZ(180*deg); + G4ThreeVector delrin_pos = (distanceFromTarget6+detThickness6+lgThickness6+delrinA6/2+.0904*mm)/df.mag()*df; //the .0003 mm is a fudge factor to prevent overlapping + delrin_pos.rotateZ(180*deg); + delrin_pos.rotateY(180*deg); + if (m_Flip == 1){ + delrin_pos.rotateY(180*deg); + delrin_rotm.rotateY(180*deg); + } + G4Transform3D delrin_trans = G4Transform3D(delrin_rotm, delrin_pos); + bool placeCrystal = true; + for (unsigned int i2=0; i2 < m_Array.size(); i2++){ + /*if(54 < m_Array[i2] && m_Array[i2] < 58){ + if (55+57-m_Array[i2] == 54+i){ + placeCrystal = false; + } + } + if(57 < m_Array[i2] && m_Array[i2] < 69){ + if (58+68-m_Array[i2] == 54+i){ + placeCrystal = false; + } + }*/ + if (54 < m_Array[i2] && m_Array[i2] < 69){ + if (m_Array[i2] == 54+i){ + placeCrystal = false; + } + } + } + if (placeCrystal){ + if(crystalBool) {new G4PVPlacement(crystal_trans, //rotation, position + logicCrystal6, //its logical volume + "CsI Detector6", //its name + world, //its mother volume + false, //no boolean operation + 54+i, //copy number + checkOverlaps); //overlaps checking + } + if(lgBool) {new G4PVPlacement(lg_trans, //rotation, position + logicLightGuide6, //its logical volume + "LightGuide6", //its name + world, //its mother volume + false, //no boolean operation + 54+i, //copy number + checkOverlaps); //overlaps checking + } + if(delrinBool) {new G4PVPlacement(delrin_trans, //rotation, position + logicDelrin6, //its logical volume + "Delrin6", //its name + world, //its mother volume + false, //no boolean operation + 54+i, //copy number + checkOverlaps); //overlaps checking + } + } + }} + + if(m_Ring7){ + // Ring 7 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lg pseudofixed + G4int detNum7 = 12; + G4double distanceFromTargetBack7 = 45.*mm; + G4double theta7 = 111.5*deg; + G4double halfTheta7 = 11.5*deg;//-0.1*deg; //fudge factor + G4double lgThickness7 = 7.0*mm; + G4double detThickness7 = 4.1*mm; + G4double distanceFromTarget7 = distanceFromTargetBack7 - detThickness7; + + //G4double distance7 = distanceFromTarget7*sin(theta7); //this gives the distance from the beam axis. + + /* + // + // Delrin Ring (for deletion) + // + G4double delrin_rmina7 = distance7+detThickness7+lgThickness7, delrin_rmaxa7 = delrin_rmina7+5*mm; + G4double delrin_hz7 = 5*mm; //distance7*tan(halfTheta7); + G4double delrin_phimin7 = 0.*deg, delrin_phimax7 = 360.*deg; + G4ThreeVector delrin_pos7 = G4ThreeVector(0,0,distanceFromTarget7*cos(theta7)); //G4ThreeVector(0,0,distance7+lgThickness7+detThickness7*sin(theta7)); + + G4Tubs* solidDelrin7 = + new G4Tubs("Delrin7", //its name + delrin_rmina7, delrin_rmaxa7, + delrin_hz7, + delrin_phimin7, delrin_phimax7); //its size + + G4LogicalVolume* logicDelrin7 = + new G4LogicalVolume(solidDelrin7, //its solid + delrin, //its material + "Delrin7"); //its name + logicDelrin7->SetVisAttributes(delrinVisAtt); + + if(delrinBool) {new G4PVPlacement(0, //no rotation + delrin_pos7, //its position + logicDelrin7, //its logical volume + "Delrin7", //its name + world, //its mother volume + false, //no boolean operation + 0, //copy number + checkOverlaps); //overlaps checking + } + */ + // + // Delrin Ring + // + G4double delrinA7 = 5*mm; + G4double delrinB7 = 10*mm; + G4double fdelrinHalfAngle7 = atan(delrinB7/2/(distanceFromTarget7+detThickness7+lgThickness7)); + G4double firs7 = pow(pow(distanceFromTarget7+detThickness7+lgThickness7,2)+pow(delrinB7/2,2),0.5)*sin(theta7-fdelrinHalfAngle7); + G4double firb7 = pow(pow(distanceFromTarget7+detThickness7+lgThickness7,2)+pow(delrinB7/2,2),0.5)*sin(theta7+fdelrinHalfAngle7); + G4double bdelrinHalfAngle7 = atan(delrinB7/2/(distanceFromTarget7+detThickness7+lgThickness7+delrinA7)); + G4double birs7 = pow(pow(distanceFromTarget7+detThickness7+lgThickness7+delrinA7,2)+pow(delrinB7/2,2),0.5)*sin(theta7-bdelrinHalfAngle7); + G4double birb7 = pow(pow(distanceFromTarget7+detThickness7+lgThickness7+delrinA7,2)+pow(delrinB7/2,2),0.5)*sin(theta7+bdelrinHalfAngle7); + + G4double delrin_dz7 = delrinB7/2; + G4double delrin_theta7 = 0; + G4double delrin_phi7 = 0; + G4double delrin_dyab7 = delrinA7/2; + G4double delrin_dxa7 = firs7*tan(180*deg/detNum7); + G4double delrin_dxb7 = birs7*tan(180*deg/detNum7); + G4double delrin_dycd7 = delrinA7/2; + G4double delrin_dxc7 = firb7*tan(180*deg/detNum7); + G4double delrin_dxd7 = birb7*tan(180*deg/detNum7); + G4double delrin_alpab7 = 0; + G4double delrin_alpcd7 = delrin_alpab7; + + G4ThreeVector delrin_pos7 = G4ThreeVector(0,0,distanceFromTarget7*cos(theta7)); + + G4Trap* solidDelrin7 = + new G4Trap("Delrin7", //its name + delrin_dz7, + delrin_theta7, delrin_phi7, + delrin_dyab7, + delrin_dxa7, delrin_dxb7, + delrin_alpab7, + delrin_dycd7, + delrin_dxc7, delrin_dxd7, + delrin_alpcd7); //its size + + G4LogicalVolume* logicDelrin7 = + new G4LogicalVolume(solidDelrin7, //its solid + delrin, //its material + "Delrin7"); //its name + logicDelrin7->SetVisAttributes(delrinVisAtt); + + // + // CsI Detector + // + G4double coneheight7 = 0.6*distanceFromTarget7; + G4double flatheight7 = coneheight7 -0.01*mm; + G4double coneangle7 = theta7; + G4double crystal_rmina7 = -(coneheight7-flatheight7)*tan(coneangle7+halfTheta7); + G4double crystal_rmaxa7 = -(coneheight7-flatheight7)*tan(coneangle7-halfTheta7); + G4double crystal_rminb7 = -coneheight7*tan(coneangle7+halfTheta7); + G4double crystal_rmaxb7 = -coneheight7*tan(coneangle7-halfTheta7); + G4double crystal_hz7 = 0.5*flatheight7;//(crystal_rmaxb7-crystal_rmaxa7)/crystal_rmaxb7*coneheight7; + G4double crystal_phimin7 = 0.*deg, crystal_phimax7 = 360.*deg/detNum7; + G4RotationMatrix tip_rotm7 = G4RotationMatrix(); + G4ThreeVector tip_pos7 = G4ThreeVector(0,0,0.5*flatheight7+(coneheight7-flatheight7)); //last term is a fudge + G4Transform3D tip_trans7 = G4Transform3D(tip_rotm7, tip_pos7); + G4ThreeVector z7 = G4ThreeVector(0,0,1); + G4ThreeVector d07 = G4ThreeVector(distanceFromTarget7*sin(coneangle7)*cos(0.5*360*deg/detNum7), + distanceFromTarget7*sin(coneangle7)*sin(0.5*360*deg/detNum7), + -distanceFromTarget7*cos(coneangle7)); + G4ThreeVector unitAxis7 = z7.cross(d07); + unitAxis7 = unitAxis7/unitAxis7.mag(); + G4double ux7 = unitAxis7.x(); + G4double uy7 = unitAxis7.y(); + G4double uz7 = unitAxis7.z(); + G4ThreeVector top7 = G4ThreeVector(cos(-coneangle7)+pow(ux7,2)*(1-cos(-coneangle7)), ux7*uy7*(1-cos(-coneangle7))-uz7*sin(-coneangle7), ux7*uz7*(1-cos(-coneangle7))+uy7*sin(-coneangle7)); + G4ThreeVector mid7 = G4ThreeVector(uy7*ux7*(1-cos(-coneangle7))+uz7*sin(-coneangle7), cos(-coneangle7)+pow(uy7,2)*(1-cos(-coneangle7)), uy7*uz7*(1-cos(-coneangle7))-ux7*sin(-coneangle7)); + G4ThreeVector bot7 = G4ThreeVector(uz7*ux7*(1-cos(-coneangle7))-uy7*sin(-coneangle7), uz7*uy7*(1-cos(-coneangle7))+ux7*sin(-coneangle7), cos(-coneangle7)+pow(uz7,2)*(1-cos(-coneangle7))); + G4RotationMatrix firstBox_rotm7 = G4RotationMatrix(); + firstBox_rotm7.setRows(top7,mid7,bot7); + G4ThreeVector firstBox_pos7 = G4ThreeVector(0,0,0); + G4Transform3D firstBox_trans7 = G4Transform3D(firstBox_rotm7, firstBox_pos7); + G4RotationMatrix secondBox_rotm7 = G4RotationMatrix(); + secondBox_rotm7.setRows(top7,mid7,bot7); + G4ThreeVector secondBox_pos7 = (3*distanceFromTarget7+detThickness7)/distanceFromTarget7*d07; + G4Transform3D secondBox_trans7 = G4Transform3D(secondBox_rotm7, secondBox_pos7); + + G4Orb* solidTip7 = + new G4Orb("tip7", + .0001*mm); + G4Box* solidSubtractionBox7 = + new G4Box("SubtractionBox7", //its name + distanceFromTarget7, + distanceFromTarget7, + distanceFromTarget7); //its size + G4Box* solidSecondSubtractionBox7 = + new G4Box("SecondSubtractionBox7", //its name + 2*distanceFromTarget7, + 2*distanceFromTarget7, + 2*distanceFromTarget7); //its size + G4Cons* solidCone7 = + new G4Cons("Cone7", //its name + crystal_rmina7, crystal_rmaxa7, + crystal_rminb7, crystal_rmaxb7, + crystal_hz7, + crystal_phimin7, crystal_phimax7); //its size + G4UnionSolid* solidTippedCone7 = + new G4UnionSolid("TippedCone7", + solidTip7, + solidCone7, + tip_trans7); + G4SubtractionSolid* solidIntermediate7 = + new G4SubtractionSolid("Intermediate7", + solidTippedCone7, + solidSubtractionBox7, + firstBox_trans7); + G4SubtractionSolid* solidCrystal7 = + new G4SubtractionSolid("Crystal7", + solidIntermediate7, + solidSecondSubtractionBox7, + secondBox_trans7); + + G4LogicalVolume* logicCrystal7 = + new G4LogicalVolume(solidCrystal7, //its solid + CsI, //its material + "CsI Detector7"); //its name + logicCrystal7->SetVisAttributes(crystalVisAtt); + logicCrystal7->SetSensitiveDetector(m_MicroballScorer); + // + // Light Guide + // + G4double lightGuide_px7 = 10*mm; + G4double lightGuide_py7 = 10*mm; + G4double lightGuide_pz7 = lgThickness7; + G4Box* solidLightGuide7 = + new G4Box("LightGuide7", //its name + 0.5*lightGuide_px7, + 0.5*lightGuide_py7, + 0.5*lightGuide_pz7); //its size + + G4LogicalVolume* logicLightGuide7 = + new G4LogicalVolume(solidLightGuide7, //its solid + glass, //its material + "LightGuide7"); //its name + logicLightGuide7->SetVisAttributes(lightGuideVisAtt); + + + for(int i = 1; i <= detNum7; i++) + { + G4RotationMatrix crystal_rotm = G4RotationMatrix(); + G4ThreeVector d0 = G4ThreeVector(distanceFromTarget7*sin(coneangle7)*cos(0.5*360*deg/detNum7), + distanceFromTarget7*sin(coneangle7)*sin(0.5*360*deg/detNum7), + distanceFromTarget7*cos(coneangle7)); + G4ThreeVector df = G4ThreeVector(distanceFromTarget7*sin(theta7)*sin((i-1)*360*deg/detNum7+.001*deg/*+0.5*360*deg/detNum7*/), + distanceFromTarget7*sin(theta7)*cos((i-1)*360*deg/detNum7+.001*deg/*+0.5*360*deg/detNum7*/), + -distanceFromTarget7*cos(theta7)); + df.setX(-df.x()); + G4ThreeVector axis = d0.cross(df); + G4double ax = axis.x(); + G4double ay = axis.y(); + G4double az = axis.z(); + G4double ux = ax/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double uy = ay/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double uz = az/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double j = acos(d0.dot(df)/(d0.mag()*df.mag())); + G4ThreeVector a = G4ThreeVector(cos(j)+pow(ux,2)*(1-cos(j)), ux*uy*(1-cos(j))-uz*sin(j), ux*uz*(1-cos(j))+uy*sin(j)); + G4ThreeVector b = G4ThreeVector(uy*ux*(1-cos(j))+uz*sin(j), cos(j)+pow(uy,2)*(1-cos(j)), uy*uz*(1-cos(j))-ux*sin(j)); + G4ThreeVector c = G4ThreeVector(uz*ux*(1-cos(j))-uy*sin(j), uz*uy*(1-cos(j))+ux*sin(j), cos(j)+pow(uz,2)*(1-cos(j))); + G4RotationMatrix abc = G4RotationMatrix(); + abc.setRows(a,b,c); + G4ThreeVector unitdf = df/df.mag(); + G4double udfx = unitdf.x(); + G4double udfy = unitdf.y(); + G4double udfz = unitdf.z(); + G4double k = 180.*deg; + G4ThreeVector d = G4ThreeVector(cos(k)+pow(udfx,2)*(1-cos(k)), udfx*udfy*(1-cos(k))-udfz*sin(k), udfx*udfz*(1-cos(k))+udfy*sin(k)); + G4ThreeVector e = G4ThreeVector(udfy*udfx*(1-cos(k))+udfz*sin(k), cos(k)+pow(udfy,2)*(1-cos(k)), udfy*udfz*(1-cos(k))-udfx*sin(k)); + G4ThreeVector f = G4ThreeVector(udfz*udfx*(1-cos(k))-udfy*sin(k), udfz*udfy*(1-cos(k))+udfx*sin(k), cos(k)+pow(udfz,2)*(1-cos(k))); + G4RotationMatrix def = G4RotationMatrix(); + def.setRows(d,e,f); + crystal_rotm=def*abc; + if (m_Flip == 1){ + crystal_rotm.rotateY(180*deg); + } + crystal_rotm.rotateZ(180*deg); + G4ThreeVector crystal_pos = G4ThreeVector(0,0,0); + G4Transform3D crystal_trans = G4Transform3D(crystal_rotm, crystal_pos); + df.setX(-df.x()); + G4RotationMatrix lg_rotm = G4RotationMatrix(); + G4ThreeVector lg_Axis = df.cross(z7); + lg_Axis = lg_Axis/lg_Axis.mag(); + lg_Axis.rotateZ(180*deg); + G4double ulgx = lg_Axis.x(); + G4double ulgy = lg_Axis.y(); + G4double ulgz = lg_Axis.z(); + G4double lg_ang = theta7; + G4ThreeVector p = G4ThreeVector(cos(lg_ang)+pow(ulgx,2)*(1-cos(lg_ang)), ulgx*ulgy*(1-cos(lg_ang))-ulgz*sin(lg_ang), ulgx*ulgz*(1-cos(lg_ang))+ulgy*sin(lg_ang)); + G4ThreeVector q = G4ThreeVector(ulgy*ulgx*(1-cos(lg_ang))+ulgz*sin(lg_ang), cos(lg_ang)+pow(ulgy,2)*(1-cos(lg_ang)), ulgy*ulgz*(1-cos(lg_ang))-ulgx*sin(lg_ang)); + G4ThreeVector r = G4ThreeVector(ulgz*ulgx*(1-cos(lg_ang))-ulgy*sin(lg_ang), ulgz*ulgy*(1-cos(lg_ang))+ulgx*sin(lg_ang), cos(lg_ang)+pow(ulgz,2)*(1-cos(lg_ang))); + G4RotationMatrix pqr = G4RotationMatrix(); + pqr.setRows(p,q,r); + lg_rotm.rotateZ((i-1)*360*deg/detNum7); + lg_rotm.rotateX(180*deg); + lg_rotm=pqr*lg_rotm; + G4ThreeVector lg_pos = (distanceFromTarget7+detThickness7+0.5*lgThickness7+.0003*mm)/df.mag()*df; + lg_pos.rotateZ(180*deg); + if (m_Flip == 0){ + lg_pos.rotateY(180*deg); + lg_rotm.rotateY(180*deg); + } + G4Transform3D lg_trans = G4Transform3D(lg_rotm, lg_pos); + G4RotationMatrix delrin_rotm = G4RotationMatrix(); + G4ThreeVector w = G4ThreeVector(sin(theta7)*sin((i-1)*360*deg/detNum7+.001*deg), sin(theta7)*cos((i-1)*360*deg/detNum7+.001*deg), cos(theta7)); + G4ThreeVector delrin_Axis = w.cross(z7); + delrin_Axis.rotateX(180*deg); + delrin_Axis = delrin_Axis/delrin_Axis.mag(); + G4double udx = delrin_Axis.x(); + G4double udy = delrin_Axis.y(); + G4double udz = delrin_Axis.z(); + G4double delAng = -90*deg+theta7; + G4ThreeVector pdel = G4ThreeVector(cos(delAng)+pow(udx,2)*(1-cos(delAng)), udx*udy*(1-cos(delAng))-udz*sin(delAng), udx*udz*(1-cos(delAng))+udy*sin(delAng)); + G4ThreeVector qdel = G4ThreeVector(udy*udx*(1-cos(delAng))+udz*sin(delAng), cos(delAng)+pow(udy,2)*(1-cos(delAng)), udy*udz*(1-cos(delAng))-udx*sin(delAng)); + G4ThreeVector rdel = G4ThreeVector(udz*udx*(1-cos(delAng))-udy*sin(delAng), udz*udy*(1-cos(delAng))+udx*sin(delAng), cos(delAng)+pow(udz,2)*(1-cos(delAng))); + G4RotationMatrix pqrdel = G4RotationMatrix(); + pqrdel.setRows(pdel,qdel,rdel); + delrin_rotm.rotateZ((-i+1)*360*deg/detNum7+.001*deg); + delrin_rotm.rotateX(180*deg); + delrin_rotm=pqrdel*delrin_rotm; + delrin_rotm.rotateZ(0*deg); + G4ThreeVector delrin_pos = (distanceFromTarget7+detThickness7+lgThickness7+delrinA7/2+.0005*mm)/df.mag()*df; //the .0003 mm is a fudge factor to prevent overlapping + delrin_pos.rotateZ(180*deg); + delrin_pos.rotateY(180*deg); + if (m_Flip == 1){ + delrin_pos.rotateY(180*deg); + delrin_rotm.rotateY(180*deg); + } + G4Transform3D delrin_trans = G4Transform3D(delrin_rotm, delrin_pos); + bool placeCrystal = true; + for (unsigned int i2=0; i2 < m_Array.size(); i2++){ + if (68 < m_Array[i2] && m_Array[i2] < 81){ + /*if (m_Array[i2] == 69 && 68+i == 80){ + placeCrystal = false; + } + else if(68+m_Array[i2]%69 == 68+i){ + placeCrystal = false; + } + if (m_Array[i2] == 68+i){ + placeDel = false; + }*/ + if (m_Array[i2] == 68+i){ + placeCrystal = false; + } + } + } + if (placeCrystal){ + if(crystalBool) {new G4PVPlacement(crystal_trans, //rotation, position + logicCrystal7, //its logical volume + "CsI Detector7", //its name + world, //its mother volume + false, //no boolean operation + 68+i, //copy number + checkOverlaps); //overlaps checking + } + } + if(placeCrystal){ + if(lgBool) {new G4PVPlacement(lg_trans, //rotation, position + logicLightGuide7, //its logical volume + "LightGuide7", //its name + world, //its mother volume + false, //no boolean operation + 68+i, //copy number + checkOverlaps); //overlaps checking + } + if(delrinBool) {new G4PVPlacement(delrin_trans, //rotation, position + logicDelrin7, //its logical volume + "Delrin7", //its name + world, //its mother volume + false, //no boolean operation + 68+i, //copy number + checkOverlaps); //overlaps checking + } + } + }} + + + if(m_Ring8) { + // Ring 8 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + G4int detNum8 = 10; + G4double distanceFromTargetBack8 = 47*mm; //Its really 47 mm from the target, but at 45.9 we avoid intersection the detectors in ring 9 + G4double theta8 = 135.0*deg; + G4double halfTheta8 = 12.0*deg;// -0.1*deg; //fudge factor + G4double lgThickness8 = 7.5*mm; + G4double detThickness8 = 3.6*mm; + G4double distanceFromTarget8 = distanceFromTargetBack8 - detThickness8; + + //G4double distance8 = distanceFromTarget8*sin(theta8); //this gives the distance from the beam axis. + /* + // + // Delrin Ring (for deletion) + // + G4double delrin_rmina8 = distance8+detThickness8+lgThickness8, delrin_rmaxa8 = delrin_rmina8+5*mm; + G4double delrin_hz8 = 5*mm; //distance8*tan(halfTheta8); + G4double delrin_phimin8 = 0.*deg, delrin_phimax8 = 360.*deg; + G4ThreeVector delrin_pos8 = G4ThreeVector(0,0,distanceFromTarget8*cos(theta8)); //G4ThreeVector(0,0,distance8+lgThickness8+detThickness8*sin(theta8)); + + G4Tubs* solidDelrin8 = + new G4Tubs("Delrin8", //its name + delrin_rmina8, delrin_rmaxa8, + delrin_hz8, + delrin_phimin8, delrin_phimax8); //its size + + G4LogicalVolume* logicDelrin8 = + new G4LogicalVolume(solidDelrin8, //its solid + delrin, //its material + "Delrin8"); //its name + logicDelrin8->SetVisAttributes(delrinVisAtt); + + if(delrinBool) {new G4PVPlacement(0, //no rotation + delrin_pos8, //its position + logicDelrin8, //its logical volume + "Delrin8", //its name + world, //its mother volume + false, //no boolean operation + 0, //copy number + checkOverlaps); //overlaps checking + } + */ + // + // Delrin Ring + // + G4double delrinA8 = 5*mm; + G4double delrinB8 = 10*mm; + G4double fdelrinHalfAngle8 = atan(delrinB8/2/(distanceFromTarget8+detThickness8+lgThickness8)); + G4double firs8 = pow(pow(distanceFromTarget8+detThickness8+lgThickness8,2)+pow(delrinB8/2,2),0.5)*sin(theta8-fdelrinHalfAngle8); + G4double firb8 = pow(pow(distanceFromTarget8+detThickness8+lgThickness8,2)+pow(delrinB8/2,2),0.5)*sin(theta8+fdelrinHalfAngle8); + G4double bdelrinHalfAngle8 = atan(delrinB8/2/(distanceFromTarget8+detThickness8+lgThickness8+delrinA8)); + G4double birs8 = pow(pow(distanceFromTarget8+detThickness8+lgThickness8+delrinA8,2)+pow(delrinB8/2,2),0.5)*sin(theta8-bdelrinHalfAngle8); + G4double birb8 = pow(pow(distanceFromTarget8+detThickness8+lgThickness8+delrinA8,2)+pow(delrinB8/2,2),0.5)*sin(theta8+bdelrinHalfAngle8); + + G4double delrin_dz8 = delrinB8/2; + G4double delrin_theta8 = 0; + G4double delrin_phi8 = 0; + G4double delrin_dyab8 = delrinA8/2; + G4double delrin_dxa8 = firs8*tan(180*deg/detNum8); + G4double delrin_dxb8 = birs8*tan(180*deg/detNum8); + G4double delrin_dycd8 = delrinA8/2; + G4double delrin_dxc8 = firb8*tan(180*deg/detNum8); + G4double delrin_dxd8 = birb8*tan(180*deg/detNum8); + G4double delrin_alpab8 = 0; + G4double delrin_alpcd8 = delrin_alpab8; + + G4ThreeVector delrin_pos8 = G4ThreeVector(0,0,distanceFromTarget8*cos(theta8)); + + G4Trap* solidDelrin8 = + new G4Trap("Delrin8", //its name + delrin_dz8, + delrin_theta8, delrin_phi8, + delrin_dyab8, + delrin_dxa8, delrin_dxb8, + delrin_alpab8, + delrin_dycd8, + delrin_dxc8, delrin_dxd8, + delrin_alpcd8); //its size + + G4LogicalVolume* logicDelrin8 = + new G4LogicalVolume(solidDelrin8, //its solid + delrin, //its material + "Delrin8"); //its name + logicDelrin8->SetVisAttributes(delrinVisAtt); + + // + // CsI Detector + // + G4double coneheight8 = 1.7*distanceFromTarget8; + G4double flatheight8 = coneheight8 -0.01*mm; + G4double coneangle8 = theta8; + G4double crystal_rmina8 = -(coneheight8-flatheight8)*tan(coneangle8+halfTheta8); + G4double crystal_rmaxa8 = -(coneheight8-flatheight8)*tan(coneangle8-halfTheta8); + G4double crystal_rminb8 = -coneheight8*tan(coneangle8+halfTheta8); + G4double crystal_rmaxb8 = -coneheight8*tan(coneangle8-halfTheta8); + G4double crystal_hz8 = 0.5*flatheight8;//(crystal_rmaxb8-crystal_rmaxa8)/crystal_rmaxb8*coneheight8; + G4double crystal_phimin8 = 0.*deg, crystal_phimax8 = 360.*deg/detNum8; + G4RotationMatrix tip_rotm8 = G4RotationMatrix(); + G4ThreeVector tip_pos8 = G4ThreeVector(0,0,0.5*flatheight8+(coneheight8-flatheight8)); //last term is a fudge + G4Transform3D tip_trans8 = G4Transform3D(tip_rotm8, tip_pos8); + G4ThreeVector z8 = G4ThreeVector(0,0,1); + G4ThreeVector d08 = G4ThreeVector(distanceFromTarget8*sin(coneangle8)*cos(0.5*360*deg/detNum8), + distanceFromTarget8*sin(coneangle8)*sin(0.5*360*deg/detNum8), + -distanceFromTarget8*cos(coneangle8)); + G4ThreeVector unitAxis8 = z8.cross(d08); + unitAxis8 = unitAxis8/unitAxis8.mag(); + G4double ux8 = unitAxis8.x(); + G4double uy8 = unitAxis8.y(); + G4double uz8 = unitAxis8.z(); + G4ThreeVector top8 = G4ThreeVector(cos(-coneangle8)+pow(ux8,2)*(1-cos(-coneangle8)), ux8*uy8*(1-cos(-coneangle8))-uz8*sin(-coneangle8), ux8*uz8*(1-cos(-coneangle8))+uy8*sin(-coneangle8)); + G4ThreeVector mid8 = G4ThreeVector(uy8*ux8*(1-cos(-coneangle8))+uz8*sin(-coneangle8), cos(-coneangle8)+pow(uy8,2)*(1-cos(-coneangle8)), uy8*uz8*(1-cos(-coneangle8))-ux8*sin(-coneangle8)); + G4ThreeVector bot8 = G4ThreeVector(uz8*ux8*(1-cos(-coneangle8))-uy8*sin(-coneangle8), uz8*uy8*(1-cos(-coneangle8))+ux8*sin(-coneangle8), cos(-coneangle8)+pow(uz8,2)*(1-cos(-coneangle8))); + G4RotationMatrix firstBox_rotm8 = G4RotationMatrix(); + firstBox_rotm8.setRows(top8,mid8,bot8); + G4ThreeVector firstBox_pos8 = G4ThreeVector(0,0,0); + G4Transform3D firstBox_trans8 = G4Transform3D(firstBox_rotm8, firstBox_pos8); + G4RotationMatrix secondBox_rotm8 = G4RotationMatrix(); + secondBox_rotm8.setRows(top8,mid8,bot8); + G4ThreeVector secondBox_pos8 = (2*distanceFromTarget8+detThickness8)/d08.mag()*d08; + G4Transform3D secondBox_trans8 = G4Transform3D(secondBox_rotm8, secondBox_pos8); + + G4Orb* solidTip8 = + new G4Orb("tip8", + .0001*mm); + G4Box* solidSubtractionBox8 = + new G4Box("SubtractionBox8", //its name + distanceFromTarget8, + distanceFromTarget8, + distanceFromTarget8); //its size + G4Cons* solidCone8 = + new G4Cons("Cone8", //its name + crystal_rmina8, crystal_rmaxa8, + crystal_rminb8, crystal_rmaxb8, + crystal_hz8, + crystal_phimin8, crystal_phimax8); //its size + G4UnionSolid* solidTippedCone8 = + new G4UnionSolid("TippedCone8", + solidTip8, + solidCone8, + tip_trans8); + G4SubtractionSolid* solidIntermediate8 = + new G4SubtractionSolid("Intermediate8", + solidTippedCone8, + solidSubtractionBox8, + firstBox_trans8); + G4SubtractionSolid* solidCrystal8 = + new G4SubtractionSolid("Crystal8", + solidIntermediate8, + solidSubtractionBox8, + secondBox_trans8); + + G4LogicalVolume* logicCrystal8 = + new G4LogicalVolume(solidCrystal8, //its solid + CsI, //its material + "CsI Detector8"); //its name + logicCrystal8->SetVisAttributes(crystalVisAtt); + logicCrystal8->SetSensitiveDetector(m_MicroballScorer); + // + // Light Guide + // + G4double lightGuide_px8 = 10*mm; + G4double lightGuide_py8 = 10*mm; + G4double lightGuide_pz8 = lgThickness8; + G4Box* solidLightGuide8 = + new G4Box("LightGuide8", //its name + 0.5*lightGuide_px8, + 0.5*lightGuide_py8, + 0.5*lightGuide_pz8); //its size + + G4LogicalVolume* logicLightGuide8 = + new G4LogicalVolume(solidLightGuide8, //its solid + glass, //its material + "LightGuide8"); //its name + logicLightGuide8->SetVisAttributes(lightGuideVisAtt); + + + for(int i = 1; i <= detNum8; i++) + { + G4RotationMatrix crystal_rotm = G4RotationMatrix(); + G4ThreeVector d0 = G4ThreeVector(distanceFromTarget8*sin(coneangle8)*cos(0.5*360*deg/detNum8), + distanceFromTarget8*sin(coneangle8)*sin(0.5*360*deg/detNum8), + distanceFromTarget8*cos(coneangle8)); + G4ThreeVector df = G4ThreeVector(distanceFromTarget8*sin(theta8)*sin((i-1)*360*deg/detNum8+.001*deg/*+0.5*360*deg/detNum8*/), + distanceFromTarget8*sin(theta8)*cos((i-1)*360*deg/detNum8+.001*deg/*+0.5*360*deg/detNum8*/), + -distanceFromTarget8*cos(theta8)); + df.setX(-df.x()); + G4ThreeVector axis = d0.cross(df); + G4double ax = axis.x(); + G4double ay = axis.y(); + G4double az = axis.z(); + G4double ux = ax/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double uy = ay/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double uz = az/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double j = acos(d0.dot(df)/(d0.mag()*df.mag())); + G4ThreeVector a = G4ThreeVector(cos(j)+pow(ux,2)*(1-cos(j)), ux*uy*(1-cos(j))-uz*sin(j), ux*uz*(1-cos(j))+uy*sin(j)); + G4ThreeVector b = G4ThreeVector(uy*ux*(1-cos(j))+uz*sin(j), cos(j)+pow(uy,2)*(1-cos(j)), uy*uz*(1-cos(j))-ux*sin(j)); + G4ThreeVector c = G4ThreeVector(uz*ux*(1-cos(j))-uy*sin(j), uz*uy*(1-cos(j))+ux*sin(j), cos(j)+pow(uz,2)*(1-cos(j))); + G4RotationMatrix abc = G4RotationMatrix(); + abc.setRows(a,b,c); + G4ThreeVector unitdf = df/df.mag(); + G4double udfx = unitdf.x(); + G4double udfy = unitdf.y(); + G4double udfz = unitdf.z(); + G4double k = 180.*deg; + G4ThreeVector d = G4ThreeVector(cos(k)+pow(udfx,2)*(1-cos(k)), udfx*udfy*(1-cos(k))-udfz*sin(k), udfx*udfz*(1-cos(k))+udfy*sin(k)); + G4ThreeVector e = G4ThreeVector(udfy*udfx*(1-cos(k))+udfz*sin(k), cos(k)+pow(udfy,2)*(1-cos(k)), udfy*udfz*(1-cos(k))-udfx*sin(k)); + G4ThreeVector f = G4ThreeVector(udfz*udfx*(1-cos(k))-udfy*sin(k), udfz*udfy*(1-cos(k))+udfx*sin(k), cos(k)+pow(udfz,2)*(1-cos(k))); + G4RotationMatrix def = G4RotationMatrix(); + def.setRows(d,e,f); + crystal_rotm=def*abc; + if (m_Flip == 1){ + crystal_rotm.rotateY(180*deg); + } + crystal_rotm.rotateZ(180*deg); + G4ThreeVector crystal_pos = G4ThreeVector(0,0,0); + G4Transform3D crystal_trans = G4Transform3D(crystal_rotm, crystal_pos); + df.setX(-df.x()); + G4RotationMatrix lg_rotm = G4RotationMatrix(); + G4ThreeVector lg_Axis = df.cross(z8); + lg_Axis = lg_Axis/lg_Axis.mag(); + lg_Axis.rotateZ(180*deg); + G4double ulgx = lg_Axis.x(); + G4double ulgy = lg_Axis.y(); + G4double ulgz = lg_Axis.z(); + G4ThreeVector p = G4ThreeVector(cos(theta8)+pow(ulgx,2)*(1-cos(theta8)), ulgx*ulgy*(1-cos(theta8))-ulgz*sin(theta8), ulgx*ulgz*(1-cos(theta8))+ulgy*sin(theta8)); + G4ThreeVector q = G4ThreeVector(ulgy*ulgx*(1-cos(theta8))+ulgz*sin(theta8), cos(theta8)+pow(ulgy,2)*(1-cos(theta8)), ulgy*ulgz*(1-cos(theta8))-ulgx*sin(theta8)); + G4ThreeVector r = G4ThreeVector(ulgz*ulgx*(1-cos(theta8))-ulgy*sin(theta8), ulgz*ulgy*(1-cos(theta8))+ulgx*sin(theta8), cos(theta8)+pow(ulgz,2)*(1-cos(theta8))); + G4RotationMatrix pqr = G4RotationMatrix(); + pqr.setRows(p,q,r); + lg_rotm.rotateZ((i-1)*360*deg/detNum8); + lg_rotm.rotateX(180*deg); + lg_rotm=pqr*lg_rotm; + G4ThreeVector lg_pos = (distanceFromTarget8+detThickness8+0.5*lgThickness8+.0003*mm)/df.mag()*df; + lg_pos.rotateZ(180*deg); + if (m_Flip == 0){ + lg_pos.rotateY(180*deg); + lg_rotm.rotateY(180*deg); + } + G4Transform3D lg_trans = G4Transform3D(lg_rotm, lg_pos); + G4RotationMatrix delrin_rotm = G4RotationMatrix(); + G4ThreeVector w = G4ThreeVector(sin(theta8)*sin((i-1)*360*deg/detNum8+.001*deg), sin(theta8)*cos((i-1)*360*deg/detNum8+.001*deg), cos(theta8)); + G4ThreeVector delrin_Axis = w.cross(z8); + delrin_Axis.rotateX(180*deg); + delrin_Axis = delrin_Axis/delrin_Axis.mag(); + G4double udx = delrin_Axis.x(); + G4double udy = delrin_Axis.y(); + G4double udz = delrin_Axis.z(); + G4double delAng = -90*deg+theta8; + G4ThreeVector pdel = G4ThreeVector(cos(delAng)+pow(udx,2)*(1-cos(delAng)), udx*udy*(1-cos(delAng))-udz*sin(delAng), udx*udz*(1-cos(delAng))+udy*sin(delAng)); + G4ThreeVector qdel = G4ThreeVector(udy*udx*(1-cos(delAng))+udz*sin(delAng), cos(delAng)+pow(udy,2)*(1-cos(delAng)), udy*udz*(1-cos(delAng))-udx*sin(delAng)); + G4ThreeVector rdel = G4ThreeVector(udz*udx*(1-cos(delAng))-udy*sin(delAng), udz*udy*(1-cos(delAng))+udx*sin(delAng), cos(delAng)+pow(udz,2)*(1-cos(delAng))); + G4RotationMatrix pqrdel = G4RotationMatrix(); + pqrdel.setRows(pdel,qdel,rdel); + delrin_rotm.rotateZ((-i+1)*360*deg/detNum8+.001*deg); + delrin_rotm.rotateX(180*deg); + delrin_rotm=pqrdel*delrin_rotm; + delrin_rotm.rotateZ(0*deg); + G4ThreeVector delrin_pos = (distanceFromTarget8+detThickness8+lgThickness8+delrinA8/2+.0005*mm)/df.mag()*df; //the .0003 mm is a fudge factor to prevent overlapping + delrin_pos.rotateZ(180*deg); + delrin_pos.rotateY(180*deg); + if (m_Flip == 1){ + delrin_pos.rotateY(180*deg); + delrin_rotm.rotateY(180*deg); + } + G4Transform3D delrin_trans = G4Transform3D(delrin_rotm, delrin_pos); + bool placeCrystal = true; + for (unsigned int i2=0; i2 < m_Array.size(); i2++){ + if (80 < m_Array[i2] && m_Array[i2] < 91){ + if (m_Array[i2] == 80+i){ + placeCrystal = false; + } + } + } + if (placeCrystal){ + if(crystalBool) {new G4PVPlacement(crystal_trans, //rotation, position + logicCrystal8, //its logical volume + "CsI Detector8", //its name + world, //its mother volume + false, //no boolean operation + 80+i, //copy number + checkOverlaps); //overlaps checking + } + } + if (placeCrystal){ + if(lgBool) {new G4PVPlacement(lg_trans, //rotation, position + logicLightGuide8, //its logical volume + "LightGuide8", //its name + world, //its mother volume + false, //no boolean operation + 80+i, //copy number + checkOverlaps); //overlaps checking + } + if(delrinBool) {new G4PVPlacement(delrin_trans, //rotation, position + logicDelrin8, //its logical volume + "Delrin8", //its name + world, //its mother volume + false, //no boolean operation + 80+i, //copy number + checkOverlaps); //overlaps checking + } + } + }} + + + if(m_Ring9){ + // Ring 9 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + G4int detNum9 = 6; + G4double distanceFromTargetBack9 = 50.*mm; + G4double theta9 = 159.0*deg; + G4double halfTheta9 = 12.0*deg;//-0.1*deg; //fudge factor + G4double lgThickness9 = 8.0*mm; + G4double detThickness9 = 3.5*mm; + G4double distanceFromTarget9 = distanceFromTargetBack9 - detThickness9; + + //G4double distance9 = distanceFromTarget9*sin(theta9); //this gives the distance from the beam axis. + + /* + // + // Delrin Ring (for deletion) + // + G4double delrin_rmina9 = distance9+detThickness9+lgThickness9, delrin_rmaxa9 = delrin_rmina9+5*mm; + G4double delrin_hz9 = 5*mm; //distance9*tan(halfTheta9); + G4double delrin_phimin9 = 0.*deg, delrin_phimax9 = 360.*deg; + G4ThreeVector delrin_pos9 = G4ThreeVector(0,0,distanceFromTarget9*cos(theta9)); //G4ThreeVector(0,0,distance9+lgThickness9+detThickness9*sin(theta9)); + + G4Tubs* solidDelrin9 = + new G4Tubs("Delrin9", //its name + delrin_rmina9, delrin_rmaxa9, + delrin_hz9, + delrin_phimin9, delrin_phimax9); //its size + + G4LogicalVolume* logicDelrin9 = + new G4LogicalVolume(solidDelrin9, //its solid + delrin, //its material + "Delrin9"); //its name + logicDelrin9->SetVisAttributes(delrinVisAtt); + + if(delrinBool) {new G4PVPlacement(0, //no rotation + delrin_pos9, //its position + logicDelrin9, //its logical volume + "Delrin9", //its name + world, //its mother volume + false, //no boolean operation + 0, //copy number + checkOverlaps); //overlaps checking + } + */ + + // + // Delrin Ring + // + G4double delrinA9 = 5*mm; + G4double delrinB9 = 10*mm; + G4double fdelrinHalfAngle9 = atan(delrinB9/2/(distanceFromTarget9+detThickness9+lgThickness9)); + G4double firs9 = pow(pow(distanceFromTarget9+detThickness9+lgThickness9,2)+pow(delrinB9/2,2),0.5)*sin(theta9-fdelrinHalfAngle9); + G4double firb9 = pow(pow(distanceFromTarget9+detThickness9+lgThickness9,2)+pow(delrinB9/2,2),0.5)*sin(theta9+fdelrinHalfAngle9); + G4double bdelrinHalfAngle9 = atan(delrinB9/2/(distanceFromTarget9+detThickness9+lgThickness9+delrinA9)); + G4double birs9 = pow(pow(distanceFromTarget9+detThickness9+lgThickness9+delrinA9,2)+pow(delrinB9/2,2),0.5)*sin(theta9-bdelrinHalfAngle9); + G4double birb9 = pow(pow(distanceFromTarget9+detThickness9+lgThickness9+delrinA9,2)+pow(delrinB9/2,2),0.5)*sin(theta9+bdelrinHalfAngle9); + + G4double delrin_dz9 = delrinB9/2; + G4double delrin_theta9 = 0; + G4double delrin_phi9 = 0; + G4double delrin_dyab9 = delrinA9/2; + G4double delrin_dxa9 = firs9*tan(180*deg/detNum9); + G4double delrin_dxb9 = birs9*tan(180*deg/detNum9); + G4double delrin_dycd9 = delrinA9/2; + G4double delrin_dxc9 = firb9*tan(180*deg/detNum9); + G4double delrin_dxd9 = birb9*tan(180*deg/detNum9); + G4double delrin_alpab9 = 0; + G4double delrin_alpcd9 = delrin_alpab9; + + G4ThreeVector delrin_pos9 = G4ThreeVector(0,0,distanceFromTarget9*cos(theta9)); + + G4Trap* solidDelrin9 = + new G4Trap("Delrin9", //its name + delrin_dz9, + delrin_theta9, delrin_phi9, + delrin_dyab9, + delrin_dxa9, delrin_dxb9, + delrin_alpab9, + delrin_dycd9, + delrin_dxc9, delrin_dxd9, + delrin_alpcd9); //its size + + G4LogicalVolume* logicDelrin9 = + new G4LogicalVolume(solidDelrin9, //its solid + delrin, //its material + "Delrin9"); //its name + logicDelrin9->SetVisAttributes(delrinVisAtt); + + // + // CsI Detector + // + G4double coneheight9 = 2*distanceFromTarget9; + G4double flatheight9 = coneheight9 -0.01*mm; + G4double coneangle9 = theta9; + G4double crystal_rmina9 = -(coneheight9-flatheight9)*tan(coneangle9+halfTheta9); + G4double crystal_rmaxa9 = -(coneheight9-flatheight9)*tan(coneangle9-halfTheta9); + G4double crystal_rminb9 = -coneheight9*tan(coneangle9+halfTheta9); + G4double crystal_rmaxb9 = -coneheight9*tan(coneangle9-halfTheta9); + G4double crystal_hz9 = 0.5*flatheight9;//(crystal_rmaxb9-crystal_rmaxa9)/crystal_rmaxb9*coneheight9; + G4double crystal_phimin9 = 0.*deg, crystal_phimax9 = 360.*deg/detNum9; + G4RotationMatrix tip_rotm9 = G4RotationMatrix(); + G4ThreeVector tip_pos9 = G4ThreeVector(0,0,0.5*flatheight9+(coneheight9-flatheight9)); //last term is a fudge + G4Transform3D tip_trans9 = G4Transform3D(tip_rotm9, tip_pos9); + G4ThreeVector z9 = G4ThreeVector(0,0,1); + G4ThreeVector d09 = G4ThreeVector(distanceFromTarget9*sin(coneangle9)*cos(0.5*360*deg/detNum9), + distanceFromTarget9*sin(coneangle9)*sin(0.5*360*deg/detNum9), + -distanceFromTarget9*cos(coneangle9)); + G4ThreeVector unitAxis9 = z9.cross(d09); + unitAxis9 = unitAxis9/unitAxis9.mag(); + G4double ux9 = unitAxis9.x(); + G4double uy9 = unitAxis9.y(); + G4double uz9 = unitAxis9.z(); + G4ThreeVector top9 = G4ThreeVector(cos(-coneangle9)+pow(ux9,2)*(1-cos(-coneangle9)), ux9*uy9*(1-cos(-coneangle9))-uz9*sin(-coneangle9), ux9*uz9*(1-cos(-coneangle9))+uy9*sin(-coneangle9)); + G4ThreeVector mid9 = G4ThreeVector(uy9*ux9*(1-cos(-coneangle9))+uz9*sin(-coneangle9), cos(-coneangle9)+pow(uy9,2)*(1-cos(-coneangle9)), uy9*uz9*(1-cos(-coneangle9))-ux9*sin(-coneangle9)); + G4ThreeVector bot9 = G4ThreeVector(uz9*ux9*(1-cos(-coneangle9))-uy9*sin(-coneangle9), uz9*uy9*(1-cos(-coneangle9))+ux9*sin(-coneangle9), cos(-coneangle9)+pow(uz9,2)*(1-cos(-coneangle9))); + G4RotationMatrix firstBox_rotm9 = G4RotationMatrix(); + firstBox_rotm9.setRows(top9,mid9,bot9); + G4ThreeVector firstBox_pos9 = G4ThreeVector(0,0,0); + G4Transform3D firstBox_trans9 = G4Transform3D(firstBox_rotm9, firstBox_pos9); + G4RotationMatrix secondBox_rotm9 = G4RotationMatrix(); + secondBox_rotm9.setRows(top9,mid9,bot9); + G4ThreeVector secondBox_pos9 = (2*distanceFromTarget9+detThickness9)/d09.mag()*d09; + G4Transform3D secondBox_trans9 = G4Transform3D(secondBox_rotm9, secondBox_pos9); + + G4Orb* solidTip9 = + new G4Orb("tip9", + .0001*mm); + G4Box* solidSubtractionBox9 = + new G4Box("SubtractionBox9", //its name + distanceFromTarget9, + distanceFromTarget9, + distanceFromTarget9); //its size + G4Cons* solidCone9 = + new G4Cons("Cone9", //its name + crystal_rmina9, crystal_rmaxa9, + crystal_rminb9, crystal_rmaxb9, + crystal_hz9, + crystal_phimin9, crystal_phimax9); //its size + G4UnionSolid* solidTippedCone9 = + new G4UnionSolid("TippedCone9", + solidTip9, + solidCone9, + tip_trans9); + G4SubtractionSolid* solidIntermediate9 = + new G4SubtractionSolid("Intermediate9", + solidTippedCone9, + solidSubtractionBox9, + firstBox_trans9); + G4SubtractionSolid* solidCrystal9 = + new G4SubtractionSolid("Crystal9", + solidIntermediate9, + solidSubtractionBox9, + secondBox_trans9); + + G4LogicalVolume* logicCrystal9 = + new G4LogicalVolume(solidCrystal9, //its solid + CsI, //its material + "CsI Detector9"); //its name + logicCrystal9->SetVisAttributes(crystalVisAtt); + logicCrystal9->SetSensitiveDetector(m_MicroballScorer); + + // + // Light Guide + // + G4double lightGuide_px9 = 10*mm; + G4double lightGuide_py9 = 10*mm; + G4double lightGuide_pz9 = lgThickness9; + G4Box* solidLightGuide9 = + new G4Box("LightGuide9", //its name + 0.5*lightGuide_px9, + 0.5*lightGuide_py9, + 0.5*lightGuide_pz9); //its size + + G4LogicalVolume* logicLightGuide9 = + new G4LogicalVolume(solidLightGuide9, //its solid + glass, //its material + "LightGuide9"); //its name + logicLightGuide9->SetVisAttributes(lightGuideVisAtt); + + + for(int i = 1; i <= detNum9; i++) + { + G4RotationMatrix crystal_rotm = G4RotationMatrix(); + G4ThreeVector d0 = G4ThreeVector(distanceFromTarget9*sin(coneangle9)*cos(0.5*360*deg/detNum9), + distanceFromTarget9*sin(coneangle9)*sin(0.5*360*deg/detNum9), + distanceFromTarget9*cos(coneangle9)); + G4ThreeVector df = G4ThreeVector(distanceFromTarget9*sin(theta9)*sin((i-1)*360*deg/detNum9+.001*deg/*+0.5*360*deg/detNum9*/), + distanceFromTarget9*sin(theta9)*cos((i-1)*360*deg/detNum9+.001*deg/*+0.5*360*deg/detNum9*/), + -distanceFromTarget9*cos(theta9)); + df.setX(-df.x()); + G4ThreeVector axis = d0.cross(df); + G4double ax = axis.x(); + G4double ay = axis.y(); + G4double az = axis.z(); + G4double ux = ax/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double uy = ay/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double uz = az/pow((pow(ax,2)+pow(ay,2)+pow(az,2)),0.5); + G4double j = acos(d0.dot(df)/(d0.mag()*df.mag())); + G4ThreeVector a = G4ThreeVector(cos(j)+pow(ux,2)*(1-cos(j)), ux*uy*(1-cos(j))-uz*sin(j), ux*uz*(1-cos(j))+uy*sin(j)); + G4ThreeVector b = G4ThreeVector(uy*ux*(1-cos(j))+uz*sin(j), cos(j)+pow(uy,2)*(1-cos(j)), uy*uz*(1-cos(j))-ux*sin(j)); + G4ThreeVector c = G4ThreeVector(uz*ux*(1-cos(j))-uy*sin(j), uz*uy*(1-cos(j))+ux*sin(j), cos(j)+pow(uz,2)*(1-cos(j))); + G4RotationMatrix abc = G4RotationMatrix(); + abc.setRows(a,b,c); + G4ThreeVector unitdf = df/df.mag(); + G4double udfx = unitdf.x(); + G4double udfy = unitdf.y(); + G4double udfz = unitdf.z(); + G4double k = 180.*deg; + G4ThreeVector d = G4ThreeVector(cos(k)+pow(udfx,2)*(1-cos(k)), udfx*udfy*(1-cos(k))-udfz*sin(k), udfx*udfz*(1-cos(k))+udfy*sin(k)); + G4ThreeVector e = G4ThreeVector(udfy*udfx*(1-cos(k))+udfz*sin(k), cos(k)+pow(udfy,2)*(1-cos(k)), udfy*udfz*(1-cos(k))-udfx*sin(k)); + G4ThreeVector f = G4ThreeVector(udfz*udfx*(1-cos(k))-udfy*sin(k), udfz*udfy*(1-cos(k))+udfx*sin(k), cos(k)+pow(udfz,2)*(1-cos(k))); + G4RotationMatrix def = G4RotationMatrix(); + def.setRows(d,e,f); + crystal_rotm=def*abc; + if (m_Flip == 1){ + crystal_rotm.rotateY(180*deg); + } + crystal_rotm.rotateZ(180*deg); + G4ThreeVector crystal_pos = G4ThreeVector(0,0,0); + G4Transform3D crystal_trans = G4Transform3D(crystal_rotm, crystal_pos); + df.setX(-df.x()); + G4RotationMatrix lg_rotm = G4RotationMatrix(); + /* + lg_rotm.rotateZ((i-1)*360*deg/detNum9); + G4ThreeVector lg_pos = G4ThreeVector((distance9+detThickness9+0.5*lgThickness9)*cos(i*360*deg/detNum9), + (distance9+detThickness9+0.5*lgThickness9)*sin(i*360*deg/detNum9), + 0)+delrin_pos9; + */ + G4ThreeVector lg_Axis = df.cross(z9); + lg_Axis = lg_Axis/lg_Axis.mag(); + lg_Axis.rotateZ(180*deg); + G4double ulgx = lg_Axis.x(); + G4double ulgy = lg_Axis.y(); + G4double ulgz = lg_Axis.z(); + G4ThreeVector p = G4ThreeVector(cos(theta9)+pow(ulgx,2)*(1-cos(theta9)), ulgx*ulgy*(1-cos(theta9))-ulgz*sin(theta9), ulgx*ulgz*(1-cos(theta9))+ulgy*sin(theta9)); + G4ThreeVector q = G4ThreeVector(ulgy*ulgx*(1-cos(theta9))+ulgz*sin(theta9), cos(theta9)+pow(ulgy,2)*(1-cos(theta9)), ulgy*ulgz*(1-cos(theta9))-ulgx*sin(theta9)); + G4ThreeVector r = G4ThreeVector(ulgz*ulgx*(1-cos(theta9))-ulgy*sin(theta9), ulgz*ulgy*(1-cos(theta9))+ulgx*sin(theta9), cos(theta9)+pow(ulgz,2)*(1-cos(theta9))); + G4RotationMatrix pqr = G4RotationMatrix(); + pqr.setRows(p,q,r); + lg_rotm.rotateZ((i-1)*360*deg/detNum9); + lg_rotm.rotateX(180*deg); + lg_rotm=pqr*lg_rotm; + G4ThreeVector lg_pos = (distanceFromTarget9+detThickness9+0.5*lgThickness9+.0003*mm)/df.mag()*df; + lg_pos.rotateZ(180*deg); + if (m_Flip == 0){ + lg_pos.rotateY(180*deg); + lg_rotm.rotateY(180*deg); + } + G4Transform3D lg_trans = G4Transform3D(lg_rotm, lg_pos); + G4RotationMatrix delrin_rotm = G4RotationMatrix(); + G4ThreeVector w = G4ThreeVector(sin(theta9)*sin((i-1)*360*deg/detNum9+.001*deg), sin(theta9)*cos((i-1)*360*deg/detNum9+.001*deg), cos(theta9)); + G4ThreeVector delrin_Axis = w.cross(z9); + delrin_Axis.rotateX(180*deg); + delrin_Axis = delrin_Axis/delrin_Axis.mag(); + G4double udx = delrin_Axis.x(); + G4double udy = delrin_Axis.y(); + G4double udz = delrin_Axis.z(); + G4double delAng = -90*deg+theta9; + G4ThreeVector pdel = G4ThreeVector(cos(delAng)+pow(udx,2)*(1-cos(delAng)), udx*udy*(1-cos(delAng))-udz*sin(delAng), udx*udz*(1-cos(delAng))+udy*sin(delAng)); + G4ThreeVector qdel = G4ThreeVector(udy*udx*(1-cos(delAng))+udz*sin(delAng), cos(delAng)+pow(udy,2)*(1-cos(delAng)), udy*udz*(1-cos(delAng))-udx*sin(delAng)); + G4ThreeVector rdel = G4ThreeVector(udz*udx*(1-cos(delAng))-udy*sin(delAng), udz*udy*(1-cos(delAng))+udx*sin(delAng), cos(delAng)+pow(udz,2)*(1-cos(delAng))); + G4RotationMatrix pqrdel = G4RotationMatrix(); + pqrdel.setRows(pdel,qdel,rdel); + delrin_rotm.rotateZ((-i+1)*360*deg/detNum9+.001*deg); + delrin_rotm.rotateX(180*deg); + delrin_rotm=pqrdel*delrin_rotm; + delrin_rotm.rotateZ(0*deg); + G4ThreeVector delrin_pos = (distanceFromTarget9+detThickness9+lgThickness9+delrinA9/2+.0005*mm)/df.mag()*df; //the .0003 mm is a fudge factor to prevent overlapping + delrin_pos.rotateZ(180*deg); + delrin_pos.rotateY(180*deg); + if (m_Flip == 1){ + delrin_pos.rotateY(180*deg); + delrin_rotm.rotateY(180*deg); + } + G4Transform3D delrin_trans = G4Transform3D(delrin_rotm, delrin_pos); + bool placeCrystal = true; + for (unsigned int i2=0; i2 < m_Array.size(); i2++){ + if (90 < m_Array[i2] && m_Array[i2] < 97){ + if (m_Array[i2] == 90+i){ + placeCrystal = false; + } + } + } + if (placeCrystal){ + if(crystalBool) {new G4PVPlacement(crystal_trans, //rotation, position + logicCrystal9, //its logical volume + "CsI Detector9", //its name + world, //its mother volume + false, //no boolean operation + 90+i, //copy number + checkOverlaps); //overlaps checking + } + } + if (placeCrystal){ + if(lgBool) {new G4PVPlacement(lg_trans, //rotation, position + logicLightGuide9, //its logical volume + "LightGuide9", //its name + world, //its mother volume + false, //no boolean operation + 90+i, //copy number + checkOverlaps); //overlaps checking + } + if(delrinBool) {new G4PVPlacement(delrin_trans, //rotation, position + logicDelrin9, //its logical volume + "Delrin9", //its name + world, //its mother volume + false, //no boolean operation + 90+i, //copy number + checkOverlaps); //overlaps checking + } + } + }} } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method void Microball::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - pTree->Branch("Microball", "TMicroballData", &m_Event) ; - pTree->SetBranchAddress("Microball", &m_Event) ; + RootOutput *pAnalysis = RootOutput::getInstance(); + TTree *pTree = pAnalysis->GetTree(); + pTree->Branch("Microball", "TMicroballData", &m_Event) ; + pTree->SetBranchAddress("Microball", &m_Event) ; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion void Microball::ReadSensitive(const G4Event* event){ - m_Event->Clear(); - - /////////// - // Calorimeter scorer - G4THitsMap<G4double*>* CaloHitMap; - std::map<G4int, G4double**>::iterator Calo_itr; - - G4int CaloCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("MicroballScorer/Calorimeter"); - CaloHitMap = (G4THitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(CaloCollectionID)); - - // Loop on the Calo map - for (Calo_itr = CaloHitMap->GetMap()->begin() ; Calo_itr != CaloHitMap->GetMap()->end() ; Calo_itr++){ - - G4double* Info = *(Calo_itr->second); - //(Info[0]/2.35)*((Info[0]*1.02)*pow((Info[0]*1.8),.5)) - // double Energy = RandGauss::shoot(Info[0],((Info[0]*1000*1.02/2.35)*pow((Info[0]*1000*1.8),.5)) ); - double Energy = RandGauss::shoot(Info[0],Microball_NS::ResoEnergy); - if(Energy>Microball_NS::EnergyThreshold){ - double Time = RandGauss::shoot(Info[1],Microball_NS::ResoTime); - int DetectorNbr = (int) Info[7]; - m_Event->SetEnergy(DetectorNbr,Energy); - m_Event->SetTime(DetectorNbr,Time); - - ms_InterCoord->SetDetectedPositionX(Info[2]) ; - ms_InterCoord->SetDetectedPositionY(Info[3]) ; - ms_InterCoord->SetDetectedPositionZ(Info[4]) ; - ms_InterCoord->SetDetectedAngleTheta(Info[5]/deg) ; - ms_InterCoord->SetDetectedAnglePhi(Info[6]/deg) ; + m_Event->Clear(); + + /////////// + // Calorimeter scorer + G4THitsMap<G4double*>* CaloHitMap; + std::map<G4int, G4double**>::iterator Calo_itr; + + G4int CaloCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("MicroballScorer/Calorimeter"); + CaloHitMap = (G4THitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(CaloCollectionID)); + + // Loop on the Calo map + for (Calo_itr = CaloHitMap->GetMap()->begin() ; Calo_itr != CaloHitMap->GetMap()->end() ; Calo_itr++){ + + G4double* Info = *(Calo_itr->second); + //(Info[0]/2.35)*((Info[0]*1.02)*pow((Info[0]*1.8),.5)) + // double Energy = RandGauss::shoot(Info[0],((Info[0]*1000*1.02/2.35)*pow((Info[0]*1000*1.8),.5)) ); + double Energy = RandGauss::shoot(Info[0],Microball_NS::ResoEnergy); + if(Energy>Microball_NS::EnergyThreshold){ + double Time = RandGauss::shoot(Info[1],Microball_NS::ResoTime); + int DetectorNbr = (int) Info[7]; + m_Event->SetEnergy(DetectorNbr,Energy); + m_Event->SetTime(DetectorNbr,Time); + + ms_InterCoord->SetDetectedPositionX(Info[2]) ; + ms_InterCoord->SetDetectedPositionY(Info[3]) ; + ms_InterCoord->SetDetectedPositionZ(Info[4]) ; + ms_InterCoord->SetDetectedAngleTheta(Info[5]/deg) ; + ms_InterCoord->SetDetectedAnglePhi(Info[6]/deg) ; + } } - } - // clear map for next event - CaloHitMap->clear(); + // clear map for next event + CaloHitMap->clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////// void Microball::InitializeScorers() { - // This check is necessary in case the geometry is reloaded - bool already_exist = false; - m_MicroballScorer = CheckScorer("MicroballScorer",already_exist) ; - - if(already_exist) - return ; - - // Otherwise the scorer is initialised - vector<int> level; level.push_back(0); - G4VPrimitiveScorer* Calorimeter= new CALORIMETERSCORERS::PS_CalorimeterWithInteraction("Calorimeter",level, 0) ; - //and register it to the multifunctionnal detector - m_MicroballScorer->RegisterPrimitive(Calorimeter); - G4SDManager::GetSDMpointer()->AddNewDetector(m_MicroballScorer) ; + // This check is necessary in case the geometry is reloaded + bool already_exist = false; + m_MicroballScorer = CheckScorer("MicroballScorer",already_exist) ; + + if(already_exist) + return ; + + // Otherwise the scorer is initialised + vector<int> level; level.push_back(0); + G4VPrimitiveScorer* Calorimeter= new CALORIMETERSCORERS::PS_CalorimeterWithInteraction("Calorimeter",level, 0) ; + //and register it to the multifunctionnal detector + m_MicroballScorer->RegisterPrimitive(Calorimeter); + G4SDManager::GetSDMpointer()->AddNewDetector(m_MicroballScorer) ; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -2998,7 +3199,7 @@ void Microball::InitializeScorers() { // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// NPS::VDetector* Microball::Construct(){ - return (NPS::VDetector*) new Microball(); + return (NPS::VDetector*) new Microball(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -3006,13 +3207,13 @@ NPS::VDetector* Microball::Construct(){ // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// extern"C" { - class proxy_nps_plastic{ + class proxy_nps_plastic{ public: - proxy_nps_plastic(){ - NPS::DetectorFactory::getInstance()->AddToken("Microball","Microball"); - NPS::DetectorFactory::getInstance()->AddDetector("Microball",Microball::Construct); - } - }; - - proxy_nps_plastic p_nps_plastic; + proxy_nps_plastic(){ + NPS::DetectorFactory::getInstance()->AddToken("Microball","Microball"); + NPS::DetectorFactory::getInstance()->AddDetector("Microball",Microball::Construct); + } + }; + + proxy_nps_plastic p_nps_plastic; } diff --git a/NPSimulation/Detectors/Microball/Microball.hh b/NPSimulation/Detectors/Microball/Microball.hh index c5167728fe2ebb63f0a23999ed2294e63ba910c1..76a981b58794bc610462e6478a5a2a5be9e4ab83 100644 --- a/NPSimulation/Detectors/Microball/Microball.hh +++ b/NPSimulation/Detectors/Microball/Microball.hh @@ -52,7 +52,7 @@ class Microball : public NPS::VDetector{ void AddMicroball(bool bR1, bool bR2, bool bR3, bool bR4, bool bR5, bool bR6, bool bR7, bool bR8, bool bR9, - vector<int>, bool bFlip); + vector<int>, bool bFlip, bool bChamber); G4LogicalVolume* BuildSquareDetector(); G4LogicalVolume* BuildCylindricalDetector(); @@ -115,6 +115,7 @@ class Microball : public NPS::VDetector{ bool m_Ring9; vector<int> m_Array; bool m_Flip; + bool m_Chamber; // Visualisation Attribute G4VisAttributes* m_VisSquare; diff --git a/NPSimulation/Detectors/Plastic/Plastic.cc b/NPSimulation/Detectors/Plastic/Plastic.cc index 678c40a80c7b4874dad10ff33fe2b988a34533ab..0ff855c1021476bd46e53d96505d548de7ec0a03 100644 --- a/NPSimulation/Detectors/Plastic/Plastic.cc +++ b/NPSimulation/Detectors/Plastic/Plastic.cc @@ -57,8 +57,8 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... namespace PLASTIC{ // Energy and time Resolution - const G4double ResoTime = 4.2 ;// = 10ns of Resolution // Unit is MeV/2.35 - const G4double ResoEnergy = 5.0 ;// Resolution in % + const G4double ResoTime = 1. ;// Resolution in ns // + const G4double ResoEnergy = 0.1 ;// Resolution in % } using namespace PLASTIC ; diff --git a/NPSimulation/PhysicsListOption.txt b/NPSimulation/PhysicsListOption.txt index 185d5fb6fa13bde97eaa1fa79c256d8dda8b9ca1..d547292bc17a5fc6c324ba0dad28976f75013dab 100644 --- a/NPSimulation/PhysicsListOption.txt +++ b/NPSimulation/PhysicsListOption.txt @@ -1,11 +1,11 @@ EmPhysicsList Option4 DefaultCutOff 1 IonBinaryCascadePhysics 0 -LocalIonInelasticPhysics 0 +LocalIonInelasticPhysics 1 EmExtraPhysics 0 -HadronElasticPhysics 0 +HadronElasticPhysics 0 StoppingPhysics 0 OpticalPhysics 0 HadronPhysicsINCLXX 0 HadronPhysicsQGSP_BIC_HP 0 -Decay 0 +Decay 1 diff --git a/NPSimulation/Simulation.cc b/NPSimulation/Simulation.cc index b38ca713cf9bb182ccdebb74e1d790a842e625e2..c112cf196987a73123455520293e322935127173 100644 --- a/NPSimulation/Simulation.cc +++ b/NPSimulation/Simulation.cc @@ -109,6 +109,7 @@ int main(int argc, char** argv){ RunAction* run_action = new RunAction() ; runManager->SetUserAction(run_action); + G4VisManager* visManager=NULL; if(!OptionManager->GetG4BatchMode()){ #ifdef G4UI_USE diff --git a/NPSimulation/ressources/macro/vis.mac b/NPSimulation/ressources/macro/vis.mac index 907f4973cae278d85c7785f7542c45722a838791..92af7f26c9d34f792535ef59c05e8ece10308527 100644 --- a/NPSimulation/ressources/macro/vis.mac +++ b/NPSimulation/ressources/macro/vis.mac @@ -10,6 +10,8 @@ /cuts/verbose 0 /process/em/verbose 0 /process/eLoss/verbose 0 + +#/process/list # # Use this open statement to create an OpenGL view: /vis/open OGLI 1200x600-0+0 @@ -47,8 +49,8 @@ /vis/viewer/set/autoRefresh true /vis/verbose 0 -/vis/viewer/set/background black -#/vis/viewer/set/background white +#/vis/viewer/set/background black +/vis/viewer/set/background white # print Option #/vis/ogl/set/printMode vectored