CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
BeamSpotOnlineFromOfflineConverter Class Reference

#include <CondTools/BeamSpot/plugins/BeamSpotOnlineFromOfflineConverter.cc>

Inheritance diagram for BeamSpotOnlineFromOfflineConverter:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 BeamSpotOnlineFromOfflineConverter (const edm::ParameterSet &)
 
cond::Time_t pack (uint32_t, uint32_t)
 
 ~BeamSpotOnlineFromOfflineConverter () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 

Private Attributes

const edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcdbsToken_
 
const std::string endTime_
 
uint32_t fIOVStartLumi_
 
uint32_t fIOVStartRun_
 
const bool fIsHLT_
 
cond::Time_t fnewSince_
 
bool fuseNewSince_
 
const int lastAnalyzedFill_
 
const int lastAnalyzedLumi_
 
const int lastAnalyzedRun_
 
const std::string lumiRange_
 
const float meanPVError_
 
const float meanPVs_
 
const int numMaxPVs_
 
const int numPVs_
 
const int numTracks_
 
const int numUsedEvents_
 
const float rmsPV_
 
const float rmsPVError_
 
const std::string startTime_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: EDAnalyzer to create a BeamSpotOnlineHLTObjectsRcd from a BeamSpotObjectsRcd (inserting some parameters manually)

Implementation: [Notes on implementation]

Definition at line 47 of file BeamSpotOnlineFromOfflineConverter.cc.

Constructor & Destructor Documentation

◆ BeamSpotOnlineFromOfflineConverter()

BeamSpotOnlineFromOfflineConverter::BeamSpotOnlineFromOfflineConverter ( const edm::ParameterSet iConfig)
explicit

Definition at line 78 of file BeamSpotOnlineFromOfflineConverter.cc.

References edm::ParameterSet::exists(), fIOVStartLumi_, fIOVStartRun_, fnewSince_, fuseNewSince_, edm::ParameterSet::getUntrackedParameter(), and pack().

79  : bsToken_(esConsumes()),
80  lastAnalyzedLumi_(iConfig.getParameter<double>("lastAnalyzedLumi")),
81  lastAnalyzedRun_(iConfig.getParameter<double>("lastAnalyzedRun")),
82  lastAnalyzedFill_(iConfig.getParameter<double>("lastAnalyzedFill")),
83  numTracks_(iConfig.getParameter<int>("numTracks")),
84  numPVs_(iConfig.getParameter<int>("numPVs")),
85  numUsedEvents_(iConfig.getParameter<int>("numUsedEvents")),
86  numMaxPVs_(iConfig.getParameter<int>("numMaxPVs")),
87  meanPVs_(iConfig.getParameter<double>("meanPVs")),
88  meanPVError_(iConfig.getParameter<double>("meanPVError")),
89  rmsPV_(iConfig.getParameter<double>("rmsPVs")),
90  rmsPVError_(iConfig.getParameter<double>("rmsPVError")),
91  startTime_(iConfig.getParameter<std::string>("startTime")),
92  endTime_(iConfig.getParameter<std::string>("endTime")),
93  lumiRange_(iConfig.getParameter<std::string>("lumiRange")),
94  fIsHLT_(iConfig.getParameter<bool>("isHLT")) {
95  if (iConfig.exists("IOVStartRun") && iConfig.exists("IOVStartLumi")) {
96  fIOVStartRun_ = iConfig.getUntrackedParameter<uint32_t>("IOVStartRun");
97  fIOVStartLumi_ = iConfig.getUntrackedParameter<uint32_t>("IOVStartLumi");
99  fuseNewSince_ = true;
100  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << "useNewSince = True";
101  } else {
102  fuseNewSince_ = false;
103  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << "useNewSince = False";
104  }
105 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
bool exists(std::string const &parameterName) const
checks if a parameter exists
T getUntrackedParameter(std::string const &, T const &) const
Log< level::Warning, true > LogPrint
const edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcd > bsToken_

◆ ~BeamSpotOnlineFromOfflineConverter()

BeamSpotOnlineFromOfflineConverter::~BeamSpotOnlineFromOfflineConverter ( )
overridedefault

Member Function Documentation

◆ analyze()

void BeamSpotOnlineFromOfflineConverter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 117 of file BeamSpotOnlineFromOfflineConverter.cc.

References cond::service::PoolDBOutputService::appendOneIOV(), cond::service::PoolDBOutputService::beginOfTime(), bsToken_, BeamSpotOnlineObjects::copyFromBeamSpotObject(), submitPVResolutionJobs::count, cond::service::PoolDBOutputService::createOneIOV(), beamSpotPI::creationTime, cond::service::PoolDBOutputService::currentTime(), endTime_, fIsHLT_, fnewSince_, fuseNewSince_, edm::EventSetup::getData(), edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), lastAnalyzedFill_, lastAnalyzedLumi_, lastAnalyzedRun_, lumiRange_, meanPVError_, meanPVs_, submitPVValidationJobs::now, numMaxPVs_, numPVs_, numTracks_, numUsedEvents_, rmsPV_, rmsPVError_, BeamSpotOnlineObjects::setCreationTime(), BeamSpotOnlineObjects::setEndTime(), BeamSpotOnlineObjects::setEndTimeStamp(), BeamSpotOnlineObjects::setLastAnalyzedFill(), BeamSpotOnlineObjects::setLastAnalyzedLumi(), BeamSpotOnlineObjects::setLastAnalyzedRun(), BeamSpotOnlineObjects::setLumiRange(), BeamSpotOnlineObjects::setMaxPVs(), BeamSpotOnlineObjects::setMeanErrorPV(), BeamSpotOnlineObjects::setMeanPV(), BeamSpotOnlineObjects::setNumPVs(), BeamSpotOnlineObjects::setNumTracks(), BeamSpotOnlineObjects::setRmsErrorPV(), BeamSpotOnlineObjects::setRmsPV(), BeamSpotOnlineObjects::setStartTime(), BeamSpotOnlineObjects::setStartTimeStamp(), BeamSpotOnlineObjects::setUsedEvents(), startTime_, AlCaHLTBitMon_QueryRunRegistry::string, and hcalRecHitTable_cff::time.

