Compare commits
4 Commits
543b0de69c
...
a74caca258
Author | SHA1 | Date |
---|---|---|
David Baranyai | a74caca258 | |
David Baranyai | f356bef59c | |
David Baranyai | e442594a71 | |
David Baranyai | d6d040e71f |
|
@ -24,6 +24,9 @@ public:
|
|||
static SiPMParameters *GetInstance();
|
||||
~SiPMParameters();
|
||||
|
||||
//---Config file---------------------------------------------------------------------------------------
|
||||
void ParseConfigFile(); //Read the default config file
|
||||
void ParseConfigFile(std::string config_file1); //Read another config file
|
||||
|
||||
//---Particle Gun parameters---------------------------------------------------------------------------
|
||||
void SetParticleGunPosition(G4ThreeVector pgp) { particleGun_position = pgp; }
|
||||
|
@ -57,12 +60,21 @@ public:
|
|||
void SetScintillatorRadius(G4double sc_r) { scint_radius = sc_r; }
|
||||
G4double GetScintillatorRadius() { return scint_radius; }
|
||||
|
||||
//---Number of Events----------------------------------------------------------------------------------
|
||||
void SetNumberOfEvents(G4int noe1) { numberofevents = noe1; }
|
||||
G4int GetNumberOfEvents() { return numberofevents; }
|
||||
|
||||
void ResetToDefaults();
|
||||
|
||||
private:
|
||||
SiPMParameters();
|
||||
static SiPMParameters *instance;
|
||||
|
||||
//---Config file---------------------------------------------------------------------------------------
|
||||
std::string config_file;
|
||||
void StoreConfigValues(std::string key1, std::string value1);
|
||||
void CheckValues();
|
||||
|
||||
G4ThreeVector particleGun_position;
|
||||
G4ThreeVector particleGun_MomentumDirection;
|
||||
G4double particleGun_energy; //in GeV
|
||||
|
@ -75,6 +87,8 @@ private:
|
|||
|
||||
G4double scint_radius;
|
||||
|
||||
G4int numberofevents;
|
||||
|
||||
};
|
||||
|
||||
#endif /* Parameters_hh */
|
||||
|
|
53
sipm.cc
53
sipm.cc
|
@ -25,15 +25,48 @@
|
|||
#include "G4OpticalPhysics.hh"
|
||||
#include "G4OpticalProcessIndex.hh"
|
||||
#include "LXePhysicsList.hh"
|
||||
#include "SiPMParameters.hh"
|
||||
#include "SiPMAnalysis.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
int main(int argc,char** argv)
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// parameter from command line
|
||||
SiPMParameters *parameters = SiPMParameters::GetInstance();
|
||||
|
||||
bool visualization = true;
|
||||
int NoE=0;
|
||||
if (argc==2) NoE=atoi(argv[1]);
|
||||
|
||||
// parameter from command line
|
||||
for(int i = 1; i < argc; i++)
|
||||
{
|
||||
if(!strcmp("-df", argv[i])) //number of events
|
||||
{
|
||||
std::cout << "Settings will be read from the default file." << std::endl;
|
||||
parameters -> ParseConfigFile();
|
||||
}
|
||||
else if(!strcmp("-f", argv[i])) //number of events
|
||||
{
|
||||
std::string filename;
|
||||
if(argc-1 >= i+1)
|
||||
{
|
||||
filename = argv[i+1];
|
||||
std::cout << "Settings will be read from " << filename << "." << std::endl;
|
||||
parameters -> ParseConfigFile(filename);
|
||||
}
|
||||
if(filename.empty())
|
||||
{
|
||||
std::cout << "File name not given, using the default values" << std::endl;
|
||||
}
|
||||
}
|
||||
else if(!strcmp("-v", argv[i])) //number of events
|
||||
{
|
||||
std::cout << "Visualization disabled." << std::endl;
|
||||
visualization = false;
|
||||
}
|
||||
}
|
||||
|
||||
NoE = parameters -> GetNumberOfEvents();
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
G4MTRunManager* runManager = new G4MTRunManager;
|
||||
|
@ -42,31 +75,31 @@ int main(int argc,char** argv)
|
|||
#else
|
||||
G4RunManager* runManager = new G4RunManager;
|
||||
#endif
|
||||
//you will modify this part ///////////
|
||||
runManager->SetUserInitialization(new LXePhysicsList());
|
||||
runManager->SetUserInitialization(new SiPMDetectorConstruction());
|
||||
//runManager->SetUserInitialization(new QGSP_BIC);
|
||||
runManager->SetUserInitialization(new SiPMActionInitialization());
|
||||
///////////////
|
||||
|
||||
//Initialize the analysis instance here first to avoid crash
|
||||
SiPMAnalysis *analysis = SiPMAnalysis::getInstance();
|
||||
|
||||
G4VisManager* visManager = new G4VisExecutive;
|
||||
visManager->Initialize();
|
||||
G4UImanager* UImanager = G4UImanager::GetUIpointer();
|
||||
|
||||
if (argc==2) {
|
||||
if (visualization == false)
|
||||
{
|
||||
// batch mode
|
||||
runManager->Initialize();
|
||||
runManager->BeamOn(NoE);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// interactive mode
|
||||
G4UIExecutive* ui = 0;
|
||||
if ( argc == 1 ) {
|
||||
ui = new G4UIExecutive(argc, argv);
|
||||
}
|
||||
UImanager->ApplyCommand("/control/macroPath /Users/divaldo/Programming/DE-Detector"); //set for your environment
|
||||
ui = new G4UIExecutive(argc, argv);
|
||||
UImanager->ApplyCommand("/control/macroPath ./macros"); //set for your environment
|
||||
UImanager->ApplyCommand("/control/execute gui.mac");
|
||||
ui->SessionStart();
|
||||
delete ui;
|
||||
|
|
|
@ -101,17 +101,6 @@ G4VPhysicalVolume* SiPMDetectorConstruction::Construct()
|
|||
G4LogicalVolume *logicContainer =
|
||||
new G4LogicalVolume(solidContainer, world_mat, "Container");
|
||||
|
||||
/*
|
||||
G4VPhysicalVolume *physContainer =
|
||||
new G4PVPlacement(0,
|
||||
G4ThreeVector(),
|
||||
logicContainer,
|
||||
"Container",
|
||||
logicWorld,
|
||||
false,
|
||||
0,
|
||||
checkOverlaps);
|
||||
*/
|
||||
G4Colour containerColour( 1.0, 1.0, 0.0);
|
||||
G4VisAttributes* containerVisAtt = new G4VisAttributes( containerColour );
|
||||
//logicContainer -> SetVisAttributes(containerVisAtt);
|
||||
|
@ -313,35 +302,6 @@ G4VPhysicalVolume* SiPMDetectorConstruction::Construct()
|
|||
|
||||
SurfacefromScintillatorToSipm -> SetMaterialPropertiesTable(ScintillatorMaterialPropertyTable);
|
||||
|
||||
//Surface
|
||||
/*
|
||||
G4int matrixX = 3;
|
||||
G4int matrixY = 3;
|
||||
G4VPVParameterisation *chamberParam = new SiPMParameterisation(matrixX,
|
||||
matrixY,
|
||||
0,
|
||||
sipm_width);
|
||||
*/
|
||||
|
||||
/*new G4PVParameterised("Chamber", // their name
|
||||
logicContainer, // their logical volume
|
||||
physWorld, // Mother logical volume
|
||||
kXAxis, // Are placed along this axis
|
||||
3, // Number of chambers
|
||||
chamberParam, // The parametrisation
|
||||
true); // checking overlaps
|
||||
*/
|
||||
/*
|
||||
new G4PVParameterised("Chamber", // their name
|
||||
logicContainer, // their logical volume
|
||||
physWorld, // Mother logical volume
|
||||
kYAxis, // Are placed along this axis
|
||||
matrixX * matrixY, // Number of chambers
|
||||
chamberParam, // The parametrisation
|
||||
true); // checking overlaps
|
||||
*/
|
||||
//G4VPVParameterisation *paramSipm = new G4VPVParameterisation();
|
||||
|
||||
//Using G4PVPlacement instead of replica or others
|
||||
|
||||
int x = parameters -> GetXDivison();
|
||||
|
@ -357,15 +317,13 @@ G4VPhysicalVolume* SiPMDetectorConstruction::Construct()
|
|||
snprintf(s1, 30, "Container_x%d_y%d", i, j);
|
||||
logicContainer -> SetName(s1);
|
||||
physContainer[x][y] = new G4PVPlacement(0,
|
||||
G4ThreeVector(i*cm, j*cm, 0),
|
||||
G4ThreeVector(i*container_sizeX, j*container_sizeY, 0),
|
||||
logicContainer,
|
||||
s1, //its name
|
||||
logicWorld,
|
||||
false,
|
||||
helper, //copy number
|
||||
checkOverlaps);
|
||||
//physSipm0 -> SetCopyNo(helper);
|
||||
//physSipm1 -> SetCopyNo(helper);
|
||||
helper++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ SiPMParameters* SiPMParameters::instance = 0;
|
|||
|
||||
SiPMParameters::SiPMParameters()
|
||||
{
|
||||
config_file = "config.conf";
|
||||
ResetToDefaults();
|
||||
}
|
||||
|
||||
|
@ -43,4 +44,162 @@ void SiPMParameters::ResetToDefaults()
|
|||
y_division = 10;
|
||||
|
||||
scint_radius = 0.25; //in cm
|
||||
|
||||
numberofevents = 10;
|
||||
}
|
||||
|
||||
void SiPMParameters::ParseConfigFile()
|
||||
{
|
||||
std::string line;
|
||||
try
|
||||
{
|
||||
std::ifstream configfile(config_file);
|
||||
if(configfile.is_open())
|
||||
{
|
||||
while (getline(configfile, line))
|
||||
{
|
||||
std::istringstream is_line(line);
|
||||
std::string key;
|
||||
if (std::getline(is_line, key, '='))
|
||||
{
|
||||
std::string value;
|
||||
if(std::getline(is_line, value))
|
||||
{
|
||||
StoreConfigValues(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CheckValues();
|
||||
}
|
||||
catch (char param)
|
||||
{
|
||||
std::cout << param << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void SiPMParameters::ParseConfigFile(std::string config_file1)
|
||||
{
|
||||
config_file = config_file1;
|
||||
ParseConfigFile();
|
||||
}
|
||||
|
||||
void SiPMParameters::StoreConfigValues(std::string key1, std::string value1)
|
||||
{
|
||||
//---Particle gun position---------------------------------------------------------------------------------------------------
|
||||
if(key1.compare("pgpositionx") == 0)
|
||||
{
|
||||
particleGun_position.setX(std::stod(value1));
|
||||
std::cout << "Particle Gun X position parsed from config file! Value = " << particleGun_position.getX() << std::endl;
|
||||
}
|
||||
else if(key1.compare("pgpositiony") == 0)
|
||||
{
|
||||
particleGun_position.setY(std::stod(value1));
|
||||
std::cout << "Particle Gun Y position parsed from config file! Value = " << particleGun_position.getY() << std::endl;
|
||||
}
|
||||
else if(key1.compare("pgpositionz") == 0)
|
||||
{
|
||||
particleGun_position.setZ(std::stod(value1));
|
||||
std::cout << "Particle Gun Z position parsed from config file! Value = " << particleGun_position.getZ() << std::endl;
|
||||
}
|
||||
|
||||
//---Particle gun momentum----------------------------------------------------------------------------------------------------
|
||||
else if(key1.compare("pgmomentumx") == 0)
|
||||
{
|
||||
particleGun_MomentumDirection.setX(std::stod(value1));
|
||||
std::cout << "Particle Gun X momentum parsed from config file! Value = " << particleGun_MomentumDirection.getX() << std::endl;
|
||||
}
|
||||
else if(key1.compare("pgmomentumy") == 0)
|
||||
{
|
||||
particleGun_MomentumDirection.setY(std::stod(value1));
|
||||
std::cout << "Particle Gun Y momentum parsed from config file! Value = " << particleGun_MomentumDirection.getY() << std::endl;
|
||||
}
|
||||
else if(key1.compare("pgmomentumz") == 0)
|
||||
{
|
||||
particleGun_MomentumDirection.setZ(std::stod(value1));
|
||||
std::cout << "Particle Gun Z momentum parsed from config file! Value = " << particleGun_MomentumDirection.getZ() << std::endl;
|
||||
}
|
||||
|
||||
//---Particle gun energy------------------------------------------------------------------------------------------------------
|
||||
else if(key1.compare("pgenergy") == 0)
|
||||
{
|
||||
particleGun_energy = std::stod(value1);
|
||||
std::cout << "Particle Gun energy parsed from config file! Value = " << particleGun_energy << std::endl;
|
||||
}
|
||||
|
||||
//---SiPM dimensions----------------------------------------------------------------------------------------------------------
|
||||
else if(key1.compare("sipmsizex") == 0)
|
||||
{
|
||||
sipm_Dimension.setX(std::stod(value1));
|
||||
std::cout << "SiPM X size parsed from config file! Value = " << sipm_Dimension.getX() << std::endl;
|
||||
}
|
||||
else if(key1.compare("sipmsizey") == 0)
|
||||
{
|
||||
sipm_Dimension.setY(std::stod(value1));
|
||||
std::cout << "SiPM Y size parsed from config file! Value = " << sipm_Dimension.getY() << std::endl;
|
||||
}
|
||||
else if(key1.compare("sipmsizez") == 0)
|
||||
{
|
||||
sipm_Dimension.setZ(std::stod(value1));
|
||||
std::cout << "SiPM Z size parsed from config file! Value = " << sipm_Dimension.getZ() << std::endl;
|
||||
}
|
||||
|
||||
//---Sscintillator------------------------------------------------------------------------------------------------------------
|
||||
else if(key1.compare("scintillatorlength") == 0)
|
||||
{
|
||||
scintillator_length = std::stod(value1);
|
||||
std::cout << "Scintillator length parsed from config file! Value = " << scintillator_length << std::endl;
|
||||
}
|
||||
else if(key1.compare("scintillatorradius") == 0)
|
||||
{
|
||||
scint_radius = std::stod(value1);
|
||||
std::cout << "Scintillator radius parsed from config file! Value = " << scint_radius << std::endl;
|
||||
}
|
||||
|
||||
//---Sscintillator------------------------------------------------------------------------------------------------------------
|
||||
else if(key1.compare("xdivision") == 0)
|
||||
{
|
||||
x_division = std::stod(value1);
|
||||
std::cout << "X division parsed from config file! Value = " << x_division << std::endl;
|
||||
}
|
||||
else if(key1.compare("ydivision") == 0)
|
||||
{
|
||||
y_division = std::stod(value1);
|
||||
std::cout << "Y division parsed from config file! Value = " << y_division << std::endl;
|
||||
}
|
||||
|
||||
//---Number of events---------------------------------------------------------------------------------------------------------
|
||||
else if(key1.compare("numberofevents") == 0)
|
||||
{
|
||||
numberofevents = std::stod(value1);
|
||||
std::cout << "Number of events parsed from config file! Value = " << numberofevents << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void SiPMParameters::CheckValues()
|
||||
{
|
||||
if(x_division <= 0)
|
||||
{
|
||||
std::cout << "X division is at least 1, setting back the default value." << std::endl;
|
||||
x_division = 1;
|
||||
}
|
||||
if(y_division <= 0)
|
||||
{
|
||||
std::cout << "Y division is at least 1, setting back the default value." << std::endl;
|
||||
y_division = 1;
|
||||
}
|
||||
if(scint_radius*2 > sipm_Dimension.getX() || scint_radius*2 > sipm_Dimension.getY())
|
||||
{
|
||||
std::cout << "Scintillator diameter can not be larger than the SiPM, ";
|
||||
if(sipm_Dimension.getX() < sipm_Dimension.getY())
|
||||
{
|
||||
scint_radius = sipm_Dimension.getX() / 2;
|
||||
std::cout << "changed to " << scint_radius * 2 << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
scint_radius = sipm_Dimension.getY() / 2;
|
||||
std::cout << "changed to " << scint_radius * 2 << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue