CMS 3D CMS Logo

CTPPSLHCInfoESSource.cc
Go to the documentation of this file.
1 // Original Author: Jan Kašpar
2 
10 
13 
14 //----------------------------------------------------------------------------------------------------
15 
20 public:
24 
25 private:
27  const edm::IOVSyncValue &,
28  edm::ValidityInterval &) override;
29 
31 
33  double m_beamEnergy;
34  double m_betaStar;
35  double m_xangle;
36 
38 };
39 
40 //----------------------------------------------------------------------------------------------------
41 //----------------------------------------------------------------------------------------------------
42 
44  : m_label(conf.getParameter<std::string>("label")),
45  m_validityRange(conf.getParameter<edm::EventRange>("validityRange")),
46  m_beamEnergy(conf.getParameter<double>("beamEnergy")),
47  m_betaStar(conf.getParameter<double>("betaStar")),
48  m_xangle(conf.getParameter<double>("xangle")),
49  m_insideValidityRange(false) {
50  setWhatProduced(this, m_label);
51  findingRecord<LHCInfoRcd>();
52 }
53 
54 //----------------------------------------------------------------------------------------------------
55 
58 
59  desc.add<std::string>("label", "")->setComment("label of the LHCInfo record");
60 
61  desc.add<edm::EventRange>("validityRange", edm::EventRange())->setComment("interval of validity");
62 
63  desc.add<double>("beamEnergy", 0.)->setComment("beam energy");
64  desc.add<double>("betaStar", 0.)->setComment("beta*");
65  desc.add<double>("xangle", 0.)->setComment("crossing angle");
66 
67  descriptions.add("ctppsLHCInfoESSource", desc);
68 }
69 
70 //----------------------------------------------------------------------------------------------------
71 
73  const edm::IOVSyncValue &iosv,
74  edm::ValidityInterval &oValidity) {
75  if (edm::contains(m_validityRange, iosv.eventID())) {
76  m_insideValidityRange = true;
79  } else {
80  m_insideValidityRange = false;
81 
82  if (iosv.eventID() < m_validityRange.startEventID()) {
85  edm::EventID endEvent =
86  (lb > 1) ? edm::EventID(run, lb - 1, 0) : edm::EventID(run - 1, edm::EventID::maxLuminosityBlockNumber(), 0);
87 
89  } else {
92  edm::EventID beginEvent = (lb < edm::EventID::maxLuminosityBlockNumber() - 1) ? edm::EventID(run, lb + 1, 0)
93  : edm::EventID(run + 1, 0, 0);
94 
96  }
97  }
98 }
99 
100 //----------------------------------------------------------------------------------------------------
101 
103  auto output = std::make_unique<LHCInfo>();
104 
105  if (m_insideValidityRange) {
106  output->setEnergy(m_beamEnergy);
107  output->setBetaStar(m_betaStar);
108  output->setCrossingAngle(m_xangle);
109  } else {
110  output->setEnergy(0.);
111  output->setBetaStar(0.);
112  output->setCrossingAngle(0.);
113  }
114 
116 }
117 
118 //----------------------------------------------------------------------------------------------------
119 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
EventID startEventID() const
Definition: EventRange.h:46
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:37
static void fillDescriptions(edm::ConfigurationDescriptions &)
CTPPSLHCInfoESSource(const edm::ParameterSet &)
ESProducts< std::remove_reference_t< TArgs >... > products(TArgs &&... args)
Definition: ESProducts.h:128
EventID endEventID() const
Definition: EventRange.h:47
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
unsigned int LuminosityBlockNumber_t
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
edm::ESProducts< std::unique_ptr< LHCInfo > > produce(const LHCInfoRcd &)
edm::EventRange m_validityRange
Provides LHCInfo data necessary for CTPPS reconstruction (and direct simulation). ...
static LuminosityBlockNumber_t maxLuminosityBlockNumber()
Definition: EventID.h:94
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
key
prepare the HTCondor submission files and eventually submit them
RunNumber_t run() const
Definition: EventID.h:38
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:92
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const EventID & eventID() const
Definition: IOVSyncValue.h:40
HLT enums.
Definition: output.py:1
unsigned int RunNumber_t
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
def move(src, dest)
Definition: eostools.py:511