From 5d65b1ce3666383aa5f045115bf4de2286dca932 Mon Sep 17 00:00:00 2001
From: deserevi <deserevi@nptool>
Date: Tue, 16 Nov 2010 22:53:41 +0000
Subject: [PATCH] * Change scheme for NPL Makefile    + scripts are used to
 move header files, libraries to the include and      lib directories    +
 scripts are located in NPLib/scripts    + liblist is know created on the fly
 and is removed from the NPTool      package

* Update NPL Makefile to include Paris and Shield detectors
---
 .../DetectorConfiguration/gaspHyde.detector   |  12 +-
 NPLib/Makefile                                | 126 +++++-------------
 NPLib/README                                  |  31 +++--
 NPLib/liblist                                 |  11 --
 NPLib/scripts/buildliblist.sh                 |  50 +++++++
 NPLib/scripts/fillincdir.sh                   |  38 ++++++
 NPLib/scripts/filllibdir.sh                   |  34 +++++
 NPLib/scripts/filllibmacdir.sh                |  36 +++++
 NPSimulation/src/GaspardTrackerTrapezoid.cc   |  39 +++---
 9 files changed, 246 insertions(+), 131 deletions(-)
 delete mode 100755 NPLib/liblist
 create mode 100755 NPLib/scripts/buildliblist.sh
 create mode 100755 NPLib/scripts/fillincdir.sh
 create mode 100755 NPLib/scripts/filllibdir.sh
 create mode 100755 NPLib/scripts/filllibmacdir.sh

diff --git a/Inputs/DetectorConfiguration/gaspHyde.detector b/Inputs/DetectorConfiguration/gaspHyde.detector
index 744325b09..5dc9f2b99 100644
--- a/Inputs/DetectorConfiguration/gaspHyde.detector
+++ b/Inputs/DetectorConfiguration/gaspHyde.detector
@@ -28,7 +28,7 @@ Target
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%	
 GaspardTracker
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2
-GPDTrapezoid
+%GPDTrapezoid
 	THETA= 0 
 	PHI= 0
 	R= 200
@@ -37,6 +37,16 @@ GPDTrapezoid
         SECONDSTAGE= 1
         THIRDSTAGE= 1
         VIS= all
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%1 Barrel
+GPDTrapezoid
+        X1_Y1=    	-25.0	-25.00   200.00
+        X128_Y1=       	 25.0	-25.00   200.00
+        X1_Y128=        -25.0 	 25.00	 200.00
+        X128_Y128=       25.0	 25.00   200.00
+        FIRSTSTAGE= 1
+        SECONDSTAGE= 1
+        THIRDSTAGE= 1
+        VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2
 %GPDDummyShape
 	THETA= 180 
diff --git a/NPLib/Makefile b/NPLib/Makefile
index 823892fea..9f8f51ce3 100644
--- a/NPLib/Makefile
+++ b/NPLib/Makefile
@@ -269,151 +269,95 @@ INCLUDE		= -I$(CLHEP_BASE_DIR)/include
  
 #------------------------------------------------------------------------------
 SHARELIB      =	CalibManager Vdetec InputOutputRoot InitCond	InterCoord \
-		Must2All	GaspardData	AnnularS1Data PlasticData DummyDetectorData SSSDData\
-		Reaction	EnergyLoss	ParisData	ShieldData
+		Must2All	GaspardData	ParisData	ShieldData \
+		AnnularS1Data	PlasticData	DummyDetectorData SSSDData \
+		Reaction	EnergyLoss
 
