-
Notifications
You must be signed in to change notification settings - Fork 101
FairModule IsSensitive checks medium property not volume name #1628
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
| #include "FairRuntimeDb.h" // for FairRuntimeDb | ||
|
|
||
| #include <TCollection.h> // for TRangeDynCast | ||
| #include <TGeoManager.h> | ||
| #include <TGeoMatrix.h> | ||
| #include <TGeoNode.h> | ||
| #include <TGeoVolume.h> | ||
|
|
@@ -103,12 +104,28 @@ class FairModule : public TNamed | |
| template<class T, class U> | ||
| void ConstructASCIIGeometry(TString containerName = ""); | ||
|
|
||
| /**Set the sensitivity flag for volumes, called from ConstructASCIIRootGeometry(), and has to be implimented for | ||
| * detectors which use ConstructASCIIRootGeometry() to build the geometry */ | ||
| virtual Bool_t IsSensitive(const std::string& name); | ||
| /** | ||
| * Check volume sensitivity by probing medium sensitivity flag. | ||
| * | ||
| * Function checks the sensitivity property of the medium. This is generic approach and should work for any volume. | ||
| * Override this _only_ in case of specific customisation. | ||
| * | ||
| * See Bool_t IsSensitive(const std::string& name) for deprecation notice. | ||
| */ | ||
| virtual bool IsSensitive(TGeoVolume* vol) { return (vol->GetMedium()->GetParam(0) == 1.0); } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IF I got some of the notes correctly, then this is a standard attribute of the medium? The Thinking about my backward compatible request, maybe the current default implementation should be And in a later update we could use this one? Yes, this means that everyone who wants to use this customization point would need to implement this code. But it would maybe help with PR acceptance?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And we use There is no constant/enum defined, just 0 - not sensitive, > 0 - sensitive. So, as I also wrote it before, this is bi-state, either volume is senstivie or non-sensitive. Thats way Other idea - using exceptions. Throw in the base function and catch it, or the derived function returns valid value. Executing the string-based check will give some deprecation message, and perhaps full removal in the future (?).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant, whether there's a constant for the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, as you can find in line 84 of this code https://root.cern.ch/doc/master/TGeoMedium_8cxx_source.html#l00064, it is just magic number. |
||
|
|
||
| /** | ||
| * Set the sensitivity flag for volumes, called from ConstructASCIIRootGeometry(), and has to be implimented for | ||
| * detectors which use ConstructASCIIRootGeometry() to build the geometry | ||
| */ | ||
| [[deprecated("Remove override of this function. Use override of IsSensitive(TGeoVolume* vol) only if customisation " | ||
| "required. This function will be removed in the future releases.")]] | ||
| virtual Bool_t IsSensitive(const std::string& name) final; | ||
|
|
||
| /**The function below is depracated, please change to the new method above */ | ||
| virtual Bool_t CheckIfSensitive(__attribute__((unused)) std::string name) __attribute__(( | ||
| deprecated("The method CheckIfSensitive is deprecated. Implement IsSensitive in the detector classes."))) | ||
| [[deprecated("The method CheckIfSensitive is deprecated. Implement IsSensitive in the detector " | ||
| "classes. To be removed in the future.")]] | ||
| virtual Bool_t CheckIfSensitive(__attribute__((unused)) std::string name) final | ||
| { | ||
| return kFALSE; | ||
| } | ||
|
|
||

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.
BTW: Can we please (in another PR!)
(dynamic_cast<FairDetector>(this) != nullptr)?