From ee358e88745a2b5a1eaa0aae7169410a6bd9a1c9 Mon Sep 17 00:00:00 2001
From: matta <matta@npt>
Date: Mon, 2 Nov 2009 06:50:26 +0000
Subject: [PATCH] * Adding a SSSDPhysics class to NPL 	- Manage calibration
 of the SSSDData. very basics right now

* Change method name in SSSDData to something understandable

* removing debugging cout in MUST2Physics
---
 NPAnalysis/10He_Riken/src/Analysis.cc         |   2 +-
 .../DummyDetector/TDUMMYDetectorDataDict.cxx  |   2 +-
 NPLib/MUST2/TMust2Physics.cxx                 |  18 +-
 NPLib/SSSD/Makefile                           |   8 +-
 NPLib/SSSD/TSSSDData.cxx                      |   2 +-
 NPLib/SSSD/TSSSDData.h                        |  30 +-
 NPLib/SSSD/TSSSDPhysics.cxx                   | 306 ++++++++++++++++++
 NPLib/SSSD/TSSSDPhysics.h                     |  92 ++++++
 NPSimulation/src/GeneralScorers.cc            |   1 -
 NPSimulation/src/ThinSi.cc                    |  12 +-
 10 files changed, 437 insertions(+), 36 deletions(-)
 create mode 100644 NPLib/SSSD/TSSSDPhysics.cxx
 create mode 100644 NPLib/SSSD/TSSSDPhysics.h

diff --git a/NPAnalysis/10He_Riken/src/Analysis.cc b/NPAnalysis/10He_Riken/src/Analysis.cc
index fff78f04d..05f742398 100644
--- a/NPAnalysis/10He_Riken/src/Analysis.cc
+++ b/NPAnalysis/10He_Riken/src/Analysis.cc
@@ -63,7 +63,7 @@ int main(int argc,char** argv)
 	
 	//	Get the formed Chained Tree and Treat it
 	TChain* Chain = RootInput:: getInstance() -> GetChain()	;
- 	   
+
 	// Open the ThinSi Branch
 	Chain->SetBranchStatus("ThinSiEnergy",true)	;
 	Chain->SetBranchStatus("InitialConditions",true)	;
diff --git a/NPLib/DummyDetector/TDUMMYDetectorDataDict.cxx b/NPLib/DummyDetector/TDUMMYDetectorDataDict.cxx
index 17c286f29..19cf82a77 100644
--- a/NPLib/DummyDetector/TDUMMYDetectorDataDict.cxx
+++ b/NPLib/DummyDetector/TDUMMYDetectorDataDict.cxx
@@ -1,5 +1,5 @@
 //
-// File generated by rootcint at Mon Oct 26 17:47:22 2009
+// File generated by rootcint at Mon Nov  2 15:47:25 2009
 
 // Do NOT change. Changes will be lost next time file is generated
 //
