Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/extended/electromagnetic/TestEm9/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/electromagnetic/TestEm9/src/DetectorConstruction.cc (Version 11.3.0) and /examples/extended/electromagnetic/TestEm9/src/DetectorConstruction.cc (Version 8.3)


  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 /// \file electromagnetic/TestEm9/src/Detector << 
 27 /// \brief Implementation of the DetectorConst << 
 28 //                                                 26 //
                                                   >>  27 // $Id: DetectorConstruction.cc,v 1.9 2006/06/29 17:02:59 gunter Exp $
                                                   >>  28 // GEANT4 tag $Name: geant4-08-02 $
 29 //                                                 29 //
 30 //                                                 30 //
 31 //////////////////////////////////////////////     31 /////////////////////////////////////////////////////////////////////////
 32 //                                                 32 //
 33 // TestEm9: Crystal calorimeter                    33 // TestEm9: Crystal calorimeter
 34 //                                                 34 //
 35 // Created: 31.01.03 V.Ivanchenko                  35 // Created: 31.01.03 V.Ivanchenko
 36 //                                                 36 //
 37 // Modified:                                       37 // Modified:
 38 //                                                 38 //
 39 //////////////////////////////////////////////     39 ////////////////////////////////////////////////////////////////////////
 40 //                                                 40 //
 41                                                    41 
                                                   >>  42 
 42 //....oooOO0OOooo........oooOO0OOooo........oo     43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 43 //....oooOO0OOooo........oooOO0OOooo........oo     44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 44                                                    45 
 45 #include "DetectorConstruction.hh"                 46 #include "DetectorConstruction.hh"
 46                                                << 
 47 #include "DetectorMessenger.hh"                    47 #include "DetectorMessenger.hh"
 48                                                    48 
 49 #include "G4Box.hh"                                49 #include "G4Box.hh"
 50 #include "G4Colour.hh"                         << 
 51 #include "G4GeometryManager.hh"                << 
 52 #include "G4LogicalVolume.hh"                      50 #include "G4LogicalVolume.hh"
 53 #include "G4LogicalVolumeStore.hh"             << 
 54 #include "G4NistManager.hh"                    << 
 55 #include "G4PVPlacement.hh"                        51 #include "G4PVPlacement.hh"
 56 #include "G4PVReplica.hh"                          52 #include "G4PVReplica.hh"
 57 #include "G4PhysicalVolumeStore.hh"            <<  53 
 58 #include "G4ProductionCuts.hh"                 <<  54 #include "G4TransportationManager.hh"
                                                   >>  55 
                                                   >>  56 #include "G4GeometryManager.hh"
                                                   >>  57 #include "G4RunManager.hh"
 59 #include "G4Region.hh"                             58 #include "G4Region.hh"
 60 #include "G4RegionStore.hh"                        59 #include "G4RegionStore.hh"
 61 #include "G4RunManager.hh"                     <<  60 #include "G4PhysicalVolumeStore.hh"
                                                   >>  61 #include "G4LogicalVolumeStore.hh"
 62 #include "G4SolidStore.hh"                         62 #include "G4SolidStore.hh"
 63 #include "G4SystemOfUnits.hh"                  <<  63 #include "G4NistManager.hh"
 64 #include "G4TransportationManager.hh"          <<  64 
 65 #include "G4UnitsTable.hh"                     << 
 66 #include "G4VisAttributes.hh"                      65 #include "G4VisAttributes.hh"
                                                   >>  66 #include "G4Colour.hh"
                                                   >>  67 
                                                   >>  68 #include "G4UnitsTable.hh"
 67 #include "G4ios.hh"                                69 #include "G4ios.hh"
 68                                                    70 
 69 //....oooOO0OOooo........oooOO0OOooo........oo     71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 70                                                    72 
 71 DetectorConstruction::DetectorConstruction()       73 DetectorConstruction::DetectorConstruction()
 72   : G4VUserDetectorConstruction(),             <<  74   :logicC(0),logicA1(0),logicA2(0)
 73     fCalMaterial(0),                           << 
 74     fVertMaterial(0),                          << 
 75     fAbsMaterial(0),                           << 
 76     fWorldMaterial(0),                         << 
 77     fYorkMaterial(0),                          << 
 78     fLogicWorld(0),                            << 
 79     fLogicCal(0),                              << 
 80     fLogicA1(0),                               << 
 81     fLogicA2(0),                               << 
 82     fLogicA3(0),                               << 
 83     fLogicA4(0),                               << 
 84     fVertexRegion(0),                          << 
 85     fMuonRegion(0),                            << 
 86     fVertexDetectorCuts(0),                    << 
 87     fMuonDetectorCuts(0),                      << 
 88     fDetectorMessenger(0)                      << 
 89 {                                                  75 {
 90   fDetectorMessenger = new DetectorMessenger(t <<  76   detectorMessenger = new DetectorMessenger(this);
 91                                                << 
 92   fEcalLength = 36. * cm;                      << 
 93   fEcalWidth = 6. * cm;                        << 
 94   fVertexLength = 3. * cm;                     << 
 95   fPadLength = 0.1 * mm;                       << 
 96   fPadWidth = 0.02 * mm;                       << 
 97   fAbsLength = 2. * mm;                        << 
 98   fWorldZ = 0.0;                               << 
 99   fLogicWorld = 0;                             << 
100   fLogicCal = 0;                               << 
101   fLogicA1 = 0;                                << 
102   fLogicA2 = 0;                                << 
103   fLogicA3 = 0;                                << 
104   fLogicA4 = 0;                                << 
105   fVertexRegion = 0;                           << 
106   fMuonRegion = 0;                             << 
107                                                    77 
                                                   >>  78   ecalLength   = 36.*cm;
                                                   >>  79   ecalWidth    = 6.*cm;
                                                   >>  80   vertexLength = 3.*cm;
                                                   >>  81   padLength    = 0.1*mm;
                                                   >>  82   padWidth     = 0.02*mm;
                                                   >>  83   absLength    = 2.*mm;
                                                   >>  84   vertexRegion = 0;
                                                   >>  85   muonRegion   = 0;
108   DefineMaterials();                               86   DefineMaterials();
109   fVertexDetectorCuts = new G4ProductionCuts() << 
110   fMuonDetectorCuts = new G4ProductionCuts();  << 
111 }                                                  87 }
112                                                    88 
113 //....oooOO0OOooo........oooOO0OOooo........oo     89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
114                                                    90 
115 DetectorConstruction::~DetectorConstruction()      91 DetectorConstruction::~DetectorConstruction()
116 {                                              <<  92 { delete detectorMessenger;}
117   delete fDetectorMessenger;                   << 
118   delete fVertexDetectorCuts;                  << 
119   delete fMuonDetectorCuts;                    << 
120 }                                              << 
121                                                    93 
122 //....oooOO0OOooo........oooOO0OOooo........oo     94 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
123                                                    95 
124 G4VPhysicalVolume* DetectorConstruction::Const     96 G4VPhysicalVolume* DetectorConstruction::Construct()
125 {                                                  97 {
126   return ConstructVolumes();                       98   return ConstructVolumes();
127 }                                                  99 }
128                                                   100 
129 //....oooOO0OOooo........oooOO0OOooo........oo    101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
130                                                   102 
131 void DetectorConstruction::DefineMaterials()      103 void DetectorConstruction::DefineMaterials()
132 {                                                 104 {
133   // Default materials                            105   // Default materials
134                                                   106 
135   G4NistManager* man = G4NistManager::Instance    107   G4NistManager* man = G4NistManager::Instance();
136   //  man->SetVerbose(1);                      << 108   man->SetVerbose(1);
137   fWorldMaterial = man->FindOrBuildMaterial("G << 109   worldMaterial = man->FindOrBuildMaterial("G4_AIR");
138   fAbsMaterial = man->FindOrBuildMaterial("G4_ << 110   absMaterial   = man->FindOrBuildMaterial("G4_Al");
139   fVertMaterial = man->FindOrBuildMaterial("G4 << 111   vertMaterial  = man->FindOrBuildMaterial("G4_Si");
140   fYorkMaterial = man->FindOrBuildMaterial("G4 << 112   yorkMaterial  = man->FindOrBuildMaterial("G4_Fe");
141   fCalMaterial = man->FindOrBuildMaterial("G4_ << 113   calMaterial   = man->FindOrBuildMaterial("G4_CESIUM_IODIDE");
142 }                                                 114 }
143                                                   115 
144 //....oooOO0OOooo........oooOO0OOooo........oo    116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
145                                                   117 
146 G4VPhysicalVolume* DetectorConstruction::Const    118 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
147 {                                                 119 {
                                                   >> 120   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
                                                   >> 121 
148   // Cleanup old geometry                         122   // Cleanup old geometry
149                                                   123 
150   G4GeometryManager::GetInstance()->OpenGeomet    124   G4GeometryManager::GetInstance()->OpenGeometry();
151                                                << 
152   if (G4NistManager::Instance()->GetVerbose()  << 
153     G4cout << *(G4Material::GetMaterialTable() << 
154                                                << 
155   if (fVertexRegion) {                         << 
156     delete fVertexRegion;                      << 
157     delete fMuonRegion;                        << 
158   }                                            << 
159   fVertexRegion = new G4Region("VertexDetector << 
160   fVertexRegion->SetProductionCuts(fVertexDete << 
161                                                << 
162   fMuonRegion = new G4Region("MuonDetector");  << 
163   fMuonRegion->SetProductionCuts(fMuonDetector << 
164                                                << 
165   G4SolidStore::GetInstance()->Clean();        << 
166   G4LogicalVolumeStore::GetInstance()->Clean() << 
167   G4PhysicalVolumeStore::GetInstance()->Clean(    125   G4PhysicalVolumeStore::GetInstance()->Clean();
                                                   >> 126   G4LogicalVolumeStore::GetInstance()->Clean();
                                                   >> 127   G4SolidStore::GetInstance()->Clean();
168                                                   128 
169   if (fVertexLength < fPadLength * 5.0) fVerte << 129   if(vertexRegion) delete vertexRegion;
170   G4double gap = 0.01 * mm;                    << 130   if(muonRegion) delete muonRegion;
171   G4double biggap = 2. * cm;                   << 131   vertexRegion = new G4Region("VertexDetector");
172   G4double york = 10. * cm;                    << 132   muonRegion   = new G4Region("MuonDetector");
173                                                << 133 
174   fWorldZ = 2. * fVertexLength + 3. * fAbsLeng << 134   if(vertexLength < padLength*5.0) vertexLength = padLength*5.0;
175                                                << 135   G4double gap    = 0.01*mm;
176   G4double worldX = fEcalWidth * 3.0;          << 136   G4double biggap = 2.*cm;
177   G4double vertexZ = -fWorldZ + fVertexLength  << 137   G4double york   = 10.*cm;
178   G4double absZ2 = -fWorldZ + fVertexLength *  << 138 
179   G4double ecalZ =                             << 139            worldZ = 2.*vertexLength + 3.*absLength + 0.5*(ecalLength + york) + biggap*2.;
180     -fWorldZ + fVertexLength * 4.0 + fAbsLengt << 140   G4double worldX = ecalWidth*3.0;
181   G4double yorkZ =                             << 141   G4double vertexZ= -worldZ + vertexLength*2.0 + absLength     + biggap;
182     -fWorldZ + fVertexLength * 4.0 + fAbsLengt << 142   G4double absZ2  = -worldZ + vertexLength*4.0 + absLength*3.5 + biggap;
                                                   >> 143   G4double ecalZ  = -worldZ + vertexLength*4.0 + absLength*4.0 + ecalLength*0.5 + 2.*biggap;
                                                   >> 144   G4double yorkZ  = -worldZ + vertexLength*4.0 + absLength*5.0 + ecalLength
                                                   >> 145                             + york*0.5 + 3.*biggap;
183                                                   146 
184   //                                              147   //
185   // World                                        148   // World
186   //                                              149   //
187   G4Box* solidW = new G4Box("World", worldX, w << 150   G4Box* solidW = new G4Box("World",worldX,worldX,worldZ);
188   fLogicWorld = new G4LogicalVolume(solidW, fW << 151   G4LogicalVolume* logicW = new G4LogicalVolume( solidW,worldMaterial,
189   G4VPhysicalVolume* world =                   << 152                                                 "World");
190     new G4PVPlacement(0, G4ThreeVector(), "Wor << 153   G4VPhysicalVolume* world = new G4PVPlacement(0,G4ThreeVector(),
                                                   >> 154                                        "World",logicW,0,false,0);
191                                                   155 
192   //                                              156   //
193   // Ecal                                         157   // Ecal
194   //                                              158   //
195   G4Box* solidE = new G4Box("VolE", worldX, wo << 159   G4Box* solidE = new G4Box("VolE",worldX,worldX,ecalLength*0.5 + gap);
196   G4LogicalVolume* logicECal = new G4LogicalVo << 160   G4LogicalVolume* logicE = new G4LogicalVolume( solidE,worldMaterial,
197   G4VPhysicalVolume* physE =                   << 161                                                 "VolE");
198     new G4PVPlacement(0, G4ThreeVector(0., 0., << 162   G4VPhysicalVolume* physE = new G4PVPlacement(0,G4ThreeVector(0.,0.,ecalZ),
                                                   >> 163                                        "VolE",logicE,world,false,0);
199                                                   164 
200   G4Box* solidC = new G4Box("Ecal", fEcalWidth << 165   G4Box* solidC = new G4Box("Ecal",ecalWidth*0.5,ecalWidth*0.5,ecalLength*0.5);
201   fLogicCal = new G4LogicalVolume(solidC, fCal << 166   logicC = new G4LogicalVolume( solidC,calMaterial,"Ecal");
202                                                   167 
203   G4cout << "Ecal is " << G4BestUnit(fEcalLeng << 168   G4cout << "Ecal is " << G4BestUnit(ecalLength,"Length")
204          << G4endl;                            << 169        << " of " << calMaterial->GetName() << G4endl;
205                                                   170 
206   // Crystals                                     171   // Crystals
207                                                   172 
208   G4double x0 = -(fEcalWidth + gap) * 2.0;     << 173   G4double x0 = -(ecalWidth + gap)*2.0;
209   G4double y = x0;                             << 174   G4double y  = x0;
210   G4double x;                                     175   G4double x;
211   G4int k = 0;                                    176   G4int k = 0;
212   G4int i, j;                                  << 177   G4VPhysicalVolume* pv;
                                                   >> 178   G4int i,j;
                                                   >> 179 
                                                   >> 180   for (i=0; i<5; i++) {
                                                   >> 181     x  = x0;
                                                   >> 182     for (j=0; j<5; j++) {
213                                                   183 
214   for (i = 0; i < 5; i++) {                    << 184       pv = new G4PVPlacement(0,G4ThreeVector(x,y,0.),"Ecal",logicC,
215     x = x0;                                    << 185                                     physE,false,k);
216     for (j = 0; j < 5; j++) {                  << 
217       new G4PVPlacement(0, G4ThreeVector(x, y, << 
218       k++;                                        186       k++;
219       x += fEcalWidth + gap;                   << 187       x += ecalWidth + gap;
220     }                                             188     }
221     y += fEcalWidth + gap;                     << 189     y += ecalWidth + gap;
222   }                                               190   }
223                                                   191 
224   // Absorber                                  << 192   //Absorber
                                                   >> 193 
                                                   >> 194   G4Box* solidA = new G4Box("Abso",worldX,worldX,absLength*0.5);
                                                   >> 195   logicA2 = new G4LogicalVolume( solidA,absMaterial,"Abs2");
                                                   >> 196   pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,absZ2),
                                                   >> 197                                        "Abs2",logicA2,world,false,0);
                                                   >> 198 
                                                   >> 199   G4cout << "Absorber is " << G4BestUnit(absLength,"Length")
                                                   >> 200        << " of " << absMaterial->GetName() << G4endl;
                                                   >> 201 
                                                   >> 202   //York
                                                   >> 203 
                                                   >> 204   G4Box* solidYV = new G4Box("VolY",worldX,worldX,york*0.5+absLength);
                                                   >> 205   G4LogicalVolume* logicYV = new G4LogicalVolume( solidYV,yorkMaterial,"VolY");
                                                   >> 206   G4VPhysicalVolume* physYV = new G4PVPlacement(0,G4ThreeVector(0.,0.,yorkZ),
                                                   >> 207                                        "VolY",logicYV,world,false,0);
                                                   >> 208 
                                                   >> 209   G4Box* solidY = new G4Box("York",worldX,worldX,york*0.5);
                                                   >> 210   G4LogicalVolume* logicY = new G4LogicalVolume( solidY,yorkMaterial,"York");
                                                   >> 211   pv = new G4PVPlacement(0,G4ThreeVector(),
                                                   >> 212                                        "York",logicY,physYV,false,0);
                                                   >> 213 
                                                   >> 214   logicA3 = new G4LogicalVolume( solidA,absMaterial,"Abs3");
                                                   >> 215   logicA4 = new G4LogicalVolume( solidA,absMaterial,"Abs4");
                                                   >> 216   pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,-(york+absLength)*0.5),
                                                   >> 217                                        "Abs3",logicA3,physYV,false,0);
                                                   >> 218   pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,(york+absLength)*0.5),
                                                   >> 219                                        "Abs4",logicA4,physYV,false,0);
                                                   >> 220 
                                                   >> 221   //Vertex volume
                                                   >> 222 
                                                   >> 223   G4Box* solidVV = new G4Box("VolV",worldX,worldX,vertexLength*2.+absLength+gap);
                                                   >> 224   G4LogicalVolume* logicVV = new G4LogicalVolume( solidVV,worldMaterial,"VolV");
                                                   >> 225   G4VPhysicalVolume* physVV = new G4PVPlacement(0,G4ThreeVector(0.,0.,vertexZ),
                                                   >> 226                                        "VolV",logicVV,world,false,0);
                                                   >> 227 
                                                   >> 228   //Absorber
                                                   >> 229 
                                                   >> 230   logicA1 = new G4LogicalVolume( solidA,absMaterial,"Abs1");
                                                   >> 231   pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,vertexLength*2.-absLength*0.5),
                                                   >> 232                                        "Abs1",logicA1,physVV,false,0);
                                                   >> 233 
                                                   >> 234   //Vertex
225                                                   235 
226   G4Box* solidA = new G4Box("Abso", worldX, wo << 236   G4double vertWidth = ecalWidth/5.;
227   fLogicA2 = new G4LogicalVolume(solidA, fAbsM << 237   G4int npads = (G4int)(vertWidth/padWidth);
228   new G4PVPlacement(0, G4ThreeVector(0., 0., a << 238   npads = (npads/2)*2 + 1;
229                                                << 239   x0 = -0.5*padWidth*((G4double)(npads-1));
230   G4cout << "Absorber is " << G4BestUnit(fAbsL << 240   G4double x1 = std::fabs(x0) + 0.5*padWidth + gap; 
231          << G4endl;                            << 241   G4double z  = -(vertexLength+absLength);
232                                                << 242 
233   // York                                      << 243   G4Box* solidVD = new G4Box("VertDet",x1,ecalWidth*0.5+gap,padLength*0.5);
234                                                << 244   G4LogicalVolume* logicVD = new G4LogicalVolume( solidVD,vertMaterial,"VertDet");
235   G4Box* solidYV = new G4Box("VolY", worldX, w << 245 
236   G4LogicalVolume* logicYV = new G4LogicalVolu << 246   G4Box* solidV = new G4Box("Vert",padWidth*0.5,ecalWidth*0.5,padLength*0.5);
237   G4VPhysicalVolume* physYV =                  << 247   G4LogicalVolume* logicV = new G4LogicalVolume( solidV,vertMaterial,"Vert");
238     new G4PVPlacement(0, G4ThreeVector(0., 0., << 248 
239                                                << 249   for (i=0; i<3; i++) {
240   G4Box* solidY = new G4Box("York", worldX, wo << 250     pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,z),"VertDet",logicVD,
241   G4LogicalVolume* logicY = new G4LogicalVolum << 251                                     physVV,false,i);
242   new G4PVPlacement(0, G4ThreeVector(), "York" << 252     z += vertexLength;
243                                                << 
244   fLogicA3 = new G4LogicalVolume(solidA, fAbsM << 
245   fLogicA4 = new G4LogicalVolume(solidA, fAbsM << 
246                                                << 
247   new G4PVPlacement(0, G4ThreeVector(0., 0., - << 
248                     false, 0);                 << 
249   new G4PVPlacement(0, G4ThreeVector(0., 0., ( << 
250                     false, 0);                 << 
251                                                << 
252   // Vertex volume                             << 
253   G4Box* solidVV = new G4Box("VolV", worldX, w << 
254   G4LogicalVolume* logicVV = new G4LogicalVolu << 
255   G4VPhysicalVolume* physVV =                  << 
256     new G4PVPlacement(0, G4ThreeVector(0., 0., << 
257                                                << 
258   // Absorber                                  << 
259   fLogicA1 = new G4LogicalVolume(solidA, fAbsM << 
260   new G4PVPlacement(0, G4ThreeVector(0., 0., f << 
261                     fLogicA1, physVV, false, 0 << 
262                                                << 
263   // Vertex                                    << 
264   G4double vertWidth = fEcalWidth / 5.;        << 
265   G4int npads = (G4int)(vertWidth / fPadWidth) << 
266   // G4cout << " vertWidth= " << vertWidth <<  << 
267   //          << " npads= " << npads << G4endl << 
268   //  insure beam to hit a middle of central p << 
269   npads = (npads / 2) * 2 + 1;                 << 
270   x0 = -0.5 * (fPadWidth + vertWidth);         << 
271   G4double x1 = 0.5 * vertWidth + gap;         << 
272   G4double z = -(fVertexLength + fAbsLength);  << 
273                                                << 
274   G4Box* solidVD = new G4Box("VertDet", x1, fE << 
275   G4LogicalVolume* logicVD = new G4LogicalVolu << 
276   logicVD->SetSolid(solidVD);                  << 
277                                                << 
278   G4Box* solidV = new G4Box("Vert", fPadWidth  << 
279   G4LogicalVolume* logicV = new G4LogicalVolum << 
280                                                << 
281   for (i = 0; i < 3; i++) {                    << 
282     new G4PVPlacement(0, G4ThreeVector(0., 0., << 
283     z += fVertexLength;                        << 
284   }                                               253   }
285   x = x0;                                         254   x = x0;
286                                                   255 
287   for (j = 0; j < npads; j++) {                << 256   for (j=0; j<npads; j++) {
288     new G4PVPlacement(0, G4ThreeVector(x, 0.,  << 257 
289     x += fPadWidth;                            << 258     pv = new G4PVPlacement(0,G4ThreeVector(x,0.,0.),logicV,"Vert",logicVD,
                                                   >> 259                                     false,k);
                                                   >> 260     x += padWidth;
290   }                                               261   }
291                                                   262 
292   G4cout << "Vertex is " << G4BestUnit(fVertex << 263   G4cout << "Vertex is " << G4BestUnit(vertexLength,"Length")
293          << G4BestUnit(fPadLength, "Length") < << 264          << " of 3 layers of Si of " << G4BestUnit(padLength,"Length")
                                                   >> 265          << " npads= " << npads
                                                   >> 266    << G4endl;
294                                                   267 
295   // Define region for the vertex detector        268   // Define region for the vertex detector
296   fVertexRegion->AddRootLogicalVolume(logicVV) << 269 
297   fVertexRegion->AddRootLogicalVolume(fLogicA3 << 270   vertexRegion->AddRootLogicalVolume(logicVV);
                                                   >> 271   vertexRegion->AddRootLogicalVolume(logicA3);
298                                                   272 
299   // Define region for the muon detector          273   // Define region for the muon detector
300   fMuonRegion->AddRootLogicalVolume(logicYV);  << 274 
                                                   >> 275   muonRegion->AddRootLogicalVolume(logicYV);
301                                                   276 
302   // color regions                                277   // color regions
303   logicVV->SetVisAttributes(G4VisAttributes::G << 278 
304   logicV->SetVisAttributes(G4VisAttributes::Ge << 279   logicVV-> SetVisAttributes(G4VisAttributes::Invisible);
305   logicECal->SetVisAttributes(G4VisAttributes: << 280   logicV-> SetVisAttributes(G4VisAttributes::Invisible);
306   logicYV->SetVisAttributes(G4VisAttributes::G << 281   logicE-> SetVisAttributes(G4VisAttributes::Invisible);
                                                   >> 282   logicYV-> SetVisAttributes(G4VisAttributes::Invisible);
307                                                   283 
308   G4VisAttributes* regWcolor = new G4VisAttrib    284   G4VisAttributes* regWcolor = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3));
309   fLogicWorld->SetVisAttributes(regWcolor);    << 285   logicW->SetVisAttributes(regWcolor);
310                                                   286 
311   G4VisAttributes* regVcolor = new G4VisAttrib    287   G4VisAttributes* regVcolor = new G4VisAttributes(G4Colour(0., 0.3, 0.7));
312   logicVD->SetVisAttributes(regVcolor);           288   logicVD->SetVisAttributes(regVcolor);
313                                                   289 
314   G4VisAttributes* regCcolor = new G4VisAttrib    290   G4VisAttributes* regCcolor = new G4VisAttributes(G4Colour(0., 0.7, 0.3));
315   fLogicCal->SetVisAttributes(regCcolor);      << 291   logicC->SetVisAttributes(regCcolor);
316                                                   292 
317   G4VisAttributes* regAcolor = new G4VisAttrib    293   G4VisAttributes* regAcolor = new G4VisAttributes(G4Colour(1., 0.5, 0.5));
318   fLogicA1->SetVisAttributes(regAcolor);       << 294   logicA1->SetVisAttributes(regAcolor);
319   fLogicA2->SetVisAttributes(regAcolor);       << 295   logicA2->SetVisAttributes(regAcolor);
320   fLogicA3->SetVisAttributes(regAcolor);       << 296   logicA3->SetVisAttributes(regAcolor);
321   fLogicA4->SetVisAttributes(regAcolor);       << 297   logicA4->SetVisAttributes(regAcolor);
322                                                   298 
323   G4VisAttributes* regMcolor = new G4VisAttrib    299   G4VisAttributes* regMcolor = new G4VisAttributes(G4Colour(1., 1., 0.));
324   logicY->SetVisAttributes(regMcolor);            300   logicY->SetVisAttributes(regMcolor);
325                                                   301 
326   // always return world                          302   // always return world
327   G4cout << "### New geometry is constructed"     303   G4cout << "### New geometry is constructed" << G4endl;
328                                                   304 
329   return world;                                   305   return world;
330 }                                                 306 }
331                                                   307 
332 //....oooOO0OOooo........oooOO0OOooo........oo    308 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
333                                                   309 
334 void DetectorConstruction::SetEcalMaterial(con    310 void DetectorConstruction::SetEcalMaterial(const G4String& mat)
335 {                                                 311 {
336   // search the material by its name              312   // search the material by its name
337   G4Material* pttoMaterial = G4NistManager::In << 313   G4Material* pttoMaterial = 
338   if (pttoMaterial && pttoMaterial != fCalMate << 314     G4NistManager::Instance()->FindOrBuildMaterial(mat, false);
339     fCalMaterial = pttoMaterial;               << 315   if (pttoMaterial) calMaterial = pttoMaterial;
340     if (fLogicCal) {                           << 
341       fLogicCal->SetMaterial(fCalMaterial);    << 
342       G4RunManager::GetRunManager()->PhysicsHa << 
343     }                                          << 
344   }                                            << 
345 }                                                 316 }
346                                                   317 
347 //....oooOO0OOooo........oooOO0OOooo........oo    318 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
348                                                   319 
349 void DetectorConstruction::SetAbsMaterial(cons    320 void DetectorConstruction::SetAbsMaterial(const G4String& mat)
350 {                                                 321 {
351   // search the material by its name              322   // search the material by its name
352   G4Material* pttoMaterial = G4NistManager::In << 323   G4Material* pttoMaterial = 
353   if (pttoMaterial && pttoMaterial != fAbsMate << 324     G4NistManager::Instance()->FindOrBuildMaterial(mat, false);
354     fAbsMaterial = pttoMaterial;               << 325   if (pttoMaterial) absMaterial = pttoMaterial;
355     if (fLogicA1) {                            << 
356       fLogicA1->SetMaterial(fAbsMaterial);     << 
357       fLogicA2->SetMaterial(fAbsMaterial);     << 
358       fLogicA3->SetMaterial(fAbsMaterial);     << 
359       fLogicA4->SetMaterial(fAbsMaterial);     << 
360       G4RunManager::GetRunManager()->PhysicsHa << 
361     }                                          << 
362   }                                            << 
363 }                                                 326 }
364                                                   327 
365 //....oooOO0OOooo........oooOO0OOooo........oo    328 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
366                                                   329 
367 void DetectorConstruction::UpdateGeometry()       330 void DetectorConstruction::UpdateGeometry()
368 {                                                 331 {
369   G4RunManager::GetRunManager()->PhysicsHasBee << 
370   G4RunManager::GetRunManager()->DefineWorldVo    332   G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
371 }                                              << 
372                                                << 
373 //....oooOO0OOooo........oooOO0OOooo........oo << 
374                                                << 
375 void DetectorConstruction::SetEcalLength(G4dou << 
376 {                                              << 
377   if (val > 0.0) {                             << 
378     fEcalLength = val;                         << 
379     G4RunManager::GetRunManager()->GeometryHas << 
380   }                                            << 
381 }                                              << 
382                                                << 
383 //....oooOO0OOooo........oooOO0OOooo........oo << 
384                                                << 
385 void DetectorConstruction::SetEcalWidth(G4doub << 
386 {                                              << 
387   if (val > 0.0) {                             << 
388     fEcalWidth = val;                          << 
389     G4RunManager::GetRunManager()->GeometryHas << 
390   }                                            << 
391 }                                              << 
392                                                << 
393 //....oooOO0OOooo........oooOO0OOooo........oo << 
394                                                << 
395 void DetectorConstruction::SetVertexLength(G4d << 
396 {                                              << 
397   if (val > 0.0) {                             << 
398     fVertexLength = val;                       << 
399     G4RunManager::GetRunManager()->GeometryHas << 
400   }                                            << 
401 }                                              << 
402                                                << 
403 //....oooOO0OOooo........oooOO0OOooo........oo << 
404                                                << 
405 void DetectorConstruction::SetPadLength(G4doub << 
406 {                                              << 
407   if (val > 0.0) {                             << 
408     fPadLength = val;                          << 
409     G4RunManager::GetRunManager()->GeometryHas << 
410   }                                            << 
411 }                                              << 
412                                                << 
413 //....oooOO0OOooo........oooOO0OOooo........oo << 
414                                                << 
415 void DetectorConstruction::SetPadWidth(G4doubl << 
416 {                                              << 
417   if (val > 0.0) {                             << 
418     fPadWidth = val;                           << 
419     G4RunManager::GetRunManager()->GeometryHas << 
420   }                                            << 
421 }                                              << 
422                                                << 
423 //....oooOO0OOooo........oooOO0OOooo........oo << 
424                                                << 
425 void DetectorConstruction::SetAbsLength(G4doub << 
426 {                                              << 
427   if (val > 0.0) {                             << 
428     fAbsLength = val;                          << 
429     G4RunManager::GetRunManager()->GeometryHas << 
430   }                                            << 
431 }                                                 333 }
432                                                   334 
433 //....oooOO0OOooo........oooOO0OOooo........oo    335 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
434                                                   336