Advertisement
luizrosalba

GEANT4 - DetectorConstruction.cpp

Nov 17th, 2015
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.52 KB | None | 0 0
  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. /// \file electromagnetic/TestEm5/src/DetectorConstruction.cc
  27. /// \brief Implementation of the DetectorConstruction class
  28. //
  29. // $Id: DetectorConstruction.cc 77600 2013-11-26 17:07:41Z gcosmo $
  30. //
  31. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  32. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  33.  
  34. #include "DetectorConstruction.hh"
  35.  
  36. #include "DetectorSD.hh"
  37.  
  38. #include "DetectorMessenger.hh"
  39.  
  40. #include "G4Material.hh"
  41. #include "G4Box.hh"
  42. #include "G4LogicalVolume.hh"
  43. #include "G4PVPlacement.hh"
  44. #include "G4UniformMagField.hh"
  45.  
  46. #include "G4GeometryManager.hh"
  47. #include "G4PhysicalVolumeStore.hh"
  48. #include "G4LogicalVolumeStore.hh"
  49. #include "G4SolidStore.hh"
  50.  
  51. #include "G4UnitsTable.hh"
  52. #include "G4NistManager.hh"
  53.  
  54. #include "G4SDManager.hh"
  55. #include "G4RunManager.hh"
  56. #include "G4Transform3D.hh"
  57. #include "G4RotationMatrix.hh"
  58. #include "G4UserLimits.hh"
  59. #include "G4VisAttributes.hh"
  60. #include "G4Colour.hh"
  61.  
  62.  
  63. #include "G4PhysicalConstants.hh"
  64. #include "G4SystemOfUnits.hh"
  65.  
  66. #include "G4GlobalMagFieldMessenger.hh"
  67. #include "G4AutoDelete.hh"
  68.  
  69.  
  70. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  71.  
  72. DetectorConstruction::DetectorConstruction()
  73. :G4VUserDetectorConstruction(),
  74. fSubstratoMaterial(0),fWorldMaterial(0),fDefaultWorld(true),
  75. fSolidWorld(0),fLogicWorld(0),fPhysiWorld(0),
  76. solidDetector(0),logicDetector(0),physiDetector(0),
  77. solidLayerA(0),logicLayerA(0),physiLayerA(0),
  78. solidSubstrato(0),logicSubstrato(0), physiSubstrato(0),
  79. solidBe(0), logicBe(0) , physiBe (0),
  80. fDetectorMessenger(0)
  81. {
  82. // default parameter values of the calorimeter
  83. fSubstratoThickness = 1.*cm;
  84. fSubstratoSizeYZ = 2.*cm;
  85. // fXposAbs = 0.*cm;
  86. // ComputeCalorParameters();
  87.  
  88. // materials
  89.  
  90. DefineMaterials();
  91. SetWorldMaterial ("AirNist"); /// definicao do material do mundo
  92. //SetWorldMaterial ("Galactic"); /// definicao do material do mundo
  93. SetDetectorMaterial("Silicon"); /// material do detector
  94.  
  95.  
  96. // create commands for interactive definition of the calorimeter
  97. fDetectorMessenger = new DetectorMessenger(this);
  98. }
  99.  
  100. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  101.  
  102. DetectorConstruction::~DetectorConstruction()
  103. {
  104. delete fDetectorMessenger;
  105. }
  106.  
  107. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  108.  
  109. G4VPhysicalVolume* DetectorConstruction::Construct()
  110. {
  111. return ConstructCalorimeter();
  112. }
  113.  
  114. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  115.  
  116. void DetectorConstruction::DefineMaterials()
  117. {
  118. //This function illustrates the possible ways to define materials
  119.  
  120. G4String symbol; //a=mass of a mole;
  121. G4double a, z, density; //z=mean number of protons;
  122.  
  123. G4int ncomponents, natoms;
  124. G4double fractionmass;
  125. G4double temperature, pressure;
  126.  
  127. //
  128. // define Elements
  129. //
  130.  
  131. G4Element* H = new G4Element("Hydrogen",symbol="H", z= 1, a= 1.01*g/mole);
  132. G4Element* C = new G4Element("Carbon", symbol="C", z= 6, a= 12.01*g/mole);
  133. G4Element* N = new G4Element("Nitrogen",symbol="N", z= 7, a= 14.01*g/mole);
  134. G4Element* O = new G4Element("Oxygen", symbol="O", z= 8, a= 16.00*g/mole);
  135. G4Element* Na = new G4Element("Sodium", symbol="Na", z=11, a= 22.99*g/mole);
  136. G4Element* Ar = new G4Element("Argon", symbol="Ar", z=18, a= 39.95*g/mole);
  137. G4Element* I = new G4Element("Iodine", symbol="I" , z=53, a= 126.90*g/mole);
  138. G4Element* Xe = new G4Element("Xenon", symbol="Xe", z=54, a= 131.29*g/mole);
  139. G4Element* Si2 = new G4Element("Silicon2", symbol="Si" , z= 14, a = 28.08*g/mole);
  140. G4Element* Be = new G4Element("Beryllium", symbol="Be" , z= 4, a = 9.012182*g/mole);
  141. G4Element* Zn = new G4Element("Zinc", symbol="Zn" , z= 30, a = 65.38*g/mole);
  142. G4Element* Ni = new G4Element("Nickel", symbol="Ni" , z= 28, a = 58.6934*g/mole);
  143. //
  144. // define simple materials
  145. //
  146.  
  147. new G4Material("H2Liq" , z= 1, a= 1.01*g/mole, density= 70.8*mg/cm3);
  148. new G4Material("Beryllium", z= 4, a= 9.01*g/mole, density= 1.848*g/cm3);
  149. new G4Material("Aluminium", z=13, a=26.98*g/mole, density= 2.700*g/cm3);
  150. new G4Material("Silicon" , z=14, a=28.08*g/mole, density= 2.330*g/cm3);
  151.  
  152. G4Material* lAr =
  153. new G4Material("liquidArgon", density= 1.390*g/cm3, ncomponents=1);
  154. lAr->AddElement(Ar, natoms=1);
  155.  
  156. new G4Material("Iron", z=26, a= 55.85*g/mole, density= 7.870*g/cm3);
  157. new G4Material("Copper", z=29, a= 63.55*g/mole, density= 8.960*g/cm3);
  158. new G4Material("Germanium",z=32, a= 72.61*g/mole, density= 5.323*g/cm3);
  159. new G4Material("Silver", z=47, a=107.87*g/mole, density= 10.50*g/cm3);
  160. new G4Material("Tungsten", z=74, a=183.85*g/mole, density= 19.30*g/cm3);
  161. new G4Material("Gold", z=79, a=196.97*g/mole, density= 19.32*g/cm3);
  162. new G4Material("Lead", z=82, a=207.19*g/mole, density= 11.35*g/cm3);
  163.  
  164. density = 2.33*g/cm3;
  165. G4Material* Silicon2 = new G4Material("Silicon2", density, ncomponents=1); //SILICON
  166. Silicon2->AddElement(Si2, natoms=1);
  167.  
  168. density = 1.848*g/cm3;
  169. G4Material* Berilio = new G4Material("Berilio", density, ncomponents=1); //SILICON
  170. Berilio->AddElement(Be, natoms=1);
  171.  
  172. //G4Material* Zn = man->FindOrBuildMaterial("G4_Zn");
  173. //G4Material* Cr = man->FindOrBuildMaterial("G4_Cr");
  174. //G4Material* Ni = man->FindOrBuildMaterial("G4_Ni");
  175.  
  176. G4Material* Al =
  177. new G4Material("Aluminum", z= 13., a= 26.98*g/mole, density= 2.6989*g/cm3);
  178.  
  179. //
  180. // define a material from elements. case 1: chemical molecule
  181. //
  182.  
  183. G4Material* H2O = new G4Material("Water",density= 1.000*g/cm3,ncomponents=2);
  184. H2O->AddElement(H, natoms=2);
  185. H2O->AddElement(O, natoms=1);
  186. H2O->GetIonisation()->SetMeanExcitationEnergy(78*eV);
  187.  
  188. G4Material* CH = new G4Material("Plastic",density= 1.04*g/cm3,ncomponents=2);
  189. CH->AddElement(C, natoms=1);
  190. CH->AddElement(H, natoms=1);
  191.  
  192. G4Material* NaI = new G4Material("NaI", density= 3.67*g/cm3, ncomponents=2);
  193. NaI->AddElement(Na, natoms=1);
  194. NaI->AddElement(I , natoms=1);
  195. NaI->GetIonisation()->SetMeanExcitationEnergy(452*eV);
  196.  
  197. //
  198. // define a material from elements. case 2: mixture by fractional mass
  199. //
  200.  
  201. G4Material* Air = new G4Material("Air", density= 1.290*mg/cm3, ncomponents=2);
  202. Air->AddElement(N, fractionmass=0.7);
  203. Air->AddElement(O, fractionmass=0.3);
  204.  
  205. G4Material* Air20 =
  206. new G4Material("Air20", density= 1.205*mg/cm3, ncomponents=2,
  207. kStateGas, 293.*kelvin, 1.*atmosphere);
  208. Air20->AddElement(N, fractionmass=0.7);
  209. Air20->AddElement(O, fractionmass=0.3);
  210.  
  211.  
  212. pressure = 1*atmosphere; ///
  213. temperature = 293.15*kelvin; /// 20 graus celsius
  214. G4Material* AirNist =
  215. new G4Material("AirNist", density= 1.20479*mg/cm3, ncomponents=4,kStateGas,temperature,pressure);
  216. AirNist->AddElement(C, fractionmass=0.000124);
  217. AirNist->AddElement(N, fractionmass=0.755267);
  218. AirNist->AddElement(O, fractionmass=0.231781);
  219. AirNist->AddElement(Ar, fractionmass=0.012827);
  220.  
  221.  
  222. //Graphite
  223. //
  224. G4Material* Graphite =
  225. new G4Material("Graphite", density= 1.7*g/cm3, ncomponents=1);
  226. Graphite->AddElement(C, fractionmass=1.);
  227.  
  228. //Havar
  229. //
  230. G4Element* Cr = new G4Element("Chrome", "Cr", z=25, a= 51.996*g/mole);
  231. G4Element* Fe = new G4Element("Iron" , "Fe", z=26, a= 55.845*g/mole);
  232. G4Element* Co = new G4Element("Cobalt", "Co", z=27, a= 58.933*g/mole);
  233. // G4Element* Ni = new G4Element("Nickel", "Ni", z=28, a= 58.693*g/mole);
  234. G4Element* W = new G4Element("Tungsten","W", z=74, a= 183.850*g/mole);
  235. G4Element* Mn = new G4Element("Mang","Mn" , z=25, a= 54.938044*g/mole);
  236. G4Element* Au = new G4Element("Gold","Au" , z= 79,a = 196.967*g/mole);
  237. G4Element* Cu = new G4Element("Cobre","Cu", z=29, a= 63.55*g/mole);
  238. G4Element* S = new G4Element("Sulfur","S", z=16, a= 32.065*g/mole);
  239. G4Element* P = new G4Element("Phosphorus","P", z=15, a= 30.973761*g/mole);
  240.  
  241.  
  242. G4Material* Havar =
  243. new G4Material("Havar", density= 8.3*g/cm3, ncomponents=5);
  244. Havar->AddElement(Cr, fractionmass=0.1785);
  245. Havar->AddElement(Fe, fractionmass=0.1822);
  246. Havar->AddElement(Co, fractionmass=0.4452);
  247. Havar->AddElement(Ni, fractionmass=0.1310);
  248. Havar->AddElement(W , fractionmass=0.0631);
  249.  
  250. //
  251. // examples of gas
  252. //
  253. new G4Material("ArgonGas", z=18, a=39.948*g/mole, density= 1.782*mg/cm3,
  254. kStateGas, 273.15*kelvin, 1*atmosphere);
  255.  
  256. new G4Material("XenonGas", z=54, a=131.29*g/mole, density= 5.458*mg/cm3,
  257. kStateGas, 293.15*kelvin, 1*atmosphere);
  258.  
  259. G4Material* CO2 =
  260. new G4Material("CarbonicGas", density= 1.977*mg/cm3, ncomponents=2);
  261. CO2->AddElement(C, natoms=1);
  262. CO2->AddElement(O, natoms=2);
  263.  
  264. G4Material* ArCO2 =
  265. new G4Material("ArgonCO2", density= 1.8223*mg/cm3, ncomponents=2);
  266. ArCO2->AddElement (Ar, fractionmass=0.7844);
  267. ArCO2->AddMaterial(CO2, fractionmass=0.2156);
  268.  
  269. //another way to define mixture of gas per volume
  270. G4Material* NewArCO2 =
  271. new G4Material("NewArgonCO2", density= 1.8223*mg/cm3, ncomponents=3);
  272. NewArCO2->AddElement (Ar, natoms=8);
  273. NewArCO2->AddElement (C, natoms=2);
  274. NewArCO2->AddElement (O, natoms=4);
  275.  
  276. G4Material* ArCH4 =
  277. new G4Material("ArgonCH4", density= 1.709*mg/cm3, ncomponents=3);
  278. ArCH4->AddElement (Ar, natoms=93);
  279. ArCH4->AddElement (C, natoms=7);
  280. ArCH4->AddElement (H, natoms=28);
  281.  
  282. G4Material* XeCH =
  283. new G4Material("XenonMethanePropane", density= 4.9196*mg/cm3, ncomponents=3,
  284. kStateGas, 293.15*kelvin, 1*atmosphere);
  285. XeCH->AddElement (Xe, natoms=875);
  286. XeCH->AddElement (C, natoms=225);
  287. XeCH->AddElement (H, natoms=700);
  288.  
  289. G4Material* steam =
  290. new G4Material("WaterSteam", density= 1.0*mg/cm3, ncomponents=1);
  291. steam->AddMaterial(H2O, fractionmass=1.);
  292. steam->GetIonisation()->SetMeanExcitationEnergy(71.6*eV);
  293.  
  294.  
  295. // PMMA C5H8O2 ( Acrylic )
  296. // -------------
  297. density = 1.19*g/cm3;
  298. G4Material* Acrilico = new G4Material("Acrilico", density, ncomponents=3);
  299. Acrilico->AddElement(C, 5);
  300. Acrilico->AddElement(H, 8);
  301. Acrilico->AddElement(O, 2);
  302.  
  303.  
  304. //
  305. // example of vacuum
  306. //
  307.  
  308. density = universe_mean_density; //from PhysicalConstants.h
  309. pressure = 3.e-18*pascal;
  310. temperature = 298.15*kelvin;
  311. new G4Material("Galactic", z=1, a=1.01*g/mole,density,
  312. kStateGas,temperature,pressure);
  313.  
  314.  
  315.  
  316. density = 7.788*g/cm3; // 2% Mn
  317. G4Material* FeMn = new G4Material("FeMn", density, ncomponents=2); //
  318. FeMn->AddElement(Fe, fractionmass=98*perCent);
  319. FeMn->AddElement(Mn, fractionmass=2*perCent);
  320.  
  321. density = 7.872*g/cm3; // 2% Mn
  322. G4Material* Aco1020 = new G4Material("Aco1020", density, ncomponents=5); //
  323. Aco1020->AddElement(C, fractionmass=0.20*perCent);
  324. Aco1020->AddElement(Mn, fractionmass=0.4*perCent);
  325. Aco1020->AddElement(P, fractionmass=0.04*perCent);
  326. Aco1020->AddElement(S, fractionmass=0.05*perCent);
  327. Aco1020->AddElement(Fe, fractionmass=99.31*perCent);
  328.  
  329.  
  330.  
  331. density = 7.874*g/cm3; // 2% Mn
  332. G4Material* FePuro = new G4Material("FePuro", density, ncomponents=1); //
  333. FePuro->AddElement(Fe, fractionmass=100*perCent);
  334.  
  335. density = 19.30*g/cm3; // 2% Mn
  336. G4Material* OuroPuro = new G4Material("OuroPuro", density, ncomponents=1); //
  337. OuroPuro->AddElement(Au, fractionmass=100*perCent);
  338.  
  339.  
  340. density = 8.960*g/cm3; // 2% Mn
  341. G4Material* CobrePuro = new G4Material("CobrePuro", density, ncomponents=1); //
  342. CobrePuro->AddElement(Cu, fractionmass=100*perCent);
  343.  
  344.  
  345. density = 8.902*g/cm3; // nicekl
  346. G4Material* Nickel = new G4Material("Niquel", density, ncomponents=1); //
  347. Nickel->AddElement(Ni, fractionmass=100*perCent);
  348.  
  349. density = 7.133*g/cm3; // zinco
  350. G4Material* Zinco = new G4Material("Zinco", density, ncomponents=1); //
  351. Zinco->AddElement(Zn, fractionmass=100*perCent);
  352. }
  353.  
  354.  
  355.  
  356. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  357.  
  358. void DetectorConstruction::ComputeCalorParameters()
  359. {
  360. // Compute derived parameters of the calorimeter
  361. // fXstartAbs = fXposAbs-0.5*fAbsorberThickness;
  362. // fXendAbs = fXposAbs+0.5*fAbsorberThickness;
  363.  
  364. // if (fDefaultWorld) {
  365. // fWorldSizeX = 1.5*fAbsorberThickness; fWorldSizeYZ= 1.2*fAbsorberSizeYZ;
  366. // }
  367. }
  368.  
  369. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  370.  
  371. G4VPhysicalVolume* DetectorConstruction::ConstructCalorimeter()
  372. {
  373. // Cleanup old geometry
  374. //
  375. G4GeometryManager::GetInstance()->OpenGeometry();
  376. G4PhysicalVolumeStore::GetInstance()->Clean();
  377. G4LogicalVolumeStore::GetInstance()->Clean();
  378. G4SolidStore::GetInstance()->Clean();
  379.  
  380. //===== DEFINITIONS OF ROTAITION MATRIXES =====================================
  381.  
  382. G4double csi = 90. *deg; // Matrix definition for a 90 deg rotation
  383. G4RotationMatrix rm;
  384. rm.rotateY(csi);
  385. // Z -
  386. // X -
  387. // Y -
  388. //
  389.  
  390.  
  391. G4double psi = 0. *deg; // Matrix definition for a 0 deg rotation
  392. G4RotationMatrix rmz;
  393. rmz.rotateX(psi);
  394.  
  395. // World
  396. //
  397.  
  398. G4double ExperimentalHall_x = 25.0*cm;
  399. G4double ExperimentalHall_y = 25.0*cm;
  400. G4double ExperimentalHall_z = 25.0*cm;
  401.  
  402. fSolidWorld = new G4Box("World", //its name
  403. ExperimentalHall_x,
  404. ExperimentalHall_y,
  405. ExperimentalHall_z);
  406.  
  407. fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid
  408. fWorldMaterial, //its material
  409. "World"); //its name
  410.  
  411. fPhysiWorld = new G4PVPlacement(0, //no rotation
  412. G4ThreeVector(), //at (0,0,0)
  413. fLogicWorld, //its logical volume
  414. "World", //its name
  415. 0, //its mother volume
  416. false, //no boolean operation
  417. 0); //copy number
  418.  
  419.  
  420.  
  421. G4double LayerAPosition_x = 0.0 ; /// nao comentar
  422.  
  423.  
  424.  
  425. //----------------------------------------------------------------------------
  426. // Layer A Descomentar para adicionar uma camada a simulação
  427. // Zinc sheet
  428. // with thickness (along X):
  429. // 5 * nm = 0.000005 ( 1/2 = 0.0000025) * mm
  430. // 10 * nm = 0.00001 ( 1/2 = 0.000005) * mm
  431. // 0,005 mm = > 1/2 = 0.0025 * mm
  432. // 0,01 mm => 1/2 = 0.005 * mm
  433. // 0.05*mm; 0.1*mm
  434. //
  435. // Fiz a camada A de Niquel
  436. //----------------------------------------------------------------------------
  437.  
  438. G4double LayerA_x = fLayerThickness; // <--------- espessura 5 microns d
  439. G4double LayerA_y = 5*mm; //
  440. G4double LayerA_z = 5*mm; //
  441.  
  442. LayerAPosition_x = -1.0 * LayerA_x ;
  443. G4double LayerAPosition_y = 0.0*mm;
  444. G4double LayerAPosition_z = 0.0*mm; //
  445.  
  446. solidLayerA = new G4Box("LayerA",
  447. LayerA_x,
  448. LayerA_y,
  449. LayerA_z);
  450.  
  451. logicLayerA = new G4LogicalVolume(solidLayerA, fLayerMaterial, "LayerA"); // Ni
  452.  
  453. physiLayerA = new G4PVPlacement(G4Transform3D(rmz,
  454. G4ThreeVector(LayerAPosition_x,
  455. LayerAPosition_y,
  456. LayerAPosition_z)),
  457. "LayerA",
  458. logicLayerA,
  459. fPhysiWorld,
  460. false,
  461. 0);
  462.  
  463.  
  464.  
  465. // Substrato /// camada inicia no 0, 0
  466. //
  467.  
  468.  
  469. G4double Sample_x = fSubstratoThickness; // <--------- espessura
  470. G4double Sample_y = 5 *mm; //
  471. G4double Sample_z = 5 *mm; //
  472.  
  473. G4double SamplePosition_x = LayerAPosition_x + (-1.0) * Sample_x; /// com layer
  474. G4double SamplePosition_y = 0.0*cm; ///
  475. G4double SamplePosition_z = 0.0*cm; //
  476.  
  477.  
  478. solidSubstrato = new G4Box("Amostra",
  479. Sample_x,
  480. Sample_y,
  481. Sample_z);
  482.  
  483. logicSubstrato = new G4LogicalVolume(solidSubstrato, //its solid
  484. fSubstratoMaterial, //its material
  485. "Amostra"); //its name
  486.  
  487. physiSubstrato = new G4PVPlacement(G4Transform3D(rmz,
  488. G4ThreeVector(SamplePosition_x,
  489. SamplePosition_y,
  490. SamplePosition_z)),
  491. "Amostra",
  492. logicSubstrato,
  493. fPhysiWorld,
  494. false,
  495. 0);
  496.  
  497. //PrintCalorParameters();
  498.  
  499.  
  500.  
  501. // **************
  502. // Cut per Region
  503. // **************
  504.  
  505. // A smaller cut is fixed in the phantom to calculate the energy deposit with the
  506. // required accuracy
  507. //G4Region* cRegion = new G4Region("LayerALog");
  508. //logicLayerA -> SetRegion(cRegion);
  509. //cRegion -> AddRootLogicalVolume(logicLayerA);
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516. /// Janela de berílio
  517.  
  518. //----------------------------------------------------------------------------
  519. // Be Window
  520. // X position =
  521. //
  522. //----------------------------------------------------------------------------
  523.  
  524.  
  525. G4Material* pttoMaterial =
  526. G4NistManager::Instance()->FindOrBuildMaterial("Beryllium");
  527.  
  528. BeMaterial = pttoMaterial;
  529.  
  530. G4double BePosition_x = 1.0 *cm; // -5.<--- window position
  531. G4double BePosition_y = (0.4124) *cm;
  532. G4double BePosition_z = 0.0 *cm;
  533.  
  534. G4double Be_x = 5* mm ; //
  535. G4double Be_y = 5 *mm; //
  536. G4double Be_z = 12.5 *micrometer; // espessura
  537. //G4double Be_z = 12.5* micrometer; //<--------- espessura 12,5 micrometros
  538.  
  539.  
  540. solidBe = new G4Box("BeWindow",
  541. Be_x,
  542. Be_y,
  543. Be_z);
  544.  
  545. logicBe = new G4LogicalVolume(solidBe,
  546. BeMaterial,
  547. "BeWindow");
  548.  
  549. physiBe = new G4PVPlacement(G4Transform3D(rm,
  550. G4ThreeVector(BePosition_x,
  551. BePosition_y,
  552. BePosition_z)),
  553. "BeWindow",
  554. logicBe,
  555. fPhysiWorld,
  556. false,
  557. 0);
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564. //----------------------------------------------------------------------------
  565. // Si Detector
  566. // X position = 40 mm + 1/2 Al phantom thickness
  567. //
  568. //----------------------------------------------------------------------------
  569.  
  570.  
  571.  
  572. G4double Detector_x = 5 * mm;
  573. G4double Detector_y = 5 * mm;
  574. G4double Detector_z = 500 * micrometer; // 500 micrometros espessura
  575.  
  576. G4double DetectorPosition_x = BePosition_x + Be_z + Detector_z; // -5.<--- Detector position
  577. G4double DetectorPosition_y = (0.4142) *cm;
  578. G4double DetectorPosition_z = 0.0 *cm;
  579.  
  580.  
  581.  
  582. solidDetector = new G4Box("Detector",
  583. Detector_x,
  584. Detector_y,
  585. Detector_z);
  586.  
  587. logicDetector = new G4LogicalVolume(solidDetector,
  588. DetectorMaterial,
  589. "Detector");
  590.  
  591. physiDetector = new G4PVPlacement(G4Transform3D(rm,
  592. G4ThreeVector(DetectorPosition_x,
  593. DetectorPosition_y,
  594. DetectorPosition_z)),
  595. "Detector",
  596. logicDetector,
  597. fPhysiWorld,
  598. false,
  599. 0);
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606. // ======== Colours definition ===============================================
  607.  
  608. G4VisAttributes * yellow = new G4VisAttributes( G4Colour(1., 1., 0. ));
  609. yellow-> SetVisibility(true);
  610. yellow-> SetForceSolid(true);
  611.  
  612. G4VisAttributes * grey = new G4VisAttributes( G4Colour(0.45, 0.45, 0.45 ));
  613. grey-> SetVisibility(true);
  614. grey-> SetForceSolid(true);
  615.  
  616. G4VisAttributes * red = new G4VisAttributes( G4Colour(1. ,0. ,0.));
  617. red-> SetVisibility(true);
  618. red-> SetForceSolid(true);
  619.  
  620. G4VisAttributes * blue = new G4VisAttributes( G4Colour(0. ,0. ,0.85));
  621. blue -> SetVisibility(true);
  622. blue -> SetForceSolid(true);
  623.  
  624. G4VisAttributes * green = new G4VisAttributes( G4Colour(0. ,1. ,0.));
  625. green -> SetVisibility(true);
  626. green -> SetForceSolid(true);
  627.  
  628. G4VisAttributes * white = new G4VisAttributes( G4Colour());
  629. white -> SetVisibility(true);
  630. white -> SetForceSolid(true);
  631.  
  632. G4VisAttributes * brown = new G4VisAttributes( G4Colour(0.8, 0.5, 0.35));
  633. brown -> SetVisibility(true);
  634. brown -> SetForceSolid(true);
  635.  
  636. // magenta
  637. G4VisAttributes * magenta = new G4VisAttributes( G4Colour(1.0, 0.0, 1.0));
  638. magenta -> SetVisibility(true);
  639. magenta -> SetForceSolid(true);
  640.  
  641. // ======== Visualization attributes =========================================
  642.  
  643. fLogicWorld -> SetVisAttributes(G4VisAttributes::Invisible); // nao
  644. logicSubstrato -> SetVisAttributes(brown); /// Ferro + Manganes Azul
  645. //logicAnodo -> SetVisAttributes(yellow); /// nao aparece por causa da espessura muito fina , o geant nao desenha
  646. //logicLayerA -> SetVisAttributes(magenta); /// Niquel
  647. //logicLayerB -> SetVisAttributes(yellow); /// Ar
  648. ///logicSourcePoint -> SetVisAttributes(magenta); /// Fonte
  649. logicDetector -> SetVisAttributes(blue); /// Detector
  650. logicBe -> SetVisAttributes(yellow); /// Detector
  651.  
  652. //always return the physical World
  653. //
  654. return fPhysiWorld;
  655. }
  656.  
  657. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  658.  
  659. void DetectorConstruction::PrintCalorParameters()
  660. {
  661. // G4cout << "aaaaaaaaaaaa" << G4endl;
  662. /*
  663. G4cout << "\n" << fWorldMaterial << G4endl;
  664. G4cout << "\n" << fAbsorberMaterial << G4endl;
  665.  
  666. G4cout << "\n The WORLD is made of " << G4BestUnit(fWorldSizeX,"Length")
  667. << " of " << fWorldMaterial->GetName();
  668. G4cout << ". The transverse size (YZ) of the world is "
  669. << G4BestUnit(fWorldSizeYZ,"Length") << G4endl;
  670. G4cout << " The ABSORBER is made of "
  671. <<G4BestUnit(fAbsorberThickness,"Length")
  672. << " of " << fAbsorberMaterial->GetName();
  673. G4cout << ". The transverse size (YZ) is "
  674. << G4BestUnit(fAbsorberSizeYZ,"Length") << G4endl;
  675. G4cout << " X position of the middle of the absorber "
  676. << G4BestUnit(fXposAbs,"Length");
  677. G4cout << G4endl;
  678. * */
  679. }
  680.  
  681. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  682.  
  683. void DetectorConstruction::SetDetectorMaterial(G4String materialChoice)
  684. {
  685. // search the material by its name
  686. G4Material* pttoMaterial =
  687. G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
  688.  
  689. if (pttoMaterial && DetectorMaterial != pttoMaterial)
  690. {
  691. DetectorMaterial = pttoMaterial;
  692. if(logicDetector) logicDetector->SetMaterial(DetectorMaterial);
  693. G4RunManager::GetRunManager()->PhysicsHasBeenModified();
  694. G4cout << " Detector feito de " << materialChoice << G4endl;
  695. }
  696. }
  697.  
  698.  
  699. void DetectorConstruction::SetSubstratoMaterial(G4String materialChoice)
  700. {
  701. G4cout<< "Aqui2" << G4endl ;
  702. // search the material by its name
  703. G4Material* pttoSubstrato =
  704. G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
  705.  
  706. if (pttoSubstrato && fSubstratoMaterial != pttoSubstrato)
  707. {
  708.  
  709. fSubstratoMaterial = pttoSubstrato;
  710.  
  711. if(logicSubstrato)
  712. {
  713. logicSubstrato->SetMaterial(fSubstratoMaterial);
  714. G4cout<< "Aqui3" << G4endl ;
  715. G4RunManager::GetRunManager()->PhysicsHasBeenModified();
  716. }
  717.  
  718.  
  719. G4cout << " Substrato feito de " << materialChoice << G4endl;
  720. }
  721. }
  722. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  723.  
  724.  
  725. void DetectorConstruction::SetLayerMaterial(G4String materialChoice)
  726. {
  727. G4Material* pttoLayer =
  728. G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
  729.  
  730. if (pttoLayer && fLayerMaterial != pttoLayer)
  731. {
  732. fLayerMaterial = pttoLayer;
  733. if(logicLayerA) logicLayerA->SetMaterial(fLayerMaterial);
  734. G4RunManager::GetRunManager()->PhysicsHasBeenModified();
  735. G4cout << " Camada feita de " << materialChoice << G4endl;
  736. }
  737. }
  738.  
  739.  
  740.  
  741.  
  742. void DetectorConstruction::SetWorldMaterial(G4String materialChoice)
  743. {
  744. // search the material by its name
  745. G4Material* pttoMaterial =
  746. G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
  747.  
  748. if (pttoMaterial && fWorldMaterial != pttoMaterial)
  749. {
  750. fWorldMaterial = pttoMaterial;
  751. if(fLogicWorld) fLogicWorld->SetMaterial(fWorldMaterial);
  752. G4RunManager::GetRunManager()->PhysicsHasBeenModified();
  753. G4cout << " Material do Mundo feito de " << materialChoice << G4endl;
  754. }
  755. }
  756.  
  757.  
  758.  
  759. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  760.  
  761. void DetectorConstruction::SetSubstratoThickness(G4double val)
  762. {
  763. fSubstratoThickness = val;
  764. G4cout << " Espessura do substrato (em um) " << fSubstratoThickness / millimeter << G4endl;
  765.  
  766. //ComputeCalorParameters();
  767. G4RunManager::GetRunManager()->ReinitializeGeometry();
  768. }
  769.  
  770. void DetectorConstruction::SetLayerThickness(G4double val )
  771. {
  772. fLayerThickness = val;
  773. G4cout << " Espessura da camanda (em um) " << fLayerThickness / millimeter << G4endl;
  774.  
  775. //ComputeCalorParameters();
  776. G4RunManager::GetRunManager()->ReinitializeGeometry();
  777.  
  778. }
  779.  
  780.  
  781.  
  782. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  783.  
  784. ///void DetectorConstruction::SetAbsorberSizeYZ(G4double val)
  785. //{
  786. //fAbsorberSizeYZ = val;
  787. //ComputeCalorParameters();
  788. //G4RunManager::GetRunManager()->ReinitializeGeometry();
  789. //}
  790.  
  791. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  792.  
  793. void DetectorConstruction::SetWorldSizeX(G4double val)
  794. {
  795. fWorldSizeX = val;
  796. fDefaultWorld = false;
  797. //ComputeCalorParameters();
  798. G4RunManager::GetRunManager()->ReinitializeGeometry();
  799. }
  800.  
  801. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  802.  
  803. void DetectorConstruction::SetWorldSizeYZ(G4double val)
  804. {
  805. fWorldSizeYZ = val;
  806. fDefaultWorld = false;
  807. //ComputeCalorParameters();
  808. G4RunManager::GetRunManager()->ReinitializeGeometry();
  809. }
  810.  
  811. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  812.  
  813. //void DetectorConstruction::SetAbsorberXpos(G4double val)
  814. //{
  815. // fXposAbs = val;
  816. //ComputeCalorParameters();
  817. // G4RunManager::GetRunManager()->ReinitializeGeometry();
  818. //}
  819.  
  820. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
  821.  
  822.  
  823. void DetectorConstruction::ConstructSDandField()
  824. {
  825. if ( fFieldMessenger.Get() == 0 ) {
  826. // Create global magnetic field messenger.
  827. // Uniform magnetic field is then created automatically if
  828. // the field value is not zero.
  829. G4ThreeVector fieldValue = G4ThreeVector();
  830. G4GlobalMagFieldMessenger* msg =
  831. new G4GlobalMagFieldMessenger(fieldValue);
  832. //msg->SetVerboseLevel(1);
  833. G4AutoDelete::Register(msg);
  834. fFieldMessenger.Put( msg );
  835.  
  836. }
  837.  
  838. /// adicionando o detetor
  839. G4SDManager* SDmanAl = G4SDManager::GetSDMpointer();
  840. G4String detectorChamberSDname = "SD";
  841. DetectorSD* aDetectorSD = new DetectorSD( detectorChamberSDname );
  842. SDmanAl->AddNewDetector( aDetectorSD );
  843. logicDetector->SetSensitiveDetector( aDetectorSD );
  844.  
  845. }
  846.  
  847. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement