CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
OnlineBeamSpotESProducer Class Reference
Inheritance diagram for OnlineBeamSpotESProducer:
edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Member Functions

 OnlineBeamSpotESProducer (const edm::ParameterSet &p)
 
std::shared_ptr< const BeamSpotObjectsproduce (const BeamSpotTransientObjectsRcd &)
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ESProducer (const ESProducer &)=delete
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProducer const & operator= (const ESProducer &)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector< ESProxyIndex > > updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
 ESProxyFactoryProducer (const ESProxyFactoryProducer &)=delete
 
const ESProxyFactoryProduceroperator= (const ESProxyFactoryProducer &)=delete
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
void createKeyedProxies (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
 DataProxyProvider ()
 
 DataProxyProvider (const DataProxyProvider &)=delete
 
const ComponentDescriptiondescription () const
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const DataProxyProvideroperator= (const DataProxyProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &desc)
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 

Private Member Functions

const BeamSpotOnlineObjectscheckSingleBS (const BeamSpotOnlineObjects *bs1)
 
const BeamSpotOnlineObjectscompareBS (const BeamSpotOnlineObjects *bs1, const BeamSpotOnlineObjects *bs2)
 

Private Attributes

edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcdbsHLTToken_
 
edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcdbsLegacyToken_
 
const edm::ESGetToken< BeamSpotObjects, BeamSpotTransientObjectsRcdbsToken_
 
BeamSpotObjects fakeBS_
 
const double sigmaZThreshold_
 
const int timeThreshold_
 

Additional Inherited Members

- Protected Types inherited from edm::ESProxyFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::DataProxyProvider
using KeyedProxiesVector = std::vector< std::pair< DataKey, std::shared_ptr< DataProxy > >>
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
auto setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
ESConsumesCollectorT< TRecord > setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
void usesResources (std::vector< std::string > const &)
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedProxiesVector registerProxies (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 

Detailed Description

Definition at line 24 of file OnlineBeamSpotESProducer.cc.

Constructor & Destructor Documentation

◆ OnlineBeamSpotESProducer()

OnlineBeamSpotESProducer::OnlineBeamSpotESProducer ( const edm::ParameterSet p)

Member Function Documentation

◆ checkSingleBS()

const BeamSpotOnlineObjects * OnlineBeamSpotESProducer::checkSingleBS ( const BeamSpotOnlineObjects bs1)
private

Definition at line 119 of file OnlineBeamSpotESProducer.cc.

119  {
120  // Current time to be compared with the one read from the payload
121  auto currentTime =
122  std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch());
123 
124  // Get the beamspot creation time and compute the time difference wrt currentTime
125  auto bs1time = std::chrono::microseconds(bs1->GetCreationTime());
126  auto diffBStime1 = (currentTime - bs1time).count();
127 
128  // Convert timeThreshold_ from hours to microseconds for comparison
129  auto limitTime = std::chrono::microseconds((std::chrono::hours)timeThreshold_).count();
130 
131  // Check that the BS is within the timeThreshold, converges and passes the sigmaZthreshold
132  if (diffBStime1 < limitTime && bs1->GetSigmaZ() > sigmaZThreshold_ && bs1->GetBeamType() == 2) {
133  return bs1;
134  } else {
135  return nullptr;
136  }
137 }

References submitPVResolutionJobs::count, BeamSpotObjects::GetBeamType(), BeamSpotOnlineObjects::GetCreationTime(), getRunInfo::hours, submitPVValidationJobs::now, sigmaZThreshold_, and timeThreshold_.

Referenced by produce().

◆ compareBS()

const BeamSpotOnlineObjects * OnlineBeamSpotESProducer::compareBS ( const BeamSpotOnlineObjects bs1,
const BeamSpotOnlineObjects bs2 
)
private

Definition at line 66 of file OnlineBeamSpotESProducer.cc.

67  {
68  // Current time to be compared with the one read from the payload
69  auto currentTime =
70  std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch());
71 
72  // Get two beamspot creation times and compute the time difference wrt currentTime
73  auto bs1time = std::chrono::microseconds(bs1->GetCreationTime());
74  auto diffBStime1 = (currentTime - bs1time).count();
75  auto bs2time = std::chrono::microseconds(bs2->GetCreationTime());
76  auto diffBStime2 = (currentTime - bs2time).count();
77 
78  // Convert timeThreshold_ from hours to microseconds for comparison
79  auto limitTime = std::chrono::microseconds((std::chrono::hours)timeThreshold_).count();
80 
81  // Logic to choose between the two BeamSpots:
82  // 1. If both BS are older than limitTime retun fake BS
83  // 2. If only one BS is newer than limitTime return it only if it has
84  // sigmaZ larger than sigmaZthreshold_ and the fit converged (BeamType 2)
85  // 3. If both are newer than the limit threshold return
86  // the BS that converged and has larger sigmaZ
87  if (diffBStime1 > limitTime && diffBStime2 > limitTime) {
88  edm::LogInfo("OnlineBeamSpotESProducer") << "Defaulting to fake becuase both payloads are too old.";
89  return nullptr;
90  } else if (diffBStime2 > limitTime) {
91  if (bs1->GetSigmaZ() > sigmaZThreshold_ && bs1->GetBeamType() == 2) {
92  return bs1;
93  } else {
94  edm::LogInfo("OnlineBeamSpotESProducer")
95  << "Defaulting to fake because the legacy Beam Spot is not suitable and HLT one is too old.";
96  return nullptr;
97  }
98  } else if (diffBStime1 > limitTime) {
99  if (bs2->GetSigmaZ() > sigmaZThreshold_ && bs2->GetBeamType() == 2) {
100  return bs2;
101  } else {
102  edm::LogInfo("OnlineBeamSpotESProducer")
103  << "Defaulting to fake because the HLT Beam Spot is not suitable and the legacy one too old.";
104  return nullptr;
105  }
106  } else {
107  if (bs1->GetSigmaZ() > bs2->GetSigmaZ() && bs1->GetBeamType() == 2) {
108  return bs1;
109  } else if (bs2->GetSigmaZ() >= bs1->GetSigmaZ() && bs2->GetBeamType() == 2) {
110  return bs2;
111  } else {
112  edm::LogInfo("OnlineBeamSpotESProducer")
113  << "Defaulting to fake because despite both payloads are young enough, none has the right BeamType.";
114  return nullptr;
115  }
116  }
117 }

