WCSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WCSimDetectorConstruction.hh
Go to the documentation of this file.
1 #ifndef WCSimDetectorConstruction_H
2 #define WCSimDetectorConstruction_H 1
3 
4 #include "WCSimPmtInfo.hh"
5 #include "WCSimPMTObject.hh"
6 #include "WCSimRootOptions.hh"
7 
8 #include "G4Transform3D.hh"
9 #include "G4VUserDetectorConstruction.hh"
10 #include "G4LogicalVolume.hh"
11 #include "G4VPhysicalVolume.hh"
12 #include "G4OpticalSurface.hh"
13 #include "globals.hh"
14 
15 #include <fstream>
16 #include <map>
17 #include <vector>
18 //#include <hash_map.h>
19 // warning : hash_map is not part of the standard
20 #include <ext/hash_map>
21 
22 
23 using __gnu_cxx::hash;
24 using __gnu_cxx::hashtable;
25 using __gnu_cxx::hash_map;
26 using __gnu_cxx::hash_multimap;
27 
28 // (JF) We don't need this distinction for DUSEL
29 //enum cyl_location {endcap1,wall,endcap2};
30 
31 class G4Box;
32 class G4Tubs;
33 class G4Material;
34 class G4LogicalVolume;
35 class G4AssemblyVolume;
36 class G4VPhysicalVolume;
39 class WCSimWCSD;
40 
41 namespace __gnu_cxx {
42  template<> struct hash< std::string >
43  {
44  size_t operator()( const std::string& x ) const
45  {
46  return hash< const char* >()( x.c_str() );
47  }
48  };
49 }
50 
51 void ComputeWCODPMT(G4int NPMT, G4double *NPMTHorizontal, G4double *NPMTVertical);
52 
53 class WCSimDetectorConstruction : public G4VUserDetectorConstruction
54 {
55 public:
56 
57  WCSimDetectorConstruction(G4int DetConfig,WCSimTuningParameters* WCSimTuningPars);
59 
61 
62  G4VPhysicalVolume* Construct();
63 
64  // Related to the WC geometry
65  void SetSuperKGeometry();
73  void SetHyperKGeometry();
76  void UpdateGeometry();
77  void SetLCType(G4int LightCollectorType)
78  {
79  LCType=LightCollectorType;
80  };
81  G4int GetLCType(){return LCType;};
82 
83  G4String GetDetectorName() {return WCDetectorName;}
84  G4double GetWaterTubeLength() {return WCLength;}
85  G4double GetWaterTubePosition() {return WCPosition;}
86  G4double GetPMTSize() {return WCPMTRadius;}
87  G4double GetODPMTSize() {return WCPMTODRadius;}
88  G4String GetPMTName() {return WCPMTName;}
90  G4double GetGeo_Dm(G4int);
91  G4int GetTotalNumPmts() {return totalNumPMTs;}
93 
95  G4double GetwaterTank_Length() {return waterTank_Length;}
96  G4int UsePMT_Coll_Eff(){return PMT_Coll_Eff;}
97 
98  G4double GetPMTSize1() {return WCPMTSize;}
99 
100  G4double GetPMTQE(G4String,G4double, G4int, G4double, G4double, G4double);
101  G4double GetPMTCollectionEfficiency(G4double theta_angle, G4String CollectionName) { return GetPMTPointer(CollectionName)->GetCollectionEfficiency(theta_angle); };
102 
103  WCSimPMTObject *CreatePMTObject(G4String, G4String);
104 
105  std::map<G4String, WCSimPMTObject*> CollectionNameMap;
107 
108  void SetPMTPointer(WCSimPMTObject* PMT, G4String CollectionName){
109  CollectionNameMap[CollectionName] = PMT;
110  }
111 
112  WCSimPMTObject* GetPMTPointer(G4String CollectionName){
113  PMTptr = CollectionNameMap[CollectionName];
114  if (PMTptr == NULL) {G4cout << CollectionName << " is not a recognized hit collection. Exiting WCSim." << G4endl; exit(1);}
115  return PMTptr;
116  }
117 
118  G4ThreeVector GetWCOffset(){return WCOffset;}
119 
120  // Related to the WC tube ID
121  static G4int GetTubeID(std::string tubeTag){return tubeLocationMap[tubeTag];}
122  static G4Transform3D GetTubeTransform(int tubeNo){return tubeIDMap[tubeNo];}
123  // OD PMTs
124  static G4int GetODTubeID(std::string tubeTag){return ODtubeLocationMap[tubeTag];}
125  static G4Transform3D GetODTubeTransform(int tubeNo){return ODtubeIDMap[tubeNo];}
126 
127  // Related to Pi0 analysis
128  G4bool SavePi0Info() {return pi0Info_isSaved;}
129  void SavePi0Info(G4bool choice) {pi0Info_isSaved=choice;}
130 
131  void SetPMT_QE_Method(G4int choice){PMT_QE_Method = choice;}
132  void SetPMT_Coll_Eff(G4int choice){PMT_Coll_Eff = choice;}
133  void SetVis_Choice(G4String choice){Vis_Choice = choice;}
134  G4String GetVis_Choice() {return Vis_Choice;}
135 
136  //Partition Length
137  void SetwaterTank_Length(G4double length){waterTank_Length = length;}
138  void SetWaterTubeLength(G4double length){WCLength = length;}
139  // Geometry options
140  void SetIsUpright(G4bool choice) {isUpright = choice;}
141 
142  // *** Begin Egg-Shaped HyperK Geometry ***
143 
144  void SetIsEggShapedHyperK(G4bool choice) {isEggShapedHyperK = choice;}
146 
149 
150 
151  // *** End Egg-Shaped HyperK Geometry ***
152 
153  std::vector<WCSimPmtInfo*>* Get_Pmts() {return &fpmts;}
154  std::vector<WCSimPmtInfo*>* Get_ODPmts() {return &fODpmts;}
155 
158 
160 
161  G4double GetIDRadius() {return WCIDRadius;}
162  G4double GetIDHeight() {return WCIDHeight;}
163 
164 private:
165 
166  // Tuning parameters
167 
169 
170  // Sensitive Detectors. We declare the pointers here because we need
171  // to check their state if we change the geometry, otherwise will segfault
172  // between events!
174 
175  //Water, Blacksheet surface
176  G4OpticalSurface * OpWaterBSSurface;
177 
178  //Glass, Cathode surface in PMTs
179 
180  G4OpticalSurface * OpGlassCathodeSurface;
181 
182  //Tyvek surface - jl145
183  G4OpticalSurface * OpWaterTySurface;
184 
185  // The messenger we use to change the geometry.
186 
188 
189  // The Construction routines
190  G4LogicalVolume* ConstructCylinder();
191  G4LogicalVolume* ConstructPMT(G4String,G4String,G4String detectorElement="tank");
192 
193  G4LogicalVolume* ConstructCaps(G4int zflip);
194 
195  void ConstructMaterials();
196 
197  G4LogicalVolume* logicWCBarrelCellODTyvek;
198  G4LogicalVolume* logicWCTowerODTyvek;
199 
200  G4LogicalVolume* logicWCBarrelCellODWLSPlate;
201  G4LogicalVolume* logicWCTowerODWLSPlate;
202 
203  G4LogicalVolume* logicWCBarrelCellBlackSheet;
204  G4LogicalVolume* logicWCTowerBlackSheet;
206 
207  G4bool WCAddGd;
208 
209  // Code for traversing the geometry and assigning tubeIDs.
210 
211  // First make a typedef for the pointer to the member fcn. The
212  // syntax is too wacked out to be using all over.
213 
215  (G4VPhysicalVolume*, int, int, const G4Transform3D&);
216 
217  // Now Funcs for traversing the geometry
218  void TraverseReplicas(G4VPhysicalVolume*, int, const G4Transform3D&,
220 
221  void DescribeAndDescendGeometry(G4VPhysicalVolume*, int, int,
222  const G4Transform3D&, DescriptionFcnPtr);
223 
224  // Functions that the traversal routines call or we use to manipulate the
225  // data we accumulate.
227 
228  void PrintGeometryTree(G4VPhysicalVolume*, int, int, const G4Transform3D&);
229  void DescribeAndRegisterPMT(G4VPhysicalVolume*, int, int,
230  const G4Transform3D&);
231  void DescribeAndRegisterPMT_1KT(G4VPhysicalVolume*, int, int,
232  const G4Transform3D&);
233  void GetWCGeom(G4VPhysicalVolume*, int, int,
234  const G4Transform3D&);
235 
236  //---Volume lengths
237 
238  // These are shared between the different member functions
239  // constructWC, constructFGD, constructlArD, constuctMRD
240  // toggle between FGD(0) and lArD(1)
241  // toggle between lArD readout types
242  // toggle between MRDScint and MRDk2k
243 
245 
246 
247  // XQ 08/17/10
248  // PMT_QE_Method == 1
249  // Only use it in the stacking function (no WLS)
250  // PMT_QE_Method == 2
251  // Use Part of it in the stacking function (MAX QE)
252  // Put the rest of it in the sensitive detector according to QE/Max_QE
253  // PMT_QE_Method == 3
254  // Put all of it in the sensitive detector according to QE
255  // Good for low energy photons
257 
258  //XQ 03/31/11
259  // 0 to not use collection efficiency
260  // 1 to use
262 
263  //NP 06/17/15
264  // "OGLSX" for classic visualization
265  // "RayTracer" for RayTracer visualization
266  G4String Vis_Choice;
267 
268 
269  G4double WCLength;
270 
271  G4double WCPosition;
272 
273  // Hit collection name parameters
274  G4String WCDetectorName;
276 
277  // WC PMT parameters
278  G4String WCPMTName;
279  typedef std::pair<G4String, G4String> PMTKey_t;
280  typedef std::map<PMTKey_t, G4LogicalVolume*> PMTMap_t;
281 
283 
284  // WC geometry parameters
285 
286  G4double WCPMTRadius;
289 
290  G4double WCIDDiameter;
291 
292  G4double WCCapLength;
293  G4double WCBackODLength;
294  G4double WCFrontODLength;
295  G4double WCIDHeight;
296 
298 
300  G4double WCBarrelNRings;
303 
305 
307  G4double WCCapPMTSpacing;
308  G4double WCCapEdgeWidth;//jh TODO: not used
309 
310  G4double WCCapEdgeLimit;
312 
313  // ################### //
314  // # Cave parameters # //
315  // ################### //
316 
318 
319  // ############################### //
320  // # *** END Cave Parameters *** # //
321  // ############################### //
322 
323  // ############################# //
324  // # Outer Detector parameters # //
325  // ############################# //
326 
328 
329  // Parameters controlled by user
330  G4double WCODDiameter;
336  G4double WCODDeadSpace;
338 
341 
342  G4double WCODPMTShift;
343 
344  // We just need these variables to be global, ease things
345  G4double WCODRadius;
347 
348  // OD PMTs parameters
349  G4String WCPMTODName;
350  G4double WCPMTODRadius;
352 
353  // Hit collection name parameters
355 
356  // ############################# //
357  // # *** END OD Parameters *** # //
358  // ############################# //
359 
360  // raise scope of derived parameters
361  G4double WCIDRadius;
362  G4double totalAngle;
363  G4double dPhi;
368  G4String water;
369 
370 
371  //for 1kt
372  G4double WCDiameter;
373  G4double WCRadius;
377  G4double WCCapNCell;
378  G4double WCBarrelLength;
379 
380  // amb79: to universally make changes in structure and geometry
381  bool isUpright;
382 
383  // *** Begin egg-shaped HyperK Geometry ***
384 
386  G4LogicalVolume* ConstructEggShapedHyperK();
387 
388  G4Material* FindMaterial(G4String);
389 
390  G4VSolid* ConstructHalf(G4double, G4double);
391 
392  G4LogicalVolume* ConstructRadialPMT(G4bool,
393  G4double, G4double,
394  G4double, G4double,
395  G4double, G4double);
396 
397  G4LogicalVolume* ConstructEndWallPMT();
398 
399  G4LogicalVolume* ConstructCeilingPMT(G4bool,
400  G4double, G4double,
401  G4double, G4double);
402 
404 
405  G4double waterTank_TopR;
406  G4double waterTank_BotR;
411 
412  G4double innerPMT_TopR;
413  G4double innerPMT_BotR;
414  G4double innerPMT_TopW;
415  G4double innerPMT_BotW;
416  G4double innerPMT_Height;
417  G4double innerPMT_Radius;
418  G4double innerPMT_Expose;
419  G4double innerPMT_Rpitch;
420  G4double innerPMT_Apitch;
421 
422  G4double outerPMT_TopR;
423  G4double outerPMT_BotR;
424  G4double outerPMT_TopW;
425  G4double outerPMT_BotW;
426  G4double outerPMT_Height;
427  G4double outerPMT_Radius;
428  G4double outerPMT_Expose;
429  G4String outerPMT_Name;
432  G4double outerPMT_Apitch;
433 
435 
438 
440  G4LogicalVolume* waterTankLV;
441 
442  G4int PMTCopyNo;
444 
445  G4int LCType; // 0: No LC, 1: Old Branch(Mirror), 2: 2018Oct(Mirror)
446 
447  // *** End egg-shaped HyperK Geometry ***
448 
449  // amb79: debug to display all parts
450  bool debugMode;
451 
452  // Variables related to the geometry
453 
454  std::ofstream geoFile; // File for text output
455 
456  G4int totalNumPMTs; // The number of PMTs for this configuration
457  G4int totalNumODPMTs; // The number of PMTs for this configuration
458  G4double WCCylInfo[3]; // Info for the geometry tree: radius & length or mail box, length, width and depth
459  G4double WCPMTSize; // Info for the geometry tree: pmt size
460  G4ThreeVector WCOffset; // Info for the geometry tree: WC center offset
461 
462  // Tube map information
463 
464  static std::map<int, G4Transform3D> tubeIDMap;
465 // static std::map<int, cyl_location> tubeCylLocation;
466  static hash_map<std::string, int, hash<std::string> > tubeLocationMap;
467 
468  // OD PMTs
469  static std::map<int, G4Transform3D> ODtubeIDMap;
470  static hash_map<std::string, int, hash<std::string> > ODtubeLocationMap;
471 
472  // Variables related to configuration
473 
474  G4int myConfiguration; // Detector Config Parameter
475  G4double innerradius;
476 
477  std::vector<WCSimPmtInfo*> fpmts;
478  std::vector<WCSimPmtInfo*> fODpmts;
479 
480 };
481 
482 #endif
483 
virtual G4double GetCollectionEfficiency(double)
G4LogicalVolume * ConstructPMT(G4String, G4String, G4String detectorElement="tank")
std::vector< WCSimPmtInfo * > fpmts
size_t operator()(const std::string &x) const
G4double GetPMTQE(G4String, G4double, G4int, G4double, G4double, G4double)
Definition: WCSimPMTQE.cc:21
G4VSolid * ConstructHalf(G4double, G4double)
void DescribeAndRegisterPMT(G4VPhysicalVolume *, int, int, const G4Transform3D &)
G4LogicalVolume * ConstructCylinder()
void SaveOptionsToOutput(WCSimRootOptions *wcopt)
static G4Transform3D GetODTubeTransform(int tubeNo)
static G4int GetODTubeID(std::string tubeTag)
WCSimDetectorConstruction(G4int DetConfig, WCSimTuningParameters *WCSimTuningPars)
void DescribeAndDescendGeometry(G4VPhysicalVolume *, int, int, const G4Transform3D &, DescriptionFcnPtr)
void PrintGeometryTree(G4VPhysicalVolume *, int, int, const G4Transform3D &)
static G4int GetTubeID(std::string tubeTag)
WCSimPMTObject * GetPMTPointer(G4String CollectionName)
WCSimTuningParameters * WCSimTuningParams
G4double GetPMTCollectionEfficiency(G4double theta_angle, G4String CollectionName)
G4LogicalVolume * ConstructCaps(G4int zflip)
void ComputeWCODPMT(G4int NPMT, G4double *NPMTHorizontal, G4double *NPMTVertical)
std::map< G4String, WCSimPMTObject * > CollectionNameMap
void SetPMTPointer(WCSimPMTObject *PMT, G4String CollectionName)
static G4Transform3D GetTubeTransform(int tubeNo)
std::map< PMTKey_t, G4LogicalVolume * > PMTMap_t
void SetwaterTank_Length(G4double length)
void(WCSimDetectorConstruction::* DescriptionFcnPtr)(G4VPhysicalVolume *, int, int, const G4Transform3D &)
WCSimPMTObject * CreatePMTObject(G4String, G4String)
void SetLCType(G4int LightCollectorType)
static hash_map< std::string, int, hash< std::string > > ODtubeLocationMap
void GetWCGeom(G4VPhysicalVolume *, int, int, const G4Transform3D &)
void TraverseReplicas(G4VPhysicalVolume *, int, const G4Transform3D &, DescriptionFcnPtr)
G4LogicalVolume * ConstructRadialPMT(G4bool, G4double, G4double, G4double, G4double, G4double, G4double)
void SetWaterTubeLength(G4double length)
static std::map< int, G4Transform3D > ODtubeIDMap
std::vector< WCSimPmtInfo * > fODpmts
std::vector< WCSimPmtInfo * > * Get_Pmts()
std::vector< WCSimPmtInfo * > * Get_ODPmts()
static std::map< int, G4Transform3D > tubeIDMap
G4LogicalVolume * ConstructCeilingPMT(G4bool, G4double, G4double, G4double, G4double)
void DescribeAndRegisterPMT_1KT(G4VPhysicalVolume *, int, int, const G4Transform3D &)
std::pair< G4String, G4String > PMTKey_t
WCSimDetectorMessenger * messenger
static hash_map< std::string, int, hash< std::string > > tubeLocationMap