117  {
118  const std::string fLabel = (fIsHLT_) ? "BeamSpotOnlineHLTObjectsRcd" : "BeamSpotOnlineLegacyObjectsRcd";
119  const BeamSpotObjects* inputSpot = &iSetup.getData(bsToken_);
120 
121  BeamSpotOnlineObjects abeam;
122  abeam.copyFromBeamSpotObject(*inputSpot);
126  abeam.setStartTimeStamp(std::time(nullptr));
127  abeam.setEndTimeStamp(std::time(nullptr));
128  abeam.setNumTracks(numTracks_);
129  abeam.setNumPVs(numPVs_);
131  abeam.setMaxPVs(numMaxPVs_);
132  abeam.setMeanPV(meanPVs_);
134  abeam.setRmsPV(rmsPV_);
135  abeam.setRmsErrorPV(rmsPVError_);
136  abeam.setStartTime(startTime_);
137  abeam.setEndTime(endTime_);
138  abeam.setLumiRange(lumiRange_);
139 
140  // Set the creation time of the payload to the current time
141  auto creationTime =
142  std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
144 
145  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << " Writing results to DB...";
146  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << abeam;
147 
149  if (poolDbService.isAvailable()) {
150  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << "poolDBService available";
151  if (poolDbService->isNewTagRequest(fLabel)) {
152  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << "new tag requested";
153  if (fuseNewSince_) {
154  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << "Using a new Since: " << fnewSince_;
155  poolDbService->createOneIOV<BeamSpotOnlineObjects>(abeam, fnewSince_, fLabel);
156  } else
157  poolDbService->createOneIOV<BeamSpotOnlineObjects>(abeam, poolDbService->beginOfTime(), fLabel);
158  } else {
159  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << "no new tag requested";
160  if (fuseNewSince_) {
161  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << "Using a new Since: " << fnewSince_;
162  poolDbService->appendOneIOV<BeamSpotOnlineObjects>(abeam, fnewSince_, fLabel);
163  } else
164  poolDbService->appendOneIOV<BeamSpotOnlineObjects>(abeam, poolDbService->currentTime(), fLabel);
165  }
166  }
167  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << "[BeamSpotOnlineFromOfflineConverter] analyze done \n";
168 }
void setStartTimeStamp(cond::Time_t val)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
void setEndTimeStamp(cond::Time_t val)
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
void setEndTime(std::string val)
void appendOneIOV(const T &payload, cond::Time_t sinceTime, const std::string &recordName)
bool isNewTagRequest(const std::string &recordName)
void copyFromBeamSpotObject(const BeamSpotObjects &bs)
Setters Methods.
Log< level::Warning, true > LogPrint
const edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcd > bsToken_
void setLumiRange(std::string val)
void setStartTime(std::string val)
void setCreationTime(cond::Time_t val)
bool isAvailable() const
Definition: Service.h:40

