31 std::shared_ptr<LHCInterpolatedOpticalFunctionsSetCollection>
currentData_;
40 : currentCrossingAngle_(-1.), currentDataValid_(
false) {
51 desc.
add<
std::string>(
"lhcInfoLabel",
"")->setComment(
"label of the LHCInfo record");
52 desc.
add<
std::string>(
"opticsLabel",
"")->setComment(
"label of the optics records");
54 descriptions.
add(
"ctppsInterpolatedOpticalFunctionsESSource", desc);
72 edm::LogInfo(
"CTPPSInterpolatedOpticalFunctionsESSource")
73 <<
"Invalid crossing angle, no optical functions produced.";
77 currentData_ = std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>();
84 edm::LogInfo(
"CTPPSInterpolatedOpticalFunctionsESSource")
89 edm::LogInfo(
"CTPPSInterpolatedOpticalFunctionsESSource")
90 <<
"No input optics available, no optical functions produced.";
93 currentData_ = std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>();
99 if (ofColl.size() == 1) {
100 const auto &it = ofColl.begin();
105 <<
"Cannot interpolate: input given only for xangle " << it->first <<
" while interpolation requested for "
108 currentData_ = std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>();
109 for (
const auto &rp_p : it->second) {
110 const auto rpId = rp_p.first;
120 if (ofColl.size() > 1) {
122 auto it1 = ofColl.begin();
126 for (; it1 != ofColl.end(); ++it1) {
129 if (it2 == ofColl.end()) {
131 it1 = std::prev(it1);
140 const auto &xangle1 = it1->first;
141 const auto &xangle2 = it2->first;
143 const auto &ofs1 = it1->second;
144 const auto &ofs2 = it2->second;
147 currentData_ = std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>();
148 for (
const auto &rp_p : ofs1) {
149 const auto rpId = rp_p.first;
150 const auto &rp_it2 = ofs2.find(rpId);
151 if (rp_it2 == ofs2.end())
152 throw cms::Exception(
"CTPPSInterpolatedOpticalFunctionsESSource") <<
"RP mismatch between ofs1 and ofs2.";
154 const auto &of1 = rp_p.second;
155 const auto &of2 = rp_it2->second;
157 const size_t num_xi_vals1 = of1.getXiValues().size();
158 const size_t num_xi_vals2 = of2.getXiValues().size();
160 if (num_xi_vals1 != num_xi_vals2)
161 throw cms::Exception(
"CTPPSInterpolatedOpticalFunctionsESSource") <<
"Size mismatch between ofs1 and ofs2.";
163 const size_t num_xi_vals = num_xi_vals1;
166 iof.
m_z = of1.getScoringPlaneZ();
170 for (
size_t fi = 0; fi < of1.getFcnValues().size(); ++fi) {
173 for (
size_t pi = 0;
pi < num_xi_vals; ++
pi) {
174 double xi = of1.getXiValues()[
pi];
175 double xi_control = of2.getXiValues()[
pi];
177 if (fabs(xi - xi_control) > 1
e-6)
178 throw cms::Exception(
"CTPPSInterpolatedOpticalFunctionsESSource") <<
"Xi mismatch between ofs1 and ofs2.";
182 double v1 = of1.getFcnValues()[fi][
pi];
183 double v2 = of2.getFcnValues()[fi][
pi];
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
edm::ESGetToken< LHCInfo, LHCInfoRcd > lhcInfoToken_
std::shared_ptr< LHCInterpolatedOpticalFunctionsSetCollection > currentData_
~CTPPSInterpolatedOpticalFunctionsESSource() override
float currentCrossingAngle_
std::shared_ptr< LHCInterpolatedOpticalFunctionsSetCollection > produce(const CTPPSInterpolatedOpticsRcd &)
float const crossingAngle() const
std::vector< double > m_xi_values
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
void initializeSplines()
builds splines from m_*_values fields
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Log< level::Info, false > LogInfo
edm::ESGetToken< LHCOpticalFunctionsSetCollection, CTPPSOpticsRcd > opticsToken_
CTPPSInterpolatedOpticalFunctionsESSource(const edm::ParameterSet &)
std::vector< std::vector< double > > m_fcn_values
length unit cm
T getParameter(std::string const &) const
Set of optical functions corresponding to one scoring plane along LHC, including splines for interpol...
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Collection of optical functions for two crossing angle values and various scoring planes...
double m_z
position of the scoring plane, in LHC/TOTEM convention, cm