From 4b260de789351a08a643c4e937e848374efb22b7 Mon Sep 17 00:00:00 2001
From: Pierre Morfouace <pierre.morfouace2@cea.fr>
Date: Mon, 10 Jan 2022 16:28:23 +0100
Subject: [PATCH] * Updtating Sofia simulation part

---
 .../TransferInducedFission.reaction           |  11 +-
 Inputs/EventGenerator/sofia.reaction          |  13 +-
 NPSimulation/Detectors/Sofia/CMakeLists.txt   |   4 +-
 .../Detectors/Sofia/{Sofia.cc => SofTofW.cc}  | 146 ++++++++----------
 .../Detectors/Sofia/{Sofia.hh => SofTofW.hh}  |  22 +--
 Projects/Sofia/sofia.detector                 |   8 +-
 Projects/s455/Analysis.cxx                    | 122 ++++-----------
 Projects/s455/Analysis.h                      |  13 +-
 8 files changed, 130 insertions(+), 209 deletions(-)
 rename NPSimulation/Detectors/Sofia/{Sofia.cc => SofTofW.cc} (77%)
 rename NPSimulation/Detectors/Sofia/{Sofia.hh => SofTofW.hh} (89%)

diff --git a/Inputs/EventGenerator/TransferInducedFission.reaction b/Inputs/EventGenerator/TransferInducedFission.reaction
index ddf6ef236..f2df925d4 100644
--- a/Inputs/EventGenerator/TransferInducedFission.reaction
+++ b/Inputs/EventGenerator/TransferInducedFission.reaction
@@ -27,8 +27,9 @@ TwoBodyReaction
  ShootHeavy= 1
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FissionDecay 
-  CompoundNucleus= 236U
-  FissionModel= GEF
-  Shoot_FF= 1
-  Shoot_neutron= 0
-  Shoot_gamma= 0
+ CompoundNucleus= 236U
+ FissionModel= GEF
+ VamosChargeStates= 1
+ Shoot_FF= 1
+ Shoot_neutron= 0
+ Shoot_gamma= 0
diff --git a/Inputs/EventGenerator/sofia.reaction b/Inputs/EventGenerator/sofia.reaction
index c7c54e908..f5301f7c3 100644
--- a/Inputs/EventGenerator/sofia.reaction
+++ b/Inputs/EventGenerator/sofia.reaction
@@ -3,7 +3,7 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%Beam energy given in MeV ; Excitation in MeV ; emmitance in rad
 Beam
- Particle= 238U
+ Particle= 179Hg
  Energy= 166000
  SigmaEnergy= 2
  SigmaX= 1 cm
@@ -16,10 +16,10 @@ Beam
  MeanY= 0
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 TwoBodyReaction
- Beam= 238U
- Target= 208Pb
- Light= 208Pb
- Heavy= 238U
+ Beam= 179Hg
+ Target= 12C
+ Light= 11C
+ Heavy= 180Hg
  ExcitationEnergyLight= 0.0
  ExcitationEnergyHeavy= 15.0
  CrossSectionPath= sofia.txt CS
@@ -27,8 +27,9 @@ TwoBodyReaction
  ShootHeavy= 1
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FissionDecay 
- CompoundNucleus= 238U
+ CompoundNucleus= 180Hg
  FissionModel= GEF
+ VamosChargeStates= 0
  Shoot_FF= 1
  Shoot_neutron= 0
  Shoot_gamma= 0
diff --git a/NPSimulation/Detectors/Sofia/CMakeLists.txt b/NPSimulation/Detectors/Sofia/CMakeLists.txt
index 57854b49e..1cb926c21 100644
--- a/NPSimulation/Detectors/Sofia/CMakeLists.txt
+++ b/NPSimulation/Detectors/Sofia/CMakeLists.txt
@@ -1,2 +1,2 @@
-add_library(NPSSofia SHARED  Sofia.cc)
-target_link_libraries(NPSSofia NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPSofia)
+add_library(NPSSofTofW SHARED  SofTofW.cc)
+target_link_libraries(NPSSofTofW NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPSofia)
diff --git a/NPSimulation/Detectors/Sofia/Sofia.cc b/NPSimulation/Detectors/Sofia/SofTofW.cc
similarity index 77%
rename from NPSimulation/Detectors/Sofia/Sofia.cc
rename to NPSimulation/Detectors/Sofia/SofTofW.cc
index 93db89c1a..bda0276b0 100644
--- a/NPSimulation/Detectors/Sofia/Sofia.cc
+++ b/NPSimulation/Detectors/Sofia/SofTofW.cc
@@ -12,7 +12,7 @@
  * Last update    :                                                           *
  *----------------------------------------------------------------------------*
  * Decription:                                                                *
- *  This class describe a simple Sofia setup for simulation                   *
+ *  This class describe a simple SofTofW setup for simulation                   *
  *                                                                            *
  *----------------------------------------------------------------------------*
  * Comment:                                                                   *
@@ -42,7 +42,7 @@
 #include "G4TransportationManager.hh"
 
 // NPTool header
-#include "Sofia.hh"
+#include "SofTofW.hh"
 #include "CalorimeterScorers.hh"
 #include "InteractionScorers.hh"
 #include "RootOutput.h"
@@ -58,12 +58,12 @@ using namespace CLHEP;
 
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-namespace Sofia_NS{
+namespace SofTofW_NS{
   // Energy and time Resolution
   const double EnergyThreshold       = 0.1*MeV;
   const double ResoTime              = 0.007*ns;
   const double ResoEnergy            = 1.0*MeV;
-  const double TwinResoEnergy        = 0*keV;
+  //const double TwinResoEnergy        = 0*keV;
   const double tof_plastic_height    = 660*mm;
   const double tof_plastic_width     = 32*mm;
   const double tof_plastic_thickness = 0.5*mm;
@@ -73,48 +73,46 @@ namespace Sofia_NS{
   const double GLAD_width            = 5*m;
   const double GLAD_length           = 2*m;
 
-  const double twin_anode_width = 10.*cm;
-  const double twin_anode_height = 10.*cm;
-  const double twin_anode_thickness = 3.1*cm;
+  //const double twin_anode_width = 10.*cm;
+  //const double twin_anode_height = 10.*cm;
+  //const double twin_anode_thickness = 3.1*cm;
 
-  const double twin_cathode_width = 30*um;
-  const double twin_cathode_height = 20*cm;
-  const double twin_cathode_thickness = 50*cm;
+  //const double twin_cathode_width = 30*um;
+  //const double twin_cathode_height = 20*cm;
+  //const double twin_cathode_thickness = 50*cm;
 
 
 }
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-// Sofia Specific Method
-Sofia::Sofia(){
+// SofTofW Specific Method
+SofTofW::SofTofW(){
   m_Event = new TSofTofWData() ;
   m_TofScorer = 0;
-  m_TwinScorer = 0;
   m_PlasticTof = 0;
-  m_AnodeDriftArea= 0;
-  m_TwinMusic= 0;
+  //m_AnodeDriftArea= 0;
+  //m_TwinMusic= 0;
   m_TofWall = 0;
 
   m_Build_GLAD= 0;
   m_GLAD_MagField = 0;
   m_GLAD_DistanceFromTarget = 0;
 
-  m_Build_Twin_Music= 0;
-  m_Twin_Music_DistanceFromTarget= 0;
-  m_Twin_Music_Gas= "P10_1atm";
+  //m_Build_Twin_Music= 0;
+  //m_Twin_Music_DistanceFromTarget= 0;
+  //m_Twin_Music_Gas= "P10_1atm";
 
   // RGB Color + Transparency
   m_VisSquare = new G4VisAttributes(G4Colour(0.53, 0.81, 0.98, 0.5));   
   m_VisGLAD = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 0.5));   
-  m_VisTwin = new G4VisAttributes(G4Colour(0.7, 0.5, 0.5, 0.5));   
 
 }
 
-Sofia::~Sofia(){
+SofTofW::~SofTofW(){
 }
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-void Sofia::AddDetector(G4ThreeVector POS){
+void SofTofW::AddDetector(G4ThreeVector POS){
   // Convert the POS value to R theta Phi as Spherical coordinate is easier in G4 
   m_R.push_back(POS.mag());
   m_Theta.push_back(POS.theta());
@@ -123,22 +121,22 @@ void Sofia::AddDetector(G4ThreeVector POS){
 
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-void Sofia::AddDetector(double  R, double  Theta, double  Phi){
+void SofTofW::AddDetector(double  R, double  Theta, double  Phi){
   m_R.push_back(R);
   m_Theta.push_back(Theta);
   m_Phi.push_back(Phi);
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-G4AssemblyVolume* Sofia::BuildTOFDetector(){
+G4AssemblyVolume* SofTofW::BuildTOFDetector(){
   m_TofWall = new G4AssemblyVolume();
 
   if(!m_PlasticTof){
-    G4Box* box = new G4Box("Sofia_Box",Sofia_NS::tof_plastic_height*0.5,
-        Sofia_NS::tof_plastic_width*0.5,Sofia_NS::tof_plastic_thickness*0.5);
+    G4Box* box = new G4Box("SofTofW_Box",SofTofW_NS::tof_plastic_height*0.5,
+        SofTofW_NS::tof_plastic_width*0.5,SofTofW_NS::tof_plastic_thickness*0.5);
 
-    G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Sofia_NS::Material);
-    m_PlasticTof = new G4LogicalVolume(box,DetectorMaterial,"logic_Sofia_Box",0,0,0);
+    G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(SofTofW_NS::Material);
+    m_PlasticTof = new G4LogicalVolume(box,DetectorMaterial,"logic_SofTofW_Box",0,0,0);
     m_PlasticTof->SetVisAttributes(m_VisSquare);
     m_PlasticTof->SetSensitiveDetector(m_TofScorer);
 
@@ -149,7 +147,7 @@ G4AssemblyVolume* Sofia::BuildTOFDetector(){
     Tv.setZ(0);
     for(unsigned int i=0; i<28; i++){
       int k = -14+i;
-      Tv.setY(k*(Sofia_NS::tof_plastic_width+0.5));
+      Tv.setY(k*(SofTofW_NS::tof_plastic_width+0.5));
       m_TofWall->AddPlacedVolume(m_PlasticTof, Tv, Rv);
     }
 
@@ -158,7 +156,7 @@ G4AssemblyVolume* Sofia::BuildTOFDetector(){
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-G4LogicalVolume* Sofia::BuildTwinMusic(){
+/*G4LogicalVolume* SofTofW::BuildTwinMusic(){
 
   double twin_width = 21*cm;
   double twin_height = 21*cm;
@@ -184,7 +182,7 @@ G4LogicalVolume* Sofia::BuildTwinMusic(){
       G4LogicalVolume* LogicalSector = new G4LogicalVolume(Sectorbox, TwinMaterial, "logic_twin", 0,0,0);
       LogicalSector->SetVisAttributes(G4VisAttributes::GetInvisible());
       // Drift Anode Area //
-      G4Box* Anodebox = new G4Box("Anode_Box", Sofia_NS::twin_anode_width*0.5, Sofia_NS::twin_anode_height*0.5, Sofia_NS::twin_anode_thickness*0.5);
+      G4Box* Anodebox = new G4Box("Anode_Box", SofTofW_NS::twin_anode_width*0.5, SofTofW_NS::twin_anode_height*0.5, SofTofW_NS::twin_anode_thickness*0.5);
 
       G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(m_Twin_Music_Gas);
       m_AnodeDriftArea = new G4LogicalVolume(Anodebox, DetectorMaterial, "logic_twin_anode", 0, 0, 0);
@@ -192,7 +190,7 @@ G4LogicalVolume* Sofia::BuildTwinMusic(){
       m_AnodeDriftArea->SetSensitiveDetector(m_TwinScorer);
 
       // Cathode plane in the middle //
-      G4Box* cathode_box = new G4Box("Cathode_box", Sofia_NS::twin_cathode_width*0.5, Sofia_NS::twin_cathode_height*0.5, Sofia_NS::twin_cathode_thickness*0.5);
+      G4Box* cathode_box = new G4Box("Cathode_box", SofTofW_NS::twin_cathode_width*0.5, SofTofW_NS::twin_cathode_height*0.5, SofTofW_NS::twin_cathode_thickness*0.5);
       G4Material* CathodeMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Al");
       G4VisAttributes* m_VisCathode = new G4VisAttributes(G4Colour(0.7,0.4,0,1));
       G4LogicalVolume* LogicalCathode = new G4LogicalVolume(cathode_box, CathodeMaterial, "logic_cathode", 0,0,0);
@@ -213,7 +211,7 @@ G4LogicalVolume* Sofia::BuildTwinMusic(){
       int anode_nbr= 0;
       for(unsigned int j=0; j<16; j++){
         anode_nbr++;
-        Tv.setZ(j*Sofia_NS::twin_anode_thickness -7.5*Sofia_NS::twin_anode_thickness);
+        Tv.setZ(j*SofTofW_NS::twin_anode_thickness -7.5*SofTofW_NS::twin_anode_thickness);
         new G4PVPlacement(0,Tv,
             m_AnodeDriftArea,
             "Anode",
@@ -222,20 +220,20 @@ G4LogicalVolume* Sofia::BuildTwinMusic(){
 
       for(unsigned int i=0; i<4; i++){
         if(i==0){
-          Tv.setX(0.5*Sofia_NS::twin_anode_width+Sofia_NS::twin_cathode_width);
-          Tv.setY(0.5*Sofia_NS::twin_anode_height);
+          Tv.setX(0.5*SofTofW_NS::twin_anode_width+SofTofW_NS::twin_cathode_width);
+          Tv.setY(0.5*SofTofW_NS::twin_anode_height);
         }
         if(i==1){
-          Tv.setX(-0.5*Sofia_NS::twin_anode_width-Sofia_NS::twin_cathode_width);
-          Tv.setY(0.5*Sofia_NS::twin_anode_height);
+          Tv.setX(-0.5*SofTofW_NS::twin_anode_width-SofTofW_NS::twin_cathode_width);
+          Tv.setY(0.5*SofTofW_NS::twin_anode_height);
         }
         if(i==2){
-          Tv.setX(-0.5*Sofia_NS::twin_anode_width-Sofia_NS::twin_cathode_width);
-          Tv.setY(-0.5*Sofia_NS::twin_anode_height);
+          Tv.setX(-0.5*SofTofW_NS::twin_anode_width-SofTofW_NS::twin_cathode_width);
+          Tv.setY(-0.5*SofTofW_NS::twin_anode_height);
         }
         if(i==3){
-          Tv.setX(0.5*Sofia_NS::twin_anode_width+Sofia_NS::twin_cathode_width);
-          Tv.setY(-0.5*Sofia_NS::twin_anode_height);
+          Tv.setX(0.5*SofTofW_NS::twin_anode_width+SofTofW_NS::twin_cathode_width);
+          Tv.setY(-0.5*SofTofW_NS::twin_anode_height);
         }
 
         Tv.setZ(0);
@@ -248,13 +246,13 @@ G4LogicalVolume* Sofia::BuildTwinMusic(){
   }
 
   return m_TwinMusic;
-}
+}*/
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-G4LogicalVolume* Sofia::BuildGLAD()
+G4LogicalVolume* SofTofW::BuildGLAD()
 {
-  G4Box* box = new G4Box("glad_Box",Sofia_NS::GLAD_width*0.5,
-      Sofia_NS::GLAD_height*0.5,Sofia_NS::GLAD_length*0.5);
+  G4Box* box = new G4Box("glad_Box",SofTofW_NS::GLAD_width*0.5,
+      SofTofW_NS::GLAD_height*0.5,SofTofW_NS::GLAD_length*0.5);
 
   G4Material* GLADMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vaccuum");
   m_GLAD = new G4LogicalVolume(box,GLADMaterial,"logic_GLAD_Box",0,0,0);
@@ -281,27 +279,26 @@ G4LogicalVolume* Sofia::BuildGLAD()
 
 // Read stream at Configfile to pick-up parameters of detector (Position,...)
 // Called in DetecorConstruction::ReadDetextorConfiguration Method
-void Sofia::ReadConfiguration(NPL::InputParser parser){
-  vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Sofia");
+void SofTofW::ReadConfiguration(NPL::InputParser parser){
+  vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("SofTofW");
   if(NPOptionManager::getInstance()->GetVerboseLevel())
     cout << "//// " << blocks.size() << " detectors found " << endl; 
 
-  vector<string> cart = {"POS","Build_GLAD","Build_Twin_Music"};
-  vector<string> sphe = {"R","Theta","Phi","Build_GLAD","Build_Twin_Music"};
+  vector<string> cart = {"POS","Build_GLAD"};
+  vector<string> sphe = {"R","Theta","Phi","Build_GLAD"};
 
   for(unsigned int i = 0 ; i < blocks.size() ; i++){
     if(blocks[i]->HasTokenList(cart)){
       if(NPOptionManager::getInstance()->GetVerboseLevel())
-        cout << endl << "////  Sofia " << i+1 <<  endl;
+        cout << endl << "////  SofTofW " << i+1 <<  endl;
 
       G4ThreeVector Pos = NPS::ConvertVector(blocks[i]->GetTVector3("POS","mm"));
       m_Build_GLAD = blocks[i]->GetInt("Build_GLAD");
-      m_Build_Twin_Music = blocks[i]->GetInt("Build_Twin_Music");
       AddDetector(Pos);
     }
     else if(blocks[i]->HasTokenList(sphe)){
       if(NPOptionManager::getInstance()->GetVerboseLevel())
-        cout << endl << "////  Sofia " << i+1 <<  endl;
+        cout << endl << "////  SofTofW " << i+1 <<  endl;
       double R = blocks[i]->GetDouble("R","mm");
       double Theta = blocks[i]->GetDouble("Theta","deg");
       double Phi = blocks[i]->GetDouble("Phi","deg");
@@ -309,10 +306,6 @@ void Sofia::ReadConfiguration(NPL::InputParser parser){
       m_GLAD_MagField = blocks[i]->GetDouble("GLAD_MagField","T");
       m_GLAD_DistanceFromTarget = blocks[i]->GetDouble("GLAD_DistanceFromTarget", "m");
 
-      m_Build_Twin_Music = blocks[i]->GetInt("Build_Twin_Music");
-      m_Twin_Music_DistanceFromTarget = blocks[i]->GetDouble("Twin_Music_DistanceFromTarget", "m");
-      m_Twin_Music_Gas = blocks[i]->GetString("Twin_Music_Gas");
-
       AddDetector(R,Theta,Phi);
     }
     else{
@@ -327,7 +320,7 @@ void Sofia::ReadConfiguration(NPL::InputParser parser){
 
 // Construct detector and inialise sensitive part.
 // Called After DetecorConstruction::AddDetector Method
-void Sofia::ConstructDetector(G4LogicalVolume* world){
+void SofTofW::ConstructDetector(G4LogicalVolume* world){
   for (unsigned short i = 0 ; i < m_R.size() ; i++) {
 
     G4double wX = m_R[i] * sin(m_Theta[i] ) * cos(m_Phi[i] ) ;
@@ -335,7 +328,7 @@ void Sofia::ConstructDetector(G4LogicalVolume* world){
     G4double wZ = m_R[i] * cos(m_Theta[i] ) ;
     G4ThreeVector Det_pos = G4ThreeVector(wX, wY, wZ) ;
     // So the face of the detector is at R instead of the middle
-    Det_pos+=Det_pos.unit()*Sofia_NS::tof_plastic_thickness*0.5;
+    Det_pos+=Det_pos.unit()*SofTofW_NS::tof_plastic_thickness*0.5;
     // Building Detector reference frame
     G4double ii = cos(m_Theta[i]) * cos(m_Phi[i]);
     G4double jj = cos(m_Theta[i]) * sin(m_Phi[i]);
@@ -353,14 +346,14 @@ void Sofia::ConstructDetector(G4LogicalVolume* world){
     BuildTOFDetector()->MakeImprint(world,Det_pos,Rot);
 
     if(m_Build_GLAD==1){
-      G4ThreeVector GLAD_pos = G4ThreeVector(0,0,m_GLAD_DistanceFromTarget+0.5*Sofia_NS::GLAD_length);
+      G4ThreeVector GLAD_pos = G4ThreeVector(0,0,m_GLAD_DistanceFromTarget+0.5*SofTofW_NS::GLAD_length);
       new G4PVPlacement(0, GLAD_pos,
           BuildGLAD(),
           "GLAD",
           world, false, 0);
     }
 
-    if(m_Build_Twin_Music==1){
+    /*if(m_Build_Twin_Music==1){
       G4ThreeVector Tv = G4ThreeVector(0,0,0);
       Tv.setZ(m_Twin_Music_DistanceFromTarget);
 
@@ -368,16 +361,16 @@ void Sofia::ConstructDetector(G4LogicalVolume* world){
           BuildTwinMusic(),
           "Twin",
            world, false, 0);
-    }
+    }*/
   }
 }
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 // Add Detector branch to the EventTree.
 // Called After DetecorConstruction::AddDetector Method
-void Sofia::InitializeRootOutput(){
+void SofTofW::InitializeRootOutput(){
   RootOutput *pAnalysis = RootOutput::getInstance();
   TTree *pTree = pAnalysis->GetTree();
-  if(!pTree->FindBranch("Sofia")){
+  if(!pTree->FindBranch("SofTofW")){
     pTree->Branch("SofTofW", "TSofTofWData", &m_Event) ;
   }
   pTree->SetBranchAddress("SofTofW", &m_Event) ;
@@ -386,7 +379,7 @@ void Sofia::InitializeRootOutput(){
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 // Read sensitive part and fill the Root tree.
 // Called at in the EventAction::EndOfEventAvtion
-void Sofia::ReadSensitive(const G4Event* ){
+void SofTofW::ReadSensitive(const G4Event* ){
   m_Event->Clear();
 
   ///////////
@@ -396,9 +389,9 @@ void Sofia::ReadSensitive(const G4Event* ){
   unsigned int size = Scorer->GetMult(); 
   for(unsigned int i = 0 ; i < size ; i++){
     vector<unsigned int> level = Scorer->GetLevel(i); 
-    double Energy = RandGauss::shoot(Scorer->GetEnergy(i),Sofia_NS::ResoEnergy);
-    if(Energy>Sofia_NS::EnergyThreshold){
-      double Time = RandGauss::shoot(Scorer->GetTime(i),Sofia_NS::ResoTime);
+    double Energy = RandGauss::shoot(Scorer->GetEnergy(i),SofTofW_NS::ResoEnergy);
+    if(Energy>SofTofW_NS::EnergyThreshold){
+      double Time = RandGauss::shoot(Scorer->GetTime(i),SofTofW_NS::ResoTime);
       int DetectorNbr = level[0];
       int PlasticNbr = level[1]-1;
       //m_Event->SetDetectorNbr(DetectorNbr);
@@ -413,7 +406,7 @@ void Sofia::ReadSensitive(const G4Event* ){
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 ////////////////////////////////////////////////////////////////   
-void Sofia::InitializeScorers() { 
+void SofTofW::InitializeScorers() { 
   // This check is necessary in case the geometry is reloaded
   bool already_exist = false; 
   m_TofScorer = CheckScorer("TofScorer",already_exist) ;
@@ -426,15 +419,12 @@ void Sofia::InitializeScorers() {
   level.push_back(1);
   level.push_back(0);
   G4VPrimitiveScorer* Calorimeter= new CalorimeterScorers::PS_Calorimeter("Calorimeter",level, 0) ;
-  G4VPrimitiveScorer* TwinCalorimeter= new CalorimeterScorers::PS_Calorimeter("TwinCalorimeter",level, 0) ;
+  //G4VPrimitiveScorer* TwinCalorimeter= new CalorimeterScorers::PS_Calorimeter("TwinCalorimeter",level, 0) ;
   G4VPrimitiveScorer* Interaction= new InteractionScorers::PS_Interactions("Interaction",ms_InterCoord, 0) ;
   //and register it to the multifunctionnal detector
   m_TofScorer->RegisterPrimitive(Calorimeter);
   m_TofScorer->RegisterPrimitive(Interaction);
   G4SDManager::GetSDMpointer()->AddNewDetector(m_TofScorer) ;
-
-  m_TwinScorer->RegisterPrimitive(TwinCalorimeter);
-  G4SDManager::GetSDMpointer()->AddNewDetector(m_TwinScorer) ;
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -443,8 +433,8 @@ void Sofia::InitializeScorers() {
 ////////////////////////////////////////////////////////////////////////////////
 //            Construct Method to be pass to the DetectorFactory              //
 ////////////////////////////////////////////////////////////////////////////////
-NPS::VDetector* Sofia::Construct(){
-  return  (NPS::VDetector*) new Sofia();
+NPS::VDetector* SofTofW::Construct(){
+  return  (NPS::VDetector*) new SofTofW();
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -452,13 +442,13 @@ NPS::VDetector* Sofia::Construct(){
 //            Registering the construct method to the factory                 //
 ////////////////////////////////////////////////////////////////////////////////
 extern"C" {
-  class proxy_nps_Sofia{
+  class proxy_nps_SofTofW{
     public:
-      proxy_nps_Sofia(){
-        NPS::DetectorFactory::getInstance()->AddToken("Sofia","Sofia");
-        NPS::DetectorFactory::getInstance()->AddDetector("Sofia",Sofia::Construct);
+      proxy_nps_SofTofW(){
+        NPS::DetectorFactory::getInstance()->AddToken("SofTofW","SofTofW");
+        NPS::DetectorFactory::getInstance()->AddDetector("SofTofW",SofTofW::Construct);
       }
   };
 
-  proxy_nps_Sofia p_nps_Sofia;
+  proxy_nps_SofTofW p_nps_SofTofW;
 }
diff --git a/NPSimulation/Detectors/Sofia/Sofia.hh b/NPSimulation/Detectors/Sofia/SofTofW.hh
similarity index 89%
rename from NPSimulation/Detectors/Sofia/Sofia.hh
rename to NPSimulation/Detectors/Sofia/SofTofW.hh
index 418210625..db5e3feda 100644
--- a/NPSimulation/Detectors/Sofia/Sofia.hh
+++ b/NPSimulation/Detectors/Sofia/SofTofW.hh
@@ -1,5 +1,5 @@
-#ifndef Sofia_h
-#define Sofia_h 1
+#ifndef SofTofW_h
+#define SofTofW_h 1
 /*****************************************************************************
  * Copyright (C) 2009-2020   this file is part of the NPTool Project       *
  *                                                                           *
@@ -14,7 +14,7 @@
  * Last update    :                                                          *
  *---------------------------------------------------------------------------*
  * Decription:                                                               *
- *  This class describe  Sofia simulation                             *
+ *  This class describe  SofTofW simulation                             *
  *                                                                           *
  *---------------------------------------------------------------------------*
  * Comment:                                                                  *
@@ -38,13 +38,13 @@ using namespace std;
 #include "TSofTofWData.h"
 #include "NPInputParser.h"
 
-class Sofia : public NPS::VDetector{
+class SofTofW : public NPS::VDetector{
   ////////////////////////////////////////////////////
   /////// Default Constructor and Destructor /////////
   ////////////////////////////////////////////////////
   public:
-    Sofia() ;
-    virtual ~Sofia() ;
+    SofTofW() ;
+    virtual ~SofTofW() ;
 
     ////////////////////////////////////////////////////
     /////// Specific Function of this Class ///////////
@@ -58,14 +58,11 @@ class Sofia : public NPS::VDetector{
 
     G4AssemblyVolume* BuildTOFDetector();
     G4LogicalVolume* BuildGLAD();
-    G4LogicalVolume* BuildTwinMusic();
   
   private:
     G4LogicalVolume* m_PlasticTof;
     G4LogicalVolume* m_GLAD;
     G4AssemblyVolume* m_TofWall;
-    G4LogicalVolume* m_TwinMusic;
-    G4LogicalVolume* m_AnodeDriftArea;
     
     ////////////////////////////////////////////////////
     //////  Inherite from NPS::VDetector class /////////
@@ -93,7 +90,6 @@ class Sofia : public NPS::VDetector{
 
     //   Associated Scorer
     G4MultiFunctionalDetector* m_TofScorer ;
-    G4MultiFunctionalDetector* m_TwinScorer ;
     ////////////////////////////////////////////////////
     ///////////Event class to store Data////////////////
     ////////////////////////////////////////////////////
@@ -114,15 +110,9 @@ class Sofia : public NPS::VDetector{
     double m_GLAD_MagField;
     double m_GLAD_DistanceFromTarget;
   
-    // Twin Music //
-    int m_Build_Twin_Music;
-    double m_Twin_Music_DistanceFromTarget;
-    string m_Twin_Music_Gas;
-
     // Visualisation Attribute
     G4VisAttributes* m_VisSquare;
     G4VisAttributes* m_VisGLAD;
-    G4VisAttributes* m_VisTwin;
 
   // Needed for dynamic loading of the library
   public:
diff --git a/Projects/Sofia/sofia.detector b/Projects/Sofia/sofia.detector
index b1e88110e..6ae144500 100644
--- a/Projects/Sofia/sofia.detector
+++ b/Projects/Sofia/sofia.detector
@@ -8,15 +8,15 @@ Target
  Y= 0 mm
  Z= 0 m
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-Sofia
+SofTofW
  R= 8 m
  THETA= -9 deg
  PHI= 0 deg
  Build_GLAD= 1
  GLAD_DistanceFromTarget= 3.3 m
  GLAD_MagField= 1.8 T 
- Build_Twin_Music= 1
- Twin_Music_DistanceFromTarget= 1.5 m
- Twin_Music_Gas= P10_1atm
+ Build_Twin_Music= 0
+ %Twin_Music_DistanceFromTarget= 1.5 m
+ %Twin_Music_Gas= P10_1atm
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
diff --git a/Projects/s455/Analysis.cxx b/Projects/s455/Analysis.cxx
index 6fe048409..71875203c 100644
--- a/Projects/s455/Analysis.cxx
+++ b/Projects/s455/Analysis.cxx
@@ -47,7 +47,6 @@ void Analysis::Init(){
 
   InitParameter();
   InitOutputBranch();
-  LoadCut();
   LoadSpline();
 
 }
@@ -151,29 +150,6 @@ void Analysis::FissionFragmentAnalysis(){
     }
   }
 
-  vector<double> good_posx;
-  vector<double> good_posy;
-  for(unsigned int i=0; i<PosX.size(); i++){
-    double tofx = PosX[i];
-    double tofy = PosY[i];
-    for(unsigned int k=0; k<Xmwpc4.size(); k++){
-      double posx = Xmwpc4[k];
-      if(abs(posx-tofx) < 100){
-        good_posx.push_back(posx);
-        SofFF->SetMwpcPosX(posx);
-        SofFF->SetTofPosX(tofx);
-      }
-    }
-    for(unsigned int p=0; p<Ymwpc4.size(); p++){
-      double posy = Ymwpc4[p];
-      if(abs(posy-tofy) < 20){
-        good_posy.push_back(posy);
-        SofFF->SetMwpcPosY(posy);
-        SofFF->SetTofPosY(tofy);
-      }
-    }
-  }
-
   int mult1 = SofTwim->mult1;
   int mult2 = SofTwim->mult2;
   int mult3 = SofTwim->mult3;
@@ -364,6 +340,38 @@ void Analysis::FissionFragmentAnalysis(){
       A1 = AoQ1 * iZ1;
       A2 = AoQ2 * iZ2;
 
+      vector<double> good_posx;
+      vector<double> good_posy;
+      for(unsigned int i=0; i<PosX.size(); i++){
+        double tofx = PosX[i];
+        double tofy = PosY[i];
+        for(unsigned int k=0; k<Xmwpc4.size(); k++){
+          double posx = Xmwpc4[k];
+          if(abs(posx-tofx) < 100){
+            good_posx.push_back(posx);
+            //SofFF->SetMwpcPosX(posx);
+            //SofFF->SetTofPosX(tofx);
+          }
+        }
+        for(unsigned int p=0; p<Ymwpc4.size(); p++){
+          double posy = Ymwpc4[p];
+          if(abs(posy-tofy) < 20){
+            //good_posy.push_back(posy);
+            good_posy.push_back(tofy);
+            //SofFF->SetMwpcPosY(posy);
+            //SofFF->SetTofPosY(tofy);
+          }
+        }
+      }
+
+      if(good_posx.size()==2 && good_posy.size()==2){
+        SofFF->SetTofPosX(good_posx[0]);
+        SofFF->SetTofPosX(good_posx[1]);
+ 
+        SofFF->SetTofPosY(good_posy[0]);
+        SofFF->SetTofPosY(good_posy[1]);
+      }
+
       //*** Filling the Fission Fragment Tree ***//
       SofFF->SetTOF(TOF_left);
       SofFF->SetTOF(TOF_right);
@@ -401,7 +409,7 @@ void Analysis::BeamAnalysis(){
     //cout << "Set beta to " << beta << endl;
     SofTrim->SetBeta(beta);
     SofTrim->BuildSimplePhysicalEvent();
-    double Zbeam,Qmax,Theta;
+    double Zbeam,Theta;
     if(SofTrim->EnergySection.size()>0){
       double Anode1 = SofTrim->EnergySection[0];
       double Anode2 = SofTrim->EnergySection[1];
@@ -411,7 +419,6 @@ void Analysis::BeamAnalysis(){
       else 
         Zbeam = SofTrim->GetMaxEnergySection();
 
-      //Qmax = DetermineQmax();
       Theta = SofTrim->Theta[0];
 
       double TofFromS2    = SofSci->CalTof[0];
@@ -435,7 +442,6 @@ void Analysis::BeamAnalysis(){
       double Gamma        = 1./(TMath::Sqrt(1 - TMath::Power(Beta,2)));
       double Brho = fBrho0 * (1 - XS2/fDS2 - XCC/fDCC);
       double AoQ  = Brho / (3.10716*Gamma*Beta);
-      double A    = AoQ * Qmax;
 
       // Y dependence correction //
       double Y_p0 = 23943.8;
@@ -445,6 +451,7 @@ void Analysis::BeamAnalysis(){
       // Z calibration //
       Zbeam = fZbeam_p0 + fZbeam_p1*Zbeam + fZbeam_p2*Zbeam*Zbeam;
       Zbeam = sqrt(Zbeam);
+      double A = AoQ * round(Zbeam);
 
       // Last beta correction //
       double Beta_norm = 0.8355;
@@ -452,7 +459,6 @@ void Analysis::BeamAnalysis(){
 
       // Filling Beam tree
       SofBeamID->SetZbeam(Zbeam);
-      //SofBeamID->SetQmax(rand.Gaus(Qmax,0.15));
       SofBeamID->SetAoQ(AoQ);
       SofBeamID->SetAbeam(A);
       SofBeamID->SetBeta(Beta);
@@ -465,37 +471,6 @@ void Analysis::BeamAnalysis(){
   }
 }
 
-////////////////////////////////////////////////////////////////////////////////
-void Analysis::LoadCut(){
-  TString input_path = "./calibration/SofTrim/cut/";
-
-  TString rootfile;
-  TString cutfile;
-  TFile* file;
-  for(int i=0; i<3; i++){
-    // Q=77
-    rootfile = Form("cutsec%iQ77.root",i+1);
-    cutfile = input_path + rootfile;
-    file = new TFile(cutfile);
-    cutQ77[i] = (TCutG*) file->Get(Form("cutsec%iQ77",i+1));
-    // Q=78
-    rootfile = Form("cutsec%iQ78.root",i+1);
-    cutfile = input_path + rootfile;
-    file = new TFile(cutfile);
-    cutQ78[i] = (TCutG*) file->Get(Form("cutsec%iQ78",i+1));
-    // Q=79
-    rootfile = Form("cutsec%iQ79.root",i+1);
-    cutfile = input_path + rootfile;
-    file = new TFile(cutfile);
-    cutQ79[i] = (TCutG*) file->Get(Form("cutsec%iQ79",i+1));
-    // Q=80
-    rootfile = Form("cutsec%iQ80.root",i+1);
-    cutfile = input_path + rootfile;
-    file = new TFile(cutfile);
-    cutQ80[i] = (TCutG*) file->Get(Form("cutsec%iQ80",i+1));
-  }
-}
-
 
 ////////////////////////////////////////////////////////////////////////////////
 void Analysis::LoadSpline(){
@@ -533,35 +508,6 @@ void Analysis::LoadSpline(){
 
 }
 
-////////////////////////////////////////////////////////////////////////////////
-int Analysis::DetermineQmax(){
-  int Qmax;
-  int Qsec[3];
-
-  unsigned int size = SofTrim->EnergySection.size();
-  for(unsigned int i=0; i<size; i++){
-    int SecNbr   = SofTrim->SectionNbr[i];
-    double Theta = SofTrim->Theta[i];
-    double Esec  = SofTrim->EnergySection[i];
-
-
-    if(cutQ77[SecNbr-1]->IsInside(Theta,Esec))
-      Qsec[SecNbr-1] = 77;
-    else if(cutQ78[SecNbr-1]->IsInside(Theta,Esec))
-      Qsec[SecNbr-1] = 78;
-    else if(cutQ79[SecNbr-1]->IsInside(Theta,Esec))
-      Qsec[SecNbr-1] = 79;
-    else if(cutQ80[SecNbr-1]->IsInside(Theta,Esec))
-      Qsec[SecNbr-1] = 80;
-    //else if(cutQ81[SecNbr-1]->IsInside(Theta,Esec))
-    //Qsec[SecNbr-1] = 81;
-  }
-
-  Qmax = max(Qsec[0],Qsec[1]);
-  Qmax = max(Qsec[2],Qmax);
-
-  return Qmax;
-}
 
 ////////////////////////////////////////////////////////////////////////////////
 void Analysis::End(){
diff --git a/Projects/s455/Analysis.h b/Projects/s455/Analysis.h
index d4f2707a7..db6b3ce1a 100644
--- a/Projects/s455/Analysis.h
+++ b/Projects/s455/Analysis.h
@@ -8,9 +8,9 @@
  *****************************************************************************/
 
 /*****************************************************************************
- * Original Author: XAUTHORX  contact address: XMAILX                        *
- *                                                                           *
- * Creation Date  : XMONTHX XYEARX                                           *
+ * Original Author: Pierre Morfouace  contact address: pierre.morfouace@cea.fr *
+ *                                                                             *
+ * Creation Date  : 06/2021                                             *
  * Last update    :                                                          *
  *---------------------------------------------------------------------------*
  * Decription:                                                               *
@@ -54,9 +54,7 @@ class Analysis: public NPL::VAnalysis{
     static NPL::VAnalysis* Construct();
 
   public:
-    void LoadCut();
     void LoadSpline();
-    int DetermineQmax();
 
   private:
     TSofSciPhysics* SofSci;
@@ -86,11 +84,6 @@ class Analysis: public NPL::VAnalysis{
     double fZBeta_p1;
 
     TRandom3 rand;
-    TCutG* cutQ77[3];
-    TCutG* cutQ78[3];
-    TCutG* cutQ79[3];
-    TCutG* cutQ80[3];
-    TCutG* cutQ81[3];
     
     TSpline3* fcorr_z_beta[4];
     TSpline3* fcorr_z_dt[4];
-- 
GitLab