-all:         $(SHARELIB)
-	rm -f ./include/*Dict.h
+FILLINCLIB	= fillinclib
+LIBLIST		= liblistfile
+
+all:         $(SHARELIB) $(FILLINCLIB) $(LIBLIST)
 #------------------------------------------------------------------------------
-############### Calibration ##############
+############### fillinclib ##############
+fillinclib:
+		./scripts/fillincdir.sh
+		./scripts/filllibdir.sh
+ifeq ($(ARCH),macosx)
+		./scripts/filllibmacdir.sh
+endif
 
+############### liblist ##############
+liblistfile:
+		echo "Building liblist"
+		./scripts/buildliblist.sh
+
+############### Calibration ##############
 ## CalibrationManager ##
 CalibManager:
 		make -C ./CalibrationManager
-		cp ./CalibrationManager/*.so ./lib ; cp ./CalibrationManager/*.h ./include
-ifeq ($(ARCH),macosx)
-		cd lib; ln -sf libCalibrationManager.so libCalibrationManager.dylib
-endif
+		cp ./CalibrationManager/*.h ./include
 
 ############### Detector ##############
-
 ## VDetector ##
 Vdetec:
 		cp ./VDetector/*.h ./include
 		make -C ./VDetector
-		cp ./VDetector/*.so ./lib
-ifeq ($(ARCH),macosx)
-		cd lib; ln -sf libVDetector.so libVDetector.dylib
-		cd lib; ln -sf libDetectorManager.so libDetectorManager.dylib
-endif
 		
 ## MUST2 ##
 Must2All:
 		make -C ./MUST2
-		cp ./MUST2/*.so ./lib ; cp ./MUST2/*.h ./include
-ifeq ($(ARCH),macosx)
-		cd lib; ln -sf libMust2Data.so libMust2Data.dylib
-		cd lib; ln -sf libMust2Physics.so libMust2Physics.dylib
-endif
 
 ## SSSD ##
 SSSDData:
 		make -C ./SSSD
-		cp ./SSSD/*.so ./lib ; cp ./SSSD/*.h ./include
-ifeq ($(ARCH),macosx)
-		cd lib; ln -sf libSSSDData.so libSSSDData.dylib
-		cd lib; ln -sf libSSSDPhysics.so libSSSDPhysics.dylib
-endif
 
 ## AnnularS1 ##
 AnnularS1Data:
 		make -C ./AnnularS1
-		cp ./AnnularS1/*.so ./lib ; cp ./AnnularS1/*.h ./include
-ifeq ($(ARCH),macosx)
-		cd lib; ln -sf libAnnularS1Data.so libAnnularS1Data.dylib
-endif
 
 ## Gaspard ##
 GaspardData:
 		make -C ./GASPARD
-		cp ./GASPARD/*.so ./lib ; cp ./GASPARD/*.h ./include
-ifeq ($(ARCH),macosx)
-		cd lib; ln -sf libGaspardData.so libGaspardData.dylib
-		cd lib; ln -sf libGaspardPhysics.so libGaspardPhysics.dylib
-		cd lib; ln -sf libGaspardTrackerModules.so libGaspardTrackerModules.dylib
-		cd lib; ln -sf libGaspardPhysicsNew.so libGaspardPhysicsNew.dylib
-endif
+
+## Paris ##
+ParisData:
+		make -C ./Paris
+
+## Shield ##
+ShieldData:
+		make -C ./Shield
 
 ## Plastic ##
 PlasticData:
 		make -C ./Plastic
-		cp ./Plastic/*.so ./lib ; cp ./Plastic/*.h ./include
-ifeq ($(ARCH),macosx)
-		cd lib; ln -sf libPlasticData.so libPlasticData.dylib
-		cd lib; ln -sf libPlasticPhysics.so libPlasticPhysics.dylib
-endif
 
 ## DUMMY Detector ##
 DummyDetectorData:
 		make -C ./DummyDetector
-		cp ./DummyDetector/*.so ./lib ; cp ./DummyDetector/*.h ./include
-ifeq ($(ARCH),macosx)
-		cd lib; ln -sf libDummyDetectorData.so libDummyDetectorData.dylib
-endif
-
-## Paris Detector ##
-ParisData:
-		make -C ./Paris
-		cp ./Paris/*.so ./lib ; cp ./Paris/*.h ./include
-ifeq ($(ARCH),macosx)
-		cd lib; ln -sf libParisData.so libParisData.dylib
-		cd lib; ln -sf libParisPhysics.so libParisPhysics.dylib
-endif
 
 
-## Paris Shield Detector ##
-ShieldData:
-		make -C ./Shield
-		cp ./Shield/*.so ./lib ; cp ./Shield/*.h ./include
-ifeq ($(ARCH),macosx)
-		cd lib; ln -sf libShieldData.so libShieldData.dylib
-		cd lib; ln -sf libShieldPhysics.so libShieldPhysics.dylib
-endif
-
 ############# Simulation ##############
-
 ## InitialConditions ##
 InitCond:
 		make -C ./InitialConditions
-		cp ./InitialConditions/*.so ./lib ; cp ./InitialConditions/*.h ./include
-ifeq ($(ARCH),macosx)
-		cd lib; ln -sf libInitialConditions.so libInititalConditions.dylib
-endif
 
 ## InteractionCoordinates ##
 InterCoord:	
 		make -C ./InteractionCoordinates
-		cp ./InteractionCoordinates/*.so ./lib ; cp ./InteractionCoordinates/*.h ./include
-ifeq ($(ARCH),macosx)
-		cd lib; ln -sf libInteractionCoordinates.so libInteractionCoordinates.dylib
-endif
 
 ############# I/O Root File ############
 InputOutputRoot:
 	make -C ./IORoot
-	cp ./IORoot/*.so ./lib ; cp ./IORoot/*.h ./include
-ifeq ($(ARCH),macosx)
-	cd lib; ln -sf libIORoot.so libIORoot.dylib
-endif
-
+	cp ./IORoot/*.h ./include
 
 
 ############# Various Tools ############
-
 ## Reaction ##
 Reaction:
 		make libReaction.so -C ./Tools
-		cp ./Tools/*.so ./lib ; cp ./Tools/*.h ./include
-ifeq ($(ARCH),macosx)
-		cd lib; ln -sf libReaction.so libReaction.dylib
-endif
 
 EnergyLoss:
 		make libEnergyLoss.so -C ./Tools
-		cp ./Tools/*.so ./lib ; cp ./Tools/*.h ./include
-ifeq ($(ARCH),macosx)
-		cd lib; ln -sf libEnergyLoss.so libEnergyLoss.dylib
-endif
 		
 #######################################
 
@@ -427,12 +371,11 @@ clean:
 	make clean -C ./SSSD
 	make clean -C ./AnnularS1
 	make clean -C ./GASPARD
+	make clean -C ./Paris
+	make clean -C ./Shield
 	make clean -C ./InteractionCoordinates
 	make clean -C ./InitialConditions
 	make clean -C ./DummyDetector
-	make clean -C ./Plastic
-	make clean -C ./Paris
-	make clean -C ./Shield
 	
 distclean:
 	rm -f ./lib/*.so
@@ -440,6 +383,7 @@ ifeq ($(ARCH),macosx)
 	rm -f ./lib/*.dylib
 endif
 	rm -f ./include/*.h 
+	rm -f liblist
 	make distclean -C ./Tools
 	make distclean -C ./IORoot
 	make distclean -C ./VDetector
@@ -448,12 +392,12 @@ endif
 	make distclean -C ./SSSD
 	make distclean -C ./AnnularS1
 	make distclean -C ./GASPARD
+	make distclean -C ./Paris
+	make distclean -C ./Shield
 	make distclean -C ./InteractionCoordinates
 	make distclean -C ./InitialConditions
 	make distclean -C ./DummyDetector
 	make distclean -C ./Plastic
-	make distclean -C ./Paris
-	make distclean -C ./Shield
 .SUFFIXES: .$(SrcSuf)
 
 ###
diff --git a/NPLib/README b/NPLib/README
index 1204aad4f..3e184ab1d 100644
--- a/NPLib/README
+++ b/NPLib/README
@@ -9,12 +9,13 @@
  * Original Author: N. de Sereville  contact address: deserevi@ipno.in2p3.fr *
  *                                                                           *
  * Creation Date  : 01/09/09                                                 *
- * Last update    : 17/09/10                                                 *
+ * Last update    : 16/11/10                                                 *
  *---------------------------------------------------------------------------*
  * Decription:                                                               *
  *      This file describes the content of the NPLib directory               *
  *---------------------------------------------------------------------------*
  * Comment:                                                                  *
+ *     16/11/10: added scripts directory description                         *
  *     01/09/10: added Shield of PARIS                                       *
  *     04/12/09: added PARIS array                                           *
  *****************************************************************************/
