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 9.5)


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