References submitPVResolutionJobs::count, BeamSpotObjects::GetBeamType(), BeamSpotOnlineObjects::GetCreationTime(), BeamSpotObjects::GetSigmaZ(), getRunInfo::hours, submitPVValidationJobs::now, sigmaZThreshold_, and timeThreshold_.

Referenced by produce().

◆ fillDescriptions()

void OnlineBeamSpotESProducer::fillDescriptions ( edm::ConfigurationDescriptions desc)
static

Definition at line 59 of file OnlineBeamSpotESProducer.cc.

59  {
61  dsc.add<int>("timeThreshold", 48)->setComment("hours");
62  dsc.add<double>("sigmaZThreshold", 2.)->setComment("cm");
63  desc.addWithDefaultLabel(dsc);
64 }

References edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, and edm::ParameterDescriptionNode::setComment().

◆ produce()

std::shared_ptr< const BeamSpotObjects > OnlineBeamSpotESProducer::produce ( const BeamSpotTransientObjectsRcd iRecord)

Definition at line 139 of file OnlineBeamSpotESProducer.cc.

139  {
140  auto legacyRec = iRecord.tryToGetRecord<BeamSpotOnlineLegacyObjectsRcd>();
141  auto hltRec = iRecord.tryToGetRecord<BeamSpotOnlineHLTObjectsRcd>();
142  if (not legacyRec and not hltRec) {
143  edm::LogInfo("OnlineBeamSpotESProducer") << "None of the Beam Spots in ES are available! \n returning a fake one.";
144  return std::shared_ptr<const BeamSpotObjects>(&fakeBS_, edm::do_nothing_deleter());
145  }
146 
147  const BeamSpotOnlineObjects* best;
148  if (legacyRec and hltRec) {
149  best = compareBS(&legacyRec->get(bsLegacyToken_), &hltRec->get(bsHLTToken_));
150  } else if (legacyRec) {
151  best = checkSingleBS(&legacyRec->get(bsLegacyToken_));
152  } else {
153  best = checkSingleBS(&hltRec->get(bsHLTToken_));
154  }
155  if (best) {
156  return std::shared_ptr<const BeamSpotObjects>(best, edm::do_nothing_deleter());
157  } else {
158  return std::shared_ptr<const BeamSpotObjects>(&fakeBS_, edm::do_nothing_deleter());
159  edm::LogInfo("OnlineBeamSpotESProducer")
160  << "None of the Online BeamSpots in the ES is suitable, \n returning a fake one. ";
161  }
162 };

References bsHLTToken_, bsLegacyToken_, checkSingleBS(), compareBS(), fakeBS_, and edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::tryToGetRecord().

Member Data Documentation

◆ bsHLTToken_

edm::ESGetToken<BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcd> OnlineBeamSpotESProducer::bsHLTToken_
private

Definition at line 35 of file OnlineBeamSpotESProducer.cc.

