From 526ffd13af42860e035e619182ebed71a6df1869 Mon Sep 17 00:00:00 2001
From: deserevi <deserevi@nptool>
Date: Thu, 21 Oct 2010 18:05:15 +0000
Subject: [PATCH] * New positioning scheme for GaspardTrackerTrapezoid in NPS  
     ---------------        ^       \             /        | v   u = (128,1) -
 (1,1)        \           /         |     v = (1,128) - (1,1)         \       
  /    <------          \       /        u        and w = u x v in direction  
         -------                  of third stage

* gaspHyde geometry is now well-defined

* Stripping scheme in NPS and NPA still to be done
---
 .../DetectorConfiguration/gaspHyde.detector   | 176 +++++++++---------
 .../include/GaspardTrackerTrapezoid.hh        |   7 -
 NPSimulation/src/GaspardTrackerTrapezoid.cc   | 133 ++++++-------
 3 files changed, 145 insertions(+), 171 deletions(-)

diff --git a/Inputs/DetectorConfiguration/gaspHyde.detector b/Inputs/DetectorConfiguration/gaspHyde.detector
index a6692ec3c..744325b09 100644
--- a/Inputs/DetectorConfiguration/gaspHyde.detector
+++ b/Inputs/DetectorConfiguration/gaspHyde.detector
@@ -28,6 +28,16 @@ Target
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%	
 GaspardTracker
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2
+GPDTrapezoid
+	THETA= 0 
+	PHI= 0
+	R= 200
+	BETA= 0 0 0
+        FIRSTSTAGE= 1
+        SECONDSTAGE= 1
+        THIRDSTAGE= 1
+        VIS= all
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2
 %GPDDummyShape
 	THETA= 180 
 	PHI= 0
@@ -78,7 +88,7 @@ GaspardTracker
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%1 Annular Back
-%GPDAnnular
+GPDAnnular
         Z=      -156.5
         RMIN=   16
         RMAX=	52
@@ -87,7 +97,7 @@ GaspardTracker
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%1 Annular Front
-%GPDAnnular
+GPDAnnular
         Z=      156.5
         RMIN=	16
         RMAX=	52
@@ -96,83 +106,83 @@ GaspardTracker
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%1 End-Cap Back
-%GPDTrapezoid
-        X1_Y1=          55.338   14.346  -146.501
-        X128_Y1=       138.518   48.726   -69.237
+GPDTrapezoid
+        X1_Y1=          55.338  -14.346  -146.501
+        X128_Y1=        55.338   14.346  -146.501
         X1_Y128=       138.519  -48.717   -69.236
-        X128_Y128=      55.338  -14.346  -146.501
+        X128_Y128=     138.518   48.726   -69.237
         FIRSTSTAGE= 1
-        SECONDSTAGE= 0
+        SECONDSTAGE= 1
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2
-%GPDTrapezoid
-        X1_Y1=          28.986    49.274  -146.501
-        X128_Y1=        63.492   132.401   -69.237
+GPDTrapezoid
+        X1_Y1=          49.215    29.045  -146.501
+        X128_Y1=        28.986    49.274  -146.501
         X1_Y128=       132.395    63.500   -69.236
-        X128_Y128=      49.215    29.045  -146.501
+        X128_Y128=      63.492   132.401   -69.237
         FIRSTSTAGE= 1
-        SECONDSTAGE= 0
+        SECONDSTAGE= 1
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%3
-%GPDTrapezoid
-        X1_Y1=         -14.346   55.338  -146.501
-        X128_Y1=       -48.726  138.518   -69.237
+GPDTrapezoid
+        X1_Y1=          14.263   55.338  -146.501
+        X128_Y1=       -14.346   55.338  -146.501
         X1_Y128=        48.717  138.519   -69.236
-        X128_Y128=      14.263   55.338  -146.501
+        X128_Y128=     -48.726  138.518   -69.237
         FIRSTSTAGE= 1
-        SECONDSTAGE= 0
+        SECONDSTAGE= 1
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%4
-%GPDTrapezoid
-        X1_Y1=         -49.274   28.986  -146.501
-        X128_Y1=      -132.401   63.492   -69.237
+GPDTrapezoid
+        X1_Y1=         -29.045   49.215  -146.501
+        X128_Y1=       -49.274   28.986  -146.501
         X1_Y128=       -63.500  132.395   -69.236
