B1DetectorConstruction.cc 8.15 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
//
// ********************************************************************
// * License and Disclaimer                                           *
// *                                                                  *
// * The  Geant4 software  is  copyright of the Copyright Holders  of *
// * the Geant4 Collaboration.  It is provided  under  the terms  and *
// * conditions of the Geant4 Software License,  included in the file *
// * LICENSE and available at  http://cern.ch/geant4/license .  These *
// * include a list of copyright holders.                             *
// *                                                                  *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work  make  any representation or  warranty, express or implied, *
// * regarding  this  software system or assume any liability for its *
// * use.  Please see the license in the file  LICENSE  and URL above *
// * for the full disclaimer and the limitation of liability.         *
// *                                                                  *
// * This  code  implementation is the result of  the  scientific and *
// * technical work of the GEANT4 collaboration.                      *
// * By using,  copying,  modifying or  distributing the software (or *
// * any work based  on the software)  you  agree  to acknowledge its *
// * use  in  resulting  scientific  publications,  and indicate your *
// * acceptance of all terms of the Geant4 Software license.          *
// ********************************************************************
//
//
/// \file B1DetectorConstruction.cc
/// \brief Implementation of the B1DetectorConstruction class

#include "B1DetectorConstruction.hh"

#include "G4RunManager.hh"
#include "G4NistManager.hh"
#include "G4Box.hh"
#include "G4Cons.hh"
#include "G4Orb.hh"
#include "G4Sphere.hh"
#include "G4Tubs.hh"
#include "G4Trd.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4SystemOfUnits.hh"
#include "B1SD.hh"
#include "G4VSensitiveDetector.hh"
#include "G4EquationOfMotion.hh"
#include "G4Mag_UsualEqRhs.hh"
#include "G4MagIntegratorStepper.hh"
#include "G4MagIntegratorDriver.hh"
#include "G4ChordFinder.hh"
#include "G4ClassicalRK4.hh"
#include "G4UniformMagField.hh"
#include "G4UniformElectricField.hh"
#include "G4EqMagElectricField.hh"
#include "G4DormandPrince745.hh"
#include "G4FieldManager.hh"
#include "G4TransportationManager.hh"
#include "G4Cons.hh"
#include <cmath>

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

B1DetectorConstruction::B1DetectorConstruction()
: G4VUserDetectorConstruction(),
  fScoringVolume1(0),
  fScoringVolume2(0)
{ }

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

B1DetectorConstruction::~B1DetectorConstruction()
{ }

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

