Skip to content

Commit

Permalink
Merge pull request #464 from OpenGATE/prevent_repeat_vol_for_digit
Browse files Browse the repository at this point in the history
Prevent using digitizer on daughters of repeated volumes
  • Loading branch information
dsarrut authored Sep 27, 2024
2 parents 79fd945 + 0b97605 commit cadb46d
Show file tree
Hide file tree
Showing 39 changed files with 425 additions and 124 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ opengate_temporaire
/opengate/tests/src/demo_code_*.py
/opengate/tests/src/test030_save
/opengate/tests/src/test_log*
/opengate/tests/src/save_tests

/opengate/data/isomeric_transition/save
/opengate/data/isomeric_transition/save2
Expand Down
11 changes: 11 additions & 0 deletions core/opengate_core/opengate_lib/GateHelpersGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ void ComputeTransformationFromVolumeToWorld(const std::string &phys_volume_name,
auto pvs = G4PhysicalVolumeStore::GetInstance();
while (name != "world") {
auto phys = pvs->GetVolume(name);
if (phys == nullptr) {
std::ostringstream oss;
oss << "The volume '" << name
<< "' is not found. Here is the list of volumes: ";
auto map = pvs->GetMap();
for (auto m : map) {
oss << m.first << " ";
}
oss << std::endl;
Fatal(oss.str());
}
auto tr = phys->GetObjectTranslation();
// auto rot = *phys->GetObjectRotation();
auto rot = phys->GetObjectRotationValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ GateDigiCollection::Iterator GateDigiCollection::NewIterator() {
}

std::string GateDigiCollection::DumpLastDigi() const {
if (GetSize() == 0)
return "";
std::ostringstream oss;
auto n = GetSize() - 1;
for (auto *att : fDigiAttributes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ void GateDigitizerHitsCollectionActor::SteppingAction(G4Step *step) {
// nb transportation
auto post = step->GetPostStepPoint();
auto process = post->GetProcessDefinedStep();
auto pname = process->GetProcessName();
static int nb_tr = 0;
if (pname == "Transportation") {
nb_tr++;
std::cout << pname << " " << nb_tr << " " << id << x << std::endl;
if (process != nullptr) {
auto pname = process->GetProcessName();
static int nb_tr = 0;
if (pname == "Transportation") {
nb_tr++;
std::cout << pname << " " << nb_tr << " " << id << x << std::endl;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ GateDigitizerProjectionActor::GateDigitizerProjectionActor(py::dict &user_info)
fActions.insert("StartSimulationAction");
fActions.insert("EndOfEventAction");
fActions.insert("BeginOfRunAction");
fPhysicalVolumeName = "None";
}

GateDigitizerProjectionActor::~GateDigitizerProjectionActor() = default;
Expand All @@ -35,6 +36,10 @@ void GateDigitizerProjectionActor::InitializeCpp() {
fImage = ImageType::New();
}

void GateDigitizerProjectionActor::SetPhysicalVolumeName(std::string name) {
fPhysicalVolumeName = name;
}

// Called when the simulation start
void GateDigitizerProjectionActor::StartSimulationAction() {
// Get input hits collection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class GateDigitizerProjectionActor : public GateVActor {

~GateDigitizerProjectionActor() override;

virtual void InitializeUserInput(py::dict &user_info) override;
void InitializeUserInput(py::dict &user_info) override;

virtual void InitializeCpp() override;
void InitializeCpp() override;

// Called when the simulation start (master thread only)
void StartSimulationAction() override;
Expand All @@ -42,6 +42,8 @@ class GateDigitizerProjectionActor : public GateVActor {
// Called every time an Event ends (all threads)
void EndOfEventAction(const G4Event *event) override;

void SetPhysicalVolumeName(std::string name);

// Image type is 3D float by default
typedef itk::Image<float, 3> ImageType;
ImageType::Pointer fImage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ void init_GateDigitizerProjectionActor(py::module &m) {
GateVActor>(m, "GateDigitizerProjectionActor")
.def(py::init<py::dict &>())
.def_readwrite("fImage", &GateDigitizerProjectionActor::fImage)
.def_readwrite("fPhysicalVolumeName",
&GateDigitizerProjectionActor::fPhysicalVolumeName);
.def("SetPhysicalVolumeName",
&GateDigitizerProjectionActor::SetPhysicalVolumeName);
}
2 changes: 1 addition & 1 deletion opengate/actors/actoroutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ class ActorOutputRoot(ActorOutputBase):

def get_output_path(self, *args, **kwargs):
if "which" in kwargs and kwargs["which"] != "merged":
warning(
self.warn_user(
"Currently, GATE 10 only stores cumulative ROOT output per simulation ('merged'), "
"not data per run. Showing you the path to the ROOT file with cumulative data."
)
Expand Down
16 changes: 7 additions & 9 deletions opengate/actors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,13 @@ def __setstate__(self, state):
self.__initcpp__()
self.__update_interface_properties__()

# def __finalize_init__(self):
# super().__finalize_init__()
# # The following attributes exist. They are declared here to avoid warning
# self.known_attributes.append("fFilters")
# self.known_attributes.append("actor_engine")
# self.known_attributes.append("user_output")
# self.known_attributes.append("simulation")
# self.known_attributes.append("__dict__")
# self.known_attributes.append("output_filename")
def __finalize_init__(self):
super().__finalize_init__()
# The following attributes exist. They are declared here to avoid warning
# fFilters is not known here because ActorBase does not inherit from a cpp counterpart.
self.known_attributes.add("fFilters")
# output_filename is a property
self.known_attributes.add("output_filename")

def to_dictionary(self):
d = super().to_dictionary()
Expand Down
Loading

0 comments on commit cadb46d

Please sign in to comment.