From ec62d5ec571f34944eb1686ae23e3e23635501ec Mon Sep 17 00:00:00 2001
From: deserevi <deserevi@nptool>
Date: Thu, 7 Oct 2010 08:30:28 +0000
Subject: [PATCH] * Begin support for multi-shape based detector (Gaspard) in
 NPAnalysis    + TGaspardTrackerDummyShape.{h,cxx} and
 TGaspardTrackerTrapezoid.{h,cxx} added       These classes will deal with
 reading the configuration, calculating the       geometry and building
 physical events.

   + TGaspardTrackerPhysicsNew.{h,cxx}
      This class holds the TGaspardTrackerData class and knows all the detectors
      to analyze through a map relating the detector number and the corresponding
      TGaspardTrackerModule object.

* Status:
   Configuration files with heterogeneous shapes are read and the map
   is filled correctly
---
 .../gaspardTestSpheric.detector               |  10 +
 NPAnalysis/Gaspard/Makefile                   |   1 +
 NPAnalysis/Gaspard/include/ObjectManager.hh   |   3 +-
 NPAnalysis/Gaspard/src/GNUmakefile            |   7 +-
 NPLib/GASPARD/Makefile                        |  17 +-
 NPLib/GASPARD/TGaspardTrackerDummyShape.cxx   | 380 ++++++++++++++++++
 NPLib/GASPARD/TGaspardTrackerDummyShape.h     |  79 ++++
 NPLib/GASPARD/TGaspardTrackerModule.cxx       |  24 ++
 NPLib/GASPARD/TGaspardTrackerModule.h         |  39 ++
 NPLib/GASPARD/TGaspardTrackerPhysicsNew.cxx   | 267 ++++++++++++
 NPLib/GASPARD/TGaspardTrackerPhysicsNew.h     | 107 +++++
 NPLib/GASPARD/TGaspardTrackerTrapezoid.cxx    | 379 +++++++++++++++++
 NPLib/GASPARD/TGaspardTrackerTrapezoid.h      |  79 ++++
 NPLib/VDetector/DetectorManager.cxx           |   4 +-
 NPLib/liblist                                 |   1 +
 15 files changed, 1393 insertions(+), 4 deletions(-)
 create mode 100644 NPLib/GASPARD/TGaspardTrackerDummyShape.cxx
 create mode 100644 NPLib/GASPARD/TGaspardTrackerDummyShape.h
 create mode 100644 NPLib/GASPARD/TGaspardTrackerPhysicsNew.cxx
 create mode 100644 NPLib/GASPARD/TGaspardTrackerPhysicsNew.h
 create mode 100644 NPLib/GASPARD/TGaspardTrackerTrapezoid.cxx
 create mode 100644 NPLib/GASPARD/TGaspardTrackerTrapezoid.h

diff --git a/Inputs/DetectorConfiguration/gaspardTestSpheric.detector b/Inputs/DetectorConfiguration/gaspardTestSpheric.detector
index fb2cb947a..7fb5fe39e 100644
--- a/Inputs/DetectorConfiguration/gaspardTestSpheric.detector
+++ b/Inputs/DetectorConfiguration/gaspardTestSpheric.detector
@@ -27,6 +27,16 @@ Target
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 GaspardTracker
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%0 Central Barrel
+GPDTrapezoid
+	THETA= 90
+	PHI= 90 
+	R= 300
+	BETA= 0 0 0
+	FIRSTSTAGE= 1
+	SECONDSTAGE= 1
+	THIRDSTAGE= 1
+	VIS= all
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%0 Central Barrel
 GPDDummyShape
 	THETA= 90
 	PHI= 90 
diff --git a/NPAnalysis/Gaspard/Makefile b/NPAnalysis/Gaspard/Makefile
index 215794b28..39d6b7505 100644
--- a/NPAnalysis/Gaspard/Makefile
+++ b/NPAnalysis/Gaspard/Makefile
@@ -8,3 +8,4 @@ clean:
 distclean:
 	make clean -C ./src
 	rm Analysis
+	rm AnalysisNew
diff --git a/NPAnalysis/Gaspard/include/ObjectManager.hh b/NPAnalysis/Gaspard/include/ObjectManager.hh
index f9e4038e8..31c24da0a 100644
--- a/NPAnalysis/Gaspard/include/ObjectManager.hh
+++ b/NPAnalysis/Gaspard/include/ObjectManager.hh
@@ -7,7 +7,8 @@
 
 // NPA
 #include "DetectorManager.h"
-#include "GaspardTracker.h"
+//#include "GaspardTracker.h"
+#include "TGaspardTrackerPhysicsNew.h"
 
 // STL C++
 #include <iostream>
diff --git a/NPAnalysis/Gaspard/src/GNUmakefile b/NPAnalysis/Gaspard/src/GNUmakefile
index 28c404622..7f69bd79d 100644
--- a/NPAnalysis/Gaspard/src/GNUmakefile
+++ b/NPAnalysis/Gaspard/src/GNUmakefile
@@ -2,6 +2,7 @@
 #			Made to compile the ROOT Analyser for MUST2 experiment
 
 CPP=g++
+#EXEC=AnalysisNew
 EXEC=Analysis
 
 # local includes
@@ -26,7 +27,11 @@ OBJ=$(SRC:.cc=.o)
 #all:$(EXEC)
 #	@$(CPP) -o $@ -c $< $(CXXFLAGS)
 
-Analysis:$(OBJ) $(INC)
+AnalysisNew:	AnalysisNew.o $(INC)
+	@$(CPP) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
+	mv AnalysisNew  ../AnalysisNew
+
+Analysis:	Analysis.o $(INC)
 	@$(CPP) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
 	mv Analysis  ../Analysis
 
diff --git a/NPLib/GASPARD/Makefile b/NPLib/GASPARD/Makefile
index a5c9b4e99..0c400bab0 100644
--- a/NPLib/GASPARD/Makefile
+++ b/NPLib/GASPARD/Makefile
@@ -268,7 +268,8 @@ GLIBS         = $(ROOTGLIBS) $(SYSLIBS)
 INCLUDE		= -I$(CLHEP_BASE_DIR)/include -I$(NPLIB)/include
  
 #------------------------------------------------------------------------------
-SHARELIB      =  libGaspardData.so	libGaspardPhysics.so
+SHARELIB      =  libGaspardData.so	libGaspardPhysics.so	\
+		 libGaspardTrackerModules.so 	libGaspardPhysicsNew.so
 all:            $(SHARELIB)
 #------------------------------------------------------------------------------
 ############### Detector ##############
@@ -286,12 +287,26 @@ libGaspardPhysics.so:	GaspardTracker.o TGaspardTrackerPhysics.o TGaspardTrackerP
 TGaspardTrackerPhysicsDict.cxx:	TGaspardTrackerPhysics.h
 			rootcint -f $@ -c $^
 
+libGaspardPhysicsNew.so:	TGaspardTrackerPhysicsNew.o TGaspardTrackerPhysicsNewDict.o
+			$(LD) $(SOFLAGS) $^ $(OutPutOpt) $@
+
+TGaspardTrackerPhysicsNewDict.cxx:	TGaspardTrackerPhysicsNew.h
+			rootcint -f $@ -c $^
+
+libGaspardTrackerModules.so:	TGaspardTrackerModule.o	TGaspardTrackerDummyShape.o \
+				TGaspardTrackerTrapezoid.o
+			$(LD) $(SOFLAGS) $^ $(OutPutOpt) $@
+
 
 
 # dependances
 GaspardTracker.o:	GaspardTracker.cxx	GaspardTracker.h
 TGaspardTrackerData.o:	TGaspardTrackerData.cxx	TGaspardTrackerData.h
 TGaspardTrackerPhysics.o:	TGaspardTrackerPhysics.cxx	TGaspardTrackerPhysics.h
