CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
CTPPSInterpolatedOpticalFunctionsESSource Class Reference
Inheritance diagram for CTPPSInterpolatedOpticalFunctionsESSource:
edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Member Functions

 CTPPSInterpolatedOpticalFunctionsESSource (const edm::ParameterSet &)
 
std::shared_ptr< LHCInterpolatedOpticalFunctionsSetCollectionproduce (const CTPPSInterpolatedOpticsRcd &)
 
 ~CTPPSInterpolatedOpticalFunctionsESSource () override
 
- 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)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 

Private Attributes

float currentCrossingAngle_
 
std::shared_ptr< LHCInterpolatedOpticalFunctionsSetCollectioncurrentData_
 
bool currentDataValid_
 
std::string lhcInfoLabel_
 

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 &)
 

Detailed Description

Definition at line 20 of file CTPPSInterpolatedOpticalFunctionsESSource.cc.

Constructor & Destructor Documentation

CTPPSInterpolatedOpticalFunctionsESSource::CTPPSInterpolatedOpticalFunctionsESSource ( const edm::ParameterSet iConfig)
CTPPSInterpolatedOpticalFunctionsESSource::~CTPPSInterpolatedOpticalFunctionsESSource ( )
inlineoverride

Definition at line 24 of file CTPPSInterpolatedOpticalFunctionsESSource.cc.

References fillDescriptions(), and produce().

24 {}

Member Function Documentation

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

Definition at line 51 of file CTPPSInterpolatedOpticalFunctionsESSource.cc.

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

Referenced by ~CTPPSInterpolatedOpticalFunctionsESSource().

