From 12e5a2fd9c41391b83b92b630b690327d9e482b1 Mon Sep 17 00:00:00 2001
From: matta <matta@npt>
Date: Wed, 6 Feb 2013 15:11:23 +0000
Subject: [PATCH] * Adding the Sharc scorer (work still in progress)

---
 Inputs/EventGenerator/24Nadp.reaction       | 43 ++++++---
 NPSimulation/include/SharcScorers.hh        | 70 +++++++++++++++
 NPSimulation/src/ComptonTelescopeScorers.cc | 16 ++--
 NPSimulation/src/Sharc.cc                   |  2 +-
 NPSimulation/src/SharcScorers.cc            | 99 +++++++++++++++++++++
 5 files changed, 212 insertions(+), 18 deletions(-)
 create mode 100644 NPSimulation/include/SharcScorers.hh
 create mode 100644 NPSimulation/src/SharcScorers.cc

diff --git a/Inputs/EventGenerator/24Nadp.reaction b/Inputs/EventGenerator/24Nadp.reaction
index 4f5e38ba5..884ffe283 100644
--- a/Inputs/EventGenerator/24Nadp.reaction
+++ b/Inputs/EventGenerator/24Nadp.reaction
@@ -1,16 +1,39 @@
-Transfert
+%%%%%%%%%%%%%%%%%%%%%% S1107 at Triumf %%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Beam
+  Particle= 24Na
+  Energy= 192
+	SigmaEnergy= 1
+	SigmaThetaX= 0.01
+	SigmaPhiY= 0.01
+	SigmaX= 0.5
+	SigmaY= 0.5
+  MeanThetaX= 0
+  MeanPhiY= 0
+  MeanX= 0
+  MeanY= 0
+  %EnergyProfilePath=
+  %XThetaXProfilePath=
+  %YPhiYProfilePath=
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+TwoBodyReaction
 	Beam= 24Na
 	Target= 2H
 	Light= 1H
 	Heavy= 25Na
 	ExcitationEnergyLight= 0.0
-	ExcitationEnergyHeavy= 0.0
-	BeamEnergy= 192
-	BeamEnergySpread= 0
-	SigmaThetaX= 0.01
-	SigmaPhiY= 0.01
-	SigmaX= 0.5
-	SigmaY= 0.5
-	CrossSectionPath= flat.txt	
+	ExcitationEnergyHeavy= 2.2
+  CrossSectionPath= 11Li(d,3He)10He.txt	CSR
 	ShootLight= 1
