B1DetectorConstruction.cc 7.64 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
//
// ********************************************************************
// * 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"
31
#include "B1SD.hh"
32
#include "G4Material.hh"
33
34
35
36
37
38
39
40
41
42
43
#include "G4RunManager.hh"
#include "G4NistManager.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4Cons.hh"
#include "G4Orb.hh"
#include "G4Sphere.hh"
#include "G4Trd.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4SystemOfUnits.hh"
44
#include "G4PhysicalConstants.hh"
45
46
#include "G4VSensitiveDetector.hh"
#include "G4Track.hh"
47
48
49
#include "G4UniformMagField.hh"
#include "G4FieldManager.hh"
#include "G4TransportationManager.hh"
50
#include "G4Element.hh"
51

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

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

B1DetectorConstruction::B1DetectorConstruction()
: G4VUserDetectorConstruction(),
  fScoringVolume(0)
{ }

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

B1DetectorConstruction::~B1DetectorConstruction()
{ }

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

G4VPhysicalVolume* B1DetectorConstruction::Construct()
68
{
69
70
  // Get nist material manager
  G4NistManager* nist = G4NistManager::Instance();
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
  //making air materiais
  //Nitrogen
  G4double a_N = 14.01*g/mole;
  G4String name, symbol;
  G4double z;
  G4Element* ele_N = new G4Element(name="Nitrogen", symbol="N", z=7., a_N);
  //Oxygen
  G4double a_o = 16.00*g/mole;
  G4Element* ele_O = new G4Element(name="Oxygen", symbol="O", z=8., a_o);
  //Argon
  G4double a_Ar = 39.948*g/mole;
  G4Element* ele_Ar = new G4Element(name="Argon", symbol="Ar", z=18., a_Ar);

  G4int num_layers;
  G4double altitude = 100*km;
  G4double layer_delta_h = num_layers/altitude;
  std::vector<G4Material *> layers_material;
  layers_material.reserve(num_layers);

  for(G4int i = 0; i < num_layers; i++) {
    //fazer if clause para verificar valor de delta h progressivamente.
    //dependendo do h + delta_h -> parâmetros diferentes.

  }
96

97
98
99
100
  // Option to switch on/off checking of volumes overlaps
  //
  G4bool checkOverlaps = true;

101
  //
102
103
  // World
  //
104
  //caracteristicas do cilíndro -> world
105
  G4double raio_i = 0;
106
  G4double raio_e = 50*m;
107
  G4double h_detector = 1*cm;
108
  G4double h = 100*m;
109
110
  G4double theta_0 = 0.*deg;
  G4double theta_f = 360.*deg;
111
112
  //making world of vacuum
  G4Material* world_mat = nist->FindOrBuildMaterial("G4_Galactic");
113

114

115
  G4Tubs* cilindro = new G4Tubs("world", raio_i, raio_e, h, theta_0, theta_f);
116

117
    logicWorld =
118
119
120
    new G4LogicalVolume(cilindro,          //its solid
                        world_mat,           //its material
                        "World");            //its name
121
122

  G4VPhysicalVolume* physWorld =
123
124
125
126
127
128
129
130
131
132
133
134
135
    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

  //
  //always return the physical World
  //
   fScoringVolume = logicWorld;
136

137
138
139
140
141
   //começar aqui os layers da atmosfera em um for semelhante ao dos detetores, porém grudados e preenchendo todo o cilindro.




142

143
144
145
146
  G4double safe_distance = 0.02*m;
  //Coloque aqui o número de detetores
  G4int num_detector = 32;
  number_detectors = num_detector;
147

148
149
150
151
152
153
G4double total_safe = h_detector + safe_distance;
  G4double delta_h = (2*h - 2*safe_distance - 4*h_detector)/(num_detector - 1);
  G4double initial_pos = -h + total_safe;
  G4double final_pos = h - total_safe;
  size = h;
  delta = delta_h;
154
155


156
  detector = new G4Tubs("detector", raio_i, raio_e, h_detector, theta_0, theta_f);
157

158
159
160
161
162
  /*
  G4LogicalVolume* logicDetector = new G4LogicalVolume(detector,          //its solid
                     world_mat,           //its material
                   "logicDetector");
*/
163

164
165
166
167
168
169
//Criando os Logical volume
logicDetector.reserve(num_detector);
 for(G4int i=0; i < num_detector; i++) {
    logicDetector[i] = new G4LogicalVolume(detector,          //its solid
                       world_mat,           //its material
                     "logicDetector" + std::to_string(i + 1));
170

171
172
    positions.push_back(initial_pos + i*delta_h);
    std::cout << positions[i] << '\n';
173

174
175
176
177
178
179
180
181
    new G4PVPlacement(0,                     //no rotation
                      G4ThreeVector(0,0,positions[i]),       //at (0,0,0)
                      logicDetector[i],            //its logical volume
                      ("detector" + std::to_string(i + 1)),               //its name
                      logicWorld,                     //its mother  volume
                      false,                 //no boolean operation
                      i,                     //copy number
                      checkOverlaps);        //overlaps checking
182

183
  }
184

185
186
187
188


//Coloca os deteroes dentro do cilindro e coloca a sua posição em um vetor com push_back()

189
190
  //fScoringDetector = logicDetector;
 //Associando os detetores à classe sensitive detector
191
  auto sdman = G4SDManager::GetSDMpointer();
192

193

194
195
196
197
198
  for(G4int i = 0; i< num_detector; i++) {
  G4String SDname = "SD" + std::to_string(i + 1);
  auto sensitive = new B1SD(SDname);
  sdman->AddNewDetector(sensitive);
  logicDetector[i]->SetSensitiveDetector(sensitive);
199

200
}
201
    //colocando cor vermelha para detectores
202

203
204
205
  G4VisAttributes* worldVisAtt1 = new G4VisAttributes(G4Colour(1.0,0.0,0.0));
  worldVisAtt1->SetVisibility(true);

206
207
208
  for(G4int i = 0; i < num_detector; i++) {
  logicDetector[i]->SetVisAttributes(worldVisAtt1 );
}
209

210
211
212
  return physWorld;
}

213
214
void B1DetectorConstruction::ConstructSDandField() {
  //creanting uniform magnetic field
215
/*
216
217
218
  G4MagneticField* magField = new G4UniformMagField(G4ThreeVector(.0000005*LT,0.,0.));
  G4FieldManager* FieldMgr  =new G4FieldManager(magField);
  logicWorld->SetFieldManager(FieldMgr, true);
219
  */
220
221
}

222

223
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......