-        X128_Y128=     -29.045   49.215  -146.501
+        X128_Y128=    -132.401   63.492   -69.237
         FIRSTSTAGE= 1
-        SECONDSTAGE= 0
+        SECONDSTAGE= 1
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
-%GPDTrapezoid
-        X1_Y1=          -55.338  -14.346   -146.501
-        X128_Y1=       -138.518  -48.726    -69.237
+GPDTrapezoid
+        X1_Y1=          -55.338   14.346   -146.501
+        X128_Y1=        -55.338  -14.346   -146.501
         X1_Y128=       -138.519   48.717    -69.236
-        X128_Y128=      -55.338   14.346   -146.501
+        X128_Y128=     -138.518  -48.726    -69.237
         FIRSTSTAGE= 1
-        SECONDSTAGE= 0
+        SECONDSTAGE= 1
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%6
-%GPDTrapezoid
-        X1_Y1=          -28.986    -49.274   -146.501
-        X128_Y1=        -63.492   -132.401    -69.237
+GPDTrapezoid
+        X1_Y1=          -49.215    -29.045   -146.501
+        X128_Y1=        -28.986    -49.274   -146.501
         X1_Y128=       -132.395    -63.500    -69.236
-        X128_Y128=      -49.215    -29.045   -146.501
+        X128_Y128=      -63.492   -132.401    -69.237
         FIRSTSTAGE= 1
-        SECONDSTAGE= 0
+        SECONDSTAGE= 1
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%7
-%GPDTrapezoid
-        X1_Y1=          14.346   -55.338   -146.501
-        X128_Y1=        48.726  -138.518    -69.237
+GPDTrapezoid
+        X1_Y1=         -14.263   -55.338   -146.501
+        X128_Y1=        14.346   -55.338   -146.501
         X1_Y128=       -48.717  -138.519    -69.236
-        X128_Y128=     -14.263   -55.338   -146.501
+        X128_Y128=      48.726  -138.518    -69.237
         FIRSTSTAGE= 1
-        SECONDSTAGE= 0
+        SECONDSTAGE= 1
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%8
-%GPDTrapezoid
-        X1_Y1=          49.274   -28.986   -146.501
-        X128_Y1=       132.401   -63.492    -69.237
+GPDTrapezoid
+        X1_Y1=          29.045   -49.215   -146.501
+        X128_Y1=        49.274   -28.986   -146.501
         X1_Y128=        63.500  -132.395    -69.236
-        X128_Y128=      29.045   -49.215   -146.501
+        X128_Y128=     132.401   -63.492    -69.237
         FIRSTSTAGE= 1
-        SECONDSTAGE= 0
+        SECONDSTAGE= 1
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%1 Barrel
@@ -336,82 +346,82 @@ GPDSquare
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%1 Front-Cap Back
-%GPDTrapezoid
-        X1_Y1=      55.338  -14.346  146.501
-        X128_Y1=       138.518   48.726   69.237
-        X1_Y128=       138.519  -48.717   69.236
-        X128_Y128=          55.338   14.346  146.501
+GPDTrapezoid
+        X1_Y1=          55.338   14.346  146.501
+        X128_Y1=        55.338  -14.346  146.501
+        X1_Y128=       138.518   48.726   69.237
+        X128_Y128=     138.519  -48.717   69.236
         FIRSTSTAGE= 1
-        SECONDSTAGE= 0
+        SECONDSTAGE= 1
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2
-%GPDTrapezoid
+GPDTrapezoid
         X1_Y1=          28.986    49.274  146.501
-        X128_Y1=        63.492   132.401   69.237
-        X1_Y128=       132.395    63.500   69.236
-        X128_Y128=      49.215    29.045  146.501
+        X128_Y1=        49.215    29.045  146.501
+        X1_Y128=        63.492   132.401   69.237
+        X128_Y128=     132.395    63.500   69.236
         FIRSTSTAGE= 1
-        SECONDSTAGE= 0
+        SECONDSTAGE= 1
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%3
-%GPDTrapezoid
+GPDTrapezoid
         X1_Y1=         -14.346   55.338  146.501
-        X128_Y1=       -48.726  138.518   69.237
-        X1_Y128=        48.717  138.519   69.236
-        X128_Y128=      14.263   55.338  146.501
+        X128_Y1=        14.263   55.338  146.501
+        X1_Y128=       -48.726  138.518   69.237
+        X128_Y128=      48.717  138.519   69.236
         FIRSTSTAGE= 1
-        SECONDSTAGE= 0
+        SECONDSTAGE= 1
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%4
-%GPDTrapezoid
+GPDTrapezoid
         X1_Y1=         -49.274   28.986  146.501
-        X128_Y1=      -132.401   63.492   69.237
-        X1_Y128=       -63.500  132.395   69.236
-        X128_Y128=     -29.045   49.215  146.501
+        X128_Y1=       -29.045   49.215  146.501
+        X1_Y128=      -132.401   63.492   69.237
+        X128_Y128=     -63.500  132.395   69.236
         FIRSTSTAGE= 1
-        SECONDSTAGE= 0
+        SECONDSTAGE= 1
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
-%GPDTrapezoid
+GPDTrapezoid
         X1_Y1=          -55.338  -14.346   146.501
-        X128_Y1=       -138.518  -48.726    69.237
-        X1_Y128=       -138.519   48.717    69.236
-        X128_Y128=      -55.338   14.346   146.501
+        X128_Y1=        -55.338   14.346   146.501
+        X1_Y128=       -138.518  -48.726    69.237
+        X128_Y128=     -138.519   48.717    69.236
         FIRSTSTAGE= 1
-        SECONDSTAGE= 0
+        SECONDSTAGE= 1
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%6
-%GPDTrapezoid
+GPDTrapezoid
         X1_Y1=          -28.986    -49.274   146.501
-        X128_Y1=        -63.492   -132.401    69.237
-        X1_Y128=       -132.395    -63.500    69.236
-        X128_Y128=      -49.215    -29.045   146.501
+        X128_Y1=        -49.215    -29.045   146.501
+        X1_Y128=        -63.492   -132.401    69.237
+        X128_Y128=     -132.395    -63.500    69.236
         FIRSTSTAGE= 1
-        SECONDSTAGE= 0
+        SECONDSTAGE= 1
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%7
-%GPDTrapezoid
+GPDTrapezoid
         X1_Y1=          14.346   -55.338   146.501
-        X128_Y1=        48.726  -138.518    69.237
-        X1_Y128=       -48.717  -138.519    69.236
-        X128_Y128=     -14.263   -55.338   146.501
+        X128_Y1=       -14.263   -55.338   146.501
+        X1_Y128=        48.726  -138.518    69.237
+        X128_Y128=     -48.717  -138.519    69.236
         FIRSTSTAGE= 1
-        SECONDSTAGE= 0
+        SECONDSTAGE= 1
         THIRDSTAGE= 1
         VIS= all
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%8
-%GPDTrapezoid
+GPDTrapezoid
         X1_Y1=          49.274   -28.986   146.501
-        X128_Y1=       132.401   -63.492    69.237
-        X1_Y128=        63.500  -132.395    69.236
-        X128_Y128=      29.045   -49.215   146.501
+        X128_Y1=        29.045   -49.215   146.501
+        X1_Y128=       132.401   -63.492    69.237
+        X128_Y128=      63.500  -132.395    69.236
         FIRSTSTAGE= 1
-        SECONDSTAGE= 0
+        SECONDSTAGE= 1
         THIRDSTAGE= 1
         VIS= all
diff --git a/NPSimulation/include/GaspardTrackerTrapezoid.hh b/NPSimulation/include/GaspardTrackerTrapezoid.hh
index 95829084e..ec2c74028 100644
--- a/NPSimulation/include/GaspardTrackerTrapezoid.hh
+++ b/NPSimulation/include/GaspardTrackerTrapezoid.hh
@@ -132,13 +132,6 @@ private:
    vector<G4double>  m_beta_u ; //  |
    vector<G4double>  m_beta_v ; //  > Tilt angle of the Telescope
    vector<G4double>  m_beta_w ; //  |
-
-   // for debugging purpose
-   G4ThreeVector	MMpos;
-   G4ThreeVector	MMu;
-   G4ThreeVector	MMv;
-   G4ThreeVector	MMw;
-   G4ThreeVector	CT;
 };
 
 
