Skip to content

Commit

Permalink
add cfg writer for SimBeamSpotObjects payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
francescobrivio committed Jun 13, 2023
1 parent bec539c commit daf6dd0
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 18 deletions.
22 changes: 4 additions & 18 deletions IOMC/EventVertexGenerators/src/BeamProfile2DB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class BeamProfile2DB : public edm::global::EDAnalyzer<> {
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
void beginJob() override;
void analyze(edm::StreamID, const edm::Event&, const edm::EventSetup&) const override;
void endJob() override;

Expand All @@ -72,23 +71,13 @@ namespace {
}

} // namespace
//
// constants, enums and typedefs
//

//
// static data member definitions
//

//
// constructors and destructor
//
BeamProfile2DB::BeamProfile2DB(const edm::ParameterSet& iConfig) : beamSpot_(read(iConfig)) {}

BeamProfile2DB::~BeamProfile2DB() {
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
}
BeamProfile2DB::~BeamProfile2DB() = default;

//
// member functions
Expand All @@ -97,9 +86,6 @@ BeamProfile2DB::~BeamProfile2DB() {
// ------------ method called for each event ------------
void BeamProfile2DB::analyze(edm::StreamID, const edm::Event& iEvent, const edm::EventSetup& iSetup) const {}

// ------------ method called once each job just before starting event loop ------------
void BeamProfile2DB::beginJob() {}

// ------------ method called once each job just after ending the event loop ------------
void BeamProfile2DB::endJob() {
edm::Service<cond::service::PoolDBOutputService> poolDbService;
Expand All @@ -117,9 +103,9 @@ void BeamProfile2DB::fillDescriptions(edm::ConfigurationDescriptions& descriptio
desc.add<double>("SigmaZ")->setComment("in cm");
desc.add<double>("BetaStar")->setComment("in cm");
desc.add<double>("Emittance")->setComment("in cm");
desc.add<double>("Alpha")->setComment("in radians");
desc.add<double>("Phi")->setComment("in radians");
desc.add<double>("TimeOffset")->setComment("in ns");
desc.add<double>("Alpha", 0.0)->setComment("in radians");
desc.add<double>("Phi", 0.0)->setComment("in radians");
desc.add<double>("TimeOffset", 0.0)->setComment("in ns");
descriptions.addDefault(desc);
}

Expand Down
53 changes: 53 additions & 0 deletions IOMC/EventVertexGenerators/test/BeamProfile2DBWriter_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import FWCore.ParameterSet.Config as cms
import FWCore.ParameterSet.VarParsing as VarParsing

process = cms.Process("writeBeamProfile2DB")

options = VarParsing.VarParsing()
options.register('unitTest',
False, # default value
VarParsing.VarParsing.multiplicity.singleton, # singleton or list
VarParsing.VarParsing.varType.bool, # string, int, or float
"are we running the unit test?")
options.register('inputTag',
"myTagName", # default value
VarParsing.VarParsing.multiplicity.singleton, # singleton or list
VarParsing.VarParsing.varType.string, # string, int, or float
"output tag name")
options.parseArguments()


process.load("FWCore.MessageLogger.MessageLogger_cfi")
from CondCore.CondDB.CondDB_cfi import *

if options.unitTest :
tag_name = 'simBS_tag'
else:
tag_name = options.inputTag

#################################
# Produce a SQLITE FILE
#################################
CondDBSimBeamSpotObjects = CondDB.clone(connect = cms.string('sqlite_file:test_%s.db' % tag_name)) # choose an output name
process.PoolDBOutputService = cms.Service("PoolDBOutputService",
CondDBSimBeamSpotObjects,
timetype = cms.untracked.string('runnumber'),
toPut = cms.VPSet(cms.PSet(record = cms.string("SimBeamSpotObjectsRcd"), # SimBeamSpot record
tag = cms.string(tag_name))), # choose your favourite tag
loadBlobStreamer = cms.untracked.bool(False)
)

process.source = cms.Source("EmptySource")

process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1))

process.simbeamspotwriter = cms.EDAnalyzer("BeamProfile2DB",
X0 = cms.double(0.0458532), # in cm
Y0 = cms.double(-0.016966), # in cm
Z0 = cms.double(-0.074992), # in cm
SigmaZ = cms.double(3.6), # in cm
BetaStar = cms.double(30.0), # in cm
Emittance = cms.double(3.931e-8) # in cm
)

process.p = cms.Path(process.simbeamspotwriter)

0 comments on commit daf6dd0

Please sign in to comment.