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 noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept 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 noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~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_
 
edm::ESWatcher< BeamSpotObjectsRcdbsWatcher_
 
const std::string endTime_
 
uint32_t fIOVStartLumi_
 
uint32_t fIOVStartRun_
 
const bool fIsHLT_
 
std::string fLabel_
 
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 48 of file BeamSpotOnlineFromOfflineConverter.cc.

Constructor & Destructor Documentation

◆ BeamSpotOnlineFromOfflineConverter()

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

Definition at line 81 of file BeamSpotOnlineFromOfflineConverter.cc.

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

82  : bsToken_(esConsumes()),
83  lastAnalyzedLumi_(iConfig.getParameter<double>("lastAnalyzedLumi")),
84  lastAnalyzedRun_(iConfig.getParameter<double>("lastAnalyzedRun")),
85  lastAnalyzedFill_(iConfig.getParameter<double>("lastAnalyzedFill")),
86  numTracks_(iConfig.getParameter<int>("numTracks")),
87  numPVs_(iConfig.getParameter<int>("numPVs")),
88  numUsedEvents_(iConfig.getParameter<int>("numUsedEvents")),
89  numMaxPVs_(iConfig.getParameter<int>("numMaxPVs")),
90  meanPVs_(iConfig.getParameter<double>("meanPVs")),
91  meanPVError_(iConfig.getParameter<double>("meanPVError")),
92  rmsPV_(iConfig.getParameter<double>("rmsPVs")),
93  rmsPVError_(iConfig.getParameter<double>("rmsPVError")),
94  startTime_(iConfig.getParameter<std::string>("startTime")),
95  endTime_(iConfig.getParameter<std::string>("endTime")),
96  lumiRange_(iConfig.getParameter<std::string>("lumiRange")),
97  fIsHLT_(iConfig.getParameter<bool>("isHLT")) {
98  if (iConfig.exists("IOVStartRun") && iConfig.exists("IOVStartLumi")) {
99  fIOVStartRun_ = iConfig.getUntrackedParameter<uint32_t>("IOVStartRun");
100  fIOVStartLumi_ = iConfig.getUntrackedParameter<uint32_t>("IOVStartLumi");
102  fuseNewSince_ = true;
103  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << "useNewSince = True";
104  } else {
105  fuseNewSince_ = false;
106  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << "useNewSince = False";
107  }
108  fLabel_ = (fIsHLT_) ? "BeamSpotOnlineHLTObjectsRcd" : "BeamSpotOnlineLegacyObjectsRcd";
109 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
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 121 of file BeamSpotOnlineFromOfflineConverter.cc.

References cond::service::PoolDBOutputService::appendOneIOV(), cond::service::PoolDBOutputService::beginOfTime(), bsToken_, bsWatcher_, edm::ESWatcher< T >::check(), BeamSpotOnlineObjects::copyFromBeamSpotObject(), submitPVResolutionJobs::count, cond::service::PoolDBOutputService::createOneIOV(), beamSpotPI::creationTime, cond::service::PoolDBOutputService::currentTime(), endTime_, fLabel_, fnewSince_, fuseNewSince_, edm::EventSetup::getData(), iEvent, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), lastAnalyzedFill_, lastAnalyzedLumi_, lastAnalyzedRun_, lumiRange_, meanPVError_, meanPVs_, submitPVValidationJobs::now, numMaxPVs_, numPVs_, numTracks_, numUsedEvents_, pack(), 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_, and hcalRecHitTable_cff::time.

121  {
122  if (bsWatcher_.check(iSetup)) {
123  const BeamSpotObjects* inputSpot = &iSetup.getData(bsToken_);
124 
125  BeamSpotOnlineObjects abeam;
126  abeam.copyFromBeamSpotObject(*inputSpot);
130  abeam.setStartTimeStamp(std::time(nullptr));
131  abeam.setEndTimeStamp(std::time(nullptr));
132  abeam.setNumTracks(numTracks_);
133  abeam.setNumPVs(numPVs_);
135  abeam.setMaxPVs(numMaxPVs_);
136  abeam.setMeanPV(meanPVs_);
138  abeam.setRmsPV(rmsPV_);
139  abeam.setRmsErrorPV(rmsPVError_);
140  abeam.setStartTime(startTime_);
141  abeam.setEndTime(endTime_);
142  abeam.setLumiRange(lumiRange_);
143 
144  // Set the creation time of the payload to the current time
145  auto creationTime =
146  std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch())
147  .count();
149 
150  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << " Writing results to DB...";
151  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << abeam;
152 
154  if (poolDbService.isAvailable()) {
155  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << "poolDBService available";
156  if (poolDbService->isNewTagRequest(fLabel_)) {
157  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << "new tag requested";
158  if (fuseNewSince_) {
159  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << "Using a new Since: " << fnewSince_;
160  poolDbService->createOneIOV<BeamSpotOnlineObjects>(abeam, fnewSince_, fLabel_);
161  } else
162  poolDbService->createOneIOV<BeamSpotOnlineObjects>(abeam, poolDbService->beginOfTime(), fLabel_);
163  } else {
164  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << "no new tag requested";
165  if (fuseNewSince_) {
167  iEvent.getLuminosityBlock().run(), iEvent.getLuminosityBlock().luminosityBlock());
168  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << "Using a new Since: " << thisSince;
169  poolDbService->appendOneIOV<BeamSpotOnlineObjects>(abeam, thisSince, fLabel_);
170  } else
171  poolDbService->appendOneIOV<BeamSpotOnlineObjects>(abeam, poolDbService->currentTime(), fLabel_);
172  }
173  }
174  edm::LogPrint("BeamSpotOnlineFromOfflineConverter") << "[BeamSpotOnlineFromOfflineConverter] analyze done \n";
175  }
176 }
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)
int iEvent
Definition: GenABIO.cc:224
unsigned long long Time_t
Definition: Time.h:14
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)
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
void setStartTime(std::string val)
void setCreationTime(cond::Time_t val)
bool isAvailable() const
Definition: Service.h:40
edm::ESWatcher< BeamSpotObjectsRcd > bsWatcher_