◆ fillDescriptions()

void BeamSpotOnlineFromOfflineConverter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 171 of file BeamSpotOnlineFromOfflineConverter.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

171  {
173  desc.add<bool>("isHLT", true);
174  desc.addOptionalUntracked<uint32_t>("IOVStartRun", 1);
175  desc.addOptionalUntracked<uint32_t>("IOVStartLumi", 1);
176  desc.add<double>("lastAnalyzedLumi", 1000);
177  desc.add<double>("lastAnalyzedRun", 1);
178  desc.add<double>("lastAnalyzedFill", -999);
179  desc.add<int>("numTracks", 0);
180  desc.add<int>("numPVs", 0);
181  desc.add<int>("numUsedEvents", 0);
182  desc.add<int>("numMaxPVs", 0);
183  desc.add<double>("meanPVs", 0.);
184  desc.add<double>("meanPVError", 0.);
185  desc.add<double>("rmsPVs", 0.);
186  desc.add<double>("rmsPVError", 0.);
187  desc.add<std::string>("startTime", std::string(""));
188  desc.add<std::string>("endTime", std::string(""));
189  desc.add<std::string>("lumiRange", std::string(""));
190  descriptions.addWithDefaultLabel(desc);
191 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ pack()

cond::Time_t BeamSpotOnlineFromOfflineConverter::pack ( uint32_t  fIOVStartRun,
uint32_t  fIOVStartLumi 
)

Definition at line 112 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by BeamSpotOnlineFromOfflineConverter().

112  {
113  return ((uint64_t)fIOVStartRun << 32 | fIOVStartLumi);
114 }
unsigned long long uint64_t
Definition: Time.h:13

Member Data Documentation

◆ bsToken_

const edm::ESGetToken<BeamSpotObjects, BeamSpotObjectsRcd> BeamSpotOnlineFromOfflineConverter::bsToken_
private

Definition at line 59 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ endTime_

const std::string BeamSpotOnlineFromOfflineConverter::endTime_
private

Definition at line 65 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ fIOVStartLumi_

uint32_t BeamSpotOnlineFromOfflineConverter::fIOVStartLumi_
private

◆ fIOVStartRun_

uint32_t BeamSpotOnlineFromOfflineConverter::fIOVStartRun_
private

◆ fIsHLT_

const bool BeamSpotOnlineFromOfflineConverter::fIsHLT_
private

Definition at line 68 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ fnewSince_

cond::Time_t BeamSpotOnlineFromOfflineConverter::fnewSince_
private

◆ fuseNewSince_

bool BeamSpotOnlineFromOfflineConverter::fuseNewSince_
private

◆ lastAnalyzedFill_

const int BeamSpotOnlineFromOfflineConverter::lastAnalyzedFill_
private

Definition at line 62 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ lastAnalyzedLumi_

const int BeamSpotOnlineFromOfflineConverter::lastAnalyzedLumi_
private

Definition at line 62 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ lastAnalyzedRun_

const int BeamSpotOnlineFromOfflineConverter::lastAnalyzedRun_
private

Definition at line 62 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ lumiRange_

const std::string BeamSpotOnlineFromOfflineConverter::lumiRange_
private

Definition at line 65 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ meanPVError_

const float BeamSpotOnlineFromOfflineConverter::meanPVError_
private

Definition at line 64 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ meanPVs_

const float BeamSpotOnlineFromOfflineConverter::meanPVs_
private

Definition at line 64 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ numMaxPVs_

const int BeamSpotOnlineFromOfflineConverter::numMaxPVs_
private

Definition at line 63 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ numPVs_

const int BeamSpotOnlineFromOfflineConverter::numPVs_
private

Definition at line 63 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ numTracks_

const int BeamSpotOnlineFromOfflineConverter::numTracks_
private

Definition at line 63 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ numUsedEvents_

const int BeamSpotOnlineFromOfflineConverter::numUsedEvents_
private

Definition at line 63 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ rmsPV_

const float BeamSpotOnlineFromOfflineConverter::rmsPV_
private

Definition at line 64 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ rmsPVError_

const float BeamSpotOnlineFromOfflineConverter::rmsPVError_
private

Definition at line 64 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ startTime_

const std::string BeamSpotOnlineFromOfflineConverter::startTime_
private

Definition at line 65 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().