WCSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WCSimDetectorConstruction.cc
Go to the documentation of this file.
4 
5 #include "G4Material.hh"
6 #include "G4Element.hh"
7 #include "G4Box.hh"
8 #include "G4LogicalVolume.hh"
9 #include "G4VPhysicalVolume.hh"
10 #include "G4PVPlacement.hh"
11 #include "G4ThreeVector.hh"
12 #include "globals.hh"
13 #include "G4VisAttributes.hh"
14 
15 #include "G4RunManager.hh"
16 #include "G4PhysicalVolumeStore.hh"
17 #include "G4LogicalVolumeStore.hh"
18 #include "G4SolidStore.hh"
19 
20 #include "G4PhysicalConstants.hh"
21 #include "G4SystemOfUnits.hh"
22 
23 std::map<int, G4Transform3D> WCSimDetectorConstruction::tubeIDMap;
24 std::map<int, G4Transform3D> WCSimDetectorConstruction::ODtubeIDMap;
25 //std::map<int, cyl_location> WCSimDetectorConstruction::tubeCylLocation;
26 hash_map<std::string, int, hash<std::string> > WCSimDetectorConstruction::tubeLocationMap;
27 hash_map<std::string, int, hash<std::string> > WCSimDetectorConstruction::ODtubeLocationMap;
28 
29 WCSimDetectorConstruction::WCSimDetectorConstruction(G4int DetConfig,WCSimTuningParameters* WCSimTuningPars):WCSimTuningParams(WCSimTuningPars)
30 {
31 
32  // Decide if (only for the case of !1kT detector) should be upright or horizontal
33  isUpright = false;
34  isEggShapedHyperK = false;
35 
36  debugMode = false;
37 
38  isODConstructed = false;
39 
40  myConfiguration = DetConfig;
41 
42  //-----------------------------------------------------
43  // Create Materials
44  //-----------------------------------------------------
45 
47 
48  //-----------------------------------------------------
49  // Initialize things related to the tubeID
50  //-----------------------------------------------------
51 
54  //WCSimDetectorConstruction::tubeCylLocation.clear();// (JF) Removed
58  totalNumPMTs = 0;
59  totalNumODPMTs = 0;
61  //-----------------------------------------------------
62  // Set the default WC geometry. This can be changed later.
63  //-----------------------------------------------------
64 
66  //SetHyperKGeometry();
67 
68  //-----------------------------------------------------
69  // Set whether or not Pi0-specific info is saved
70  //-----------------------------------------------------
71 
72  SavePi0Info(false);
73 
74  //-----------------------------------------------------
75  // Set the default method for implementing the PMT QE
76  //-----------------------------------------------------
78 
79  //default is to use collection efficiency
80  SetPMT_Coll_Eff(1);
81  // set default visualizer to OGLSX
82  SetVis_Choice("OGLSX");
83 
84  //-----------------------------------------------------
85  // Make the detector messenger to allow changing geometry
86  //-----------------------------------------------------
87 
89 }
90 
91 #include "G4GeometryManager.hh"
92 #include "G4LogicalBorderSurface.hh"
93 #include "G4LogicalSkinSurface.hh"
94 
96 {
97 
98 
99  G4bool geomChanged = true;
100  G4RunManager::GetRunManager()->DefineWorldVolume(Construct(), geomChanged);
101 
102  }
103 
104 
105 
107  for (unsigned int i=0;i<fpmts.size();i++){
108  delete fpmts.at(i);
109  }
110  fpmts.clear();
111  for (unsigned int i=0;i<fODpmts.size();i++){
112  delete fODpmts.at(i);
113  }
114  fODpmts.clear();
115 }
116 
118 {
119  G4GeometryManager::GetInstance()->OpenGeometry();
120 
121  G4PhysicalVolumeStore::GetInstance()->Clean();
122  G4LogicalVolumeStore::GetInstance()->Clean();
123  G4SolidStore::GetInstance()->Clean();
124  G4LogicalBorderSurface::CleanSurfaceTable();
125  G4LogicalSkinSurface::CleanSurfaceTable();
127 
128  totalNumPMTs = 0;
129  totalNumODPMTs = 0;
130 
131  //-----------------------------------------------------
132  // Create Logical Volumes
133  //-----------------------------------------------------
134 
135  // First create the logical volumes of the sub detectors. After they are
136  // created their size will be used to make the world volume.
137  // Note the order is important because they rearrange themselves depending
138  // on their size and detector ordering.
139 
140  G4LogicalVolume* logicWCBox;
141  // Select between egg-shaped HyperK and cylinder
142  if (isEggShapedHyperK) logicWCBox = ConstructEggShapedHyperK();
143  else logicWCBox = ConstructCylinder();
144 
145  G4cout << " WCLength = " << WCLength/m << " m"<< G4endl;
146 
147  //-------------------------------
148 
149  // Now make the detector Hall. The lengths of the subdectors
150  // were set above.
151 
152  G4double expHallLength = 3.*WCLength; //jl145 - extra space to simulate cosmic muons more easily
153 
154  G4cout << " expHallLength = " << expHallLength / m << G4endl;
155  G4double expHallHalfLength = 0.5*expHallLength;
156 
157  G4Box* solidExpHall = new G4Box("expHall",
158  expHallHalfLength,
159  expHallHalfLength,
160  expHallHalfLength);
161 
162  G4LogicalVolume* logicExpHall =
163  new G4LogicalVolume(solidExpHall,
164  G4Material::GetMaterial("Vacuum"),
165  "expHall",
166  0,0,0);
167 
168  // Now set the visualization attributes of the logical volumes.
169 
170  // logicWCBox->SetVisAttributes(G4VisAttributes::Invisible);
171  logicExpHall->SetVisAttributes(G4VisAttributes::Invisible);
172 
173  //-----------------------------------------------------
174  // Create and place the physical Volumes
175  //-----------------------------------------------------
176 
177  // Experimental Hall
178  G4VPhysicalVolume* physiExpHall =
179  new G4PVPlacement(0,G4ThreeVector(),
180  logicExpHall,
181  "expHall",
182  0,false,0,true);
183 
184  // Water Cherenkov Detector (WC) mother volume
185  // WC Box, nice to turn on for x and y views to provide a frame:
186 
187  //G4RotationMatrix* rotationMatrix = new G4RotationMatrix;
188  //rotationMatrix->rotateX(90.*deg);
189  //rotationMatrix->rotateZ(90.*deg);
190 
191  G4ThreeVector genPosition = G4ThreeVector(0., 0., WCPosition);
192  G4VPhysicalVolume* physiWCBox =
193  new G4PVPlacement(0,
194  genPosition,
195  logicWCBox,
196  "WCBox",
197  logicExpHall,
198  false,
199  0);
200 
201  // Reset the tubeID and tubeLocation maps before refiling them
202  tubeIDMap.clear();
203  tubeLocationMap.clear();
204  ODtubeIDMap.clear();
205  ODtubeLocationMap.clear();
206 
207 
208  // Traverse and print the geometry Tree
209 
210  // TraverseReplicas(physiWCBox, 0, G4Transform3D(),
211  // &WCSimDetectorConstruction::PrintGeometryTree) ;
212 
213  TraverseReplicas(physiWCBox, 0, G4Transform3D(),
215 
216 
217  TraverseReplicas(physiWCBox, 0, G4Transform3D(),
219 
221 
222  // Return the pointer to the physical experimental hall
223  return physiExpHall;
224 }
225 
226 WCSimPMTObject *WCSimDetectorConstruction::CreatePMTObject(G4String PMTType, G4String CollectionName)
227 {
228  if (PMTType == "PMT20inch"){
229  WCSimPMTObject* PMT = new PMT20inch;
230  WCSimDetectorConstruction::SetPMTPointer(PMT, CollectionName);
231  return PMT;
232  }
233  else if (PMTType == "PMT8inch"){
234  WCSimPMTObject* PMT = new PMT8inch;
235  WCSimDetectorConstruction::SetPMTPointer(PMT, CollectionName);
236  return PMT;
237  }
238  else if (PMTType == "PMT10inch"){
239  WCSimPMTObject* PMT = new PMT10inch;
240  WCSimDetectorConstruction::SetPMTPointer(PMT, CollectionName);
241  return PMT;
242  }
243  else if (PMTType == "PMT10inchHQE"){
244  WCSimPMTObject* PMT = new PMT10inchHQE;
245  WCSimDetectorConstruction::SetPMTPointer(PMT, CollectionName);
246  return PMT;
247  }
248  else if (PMTType == "PMT12inchHQE"){
249  WCSimPMTObject* PMT = new PMT12inchHQE;
250  WCSimDetectorConstruction::SetPMTPointer(PMT, CollectionName);
251  return PMT;
252  }
253  else if (PMTType == "HPD20inchHQE"){
254  WCSimPMTObject* PMT = new HPD20inchHQE;
255  WCSimDetectorConstruction::SetPMTPointer(PMT, CollectionName);
256  return PMT;
257  }
258  else if (PMTType == "HPD12inchHQE"){
259  WCSimPMTObject* PMT = new HPD12inchHQE;
260  WCSimDetectorConstruction::SetPMTPointer(PMT, CollectionName);
261  return PMT;
262  }
263  else if (PMTType == "BoxandLine20inchHQE"){
265  WCSimDetectorConstruction::SetPMTPointer(PMT, CollectionName);
266  return PMT;
267  }
268  else if (PMTType == "BoxandLine12inchHQE"){
270  WCSimDetectorConstruction::SetPMTPointer(PMT, CollectionName);
271  return PMT;
272  }
273  else if (PMTType == "PMT5inch"){
274  WCSimPMTObject* PMT = new PMT5inch;
275  WCSimDetectorConstruction::SetPMTPointer(PMT, CollectionName);
276  return PMT;
277  }
278  else if (PMTType == "PMT3inch"){
279  WCSimPMTObject* PMT = new PMT3inch;
280  WCSimDetectorConstruction::SetPMTPointer(PMT, CollectionName);
281  return PMT;
282  }
283 
284  else { G4cout << PMTType << " is not a recognized PMT Type. Exiting WCSim." << G4endl; exit(1);}
285 }
286 
288 {
290  wcopt->SetSavePi0(pi0Info_isSaved);
292  wcopt->SetPMTCollEff(PMT_Coll_Eff);
294 }
std::vector< WCSimPmtInfo * > fpmts
void SetSavePi0(bool iSavePi0)
void DescribeAndRegisterPMT(G4VPhysicalVolume *, int, int, const G4Transform3D &)
G4LogicalVolume * ConstructCylinder()
void SetGeomHasOD(bool iGeomHasOD)
void SaveOptionsToOutput(WCSimRootOptions *wcopt)
void SetDetectorName(string iDetectorName)
WCSimDetectorConstruction(G4int DetConfig, WCSimTuningParameters *WCSimTuningPars)
void SetPMTQEMethod(bool iPMTQEMethod)
void SetPMTPointer(WCSimPMTObject *PMT, G4String CollectionName)
WCSimPMTObject * CreatePMTObject(G4String, G4String)
static hash_map< std::string, int, hash< std::string > > ODtubeLocationMap
void GetWCGeom(G4VPhysicalVolume *, int, int, const G4Transform3D &)
void TraverseReplicas(G4VPhysicalVolume *, int, const G4Transform3D &, DescriptionFcnPtr)
static std::map< int, G4Transform3D > ODtubeIDMap
std::vector< WCSimPmtInfo * > fODpmts
static std::map< int, G4Transform3D > tubeIDMap
void SetPMTCollEff(bool iPMTCollEff)
WCSimDetectorMessenger * messenger
static hash_map< std::string, int, hash< std::string > > tubeLocationMap