Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/basic/B2/B2a/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/basic/B2/B2a/src/DetectorConstruction.cc (Version 11.3.0) and /examples/basic/B2/B2a/src/DetectorConstruction.cc (Version 11.0)


  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 //                                                 26 //
 27 /// \file B2/B2a/src/DetectorConstruction.cc   <<  27 /// \file DetectorConstruction.cc
 28 /// \brief Implementation of the B2a::Detector     28 /// \brief Implementation of the B2a::DetectorConstruction class
 29                                                    29 
 30 #include "DetectorConstruction.hh"                 30 #include "DetectorConstruction.hh"
 31                                                << 
 32 #include "DetectorMessenger.hh"                    31 #include "DetectorMessenger.hh"
 33 #include "TrackerSD.hh"                            32 #include "TrackerSD.hh"
 34                                                    33 
 35 #include "G4AutoDelete.hh"                     << 
 36 #include "G4Box.hh"                            << 
 37 #include "G4Colour.hh"                         << 
 38 #include "G4GeometryManager.hh"                << 
 39 #include "G4GeometryTolerance.hh"              << 
 40 #include "G4GlobalMagFieldMessenger.hh"        << 
 41 #include "G4LogicalVolume.hh"                  << 
 42 #include "G4Material.hh"                           34 #include "G4Material.hh"
 43 #include "G4NistManager.hh"                        35 #include "G4NistManager.hh"
 44 #include "G4PVPlacement.hh"                    << 
 45 #include "G4SDManager.hh"                          36 #include "G4SDManager.hh"
 46 #include "G4SystemOfUnits.hh"                  <<  37 
                                                   >>  38 #include "G4Box.hh"
 47 #include "G4Tubs.hh"                               39 #include "G4Tubs.hh"
                                                   >>  40 #include "G4LogicalVolume.hh"
                                                   >>  41 #include "G4PVPlacement.hh"
                                                   >>  42 #include "G4GlobalMagFieldMessenger.hh"
                                                   >>  43 #include "G4AutoDelete.hh"
                                                   >>  44 
                                                   >>  45 #include "G4GeometryTolerance.hh"
                                                   >>  46 #include "G4GeometryManager.hh"
                                                   >>  47 
 48 #include "G4UserLimits.hh"                         48 #include "G4UserLimits.hh"
                                                   >>  49 
 49 #include "G4VisAttributes.hh"                      50 #include "G4VisAttributes.hh"
                                                   >>  51 #include "G4Colour.hh"
                                                   >>  52 
                                                   >>  53 #include "G4SystemOfUnits.hh"
 50                                                    54 
 51 using namespace B2;                                55 using namespace B2;
 52                                                    56 
 53 namespace B2a                                      57 namespace B2a
 54 {                                                  58 {
 55                                                    59 
 56 //....oooOO0OOooo........oooOO0OOooo........oo     60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 57                                                    61 
 58 G4ThreadLocal G4GlobalMagFieldMessenger* Detec <<  62 G4ThreadLocal
                                                   >>  63 G4GlobalMagFieldMessenger* DetectorConstruction::fMagFieldMessenger = nullptr;
 59                                                    64 
 60 DetectorConstruction::DetectorConstruction()       65 DetectorConstruction::DetectorConstruction()
 61 {                                                  66 {
 62   fMessenger = new DetectorMessenger(this);        67   fMessenger = new DetectorMessenger(this);
 63                                                    68 
 64   fNbOfChambers = 5;                               69   fNbOfChambers = 5;
 65   fLogicChamber = new G4LogicalVolume*[fNbOfCh     70   fLogicChamber = new G4LogicalVolume*[fNbOfChambers];
 66 }                                                  71 }
 67                                                    72 
 68 //....oooOO0OOooo........oooOO0OOooo........oo     73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 69                                                    74 
 70 DetectorConstruction::~DetectorConstruction()      75 DetectorConstruction::~DetectorConstruction()
 71 {                                                  76 {
 72   delete[] fLogicChamber;                      <<  77   delete [] fLogicChamber;
 73   delete fStepLimit;                               78   delete fStepLimit;
 74   delete fMessenger;                               79   delete fMessenger;
 75 }                                                  80 }
 76                                                    81 
 77 //....oooOO0OOooo........oooOO0OOooo........oo     82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 78                                                    83 
 79 G4VPhysicalVolume* DetectorConstruction::Const     84 G4VPhysicalVolume* DetectorConstruction::Construct()
 80 {                                                  85 {
 81   // Define materials                              86   // Define materials
 82   DefineMaterials();                               87   DefineMaterials();
 83                                                    88 
 84   // Define volumes                                89   // Define volumes
 85   return DefineVolumes();                          90   return DefineVolumes();
 86 }                                                  91 }
 87                                                    92 
 88 //....oooOO0OOooo........oooOO0OOooo........oo     93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 89                                                    94 
 90 void DetectorConstruction::DefineMaterials()       95 void DetectorConstruction::DefineMaterials()
 91 {                                                  96 {
 92   // Material definition                           97   // Material definition
 93                                                    98 
 94   G4NistManager* nistManager = G4NistManager::     99   G4NistManager* nistManager = G4NistManager::Instance();
 95                                                   100 
 96   // Air defined using NIST Manager               101   // Air defined using NIST Manager
 97   nistManager->FindOrBuildMaterial("G4_AIR");     102   nistManager->FindOrBuildMaterial("G4_AIR");
 98                                                   103 
 99   // Lead defined using NIST Manager              104   // Lead defined using NIST Manager
100   fTargetMaterial = nistManager->FindOrBuildMa << 105   fTargetMaterial  = nistManager->FindOrBuildMaterial("G4_Pb");
101                                                   106 
102   // Xenon gas defined using NIST Manager         107   // Xenon gas defined using NIST Manager
103   fChamberMaterial = nistManager->FindOrBuildM    108   fChamberMaterial = nistManager->FindOrBuildMaterial("G4_Xe");
104                                                   109 
105   // Print materials                              110   // Print materials
106   G4cout << *(G4Material::GetMaterialTable())     111   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
107 }                                                 112 }
108                                                   113 
109 //....oooOO0OOooo........oooOO0OOooo........oo    114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
110                                                   115 
111 G4VPhysicalVolume* DetectorConstruction::Defin    116 G4VPhysicalVolume* DetectorConstruction::DefineVolumes()
112 {                                                 117 {
113   G4Material* air = G4Material::GetMaterial("G << 118   G4Material* air  = G4Material::GetMaterial("G4_AIR");
114                                                   119 
115   // Sizes of the principal geometrical compon    120   // Sizes of the principal geometrical components (solids)
116                                                   121 
117   G4double chamberSpacing = 80 * cm;  // from  << 122   G4double chamberSpacing = 80*cm; // from chamber center to center!
118                                                   123 
119   G4double chamberWidth = 20.0 * cm;  // width << 124   G4double chamberWidth = 20.0*cm; // width of the chambers
120   G4double targetLength = 5.0 * cm;  // full l << 125   G4double targetLength =  5.0*cm; // full length of Target
121                                                   126 
122   G4double trackerLength = (fNbOfChambers + 1) << 127   G4double trackerLength = (fNbOfChambers+1)*chamberSpacing;
123                                                   128 
124   G4double worldLength = 1.2 * (2 * targetLeng << 129   G4double worldLength = 1.2 * (2*targetLength + trackerLength);
125                                                   130 
126   G4double targetRadius = 0.5 * targetLength;  << 131   G4double targetRadius  = 0.5*targetLength;   // Radius of Target
127   targetLength = 0.5 * targetLength;  // Half  << 132   targetLength = 0.5*targetLength;             // Half length of the Target
128   G4double trackerSize = 0.5 * trackerLength;  << 133   G4double trackerSize   = 0.5*trackerLength;  // Half length of the Tracker
129                                                   134 
130   // Definitions of Solids, Logical Volumes, P    135   // Definitions of Solids, Logical Volumes, Physical Volumes
131                                                   136 
132   // World                                        137   // World
133                                                   138 
134   G4GeometryManager::GetInstance()->SetWorldMa    139   G4GeometryManager::GetInstance()->SetWorldMaximumExtent(worldLength);
135                                                   140 
136   G4cout << "Computed tolerance = "               141   G4cout << "Computed tolerance = "
137          << G4GeometryTolerance::GetInstance() << 142          << G4GeometryTolerance::GetInstance()->GetSurfaceTolerance()/mm
                                                   >> 143          << " mm" << G4endl;
138                                                   144 
139   auto worldS = new G4Box("world",  // its nam << 145   G4Box* worldS
140                           worldLength / 2, wor << 146     = new G4Box("world",                                    //its name
141   auto worldLV = new G4LogicalVolume(worldS,   << 147                 worldLength/2,worldLength/2,worldLength/2); //its size
142                                      air,  //  << 148   G4LogicalVolume* worldLV
143                                      "World"); << 149     = new G4LogicalVolume(
                                                   >> 150                  worldS,   //its solid
                                                   >> 151                  air,      //its material
                                                   >> 152                  "World"); //its name
144                                                   153 
145   //  Must place the World Physical volume unr    154   //  Must place the World Physical volume unrotated at (0,0,0).
146   //                                              155   //
147   auto worldPV = new G4PVPlacement(nullptr,  / << 156   G4VPhysicalVolume* worldPV
148                                    G4ThreeVect << 157     = new G4PVPlacement(
149                                    worldLV,  / << 158                  0,               // no rotation
150                                    "World",  / << 159                  G4ThreeVector(), // at (0,0,0)
151                                    nullptr,  / << 160                  worldLV,         // its logical volume
152                                    false,  //  << 161                  "World",         // its name
153                                    0,  // copy << 162                  0,               // its mother  volume
154                                    fCheckOverl << 163                  false,           // no boolean operations
                                                   >> 164                  0,               // copy number
                                                   >> 165                  fCheckOverlaps); // checking overlaps
155                                                   166 
156   // Target                                       167   // Target
157                                                   168 
158   G4ThreeVector positionTarget = G4ThreeVector << 169   G4ThreeVector positionTarget = G4ThreeVector(0,0,-(targetLength+trackerSize));
159                                                   170 
160   auto targetS = new G4Tubs("target", 0., targ << 171   G4Tubs* targetS
161   fLogicTarget = new G4LogicalVolume(targetS,  << 172     = new G4Tubs("target",0.,targetRadius,targetLength,0.*deg,360.*deg);
162   new G4PVPlacement(nullptr,  // no rotation   << 173   fLogicTarget
                                                   >> 174     = new G4LogicalVolume(targetS, fTargetMaterial,"Target",0,0,0);
                                                   >> 175   new G4PVPlacement(0,               // no rotation
163                     positionTarget,  // at (x,    176                     positionTarget,  // at (x,y,z)
164                     fLogicTarget,  // its logi << 177                     fLogicTarget,    // its logical volume
165                     "Target",  // its name     << 178                     "Target",        // its name
166                     worldLV,  // its mother vo << 179                     worldLV,         // its mother volume
167                     false,  // no boolean oper << 180                     false,           // no boolean operations
168                     0,  // copy number         << 181                     0,               // copy number
169                     fCheckOverlaps);  // check << 182                     fCheckOverlaps); // checking overlaps
170                                                   183 
171   G4cout << "Target is " << 2 * targetLength / << 184   G4cout << "Target is " << 2*targetLength/cm << " cm of "
172          << G4endl;                            << 185          << fTargetMaterial->GetName() << G4endl;
173                                                   186 
174   // Tracker                                      187   // Tracker
175                                                   188 
176   G4ThreeVector positionTracker = G4ThreeVecto << 189   G4ThreeVector positionTracker = G4ThreeVector(0,0,0);
177                                                   190 
178   auto trackerS = new G4Tubs("tracker", 0, tra << 191   G4Tubs* trackerS
179   auto trackerLV = new G4LogicalVolume(tracker << 192     = new G4Tubs("tracker",0,trackerSize,trackerSize, 0.*deg, 360.*deg);
180   new G4PVPlacement(nullptr,  // no rotation   << 193   G4LogicalVolume* trackerLV
181                     positionTracker,  // at (x << 194     = new G4LogicalVolume(trackerS, air, "Tracker",0,0,0);
182                     trackerLV,  // its logical << 195   new G4PVPlacement(0,               // no rotation
183                     "Tracker",  // its name    << 196                     positionTracker, // at (x,y,z)
184                     worldLV,  // its mother  v << 197                     trackerLV,       // its logical volume
185                     false,  // no boolean oper << 198                     "Tracker",       // its name
186                     0,  // copy number         << 199                     worldLV,         // its mother  volume
187                     fCheckOverlaps);  // check << 200                     false,           // no boolean operations
                                                   >> 201                     0,               // copy number
                                                   >> 202                     fCheckOverlaps); // checking overlaps
188                                                   203 
189   // Visualization attributes                     204   // Visualization attributes
190                                                   205 
191   G4VisAttributes boxVisAtt(G4Colour::White()) << 206   G4VisAttributes* boxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
192   G4VisAttributes chamberVisAtt(G4Colour::Yell << 207   G4VisAttributes* chamberVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,0.0));
193                                                   208 
194   worldLV->SetVisAttributes(boxVisAtt);        << 209   worldLV      ->SetVisAttributes(boxVisAtt);
195   fLogicTarget->SetVisAttributes(boxVisAtt);   << 210   fLogicTarget ->SetVisAttributes(boxVisAtt);
196   trackerLV->SetVisAttributes(boxVisAtt);      << 211   trackerLV    ->SetVisAttributes(boxVisAtt);
197                                                   212 
198   // Tracker segments                             213   // Tracker segments
199                                                   214 
200   G4cout << "There are " << fNbOfChambers << " << 215   G4cout << "There are " << fNbOfChambers << " chambers in the tracker region. "
201          << "The chambers are " << chamberWidt << 216          << G4endl
202          << G4endl << "The distance between ch << 217          << "The chambers are " << chamberWidth/cm << " cm of "
                                                   >> 218          << fChamberMaterial->GetName() << G4endl
                                                   >> 219          << "The distance between chamber is " << chamberSpacing/cm << " cm"
                                                   >> 220          << G4endl;
203                                                   221 
204   G4double firstPosition = -trackerSize + cham    222   G4double firstPosition = -trackerSize + chamberSpacing;
205   G4double firstLength = trackerLength / 10;   << 223   G4double firstLength   = trackerLength/10;
206   G4double lastLength = trackerLength;         << 224   G4double lastLength    = trackerLength;
207                                                   225 
208   G4double halfWidth = 0.5 * chamberWidth;     << 226   G4double halfWidth = 0.5*chamberWidth;
209   G4double rmaxFirst = 0.5 * firstLength;         227   G4double rmaxFirst = 0.5 * firstLength;
210                                                   228 
211   G4double rmaxIncr = 0.0;                        229   G4double rmaxIncr = 0.0;
212   if (fNbOfChambers > 0) {                     << 230   if( fNbOfChambers > 0 ){
213     rmaxIncr = 0.5 * (lastLength - firstLength << 231     rmaxIncr =  0.5 * (lastLength-firstLength)/(fNbOfChambers-1);
214     if (chamberSpacing < chamberWidth) {       << 232     if (chamberSpacing  < chamberWidth) {
215       G4Exception("DetectorConstruction::Defin << 233        G4Exception("DetectorConstruction::DefineVolumes()",
216                   "Width>Spacing");            << 234                    "InvalidSetup", FatalException,
                                                   >> 235                    "Width>Spacing");
217     }                                             236     }
218   }                                               237   }
219                                                   238 
220   for (G4int copyNo = 0; copyNo < fNbOfChamber << 239   for (G4int copyNo=0; copyNo<fNbOfChambers; copyNo++) {
221     G4double Zposition = firstPosition + copyN << 240 
222     G4double rmax = rmaxFirst + copyNo * rmaxI << 241       G4double Zposition = firstPosition + copyNo * chamberSpacing;
223                                                << 242       G4double rmax =  rmaxFirst + copyNo * rmaxIncr;
224     auto chamberS = new G4Tubs("Chamber_solid" << 243 
225                                                << 244       G4Tubs* chamberS
226     fLogicChamber[copyNo] =                    << 245         = new G4Tubs("Chamber_solid", 0, rmax, halfWidth, 0.*deg, 360.*deg);
227       new G4LogicalVolume(chamberS, fChamberMa << 246 
228                                                << 247       fLogicChamber[copyNo] =
229     fLogicChamber[copyNo]->SetVisAttributes(ch << 248               new G4LogicalVolume(chamberS,fChamberMaterial,"Chamber_LV",0,0,0);
230                                                << 249 
231     new G4PVPlacement(nullptr,  // no rotation << 250       fLogicChamber[copyNo]->SetVisAttributes(chamberVisAtt);
232                       G4ThreeVector(0, 0, Zpos << 251 
233                       fLogicChamber[copyNo],   << 252       new G4PVPlacement(0,                            // no rotation
234                       "Chamber_PV",  // its na << 253                         G4ThreeVector(0,0,Zposition), // at (x,y,z)
235                       trackerLV,  // its mothe << 254                         fLogicChamber[copyNo],        // its logical volume
236                       false,  // no boolean op << 255                         "Chamber_PV",                 // its name
237                       copyNo,  // copy number  << 256                         trackerLV,                    // its mother  volume
238                       fCheckOverlaps);  // che << 257                         false,                        // no boolean operations
                                                   >> 258                         copyNo,                       // copy number
                                                   >> 259                         fCheckOverlaps);              // checking overlaps
                                                   >> 260 
239   }                                               261   }
240                                                   262 
241   // Example of User Limits                       263   // Example of User Limits
242   //                                              264   //
243   // Below is an example of how to set trackin    265   // Below is an example of how to set tracking constraints in a given
244   // logical volume                               266   // logical volume
245   //                                              267   //
246   // Sets a max step length in the tracker reg    268   // Sets a max step length in the tracker region, with G4StepLimiter
247                                                   269 
248   G4double maxStep = 0.5 * chamberWidth;       << 270   G4double maxStep = 0.5*chamberWidth;
249   fStepLimit = new G4UserLimits(maxStep);         271   fStepLimit = new G4UserLimits(maxStep);
250   trackerLV->SetUserLimits(fStepLimit);           272   trackerLV->SetUserLimits(fStepLimit);
251                                                   273 
252   /// Set additional contraints on the track,     274   /// Set additional contraints on the track, with G4UserSpecialCuts
253   ///                                             275   ///
254   /// G4double maxLength = 2*trackerLength, ma    276   /// G4double maxLength = 2*trackerLength, maxTime = 0.1*ns, minEkin = 10*MeV;
255   /// trackerLV->SetUserLimits(new G4UserLimit    277   /// trackerLV->SetUserLimits(new G4UserLimits(maxStep,
256   ///                                             278   ///                                           maxLength,
257   ///                                             279   ///                                           maxTime,
258   ///                                             280   ///                                           minEkin));
259                                                   281 
260   // Always return the physical world             282   // Always return the physical world
261                                                   283 
262   return worldPV;                                 284   return worldPV;
263 }                                                 285 }
264                                                   286 
265 //....oooOO0OOooo........oooOO0OOooo........oo    287 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
266                                                   288 
267 void DetectorConstruction::ConstructSDandField    289 void DetectorConstruction::ConstructSDandField()
268 {                                                 290 {
269   // Sensitive detectors                          291   // Sensitive detectors
270                                                   292 
271   G4String trackerChamberSDname = "/TrackerCha    293   G4String trackerChamberSDname = "/TrackerChamberSD";
272   auto trackerSD = new TrackerSD(trackerChambe << 294   TrackerSD* aTrackerSD = new TrackerSD(trackerChamberSDname,
273   G4SDManager::GetSDMpointer()->AddNewDetector << 295                                             "TrackerHitsCollection");
274   // Setting trackerSD to all logical volumes  << 296   G4SDManager::GetSDMpointer()->AddNewDetector(aTrackerSD);
                                                   >> 297   // Setting aTrackerSD to all logical volumes with the same name
275   // of "Chamber_LV".                             298   // of "Chamber_LV".
276   SetSensitiveDetector("Chamber_LV", trackerSD << 299   SetSensitiveDetector("Chamber_LV", aTrackerSD, true);
277                                                   300 
278   // Create global magnetic field messenger.      301   // Create global magnetic field messenger.
279   // Uniform magnetic field is then created au    302   // Uniform magnetic field is then created automatically if
280   // the field value is not zero.                 303   // the field value is not zero.
281   G4ThreeVector fieldValue = G4ThreeVector();     304   G4ThreeVector fieldValue = G4ThreeVector();
282   fMagFieldMessenger = new G4GlobalMagFieldMes    305   fMagFieldMessenger = new G4GlobalMagFieldMessenger(fieldValue);
283   fMagFieldMessenger->SetVerboseLevel(1);         306   fMagFieldMessenger->SetVerboseLevel(1);
284                                                   307 
285   // Register the field messenger for deleting    308   // Register the field messenger for deleting
286   G4AutoDelete::Register(fMagFieldMessenger);     309   G4AutoDelete::Register(fMagFieldMessenger);
287 }                                                 310 }
288                                                   311 
289 //....oooOO0OOooo........oooOO0OOooo........oo    312 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
290                                                   313 
291 void DetectorConstruction::SetTargetMaterial(G    314 void DetectorConstruction::SetTargetMaterial(G4String materialName)
292 {                                                 315 {
293   G4NistManager* nistManager = G4NistManager::    316   G4NistManager* nistManager = G4NistManager::Instance();
294                                                   317 
295   G4Material* pttoMaterial = nistManager->Find << 318   G4Material* pttoMaterial =
                                                   >> 319               nistManager->FindOrBuildMaterial(materialName);
296                                                   320 
297   if (fTargetMaterial != pttoMaterial) {          321   if (fTargetMaterial != pttoMaterial) {
298     if (pttoMaterial) {                        << 322      if ( pttoMaterial ) {
299       fTargetMaterial = pttoMaterial;          << 323         fTargetMaterial = pttoMaterial;
300       if (fLogicTarget) fLogicTarget->SetMater << 324         if (fLogicTarget) fLogicTarget->SetMaterial(fTargetMaterial);
301       G4cout << G4endl << "----> The target is << 325         G4cout
302     }                                          << 326           << G4endl
303     else {                                     << 327           << "----> The target is made of " << materialName << G4endl;
304       G4cout << G4endl << "-->  WARNING from S << 328      } else {
305              << G4endl;                        << 329         G4cout
306     }                                          << 330           << G4endl
                                                   >> 331           << "-->  WARNING from SetTargetMaterial : "
                                                   >> 332           << materialName << " not found" << G4endl;
                                                   >> 333      }
307   }                                               334   }
308 }                                                 335 }
309                                                   336 
310 //....oooOO0OOooo........oooOO0OOooo........oo    337 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
311                                                   338 
312 void DetectorConstruction::SetChamberMaterial(    339 void DetectorConstruction::SetChamberMaterial(G4String materialName)
313 {                                                 340 {
314   G4NistManager* nistManager = G4NistManager::    341   G4NistManager* nistManager = G4NistManager::Instance();
315                                                   342 
316   G4Material* pttoMaterial = nistManager->Find << 343   G4Material* pttoMaterial =
                                                   >> 344               nistManager->FindOrBuildMaterial(materialName);
317                                                   345 
318   if (fChamberMaterial != pttoMaterial) {         346   if (fChamberMaterial != pttoMaterial) {
319     if (pttoMaterial) {                        << 347      if ( pttoMaterial ) {
320       fChamberMaterial = pttoMaterial;         << 348         fChamberMaterial = pttoMaterial;
321       for (G4int copyNo = 0; copyNo < fNbOfCha << 349         for (G4int copyNo=0; copyNo<fNbOfChambers; copyNo++) {
322         if (fLogicChamber[copyNo]) fLogicChamb << 350             if (fLogicChamber[copyNo]) fLogicChamber[copyNo]->
323       }                                        << 351                                                SetMaterial(fChamberMaterial);
324       G4cout << G4endl << "----> The chambers  << 352         }
325     }                                          << 353         G4cout
326     else {                                     << 354           << G4endl
327       G4cout << G4endl << "-->  WARNING from S << 355           << "----> The chambers are made of " << materialName << G4endl;
328              << G4endl;                        << 356      } else {
329     }                                          << 357         G4cout
                                                   >> 358           << G4endl
                                                   >> 359           << "-->  WARNING from SetChamberMaterial : "
                                                   >> 360           << materialName << " not found" << G4endl;
                                                   >> 361      }
330   }                                               362   }
331 }                                                 363 }
332                                                   364 
333 //....oooOO0OOooo........oooOO0OOooo........oo    365 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
334                                                   366 
335 void DetectorConstruction::SetMaxStep(G4double    367 void DetectorConstruction::SetMaxStep(G4double maxStep)
336 {                                                 368 {
337   if ((fStepLimit) && (maxStep > 0.)) fStepLim << 369   if ((fStepLimit)&&(maxStep>0.)) fStepLimit->SetMaxAllowedStep(maxStep);
338 }                                                 370 }
339                                                   371 
340 //....oooOO0OOooo........oooOO0OOooo........oo    372 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
341                                                   373 
342 void DetectorConstruction::SetCheckOverlaps(G4    374 void DetectorConstruction::SetCheckOverlaps(G4bool checkOverlaps)
343 {                                                 375 {
344   fCheckOverlaps = checkOverlaps;                 376   fCheckOverlaps = checkOverlaps;
345 }                                                 377 }
346                                                   378 
347 //....oooOO0OOooo........oooOO0OOooo........oo    379 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
348                                                   380 
349 }  // namespace B2a                            << 381 }