Referenced by OnlineBeamSpotESProducer(), and produce().

◆ bsLegacyToken_

edm::ESGetToken<BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcd> OnlineBeamSpotESProducer::bsLegacyToken_
private

Definition at line 36 of file OnlineBeamSpotESProducer.cc.

Referenced by OnlineBeamSpotESProducer(), and produce().

◆ bsToken_

const edm::ESGetToken<BeamSpotObjects, BeamSpotTransientObjectsRcd> OnlineBeamSpotESProducer::bsToken_
private

Definition at line 34 of file OnlineBeamSpotESProducer.cc.

◆ fakeBS_

BeamSpotObjects OnlineBeamSpotESProducer::fakeBS_
private

Definition at line 38 of file OnlineBeamSpotESProducer.cc.

Referenced by OnlineBeamSpotESProducer(), and produce().

◆ sigmaZThreshold_

const double OnlineBeamSpotESProducer::sigmaZThreshold_
private

Definition at line 40 of file OnlineBeamSpotESProducer.cc.

Referenced by checkSingleBS(), and compareBS().

◆ timeThreshold_

const int OnlineBeamSpotESProducer::timeThreshold_
private

Definition at line 39 of file OnlineBeamSpotESProducer.cc.

Referenced by checkSingleBS(), and compareBS().

BeamSpotOnlineHLTObjectsRcd
Definition: BeamSpotOnlineHLTObjectsRcd.h:24
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
OnlineBeamSpotESProducer::bsLegacyToken_
edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcd > bsLegacyToken_
Definition: OnlineBeamSpotESProducer.cc:36
submitPVValidationJobs.now
now
Definition: submitPVValidationJobs.py:639
BeamSpotObjects::GetSigmaZ
double GetSigmaZ() const
get sigma Z, RMS bunch length
Definition: BeamSpotObjects.h:73
edm::do_nothing_deleter
Definition: do_nothing_deleter.h:34
BeamSpotObjects::GetBeamType
int GetBeamType() const
get beam type
Definition: BeamSpotObjects.h:101
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
OnlineBeamSpotESProducer::timeThreshold_
const int timeThreshold_
Definition: OnlineBeamSpotESProducer.cc:39
BeamSpotObjects::SetBeamWidthY
void SetBeamWidthY(double val)
set average transverse beam width Y
Definition: BeamSpotObjects.h:50
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
BeamSpotObjects::SetSigmaZ
void SetSigmaZ(double val)
set sigma Z, RMS bunch length
Definition: BeamSpotObjects.h:42
cc
OnlineBeamSpotESProducer::sigmaZThreshold_
const double sigmaZThreshold_
Definition: OnlineBeamSpotESProducer.cc:40
OnlineBeamSpotESProducer::fakeBS_
BeamSpotObjects fakeBS_
Definition: OnlineBeamSpotESProducer.cc:38
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
BeamSpotOnlineLegacyObjectsRcd
Definition: BeamSpotOnlineLegacyObjectsRcd.h:24
BeamSpotObjects::SetPosition
void SetPosition(double x, double y, double z)
set XYZ position
Definition: BeamSpotObjects.h:36
OnlineBeamSpotESProducer::checkSingleBS
const BeamSpotOnlineObjects * checkSingleBS(const BeamSpotOnlineObjects *bs1)
Definition: OnlineBeamSpotESProducer.cc:119
BeamSpotObjects::SetType
void SetType(int type)
set beam type
Definition: BeamSpotObjects.h:58
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
BeamSpotOnlineObjects::GetCreationTime
cond::Time_t GetCreationTime() const
Definition: BeamSpotOnlineObjects.cc:84
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
edm::eventsetup::DependentRecordImplementation::tryToGetRecord
std::optional< DepRecordT > tryToGetRecord() const
Definition: DependentRecordImplementation.h:71
BeamSpotOnlineObjects
Definition: BeamSpotOnlineObjects.h:25
BeamSpotObjects::SetBeamWidthX
void SetBeamWidthX(double val)
set average transverse beam width X
Definition: BeamSpotObjects.h:48
OnlineBeamSpotESProducer::bsHLTToken_
edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcd > bsHLTToken_
Definition: OnlineBeamSpotESProducer.cc:35
OnlineBeamSpotESProducer::compareBS
const BeamSpotOnlineObjects * compareBS(const BeamSpotOnlineObjects *bs1, const BeamSpotOnlineObjects *bs2)
Definition: OnlineBeamSpotESProducer.cc:66
getRunInfo.hours
hours
Definition: getRunInfo.py:25
edm::ParameterDescriptionNode::setComment
void setComment(std::string const &value)
Definition: ParameterDescriptionNode.cc:106