-	ShootHeavy= 0
\ No newline at end of file
+	ShootHeavy= 1
+  
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+GammaDecay 25Na
+  Cascade
+    BranchingRatio= 70
+    Energies= 2.2
+    DifferentialCrossSection= 11Li(d,3He)10He.txt	Gamma25Na
+  Cascade
+    BranchingRatio= 30
+    Energies= 1.0 1.2
\ No newline at end of file
diff --git a/NPSimulation/include/SharcScorers.hh b/NPSimulation/include/SharcScorers.hh
new file mode 100644
index 000000000..1d8a3f255
--- /dev/null
+++ b/NPSimulation/include/SharcScorers.hh
@@ -0,0 +1,70 @@
+#ifndef SharcScorers_h
+#define SharcScorers_h 1
+/*****************************************************************************
+ * Copyright (C) 2009-2010   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: Adrien MATTA  contact address: matta@ipno.in2p3.fr       *
+ *                                                                           *
+ * Creation Date  : February 2013                                            *
+ * Last update    :                                                          *
+ *---------------------------------------------------------------------------*
+ * Decription:                                                               *
+ *  File old the scorer specific to the Sharc Detector                       *
+ *                                                                           *
+ *---------------------------------------------------------------------------*
+ * Comment:                                                                  *
+ * This new style of scorer is aim to become the standard way of doing scorer*
+ * in NPTool.                                                                *
+ *The index is build using the TrackID, Detector Number and Strip Number.    *
+ *The scorer Hold Energy and time together                                   *
+ *Only one scorer is needed for a detector                                   *
+ *****************************************************************************/
+#include "G4VPrimitiveScorer.hh"
+#include "G4THitsMap.hh"
+namespace SHARC {
+  //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+  //   This Threshold is used in the above scorer. Any energy deposit under this threshold will not create an entry.
+  const double TriggerThreshold = 0.1*keV ;
+  
+  class PS_Silicon_Rectangle : public G4VPrimitiveScorer{
+    
+  public: // with description
+    PS_Silicon_Rectangle(G4String name, G4double StripPlaneLength, G4double StripPlaneWidth, G4int NumberOfStripLength,G4int NumberOfStripWidth,G4int depth);
+    virtual ~PS_Silicon_Rectangle();
+    
+  protected: // with description
+    virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*);
+    
+  public:
+    virtual void Initialize(G4HCofThisEvent*);
+    virtual void EndOfEvent(G4HCofThisEvent*);
+    virtual void clear();
+    virtual void DrawAll();
+    virtual void PrintAll();
+    
+  private: // Geometry of the detector
+    G4double m_StripPlaneLength;
+    G4double m_StripPlaneWidth;
+    G4int    m_NumberOfStripLength;
+    G4int    m_NumberOfStripWidth;
+    G4double m_StripPitchLength;
+    G4double m_StripPitchWidth;
+    
+  private: // inherited from G4VPrimitiveScorer
+    G4int HCID;
+    G4THitsMap<G4int>* EvtMap;
+    
+  private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit)
+    G4ThreeVector m_Position  ;
+    G4int m_DetectorNumber    ;
+    G4int m_StripLengthNumber ;
+    G4int m_StripWidthNumber  ;
+  };
+}
+
+#endif
diff --git a/NPSimulation/src/ComptonTelescopeScorers.cc b/NPSimulation/src/ComptonTelescopeScorers.cc
index 278a8b93b..12e8817e6 100755
--- a/NPSimulation/src/ComptonTelescopeScorers.cc
+++ b/NPSimulation/src/ComptonTelescopeScorers.cc
@@ -6,13 +6,14 @@
  *****************************************************************************/
 
 /*****************************************************************************
- * Original Author: M. Labiche  contact address: marc.labiche@stfc.ac.uk     *
+ * Original Author: Nicolas de Sereville                                     *
+ * contact address: marc.labiche@stfc.ac.uk                                  *
  *                                                                           *
  * Creation Date  : 30/02/10                                                 *
  * Last update    :                                                          *
  *---------------------------------------------------------------------------*
  * Decription: This class holds all the scorers needed by the                *
- *             Paris*** objects.                                    *
+ *             Caompton telescope detector.                                  *
  *---------------------------------------------------------------------------*
  * Comment:                                                                  *
  *                                                                           *
@@ -31,11 +32,12 @@
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-// Added by Adrien MATTA:
-// Those Scorer use TrackID as map index. This way ones can rebuild energy deposit,
-// time of flight or position,... particle by particle for each event. Because standard
-// scorer provide by G4 don't work this way but using a global ID for each event you should
-// not use those scorer with some G4 provided ones or being very carefull doing so.
+  /* Added by Adrien MATTA:
+   Those Scorer use TrackID as map index. This way ones can rebuild energy deposit,
+   time of flight or position,... particle by particle for each event. Because standard
+   scorer provide by G4 don't work this way but using a global ID for each event you should
+   not use those scorer with some G4 provided ones or being very carefull doing so.
+   */
 
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
diff --git a/NPSimulation/src/Sharc.cc b/NPSimulation/src/Sharc.cc
index f42e734b4..baa7ea8ac 100644
--- a/NPSimulation/src/Sharc.cc
+++ b/NPSimulation/src/Sharc.cc
@@ -618,7 +618,7 @@ void Sharc::ReadSensitive(const G4Event* event){
    G4THitsMap<G4double>*  EnergyHitMap;
    G4THitsMap<G4double>*  TimeHitMap;
    
-   std::map<G4int, G4int*>::iterator DetNbr_itr     ;
+   std::map<G4int, G4int*>::iterator DetNbr_itr    ;
    std::map<G4int, G4int*>::iterator StripNbr_itr  ;
    std::map<G4int, G4double*>::iterator Energy_itr ;
    std::map<G4int, G4double*>::iterator Time_itr   ;
diff --git a/NPSimulation/src/SharcScorers.cc b/NPSimulation/src/SharcScorers.cc
new file mode 100644
index 000000000..6fffecf08
--- /dev/null
+++ b/NPSimulation/src/SharcScorers.cc
@@ -0,0 +1,99 @@
+/*****************************************************************************
+ * Copyright (C) 2009-2010   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: Adrien MATTA  contact address: matta@ipno.in2p3.fr       *
+ *                                                                           *
+ * Creation Date  : February 2013                                            *
+ * Last update    :                                                          *
+ *---------------------------------------------------------------------------*
+ * Decription:                                                               *
+ *  File old the scorer specific to the Sharc Detector                       *
+ *                                                                           *
+ *---------------------------------------------------------------------------*
+ * Comment:                                                                  *
+ * This new type of scorer is aim to become the standard for DSSD,SSSD and   *
+ * PAD detector (any thing with a rectangular shape)                         *
+ *****************************************************************************/
+#include "SharcScorers.hh"
+#include "G4UnitsTable.hh"
+using namespace SHARC ;
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+PS_Silicon_Rectangle::PS_Silicon_Rectangle(G4String name, G4double StripPlaneLength, G4double StripPlaneWidth, G4int NumberOfStripLength,G4int NumberOfStripWidth,G4int depth)
+:G4VPrimitiveScorer(name, depth), HCID(-1){
+  m_StripPlaneLength = StripPlaneLength;
+  m_StripPlaneWidth = StripPlaneWidth;
+  m_NumberOfStripLength = NumberOfStripLength;
+  m_NumberOfStripWidth = NumberOfStripWidth;
+  m_StripPitchLength = m_StripPlaneLength / m_NumberOfStripLength;
+  m_StripPitchWidth = m_StripPlaneWidth / m_NumberOfStripWidth;
+  
+  m_Position = G4ThreeVector(-1000,-1000,-1000);
+  m_DetectorNumber = -1;
+  m_StripLengthNumber = -1;
+  m_StripWidthNumber = -1;
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+PS_Silicon_Rectangle::~PS_Silicon_Rectangle(){
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+G4bool PS_Silicon_Rectangle::ProcessHits(G4Step* aStep, G4TouchableHistory*){
+
+  m_DetectorNumber = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(0);
+  m_Position  = aStep->GetPreStepPoint()->GetPosition();
+  m_Position = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS);
+  
+  m_StripLengthNumber = (int)((m_Position(1) + m_StripPlaneLength / 2.) / m_StripPitchLength ) + 1  ;
+  m_StripWidthNumber = (int)((m_Position(2) + m_StripPlaneWidth / 2.) / m_StripPitchWidth ) + 1  ;
+
+  //Rare case where particle is close to edge of silicon plan
+  if (m_StripLengthNumber == m_NumberOfStripLength+1) m_StripLengthNumber = m_StripLengthNumber;
+  if (m_StripWidthNumber == m_NumberOfStripWidth+1) m_StripWidthhNumber = m_StripWidthNumber;
+  
+  G4double[2] EnergyAndTime;
+  
+  EnergyAndTime[0] = aStep->GetTotalEnergyDeposit();
+  EnergyAndTime[1] = aStep->GetPreStepPoint()->GetGlobalTime();;
+  
+  if (edep < TriggerThreshold) return FALSE;
+  G4int  index =  aStep->GetTrack()->GetTrackID();
+  EvtMap->set(index+DetNbr, X);
+  return TRUE;
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+void PS_Silicon_Rectangle::Initialize(G4HCofThisEvent* HCE){
+  EvtMap = new G4THitsMap<G4int>(GetMultiFunctionalDetector()->GetName(), GetName());
+  if (HCID < 0) {
+    HCID = GetCollectionID(0);
+  }
+  HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+void PS_Silicon_Rectangle::EndOfEvent(G4HCofThisEvent*){
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+void PS_Silicon_Rectangle::clear(){
+  EvtMap->clear();
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+void PS_Silicon_Rectangle::DrawAll(){
+  
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+void PS_Silicon_Rectangle::PrintAll(){
+  G4cout << " MultiFunctionalDet  " << detector->GetName() << G4endl ;
+  G4cout << " PrimitiveScorer " << GetName() << G4endl               ;
+  G4cout << " Number of entries " << EvtMap->entries() << G4endl     ;
+}
-- 
GitLab