36 std::shared_ptr<LHCInterpolatedOpticalFunctionsSetCollection>
currentData_;
58 ->setComment(
"label of the LHCInfo record");
61 ->setComment(
"label of the optics record");
63 descriptions.
add(
"ctppsInterpolatedOpticalFunctionsESSource", desc);
84 edm::LogInfo(
"CTPPSInterpolatedOpticalFunctionsESSource") <<
"Invalid crossing angle, no optical functions produced.";
88 currentData_ = std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>();
100 edm::LogInfo(
"CTPPSInterpolatedOpticalFunctionsESSource") <<
"No input optics available, no optical functions produced.";
103 currentData_ = std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>();
109 if (hOFColl->size() == 1)
111 const auto &it = hOFColl->begin();
115 throw cms::Exception(
"CTPPSInterpolatedOpticalFunctionsESSource") <<
"Cannot interpolate: input given only for xangle " 118 currentData_ = std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>();
119 for (
const auto &rp_p : it->second)
121 const auto rpId = rp_p.first;
131 if (hOFColl->size() > 1)
134 auto it1 = hOFColl->begin();
139 for (; it1 != hOFColl->end(); ++it1)
143 if (it2 == hOFColl->end())
146 it1 = std::prev(it1);
155 const auto &xangle1 = it1->first;
156 const auto &xangle2 = it2->first;
158 const auto &ofs1 = it1->second;
159 const auto &ofs2 = it2->second;
162 currentData_ = std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>();
163 for (
const auto &rp_p : ofs1)
165 const auto rpId = rp_p.first;
166 const auto &rp_it2 = ofs2.find(
rpId);
167 if (rp_it2 == ofs2.end())
168 throw cms::Exception(
"CTPPSInterpolatedOpticalFunctionsESSource") <<
"RP mismatch between ofs1 and ofs2.";
170 const auto &of1 = rp_p.second;
171 const auto &of2 = rp_it2->second;
173 const size_t num_xi_vals1 = of1.getXiValues().size();
174 const size_t num_xi_vals2 = of2.getXiValues().size();
176 if (num_xi_vals1 != num_xi_vals2)
177 throw cms::Exception(
"CTPPSInterpolatedOpticalFunctionsESSource") <<
"Size mismatch between ofs1 and ofs2.";
179 const size_t num_xi_vals = num_xi_vals1;
182 iof.
m_z = of1.getScoringPlaneZ();
186 for (
size_t fi = 0; fi < of1.getFcnValues().size(); ++fi)
190 for (
size_t pi = 0;
pi < num_xi_vals; ++
pi)
192 double xi = of1.getXiValues()[
pi];
193 double xi_control = of2.getXiValues()[
pi];
195 if (fabs(xi - xi_control) > 1
e-6)
196 throw cms::Exception(
"CTPPSInterpolatedOpticalFunctionsESSource") <<
"Xi mismatch between ofs1 and ofs2.";
200 double v1 = of1.getFcnValues()[fi][
pi];
201 double v2 = of2.getFcnValues()[fi][
pi];
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
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
void initializeSplines()
builds splines from m_*_values fields
const DepRecordT getRecord() const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
CTPPSInterpolatedOpticalFunctionsESSource(const edm::ParameterSet &)
std::vector< std::vector< double > > m_fcn_values
length unit cm
Set of optical functions corresponding to one scoring plane along LHC, including splines for interpol...
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::string lhcInfoLabel_
double m_z
position of the scoring plane, in LHC/TOTEM convention, cm