diff --git a/NPSimulation/src/GaspardTrackerTrapezoid.cc b/NPSimulation/src/GaspardTrackerTrapezoid.cc
index a82558cc5..b5fc412ce 100644
--- a/NPSimulation/src/GaspardTrackerTrapezoid.cc
+++ b/NPSimulation/src/GaspardTrackerTrapezoid.cc
@@ -590,16 +590,13 @@ void GaspardTrackerTrapezoid::ReadConfiguration(string Path)
 // Called After DetecorConstruction::AddDetector Method
 void GaspardTrackerTrapezoid::ConstructDetector(G4LogicalVolume* world)
 {
-   G4RotationMatrix* MMrot    = NULL                   ;
-/*   G4ThreeVector     MMpos    = G4ThreeVector(0, 0, 0) ;
-   G4ThreeVector     MMu      = G4ThreeVector(0, 0, 0) ;
-   G4ThreeVector     MMv      = G4ThreeVector(0, 0, 0) ;
-   G4ThreeVector     MMw      = G4ThreeVector(0, 0, 0) ;*/
-   MMpos    = G4ThreeVector(0, 0, 0) ;
-   MMu      = G4ThreeVector(0, 0, 0) ;
-   MMv      = G4ThreeVector(0, 0, 0) ;
-   MMw      = G4ThreeVector(0, 0, 0) ;
-   G4ThreeVector     MMCenter = G4ThreeVector(0, 0, 0) ;
+   G4RotationMatrix* MMrot    = NULL;
+   G4ThreeVector     MMpos    = G4ThreeVector(0, 0, 0);
+   G4ThreeVector     MMu      = G4ThreeVector(0, 0, 0);
+   G4ThreeVector     MMv      = G4ThreeVector(0, 0, 0);
+   G4ThreeVector     MMw      = G4ThreeVector(0, 0, 0);
+   G4ThreeVector     MMCenter = G4ThreeVector(0, 0, 0);
+
    bool FirstStage  = true ;
    bool SecondStage = true ;
    bool ThirdStage  = true ;
@@ -613,106 +610,80 @@ void GaspardTrackerTrapezoid::ConstructDetector(G4LogicalVolume* world)
          // (u,v) // to silicon plan
          // w perpendicular to (u,v) plan and pointing ThirdStage
          // new positioning scheme ?
-         G4cout << "############ Gaspard Trapezoid " << i << " #############" << G4endl;
-         MMu = m_X128_Y1[i] - m_X1_Y1[i] ;
-         MMu *= -1;
-         G4cout << "MMu: " << MMu << G4endl;
-         MMu = MMu.unit()                ;
-         G4cout << "Norm MMu: " << MMu << G4endl;
-
-         MMv = -0.5 * (m_X1_Y128[i] + m_X128_Y128[i] - m_X1_Y1[i] - m_X1_Y128[i]);
-         G4cout << "MMv: " << MMv << G4endl;
-         MMv = MMv.unit()                ;
-         G4cout << "Norm MMv: " << MMv << G4endl;
-
-         G4ThreeVector MMscal = MMu.dot(MMv);
-         G4cout << "Norm MMu.MMv: " << MMscal << G4endl;
-
-//         MMw = MMu.cross(MMv)                  ;
-         MMw = MMv.cross(MMu)                  ;
-//         if (MMw.z() > 0) MMw = MMv.cross(MMu) ;
-         MMw = MMw.unit()                      ;
-         G4cout << "Norm MMw: " << MMw << G4endl;
-
-         // old positioning scheme
-/*         G4cout << "############ Gaspard Trapezoid " << i << " #############" << G4endl;
-         MMu = m_X128_Y1[i] - m_X1_Y128[i] ;
-         G4cout << "MMu: " << MMu << G4endl;
-         MMu = MMu.unit()                ;
-         G4cout << "Norm MMu: " << MMu << G4endl;
-
-         MMv = -0.5 * (m_X1_Y1[i] + m_X128_Y128[i] - m_X1_Y128[i] - m_X128_Y1[i]);
-         G4cout << "MMv: " << MMv << G4endl;
-         MMv = MMv.unit()                ;
-         G4cout << "Norm MMv: " << MMv << G4endl;
-
-         G4ThreeVector MMscal = MMu.dot(MMv);
-         G4cout << "Norm MMu.MMv: " << MMscal << G4endl;
-
-         MMw = MMu.cross(MMv)                  ;
-//         MMw = MMv.cross(MMu)                  ;
-//         if (MMw.z() > 0) MMw = MMv.cross(MMu) ;
-         MMw = MMw.unit()                      ;
-         G4cout << "Norm MMw: " << MMw << G4endl;
-*/
+         MMu = m_X128_Y1[i] - m_X1_Y1[i];
+         MMu = MMu.unit();
+
+         MMv = 0.5 * (m_X1_Y128[i] + m_X128_Y128[i] - m_X1_Y1[i] - m_X128_Y1[i]);
+         MMv = MMv.unit();
+
+         MMw = MMu.cross(MMv);
+         MMw = MMw.unit();
+
          // Center of the module
-         MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4 ;
+         MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4;
 
          // Passage Matrix from Lab Referential to Module Referential
-         MMrot = new G4RotationMatrix(MMu, MMv, MMw) ;
+         MMrot = new G4RotationMatrix(MMu, MMv, MMw);
          // translation to place Module
-         MMpos = MMw * Length * 0.5 + MMCenter ;
+         MMpos = MMw * Length * 0.5 + MMCenter;
       }
 
       // By Angle
       else {
-         G4double Theta = m_Theta[i] ;
-         G4double Phi   = m_Phi[i]   ;
+         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 ;
+         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
          // w perpendicular to (u,v) plan and pointing ThirdStage
          // Phi is angle between X axis and projection in (X,Y) plan
          // Theta is angle between  position vector and z axis
-         G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad)   ;
-         G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad)   ;
-         G4double wZ = m_R[i] * cos(Theta / rad)             ;
-
-         MMw = G4ThreeVector(wX, wY, wZ)                ;
-//         G4ThreeVector CT = MMw                       ;
-         CT = MMw                       ;
-         MMw = MMw.unit()                          ;
-
-         G4ThreeVector Y = G4ThreeVector(0 , 1 , 0)         ;
-
-         MMu = MMw.cross(Y)      ;
-         MMv = MMw.cross(MMu) ;
-
+         G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad);
+         G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad);
+         G4double wZ = m_R[i] * cos(Theta / rad);
+         MMw = G4ThreeVector(wX, wY, wZ);
+
+         // vector corresponding to the center of the module
+         MMCenter = MMw;
+
+         // vector parallel to one axis of silicon plane
+         G4double ii = cos(Theta / rad) * cos(Phi / rad);
+         G4double jj = cos(Theta / rad) * sin(Phi / rad);
+         G4double kk = -sin(Theta / rad);
+         G4ThreeVector Y = G4ThreeVector(ii, jj, kk);
+
+         MMw = MMw.unit();
+         MMu = MMw.cross(Y);
+         MMv = MMw.cross(MMu);
          MMv = MMv.unit();
          MMu = MMu.unit();
+
+         MMw = G4ThreeVector(wX, wY, wZ);
+         MMCenter = MMw;
+         MMw = MMw.unit();
+
          // Passage Matrix from Lab Referential to Telescope Referential
-         // MUST2
          MMrot = new G4RotationMatrix(MMu, MMv, MMw);
          // Telescope is rotate of Beta angle around MMv axis.
          MMrot->rotate(m_beta_u[i], MMu);
          MMrot->rotate(m_beta_v[i], MMv);
          MMrot->rotate(m_beta_w[i], MMw);
          // translation to place Telescope
-         MMpos = MMw * Length * 0.5 + CT ;
+         MMpos = MMw * Length * 0.5 + MMCenter;
       }
 
-      FirstStage  = m_wFirstStage[i]  ;
-      SecondStage = m_wSecondStage[i] ;
-      ThirdStage  = m_wThirdStage[i]  ;
+      FirstStage  = m_wFirstStage[i];
+      SecondStage = m_wSecondStage[i];
+      ThirdStage  = m_wThirdStage[i];
 
-      VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage , world);
+      VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, world);
    }
 
-   delete MMrot ;
+   delete MMrot;
 }
 
 
-- 
GitLab