Skip to content

Commit

Permalink
Merge pull request #99 from rest-for-physics/lobis-fix-pipeline
Browse files Browse the repository at this point in the history
Fix pipeline due to compilation warning
  • Loading branch information
lobis authored Mar 2, 2023
2 parents 86b8b09 + 60726ee commit a7610c7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
2 changes: 0 additions & 2 deletions .github/pr-badge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@
message: "Ok: $additions"
color: "green"
when: "$additions < 100"
- imageUrl: "https://gitlab.cern.ch/rest-for-physics/restG4/badges/$branchName/pipeline.svg"
url: "https://gitlab.cern.ch/rest-for-physics/restG4/-/commits/$branchName"
- imageUrl: "https://github.com/rest-for-physics/restG4/actions/workflows/validation.yml/badge.svg?branch=$branchName"
url: "https://github.com/rest-for-physics/restG4/commits/$branchName"
24 changes: 12 additions & 12 deletions src/DetectorConstruction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,20 @@ G4VPhysicalVolume* DetectorConstruction::Construct() {
filesystem::current_path(startingPath);

auto sensitiveVolume = (string)restG4Metadata->GetSensitiveVolume();
G4VPhysicalVolume* physicalVolume = GetPhysicalVolume(sensitiveVolume);
if (physicalVolume == nullptr) {
G4VPhysicalVolume* sensitivePhysicalVolume = GetPhysicalVolume(sensitiveVolume);
if (sensitivePhysicalVolume == nullptr) {
// sensitive volume was not found, perhaps the user specified a logical volume
auto physicalVolumes = geometryInfo.GetAllPhysicalVolumesFromLogical(sensitiveVolume);
if (physicalVolumes.size() == 1) {
restG4Metadata->InsertSensitiveVolume(
geometryInfo.GetAlternativeNameFromGeant4PhysicalName(physicalVolumes[0]));
sensitiveVolume = (string)restG4Metadata->GetSensitiveVolume();
physicalVolume = GetPhysicalVolume(sensitiveVolume);
sensitivePhysicalVolume = GetPhysicalVolume(sensitiveVolume);
}
}

if (physicalVolume == nullptr) {
G4cout << "ERROR: Sensitive volume '" << sensitiveVolume << "' not found" << G4endl;
if (sensitivePhysicalVolume == nullptr) {
cerr << "ERROR: Sensitive volume '" << sensitiveVolume << "' not found" << endl;
exit(1);
}

Expand All @@ -129,7 +129,7 @@ G4VPhysicalVolume* DetectorConstruction::Construct() {
fieldMgr->SetDetectorField(magField);
fieldMgr->CreateChordFinder(magField);

G4LogicalVolume* volume = physicalVolume->GetLogicalVolume();
G4LogicalVolume* volume = sensitivePhysicalVolume->GetLogicalVolume();
G4Material* material = volume->GetMaterial();
G4cout << "Sensitive volume properties:" << G4endl;
G4cout << "\t- Material: " << material->GetName() << G4endl;
Expand All @@ -149,34 +149,34 @@ G4VPhysicalVolume* DetectorConstruction::Construct() {

if (spatialGeneratorTypeEnum == TRestGeant4PrimaryGeneratorTypes::SpatialGeneratorTypes::VOLUME &&
primaryGeneratorInfo.GetSpatialGeneratorFrom() != "Not defined") {
G4VPhysicalVolume* physicalVolume =
G4VPhysicalVolume* gdmlPhysicalVolume =
GetPhysicalVolume(primaryGeneratorInfo.GetSpatialGeneratorFrom().Data());
if (physicalVolume == nullptr) {
if (gdmlPhysicalVolume == nullptr) {
// perhaps the user selected a logical volume instead
auto physicalVolumes = geometryInfo.GetAllPhysicalVolumesFromLogical(
primaryGeneratorInfo.GetSpatialGeneratorFrom().Data());
if (physicalVolumes.size() == 1) {
physicalVolume = GetPhysicalVolume(physicalVolumes[0].Data());
gdmlPhysicalVolume = GetPhysicalVolume(physicalVolumes[0].Data());
cout << "Generator volume '" << primaryGeneratorInfo.GetSpatialGeneratorFrom()
<< "' was not found in the geometry. Using the physical volume '" << physicalVolumes[0]
<< "' instead, which was obtained from logical volume '"
<< primaryGeneratorInfo.GetSpatialGeneratorFrom() << "'" << endl;
}
}
if (physicalVolume == nullptr) {
if (gdmlPhysicalVolume == nullptr) {
cerr << "ERROR: The generator volume '" << primaryGeneratorInfo.GetSpatialGeneratorFrom()
<< "' was not found in the geometry" << endl;
exit(1);
}

fGeneratorTranslation = physicalVolume->GetTranslation();
fGeneratorTranslation = gdmlPhysicalVolume->GetTranslation();
if (spatialGeneratorTypeEnum == TRestGeant4PrimaryGeneratorTypes::SpatialGeneratorTypes::SURFACE ||
spatialGeneratorTypeEnum == TRestGeant4PrimaryGeneratorTypes::SpatialGeneratorTypes::VOLUME) {
restG4Metadata->fGeant4PrimaryGeneratorInfo.fSpatialGeneratorPosition = {
fGeneratorTranslation.x(), fGeneratorTranslation.y(), fGeneratorTranslation.z()};
}

fGeneratorSolid = physicalVolume->GetLogicalVolume()->GetSolid();
fGeneratorSolid = gdmlPhysicalVolume->GetLogicalVolume()->GetSolid();

fBoundBoxXMax = -1.e30;
fBoundBoxYMax = -1.e30;
Expand Down

0 comments on commit a7610c7

Please sign in to comment.