From 19135d1b5186b6e3261699bc02eaf9749e97afff Mon Sep 17 00:00:00 2001
From: adrien matta <matta@lpccaen.in2p3.fr>
Date: Thu, 16 Jul 2020 17:12:36 +0200
Subject: [PATCH] * adding scorer to inner and outer barrel in strasse

---
 NPSimulation/Detectors/Strasse/Strasse.cc | 117 +++++++++++++---------
 Projects/Nebula/Nebula.detector           |  24 +++--
 Projects/Strasse/strasse.detector         |  30 +++---
 3 files changed, 99 insertions(+), 72 deletions(-)

diff --git a/NPSimulation/Detectors/Strasse/Strasse.cc b/NPSimulation/Detectors/Strasse/Strasse.cc
index d9bff6487..627f954ed 100644
--- a/NPSimulation/Detectors/Strasse/Strasse.cc
+++ b/NPSimulation/Detectors/Strasse/Strasse.cc
@@ -63,7 +63,7 @@ using namespace CLHEP;
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 namespace Strasse_NS{
   // Energy and time Resolution
-  const double EnergyThreshold = 0.1*MeV;
+  const double EnergyThreshold = 10*keV;
   const double ResoEnergy = 0.015*MeV ;
 
   ////////////////////
@@ -86,6 +86,8 @@ namespace Strasse_NS{
   double Inner_PCB_DownstreamWidth=2*mm;
   double Inner_PCB_MidWidth=2*mm;
   double Inner_PCB_Thickness=3*mm;
+  double Inner_Wafer_FrontStrips= 128;
+  double Inner_Wafer_BackStrips= 128;
 
   ////////////////////
   // Outer Detector //
@@ -107,6 +109,9 @@ namespace Strasse_NS{
   double Outer_PCB_DownstreamWidth=2*mm;
   double Outer_PCB_MidWidth=2*mm;
   double Outer_PCB_Thickness=3*mm;
+  double Outer_Wafer_FrontStrips= 128;
+  double Outer_Wafer_BackStrips= 128;
+
 
 }
 
@@ -267,6 +272,7 @@ G4LogicalVolume* Strasse::BuildInnerDetector(){
     G4LogicalVolume* logicActiveWafer =
       new G4LogicalVolume(ActiveWaferShape,m_MaterialSilicon,"logicActiveWafer", 0, 0, 0);
     logicActiveWafer->SetVisAttributes(SiliconVisAtt);
+    logicActiveWafer->SetSensitiveDetector(m_InnerScorer);
 
     new G4PVPlacement(new G4RotationMatrix(0,0,0),
         G4ThreeVector(0,0,0.5*(Inner_Wafer_PADExternal-Inner_Wafer_PADInternal)), // assymetric pading for bounding
@@ -392,6 +398,7 @@ G4LogicalVolume* Strasse::BuildOuterDetector(){
     G4LogicalVolume* logicActiveWafer =
       new G4LogicalVolume(ActiveWaferShape,m_MaterialSilicon,"logicActiveWafer", 0, 0, 0);
     logicActiveWafer->SetVisAttributes(SiliconVisAtt);
+    logicActiveWafer->SetSensitiveDetector(m_OuterScorer);
 
     new G4PVPlacement(new G4RotationMatrix(0,0,0),
         G4ThreeVector(0,0,0.5*(Outer_Wafer_PADExternal-Outer_Wafer_PADInternal)), // assymetric pading for bounding
@@ -440,6 +447,8 @@ void Strasse::ReadConfiguration(NPL::InputParser parser){
     "Inner_PCB_DownstreamWidth",
     "Inner_PCB_MidWidth",       
     "Inner_PCB_Thickness",      
+    "Inner_Wafer_FrontStrips",
+    "Inner_Wafer_BackStrips",
     "Outer_Wafer_Length",       
     "Outer_Wafer_Width",        
     "Outer_Wafer_Thickness",    
@@ -454,6 +463,8 @@ void Strasse::ReadConfiguration(NPL::InputParser parser){
     "Outer_PCB_DownstreamWidth",
     "Outer_PCB_MidWidth",       
     "Outer_PCB_Thickness",      
+    "Outer_Wafer_FrontStrips",
+    "Outer_Wafer_BackStrips"
   };
 
   if(blocks_info[0]->HasTokenList(info)){
@@ -465,6 +476,8 @@ void Strasse::ReadConfiguration(NPL::InputParser parser){
     Inner_Wafer_PADExternal = blocks_info[0]->GetDouble("Inner_Wafer_PADExternal","mm");     
     Inner_Wafer_PADInternal = blocks_info[0]->GetDouble("Inner_Wafer_PADInternal","mm");   
     Inner_Wafer_GuardRing = blocks_info[0]->GetDouble("Inner_Wafer_GuardRing","mm");     
+    Inner_Wafer_FrontStrips = blocks_info[0]->GetInt("Inner_Wafer_FrontStrips");        
+    Inner_Wafer_BackStrips = blocks_info[0]->GetInt("Inner_Wafer_BackStrips");       
     Inner_PCB_PortWidth = blocks_info[0]->GetDouble("Inner_PCB_PortWidth","mm");       
     Inner_PCB_StarboardWidth = blocks_info[0]->GetDouble("Inner_PCB_StarboardWidth","mm");  
     Inner_PCB_BevelAngle = blocks_info[0]->GetDouble("Inner_PCB_BevelAngle","mm");      
@@ -479,6 +492,8 @@ void Strasse::ReadConfiguration(NPL::InputParser parser){
     Outer_Wafer_PADExternal = blocks_info[0]->GetDouble("Outer_Wafer_PADExternal","mm");   
     Outer_Wafer_PADInternal = blocks_info[0]->GetDouble("Outer_Wafer_PADInternal","mm");   
     Outer_Wafer_GuardRing = blocks_info[0]->GetDouble("Outer_Wafer_GuardRing","mm");     
+    Outer_Wafer_FrontStrips = blocks_info[0]->GetInt("Outer_Wafer_FrontStrips");        
+    Outer_Wafer_BackStrips = blocks_info[0]->GetInt("Outer_Wafer_BackStrips");       
     Outer_PCB_PortWidth = blocks_info[0]->GetDouble("Outer_PCB_PortWidth","mm");       
     Outer_PCB_StarboardWidth = blocks_info[0]->GetDouble("Outer_PCB_StarboardWidth","mm");  
     Outer_PCB_BevelAngle = blocks_info[0]->GetDouble("Outer_PCB_BevelAngle","deg");      
@@ -590,78 +605,82 @@ void Strasse::InitializeRootOutput(){
 // Called at in the EventAction::EndOfEventAvtion
 void Strasse::ReadSensitive(const G4Event* ){
   m_Event->Clear();
-  /*
+
   ///////////
-  // First Stage scorer
+  // Inner barrel scorer
   DSSDScorers::PS_Rectangle* InnerScorer= (DSSDScorers::PS_Rectangle*) m_InnerScorer->GetPrimitive(0);
 
   unsigned int sizeFront = InnerScorer->GetLengthMult(); 
   for(unsigned int i = 0 ; i < sizeFront ; i++){
-  double Energy = RandGauss::shoot(InnerScorer->GetEnergyLength(i), ResoEnergy);   
-  if(Energy>EnergyThreshold){
-  int DetNbr  = InnerScorer->GetDetectorLength(i);
-  int StripFront = InnerScorer->GetStripLength(i);
-  m_Event->SetInnerXE(DetNbr, StripFront, Energy);
-  }
+    double Energy = RandGauss::shoot(InnerScorer->GetEnergyLength(i), ResoEnergy);   
+    if(Energy>EnergyThreshold){
+      int DetNbr  = InnerScorer->GetDetectorLength(i);
+      int StripFront = InnerScorer->GetStripLength(i);
+     // m_Event->SetInnerXE(DetNbr, StripFront, Energy);
+     std::cout << DetNbr << " " << StripFront << " " << Energy/keV << std::endl;
+    }
   }
   unsigned int sizeBack = InnerScorer->GetWidthMult(); 
   for(unsigned int i = 0 ; i < sizeBack ; i++){
-  double Energy = RandGauss::shoot(InnerScorer->GetEnergyWidth(i), ResoEnergy);   
-  if(Energy>EnergyThreshold){
-  int DetNbr  = InnerScorer->GetDetectorWidth(i);
-  int StripFront = InnerScorer->GetStripWidth(i);
-  m_Event->SetInnerYE(DetNbr, StripFront, Energy);
-  }
+    double Energy = RandGauss::shoot(InnerScorer->GetEnergyWidth(i), ResoEnergy);   
+    if(Energy>EnergyThreshold){
+      int DetNbr  = InnerScorer->GetDetectorWidth(i);
+      int StripFront = InnerScorer->GetStripWidth(i);
+    //  m_Event->SetInnerYE(DetNbr, StripFront, Energy);
+    }
   }
   InnerScorer->clear();
-
+  
   ///////////
-  // Second Stage scorer
+  // Outer barrel scorer
   DSSDScorers::PS_Rectangle* OuterScorer= (DSSDScorers::PS_Rectangle*) m_OuterScorer->GetPrimitive(0);
 
-  unsigned int sizeFrontOuter = OuterScorer->GetLengthMult(); 
-  for(unsigned int i = 0 ; i < sizeFrontOuter ; i++){
-  double Energy = RandGauss::shoot(OuterScorer->GetEnergyLength(i), ResoEnergy);   
-  if(Energy>EnergyThreshold){
-  int DetNbr  = OuterScorer->GetDetectorLength(i);
-  int StripFront = OuterScorer->GetStripLength(i);
-  m_Event->SetOuterXE(DetNbr, StripFront, Energy);
-  }
-  }
-  unsigned int sizeBackOuter = OuterScorer->GetWidthMult(); 
-  for(unsigned int i = 0 ; i < sizeBackOuter ; i++){
-  double Energy = RandGauss::shoot(OuterScorer->GetEnergyWidth(i), ResoEnergy);   
-  if(Energy>EnergyThreshold){
-  int DetNbr  = OuterScorer->GetDetectorWidth(i);
-  int StripFront = OuterScorer->GetStripWidth(i);
-  m_Event->SetOuterYE(DetNbr, StripFront, Energy);
+  sizeFront = OuterScorer->GetLengthMult(); 
+  for(unsigned int i = 0 ; i < sizeFront ; i++){
+    double Energy = RandGauss::shoot(OuterScorer->GetEnergyLength(i), ResoEnergy);   
+    if(Energy>EnergyThreshold){
+      int DetNbr  = OuterScorer->GetDetectorLength(i);
+      int StripFront = OuterScorer->GetStripLength(i);
+ //     m_Event->SetOuterXE(DetNbr, StripFront, Energy);
+    }
   }
+  
+  sizeBack = OuterScorer->GetWidthMult(); 
+  for(unsigned int i = 0 ; i < sizeBack ; i++){
+    double Energy = RandGauss::shoot(OuterScorer->GetEnergyWidth(i), ResoEnergy);   
+    if(Energy>EnergyThreshold){
+      int DetNbr  = OuterScorer->GetDetectorWidth(i);
+      int StripFront = OuterScorer->GetStripWidth(i);
+   //   m_Event->SetOuterYE(DetNbr, StripFront, Energy);
+    }
   }
   OuterScorer->clear();
-  */
 
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 ////////////////////////////////////////////////////////////////   
 void Strasse::InitializeScorers() { 
-  /*  // This check is necessary in case the geometry is reloaded
-      bool already_exist = false; 
-      m_InnerScorer = CheckScorer("InnerScorer",already_exist) ;
-      m_OuterScorer = CheckScorer("OuterScorer",already_exist) ;
+  // This check is necessary in case the geometry is reloaded
+  bool already_exist = false; 
+  m_InnerScorer = CheckScorer("InnerScorer",already_exist) ;
+  m_OuterScorer = CheckScorer("OuterScorer",already_exist) ;
 
-      if(already_exist) 
-      return ;
+  if(already_exist) 
+    return ;
 
   // Otherwise the scorer is initialised
-  G4VPrimitiveScorer* InnerScorer = new DSSDScorers::PS_Rectangle("InnerScorer",1,
-  TrapezoidBaseLarge,
-  TrapezoidHeight,
-  128,128);
-  G4VPrimitiveScorer* OuterScorer = new DSSDScorers::PS_Rectangle("OuterScorer",1,
-  TrapezoidBaseLarge,
-  TrapezoidHeight,
-  16,16);
+  G4VPrimitiveScorer* InnerScorer = new DSSDScorers::PS_Rectangle("InnerScorer",2,
+      Inner_Wafer_Length,
+      Inner_Wafer_Width,
+      Inner_Wafer_FrontStrips,
+      Inner_Wafer_BackStrips);
+
+  G4VPrimitiveScorer* OuterScorer = new DSSDScorers::PS_Rectangle("OuterScorer",2,
+      Outer_Wafer_Length,
+      Outer_Wafer_Width,
+      Outer_Wafer_FrontStrips,
+      Outer_Wafer_BackStrips);
 
   G4VPrimitiveScorer* InteractionInner = new InteractionScorers::PS_Interactions("InteractionInner",ms_InterCoord,0);
   G4VPrimitiveScorer* InteractionOuter = new InteractionScorers::PS_Interactions("InteractionOuter",ms_InterCoord,0);
@@ -674,7 +693,7 @@ void Strasse::InitializeScorers() {
 
   G4SDManager::GetSDMpointer()->AddNewDetector(m_InnerScorer);
   G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterScorer);
-  */
+
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
diff --git a/Projects/Nebula/Nebula.detector b/Projects/Nebula/Nebula.detector
index 776b850b7..f46956bad 100644
--- a/Projects/Nebula/Nebula.detector
+++ b/Projects/Nebula/Nebula.detector
@@ -20,14 +20,18 @@ Nebula
  Veto= 0
  Frame= 0
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%% Telescope 1 %%%%%%% 
-M2Telescope
- X1_Y1= -50.23  50.23 365 mm
- X1_Y128= -50.23  -50.23  365 mm
- X128_Y128= 50.23 -50.23  365 mm
- X128_Y1= 50.23 50.23 365 mm
- SI=  1   
- SILI=  0   
- CSI= 1   
- VIS= all         
+ 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Nebula
+ POS= 0 0 10 m
+ NumberOfModule= 30
+ Veto= 1
+ Frame= 1
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Nebula
+ POS= 0 0 10.15 m
+ NumberOfModule= 30
+ Veto= 0
+ Frame= 0
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
diff --git a/Projects/Strasse/strasse.detector b/Projects/Strasse/strasse.detector
index 727174853..d9231047e 100644
--- a/Projects/Strasse/strasse.detector
+++ b/Projects/Strasse/strasse.detector
@@ -19,6 +19,8 @@ Strasse Info
   Inner_Wafer_PADExternal= 1 mm
   Inner_Wafer_PADInternal= 1 mm
   Inner_Wafer_GuardRing= 1.5 mm
+  Inner_Wafer_FrontStrips= 128
+  Inner_Wafer_BackStrips= 128
   Inner_PCB_PortWidth= 5 mm
   Inner_PCB_StarboardWidth= 1 mm
   Inner_PCB_BevelAngle=  45 deg
@@ -27,7 +29,7 @@ Strasse Info
   Inner_PCB_MidWidth= 1 mm
   Inner_PCB_Thickness= 1.6 mm
   Outer_Wafer_Length= 107 mm
-  Outer_Wafer_Width= 86 mm
+  Outer_Wafer_Width= 60 mm
   Outer_Wafer_Thickness= 300 micrometer
   Outer_Wafer_AlThickness= 0.4 micrometer
   Outer_Wafer_PADExternal= 1 mm
@@ -40,76 +42,78 @@ Strasse Info
   Outer_PCB_DownstreamWidth= 1 mm
   Outer_PCB_MidWidth= 1 mm
   Outer_PCB_Thickness= 1.6 mm
+  Outer_Wafer_FrontStrips= 128
+  Outer_Wafer_BackStrips= 128
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%1
 Strasse Inner
-  Radius= 32 mm
+  Radius= 30 mm
   Z= 100 mm
   Phi= 0 deg
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2
 Strasse Inner
-  Radius= 32 mm
+  Radius= 30 mm
   Z= 100 mm
   Phi= 60 deg
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%3
 Strasse Inner
-  Radius= 32 mm
+  Radius= 30 mm
   Z= 100 mm
   Phi= 120 deg
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%4
 Strasse Inner
-  Radius= 32 mm
+  Radius= 30 mm
   Z= 100 mm
   Phi= 180 deg
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
 Strasse Inner
-  Radius= 32 mm
+  Radius= 30 mm
   Z= 100 mm
   Phi= 240 deg
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%6
 Strasse Inner
-  Radius= 32 mm
+  Radius= 30 mm
   Z= 100 mm
   Phi= 300 deg
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%1
 Strasse Outer
-  Radius= 80 mm
+  Radius= 60 mm
   Z= 129 mm
   Phi= 0 deg
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2
 Strasse Outer
-  Radius= 80 mm
+  Radius= 60 mm
   Z= 129 mm
   Phi= 60 deg
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%3
 Strasse Outer
-  Radius= 80 mm
+  Radius= 60 mm
   Z= 129 mm
   Phi= 120 deg
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%4
 Strasse Outer
-  Radius= 80 mm
+  Radius= 60 mm
   Z= 129 mm
   Phi= 180 deg
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
 Strasse Outer
-  Radius= 80 mm
+  Radius= 60 mm
   Z= 129 mm
   Phi= 240 deg
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%6
 Strasse Outer
-  Radius= 80 mm
+  Radius= 60 mm
   Z= 129 mm
   Phi= 300 deg
 
-- 
GitLab