Skip to content
Snippets Groups Projects
Commit 817e4b81 authored by Adrien Matta's avatar Adrien Matta :skull_crossbones:
Browse files

* Fixing Invisible disparition from Geant4

        - now replaced by GetInvisible() for some reason
parent 46368819
No related branches found
No related tags found
No related merge requests found
Pipeline #177695 passed
Showing
with 11152 additions and 12090 deletions
This diff is collapsed.
......@@ -25,62 +25,59 @@
#include "DetectorConstruction.hh"
// G4
#include "G4Material.hh"
#include "G4Box.hh"
#include "G4GeometryManager.hh"
#include "G4LogicalVolume.hh"
#include "G4ThreeVector.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4Material.hh"
#include "G4PVPlacement.hh"
#include "G4VisAttributes.hh"
#include "G4GeometryManager.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4VPhysicalVolume.hh"
#include "G4SolidStore.hh"
#include "G4RegionStore.hh"
#include "G4RunManager.hh"
#include "G4SDManager.hh"
#include "G4RegionStore.hh"
#include "G4SolidStore.hh"
#include "G4ThreeVector.hh"
#include "G4TransportationManager.hh"
#include "G4VPhysicalVolume.hh"
#include "G4VisAttributes.hh"
#ifdef NPS_GDML
#include"G4GDMLParser.hh"
#include "G4GDMLParser.hh"
#endif
// STL
#include<cstdlib>
#include<fstream>
#include<string>
#include<set>
#include <cstdlib>
#include <fstream>
#include <set>
#include <string>
// NPL
#include "RootOutput.h"
#include "NPOptionManager.h"
#include "NPInputParser.h"
#include "NPOptionManager.h"
#include "RootOutput.h"
// NPS
#include "NPSDetectorFactory.hh"
#include "MaterialManager.hh"
#include "DetectorMessenger.hh"
#include "MaterialManager.hh"
#include "NPSDetectorFactory.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::DetectorConstruction(){
world_log = NULL;
world_phys = NULL;
world_box = NULL;
m_Target = NULL;
m_Chamber = NULL ;
m_Messenger = new DetectorMessenger(this);
DetectorConstruction::DetectorConstruction() {
world_log = NULL;
world_phys = NULL;
world_box = NULL;
m_Target = NULL;
m_Chamber = NULL;
m_Messenger = new DetectorMessenger(this);
m_ReadSensitivePtr = &NPS::VDetector::ReadSensitive;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::~DetectorConstruction(){
}
DetectorConstruction::~DetectorConstruction() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* DetectorConstruction::Construct(){
return ReadConfigurationFile();
}
G4VPhysicalVolume* DetectorConstruction::Construct() { return ReadConfigurationFile(); }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::AddDetector(NPS::VDetector* NewDetector){
void DetectorConstruction::AddDetector(NPS::VDetector* NewDetector) {
// Add new detector to vector
m_Detectors.push_back(NewDetector);
......@@ -94,9 +91,8 @@ void DetectorConstruction::AddDetector(NPS::VDetector* NewDetector){
NewDetector->InitializeRootOutput();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){
G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile() {
// Construct the World volume
G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum");
......@@ -105,19 +101,17 @@ G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){
G4double world_y = 100.0 * m;
G4double world_z = 100.0 * m;
if(!world_box)
if (!world_box)
world_box = new G4Box("world_box", world_x, world_y, world_z);
if(!world_log)
if (!world_log)
world_log = new G4LogicalVolume(world_box, Vacuum, "world_log", 0, 0, 0);
if(!world_phys)
world_phys = new G4PVPlacement(0, G4ThreeVector(), world_log, "world", 0, false, 0);
G4VisAttributes* VisAtt = new G4VisAttributes(G4VisAttributes::Invisible);
world_log->SetVisAttributes(VisAtt);
if (!world_phys)
world_phys = new G4PVPlacement(0, G4ThreeVector(), world_log, "world", 0, false, 0);
G4VisAttributes* VisAtt = new G4VisAttributes(G4VisAttributes::GetInvisible());
world_log->SetVisAttributes(VisAtt);
//------------------------------------------------------------------
......@@ -128,22 +122,21 @@ G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){
////////General Reading needs////////
std::string LineBuffer;
std::string DataBuffer;
static bool already=false;
static bool already = false;
std::set<std::string> check;
int VerboseLevel = 0 ;
if(!already){
int VerboseLevel = 0;
if (!already) {
VerboseLevel = NPOptionManager::getInstance()->GetVerboseLevel();
already = 1;
}
else
VerboseLevel = 0;
if(VerboseLevel)
cout << endl << "\033[1;36m//// Reading detector file "<< Path << endl<<endl;
if(already)
cout << endl << "\033[1;36m//// Changing detector file to "<< Path << endl<<endl;
if (VerboseLevel)
cout << endl << "\033[1;36m//// Reading detector file " << Path << endl << endl;
if (already)
cout << endl << "\033[1;36m//// Changing detector file to " << Path << endl << endl;
// Access the DetectorFactory and ask it to load the Class List
std::string classlist = getenv("NPTOOL");
......@@ -156,19 +149,19 @@ G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){
/////////// Search for Target /////////////
////////////////////////////////////////////
std::vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Target");
if(blocks.size()==1){
if (blocks.size() == 1) {
m_Target = new Target();
m_Target->ReadConfiguration(parser);
AddDetector(m_Target);
}
else{
else {
blocks = parser.GetAllBlocksWithToken("CryogenicTarget");
if(blocks.size()==1){
if (blocks.size() == 1) {
m_Target = new Target();
m_Target->ReadConfiguration(parser);
AddDetector(m_Target);
}
else{
else {
cout << "WARNING: No target found in detector input file! Use with caution" << endl;
}
}
......@@ -177,33 +170,33 @@ G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){
////////////////////////////////////////////
blocks.clear();
blocks = parser.GetAllBlocksWithToken("Chamber");
if(blocks.size()==1){
if (blocks.size() == 1) {
m_Chamber = new Chamber();
m_Chamber->ReadConfiguration(parser);
AddDetector(m_Chamber);
}
}
////////////////////////////////////////////
/////////// Search for Detectors ///////////
////////////////////////////////////////////
// Get the list of main token
std::vector<std::string> token = parser.GetAllBlocksToken();
// Look for detectors among them
for(unsigned int i = 0 ; i < token.size() ; i++){
for (unsigned int i = 0; i < token.size(); i++) {
NPS::VDetector* detector = theFactory->Construct(token[i]);
if(detector!=NULL && check.find(token[i])==check.end()){
if (detector != NULL && check.find(token[i]) == check.end()) {
cout << "/////////////////////////////////////////" << endl;
cout << "//// Adding Detector " << token[i] << endl;
cout << "//// Adding Detector " << token[i] << endl;
detector->ReadConfiguration(parser);
cout << "/////////////////////////////////////////" << endl;
// Add array to the VDetector Vector
AddDetector(detector);
check.insert(token[i]);
}
else if(detector!=NULL)
else if (detector != NULL)
delete detector;
}
cout << "\033[0m" ;
cout << "\033[0m";
// Create the Material sample for DEDX tables
MaterialManager::getInstance()->CreateSampleVolumes(world_log);
......@@ -211,29 +204,27 @@ G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::ReadAllSensitive(const G4Event* event){
unsigned int mysize = m_Detectors.size();
for (unsigned short i = 0 ; i < mysize ; i++) {
(m_Detectors[i]->*m_ReadSensitivePtr)(event);
void DetectorConstruction::ReadAllSensitive(const G4Event* event) {
unsigned int mysize = m_Detectors.size();
for (unsigned short i = 0; i < mysize; i++) {
(m_Detectors[i]->*m_ReadSensitivePtr)(event);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4LogicalVolume* DetectorConstruction::GetWorldLogic(){
return world_log;
}
G4LogicalVolume* DetectorConstruction::GetWorldLogic() { return world_log; }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::ClearGeometry(){
void DetectorConstruction::ClearGeometry() {
unsigned int mySize = m_Detectors.size();
for (unsigned short i = 0 ; i < mySize ; i++) {
for (unsigned short i = 0; i < mySize; i++) {
delete m_Detectors[i];
}
m_Detectors.clear();
// Delete previous Sensitive Detector (Scorer)
// Delete previous Sensitive Detector (Scorer)
delete G4SDManager::GetSDMpointer();
G4GeometryManager::GetInstance()->OpenGeometry();
......@@ -241,56 +232,55 @@ void DetectorConstruction::ClearGeometry(){
// Cleaning stores by hand (everything but the world)
// Cleaning the PVP
G4PhysicalVolumeStore* PVP = G4PhysicalVolumeStore::GetInstance();
while(PVP->size()>1){
delete PVP->at(PVP->size()-1);
while (PVP->size() > 1) {
delete PVP->at(PVP->size() - 1);
PVP->pop_back();
}
// Cleaning the Logical Volume
G4LogicalVolumeStore* LV = G4LogicalVolumeStore::GetInstance();
while(LV->size()>1) {
delete LV->at(LV->size()-1);
while (LV->size() > 1) {
delete LV->at(LV->size() - 1);
LV->pop_back();
}
// Cleaning the Solid store
G4SolidStore* SL = G4SolidStore::GetInstance();
while(SL->size()>1) {
delete SL->at(SL->size()-1);
while (SL->size() > 1) {
delete SL->at(SL->size() - 1);
SL->pop_back();
}
G4Region* reg = G4RegionStore::GetInstance()->GetRegion("NPSimulationProcess",false);
if(reg)
G4Region* reg = G4RegionStore::GetInstance()->GetRegion("NPSimulationProcess", false);
if (reg)
G4RegionStore::GetInstance()->DeRegister(reg);
delete reg;
m_Target = 0;
m_Chamber = 0;
m_Target = 0;
m_Chamber = 0;
world_log->ClearDaughters();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::RedefineGeometry(std::string file){
ClearGeometry() ;
void DetectorConstruction::RedefineGeometry(std::string file) {
ClearGeometry();
if(file!="")
if (file != "")
NPOptionManager::getInstance()->SetDetectorFile(file);
Construct();
if(m_Target)
if (m_Target)
m_Target->SetReactionRegion();
G4RunManager::GetRunManager()->GeometryHasBeenModified();
G4RunManager::GetRunManager()->PhysicsHasBeenModified() ;
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
G4RunManager::GetRunManager()->Initialize();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::ExportGeometry(string file){
void DetectorConstruction::ExportGeometry(string file) {
#ifdef NPS_GDML
G4GDMLParser parser ;
parser.Write(file.c_str(),world_log);
G4GDMLParser parser;
parser.Write(file.c_str(), world_log);
#else
// To silenced the compiler
file = "";
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment