34 std::shared_ptr<LHCInterpolatedOpticalFunctionsSetCollection>
currentData_;
45 currentDataValid_(
false),
46 useNewLHCInfo_(iConfig.getParameter<
bool>(
"useNewLHCInfo")) {
59 desc.add<
std::string>(
"lhcInfoLabel",
"")->setComment(
"label of the LHCInfo record");
60 desc.add<
std::string>(
"lhcInfoPerFillLabel",
"")->setComment(
"label of the LHCInfoPerFill record");
61 desc.add<
std::string>(
"lhcInfoPerLSLabel",
"")->setComment(
"label of the LHCInfoPerLS record");
62 desc.add<
std::string>(
"opticsLabel",
"")->setComment(
"label of the optics records");
63 desc.add<
bool>(
"useNewLHCInfo",
false)->setComment(
"flag whether to use new LHCInfoPer* records or old LHCInfo");
65 descriptions.
add(
"ctppsInterpolatedOpticalFunctionsESSource",
desc);
85 if (lhcInfoCombined.isCrossingAngleInvalid()) {
86 edm::LogInfo(
"CTPPSInterpolatedOpticalFunctionsESSource")
87 <<
"Invalid crossing angle, no optical functions produced.";
91 currentData_ = std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>();
98 edm::LogInfo(
"CTPPSInterpolatedOpticalFunctionsESSource")
102 if (ofColl.empty()) {
103 edm::LogInfo(
"CTPPSInterpolatedOpticalFunctionsESSource")
104 <<
"No input optics available, no optical functions produced.";
107 currentData_ = std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>();
113 if (ofColl.size() == 1) {
114 const auto &it = ofColl.begin();
119 <<
"Cannot interpolate: input given only for xangle " << it->first <<
" while interpolation requested for " 122 currentData_ = std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>();
123 for (
const auto &rp_p : it->second) {
124 const auto rpId = rp_p.first;
134 if (ofColl.size() > 1) {
136 auto it1 = ofColl.begin();
140 for (; it1 != ofColl.end(); ++it1) {
143 if (it2 == ofColl.end()) {
145 it1 = std::prev(it1);
154 const auto &xangle1 = it1->first;
155 const auto &xangle2 = it2->first;
157 const auto &ofs1 = it1->second;
158 const auto &ofs2 = it2->second;
161 currentData_ = std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>();
162 for (
const auto &rp_p : ofs1) {
163 const auto rpId = rp_p.first;
164 const auto &rp_it2 = ofs2.find(rpId);
165 if (rp_it2 == ofs2.end())
166 throw cms::Exception(
"CTPPSInterpolatedOpticalFunctionsESSource") <<
"RP mismatch between ofs1 and ofs2.";
168 const auto &of1 = rp_p.second;
169 const auto &of2 = rp_it2->second;
171 const size_t num_xi_vals1 = of1.getXiValues().size();
172 const size_t num_xi_vals2 = of2.getXiValues().size();
174 if (num_xi_vals1 != num_xi_vals2)
175 throw cms::Exception(
"CTPPSInterpolatedOpticalFunctionsESSource") <<
"Size mismatch between ofs1 and ofs2.";
177 const size_t num_xi_vals = num_xi_vals1;
180 iof.
m_z = of1.getScoringPlaneZ();
184 for (
size_t fi = 0; fi < of1.getFcnValues().size(); ++fi) {
187 for (
size_t pi = 0;
pi < num_xi_vals; ++
pi) {
188 double xi = of1.getXiValues()[
pi];
189 double xi_control = of2.getXiValues()[
pi];
191 if (fabs(
xi - xi_control) > 1
e-6)
192 throw cms::Exception(
"CTPPSInterpolatedOpticalFunctionsESSource") <<
"Xi mismatch between ofs1 and ofs2.";
196 double v1 = of1.getFcnValues()[fi][
pi];
197 double v2 = of2.getFcnValues()[fi][
pi];
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
T getParameter(std::string const &) const
edm::ESGetToken< LHCInfoPerLS, LHCInfoPerLSRcd > lhcInfoPerLSToken_
const bool useNewLHCInfo_
edm::ESGetToken< LHCInfo, LHCInfoRcd > lhcInfoToken_
std::shared_ptr< LHCInterpolatedOpticalFunctionsSetCollection > currentData_
uint32_t cc[maxCellsPerHit]
static constexpr float crossingAngleInvalid
~CTPPSInterpolatedOpticalFunctionsESSource() override
float currentCrossingAngle_
std::shared_ptr< LHCInterpolatedOpticalFunctionsSetCollection > produce(const CTPPSInterpolatedOpticsRcd &)
std::vector< double > m_xi_values
void initializeSplines()
builds splines from m_*_values fields
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
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
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)
edm::ESGetToken< LHCInfoPerFill, LHCInfoPerFillRcd > lhcInfoPerFillToken_
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
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
static LHCInfoCombined createLHCInfoCombined(const edm::eventsetup::DependentRecordImplementation< RecordT, ListT > &iRecord, const edm::ESGetToken< LHCInfoPerLS, LHCInfoPerLSRcd > &tokenInfoPerLS, const edm::ESGetToken< LHCInfoPerFill, LHCInfoPerFillRcd > &tokenInfoPerFill, const edm::ESGetToken< LHCInfo, LHCInfoRcd > &tokenInfo, bool useNewLHCInfo)