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
 
ESProducer const & operator= (const ESProducer &)=delete
 
template<typename Record >
void updateFromMayConsumes (unsigned int iIndex, const Record &iRecord)
 
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

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

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={})
 
- 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  m_betaStar(conf.getParameter<double>("betaStar")),
63 
64  m_engine(new CLHEP::HepJamesRandom(conf.getParameter<unsigned int>("seed"))) {
65  const auto &xangleHistogramFile = conf.getParameter<std::string>("xangleHistogramFile");
66  const auto &xangleHistogramObject = conf.getParameter<std::string>("xangleHistogramObject");
67 
68  TFile *f_in = TFile::Open(xangleHistogramFile.c_str());
69  TH1D *h_xangle = (TH1D *)f_in->Get(xangleHistogramObject.c_str());
70 
71  double s = 0.;
72  for (int bi = 1; bi <= h_xangle->GetNbinsX(); ++bi)
73  s += h_xangle->GetBinContent(bi);
74 
75  double cw = 0.;
76  for (int bi = 1; bi <= h_xangle->GetNbinsX(); ++bi) {
77  double xangle = h_xangle->GetBinCenter(bi);
78  double w = h_xangle->GetBinContent(bi) / s;
79 
80  binData.push_back({cw, cw + w, xangle});
81 
82  cw += w;
83  }
84 
85  delete f_in;
86 
87  setWhatProduced(this, m_label);
88  findingRecord<LHCInfoRcd>();
89 }

References binData, edm::ParameterSet::getParameter(), m_label, alignCSCRings::s, edm::ESProducer::setWhatProduced(), AlCaHLTBitMon_QueryRunRegistry::string, w, and OpticalFunctionsConfig_cfi::xangle.

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 93 of file CTPPSLHCInfoRandomXangleESSource.cc.

93  {
95 
96  desc.add<std::string>("label", "")->setComment("label of the LHCInfo record");
97 
98  desc.add<unsigned int>("seed", 1)->setComment("random seed");
99 
100  desc.add<unsigned int>("generateEveryNEvents", 1)->setComment("how often to generate new xangle");
101 
102  desc.add<std::string>("xangleHistogramFile", "")->setComment("ROOT file with xangle distribution");
103  desc.add<std::string>("xangleHistogramObject", "")->setComment("xangle distribution object in the ROOT file");
104 
105  desc.add<double>("beamEnergy", 0.)->setComment("beam energy");
106  desc.add<double>("betaStar", 0.)->setComment("beta*");
107 
108  descriptions.add("ctppsLHCInfoRandomXangleESSource", desc);
109 }

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterDescriptionNode::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ produce()

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

Definition at line 123 of file CTPPSLHCInfoRandomXangleESSource.cc.

123  {
124  auto output = std::make_unique<LHCInfo>();
125 
126  const double u = CLHEP::RandFlat::shoot(m_engine.get(), 0., 1.);
127 
128  double xangle = 0.;
129  for (const auto &d : binData) {
130  if (d.min <= u && u <= d.max) {
131  xangle = d.xangle;
132  break;
133  }
134  }
135 
136  output->setEnergy(m_beamEnergy);
137  output->setCrossingAngle(xangle);
138  output->setBetaStar(m_betaStar);
139 
141 }

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

◆ setIntervalFor()

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

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 113 of file CTPPSLHCInfoRandomXangleESSource.cc.

115  {
116  edm::EventID beginEvent = iosv.eventID();
117  edm::EventID endEvent(beginEvent.run(), beginEvent.luminosityBlock(), beginEvent.event() + m_generateEveryNEvents);
118  oValidity = edm::ValidityInterval(edm::IOVSyncValue(beginEvent), edm::IOVSyncValue(endEvent));
119 }

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

Member Data Documentation

◆ binData

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

◆ m_beamEnergy

double CTPPSLHCInfoRandomXangleESSource::m_beamEnergy
private

Definition at line 41 of file CTPPSLHCInfoRandomXangleESSource.cc.

Referenced by produce().

◆ m_betaStar

double CTPPSLHCInfoRandomXangleESSource::m_betaStar
private

Definition at line 42 of file CTPPSLHCInfoRandomXangleESSource.cc.

Referenced by produce().

◆ m_engine

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

Definition at line 44 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
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
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
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
w
const double w
Definition: UKUtility.cc:23
CTPPSLHCInfoRandomXangleESSource::m_betaStar
double m_betaStar
Definition: CTPPSLHCInfoRandomXangleESSource.cc:42
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:44
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
cond::ValidityInterval
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
eostools.move
def move(src, dest)
Definition: eostools.py:511
CTPPSLHCInfoRandomXangleESSource::binData
std::vector< BinData > binData
Definition: CTPPSLHCInfoRandomXangleESSource.cc:50
CTPPSLHCInfoRandomXangleESSource::m_beamEnergy
double m_beamEnergy
Definition: CTPPSLHCInfoRandomXangleESSource.cc:41
ztail.d
d
Definition: ztail.py:151
edm::ParameterDescriptionNode::setComment
void setComment(std::string const &value)
Definition: ParameterDescriptionNode.cc:106
edm::EventID
Definition: EventID.h:31
CTPPSLHCInfoRandomXangleESSource::m_generateEveryNEvents
unsigned int m_generateEveryNEvents
Definition: CTPPSLHCInfoRandomXangleESSource.cc:39