@@ -23,6 +24,7 @@ This directory contains a set of libraries which are used both in the
 NPSimulation and the NPAnalysis modules. The structure of this directory is:
 NPLib / include
       / lib
+      / scripts
       / IORoot
       / Tools
       / InitialConditions
@@ -46,16 +48,19 @@ II) lib directory
 	When compiling NPLib (see INSTALL file) all the shared libraries are 
 	copied to this directory
 
-III) IORoot
+III) scripts
+	This directory contains several scripts used in the global Makefile.
+
+IV) IORoot
 	This directory includes one library:
 		libIORoot.so
 	This library contains two singleton classes (RootOutput and RootInput) used
 	both in NPSimulation and NPAnalysis.
 	These classes are used to deal with the input and output ROOT files and trees.
 
-IV) Tools
+V) Tools
 
-V) InitialConditions
+VI) InitialConditions
 	This directory includes one library:
 		libInitialConditions.so
 	This library records all the information concerning the event generators, 
@@ -63,7 +68,7 @@ V) InitialConditions
 	This class derives from TObject (ROOT) and its aim is to be stored in the 
 	output TTree of the G4 simulation 
 
-VI) InteractionCoordinates
+VII) InteractionCoordinates
 	This directory includes one library:
 		libInteractionCoordinates.so
 	This library mainly records the coordinates of interaction between a particle 
