Skip to content

Commit

Permalink
Merge pull request #2 from lopezzot/dev
Browse files Browse the repository at this point in the history
From Dev to master
  • Loading branch information
lopezzot authored Jul 20, 2021
2 parents 5845c03 + 23bd465 commit 9e0a63b
Show file tree
Hide file tree
Showing 15 changed files with 262 additions and 88 deletions.
16 changes: 12 additions & 4 deletions DREMTubes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace PrintUsageError {
G4cerr << "->DREMTubes usage: " << G4endl;
G4cerr << "DREMTubes [-m macro ] [-u UIsession] [-t nThreads] [-pl PhysicsList]"
<< G4endl;
G4cerr << " [-opt FullOptic]" << G4endl;
}
}

Expand All @@ -41,7 +42,7 @@ int main(int argc, char** argv) {

// Error in argument numbers
//
if ( argc > 9 ) {
if ( argc > 11 ) {
PrintUsageError::UsageError();
return 1;
}
Expand All @@ -51,6 +52,7 @@ int main(int argc, char** argv) {
G4String macro;
G4String session;
G4String custom_pl = "FTFP_BERT"; //default physics list
G4bool FullOptic = false;
#ifdef G4MULTITHREADED
G4int nThreads = 0;
#endif
Expand All @@ -59,6 +61,8 @@ int main(int argc, char** argv) {
if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
else if ( G4String(argv[i]) == "-u" ) session = argv[i+1];
else if ( G4String(argv[i]) == "-pl") custom_pl = argv[i+1];
else if ( G4String(argv[i]) == "-opt") FullOptic =
G4UIcommand::ConvertToBool(argv[i+1]);
#ifdef G4MULTITHREADED
else if ( G4String(argv[i]) == "-t" ) {
nThreads = G4UIcommand::ConvertToInt(argv[i+1]);
Expand All @@ -68,7 +72,11 @@ int main(int argc, char** argv) {
PrintUsageError::UsageError();
return 1;
}
}
}

//Print if FullOptic option is on
//
if (FullOptic){ G4cout<<"DREMTubes-> Run with full optical description"<<G4endl; }

// Detect interactive mode (if no macro provided) and define UI session
//
Expand All @@ -93,9 +101,9 @@ int main(int argc, char** argv) {
auto DetConstruction = new DREMTubesDetectorConstruction();
runManager->SetUserInitialization(DetConstruction);

runManager->SetUserInitialization(new DREMTubesPhysicsList(custom_pl));
runManager->SetUserInitialization(new DREMTubesPhysicsList(custom_pl, FullOptic ));

auto actionInitialization = new DREMTubesActionInitialization();
auto actionInitialization = new DREMTubesActionInitialization( FullOptic );
runManager->SetUserInitialization(actionInitialization);

// Initialize visualization
Expand Down
7 changes: 6 additions & 1 deletion include/DREMTubesActionInitialization.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,23 @@
//Includers from Geant4
//
#include "G4VUserActionInitialization.hh"
#include "G4Types.hh"

class DREMTubesActionInitialization : public G4VUserActionInitialization {

public:
//Constructor
//
DREMTubesActionInitialization();
DREMTubesActionInitialization( const G4bool FullOptic );
virtual ~DREMTubesActionInitialization();

virtual void BuildForMaster() const;
virtual void Build() const;

private:

G4bool fFullOptic;

};

#endif
Expand Down
2 changes: 1 addition & 1 deletion include/DREMTubesDetectorConstruction.hh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//Prevent including header multplie times
//
#ifndef DREMTubesDetectorConstruction_h
#define DREMTUbesDetectorConstruction_h 1
#define DREMTubesDetectorConstruction_h 1

//Includers from Geant4
//
Expand Down
8 changes: 4 additions & 4 deletions include/DREMTubesEventAction.hh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DREMTubesEventAction : public G4UserEventAction {
void Addenergy(G4double de);//Add all energy deposited
//void AddEnergyfibre(G4double de, G4int number);//Add energy in fiber cpn
//void AddSignalfibre(G4int number);
void SavePrimaryParticle(G4String name);
void SavePrimaryPDGID(G4int pdgid);
void SaveAbsorberMaterial(G4String AbsorberMaterialName);
void SavePrimaryEnergy(G4double primaryparticleenergy);
void AddEscapedEnergy(G4double escapedenergy);
Expand All @@ -66,7 +66,7 @@ class DREMTubesEventAction : public G4UserEventAction {
G4double EnergyTot;//Total energy deposited (does not count invisibile energy)
//G4double Signalfibre[64];
////Signal in 64 single module fibers, to be used with AddEnergyfibre
G4String PrimaryParticleName; //Name of primary particle
G4int PrimaryPDGID; //PDGID of primary particle
G4String AbsorberMaterial; //Name of absorber material
G4double PrimaryParticleEnergy;//Primary particle energy
G4double EscapedEnergy;
Expand All @@ -84,8 +84,8 @@ inline void DREMTubesEventAction::AddEscapedEnergy(G4double escapedenergy){
EscapedEnergy += escapedenergy;
}

inline void DREMTubesEventAction::SavePrimaryParticle(G4String name){
PrimaryParticleName = name;
inline void DREMTubesEventAction::SavePrimaryPDGID(G4int pdgid){
PrimaryPDGID = pdgid;
}

inline void DREMTubesEventAction::SaveAbsorberMaterial(G4String AbsorberMaterialName){
Expand Down
4 changes: 3 additions & 1 deletion include/DREMTubesOpticalPhysics.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DREMTubesOpticalPhysics : public G4VPhysicsConstructor {
public:
// Constructor
//
DREMTubesOpticalPhysics(G4bool toggle=true);
DREMTubesOpticalPhysics( const G4bool FullOptic, G4bool toggle=true);
// Deconstructor
//
virtual ~DREMTubesOpticalPhysics();
Expand Down Expand Up @@ -56,6 +56,8 @@ class DREMTubesOpticalPhysics : public G4VPhysicsConstructor {
G4OpBoundaryProcess* theBoundaryProcess;

G4bool AbsorptionOn;

G4bool fFullOptic;

};

Expand Down
7 changes: 6 additions & 1 deletion include/DREMTubesPhysicsList.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ class DREMTubesPhysicsList : public G4VModularPhysicsList{
public:
//Constructor
//
DREMTubesPhysicsList(G4String);
DREMTubesPhysicsList(G4String, const G4bool FullOptic );
//De-constructor
//
virtual ~DREMTubesPhysicsList();

DREMTubesOpticalPhysics* OpPhysics;

G4bool AbsorptionOn;

private:

G4bool fFullOptic;

};

#endif
Expand Down
2 changes: 1 addition & 1 deletion include/DREMTubesRunAction.hh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//**************************************************
// \file DREMTubesRunAction.hh
// \brief: Definition of DREMTUbesBRunAction class
// \brief: Definition of DREMTubesBRunAction class
// \author: Lorenzo Pezzotti (CERN EP-SFT-sim) @lopezzot
// \start date: 7 July 2021
//**************************************************
Expand Down
21 changes: 19 additions & 2 deletions include/DREMTubesSteppingAction.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//Includers from Geant4
//
#include "G4UserSteppingAction.hh"
#include "G4Types.hh"
class G4OpBoundaryProcess;

class DREMTubesDetectorConstruction;
Expand All @@ -23,22 +24,38 @@ class DREMTubesSteppingAction : public G4UserSteppingAction {
public:
//Constructor
//
DREMTubesSteppingAction(DREMTubesEventAction* eventAction);
DREMTubesSteppingAction(DREMTubesEventAction* eventAction,
const G4bool FullOptic );
//De-constructor
//
virtual ~DREMTubesSteppingAction();

//User impementation of SteppingAction
//
virtual void UserSteppingAction( const G4Step* step );

//Retrieve auxialiry info from Step
//
void AuxSteppingAction( const G4Step* step );

//Fast signal simulation (no optical photon propagation)
//fFullOptic == false
//
void FastSteppingAction( const G4Step* step );

//Slow signal simulation (optical photon propagation)
//fFullOptic == true
//
void SlowSteppingAction( const G4Step* step );

private:
//Data members
//
DREMTubesEventAction* fEventAction;

G4OpBoundaryProcess* fOpProcess;


G4bool fFullOptic;
};

#endif
Expand Down
8 changes: 5 additions & 3 deletions src/DREMTubesActionInitialization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

//Constructor
//
DREMTubesActionInitialization::DREMTubesActionInitialization()
: G4VUserActionInitialization() {}
DREMTubesActionInitialization::DREMTubesActionInitialization( const G4bool FullOptic )
: G4VUserActionInitialization(),
fFullOptic( FullOptic )
{}

//De-constructor
//
Expand All @@ -39,7 +41,7 @@ void DREMTubesActionInitialization::Build() const {
auto eventAction = new DREMTubesEventAction;
SetUserAction(new DREMTubesRunAction( eventAction ));
SetUserAction(eventAction);
SetUserAction(new DREMTubesSteppingAction(eventAction));
SetUserAction(new DREMTubesSteppingAction(eventAction, fFullOptic));

}

Expand Down
50 changes: 30 additions & 20 deletions src/DREMTubesDetectorConstruction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ G4VPhysicalVolume* DREMTubesDetectorConstruction::DefineVolumes() {
G4int NofFibersrow = 3*16;
G4int NofFiberscolumn = 60;
G4double moduleZ = (1000.)*mm;
double tolerance = 0.05*mm;
double tolerance = 0.0*mm;
G4double moduleX = 3.*32.*mm+1.*mm+2.*tolerance*NofFibersrow;
G4double moduleY = 59.*(1.733+2*tolerance)*mm+2.0*mm;

Expand Down Expand Up @@ -453,8 +453,8 @@ G4VPhysicalVolume* DREMTubesDetectorConstruction::DefineVolumes() {
// Calorimeter placement (with rotation wrt beam axis)
//
G4RotationMatrix rotm = G4RotationMatrix();
rotm.rotateY(1.0*deg);
rotm.rotateX(1.0*deg);
rotm.rotateY(0.0*deg);
rotm.rotateX(0.0*deg);
G4ThreeVector position;
position.setX(0.);
position.setY(0.);
Expand Down Expand Up @@ -496,15 +496,25 @@ G4VPhysicalVolume* DREMTubesDetectorConstruction::DefineVolumes() {
OpSurfaceGlassSi -> SetType(dielectric_metal);
OpSurfaceGlassSi -> SetModel(glisur);
OpSurfaceGlassSi -> SetFinish(polished);
G4double efficiencyOpSurfaceGlassSi[ENTRIES] = // detection efficiency
{ 0.4, 0.4, 0.4, 0.4,
0.4, 0.4, 0.4, 0.4,
0.4, 0.4, 0.4, 0.4,
0.4, 0.4, 0.4, 0.4,
0.4, 0.4, 0.4, 0.4,
0.4, 0.4, 0.4, 0.4,
0.4, 0.4, 0.4, 0.4,
0.4, 0.4, 0.4, 0.4};
G4double efficiencyOpSurfaceGlassSi[ENTRIES] = //100% detection efficiency
{ 1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1 };

/*G4double efficiencyOpSurfaceGlassSi[ENTRIES] = //0% detection efficiency
{ 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0 };*/

G4double reflectivityOpSurfaceGlassSi[ENTRIES] = // 0% reflection
{ 0., 0., 0., 0.,
Expand Down Expand Up @@ -559,8 +569,8 @@ G4VPhysicalVolume* DREMTubesDetectorConstruction::DefineVolumes() {

// Logical Skin Surface placement around the silicon of the SiPM
//
/*G4LogicalSkinSurface* OpsurfaceSi = new G4LogicalSkinSurface("OpsurfaceSi",
SiLV, OpSurfaceGlassSi);*/
/*G4LogicalSkinSurface* OpsurfaceSi =*/ new G4LogicalSkinSurface("OpsurfaceSi",
SiLV, OpSurfaceGlassSi);

// Optical Surface properties between the scintillating fibers
// and the default material
Expand Down Expand Up @@ -598,8 +608,8 @@ G4VPhysicalVolume* DREMTubesDetectorConstruction::DefineVolumes() {
std::string S_name;
std::string SiPM_name;
S_name = "S_row" + S_fiber_row.str() + "_column_" + S_fiber_column.str();
SiPM_name =
"SiPMS_row" + S_fiber_row.str() + "_column_" + S_fiber_column.str();
SiPM_name = "S_SiPM";
//SiPM_name = "SiPMS_row" + S_fiber_row.str() + "_column_" + S_fiber_column.str();

G4double S_x, S_y;
G4ThreeVector vec_S_fiber;
Expand Down Expand Up @@ -648,7 +658,7 @@ G4VPhysicalVolume* DREMTubesDetectorConstruction::DefineVolumes() {
SiPM_name,
moduleequippedLV,
false,
0);
copynumber); //same copynumber of fibers

/*logic_OpSurface_defaultAir[NofFibersrow][NofFiberscolumn] =
new G4LogicalBorderSurface("logic_OpSurface_defaultAir",
Expand Down Expand Up @@ -676,8 +686,8 @@ G4VPhysicalVolume* DREMTubesDetectorConstruction::DefineVolumes() {
std::string C_name;
std::string SiPM_name;
C_name = "C_row" + C_fiber_row.str() + "_column_" + C_fiber_column.str();
SiPM_name =
"SiPMC_row" + C_fiber_row.str() + "_column_" + C_fiber_column.str();
SiPM_name = "C_SiPM";
//SiPM_name = "SiPMC_row" + C_fiber_row.str() + "_column_" + C_fiber_column.str();

G4double C_x, C_y;
G4ThreeVector vec_C_fiber;
Expand Down Expand Up @@ -723,7 +733,7 @@ G4VPhysicalVolume* DREMTubesDetectorConstruction::DefineVolumes() {
SiPM_name,
moduleequippedLV,
false,
0);
copynumber); //same copynumber of fiber

/*logic_OpSurface_defaultAir[NofFibersrow][NofFiberscolumn] =
new G4LogicalBorderSurface("logic_OpSurface_defaultAir",
Expand Down
15 changes: 14 additions & 1 deletion src/DREMTubesEventAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ DREMTubesEventAction::DREMTubesEventAction()
NofCherenkovDetected(0),
//NofScintillationDetected(0),
EnergyTot(0.),
PrimaryPDGID(0),
PrimaryParticleEnergy(0.),
EscapedEnergy(0.),
VectorSignals(0.),
Expand Down Expand Up @@ -96,12 +97,24 @@ void DREMTubesEventAction::EndOfEventAction(const G4Event* ) {
analysisManager->FillNtupleDColumn(3, NofCherenkovDetected);
analysisManager->FillNtupleDColumn(4, EnergyTot);
analysisManager->FillNtupleDColumn(5, PrimaryParticleEnergy);
analysisManager->FillNtupleSColumn(6, PrimaryParticleName);
analysisManager->FillNtupleIColumn(6, PrimaryPDGID);
//analysisManager->FillNtupleSColumn(7, AbsorberMaterial);
analysisManager->FillNtupleDColumn(7, EscapedEnergy);
//analysisManager->FillNtupleDColumn(9, Energyem2);
analysisManager->AddNtupleRow();

G4int tot_S = 0;
G4int tot_C = 0;
for(unsigned int i=0; i<VectorSignals.size(); i++){
tot_S += VectorSignals.at(i);
}

for(unsigned int i=0; i<VectorSignalsCher.size(); i++){
tot_C += VectorSignalsCher.at(i);
}

G4cout<<"Tot S "<<tot_S<<" Tot C "<<tot_C<<G4endl;

}

//**************************************************
Loading

0 comments on commit 9e0a63b

Please sign in to comment.