CMS 3D CMS Logo

CTPPSModifiedOpticalFunctionsESSource.cc
Go to the documentation of this file.
1 // authors: Jan Kaspar (jan.kaspar@gmail.com)
2 
8 
10 
13 
15 
17 public:
20 
21  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
22 
23  std::shared_ptr<LHCInterpolatedOpticalFunctionsSetCollection> produce(const CTPPSInterpolatedOpticsRcd &);
24 
25 private:
27 
29 
30  double factor_;
31 
33 };
34 
35 //----------------------------------------------------------------------------------------------------
36 //----------------------------------------------------------------------------------------------------
37 
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  setWhatProduced(this, iConfig.getParameter<std::string>("outputOpticsLabel"))
46  .setConsumes(inputOpticsToken_, edm::ESInputTag("", iConfig.getParameter<std::string>("inputOpticsLabel")));
47 }
48 
49 //----------------------------------------------------------------------------------------------------
50 
53 
54  desc.add<std::string>("inputOpticsLabel", "")->setComment("label of the input optics records");
55  desc.add<std::string>("outputOpticsLabel", "modified")->setComment("label of the output optics records");
56 
57  desc.add<std::string>("scenario", "none")->setComment("name of modification scenario");
58 
59  desc.add<double>("factor", 0.)->setComment("size of modification (number of sigmas)");
60 
61  desc.add<unsigned int>("rpId_45_N", 0)->setComment("decimal RP id for 45 near");
62  desc.add<unsigned int>("rpId_45_F", 0)->setComment("decimal RP id for 45 far");
63  desc.add<unsigned int>("rpId_56_N", 0)->setComment("decimal RP id for 56 near");
64  desc.add<unsigned int>("rpId_56_F", 0)->setComment("decimal RP id for 56 far");
65 
66  descriptions.add("ctppsModifiedOpticalFunctionsESSource", desc);
67 }
68 
69 //----------------------------------------------------------------------------------------------------
70 
71 std::shared_ptr<LHCInterpolatedOpticalFunctionsSetCollection> CTPPSModifiedOpticalFunctionsESSource::produce(
72  const CTPPSInterpolatedOpticsRcd &iRecord) {
73  // get input
75 
76  // prepare output
77  std::shared_ptr<LHCInterpolatedOpticalFunctionsSetCollection> output =
78  std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>(input);
79 
80  // premare arm/RP id map
81  struct ArmInfo {
82  unsigned int rpId_N = 0, rpId_F = 0;
83  };
84 
85  std::map<unsigned int, ArmInfo> armInfo;
86 
87  for (const auto &fsp : *output) {
88  CTPPSDetId rpId(fsp.first);
89  unsigned int rpDecId = 100 * rpId.arm() + 10 * rpId.station() + rpId.rp();
90 
91  if (rpDecId == rpDecId_45_N_)
92  armInfo[0].rpId_N = fsp.first;
93  if (rpDecId == rpDecId_45_F_)
94  armInfo[0].rpId_F = fsp.first;
95  if (rpDecId == rpDecId_56_N_)
96  armInfo[1].rpId_N = fsp.first;
97  if (rpDecId == rpDecId_56_F_)
98  armInfo[1].rpId_F = fsp.first;
99  }
100 
101  // loop over arms
102  bool applied = false;
103 
104  for (const auto &ap : armInfo) {
105  const auto &arm = ap.first;
106 
107  //printf("* arm %u\n", arm);
108 
109  auto &of_N = output->find(ap.second.rpId_N)->second;
110  auto &of_F = output->find(ap.second.rpId_F)->second;
111 
112  const double z_N = of_N.getScoringPlaneZ();
113  const double z_F = of_F.getScoringPlaneZ();
114  const double de_z = (arm == 0) ? z_N - z_F : z_F - z_N;
115 
116  //printf(" z_N = %.3f m, z_F = %.3f m\n", z_N*1E-2, z_F*1E-2);
117 
118  if (of_N.m_xi_values.size() != of_N.m_xi_values.size())
119  throw cms::Exception("CTPPSModifiedOpticalFunctionsESSource")
120  << "Different xi sampling of optical functions in near and far RP.";
121 
122  // loop over sampling points (in xi)
123  for (unsigned int i = 0; i < of_N.m_xi_values.size(); ++i) {
124  const double xi = of_N.m_xi_values[i];
125 
126  double x_d_N = of_N.m_fcn_values[LHCOpticalFunctionsSet::exd][i];
127  double x_d_F = of_F.m_fcn_values[LHCOpticalFunctionsSet::exd][i];
128 
129  double L_x_N = of_N.m_fcn_values[LHCOpticalFunctionsSet::eLx][i];
130  double L_x_F = of_F.m_fcn_values[LHCOpticalFunctionsSet::eLx][i];
131  double Lp_x = of_N.m_fcn_values[LHCOpticalFunctionsSet::eLpx][i];
132 
133  //printf(" xi = %.3f, Lp_x = %.3f, %.3f\n", xi, Lp_x, (L_x_F - L_x_N) / de_z);
134 
135  // apply modification scenario
136  if (scenario_ == "none")
137  applied = true;
138 
139  if (scenario_ == "Lx") {
140  const double a = 3180., b = 40.; // cm
141  const double de_L_x = factor_ * (a * xi + b);
142  L_x_N += de_L_x;
143  L_x_F += de_L_x;
144  applied = true;
145  }
146 
147  if (scenario_ == "Lpx") {
148  const double a = 0.42, b = 0.015; // dimensionless
149  const double de_Lp_x = factor_ * (a * xi + b) * Lp_x;
150  Lp_x += de_Lp_x;
151  L_x_N -= de_Lp_x * de_z / 2.;
152  L_x_F += de_Lp_x * de_z / 2.;
153  applied = true;
154  }
155 
156  if (scenario_ == "xd") {
157  const double d = 0.08; // dimensionless
158  x_d_N += x_d_N * d * factor_;
159  x_d_F += x_d_F * d * factor_;
160  applied = true;
161  }
162 
163  // TODO: for test only
164  if (scenario_ == "Lx-scale") {
165  L_x_N *= factor_;
166  L_x_F *= factor_;
167  applied = true;
168  }
169 
170  // store updated values
171  of_N.m_fcn_values[LHCOpticalFunctionsSet::exd][i] = x_d_N;
172  of_F.m_fcn_values[LHCOpticalFunctionsSet::exd][i] = x_d_F;
173 
174  of_N.m_fcn_values[LHCOpticalFunctionsSet::eLx][i] = L_x_N;
175  of_F.m_fcn_values[LHCOpticalFunctionsSet::eLx][i] = L_x_F;
176 
177  of_N.m_fcn_values[LHCOpticalFunctionsSet::eLpx][i] = Lp_x;
178  of_F.m_fcn_values[LHCOpticalFunctionsSet::eLpx][i] = Lp_x;
179  }
180 
181  // re-initialise splines
182  of_N.initializeSplines();
183  of_F.initializeSplines();
184  }
185 
186  // modification applied?
187  if (!applied)
188  edm::LogError("CTPPSModifiedOpticalFunctionsESSource") << "Could not apply scenario `" + scenario_ + "'.";
189 
190  // save modified output
191  return output;
192 }
193 
194 //----------------------------------------------------------------------------------------------------
195 
CTPPSModifiedOpticalFunctionsESSource::CTPPSModifiedOpticalFunctionsESSource
CTPPSModifiedOpticalFunctionsESSource(const edm::ParameterSet &)
Definition: CTPPSModifiedOpticalFunctionsESSource.cc:38
LHCOpticalFunctionsSet::exd
Definition: LHCOpticalFunctionsSet.h:16
mps_fire.i
i
Definition: mps_fire.py:355
edm::ESInputTag
Definition: ESInputTag.h:87
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
input
static const std::string input
Definition: EdmProvDump.cc:48
MessageLogger.h
ESHandle.h
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
hybridSuperClusters_cfi.xi
xi
Definition: hybridSuperClusters_cfi.py:10
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ESProducer.h
CTPPSModifiedOpticalFunctionsESSource::rpDecId_45_F_
unsigned int rpDecId_45_F_
Definition: CTPPSModifiedOpticalFunctionsESSource.cc:32
CTPPSModifiedOpticalFunctionsESSource::produce
std::shared_ptr< LHCInterpolatedOpticalFunctionsSetCollection > produce(const CTPPSInterpolatedOpticsRcd &)
Definition: CTPPSModifiedOpticalFunctionsESSource.cc:71
CTPPSModifiedOpticalFunctionsESSource::factor_
double factor_
Definition: CTPPSModifiedOpticalFunctionsESSource.cc:30
year_2016_postTS2_cff.rpId
rpId
Definition: year_2016_postTS2_cff.py:23
LHCOpticalFunctionsSet::eLx
Definition: LHCOpticalFunctionsSet.h:16
LHCInterpolatedOpticalFunctionsSetCollection
Definition: LHCInterpolatedOpticalFunctionsSetCollection.h:10
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
LHCInterpolatedOpticalFunctionsSetCollection.h
CTPPSModifiedOpticalFunctionsESSource::scenario_
std::string scenario_
Definition: CTPPSModifiedOpticalFunctionsESSource.cc:28
CTPPSModifiedOpticalFunctionsESSource
Definition: CTPPSModifiedOpticalFunctionsESSource.cc:16
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:112
b
double b
Definition: hdecay.h:118
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CTPPSModifiedOpticalFunctionsESSource::rpDecId_56_N_
unsigned int rpDecId_56_N_
Definition: CTPPSModifiedOpticalFunctionsESSource.cc:32
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
a
double a
Definition: hdecay.h:119
CTPPSDetId
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:31
CTPPSModifiedOpticalFunctionsESSource::rpDecId_56_F_
unsigned int rpDecId_56_F_
Definition: CTPPSModifiedOpticalFunctionsESSource.cc:32
createfilelist.int
int
Definition: createfilelist.py:10
CTPPSInterpolatedOpticsRcd.h
edm::ESGetToken< LHCInterpolatedOpticalFunctionsSetCollection, CTPPSInterpolatedOpticsRcd >
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
ModuleFactory.h
std
Definition: JetResolutionObject.h:76
CTPPSModifiedOpticalFunctionsESSource::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: CTPPSModifiedOpticalFunctionsESSource.cc:51
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
LHCOpticalFunctionsSet::eLpx
Definition: LHCOpticalFunctionsSet.h:16
EventSetup.h
CTPPSModifiedOpticalFunctionsESSource::inputOpticsToken_
edm::ESGetToken< LHCInterpolatedOpticalFunctionsSetCollection, CTPPSInterpolatedOpticsRcd > inputOpticsToken_
Definition: CTPPSModifiedOpticalFunctionsESSource.cc:26
CTPPSDetId.h
edm::ESProducer
Definition: ESProducer.h:101
ztail.d
d
Definition: ztail.py:151
cms::Exception
Definition: Exception.h:70
CTPPSModifiedOpticalFunctionsESSource::~CTPPSModifiedOpticalFunctionsESSource
~CTPPSModifiedOpticalFunctionsESSource() override
Definition: CTPPSModifiedOpticalFunctionsESSource.cc:19
ParameterSet.h
edm::ParameterDescriptionNode::setComment
void setComment(std::string const &value)
Definition: ParameterDescriptionNode.cc:106
CTPPSModifiedOpticalFunctionsESSource::rpDecId_45_N_
unsigned int rpDecId_45_N_
Definition: CTPPSModifiedOpticalFunctionsESSource.cc:32
CTPPSInterpolatedOpticsRcd
Definition: CTPPSInterpolatedOpticsRcd.h:13