diff --git a/NPLib/MUST2/TMust2Physics.cxx b/NPLib/MUST2/TMust2Physics.cxx
index 080a596f2..70b6fcf02 100644
--- a/NPLib/MUST2/TMust2Physics.cxx
+++ b/NPLib/MUST2/TMust2Physics.cxx
@@ -663,22 +663,22 @@ void TMust2Physics::AddParameterToCalibrationManager()
 			
 				for( int j = 0 ; j < 128 ; j++)
 					{
-						Cal->AddParameter("MUST2", "T"+itoa(i)+"_Si_X"+itoa(j)+"_E","MUST2_T"+itoa(i)+"_Si_X"+itoa(j)+"_E")	;
-						Cal->AddParameter("MUST2", "T"+itoa(i)+"_Si_Y"+itoa(j)+"_E","MUST2_T"+itoa(i)+"_Si_Y"+itoa(j)+"_E")	;
-						Cal->AddParameter("MUST2", "T"+itoa(i)+"_Si_X"+itoa(j)+"_T","MUST2_T"+itoa(i)+"_Si_X"+itoa(j)+"_T")	;
-						Cal->AddParameter("MUST2", "T"+itoa(i)+"_Si_Y"+itoa(j)+"_T","MUST2_T"+itoa(i)+"_Si_Y"+itoa(j)+"_T")	;	
+						Cal->AddParameter("MUST2", "T"+itoa(i+1)+"_Si_X"+itoa(j+1)+"_E","MUST2_T"+itoa(i+1)+"_Si_X"+itoa(j+1)+"_E")	;
+						Cal->AddParameter("MUST2", "T"+itoa(i+1)+"_Si_Y"+itoa(j+1)+"_E","MUST2_T"+itoa(i+1)+"_Si_Y"+itoa(j+1)+"_E")	;
+						Cal->AddParameter("MUST2", "T"+itoa(i+1)+"_Si_X"+itoa(j+1)+"_T","MUST2_T"+itoa(i+1)+"_Si_X"+itoa(j+1)+"_T")	;
+						Cal->AddParameter("MUST2", "T"+itoa(i+1)+"_Si_Y"+itoa(j+1)+"_T","MUST2_T"+itoa(i+1)+"_Si_Y"+itoa(j+1)+"_T")	;	
 					}
 		
 				for( int j = 0 ; j < 16 ; j++)
 					{
-						Cal->AddParameter("MUST2", "T"+itoa(i)+"_SiLi"+itoa(j)+"_E","MUST2_T"+itoa(i)+"_SiLi"+itoa(j)+"_E")	;
-						Cal->AddParameter("MUST2", "T"+itoa(i)+"_SiLi"+itoa(j)+"_T","MUST2_T"+itoa(i)+"_SiLi"+itoa(j)+"_T")	;
+						Cal->AddParameter("MUST2", "T"+itoa(i+1)+"_SiLi"+itoa(j+1)+"_E","MUST2_T"+itoa(i+1)+"_SiLi"+itoa(j+1)+"_E")	;
+						Cal->AddParameter("MUST2", "T"+itoa(i+1)+"_SiLi"+itoa(j+1)+"_T","MUST2_T"+itoa(i+1)+"_SiLi"+itoa(j+1)+"_T")	;
 					}
 			
 				for( int j = 0 ; j < 16 ; j++)
 					{
-						Cal->AddParameter("MUST2", "T"+itoa(i)+"_CsI"+itoa(j)+"_E","MUST2_T"+itoa(i)+"_CsI"+itoa(j)+"_E")		;
-						Cal->AddParameter("MUST2", "T"+itoa(i)+"_CsI"+itoa(j)+"_T","MUST2_T"+itoa(i)+"_CsI"+itoa(j)+"_T")		;
+						Cal->AddParameter("MUST2", "T"+itoa(i+1)+"_CsI"+itoa(j+1)+"_E","MUST2_T"+itoa(i+1)+"_CsI"+itoa(j+1)+"_E")		;
+						Cal->AddParameter("MUST2", "T"+itoa(i+1)+"_CsI"+itoa(j+1)+"_T","MUST2_T"+itoa(i+1)+"_CsI"+itoa(j+1)+"_T")		;
 					}
 			}
 	
@@ -699,10 +699,8 @@ void TMust2Physics::InitializeRootInput()
 //	Create associated branches and associated private member DetectorPhysics address
 void TMust2Physics::InitializeRootOutput() 	
 	{
-		cout << "coucou" << endl ;
 		TTree* outputTree = RootOutput::getInstance()->GetTree()		;
 		outputTree->Branch( "MUST2" , "TMust2Physics" , &EventPhysics )	;
-		cout << "coucou2" << endl ;
 	}
 
 
diff --git a/NPLib/SSSD/Makefile b/NPLib/SSSD/Makefile
index 9ceff2d71..f9b71f05d 100755
--- a/NPLib/SSSD/Makefile
+++ b/NPLib/SSSD/Makefile
@@ -268,7 +268,7 @@ GLIBS         = $(ROOTGLIBS) $(SYSLIBS)
 INCLUDE		= -I$(CLHEP_BASE_DIR)/include -I$(NPLIB)/include
  
 #------------------------------------------------------------------------------
-SHARELIB      =  libSSSDData.so
+SHARELIB      =  libSSSDData.so libSSSDPhysics.so
 
 all:            $(SHARELIB)
 #------------------------------------------------------------------------------
@@ -281,9 +281,15 @@ libSSSDData.so:	TSSSDData.o	TSSSDDataDict.o
 TSSSDDataDict.cxx:	TSSSDData.h
 			rootcint -f $@ -c $^
 