52 {
54 
55  desc.add<std::string>("lhcInfoLabel", "")
56  ->setComment("label of the LHCInfo record");
57 
58  descriptions.add("ctppsInterpolatedOpticalFunctionsESSource", desc);
59 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::shared_ptr< LHCInterpolatedOpticalFunctionsSetCollection > CTPPSInterpolatedOpticalFunctionsESSource::produce ( const CTPPSInterpolatedOpticsRcd iRecord)

Definition at line 63 of file CTPPSInterpolatedOpticalFunctionsESSource.cc.

References LHCInfo::crossingAngle(), currentCrossingAngle_, currentData_, currentDataValid_, DEFINE_FWK_EVENTSETUP_MODULE, MillePedeFileConverter_cfg::e, Exception, plotBeamSpotDB::first, edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getRecord(), LHCInterpolatedOpticalFunctionsSet::initializeSplines(), lhcInfoLabel_, LHCOpticalFunctionsSet::m_fcn_values, LHCOpticalFunctionsSet::m_xi_values, LHCOpticalFunctionsSet::m_z, eostools::move(), GetRecoTauVFromDQM_MC_cff::next, LHCOpticalFunctionsSet::nFunctions, pi, and hybridSuperClusters_cfi::xi.

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

64 {
65  // get the input data
67  iRecord.getRecord<CTPPSOpticsRcd>().get(hOFColl);
68 
69  edm::ESHandle<LHCInfo> hLHCInfo;
70  iRecord.getRecord<LHCInfoRcd>().get(lhcInfoLabel_, hLHCInfo);
71 
72  // is there anything to do?
74  return currentData_;
75 
76  // is crossing angle reasonable (LHCInfo is correctly filled in DB)?
77  if (hLHCInfo->crossingAngle() == 0.)
78  {
79  edm::LogInfo("CTPPSInterpolatedOpticalFunctionsESSource") << "Invalid crossing angle, no optical functions produced.";
80 
81  currentDataValid_ = false;
83  currentData_ = std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>();
84 
85  return currentData_;
86  }
87 
88  // set new crossing angle
90  edm::LogInfo("CTPPSInterpolatedOpticalFunctionsESSource") << "Crossing angle has changed to " << currentCrossingAngle_ << ".";
91 
92  // is input optics available ?
93  if (hOFColl->empty())
94  {
95  edm::LogInfo("CTPPSInterpolatedOpticalFunctionsESSource") << "No input optics available, no optical functions produced.";
96 
97  currentDataValid_ = false;
98  currentData_ = std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>();
99 
100  return currentData_;
101  }
102 
103  // regular case with single-xangle input
104  if (hOFColl->size() == 1)
105  {
106  const auto &it = hOFColl->begin();
107 
108  // does the input xangle correspond to the actual one?
109  if (fabs(currentCrossingAngle_ - it->first) > 1e-6)
110  throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "Cannot interpolate: input given only for xangle "
111  << it->first << " while interpolation requested for " << currentCrossingAngle_ << ".";
112 
113  currentData_ = std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>();
114  for (const auto &rp_p : it->second)
115  {
116  const auto rpId = rp_p.first;
117  LHCInterpolatedOpticalFunctionsSet iof(rp_p.second);
118  iof.initializeSplines();
119  currentData_->emplace(rpId, std::move(iof));
120  }
121 
122  currentDataValid_ = true;
123  }
124 
125  // regular case with multi-xangle input
126  if (hOFColl->size() > 1)
127  {
128  // find the closest xangle points for interpolation
129  auto it1 = hOFColl->begin();
130  auto it2 = std::next(it1);
131 
132  if (currentCrossingAngle_ > it1->first)
133  {
134  for (; it1 != hOFColl->end(); ++it1)
135  {
136  it2 = std::next(it1);
137 
138  if (it2 == hOFColl->end())
139  {
140  it2 = it1;
141  it1 = std::prev(it1);
142  break;
143  }
144 
145  if (it1->first <= currentCrossingAngle_ && currentCrossingAngle_ < it2->first)
146  break;
147  }
148  }
149 
150  const auto &xangle1 = it1->first;
151  const auto &xangle2 = it2->first;
152 
153  const auto &ofs1 = it1->second;
154  const auto &ofs2 = it2->second;
155 
156  // do the interpoaltion RP by RP
157  currentData_ = std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>();
158  for (const auto &rp_p : ofs1)
159  {
160  const auto rpId = rp_p.first;
161  const auto &rp_it2 = ofs2.find(rpId);
162  if (rp_it2 == ofs2.end())
163  throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "RP mismatch between ofs1 and ofs2.";
164 
165  const auto &of1 = rp_p.second;
166  const auto &of2 = rp_it2->second;
167 
168  const size_t num_xi_vals1 = of1.getXiValues().size();
169  const size_t num_xi_vals2 = of2.getXiValues().size();
170 
171  if (num_xi_vals1 != num_xi_vals2)
172  throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "Size mismatch between ofs1 and ofs2.";
173 
174  const size_t num_xi_vals = num_xi_vals1;
175 
177  iof.m_z = of1.getScoringPlaneZ();
179  iof.m_xi_values.resize(num_xi_vals);
180 
181  for (size_t fi = 0; fi < of1.getFcnValues().size(); ++fi)
182  {
183  iof.m_fcn_values[fi].resize(num_xi_vals);
184 
185  for (size_t pi = 0; pi < num_xi_vals; ++pi)
186  {
187  double xi = of1.getXiValues()[pi];
188  double xi_control = of2.getXiValues()[pi];
189 
190  if (fabs(xi - xi_control) > 1e-6)
191  throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "Xi mismatch between ofs1 and ofs2.";
192 
193  iof.m_xi_values[pi] = xi;
194 
195  double v1 = of1.getFcnValues()[fi][pi];
196  double v2 = of2.getFcnValues()[fi][pi];
197  iof.m_fcn_values[fi][pi] = v1 + (v2 - v1) / (xangle2 - xangle1) * (currentCrossingAngle_ - xangle1);
198  }
199  }
200 
201  iof.initializeSplines();
202 
203  currentDataValid_ = true;
204  currentData_->emplace(rpId, std::move(iof));
205  }
206  }
207 
208  return currentData_;
209 }
std::shared_ptr< LHCInterpolatedOpticalFunctionsSetCollection > currentData_
const Double_t pi
float const crossingAngle() const
Definition: LHCInfo.cc:176
std::vector< double > m_xi_values
void initializeSplines()
builds splines from m_*_values fields
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...
double m_z
position of the scoring plane, in LHC/TOTEM convention, cm
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

float CTPPSInterpolatedOpticalFunctionsESSource::currentCrossingAngle_
private

Definition at line 33 of file CTPPSInterpolatedOpticalFunctionsESSource.cc.

Referenced by produce().

std::shared_ptr<LHCInterpolatedOpticalFunctionsSetCollection> CTPPSInterpolatedOpticalFunctionsESSource::currentData_
private

Definition at line 35 of file CTPPSInterpolatedOpticalFunctionsESSource.cc.

Referenced by produce().

bool CTPPSInterpolatedOpticalFunctionsESSource::currentDataValid_
private

Definition at line 34 of file CTPPSInterpolatedOpticalFunctionsESSource.cc.

Referenced by produce().

std::string CTPPSInterpolatedOpticalFunctionsESSource::lhcInfoLabel_
private

Definition at line 31 of file CTPPSInterpolatedOpticalFunctionsESSource.cc.

Referenced by produce().