-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Allow caching of HFShowerLibrary #40278
Conversation
- removed virtual destructor to save 12 bytes of space when stored in a contiguous container. - explicitly have compiler create default constructor/operator=
- improved const correctness - moved member data which was only used as temporary storage to be function local variables (done in other classes as well). - encapsulate message logger calls within the log member function - made member data names conform to CMS standards - added unit tests - hold onto HFFibre directly, not via unique_ptr
- modified HFShowerLibrary to be easier to test by removing dependencies on conditions classes.
Use a helper class to manage the TBranch and how to read it back properly based on the file format.
The ability is off by default. The data can be safely shared by all HFShowerLibrary instances in a job.
please test |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-40278/33330
|
A new Pull Request was created by @Dr15Jones (Chris Jones) for master. It involves the following packages:
@civanch, @mdhildreth can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
const HcalSimulationParameters* hps, | ||
edm::ParameterSet const& p); | ||
~HFFibre() = default; | ||
HFFibre(const HcalDDDSimConstants* hcons, const HcalSimulationParameters* hps, edm::ParameterSet const& p); |
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.
The name
was not used.
std::array<double, 2> lambdaLimits_; | ||
}; | ||
|
||
HFFibre(Params iP); |
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.
This helps with testing as one doesn't have to create a ParameterSet
in order to setup the class.
|
||
private: | ||
const HcalDDDSimConstants* hcalConstant_; |
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.
Removed variables were only used during construction so did not have to be kept around.
int fileVersion_; | ||
bool cacheBranches_ = false; | ||
}; | ||
HFShowerLibrary(Params const &, FileParams const &, HFFibre::Params); |
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.
Helps with testing.
[[nodiscard]] HFShowerPhotonCollection getRecord(int) const; | ||
|
||
private: | ||
HFShowerPhotonCollection photons_; |
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.
Photons for all entries are stored in the same collection in order to avoid overhead of many individual std::vector<>
s. To find the entries one consults offsets_
.
ss1 << "\n"; | ||
nBinAtt_ = static_cast<int>(attL_.size()); | ||
|
||
edm::LogVerbatim("HFShower").log([&](auto& logger) { |
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.
LogVerbatim::log
will only call the lambda if the message will potentially be sent. This avoids building the std::stringstream
only to have its contents thrown away.
const HcalSimulationParameters* hps, | ||
edm::ParameterSet const& hfShower, | ||
edm::ParameterSet const& hfShowerLibrary) | ||
: HFShowerLibrary(paramsFrom(hfShower, hfShowerLibrary, hcons->getPhiTableHF().front()), |
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.
Having a constructor that takes the two different ParameterSets allowed those values to be passed to two different functions without having to call getParameterSet
several times.
if (nRecords > maxRecordsToCache) { | ||
nRecords = maxRecordsToCache; | ||
} | ||
offsets_.reserve(nRecords + 1); |
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.
offsets_[0+record]
returns the starting element in photons_
to read while offsets_[1+record]
gives one passed the end. Hence why we need 1 more element.
|
||
void HFShowerLibrary::getRecord(int type, int record) { | ||
HFShowerPhotonCollection HFShowerLibrary::BranchReader::getRecordOldForm(TBranch* iBranch, int iEntry) { |
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.
Moved handling of the different file formats into their own functions.
+1 Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-9fae6b/29549/summary.html Comparison SummarySummary:
|
+1 For this type of modification regression means that nothing changed for Run2 and Run3. Class organisation is improved. |
This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @perrotta, @dpiparo, @rappoccio (and backports should be raised in the release meeting by the corresponding L2) |
+1 |
PR description:
PR validation:
Comparing timing with and without caching showed a 1-2% speed improvement when using caching.