+libSSSDPhysics.so:	TSSSDPhysics.o	TSSSDPhysicsDict.o
+		$(LD) $(SOFLAGS) $^ $(OutPutOpt) $@
 
+TSSSDPhysicsDict.cxx:	TSSSDPhysics.h
+			rootcint -f $@ -c $^
+			
 # dependances
 TSSSDData.o:		TSSSDData.cxx	TSSSDData.h
+TSSSDPhysics.o:	TSSSDPhysics.cxx	TSSSDPhysics.h
 #######################################
 
 ############# Clean and More ##########
diff --git a/NPLib/SSSD/TSSSDData.cxx b/NPLib/SSSD/TSSSDData.cxx
index 3877b7174..66d7b2239 100644
--- a/NPLib/SSSD/TSSSDData.cxx
+++ b/NPLib/SSSD/TSSSDData.cxx
@@ -51,7 +51,7 @@ void TSSSDData::Clear()
 	// Energy
 	fSSSD_StripE_DetectorNbr.clear()	;
 	fSSSD_StripE_StripNbr.clear()	;
-	fSSSD_StripE_Energy.clear()		;
+	fSSSD_StripE_Energy.clear()		; 
 	// Time
 	fSSSD_StripT_DetectorNbr.clear()	;
 	fSSSD_StripT_StripNbr.clear()	;
diff --git a/NPLib/SSSD/TSSSDData.h b/NPLib/SSSD/TSSSDData.h
index a57f0061d..7e90e7f05 100644
--- a/NPLib/SSSD/TSSSDData.h
+++ b/NPLib/SSSD/TSSSDData.h
@@ -49,28 +49,28 @@ class TSSSDData : public TObject {
 		/////////////////////           SETTERS           ////////////////////////
 		// DSSD
 		// (X,E)
-		void	SetStripEDetectorNbr(UShort_t DetNbr) {fSSSD_StripE_DetectorNbr.push_back(DetNbr);}
-		void	SetStripEStripNbr(UShort_t StripNbr)  {fSSSD_StripE_StripNbr.push_back(StripNbr);}
-		void	SetStripEEnergy(Double_t Energy)      {fSSSD_StripE_Energy.push_back(Energy);}
+		void	SetEnergyDetectorNbr	(UShort_t DetNbr) 	{ fSSSD_StripE_DetectorNbr.push_back(DetNbr)	;}
+		void	SetEnergyStripNbr			(UShort_t StripNbr) { fSSSD_StripE_StripNbr.push_back(StripNbr)		;}
+		void	SetEnergy							(Double_t Energy)   { fSSSD_StripE_Energy.push_back(Energy)				;}
 		// (X,T)
-		void	SetStripTDetectorNbr(UShort_t DetNbr) {fSSSD_StripT_DetectorNbr.push_back(DetNbr);}
-		void	SetStripTStripNbr(UShort_t StripNbr)  {fSSSD_StripT_StripNbr.push_back(StripNbr);}
-		void	SetStripTTime(Double_t Time)          {fSSSD_StripT_Time.push_back(Time);}
+		void	SetTimeDetectorNbr		(UShort_t DetNbr) 	{ fSSSD_StripT_DetectorNbr.push_back(DetNbr)	;}
+		void	SetTimeStripNbr				(UShort_t StripNbr) { fSSSD_StripT_StripNbr.push_back(StripNbr)		;}
+		void	SetTime								(Double_t Time)     { fSSSD_StripT_Time.push_back(Time)						;}
 
 		/////////////////////           GETTERS           ////////////////////////
 		// DSSD
 		// (X,E)
-		UShort_t	GetStripEMult()               {return fSSSD_StripE_DetectorNbr.size();}
-		UShort_t	GetStripEDetectorNbr(Int_t i) {return fSSSD_StripE_DetectorNbr.at(i);}
-		UShort_t	GetStripEStripNbr(Int_t i)    {return fSSSD_StripE_StripNbr.at(i);}
-		Double_t	GetStripEEnergy(Int_t i)      {return fSSSD_StripE_Energy.at(i);}
+		UShort_t	GetEnergyMult					()           	{	return fSSSD_StripE_DetectorNbr.size()	;}
+		UShort_t	GetEnergyDetectorNbr	(Int_t i) 		{	return fSSSD_StripE_DetectorNbr.at(i)		;}
+		UShort_t	GetEnergyStripNbr			(Int_t i)    	{	return fSSSD_StripE_StripNbr.at(i)			;}
+		Double_t	GetEnergy							(Int_t i)     {	return fSSSD_StripE_Energy.at(i)				;}
 		// (X,T)
-		UShort_t	GetStripTMult()               {return fSSSD_StripT_DetectorNbr.size();}
-		UShort_t	GetStripTDetectorNbr(Int_t i) {return fSSSD_StripT_DetectorNbr.at(i);}
-		UShort_t	GetStripTStripNbr(Int_t i)    {return fSSSD_StripT_StripNbr.at(i);}
-		Double_t	GetStripTTime(Int_t i)        {return fSSSD_StripT_Time.at(i);}
+		UShort_t	GetTimeMult						()            {	return fSSSD_StripT_DetectorNbr.size()	;}
+		UShort_t	GetTimeDetectorNbr		(Int_t i) 		{	return fSSSD_StripT_DetectorNbr.at(i)		;}
+		UShort_t	GetTimeStripNbr				(Int_t i)   	{	return fSSSD_StripT_StripNbr.at(i)			;}
+		Double_t	GetTime								(Int_t i)     {	return fSSSD_StripT_Time.at(i)					;}
 	
-		ClassDef(TSSSDData,2)  // SSSDData structure
+		ClassDef(TSSSDData,1)  // SSSDData structure
 };
 
 #endif