◆ fillDescriptions()

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

Definition at line 179 of file BeamSpotOnlineFromOfflineConverter.cc.

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

179  {
181  desc.add<bool>("isHLT", true);
182  desc.addOptionalUntracked<uint32_t>("IOVStartRun", 1);
183  desc.addOptionalUntracked<uint32_t>("IOVStartLumi", 1);
184  desc.add<double>("lastAnalyzedLumi", 1000);
185  desc.add<double>("lastAnalyzedRun", 1);
186  desc.add<double>("lastAnalyzedFill", -999);
187  desc.add<int>("numTracks", 0);
188  desc.add<int>("numPVs", 0);
189  desc.add<int>("numUsedEvents", 0);
190  desc.add<int>("numMaxPVs", 0);
191  desc.add<double>("meanPVs", 0.);
192  desc.add<double>("meanPVError", 0.);
193  desc.add<double>("rmsPVs", 0.);
194  desc.add<double>("rmsPVError", 0.);
195  desc.add<std::string>("startTime", std::string(""));
196  desc.add<std::string>("endTime", std::string(""));
197  desc.add<std::string>("lumiRange", std::string(""));
198  descriptions.addWithDefaultLabel(desc);
199 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ pack()

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

Definition at line 116 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze(), and BeamSpotOnlineFromOfflineConverter().

116  {
117  return ((uint64_t)fIOVStartRun << 32 | fIOVStartLumi);
118 }
unsigned long long uint64_t
Definition: Time.h:13

Member Data Documentation

◆ bsToken_

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

Definition at line 60 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ bsWatcher_

edm::ESWatcher<BeamSpotObjectsRcd> BeamSpotOnlineFromOfflineConverter::bsWatcher_
private

Definition at line 61 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ endTime_

const std::string BeamSpotOnlineFromOfflineConverter::endTime_
private

Definition at line 67 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

◆ fLabel_

std::string BeamSpotOnlineFromOfflineConverter::fLabel_
private

◆ fnewSince_

cond::Time_t BeamSpotOnlineFromOfflineConverter::fnewSince_
private

◆ fuseNewSince_

bool BeamSpotOnlineFromOfflineConverter::fuseNewSince_
private

◆ lastAnalyzedFill_

const int BeamSpotOnlineFromOfflineConverter::lastAnalyzedFill_
private

Definition at line 64 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ lastAnalyzedLumi_

const int BeamSpotOnlineFromOfflineConverter::lastAnalyzedLumi_
private

Definition at line 64 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ lastAnalyzedRun_

const int BeamSpotOnlineFromOfflineConverter::lastAnalyzedRun_
private

Definition at line 64 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ lumiRange_

const std::string BeamSpotOnlineFromOfflineConverter::lumiRange_
private

Definition at line 67 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ meanPVError_

const float BeamSpotOnlineFromOfflineConverter::meanPVError_
private

Definition at line 66 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ meanPVs_

const float BeamSpotOnlineFromOfflineConverter::meanPVs_
private

Definition at line 66 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ numMaxPVs_

const int BeamSpotOnlineFromOfflineConverter::numMaxPVs_
private

Definition at line 65 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ numPVs_

const int BeamSpotOnlineFromOfflineConverter::numPVs_
private

Definition at line 65 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ numTracks_

const int BeamSpotOnlineFromOfflineConverter::numTracks_
private

Definition at line 65 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ numUsedEvents_

const int BeamSpotOnlineFromOfflineConverter::numUsedEvents_
private

Definition at line 65 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ rmsPV_

const float BeamSpotOnlineFromOfflineConverter::rmsPV_
private

Definition at line 66 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ rmsPVError_

const float BeamSpotOnlineFromOfflineConverter::rmsPVError_
private

Definition at line 66 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().

◆ startTime_

const std::string BeamSpotOnlineFromOfflineConverter::startTime_
private

Definition at line 67 of file BeamSpotOnlineFromOfflineConverter.cc.

Referenced by analyze().