CMS 3D CMS Logo

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

Public Member Functions

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

double factor_
 
edm::ESGetToken< LHCInterpolatedOpticalFunctionsSetCollection, CTPPSInterpolatedOpticsRcdinputOpticsToken_
 
unsigned int rpDecId_45_F_
 
unsigned int rpDecId_45_N_
 
unsigned int rpDecId_56_F_
 
unsigned int rpDecId_56_N_
 
std::string scenario_
 

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 16 of file CTPPSModifiedOpticalFunctionsESSource.cc.

Constructor & Destructor Documentation

CTPPSModifiedOpticalFunctionsESSource::CTPPSModifiedOpticalFunctionsESSource ( const edm::ParameterSet iConfig)

Definition at line 38 of file CTPPSModifiedOpticalFunctionsESSource.cc.

References edm::ParameterSet::getParameter(), inputOpticsToken_, edm::ESProducer::setWhatProduced(), and AlCaHLTBitMon_QueryRunRegistry::string.

39  : scenario_(iConfig.getParameter<std::string>("scenario")),
40  factor_(iConfig.getParameter<double>("factor")),
41  rpDecId_45_N_(iConfig.getParameter<unsigned int>("rpId_45_N")),
42  rpDecId_45_F_(iConfig.getParameter<unsigned int>("rpId_45_F")),
43  rpDecId_56_N_(iConfig.getParameter<unsigned int>("rpId_56_N")),
44  rpDecId_56_F_(iConfig.getParameter<unsigned int>("rpId_56_F"))
45 {
46  auto cc = setWhatProduced(this, iConfig.getParameter<std::string>("outputOpticsLabel"));
47 
49  (edm::ESInputTag("", iConfig.getParameter<std::string>("inputOpticsLabel")));
50 }
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:124
edm::ESGetToken< LHCInterpolatedOpticalFunctionsSetCollection, CTPPSInterpolatedOpticsRcd > inputOpticsToken_
CTPPSModifiedOpticalFunctionsESSource::~CTPPSModifiedOpticalFunctionsESSource ( )
inlineoverride

Definition at line 19 of file CTPPSModifiedOpticalFunctionsESSource.cc.

References fillDescriptions(), and produce().

19 {}

Member Function Documentation

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

Definition at line 54 of file CTPPSModifiedOpticalFunctionsESSource.cc.

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

Referenced by ~CTPPSModifiedOpticalFunctionsESSource().

54  {
56 
57  desc.add<std::string>("inputOpticsLabel", "")->setComment("label of the input optics records");
58  desc.add<std::string>("outputOpticsLabel", "modified")->setComment("label of the output optics records");
59 
60  desc.add<std::string>("scenario", "none")->setComment("name of modification scenario");
61 
62  desc.add<double>("factor", 0.)->setComment("size of modification (number of sigmas)");
63 
64  desc.add<unsigned int>("rpId_45_N", 0)->setComment("decimal RP id for 45 near");
65  desc.add<unsigned int>("rpId_45_F", 0)->setComment("decimal RP id for 45 far");
66  desc.add<unsigned int>("rpId_56_N", 0)->setComment("decimal RP id for 56 near");
67  desc.add<unsigned int>("rpId_56_F", 0)->setComment("decimal RP id for 56 far");
68 
69  descriptions.add("ctppsModifiedOpticalFunctionsESSource", desc);
70 }
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::shared_ptr< LHCInterpolatedOpticalFunctionsSetCollection > CTPPSModifiedOpticalFunctionsESSource::produce ( const CTPPSInterpolatedOpticsRcd iRecord)

Definition at line 74 of file CTPPSModifiedOpticalFunctionsESSource.cc.

References a, protons_cff::arm, CTPPSDetId::arm(), b, edmIntegrityCheck::d, DEFINE_FWK_EVENTSETUP_MODULE, LHCOpticalFunctionsSet::eLpx, LHCOpticalFunctionsSet::eLx, LHCOpticalFunctionsSet::exd, factor_, edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::get(), mps_fire::i, input, inputOpticsToken_, convertSQLitetoXML_cfg::output, CTPPSDetId::rp(), rpDecId_45_F_, rpDecId_45_N_, rpDecId_56_F_, rpDecId_56_N_, year_2016_postTS2_cff::rpId, scenario_, CTPPSDetId::station(), and protons_cff::xi.

Referenced by ~CTPPSModifiedOpticalFunctionsESSource().