diff --git a/NPLib/SSSD/TSSSDPhysics.cxx b/NPLib/SSSD/TSSSDPhysics.cxx
new file mode 100644
index 000000000..2a36bb387
--- /dev/null
+++ b/NPLib/SSSD/TSSSDPhysics.cxx
@@ -0,0 +1,306 @@
+/*****************************************************************************
+ * Copyright (C) 2009   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 SSSD  Physics                                            *
+ *                                                                           *
+ *---------------------------------------------------------------------------*
+ * Comment:                                                                  *
+ *                                                                           *
+ *                                                                           *
+ *****************************************************************************/
+//	NPL
+#include "TSSSDPhysics.h"
+#include "RootOutput.h"
+#include "RootInput.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)
+			{
+			  std::ostringstream o;
+			
+			  if (!(o << value))
+			    return ""	;
+			    
+			  return o.str();
+			}
+
+ClassImp(TSSSDPhysics)
+///////////////////////////////////////////////////////////////////////////
+TSSSDPhysics::TSSSDPhysics()
+	{		
+		NumberOfDetector = 0 ;
+		EventData = new TSSSDData	;
+		EventPhysics = this					;
+	}
+///////////////////////////////////////////////////////////////////////////
+TSSSDPhysics::~TSSSDPhysics()
+	{}
+///////////////////////////////////////////////////////////////////////////
+void TSSSDPhysics::Clear()
+	{
+		DetectorNumber	.clear()	;
+		StripNumber			.clear()	;
+		Energy					.clear()	;
+		Time						.clear()	;
+	}
+///////////////////////////////////////////////////////////////////////////
+void TSSSDPhysics::ReadConfiguration(string Path) 
+	{
+   ifstream ConfigFile           ;
+   ConfigFile.open(Path.c_str()) ;
+   string LineBuffer          ;
+   string DataBuffer          ;
+
+   double TLX , BLX , BRX , TRX , TLY , BLY , BRY , TRY , TLZ , BLZ , BRZ , TRZ   ;
+   double Theta = 0 , Phi = 0 , R = 0 , beta_u = 0 , beta_v = 0 , beta_w = 0                     ;
+   bool check_A = false   ;
+   bool check_B = false ;
+   bool check_C = false   ;
+   bool check_D = false ;
+
+   bool check_Theta = false   ;
+   bool check_Phi  = false  ;
+   bool check_R     = false   ;
+   bool check_beta = false  ;
+   bool ReadingStatus = false ;
+
+ while (!ConfigFile.eof()) 
+ 	{
+      
+		getline(ConfigFile, LineBuffer);
+
+		//	If line is a Start Up ThinSi bloc, Reading toggle to true      
+		  	if (LineBuffer.compare(0, 6, "ThinSi") == 0) 
+		    	{
+		      	 cout << "///" << endl           ;
+		      		  cout << "Detector 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, "ThinSi") == 0) {
+					cout << "WARNING: Another Telescope is find before standard sequence of Token, Error may occured in Telecope definition" << endl ;
+					ReadingStatus = false ;
+				}
+
+					 //Position method
+		         else if (DataBuffer.compare(0, 3, "A=") == 0) {
+		            check_A = true;
+		            ConfigFile >> DataBuffer ;
+		            TLX = atof(DataBuffer.c_str()) ;
+		            ConfigFile >> DataBuffer ;
+		            TLY = atof(DataBuffer.c_str()) ;
+		            ConfigFile >> DataBuffer ;
+		            TLZ = atof(DataBuffer.c_str()) ;
+
+		         }
+				
+				else if (DataBuffer.compare(0, 3, "B=") == 0) {
+					check_B = true;
+					ConfigFile >> DataBuffer ;
+					BLX = atof(DataBuffer.c_str()) ;
+					ConfigFile >> DataBuffer ;
+					BLY = atof(DataBuffer.c_str()) ;
+					ConfigFile >> DataBuffer ;
+					BLZ = atof(DataBuffer.c_str()) ;
+
+				}
+
+				else if (DataBuffer.compare(0, 3, "C=") == 0) {
+					check_C = true;
+					ConfigFile >> DataBuffer ;
+					BRX = atof(DataBuffer.c_str()) ;
+					ConfigFile >> DataBuffer ;
+					BRY = atof(DataBuffer.c_str()) ;
+					ConfigFile >> DataBuffer ;
+					BRZ = atof(DataBuffer.c_str()) ;
+
+				}
+
+				else if (DataBuffer.compare(0, 3, "D=") == 0) {
+					check_D = true;
+					ConfigFile >> DataBuffer ;
+					TRX = atof(DataBuffer.c_str()) ;
+					ConfigFile >> DataBuffer ;
+					TRY = atof(DataBuffer.c_str()) ;
+					ConfigFile >> DataBuffer ;
+					TRZ = atof(DataBuffer.c_str()) ;
+
+				}
+
+									
+				//Angle method
+				else if (DataBuffer.compare(0, 6, "THETA=") == 0) {
+					check_Theta = true;
+					ConfigFile >> DataBuffer ;
+					Theta = atof(DataBuffer.c_str()) ;
+				}
+
+				else if (DataBuffer.compare(0, 4, "PHI=") == 0) {
+					check_Phi = true;
+					ConfigFile >> DataBuffer ;
+					Phi = atof(DataBuffer.c_str()) ;
+				}
+
+				else if (DataBuffer.compare(0, 2, "R=") == 0) {
+					check_R = true;
+					ConfigFile >> DataBuffer ;
+					R = atof(DataBuffer.c_str()) ;
+				}
+
+
+				else if (DataBuffer.compare(0, 5, "BETA=") == 0) {
+					check_beta = true;
+					ConfigFile >> DataBuffer ;
+					beta_u = atof(DataBuffer.c_str()) ;
+					ConfigFile >> DataBuffer ;
+					beta_v = atof(DataBuffer.c_str()) ;
+					ConfigFile >> DataBuffer ;
+					beta_w = atof(DataBuffer.c_str()) ;
+				}
+		      
+		         	///////////////////////////////////////////////////
+					//	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_A && check_B && check_C && check_D) || (check_Theta && check_Phi && check_R && check_beta) ) 
+		         	{ 
+				         	ReadingStatus = false; 
+				         	
+				         	///Add The previously define telescope
+		         			//With position method
+				         	 if ((check_A && check_B && check_C && check_D) || !(check_Theta && check_Phi && check_R)) {
+						            	 NumberOfDetector++;
+						         }
+
+					         //with angle method
+					         else if ((check_Theta && check_Phi && check_R) || !(check_A && check_B && check_C && check_D)) {
+						         		  NumberOfDetector++;
+						         }
+						         
+						        //	Reinitialisation of Check Boolean 
+						        
+								check_A = false   ;
+								check_B = false ;
+								check_C = false   ;
+								check_D = false ;
+
+								check_Theta = false   ;
+								check_Phi  = false  ;
+								check_R     = false   ;
+								check_beta = false  ;
+								ReadingStatus = false ;
+							         
+		         	}
+		         	
+						}
+					}
+
+}
+
+
+///////////////////////////////////////////////////////////////////////////
+void TSSSDPhysics::AddParameterToCalibrationManager()
+	{
+		CalibrationManager* Cal = CalibrationManager::getInstance();
+		
+		for(int i = 0 ; i < NumberOfDetector ; i++)
+			{
+			
+				for( int j = 0 ; j < 16 ; j++)
+					{
+						Cal->AddParameter("SSSD", "Detector"+itoa(i+1)+"_Strip"+itoa(j+1)+"_E","SSSD_Detector"+itoa(i+1)+"_Strip"+itoa(j+1)+"_E")	;
+						Cal->AddParameter("SSSD", "Detector"+itoa(i+1)+"_Strip"+itoa(j+1)+"_T","SSSD_Detector"+itoa(i+1)+"_Strip"+itoa(j+1)+"_T")	;	
+					}
+		
+			}
+	}
+	
+///////////////////////////////////////////////////////////////////////////
+void TSSSDPhysics::InitializeRootInput()
+	{
+		TChain* inputChain = RootInput::getInstance()->GetChain()	;
+		inputChain->SetBranchStatus ( "ThinSi" 		, true )					;
+		inputChain->SetBranchStatus ( "ThinSi_*" 	, true )					;
+		inputChain->SetBranchAddress( "ThinSi" 		, &EventData )		;
+	}	
+
+///////////////////////////////////////////////////////////////////////////
+void TSSSDPhysics::InitializeRootOutput()
+	{
+		TTree* outputTree = RootOutput::getInstance()->GetTree()			;
+		outputTree->Branch( "SSSD" , "TSSSDPhysics" , &EventPhysics )	;
+	}
+
+///////////////////////////////////////////////////////////////////////////
+void TSSSDPhysics::BuildPhysicalEvent()
+	{
+		BuildSimplePhysicalEvent()	;
+	}
+
+///////////////////////////////////////////////////////////////////////////
+void TSSSDPhysics::BuildSimplePhysicalEvent()
+	{
+		if( EventData->GetEnergyMult() == EventData->GetTimeMult() )
+			{
+				for(unsigned int i = 0 ; i < EventData->GetEnergyMult() ; i++)
+					{
+					
+						DetectorNumber	.push_back( EventData->GetEnergyDetectorNbr(i) )	;
+						StripNumber			.push_back( EventData->GetEnergyStripNbr(i)    )	;
+						
+						Energy					.push_back(
+							CalibrationManager::getInstance()->ApplyCalibration(	"SSSD/Detector" + itoa( EventData->GetEnergyDetectorNbr(i) ) + "_Strip" + itoa( EventData->GetEnergyStripNbr(i) ) +"_E",	
+																																		EventData->GetEnergy(i) )
+																			)	;
+																			
+						Time						.push_back(
+							CalibrationManager::getInstance()->ApplyCalibration(	"SSSD/Detector" + itoa( EventData->GetEnergyDetectorNbr(i) ) + "_Strip" + itoa( EventData->GetEnergyStripNbr(i) ) +"_T",	
+																																		EventData->GetTime(i) )
+																			)	;
+					}
+			}
+		
+		else return ;
+		
+	}
+
diff --git a/NPLib/SSSD/TSSSDPhysics.h b/NPLib/SSSD/TSSSDPhysics.h
new file mode 100644
index 000000000..2663cf392
--- /dev/null
+++ b/NPLib/SSSD/TSSSDPhysics.h
@@ -0,0 +1,92 @@
+#ifndef __SSSDPhysics__
+#define __SSSDPhysics__
+/*****************************************************************************
+ * Copyright (C) 2009   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 the Single Side Striped Detector  Physics                *
+ *                                                                           *
+ *---------------------------------------------------------------------------*
+ * Comment:                                                                  *
+ *                                                                           *
+ *                                                                           *
+ *****************************************************************************/
+//	STL
+#include <vector>
+using namespace std ;
+
+//	ROOT
+#include "TObject.h"
+
+//	NPL
+#include "TSSSDData.h"
+#include "../include/VDetector.h"
+#include "../include/CalibrationManager.h"
+
+class TSSSDPhysics : public TObject, public NPA::VDetector
+{
+
+	public:	//	Calibrated Data
+
+		vector<UShort_t>	DetectorNumber	;
+		vector<UShort_t>	StripNumber			;
+		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 InitializeRootInput() 					;
+
+
+		//	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()				;
+
+		//	Those two method all to clear the Event Physics or Data
+		void ClearEventPhysics()		{Clear();}		
+		void ClearEventData()				{EventData->Clear();}		
+
+	public:
+		TSSSDPhysics();
+		virtual ~TSSSDPhysics();
+
+	private:	// Data not writted in the tree
+				int								NumberOfDetector	;//!
+				TSSSDData* 	  	EventData					;//!
+				TSSSDPhysics* 	  EventPhysics			;//!
+
+		void	Clear();
+    void  Clear(const Option_t*) {};
+	
+		ClassDef(TSSSDPhysics,1)  // SSSDPhysics structure
+};
+
+#endif
diff --git a/NPSimulation/src/GeneralScorers.cc b/NPSimulation/src/GeneralScorers.cc
index 4ab30937e..38c9e6e23 100644
--- a/NPSimulation/src/GeneralScorers.cc
+++ b/NPSimulation/src/GeneralScorers.cc
@@ -75,7 +75,6 @@ G4bool PSDetectorNumber::ProcessHits(G4Step* aStep, G4TouchableHistory*)
    if (edep < TriggerThreshold) return FALSE;
    
    G4int  index = aStep->GetTrack()->GetTrackID();
