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[ 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/optical/OpNovice2/src/DetectorConstruction.cc (Version 11.3.0) and /examples/extended/optical/OpNovice2/src/DetectorConstruction.cc (Version 10.7.p1)


  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 optical/OpNovice2/src/DetectorConstr     26 /// \file optical/OpNovice2/src/DetectorConstruction.cc
 27 /// \brief Implementation of the DetectorConst     27 /// \brief Implementation of the DetectorConstruction class
 28 //                                                 28 //
 29 //                                                 29 //
 30 //                                                 30 //
 31 //....oooOO0OOooo........oooOO0OOooo........oo     31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 32 //....oooOO0OOooo........oooOO0OOooo........oo     32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 33                                                    33 
 34 #include "DetectorConstruction.hh"                 34 #include "DetectorConstruction.hh"
 35                                                    35 
 36 #include "DetectorMessenger.hh"                    36 #include "DetectorMessenger.hh"
 37                                                    37 
 38 #include "G4Box.hh"                            <<  38 #include "G4NistManager.hh"
                                                   >>  39 #include "G4Material.hh"
 39 #include "G4Element.hh"                            40 #include "G4Element.hh"
 40 #include "G4LogicalBorderSurface.hh"               41 #include "G4LogicalBorderSurface.hh"
 41 #include "G4LogicalSkinSurface.hh"                 42 #include "G4LogicalSkinSurface.hh"
 42 #include "G4LogicalVolume.hh"                  << 
 43 #include "G4Material.hh"                       << 
 44 #include "G4NistManager.hh"                    << 
 45 #include "G4OpticalSurface.hh"                     43 #include "G4OpticalSurface.hh"
                                                   >>  44 #include "G4Box.hh"
                                                   >>  45 #include "G4LogicalVolume.hh"
                                                   >>  46 #include "G4ThreeVector.hh"
 46 #include "G4PVPlacement.hh"                        47 #include "G4PVPlacement.hh"
 47 #include "G4SystemOfUnits.hh"                      48 #include "G4SystemOfUnits.hh"
 48 #include "G4ThreeVector.hh"                    << 
 49                                                    49 
 50 //....oooOO0OOooo........oooOO0OOooo........oo     50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 51                                                    51 
 52 DetectorConstruction::DetectorConstruction()       52 DetectorConstruction::DetectorConstruction()
 53   : G4VUserDetectorConstruction(), fDetectorMe <<  53   : G4VUserDetectorConstruction()
                                                   >>  54   , fDetectorMessenger(nullptr)
 54 {                                                  55 {
 55   fTankMPT = new G4MaterialPropertiesTable();  <<  56   fExpHall_x = fExpHall_y = fExpHall_z = 10.0 * m;
 56   fWorldMPT = new G4MaterialPropertiesTable(); <<  57   fTank_x = fTank_y = fTank_z = 1.0 * m;
                                                   >>  58 
                                                   >>  59   fTank = nullptr;
                                                   >>  60 
                                                   >>  61   fTankMPT    = new G4MaterialPropertiesTable();
                                                   >>  62   fWorldMPT   = new G4MaterialPropertiesTable();
 57   fSurfaceMPT = new G4MaterialPropertiesTable(     63   fSurfaceMPT = new G4MaterialPropertiesTable();
 58                                                    64 
 59   fSurface = new G4OpticalSurface("Surface");      65   fSurface = new G4OpticalSurface("Surface");
 60   fSurface->SetType(dielectric_dielectric);        66   fSurface->SetType(dielectric_dielectric);
 61   fSurface->SetFinish(ground);                     67   fSurface->SetFinish(ground);
 62   fSurface->SetModel(unified);                     68   fSurface->SetModel(unified);
 63   fSurface->SetMaterialPropertiesTable(fSurfac     69   fSurface->SetMaterialPropertiesTable(fSurfaceMPT);
 64                                                    70 
 65   fTankMaterial = G4NistManager::Instance()->F <<  71   fTank_LV  = nullptr;
                                                   >>  72   fWorld_LV = nullptr;
                                                   >>  73 
                                                   >>  74   fTankMaterial  = G4NistManager::Instance()->FindOrBuildMaterial("G4_WATER");
 66   fWorldMaterial = G4NistManager::Instance()->     75   fWorldMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR");
 67                                                    76 
 68   fDetectorMessenger = new DetectorMessenger(t     77   fDetectorMessenger = new DetectorMessenger(this);
 69 }                                                  78 }
 70                                                    79 
 71 //....oooOO0OOooo........oooOO0OOooo........oo     80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 72                                                    81 
 73 DetectorConstruction::~DetectorConstruction()  <<  82 DetectorConstruction::~DetectorConstruction() {
 74 {                                              << 
 75   delete fTankMPT;                                 83   delete fTankMPT;
 76   delete fWorldMPT;                                84   delete fWorldMPT;
 77   delete fSurfaceMPT;                              85   delete fSurfaceMPT;
 78   delete fSurface;                                 86   delete fSurface;
 79   delete fDetectorMessenger;                       87   delete fDetectorMessenger;
 80 }                                                  88 }
 81                                                    89 
 82 //....oooOO0OOooo........oooOO0OOooo........oo     90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 83                                                    91 
 84 G4VPhysicalVolume* DetectorConstruction::Const     92 G4VPhysicalVolume* DetectorConstruction::Construct()
 85 {                                                  93 {
 86   fTankMaterial->SetMaterialPropertiesTable(fT     94   fTankMaterial->SetMaterialPropertiesTable(fTankMPT);
 87   fTankMaterial->GetIonisation()->SetBirksCons     95   fTankMaterial->GetIonisation()->SetBirksConstant(0.126 * mm / MeV);
 88                                                    96 
 89   fWorldMaterial->SetMaterialPropertiesTable(f     97   fWorldMaterial->SetMaterialPropertiesTable(fWorldMPT);
 90                                                    98 
 91   // ------------- Volumes --------------          99   // ------------- Volumes --------------
 92   // The experimental Hall                        100   // The experimental Hall
 93   auto world_box = new G4Box("World", fExpHall << 101   G4Box* world_box = new G4Box("World", fExpHall_x, fExpHall_y, fExpHall_z);
 94                                                   102 
 95   fWorld_LV = new G4LogicalVolume(world_box, f << 103   fWorld_LV = new G4LogicalVolume(world_box, fWorldMaterial, "World", 0, 0, 0);
 96                                                   104 
 97   G4VPhysicalVolume* world_PV =                   105   G4VPhysicalVolume* world_PV =
 98     new G4PVPlacement(nullptr, G4ThreeVector() << 106     new G4PVPlacement(0, G4ThreeVector(), fWorld_LV, "World", 0, false, 0);
 99                                                   107 
100   // The tank                                     108   // The tank
101   auto tank_box = new G4Box("Tank", fTank_x, f << 109   G4Box* tank_box = new G4Box("Tank", fTank_x, fTank_y, fTank_z);
102                                                   110 
103   fTank_LV = new G4LogicalVolume(tank_box, fTa << 111   fTank_LV = new G4LogicalVolume(tank_box, fTankMaterial, "Tank", 0, 0, 0);
104                                                   112 
105   fTank = new G4PVPlacement(nullptr, G4ThreeVe << 113   fTank = new G4PVPlacement(0, G4ThreeVector(), fTank_LV, "Tank", fWorld_LV,
                                                   >> 114                             false, 0);
106                                                   115 
107   // ------------- Surface --------------         116   // ------------- Surface --------------
108                                                   117 
109   auto surface = new G4LogicalBorderSurface("S << 118   G4LogicalBorderSurface* surface =
                                                   >> 119     new G4LogicalBorderSurface("Surface", fTank, world_PV, fSurface);
110                                                   120 
111   auto opticalSurface =                        << 121   G4OpticalSurface* opticalSurface = dynamic_cast<G4OpticalSurface*>(
112     dynamic_cast<G4OpticalSurface*>(surface->G << 122     surface->GetSurface(fTank, world_PV)->GetSurfaceProperty());
113   G4cout << "******  opticalSurface->DumpInfo:    123   G4cout << "******  opticalSurface->DumpInfo:" << G4endl;
114   if (opticalSurface) {                        << 124   if(opticalSurface)
                                                   >> 125   {
115     opticalSurface->DumpInfo();                   126     opticalSurface->DumpInfo();
116   }                                               127   }
117   G4cout << "******  end of opticalSurface->Du    128   G4cout << "******  end of opticalSurface->DumpInfo" << G4endl;
118                                                   129 
119   return world_PV;                                130   return world_PV;
120 }                                                 131 }
121                                                   132 
122 //....oooOO0OOooo........oooOO0OOooo........oo    133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
123 void DetectorConstruction::SetSurfaceSigmaAlph    134 void DetectorConstruction::SetSurfaceSigmaAlpha(G4double v)
124 {                                                 135 {
125   fSurface->SetSigmaAlpha(v);                     136   fSurface->SetSigmaAlpha(v);
126   G4RunManager::GetRunManager()->GeometryHasBe    137   G4RunManager::GetRunManager()->GeometryHasBeenModified();
127                                                   138 
128   G4cout << "Surface sigma alpha set to: " <<  << 139   G4cout << "Surface sigma alpha set to: " << fSurface->GetSigmaAlpha()
                                                   >> 140          << G4endl;
129 }                                                 141 }
130                                                   142 
131 //....oooOO0OOooo........oooOO0OOooo........oo    143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
132 void DetectorConstruction::SetSurfacePolish(G4    144 void DetectorConstruction::SetSurfacePolish(G4double v)
133 {                                                 145 {
134   fSurface->SetPolish(v);                         146   fSurface->SetPolish(v);
135   G4RunManager::GetRunManager()->GeometryHasBe    147   G4RunManager::GetRunManager()->GeometryHasBeenModified();
136                                                   148 
137   G4cout << "Surface polish set to: " << fSurf    149   G4cout << "Surface polish set to: " << fSurface->GetPolish() << G4endl;
138 }                                                 150 }
139                                                   151 
140 //....oooOO0OOooo........oooOO0OOooo........oo    152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
141 void DetectorConstruction::AddTankMPV(const G4 << 153 void DetectorConstruction::AddTankMPV(const G4String& prop,
                                                   >> 154                                       G4MaterialPropertyVector* mpv)
142 {                                                 155 {
143   fTankMPT->AddProperty(prop, mpv);               156   fTankMPT->AddProperty(prop, mpv);
144   G4cout << "The MPT for the box is now: " <<     157   G4cout << "The MPT for the box is now: " << G4endl;
145   fTankMPT->DumpTable();                          158   fTankMPT->DumpTable();
146   G4cout << "............." << G4endl;            159   G4cout << "............." << G4endl;
147 }                                                 160 }
148                                                   161 
149 //....oooOO0OOooo........oooOO0OOooo........oo    162 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
150 void DetectorConstruction::AddWorldMPV(const G << 163 void DetectorConstruction::AddWorldMPV(const G4String& prop,
                                                   >> 164                                        G4MaterialPropertyVector* mpv)
151 {                                                 165 {
152   fWorldMPT->AddProperty(prop, mpv);              166   fWorldMPT->AddProperty(prop, mpv);
153   G4cout << "The MPT for the world is now: " <    167   G4cout << "The MPT for the world is now: " << G4endl;
154   fWorldMPT->DumpTable();                         168   fWorldMPT->DumpTable();
155   G4cout << "............." << G4endl;            169   G4cout << "............." << G4endl;
156 }                                                 170 }
157                                                   171 
158 //....oooOO0OOooo........oooOO0OOooo........oo    172 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
159 void DetectorConstruction::AddSurfaceMPV(const << 173 void DetectorConstruction::AddSurfaceMPV(const G4String& prop,
                                                   >> 174                                          G4MaterialPropertyVector* mpv)
160 {                                                 175 {
161   fSurfaceMPT->AddProperty(prop, mpv);            176   fSurfaceMPT->AddProperty(prop, mpv);
162   G4cout << "The MPT for the surface is now: "    177   G4cout << "The MPT for the surface is now: " << G4endl;
163   fSurfaceMPT->DumpTable();                       178   fSurfaceMPT->DumpTable();
164   G4cout << "............." << G4endl;            179   G4cout << "............." << G4endl;
165 }                                                 180 }
166                                                   181 
167 //....oooOO0OOooo........oooOO0OOooo........oo    182 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
168 void DetectorConstruction::AddTankMPC(const G4    183 void DetectorConstruction::AddTankMPC(const G4String& prop, G4double v)
169 {                                                 184 {
170   fTankMPT->AddConstProperty(prop, v);            185   fTankMPT->AddConstProperty(prop, v);
171   G4cout << "The MPT for the box is now: " <<     186   G4cout << "The MPT for the box is now: " << G4endl;
172   fTankMPT->DumpTable();                          187   fTankMPT->DumpTable();
173   G4cout << "............." << G4endl;            188   G4cout << "............." << G4endl;
174 }                                                 189 }
175                                                   190 
176 //....oooOO0OOooo........oooOO0OOooo........oo    191 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
177 void DetectorConstruction::AddWorldMPC(const G    192 void DetectorConstruction::AddWorldMPC(const G4String& prop, G4double v)
178 {                                                 193 {
179   fWorldMPT->AddConstProperty(prop, v);           194   fWorldMPT->AddConstProperty(prop, v);
180   G4cout << "The MPT for the world is now: " <    195   G4cout << "The MPT for the world is now: " << G4endl;
181   fWorldMPT->DumpTable();                         196   fWorldMPT->DumpTable();
182   G4cout << "............." << G4endl;            197   G4cout << "............." << G4endl;
183 }                                                 198 }
184 //....oooOO0OOooo........oooOO0OOooo........oo    199 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
185 void DetectorConstruction::AddSurfaceMPC(const    200 void DetectorConstruction::AddSurfaceMPC(const G4String& prop, G4double v)
186 {                                                 201 {
187   fSurfaceMPT->AddConstProperty(prop, v);         202   fSurfaceMPT->AddConstProperty(prop, v);
188   G4cout << "The MPT for the surface is now: "    203   G4cout << "The MPT for the surface is now: " << G4endl;
189   fSurfaceMPT->DumpTable();                       204   fSurfaceMPT->DumpTable();
190   G4cout << "............." << G4endl;            205   G4cout << "............." << G4endl;
191 }                                                 206 }
192                                                   207 
193 //....oooOO0OOooo........oooOO0OOooo........oo    208 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
194 void DetectorConstruction::SetWorldMaterial(co    209 void DetectorConstruction::SetWorldMaterial(const G4String& mat)
195 {                                                 210 {
196   G4Material* pmat = G4NistManager::Instance()    211   G4Material* pmat = G4NistManager::Instance()->FindOrBuildMaterial(mat);
197   if (pmat && fWorldMaterial != pmat) {        << 212   if(pmat && fWorldMaterial != pmat)
                                                   >> 213   {
198     fWorldMaterial = pmat;                        214     fWorldMaterial = pmat;
199     if (fWorld_LV) {                           << 215     if(fWorld_LV)
                                                   >> 216     {
200       fWorld_LV->SetMaterial(fWorldMaterial);     217       fWorld_LV->SetMaterial(fWorldMaterial);
201       fWorldMaterial->SetMaterialPropertiesTab    218       fWorldMaterial->SetMaterialPropertiesTable(fWorldMPT);
202     }                                             219     }
203     G4RunManager::GetRunManager()->PhysicsHasB    220     G4RunManager::GetRunManager()->PhysicsHasBeenModified();
204     G4cout << "World material set to " << fWor    221     G4cout << "World material set to " << fWorldMaterial->GetName() << G4endl;
205   }                                               222   }
206 }                                                 223 }
207                                                   224 
208 //....oooOO0OOooo........oooOO0OOooo........oo    225 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
209 void DetectorConstruction::SetTankMaterial(con    226 void DetectorConstruction::SetTankMaterial(const G4String& mat)
210 {                                                 227 {
211   G4Material* pmat = G4NistManager::Instance()    228   G4Material* pmat = G4NistManager::Instance()->FindOrBuildMaterial(mat);
212   if (pmat && fTankMaterial != pmat) {         << 229   if(pmat && fTankMaterial != pmat)
                                                   >> 230   {
213     fTankMaterial = pmat;                         231     fTankMaterial = pmat;
214     if (fTank_LV) {                            << 232     if(fTank_LV)
                                                   >> 233     {
215       fTank_LV->SetMaterial(fTankMaterial);       234       fTank_LV->SetMaterial(fTankMaterial);
216       fTankMaterial->SetMaterialPropertiesTabl    235       fTankMaterial->SetMaterialPropertiesTable(fTankMPT);
217       fTankMaterial->GetIonisation()->SetBirks    236       fTankMaterial->GetIonisation()->SetBirksConstant(0.126 * mm / MeV);
218     }                                             237     }
219     G4RunManager::GetRunManager()->PhysicsHasB    238     G4RunManager::GetRunManager()->PhysicsHasBeenModified();
220     G4cout << "Tank material set to " << fTank    239     G4cout << "Tank material set to " << fTankMaterial->GetName() << G4endl;
221   }                                               240   }
222 }                                                 241 }
223                                                   242