@@ -71,19 +76,19 @@ VI) InteractionCoordinates
 	This class derives from TObject (ROOT) and its aim is to be stored in the 
 	output TTree of the G4 simulation.
 
-VII) CalibrationManager
+VIII) CalibrationManager
 	This directory includes one library:
 	libCalibrationManager.so
 		This folder contain the the class object for managing calibration file.
 	A caliration manager singleton is instantiate in NPAnalysis project.
 	 
-VIII) DummyDetector
+IX) DummyDetector
 	This directory includes one library:
 		libDUMMYDetector.so
 	This library stores the results of the G4 simulation for the example detector
 	DummyDetector.
 
-IX) MUST2
+X) MUST2
 	This directory includes two libraries:
 		libMust2Data.so
 		libMust2Physics.so
@@ -96,7 +101,7 @@ IX) MUST2
 		This library deals with the treatment applied to the ROOT output file 
 		obtained from NPSimulation. This library is *only* used by NPAnalysis.
 
-X) AnnularS1
+XI) AnnularS1
 	This directory includes one library:
 		libAnnularS1Data.so
 	This library stores the results of the G4 simulation for the S1 detector. 
@@ -106,7 +111,7 @@ X) AnnularS1
 	This class derives from TObject (ROOT) and its aim is to be stored in the 
 	output TTree of the G4 simulation.
 
-XI) GASPARD
+XII) GASPARD
 	This directory includes two libraries:
 		libGaspardData.so
 		libGaspardPhysics.so
@@ -119,7 +124,7 @@ XI) GASPARD
 		This library deals with the treatment applied to the ROOT output file 
 		obtained from NPSimulation. This library is *only* used by NPAnalysis.
 
-XII) Paris
+XIII) Paris
 	This directory includes tow library:
 		libParisData.so
 		libParisPhysics.so
@@ -130,7 +135,7 @@ XII) Paris
 		obtained from NPSimulation. This library is *only* used by NPAnalysis.
 
 
-XIII) Shield
+XIV) Shield
 	This directory includes two library:
 		libShieldData.so
 		libShieldPhysics.so
@@ -140,7 +145,7 @@ XIII) Shield
 		This library deals with the treatment applied to the ROOT output file 
 		obtained from NPSimulation. This library is *only* used by NPAnalysis.
 
-XIV) VDetector
+XV) VDetector
 	This directory includes two libraries:
 		libVDetector.so
 		libDetectorManager.so
