Import Geant4 11.0.0 source tree
This commit is contained in:
committed by
Ben Morgan
parent
6399a014b6
commit
80e2389dd8
@@ -57,10 +57,14 @@
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4UserLimits.hh"
|
||||
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4Colour.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
WLSDetectorConstruction::WLSDetectorConstruction()
|
||||
: fMaterials(nullptr)
|
||||
: fVisAttributes()
|
||||
, fMaterials(nullptr)
|
||||
, fLogicHole(nullptr)
|
||||
, fLogicWorld(nullptr)
|
||||
, fPhysiWorld(nullptr)
|
||||
@@ -113,6 +117,10 @@ WLSDetectorConstruction::~WLSDetectorConstruction()
|
||||
delete fDetectorMessenger;
|
||||
if(fMaterials)
|
||||
delete fMaterials;
|
||||
for (auto visAttributes: fVisAttributes)
|
||||
{
|
||||
delete visAttributes;
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -139,6 +147,11 @@ G4VPhysicalVolume* WLSDetectorConstruction::Construct()
|
||||
|
||||
G4VPhysicalVolume* WLSDetectorConstruction::ConstructDetector()
|
||||
{
|
||||
|
||||
auto air = FindMaterial("G4_AIR");
|
||||
//G4cout << "\nMaterial Properties Table for G4_AIR:" << G4endl;
|
||||
//air->GetMaterialPropertiesTable()->DumpTable();
|
||||
|
||||
//--------------------------------------------------
|
||||
// World
|
||||
//--------------------------------------------------
|
||||
@@ -147,7 +160,7 @@ G4VPhysicalVolume* WLSDetectorConstruction::ConstructDetector()
|
||||
new G4Box("World", fWorldSizeX, fWorldSizeY, fWorldSizeZ);
|
||||
|
||||
fLogicWorld =
|
||||
new G4LogicalVolume(solidWorld, FindMaterial("G4_AIR"), "World");
|
||||
new G4LogicalVolume(solidWorld, air, "World");
|
||||
|
||||
fPhysiWorld =
|
||||
new G4PVPlacement(0, G4ThreeVector(), fLogicWorld, "World", 0, false, 0);
|
||||
@@ -156,11 +169,13 @@ G4VPhysicalVolume* WLSDetectorConstruction::ConstructDetector()
|
||||
// Extrusion
|
||||
//--------------------------------------------------
|
||||
|
||||
auto coating = FindMaterial("Coating");
|
||||
|
||||
G4VSolid* solidExtrusion = new G4Box("Extrusion", GetBarBase() / 2.,
|
||||
GetBarBase() / 2., GetBarLength() / 2.);
|
||||
|
||||
G4LogicalVolume* logicExtrusion =
|
||||
new G4LogicalVolume(solidExtrusion, FindMaterial("Coating"), "Extrusion");
|
||||
new G4LogicalVolume(solidExtrusion, coating, "Extrusion");
|
||||
|
||||
G4OpticalSurface* TiO2Surface = new G4OpticalSurface(
|
||||
"TiO2Surface", glisur, ground, dielectric_metal, fExtrusionPolish);
|
||||
@@ -188,6 +203,10 @@ G4VPhysicalVolume* WLSDetectorConstruction::ConstructDetector()
|
||||
// Scintillator
|
||||
//--------------------------------------------------
|
||||
|
||||
auto polystyrene = FindMaterial("Polystyrene");
|
||||
//G4cout << "\nMaterial Properties Table for Polystyrene:" << G4endl;
|
||||
//polystyrene->GetMaterialPropertiesTable()->DumpTable();
|
||||
|
||||
G4VSolid* solidScintillator =
|
||||
new G4Box("Scintillator",
|
||||
GetBarBase() / 2. - GetCoatingThickness() - GetCoatingRadius(),
|
||||
@@ -195,11 +214,13 @@ G4VPhysicalVolume* WLSDetectorConstruction::ConstructDetector()
|
||||
GetBarLength() / 2.);
|
||||
|
||||
G4LogicalVolume* logicScintillator = new G4LogicalVolume(
|
||||
solidScintillator, FindMaterial("Polystyrene"), "Scintillator");
|
||||
solidScintillator, polystyrene, "Scintillator");
|
||||
|
||||
new G4PVPlacement(0, G4ThreeVector(), logicScintillator, "Scintillator",
|
||||
logicExtrusion, false, 0);
|
||||
|
||||
|
||||
G4LogicalVolume* logicScintSide = nullptr;
|
||||
G4LogicalVolume* logicScintCrnr = nullptr;
|
||||
if(GetCoatingRadius() > 0.)
|
||||
{
|
||||
G4VSolid* solidScintside =
|
||||
@@ -211,11 +232,11 @@ G4VPhysicalVolume* WLSDetectorConstruction::ConstructDetector()
|
||||
new G4Tubs("CrnrOfBar", 0.0 * cm, GetCoatingRadius(), GetBarLength() / 2.,
|
||||
0. * deg, 90. * deg);
|
||||
|
||||
G4LogicalVolume* logicScintSide = new G4LogicalVolume(
|
||||
solidScintside, FindMaterial("Polystyrene"), "SideOfBar");
|
||||
logicScintSide = new G4LogicalVolume(
|
||||
solidScintside, polystyrene, "SideOfBar");
|
||||
|
||||
G4LogicalVolume* logicScintCrnr = new G4LogicalVolume(
|
||||
solidScintcrnr, FindMaterial("Polystyrene"), "CrnrOfBar");
|
||||
logicScintCrnr = new G4LogicalVolume(
|
||||
solidScintcrnr, polystyrene, "CrnrOfBar");
|
||||
|
||||
G4double pos =
|
||||
GetBarBase() / 2. - GetCoatingThickness() - GetCoatingRadius() / 2.;
|
||||
@@ -227,12 +248,7 @@ G4VPhysicalVolume* WLSDetectorConstruction::ConstructDetector()
|
||||
"SideOfBar", logicExtrusion, false, 1);
|
||||
|
||||
G4RotationMatrix* rot1 = new G4RotationMatrix();
|
||||
*rot1 = StringToRotationMatrix("Z90");
|
||||
*rot1 = rot1->inverse();
|
||||
if(*rot1 == G4RotationMatrix())
|
||||
{
|
||||
rot1 = nullptr;
|
||||
}
|
||||
rot1->rotateZ(-90.*deg);
|
||||
|
||||
new G4PVPlacement(rot1, G4ThreeVector(pos, 0., 0.), logicScintSide,
|
||||
"SideOfBar", logicExtrusion, false, 2);
|
||||
@@ -249,23 +265,13 @@ G4VPhysicalVolume* WLSDetectorConstruction::ConstructDetector()
|
||||
"CrnrOfBar", logicExtrusion, false, 1);
|
||||
|
||||
G4RotationMatrix* rot2 = new G4RotationMatrix();
|
||||
*rot2 = StringToRotationMatrix("Z180");
|
||||
*rot2 = rot2->inverse();
|
||||
if(*rot2 == G4RotationMatrix())
|
||||
{
|
||||
rot2 = nullptr;
|
||||
}
|
||||
rot2->rotateZ(-180.*deg);
|
||||
|
||||
new G4PVPlacement(rot2, G4ThreeVector(-pos, -pos, 0.), logicScintCrnr,
|
||||
"CrnrOfBar", logicExtrusion, false, 2);
|
||||
|
||||
G4RotationMatrix* rot3 = new G4RotationMatrix();
|
||||
*rot3 = StringToRotationMatrix("Z270");
|
||||
*rot3 = rot3->inverse();
|
||||
if(*rot3 == G4RotationMatrix())
|
||||
{
|
||||
rot3 = nullptr;
|
||||
}
|
||||
rot3->rotateZ(-270.*deg);
|
||||
|
||||
new G4PVPlacement(rot3, G4ThreeVector(pos, -pos, 0.), logicScintCrnr,
|
||||
"CrnrOfBar", logicExtrusion, false, 3);
|
||||
@@ -276,7 +282,7 @@ G4VPhysicalVolume* WLSDetectorConstruction::ConstructDetector()
|
||||
G4VSolid* solidHole = new G4Tubs(
|
||||
"Hole", 0., GetHoleRadius(), GetHoleLength() / 2., 0. * deg, 360. * deg);
|
||||
|
||||
fLogicHole = new G4LogicalVolume(solidHole, FindMaterial("G4_AIR"), "Hole");
|
||||
fLogicHole = new G4LogicalVolume(solidHole, air, "Hole");
|
||||
|
||||
fPhysiHole = new G4PVPlacement(0, G4ThreeVector(), fLogicHole, "Hole",
|
||||
logicScintillator, false, 0);
|
||||
@@ -286,21 +292,11 @@ G4VPhysicalVolume* WLSDetectorConstruction::ConstructDetector()
|
||||
// Fiber
|
||||
//--------------------------------------------------
|
||||
|
||||
ConstructFiber();
|
||||
|
||||
return fPhysiWorld;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void WLSDetectorConstruction::ConstructFiber()
|
||||
{
|
||||
if(!(fLogicHole) || !(fPhysiHole))
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "The Fiber Hole has not been constructed";
|
||||
G4Exception("WLSDetectorConstruction::ConstructFiber", "", FatalException,
|
||||
ed);
|
||||
G4Exception("WLSDetectorConstruction", "wls001", FatalException, ed);
|
||||
}
|
||||
|
||||
// Pointers to the most recently constructed volume
|
||||
@@ -317,11 +313,16 @@ void WLSDetectorConstruction::ConstructFiber()
|
||||
if(fSurfaceRoughness < 1.)
|
||||
opSurface = new G4OpticalSurface("RoughSurface", glisur, ground,
|
||||
dielectric_dielectric, fSurfaceRoughness);
|
||||
|
||||
G4LogicalVolume* logicWLSfiber = nullptr;
|
||||
G4LogicalVolume* logicClad1 = nullptr;
|
||||
G4LogicalVolume* logicClad2 = nullptr;
|
||||
G4VPhysicalVolume* physiClad1 = nullptr;
|
||||
G4VPhysicalVolume* physiClad2 = nullptr;
|
||||
|
||||
G4LogicalVolume* logicClad1 = nullptr;
|
||||
G4LogicalVolume* logicClad2 = nullptr;
|
||||
G4VPhysicalVolume* physiClad1 = nullptr;
|
||||
G4VPhysicalVolume* physiClad2 = nullptr;
|
||||
auto fpethylene = FindMaterial("FPethylene");
|
||||
auto pethylene = FindMaterial("Pethylene");
|
||||
auto pmma = FindMaterial("PMMA");
|
||||
|
||||
// Determine the number of cladding layers to be built
|
||||
switch(fNumOfCladLayers)
|
||||
@@ -332,6 +333,9 @@ void WLSDetectorConstruction::ConstructFiber()
|
||||
// Cladding 2
|
||||
//--------------------------------------------------
|
||||
|
||||
//G4cout << "\nMaterial Properties Table for fPethylene:" << G4endl;
|
||||
//fpethylene->GetMaterialPropertiesTable()->DumpTable();
|
||||
|
||||
G4VSolid* solidClad2;
|
||||
|
||||
if(fXYRatio == 1.)
|
||||
@@ -340,7 +344,7 @@ void WLSDetectorConstruction::ConstructFiber()
|
||||
solidClad2 = new G4EllipticalTube("Clad2", fClad2RX, fClad2RY, fClad2Z);
|
||||
|
||||
logicClad2 =
|
||||
new G4LogicalVolume(solidClad2, FindMaterial("FPethylene"), "Clad2");
|
||||
new G4LogicalVolume(solidClad2, fpethylene, "Clad2");
|
||||
|
||||
physiClad2 =
|
||||
new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, fWLSfiberOrigin),
|
||||
@@ -357,7 +361,7 @@ void WLSDetectorConstruction::ConstructFiber()
|
||||
|
||||
logicPlacement = logicClad2;
|
||||
physiPlacement = physiClad2;
|
||||
break;
|
||||
[[fallthrough]];
|
||||
|
||||
case 1:
|
||||
|
||||
@@ -365,6 +369,9 @@ void WLSDetectorConstruction::ConstructFiber()
|
||||
// Cladding 1
|
||||
//--------------------------------------------------
|
||||
|
||||
//G4cout << "\nMaterial Properties Table for Pethylene:" << G4endl;
|
||||
//pethylene->GetMaterialPropertiesTable()->DumpTable();
|
||||
|
||||
G4VSolid* solidClad1;
|
||||
|
||||
if(fXYRatio == 1.)
|
||||
@@ -373,7 +380,7 @@ void WLSDetectorConstruction::ConstructFiber()
|
||||
solidClad1 = new G4EllipticalTube("Clad1", fClad1RX, fClad1RY, fClad1Z);
|
||||
|
||||
logicClad1 =
|
||||
new G4LogicalVolume(solidClad1, FindMaterial("Pethylene"), "Clad1");
|
||||
new G4LogicalVolume(solidClad1, pethylene, "Clad1");
|
||||
|
||||
physiClad1 =
|
||||
new G4PVPlacement(0, G4ThreeVector(0., 0., fWLSfiberOrigin), logicClad1,
|
||||
@@ -391,7 +398,7 @@ void WLSDetectorConstruction::ConstructFiber()
|
||||
|
||||
logicPlacement = logicClad1;
|
||||
physiPlacement = physiClad1;
|
||||
break;
|
||||
[[fallthrough]];
|
||||
|
||||
default:
|
||||
|
||||
@@ -399,6 +406,9 @@ void WLSDetectorConstruction::ConstructFiber()
|
||||
// WLS Fiber
|
||||
//--------------------------------------------------
|
||||
|
||||
//G4cout << "\nMaterial Properties Table for PMMA:" << G4endl;
|
||||
//pmma->GetMaterialPropertiesTable()->DumpTable();
|
||||
|
||||
G4VSolid* solidWLSfiber;
|
||||
|
||||
if(fXYRatio == 1.)
|
||||
@@ -412,8 +422,8 @@ void WLSDetectorConstruction::ConstructFiber()
|
||||
fWLSfiberRY, fWLSfiberZ);
|
||||
}
|
||||
|
||||
G4LogicalVolume* logicWLSfiber =
|
||||
new G4LogicalVolume(solidWLSfiber, FindMaterial("PMMA"), "WLSFiber");
|
||||
logicWLSfiber =
|
||||
new G4LogicalVolume(solidWLSfiber, pmma, "WLSFiber");
|
||||
|
||||
logicWLSfiber->SetUserLimits(
|
||||
new G4UserLimits(DBL_MAX, DBL_MAX, 10. * ms));
|
||||
@@ -438,13 +448,17 @@ void WLSDetectorConstruction::ConstructFiber()
|
||||
//--------------------------------------------------
|
||||
|
||||
// Place the mirror only if the user wants the mirror
|
||||
G4LogicalVolume* logicMirror = nullptr;
|
||||
|
||||
auto aluminum = FindMaterial("G4_Al");
|
||||
|
||||
if(fMirrorToggle)
|
||||
{
|
||||
G4VSolid* solidMirror =
|
||||
new G4Box("Mirror", fMirrorRmax, fMirrorRmax, fMirrorZ);
|
||||
|
||||
G4LogicalVolume* logicMirror =
|
||||
new G4LogicalVolume(solidMirror, FindMaterial("G4_Al"), "Mirror");
|
||||
logicMirror =
|
||||
new G4LogicalVolume(solidMirror, aluminum, "Mirror");
|
||||
|
||||
G4OpticalSurface* mirrorSurface = new G4OpticalSurface(
|
||||
"MirrorSurface", glisur, ground, dielectric_metal, fMirrorPolish);
|
||||
@@ -476,7 +490,7 @@ void WLSDetectorConstruction::ConstructFiber()
|
||||
G4VSolid* solidCouple = new G4Box("Couple", fCoupleRX, fCoupleRY, fCoupleZ);
|
||||
|
||||
G4LogicalVolume* logicCouple =
|
||||
new G4LogicalVolume(solidCouple, FindMaterial("G4_AIR"), "Couple");
|
||||
new G4LogicalVolume(solidCouple, air, "Couple");
|
||||
|
||||
new G4PVPlacement(0, G4ThreeVector(0., 0., fCoupleOrigin), logicCouple,
|
||||
"Couple", fLogicWorld, false, 0);
|
||||
@@ -493,7 +507,9 @@ void WLSDetectorConstruction::ConstructFiber()
|
||||
fMPPCTheta = 0.;
|
||||
fMPPCOriginX = std::sin(fMPPCTheta) * (fMPPCDist + fClrfiberZ);
|
||||
fMPPCOriginZ = -fCoupleZ + std::cos(fMPPCTheta) * (fMPPCDist + fClrfiberZ);
|
||||
G4cerr << "Invalid alignment. Alignment Reset to 0" << G4endl;
|
||||
G4ExceptionDescription ed;
|
||||
ed << "Invalid alignment. Alignment reset to 0.";
|
||||
G4Exception("WLSDetectorConstruction", "wls002", JustWarning, ed);
|
||||
}
|
||||
|
||||
// Clear Fiber (Coupling Layer)
|
||||
@@ -511,7 +527,7 @@ void WLSDetectorConstruction::ConstructFiber()
|
||||
}
|
||||
|
||||
G4LogicalVolume* logicClrfiber =
|
||||
new G4LogicalVolume(solidClrfiber, FindMaterial("G4_AIR"), "ClearFiber");
|
||||
new G4LogicalVolume(solidClrfiber, air, "ClearFiber");
|
||||
|
||||
new G4PVPlacement(new G4RotationMatrix(CLHEP::HepRotationY(-fMPPCTheta)),
|
||||
G4ThreeVector(fMPPCOriginX, 0.0, fMPPCOriginZ),
|
||||
@@ -530,7 +546,7 @@ void WLSDetectorConstruction::ConstructFiber()
|
||||
solidPhotonDet = new G4Tubs("PhotonDet", 0., fMPPCHalfL, fMPPCZ, 0., twopi);
|
||||
|
||||
G4LogicalVolume* logicPhotonDet =
|
||||
new G4LogicalVolume(solidPhotonDet, FindMaterial("G4_Al"), "PhotonDet_LV");
|
||||
new G4LogicalVolume(solidPhotonDet, aluminum, "PhotonDet_LV");
|
||||
|
||||
new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), logicPhotonDet, "PhotonDet",
|
||||
logicClrfiber, false, 0);
|
||||
@@ -553,8 +569,88 @@ void WLSDetectorConstruction::ConstructFiber()
|
||||
|
||||
new G4LogicalSkinSurface("PhotonDetSurface", logicPhotonDet,
|
||||
photonDetSurface);
|
||||
|
||||
// visualization attributes -------------------------------------------------
|
||||
|
||||
auto visAttributes = new G4VisAttributes(G4Colour(1.0,1.0,1.0));
|
||||
visAttributes->SetVisibility(false);
|
||||
fLogicWorld->SetVisAttributes(visAttributes);
|
||||
fVisAttributes.push_back(visAttributes);
|
||||
|
||||
visAttributes = new G4VisAttributes(G4Colour(0.2,0.2,0.2,0.5));
|
||||
visAttributes->SetVisibility(true);
|
||||
logicExtrusion->SetVisAttributes(visAttributes);
|
||||
fVisAttributes.push_back(visAttributes);
|
||||
|
||||
visAttributes = new G4VisAttributes(G4Colour(0.0,0.0,1.0,0.9));
|
||||
visAttributes->SetVisibility(true);
|
||||
logicScintillator->SetVisAttributes(visAttributes);
|
||||
fVisAttributes.push_back(visAttributes);
|
||||
|
||||
visAttributes = new G4VisAttributes(G4Colour(0.0,0.8,0.2,0.2));
|
||||
visAttributes->SetVisibility(true);
|
||||
logicScintSide->SetVisAttributes(visAttributes);
|
||||
fVisAttributes.push_back(visAttributes);
|
||||
|
||||
visAttributes = new G4VisAttributes(G4Colour(0.0,0.8,0.2,0.2));
|
||||
visAttributes->SetVisibility(true);
|
||||
logicScintCrnr->SetVisAttributes(visAttributes);
|
||||
fVisAttributes.push_back(visAttributes);
|
||||
|
||||
visAttributes = new G4VisAttributes(G4Colour(0.4,0.0,0.0,0.5));
|
||||
visAttributes->SetVisibility(true);
|
||||
fLogicHole->SetVisAttributes(visAttributes);
|
||||
fVisAttributes.push_back(visAttributes);
|
||||
|
||||
if(logicClad1 != nullptr)
|
||||
{
|
||||
visAttributes = new G4VisAttributes(G4Colour(0.0,0.8,0.5,0.5));
|
||||
visAttributes->SetVisibility(true);
|
||||
logicClad1->SetVisAttributes(visAttributes);
|
||||
fVisAttributes.push_back(visAttributes);
|
||||
}
|
||||
|
||||
if(logicClad2 != nullptr)
|
||||
{
|
||||
visAttributes = new G4VisAttributes(G4Colour(0.0,0.5,0.8,0.5));
|
||||
visAttributes->SetVisibility(true);
|
||||
logicClad2->SetVisAttributes(visAttributes);
|
||||
fVisAttributes.push_back(visAttributes);
|
||||
}
|
||||
|
||||
visAttributes = new G4VisAttributes(G4Colour(0.8,0.8,1.0));
|
||||
visAttributes->SetVisibility(true);
|
||||
logicWLSfiber->SetVisAttributes(visAttributes);
|
||||
fVisAttributes.push_back(visAttributes);
|
||||
|
||||
if(fMirrorToggle == true)
|
||||
{
|
||||
visAttributes = new G4VisAttributes(G4Colour(0.3,0.3,1.0,0.3));
|
||||
visAttributes->SetVisibility(true);
|
||||
logicMirror->SetVisAttributes(visAttributes);
|
||||
fVisAttributes.push_back(visAttributes);
|
||||
}
|
||||
|
||||
visAttributes = new G4VisAttributes(G4Colour(0.0,0.0,0.5,0.5));
|
||||
visAttributes->SetVisibility(true);
|
||||
logicCouple->SetVisAttributes(visAttributes);
|
||||
fVisAttributes.push_back(visAttributes);
|
||||
|
||||
visAttributes = new G4VisAttributes(G4Colour(0.3,0.3,0.3,0.5));
|
||||
visAttributes->SetVisibility(true);
|
||||
logicClrfiber->SetVisAttributes(visAttributes);
|
||||
fVisAttributes.push_back(visAttributes);
|
||||
|
||||
visAttributes = new G4VisAttributes(G4Colour(1.0,1.0,1.0,0.8));
|
||||
visAttributes->SetVisibility(true);
|
||||
logicPhotonDet->SetVisAttributes(visAttributes);
|
||||
fVisAttributes.push_back(visAttributes);
|
||||
|
||||
return fPhysiWorld;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void WLSDetectorConstruction::ConstructSDandField()
|
||||
@@ -603,72 +699,13 @@ void WLSDetectorConstruction::UpdateGeometryParameters()
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4RotationMatrix WLSDetectorConstruction::StringToRotationMatrix(
|
||||
G4String rotation)
|
||||
{
|
||||
// We apply successive rotations OF THE OBJECT around the FIXED
|
||||
// axes of the parent's local coordinates; rotations are applied
|
||||
// left-to-right (rotation="r1,r2,r3" => r1 then r2 then r3).
|
||||
|
||||
G4RotationMatrix rot;
|
||||
|
||||
unsigned int place = 0;
|
||||
|
||||
while(place < rotation.size())
|
||||
{
|
||||
G4double angle;
|
||||
char* p;
|
||||
|
||||
const G4String tmpstring = rotation.substr(place + 1);
|
||||
angle = strtod(tmpstring.c_str(), &p) * deg;
|
||||
|
||||
if(!p || (*p != (char) ',' && *p != (char) '\0'))
|
||||
{
|
||||
G4cerr << "Invalid rotation specification: " << rotation.c_str()
|
||||
<< G4endl;
|
||||
return rot;
|
||||
}
|
||||
|
||||
G4RotationMatrix thisRotation;
|
||||
|
||||
switch(rotation.substr(place, 1).c_str()[0])
|
||||
{
|
||||
case 'X':
|
||||
case 'x':
|
||||
thisRotation = G4RotationMatrix(CLHEP::HepRotationX(angle));
|
||||
break;
|
||||
case 'Y':
|
||||
case 'y':
|
||||
thisRotation = G4RotationMatrix(CLHEP::HepRotationY(angle));
|
||||
break;
|
||||
case 'Z':
|
||||
case 'z':
|
||||
thisRotation = G4RotationMatrix(CLHEP::HepRotationZ(angle));
|
||||
break;
|
||||
default:
|
||||
G4cerr << " Invalid rotation specification: " << rotation << G4endl;
|
||||
return rot;
|
||||
}
|
||||
|
||||
rot = thisRotation * rot;
|
||||
place = rotation.find(',', place);
|
||||
if(place > rotation.size())
|
||||
break;
|
||||
++place;
|
||||
}
|
||||
|
||||
return rot;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void WLSDetectorConstruction::SetPhotonDetGeometry(G4String shape)
|
||||
// Set the Geometry of the PhotonDet detector
|
||||
// Pre: shape must be either "Circle" and "Square"
|
||||
{
|
||||
if(shape == "Circle" || shape == "Square")
|
||||
fMPPCShape = shape;
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
G4RunManager::GetRunManager()->GeometryHasBeenModified();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
#include "WLSPhotonDetHit.hh"
|
||||
#include "WLSRun.hh"
|
||||
#include "WLSRunAction.hh"
|
||||
#include "WLSTrajectory.hh"
|
||||
|
||||
#include "G4AnalysisManager.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4EventManager.hh"
|
||||
#include "G4RunManager.hh"
|
||||
@@ -75,7 +75,6 @@ void WLSEventAction::BeginOfEventAction(const G4Event*)
|
||||
fClad1Bounce = 0;
|
||||
fClad2Bounce = 0;
|
||||
fReflected = 0;
|
||||
fDetected = 0;
|
||||
fEscaped = 0;
|
||||
fMirror = 0;
|
||||
}
|
||||
@@ -108,6 +107,14 @@ void WLSEventAction::EndOfEventAction(const G4Event* evt)
|
||||
n_hit = mppcHC->entries();
|
||||
}
|
||||
|
||||
auto analysisManager = G4AnalysisManager::Instance();
|
||||
analysisManager->FillH1(2, mppcHC->entries());
|
||||
for (size_t i = 0; i < mppcHC->entries(); ++i) {
|
||||
auto pdHit = (*mppcHC)[i];
|
||||
analysisManager->FillH1(0, pdHit->GetEnergy());
|
||||
analysisManager->FillH1(1, pdHit->GetArrivalTime());
|
||||
}
|
||||
|
||||
if(fVerboseLevel > 1)
|
||||
{
|
||||
G4cout << "-------------------------------------" << G4endl
|
||||
@@ -121,7 +128,6 @@ void WLSEventAction::EndOfEventAction(const G4Event* evt)
|
||||
<< " Clad1 Bounce: " << fClad1Bounce << G4endl
|
||||
<< " Clad2 Bounce: " << fClad2Bounce << G4endl
|
||||
<< " Reflected: " << fReflected << G4endl
|
||||
<< " Detected: " << fDetected << G4endl
|
||||
<< " Escaped: " << fEscaped << G4endl
|
||||
<< " Mirror: " << fMirror << G4endl
|
||||
<< " Detector hit: " << n_hit << G4endl;
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
//
|
||||
#include "WLSPhotonDetHit.hh"
|
||||
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
G4ThreadLocal G4Allocator<WLSPhotonDetHit>* WLSPhotonDetHitAllocator = nullptr;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -37,6 +39,7 @@ G4ThreadLocal G4Allocator<WLSPhotonDetHit>* WLSPhotonDetHitAllocator = nullptr;
|
||||
WLSPhotonDetHit::WLSPhotonDetHit()
|
||||
{
|
||||
fArrivalTime = 0.;
|
||||
fEnergy = 0.;
|
||||
fPosArrive = G4ThreeVector(0., 0., 0.);
|
||||
fPosExit = G4ThreeVector(0., 0., 0.);
|
||||
}
|
||||
@@ -44,11 +47,12 @@ WLSPhotonDetHit::WLSPhotonDetHit()
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
WLSPhotonDetHit::WLSPhotonDetHit(G4ThreeVector pExit, G4ThreeVector pArrive,
|
||||
G4double pTime)
|
||||
G4double pTime, G4double pEnergy)
|
||||
{
|
||||
fPosExit = pExit;
|
||||
fPosArrive = pArrive;
|
||||
fArrivalTime = pTime;
|
||||
fEnergy = pEnergy;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -70,6 +74,7 @@ const WLSPhotonDetHit& WLSPhotonDetHit::operator=(const WLSPhotonDetHit& right)
|
||||
fPosExit = right.fPosExit;
|
||||
fPosArrive = right.fPosArrive;
|
||||
fArrivalTime = right.fArrivalTime;
|
||||
fEnergy = right.fEnergy;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -79,5 +84,21 @@ const WLSPhotonDetHit& WLSPhotonDetHit::operator=(const WLSPhotonDetHit& right)
|
||||
G4bool WLSPhotonDetHit::operator==(const WLSPhotonDetHit& right) const
|
||||
{
|
||||
return fPosExit == right.fPosExit && fPosArrive == right.fPosArrive &&
|
||||
fArrivalTime == right.fArrivalTime;
|
||||
fArrivalTime == right.fArrivalTime && fEnergy == right.fEnergy;
|
||||
}
|
||||
|
||||
void WLSPhotonDetHit::Print()
|
||||
{
|
||||
G4cout
|
||||
<< "Arrival time: "
|
||||
<< std::setw(7) << G4BestUnit(fArrivalTime, "Time")
|
||||
<< "Arrival position: ("
|
||||
<< std::setw(7) << G4BestUnit(fPosArrive.x(), "Length") << ", "
|
||||
<< std::setw(7) << G4BestUnit(fPosArrive.y(), "Length") << "); "
|
||||
<< "Exit position: ("
|
||||
<< std::setw(7) << G4BestUnit(fPosExit.x(), "Length") << ", "
|
||||
<< std::setw(7) << G4BestUnit(fPosExit.y(), "Length") << "); "
|
||||
<< "Energy: "
|
||||
<< std::setw(7) << G4BestUnit(fEnergy, "Energy")
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
@@ -72,17 +72,7 @@ void WLSPhotonDetSD::Initialize(G4HCofThisEvent* HCE)
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4bool WLSPhotonDetSD::ProcessHits(G4Step*, G4TouchableHistory*)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4bool WLSPhotonDetSD::ProcessHits_boundary(const G4Step* aStep,
|
||||
G4TouchableHistory*)
|
||||
// Generates a hit and uses the postStepPoint; PostStepPoint because the hit
|
||||
// is generated manually when the photon hits the detector
|
||||
G4bool WLSPhotonDetSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
|
||||
{
|
||||
if(!aStep)
|
||||
return false;
|
||||
@@ -106,6 +96,7 @@ G4bool WLSPhotonDetSD::ProcessHits_boundary(const G4Step* aStep,
|
||||
G4ThreeVector photonExit = trackInformation->GetExitPosition();
|
||||
G4ThreeVector photonArrive = thePostPoint->GetPosition();
|
||||
G4double arrivalTime = theTrack->GetGlobalTime();
|
||||
G4double energy = theTrack->GetTotalEnergy();
|
||||
|
||||
// Convert the global coordinate for arriving photons into
|
||||
// the local coordinate of the detector
|
||||
@@ -114,7 +105,19 @@ G4bool WLSPhotonDetSD::ProcessHits_boundary(const G4Step* aStep,
|
||||
|
||||
// Creating the hit and add it to the collection
|
||||
fPhotonDetHitCollection->insert(
|
||||
new WLSPhotonDetHit(photonExit, photonArrive, arrivalTime));
|
||||
new WLSPhotonDetHit(photonExit, photonArrive, arrivalTime, energy));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void WLSPhotonDetSD::EndOfEvent(G4HCofThisEvent*)
|
||||
{
|
||||
if ( verboseLevel>1 ) {
|
||||
G4int nofHits = fPhotonDetHitCollection->entries();
|
||||
G4cout << G4endl
|
||||
<< "-------->Hits Collection: in this event there are " << nofHits
|
||||
<< " hits in the photon detector: " << G4endl;
|
||||
for ( G4int i=0; i<nofHits; i++ ) (*fPhotonDetHitCollection)[i]->Print();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ void WLSPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
}
|
||||
|
||||
// this does not work.
|
||||
G4String cmd = "/gun/energy " + G4String(sampledEnergy / eV) + " eV";
|
||||
G4String cmd = "/gun/energy " + G4UIcommand::ConvertToString(sampledEnergy / eV) + " eV";
|
||||
G4UImanager::GetUIpointer()->ApplyCommand(cmd);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,8 +54,6 @@ WLSRun::WLSRun()
|
||||
fClad2Bounce2 = 0.;
|
||||
fReflected = 0.;
|
||||
fReflected2 = 0.;
|
||||
fDetected = 0.;
|
||||
fDetected2 = 0.;
|
||||
fEscaped = 0.;
|
||||
fEscaped2 = 0.;
|
||||
fMirror = 0.;
|
||||
@@ -92,8 +90,6 @@ void WLSRun::Merge(const G4Run* run)
|
||||
fClad2Bounce2 += localRun->fClad2Bounce2;
|
||||
fReflected += localRun->fReflected;
|
||||
fReflected2 += localRun->fReflected2;
|
||||
fDetected += localRun->fDetected;
|
||||
fDetected2 += localRun->fDetected2;
|
||||
fEscaped += localRun->fEscaped;
|
||||
fEscaped2 += localRun->fEscaped2;
|
||||
fMirror += localRun->fMirror;
|
||||
@@ -184,14 +180,6 @@ void WLSRun::EndOfRun()
|
||||
else
|
||||
rmsReflected = 0.;
|
||||
|
||||
fDetected = fDetected / TotNbofEvents;
|
||||
fDetected2 = fDetected2 / TotNbofEvents;
|
||||
G4double rmsDetected = fDetected2 - fDetected * fDetected;
|
||||
if(rmsDetected > 0.)
|
||||
rmsDetected = std::sqrt(rmsDetected);
|
||||
else
|
||||
rmsDetected = 0.;
|
||||
|
||||
fEscaped = fEscaped / TotNbofEvents;
|
||||
fEscaped2 = fEscaped2 / TotNbofEvents;
|
||||
G4double rmsEscaped = fEscaped2 - fEscaped * fEscaped;
|
||||
@@ -229,7 +217,6 @@ void WLSRun::EndOfRun()
|
||||
<< " +- " << rmsClad1Bounce << G4endl
|
||||
<< " Clad2 Bounce: " << fClad2Bounce << " +- " << rmsClad2Bounce
|
||||
<< G4endl << " Reflected: " << fReflected << " +- " << rmsReflected
|
||||
<< G4endl << " Detected: " << fDetected << " +- " << rmsDetected
|
||||
<< G4endl << " Escaped: " << fEscaped << " +- " << rmsEscaped
|
||||
<< G4endl << " Mirror: " << fMirror << " +- " << rmsMirror
|
||||
<< G4endl << " Detector hit: " << fDetectorHits << " +- "
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "WLSRun.hh"
|
||||
#include "WLSSteppingAction.hh"
|
||||
|
||||
#include "G4AnalysisManager.hh"
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "Randomize.hh"
|
||||
@@ -43,7 +44,20 @@
|
||||
|
||||
WLSRunAction::WLSRunAction()
|
||||
: fRun(nullptr)
|
||||
{}
|
||||
{
|
||||
auto analysisManager = G4AnalysisManager::Instance();
|
||||
|
||||
analysisManager->SetDefaultFileType("root");
|
||||
analysisManager->SetVerboseLevel(1);
|
||||
G4cout << "Using " << analysisManager->GetType() << G4endl;
|
||||
|
||||
analysisManager->CreateH1("Energy", "Energy of optical photon", 100,
|
||||
2.*CLHEP::eV, 3.2*CLHEP::eV);
|
||||
analysisManager->CreateH1("Time", "Arrival time", 100, 0., 100.*CLHEP::ns);
|
||||
analysisManager->CreateH1("Number of photons", "Number of photons", 100, 0., 100.);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -57,12 +71,37 @@ G4Run* WLSRunAction::GenerateRun()
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void WLSRunAction::BeginOfRunAction(const G4Run*) {}
|
||||
void WLSRunAction::BeginOfRunAction(const G4Run*)
|
||||
{
|
||||
G4AnalysisManager::Instance()->OpenFile("wls");
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void WLSRunAction::EndOfRunAction(const G4Run*)
|
||||
{
|
||||
auto analysisManager = G4AnalysisManager::Instance();
|
||||
if (analysisManager->GetH1(0)) {
|
||||
G4cout << G4endl << " ----> print histograms statistics ";
|
||||
if(isMaster)
|
||||
{
|
||||
G4cout << "for the entire run " << G4endl << G4endl;
|
||||
}
|
||||
else {
|
||||
G4cout << "for the local thread " << G4endl << G4endl;
|
||||
}
|
||||
|
||||
G4cout << " Mean number of photons detected/event: "
|
||||
<< analysisManager->GetH1(2)->mean()
|
||||
<< " rms = "
|
||||
<< analysisManager->GetH1(2)->rms() << G4endl;
|
||||
|
||||
}
|
||||
|
||||
analysisManager->Write();
|
||||
analysisManager->CloseFile();
|
||||
|
||||
|
||||
if(isMaster)
|
||||
fRun->EndOfRun();
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ void WLSSteppingAction::UserSteppingAction(const G4Step* theStep)
|
||||
// Record Photons that missed the photon detector but escaped from readout
|
||||
if(!thePostPV && trackInformation->IsStatus(EscapedFromReadOut))
|
||||
{
|
||||
G4cout << "SteppingAction: status = EscapedFromReadOut" << G4endl;
|
||||
//G4cout << "SteppingAction: status = EscapedFromReadOut" << G4endl;
|
||||
fEventAction->AddEscaped();
|
||||
// UpdateHistogramSuccess(thePostPoint,theTrack);
|
||||
ResetCounters();
|
||||
@@ -308,7 +308,7 @@ void WLSSteppingAction::UserSteppingAction(const G4Step* theStep)
|
||||
}
|
||||
return;
|
||||
|
||||
// Reflection of the mirror
|
||||
// Reflection off the mirror
|
||||
case LambertianReflection:
|
||||
case LobeReflection:
|
||||
case SpikeReflection:
|
||||
@@ -324,30 +324,12 @@ void WLSSteppingAction::UserSteppingAction(const G4Step* theStep)
|
||||
|
||||
// Detected by a detector
|
||||
case Detection:
|
||||
// Detected automatically with G4OpBoundaryProcess->InvokeSD set true
|
||||
|
||||
// Check if the photon hits the detector and process the hit if it does
|
||||
if(thePostPVname == "PhotonDet")
|
||||
{
|
||||
// G4cout << "Detection" << G4endl;
|
||||
fEventAction->AddDetected();
|
||||
G4SDManager* SDman = G4SDManager::GetSDMpointer();
|
||||
G4String SDname = "WLS/PhotonDet";
|
||||
WLSPhotonDetSD* mppcSD =
|
||||
(WLSPhotonDetSD*) SDman->FindSensitiveDetector(SDname);
|
||||
|
||||
if(mppcSD)
|
||||
mppcSD->ProcessHits_boundary(theStep, nullptr);
|
||||
|
||||
// Record Photons that escaped at the end
|
||||
// if (trackInformation->IsStatus(EscapedFromReadOut))
|
||||
// UpdateHistogramSuccess(thePostPoint,theTrack);
|
||||
|
||||
// Stop Tracking when it hits the detector's surface
|
||||
ResetCounters();
|
||||
theTrack->SetTrackStatus(fStopAndKill);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
// Stop Tracking when it hits the detector's surface
|
||||
ResetCounters();
|
||||
theTrack->SetTrackStatus(fStopAndKill);
|
||||
return;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "G4Step.hh"
|
||||
#include "G4StepStatus.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4VProcess.hh"
|
||||
|
||||
@@ -136,7 +137,7 @@ std::vector<G4AttValue>* WLSTrajectoryPoint::CreateAttValues() const
|
||||
values->push_back(G4AttValue("Time", G4BestUnit(fTime, "Time"), ""));
|
||||
values->push_back(
|
||||
G4AttValue("Momentum", G4BestUnit(fMomentum, "Momentum"), ""));
|
||||
values->push_back(G4AttValue("StepStatus", fStepStatus, ""));
|
||||
values->push_back(G4AttValue("StepStatus", G4UIcommand::ConvertToString(fStepStatus), ""));
|
||||
values->push_back(G4AttValue("VolumeName", fVolumeName, ""));
|
||||
|
||||
return values;
|
||||
|
||||
Reference in New Issue
Block a user