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)
 
bool isGoodBS (const BeamSpotOnlineObjects *bs1) const
 

Private Attributes

edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcdbsHLTToken_
 
edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcdbsLegacyToken_
 
edm::ESGetToken< BeamSpotObjects, BeamSpotTransientObjectsRcd > const bsToken_
 
BeamSpotObjects fakeBS_
 
const double sigmaXYThreshold_
 
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 es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const char *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 >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
template<typename TFunc >
auto setWhatProduced (TFunc &&func, const es::Label &iLabel={})
 
template<typename TReturn , typename TRecord , typename TFunc , typename TDecorator >
ESConsumesCollectorT< TRecord > setWhatProduced (TFunc &&func, TDecorator &&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)

Definition at line 45 of file OnlineBeamSpotESProducer.cc.

References bsHLTToken_, bsLegacyToken_, gpuPixelDoublets::cc, fakeBS_, BeamSpotObjects::setBeamWidthX(), BeamSpotObjects::setBeamWidthY(), BeamSpotObjects::setPosition(), BeamSpotObjects::setSigmaZ(), BeamSpotObjects::setType(), and edm::ESProducer::setWhatProduced().

47  : timeThreshold_(p.getParameter<int>("timeThreshold")),
48  sigmaZThreshold_(p.getParameter<double>("sigmaZThreshold")),
49  sigmaXYThreshold_(p.getParameter<double>("sigmaXYThreshold") * 1E-4) {
50  auto cc = setWhatProduced(this);
51 
54  fakeBS_.setSigmaZ(15.);
55  fakeBS_.setPosition(0.0001, 0.0001, 0.0001);
56  fakeBS_.setType(-1);
57 
60 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcd > bsHLTToken_
void setType(int type)
set beam type
edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcd > bsLegacyToken_
void setSigmaZ(double val)
set sigma Z, RMS bunch length
void setPosition(double x, double y, double z)
set XYZ position
void setBeamWidthX(double val)
set average transverse beam width X
void setBeamWidthY(double val)
set average transverse beam width Y

Member Function Documentation

◆ checkSingleBS()

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

Definition at line 123 of file OnlineBeamSpotESProducer.cc.

References submitPVResolutionJobs::count, BeamSpotOnlineObjects::creationTime(), getRunInfo::hours, isGoodBS(), submitPVValidationJobs::now, and timeThreshold_.

Referenced by produce().

123  {
124  // Current time to be compared with the one read from the payload
125  auto currentTime =
126  std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch());
127 
128  // Get the beamspot creation time and compute the time difference wrt currentTime
129  auto bs1time = std::chrono::microseconds(bs1->creationTime());
130  auto diffBStime1 = (currentTime - bs1time).count();
131 
132  // Convert timeThreshold_ from hours to microseconds for comparison
133  auto limitTime = std::chrono::microseconds((std::chrono::hours)timeThreshold_).count();
134 
135  // Check that the BS is within the timeThreshold, converges and passes the sigmaZthreshold
136  if (diffBStime1 < limitTime && isGoodBS(bs1)) {
137  return bs1;
138  } else {
139  return nullptr;
140  }
141 }
cond::Time_t creationTime() const
bool isGoodBS(const BeamSpotOnlineObjects *bs1) const

◆ compareBS()

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

Definition at line 70 of file OnlineBeamSpotESProducer.cc.

References submitPVResolutionJobs::count, BeamSpotOnlineObjects::creationTime(), getRunInfo::hours, isGoodBS(), submitPVValidationJobs::now, BeamSpotObjects::sigmaZ(), and timeThreshold_.

Referenced by produce().

71  {
72  // Current time to be compared with the one read from the payload
73  auto currentTime =
74  std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch());
75 
76  // Get two beamspot creation times and compute the time difference wrt currentTime
77  auto bs1time = std::chrono::microseconds(bs1->creationTime());
78  auto diffBStime1 = (currentTime - bs1time).count();
79  auto bs2time = std::chrono::microseconds(bs2->creationTime());
80  auto diffBStime2 = (currentTime - bs2time).count();
81 
82  // Convert timeThreshold_ from hours to microseconds for comparison
83  auto limitTime = std::chrono::microseconds((std::chrono::hours)timeThreshold_).count();
84 
85  // Logic to choose between the two BeamSpots:
86  // 1. If both BS are older than limitTime retun fake BS
87  // 2. If only one BS is newer than limitTime return it only if
88  // it passes isGoodBS (checks on sigmaZ, sigmaXY and fit convergence)
89  // 3. If both are newer than the limit threshold return the BS that
90  // passes isGoodBS and has larger sigmaZ
91  if (diffBStime1 > limitTime && diffBStime2 > limitTime) {
92  edm::LogInfo("OnlineBeamSpotESProducer") << "Defaulting to fake because both payloads are too old.";
93  return nullptr;
94  } else if (diffBStime2 > limitTime) {
95  if (isGoodBS(bs1)) {
96  return bs1;
97  } else {
98  edm::LogInfo("OnlineBeamSpotESProducer")
99  << "Defaulting to fake because the legacy Beam Spot is not suitable and HLT one is too old.";
100  return nullptr;
101  }
102  } else if (diffBStime1 > limitTime) {
103  if (isGoodBS(bs2)) {
104  return bs2;
105  } else {
106  edm::LogInfo("OnlineBeamSpotESProducer")
107  << "Defaulting to fake because the HLT Beam Spot is not suitable and the legacy one too old.";
108  return nullptr;
109  }
110  } else {
111  if (bs1->sigmaZ() > bs2->sigmaZ() && isGoodBS(bs1)) {
112  return bs1;
113  } else if (bs2->sigmaZ() >= bs1->sigmaZ() && isGoodBS(bs2)) {
114  return bs2;
115  } else {
116  edm::LogInfo("OnlineBeamSpotESProducer")
117  << "Defaulting to fake because despite both payloads are young enough, none has passed the fit sanity checks";
118  return nullptr;
119  }
120  }
121 }
cond::Time_t creationTime() const
bool isGoodBS(const BeamSpotOnlineObjects *bs1) const
Log< level::Info, false > LogInfo
double sigmaZ() const
get sigma Z, RMS bunch length

