-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Online BeamSpot ESProducer for Run3 workflow #30965
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0d7337b
cleaning up on top of pre3
gennai ceee70f
fixed buildfile
gennai 464ea2a
further clean up of the code
gennai d093bd5
applied code format patch
gennai 3248c15
applied jpata and Matti comments
gennai 03d82de
using now regular member for fakeBS_
gennai 851cd62
removing un-needed commented lines
gennai File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
RecoVertex/BeamSpotProducer/plugins/OfflineToTransientBeamSpotESProducer.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include "CondFormats/DataRecord/interface/BeamSpotObjectsRcd.h" | ||
#include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h" | ||
#include "CondFormats/DataRecord/interface/BeamSpotTransientObjectsRcd.h" | ||
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
#include "FWCore/Framework/interface/ESProductHost.h" | ||
#include "FWCore/Utilities/interface/ReusableObjectHolder.h" | ||
#include "FWCore/Framework/interface/ESProducer.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
|
||
#include "FWCore/Framework/interface/EventSetup.h" | ||
#include "FWCore/Framework/interface/ESHandle.h" | ||
#include "FWCore/Framework/interface/ModuleFactory.h" | ||
#include "FWCore/Framework/interface/ESProducer.h" | ||
#include "FWCore/Utilities/interface/do_nothing_deleter.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
|
||
#include <iostream> | ||
#include <memory> | ||
#include <string> | ||
|
||
using namespace edm; | ||
class OfflineToTransientBeamSpotESProducer : public edm::ESProducer { | ||
public: | ||
OfflineToTransientBeamSpotESProducer(const edm::ParameterSet& p); | ||
// ~OfflineToTransientBeamSpotESProducer() override; | ||
std::shared_ptr<const BeamSpotObjects> produce(const BeamSpotTransientObjectsRcd&); | ||
static void fillDescriptions(edm::ConfigurationDescriptions& desc); | ||
|
||
private: | ||
//const BeamSpotObjects* theOfflineBS_; | ||
//const BeamSpotObjects *transientBS_ = nullptr; | ||
const BeamSpotObjects dummyBS_; | ||
edm::ESGetToken<BeamSpotObjects, BeamSpotTransientObjectsRcd> const bsToken_; | ||
edm::ESGetToken<BeamSpotObjects, BeamSpotObjectsRcd> bsOfflineToken_; | ||
}; | ||
|
||
OfflineToTransientBeamSpotESProducer::OfflineToTransientBeamSpotESProducer(const edm::ParameterSet& p) { | ||
auto cc = setWhatProduced(this); | ||
|
||
bsOfflineToken_ = cc.consumesFrom<BeamSpotObjects, BeamSpotObjectsRcd>(); | ||
} | ||
|
||
//OfflineToTransientBeamSpotESProducer::~OfflineToTransientBeamSpotESProducer() { | ||
//delete theOfflineBS_; | ||
//} | ||
void OfflineToTransientBeamSpotESProducer::fillDescriptions(edm::ConfigurationDescriptions& desc) { | ||
edm::ParameterSetDescription dsc; | ||
desc.addWithDefaultLabel(dsc); | ||
} | ||
std::shared_ptr<const BeamSpotObjects> OfflineToTransientBeamSpotESProducer::produce( | ||
const BeamSpotTransientObjectsRcd& iRecord) { | ||
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()); | ||
}; | ||
|
||
DEFINE_FWK_EVENTSETUP_MODULE(OfflineToTransientBeamSpotESProducer); |
98 changes: 98 additions & 0 deletions
98
RecoVertex/BeamSpotProducer/plugins/OnlineBeamSpotESProducer.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
#include "FWCore/Framework/interface/ESHandle.h" | ||
#include "FWCore/Framework/interface/ModuleFactory.h" | ||
#include "FWCore/Framework/interface/ESProducer.h" | ||
#include "FWCore/Utilities/interface/do_nothing_deleter.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
#include "DataFormats/BeamSpot/interface/BeamSpot.h" | ||
#include "CondFormats/DataRecord/interface/BeamSpotObjectsRcd.h" | ||
//#include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h" | ||
#include "CondFormats/BeamSpotObjects/interface/BeamSpotOnlineObjects.h" | ||
#include "CondFormats/DataRecord/interface/BeamSpotOnlineLegacyObjectsRcd.h" | ||
#include "CondFormats/DataRecord/interface/BeamSpotOnlineHLTObjectsRcd.h" | ||
#include "CondFormats/DataRecord/interface/BeamSpotTransientObjectsRcd.h" | ||
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
|
||
#include "FWCore/Framework/interface/ESProductHost.h" | ||
#include "FWCore/Utilities/interface/ReusableObjectHolder.h" | ||
#include "FWCore/Framework/interface/ESProducer.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include <memory> | ||
#include <iostream> | ||
#include <string> | ||
|
||
using namespace edm; | ||
|
||
class OnlineBeamSpotESProducer : public edm::ESProducer { | ||
public: | ||
OnlineBeamSpotESProducer(const edm::ParameterSet& p); | ||
std::shared_ptr<const BeamSpotObjects> produce(const BeamSpotTransientObjectsRcd&); | ||
static void fillDescriptions(edm::ConfigurationDescriptions& desc); | ||
|
||
private: | ||
const BeamSpotOnlineObjects* compareBS(const BeamSpotOnlineObjects* bs1, const BeamSpotOnlineObjects* bs2); | ||
std::shared_ptr<BeamSpotObjects> fakeBS_; | ||
|
||
edm::ESGetToken<BeamSpotObjects, BeamSpotTransientObjectsRcd> const bsToken_; | ||
edm::ESGetToken<BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcd> bsHLTToken_; | ||
edm::ESGetToken<BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcd> bsLegacyToken_; | ||
}; | ||
OnlineBeamSpotESProducer::OnlineBeamSpotESProducer(const edm::ParameterSet& p) { | ||
auto cc = setWhatProduced(this); | ||
|
||
fakeBS_ = std::make_shared<BeamSpotOnlineObjects>(); | ||
fakeBS_->SetBeamWidthX(0.1); | ||
fakeBS_->SetBeamWidthY(0.1); | ||
fakeBS_->SetSigmaZ(15.); | ||
fakeBS_->SetPosition(0., 0., 0.); | ||
fakeBS_->SetType(-1); | ||
|
||
bsHLTToken_ = cc.consumesFrom<BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcd>(); | ||
bsLegacyToken_ = cc.consumesFrom<BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcd>(); | ||
} | ||
|
||
void OnlineBeamSpotESProducer::fillDescriptions(edm::ConfigurationDescriptions& desc) { | ||
edm::ParameterSetDescription dsc; | ||
desc.addWithDefaultLabel(dsc); | ||
} | ||
|
||
const BeamSpotOnlineObjects* OnlineBeamSpotESProducer::compareBS(const BeamSpotOnlineObjects* bs1, | ||
const BeamSpotOnlineObjects* bs2) { | ||
//Random logic so far ... | ||
if (bs1->GetSigmaZ() - 0.0001 < bs2->GetSigmaZ()) { //just temporary for debugging | ||
if (bs1->GetSigmaZ() > 5.) { | ||
return bs1; | ||
} else { | ||
return bs2; | ||
} | ||
|
||
} else { | ||
if (bs2->GetSigmaZ() > 5.) { | ||
return bs2; | ||
} else { | ||
return bs1; | ||
} | ||
} | ||
} | ||
|
||
std::shared_ptr<const BeamSpotObjects> OnlineBeamSpotESProducer::produce(const BeamSpotTransientObjectsRcd& iRecord) { | ||
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()); | ||
gennai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// 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()); | ||
}; | ||
|
||
DEFINE_FWK_EVENTSETUP_MODULE(OnlineBeamSpotESProducer); |
56 changes: 56 additions & 0 deletions
56
RecoVertex/BeamSpotProducer/plugins/OnlineBeamSpotFromDB.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/**_________________________________________________________________ | ||
class: OnlineBeamSpotFromDB.cc | ||
package: RecoVertex/BeamSpotProducer | ||
|
||
|
||
|
||
author: Francisco Yumiceva, Fermilab (yumiceva@fnal.gov) | ||
|
||
|
||
________________________________________________________________**/ | ||
|
||
#include "DataFormats/BeamSpot/interface/BeamSpot.h" | ||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
#include "FWCore/ServiceRegistry/interface/Service.h" | ||
#include "FWCore/Framework/interface/ESHandle.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
#include "FWCore/Framework/interface/IOVSyncValue.h" | ||
#include "CondFormats/DataRecord/interface/BeamSpotTransientObjectsRcd.h" | ||
#include "CondFormats/BeamSpotObjects/interface/BeamSpotOnlineObjects.h" | ||
#include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/ConsumesCollector.h" | ||
#include "FWCore/Framework/interface/one/EDAnalyzer.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
#include <string> | ||
|
||
class OnlineBeamSpotFromDB : public edm::one::EDAnalyzer<> { | ||
public: | ||
explicit OnlineBeamSpotFromDB(const edm::ParameterSet& iConfig); | ||
static void fillDescriptions(edm::ConfigurationDescriptions& desc); | ||
edm::ESGetToken<BeamSpotObjects, BeamSpotTransientObjectsRcd> bsToken_; | ||
|
||
private: | ||
void analyze(const edm::Event&, const edm::EventSetup&) override; | ||
}; | ||
|
||
OnlineBeamSpotFromDB::OnlineBeamSpotFromDB(const edm::ParameterSet& iConfig) | ||
: bsToken_(esConsumes<BeamSpotObjects, BeamSpotTransientObjectsRcd>()) {} | ||
|
||
void OnlineBeamSpotFromDB::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { | ||
auto const& mybeamspot = iSetup.getData(bsToken_); | ||
|
||
edm::LogInfo("Run numver: ") << iEvent.id().run(); | ||
edm::LogInfo("beamspot from HLT ") << mybeamspot; | ||
} | ||
void OnlineBeamSpotFromDB::fillDescriptions(edm::ConfigurationDescriptions& desc) { | ||
edm::ParameterSetDescription dsc; | ||
desc.addWithDefaultLabel(dsc); | ||
} | ||
|
||
//define this as a plug-in | ||
DEFINE_FWK_MODULE(OnlineBeamSpotFromDB); | ||
gennai marked this conversation as resolved.
Show resolved
Hide resolved
|
55 changes: 55 additions & 0 deletions
55
RecoVertex/BeamSpotProducer/test/readOnlineBeamSpotFromDB.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
process = cms.Process("readDB") | ||
process.load("FWCore.MessageLogger.MessageLogger_cfi") | ||
|
||
|
||
process.load("CondCore.DBCommon.CondDBSetup_cfi") | ||
|
||
|
||
""" | ||
process.BeamSpotDBSource = cms.ESSource("PoolDBESSource", | ||
process.CondDBSetup, | ||
toGet = cms.VPSet( | ||
|
||
|
||
cms.PSet( | ||
record = cms.string('BeamSpotOnlineLegacyObjectsRcd'), | ||
tag = cms.string("BeamSpotOnlineTestLegacy"), | ||
refreshTime = cms.uint64(1) | ||
|
||
), | ||
#cms.PSet( | ||
# record = cms.string('BeamSpotOnlineHLTObjectsRcd'), | ||
# tag = cms.string('BSOnLineHLT_tag'), | ||
# refreshTime = cms.uint64(1) | ||
# ) | ||
|
||
), | ||
# connect = cms.string('sqlite_file:BeamSpotOnlineLegacy_JetHT.db') | ||
connect = cms.string('oracle://cms_orcon_prod/CMS_CONDITIONS') | ||
#connect = cms.string('frontier://PromptProd/CMS_COND_31X_BEAMSPOT') | ||
) | ||
process.BeamSpotESProducer = cms.ESProducer("OnlineBeamSpotESProducer") | ||
""" | ||
from Configuration.AlCa.GlobalTag import GlobalTag as customiseGlobalTag | ||
process.GlobalTag = customiseGlobalTag(globaltag = "auto:run3_hlt_GRun") | ||
process.BeamSpotESProducer = cms.ESProducer("OfflineToTransientBeamSpotESProducer") | ||
|
||
|
||
process.MessageLogger.destinations = cms.untracked.vstring('detailedInfo') | ||
process.MessageLogger.detailedInfo = cms.untracked.PSet(threshold = cms.untracked.string('INFO')) | ||
|
||
process.source = cms.Source("EmptySource") | ||
process.source.numberEventsInRun=cms.untracked.uint32(2) | ||
process.source.firstRun = cms.untracked.uint32(336365) | ||
process.source.firstLuminosityBlock = cms.untracked.uint32(13) | ||
process.source.numberEventsInLuminosityBlock = cms.untracked.uint32(1) | ||
process.maxEvents = cms.untracked.PSet( | ||
input = cms.untracked.int32(5) | ||
) | ||
process.beamspot = cms.EDAnalyzer("OnlineBeamSpotFromDB") | ||
|
||
|
||
process.p = cms.Path(process.beamspot) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
let's remove