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
Ph2 TK Digitizer software updated for RandomNumberGenerator service #22836
Ph2 TK Digitizer software updated for RandomNumberGenerator service #22836
Conversation
The code-checks are being triggered in jenkins. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-22836/4223 |
A new Pull Request was created by @suchandradutta (Suchandra Dutta) for master. It involves the following packages: SimTracker/SiPhase2Digitizer @cmsbuild, @civanch, @kpedro88, @mdhildreth can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
Thanks @suchandradutta , Could you please edit the title mentioning that this is a fix in the random generator usage in the phase2 tracker digitizer to be a bit more explicit ? Also could you please backport to 93X ? Thank you again |
@boudoul yes I shall back port it for 93X once the PR is reviewed and accepted. I hope you agree. |
sure, thanks |
void Phase2TrackerDigitizerAlgorithm::initializeEvent(CLHEP::HepRandomEngine* eng) { | ||
if (addNoise || AddPixelInefficiency || fluctuateCharge || addThresholdSmearing) { | ||
|
||
flatDistribution_ = std::unique_ptr<CLHEP::RandFlat>(new CLHEP::RandFlat(*eng, 0., 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.
@suchandradutta , it is recommended to use a constructor CLHEP::RandFlat(eng,0.,1.), however, this is also an overhead. It is enough to use use "rengine_->flat(); flatDistribution_ is not needed.
@@ -200,12 +198,12 @@ class Phase2TrackerDigitizerAlgorithm { | |||
const SubdetEfficiencies subdetEfficiencies_; | |||
|
|||
// For random numbers | |||
const std::unique_ptr<CLHEP::RandFlat> flatDistribution_; | |||
const std::unique_ptr<CLHEP::RandGaussQ> gaussDistribution_; | |||
std::unique_ptr<CLHEP::RandFlat> flatDistribution_; |
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 is not needed to keep flatDistribution_
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.
@suchandradutta Thanks! I gave some suggestions for further improvements (all not necessarily for this PR).
algomap_[AlgorithmType::InnerPixel] = std::unique_ptr<Phase2TrackerDigitizerAlgorithm>(new PixelDigitizerAlgorithm(iconfig_)); | ||
algomap_[AlgorithmType::PixelinPS] = std::unique_ptr<Phase2TrackerDigitizerAlgorithm>(new PSPDigitizerAlgorithm(iconfig_)); | ||
algomap_[AlgorithmType::StripinPS] = std::unique_ptr<Phase2TrackerDigitizerAlgorithm>(new PSSDigitizerAlgorithm(iconfig_)); | ||
algomap_[AlgorithmType::TwoStrip] = std::unique_ptr<Phase2TrackerDigitizerAlgorithm>(new SSDigitizerAlgorithm(iconfig_)); |
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.
Right-hand side could be written more shortly as std::make_unique<PixelDigitizerAlgorithm>(iConfig);
etc.
On a more general note (possibly going beyond this PR)
algomap_
could be implemented asstd::vector
(consumes less memory, faster access)iconfig_
could now be removed ifisOTreadoutAnalog
parameter would be read to member variable
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.
@suchandradutta Could you actually remove the iconfig_
in this PR? It will have to be either removed or changed to a regular member (not reference, so consumes memory) for premixing. Thanks.
void Phase2TrackerDigitizer::endLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& iSetup) { | ||
algomap_.clear(); | ||
edm::LogInfo("Phase2TrackerDigitizer") << "End Luminosity Block"; |
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.
Please remove this function as it does nothing useful anymore.
Phase2TrackerDigitizer::~Phase2TrackerDigitizer() { | ||
edm::LogInfo("Phase2TrackerDigitizer") << "Destroying the Digitizer"; | ||
algomap_.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.
Calling clear()
is unnecessary (algomap_
's destructor will clean up all its contents automatically).
flatDistribution_.reset(nullptr); | ||
gaussDistribution_.reset(nullptr); | ||
smearedThreshold_Endcap_.reset(nullptr); | ||
smearedThreshold_Barrel_.reset(nullptr); |
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.
These are not needed, unique_ptr
default is nullptr
.
// Threshold smearing with gaussian distribution: | ||
if (addThresholdSmearing) { | ||
smearedThreshold_Endcap_ = std::unique_ptr<CLHEP::RandGaussQ> (new CLHEP::RandGaussQ(eng, theThresholdInE_Endcap , theThresholdSmearing_Endcap)); | ||
smearedThreshold_Barrel_ = std::unique_ptr<CLHEP::RandGaussQ> (new CLHEP::RandGaussQ(eng, theThresholdInE_Barrel , theThresholdSmearing_Barrel)); |
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.
std::make_unique<T>()
could be used here as well (if these are still needed, ref. @civanch's comment #22836 (comment)).
@boudoul is there a specific need for this in 93X? |
hi @kpedro88 , I do not have any particularly need. However when I do see in the description of the issue #22710 (adressed by this PR) how not safe it is (with many details explained in this issue) and knowing that 93X is intensively used for MC prod, I would feel better if this fix is also propagated there. |
Okay, I hadn't read #22710. At some point we plan to leave 9_3_X behind, so unless UPSG is going to stop current production to wait for this, I'm not sure if a backport will get merged. Well, we can still make the backport PR so we have it if needed. |
Is there the same issue in run-2 Digi, or only Phase2? |
@civanch No, this issue is specific to phase2. |
The code-checks are being triggered in jenkins. |
Pull request #22836 was updated. @cmsbuild, @civanch, @kpedro88, @mdhildreth can you please check and sign again. |
please test |
The tests are being triggered in jenkins. |
Comparison job queued. |
Comparison is ready Comparison Summary:
|
Changes throughout Phase 2 workflows due to difference in random number usage, consistent with statistical fluctuations |
+1 |
+1 |
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. @davidlange6, @slava77, @smuzaffar, @fabiocos (and backports should be raised in the release meeting by the corresponding L2) |
@suchandradutta @makortel as far as I can see this PR is complementary to #22874 and not conflicting, right? |
@fabiocos Yes, they are independent. |
+1 |
The usage of edm::RandomNumberGenerator reviewed following the comment in [1]. We are now generating random numbers in each event independently. The code is accordingly updated.
@makortel, @boudoul, @emiglior
[1] #22710 (comment)