From 20476dac18c71bd9ad905594ae6aef49fbad8036 Mon Sep 17 00:00:00 2001
From: Oliver Kirsebom <oliver.kirsebom@gmail.com>
Date: Thu, 11 Jan 2018 18:27:34 -0400
Subject: [PATCH] next step: implement SetBetaDetectorV2On and
 SetMuonTelescopeOn methods in DetectorConstruct

---
 include/VKDetectorConstruction.hh | 14 +++++-
 include/VKDetectorMessenger.hh    |  2 +
 mac/electron.mac                  | 82 +++++++++++++++----------------
 src/VKBetaDetectorV2.cpp          | 37 ++++++++++++--
 src/VKDetectorConstruction.cpp    | 13 +++++
 src/VKDetectorMessenger.cpp       | 22 ++++++++-
 6 files changed, 122 insertions(+), 48 deletions(-)

diff --git a/include/VKDetectorConstruction.hh b/include/VKDetectorConstruction.hh
index d12a6a2..176ae8e 100644
--- a/include/VKDetectorConstruction.hh
+++ b/include/VKDetectorConstruction.hh
@@ -75,11 +75,23 @@ class VKDetectorConstruction : public G4VUserDetectorConstruction
     void SetMagnetOn(G4bool b);
 
     /*
-     * Add or remove the beta detector from setup 
+     * Add or remove the beta detector (v1.0) from setup 
      * @param b If true, detector is created. If false, detector is removed/not created
      */
     void SetBetaDetectorOn(G4bool b);
 