+TGaspardTrackerPhysicsNew.o:	TGaspardTrackerPhysicsNew.cxx	TGaspardTrackerPhysicsNew.h
+TGaspardTrackerModule.o:	TGaspardTrackerModule.cxx	TGaspardTrackerModule.h
+TGaspardTrackerDummyShape.o:	TGaspardTrackerDummyShape.cxx	TGaspardTrackerDummyShape.h
+TGaspardTrackerTrapezoid.o:	TGaspardTrackerTrapezoid.cxx	TGaspardTrackerTrapezoid.h
 #######################################
 
 ############# Clean and More ##########
diff --git a/NPLib/GASPARD/TGaspardTrackerDummyShape.cxx b/NPLib/GASPARD/TGaspardTrackerDummyShape.cxx
new file mode 100644
index 000000000..e1e8b8d2f
--- /dev/null
+++ b/NPLib/GASPARD/TGaspardTrackerDummyShape.cxx
@@ -0,0 +1,380 @@
+#include "TGaspardTrackerDummyShape.h"
+
+// C++ headers
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <cmath>
+
+
+TGaspardTrackerDummyShape::TGaspardTrackerDummyShape(map<int, TGaspardTrackerModule*> &Module) 
+	: m_ModuleTest(Module),
+	  m_NumberOfModule(0)
+{
+}
+
+
+
+TGaspardTrackerDummyShape::~TGaspardTrackerDummyShape()
+{
+}
+
+
+
+void TGaspardTrackerDummyShape::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
+
+   double   Ax, Bx, Cx, Dx, Ay, By, Cy, Dy, Az, Bz, Cz, Dz;
+   TVector3 A, B, C, D;
+   double   Theta = 0, Phi = 0, R = 0, beta_u = 0 , beta_v = 0 , beta_w = 0;
+
+   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;
+   bool check_beta  = false;
+
+   bool ReadingStatus = false;
+
+   while (!ConfigFile.eof()) {
+      getline(ConfigFile, LineBuffer);
+
+      // If line is a GaspardXXX bloc, reading toggle to true
+      // and toggle to true flags indicating which shape is treated.
+      if (LineBuffer.compare(0, 13, "GPDDummyShape") == 0) {
+         cout << "///////////////////////" << endl;
+         cout << "DummyShape module found:" << endl;
+         ReadingStatus = true;
+      }
+
+      // Reading Block
+      while (ReadingStatus) {
+         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, 13, "GPDDummyShape") == 0) {
+            cout << "WARNING: Another Module is find before standard sequence of Token, Error may occured in Telecope definition" << endl;
+            ReadingStatus = false;
+         }
+
+         // Position method
+         else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) {
+            check_A = true;
+            ConfigFile >> DataBuffer;
+            Ax = atof(DataBuffer.c_str());
+            Ax = Ax;
+            ConfigFile >> DataBuffer;
+            Ay = atof(DataBuffer.c_str());
+            Ay = Ay;
+            ConfigFile >> DataBuffer;
+            Az = atof(DataBuffer.c_str());
+            Az = Az;
+
+            A = TVector3(Ax, Ay, Az);
+            cout << "X1 Y1 corner position : (" << A.X() << ";" << A.Y() << ";" << A.Z() << ")" << endl;
+         }
+         else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) {
+            check_B = true;
+            ConfigFile >> DataBuffer;
+            Bx = atof(DataBuffer.c_str());
+            Bx = Bx;
+            ConfigFile >> DataBuffer;
+            By = atof(DataBuffer.c_str());
+            By = By;
+            ConfigFile >> DataBuffer;
+            Bz = atof(DataBuffer.c_str());
+            Bz = Bz;
+
+            B = TVector3(Bx, By, Bz);
+            cout << "X128 Y1 corner position : (" << B.X() << ";" << B.Y() << ";" << B.Z() << ")" << endl;
+         }
+         else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) {
+            check_C = true;
+            ConfigFile >> DataBuffer;
+            Cx = atof(DataBuffer.c_str());
+            Cx = Cx;
+            ConfigFile >> DataBuffer;
+            Cy = atof(DataBuffer.c_str());
+            Cy = Cy;
+            ConfigFile >> DataBuffer;
+            Cz = atof(DataBuffer.c_str());
+            Cz = Cz;
+
+            C = TVector3(Cx, Cy, Cz);
+            cout << "X1 Y128 corner position : (" << C.X() << ";" << C.Y() << ";" << C.Z() << ")" << endl;
+         }
+         else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) {
+            check_D = true;
+            ConfigFile >> DataBuffer;
+            Dx = atof(DataBuffer.c_str());
+            Dx = Dx;
+            ConfigFile >> DataBuffer;
+            Dy = atof(DataBuffer.c_str());
+            Dy = Dy;
+            ConfigFile >> DataBuffer;
+            Dz = atof(DataBuffer.c_str());
+            Dz = Dz;
+
+            D = TVector3(Dx, Dy, Dz);
+            cout << "X128 Y128 corner position : (" << D.X() << ";" << D.Y() << ";" << D.Z() << ")" << endl;
+         } // End Position Method
+
+         // Angle method
+         else if (DataBuffer.compare(0, 6, "THETA=") == 0) {
+            check_Theta = true;
+            ConfigFile >> DataBuffer;
+            Theta = atof(DataBuffer.c_str());
+            Theta = Theta;
+            cout << "Theta:  " << Theta << endl;
+         }
+         else if (DataBuffer.compare(0, 4, "PHI=") == 0) {
+            check_Phi = true;
+            ConfigFile >> DataBuffer;
+            Phi = atof(DataBuffer.c_str());
+            Phi = Phi;
+            cout << "Phi:  " << Phi << endl;
+         }
+         else if (DataBuffer.compare(0, 2, "R=") == 0) {
+            check_R = true;
+            ConfigFile >> DataBuffer;
+            R = atof(DataBuffer.c_str());
+            R = R;
+            cout << "R:  " << R << endl;
+         }
+         else if (DataBuffer.compare(0, 5, "BETA=") == 0) {
+            check_beta = true;
+            ConfigFile >> DataBuffer;
+            beta_u = atof(DataBuffer.c_str());
+            beta_u = beta_u;
+            ConfigFile >> DataBuffer;
+            beta_v = atof(DataBuffer.c_str());
+            beta_v = beta_v;
+            ConfigFile >> DataBuffer;
+            beta_w = atof(DataBuffer.c_str());
+            beta_w = beta_w;
+            cout << "Beta:  " << beta_u << " " << beta_v << " " << beta_w << 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 ) {
+               AddModule(A, B, C, D);
+               m_ModuleTest[m_index["DummyShape"] + m_NumberOfModule] = this;
+            }
+
+            // with angle method
+            else if ( check_Theta && check_Phi && check_R && check_beta ) {
+               AddModule(Theta, Phi, R, beta_u, beta_v, beta_w);
+               m_ModuleTest[m_index["DummyShape"] + m_NumberOfModule] = this;
+            }
+
+            // reset boolean flag for point positioning
+            check_A = false;
+            check_B = false;
+            check_C = false;
+            check_D = false;
+            // reset boolean flag for angle positioning
+            check_Theta = false;
+            check_Phi   = false;
+            check_R     = false;
+            check_beta  = false;
+
+         } // end test for adding a module
+      } // end while for reading block
+   } // end while for reading file
+
+   cout << endl << "/////////////////////////////" << endl<<endl;
+}
+
+
+
+void TGaspardTrackerDummyShape::BuildPhysicalEvent()
+{
+}
+
+
+
+void TGaspardTrackerDummyShape::BuildSimplePhysicalEvent()
+{
+}
+
+
+
+
+void TGaspardTrackerDummyShape::AddModule(TVector3 C_X1_Y1,
+                                          TVector3 C_X128_Y1,
+                                          TVector3 C_X1_Y128,
+                                          TVector3 C_X128_Y128)
+{
+   m_NumberOfModule++;
+
+   // remove warning using C_X128_Y128
+   C_X128_Y128.Unit();
+
+   // Vector U on Module Face (paralelle to Y Strip) (NB: remember that Y strip are allong X axis)
+   TVector3 U = C_X128_Y1 - C_X1_Y1;
+   U = U.Unit();
+
+   // Vector V on Module Face (parallele to X Strip)
+   TVector3 V = C_X1_Y128 - C_X1_Y1;
+   V = V.Unit();
+
+   // Position Vector of Strip Center
+   TVector3 StripCenter = TVector3(0,0,0);
+   // Position Vector of X=1 Y=1 Strip 
+   TVector3 Strip_1_1;
+
+   // Geometry Parameter
+   double Face = 50;            // mm
+   double NumberOfStrip = 128;
+   double StripPitch = Face/NumberOfStrip; // mm
+
+   // Buffer object to fill Position Array
+   vector<double> lineX;
+   vector<double> lineY;
+   vector<double> lineZ;
+
+   vector< vector< double > >   OneModuleStripPositionX;
+   vector< vector< double > >   OneModuleStripPositionY;
+   vector< vector< double > >   OneModuleStripPositionZ;
+
+   // Moving StripCenter to 1.1 corner:
+   Strip_1_1 = C_X1_Y1 + (U+V) * (StripPitch/2.);
+
+   for (int i = 0; i < NumberOfStrip; i++) {
+      lineX.clear();
+      lineY.clear();
+      lineZ.clear();
+
+      for (int j = 0; j < NumberOfStrip; j++) {
+         StripCenter  = Strip_1_1 + StripPitch*( i*U + j*V  );
+//         StripCenter += -TargetPosition;
+
+         lineX.push_back( StripCenter.X() );
+         lineY.push_back( StripCenter.Y() );
+         lineZ.push_back( StripCenter.Z() );
+      }
+
+      OneModuleStripPositionX.push_back(lineX);
+      OneModuleStripPositionY.push_back(lineY);
+      OneModuleStripPositionZ.push_back(lineZ);
+   }
+
+   m_StripPositionX.push_back( OneModuleStripPositionX );
+   m_StripPositionY.push_back( OneModuleStripPositionY );
+   m_StripPositionZ.push_back( OneModuleStripPositionZ );
+}
+
+
+
+void TGaspardTrackerDummyShape::AddModule(double theta,
+                                          double phi,
+                                          double distance,
+                                          double beta_u,
+                                          double beta_v,
+                                          double beta_w)
+{
+   m_NumberOfModule++;
+
+   // convert from degree to radian:
+   double Pi = 3.141592654;
+   theta = theta * Pi/180. ;
+   phi   = phi   * Pi/180. ;
+
+   // Vector U on Module Face (paralelle to Y Strip) (NB: remember that Y strip are allong X axis)
+   TVector3 U ;
+   // Vector V on Module Face (parallele to X Strip)
+   TVector3 V ;
+   // Vector W normal to Module Face (pointing CsI)
+   TVector3 W ;
+   // Vector position of Module Face center
+   TVector3 C ;
+
+   C = TVector3(distance * sin(theta) * cos(phi),
+                distance * sin(theta) * sin(phi),
+                distance * cos(theta));
+
+  TVector3 YperpW = TVector3( cos(theta) * cos(phi),
+                              cos(theta) * sin(phi),
+                             -sin(theta));
+
+   W = C.Unit();
+   U = W.Cross(YperpW);
+   V = W.Cross(U);
+
+   U = U.Unit();
+   V = V.Unit();
+
+   U.Rotate( beta_u * Pi/180. , U ) ;
+   V.Rotate( beta_u * Pi/180. , U ) ;
+
+   U.Rotate( beta_v * Pi/180. , V ) ;
+   V.Rotate( beta_v * Pi/180. , V ) ;
+
+   U.Rotate( beta_w * Pi/180. , W ) ;
+   V.Rotate( beta_w * Pi/180. , W ) ;
+
+   double Face = 50; // mm
+   double NumberOfStrip = 100;
+   double StripPitch = Face/NumberOfStrip; // mm
+
+   vector<double> lineX;
+   vector<double> lineY;
+   vector<double> lineZ;
+
+   vector< vector< double > >   OneModuleStripPositionX;
+   vector< vector< double > >   OneModuleStripPositionY;
+   vector< vector< double > >   OneModuleStripPositionZ;
+
+   double X, Y, Z;
+
+   // Moving C to the 1.1 corner:
+   C.SetX( C.X() - ( Face/2 - StripPitch/2 ) * ( V.X() + U.X() ) )  ;
+   C.SetY( C.Y() - ( Face/2 - StripPitch/2 ) * ( V.Y() + U.Y() ) )  ;
+   C.SetZ( C.Z() - ( Face/2 - StripPitch/2 ) * ( V.Z() + U.Z() ) )  ;
+
+   for (int i = 0; i < NumberOfStrip; i++) {
+      lineX.clear();
+      lineY.clear();
+      lineZ.clear();
+
+      for (int j = 0; j < NumberOfStrip; j++) {
+         X = C.X() + StripPitch * ( U.X()*i + V.X()*j );
+         Y = C.Y() + StripPitch * ( U.Y()*i + V.Y()*j );
+         Z = C.Z() + StripPitch * ( U.Z()*i + V.Z()*j );
+
+         lineX.push_back(X);
+         lineY.push_back(Y);
+         lineZ.push_back(Z);
+      }
+
+      OneModuleStripPositionX.push_back(lineX);
+      OneModuleStripPositionY.push_back(lineY);
+      OneModuleStripPositionZ.push_back(lineZ);
+   }
+
+   m_StripPositionX.push_back( OneModuleStripPositionX );
+   m_StripPositionY.push_back( OneModuleStripPositionY );
+   m_StripPositionZ.push_back( OneModuleStripPositionZ );
+}
diff --git a/NPLib/GASPARD/TGaspardTrackerDummyShape.h b/NPLib/GASPARD/TGaspardTrackerDummyShape.h
new file mode 100644
index 000000000..58ccf73e9
--- /dev/null
+++ b/NPLib/GASPARD/TGaspardTrackerDummyShape.h
@@ -0,0 +1,79 @@
+#ifndef TGaspardTrackerDummyShape_h
+#define TGaspardTrackerDummyShape_h 1
+
+// C++ headers
+#include <string>
+#include <map>
+#include <vector>
+
+// NPTool - ROOT headers
+#include "TInteractionCoordinates.h"
+#include "TGaspardTrackerData.h"
+#include "TVector3.h"
+
+// Gaspard headers
+#include "TGaspardTrackerModule.h"
+
+using namespace std;
+
+
+
+class TGaspardTrackerDummyShape : public TGaspardTrackerModule
+{
+public:
+   ////////////////////////////////////////////////////
+   /////// Default Constructor and Destructor /////////
+   ////////////////////////////////////////////////////
+   TGaspardTrackerDummyShape(map<int, TGaspardTrackerModule*> &Module);
+   virtual ~TGaspardTrackerDummyShape();
+
+public:
+   ////////////////////////////////////////////////////
+   ////  Inherite from GaspardTrackerModule class /////
+   ////////////////////////////////////////////////////
+   // Read stream at Configfile to pick-up parameters of detector (Position,...)
+   void ReadConfiguration(string Path);
+
+   // The goal of this method is to extract physical parameters from raw data
+   // Method called at each event read from the Input Tree
+   void BuildPhysicalEvent();
+
+   // Same as before but with a simpler treatment
+   void BuildSimplePhysicalEvent();
+
+private:
+   map<int, TGaspardTrackerModule*> &m_ModuleTest;
+
+public:
+   ////////////////////////////////
+   // Specific to GaspardTracker //
+   ////////////////////////////////
+   // Add a Module using Corner Coordinate information
+   void AddModule(TVector3 C_X1_Y1,
+                  TVector3 C_X128_Y1,
+                  TVector3 C_X1_Y128,
+                  TVector3 C_X128_Y128);
+
+   // Add a Module using R Theta Phi of Si center information
+   void AddModule(double theta,
+                  double phi,
+                  double distance,
+                  double beta_u,
+                  double beta_v,
+                  double beta_w);
+
+   // Getters to retrieve the (X,Y,Z) coordinates of a pixel defined by strips (X,Y)
+   double GetStripPositionX(int N ,int X ,int Y)        { return m_StripPositionX[N-1][X-1][Y-1]; }
+   double GetStripPositionY(int N ,int X ,int Y)        { return m_StripPositionY[N-1][X-1][Y-1]; }
+   double GetStripPositionZ(int N ,int X ,int Y)        { return m_StripPositionZ[N-1][X-1][Y-1]; }
+   double GetNumberOfModule()                           { return m_NumberOfModule; }
+
+private:
+   // Spatial Position of Strip Calculated on basis of detector position
+   int m_NumberOfModule;
+   vector< vector < vector < double > > >       m_StripPositionX;
+   vector< vector < vector < double > > >       m_StripPositionY;
+   vector< vector < vector < double > > >       m_StripPositionZ;
+};
+
+#endif
diff --git a/NPLib/GASPARD/TGaspardTrackerModule.cxx b/NPLib/GASPARD/TGaspardTrackerModule.cxx
index e69de29bb..fc908d0fb 100644
--- a/NPLib/GASPARD/TGaspardTrackerModule.cxx
+++ b/NPLib/GASPARD/TGaspardTrackerModule.cxx
@@ -0,0 +1,24 @@
+#include "TGaspardTrackerModule.h"
+
+
+
+TGaspardTrackerModule::TGaspardTrackerModule()
+{
+   InitializeIndex();
+}
+
+
+
+TGaspardTrackerModule::~TGaspardTrackerModule()
+{
+}
+
+
+
+void TGaspardTrackerModule::InitializeIndex()
+{
+   m_index["Square"]     =    0;
+   m_index["Trapezoid"]  =  100;
+   m_index["Annular"]    =  200;
+   m_index["DummyShape"] = 1000;
+}
diff --git a/NPLib/GASPARD/TGaspardTrackerModule.h b/NPLib/GASPARD/TGaspardTrackerModule.h
index e69de29bb..1b4c5bc40 100644
--- a/NPLib/GASPARD/TGaspardTrackerModule.h
+++ b/NPLib/GASPARD/TGaspardTrackerModule.h
@@ -0,0 +1,39 @@
+#ifndef TGaspardTrackerModule_h
+#define TGaspardTrackerModule_h 1
+
+// C++ headers
+#include <string>
+#include <map>
+
+// NPTool - ROOT headers
+#include "TGaspardTrackerData.h"
+
+using namespace std;
+
+
+
+class TGaspardTrackerModule
+{
+public:
+   TGaspardTrackerModule();
+   virtual ~TGaspardTrackerModule();
+
+public:
+   // Read stream at Configfile to pick-up parameters of detector (Position,...)
+   virtual void ReadConfiguration(string Path) = 0;
+
+   // The goal of this method is to extract physical parameters from raw data
+   // Method called at each event read from the Input Tree
+   virtual void BuildPhysicalEvent() = 0;
+
+   // Same as before but with a simpler treatment
+   virtual void BuildSimplePhysicalEvent() = 0;
+
+   // Initialize the Index map for the different modules of Gaspard
+   void InitializeIndex();
+
+protected:
+   map<string, int> m_index;
+};
+
+#endif
diff --git a/NPLib/GASPARD/TGaspardTrackerPhysicsNew.cxx b/NPLib/GASPARD/TGaspardTrackerPhysicsNew.cxx
new file mode 100644
index 000000000..34fcc15ab
--- /dev/null
+++ b/NPLib/GASPARD/TGaspardTrackerPhysicsNew.cxx
@@ -0,0 +1,267 @@
+/*****************************************************************************
+ * Copyright (C) 2009-2010   this file is part of the NPTool Project         *
+ *                                                                           *
+ * For the licensing terms see $NPTOOL/Licence/NPTool_Licence                *
+ * For the list of contributors see $NPTOOL/Licence/Contributors             *
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Original Author: N. de Sereville  contact address: deserevi@ipno.in2p3.fr *
+ *                                                                           *
+ * Creation Date  : 31/08/09                                                 *
+ * Last update    : 10/09/09                                                 *
+ *---------------------------------------------------------------------------*
+ * Decription: This class is mainly an interface to the                      *
+ *             TGaspardTrackerPhysics class and it deals with the geometrical*
+ *             correspondance between strip number and absolute coordinates  *
+ *             (X, Y, Z) of interaction.                                     *
+ *---------------------------------------------------------------------------*
+ * Comment:                                                                  *
+ *   + 10/09/09: Add support for Square and DummyShape shapes                *
+ *               (N. de Sereville)                                           *
+ *                                                                           *
+ *                                                                           *
+ *****************************************************************************/
+
+#include "TGaspardTrackerPhysicsNew.h"
+
+// C++ headers
+#include <iostream>	
+#include <fstream>
+#include <string>
+#include <cmath>
+#include <stdlib.h>
+
+// NPL headers
+#include "RootInput.h"
+#include "RootOutput.h"
+
+// ROOT headers
+#include "TChain.h"
+
+// Gaspard headers
+#include "TGaspardTrackerDummyShape.h"
+#include "TGaspardTrackerTrapezoid.h"
+
+using namespace std ;	
+
+
+
+
+TGaspardTrackerPhysicsNew::TGaspardTrackerPhysicsNew()
+	: m_EventData (new TGaspardTrackerData()),
+	  m_EventPhysics (this)
+{
+}	
+
+
+
+TGaspardTrackerPhysicsNew::~TGaspardTrackerPhysicsNew()
+{
+   delete m_EventData;
+   delete m_EventPhysics;
+}	
+
+
+
+void TGaspardTrackerPhysicsNew::Clear()
+{
+}
+
+
+
+// Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token
+void TGaspardTrackerPhysicsNew::ReadConfiguration(string Path) 	
+{
+   // open configuration file
+   ifstream ConfigFile;
+   ConfigFile.open(Path.c_str());
+
+   bool GPDTrkSquare     = false;
+   bool GPDTrkTrapezoid  = false;
+   bool GPDTrkAnnular    = false;
+   bool GPDTrkDummyShape = false;
+
+   string LineBuffer;
+   while (!ConfigFile.eof()) {
+      getline(ConfigFile, LineBuffer);
+      if (LineBuffer.compare(0, 9, "GPDSquare") == 0  &&  GPDTrkSquare == false) {
+         GPDTrkSquare = true;
+/*
+         // instantiate a new "detector" corresponding to the Square elements
+         TGaspardTrackerModule* myDetector = new TGaspardTrackerSquare();
+
+         // read part of the configuration file corresponding to square elements
+         ConfigFile.close();
+         myDetector->ReadConfiguration(Path);
+         ConfigFile.open(Path.c_str());
+*/      }
+      else if (LineBuffer.compare(0, 12, "GPDTrapezoid") == 0  &&  GPDTrkTrapezoid == false) {
+         GPDTrkTrapezoid = true;
+
+         // instantiate a new "detector" corresponding to the Trapezoid elements
+         TGaspardTrackerModule* myDetector = new TGaspardTrackerTrapezoid(m_ModulesMap);
+
+         // read part of the configuration file corresponding to trapezoid elements
+         ConfigFile.close();
+         myDetector->ReadConfiguration(Path);
+         ConfigFile.open(Path.c_str());
+      }
+      else if (LineBuffer.compare(0, 10, "GPDAnnular") == 0  &&  GPDTrkAnnular == false) {
+         GPDTrkAnnular = true;
+/*
+         // instantiate a new "detector" corresponding to the Trapezoid elements
+         TGaspardTrackerModule* myDetector = new TGaspardTrackerAnnular();
+
+         // read part of the configuration file corresponding to trapezoid elements
+         ConfigFile.close();
+         myDetector->ReadConfiguration(Path);
+         ConfigFile.open(Path.c_str());
+*/      }
+      else if (LineBuffer.compare(0, 13, "GPDDummyShape") == 0  &&  GPDTrkDummyShape == false) {
+         GPDTrkDummyShape = true;
+
+         // instantiate a new "detector" corresponding to the Shape elements
+         // The GaspardTrackerSquare class should be replaced by the
+         // GaspardTrackerShape class you need to define
+         TGaspardTrackerModule* myDetector = new TGaspardTrackerDummyShape(m_ModulesMap);
+
+         // read part of the configuration file corresponding to shape elements
+         ConfigFile.close();
+         myDetector->ReadConfiguration(Path);
+         ConfigFile.open(Path.c_str());
+      }
+   }
+
+   DumpMap();
+}
+
+
+// Read stream at Path and pick-up calibration parameter using Token
+// If argument is "Simulation" no change calibration is loaded
+void TGaspardTrackerPhysicsNew::ReadCalibrationFile(string Path)	
+{
+/*   // Order of Polynom function used for calibration
+   int Calibration_Si_E_Order;
+   int Calibration_Si_T_Order;
+   int Calibration_SiLi_E_Order;
+   int Calibration_CsI_E_Order;
+
+   // Calibration_Si_X_E[DetectorNumber][StripNumber][Order of Coeff]
+   vector< vector< vector< double > > >	Calibration_Si_X_E	;
+   vector< vector< vector< double > > >	Calibration_Si_X_T	;
+   vector< vector< vector< double > > >	Calibration_Si_Y_E	;
+   vector< vector< vector< double > > >	Calibration_Si_Y_T	;
+
+   // Calibration_SiLi_E[DetectorNumber][PadNumber][Order of Coeff]
+   vector< vector< vector< double > > >	Calibration_SiLi_E	;
+
+   // Calibration_SiLi_E[DetectorNumber][CrystalNumber][Order of Coeff]
+   vector< vector< vector< double > > >	Calibration_CsI_E	;
+
+   if (Path == "Simulation") {   // Simulation case: data already calibrated
+      Calibration_Si_E_Order   = 1;
+      Calibration_Si_T_Order   = 1;
+      Calibration_SiLi_E_Order = 1;
+      Calibration_CsI_E_Order  = 1;
+
+      vector<double> Coef;
+      // Order 0				Order 1
+      Coef.push_back(0) ; Coef.push_back(1) 	;
+
+      vector< vector<double> > StripLine 		;
+      StripLine.resize( 128 , Coef)			;
+
+      Calibration_Si_X_E.resize( m_NumberOfModule , StripLine)	;
+      Calibration_Si_X_T.resize( m_NumberOfModule , StripLine)	;
+      Calibration_Si_Y_E.resize( m_NumberOfModule , StripLine)	;
+      Calibration_Si_Y_T.resize( m_NumberOfModule , StripLine)	;
+				
+      Calibration_SiLi_E.resize( m_NumberOfModule , StripLine)	;
+      Calibration_CsI_E .resize( m_NumberOfModule , StripLine)	;
+   }
+   else {
+   }
+*/
+}		
+
+	
+
+// 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 TGaspardTrackerPhysicsNew::InitializeRootInput() 		
+{
+   TChain* inputChain = RootInput::getInstance()->GetChain();
+   inputChain->SetBranchStatus("GASPARD", true);
+   inputChain->SetBranchStatus("fGPD*", true);
+   inputChain->SetBranchAddress("GASPARD", &m_EventData);
+}
+
+
+
+// Create associated branches and associated private member DetectorPhysics address
+void TGaspardTrackerPhysicsNew::InitializeRootOutput() 	
+{
+   TTree* outputTree = RootOutput::getInstance()->GetTree();
+   outputTree->Branch("GASPARD", "TGaspardTrackerPhysicsNew", &m_EventPhysics);
+}
+
+
+
+// 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 TGaspardTrackerPhysicsNew::BuildPhysicalEvent()		
+{
+/*   if (m_ModulesMap.size() > 0) {
+      for (UInt_t i = 0; i < m_ModulesMap.size(); i++) {
+         m_ModulesMap[i]->BuildPhysicalEvent();
+      }
+   }*/
+}
+
+
+
+void TGaspardTrackerPhysicsNew::DumpMap()
+{
+   cout << "TGaspardTrackerPhysicsNew::DumpMap()" << endl;
+
+   map<int, TGaspardTrackerModule*>::iterator it;
+
+   for (it = m_ModulesMap.begin(); it != m_ModulesMap.end(); ++it) {
+      cout << "Module " << it->first << " -> Address " << it->second << endl;
+   }
+}
+
+
+
+// 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 TGaspardTrackerPhysicsNew::BuildSimplePhysicalEvent()	
+{
+   BuildPhysicalEvent();
+}
+
+
+
+double TGaspardTrackerPhysicsNew::GetEnergyDeposit()		
+{ 
+/*   if (m_EventPhysics->TotalEnergy.size() > 0)
+      return m_EventPhysics->TotalEnergy[0]; 
+   else*/ 
+      return -1000;
+}
+
+
+
+TVector3 TGaspardTrackerPhysicsNew::GetPositionOfInteraction()
+{
+   TVector3 Position = TVector3(-1000,-1000,-1000);
+
+/*   if (m_EventPhysics->ModuleNumber.size() == 1) {
+      Position = TVector3(GetStripPositionX(m_EventPhysics->ModuleNumber[0], m_EventPhysics->FirstStage_X[0], m_EventPhysics->FirstStage_Y[0]),
+                          GetStripPositionY(m_EventPhysics->ModuleNumber[0], m_EventPhysics->FirstStage_X[0], m_EventPhysics->FirstStage_Y[0]),
+                          GetStripPositionZ(m_EventPhysics->ModuleNumber[0], m_EventPhysics->FirstStage_X[0], m_EventPhysics->FirstStage_Y[0])); 
+   }
+*/
+   return(Position);
+}
diff --git a/NPLib/GASPARD/TGaspardTrackerPhysicsNew.h b/NPLib/GASPARD/TGaspardTrackerPhysicsNew.h
new file mode 100644
index 000000000..e3715b66a
--- /dev/null
+++ b/NPLib/GASPARD/TGaspardTrackerPhysicsNew.h
@@ -0,0 +1,107 @@
+/*****************************************************************************
+ * Copyright (C) 2009-2010   this file is part of the NPTool Project         *
+ *                                                                           *
+ * For the licensing terms see $NPTOOL/Licence/NPTool_Licence                *
+ * For the list of contributors see $NPTOOL/Licence/Contributors             *
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Original Author: N. de Sereville  contact address: deserevi@ipno.in2p3.fr *
+ *                                                                           *
+ * Creation Date  : 31/08/09                                                 *
+ * Last update    : 10/09/09                                                 *
+ *---------------------------------------------------------------------------*
+ * Decription: This class is mainly an interface to the                      *
+ *             TGaspardTrackerPhysics class and it deals with the geometrical*
+ *             correspondance between strip number and absolute coordinates  *
+ *             (X, Y, Z) of interaction.                                     *
+ *---------------------------------------------------------------------------*
+ * Comment:                                                                  *
+ *   + 10/09/09: Add support for Square and DummyShape shapes                *
+ *               (N. de Sereville)                                           *
+ *                                                                           *
+ *                                                                           *
+ *****************************************************************************/
+
+#ifndef TGaspardTrackerPhysicsNew_H
+
+// NPL
+#include "../include/VDetector.h"
+#include "TGaspardTrackerData.h"
+#include "TGaspardTrackerModule.h"
+
+// C++
+#include <map>
+#include <vector>
+
+// Root
+#include "TObject.h"
+#include "TVector3.h"
+
+class TGaspardTrackerPhysicsNew : public TObject, public NPA::VDetector
+{
+public:
+   TGaspardTrackerPhysicsNew();
+   virtual ~TGaspardTrackerPhysicsNew();
+
+public:
+  void Clear()                                                                    ;
+  void Clear(const Option_t*) {};
+
+public:
+   /////////////////////////////////////
+   // Innherited from VDetector Class //
+   /////////////////////////////////////
+   // Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token
+   void ReadConfiguration(string);
+
+   // Read stream at CalibFile and pick-up calibration parameter using Token
+   // If argument is "Simulation" no change calibration is loaded
+   void ReadCalibrationFile(string);
+
+   // 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. 
+   // The aim 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()	{m_EventPhysics->Clear();}
+   void ClearEventData()	{m_EventData->Clear();}
+
+
+public:
+   void DumpMap();
+
+private:
+   map<int, TGaspardTrackerModule*>	m_ModulesMap;	//!
+
+public:
+   // Get Root input and output objects
+   TGaspardTrackerData* 	GetEventData()		{return m_EventData;}
+   TGaspardTrackerPhysicsNew*	GetEventPhysics()	{return m_EventPhysics;}
+
+   // To be called after a build Physical Event 
+   double	GetEnergyDeposit();
+   TVector3	GetPositionOfInteraction();
+
+
+private:
+   ////////////////////////////////////////
+   // Root Input and Output tree classes //
+   ////////////////////////////////////////
+   TGaspardTrackerData*		m_EventData;	//!
+   TGaspardTrackerPhysicsNew*	m_EventPhysics;	//!
+};
+
+#endif
diff --git a/NPLib/GASPARD/TGaspardTrackerTrapezoid.cxx b/NPLib/GASPARD/TGaspardTrackerTrapezoid.cxx
new file mode 100644
index 000000000..c5f7c7593
--- /dev/null
+++ b/NPLib/GASPARD/TGaspardTrackerTrapezoid.cxx
@@ -0,0 +1,379 @@
+#include "TGaspardTrackerTrapezoid.h"
+
+// C++ headers
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <cmath>
+
+
+TGaspardTrackerTrapezoid::TGaspardTrackerTrapezoid(map<int, TGaspardTrackerModule*> &Module) 
+	: m_ModuleTest(Module),
+	  m_NumberOfModule(0)
+{
+}
+
+
+
+TGaspardTrackerTrapezoid::~TGaspardTrackerTrapezoid()
+{
+}
+
+
+
+void TGaspardTrackerTrapezoid::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
+
+   double   Ax, Bx, Cx, Dx, Ay, By, Cy, Dy, Az, Bz, Cz, Dz;
+   TVector3 A, B, C, D;
+   double   Theta = 0, Phi = 0, R = 0, beta_u = 0 , beta_v = 0 , beta_w = 0;
+
+   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;
+   bool check_beta  = false;
+
+   bool ReadingStatus = false;
+
+   while (!ConfigFile.eof()) {
+      getline(ConfigFile, LineBuffer);
+
+      // If line is a GaspardXXX bloc, reading toggle to true
+      // and toggle to true flags indicating which shape is treated.
+      if (LineBuffer.compare(0, 12, "GPDTrapezoid") == 0) {
+         cout << "///////////////////////" << endl;
+         cout << "Trapezoid module found:" << endl;
+         ReadingStatus = true;
+      }
+
+      // Reading Block
+      while (ReadingStatus) {
+         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, 12, "GPDTrapezoid") == 0) {
+            cout << "WARNING: Another Module is find before standard sequence of Token, Error may occured in Telecope definition" << endl;
+            ReadingStatus = false;
+         }
+
+         // Position method
+         else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) {
+            check_A = true;
+            ConfigFile >> DataBuffer;
+            Ax = atof(DataBuffer.c_str());
+            Ax = Ax;
+            ConfigFile >> DataBuffer;
+            Ay = atof(DataBuffer.c_str());
+            Ay = Ay;
+            ConfigFile >> DataBuffer;
+            Az = atof(DataBuffer.c_str());
+            Az = Az;
+
+            A = TVector3(Ax, Ay, Az);
+            cout << "X1 Y1 corner position : (" << A.X() << ";" << A.Y() << ";" << A.Z() << ")" << endl;
+         }
+         else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) {
+            check_B = true;
+            ConfigFile >> DataBuffer;
+            Bx = atof(DataBuffer.c_str());
+            Bx = Bx;
+            ConfigFile >> DataBuffer;
+            By = atof(DataBuffer.c_str());
+            By = By;
+            ConfigFile >> DataBuffer;
+            Bz = atof(DataBuffer.c_str());
+            Bz = Bz;
+
+            B = TVector3(Bx, By, Bz);
+            cout << "X128 Y1 corner position : (" << B.X() << ";" << B.Y() << ";" << B.Z() << ")" << endl;
+         }
+         else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) {
+            check_C = true;
+            ConfigFile >> DataBuffer;
+            Cx = atof(DataBuffer.c_str());
+            Cx = Cx;
+            ConfigFile >> DataBuffer;
+            Cy = atof(DataBuffer.c_str());
+            Cy = Cy;
+            ConfigFile >> DataBuffer;
+            Cz = atof(DataBuffer.c_str());
+            Cz = Cz;
+
+            C = TVector3(Cx, Cy, Cz);
+            cout << "X1 Y128 corner position : (" << C.X() << ";" << C.Y() << ";" << C.Z() << ")" << endl;
+         }
+         else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) {
+            check_D = true;
+            ConfigFile >> DataBuffer;
+            Dx = atof(DataBuffer.c_str());
+            Dx = Dx;
+            ConfigFile >> DataBuffer;
+            Dy = atof(DataBuffer.c_str());
+            Dy = Dy;
+            ConfigFile >> DataBuffer;
+            Dz = atof(DataBuffer.c_str());
+            Dz = Dz;
+
+            D = TVector3(Dx, Dy, Dz);
+            cout << "X128 Y128 corner position : (" << D.X() << ";" << D.Y() << ";" << D.Z() << ")" << endl;
+         } // End Position Method
+
+         // Angle method
+         else if (DataBuffer.compare(0, 6, "THETA=") == 0) {
+            check_Theta = true;
+            ConfigFile >> DataBuffer;
+            Theta = atof(DataBuffer.c_str());
+            Theta = Theta;
+            cout << "Theta:  " << Theta << endl;
+         }
+         else if (DataBuffer.compare(0, 4, "PHI=") == 0) {
+            check_Phi = true;
+            ConfigFile >> DataBuffer;
+            Phi = atof(DataBuffer.c_str());
+            Phi = Phi;
+            cout << "Phi:  " << Phi << endl;
+         }
+         else if (DataBuffer.compare(0, 2, "R=") == 0) {
+            check_R = true;
+            ConfigFile >> DataBuffer;
+            R = atof(DataBuffer.c_str());
+            R = R;
+            cout << "R:  " << R << endl;
+         }
+         else if (DataBuffer.compare(0, 5, "BETA=") == 0) {
+            check_beta = true;
+            ConfigFile >> DataBuffer;
+            beta_u = atof(DataBuffer.c_str());
+            beta_u = beta_u;
+            ConfigFile >> DataBuffer;
+            beta_v = atof(DataBuffer.c_str());
+            beta_v = beta_v;
+            ConfigFile >> DataBuffer;
+            beta_w = atof(DataBuffer.c_str());
+            beta_w = beta_w;
+            cout << "Beta:  " << beta_u << " " << beta_v << " " << beta_w << 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 ) {
+               AddModule(A, B, C, D);
+               m_ModuleTest[m_index["Trapezoid"] + m_NumberOfModule] = this;
+            }
+
+            // with angle method
+            else if ( check_Theta && check_Phi && check_R && check_beta ) {
+               AddModule(Theta, Phi, R, beta_u, beta_v, beta_w);
+               m_ModuleTest[m_index["Trapezoid"] + m_NumberOfModule] = this;
+            }
+
+            // reset boolean flag for point positioning
+            check_A = false;
+            check_B = false;
+            check_C = false;
+            check_D = false;
+            // reset boolean flag for angle positioning
+            check_Theta = false;
+            check_Phi   = false;
+            check_R     = false;
+            check_beta  = false;
+
+         } // end test for adding a module
+      } // end while for reading block
+   } // end while for reading file
+
+   cout << endl << "/////////////////////////////" << endl<<endl;
+}
+
+
+
+void TGaspardTrackerTrapezoid::BuildPhysicalEvent()
+{
+}
+
+
+
+void TGaspardTrackerTrapezoid::BuildSimplePhysicalEvent()
+{
+}
+
+
+
+void TGaspardTrackerTrapezoid::AddModule(TVector3 C_X1_Y1,
+                                          TVector3 C_X128_Y1,
+                                          TVector3 C_X1_Y128,
+                                          TVector3 C_X128_Y128)
+{
+   m_NumberOfModule++;
+
+   // remove warning using C_X128_Y128
+   C_X128_Y128.Unit();
+
+   // Vector U on Module Face (paralelle to Y Strip) (NB: remember that Y strip are allong X axis)
+   TVector3 U = C_X128_Y1 - C_X1_Y1;
+   U = U.Unit();
+
+   // Vector V on Module Face (parallele to X Strip)
+   TVector3 V = C_X1_Y128 - C_X1_Y1;
+   V = V.Unit();
+
+   // Position Vector of Strip Center
+   TVector3 StripCenter = TVector3(0,0,0);
+   // Position Vector of X=1 Y=1 Strip 
+   TVector3 Strip_1_1;
+
+   // Geometry Parameter
+   double Face = 50;            // mm
+   double NumberOfStrip = 128;
+   double StripPitch = Face/NumberOfStrip; // mm
+
+   // Buffer object to fill Position Array
+   vector<double> lineX;
+   vector<double> lineY;
+   vector<double> lineZ;
+
+   vector< vector< double > >   OneModuleStripPositionX;
+   vector< vector< double > >   OneModuleStripPositionY;
+   vector< vector< double > >   OneModuleStripPositionZ;
+
+   // Moving StripCenter to 1.1 corner:
+   Strip_1_1 = C_X1_Y1 + (U+V) * (StripPitch/2.);
+
+   for (int i = 0; i < NumberOfStrip; i++) {
+      lineX.clear();
+      lineY.clear();
+      lineZ.clear();
+
+      for (int j = 0; j < NumberOfStrip; j++) {
+         StripCenter  = Strip_1_1 + StripPitch*( i*U + j*V  );
+//         StripCenter += -TargetPosition;
+
+         lineX.push_back( StripCenter.X() );
+         lineY.push_back( StripCenter.Y() );
+         lineZ.push_back( StripCenter.Z() );
+      }
+
+      OneModuleStripPositionX.push_back(lineX);
+      OneModuleStripPositionY.push_back(lineY);
+      OneModuleStripPositionZ.push_back(lineZ);
+   }
+
+   m_StripPositionX.push_back( OneModuleStripPositionX );
+   m_StripPositionY.push_back( OneModuleStripPositionY );
+   m_StripPositionZ.push_back( OneModuleStripPositionZ );
+}
+
+
+
+void TGaspardTrackerTrapezoid::AddModule(double theta,
+                                          double phi,
+                                          double distance,
+                                          double beta_u,
+                                          double beta_v,
+                                          double beta_w)
+{
+   m_NumberOfModule++;
+
+   // convert from degree to radian:
+   double Pi = 3.141592654;
+   theta = theta * Pi/180. ;
+   phi   = phi   * Pi/180. ;
+
+   // Vector U on Module Face (paralelle to Y Strip) (NB: remember that Y strip are allong X axis)
+   TVector3 U ;
+   // Vector V on Module Face (parallele to X Strip)
+   TVector3 V ;
+   // Vector W normal to Module Face (pointing CsI)
+   TVector3 W ;
+   // Vector position of Module Face center
+   TVector3 C ;
+
+   C = TVector3(distance * sin(theta) * cos(phi),
+                distance * sin(theta) * sin(phi),
+                distance * cos(theta));
+
+  TVector3 YperpW = TVector3( cos(theta) * cos(phi),
+                              cos(theta) * sin(phi),
+                             -sin(theta));
+
+   W = C.Unit();
+   U = W.Cross(YperpW);
+   V = W.Cross(U);
+
+   U = U.Unit();
+   V = V.Unit();
+
+   U.Rotate( beta_u * Pi/180. , U ) ;
+   V.Rotate( beta_u * Pi/180. , U ) ;
+
+   U.Rotate( beta_v * Pi/180. , V ) ;
+   V.Rotate( beta_v * Pi/180. , V ) ;
+
+   U.Rotate( beta_w * Pi/180. , W ) ;
+   V.Rotate( beta_w * Pi/180. , W ) ;
+
+   double Face = 50; // mm
+   double NumberOfStrip = 100;
+   double StripPitch = Face/NumberOfStrip; // mm
+
+   vector<double> lineX;
+   vector<double> lineY;
+   vector<double> lineZ;
+
+   vector< vector< double > >   OneModuleStripPositionX;
+   vector< vector< double > >   OneModuleStripPositionY;
+   vector< vector< double > >   OneModuleStripPositionZ;
+
+   double X, Y, Z;
+
+   // Moving C to the 1.1 corner:
+   C.SetX( C.X() - ( Face/2 - StripPitch/2 ) * ( V.X() + U.X() ) )  ;
+   C.SetY( C.Y() - ( Face/2 - StripPitch/2 ) * ( V.Y() + U.Y() ) )  ;
+   C.SetZ( C.Z() - ( Face/2 - StripPitch/2 ) * ( V.Z() + U.Z() ) )  ;
+
+   for (int i = 0; i < NumberOfStrip; i++) {
+      lineX.clear();
+      lineY.clear();
+      lineZ.clear();
+
+      for (int j = 0; j < NumberOfStrip; j++) {
+         X = C.X() + StripPitch * ( U.X()*i + V.X()*j );
+         Y = C.Y() + StripPitch * ( U.Y()*i + V.Y()*j );
+         Z = C.Z() + StripPitch * ( U.Z()*i + V.Z()*j );
+
+         lineX.push_back(X);
+         lineY.push_back(Y);
+         lineZ.push_back(Z);
+      }
+
+      OneModuleStripPositionX.push_back(lineX);
+      OneModuleStripPositionY.push_back(lineY);
+      OneModuleStripPositionZ.push_back(lineZ);
+   }
+
+   m_StripPositionX.push_back( OneModuleStripPositionX );
+   m_StripPositionY.push_back( OneModuleStripPositionY );
+   m_StripPositionZ.push_back( OneModuleStripPositionZ );
+}
diff --git a/NPLib/GASPARD/TGaspardTrackerTrapezoid.h b/NPLib/GASPARD/TGaspardTrackerTrapezoid.h
new file mode 100644
index 000000000..4c8964ed8
--- /dev/null
+++ b/NPLib/GASPARD/TGaspardTrackerTrapezoid.h
@@ -0,0 +1,79 @@
+#ifndef TGaspardTrackerTrapezoid_h
+#define TGaspardTrackerTrapezoid_h 1
+
+// C++ headers
+#include <string>
+#include <map>
+#include <vector>
+
+// NPTool - ROOT headers
+#include "TInteractionCoordinates.h"
+#include "TGaspardTrackerData.h"
+#include "TVector3.h"
+
+// Gaspard headers
+#include "TGaspardTrackerModule.h"
+
+using namespace std;
+
+
+
+class TGaspardTrackerTrapezoid : public TGaspardTrackerModule
+{
+public:
+   ////////////////////////////////////////////////////
+   /////// Default Constructor and Destructor /////////
+   ////////////////////////////////////////////////////
+   TGaspardTrackerTrapezoid(map<int, TGaspardTrackerModule*> &Module);
+   virtual ~TGaspardTrackerTrapezoid();
+
+public:
+   ////////////////////////////////////////////////////
+   ////  Inherite from GaspardTrackerModule class /////
+   ////////////////////////////////////////////////////
+   // Read stream at Configfile to pick-up parameters of detector (Position,...)
+   void ReadConfiguration(string Path);
+
+   // The goal of this method is to extract physical parameters from raw data
+   // Method called at each event read from the Input Tree
+   void BuildPhysicalEvent();
+
+   // Same as before but with a simpler treatment
+   void BuildSimplePhysicalEvent();
+
+private:
+   map<int, TGaspardTrackerModule*> &m_ModuleTest;
+
+public:
+   ////////////////////////////////
+   // Specific to GaspardTracker //
+   ////////////////////////////////
+   // Add a Module using Corner Coordinate information
+   void AddModule(TVector3 C_X1_Y1,
+                  TVector3 C_X128_Y1,
+                  TVector3 C_X1_Y128,
+                  TVector3 C_X128_Y128);
+
+   // Add a Module using R Theta Phi of Si center information
+   void AddModule(double theta,
+                  double phi,
+                  double distance,
+                  double beta_u,
+                  double beta_v,
+                  double beta_w);
+
+   // Getters to retrieve the (X,Y,Z) coordinates of a pixel defined by strips (X,Y)
+   double GetStripPositionX(int N ,int X ,int Y)        { return m_StripPositionX[N-1][X-1][Y-1]; }
+   double GetStripPositionY(int N ,int X ,int Y)        { return m_StripPositionY[N-1][X-1][Y-1]; }
+   double GetStripPositionZ(int N ,int X ,int Y)        { return m_StripPositionZ[N-1][X-1][Y-1]; }
+   double GetNumberOfModule()                           { return m_NumberOfModule; }
+
+private:
+   // Spatial Position of Strip Calculated on basis of detector position
+   int m_NumberOfModule;
+   vector< vector < vector < double > > >       m_StripPositionX;
+   vector< vector < vector < double > > >       m_StripPositionY;
+   vector< vector < vector < double > > >       m_StripPositionZ;
+};
+
+#endif
diff --git a/NPLib/VDetector/DetectorManager.cxx b/NPLib/VDetector/DetectorManager.cxx
index a1cd19be3..2764db4ff 100644
--- a/NPLib/VDetector/DetectorManager.cxx
+++ b/NPLib/VDetector/DetectorManager.cxx
@@ -10,6 +10,7 @@
 #include "../SSSD/TSSSDPhysics.h"
 #include "../Plastic/TPlasticPhysics.h"
 #include "../GASPARD/GaspardTracker.h"
