Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTPPS update Run3 Direct Simulation to use old LHCInfo after LHCInfo update #42890

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "CondFormats/DataRecord/interface/LHCInfoRcd.h"
#include "CondTools/RunInfo/interface/LHCInfoCombined.h"
#include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h"

#include "CondFormats/RunInfo/interface/LHCInfo.h"
Expand All @@ -31,16 +31,23 @@ class CTPPSBeamParametersFromLHCInfoESSource : public edm::ESProducer {
static void fillDescriptions(edm::ConfigurationDescriptions&);

private:
const edm::ESGetToken<LHCInfo, LHCInfoRcd> lhcInfoToken_;
edm::ESGetToken<LHCInfo, LHCInfoRcd> lhcInfoToken_;
edm::ESGetToken<LHCInfoPerLS, LHCInfoPerLSRcd> lhcInfoPerLSToken_;
edm::ESGetToken<LHCInfoPerFill, LHCInfoPerFillRcd> lhcInfoPerFillToken_;
const bool useNewLHCInfo_;

CTPPSBeamParameters defaultParameters_;
};

//----------------------------------------------------------------------------------------------------

CTPPSBeamParametersFromLHCInfoESSource::CTPPSBeamParametersFromLHCInfoESSource(const edm::ParameterSet& iConfig)
: lhcInfoToken_(
setWhatProduced(this).consumes(edm::ESInputTag("", iConfig.getParameter<std::string>("lhcInfoLabel")))) {
: useNewLHCInfo_(iConfig.getParameter<bool>("useNewLHCInfo")) {
auto cc = setWhatProduced(this);
lhcInfoToken_ = cc.consumes(edm::ESInputTag("", iConfig.getParameter<std::string>("lhcInfoLabel")));
lhcInfoPerLSToken_ = cc.consumes(edm::ESInputTag("", iConfig.getParameter<std::string>("lhcInfoPerLSLabel")));
lhcInfoPerFillToken_ = cc.consumes(edm::ESInputTag("", iConfig.getParameter<std::string>("lhcInfoPerFillLabel")));
Comment on lines +47 to +49
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps only for possible future development at this point, but in all these cases the configuration parameters could be made ESInputTag directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not sound like a bad idea, however in every module I worked on lhcInfoLabel is a string instead of ESInputTag so I think there might be a reason for it. It's worth investigating but I would defer it to a future PR - it's an aesthetic update, needed in many files and will take a while to implement and test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth investigating but I would defer it to a future PR

That would be be perfectly fine, thanks.

(in principle using ESInputTag directly in configuration opens the possibility to use the first "module label" field of ESInputTag for ensuring the ES data products come from the expected ES module, if such requirement would be wanted, but that feature is not really used in CMSSW application configuration)


defaultParameters_.setBeamDivergenceX45(iConfig.getParameter<double>("beamDivX45"));
defaultParameters_.setBeamDivergenceY45(iConfig.getParameter<double>("beamDivX56"));
defaultParameters_.setBeamDivergenceX56(iConfig.getParameter<double>("beamDivY45"));
Expand All @@ -62,13 +69,16 @@ CTPPSBeamParametersFromLHCInfoESSource::CTPPSBeamParametersFromLHCInfoESSource(c

std::unique_ptr<CTPPSBeamParameters> CTPPSBeamParametersFromLHCInfoESSource::produce(
const CTPPSBeamParametersRcd& iRecord) {
LHCInfo const& lhcInfo = iRecord.get(lhcInfoToken_);
auto lhcInfoCombined =
LHCInfoCombined::createLHCInfoCombined<CTPPSBeamParametersRcd,
edm::mpl::Vector<LHCInfoRcd, LHCInfoPerFillRcd, LHCInfoPerLSRcd>>(
iRecord, lhcInfoPerLSToken_, lhcInfoPerFillToken_, lhcInfoToken_, useNewLHCInfo_);

auto bp = std::make_unique<CTPPSBeamParameters>(defaultParameters_);

const auto beamMom = lhcInfo.energy();
const auto betaStar = lhcInfo.betaStar() * 1E2; // conversion m --> cm
const auto xangle = lhcInfo.crossingAngle() * 1E-6; // conversion mu rad --> rad
const auto beamMom = lhcInfoCombined.energy;
const auto betaStar = lhcInfoCombined.betaStarX * 1E2; // conversion m --> cm
const auto xangle = lhcInfoCombined.crossingAngle() * 1E-6; // conversion mu rad --> rad

bp->setBeamMom45(beamMom);
bp->setBeamMom56(beamMom);
Expand All @@ -92,6 +102,9 @@ void CTPPSBeamParametersFromLHCInfoESSource::fillDescriptions(edm::Configuration
edm::ParameterSetDescription desc;

desc.add<std::string>("lhcInfoLabel", "");
desc.add<std::string>("lhcInfoPerLSLabel", "");
desc.add<std::string>("lhcInfoPerFillLabel", "");
desc.add<bool>("useNewLHCInfo", false);

// beam divergence (rad)
desc.add<double>("beamDivX45", 0.1);
Expand All @@ -112,7 +125,7 @@ void CTPPSBeamParametersFromLHCInfoESSource::fillDescriptions(edm::Configuration
desc.add<double>("vtxStddevY", 2.e-2);
desc.add<double>("vtxStddevZ", 2.e-2);

descriptions.add("ctppsBeamParametersFromLHCInfoESSource", desc);
descriptions.add("ctppsBeamParametersFromLHCInfoESSourceDefault", desc);
}

//----------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void CTPPSInterpolatedOpticalFunctionsESSource::fillDescriptions(edm::Configurat
desc.add<std::string>("opticsLabel", "")->setComment("label of the optics records");
desc.add<bool>("useNewLHCInfo", false)->setComment("flag whether to use new LHCInfoPer* records or old LHCInfo");

descriptions.add("ctppsInterpolatedOpticalFunctionsESSource", desc);
descriptions.add("ctppsInterpolatedOpticalFunctionsESSourceDefault", desc);
}

//----------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from CalibPPS.ESProducers.ctppsBeamParametersFromLHCInfoESSourceDefault_cfi import ctppsBeamParametersFromLHCInfoESSourceDefault as _ctppsBeamParametersFromLHCInfoESSourceDefault
ctppsBeamParametersFromLHCInfoESSource = _ctppsBeamParametersFromLHCInfoESSourceDefault.clone()

from Configuration.Eras.Modifier_run3_common_cff import run3_common
run3_common.toModify(ctppsBeamParametersFromLHCInfoESSource, useNewLHCInfo = True)

from Configuration.Eras.Modifier_ctpps_directSim_cff import ctpps_directSim
ctpps_directSim.toModify(ctppsBeamParametersFromLHCInfoESSource, useNewLHCInfo = False)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from CalibPPS.ESProducers.ctppsInterpolatedOpticalFunctionsESSourceDefault_cfi import ctppsInterpolatedOpticalFunctionsESSourceDefault as _ctppsInterpolatedOpticalFunctionsESSourceDefault
ctppsInterpolatedOpticalFunctionsESSource = _ctppsInterpolatedOpticalFunctionsESSourceDefault.clone()

from Configuration.Eras.Modifier_run3_common_cff import run3_common
run3_common.toModify(ctppsInterpolatedOpticalFunctionsESSource, useNewLHCInfo = True)

from Configuration.Eras.Modifier_ctpps_directSim_cff import ctpps_directSim
ctpps_directSim.toModify(ctppsInterpolatedOpticalFunctionsESSource, useNewLHCInfo = False)
2 changes: 1 addition & 1 deletion CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
#ctppsOpticalFunctionsESSource.configuration.append(config_2016_preTS2)

# optics interpolation between crossing angles
from CalibPPS.ESProducers.ctppsInterpolatedOpticalFunctionsESSource_cff import *
from CalibPPS.ESProducers.ctppsInterpolatedOpticalFunctionsESSource_cfi import *
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@
ctppsOpticalFunctionsESSource.configuration.append(optics_2022)

# optics interpolation between crossing angles
from CalibPPS.ESProducers.ctppsInterpolatedOpticalFunctionsESSource_cff import *
from CalibPPS.ESProducers.ctppsInterpolatedOpticalFunctionsESSource_cfi import *
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
process = cms.Process( 'TEST',ctpps_2018)

# LHCInfo plotter
process.load('Validation.CTPPS.ctppsLHCInfoPlotter_cff')
process.load('Validation.CTPPS.ctppsLHCInfoPlotter_cfi')
process.ctppsLHCInfoPlotter.outputFile = "alcareco_lhc_info_express.root"

# Load geometry from DB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
process = cms.Process( 'TEST',ctpps_2018)

# LHCInfo plotter
process.load('Validation.CTPPS.ctppsLHCInfoPlotter_cff')
process.load('Validation.CTPPS.ctppsLHCInfoPlotter_cfi')
process.ctppsLHCInfoPlotter.outputFile = "alcareco_lhc_info_prompt.root"

# Load geometry from DB
Expand Down
7 changes: 5 additions & 2 deletions CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
#include "FWCore/Framework/interface/DependentRecordImplementation.h"

#include "CondFormats/DataRecord/interface/LHCInfoRcd.h"
#include "CondFormats/DataRecord/interface/LHCInfoPerFillRcd.h"
#include "CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h"

#include "FWCore/Utilities/interface/mplVector.h"

class CTPPSBeamParametersRcd
: public edm::eventsetup::DependentRecordImplementation<CTPPSBeamParametersRcd, edm::mpl::Vector<LHCInfoRcd>> {};
class CTPPSBeamParametersRcd : public edm::eventsetup::DependentRecordImplementation<
CTPPSBeamParametersRcd,
edm::mpl::Vector<LHCInfoRcd, LHCInfoPerFillRcd, LHCInfoPerLSRcd>> {};

#endif
2 changes: 1 addition & 1 deletion CondTools/RunInfo/interface/LHCInfoCombined.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class LHCInfoCombined {
void setFromPerLS(const LHCInfoPerLS& infoPerLS);
void setFromPerFill(const LHCInfoPerFill& infoPerFill);

float crossingAngle();
float crossingAngle() const;
static constexpr float crossingAngleInvalid = -1.;
bool isCrossingAngleInvalid();

Expand Down
2 changes: 1 addition & 1 deletion CondTools/RunInfo/src/LHCInfoCombined.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void LHCInfoCombined::setFromPerFill(const LHCInfoPerFill& infoPerFill) {
fillNumber = infoPerFill.fillNumber();
}

float LHCInfoCombined::crossingAngle() {
float LHCInfoCombined::crossingAngle() const {
if (crossingAngleX == 0. && crossingAngleY == 0.) {
return crossingAngleInvalid;
}
Expand Down
3 changes: 3 additions & 0 deletions Configuration/Eras/python/Modifier_ctpps_directSim_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import FWCore.ParameterSet.Config as cms

ctpps_directSim = cms.Modifier()
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import FWCore.ParameterSet.Config as cms

from Configuration.Eras.Era_Run3_cff import Run3
from Configuration.Eras.Modifier_ctpps_directSim_cff import ctpps_directSim

Run3_CTPPS_directSim = cms.ModifierChain(Run3,ctpps_directSim)
2 changes: 1 addition & 1 deletion RecoPPS/Local/test/2023_lhcinfo_test_recoCTPPS_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

from Configuration.AlCa.GlobalTag import GlobalTag

process.GlobalTag.globaltag = "130X_dataRun3_Prompt_forLHCInfo_Candidate_2023_08_08_10_52_01"
process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run3_data')

# local RP reconstruction chain with standard settings
process.load("RecoPPS.Configuration.recoCTPPS_cff")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void CTPPSProtonProducer::fillDescriptions(edm::ConfigurationDescriptions &descr
desc.add<std::string>("multiRPAlgorithm", "chi2")
->setComment("algorithm for multi-RP reco, options include chi2, newton, anal-iter");

descriptions.add("ctppsProtons", desc);
descriptions.add("ctppsProtonsDefault", desc);
}

//----------------------------------------------------------------------------------------------------
Expand Down
13 changes: 1 addition & 12 deletions RecoPPS/ProtonReconstruction/python/ctppsProtons_cff.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
import FWCore.ParameterSet.Config as cms

# import default alignment settings
from CalibPPS.ESProducers.ctppsAlignment_cff import *
from RecoPPS.ProtonReconstruction.ctppsProtons_cfi import *

# import default optics settings
from CalibPPS.ESProducers.ctppsOpticalFunctions_cff import *

# import and adjust proton-reconstructions settings
from RecoPPS.ProtonReconstruction.ctppsProtons_cfi import *


ctppsProtons.pixelDiscardBXShiftedTracks = True
ctppsProtons.default_time = -999.

from Configuration.Eras.Modifier_run3_common_cff import run3_common
run3_common.toModify(ctppsProtons, useNewLHCInfo = True)
12 changes: 12 additions & 0 deletions RecoPPS/ProtonReconstruction/python/ctppsProtons_cfi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# import and adjust proton-reconstructions settings
from RecoPPS.ProtonReconstruction.ctppsProtonsDefault_cfi import ctppsProtonsDefault as _ctppsProtonsDefault
ctppsProtons = _ctppsProtonsDefault.clone(
pixelDiscardBXShiftedTracks = True,
default_time = -999.
)

from Configuration.Eras.Modifier_run3_common_cff import run3_common
run3_common.toModify(ctppsProtons, useNewLHCInfo = True)

from Configuration.Eras.Modifier_ctpps_directSim_cff import ctpps_directSim
ctpps_directSim.toModify(ctppsProtons, useNewLHCInfo = False)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# beam optics
from CondCore.CondDB.CondDB_cfi import *
from CalibPPS.ESProducers.ctppsBeamParametersFromLHCInfoESSource_cfi import *
from CalibPPS.ESProducers.ctppsInterpolatedOpticalFunctionsESSource_cff import *
from CalibPPS.ESProducers.ctppsInterpolatedOpticalFunctionsESSource_cfi import *
ctppsInterpolatedOpticalFunctionsESSource.lhcInfoLabel = ""

"""
Expand Down
40 changes: 32 additions & 8 deletions Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"

#include "CondFormats/RunInfo/interface/LHCInfo.h"
#include "CondFormats/DataRecord/interface/LHCInfoRcd.h"
#include "CondTools/RunInfo/interface/LHCInfoCombined.h"

#include "TFile.h"
#include "TH1D.h"
Expand All @@ -29,13 +28,20 @@ class CTPPSHepMCDistributionPlotter : public edm::one::EDAnalyzer<> {
public:
explicit CTPPSHepMCDistributionPlotter(const edm::ParameterSet &);

static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);

private:
void analyze(const edm::Event &, const edm::EventSetup &) override;
void endJob() override;

edm::EDGetTokenT<edm::HepMCProduct> tokenHepMC_;
edm::ESGetToken<LHCInfo, LHCInfoRcd> lhcInfoESToken_;
std::string outputFile_;
const edm::EDGetTokenT<edm::HepMCProduct> tokenHepMC_;

const edm::ESGetToken<LHCInfo, LHCInfoRcd> lhcInfoToken_;
const edm::ESGetToken<LHCInfoPerLS, LHCInfoPerLSRcd> lhcInfoPerLSToken_;
const edm::ESGetToken<LHCInfoPerFill, LHCInfoPerFillRcd> lhcInfoPerFillToken_;
const bool useNewLHCInfo_;

const std::string outputFile_;

std::unique_ptr<TH1D> h_vtx_x_, h_vtx_y_, h_vtx_z_, h_vtx_t_;
std::unique_ptr<TH1D> h_xi_, h_th_x_, h_th_y_;
Expand All @@ -51,7 +57,12 @@ using namespace HepMC;

CTPPSHepMCDistributionPlotter::CTPPSHepMCDistributionPlotter(const edm::ParameterSet &iConfig)
: tokenHepMC_(consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("tagHepMC"))),
lhcInfoESToken_(esConsumes(ESInputTag("", iConfig.getParameter<std::string>("lhcInfoLabel")))),

lhcInfoToken_(esConsumes(ESInputTag("", iConfig.getParameter<std::string>("lhcInfoLabel")))),
lhcInfoPerLSToken_(esConsumes(ESInputTag("", iConfig.getParameter<std::string>("lhcInfoPerLSLabel")))),
lhcInfoPerFillToken_(esConsumes(ESInputTag("", iConfig.getParameter<std::string>("lhcInfoPerFillLabel")))),
useNewLHCInfo_(iConfig.getParameter<bool>("useNewLHCInfo")),

outputFile_(iConfig.getParameter<string>("outputFile")),

h_vtx_x_(new TH1D("h_vtx_x", ";vtx_x (mm)", 100, 0., 0.)),
Expand All @@ -65,9 +76,22 @@ CTPPSHepMCDistributionPlotter::CTPPSHepMCDistributionPlotter(const edm::Paramete

//----------------------------------------------------------------------------------------------------

void CTPPSHepMCDistributionPlotter::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
edm::ParameterSetDescription desc;

desc.add<std::string>("lhcInfoLabel", "")->setComment("label of the LHCInfo record");
desc.add<std::string>("lhcInfoPerLSLabel", "")->setComment("label of the LHCInfoPerLS record");
desc.add<std::string>("lhcInfoPerFillLabel", "")->setComment("label of the LHCInfoPerFill record");
desc.add<bool>("useNewLHCInfo", false)->setComment("flag whether to use new LHCInfoPer* records or old LHCInfo");

desc.add<std::string>("outputFile", "")->setComment("output file");

descriptions.add("ctppsHepMCDistributionPlotterDefault", desc);
}

void CTPPSHepMCDistributionPlotter::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
// get conditions
const auto &lhcInfo = iSetup.getData(lhcInfoESToken_);
LHCInfoCombined lhcInfoCombined(iSetup, lhcInfoPerLSToken_, lhcInfoPerFillToken_, lhcInfoToken_, useNewLHCInfo_);

// get input
edm::Handle<edm::HepMCProduct> hHepMC;
Expand Down Expand Up @@ -98,7 +122,7 @@ void CTPPSHepMCDistributionPlotter::analyze(const edm::Event &iEvent, const edm:
continue;

const auto &mom = part->momentum();
const double p_nom = lhcInfo.energy();
const double p_nom = lhcInfoCombined.energy;

if (mom.rho() / p_nom < 0.7)
continue;
Expand Down
2 changes: 1 addition & 1 deletion Validation/CTPPS/plugins/CTPPSLHCInfoPlotter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void CTPPSLHCInfoPlotter::fillDescriptions(edm::ConfigurationDescriptions &descr

desc.add<std::string>("outputFile", "")->setComment("output file");

descriptions.add("ctppsLHCInfoPlotter", desc);
descriptions.add("ctppsLHCInfoPlotterDefault", desc);
}

//----------------------------------------------------------------------------------------------------
Expand Down
Loading