Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RandomDetector.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 //
30 // $Id$
31 //
32 //
33 // --------------------------------------------------------------
34 // RandomDetector
35 //
36 // Author: Martin Liendl - Martin.Liendl@cern.ch
37 //
38 // --------------------------------------------------------------
39 //
40 #include "globals.hh"
41 #include "Randomize.hh"
42 #include "G4PVPlacement.hh"
43 #include "G4LogicalVolume.hh"
44 #include "G4Box.hh"
45 #include "G4Material.hh"
46 #include "G4SystemOfUnits.hh"
47 
48 #include "RandomDetector.hh"
49 
50 //RandomDetector::RandomDetector(G4int levels, G4int perLevel, G4double prop)
51 
53  : levels_(0),
54  perLevel_(0),
55  overlapProp_(prop),
56  worldDim_(10.*m)
57 {
58 }
59 
60 
62 {
63 }
64 
65 
67 {
68  // Material: only one for all volumes ...
69  G4double density = 1.390*g/cm3;
70  G4double a = 39.95*g/mole;
71  G4Material* lAr = new G4Material("liquidArgon", 18., a, density);
72 
73  // world volume
74  G4double halfDim = worldDim_/2.;
75  G4Box * aWorldBox = new G4Box("WorldBox", halfDim, halfDim, halfDim);
76  G4LogicalVolume * aWorldLV = new G4LogicalVolume(aWorldBox, lAr, "WorldLV");
77 
78  // 2 daughters, overlapping with prop. p (protruding parent or each other)
79  // G4double outer = sqrt(3.*halfDim*halfDim);
80  G4double inner = halfDim;
81  G4double childDim = halfDim/3.;
82  G4double childRad = std::sqrt(3.*childDim*childDim);
83  G4Box * aChildBox = new G4Box("ChildBox", childDim, childDim, childDim);
84  G4LogicalVolume * child1 = new G4LogicalVolume(aChildBox, lAr, "Child_1_LV");
85  G4LogicalVolume * child2 = new G4LogicalVolume(aChildBox, lAr, "Child_2_LV");
86 
87  G4bool parentOverlap = G4UniformRand() < overlapProp_ ? true : false;
88  G4bool childOverlap = G4UniformRand() < overlapProp_ ? true : false;
89 
90  G4ThreeVector ax1(1.,1.,1.);
91  G4RotationMatrix * rm1 = new G4RotationMatrix(ax1,30.*deg);
92  G4ThreeVector ax2(0.2,-1.,0.45);
93  G4RotationMatrix * rm2 = new G4RotationMatrix(ax2,70.*deg);
94 
95  G4double t1 = G4UniformRand()*180.*deg;
96  G4double p1 = G4UniformRand()*360.*deg;
97  G4double t2 = G4UniformRand()*180.*deg;
98  G4double p2 = G4UniformRand()*360.*deg;
99  G4double r1, r2;
100 
101  if (parentOverlap)
102  {
103  r1 = inner - childRad/3.;
104  }
105  else
106  {
107  r1 = inner - childRad - childRad/5.;
108  }
109 
110  r2 = inner - childRad - childRad/5.;
111 
112  if (childOverlap)
113  {
114  t2 = t1;
115  p2 = p1;
116  }
117 
118  G4ThreeVector tr1( r1*std::cos(p1)*std::sin(t1), r1*std::sin(p1)*std::sin(t1), r1*std::cos(t1));
119  G4ThreeVector tr2( r2*std::cos(p2)*std::sin(t2), r2*std::sin(p2)*std::sin(t2), r2*std::cos(t2));
120 
121  new G4PVPlacement(rm1,tr1,child1,"Child_1",aWorldLV,false,1);
122  new G4PVPlacement(rm2,tr2,child2,"Child_2",aWorldLV,false,2);
123  return new G4PVPlacement(0,G4ThreeVector(),aWorldLV,"Random",0,false,1);
124 }
125