diff --git a/NPLib/liblist b/NPLib/liblist
deleted file mode 100755
index 39ebc0c95..000000000
--- a/NPLib/liblist
+++ /dev/null
@@ -1,11 +0,0 @@
-echo  -L$NPLIB/lib -lVDetector -lDetectorManager -lCalibrationManager -lIORoot -lReaction -lEnergyLoss \
-			-lMust2Data -lMust2Physics \
-			-lSSSDData -lSSSDPhysics \
-			-lPlasticData -lPlasticPhysics \
-			-lAnnularS1Data \
-			-lGaspardData -lGaspardPhysics \
-			-lGaspardPhysicsNew -lGaspardTrackerModules \
-			-lDUMMYDetectorData \
-			-lParisData -lParisPhysics\
-			-lShieldData -lShieldPhysics\
-			-lInitialConditions -lInteractionCoordinates
diff --git a/NPLib/scripts/buildliblist.sh b/NPLib/scripts/buildliblist.sh
new file mode 100755
index 000000000..d952c8376
--- /dev/null
+++ b/NPLib/scripts/buildliblist.sh
@@ -0,0 +1,50 @@
+# *****************************************************************************
+# * 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: N. de Sereville  contact address: deserevi@ipno.in2p3.fr *
+# *                                                                           *
+# * Creation Date  : 16/11/10                                                 *
+# * Last update    :                                                          *
+# *---------------------------------------------------------------------------*
+# * Decription: This script builds the liblist file which is used when linking*
+# *             the NPS and NPA binary files.                                 * 
+# *---------------------------------------------------------------------------*
+# * Comment:                                                                  *
+# *                                                                           *
+# *                                                                           *
+# *****************************************************************************
+
+#! /bin/bash
+
+# output file
+outfile="liblist"
+
+# if output file exists delete it
+if [ -e $outfile ] ; then 
+   rm $outfile 
+fi ;
+
+# create output file
+echo "echo -L$NPLIB/lib \\" >> $outfile
+chmod a+x $outfile
+
+# loop on *.so files in lib/ directory
+for file in lib/*.so
+do
+   if [ -f $file ] ; then 
+      # remove .so extension
+      name=${file%\.*}
+      # replace "lib/lib" pattern by "-l"
+      name=$(echo $name | sed -e "s/lib\/lib/-l/g")
+      # add trailing \
+      name="$name \\"
+      # add tab at the beginning
+      name=$(echo -e "\t $name")
+      echo -e "\t $name" >> $outfile
+   fi ;
+done
diff --git a/NPLib/scripts/fillincdir.sh b/NPLib/scripts/fillincdir.sh
new file mode 100755
index 000000000..15d104e25
--- /dev/null
+++ b/NPLib/scripts/fillincdir.sh
@@ -0,0 +1,38 @@
+# *****************************************************************************
+# * 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: N. de Sereville  contact address: deserevi@ipno.in2p3.fr *
+# *                                                                           *
+# * Creation Date  : 16/11/10                                                 *
+# * Last update    :                                                          *
+# *---------------------------------------------------------------------------*
+# * Decription: This script moves all the header files (*.h) from all         *
+# *             directories to the lib/ directory.                            *
+# *---------------------------------------------------------------------------*
+# * Comment:                                                                  *
+# *                                                                           *
+# *                                                                           *
+# *****************************************************************************
+
+#! /bin/bash
+
+# previously, clean include directory
+cd include/
+rm -f *
+cd ../
+
+# loop recursively on header files in all directories
+for file in */*.h
+do
+   # copy header files to the include directory
+   cp -f $file include/
+done
+
+# remove include file with *Dict*
+cd include/
+rm -f *Dict*
diff --git a/NPLib/scripts/filllibdir.sh b/NPLib/scripts/filllibdir.sh
new file mode 100755
index 000000000..0d2c91851
--- /dev/null
+++ b/NPLib/scripts/filllibdir.sh
@@ -0,0 +1,34 @@
+# *****************************************************************************
+# * 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: N. de Sereville  contact address: deserevi@ipno.in2p3.fr *
+# *                                                                           *
+# * Creation Date  : 16/11/10                                                 *
+# * Last update    :                                                          *
+# *---------------------------------------------------------------------------*
+# * Decription: This script moves all the libraries (*.so) in all directories *
+# *             to the lib/ directory.                                        *
+# *---------------------------------------------------------------------------*
+# * Comment:                                                                  *
+# *                                                                           *
+# *                                                                           *
+# *****************************************************************************
+
+#! /bin/bash
+
+# previously, clean lib/ directory
+cd lib/
+rm -f *
+cd ../
+
+# loop recursively on header files in all directories
+for file in */*.so
+do
+   # copy header files to the include directory
+   cp -f $file lib/
+done
diff --git a/NPLib/scripts/filllibmacdir.sh b/NPLib/scripts/filllibmacdir.sh
new file mode 100755
index 000000000..cce146eca
--- /dev/null
+++ b/NPLib/scripts/filllibmacdir.sh
@@ -0,0 +1,36 @@
+# *****************************************************************************
+# * 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: N. de Sereville  contact address: deserevi@ipno.in2p3.fr *
+# *                                                                           *
+# * Creation Date  : 16/11/10                                                 *
+# * Last update    :                                                          *
+# *---------------------------------------------------------------------------*
+# * Decription: This script creates symbolic links from .so to .dylib in the  *
+# *             lib/ directory.                                               *
+# *                                                                           *
+# *---------------------------------------------------------------------------*
+# * Comment:                                                                  *
+# *                                                                           *
+# *                                                                           *
+# *****************************************************************************
+
+#! /bin/bash
+
+# move to lib directory
+cd lib
+
+# loop recursively on header files in all directories
+for file in *.so
+do
+   # build dylib file
+   name=${file%\.*}
+   name="$name.dylib"
+   # make symbolic link from .so to .dylib
+   ln -sf $file $name  
+done
diff --git a/NPSimulation/src/GaspardTrackerTrapezoid.cc b/NPSimulation/src/GaspardTrackerTrapezoid.cc
index b5fc412ce..447b24b8b 100644
--- a/NPSimulation/src/GaspardTrackerTrapezoid.cc
+++ b/NPSimulation/src/GaspardTrackerTrapezoid.cc
@@ -229,8 +229,10 @@ void GaspardTrackerTrapezoid::VolumeMaker(G4int TelescopeNumber   ,
    // Definition of the volume containing the sensitive detector
    G4Trap* solidGPDTrapezoid = new G4Trap(Name, 
                                           Length/2, 0*deg, 0*deg, 
-                                          Height/2, BaseSmall/2, BaseLarge/2, 0*deg, 
-                                          Height/2, BaseSmall/2, BaseLarge/2, 0*deg);
+                                          Height/2, BaseLarge/2, BaseSmall/2, 0*deg, 
+                                          Height/2, BaseLarge/2, BaseSmall/2, 0*deg);
+//                                          Height/2, BaseSmall/2, BaseLarge/2, 0*deg, 
+//                                          Height/2, BaseSmall/2, BaseLarge/2, 0*deg);
    G4LogicalVolume* logicGPDTrapezoid = new G4LogicalVolume(solidGPDTrapezoid, Vacuum, Name, 0, 0, 0);
 
    PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicGPDTrapezoid, Name, world, false, 0);
@@ -270,8 +272,10 @@ void GaspardTrackerTrapezoid::VolumeMaker(G4int TelescopeNumber   ,
 
       G4Trap* solidFirstStage = new G4Trap("solidFirstStage", 
                                            FirstStageThickness/2, 0*deg, 0*deg, 
-                                           FirstStageHeight/2, FirstStageBaseSmall/2, FirstStageBaseLarge/2, 0*deg, 
-                                           FirstStageHeight/2, FirstStageBaseSmall/2, FirstStageBaseLarge/2, 0*deg);
+                                           FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, 
+                                           FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg);
+//                                           FirstStageHeight/2, FirstStageBaseSmall/2, FirstStageBaseLarge/2, 0*deg, 
+//                                           FirstStageHeight/2, FirstStageBaseSmall/2, FirstStageBaseLarge/2, 0*deg);
       G4LogicalVolume* logicFirstStage = new G4LogicalVolume(solidFirstStage, Silicon, "logicFirstStage", 0, 0, 0);
 
       PVPBuffer = new G4PVPlacement(0,
@@ -299,8 +303,10 @@ void GaspardTrackerTrapezoid::VolumeMaker(G4int TelescopeNumber   ,
 
       G4Trap* solidSecondStage = new G4Trap("solidSecondStage", 
                                             SecondStageThickness/2, 0*deg, 0*deg, 
-                                            SecondStageHeight/2, SecondStageBaseSmall/2, SecondStageBaseLarge/2, 0*deg, 
-                                            SecondStageHeight/2, SecondStageBaseSmall/2, SecondStageBaseLarge/2, 0*deg);
+                                           FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, 
+                                           FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg);
+//                                           FirstStageHeight/2, FirstStageBaseSmall/2, FirstStageBaseLarge/2, 0*deg, 
+//                                           FirstStageHeight/2, FirstStageBaseSmall/2, FirstStageBaseLarge/2, 0*deg);
       G4LogicalVolume* logicSecondStage = new G4LogicalVolume(solidSecondStage, Silicon, "logicSecondStage", 0, 0, 0);
 
       PVPBuffer = new G4PVPlacement(0,
@@ -328,8 +334,10 @@ void GaspardTrackerTrapezoid::VolumeMaker(G4int TelescopeNumber   ,
 
       G4Trap* solidThirdStage = new G4Trap("solidThirdStage", 
                                            ThirdStageThickness/2, 0*deg, 0*deg, 
-                                           ThirdStageHeight/2, ThirdStageBaseSmall/2, ThirdStageBaseLarge/2, 0*deg, 
-                                           ThirdStageHeight/2, ThirdStageBaseSmall/2, ThirdStageBaseLarge/2, 0*deg);
+                                           FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, 
+                                           FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg);
+//                                           FirstStageHeight/2, FirstStageBaseSmall/2, FirstStageBaseLarge/2, 0*deg, 
+//                                           FirstStageHeight/2, FirstStageBaseSmall/2, FirstStageBaseLarge/2, 0*deg);
       G4LogicalVolume* logicThirdStage = new G4LogicalVolume(solidThirdStage, Silicon, "logicThirdStage", 0, 0, 0);
 
       PVPBuffer = new G4PVPlacement(0,
@@ -610,14 +618,18 @@ void GaspardTrackerTrapezoid::ConstructDetector(G4LogicalVolume* world)
          // (u,v) // to silicon plan
          // w perpendicular to (u,v) plan and pointing ThirdStage
          // new positioning scheme ?
+         G4cout << "XXXXXXXXXXXX Trapezoid " << i << " XXXXXXXXXXXXX" << G4endl;
          MMu = m_X128_Y1[i] - m_X1_Y1[i];
          MMu = MMu.unit();
+         G4cout << "MMu: " << MMu << G4endl;
 
          MMv = 0.5 * (m_X1_Y128[i] + m_X128_Y128[i] - m_X1_Y1[i] - m_X128_Y1[i]);
          MMv = MMv.unit();
+         G4cout << "MMv: " << MMv << G4endl;
 
          MMw = MMu.cross(MMv);
          MMw = MMw.unit();
+         G4cout << "MMw: " << MMw << G4endl;
 
          // Center of the module
          MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4;
@@ -632,10 +644,6 @@ void GaspardTrackerTrapezoid::ConstructDetector(G4LogicalVolume* world)
       else {
          G4double Theta = m_Theta[i];
          G4double Phi   = m_Phi[i];
-         //This part because if Phi and Theta = 0 equation are false
-         if (Theta == 0)        Theta = 0.0001;
-         if (Theta == 2*cos(0)) Theta = 2 * acos(0) - 0.00001;
-         if (Phi   == 0)        Phi   = 0.0001;
 
          // (u,v,w) unitary vector associated to telescope referencial
          // (u,v) // to silicon plan
@@ -662,9 +670,10 @@ void GaspardTrackerTrapezoid::ConstructDetector(G4LogicalVolume* world)
          MMv = MMv.unit();
          MMu = MMu.unit();
 
-         MMw = G4ThreeVector(wX, wY, wZ);
-         MMCenter = MMw;
-         MMw = MMw.unit();
+         G4cout << "XXXXXXXXXXXX Trapezoid " << i << " XXXXXXXXXXXXX" << G4endl;
+         G4cout << "MMu: " << MMu << G4endl;
+         G4cout << "MMv: " << MMv << G4endl;
+         G4cout << "MMw: " << MMw << G4endl;
 
          // Passage Matrix from Lab Referential to Telescope Referential
          MMrot = new G4RotationMatrix(MMu, MMv, MMw);
-- 
GitLab