Import Geant4 11.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2024-06-28 13:08:51 +02:00
parent f7b23877ed
commit e58e650b32
5232 changed files with 239416 additions and 244360 deletions
@@ -28,25 +28,23 @@
/// \brief Implementation of the ExTGActionInitialization class
#include "ExTGActionInitialization.hh"
#include "ExTGRunAction.hh"
#include "ExTGPrimaryGeneratorAction.hh"
#include "ExTGRunAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGActionInitialization::ExTGActionInitialization()
: G4VUserActionInitialization()
{}
ExTGActionInitialization::ExTGActionInitialization() : G4VUserActionInitialization() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGActionInitialization::~ExTGActionInitialization()
{}
ExTGActionInitialization::~ExTGActionInitialization() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExTGActionInitialization::BuildForMaster() const
{
SetUserAction(new ExTGRunAction);
SetUserAction(new ExTGRunAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -55,6 +53,6 @@ void ExTGActionInitialization::Build() const
{
SetUserAction(new ExTGRunAction);
SetUserAction(new ExTGPrimaryGeneratorAction);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -27,13 +27,14 @@
/// \file persistency/P03/src/ExTGDetectorConstruction.cc
/// \brief Implementation of the ExTGDetectorConstruction class
#include "G4tgbVolumeMgr.hh"
#include "ExTGDetectorConstruction.hh"
#include "G4tgbVolumeMgr.hh"
#include "G4tgrMessenger.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGDetectorConstruction::ExTGDetectorConstruction()
{
{
fMessenger = new G4tgrMessenger;
}
@@ -46,16 +47,16 @@ ExTGDetectorConstruction::~ExTGDetectorConstruction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* ExTGDetectorConstruction::Construct()
{
//------------------------------------------------
//------------------------------------------------
// Define one or several text files containing the geometry description
//------------------------------------------------
//------------------------------------------------
G4String filename = "g4geom.txt";
G4tgbVolumeMgr* volmgr = G4tgbVolumeMgr::GetInstance();
volmgr->AddTextFile(filename);
//------------------------------------------------
//------------------------------------------------
// Read the text files and construct the GEANT4 geometry
//------------------------------------------------
//------------------------------------------------
G4VPhysicalVolume* physiWorld = volmgr->ReadAndConstructDetector();
return physiWorld;
@@ -27,13 +27,14 @@
/// \file persistency/P03/src/ExTGDetectorConstructionWithCpp.cc
/// \brief Implementation of the ExTGDetectorConstructionWithCpp class
#include "G4tgbVolumeMgr.hh"
#include "ExTGDetectorConstructionWithCpp.hh"
#include "G4tgrMessenger.hh"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4NistManager.hh"
#include "G4PVPlacement.hh"
#include "G4tgbVolumeMgr.hh"
#include "G4tgrMessenger.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGDetectorConstructionWithCpp::ExTGDetectorConstructionWithCpp()
@@ -50,26 +51,26 @@ ExTGDetectorConstructionWithCpp::~ExTGDetectorConstructionWithCpp()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* ExTGDetectorConstructionWithCpp::Construct()
{
//------------------------------------------------
//------------------------------------------------
// Define one or several text files containing the geometry description
//------------------------------------------------
//------------------------------------------------
G4String filename = "g4geom_simple.txt";
G4tgbVolumeMgr* volmgr = G4tgbVolumeMgr::GetInstance();
volmgr->AddTextFile(filename);
//------------------------------------------------
//------------------------------------------------
// Read the text files and construct the GEANT4 geometry
//------------------------------------------------
//------------------------------------------------
G4VPhysicalVolume* physiWorld = volmgr->ReadAndConstructDetector();
//------------------------------------------------
//------------------------------------------------
// Build another volume and place it in the text geometry
//------------------------------------------------
G4Box* solid = new G4Box("mybox",2.,2.,3.);
//------------------------------------------------
G4Box* solid = new G4Box("mybox", 2., 2., 3.);
G4Material* water = G4NistManager::Instance()->FindOrBuildMaterial("G4_Fe");
G4LogicalVolume* logicVol = new G4LogicalVolume(solid,water,"mybox",0,0,0);
G4LogicalVolume* logicVol = new G4LogicalVolume(solid, water, "mybox", 0, 0, 0);
//----- Place the volume in the world of the text geometry
G4LogicalVolume* textWorldVol = physiWorld->GetLogicalVolume();
@@ -77,24 +78,23 @@ G4VPhysicalVolume* ExTGDetectorConstructionWithCpp::Construct()
// NOTE: if you want to place your full text geometry in the C++ geometry,
// you should use this G4LogicalVolume and place it in a C++ logical
// volume
new G4PVPlacement(0, // no rotation
G4ThreeVector(0.,-20.,0), // at (x,y,z)
logicVol, // its logical volume
"myBox1", // its name
textWorldVol, // its mother volume
false, // no boolean operations
0); // copy number
new G4PVPlacement(0, // no rotation
G4ThreeVector(0., -20., 0), // at (x,y,z)
logicVol, // its logical volume
"myBox1", // its name
textWorldVol, // its mother volume
false, // no boolean operations
0); // copy number
//----- Place the volume inside a volume of the text geometry
G4LogicalVolume* textSphereVol =
G4tgbVolumeMgr::GetInstance()->FindG4LogVol("sphere",1);
new G4PVPlacement(0, // no rotation
G4ThreeVector(0.,0.,0), // at (x,y,z)
logicVol, // its logical volume
"myBox2", // its name
textSphereVol, // its mother volume
false, // no boolean operations
1); // copy number
G4LogicalVolume* textSphereVol = G4tgbVolumeMgr::GetInstance()->FindG4LogVol("sphere", 1);
new G4PVPlacement(0, // no rotation
G4ThreeVector(0., 0., 0), // at (x,y,z)
logicVol, // its logical volume
"myBox2", // its name
textSphereVol, // its mother volume
false, // no boolean operations
1); // copy number
return physiWorld;
}
@@ -28,7 +28,9 @@
/// \brief Implementation of the ExTGDetectorConstructionWithCuts class
#include "ExTGDetectorConstructionWithCuts.hh"
#include "ExTGRCDetectorBuilder.hh"
#include "G4tgbVolumeMgr.hh"
#include "G4tgrMessenger.hh"
@@ -47,18 +49,18 @@ ExTGDetectorConstructionWithCuts::~ExTGDetectorConstructionWithCuts()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* ExTGDetectorConstructionWithCuts::Construct()
{
//------------------------------------------------
//------------------------------------------------
// Define one or several text files containing the geometry description
//------------------------------------------------
//------------------------------------------------
G4String filename = "g4geom_cutsPerRegion.txt";
G4tgbVolumeMgr* volmgr = G4tgbVolumeMgr::GetInstance();
volmgr->AddTextFile(filename);
//------------------------------------------------
//------------------------------------------------
// Use your own detector builder, that will invoke your own line processor
//------------------------------------------------
//------------------------------------------------
ExTGRCDetectorBuilder* gtb = new ExTGRCDetectorBuilder;
volmgr->SetDetectorBuilder( gtb );
volmgr->SetDetectorBuilder(gtb);
const G4tgrVolume* tgrVoltop = gtb->ReadDetector();
G4VPhysicalVolume* physiWorld = gtb->ConstructDetector(tgrVoltop);
@@ -29,11 +29,11 @@
/// \brief Implementation of the ExTGDetectorConstructionWithSD class
#include "ExTGDetectorConstructionWithSD.hh"
#include "ExTGTrackerSD.hh"
#include "G4LogicalVolume.hh"
#include "G4SDManager.hh"
#include "G4tgbVolumeMgr.hh"
#include "G4tgrMessenger.hh"
@@ -52,16 +52,16 @@ ExTGDetectorConstructionWithSD::~ExTGDetectorConstructionWithSD()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* ExTGDetectorConstructionWithSD::Construct()
{
//------------------------------------------------
//------------------------------------------------
// Define one or several text files containing the geometry description
//------------------------------------------------
//------------------------------------------------
G4String filename = "g4geom_SD.txt";
G4tgbVolumeMgr* volmgr = G4tgbVolumeMgr::GetInstance();
volmgr->AddTextFile(filename);
//------------------------------------------------
//------------------------------------------------
// Read the text files and construct the GEANT4 geometry
//------------------------------------------------
//------------------------------------------------
G4VPhysicalVolume* physiWorld = volmgr->ReadAndConstructDetector();
return physiWorld;
@@ -69,24 +69,19 @@ G4VPhysicalVolume* ExTGDetectorConstructionWithSD::Construct()
void ExTGDetectorConstructionWithSD::ConstructSDandField()
{
//------------------------------------------------
//------------------------------------------------
// Sensitive detectors
//------------------------------------------------
//------------------------------------------------
G4String trackerChamberSDname = "ExTextGeom/TrackerChamberSD";
ExTGTrackerSD* aTrackerSD = new ExTGTrackerSD( trackerChamberSDname );
ExTGTrackerSD* aTrackerSD = new ExTGTrackerSD(trackerChamberSDname);
G4SDManager::GetSDMpointer()->AddNewDetector(aTrackerSD);
G4LogicalVolume * logicChamber =
G4tgbVolumeMgr::GetInstance()->FindG4LogVol("Chamber",0);
if(logicChamber)
{
SetSensitiveDetector("Chamber", aTrackerSD );
G4LogicalVolume* logicChamber = G4tgbVolumeMgr::GetInstance()->FindG4LogVol("Chamber", 0);
if (logicChamber) {
SetSensitiveDetector("Chamber", aTrackerSD);
}
else
{
G4Exception("ExTGDetectorConstructionWithSD::Construct()",
"InvalidGeometry", JustWarning,
else {
G4Exception("ExTGDetectorConstructionWithSD::Construct()", "InvalidGeometry", JustWarning,
"Volume does not exists in geometry: Chamber");
}
}
@@ -28,12 +28,13 @@
/// \brief Implementation of the ExTGPrimaryGeneratorAction class
#include "ExTGPrimaryGeneratorAction.hh"
#include "G4Event.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "globals.hh"
#include "G4SystemOfUnits.hh"
#include "globals.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGPrimaryGeneratorAction::ExTGPrimaryGeneratorAction()
@@ -41,14 +42,14 @@ ExTGPrimaryGeneratorAction::ExTGPrimaryGeneratorAction()
G4int n_particle = 1;
fParticleGun = new G4ParticleGun(n_particle);
// default particle
// default particle
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4ParticleDefinition* particle = particleTable->FindParticle("e-");
fParticleGun->SetParticleDefinition(particle);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
fParticleGun->SetParticleEnergy(10*MeV);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0., 0., 1.));
fParticleGun->SetParticleEnergy(10 * MeV);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -59,9 +60,8 @@ ExTGPrimaryGeneratorAction::~ExTGPrimaryGeneratorAction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExTGPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
fParticleGun->SetParticlePosition(G4ThreeVector(0.*cm,0.*cm,0.*cm));
{
fParticleGun->SetParticlePosition(G4ThreeVector(0. * cm, 0. * cm, 0. * cm));
fParticleGun->GeneratePrimaryVertex(anEvent);
}
@@ -28,6 +28,7 @@
/// \brief Implementation of the ExTGRCDetectorBuilder class
#include "ExTGRCDetectorBuilder.hh"
#include "ExTGRCLineProcessor.hh"
#include "ExTGRCRegionCutsMgr.hh"
@@ -35,15 +36,14 @@
#include "G4tgrVolumeMgr.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGRCDetectorBuilder::ExTGRCDetectorBuilder()
: G4tgbDetectorBuilder(), fTlproc(0)
{
}
ExTGRCDetectorBuilder::ExTGRCDetectorBuilder() : G4tgbDetectorBuilder(), fTlproc(0) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGRCDetectorBuilder::~ExTGRCDetectorBuilder()
{
if (fTlproc) { delete fTlproc; }
if (fTlproc) {
delete fTlproc;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -52,10 +52,10 @@ const G4tgrVolume* ExTGRCDetectorBuilder::ReadDetector()
//------------------- construct geometry
fTlproc = new ExTGRCLineProcessor;
G4tgrFileReader* tfr = G4tgrFileReader::GetInstance();
tfr->SetLineProcessor( fTlproc );
tfr->SetLineProcessor(fTlproc);
tfr->ReadFiles();
//---------- find top G4tgrVolume
//---------- find top G4tgrVolume
G4tgrVolumeMgr* tgrVolmgr = G4tgrVolumeMgr::GetInstance();
const G4tgrVolume* tgrVoltop = tgrVolmgr->GetTopVolume();
@@ -63,17 +63,15 @@ const G4tgrVolume* ExTGRCDetectorBuilder::ReadDetector()
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* ExTGRCDetectorBuilder::
ConstructDetector( const G4tgrVolume* tgrVoltop)
G4VPhysicalVolume* ExTGRCDetectorBuilder::ConstructDetector(const G4tgrVolume* tgrVoltop)
{
G4VPhysicalVolume* topPV =
G4tgbDetectorBuilder::ConstructDetector( tgrVoltop );
G4VPhysicalVolume* topPV = G4tgbDetectorBuilder::ConstructDetector(tgrVoltop);
//--- Create regions
ExTGRCRegionCutsMgr::GetInstance()->BuildRegions();
//--- Set cuts to regions
ExTGRCRegionCutsMgr::GetInstance()->BuildProductionCuts();
ExTGRCRegionCutsMgr::GetInstance()->BuildProductionCuts();
return topPV;
}
@@ -28,61 +28,51 @@
/// \brief Implementation of the ExTGRCLineProcessor class
#include "ExTGRCLineProcessor.hh"
#include "ExTGRCRegionCutsMgr.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGRCLineProcessor::ExTGRCLineProcessor() : G4tgrLineProcessor()
{
}
ExTGRCLineProcessor::ExTGRCLineProcessor() : G4tgrLineProcessor() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGRCLineProcessor::~ExTGRCLineProcessor()
{
}
ExTGRCLineProcessor::~ExTGRCLineProcessor() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool ExTGRCLineProcessor::ProcessLine( const std::vector<G4String>& wl )
G4bool ExTGRCLineProcessor::ProcessLine(const std::vector<G4String>& wl)
{
G4bool iret = G4tgrLineProcessor::ProcessLine( wl );
G4bool iret = G4tgrLineProcessor::ProcessLine(wl);
G4String wl0 = wl[0];
for( size_t ii = 0; ii < wl0.length(); ii++ )
{
wl0[ii] = toupper( wl0[ii] );
for (size_t ii = 0; ii < wl0.length(); ii++) {
wl0[ii] = toupper(wl0[ii]);
}
if( !iret )
{
if (!iret) {
//------------------------------- parameter number
if( wl0 == ":REGION" )
{
std::vector<G4String>::const_iterator ite = wl.begin()+1;
if (wl0 == ":REGION") {
std::vector<G4String>::const_iterator ite = wl.begin() + 1;
std::vector<G4String> wlc;
for( ; ite != wl.end(); ite++ ) //loop skipping the first one
for (; ite != wl.end(); ite++) // loop skipping the first one
{
wlc.push_back( *ite );
wlc.push_back(*ite);
}
// wlc = wlc.erase( wlc.begin() );
ExTGRCRegionCutsMgr::GetInstance()->AddRegionData( wlc );
iret = 1;
ExTGRCRegionCutsMgr::GetInstance()->AddRegionData(wlc);
iret = 1;
}
else if( wl0 == ":CUTS" )
{
std::vector<G4String>::const_iterator ite = wl.begin()+1;
else if (wl0 == ":CUTS") {
std::vector<G4String>::const_iterator ite = wl.begin() + 1;
std::vector<G4String> wlc;
for( ; ite != wl.end(); ite++ ) //loop skipping the first one
for (; ite != wl.end(); ite++) // loop skipping the first one
{
wlc.push_back( *ite );
wlc.push_back(*ite);
}
ExTGRCRegionCutsMgr::GetInstance()->AddRegionCuts( wlc );
iret = 1;
ExTGRCRegionCutsMgr::GetInstance()->AddRegionCuts(wlc);
iret = 1;
}
else {
iret = 0;
}
else
{
iret = 0;
}
}
return iret;
@@ -28,32 +28,30 @@
/// \brief Implementation of the ExTGRCRegionCutsMgr class
#include "ExTGRCRegionCutsMgr.hh"
#include "ExTGRCRegionData.hh"
#include "G4LogicalVolume.hh"
#include "G4ProductionCuts.hh"
#include "G4Region.hh"
#include "G4RegionStore.hh"
#include "G4ProductionCuts.hh"
#include "G4LogicalVolume.hh"
#include "G4UIcommand.hh"
#include "G4tgbVolumeMgr.hh"
#include "G4tgrUtils.hh"
#include "G4UIcommand.hh"
ExTGRCRegionCutsMgr* ExTGRCRegionCutsMgr::fInstance = 0;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGRCRegionCutsMgr* ExTGRCRegionCutsMgr::GetInstance()
{
if( !fInstance )
{
if (!fInstance) {
fInstance = new ExTGRCRegionCutsMgr;
}
return fInstance;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGRCRegionCutsMgr::ExTGRCRegionCutsMgr()
{
}
ExTGRCRegionCutsMgr::ExTGRCRegionCutsMgr() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGRCRegionCutsMgr::~ExTGRCRegionCutsMgr()
@@ -62,62 +60,52 @@ ExTGRCRegionCutsMgr::~ExTGRCRegionCutsMgr()
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExTGRCRegionCutsMgr::AddRegionData( const std::vector<G4String>& rd )
void ExTGRCRegionCutsMgr::AddRegionData(const std::vector<G4String>& rd)
{
if( (rd.size() > 1) && (FindRegionData( rd[0] ).size() != 0) )
{
G4Exception("ExTGRCRegionCutsMgr::AddRegionData", "InvalidArgument",
JustWarning,
G4String("Region already exists: " + rd[0]).c_str() );
if ((rd.size() > 1) && (FindRegionData(rd[0]).size() != 0)) {
G4Exception("ExTGRCRegionCutsMgr::AddRegionData", "InvalidArgument", JustWarning,
G4String("Region already exists: " + rd[0]).c_str());
return;
}
fRegionDatae.push_back( new ExTGRCRegionData( rd ) );
fRegionDatae.push_back(new ExTGRCRegionData(rd));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExTGRCRegionCutsMgr::AddRegionCuts( const std::vector<G4String>& rc )
void ExTGRCRegionCutsMgr::AddRegionCuts(const std::vector<G4String>& rc)
{
if( rc.size() == 0 )
{
if (rc.size() == 0) {
G4cerr << "ERROR - ExTGRCRegionCutsMgr::AddRegionCuts()" << G4endl
<< " Must have 3 or 4 arguments : REGION_NAME, gamma_CUT,"
<< " e-_CUT (e+_CUT)." << G4endl
<< " It has only " << rc.size() << " !" << G4endl;
G4Exception("ExTGRCRegionCutsMgr::AddRegionCuts()", "InvalidArgument",
FatalErrorInArgument, G4UIcommand::ConvertToString(G4int(rc.size())) );
<< " e-_CUT (e+_CUT)." << G4endl << " It has only " << rc.size() << " !"
<< G4endl;
G4Exception("ExTGRCRegionCutsMgr::AddRegionCuts()", "InvalidArgument", FatalErrorInArgument,
G4UIcommand::ConvertToString(G4int(rc.size())));
}
// Find region
// std::vector<ExTGRCRegionData*>::const_iterator iter;
std::vector<ExTGRCRegionData*> regs = FindRegionData(rc[0]);
if( regs.size() == 0 )
{
G4Exception("ExTGRCRegionCutsMgr::AddRegionCuts()",
"InvalidArgument", FatalErrorInArgument,
if (regs.size() == 0) {
G4Exception("ExTGRCRegionCutsMgr::AddRegionCuts()", "InvalidArgument", FatalErrorInArgument,
G4String(" region does not exist: " + rc[0]).c_str());
}
}
for( size_t ii = 0; ii < regs.size(); ii++)
{
regs[ii]->SetCutsData( rc );
for (size_t ii = 0; ii < regs.size(); ii++) {
regs[ii]->SetCutsData(rc);
}
}
std::vector<ExTGRCRegionData*>
ExTGRCRegionCutsMgr::FindRegionData( const G4String& name)
std::vector<ExTGRCRegionData*> ExTGRCRegionCutsMgr::FindRegionData(const G4String& name)
{
std::vector<ExTGRCRegionData*> regs;
std::vector<ExTGRCRegionData*>::const_iterator iter;
for( iter = fRegionDatae.begin(); iter != fRegionDatae.end(); iter++ )
{
if( G4tgrUtils::AreWordsEquivalent( name , (*iter)->GetRegionName()) )
{
for (iter = fRegionDatae.begin(); iter != fRegionDatae.end(); iter++) {
if (G4tgrUtils::AreWordsEquivalent(name, (*iter)->GetRegionName())) {
regs.push_back(*iter);
}
}
return regs;
return regs;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -126,15 +114,12 @@ void ExTGRCRegionCutsMgr::BuildRegions()
std::vector<ExTGRCRegionData*>::const_iterator iter;
std::vector<G4String>::const_iterator ites;
// std::vector<G4LogicalVolume*>::const_iterator itelv;
for( iter = fRegionDatae.begin(); iter != fRegionDatae.end(); iter++ )
{
G4Region* reg = new G4Region( (*iter)->GetRegionName() );
for (iter = fRegionDatae.begin(); iter != fRegionDatae.end(); iter++) {
G4Region* reg = new G4Region((*iter)->GetRegionName());
std::vector<G4String> lvs = (*iter)->GetLVNames();
for( ites = lvs.begin(); ites != lvs.end(); ites++ )
{
G4LogicalVolume* logVol =
G4tgbVolumeMgr::GetInstance()->FindG4LogVol(*ites, true );
reg->AddRootLogicalVolume( logVol );
for (ites = lvs.begin(); ites != lvs.end(); ites++) {
G4LogicalVolume* logVol = G4tgbVolumeMgr::GetInstance()->FindG4LogVol(*ites, true);
reg->AddRootLogicalVolume(logVol);
}
}
}
@@ -145,22 +130,19 @@ void ExTGRCRegionCutsMgr::BuildProductionCuts()
std::vector<ExTGRCRegionData*>::const_iterator iter;
G4RegionStore* regions = G4RegionStore::GetInstance();
//----- loop to region datae
for( iter = fRegionDatae.begin(); iter != fRegionDatae.end(); iter++ )
{
if( (*iter)->CutsAreSet() )
{
G4Region* reg = regions->GetRegion( (*iter)->GetRegionName() );
if( !reg )
{
G4Exception("ExTGRCRegionCutsMgr::BuildProductionCuts()",
"InvalidArgument", FatalErrorInArgument,
G4String("Region not found: " + (*iter)->GetRegionName()).c_str() );
}
G4ProductionCuts* cuts = new G4ProductionCuts ;
for (iter = fRegionDatae.begin(); iter != fRegionDatae.end(); iter++) {
if ((*iter)->CutsAreSet()) {
G4Region* reg = regions->GetRegion((*iter)->GetRegionName());
if (!reg) {
G4Exception("ExTGRCRegionCutsMgr::BuildProductionCuts()", "InvalidArgument",
FatalErrorInArgument,
G4String("Region not found: " + (*iter)->GetRegionName()).c_str());
}
G4ProductionCuts* cuts = new G4ProductionCuts;
cuts->SetProductionCut((*iter)->GetGammaCut(),"gamma");
cuts->SetProductionCut((*iter)->GetElectronCut(),"e-");
cuts->SetProductionCut((*iter)->GetPositronCut(),"e+");
cuts->SetProductionCut((*iter)->GetGammaCut(), "gamma");
cuts->SetProductionCut((*iter)->GetElectronCut(), "e-");
cuts->SetProductionCut((*iter)->GetPositronCut(), "e+");
reg->SetProductionCuts(cuts);
}
}
@@ -28,22 +28,20 @@
/// \brief Implementation of the ExTGRCRegionData class
#include "ExTGRCRegionData.hh"
#include "G4tgrUtils.hh"
#include "G4UIcommand.hh"
#include "G4tgrUtils.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGRCRegionData::ExTGRCRegionData(const std::vector<G4String>& wl )
ExTGRCRegionData::ExTGRCRegionData(const std::vector<G4String>& wl)
{
if( wl.size() < 2 )
{
G4Exception("ExTGRCRegionData::ExTGRCRegionData()",
"InvalidArgument", FatalErrorInArgument,
G4UIcommand::ConvertToString( G4int(wl.size()) ) );
if (wl.size() < 2) {
G4Exception("ExTGRCRegionData::ExTGRCRegionData()", "InvalidArgument", FatalErrorInArgument,
G4UIcommand::ConvertToString(G4int(wl.size())));
}
fRegionName = wl[0];
for( size_t ii = 1; ii < wl.size(); ii++ )
{
fLVNames.push_back( wl[ii] );
for (size_t ii = 1; ii < wl.size(); ii++) {
fLVNames.push_back(wl[ii]);
}
fbCutsSet = false;
fGammaCut = 1.;
@@ -52,40 +50,32 @@ ExTGRCRegionData::ExTGRCRegionData(const std::vector<G4String>& wl )
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGRCRegionData::~ExTGRCRegionData()
{
}
ExTGRCRegionData::~ExTGRCRegionData() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExTGRCRegionData::SetCutsData( const std::vector<G4String>& rc )
void ExTGRCRegionData::SetCutsData(const std::vector<G4String>& rc)
{
if( (rc.size() != 3) && (rc.size() != 4) )
{
if ((rc.size() != 3) && (rc.size() != 4)) {
G4cerr << "ERROR - ExTGRCRegionData::SetCutsData()" << G4endl
<< " Must have 3 or 4 arguments : "
<< "REGION_NAME, gamma_CUT, e-_CUT (e+_CUT)." << G4endl
<< " It has only " << rc.size() << " !" << G4endl;
G4Exception("ExTGRCRegionCutsMgr::AddRegionCuts()",
"InvalidArgument", FatalErrorInArgument,
G4UIcommand::ConvertToString( G4int(rc.size()) ) );
<< "REGION_NAME, gamma_CUT, e-_CUT (e+_CUT)." << G4endl << " It has only "
<< rc.size() << " !" << G4endl;
G4Exception("ExTGRCRegionCutsMgr::AddRegionCuts()", "InvalidArgument", FatalErrorInArgument,
G4UIcommand::ConvertToString(G4int(rc.size())));
}
if( fbCutsSet )
{
G4Exception("ExTGRCRegionData::SetCutsData()",
"InvalidArgument", JustWarning,
G4String("Cuts are already set for region " + fRegionName).c_str() );
if (fbCutsSet) {
G4Exception("ExTGRCRegionData::SetCutsData()", "InvalidArgument", JustWarning,
G4String("Cuts are already set for region " + fRegionName).c_str());
}
fGammaCut = G4tgrUtils::GetDouble( rc[1] );
fElectronCut = G4tgrUtils::GetDouble( rc[2] );
if( rc.size() == 3 )
{
fGammaCut = G4tgrUtils::GetDouble(rc[1]);
fElectronCut = G4tgrUtils::GetDouble(rc[2]);
if (rc.size() == 3) {
fPositronCut = fElectronCut;
}
else
{
fPositronCut = G4tgrUtils::GetDouble( rc[3] );
else {
fPositronCut = G4tgrUtils::GetDouble(rc[3]);
}
fbCutsSet = true;
@@ -32,23 +32,16 @@
#include "G4tgbGeometryDumper.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGRunAction::ExTGRunAction()
ExTGRunAction::ExTGRunAction() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGRunAction::~ExTGRunAction() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExTGRunAction::BeginOfRunAction(const G4Run*)
{
if (IsMaster()) G4tgbGeometryDumper::GetInstance()->DumpGeometry("geom.txt");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGRunAction::~ExTGRunAction()
{
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExTGRunAction::BeginOfRunAction(const G4Run* )
{
if( IsMaster() ) G4tgbGeometryDumper::GetInstance()->DumpGeometry("geom.txt");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExTGRunAction::EndOfRunAction(const G4Run*)
{
}
void ExTGRunAction::EndOfRunAction(const G4Run*) {}
@@ -29,60 +29,55 @@
/// \brief Implementation of the ExTGTrackerHit class
#include "ExTGTrackerHit.hh"
#include "G4UnitsTable.hh"
#include "G4VVisManager.hh"
#include "G4Circle.hh"
#include "G4Colour.hh"
#include "G4UnitsTable.hh"
#include "G4VVisManager.hh"
#include "G4VisAttributes.hh"
G4ThreadLocal G4Allocator<ExTGTrackerHit>* ExTGTrackerHitAllocator = 0;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGTrackerHit::ExTGTrackerHit()
{
}
ExTGTrackerHit::ExTGTrackerHit() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGTrackerHit::~ExTGTrackerHit()
{
}
ExTGTrackerHit::~ExTGTrackerHit() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGTrackerHit::ExTGTrackerHit(const ExTGTrackerHit& right)
: G4VHit()
ExTGTrackerHit::ExTGTrackerHit(const ExTGTrackerHit& right) : G4VHit()
{
fTrackID = right.fTrackID;
fTrackID = right.fTrackID;
fChamberNb = right.fChamberNb;
fEdep = right.fEdep;
fPos = right.fPos;
fEdep = right.fEdep;
fPos = right.fPos;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const ExTGTrackerHit& ExTGTrackerHit::operator=(const ExTGTrackerHit& right)
{
fTrackID = right.fTrackID;
fTrackID = right.fTrackID;
fChamberNb = right.fChamberNb;
fEdep = right.fEdep;
fPos = right.fPos;
fEdep = right.fEdep;
fPos = right.fPos;
return *this;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool ExTGTrackerHit::operator==(const ExTGTrackerHit& right) const
{
return (this==&right) ? true : false;
return (this == &right) ? true : false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExTGTrackerHit::Draw()
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if(pVVisManager)
{
if (pVVisManager) {
G4Circle circle(fPos);
circle.SetScreenSize(2.);
circle.SetFillStyle(G4Circle::filled);
G4Colour colour(1.,0.,0.);
G4Colour colour(1., 0., 0.);
G4VisAttributes attribs(colour);
circle.SetVisAttributes(attribs);
pVVisManager->Draw(circle);
@@ -93,6 +88,6 @@ void ExTGTrackerHit::Draw()
void ExTGTrackerHit::Print()
{
G4cout << " trackID: " << fTrackID << " chamberNb: " << fChamberNb
<< " energy deposit: " << G4BestUnit(fEdep,"Energy")
<< " position: " << G4BestUnit(fPos,"Length") << G4endl;
<< " energy deposit: " << G4BestUnit(fEdep, "Energy")
<< " position: " << G4BestUnit(fPos, "Length") << G4endl;
}
@@ -29,55 +29,52 @@
/// \brief Implementation of the ExTGTrackerSD class
#include "ExTGTrackerSD.hh"
#include "G4HCofThisEvent.hh"
#include "G4SDManager.hh"
#include "G4Step.hh"
#include "G4ThreeVector.hh"
#include "G4SDManager.hh"
#include "G4ios.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGTrackerSD::ExTGTrackerSD(G4String name)
:G4VSensitiveDetector(name)
ExTGTrackerSD::ExTGTrackerSD(G4String name) : G4VSensitiveDetector(name)
{
G4String HCname;
collectionName.insert(HCname="trackerCollection");
collectionName.insert(HCname = "trackerCollection");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExTGTrackerSD::~ExTGTrackerSD()
{
}
ExTGTrackerSD::~ExTGTrackerSD() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExTGTrackerSD::Initialize(G4HCofThisEvent* HCE)
{
fTrackerCollection = new ExTGTrackerHitsCollection
(SensitiveDetectorName,collectionName[0]);
fTrackerCollection = new ExTGTrackerHitsCollection(SensitiveDetectorName, collectionName[0]);
static G4int HCID = -1;
if ( HCID<0 )
{
if (HCID < 0) {
HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
}
HCE->AddHitsCollection( HCID, fTrackerCollection );
HCE->AddHitsCollection(HCID, fTrackerCollection);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool ExTGTrackerSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
G4bool ExTGTrackerSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
{
G4double edep = aStep->GetTotalEnergyDeposit();
if(edep==0.) { return false; }
if (edep == 0.) {
return false;
}
ExTGTrackerHit* newHit = new ExTGTrackerHit();
newHit->SetTrackID (aStep->GetTrack()->GetTrackID());
newHit->SetChamberNb(aStep->GetPreStepPoint()->GetTouchableHandle()
->GetCopyNumber());
newHit->SetEdep (edep);
newHit->SetPos (aStep->GetPostStepPoint()->GetPosition());
fTrackerCollection->insert( newHit );
//newHit->Print();
//newHit->Draw();
newHit->SetTrackID(aStep->GetTrack()->GetTrackID());
newHit->SetChamberNb(aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber());
newHit->SetEdep(edep);
newHit->SetPos(aStep->GetPostStepPoint()->GetPosition());
fTrackerCollection->insert(newHit);
// newHit->Print();
// newHit->Draw();
return true;
}
@@ -85,12 +82,10 @@ G4bool ExTGTrackerSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExTGTrackerSD::EndOfEvent(G4HCofThisEvent*)
{
G4int NbHits = fTrackerCollection->entries();
G4cout << "\n-------->Hits Collection: in this event there are " << NbHits
<< " hits in the tracker chambers: " << G4endl;
for (G4int i=0;i<NbHits;i++)
{
(*fTrackerCollection)[i]->Print();
}
G4int NbHits = fTrackerCollection->entries();
G4cout << "\n-------->Hits Collection: in this event there are " << NbHits
<< " hits in the tracker chambers: " << G4endl;
for (G4int i = 0; i < NbHits; i++) {
(*fTrackerCollection)[i]->Print();
}
}