source: trunk/examples/extended/geometry/olap/src/RandomDetector.cc @ 1337

Last change on this file since 1337 was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 4.4 KB
Line 
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//
26//
27// $Id: RandomDetector.cc,v 1.5 2006/06/29 17:23:16 gunter Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-01 $
29//
30//
31// --------------------------------------------------------------
32// RandomDetector
33//
34// Author: Martin Liendl - Martin.Liendl@cern.ch
35//
36// --------------------------------------------------------------
37//
38#include "globals.hh"
39#include "Randomize.hh"
40#include "G4PVPlacement.hh"
41#include "G4LogicalVolume.hh"
42#include "G4Box.hh"
43#include "G4Material.hh"
44
45#include "RandomDetector.hh"
46
47//RandomDetector::RandomDetector(G4int levels, G4int perLevel, G4double prop)
48
49RandomDetector::RandomDetector(G4double prop)
50 : levels_(0), 
51   perLevel_(0), 
52   overlapProp_(prop),
53   worldDim_(10.*m)
54{
55}
56 
57
58RandomDetector::~RandomDetector()
59{
60}
61
62
63G4VPhysicalVolume * RandomDetector::Construct()
64{
65  // Material: only one for all volumes ...
66  G4double density = 1.390*g/cm3;
67  G4double a = 39.95*g/mole;
68  G4Material* lAr = new G4Material("liquidArgon", 18., a, density);
69 
70  // world volume
71  G4double halfDim = worldDim_/2.;
72  G4Box * aWorldBox = new G4Box("WorldBox", halfDim, halfDim, halfDim);
73  G4LogicalVolume * aWorldLV = new G4LogicalVolume(aWorldBox, lAr, "WorldLV");
74 
75  // 2 daughters, overlapping with prop. p (protruding parent or each other)
76  // G4double outer = sqrt(3.*halfDim*halfDim);
77  G4double inner = halfDim;
78  G4double childDim = halfDim/3.;
79  G4double childRad = std::sqrt(3.*childDim*childDim);
80  G4Box * aChildBox = new G4Box("ChildBox", childDim, childDim, childDim);
81  G4LogicalVolume * child1 = new G4LogicalVolume(aChildBox, lAr, "Child_1_LV");
82  G4LogicalVolume * child2 = new G4LogicalVolume(aChildBox, lAr, "Child_2_LV");
83 
84  G4bool parentOverlap = G4UniformRand() < overlapProp_ ? true : false;
85  G4bool childOverlap  = G4UniformRand() < overlapProp_ ? true : false;
86 
87  G4ThreeVector ax1(1.,1.,1.);
88  G4RotationMatrix * rm1 = new G4RotationMatrix(ax1,30.*deg);
89  G4ThreeVector ax2(0.2,-1.,0.45);
90  G4RotationMatrix * rm2 = new G4RotationMatrix(ax2,70.*deg);
91 
92  G4double t1 = G4UniformRand()*180.*deg;
93  G4double p1 = G4UniformRand()*360.*deg;
94  G4double t2 = G4UniformRand()*180.*deg;
95  G4double p2 = G4UniformRand()*360.*deg;
96  G4double r1, r2;
97 
98  if (parentOverlap)
99  {
100    r1 = inner - childRad/3.; 
101  }
102  else
103  {
104    r1 = inner - childRad - childRad/5.;
105  }
106 
107  r2 = inner - childRad - childRad/5.;
108 
109  if (childOverlap)
110  {
111    t2 = t1;
112    p2 = p1;
113  }
114 
115  G4ThreeVector tr1( r1*std::cos(p1)*std::sin(t1), r1*std::sin(p1)*std::sin(t1), r1*std::cos(t1));
116  G4ThreeVector tr2( r2*std::cos(p2)*std::sin(t2), r2*std::sin(p2)*std::sin(t2), r2*std::cos(t2));
117 
118  new G4PVPlacement(rm1,tr1,child1,"Child_1",aWorldLV,false,1);
119  new G4PVPlacement(rm2,tr2,child2,"Child_2",aWorldLV,false,2);
120  return new G4PVPlacement(0,G4ThreeVector(),aWorldLV,"Random",0,false,1);
121}
122
Note: See TracBrowser for help on using the repository browser.