CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

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
 
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)
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
bool concurrentFinder () const
 
const
eventsetup::ComponentDescription
descriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
 EventSetupRecordIntervalFinder (const EventSetupRecordIntervalFinder &)=delete
 
std::set
< eventsetup::EventSetupRecordKey
findingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
bool nonconcurrentAndIOVNeedsUpdate (const eventsetup::EventSetupRecordKey &key, const IOVSyncValue &syncValue) const
 
const
EventSetupRecordIntervalFinder
operator= (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::DataProxyProvider
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::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 >
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)
 
- 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 ( const edm::ParameterSet conf)

Definition at line 56 of file CTPPSLHCInfoRandomXangleESSource.cc.

References c, Exception, edm::ParameterSet::getParameter(), m_label, edm::ESProducer::setWhatProduced(), AlCaHLTBitMon_QueryRunRegistry::string, x, xangleBetaStarBins, 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 
68  edm::FileInPath fip(xangleBetaStarHistogramFile);
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:163
const edm::EventSetup & c
std::unique_ptr< CLHEP::HepRandomEngine > m_engine
T getParameter(std::string const &) const
Definition: ParameterSet.h:303

Member Function Documentation

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

Definition at line 105 of file CTPPSLHCInfoRandomXangleESSource.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, edm::ParameterDescriptionNode::setComment(), 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 setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::ESProducts< std::unique_ptr< LHCInfo > > CTPPSLHCInfoRandomXangleESSource::produce ( const LHCInfoRcd )

Definition at line 134 of file CTPPSLHCInfoRandomXangleESSource.cc.

References ztail::d, m_beamEnergy, m_engine, eostools::move(), convertSQLitetoXML_cfg::output, edm::es::products(), 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 }
std::unique_ptr< CLHEP::HepRandomEngine > m_engine
ESProducts< std::remove_reference_t< TArgs >...> products(TArgs &&...args)
Definition: ESProducts.h:128
tuple d
Definition: ztail.py:151
def move
Definition: eostools.py:511
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 }
RunNumber_t run() const
Definition: EventID.h:38
EventNumber_t event() const
Definition: EventID.h:40
const EventID & eventID() const
Definition: IOVSyncValue.h:40
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39

Member Data Documentation

double CTPPSLHCInfoRandomXangleESSource::m_beamEnergy
private

Definition at line 41 of file CTPPSLHCInfoRandomXangleESSource.cc.

Referenced by produce().

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

Definition at line 43 of file CTPPSLHCInfoRandomXangleESSource.cc.

Referenced by produce().

unsigned int CTPPSLHCInfoRandomXangleESSource::m_generateEveryNEvents
private

Definition at line 39 of file CTPPSLHCInfoRandomXangleESSource.cc.

Referenced by setIntervalFor().

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