From 044f8da8f984b2b20e7c0021dd8d7a7e9f09f40a Mon Sep 17 00:00:00 2001
From: Xythere <xytherex@gmail.com>
Date: Fri, 13 Dec 2024 15:51:06 +0100
Subject: [PATCH] adding Micron quadranMSQ25 detector

---
 .../Detectors/quadranMSQ25/quadranMSQ25.cc    | 41 +++++++++++--------
 .../Detectors/quadranMSQ25/quadranMSQ25.hh    | 20 +++++----
 2 files changed, 37 insertions(+), 24 deletions(-)

diff --git a/NPSimulation/Detectors/quadranMSQ25/quadranMSQ25.cc b/NPSimulation/Detectors/quadranMSQ25/quadranMSQ25.cc
index 64597a7a8..dede78662 100644
--- a/NPSimulation/Detectors/quadranMSQ25/quadranMSQ25.cc
+++ b/NPSimulation/Detectors/quadranMSQ25/quadranMSQ25.cc
@@ -69,7 +69,7 @@ quadranMSQ25::quadranMSQ25() {
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 quadranMSQ25::~quadranMSQ25() {}
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-void quadranMSQ25::AddTelescope(G4ThreeVector TL, G4ThreeVector BL, G4ThreeVector BR, G4ThreeVector TR) {
+void quadranMSQ25::AddTelescope(G4ThreeVector TL, G4ThreeVector BL, G4ThreeVector BR, G4ThreeVector TR, G4double thickness) {
   m_DefinitionType.push_back(true);
 
   m_TL.push_back(TL);
@@ -83,9 +83,11 @@ void quadranMSQ25::AddTelescope(G4ThreeVector TL, G4ThreeVector BL, G4ThreeVecto
   m_beta_u.push_back(0);
   m_beta_v.push_back(0);
   m_beta_w.push_back(0);
+
+  m_thickness.push_back(thickness);
 }
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-void quadranMSQ25::AddTelescope(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, G4double beta_w) {
+void quadranMSQ25::AddTelescope(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, G4double beta_w, G4double thickness) {
   G4ThreeVector empty = G4ThreeVector(0, 0, 0);
 
   m_DefinitionType.push_back(false);
@@ -101,16 +103,19 @@ void quadranMSQ25::AddTelescope(G4double R, G4double Theta, G4double Phi, G4doub
   m_BL.push_back(empty);
   m_BR.push_back(empty);
   m_TR.push_back(empty);
+
+  m_thickness.push_back(thickness);
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-void quadranMSQ25::VolumeMaker(G4int DetNumber, G4ThreeVector Det_pos, G4RotationMatrix* Det_rot, G4LogicalVolume* world) {
+void quadranMSQ25::VolumeMaker(G4int DetNumber, G4ThreeVector Det_pos, G4RotationMatrix* Det_rot, G4LogicalVolume* world, G4double thick) {
   G4double NbrTelescopes = DetNumber;
   G4String DetectorNumber;
   std::ostringstream Number;
   Number << NbrTelescopes;
   DetectorNumber = Number.str();
 
+  G4VisAttributes* VisAtt1 = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2));
   ////////////////////////////////////////////////////////////////
   /////////General Geometry Parameter Definition /////////////////
   ////////////////////////////////////////////////////////////////
@@ -131,7 +136,6 @@ void quadranMSQ25::VolumeMaker(G4int DetNumber, G4ThreeVector Det_pos, G4Rotatio
       new G4Box(Name + "_Frame", 0.5 * (DetectorSize - SiliconSize) / 2, 0.5 * DetectorSize, 0.5 * FrameThickness * mm);
 
   G4LogicalVolume* logicFrameHorizontal = new G4LogicalVolume(solidFrameHorizontal, m_MaterialAl, Name, 0, 0);
-  G4VisAttributes* VisAtt1 = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2));
   logicFrameHorizontal->SetVisAttributes(VisAtt1);
 
   G4LogicalVolume* logicFrameVertical = new G4LogicalVolume(solidFrameVertical, m_MaterialAl, Name, 0, 0);
@@ -142,13 +146,13 @@ void quadranMSQ25::VolumeMaker(G4int DetNumber, G4ThreeVector Det_pos, G4Rotatio
   G4ThreeVector FrameLeftPosition = G4ThreeVector(0.5 * SiliconSize + 0.5 * (DetectorSize - SiliconSize) / 2, 0, 0);
   G4ThreeVector FrameRightPosition = G4ThreeVector(-0.5 * SiliconSize - 0.5 * (DetectorSize - SiliconSize) / 2, 0, 0);
 
-  new G4PVPlacement(0, FrameTopPosition, logicFrameHorizontal, Name + "_Frame", logicquadranMSQ25, false, DetNumber);
+  new G4PVPlacement(0, FrameTopPosition, logicFrameHorizontal, Name + "_FrameT", logicquadranMSQ25, false, DetNumber);
 
-  new G4PVPlacement(0, FrameBottomPosition, logicFrameHorizontal, Name + "_Frame", logicquadranMSQ25, false, DetNumber);
+  new G4PVPlacement(0, FrameBottomPosition, logicFrameHorizontal, Name + "_FrameH", logicquadranMSQ25, false, DetNumber);
 
-  new G4PVPlacement(0, FrameLeftPosition, logicFrameVertical, Name + "_Frame", logicquadranMSQ25, false, DetNumber);
+  new G4PVPlacement(0, FrameLeftPosition, logicFrameVertical, Name + "_FrameL", logicquadranMSQ25, false, DetNumber);
 
-  new G4PVPlacement(0, FrameRightPosition, logicFrameVertical, Name + "_Frame", logicquadranMSQ25, false, DetNumber);
+  new G4PVPlacement(0, FrameRightPosition, logicFrameVertical, Name + "_FrameR", logicquadranMSQ25, false, DetNumber);
 
   G4ThreeVector posAluFront = G4ThreeVector(0, 0, AluStripFront_PosZ);
   G4ThreeVector posSi = G4ThreeVector(0, 0, 0);
@@ -162,7 +166,7 @@ void quadranMSQ25::VolumeMaker(G4int DetNumber, G4ThreeVector Det_pos, G4Rotatio
 
   new G4PVPlacement(0, posAluBack, logicAlu, Name + "_AluBack", logicquadranMSQ25, true, DetNumber);
 
-  G4Box* solidSi = new G4Box("quadranMSQ25", 0.5 * SiliconSize, 0.5 * SiliconSize, 0.5 * SiliconThickness);
+  G4Box* solidSi = new G4Box("quadranMSQ25", 0.5 * SiliconSize, 0.5 * SiliconSize, 0.5 * thick);
 
   G4LogicalVolume* logicSi = new G4LogicalVolume(solidSi, m_MaterialSilicon, "logicSi", 0, 0, 0);
 
@@ -187,8 +191,8 @@ void quadranMSQ25::ReadConfiguration(NPL::InputParser parser) {
   if (NPOptionManager::getInstance()->GetVerboseLevel())
     cout << "//// " << blocks.size() << " detectors found " << endl;
 
-  vector<string> cart = {"A", "B", "C", "D"};
-  vector<string> sphe = {"R", "THETA", "PHI", "BETA"};
+  vector<string> cart = {"A", "B", "C", "D", "Thickness"};
+  vector<string> sphe = {"R", "THETA", "PHI", "BETA", "Thickness"};
 
   for (unsigned int i = 0; i < blocks.size(); i++) {
     if (blocks[i]->HasTokenList(cart)) {
@@ -198,7 +202,8 @@ void quadranMSQ25::ReadConfiguration(NPL::InputParser parser) {
       G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B", "mm"));
       G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C", "mm"));
       G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D", "mm"));
-      AddTelescope(A, B, C, D);
+      G4double T = blocks[i]->GetDouble("Thickness", "um");
+      AddTelescope(A, B, C, D, T);
     }
     else if (blocks[i]->HasTokenList(sphe)) {
       if (NPOptionManager::getInstance()->GetVerboseLevel())
@@ -207,7 +212,8 @@ void quadranMSQ25::ReadConfiguration(NPL::InputParser parser) {
       double Theta = blocks[i]->GetDouble("THETA", "deg");
       double Phi = blocks[i]->GetDouble("PHI", "deg");
       vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg");
-      AddTelescope(R, Theta, Phi, beta[0], beta[1], beta[2]);
+      G4double T = blocks[i]->GetDouble("Thickness", "um");
+      AddTelescope(R, Theta, Phi, beta[0], beta[1], beta[2], T);
     }
     else {
       cout << "ERROR: check your input file formatting " << endl;
@@ -296,7 +302,7 @@ void quadranMSQ25::ConstructDetector(G4LogicalVolume* world) {
       Det_pos = Det_w + CT;
     }
 
-    VolumeMaker(i + 1, Det_pos, Det_rot, world);
+    VolumeMaker(i + 1, Det_pos, Det_rot, world, m_thickness[i]);
   }
 
   delete Det_rot;
@@ -335,14 +341,15 @@ void quadranMSQ25::ReadSensitive(const G4Event* event) {
     if (Energy > EnergyThreshold) {
       double Time = Info[1];
       int DetNbr = (int)Info[7];
-      int StripFront = (int)Info[8];
+      int striplength = (int)Info[8]-1;
+      int stripwidth  = (int)Info[9]-1;
 
       m_Event->SetEnergyDetectorNbr(DetNbr);
-      m_Event->SetEnergyStripNbr(StripFront);
+      m_Event->SetEnergyStripNbr(striplength*2+stripwidth);
       m_Event->SetEnergy(RandGauss::shoot(Energy, ResoEnergy));
 
       m_Event->SetTimeDetectorNbr(DetNbr);
-      m_Event->SetTimeStripNbr(StripFront);
+      m_Event->SetTimeStripNbr(striplength*2+stripwidth);
       m_Event->SetTime(RandGauss::shoot(Time, ResoTime));
     }
   }
diff --git a/NPSimulation/Detectors/quadranMSQ25/quadranMSQ25.hh b/NPSimulation/Detectors/quadranMSQ25/quadranMSQ25.hh
index 2de0b4f7a..74e2be4b8 100644
--- a/NPSimulation/Detectors/quadranMSQ25/quadranMSQ25.hh
+++ b/NPSimulation/Detectors/quadranMSQ25/quadranMSQ25.hh
@@ -45,13 +45,14 @@ using namespace CLHEP;
 namespace quadranMSQ25_LOCAL{
    // Energy and time Resolution
    const G4double ResoTime    = 0      ; //unchecked
-   const G4double ResoEnergy  = 0.043  ; //unchecked// = 150keV of Resolution   //   Unit is MeV/2.35
+   const G4double ResoEnergy  = 1e-9 ; //unchecked// = 150keV of Resolution   //   Unit is MeV (sigma)
+   // const G4double ResoEnergy  = 20e-3 ; //unchecked// = 150keV of Resolution   //   Unit is MeV (sigma)
    const G4double EnergyThreshold = 100*keV; //unchecked
    // Geometry
-   const G4double DetectorSize      = 70*mm           ;
-   const G4double SiliconThickness  = 500*micrometer  ;
+   const G4double DetectorSize      = 71.12*mm           ;
+   const G4double SiliconThickness  = 800*micrometer  ;
    const G4double FrameThickness    = 3.2*mm          ; 
-   const G4double SiliconSize       = 50*mm           ; //unchecked
+   const G4double SiliconSize       = 50.8*mm           ; //unchecked
    const G4double AluThickness      = 0.3*micrometer  ;
    const G4int  NumberOfStripH       = 2              ;
    const G4int  NumberOfStripL       = 2              ;
@@ -77,21 +78,24 @@ public:
    void AddTelescope(   G4ThreeVector  TL    ,
                         G4ThreeVector  BL    ,
                         G4ThreeVector  BR    ,
-                        G4ThreeVector  TR    );
+                        G4ThreeVector  TR    ,
+                        G4double       T    );
    // By Angle Method
    void AddTelescope(   G4double    R        ,
                         G4double    Theta    ,
                         G4double    Phi      ,
                         G4double    beta_u   ,
                         G4double    beta_v   ,
-                        G4double    beta_w   );
+                        G4double    beta_w   , 
+                        G4double    T       );
 
    // 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 );
+                        G4LogicalVolume*  world ,
+                        G4double          thick );
 
 
    ////////////////////////////////////////////////////
@@ -149,6 +153,8 @@ private:
 private:
    // True if Define by Position, False is Define by angle
    vector<bool>   m_DefinitionType  ;
+   
+   vector<G4double>   m_thickness  ;
 
    // Used for "By Point Definition"
    vector<G4ThreeVector>   m_TL     ; // Top Left Corner Position Vector
-- 
GitLab