B1DetectorConstruction.cc 18.7 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 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 45 46 47
#include "G4VSensitiveDetector.hh"
#include "G4Track.hh"


48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

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

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

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

B1DetectorConstruction::~B1DetectorConstruction()
{ }

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

G4VPhysicalVolume* B1DetectorConstruction::Construct()
64
{
65 66
  // Get nist material manager
  G4NistManager* nist = G4NistManager::Instance();
67 68


69 70 71 72
  // Option to switch on/off checking of volumes overlaps
  //
  G4bool checkOverlaps = true;

73
  //
74 75
  // World
  //
76
  //caracteristicas do cilíndro -> world
77
  G4double raio_i = 0;
78
  G4double raio_e = 9*m;
79
  G4double h_detector = 0.100*m;
80
  G4double h = 9*m;
81 82 83
  G4double theta_0 = 0.*deg;
  G4double theta_f = 360.*deg;
  G4Material* world_mat = nist->FindOrBuildMaterial("G4_AIR");
84

85
  G4Tubs* cilindro = new G4Tubs("world", raio_i, raio_e, h, theta_0, theta_f);
86 87

  G4LogicalVolume* logicWorld =
88 89 90
    new G4LogicalVolume(cilindro,          //its solid
                        world_mat,           //its material
                        "World");            //its name
91 92

  G4VPhysicalVolume* physWorld =
93 94 95 96 97 98 99 100 101 102 103 104 105
    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;
106 107 108 109 110

  //Criando detetor para ver partículas que chegam à superfície


  G4Tubs* detector = new G4Tubs("detector", raio_i, raio_e, h_detector, theta_0, theta_f);
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
  G4LogicalVolume* logicDetector1 = new G4LogicalVolume(detector,
                                                      world_mat,
                                                      "detector1");

  G4LogicalVolume* logicDetector2 = new G4LogicalVolume(detector,
                                                      world_mat,
                                                      "detector2");

  G4LogicalVolume* logicDetector3 = new G4LogicalVolume(detector,
                                                      world_mat,
                                                      "detector3");

  G4LogicalVolume* logicDetector4 = new G4LogicalVolume(detector,
                                                      world_mat,
                                                      "detector4");

G4LogicalVolume* logicDetector5 = new G4LogicalVolume(detector,
                                                      world_mat,
                                                      "detector5");

G4LogicalVolume* logicDetector6 = new G4LogicalVolume(detector,
                                                      world_mat,
                                                      "detector6");

G4LogicalVolume* logicDetector7 = new G4LogicalVolume(detector,
                                                      world_mat,
                                                      "detector7");


G4LogicalVolume* logicDetector8 = new G4LogicalVolume(detector,
                                                      world_mat,
                                                      "detector8");

G4LogicalVolume* logicDetector9 = new G4LogicalVolume(detector,
                                                      world_mat,
                                                      "detector9");

G4LogicalVolume* logicDetector10 = new G4LogicalVolume(detector,
                                                      world_mat,
                                                      "detector10");


G4LogicalVolume* logicDetector11 = new G4LogicalVolume(detector,
                                                      world_mat,
                                                      "detector11");

G4LogicalVolume* logicDetector12 = new G4LogicalVolume(detector,
                                                      world_mat,
                                                      "detector12");


G4LogicalVolume* logicDetector13 = new G4LogicalVolume(detector,
                                                      world_mat,
                                                      "detector13");
G4LogicalVolume* logicDetector14 = new G4LogicalVolume(detector,
                                                      world_mat,
                                                      "detector14");
G4LogicalVolume* logicDetector15 = new G4LogicalVolume(detector,
                                                      world_mat,
                                                      "detector15");

G4LogicalVolume* logicDetector16 = new G4LogicalVolume(detector,
175
                                                      world_mat,
176 177 178 179 180 181 182 183
                                                      "detector16");
G4LogicalVolume* logicDetector17 = new G4LogicalVolume(detector,
                                                      world_mat,
                                                      "detector17");

G4LogicalVolume* logicDetector18 = new G4LogicalVolume(detector,
                                                        world_mat,
                                                      "detector18");
184
/*
185 186 187
G4LogicalVolume* logicDetector19 = new G4LogicalVolume(detector,
                                                      world_mat,
                                                     "detector19");
188 189 190 191 192 193 194 195 196 197
*/

G4double safe_distance = 0.005*m;
G4int num_detector = 19;
G4double total_safe = 2*h_detector + safe_distance;
G4double delta_h = (2*h - 2*safe_distance - 4*h_detector)/(num_detector - 2);
G4double initial_pos = -h + total_safe;
G4double final_pos = h - total_safe;
size = h;
delta = delta_h;
198
//colocando mais detetores
199 200 201 202
G4double pos1 = initial_pos;
G4cout << pos1 << G4endl;
positions.push_back(pos1);
G4cout << positions[0];
203
   new G4PVPlacement(0,
204
                     G4ThreeVector(0,0,(initial_pos)),
205 206 207 208 209 210 211
                     logicDetector1,
                     "detector1",
                      logicWorld,
                      false,
                      1,
                      checkOverlaps);

212 213
G4double pos2 = (initial_pos + delta_h);
positions.push_back(pos2);
214
   new G4PVPlacement(0,
215
                     G4ThreeVector(0,0,(pos2)),
216 217 218 219 220 221 222
                     logicDetector2,
                     "detector2",
                      logicWorld,
                      false,
                      1,
                     checkOverlaps);

223 224
G4double pos3 = (initial_pos + 2*delta_h);
positions.push_back(pos3);
225

226
  new G4PVPlacement(0,
227
                     G4ThreeVector(0,0,(pos3)),
228 229 230 231 232 233 234
                     logicDetector3,
                     "detector3",
                      logicWorld,
                      false,
                      1,
                     checkOverlaps);

235 236 237
G4double pos4 = (initial_pos + 3*delta_h);
positions.push_back(pos4);
G4cout << h << G4endl;
238
   new G4PVPlacement(0,
239
                    G4ThreeVector(0,0,(pos4)),
240 241 242 243 244 245 246
                     logicDetector4,
                     "detector4",
                      logicWorld,
                      false,
                      1,
                     checkOverlaps);

247 248 249 250

G4double  pos5 = (initial_pos + 4*delta_h);
positions.push_back(pos5);

251
    new G4PVPlacement(0,
252
                     G4ThreeVector(0,0,(pos5)),
253 254 255 256 257 258 259
                     logicDetector5,
                     "detector5",
                      logicWorld,
                      false,
                      1,
                     checkOverlaps);

260 261 262 263

G4double pos6 = (initial_pos + 5*delta_h);
positions.push_back(pos6);

264
    new G4PVPlacement(0,
265
                     G4ThreeVector(0,0,(pos6)),
266 267 268 269 270 271 272
                     logicDetector6,
                     "detector6",
                      logicWorld,
                      false,
                      1,
                     checkOverlaps);

273 274 275
G4double pos7 = (initial_pos + 6*delta_h);
positions.push_back(pos7);

276
    new G4PVPlacement(0,
277
                     G4ThreeVector(0,0,(pos7)),
278 279 280 281 282 283 284
                     logicDetector7,
                     "detector7",
                      logicWorld,
                      false,
                      1,
                     checkOverlaps);

285 286
G4double pos8 = (initial_pos + 7*delta_h);
positions.push_back(pos8);
287 288

    new G4PVPlacement(0,
289
                     G4ThreeVector(0,0,(pos8)),
290 291 292 293 294 295 296
                     logicDetector8,
                     "detector8",
                      logicWorld,
                      false,
                      1,
                     checkOverlaps);

297 298 299
G4double pos9 = (initial_pos + 8*delta_h);
positions.push_back(pos9);

300
   new G4PVPlacement(0,
301
                     G4ThreeVector(0,0,(pos9)),
302 303 304 305 306 307 308
                     logicDetector9,
                     "detector9",
                      logicWorld,
                      false,
                      1,
                     checkOverlaps);

309 310 311
G4double pos10 = (initial_pos + 9*delta_h);
positions.push_back(pos10);

312
   new G4PVPlacement(0,
313
                     G4ThreeVector(0,0,pos10),
314 315 316 317 318 319 320
                     logicDetector10,
                     "detector10",
                      logicWorld,
                      false,
                      1,
                     checkOverlaps);

321 322 323
G4double pos11 = (initial_pos + 10*delta_h);
positions.push_back(pos11);

324
   new G4PVPlacement(0,
325
                     G4ThreeVector(0,0,pos11),
326 327 328 329 330 331
                     logicDetector11,
                     "detector11",
                      logicWorld,
                      false,
                      1,
                     checkOverlaps);
332 333 334 335

G4double pos12 = (initial_pos + 11*delta_h);
positions.push_back(pos12);

336
  new G4PVPlacement(0,
337
                     G4ThreeVector(0,0,pos12),
338 339 340 341 342 343
                     logicDetector12,
                     "detector12",
                      logicWorld,
                      false,
                      1,
                     checkOverlaps);
344 345 346 347

G4double pos13 = (initial_pos + 12*delta_h);
positions.push_back(pos13);

348
  new G4PVPlacement(0,
349
                     G4ThreeVector(0,0,pos13),
350 351 352 353 354 355 356
                     logicDetector13,
                     "detector13",
                      logicWorld,
                      false,
                      1,
                     checkOverlaps);

357 358 359
G4double pos14 = (initial_pos + 13*delta_h);
positions.push_back(pos14);

360
   new G4PVPlacement(0,
361
                     G4ThreeVector(0,0,pos14),
362 363 364 365 366 367 368
                     logicDetector14,
                     "detector14",
                      logicWorld,
                      false,
                      1,
                     checkOverlaps);

369 370 371
G4double pos15 = (initial_pos + 14*delta_h);
positions.push_back(pos15);

372
 new G4PVPlacement(0,
373
                     G4ThreeVector(0,0,pos15),
374 375 376 377 378 379 380
                     logicDetector15,
                     "detector15",
                      logicWorld,
                      false,
                      1,
                     checkOverlaps);

381 382 383
G4double pos16 = (initial_pos + 15*delta_h);
positions.push_back(pos16);

384
 new G4PVPlacement(0,
385
                     G4ThreeVector(0,0,pos16),
386 387 388 389 390 391 392
                     logicDetector16,
                     "detector16",
                      logicWorld,
                      false,
                      1,
                     checkOverlaps);

393 394 395
G4double pos17 = (initial_pos + 16*delta_h);
positions.push_back(pos17);

396
new G4PVPlacement(0,
397
                     G4ThreeVector(0,0,pos17),
398 399 400 401 402 403 404
                     logicDetector17,
                     "detector17",
                      logicWorld,
                      false,
                      1,
                     checkOverlaps);

405 406 407
G4double pos18 = (initial_pos + 17*delta_h);
positions.push_back(pos18);

408
new G4PVPlacement(0,
409
                  G4ThreeVector(0,0,pos18),
410 411 412 413 414 415 416 417
                  logicDetector18,
                  "detector18",
                  logicWorld,
                  false,
                  1,
                  checkOverlaps);


418 419 420
/*

positions.push_back(final_pos);
421 422

new G4PVPlacement(0,
423
                  G4ThreeVector(0,0,(final_pos)),
424 425 426 427 428 429
                  logicDetector19,
                  "detector19",
                  logicWorld,
                  false,
                  1,
                  checkOverlaps);
430
*/
431 432 433 434

    //fScoringDetector = logicDetector;

   //associando à um sensitive G4VSensitiveDetecto
435
  auto sdman = G4SDManager::GetSDMpointer();
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527

  G4String SDname1;
  auto sensitive1 = new B1SD(SDname1 = "SD1");
  sdman->AddNewDetector(sensitive1);
  logicDetector1->SetSensitiveDetector(sensitive1);

  G4String SDname2;
  auto sensitive2 = new B1SD(SDname2 = "SD2");
  sdman->AddNewDetector(sensitive2);
  logicDetector2->SetSensitiveDetector(sensitive2);

 G4String SDname3;
  auto sensitive3 = new B1SD(SDname3 = "SD3");
  sdman->AddNewDetector(sensitive3);
  logicDetector3->SetSensitiveDetector(sensitive3);

G4String SDname4;
  auto sensitive4 = new B1SD(SDname4 = "SD4");
  sdman->AddNewDetector(sensitive4);
  logicDetector4->SetSensitiveDetector(sensitive4);

G4String SDname5;
  auto sensitive5 = new B1SD(SDname5 = "SD5");
  sdman->AddNewDetector(sensitive5);
  logicDetector5->SetSensitiveDetector(sensitive5);

G4String SDname6;
  auto sensitive6 = new B1SD(SDname6 = "SD6");
  sdman->AddNewDetector(sensitive6);
  logicDetector6->SetSensitiveDetector(sensitive6);

G4String SDname7;
  auto sensitive7 = new B1SD(SDname7 = "SD7");
  sdman->AddNewDetector(sensitive7);
  logicDetector7->SetSensitiveDetector(sensitive7);

G4String SDname8;
  auto sensitive8 = new B1SD(SDname8 = "SD8");
  sdman->AddNewDetector(sensitive8);
  logicDetector8->SetSensitiveDetector(sensitive8);

G4String SDname9;
  auto sensitive9 = new B1SD(SDname9 = "SD9");
  sdman->AddNewDetector(sensitive9);
  logicDetector9->SetSensitiveDetector(sensitive9);

G4String SDname10;
  auto sensitive10 = new B1SD(SDname10 = "SD10");
  sdman->AddNewDetector(sensitive10);
  logicDetector10->SetSensitiveDetector(sensitive10);

G4String SDname11;
  auto sensitive11 = new B1SD(SDname11 = "SD11");
  sdman->AddNewDetector(sensitive11);
  logicDetector11->SetSensitiveDetector(sensitive11);

G4String SDname12;
  auto sensitive12 = new B1SD(SDname12 = "SD12");
  sdman->AddNewDetector(sensitive12);
  logicDetector12->SetSensitiveDetector(sensitive12);

G4String SDname13;
  auto sensitive13 = new B1SD(SDname13 = "SD13");
  sdman->AddNewDetector(sensitive13);
  logicDetector13->SetSensitiveDetector(sensitive13);

G4String SDname14;
  auto sensitive14 = new B1SD(SDname14 = "SD14");
  sdman->AddNewDetector(sensitive14);
  logicDetector14->SetSensitiveDetector(sensitive14);


G4String SDname15;
  auto sensitive15 = new B1SD(SDname15 = "SD15");
  sdman->AddNewDetector(sensitive15);
  logicDetector15->SetSensitiveDetector(sensitive15);

G4String SDname16;
  auto sensitive16 = new B1SD(SDname16 = "SD16");
  sdman->AddNewDetector(sensitive16);
  logicDetector16->SetSensitiveDetector(sensitive16);

G4String SDname17;
  auto sensitive17 = new B1SD(SDname17 = "SD17");
  sdman->AddNewDetector(sensitive17);
  logicDetector17->SetSensitiveDetector(sensitive17);

  G4String SDname18;
  auto sensitive18 = new B1SD(SDname18= "SD18");
  sdman->AddNewDetector(sensitive18);
  logicDetector18->SetSensitiveDetector(sensitive18);

528
/*
529 530 531 532 533
    G4String SDname19;
    auto sensitive19 = new B1SD(SDname19= "SD19");
      sdman->AddNewDetector(sensitive19);
      logicDetector19->SetSensitiveDetector(sensitive19);

534
*/
535 536 537 538
    //colocando cor vermelha para detector
  G4VisAttributes* worldVisAtt1 = new G4VisAttributes(G4Colour(1.0,0.0,0.0));
  worldVisAtt1->SetVisibility(true);

539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556
  logicDetector1->SetVisAttributes(worldVisAtt1);
  logicDetector2->SetVisAttributes(worldVisAtt1);
  logicDetector3->SetVisAttributes(worldVisAtt1);
  logicDetector4->SetVisAttributes(worldVisAtt1);
  logicDetector5->SetVisAttributes(worldVisAtt1);
  logicDetector6->SetVisAttributes(worldVisAtt1);
  logicDetector7->SetVisAttributes(worldVisAtt1);
  logicDetector8->SetVisAttributes(worldVisAtt1);
  logicDetector9->SetVisAttributes(worldVisAtt1);
  logicDetector10->SetVisAttributes(worldVisAtt1);
  logicDetector11->SetVisAttributes(worldVisAtt1);
  logicDetector12->SetVisAttributes(worldVisAtt1);
  logicDetector13->SetVisAttributes(worldVisAtt1);
  logicDetector14->SetVisAttributes(worldVisAtt1);
  logicDetector15->SetVisAttributes(worldVisAtt1);
  logicDetector16->SetVisAttributes(worldVisAtt1);
  logicDetector17->SetVisAttributes(worldVisAtt1);
  logicDetector18->SetVisAttributes(worldVisAtt1);
557
//logicDetector19->SetVisAttributes(worldVisAtt1);
558

559 560 561
  return physWorld;
}

562

563
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......