From 977bda7b3e0019e925fb9221188f04c99d2b51a4 Mon Sep 17 00:00:00 2001
From: Pierre Morfouace <morfouac@ipno.in2p3.fr>
Date: Fri, 15 May 2015 15:06:25 -0400
Subject: [PATCH] Adding Hira classes for simulation

---
 Inputs/DetectorConfiguration/hira.detector | 120 ++++
 NPLib/HiRA/CMakeLists.txt                  |   9 +-
 NPLib/HiRA/THiraPhysics.cxx                | 314 +++++++++
 NPLib/HiRA/THiraPhysics.h                  | 100 +++
 NPSimulation/Hira/Hira.cc                  | 729 +++++++++++++++++++++
 NPSimulation/Hira/Hira.hh                  | 235 +++++++
 6 files changed, 1503 insertions(+), 4 deletions(-)
 create mode 100755 Inputs/DetectorConfiguration/hira.detector
 create mode 100644 NPLib/HiRA/THiraPhysics.cxx
 create mode 100644 NPLib/HiRA/THiraPhysics.h
 create mode 100644 NPSimulation/Hira/Hira.cc
 create mode 100644 NPSimulation/Hira/Hira.hh

diff --git a/Inputs/DetectorConfiguration/hira.detector b/Inputs/DetectorConfiguration/hira.detector
new file mode 100755
index 000000000..0dd038656
--- /dev/null
+++ b/Inputs/DetectorConfiguration/hira.detector
@@ -0,0 +1,120 @@
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+GeneralTarget
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Thickness in micrometer
+% Radius in mm
+% Temperature in K, Pressure in bar
+Target
+	THICKNESS= 0.2
+    	ANGLE= 0
+	RADIUS=	5
+	MATERIAL= CD2
+	X= 0
+	Y= 0
+	Z= 0
+	
+%%%%%%%%%%%%%%%%%%%%%			
+HIRAArray			
+%%%%%%%%%%%%%%%%%%%%%
+		
+%%%%%%% Telescope 1 %%%%%%%			
+HiraTelescope 			
+A=	173.37	146.75	262.67	
+B=	131.14	113.17	299.62
+C=	151.53	79.58	301.68
+D=	193.66	113.27	265.03
+
+%%%%%%% Telescope 2 %%%%%%%			
+HiraTelescope 			
+A=	185.54	74.46	284.21
+B=	139.49	39.19	313.95
+C=	155.91	3.85	309.52
+D=	202.07	39.18	280.08
+		
+%%%%%%% Telescope 3 %%%%%%%			
+HiraTelescope 			
+A=	189.04	-1.58	291.62
+B=	139.10	-36.55	314.66
+C=	151.29	-71.91	302.98
+D=	201.44	-36.97	280.35
+
+%%%%%%% Telescope 4 %%%%%%%			
+HiraTelescope 			
+A=	183.90	-77.07	283.93
+B=	130.43	-110.63	300.17
+C=	139.05	-144.12	281.73
+D=	192.75	-110.68	265.85
+
+%%%%%%% Telescope 5 %%%%%%%			
+HiraTelescope 			
+A=	89.03	146.90	300.27
+B=	37.97	113.38	323.02
+C=	56.43	79.76	330.94
+D=	107.59	113.39	308.52
+
+%%%%%%% Telescope 6 %%%%%%%			
+HiraTelescope 			
+A=	94.01	74.21	324.51
+B=	41.45	38.75	339.56
+C=	58.48	34.39	339.75
+D=	111.12	38.96	325.13
+
+%%%%%%% Telescope 7 %%%%%%%			
+HiraTelescope 			
+A=	95.57	-1.96	332.31
+B=	41.29	-37.33	339.64
+C=	56.63	-72.62	332.23
+D=	110.97	-37.25	325.09
+
+%%%%%%% Telescope 8 %%%%%%%			
+HiraTelescope 			
+A=	93.18	-77.88	323.56
+B=	37.45	-111.64	323.69
+C=	51.20	-145.11	308.69
+D=	107.05	-111.48	308.92
+
+%%%%%%% Telescope 9 %%%%%%%			
+HiraTelescope 			
+A=	-22.26	91.79	332.36
+B=	-77.07	56.46	330.57
+C=	-61.34	21.44	338.41
+D=	-6.58	56.83	340.66
+
+%%%%%%% Telescope 10 %%%%%%%			
+HiraTelescope 			
+A=	-23.10	-19.16	344.31
+B=	-76.45	-54.13	330.49
+C=	-59.35	-89.22	327.12	
+D=	-5.97	-54.26	341.22
+
+%%%%%%% Telescope 11 %%%%%%%			
+HiraTelescope 			
+A=	-96.45	147.32	297.42
+B=	-151.2	113.36	286.61
+C=	-140.2	79.81	303.70
+D=	-85.74	113.90	314.86
+
+%%%%%%% Telescope 12 %%%%%%%			
+HiraTelescope 			
+A=	-105.62	74.17	320.23
+B=	-157.09	38.47	302.22
+C=	-143.26	3.23	312.38
+D=	-91.94	38.96	330.70
+
+%%%%%%% Telescope 13 %%%%%%%			
+HiraTelescope 			
+A=	-108.60	-1.94	327.52
+B=	-156.99	-37.61	302.29
+C=	-140.04	-72.81	305.17
+D=	-91.79	-37.71	330.80
+
+%%%%%%% Telescope 14 %%%%%%%			
+HiraTelescope 			
+A=	-104.76	-78.01	319.19
+B=	-150.28	-111.80	287.13
+C=	-130.29	-145.22	282.83
+D=	-84.95	-111.59	315.32
+
+
diff --git a/NPLib/HiRA/CMakeLists.txt b/NPLib/HiRA/CMakeLists.txt
index 935e8dfa3..1c02027ee 100644
--- a/NPLib/HiRA/CMakeLists.txt
+++ b/NPLib/HiRA/CMakeLists.txt
@@ -1,5 +1,6 @@
-add_custom_command(OUTPUT THiraDataDict.cxx THiraDataDict_rdict.pcm THiraData.rootmap COMMAND ../scripts/build_dict.sh THiraData.h THiraDataDict.cxx THiraData.rootmap libNPHiRA.dylib DEPENDS THiraData.h)
-add_library(NPHiRA SHARED THiraData.cxx THiraDataDict.cxx )
-target_link_libraries(NPHiRA ${ROOT_LIBRARIES} NPCore) 
-install(FILES THiraData.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY})
+add_custom_command(OUTPUT THiraPhysicsDict.cxx THiraPhysicsDict_rdict.pcm THiraPhysics.rootmap COMMAND ../scripts/build_dict.sh THiraPhysics.h THiraPhysicsDict.cxx THiraPhysics.rootmap libNPHira.dylib DEPENDS THiraPhysics.h)
+add_custom_command(OUTPUT THiraDataDict.cxx THiraDataDict_rdict.pcm THiraData.rootmap COMMAND ../scripts/build_dict.sh THiraData.h THiraDataDict.cxx THiraData.rootmap libNPHira.dylib DEPENDS THiraData.h)
+add_library(NPHira SHARED THiraData.cxx THiraPhysics.cxx THiraDataDict.cxx THiraPhysicsDict.cxx )
+target_link_libraries(NPHira ${ROOT_LIBRARIES} NPCore) 
+install(FILES THiraData.h THiraPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY})
 
