Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:52

0001 /****************************************************************************
0002  * Authors:
0003  *   Wagner Carvalho wcarvalh@cern.ch
0004  *   Jan Kašpar
0005  ****************************************************************************/
0006 
0007 #include "FWCore/Framework/interface/MakerMacros.h"
0008 #include "FWCore/Framework/interface/SourceFactory.h"
0009 #include "FWCore/Framework/interface/ModuleFactory.h"
0010 
0011 #include "FWCore/Framework/interface/ESHandle.h"
0012 #include "FWCore/Framework/interface/ESProducer.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015 
0016 #include "CondFormats/DataRecord/interface/LHCInfoRcd.h"
0017 #include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h"
0018 
0019 #include "CondFormats/RunInfo/interface/LHCInfo.h"
0020 
0021 #include "CondFormats/PPSObjects/interface/CTPPSBeamParameters.h"
0022 
0023 //----------------------------------------------------------------------------------------------------
0024 
0025 class CTPPSBeamParametersFromLHCInfoESSource : public edm::ESProducer {
0026 public:
0027   CTPPSBeamParametersFromLHCInfoESSource(const edm::ParameterSet&);
0028   ~CTPPSBeamParametersFromLHCInfoESSource() override = default;
0029 
0030   std::unique_ptr<CTPPSBeamParameters> produce(const CTPPSBeamParametersRcd&);
0031   static void fillDescriptions(edm::ConfigurationDescriptions&);
0032 
0033 private:
0034   const edm::ESGetToken<LHCInfo, LHCInfoRcd> lhcInfoToken_;
0035 
0036   CTPPSBeamParameters defaultParameters_;
0037 };
0038 
0039 //----------------------------------------------------------------------------------------------------
0040 
0041 CTPPSBeamParametersFromLHCInfoESSource::CTPPSBeamParametersFromLHCInfoESSource(const edm::ParameterSet& iConfig)
0042     : lhcInfoToken_(
0043           setWhatProduced(this).consumes(edm::ESInputTag("", iConfig.getParameter<std::string>("lhcInfoLabel")))) {
0044   defaultParameters_.setBeamDivergenceX45(iConfig.getParameter<double>("beamDivX45"));
0045   defaultParameters_.setBeamDivergenceY45(iConfig.getParameter<double>("beamDivX56"));
0046   defaultParameters_.setBeamDivergenceX56(iConfig.getParameter<double>("beamDivY45"));
0047   defaultParameters_.setBeamDivergenceY56(iConfig.getParameter<double>("beamDivY56"));
0048 
0049   defaultParameters_.setVtxOffsetX45(iConfig.getParameter<double>("vtxOffsetX45"));
0050   defaultParameters_.setVtxOffsetY45(iConfig.getParameter<double>("vtxOffsetY45"));
0051   defaultParameters_.setVtxOffsetZ45(iConfig.getParameter<double>("vtxOffsetZ45"));
0052   defaultParameters_.setVtxOffsetX56(iConfig.getParameter<double>("vtxOffsetX56"));
0053   defaultParameters_.setVtxOffsetY56(iConfig.getParameter<double>("vtxOffsetY56"));
0054   defaultParameters_.setVtxOffsetZ56(iConfig.getParameter<double>("vtxOffsetZ56"));
0055 
0056   defaultParameters_.setVtxStddevX(iConfig.getParameter<double>("vtxStddevX"));
0057   defaultParameters_.setVtxStddevY(iConfig.getParameter<double>("vtxStddevY"));
0058   defaultParameters_.setVtxStddevZ(iConfig.getParameter<double>("vtxStddevZ"));
0059 }
0060 
0061 //----------------------------------------------------------------------------------------------------
0062 
0063 std::unique_ptr<CTPPSBeamParameters> CTPPSBeamParametersFromLHCInfoESSource::produce(
0064     const CTPPSBeamParametersRcd& iRecord) {
0065   LHCInfo const& lhcInfo = iRecord.get(lhcInfoToken_);
0066 
0067   auto bp = std::make_unique<CTPPSBeamParameters>(defaultParameters_);
0068 
0069   const auto beamMom = lhcInfo.energy();
0070   const auto betaStar = lhcInfo.betaStar() * 1E2;      // conversion m --> cm
0071   const auto xangle = lhcInfo.crossingAngle() * 1E-6;  // conversion mu rad --> rad
0072 
0073   bp->setBeamMom45(beamMom);
0074   bp->setBeamMom56(beamMom);
0075 
0076   bp->setBetaStarX45(betaStar);
0077   bp->setBetaStarX56(betaStar);
0078   bp->setBetaStarY45(betaStar);
0079   bp->setBetaStarY56(betaStar);
0080 
0081   bp->setHalfXangleX45(xangle);
0082   bp->setHalfXangleX56(xangle);
0083   bp->setHalfXangleY45(xangle);
0084   bp->setHalfXangleY56(xangle);
0085 
0086   return bp;
0087 }
0088 
0089 //----------------------------------------------------------------------------------------------------
0090 
0091 void CTPPSBeamParametersFromLHCInfoESSource::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0092   edm::ParameterSetDescription desc;
0093 
0094   desc.add<std::string>("lhcInfoLabel", "");
0095 
0096   // beam divergence (rad)
0097   desc.add<double>("beamDivX45", 0.1);
0098   desc.add<double>("beamDivY45", 0.1);
0099   desc.add<double>("beamDivX56", 0.1);
0100   desc.add<double>("beamDivY56", 0.1);
0101 
0102   // vertex offset (cm)
0103   desc.add<double>("vtxOffsetX45", 1.e-2);
0104   desc.add<double>("vtxOffsetY45", 1.e-2);
0105   desc.add<double>("vtxOffsetZ45", 1.e-2);
0106   desc.add<double>("vtxOffsetX56", 1.e-2);
0107   desc.add<double>("vtxOffsetY56", 1.e-2);
0108   desc.add<double>("vtxOffsetZ56", 1.e-2);
0109 
0110   // vertex sigma (cm)
0111   desc.add<double>("vtxStddevX", 2.e-2);
0112   desc.add<double>("vtxStddevY", 2.e-2);
0113   desc.add<double>("vtxStddevZ", 2.e-2);
0114 
0115   descriptions.add("ctppsBeamParametersFromLHCInfoESSource", desc);
0116 }
0117 
0118 //----------------------------------------------------------------------------------------------------
0119 
0120 DEFINE_FWK_EVENTSETUP_MODULE(CTPPSBeamParametersFromLHCInfoESSource);