36 #include "CLHEP/Random/RandFlat.h"
37 #include "CLHEP/Random/JamesRandom.h"
97 std::shared_ptr<CTPPSGeometry>
realTG;
111 std::unique_ptr<CLHEP::HepRandomEngine>
m_engine_;
139 : compactViewTag_(conf.getParameter<
std::
string>(
"compactViewTag")),
140 lhcInfoLabel_(conf.getParameter<
std::
string>(
"lhcInfoLabel")),
141 opticsLabel_(conf.getParameter<
std::
string>(
"opticsLabel")),
142 generateEveryNEvents_(conf.getUntrackedParameter<unsigned
int>(
"generateEveryNEvents")),
143 verbosity_(conf.getUntrackedParameter<unsigned
int>(
"verbosity")),
144 isRun2_(conf.getParameter<
bool>(
"isRun2")),
145 m_engine_(new
CLHEP::HepJamesRandom(conf.getParameter<unsigned
int>(
"seed"))),
146 geometryBuilt_(
false) {
147 double l_int_sum = 0;
149 for (
const auto &
cfg : conf.
getParameter<std::vector<edm::ParameterSet>>(
"periods")) {
150 double l_int =
cfg.getParameter<
double>(
"L_int");
166 bin.min /= l_int_sum;
167 bin.max /= l_int_sum;
181 findingRecord<LHCInfoRcd>();
182 findingRecord<CTPPSOpticsRcd>();
183 findingRecord<PPSDirectSimulationDataRcd>();
184 findingRecord<RPRealAlignmentRecord>();
185 findingRecord<RPMisalignedAlignmentRecord>();
186 findingRecord<VeryForwardRealGeometryRecord>();
187 findingRecord<VeryForwardMisalignedGeometryRecord>();
194 desc.add<
std::string>(
"compactViewTag",
"")->setComment(
"label of the geometry compact view");
195 desc.add<
std::string>(
"lhcInfoLabel",
"")->setComment(
"label of the LHCInfo record");
196 desc.add<
std::string>(
"opticsLabel",
"")->setComment(
"label of the optics record");
197 desc.add<
unsigned int>(
"seed", 1)->setComment(
"random seed");
198 desc.add<
bool>(
"isRun2",
false)->setComment(
"use diamond's run 2 geometry definition?");
199 desc.addUntracked<
unsigned int>(
"generateEveryNEvents", 1)->setComment(
"how often to switch conditions");
200 desc.addUntracked<
unsigned int>(
"verbosity", 0);
203 std::vector<edm::ParameterSet> vp;
204 desc_profile.
add<
double>(
"L_int", 0.)->
setComment(
"integrated luminosity");
208 desc_profile_ctppsLHCInfo.
add<
double>(
"xangle", -1)
209 ->setComment(
"constant xangle, if negative, the xangle/beta* distribution will be used");
210 desc_profile_ctppsLHCInfo.
add<
double>(
"betaStar", 0.)->
setComment(
"constant beta*");
211 desc_profile_ctppsLHCInfo.
add<
double>(
"beamEnergy", 0.)->
setComment(
"beam energy");
212 desc_profile_ctppsLHCInfo.
add<
std::string>(
"xangleBetaStarHistogramFile",
"")
213 ->setComment(
"ROOT file with xangle/beta* distribution");
214 desc_profile_ctppsLHCInfo.
add<
std::string>(
"xangleBetaStarHistogramObject",
"")
215 ->setComment(
"xangle distribution object in the ROOT file");
221 of_desc.
add<
double>(
"xangle")->setComment(
"half crossing angle value in urad");
222 of_desc.
add<
edm::FileInPath>(
"fileName")->setComment(
"ROOT file with optical functions");
223 std::vector<edm::ParameterSet> of;
224 desc_profile_ctppsOpticalFunctions.addVPSet(
"opticalFunctions", of_desc, of)
225 ->setComment(
"list of optical functions at different crossing angles");
228 sp_desc.
add<
unsigned int>(
"rpId")->setComment(
"associated detector DetId");
229 sp_desc.
add<
std::string>(
"dirName")->setComment(
"associated path to the optical functions file");
230 sp_desc.
add<
double>(
"z")->setComment(
"longitudinal position at scoring plane/detector");
231 std::vector<edm::ParameterSet> sp;
232 desc_profile_ctppsOpticalFunctions.addVPSet(
"scoringPlanes", sp_desc, sp)
233 ->setComment(
"list of sensitive planes/detectors stations");
238 desc_profile_ctppsRPAlignmentCorrectionsDataXML.
add<std::vector<std::string>>(
"MeasuredFiles");
239 desc_profile_ctppsRPAlignmentCorrectionsDataXML.add<std::vector<std::string>>(
"RealFiles");
240 desc_profile_ctppsRPAlignmentCorrectionsDataXML.add<std::vector<std::string>>(
"MisalignedFiles");
242 desc_profile_ctppsRPAlignmentCorrectionsDataXML);
246 desc_profile_ctppsDirectSimuData.
add<
std::string>(
"empiricalAperture45");
247 desc_profile_ctppsDirectSimuData.add<
std::string>(
"empiricalAperture56");
249 desc_profile_ctppsDirectSimuData.add<
std::string>(
"timeResolutionDiamonds45");
250 desc_profile_ctppsDirectSimuData.add<
std::string>(
"timeResolutionDiamonds56");
253 eps_desc.
add<
unsigned int>(
"rpId")->setComment(
"RP id");
254 eps_desc.add<
std::string>(
"file")->setComment(
"file name");
255 eps_desc.add<
std::string>(
"object")->setComment(
"path to the efficiency histogram");
256 desc_profile_ctppsDirectSimuData.addVPSet(
"efficienciesPerRP", eps_desc, std::vector<edm::ParameterSet>());
257 desc_profile_ctppsDirectSimuData.addVPSet(
"efficienciesPerPlane", eps_desc, std::vector<edm::ParameterSet>());
261 desc.addVPSet(
"periods", desc_profile, vp)->setComment(
"profiles");
263 descriptions.
add(
"ctppsCompositeESSource",
desc);
280 const auto rpId = ps.getParameter<
unsigned int>(
"rpId");
282 const auto &
object = ps.getParameter<
std::string>(
"object");
287 const auto rpId = ps.getParameter<
unsigned int>(
"rpId");
289 const auto &
object = ps.getParameter<
std::string>(
"object");
303 p.misalignedTG = std::make_shared<CTPPSGeometry>(
p.misalignedGD.get(),
verbosity_);
306 p.realTG = std::make_shared<CTPPSGeometry>(
p.realGD.get(),
verbosity_);
322 std::vector<FileInfo> fileInfo;
325 const double &
xangle =
pset.getParameter<
double>(
"xangle");
332 double m_scoringPlaneZ;
335 std::unordered_map<unsigned int, RPInfo> rpInfo;
338 const unsigned int rpId =
pset.getParameter<
unsigned int>(
"rpId");
340 const double z =
pset.getParameter<
double>(
"z");
345 for (
const auto &fi : fileInfo) {
346 std::unordered_map<unsigned int, LHCOpticalFunctionsSet> xa_data;
348 for (
const auto &rpi : rpInfo) {
353 pData.
lhcOptical.emplace(fi.m_xangle, xa_data);
361 auto ctppsRPAlignmentCorrectionsDataXMLPSet =
366 ctppsRPAlignmentCorrectionsDataXMLPSet);
369 pData.
acReal = std::make_shared<CTPPSRPAlignmentCorrectionsData>(
370 ctppsRPAlignmentCorrectionsDataESSourceXMLCommon.
acsReal.empty()
372 : ctppsRPAlignmentCorrectionsDataESSourceXMLCommon.
acsReal[0].second);
374 pData.
acMisaligned = std::make_shared<CTPPSRPAlignmentCorrectionsData>(
375 ctppsRPAlignmentCorrectionsDataESSourceXMLCommon.
acsMisaligned.empty()
377 : ctppsRPAlignmentCorrectionsDataESSourceXMLCommon.
acsMisaligned[0].second);
394 std::unique_ptr<TFile> f_in(TFile::Open(fip.fullPath().c_str()));
399 TH2D *h_xangle_beta_star =
401 if (!h_xangle_beta_star)
407 for (
int bi = 1; bi <= h_xangle_beta_star->GetNcells(); ++bi)
408 sum += h_xangle_beta_star->GetBinContent(bi);
411 for (
int x = 1;
x <= h_xangle_beta_star->GetNbinsX(); ++
x)
412 for (
int y = 1;
y <= h_xangle_beta_star->GetNbinsY(); ++
y) {
413 const double w = h_xangle_beta_star->GetBinContent(h_xangle_beta_star->GetBin(
x,
y)) / sum;
418 std::pair<double, double>(h_xangle_beta_star->GetXaxis()->GetBinCenter(
x),
419 h_xangle_beta_star->GetYaxis()->GetBinCenter(
y))});
443 const double u = CLHEP::RandFlat::shoot(
m_engine_.get(), 0., 1.);
446 if (
bin.min <= u && u <=
bin.max) {
506 const double u = CLHEP::RandFlat::shoot(
m_engine_.get(), 0., 1.);
508 if (
d.min <= u && u <=
d.max) {
516 auto lhcInfo = std::make_unique<LHCInfo>();
518 lhcInfo->setCrossingAngle(
xangle);