Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/extended/geometry/transforms/src/DetectorConstruction.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/geometry/transforms/src/DetectorConstruction.cc (Version 11.3.0) and /examples/extended/geometry/transforms/src/DetectorConstruction.cc (Version 10.3.p3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
                                                   >>  26 // $Id: DetectorConstruction.cc 68726 2013-04-05 09:35:20Z gcosmo $
 26 //                                                 27 //
 27 /// \file DetectorConstruction.cc                  28 /// \file DetectorConstruction.cc
 28 /// \brief Implementation of the DetectorConst     29 /// \brief Implementation of the DetectorConstruction class
 29                                                    30 
 30 #include "DetectorConstruction.hh"                 31 #include "DetectorConstruction.hh"
 31                                                << 
 32 #include "DetectorMessenger.hh"                    32 #include "DetectorMessenger.hh"
 33                                                    33 
 34 #include "G4GeometryManager.hh"                << 
 35 #include "G4LogicalVolume.hh"                  << 
 36 #include "G4LogicalVolumeStore.hh"             << 
 37 #include "G4Material.hh"                           34 #include "G4Material.hh"
 38 #include "G4NistManager.hh"                        35 #include "G4NistManager.hh"
                                                   >>  36 #include "G4Tubs.hh"
                                                   >>  37 #include "G4Trd.hh"
                                                   >>  38 #include "G4LogicalVolume.hh"
 39 #include "G4PVPlacement.hh"                        39 #include "G4PVPlacement.hh"
 40 #include "G4PhysicalConstants.hh"              <<  40 #include "G4Transform3D.hh"
 41 #include "G4PhysicalVolumeStore.hh"            << 
 42 #include "G4ReflectionFactory.hh"              << 
 43 #include "G4RotationMatrix.hh"                     41 #include "G4RotationMatrix.hh"
                                                   >>  42 #include "G4ReflectionFactory.hh"
                                                   >>  43 
                                                   >>  44 #include "G4GeometryManager.hh"
                                                   >>  45 #include "G4PhysicalVolumeStore.hh"
                                                   >>  46 #include "G4LogicalVolumeStore.hh"
 44 #include "G4SolidStore.hh"                         47 #include "G4SolidStore.hh"
                                                   >>  48 #include "G4PhysicalConstants.hh"
 45 #include "G4SystemOfUnits.hh"                      49 #include "G4SystemOfUnits.hh"
 46 #include "G4Transform3D.hh"                    << 
 47 #include "G4Trd.hh"                            << 
 48 #include "G4Tubs.hh"                           << 
 49                                                    50 
 50 //....oooOO0OOooo........oooOO0OOooo........oo     51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 51                                                    52 
 52 DetectorConstruction::DetectorConstruction()       53 DetectorConstruction::DetectorConstruction()
                                                   >>  54  : G4VUserDetectorConstruction(),
                                                   >>  55    fMessenger(0),
                                                   >>  56    fMethod(kWithDirectMatrix),
                                                   >>  57    fWorldVolume(0),
                                                   >>  58    fTrdVolume(0)
                                                   >>  59    
 53 {                                                  60 {
 54   fMessenger = new DetectorMessenger(this);        61   fMessenger = new DetectorMessenger(this);
 55 }                                                  62 }
 56                                                    63 
 57 //....oooOO0OOooo........oooOO0OOooo........oo     64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 58                                                    65 
 59 DetectorConstruction::~DetectorConstruction()      66 DetectorConstruction::~DetectorConstruction()
 60 {                                              <<  67 { 
 61   delete fMessenger;                               68   delete fMessenger;
 62 }                                                  69 }
 63                                                    70 
 64 //....oooOO0OOooo........oooOO0OOooo........oo     71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 65                                                    72 
 66 G4VPhysicalVolume* DetectorConstruction::Const     73 G4VPhysicalVolume* DetectorConstruction::Construct()
 67 {                                                  74 {
 68   // Materials                                     75   // Materials
 69   G4NistManager* nist = G4NistManager::Instanc     76   G4NistManager* nist = G4NistManager::Instance();
 70   G4Material* material = nist->FindOrBuildMate     77   G4Material* material = nist->FindOrBuildMaterial("G4_AIR");
 71                                                <<  78   
 72   // Clean old geometry, if any                    79   // Clean old geometry, if any
 73   //                                               80   //
 74   G4GeometryManager::GetInstance()->OpenGeomet     81   G4GeometryManager::GetInstance()->OpenGeometry();
 75   G4PhysicalVolumeStore::GetInstance()->Clean(     82   G4PhysicalVolumeStore::GetInstance()->Clean();
 76   G4LogicalVolumeStore::GetInstance()->Clean()     83   G4LogicalVolumeStore::GetInstance()->Clean();
 77   G4SolidStore::GetInstance()->Clean();            84   G4SolidStore::GetInstance()->Clean();
 78   G4ReflectionFactory::Instance()->Clean();    <<  85         
 79                                                << 
 80   // World                                         86   // World
 81   //                                           <<  87   //  
 82   G4double rmin = 0.;                              88   G4double rmin = 0.;
 83   G4double rmax = 5 * cm;                      <<  89   G4double rmax = 5*cm;
 84   G4double hz = 5 * cm;                        <<  90   G4double hz   = 5*cm;
 85   G4double phiMin = 0.;                            91   G4double phiMin = 0.;
 86   G4double deltaPhi = 360 * degree;            <<  92   G4double deltaPhi = 360*degree;
 87                                                <<  93         
 88   auto solidWorld = new G4Tubs("World",  // na <<  94   G4Tubs* solidWorld 
 89                                rmin, rmax, hz, <<  95     = new G4Tubs("World",                            //name
 90                                                <<  96                   rmin, rmax, hz, phiMin, deltaPhi); //size
 91   fWorldVolume = new G4LogicalVolume(solidWorl <<  97 
 92                                      material, <<  98   fWorldVolume 
 93                                      "World"); <<  99     = new G4LogicalVolume(solidWorld,                //solid
 94                                                << 100                           material,                  //material
 95   G4VPhysicalVolume* physiWorld = new G4PVPlac << 101                           "World");                  //name
 96                                                << 102 
 97                                                << 103   G4VPhysicalVolume* physiWorld
 98                                                << 104     = new G4PVPlacement(0,                     //no rotation
 99                                                << 105                         G4ThreeVector(),       //at (0,0,0)
100                                                << 106                         fWorldVolume,          //logical volume
101                                                << 107                         "World",               //name
102                                                << 108                         0,                     //mother volume
103   // Trd volume                                << 109                         false,                 //no boolean operation
104   //                                           << 110                         0);                    //copy number
105   G4double dX1 = 1 * cm;                       << 111 
106   G4double dX2 = 1 * cm;                       << 112   // Trd volume 
107   G4double dY1 = 1 * cm;                       << 113   //  
108   G4double dY2 = 2 * cm;                       << 114   G4double dX1 = 1*cm;
109   G4double dZ = 3 * cm;                        << 115   G4double dX2 = 1*cm;
110                                                << 116   G4double dY1 = 1*cm; 
111   auto solidTrd = new G4Trd("trd",  // name    << 117   G4double dY2 = 2*cm;
112                             dX1 / 2, dX2 / 2,  << 118   G4double dZ  = 3*cm; 
113                                                << 119 
114   fTrdVolume = new G4LogicalVolume(solidTrd,   << 120   G4Trd* solidTrd 
115                                    material,   << 121     = new G4Trd("trd",                               //name
116                                    "trd");  // << 122                  dX1/2, dX2/2, dY1/2, dY2/2, dZ/2);  //size
                                                   >> 123 
                                                   >> 124   fTrdVolume
                                                   >> 125     = new G4LogicalVolume(solidTrd,                  //solid
                                                   >> 126                           material,                  //material
                                                   >> 127                           "trd");                    //name
                                                   >> 128                                 
117                                                   129 
118   // Place Volume1 and Volume2 according to se    130   // Place Volume1 and Volume2 according to selected methods
119   //                                           << 131   // 
120   switch (fMethod) {                           << 132   switch ( fMethod ) {
121     case kWithDirectMatrix:                    << 133     case kWithDirectMatrix:   PlaceWithDirectMatrix(); break;
122       PlaceWithDirectMatrix();                 << 134     case kWithInverseMatrix:  PlaceWithInverseMatrix(); break;
123       break;                                   << 135     case kWithAxialRotations: PlaceWithAxialRotations(); break;
124     case kWithInverseMatrix:                   << 136     case kWithEulerAngles:    PlaceWithEulerAngles(); break;
125       PlaceWithInverseMatrix();                << 137     case kWithReflections:    PlaceWithReflections(); break;
126       break;                                   << 138     default: ;;
127     case kWithAxialRotations:                  << 
128       PlaceWithAxialRotations();               << 
129       break;                                   << 
130     case kWithEulerAngles:                     << 
131       PlaceWithEulerAngles();                  << 
132       break;                                   << 
133     case kWithReflections:                     << 
134       PlaceWithReflections();                  << 
135       break;                                   << 
136     default:;                                  << 
137       ;                                        << 
138   }                                               139   }
139                                                   140 
140   // Return the root volume                       141   // Return the root volume
141   //                                              142   //
142   return physiWorld;                              143   return physiWorld;
143 }                                                 144 }
144                                                   145 
145 //....oooOO0OOooo........oooOO0OOooo........oo    146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
146                                                   147 
147 void DetectorConstruction::PlaceWithDirectMatr    148 void DetectorConstruction::PlaceWithDirectMatrix()
148 {                                                 149 {
149   G4double og = 3 * cm;                        << 150   G4double og = 3*cm; 
150                                                   151 
151   // 1st position                              << 152   // 1st position 
152   //                                              153   //
153   G4double phi = 30 * deg;                     << 154   G4double phi = 30*deg;
154   // u, v, w are the daughter axes, projected     155   // u, v, w are the daughter axes, projected on the mother frame
155   G4ThreeVector u = G4ThreeVector(0, 0, -1);      156   G4ThreeVector u = G4ThreeVector(0, 0, -1);
156   G4ThreeVector v = G4ThreeVector(-std::sin(ph << 157   G4ThreeVector v = G4ThreeVector(-std::sin(phi), std::cos(phi),0.);
157   G4ThreeVector w = G4ThreeVector(std::cos(phi << 158   G4ThreeVector w = G4ThreeVector( std::cos(phi), std::sin(phi),0.);
158   G4RotationMatrix rotm1 = G4RotationMatrix(u, << 159   G4RotationMatrix rotm1  = G4RotationMatrix(u, v, w);
159   G4cout << "\n --> phi = " << phi / deg << "  << 160   G4cout << "\n --> phi = " << phi/deg << " deg;  direct rotation matrix : ";
160   rotm1.print(G4cout);                         << 161   rotm1.print(G4cout);     
161   G4ThreeVector position1 = og * w;            << 162   G4ThreeVector position1 = og*w;
162   G4Transform3D transform1 = G4Transform3D(rot << 163   G4Transform3D transform1 = G4Transform3D(rotm1,position1);
163                                                << 164 
164   new G4PVPlacement(transform1,  // position,  << 165   new G4PVPlacement(transform1,         //position, rotation        
165                     fTrdVolume,  // logical vo << 166                     fTrdVolume,         //logical volume
166                     "Trd",  // name            << 167                     "Trd",              //name
167                     fWorldVolume,  // mother v << 168                     fWorldVolume,       //mother volume
168                     false,  // no boolean oper << 169                     false,              //no boolean operation
169                     1);  // copy number        << 170                     1);                 //copy number                       
170                                                << 171 
171   // 2nd position                              << 172   // 2nd position 
172   //                                           << 173   //
173   phi = phi + 90 * deg;                        << 174   phi = phi + 90*deg;
174   v = G4ThreeVector(-std::sin(phi), std::cos(p << 175   v = G4ThreeVector(-std::sin(phi), std::cos(phi),0.);
175   w = G4ThreeVector(std::cos(phi), std::sin(ph << 176   w = G4ThreeVector( std::cos(phi), std::sin(phi),0.);
176   G4RotationMatrix rotm2 = G4RotationMatrix(u, << 177   G4RotationMatrix rotm2  = G4RotationMatrix(u, v, w);
177   G4ThreeVector position2 = og * w;            << 178   G4ThreeVector position2 = og*w;
178   G4Transform3D transform2 = G4Transform3D(rot << 179   G4Transform3D transform2 = G4Transform3D(rotm2,position2);
179   new G4PVPlacement(transform2,  // position,  << 180   new G4PVPlacement(transform2,         //position, rotation        
180                     fTrdVolume,  // logical vo << 181                     fTrdVolume,         //logical volume
181                     "Trd",  // name            << 182                     "Trd",              //name
182                     fWorldVolume,  // mother v << 183                     fWorldVolume,       //mother volume
183                     false,  // no boolean oper << 184                     false,              //no boolean operation
184                     2);  // copy number        << 185                     1);                 //copy number                       
185 }                                                 186 }
186                                                   187 
187 //....oooOO0OOooo........oooOO0OOooo........oo    188 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
188                                                   189 
189 void DetectorConstruction::PlaceWithInverseMat    190 void DetectorConstruction::PlaceWithInverseMatrix()
190 {                                                 191 {
191   G4double og = 3 * cm;                        << 192   G4double og = 3*cm; 
192                                                   193 
193   // 1st position                                 194   // 1st position
194   //                                              195   //
195   G4double phi = 30 * deg;                     << 196   G4double phi = 30*deg;
196   // u, v, w are the daughter axes, projected  << 197   // u, v, w are the daughter axes, projected on the mother frame     
197   G4ThreeVector u = G4ThreeVector(0, 0, -1);      198   G4ThreeVector u = G4ThreeVector(0, 0, -1);
198   G4ThreeVector v = G4ThreeVector(-std::sin(ph << 199   G4ThreeVector v = G4ThreeVector(-std::sin(phi), std::cos(phi),0.);
199   G4ThreeVector w = G4ThreeVector(std::cos(phi << 200   G4ThreeVector w = G4ThreeVector( std::cos(phi), std::sin(phi),0.);
200   G4RotationMatrix rotm1 = G4RotationMatrix(u, << 201   G4RotationMatrix rotm1 = G4RotationMatrix(u, v, w); 
201   auto rotm1Inv = new G4RotationMatrix(rotm1.i << 202   G4RotationMatrix* rotm1Inv = new G4RotationMatrix(rotm1.inverse());
202   G4cout << "\n --> phi = " << phi / deg << "  << 203   G4cout << "\n --> phi = " << phi/deg << " deg;  inverse rotation matrix : ";
203   rotm1Inv->print(G4cout);                     << 204   rotm1Inv->print(G4cout);   
204   G4ThreeVector position1 = og * w;            << 205   G4ThreeVector position1 = og*w;
205                                                << 206 
206   new G4PVPlacement(rotm1Inv, position1,       << 207   new G4PVPlacement(rotm1Inv,
207                     fTrdVolume,  // logical vo << 208                     position1,
208                     "Trd",  // name            << 209                     fTrdVolume,         //logical volume
209                     fWorldVolume,  // mother v << 210                     "Trd",              //name
210                     false,  // no boolean oper << 211                     fWorldVolume,       //mother volume
211                     1);  // copy number        << 212                     false,              //no boolean operation
                                                   >> 213                     1);                 //copy number                       
212                                                   214 
213   // 2nd position                                 215   // 2nd position
214   //                                              216   //
215   phi = phi + 90 * deg;                        << 217   phi = phi + 90*deg;
216   v = G4ThreeVector(-std::sin(phi), std::cos(p << 218   v = G4ThreeVector(-std::sin(phi), std::cos(phi),0.);
217   w = G4ThreeVector(std::cos(phi), std::sin(ph << 219   w = G4ThreeVector( std::cos(phi), std::sin(phi),0.);
218   G4RotationMatrix rotm2 = G4RotationMatrix(u, << 220   G4RotationMatrix rotm2  = G4RotationMatrix(u, v, w);
219   auto rotm2Inv = new G4RotationMatrix(rotm2.i << 221   G4RotationMatrix* rotm2Inv  = new G4RotationMatrix(rotm2.inverse());
220   G4ThreeVector position2 = og * w;            << 222   G4ThreeVector position2 = og*w;
221                                                << 223 
222   new G4PVPlacement(rotm2Inv,  // rotation     << 224   new G4PVPlacement(rotm2Inv,           //rotation
223                     position2,  // position    << 225                     position2,          //position        
224                     fTrdVolume,  // logical vo << 226                     fTrdVolume,         //logical volume
225                     "Trd",  // name            << 227                     "Trd",              //name
226                     fWorldVolume,  // mother v << 228                     fWorldVolume,       //mother volume
227                     false,  // no boolean oper << 229                     false,              //no boolean operation
228                     2);  // copy number        << 230                     2);                 //copy number
229 }                                                 231 }
230                                                   232 
231 //....oooOO0OOooo........oooOO0OOooo........oo    233 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
232                                                   234 
233 void DetectorConstruction::PlaceWithAxialRotat    235 void DetectorConstruction::PlaceWithAxialRotations()
234 {                                                 236 {
235   G4double og = 3 * cm;                        << 237   G4double og = 3*cm; 
236                                                   238 
237   // 1st position (with first G4PVPlacement co    239   // 1st position (with first G4PVPlacement constructor)
238   //                                              240   //
239   G4double phi = 30 * deg, theta = 90 * deg;   << 241   G4double phi = 30*deg, theta = 90*deg;
240   G4ThreeVector rotAxis = G4ThreeVector(std::s << 
241   G4RotationMatrix rotm1 = G4RotationMatrix();    242   G4RotationMatrix rotm1 = G4RotationMatrix();
242   rotm1.rotateY(theta);                        << 243   rotm1.rotateY(theta); 
243   rotm1.rotate(phi, rotAxis);                  << 244   rotm1.rotateZ(phi);
244   G4cout << "\n --> direct rotation matrix : " << 245   G4cout << "\n --> phi = " << phi/deg << " deg;  direct rotation matrix : ";
245          << " theta = " << theta / deg << " de << 246   rotm1.print(G4cout);        
246          << " phi  = " << phi / deg << " deg;" << 247   G4ThreeVector w = G4ThreeVector(std::cos(phi), std::sin(phi),0.);    
247   rotm1.print(G4cout);                         << 248   G4ThreeVector position1 = og*w;
248   G4ThreeVector w =                            << 249   G4Transform3D transform1(rotm1,position1);
249     G4ThreeVector(std::sin(theta) * std::cos(p << 250 
250   G4ThreeVector position1 = og * w;            << 251   new G4PVPlacement(transform1,          //rotation,position
251   G4Transform3D transform1(rotm1, position1);  << 252                     fTrdVolume,          //logical volume
252                                                << 253                     "Trd",               //name
253   new G4PVPlacement(transform1,  // rotation,p << 254                     fWorldVolume,        //mother volume
254                     fTrdVolume,  // logical vo << 255                     false,               //no boolean operation
255                     "Trd",  // name            << 256                     1);                  //copy number                       
256                     fWorldVolume,  // mother v << 
257                     false,  // no boolean oper << 
258                     1);  // copy number        << 
259                                                   257 
260   // 2nd position (with second G4PVPlacement c    258   // 2nd position (with second G4PVPlacement constructor)
261   //                                              259   //
262   phi = phi + 90 * deg;                        << 260   phi = phi + 90*deg;  
263   // rotm2Inv could be calculated with rotm2.i << 261   //rotm2Inv could be calculated with rotm2.inverse()
264   // but also by the following :               << 262   //but also by the following :
265   auto rotm2Inv = new G4RotationMatrix();      << 263   G4RotationMatrix* rotm2Inv  = new G4RotationMatrix();  
266   rotm2Inv->rotate(-phi, rotAxis);             << 264   rotm2Inv->rotateZ(-phi); 
267   rotm2Inv->rotateY(-theta);                   << 265   rotm2Inv->rotateY(-theta);     
268   w =                                          << 266   w = G4ThreeVector(std::cos(phi), std::sin(phi),0.);    
269     G4ThreeVector(std::sin(theta) * std::cos(p << 267   G4ThreeVector position2 = og*w;
270   G4ThreeVector position2 = og * w;            << 268   
271                                                << 269   new G4PVPlacement(rotm2Inv,           //rotation
272   new G4PVPlacement(rotm2Inv,  // rotation     << 270                     position2,          //position                             
273                     position2,  // position    << 271                     fTrdVolume,         //logical volume
274                     fTrdVolume,  // logical vo << 272                     "Trd",              //name
275                     "Trd",  // name            << 273                     fWorldVolume,       //mother volume
276                     fWorldVolume,  // mother v << 274                     false,              //no boolean operation
277                     false,  // no boolean oper << 275                     2);                 //copy number
278                     2);  // copy number        << 
279 }                                                 276 }
280                                                   277 
281 //....oooOO0OOooo........oooOO0OOooo........oo    278 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
282                                                   279 
283 void DetectorConstruction::PlaceWithEulerAngle    280 void DetectorConstruction::PlaceWithEulerAngles()
284 {                                                 281 {
285   // definitions : mother frame = {x,y,z} ; da << 282   //definitions : mother frame = {x,y,z} ; daughter frame = {u,v,w}
286   //  n = node line = intercept of xy and uv p << 283   // n = node line = intercept of xy and uv planes
287   //  phi_euler   = (x,n) : precession         << 284   // phi_euler   = (x,n) : precession
288   //  theta_euler = (z,w) : nutation           << 285   // theta_euler = (z,w) : nutation
289   //  psi_euler   = (n,u) : proper rotation    << 286   // psi_euler   = (n,u) : proper rotation
290                                                << 287   
291   G4double og = 3 * cm;                        << 288   G4double og = 3*cm;  
292                                                   289 
293   // 1st position (with first G4PVPlacement co    290   // 1st position (with first G4PVPlacement constructor)
294   //                                              291   //
295   G4double phi = 30 * deg;                     << 292   G4double phi = 30*deg;   
296   G4double phi_euler = phi + pi / 2;           << 293   G4double phi_euler   =  phi + pi/2; 
297   G4double theta_euler = 90 * deg;             << 294   G4double theta_euler =  90*deg;
298   G4double psi_euler = -90 * deg;              << 295   G4double psi_euler   = -90*deg;
299   // attention : clhep Euler constructor build << 296   //attention : clhep Euler constructor build inverse matrix !
300   G4RotationMatrix rotm1Inv = G4RotationMatrix << 297   G4RotationMatrix rotm1Inv = G4RotationMatrix(phi_euler,theta_euler,psi_euler);
301   G4RotationMatrix rotm1 = rotm1Inv.inverse();    298   G4RotationMatrix rotm1 = rotm1Inv.inverse();
302   // remark : could be built as rotm1 = G4Rota << 299   //remark : could be built as rotm1 = G4RotationMatrix(-psi, -theta, -phi)
303   G4cout << "\n --> phi = " << phi / deg << "  << 300   G4cout << "\n --> phi = " << phi/deg << " deg;  direct rotation matrix : ";
304   rotm1.print(G4cout);                         << 301   rotm1.print(G4cout);           
305   G4ThreeVector w = G4ThreeVector(std::cos(phi << 302   G4ThreeVector w = G4ThreeVector(std::cos(phi),  std::sin(phi),0.);
306   G4ThreeVector position1 = og * w;            << 303   G4ThreeVector position1 = og*w;
307   G4Transform3D transform1 = G4Transform3D(rot << 304   G4Transform3D transform1 = G4Transform3D(rotm1,position1);
308                                                << 305 
309   new G4PVPlacement(transform1,  // position,  << 306   new G4PVPlacement(transform1,         //position, rotation        
310                     fTrdVolume,  // logical vo << 307                     fTrdVolume,         //logical volume
311                     "Trd",  // name            << 308                     "Trd",              //name
312                     fWorldVolume,  // mother v << 309                     fWorldVolume,       //mother volume
313                     false,  // no boolean oper << 310                     false,              //no boolean operation
314                     1);  // copy number        << 311                     1);                 //copy number                       
315                                                   312 
316   // 2nd position (with second G4PVPlacement c    313   // 2nd position (with second G4PVPlacement constructor)
317   //                                              314   //
318   phi = phi + 90 * deg;                        << 315   phi = phi + 90*deg;
319                                                << 316   
320   phi_euler = phi + pi / 2;                    << 317   phi_euler   =  phi + pi/2; 
321   auto rotm2Inv = new G4RotationMatrix(phi_eul << 318   G4RotationMatrix* rotm2Inv  
322   w = G4ThreeVector(std::cos(phi), std::sin(ph << 319                 = new G4RotationMatrix(phi_euler,theta_euler,psi_euler);  
323   G4ThreeVector position2 = og * w;            << 320   w = G4ThreeVector(std::cos(phi),  std::sin(phi),0.);
324                                                << 321   G4ThreeVector position2 = og*w;
325   new G4PVPlacement(rotm2Inv,  // rotation     << 322                            
326                     position2,  // position    << 323   new G4PVPlacement(rotm2Inv,           //rotation
327                     fTrdVolume,  // logical vo << 324                     position2,          //position                     
328                     "Trd",  // name            << 325                     fTrdVolume,         //logical volume
329                     fWorldVolume,  // mother v << 326                     "Trd",              //name
330                     false,  // no boolean oper << 327                     fWorldVolume,       //mother volume
331                     2);  // copy number        << 328                     false,              //no boolean operation
                                                   >> 329                     2);                 //copy number                       
332 }                                                 330 }
333                                                   331 
334 //....oooOO0OOooo........oooOO0OOooo........oo    332 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
335                                                   333 
336 void DetectorConstruction::PlaceWithReflection    334 void DetectorConstruction::PlaceWithReflections()
337 {                                                 335 {
338   /// Placement with reflections.              << 336 /// Placement with reflcetions.
339   /// In order to better show the reflection s << 337 /// In order to better show the reflection symmetry we do not apply
340   /// the rotation along Y axis.               << 338 /// the rotation along Y axis.  
341                                                   339 
342   G4double og = 3 * cm;                        << 340   G4double og = 3*cm; 
343                                                   341 
344   // Place first two positionz in z = + 3cm    << 342   // Place first two positionz in z = - 3cm
345   //                                              343   //
346                                                   344 
347   // 1st position                                 345   // 1st position
348   G4double phi = 30 * deg;                     << 346   G4double phi = 30*deg;
349   G4RotationMatrix rotm1;                         347   G4RotationMatrix rotm1;
350   // rotm1.rotateY(90*deg);                    << 348   //rotm1.rotateY(90*deg); 
351   rotm1.rotateZ(phi);                          << 349   rotm1.rotateZ(phi); 
352   G4ThreeVector uz = G4ThreeVector(std::cos(ph << 350   G4ThreeVector uz = G4ThreeVector(std::cos(phi), std::sin(phi), 0);    
353   G4ThreeVector position = og * uz;            << 351   G4ThreeVector position = og*uz;
354   G4Transform3D transform1(rotm1, position);   << 352   G4Transform3D transform1(rotm1,position);
355   G4Transform3D translateZ = HepGeom::Translat << 353   G4Transform3D translateZ = HepGeom::Translate3D(0, 0, -3.*cm);
356                                                << 354 
357   new G4PVPlacement(translateZ * transform1,   << 355   new G4PVPlacement(translateZ * transform1, //rotation,position
358                     fTrdVolume,  // logical vo << 356                     fTrdVolume,              //logical volume
359                     "Trd",  // name            << 357                     "Trd",                   //name
360                     fWorldVolume,  // mother v << 358                     fWorldVolume,            //mother volume
361                     false,  // no boolean oper << 359                     false,                   //no boolean operation
362                     1);  // copy number        << 360                     1);                      //copy number
363                                                   361 
364   // 2nd position                                 362   // 2nd position
365   phi = phi + pi / 2;                          << 363   phi = phi + pi/2 ;
366   G4RotationMatrix rotm2;                         364   G4RotationMatrix rotm2;
367   // rotm2.rotateY(90*deg);                    << 365   //rotm2.rotateY(90*deg); 
368   rotm2.rotateZ(phi);                          << 366   rotm2.rotateZ(phi); 
369   uz = G4ThreeVector(std::cos(phi), std::sin(p << 367   uz = G4ThreeVector(std::cos(phi), std::sin(phi), 0.);    
370   position = og * uz;                          << 368   position = og*uz;
371   G4Transform3D transform2 = G4Transform3D(rot    369   G4Transform3D transform2 = G4Transform3D(rotm2, position);
                                                   >> 370   
                                                   >> 371   new G4PVPlacement(translateZ * transform2, //rotation, position
                                                   >> 372                     fTrdVolume,              //logical volume
                                                   >> 373                     "Trd",                   //name
                                                   >> 374                     fWorldVolume,            //mother volume
                                                   >> 375                     false,                   //no boolean operation
                                                   >> 376                     2);                      //copy number
372                                                   377 
373   new G4PVPlacement(translateZ * transform2,   << 
374                     fTrdVolume,  // logical vo << 
375                     "Trd",  // name            << 
376                     fWorldVolume,  // mother v << 
377                     false,  // no boolean oper << 
378                     2);  // copy number        << 
379                                                   378 
380   // Place next two positionz in z = - 3cm wit << 379   // Place next two positionz in z = + 3cm with reflection 
381   //                                              380   //
382                                                   381 
383   // 3rd position                                 382   // 3rd position
384   translateZ = HepGeom::Translate3D(0, 0, -3.  << 383   translateZ = HepGeom::Translate3D(0, 0, +3.*cm);
385   G4Transform3D reflect3D = HepGeom::ReflectZ3    384   G4Transform3D reflect3D = HepGeom::ReflectZ3D();
386                                                   385 
387   G4ReflectionFactory::Instance()->Place(trans << 386   G4ReflectionFactory::Instance()
388                                          "Trd" << 387     ->Place(translateZ * transform1 * reflect3D, //rotation,position
389                                          fTrdV << 388             "Trd",                               //name
390                                          fWorl << 389             fTrdVolume,                          //logical volume
391                                          false << 390             fWorldVolume,                        //mother volume
392                                          3);   << 391             false,                               //no boolean operation
                                                   >> 392             3);                                  //copy number
393                                                   393 
394   // 4rd position                                 394   // 4rd position
395   G4ReflectionFactory::Instance()->Place(trans << 395   G4ReflectionFactory::Instance()
396                                          "Trd" << 396     ->Place( translateZ * transform2 * reflect3D,//rotation,position
397                                          fTrdV << 397             "Trd",                               //name
398                                          fWorl << 398             fTrdVolume,                          //logical volume
399                                          false << 399             fWorldVolume,                        //mother volume
400                                          4);   << 400             false,                               //no boolean operation
                                                   >> 401             4);                                  //copy number
401 }                                                 402 }
402                                                   403 
403 //....oooOO0OOooo........oooOO0OOooo........oo    404 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
404                                                   405 
405 #include "G4RunManager.hh"                        406 #include "G4RunManager.hh"
406                                                   407 
407 void DetectorConstruction::SetMethod(EMethod m << 408 void DetectorConstruction::SetMethod(EMethod method) { 
408 {                                              << 
409   fMethod = method;                               409   fMethod = method;
410   G4RunManager::GetRunManager()->DefineWorldVo << 410   G4RunManager::GetRunManager()->DefineWorldVolume(Construct());  
411 }                                              << 411 }  
412                                                   412 
413 //....oooOO0OOooo........oooOO0OOooo........oo    413 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
414                                                   414