+#include "../GASPARD/TGaspardTrackerPhysicsNew.h"
 #include "../Paris/Paris.h"
 #include "../Shield/Shield.h"
 
@@ -77,7 +78,8 @@ void DetectorManager::ReadConfigurationFile(string Path)
          cout << "//////// Gaspard Tracker ////////" << endl;
 
          // Instantiate the new array as a VDetector Object
-         VDetector* myDetector = new GaspardTracker();
+//         VDetector* myDetector = new GaspardTracker();
+         VDetector* myDetector = new TGaspardTrackerPhysicsNew();
 
          // Read Position of Telescope
          ConfigFile.close();
diff --git a/NPLib/liblist b/NPLib/liblist
index a09875ac0..39ebc0c95 100755
--- a/NPLib/liblist
+++ b/NPLib/liblist
@@ -4,6 +4,7 @@ echo  -L$NPLIB/lib -lVDetector -lDetectorManager -lCalibrationManager -lIORoot -
 			-lPlasticData -lPlasticPhysics \
 			-lAnnularS1Data \
 			-lGaspardData -lGaspardPhysics \
+			-lGaspardPhysicsNew -lGaspardTrackerModules \
 			-lDUMMYDetectorData \
 			-lParisData -lParisPhysics\
 			-lShieldData -lShieldPhysics\
-- 
GitLab