CMS 3D CMS Logo

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

Provides LHCInfo data necessary for CTPPS reconstruction (and direct simulation). More...

Inheritance diagram for CTPPSLHCInfoRandomXangleESSource:
edm::ESProducer edm::EventSetupRecordIntervalFinder edm::ESProductResolverFactoryProducer edm::eventsetup::ESProductResolverProvider

Classes

struct  BinData
 

Public Member Functions

 CTPPSLHCInfoRandomXangleESSource (const edm::ParameterSet &)
 
edm::ESProducts< std::unique_ptr< LHCInfo > > produce (const LHCInfoRcd &)
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ESProducer (const ESProducer &)=delete
 
 ESProducer (ESProducer &&)=delete
 
ESResolverIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProduceroperator= (const ESProducer &)=delete
 
ESProduceroperator= (ESProducer &&)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector< ESResolverIndex > > updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProductResolverFactoryProducer
 ESProductResolverFactoryProducer ()
 
 ESProductResolverFactoryProducer (const ESProductResolverFactoryProducer &)=delete
 
const ESProductResolverFactoryProduceroperator= (const ESProductResolverFactoryProducer &)=delete
 
 ~ESProductResolverFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
void createKeyedResolvers (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
const ComponentDescriptiondescription () const
 
 ESProductResolverProvider ()
 
 ESProductResolverProvider (const ESProductResolverProvider &)=delete
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedResolverskeyedResolvers (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const ESProductResolverProvideroperator= (const ESProductResolverProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~ESProductResolverProvider () noexcept(false)
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
bool concurrentFinder () const
 
const eventsetup::ComponentDescriptiondescriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
 EventSetupRecordIntervalFinder (const EventSetupRecordIntervalFinder &)=delete
 
std::set< eventsetup::EventSetupRecordKeyfindingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
bool nonconcurrentAndIOVNeedsUpdate (const eventsetup::EventSetupRecordKey &key, const IOVSyncValue &syncValue) const
 
const EventSetupRecordIntervalFinderoperator= (const EventSetupRecordIntervalFinder &)=delete
 
void resetInterval (const eventsetup::EventSetupRecordKey &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder () noexcept(false)
 

Static Public Member Functions

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

Private Member Functions

void setIntervalFor (const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
 

Private Attributes

double m_beamEnergy
 
std::unique_ptr< CLHEP::HepRandomEngine > m_engine
 
unsigned int m_generateEveryNEvents
 
std::string m_label
 
std::vector< BinDataxangleBetaStarBins
 

Additional Inherited Members

- Protected Types inherited from edm::ESProductResolverFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::ESProductResolverProvider
using KeyedResolversVector = std::vector< std::pair< DataKey, std::shared_ptr< ESProductResolver > >>
 
- Protected Member Functions inherited from edm::ESProducer
ESConsumesInfoconsumesInfoPushBackNew ()
 
unsigned int consumesInfoSize () const
 
template<typename CallbackT , typename TList , typename TRecord >
void registerProducts (std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>> iCallback, const TList *, const TRecord *iRecord, const es::Label &iLabel)
 
template<typename CallbackT , typename TRecord >
void registerProducts (std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>>, const eventsetup::produce::Null *, const TRecord *, const es::Label &)
 
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 TDecorator >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TDecorator &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::ESProductResolverFactoryProducer
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::ESProductResolverFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedResolversVector registerResolvers (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::ESProductResolverProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 
- Protected Member Functions inherited from edm::EventSetupRecordIntervalFinder
template<class T >
void findingRecord ()
 
void findingRecordWithKey (const eventsetup::EventSetupRecordKey &)
 

Detailed Description

Provides LHCInfo data necessary for CTPPS reconstruction (and direct simulation).

Definition at line 26 of file CTPPSLHCInfoRandomXangleESSource.cc.

Constructor & Destructor Documentation

◆ CTPPSLHCInfoRandomXangleESSource()

CTPPSLHCInfoRandomXangleESSource::CTPPSLHCInfoRandomXangleESSource ( const edm::ParameterSet conf)

Definition at line 56 of file CTPPSLHCInfoRandomXangleESSource.cc.

References simBeamSpotPI::betaStar, HltBtagPostValidation_cff::c, Exception, edm::ParameterSet::getParameter(), m_label, edm::ESProducer::setWhatProduced(), AlCaHLTBitMon_QueryRunRegistry::string, x, profile_base_cff::xangle, xangleBetaStarBins, profile_base_cff::xangleBetaStarHistogramFile, profile_base_cff::xangleBetaStarHistogramObject, and y.

57  : m_label(conf.getParameter<std::string>("label")),
58 
59  m_generateEveryNEvents(conf.getParameter<unsigned int>("generateEveryNEvents")),
60 
61  m_beamEnergy(conf.getParameter<double>("beamEnergy")),
62 
63  m_engine(new CLHEP::HepJamesRandom(conf.getParameter<unsigned int>("seed"))) {
64  // get input beta* vs. xangle histogram
65  const auto &xangleBetaStarHistogramFile = conf.getParameter<std::string>("xangleBetaStarHistogramFile");
66  const auto &xangleBetaStarHistogramObject = conf.getParameter<std::string>("xangleBetaStarHistogramObject");
67 
69  std::unique_ptr<TFile> f_in(TFile::Open(fip.fullPath().c_str()));
70  if (!f_in)
71  throw cms::Exception("PPS") << "Cannot open input file '" << xangleBetaStarHistogramFile << "'.";
72 
73  TH2D *h_xangle_beta_star = (TH2D *)f_in->Get(xangleBetaStarHistogramObject.c_str());
74  if (!h_xangle_beta_star)
75  throw cms::Exception("PPS") << "Cannot load input object '" << xangleBetaStarHistogramObject << "'.";
76 
77  // parse histogram
78  double sum = 0.;
79  for (int x = 1; x <= h_xangle_beta_star->GetNbinsX(); ++x) {
80  for (int y = 1; y <= h_xangle_beta_star->GetNbinsY(); ++y)
81  sum += h_xangle_beta_star->GetBinContent(x, y);
82  }
83 
84  double cw = 0;
85  for (int x = 1; x <= h_xangle_beta_star->GetNbinsX(); ++x) {
86  for (int y = 1; y <= h_xangle_beta_star->GetNbinsY(); ++y) {
87  const double c = h_xangle_beta_star->GetBinContent(x, y);
88  const double xangle = h_xangle_beta_star->GetXaxis()->GetBinCenter(x);
89  const double betaStar = h_xangle_beta_star->GetYaxis()->GetBinCenter(y);
90 
91  if (c > 0.) {
92  const double rc = c / sum;
93  xangleBetaStarBins.push_back({cw, cw + rc, xangle, betaStar});
94  cw += rc;
95  }
96  }
97  }
98 
99  setWhatProduced(this, m_label);
100  findingRecord<LHCInfoRcd>();
101 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::unique_ptr< CLHEP::HepRandomEngine > m_engine

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 105 of file CTPPSLHCInfoRandomXangleESSource.cc.

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

105  {
107 
108  desc.add<std::string>("label", "")->setComment("label of the LHCInfo record");
109 
110  desc.add<unsigned int>("seed", 1)->setComment("random seed");
111 
112  desc.add<unsigned int>("generateEveryNEvents", 1)->setComment("how often to generate new xangle");
113 
114  desc.add<std::string>("xangleBetaStarHistogramFile", "")->setComment("ROOT file with xangle distribution");
115  desc.add<std::string>("xangleBetaStarHistogramObject", "")->setComment("xangle distribution object in the ROOT file");
116 
117  desc.add<double>("beamEnergy", 0.)->setComment("beam energy");
118 
119  descriptions.add("ctppsLHCInfoRandomXangleESSource", desc);
120 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

edm::ESProducts< std::unique_ptr< LHCInfo > > CTPPSLHCInfoRandomXangleESSource::produce ( const LHCInfoRcd )

Definition at line 134 of file CTPPSLHCInfoRandomXangleESSource.cc.

References simBeamSpotPI::betaStar, ztail::d, m_beamEnergy, m_engine, eostools::move(), edm::es::products(), profile_base_cff::xangle, and xangleBetaStarBins.

134  {
135  auto output = std::make_unique<LHCInfo>();
136 
137  double xangle = 0., betaStar = 0.;
138  const double u = CLHEP::RandFlat::shoot(m_engine.get(), 0., 1.);
139  for (const auto &d : xangleBetaStarBins) {
140  if (d.min <= u && u <= d.max) {
141  xangle = d.xangle;
142  betaStar = d.betaStar;
143  break;
144  }
145  }
146 
147  output->setEnergy(m_beamEnergy);
148  output->setCrossingAngle(xangle);
149  output->setBetaStar(betaStar);
150 
152 }
ESProducts< std::remove_reference_t< TArgs >... > products(TArgs &&... args)
Definition: ESProducts.h:128
std::unique_ptr< CLHEP::HepRandomEngine > m_engine
d
Definition: ztail.py:151
Definition: output.py:1
def move(src, dest)
Definition: eostools.py:511

◆ setIntervalFor()

void CTPPSLHCInfoRandomXangleESSource::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey key,
const edm::IOVSyncValue iosv,
edm::ValidityInterval oValidity 
)
overrideprivatevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 124 of file CTPPSLHCInfoRandomXangleESSource.cc.

References edm::EventID::event(), edm::IOVSyncValue::eventID(), edm::EventID::luminosityBlock(), m_generateEveryNEvents, and edm::EventID::run().

126  {
127  edm::EventID beginEvent = iosv.eventID();
128  edm::EventID endEvent(beginEvent.run(), beginEvent.luminosityBlock(), beginEvent.event() + m_generateEveryNEvents);
129  oValidity = edm::ValidityInterval(edm::IOVSyncValue(beginEvent), edm::IOVSyncValue(endEvent));
130 }
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
RunNumber_t run() const
Definition: EventID.h:38
const EventID & eventID() const
Definition: IOVSyncValue.h:40
EventNumber_t event() const
Definition: EventID.h:40

Member Data Documentation

◆ m_beamEnergy

double CTPPSLHCInfoRandomXangleESSource::m_beamEnergy
private

Definition at line 41 of file CTPPSLHCInfoRandomXangleESSource.cc.

Referenced by produce().

◆ m_engine

std::unique_ptr<CLHEP::HepRandomEngine> CTPPSLHCInfoRandomXangleESSource::m_engine
private

Definition at line 43 of file CTPPSLHCInfoRandomXangleESSource.cc.

Referenced by produce().

◆ m_generateEveryNEvents

unsigned int CTPPSLHCInfoRandomXangleESSource::m_generateEveryNEvents
private

Definition at line 39 of file CTPPSLHCInfoRandomXangleESSource.cc.

Referenced by setIntervalFor().

◆ m_label

std::string CTPPSLHCInfoRandomXangleESSource::m_label
private

◆ xangleBetaStarBins

std::vector<BinData> CTPPSLHCInfoRandomXangleESSource::xangleBetaStarBins
private