-
Notifications
You must be signed in to change notification settings - Fork 62
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
Pandora plugin to calculate material properties of calorimeters dynamically #432
base: main
Are you sure you want to change the base?
Conversation
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.
Thank you for your PR! It is well-written.
I have one question: Would it be possible or advisable for the plugin to erase any previous data extension? If so, this can be done by adding a few lines I mentioned in the comments, and the detector constructor can be unstaged from the PR
Thank you for your time!
detector/calorimeter/ECalBarrel_NobleLiquid_InclinedTrapezoids_o1_v01_geo.cpp
Show resolved
Hide resolved
caloData->extent[2] = 0.0; // Barrel-specific value | ||
caloData->extent[3] = half_length; | ||
|
||
caloDetElem.addExtension<dd4hep::rec::LayeredCalorimeterData>(caloData); |
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.
could you move this line after the print out "Successfully added LayeredCalorimeterData", at the end of the function?
In addition, to be discussed... do you think it is acceptable/advisable to remove any data extension attached by the detector constructor itself? If so, it can be done as follows:
if( ! caloDetElem->extensions.empty()) {
dd4hep::printout(PrintLevel::WARNING, LOG_SOURCE, "Removing data extensions from %s", subDetectorName.c_str());
// delete extensions first, then clear container
for (auto& p : caloDetElem->extensions) {
delete p.second;
}
caloDetElem->extensions.clear();
}
This also requires an additional header:
#include <DD4hep/detail/DetectorInterna.h>
This way, the plugin becomes more robust against potential cases where other data extension is hardcoded in the detector constructor (if a previous data extension exists, DD4hep crashes)
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.
Wouldn't this cause a memory leak?
caloDetElem->extensions.clear();
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, you are right, thank you for spotting it!
I changed my suggestion in the original message
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.
... do you think it is acceptable/advisable to remove any data extension attached
Actually, it is not advisable to remove all extensions. It might make sense to remove the extension of the type we add here. It might also make sense to throw an error and let the user figure out which extension they want to keep. Maybe add a flag to replace or not an existing extension.
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.
We need to add a convenience function in dd4hep to make it easier to remove specific extensions. This issue brought up here will be addressed in a later PR then.
dd4hep::rec::Vector3D ivr1 = dd4hep::rec::Vector3D(0., rad_first, 0); // defining starting vector points of the given layer | ||
dd4hep::rec::Vector3D ivr2 = dd4hep::rec::Vector3D(0., rad_last, 0); // defining end vector points of the given layer | ||
|
||
const dd4hep::rec::MaterialVec &materials = matMgr.materialsBetween(ivr1, ivr2); // calling material manager(MM) to get material info between two points |
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.
do you think it would be good idea to protect against empty vectors?
// skip layer if no materials found
if( materials.empty() ) continue;
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 unless rad_first == rad_last
it is impossible for there to be no materials between two points? There must at least be the world volume. Or something is more wrong in the geometry than we can protect against here.
194a422
to
20b9dfa
Compare
…nedTrapezoids_o1_v01_geo.cpp
…levant changes in the xml file to acoomodate the plugin. The layeredCalorimeter information from ECalBarrel_NobleLiquid_InclinedTrapezoids_o1_v01_geo.cpp is removed to accomodate the new plugin
…ng internal variables
…rheight for calolayer extension instead of scaling back and forth align some code with the plugin code as well
20b9dfa
to
06d6e63
Compare
BEGINRELEASENOTES
LayeredCalorimeterData
class from DD4hep to store layer-by-layer information e.g radiation length., essential for shower reconstruction and energy measurement.ECalBarrel_NobleLiquid_InclinedTrapezoids_o1_v01_geo.cpp
and xml fileCLD_o4_v05.xml
should also be noted to accommodate the plugin.ENDRELEASENOTES