◆ fillDescriptions()

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

Definition at line 62 of file OnlineBeamSpotESProducer.cc.

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

62  {
64  dsc.add<int>("timeThreshold", 48)->setComment("hours");
65  dsc.add<double>("sigmaZThreshold", 2.)->setComment("cm");
66  dsc.add<double>("sigmaXYThreshold", 4.)->setComment("um");
67  desc.addWithDefaultLabel(dsc);
68 }
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)

◆ isGoodBS()

bool OnlineBeamSpotESProducer::isGoodBS ( const BeamSpotOnlineObjects bs1) const
private

Definition at line 144 of file OnlineBeamSpotESProducer.cc.

References BeamSpotObjects::beamType(), BeamSpotObjects::beamWidthX(), BeamSpotObjects::beamWidthY(), sigmaXYThreshold_, BeamSpotObjects::sigmaZ(), sigmaZThreshold_, and reco::BeamSpot::Tracker.

Referenced by checkSingleBS(), and compareBS().

144  {
145  if (bs1->sigmaZ() > sigmaZThreshold_ && bs1->beamType() == reco::BeamSpot::Tracker &&
147  return true;
148  else
149  return false;
150 }
double beamWidthX() const
get average transverse beam width
int beamType() const
get beam type
double beamWidthY() const
get average transverse beam width
double sigmaZ() const
get sigma Z, RMS bunch length

◆ produce()

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

Definition at line 152 of file OnlineBeamSpotESProducer.cc.

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

152  {
153  auto legacyRec = iRecord.tryToGetRecord<BeamSpotOnlineLegacyObjectsRcd>();
154  auto hltRec = iRecord.tryToGetRecord<BeamSpotOnlineHLTObjectsRcd>();
155  if (not legacyRec and not hltRec) {
156  edm::LogInfo("OnlineBeamSpotESProducer") << "None of the Beam Spots in ES are available! \n returning a fake one.";
157  return std::shared_ptr<const BeamSpotObjects>(&fakeBS_, edm::do_nothing_deleter());
158  }
159 
161  if (legacyRec and hltRec) {
162  best = compareBS(&legacyRec->get(bsLegacyToken_), &hltRec->get(bsHLTToken_));
163  } else if (legacyRec) {
164  best = checkSingleBS(&legacyRec->get(bsLegacyToken_));
165  } else {
166  best = checkSingleBS(&hltRec->get(bsHLTToken_));
167  }
168  if (best) {
169  return std::shared_ptr<const BeamSpotObjects>(best, edm::do_nothing_deleter());
170  } else {
171  return std::shared_ptr<const BeamSpotObjects>(&fakeBS_, edm::do_nothing_deleter());
172  edm::LogInfo("OnlineBeamSpotESProducer")
173  << "None of the Online BeamSpots in the ES is suitable, \n returning a fake one. ";
174  }
175 };
const BeamSpotOnlineObjects * checkSingleBS(const BeamSpotOnlineObjects *bs1)
edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcd > bsHLTToken_
const BeamSpotOnlineObjects * compareBS(const BeamSpotOnlineObjects *bs1, const BeamSpotOnlineObjects *bs2)
edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcd > bsLegacyToken_
Log< level::Info, false > LogInfo

Member Data Documentation

◆ bsHLTToken_

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

Definition at line 36 of file OnlineBeamSpotESProducer.cc.

Referenced by OnlineBeamSpotESProducer(), and produce().

◆ bsLegacyToken_

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

Definition at line 37 of file OnlineBeamSpotESProducer.cc.

Referenced by OnlineBeamSpotESProducer(), and produce().

◆ bsToken_

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

Definition at line 35 of file OnlineBeamSpotESProducer.cc.

◆ fakeBS_

BeamSpotObjects OnlineBeamSpotESProducer::fakeBS_
private

Definition at line 39 of file OnlineBeamSpotESProducer.cc.

Referenced by OnlineBeamSpotESProducer(), and produce().

◆ sigmaXYThreshold_

const double OnlineBeamSpotESProducer::sigmaXYThreshold_
private

Definition at line 42 of file OnlineBeamSpotESProducer.cc.

Referenced by isGoodBS().

◆ sigmaZThreshold_

const double OnlineBeamSpotESProducer::sigmaZThreshold_
private

Definition at line 41 of file OnlineBeamSpotESProducer.cc.

Referenced by isGoodBS().

◆ timeThreshold_

const int OnlineBeamSpotESProducer::timeThreshold_
private

Definition at line 40 of file OnlineBeamSpotESProducer.cc.

Referenced by checkSingleBS(), and compareBS().