G4VPhysicalVolume* B1DetectorConstruction::Construct()
{
  // Get nist material manager
  G4NistManager* nist = G4NistManager::Instance();

  // Envelope parameters
  //
  G4double env_sizeXY = 10*m, env_sizeZ = 10*m;
  G4Material* env_mat = nist->FindOrBuildMaterial("G4_WATER");

  // Option to switch on/off checking of volumes overlaps
  //
  G4bool checkOverlaps = true;



  //
  // World
  //
  G4double world_sizeXY = 1.2*env_sizeXY;
  G4double world_sizeZ  = 1.2*env_sizeZ;
  G4Material* world_mat = nist->FindOrBuildMaterial("G4_Galactic");

  G4Box* solidWorld =
    new G4Box("World",                       //its name
      5*m, 5*m, 9*m);     //its size

    logicWorld =
    new G4LogicalVolume(solidWorld,          //its solid
                        world_mat,           //its material
                        "World");            //its name

  G4VPhysicalVolume* physWorld =
    new G4PVPlacement(0,                     //no rotation
                      G4ThreeVector(),       //at (0,0,0)
                      logicWorld,            //its logical volume
                      "World",               //its name
                      0,                     //its mother  volume
                      false,                 //no boolean operation
                      0,                     //copy number
                      checkOverlaps);        //overlaps checking


 //-------- ABSORBER --------------
 //materials
 
  //carbon

  G4Material* carbon = nist->FindOrBuildMaterial("G4_C");
  
  //concrete
  
  G4Material* concrete = nist->FindOrBuildMaterial("G4_CONCRETE");

  //initial values from the aborber paper

  G4double initial_angle = 2.;
  G4double final_angle = 10.;
  G4double z_0 = 0.9*m;
# define PI 3.14159265

  //cone trunks

  //carbon cone
  G4double carbon_pDz = 1.125*m;
  G4double carbon_pRmin1 = z_0*tan(initial_angle*PI/180.00);
  G4double carbon_pRmax1 = z_0*tan(final_angle*PI/180.00);
  G4double carbon_pRmin2 = (z_0 + 2*carbon_pDz)*tan(initial_angle*PI/180.00);
  G4double carbon_pRmax2 = (z_0 + 2*carbon_pDz)*tan(final_angle*PI/180.00);
  G4double carbon_pSphi = 0.*deg;
  G4double carbon_pDphi = 360.*deg;

  G4Cons* carbon_cons = new G4Cons("carbon_cons", carbon_pRmin1, carbon_pRmax1, 
		                   carbon_pRmin2, carbon_pRmax2, carbon_pDz,
				    carbon_pSphi, carbon_pDphi);

  G4LogicalVolume* carbon_Lvolume = new G4LogicalVolume(carbon_cons, carbon, "carbon_logical");

  new G4PVPlacement(0,
		    G4ThreeVector(0,0,(z_0 + carbon_pDz)),
		    carbon_Lvolume,
		    "carbon_cone",
		    logicWorld,
		    false,
		    1
		    );


 G4VisAttributes* blue = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0));
 carbon_Lvolume->SetVisAttributes(blue);


 //concrete cone
 
 G4double concrete_pDz = 0.76*m; // half lenght of cone
  G4double concrete_pRmin1 = carbon_pRmin2;  // inner radius at the begining of cone /
  G4double concrete_pRmax1 = carbon_pRmax2; // outer radius at the begining of cone
  G4double concrete_pRmin2 = (z_0 + 2*carbon_pDz + 2*concrete_pDz)*tan(initial_angle*PI/180.00); // inner radius at the end of cone
  G4double concrete_pRmax2 = (z_0 + 2*carbon_pDz + 2*concrete_pDz)*tan(final_angle*PI/180.00); // outer radius at the end of cone
    G4double concrete_pSphi = 0.*deg; //starting angle
  G4double concrete_pDphi = 360.*deg; // eng angle
  
 G4Cons* concrete_cons = new G4Cons("concrete_cons", concrete_pRmin1, concrete_pRmax1, concrete_pRmin2, concrete_pRmax2, concrete_pDz, concrete_pSphi, concrete_pDphi);

 G4LogicalVolume* concrete_Lvolume = new G4LogicalVolume(concrete_cons, concrete, "concrete_logical");

 new G4PVPlacement(0,
		 G4ThreeVector(0, 0, (z_0 + 2*carbon_pDz + concrete_pDz)),
		 concrete_Lvolume,
		 "concrete_cone",
		 logicWorld,
		 false,
		 1);

G4VisAttributes* red = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
concrete_Lvolume->SetVisAttributes(red);
  

//detector
G4double pos_after_detec = 3.*m;
G4double detec_length = 0.5*cm;
G4double initial_radius = (z_0 + 2*carbon_pDz + 2*concrete_pDz + pos_after_detec)*tan(initial_angle*PI/180.00);
G4double final_radius = (z_0 + 2*carbon_pDz + 2*concrete_pDz + pos_after_detec)*tan(final_angle*PI/180.00);

G4Tubs* detec_tub = new G4Tubs("detec_tubs", initial_radius, final_radius, detec_length, 0.*deg,360.*deg);

G4LogicalVolume* detec_volume = new G4LogicalVolume(detec_tub, world_mat, "detec");

 new G4PVPlacement(0,
		 G4ThreeVector(0,0,(z_0 + 2*carbon_pDz + 2*concrete_pDz + pos_after_detec)),
		 detec_volume,
		 "detector",
		 logicWorld,
		 false,
		 0,
		false
		 );


G4VisAttributes* color = new G4VisAttributes(G4Colour(0.0, 1.0, 1.0));
 carbon_Lvolume->SetVisAttributes(color );

  fScoringVolume1 = carbon_Lvolume;
  fScoringVolume2 = concrete_Lvolume;

//sensitive detector

auto sdman = G4SDManager::GetSDMpointer();
G4String SDname = "SD";
auto sensitive = new B1SD(SDname);
sdman->AddNewDetector(sensitive);
detec_volume->SetSensitiveDetector(sensitive);

  return physWorld;
}

void B1DetectorConstruction::ConstructSDandField() {
  //creating uniform magnetic field
  /*
    G4MagneticField* magField = new G4UniformMagField(G4ThreeVector(.000005*LT,0.,0.));
    G4FieldManager* FieldMgr  =new G4FieldManager(magField);
    logicWorld->SetFieldManager(FieldMgr, true);
  */

  


}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......