diff --git a/NPLib/HiRA/THiraPhysics.cxx b/NPLib/HiRA/THiraPhysics.cxx
new file mode 100644
index 000000000..818acd40c
--- /dev/null
+++ b/NPLib/HiRA/THiraPhysics.cxx
@@ -0,0 +1,314 @@
+/*****************************************************************************
+ * Copyright (C) 2009-2013   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  : november 2009                                            *
+ * Last update    :                                                          *
+ *---------------------------------------------------------------------------*
+ * Decription:                                                               *
+ *  This class hold Hira  Physics                                         *
+ *                                                                           *
+ *---------------------------------------------------------------------------*
+ * Comment:                                                                  *
+ *                                                                           *
+ *                                                                           *
+ *****************************************************************************/
+
+//   NPL
+#include "THiraPhysics.h"
+#include "RootInput.h"
+#include "RootOutput.h"
+#include "NPDetectorFactory.h"
+#include "NPCalibrationManager.h"
+
+//   STL
+#include <iostream>
+#include <sstream>
+#include <fstream>
+#include <limits>
+#include <stdlib.h>
+using namespace std;
+
+//   ROOT
+#include "TChain.h"
+
+//   tranform an integer to a string
+string itoa(int value)
+{
+   char buffer [33];
+   sprintf(buffer,"%d",value);
+   return buffer;
+}
+
+ClassImp(THiraPhysics)
+///////////////////////////////////////////////////////////////////////////
+THiraPhysics::THiraPhysics()
+   {      
+      NumberOfDetector = 0 ;
+      EventData = new THiraData ;
+      EventPhysics = this ;
+   }
+   
+///////////////////////////////////////////////////////////////////////////
+THiraPhysics::~THiraPhysics()
+   {}
+   
+///////////////////////////////////////////////////////////////////////////
+void THiraPhysics::Clear()
+   {
+
+   }
+   
+///////////////////////////////////////////////////////////////////////////
+void THiraPhysics::ReadConfiguration(string Path) 
+   {
+      ifstream ConfigFile           ;
+      ConfigFile.open(Path.c_str()) ;
+      string LineBuffer             ;
+      string DataBuffer             ;
+
+      bool check_Theta = false          ;
+      bool check_Phi  = false           ;
+      bool check_R     = false          ;
+      bool check_Thickness = false      ;
+      bool check_Radius = false         ;
+      bool check_LeadThickness = false  ;
+      bool check_Scintillator = false   ;
+      bool check_Height = false         ;
+      bool check_Width = false          ;
+      bool check_Shape = false          ;
+      bool check_X = false              ;
+      bool check_Y = false              ;
+      bool check_Z = false              ;      
+      bool ReadingStatus = false        ;
+
+    while (!ConfigFile.eof()) 
+       {
+         
+         getline(ConfigFile, LineBuffer);
+
+         //   If line is a Start Up Hira bloc, Reading toggle to true      
+         if (LineBuffer.compare(0, 3, "Hira") == 0)
+            {
+               cout << "///" << endl ;
+               cout << "Platic found: " << endl ;        
+               ReadingStatus = true ;
+            }
+            
+         //   Else don't toggle to Reading Block Status
+         else ReadingStatus = false ;
+         
+         //   Reading Block
+         while(ReadingStatus)
+            {
+               // Pickup Next Word 
+               ConfigFile >> DataBuffer ;
+
+               //   Comment Line 
+               if (DataBuffer.compare(0, 1, "%") == 0) {   ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );}
+
+                  //   Finding another telescope (safety), toggle out
+               else if (DataBuffer.compare(0, 6, "Hira") == 0) {
+                  cout << "WARNING: Another Detector is find before standard sequence of Token, Error may occured in Telecope definition" << endl ;
+                  ReadingStatus = false ;
+               }
+                              
+                                    //Angle method
+               else if (DataBuffer=="THETA=") {
+                  check_Theta = true;
+                  ConfigFile >> DataBuffer ;
+                  cout << "Theta:  " << atof(DataBuffer.c_str()) << "deg" << endl;
+               }
+
+               else if (DataBuffer=="PHI=") {
+                  check_Phi = true;
+                  ConfigFile >> DataBuffer ;
+                  cout << "Phi:  " << atof( DataBuffer.c_str() ) << "deg" << endl;
+               }
+
+               else if (DataBuffer=="R=") {
+                  check_R = true;
+                  ConfigFile >> DataBuffer ;
+                  cout << "R:  " << atof( DataBuffer.c_str() ) << "mm" << endl;
+               }
+               
+               //Position method
+               else if (DataBuffer=="X=") {
+                  check_X = true;
+                  ConfigFile >> DataBuffer ;
+                  cout << "X:  " << atof( DataBuffer.c_str() ) << "mm" << endl;
+               }
+
+               else if (DataBuffer=="Y=") {
+                  check_Y = true;
+                  ConfigFile >> DataBuffer ;
+                  cout << "Y:  " << atof( DataBuffer.c_str() ) << "mm"<< endl;
+               }
+
+               else if (DataBuffer=="Z=") {
+                  check_Z = true;
+                  ConfigFile >> DataBuffer ;
+                  cout << "Z:  " << atof( DataBuffer.c_str() ) << "mm" << endl;
+               }
+               
+               
+               //General
+               else if (DataBuffer=="Shape=") {
+                  check_Shape = true;
+                  ConfigFile >> DataBuffer ;
+                  cout << "Shape:  " << DataBuffer << endl;
+               }
+               
+               // Cylindrical shape
+               else if (DataBuffer== "Radius=") {
+                  check_Radius = true;
+                  ConfigFile >> DataBuffer ;
+                  cout << "Hira Radius:  " << atof( DataBuffer.c_str() ) << "mm" << endl;
+               }
+               
+               // Squared shape
+               else if (DataBuffer=="Width=") {
+                  check_Width = true;
+                  ConfigFile >> DataBuffer ;
+                  cout << "Hira Width:  " <<atof( DataBuffer.c_str() ) << "mm" << endl;
+               }
+               
+               else if (DataBuffer== "Height=") {
+                  check_Height = true;
+                  ConfigFile >> DataBuffer ;
+                  cout << "Hira Height:  " << atof( DataBuffer.c_str() ) << "mm" << endl;
+               }
+               
+               // Common
+               else if (DataBuffer=="Thickness=") {
+                  check_Thickness = true;
+                  ConfigFile >> DataBuffer ;
+                  cout << "Hira Thickness:  " << atof( DataBuffer.c_str() ) << "mm" << endl;
+               }
+               
+               else if (DataBuffer== "Scintillator=") {
+                  check_Scintillator = true ;
+                  ConfigFile >> DataBuffer ;
+                  cout << "Hira Scintillator type:  " << DataBuffer << endl;
+               }
+               
+               else if (DataBuffer=="LeadThickness=") {
+                  check_LeadThickness = true;
+                  ConfigFile >> DataBuffer ;
+                  cout << "Lead Thickness :  " << atof( DataBuffer.c_str() ) << "mm" << endl;
+               }
+                                                
+               ///////////////////////////////////////////////////
+               //   If no Detector Token and no comment, toggle out
+               else 
+                  {ReadingStatus = false; cout << "Wrong Token Sequence: Getting out " << DataBuffer << endl ;}
+               
+                  /////////////////////////////////////////////////
+                  //   If All necessary information there, toggle out
+               
+               if ( check_Theta && check_Phi && check_R && check_Thickness && check_Radius &&   check_LeadThickness && check_Scintillator &&   check_Height &&   check_Width && check_Shape && check_X && check_Y && check_Z ) 
+                  { 
+                     NumberOfDetector++;
+                     
+                     //   Reinitialisation of Check Boolean  
+                     check_Theta = false          ;
+                     check_Phi  = false           ;
+                     check_R     = false          ;
+                     check_Thickness = false      ;
+                     check_Radius = false         ;
+                     check_LeadThickness = false  ;
+                     check_Scintillator = false   ;
+                     check_Height = false         ;
+                     check_Width = false          ;
+                     check_Shape = false          ;
+                     check_X = false              ;
+                     check_Y = false              ;
+                     check_Z = false              ;
+                     ReadingStatus = false        ;   
+                     cout << "///"<< endl         ;                
+                  }
+            }
+      }
+   }
+
+///////////////////////////////////////////////////////////////////////////
+void THiraPhysics::AddParameterToCalibrationManager()
+   {
+      CalibrationManager* Cal = CalibrationManager::getInstance();
+      
+      for(int i = 0 ; i < NumberOfDetector ; i++)
+         {
+            for( int j = 0 ; j < 16 ; j++)
+               {
+                  Cal->AddParameter("Hira", "Detector"+itoa(i+1)+"_E","Hira_Detector"+itoa(i+1)+"_E")   ;
+                  Cal->AddParameter("Hira", "Detector"+itoa(i+1)+"_T","Hira_Detector"+itoa(i+1)+"_T")   ;   
+               }
+      
+         }
+   }
+   
+///////////////////////////////////////////////////////////////////////////
+void THiraPhysics::InitializeRootInputRaw() 
+   {
+      TChain* inputChain = RootInput::getInstance()->GetChain()     ;
+      inputChain->SetBranchStatus ( "Hira"       , true )        ;
+      inputChain->SetBranchStatus ( "fHira_*"    , true )        ;
+      inputChain->SetBranchAddress( "Hira"       , &EventData )  ;
+   }
+///////////////////////////////////////////////////////////////////////////
+void THiraPhysics::InitializeRootInputPhysics()
+   {
+      /*TChain* inputChain = RootInput::getInstance()->GetChain();
+      inputChain->SetBranchStatus ( "Hira", true );
+      inputChain->SetBranchStatus ( "DetectorNumber", true );
+      inputChain->SetBranchStatus ( "Energy", true );
+      inputChain->SetBranchStatus ( "Time", true );
+      inputChain->SetBranchAddress( "Hira", &EventPhysics );*/
+   }
+///////////////////////////////////////////////////////////////////////////
+void THiraPhysics::InitializeRootOutput()
+   {
+      TTree* outputTree = RootOutput::getInstance()->GetTree()            ;
+      outputTree->Branch( "Hira" , "THiraPhysics" , &EventPhysics ) ;
+   }
+
+///////////////////////////////////////////////////////////////////////////
+void THiraPhysics::BuildPhysicalEvent()
+   {
+      BuildSimplePhysicalEvent()   ;
+   }
+
+///////////////////////////////////////////////////////////////////////////
+void THiraPhysics::BuildSimplePhysicalEvent()
+   {
+      
+   }
+
+////////////////////////////////////////////////////////////////////////////////
+//            Construct Method to be pass to the DetectorFactory              //
+////////////////////////////////////////////////////////////////////////////////
+NPL::VDetector* THiraPhysics::Construct(){
+    return (NPL::VDetector*) new THiraPhysics();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//            Registering the construct method to the factory                 //
+////////////////////////////////////////////////////////////////////////////////
+extern "C"{
+    class proxy{
+    public:
+        proxy(){
+            NPL::DetectorFactory::getInstance()->AddToken("HIRAArray","Hira");
+            NPL::DetectorFactory::getInstance()->AddDetector("HIRAArray",THiraPhysics::Construct);
+        }
+    };
+    
+    proxy p;
+}
+
diff --git a/NPLib/HiRA/THiraPhysics.h b/NPLib/HiRA/THiraPhysics.h
new file mode 100644
index 000000000..d73396ffe
--- /dev/null
+++ b/NPLib/HiRA/THiraPhysics.h
@@ -0,0 +1,100 @@
+#ifndef __HiraPhysics__
+#define __HiraPhysics__
+/*****************************************************************************
+ * Copyright (C) 2009-2014    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: a.matta@surrey.ac.uk      *
+ *                                                                           *
+ * Creation Date  : November 2009                                            *
+ * Last update    :                                                          *
+ *---------------------------------------------------------------------------*
+ * Decription:                                                               *
+ *  This class hold theHira Detector  Physics                             *
+ *                                                                           *
+ *---------------------------------------------------------------------------*
+ * Comment:                                                                  *
+ *                                                                           *
+ *                                                                           *
+ *****************************************************************************/
+ 
+//   STL
+#include <vector>
+using namespace std ;
+
+//   ROOT
+#include "TObject.h"
+
+//   NPL
+#include "THiraData.h"
+#include "NPVDetector.h"
+
+//#include "../include/CalibrationManager.h"
+
+class THiraPhysics : public TObject, public NPL::VDetector
+{
+   public:   //   Constructor and Destructor
+      THiraPhysics();
+      ~THiraPhysics();
+
+   public:
+      void  Clear();
+      void  Clear(const Option_t*) {};
+   
+   public:   //   Calibrated Data
+      vector<UShort_t>   DetectorNumber ;
+      vector<Double_t>   Energy;
+      vector<Double_t>   Time;
+
+   public:   //   inherrited from VDetector
+      //   Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token
+      void ReadConfiguration(string);
+      
+
+      //   Add Parameter to the CalibrationManger
+      void AddParameterToCalibrationManager();      
+
+      //   Activated associated Branches and link it to the private member DetectorData address
+      //   In this method mother Branches (Detector) AND daughter leaf (fDetector_parameter) have to be activated
+      void InitializeRootInputRaw() ;
+      
+      //   Activated associated Branches and link it to the private member DetectorPhysics address
+      //   In this method mother Branches (Detector) AND daughter leaf (parameter) have to be activated
+      void InitializeRootInputPhysics() ;
+
+      //   Create associated branches and associated private member DetectorPhysics address
+      void InitializeRootOutput();
+      
+      //   This method is called at each event read from the Input Tree. Aime is to build treat Raw dat in order to extract physical parameter. 
+      void BuildPhysicalEvent();
+      
+      //   Same as above, but only the simplest event and/or simple method are used (low multiplicity, faster algorythm but less efficient ...).
+      //   This method aimed to be used for analysis performed during experiment, when speed is requiered.
+      //   NB: This method can eventually be the same as BuildPhysicalEvent.
+      void BuildSimplePhysicalEvent();
+
+      // Same as above but for online analysis
+      void BuildOnlinePhysicalEvent()  {BuildPhysicalEvent();};
+
+      // Give and external THiraData object to THiraPhysics. Needed for online analysis for example.
+      void SetRawDataPointer(THiraData* rawDataPointer) {EventData = rawDataPointer;}
+
+      //   Those two method all to clear the Event Physics or Data
+      void ClearEventPhysics() {Clear();}      
+      void ClearEventData()    {EventData->Clear();}      
+
+   private:   // Data not writted in the tree
+      int                   NumberOfDetector ;//!
+      THiraData*         EventData ;//!
+      THiraPhysics*      EventPhysics ;//!
+
+    public:// Static constructor to be passed to the Detector Factory
+    static NPL::VDetector* Construct();
+      ClassDef(THiraPhysics,1)  // HiraPhysics structure
+};
+
+#endif
diff --git a/NPSimulation/Hira/Hira.cc b/NPSimulation/Hira/Hira.cc
new file mode 100644
index 000000000..f80216ddf
--- /dev/null
+++ b/NPSimulation/Hira/Hira.cc
@@ -0,0 +1,729 @@
+/*****************************************************************************
+ * Copyright (C) 2009-2013   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: Pierre MORFOUACE  contact address:                       *
+ *                                                                           *
+ * Creation Date  : February 2015                                            *
+ * Last update    :                                                          *
+ *---------------------------------------------------------------------------*
+ * Decription:                                                               *
+ *  This class describe the HiRA telescope                                   *
+ *                                                                           *
+ *---------------------------------------------------------------------------*
+ * Comment:                                                                  *
+ *                                                                           *
+ *****************************************************************************/
+
+// C++ headers
+#include <sstream>
+#include <cmath>
+#include <limits>
+//G4 Geometry object
+#include "G4Box.hh"
+#include "G4Trd.hh"
+#include "G4Tubs.hh"
+#include "G4Cons.hh"
+#include "G4UnionSolid.hh" 
+#include "G4ExtrudedSolid.hh"
+#include "G4TwoVector.hh"
+//G4 sensitive
+#include "G4SDManager.hh"
+
+//G4 various object
+#include "G4Material.hh"
+#include "G4Transform3D.hh"
+#include "G4PVPlacement.hh"
+#include "G4Colour.hh"
+#include "G4PVDivision.hh"
+#include "G4SubtractionSolid.hh"
+
+// NPS
+#include "Hira.hh"
+#include "MaterialManager.hh"
+#include "SiliconScorers.hh"
+#include "CalorimeterScorers.hh"
+
+// NPL
+#include "NPOptionManager.h"
+#include "RootOutput.h"
+#include "NPSDetectorFactory.hh"
+//using namespace OBSOLETEGENERALSCORERS ;
+
+using namespace HIRA;
+
+// CLHEP header
+#include "CLHEP/Random/RandGauss.h"
+
+using namespace std;
+using namespace CLHEP;
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+Hira::Hira(){
+  InitializeMaterial();
+  m_EventHira = new THiraData();
+  
+  // Dark Grey
+  m_SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ;
+  // Green
+  m_CsIVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)) ;
+  m_LogicThinSi = 0;
+  m_LogicThickSi = 0;
+  m_LogicCsICrystal = 0;
+  m_LogicCluster = 0;
+}
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+Hira::~Hira(){
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+// Virtual Method of VDetector class
+// Read stream at Configfile to pick-up parameters of detector (Position,...)
+// Called in DetecorConstruction::ReadDetextorConfiguration Method
+void Hira::ReadConfiguration(string Path){
+  
+   ifstream ConfigFile           ;
+   ConfigFile.open(Path.c_str()) ;
+   string LineBuffer          ;
+   string DataBuffer          ;
+
+   // A:X1_Y1     --> X:1    Y:1
+   // B:X128_Y1   --> X:128  Y:1
+   // C:X1_Y128   --> X:1    Y:128
+   // D:X128_Y128    --> X:128  Y:128
+
+   G4double Ax , Bx , Cx , Dx , Ay , By , Cy , Dy , Az , Bz , Cz , Dz          ;
+   G4ThreeVector A , B , C , D                                                 ;
+   //G4double Theta = 0 , Phi = 0 , R = 0                     ;
+
+   bool ReadingStatus = false ;
+
+   bool check_A = false ;
+   bool check_C = false ;
+   bool check_B = false ;
+   bool check_D = false ;
+
+   /*bool check_Theta = false ;
+   bool check_Phi   = false ;
+   bool check_R     = false ;*/
+   
+
+
+   while (!ConfigFile.eof()) {
+      getline(ConfigFile, LineBuffer);
+      if (LineBuffer.compare(0, 13, "HiraTelescope") == 0) {
+         G4cout << "///" << G4endl           ;
+         G4cout << "Hira element found: " << G4endl   ;
+         ReadingStatus = true ;
+         }
+         
+   while(ReadingStatus){      
+
+         ConfigFile >> DataBuffer;
+         //   Comment Line 
+      if (DataBuffer.compare(0, 1, "%") == 0) {/*do nothing */;}
+      
+         // Position method
+         else if (DataBuffer.compare(0, 2, "A=") == 0) {
+            check_A = true;
+            ConfigFile >> DataBuffer ;
+            Ax = atof(DataBuffer.c_str()) ;
+            Ax = Ax * mm ;
+            ConfigFile >> DataBuffer ;
+            Ay = atof(DataBuffer.c_str()) ;
+            Ay = Ay * mm ;
+            ConfigFile >> DataBuffer ;
+            Az = atof(DataBuffer.c_str()) ;
+            Az = Az * mm ;
+
+            A = G4ThreeVector(Ax, Ay, Az);
+            G4cout << "A corner position : " << A << G4endl;
+         }
+        
+         else if (DataBuffer.compare(0, 2, "B=") == 0) {
+            check_B = true;
+            ConfigFile >> DataBuffer ;
+            Bx = atof(DataBuffer.c_str()) ;
+            Bx = Bx * mm ;
+            ConfigFile >> DataBuffer ;
+            By = atof(DataBuffer.c_str()) ;
+            By = By * mm ;
+            ConfigFile >> DataBuffer ;
+            Bz = atof(DataBuffer.c_str()) ;
+            Bz = Bz * mm ;
+
+            B = G4ThreeVector(Bx, By, Bz);
+            G4cout << "B corner position : " << B << G4endl;
+         }
+         
+         else if (DataBuffer.compare(0, 2, "C=") == 0) {
+            check_C = true;
+            ConfigFile >> DataBuffer ;
+            Cx = atof(DataBuffer.c_str()) ;
+            Cx = Cx * mm ;
+            ConfigFile >> DataBuffer ;
+            Cy = atof(DataBuffer.c_str()) ;
+            Cy = Cy * mm ;
+            ConfigFile >> DataBuffer ;
+            Cz = atof(DataBuffer.c_str()) ;
+            Cz = Cz * mm ;
+
+            C = G4ThreeVector(Cx, Cy, Cz);
+            G4cout << "C corner position : " << C << G4endl;
+         }
+        
+         else if (DataBuffer.compare(0, 2, "D=") == 0) {
+            check_D = true;
+            ConfigFile >> DataBuffer ;
+            Dx = atof(DataBuffer.c_str()) ;
+            Dx = Dx * mm ;
+            ConfigFile >> DataBuffer ;
+            Dy = atof(DataBuffer.c_str()) ;
+            Dy = Dy * mm ;
+            ConfigFile >> DataBuffer ;
+            Dz = atof(DataBuffer.c_str()) ;
+            Dz = Dz * mm ;
+
+            D = G4ThreeVector(Dx, Dy, Dz);
+            G4cout << "D corner position : " << D << G4endl;
+         }
+         
+
+       // Angle method
+      /*   else if (DataBuffer.compare(0, 6, "THETA=") == 0) {
+            check_Theta = true;
+            ConfigFile >> DataBuffer ;
+            Theta = atof(DataBuffer.c_str()) ;
+            Theta = Theta * deg;
+            G4cout << "Theta:  " << Theta / deg << G4endl;
+         }
+
+         else if (DataBuffer.compare(0, 4, "PHI=") == 0) {
+            check_Phi = true;
+            ConfigFile >> DataBuffer ;
+            Phi = atof(DataBuffer.c_str()) ;
+            Phi = Phi * deg;
+            G4cout << "Phi:  " << Phi / deg << G4endl;
+         }
+
+         else if (DataBuffer.compare(0, 2, "R=") == 0) {
+            check_R = true;
+            ConfigFile >> DataBuffer ;
+            R = atof(DataBuffer.c_str()) ;
+            R = R * mm;
+            G4cout << "R:  " << R / mm << G4endl;
+         }
+
+         else if (DataBuffer.compare(0, 5, "BETA=") == 0) {
+            ConfigFile >> DataBuffer ;
+            beta_u = atof(DataBuffer.c_str()) ;
+            beta_u = beta_u * deg   ;
+            ConfigFile >> DataBuffer ;
+            beta_v = atof(DataBuffer.c_str()) ;
+            beta_v = beta_v * deg   ;
+            ConfigFile >> DataBuffer ;
+            beta_w = atof(DataBuffer.c_str()) ;
+            beta_w = beta_w * deg   ;
+            G4cout << "Beta:  " << beta_u / deg << " " << beta_v / deg << " " << beta_w / deg << G4endl  ;
+         }*/
+
+         
+         else G4cout << "WARNING: Wrong Token, GaspardTrackerRectangle: Rectangle Element not added" << G4endl;
+
+         //Add The previously define telescope
+         //With position method
+         if (check_A && check_B && check_C && check_D) {
+         
+          ReadingStatus = false ;
+          check_A = false ;
+          check_C = false ;
+          check_B = false ;
+          check_D = false ;
+
+            AddTelescope(A                ,
+                      	 B                ,
+                         C                ,
+                         D);
+         }
+
+         //with angle method
+        /*if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && checkVis) && !(check_A && check_B && check_C && check_D)) {
+            ReadingStatus = false ;
+             check_Theta = false ;
+             check_Phi   = false ;
+             check_R     = false ;
+           check_FirstStage = false ;
+          check_SecondStage = false ;
+           check_ThirdStage = false ;
+           checkVis = false ;
+           
+            AddModule(R                ,
+                      Theta            ,
+                      Phi              ,
+                      beta_u           ,
+                      beta_v           ,
+                      beta_w           ,
+                      FIRSTSTAGE  == 1 ,
+                      SECONDSTAGE == 1 ,
+                      THIRDSTAGE  == 1);
+         }*/
+
+         
+      }
+   }
+}
+       
+
+
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+void Hira::AddTelescope(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4){
+  G4ThreeVector Pos=(Pos1+Pos2+Pos3+Pos4)/4.;
+  G4ThreeVector u = Pos4-Pos2;
+  G4ThreeVector w = Pos.unit();
+  G4ThreeVector v = w.cross(u);
+  u = u.unit(); v = v.unit(); w = w.unit();
+  Pos = Pos + w*Length*0.5;
+
+  m_Type.push_back(1); 
+  m_Pos.push_back(Pos);
+  m_Rot.push_back(new G4RotationMatrix(u,v,w));
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+// Construct detector and inialise sensitive part.
+// Called After DetecorConstruction::AddDetector Method
+void Hira::ConstructDetector(G4LogicalVolume* world){
+	unsigned int mysize = m_Pos.size();
+	 
+	for(unsigned int i = 0 ; i < mysize ; i++){
+		VolumeMaker(i + 1, m_Pos[i], m_Rot[i], world);
+	}
+}
+
+
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+// Read sensitive part and fill the Root tree.
+// Called at in the EventAction::EndOfEventAvtion
+void Hira::ReadSensitive(const G4Event* event){
+  m_EventHira->Clear();
+	
+  // ThinSi //
+  G4THitsMap<G4double*>* ThinSiHitMap;
+  std::map<G4int, G4double**>::iterator ThinSi_itr;
+
+  G4int ThinSiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Hira_ThinSiScorer/ThinSi");
+  ThinSiHitMap = (G4THitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(ThinSiCollectionID));
+
+  // Loop on the ThinSi map 
+  for (ThinSi_itr = ThinSiHitMap->GetMap()->begin() ; ThinSi_itr != ThinSiHitMap->GetMap()->end() ; ThinSi_itr++){
+    G4double* Info = *(ThinSi_itr->second); 
+    double E_ThinSi = RandGauss::shoot(Info[0],ResoThinSi);
+
+    if(E_ThinSi>EnergyThreshold){
+	m_EventHira->SetHiraThinSiStripEEnergy(E_ThinSi); 
+      	m_EventHira->SetHiraThinSiStripEDetectorNbr(Info[7]);
+	m_EventHira->SetHiraThinSiStripEStripNbr(Info[8]);
+	
+	m_EventHira->SetHiraThinSiStripTTime(Info[1]);
+	m_EventHira->SetHiraThinSiStripTDetectorNbr(Info[7]);
+	m_EventHira->SetHiraThinSiStripTStripNbr(Info[8]);
+    }
+  }
+
+  // Clear Map for next event
+  ThinSiHitMap->clear();
+
+  // ThickSi //
+  G4THitsMap<G4double*>* ThickSiHitMap;
+  std::map<G4int, G4double**>::iterator ThickSi_itr;
+  G4int ThickSiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Hira_ThickSiScorer/ThickSi");
+  ThickSiHitMap = (G4THitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(ThickSiCollectionID));
+
+  // Loop on the ThickSi map 
+  for (ThickSi_itr = ThickSiHitMap->GetMap()->begin() ; ThickSi_itr != ThickSiHitMap->GetMap()->end() ; ThickSi_itr++){
+    G4double* Info = *(ThickSi_itr->second); 
+    double E_ThickSi = RandGauss::shoot(Info[0],ResoThickSi);
+    if(E_ThickSi>EnergyThreshold){
+	m_EventHira->SetHiraThickSiStripXEEnergy(E_ThickSi); 
+      	m_EventHira->SetHiraThickSiStripXEDetectorNbr(Info[7]);
+	m_EventHira->SetHiraThickSiStripXEStripNbr(Info[8]);
+	
+	m_EventHira->SetHiraThickSiStripXTTime(Info[1]);
+	m_EventHira->SetHiraThickSiStripXTDetectorNbr(Info[7]);
+	m_EventHira->SetHiraThickSiStripXTStripNbr(Info[8]);
+
+	m_EventHira->SetHiraThickSiStripYEEnergy(E_ThickSi); 
+      	m_EventHira->SetHiraThickSiStripYEDetectorNbr(Info[7]);
+	m_EventHira->SetHiraThickSiStripYEStripNbr(Info[9]);
+	
+	m_EventHira->SetHiraThickSiStripYTTime(Info[1]);
+	m_EventHira->SetHiraThickSiStripYTDetectorNbr(Info[7]);
+	m_EventHira->SetHiraThickSiStripYTStripNbr(Info[9]);
+    }
+  }
+  // Clear Map for next event
+  ThickSiHitMap->clear();
+
+  // CsI //
+  G4THitsMap<G4double*>* CsIHitMap;
+  std::map<G4int, G4double**>::iterator CsI_itr;
+  G4int CsICollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Hira_CsIScorer/CsI");
+  CsIHitMap = (G4THitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(CsICollectionID));
+
+  // Loop on the CsI map 
+  for (CsI_itr = CsIHitMap->GetMap()->begin() ; CsI_itr != CsIHitMap->GetMap()->end() ; CsI_itr++){
+    G4double* Info = *(CsI_itr->second); 
+    double E_CsI = RandGauss::shoot(Info[0],ResoCsI);
+    if(E_CsI>EnergyThreshold){
+	m_EventHira->SetHiraCsIEEnergy(E_CsI); 
+      	m_EventHira->SetHiraCsIEDetectorNbr(Info[3]);
+	m_EventHira->SetHiraCsIECristalNbr(Info[2]);
+    }
+  }
+  // Clear Map for next event
+  CsIHitMap->clear();
+
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+void Hira::InitializeScorers(){
+  //Look for previous definition of the scorer (geometry reload)
+  bool already_exist = false;
+  vector<G4int> NestingLevel;
+  NestingLevel.push_back(2);
+  NestingLevel.push_back(3);
+
+  m_ThinSiStripScorer = CheckScorer("Hira_ThinSiScorer",already_exist);
+  m_ThickSiStripScorer = CheckScorer("Hira_ThickSiScorer",already_exist);
+  m_CsIScorer = CheckScorer("Hira_CsIScorer",already_exist);
+
+  // if the scorer were created previously nothing else need to be made
+  if(already_exist) return;
+
+  G4VPrimitiveScorer* ThinSiScorer = new SILICONSCORERS::PS_Silicon_Rectangle("ThinSi",0,
+      SiliconFace,
+      SiliconFace,
+      NumberOfStrip,
+      1);
+
+  m_ThinSiStripScorer->RegisterPrimitive(ThinSiScorer);
+
+  G4VPrimitiveScorer* ThickSiScorer = new SILICONSCORERS::PS_Silicon_Rectangle("ThickSi",0,
+      SiliconFace,
+      SiliconFace,
+      NumberOfStrip,
+      NumberOfStrip);
+
+  m_ThickSiStripScorer->RegisterPrimitive(ThickSiScorer);
+
+  G4VPrimitiveScorer* CsIScorer= new CALORIMETERSCORERS::PS_Calorimeter("CsI",NestingLevel);
+
+  m_CsIScorer->RegisterPrimitive(CsIScorer);
+
+  //   Add All Scorer to the Global Scorer Manager 
+  G4SDManager::GetSDMpointer()->AddNewDetector(m_ThinSiStripScorer) ;
+  G4SDManager::GetSDMpointer()->AddNewDetector(m_ThickSiStripScorer) ;
+  G4SDManager::GetSDMpointer()->AddNewDetector(m_CsIScorer) ;
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+void Hira::InitializeRootOutput(){
+  TTree *pTree = RootOutput::getInstance()->GetTree();   
+  pTree->Branch("Hira", "THiraData", &m_EventHira) ;
+ 
+  // This insure that the object are correctly bind in case of 
+  // a redifinition of the geometry in the simulation
+  pTree->SetBranchAddress("Hira", &m_EventHira) ;
+}
+
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+void Hira::VolumeMaker(G4int DetectorNumber,
+                       G4ThreeVector MMpos,
+                       G4RotationMatrix* MMrot,
+                       G4LogicalVolume* world)
+{
+  	G4double NbrTelescopes = DetectorNumber  ;
+  	G4String DetNumber                   ;
+   	ostringstream Number                      ;
+  	Number << NbrTelescopes                   ;
+   	DetNumber = Number.str()             ;
+
+
+  	////////////////////////////////////////////////////////////////
+   	////////////// Starting Volume Definition //////////////////////
+   	////////////////////////////////////////////////////////////////
+   	G4String Name = "Hira" + DetNumber ;
+
+   	// Definition of the volume containing the sensitive detector
+   	G4Box*           solidMotherVolume = new G4Box(Name, 0.5*FaceFront, 0.5*FaceBack, 0.5*Length);
+   	G4LogicalVolume* m_logicMotherVolume = new G4LogicalVolume(solidMotherVolume, m_MaterialVacuum, Name, 0, 0, 0);
+
+   	new G4PVPlacement(G4Transform3D(*MMrot, MMpos), m_logicMotherVolume, Name, world, false, DetectorNumber);
+
+   	G4VisAttributes* MotherVolumeVisAtt = new G4VisAttributes(G4Colour(0.90, 0.90, 0.90));
+  	 MotherVolumeVisAtt->SetForceWireframe(true); 
+   	m_logicMotherVolume->SetVisAttributes(G4VisAttributes::Invisible);
+
+	///////////////////////////////////////////////////
+	///////////////////// Thin Si /////////////////////
+	///////////////////////////////////////////////////
+	G4String NameThinSi = "ThinSi"+DetNumber;
+	//if(!m_LogicThinSi){
+	if(0==0){
+		G4Box* solidThinSi = new G4Box(NameThinSi, 0.5*SiliconFace, 0.5*SiliconFace, 0.5*ThinSiThickness);	;
+		m_LogicThinSi = new G4LogicalVolume(solidThinSi, m_MaterialSilicon, "logicThinSi", 0, 0, 0);
+
+		G4ThreeVector positionThinSi = G4ThreeVector(0, 0, ThinSi_PosZ);
+
+		new G4PVPlacement(new G4RotationMatrix(0,0,0),
+               		      	 positionThinSi,
+                    		 m_LogicThinSi,"ThinSi",
+                   		 m_logicMotherVolume,false,DetectorNumber);
+
+		// Set ThinSi sensible
+        	m_LogicThinSi->SetSensitiveDetector(m_ThinSiStripScorer);
+	
+		// Visualisation of ThinSi
+        	m_LogicThinSi->SetVisAttributes(m_SiliconVisAtt) ;   
+	}
+
+	///////////////////////////////////////////////////
+	///////////////////// Thick Si ////////////////////
+	///////////////////////////////////////////////////
+	G4String NameThickSi = "ThickSi"+DetNumber;
+	//if(!m_LogicThickSi){
+	if(0==0){
+		G4Box* solidThickSi = new G4Box(NameThickSi, 0.5*SiliconFace, 0.5*SiliconFace, 0.5*ThickSiThickness);	
+		m_LogicThickSi = new G4LogicalVolume(solidThickSi, m_MaterialSilicon, "logicThickSi", 0, 0, 0);
+
+		G4ThreeVector positionThickSi = G4ThreeVector(0, 0, ThickSi_PosZ);
+
+		new G4PVPlacement(new G4RotationMatrix(0,0,0),
+                      	positionThickSi,
+                      	m_LogicThickSi,"ThickSi",
+                      	m_logicMotherVolume,false,DetectorNumber);
+
+		// Set ThickSi sensible
+        	m_LogicThickSi->SetSensitiveDetector(m_ThickSiStripScorer);
+	
+		// Visualisation of ThickSi
+        	m_LogicThickSi->SetVisAttributes(m_SiliconVisAtt) ; 
+	}
+
+	///////////////////////////////////////////////////
+	/////////////////////// CsI ///////////////////////
+	///////////////////////////////////////////////////
+	G4String NameCsI = "CsI"+DetNumber;
+	G4Trd* solidCsIStage = new G4Trd(NameCsI, 0.5*CsIFaceFront, 0.5*CsIFaceBack, 0.5*CsIFaceFront, 0.5*CsIFaceBack, 0.5*CsIThickness);
+    	m_LogicCsICrystal = new G4LogicalVolume(solidCsIStage, m_MaterialCsI, "logicCsICrystal", 0, 0, 0);
+    	
+	// Set CsI sensible
+    	m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer);
+    
+ 	// Visualisation of CsI
+   	m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt);
+
+	//if(!m_LogicCluster){
+	if(0==0){
+	// Sub Mother Volume
+    	G4Trd* solidCluster = new G4Trd("SolidCluster", 0.5*ClusterFaceFront,0.5*ClusterFaceBack,0.5*ClusterFaceFront,0.5*ClusterFaceBack, 0.5*CsIThickness);
+    	m_LogicCluster = new G4LogicalVolume(solidCluster, m_MaterialVacuum, "LogicSolidCluster", 0, 0, 0);
+   	m_LogicCluster->SetVisAttributes(G4VisAttributes::Invisible);
+
+	G4ThreeVector FramePos(0,0,CsI_PosZ);
+
+	new G4PVPlacement(new G4RotationMatrix(0,0,0),
+                      	FramePos,
+                      	m_LogicCluster,"Cluster",
+                      	m_logicMotherVolume,false,0);
+
+
+	//G4ThreeVector Origin(-CsIFaceFront,-CsIFaceFront,0);
+	G4ThreeVector Origin(-0.5*CsIFaceFront,-0.5*CsIFaceFront,0);
+	
+	// A cluster is a 2 by 2 aggregat of CsI crystal
+    		unsigned int CsINbr = 1;
+    		for(unsigned int i = 0 ; i < 2 ; i++){
+      			for(unsigned int j = 0 ; j <2 ; j++){
+        			G4ThreeVector Pos = Origin + G4ThreeVector(i*CsIFaceFront,j*CsIFaceFront,0);
+        			new G4PVPlacement(0, 
+        			 	Pos, 
+           			 	m_LogicCsICrystal, 
+            				"CsI_Cristal", 
+            			 	m_LogicCluster, 
+            			 	false, 
+            				CsINbr++); 
+      			}
+    		}
+	/*G4LogicalVolume* LogicClusterFrame = new G4LogicalVolume(solidCluster, m_MaterialCsI, "LogicSolidClusterFrame", 0, 0, 0);
+    	LogicClusterFrame->SetVisAttributes(m_CsIVisAtt);
+
+    	new G4PVPlacement(0, 
+        		FramePos, 
+       		 	LogicClusterFrame, 
+        		"ClusterFrame", 
+        		m_LogicCluster, 
+        		false, 
+        		0);*/
+	}
+
+   //ConstructThinSi();
+   //ConstructThickSi();
+   //ConstructCsICrystal();
+
+	
+}
+
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+void Hira::ConstructCsICrystal(){
+	if(!m_LogicCsICrystal){
+
+		G4Trd* solidCsICrystal = new G4Trd("solidCsICrystal",0.5*CsIFaceFront,0.5*CsIFaceBack,0.5*CsIFaceFront,0.5*CsIFaceBack, 0.5*CsIThickness);
+ 		m_LogicCsICrystal = new G4LogicalVolume(solidCsICrystal, m_MaterialVacuum, "logicCsI", 0, 0, 0);
+    		m_LogicCsICrystal->SetVisAttributes(G4VisAttributes::Invisible);
+    
+    		    // CsI
+    		G4Trd* solidCsIStage = new G4Trd("solidLaBr3Stage", 0.5*CsIFaceFront, 0.5*CsIFaceBack, 0.5*CsIFaceFront, 0.5*CsIFaceBack, 0.5*CsIThickness);
+    		G4LogicalVolume* logicCsIStage = new G4LogicalVolume(solidCsIStage, m_MaterialCsI, "logicCsIStage", 0, 0, 0);
+    	
+    		G4ThreeVector positionCsICrystal = G4ThreeVector(0, 0, CsI_PosZ);
+    
+    		new G4PVPlacement(new G4RotationMatrix(0,0,0),
+                      		positionCsICrystal,
+                      		logicCsIStage,"CsICrystal",
+                      		m_LogicCsICrystal,false,0);
+    
+    		// Set CsI sensible
+    		logicCsIStage->SetSensitiveDetector(m_CsIScorer);
+    
+    		// Visualisation of CsI
+    		logicCsIStage->SetVisAttributes(m_CsIVisAtt);
+	}
+
+	if(!m_LogicCluster){
+
+	// Mother Volume
+    	G4Trd* solidCluster = new G4Trd("SolidCluster", 0.5*CsIFaceFront,0.5*CsIFaceBack,0.5*CsIFaceFront,0.5*CsIFaceBack, 0.5*CsIThickness);
+    	m_LogicCluster = new G4LogicalVolume(solidCluster, m_MaterialVacuum, "LogicSolidCluster", 0, 0, 0);
+   	m_LogicCluster->SetVisAttributes(G4VisAttributes::Invisible);
+
+	G4ThreeVector Origin(-CsIFaceFront,-CsIFaceFront,0);
+	G4ThreeVector FramePos(0,0,CsI_PosZ);
+	// A cluster is a 2 by 2 aggregat of CsI crystal
+    		unsigned int CsINbr = 1;
+    		for(unsigned int i = 0 ; i < 2 ; i++){
+      			for(unsigned int j = 0 ; j <2 ; j++){
+        			G4ThreeVector Pos = Origin + G4ThreeVector(i*CsIFaceFront,j*CsIFaceFront,0);
+        			new G4PVPlacement(0, 
+        			 	Pos, 
+           			 	m_LogicCsICrystal, 
+            				"CsI_Cristal", 
+            			 	m_LogicCluster, 
+            			 	false, 
+            				CsINbr++); 
+      			}
+    		}
+		G4LogicalVolume* LogicClusterFrame = new G4LogicalVolume(solidCluster, m_MaterialCsI, "LogicSolidClusterFrame", 0, 0, 0);
+    		LogicClusterFrame->SetVisAttributes(m_CsIVisAtt);
+
+    		new G4PVPlacement(0, 
+        		FramePos, 
+       		 	LogicClusterFrame, 
+        		"ClusterFrame", 
+        		m_LogicCluster, 
+        		false, 
+        		0);
+	}
+    
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+void Hira::ConstructThinSi(){
+cout << "coucou1" << endl;
+	G4String Name = "ThinSi";
+	if(!m_LogicThinSi){
+cout << "coucou2" << endl;
+		G4Box* solidThinSi = new G4Box(Name, 0.5*SiliconFace, 0.5*SiliconFace, 0.5*ThinSiThickness);	;
+		m_LogicThinSi = new G4LogicalVolume(solidThinSi, m_MaterialSilicon, "logicThinSi", 0, 0, 0);
+
+		G4ThreeVector positionThinSi = G4ThreeVector(0, 0, ThinSi_PosZ);
+cout << "coucou3" << endl;
+		new G4PVPlacement(new G4RotationMatrix(0,0,0),
+               		      	 positionThinSi,
+                    		 m_LogicThinSi,"ThinSi",
+                   		 m_logicMotherVolume,false,0);
+cout << "coucou4" << endl;
+		// Set ThinSi sensible
+        	m_LogicThinSi->SetSensitiveDetector(m_ThinSiStripScorer);
+	
+		// Visualisation of ThinSi
+        	m_LogicThinSi->SetVisAttributes(m_SiliconVisAtt) ;   
+	}
+
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+void Hira::ConstructThickSi(){
+
+	G4String Name = "ThickSi";
+	if(!m_LogicThickSi){
+		G4Box* solidThickSi = new G4Box(Name, 0.5*SiliconFace, 0.5*SiliconFace, 0.5*ThickSiThickness);	
+		m_LogicThickSi = new G4LogicalVolume(solidThickSi, m_MaterialSilicon, "logicThickSi", 0, 0, 0);
+
+		G4ThreeVector positionThickSi = G4ThreeVector(0, 0, ThickSi_PosZ);
+
+		new G4PVPlacement(new G4RotationMatrix(0,0,0),
+                      	positionThickSi,
+                      	m_LogicThickSi,"ThickSi",
+                      	m_logicMotherVolume,false,0);
+
+		// Set ThickSi sensible
+        	m_LogicThickSi->SetSensitiveDetector(m_ThickSiStripScorer);
+	
+		// Visualisation of ThickSi
+        	m_LogicThickSi->SetVisAttributes(m_SiliconVisAtt) ; 
+	}
+  
+}
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+void Hira::InitializeMaterial(){
+    m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si");
+    m_MaterialAluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al");
+    m_MaterialCsI = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI");
+    m_MaterialMylar = MaterialManager::getInstance()->GetMaterialFromLibrary("Mylar");
+    m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB");
+    m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum");
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//            Construct Method to be pass to the DetectorFactory              //
+////////////////////////////////////////////////////////////////////////////////
+NPS::VDetector* Hira::Construct(){
+    return  (NPS::VDetector*) new Hira();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//            Registering the construct method to the factory                 //
+////////////////////////////////////////////////////////////////////////////////
+extern"C" {
+    class proxy{
+    public:
+        proxy(){
+            NPS::DetectorFactory::getInstance()->AddToken("HIRAArray","Hira");
+            NPS::DetectorFactory::getInstance()->AddDetector("HIRAArray",Hira::Construct);
+        }
+    };
+    
+    proxy p;
+}
+
+
+
diff --git a/NPSimulation/Hira/Hira.hh b/NPSimulation/Hira/Hira.hh
new file mode 100644
index 000000000..61ed65061
--- /dev/null
+++ b/NPSimulation/Hira/Hira.hh
@@ -0,0 +1,235 @@
+#ifndef Sharc_h
+#define Sharc_h 1
+/*****************************************************************************
+ * Copyright (C) 2009-2013   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: Pierre MORFOUACE  contact address:						 *
+ *                                                                           *
+ * Creation Date  : Feb 2015												 *
+ * Last update    :                                                          *
+ *---------------------------------------------------------------------------*
+ * Decription:                                                               *
+ *  This class describe the Sharc Silicon detector                           *
+ *                                                                           *
+ *---------------------------------------------------------------------------*
+ * Comment:                                                                  *
+ *                                                                           *
+ *****************************************************************************/
+// C++ header
+#include <string>
+#include <vector>
+
+// G4 header defining G4 types
+#include "globals.hh"
+
+// G4 headers
+#include "G4ThreeVector.hh"
+#include "G4RotationMatrix.hh"
+#include "G4LogicalVolume.hh"
+#include "G4VisAttributes.hh"
+#include "G4MultiFunctionalDetector.hh"
+
+// NPSimulation header
+#include "NPSVDetector.hh"
+
+// NPLib
+#include "THiraData.h"
+using namespace std;
+using namespace CLHEP;
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+namespace HIRA
+{
+	
+	// Resolution
+	const G4double ResoTime		= 0.212765957    ;// = 500ps                 //   Unit is  ns/2.35
+	const G4double ResoCsI      	= 0.08           ;// = 188 kev of resolution //   Unit is MeV/2.35
+	const G4double ResoThickSi  	= 0.022          ;// = 52keV of Resolution   //   Unit is MeV/2.35
+	const G4double ResoThinSi	= 0.064          ;// = 150keV of Resolution   //   Unit is MeV/2.35
+	
+	const G4double EnergyThreshold = 100*keV;
+	
+	const G4double FaceFront	= 7.*cm ;
+	const G4double FaceBack		= 7*cm ;
+	const G4double Length		= 7.*cm ;
+	const G4int NumberOfStrip	= 32;
+	
+	const G4double SiliconFace       = 64*mm ;
+	const G4double AluStripThickness = 0.4*micrometer ;
+	const G4double ThinSiThickness	 = 65*micrometer ;
+	const G4double ThickSiThickness	 = 1500*micrometer ;
+	const G4double DistBetweenSi	 = 1*cm;
+	const G4double VacBoxThickness   = 1*cm ;
+	const G4double MylarCsIThickness = 3*micrometer;
+	const G4double CsIThickness      = 4.*cm + 2*MylarCsIThickness ;
+	const G4double CsIFaceFront      = 3.2*cm;
+	const G4double CsIFaceBack       = 3.7*cm;
+	const G4double DistInterCsI      = 0.2*mm;
+	const G4double ClusterFaceFront  = 7*cm;
+	const G4double ClusterFaceBack   = 9*cm;
+	
+	
+	// Starting at the front and going to CsI
+	const G4double AluStripFrontThinSi_PosZ		= Length* -0.5 + 0.5*AluStripThickness;
+	const G4double ThinSi_PosZ			= AluStripFrontThinSi_PosZ + 0.5*AluStripThickness + 0.5*ThinSiThickness;
+	const G4double AluStripBackThinSi_PosZ		= ThinSi_PosZ + 0.5*ThinSiThickness + 0.5*AluStripThickness;
+	
+	const G4double AluStripFrontThickSi_PosZ	= AluStripBackThinSi_PosZ + DistBetweenSi + 0.5*AluStripThickness + 0.5*AluStripThickness;
+	const G4double ThickSi_PosZ			= AluStripFrontThickSi_PosZ + 0.5*AluStripThickness + 0.5*ThickSiThickness;
+	const G4double AluStripBackThickSi_PosZ		= ThickSi_PosZ + 0.5*ThickSiThickness + 0.5*AluStripThickness;
+	
+	const G4double VacBox_PosZ			= AluStripBackThickSi_PosZ + 0.5*AluStripThickness + 0.5* VacBoxThickness;
+	const G4double CsI_PosZ				= VacBox_PosZ + 0.5*VacBoxThickness + 0.5*CsIThickness;
+	
+	
+   
+   
+}
+
+using namespace HIRA ;
+class Hira : public NPS::VDetector
+{
+  ////////////////////////////////////////////////////
+  /////// Default Constructor and Destructor /////////
+  ////////////////////////////////////////////////////
+public:
+  Hira() ;
+   ~Hira() ;
+  
+  ////////////////////////////////////////////////////
+  //////// Specific Function of this Class ///////////
+  ////////////////////////////////////////////////////
+public:
+	// By Position Method
+	void AddTelescope(  G4ThreeVector  Pos1    ,
+						G4ThreeVector  Pos2    ,
+						G4ThreeVector  Pos3    ,
+						G4ThreeVector  Pos4    );
+
+	// 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 );
+
+
+private:
+	G4LogicalVolume* m_LogicThinSi;
+	G4LogicalVolume* m_LogicThickSi;
+	G4LogicalVolume* m_LogicCsICrystal;
+	G4LogicalVolume* m_LogicCluster;
+	G4LogicalVolume* m_logicMotherVolume;
+	////////////////////////////////////////////////////
+	//////// Specific Function of this Class ///////////
+	////////////////////////////////////////////////////
+public:
+	// To add a box detector
+	// Effectively construct Volume
+	void ConstructCsICrystal();
+	void ConstructThinSi();
+	void ConstructThickSi();
+	
+  
+  ////////////////////////////////////////////////////
+  /////////  Inherite from VDetector class ///////////
+  ////////////////////////////////////////////////////
+public:
+  // Read stream at Configfile to pick-up parameters of detector (Position,...)
+  // Called in DetecorConstruction::ReadDetextorConfiguration Method
+  void ReadConfiguration(string Path) ;
+  
+  // Construct detector and inialise sensitive part.
+  // Called After DetecorConstruction::AddDetector Method
+  void ConstructDetector(G4LogicalVolume* world) ;
+  
+  // Add Detector branch to the EventTree.
+  // Called After DetecorConstruction::AddDetector Method
+  void InitializeRootOutput() ;
+  
+  // Read sensitive part and fill the Root tree.
+  // Called at in the EventAction::EndOfEventAvtion
+  void ReadSensitive(const G4Event* event) ;
+  
+  ////////////////////////////////////////////////////
+  ///////////Event class to store Data////////////////
+  ////////////////////////////////////////////////////
+private:
+  THiraData*    m_EventHira ;
+  
+  ////////////////////////////////////////////////////
+  ///////////////// Scorer Related ///////////////////
+  ////////////////////////////////////////////////////
+  
+private:
+  //   Initialize all Scorer
+  void InitializeScorers() ;
+  
+	//   Silicon Associate Scorer
+	G4MultiFunctionalDetector* m_ThinSiStripScorer ;
+	G4MultiFunctionalDetector* m_ThickSiStripScorer ;
+    
+    //   CsI Associate Scorer 
+    G4MultiFunctionalDetector* m_CsIScorer ;
+  
+private:
+  //    Initialize material used in detector definition
+  void InitializeMaterial();
+  
+  //   List of material
+	// Si
+	G4Material* m_MaterialSilicon;
+	// Al
+	G4Material* m_MaterialAluminium;
+	// CsI
+	G4Material* m_MaterialCsI;
+	//  Vacuum
+	G4Material* m_MaterialVacuum ;
+	//  Mylar
+	G4Material* m_MaterialMylar;
+	//  PCB
+	G4Material* m_MaterialPCB;
+  
+  ////////////////////////////////////////////////////
+  ///////////////Private intern Data//////////////////
+  ////////////////////////////////////////////////////
+private:
+
+	// True if the detector is a Cluster, false if a single Phoswich
+  	vector<bool> m_Type;
+  
+ 	// Detector position
+ 	vector<G4ThreeVector> m_Pos;
+  	vector<G4RotationMatrix*> m_Rot;
+	
+  
+	// Used for "By Point Definition"
+	//vector<G4ThreeVector>   m_TL     ; // Top Left Corner Position Vector
+	//vector<G4ThreeVector>   m_BL     ; // Bottom Left Corner Position Vector
+	//vector<G4ThreeVector>   m_BR     ; // Bottom Right Corner Position Vector
+	//vector<G4ThreeVector>   m_TR     ; // Center Corner Position Vector
+	
+	// Used for "By Angle Definition"
+	//vector<G4double>  m_R      ; //  |
+	//vector<G4double>  m_Theta  ; //  > Spherical coordinate of Strips Silicium Plate
+	//vector<G4double>  m_Phi    ; //  |
+	
+	vector<G4double>  m_beta_u ; //  |
+	vector<G4double>  m_beta_v ; //  >Tilt angle of the Telescope
+	vector<G4double>  m_beta_w ; //  |
+	
+  
+private:/// Visualisation Attribute:
+   G4VisAttributes* m_SiliconVisAtt  ;
+   G4VisAttributes* m_CsIVisAtt;
+    
+public:
+    static NPS::VDetector* Construct();
+  
+};
+#endif
-- 
GitLab