-   
    EvtMap->set(index+DetNumber, DetNumber);
    return TRUE;
 }
diff --git a/NPSimulation/src/ThinSi.cc b/NPSimulation/src/ThinSi.cc
index 748eadeda..3af43f06a 100644
--- a/NPSimulation/src/ThinSi.cc
+++ b/NPSimulation/src/ThinSi.cc
@@ -610,8 +610,8 @@ void ThinSi::ReadSensitive(const G4Event* event)
 	      
 	        if (N > 0) 
 						{
-								m_Event->SetStripEDetectorNbr(N)						;
-								m_Event->SetStripTDetectorNbr(N)						;
+								m_Event->SetEnergyDetectorNbr(N)						;
+								m_Event->SetTimeDetectorNbr(N)						;
 								
 						//  Strip Number
 				        StripNbr_itr = StripNbrHitMap->GetMap()->begin();
@@ -620,8 +620,8 @@ void ThinSi::ReadSensitive(const G4Event* event)
 				            G4int S         = *(StripNbr_itr->second)      	;
 										
 				            if (STrackID == NTrackID) {
-				             	 m_Event->SetStripEStripNbr(S)		;
-				             	 m_Event->SetStripTStripNbr(S)		;
+				             	 m_Event->SetEnergyStripNbr(S)		;
+				             	 m_Event->SetTimeStripNbr(S)		;
 				            }
 				            
 				            StripNbr_itr++;
@@ -634,7 +634,7 @@ void ThinSi::ReadSensitive(const G4Event* event)
 				            G4double E      = *(Energy_itr->second)      	;
 
 				            if (ETrackID == NTrackID) {
-				               m_Event->SetStripEEnergy( RandGauss::shoot(E, ResoEnergy ) )    ;
+				               m_Event->SetEnergy( RandGauss::shoot(E, ResoEnergy ) )    ;
 				            }
 				            
 				            Energy_itr++;
@@ -648,7 +648,7 @@ void ThinSi::ReadSensitive(const G4Event* event)
 				            G4double T     = *(Time_itr->second)      ;
 
 				            if (TTrackID == NTrackID) {
-				               	m_Event->SetStripTTime( RandGauss::shoot(T, ResoTime ) )    ;
+				               	m_Event->SetTime( RandGauss::shoot(T, ResoTime ) )    ;
 				            }
 				            
 				            Time_itr++;
-- 
GitLab