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 ()
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer ()(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval) override
 overrides DataProxyProvider method More...
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
 DataProxyProvider ()
 
const ComponentDescriptiondescription () const
 
bool isUsingRecord (const EventSetupRecordKey &) const
 
const KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey) const
 
void resetProxies (const EventSetupRecordKey &iRecordType)
 
void resetProxiesIfTransient (const EventSetupRecordKey &iRecordType)
 
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
const eventsetup::ComponentDescriptiondescriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
std::set< eventsetup::EventSetupRecordKeyfindingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
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

- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
 
typedef std::vector< EventSetupRecordKeyKeys
 
typedef std::map< EventSetupRecordKey, KeyedProxiesRecordProxies
 
- Protected Member Functions inherited from edm::ESProducer
 ESProducer (const ESProducer &)=delete
 
ESProducer const & operator= (const ESProducer &)=delete
 
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={})
 
- 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 eventsetup::EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList) override
 override DataProxyProvider method More...
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
void eraseAll (const EventSetupRecordKey &iRecordKey)
 deletes all the Proxies in aStream More...
 
void invalidateProxies (const EventSetupRecordKey &iRecordKey)
 
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &)
 
- 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 binData, edm::ParameterSet::getParameter(), m_label, alignCSCRings::s, edm::ESProducer::setWhatProduced(), AlCaHLTBitMon_QueryRunRegistry::string, w, and base_cff::xangle.

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 }
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:124
const double w
Definition: UKUtility.cc:23
std::unique_ptr< CLHEP::HepRandomEngine > m_engine

Member Function Documentation

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

Definition at line 93 of file CTPPSLHCInfoRandomXangleESSource.cc.

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

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 }
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 123 of file CTPPSLHCInfoRandomXangleESSource.cc.

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

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

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 }
std::unique_ptr< CLHEP::HepRandomEngine > m_engine
ESProducts< std::remove_reference_t< TArgs >... > products(TArgs &&...args)
Definition: ESProducts.h:128
def move(src, dest)
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 113 of file CTPPSLHCInfoRandomXangleESSource.cc.

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

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 }
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
const EventID & eventID() const
Definition: IOVSyncValue.h:40
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40

Member Data Documentation

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

Definition at line 41 of file CTPPSLHCInfoRandomXangleESSource.cc.

Referenced by produce().

double CTPPSLHCInfoRandomXangleESSource::m_betaStar
private

Definition at line 42 of file CTPPSLHCInfoRandomXangleESSource.cc.

Referenced by produce().

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

Definition at line 44 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