-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iss1376 geant4 object pointer for comparison #1633
base: trunk
Are you sure you want to change the base?
Iss1376 geant4 object pointer for comparison #1633
Conversation
…he elctron definition to be simpler
return volume; | ||
} | ||
} | ||
return nullptr; // Volume not found |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we warn here?
|
||
if (processName.compareTo("eBrem") == 0 && | ||
auto electron = G4Electron::Definition(); | ||
auto eBrem_process = Geant4_PtrRetrieval::GetProcess(electron, "eBrem"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we can just do pointer comparison, no need to do string comparison right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have several style comments, but I can point those out privately.
Bigger picture tho: why did you need two classes and not just one? Geant4_PtrRetrieval
is still not a good name, there are a billion pointers in GEANT4. I honestly dont have a bullet proof suggestion, but something like a GeometryHelper
, or VolumeCheckHelper
would be better (and it should have the conent of the current pointer retrieval and volume test file). @tomeichlersmith @EinarElen do you have a preference, new suggestion?
One thing of note though: I wasn't able to fix this line
Because its a wrapped process the pointer it creates is not the same as the unwrapped pointer. So when I would try to do comparisons and printouts.
Clearly photonNuclear is in there. But the pointer is different because of the wrapping. I couldn't figure out how to get rid of the wrapping without going back to just doing string to string, but more complicated. If anyone has any suggestions on how this could be fixed I would appreciate it @tomeichlersmith @EinarElen |
Could you use the pointer returned by In any case, I think that's okay. The main goal of switching to comparing pointers rather than strings is the performance improvement. This is only called at the beginning of a run so it doesn't have as large of a performance effect. |
@tvami What are you referring to here? The functions are just in the As far as the naming, I would maybe rename it to be more clearly just a namespace where we have used all lower case, no under scores. |
I meant to not have two header files (Geant4_PtrRetrieval.h and VolumeTests.h), just one. Haha it's too generic and too specific at the same time. Can we not expect to retrieve something else than a pointer? Or then it will be another namespace? VolumeTests.h already just returns booleans, so if we merge the two then |
We have the Right now, it holds implementations of Geant4's user actions, but I think including a (If this sounds good but you are having trouble implementing it @LiamBrennan-UCSB , let me know and I can push what I'm thinking to this branch.) |
OK but then |
Yea that makes sense 👍 |
@@ -56,7 +56,6 @@ class TargetENProcessFilter : public simcore::UserAction { | |||
* target parent volume and so it will break if the target parent volume | |||
* changes its name. | |||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You removed the variable but not the corresponding comment
// auto volume{track->GetVolume()->GetLogicalVolume() | ||
// ? track->GetVolume()->GetLogicalVolume()->GetName() | ||
// : "undefined"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete these, although I'm not sure what the advantage of your new lines are wrt to what is now to be deleted
return process; | ||
} | ||
} | ||
std::cerr << "[WARNING] Process '" << processName << "' not found.\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dont use cerr use the ldmx logging
std::cerr << "[WARNING] Process '" << processName << "' not found.\n"; | |
ldmx_log(warn) << "Process '" << processName << "' not found."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Talking with Liam I understand this might not be simple, as this is a namespace. Should we not throw the warning in the user class end? i.e. if the getProcess
returned a nullptr
then have the warning in the respective filter? @EinarElen @tomeichlersmith
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I vote to have the warning in the user class end although its not technically difficult to support logging within a namespace. The only requirement for ldmx_log
to function is for a framework::logging::logger
named theLog_
to be present within scope. A namespace-level variable could then support logging for all of the functions under one "channel", but I think it makes more sense to have the warning be in the user classes.
inline G4Region* getRegion(const std::string& name) { | ||
G4Region* region = G4RegionStore::GetInstance()->GetRegion(name); | ||
if (!region) { | ||
std::cerr << "[WARNING] Region '" << name << "' not found.\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
inline G4VPhysicalVolume* getPhysicalVolume(const std::string& name) { | ||
auto* volume = G4PhysicalVolumeStore::GetInstance()->GetVolume(name); | ||
if (!volume) { | ||
std::cerr << "[WARNING] Volume '" << name << "' not found.\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
inline G4LogicalVolume* getLogicalVolume(const std::string& name) { | ||
auto* volume = G4LogicalVolumeStore::GetInstance()->GetVolume(name); | ||
if (!volume) { | ||
std::cerr << "[WARNING] Volume '" << name << "' not found.\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
* @param[in] vol G4LogicalVolume to check | ||
* @param[in] vol_to_bias UNUSED name of volume to bias | ||
*/ | ||
[[maybe_unused]] inline bool isInHcal(G4LogicalVolume* vol, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused about the [[maybe_unused]]
here and in the next occasions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me too, it is certainly used within DetectorConstruction.cxx
to I think these attributes should be removed to make sure that the compilation is appropriately using this single definition in multiple places.
if (processName.compareTo("eBrem") == 0 && | ||
auto electron = G4Electron::Definition(); | ||
auto ebrem_process = | ||
simcore::g4user::ptrretrieval::getProcess(electron, "eBrem"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it really the electron that's supposed to be here @tomeichlersmith @EinarElen ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so... thats the particle that would do the eBrem. Are you asking if this should be a photon whose creator process is eBrem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that was my thinking, but I guess it works as it is
…identally deleted file
….com:LDMX-Software/ldmx-sw into Iss1376-Geant4-Object-Pointer-for-Comparison
@@ -6,7 +6,7 @@ namespace simcore { | |||
|
|||
XsecBiasingOperator::XsecBiasingOperator( | |||
std::string name, const framework::config::Parameters& parameters) | |||
: G4VBiasingOperator(name) {} | |||
: G4VBiasingOperator(name), theLog_{framework::logging::makeLogger(name)} {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you merged but should have rebased, bc these changes here are already merged in https://github.com/LDMX-Software/ldmx-sw/pull/1630/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git switch trunk
git fetch
git pull
git switch -
git rebase trunk
Fixing Issue #1286 and Issue #1376. Adds functionality to call a Geant4 pointer to compare to another pointer within Simcore, Biasing, etc such that a pointer to pointer comparison can be made rather than completing string to string as was done previously.
What are the issues that this addresses?
Check List