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
BS online for 11 2 x #30591
BS online for 11 2 x #30591
Conversation
The code-checks are being triggered in jenkins. |
-code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-30591/16842
Code check has found code style and quality issues which could be resolved by applying following patch(s)
|
The code-checks are being triggered in jenkins. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-30591/16843
|
A new Pull Request was created by @gennai (simone gennai) for master. It involves the following packages: CondFormats/DataRecord @perrotta, @slava77, @christopheralanwest, @tocheng, @cmsbuild, @jpata, @tlampen, @ggovi, @pohsun can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
@Martin-Grunewald @Sam-Harper you may want to have a look at this as well |
Adding also @francescobrivio |
RecoVertex/BeamSpotProducer/plugins/OfflineToTransientBeamSpotESProducer.cc
Outdated
Show resolved
Hide resolved
RecoVertex/BeamSpotProducer/plugins/OnlineBeamSpotESProducer.cc
Outdated
Show resolved
Hide resolved
//std::cout << iEvent.getRun().beginTime().value() << std::endl; | ||
//std::cout << iEvent.time().value() << std::endl; | ||
std::cout << *mybeamspot << std::endl; | ||
std::cout << *myGTbeamspot << std::endl; |
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.
MessageLogger...
@gennai |
Hi @Martin-Grunewald , thanks for spotting the cout they clearly should not be there, and also for the reminder of the fill description method! I will work on it asap. |
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
|
||
class OnlineBeamSpotFromDB : public edm::EDAnalyzer { |
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.
global/one/stream EDAnalyzer... not a legacy one
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'd also suggest to move the contents of the EDAnalyzer and ESProducers headers to the corresponding source files because the separate header files are not needed.
} | ||
|
||
OfflineToTransientBeamSpotESProducer::~OfflineToTransientBeamSpotESProducer() { | ||
delete transientBS_; |
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 would delete also the product read from BeamSpotObjectsRcd
which would lead to double-delete.
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.
shall I remove the delete then? When running I didn't notice any error or warning messages, though.
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.
so matti, I couldnt follow this specific double delete. Is this because transientBS_ is returned as a shared pointer by the producer? But in this case, due to the deletation function, the shared pointer wont delete the object. Or something else?
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 current version of the code is ok (no delete
) so further discussion may be moot, but earlier in the produce()
there was an assignment
transientBS_ = &rec.get(bsOfflineToken_);
and a later delete transientBS_
would delete an object returned by rec.get()
, which is owned by the EventSetup system.
if (iRecord.tryToGetRecord<BeamSpotObjectsRcd>()) { | ||
host->ifRecordChanges<BeamSpotObjectsRcd>( | ||
iRecord, [this, h = host.get()](auto const& rec) { transientBS_ = &rec.get(bsOfflineToken_); }); | ||
} |
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 don't follow why the ESProductHost would be needed
. How about something along
// in class declaration
const BeamSpotObjects dummyBS_;
// in here
auto optionalRec = iRecord.tryToGetRecord<BeamSpotObjectsRcd>();
if (not optionalRec) {
return std::shared_ptr<const BeamSpotObjects>(&dummyBS_), edm::do_nothing_deleter());
}
return std::shared_ptr<const BeamSpotObjects>(&optionalRec->get(bsOfflineToken_), edm::do_nothing_deleter());
|
||
OnlineBeamSpotESProducer::~OnlineBeamSpotESProducer() { | ||
delete theHLTBS_; | ||
delete theLegacyBS_; |
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 may delete the ESProduct leading to double-delete.
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 comment on the double-delete still holds though.
transientBS_->SetPosition(0, 0, 0); | ||
transientBS_->SetBeamWidthY(0.1); | ||
transientBS_->SetBeamWidthX(0.1); | ||
transientBS_->SetSigmaZ(5.0); |
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.
Modifying an ESProducer member variable that is returned as an ESProduct does not work with concurrent IOVs. I'm wondering if this code as written is intended for production use?
Assuming "no", and that the intention is to return the better of "HLT" and "legacy", how about something along
auto legacyRec = iRecord.tryToGetRecord<BeamSpotOnlineLegacyObjectsRcd>();
auto hltRec = iRecord.tryToGetRecord<BeamSpotOnlineHLTObjectsRcd>();
if (not legacyRec and not hltRec) {
return std::shared_ptr<const BeamSpotObjects>(&fakeBS_, edm::do_nothing_deleter());
// or copy in case 'const BeamSpotObjects fakeBS_' member would not be preferred
return std::make_shared<BeamSpotObjects>(fakeBS_);
}
const BeamSpotOnlineObjects* best;
if (legacyRec and hltRec) {
best = compareBS(&legacyRec->get(bsLegacyToken_), &hltRec->get(bsHLTToken_));
}
else if (legacyRec) {
best = &legacyRec->get(bsLegacytoken_);
}
else {
best = &hltRec->get(bsHLTToken_);
}
return std::shared_ptr<const BeamSpotObjects>(best, edm::do_nothing_deleter());
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'd still suggest the above. It would avoid the edm::ESProductHost
and any allocations that currently may lead to memory leak and double-delete.
The code-checks are being triggered in jenkins. |
Let me close this PR and open a cleaner one as I messed up quite heavily. |
-code-checks ERROR: Build errors found during clang-tidy run.
|
PR description:
In this PR I modify the transient beamspot record to depend also from the offline beamspot record and added a number of plugins for its use in the HLT menu for Run3.
PR validation:
I have made some checks running the RecoVertex/BeamSpotProducer/test/readOnlineBeamSpotFromDB.py
script