Skip to content
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

Closed
wants to merge 926 commits into from
Closed

Conversation

gennai
Copy link
Contributor

@gennai gennai commented Jul 8, 2020

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

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 8, 2020

The code-checks are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 8, 2020

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-30591/16842

  • This PR adds an extra 36KB to repository

Code check has found code style and quality issues which could be resolved by applying following patch(s)

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 8, 2020

The code-checks are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 8, 2020

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-30591/16843

  • This PR adds an extra 36KB to repository

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 8, 2020

A new Pull Request was created by @gennai (simone gennai) for master.

It involves the following packages:

CondFormats/DataRecord
RecoVertex/BeamSpotProducer

@perrotta, @slava77, @christopheralanwest, @tocheng, @cmsbuild, @jpata, @tlampen, @ggovi, @pohsun can you please review it and eventually sign? Thanks.
@makortel, @GiacomoSguazzoni, @JanFSchulte, @tocheng, @VinInn, @ebrondol, @rovere, @mmusich, @mtosi, @dgulhan, @seemasharmafnal this is something you requested to watch as well.
@silviodonato, @dpiparo you are the release manager for this.

cms-bot commands are listed here

@gennai
Copy link
Contributor Author

gennai commented Jul 8, 2020

@Martin-Grunewald @Sam-Harper you may want to have a look at this as well

@gennai
Copy link
Contributor Author

gennai commented Jul 8, 2020

Adding also @francescobrivio

//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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MessageLogger...

@Martin-Grunewald
Copy link
Contributor

@gennai
All new plugins either need a fillDescriptions method (even if there are no parameters!), or a cfi file in ../python.
This is needed such that ConfDB parsing can discover the new plugins (via the fillDescriptions-generated or the explicit cfi file).

@gennai
Copy link
Contributor Author

gennai commented Jul 8, 2020

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 {
Copy link
Contributor

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

Copy link
Contributor

@makortel makortel left a 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_;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor

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_); });
}
Copy link
Contributor

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_;
Copy link
Contributor

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.

Copy link
Contributor

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);
Copy link
Contributor

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());

Copy link
Contributor

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.

@cmsbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@gennai
Copy link
Contributor Author

gennai commented Jul 29, 2020

Let me close this PR and open a cleaner one as I messed up quite heavily.

@gennai gennai closed this Jul 29, 2020
@cmsbuild
Copy link
Contributor

-code-checks

ERROR: Build errors found during clang-tidy run.

CondFormats/DataRecord/interface/BeamSpotTransientObjectsRcd.h:30:1: error: version control conflict marker in file [clang-diagnostic-error]
<<<<<<< HEAD
^
Suppressed 1051 warnings (1050 in non-user code, 1 with check filters).
--
CondFormats/DataRecord/interface/BeamSpotTransientObjectsRcd.h:30:1: error: version control conflict marker in file [clang-diagnostic-error]
<<<<<<< HEAD
^
Suppressed 1124 warnings (1123 in non-user code, 1 with check filters).
--
CondFormats/DataRecord/interface/BeamSpotTransientObjectsRcd.h:30:1: error: version control conflict marker in file [clang-diagnostic-error]
<<<<<<< HEAD
^
Suppressed 1459 warnings (1458 in non-user code, 1 with check filters).
--
gmake: *** [config/SCRAM/GMake/Makefile.coderules:128: code-checks] Error 2
gmake: *** [There are compilation/build errors. Please see the detail log above.] Error 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment