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::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::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::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 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)
 
- 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.

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 }

References BeamSpotFakeParameters_cfi::betaStar, HltBtagPostValidation_cff::c, Exception, edm::ParameterSet::getParameter(), m_label, edm::ESProducer::setWhatProduced(), AlCaHLTBitMon_QueryRunRegistry::string, x, OpticalFunctionsConfig_cfi::xangle, xangleBetaStarBins, and y.

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 105 of file CTPPSLHCInfoRandomXangleESSource.cc.

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 }

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

◆ produce()

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

Definition at line 134 of file CTPPSLHCInfoRandomXangleESSource.cc.

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 }

References BeamSpotFakeParameters_cfi::betaStar, ztail::d, m_beamEnergy, m_engine, eostools::move(), convertSQLitetoXML_cfg::output, edm::es::products(), OpticalFunctionsConfig_cfi::xangle, and xangleBetaStarBins.

◆ 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.

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 }

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

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
DDAxes::y
BeamSpotFakeParameters_cfi.betaStar
betaStar
Definition: BeamSpotFakeParameters_cfi.py:19
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
CTPPSLHCInfoRandomXangleESSource::xangleBetaStarBins
std::vector< BinData > xangleBetaStarBins
Definition: CTPPSLHCInfoRandomXangleESSource.cc:50
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
DDAxes::x
edm::EventID::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
edm::es::products
ESProducts< std::remove_reference_t< TArgs >... > products(TArgs &&... args)
Definition: ESProducts.h:128
edm::FileInPath
Definition: FileInPath.h:64
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::IOVSyncValue
Definition: IOVSyncValue.h:31
edm::EventID::run
RunNumber_t run() const
Definition: EventID.h:38
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
OpticalFunctionsConfig_cfi.xangle
xangle
Definition: OpticalFunctionsConfig_cfi.py:17
edm::IOVSyncValue::eventID
const EventID & eventID() const
Definition: IOVSyncValue.h:40
CTPPSLHCInfoRandomXangleESSource::m_label
std::string m_label
Definition: CTPPSLHCInfoRandomXangleESSource.cc:37
edm::EventID::event
EventNumber_t event() const
Definition: EventID.h:40
CTPPSLHCInfoRandomXangleESSource::m_engine
std::unique_ptr< CLHEP::HepRandomEngine > m_engine
Definition: CTPPSLHCInfoRandomXangleESSource.cc:43
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
cond::ValidityInterval
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:246
CTPPSLHCInfoRandomXangleESSource::m_beamEnergy
double m_beamEnergy
Definition: CTPPSLHCInfoRandomXangleESSource.cc:41
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ztail.d
d
Definition: ztail.py:151
edm::EventID
Definition: EventID.h:31
CTPPSLHCInfoRandomXangleESSource::m_generateEveryNEvents
unsigned int m_generateEveryNEvents
Definition: CTPPSLHCInfoRandomXangleESSource.cc:39