75  {
76  // get input
78 
79  // prepare output
80  std::shared_ptr<LHCInterpolatedOpticalFunctionsSetCollection> output =
81  std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>(input);
82 
83  // premare arm/RP id map
84  struct ArmInfo {
85  unsigned int rpId_N = 0, rpId_F = 0;
86  };
87 
88  std::map<unsigned int, ArmInfo> armInfo;
89 
90  for (const auto &fsp : *output) {
91  CTPPSDetId rpId(fsp.first);
92  unsigned int rpDecId = 100 * rpId.arm() + 10 * rpId.station() + rpId.rp();
93 
94  if (rpDecId == rpDecId_45_N_)
95  armInfo[0].rpId_N = fsp.first;
96  if (rpDecId == rpDecId_45_F_)
97  armInfo[0].rpId_F = fsp.first;
98  if (rpDecId == rpDecId_56_N_)
99  armInfo[1].rpId_N = fsp.first;
100  if (rpDecId == rpDecId_56_F_)
101  armInfo[1].rpId_F = fsp.first;
102  }
103 
104  // loop over arms
105  bool applied = false;
106 
107  for (const auto &ap : armInfo) {
108  const auto &arm = ap.first;
109 
110  //printf("* arm %u\n", arm);
111 
112  auto &of_N = output->find(ap.second.rpId_N)->second;
113  auto &of_F = output->find(ap.second.rpId_F)->second;
114 
115  const double z_N = of_N.getScoringPlaneZ();
116  const double z_F = of_F.getScoringPlaneZ();
117  const double de_z = (arm == 0) ? z_N - z_F : z_F - z_N;
118 
119  //printf(" z_N = %.3f m, z_F = %.3f m\n", z_N*1E-2, z_F*1E-2);
120 
121  if (of_N.m_xi_values.size() != of_N.m_xi_values.size())
122  throw cms::Exception("CTPPSModifiedOpticalFunctionsESSource")
123  << "Different xi sampling of optical functions in near and far RP.";
124 
125  // loop over sampling points (in xi)
126  for (unsigned int i = 0; i < of_N.m_xi_values.size(); ++i) {
127  const double xi = of_N.m_xi_values[i];
128 
129  double x_d_N = of_N.m_fcn_values[LHCOpticalFunctionsSet::exd][i];
130  double x_d_F = of_F.m_fcn_values[LHCOpticalFunctionsSet::exd][i];
131 
132  double L_x_N = of_N.m_fcn_values[LHCOpticalFunctionsSet::eLx][i];
133  double L_x_F = of_F.m_fcn_values[LHCOpticalFunctionsSet::eLx][i];
134  double Lp_x = of_N.m_fcn_values[LHCOpticalFunctionsSet::eLpx][i];
135 
136  //printf(" xi = %.3f, Lp_x = %.3f, %.3f\n", xi, Lp_x, (L_x_F - L_x_N) / de_z);
137 
138  // apply modification scenario
139  if (scenario_ == "none")
140  applied = true;
141 
142  if (scenario_ == "Lx") {
143  const double a = 3180., b = 40.; // cm
144  const double de_L_x = factor_ * (a * xi + b);
145  L_x_N += de_L_x;
146  L_x_F += de_L_x;
147  applied = true;
148  }
149 
150  if (scenario_ == "Lpx") {
151  const double a = 0.42, b = 0.015; // dimensionless
152  const double de_Lp_x = factor_ * (a * xi + b) * Lp_x;
153  Lp_x += de_Lp_x;
154  L_x_N -= de_Lp_x * de_z / 2.;
155  L_x_F += de_Lp_x * de_z / 2.;
156  applied = true;
157  }
158 
159  if (scenario_ == "xd") {
160  const double d = 0.08; // dimensionless
161  x_d_N += x_d_N * d * factor_;
162  x_d_F += x_d_F * d * factor_;
163  applied = true;
164  }
165 
166  // TODO: for test only
167  if (scenario_ == "Lx-scale") {
168  L_x_N *= factor_;
169  L_x_F *= factor_;
170  applied = true;
171  }
172 
173  // store updated values
174  of_N.m_fcn_values[LHCOpticalFunctionsSet::exd][i] = x_d_N;
175  of_F.m_fcn_values[LHCOpticalFunctionsSet::exd][i] = x_d_F;
176 
177  of_N.m_fcn_values[LHCOpticalFunctionsSet::eLx][i] = L_x_N;
178  of_F.m_fcn_values[LHCOpticalFunctionsSet::eLx][i] = L_x_F;
179 
180  of_N.m_fcn_values[LHCOpticalFunctionsSet::eLpx][i] = Lp_x;
181  of_F.m_fcn_values[LHCOpticalFunctionsSet::eLpx][i] = Lp_x;
182  }
183 
184  // re-initialise splines
185  of_N.initializeSplines();
186  of_F.initializeSplines();
187  }
188 
189  // modification applied?
190  if (!applied)
191  edm::LogError("CTPPSModifiedOpticalFunctionsESSource") << "Could not apply scenario `" + scenario_ + "'.";
192 
193  // save modified output
194  return output;
195 }
static std::string const input
Definition: EdmProvDump.cc:48
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
double b
Definition: hdecay.h:120
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
double a
Definition: hdecay.h:121
edm::ESGetToken< LHCInterpolatedOpticalFunctionsSetCollection, CTPPSInterpolatedOpticsRcd > inputOpticsToken_

Member Data Documentation

double CTPPSModifiedOpticalFunctionsESSource::factor_
private

Definition at line 30 of file CTPPSModifiedOpticalFunctionsESSource.cc.

Referenced by produce().

edm::ESGetToken<LHCInterpolatedOpticalFunctionsSetCollection, CTPPSInterpolatedOpticsRcd> CTPPSModifiedOpticalFunctionsESSource::inputOpticsToken_
private
unsigned int CTPPSModifiedOpticalFunctionsESSource::rpDecId_45_F_
private

Definition at line 32 of file CTPPSModifiedOpticalFunctionsESSource.cc.

Referenced by produce().

unsigned int CTPPSModifiedOpticalFunctionsESSource::rpDecId_45_N_
private

Definition at line 32 of file CTPPSModifiedOpticalFunctionsESSource.cc.

Referenced by produce().

unsigned int CTPPSModifiedOpticalFunctionsESSource::rpDecId_56_F_
private

Definition at line 32 of file CTPPSModifiedOpticalFunctionsESSource.cc.

Referenced by produce().

unsigned int CTPPSModifiedOpticalFunctionsESSource::rpDecId_56_N_
private

Definition at line 32 of file CTPPSModifiedOpticalFunctionsESSource.cc.

Referenced by produce().

std::string CTPPSModifiedOpticalFunctionsESSource::scenario_
private

Definition at line 28 of file CTPPSModifiedOpticalFunctionsESSource.cc.

Referenced by produce().