+    /*
+     * Add or remove the beta detector (v2.0) from setup 
+     * @param b If true, detector is created. If false, detector is removed/not created
+     */
+    void SetBetaDetectorV2On(G4bool b);
+
+    /*
+     * Add or remove the muon telescope from setup 
+     * @param b If true, telescope is created. If false, telescope is removed/not created
+     */
+    void SetMuonTelescopeOn(G4bool b);
+
     /*
      * Add or remove the catcher foil from the setup 
      * @param b If true, catcher foil is created. If false, catcher foil is removed/not created
diff --git a/include/VKDetectorMessenger.hh b/include/VKDetectorMessenger.hh
index e2a2dff..0be8dec 100644
--- a/include/VKDetectorMessenger.hh
+++ b/include/VKDetectorMessenger.hh
@@ -55,6 +55,8 @@ class VKDetectorMessenger: public G4UImessenger
     G4UIdirectory *fFieldDir;
     G4UIcmdWithABool *fMagnetCmd;
     G4UIcmdWithABool *fBetaDetectorCmd;
+    G4UIcmdWithABool *fBetaDetectorV2Cmd;
+    G4UIcmdWithABool *fMuonTelescopeCmd;
     G4UIcmdWithABool *fCatcherFoilCmd;
     G4UIcmdWithABool *fShieldCmd;
     G4UIcmdWithABool *fLeadBlockCmd;
diff --git a/mac/electron.mac b/mac/electron.mac
index ea9387a..345713e 100644
--- a/mac/electron.mac
+++ b/mac/electron.mac
@@ -21,60 +21,60 @@
 /gps/energy 975.657 keV
 #/gps/energy 1682.232 keV
 
-/VK/field/maxbfield 0.0700 tesla
-/VK/output/openFile output/scan/e2/bmax0700.root                
+/VK/field/maxbfield 0.12 tesla
+/VK/output/openFile output/test.root                
 /run/beamOn 10000
 
-/VK/field/maxbfield 0.0750 tesla
-/VK/output/openFile output/scan/e2/bmax0750.root                
-/run/beamOn 10000
+#/VK/field/maxbfield 0.0750 tesla
+#/VK/output/openFile output/scan/e2/bmax0750.root                
+#/run/beamOn 10000
 
-/VK/field/maxbfield 0.0800 tesla
-/VK/output/openFile output/scan/e2/bmax0800.root                
-/run/beamOn 10000
+#/VK/field/maxbfield 0.0800 tesla
+#/VK/output/openFile output/scan/e2/bmax0800.root                
+#/run/beamOn 10000
 
-/VK/field/maxbfield 0.0850 tesla
-/VK/output/openFile output/scan/e2/bmax0850.root                
-/run/beamOn 10000
+#/VK/field/maxbfield 0.0850 tesla
+#/VK/output/openFile output/scan/e2/bmax0850.root                
+#/run/beamOn 10000
 
-/VK/field/maxbfield 0.0900 tesla
-/VK/output/openFile output/scan/e2/bmax0900.root                
-/run/beamOn 10000
+#/VK/field/maxbfield 0.0900 tesla
+#/VK/output/openFile output/scan/e2/bmax0900.root                
+#/run/beamOn 10000
 
-/VK/field/maxbfield 0.0950 tesla
-/VK/output/openFile output/scan/e2/bmax0950.root                
-/run/beamOn 10000
+#/VK/field/maxbfield 0.0950 tesla
+#/VK/output/openFile output/scan/e2/bmax0950.root                
+#/run/beamOn 10000
 
-/VK/field/maxbfield 0.1000 tesla
-/VK/output/openFile output/scan/e2/bmax1000.root                
-/run/beamOn 10000
+#/VK/field/maxbfield 0.1000 tesla
+#/VK/output/openFile output/scan/e2/bmax1000.root                
+#/run/beamOn 10000
 
-/VK/field/maxbfield 0.1050 tesla
-/VK/output/openFile output/scan/e2/bmax1050.root                
-/run/beamOn 10000
+#/VK/field/maxbfield 0.1050 tesla
+#/VK/output/openFile output/scan/e2/bmax1050.root                
+#/run/beamOn 10000
 
-/VK/field/maxbfield 0.1100 tesla
-/VK/output/openFile output/scan/e2/bmax1100.root                
-/run/beamOn 10000
+#/VK/field/maxbfield 0.1100 tesla
+#/VK/output/openFile output/scan/e2/bmax1100.root                
+#/run/beamOn 10000
 
-/VK/field/maxbfield 0.1150 tesla
-/VK/output/openFile output/scan/e2/bmax1150.root                
-/run/beamOn 10000
+#/VK/field/maxbfield 0.1150 tesla
+#/VK/output/openFile output/scan/e2/bmax1150.root                
+#/run/beamOn 10000
 
-/VK/field/maxbfield 0.1200 tesla
-/VK/output/openFile output/scan/e2/bmax1200.root                
-/run/beamOn 10000
+#/VK/field/maxbfield 0.1200 tesla
+#/VK/output/openFile output/scan/e2/bmax1200.root                
+#/run/beamOn 10000
 
-/VK/field/maxbfield 0.1250 tesla
-/VK/output/openFile output/scan/e2/bmax1250.root                
-/run/beamOn 10000
+#/VK/field/maxbfield 0.1250 tesla
+#/VK/output/openFile output/scan/e2/bmax1250.root                
+#/run/beamOn 10000
 
-/VK/field/maxbfield 0.1300 tesla
-/VK/output/openFile output/scan/e2/bmax1300.root                
-/run/beamOn 10000
+#/VK/field/maxbfield 0.1300 tesla
+#/VK/output/openFile output/scan/e2/bmax1300.root                
+#/run/beamOn 10000
 
-/VK/field/maxbfield 0.1350 tesla
-/VK/output/openFile output/scan/e2/bmax1350.root                
-/run/beamOn 10000
+#/VK/field/maxbfield 0.1350 tesla
+#/VK/output/openFile output/scan/e2/bmax1350.root                
+#/run/beamOn 10000
 
 
diff --git a/src/VKBetaDetectorV2.cpp b/src/VKBetaDetectorV2.cpp
index 4a68baa..3e149d5 100644
--- a/src/VKBetaDetectorV2.cpp
+++ b/src/VKBetaDetectorV2.cpp
@@ -34,6 +34,13 @@
 #include "G4PhysicalVolumeStore.hh"
 
 /*
+ * -------------------------------------------------------------
+ * OBS!!! In this simplified GEANT4 model of the detector, 
+ *        no SiPMs have been attached to the FRONT detector. 
+ *        Also, no reflective layer has been inserted at the 
+ *        interface of the FRONT and SIGNAL detectors.
+ * -------------------------------------------------------------
+ * 
  * The beta detector consists of stacked, cylindrical FRONT 
  * and SIGNAL detectors surrounded by a cup-shaped active 
  * cosmic-ray VETO shield.  
@@ -123,6 +130,23 @@ VKBetaDetectorV2::VKBetaDetectorV2(G4RotationMatrix *pRot,
     fContainer_log = new G4LogicalVolume(fContainer_sol, fLabVacuum, "betaDetector_log");
     
     
+    // ----------------------------------------------- //
+    //                 FRONT scintillator             //
+    // ----------------------------------------------- //
+
+    // solid
+    fFront_sol = new G4Tubs("front_sol", 0., fFrontDiameter/2, 
+                              fFrontLength/2, 0.*deg, 360.*deg);
+
+    // logical                     
+    fFront_log = new G4LogicalVolume(fFront_sol, fEJ200, "front_log");
+
+    // physical
+    displ = -(fContainerLength - fFrontLength)/2 + fReflectorThickness;
+    pos   = G4ThreeVector(0, 0, displ);
+    new G4PVPlacement(0, pos, fFront_log, "front", fContainer_log, false, 0, fCheckOverlaps);
+
+
     // ----------------------------------------------- //
     //                 SIGNAL scintillator             //
     // ----------------------------------------------- //
@@ -135,7 +159,8 @@ VKBetaDetectorV2::VKBetaDetectorV2(G4RotationMatrix *pRot,
     fSignal_log = new G4LogicalVolume(fSignal_sol, fEJ200, "signal_log");
 
     // physical
-    displ = -(fContainerLength - fSignalLength)/2 + fReflectorThickness;
+    displ = -(fContainerLength - fSignalLength)/2 + fReflectorThickness
+            + fFrontLength;  //+ fReflectorThickness;
     pos   = G4ThreeVector(0, 0, displ);
     new G4PVPlacement(0, pos, fSignal_log, "signal", fContainer_log, false, 0, fCheckOverlaps);
     
@@ -269,8 +294,10 @@ void VKBetaDetectorV2::SetDefaults()
     fCheckOverlaps       = fDetConstr -> GetCheckOverlaps();
     
     // dimensions
+    fFrontDiameter       = 45*mm; 
+    fFrontLength         =  5*mm;
     fSignalDiameter      = 45*mm; 
-    fSignalLength        = 45*mm;
+    fSignalLength        = 40*mm;
     fReflectorThickness  = 0.5*mm;
     fVetoThickness       = 5*mm;
     fVetoLength          = 75*mm;
@@ -282,8 +309,8 @@ void VKBetaDetectorV2::SetDefaults()
     fSiPMLength   = 10*mm;
     
     // deduce container size
-    fContainerDiameter   = 2*(fSignalDiameter/2 + 2*fReflectorThickness + fVetoThickness);
-    fContainerLength     = fVetoLength + fReflectorThickness + fSiPMLength;
+    fContainerDiameter = 2*(fSignalDiameter/2 + 2*fReflectorThickness + fVetoThickness);
+    fContainerLength   = fVetoLength + fReflectorThickness + fSiPMLength;
     
     // coating reflectivity
     fRefl = fDetConstr -> GetCoatingReflectivity();
@@ -393,7 +420,7 @@ void VKBetaDetectorV2::ConstructCoatingSolid( G4double& displ )
     G4Tubs* c2     = new G4Tubs("coating2_sol", r2min, r2max, l2/2, 0.*deg, 360.*deg);
 
     // relative placement of 1 and 2
-    dz = (l2-l1)/2 + fSignalLength + l2;
+    dz = (l2-l1)/2 + fSignalLength + fFrontLength + l2;
     translation = G4ThreeVector(0, 0, dz); 
     transform = G4Transform3D(doNotRotate, translation);
 
diff --git a/src/VKDetectorConstruction.cpp b/src/VKDetectorConstruction.cpp
index 54ee73a..4295ff7 100644
--- a/src/VKDetectorConstruction.cpp
+++ b/src/VKDetectorConstruction.cpp
@@ -28,6 +28,7 @@
 #include "VKMaterials.hh"
 #include "VKMagnet.hh"
 #include "VKBetaDetector.hh"
+#include "VKBetaDetectorV2.hh"
 #include "VKCatcherFoil.hh"
 #include "VKShield.hh"
 #include "VKLeadBlock.hh"
@@ -313,6 +314,18 @@ void VKDetectorConstruction::SetBetaDetectorOn(G4bool b)
 }
 
 
+void VKDetectorConstruction::SetBetaDetectorV2On(G4bool b) 
+{   
+    // not implemented yet !!!
+}
+
+
+void VKDetectorConstruction::SetMuonTelescopeOn(G4bool b) 
+{   
+    // not implemented yet !!!
+}
+
+
 void VKDetectorConstruction::SetCatcherFoilOn(G4bool b) 
 {
     fCatcherFoilOn = b;
diff --git a/src/VKDetectorMessenger.cpp b/src/VKDetectorMessenger.cpp
index 59355b1..c54fe13 100644
--- a/src/VKDetectorMessenger.cpp
+++ b/src/VKDetectorMessenger.cpp
@@ -53,10 +53,20 @@ VKDetectorMessenger::VKDetectorMessenger(VKDetectorConstruction* pDetConstr)
     fMagnetCmd->SetToBeBroadcasted(false);
 
     fBetaDetectorCmd = new G4UIcmdWithABool("/VK/detector/volumes/betaDetector", this);
-    fBetaDetectorCmd->SetGuidance("Enable/Disable the beta detector.");
+    fBetaDetectorCmd->SetGuidance("Enable/Disable the old beta detector (v1).");
     fBetaDetectorCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
     fBetaDetectorCmd->SetToBeBroadcasted(false);
 
+    fBetaDetectorV2Cmd = new G4UIcmdWithABool("/VK/detector/volumes/betaDetectorV2", this);
+    fBetaDetectorV2Cmd->SetGuidance("Enable/Disable the new beta detector (v2).");
+    fBetaDetectorV2Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
+    fBetaDetectorV2Cmd->SetToBeBroadcasted(false);
+
+    fMuonTelescopeCmd = new G4UIcmdWithABool("/VK/detector/volumes/muonTelescope", this);
+    fMuonTelescopeCmd->SetGuidance("Enable/Disable the muon telescope.");
+    fMuonTelescopeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
+    fMuonTelescopeCmd->SetToBeBroadcasted(false);
+
     fCatcherFoilCmd = new G4UIcmdWithABool("/VK/detector/volumes/catcherFoil", this);
     fCatcherFoilCmd->SetGuidance("Enable/Disable the catcher foil.");
     fCatcherFoilCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
@@ -109,6 +119,8 @@ VKDetectorMessenger::~VKDetectorMessenger()
 {
     delete fMagnetCmd;
     delete fBetaDetectorCmd;
+    delete fBetaDetectorV2Cmd;
+    delete fMuonTelescopeCmd;
     delete fCatcherFoilCmd;
     delete fShieldCmd;
     delete fLeadBlockCmd;
@@ -130,6 +142,14 @@ void VKDetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
     {
         fDetConstr -> SetBetaDetectorOn(fBetaDetectorCmd -> GetNewBoolValue(newValue));
     }
+    else if (command == fBetaDetectorV2Cmd)
+    {
+        fDetConstr -> SetBetaDetectorV2On(fBetaDetectorV2Cmd -> GetNewBoolValue(newValue));
+    }
+    else if (command == fMuonTelescopeCmd)
+    {
+        fDetConstr -> SetMuonTelescopeOn(fMuonTelescopeCmd -> GetNewBoolValue(newValue));
+    }
     else if (command == fCatcherFoilCmd)
     {
         fDetConstr -> SetCatcherFoilOn(fCatcherFoilCmd -> GetNewBoolValue(newValue));
-- 
GitLab