36 #include "CLHEP/Random/RandFlat.h" 37 #include "CLHEP/Random/JamesRandom.h" 97 std::shared_ptr<CTPPSGeometry>
realTG;
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");
342 rpInfo.emplace(rpId,
entry);
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);
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
LHCOpticalFunctionsSetCollection lhcOptical
void setComment(std::string const &value)
std::shared_ptr< CTPPSRPAlignmentCorrectionsData > acMisaligned
std::string compactViewTag_
T getParameter(std::string const &) const
void buildAlignment(const edm::ParameterSet &profile, ProfileData &pData)
static void fillDescriptions(edm::ConfigurationDescriptions &)
void buildGeometry(const DDCompactView &cpv)
std::string lhcInfoLabel_
std::shared_ptr< DDCompactView > ddCompactView
std::shared_ptr< CTPPSRPAlignmentCorrectionsData > produceMisalignedAlignments(const RPMisalignedAlignmentRecord &)
CTPPSRPAlignmentCorrectionsDataSequence acsMisaligned
std::shared_ptr< DetGeomDesc > misalignedGD
void buildLHCInfo(const edm::ParameterSet &profile, ProfileData &pData)
std::pair< Time_t, Time_t > ValidityInterval
const ProfileData * currentProfile_
std::shared_ptr< CTPPSGeometry > produceMisalignedTG(const VeryForwardMisalignedGeometryRecord &)
void buildDirectSimuData(const edm::ParameterSet &profile, ProfileData &pData)
std::unique_ptr< DetGeomDesc > applyAlignments(const DetGeomDesc &, const CTPPSRPAlignmentCorrectionsData *)
void setTimeResolutionDiamonds56(std::string s)
Compact representation of the geometrical detector hierarchy.
std::unique_ptr< CLHEP::HepRandomEngine > m_engine_
unsigned int generateEveryNEvents_
void buildOptics(const edm::ParameterSet &profile, ProfileData &pData)
Event setup record containing the real (actual) geometry information.
LuminosityBlockNumber_t luminosityBlock() const
edm::EventID previously_set_eventID_
PPSDirectSimulationData directSimuData
std::shared_ptr< CTPPSRPAlignmentCorrectionsData > produceRealAlignments(const RPRealAlignmentRecord &)
std::shared_ptr< CTPPSGeometry > misalignedTG
void setEmpiricalAperture45(std::string s)
std::map< unsigned int, FileObject > & getEfficienciesPerRP()
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::unique_ptr< DetGeomDesc > buildDetGeomDescFromCompactView(const DDCompactView &myCompactView, const bool isRun2)
Log< level::Info, false > LogInfo
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
std::shared_ptr< DetGeomDesc > realGD
Set of optical functions corresponding to one scoring plane along LHC.
void setEmpiricalAperture56(std::string s)
void addUntrackedParameter(std::string const &name, T const &value)
void fcn(int &, double *, double &, double *, int)
CTPPSCompositeESSource(const edm::ParameterSet &)
std::unique_ptr< PPSDirectSimulationData > produceDirectSimuData(const PPSDirectSimulationDataRcd &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< BinData< std::pair< double, double > > > xangleBetaStarBins
edm::ESGetToken< DDCompactView, IdealGeometryRecord > tokenCompactViewReal_
std::shared_ptr< CTPPSGeometry > realTG
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
const EventID & eventID() const
Container for CTPPS RP alignment corrections. The corrections are stored on two levels - RP and senso...
std::vector< BinData< ProfileData > > profile_bins_
Event setup record containing the misaligned geometry information. It is used for alignment studies o...
CTPPSRPAlignmentCorrectionsDataSequence acsReal
std::unique_ptr< LHCInfo > produceLhcInfo(const LHCInfoRcd &)
const DepRecordT getRecord() const
void setTimeResolutionDiamonds45(std::string s)
std::unique_ptr< LHCOpticalFunctionsSetCollection > produceOptics(const CTPPSOpticsRcd &)
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Collection of optical functions for two crossing angle values and various scoring planes...
std::shared_ptr< CTPPSGeometry > produceRealTG(const VeryForwardRealGeometryRecord &)
edm::ESGetToken< DDCompactView, IdealGeometryRecord > tokenCompactViewMisaligned_
EventNumber_t event() const
std::shared_ptr< CTPPSRPAlignmentCorrectionsData > acReal
std::map< unsigned int, FileObject > & getEfficienciesPerPlane()