CMS 3D CMS Logo

LHCInfoProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PhysicsTools/NanoAOD
4 // Class: LHCInfoProducer
5 //
11 //
12 // Original Author: Justin Williams
13 // Created: 05 Jul 2019 14:06:12 GMT
14 //
15 //
16 
17 // System include files
18 #include <memory>
19 #include <map>
20 #include <string>
21 #include <vector>
22 #include <iostream>
23 
24 // user include files
27 
30 
36 
39 
41 
45 
47 
49 
50 class LHCInfoProducer : public edm::global::EDProducer<edm::BeginLuminosityBlockProducer> {
51 public:
53  : lhcinfoToken_(esConsumes<edm::Transition::BeginLuminosityBlock>(
54  edm::ESInputTag("", iConfig.getParameter<std::string>("lhcInfoLabel")))),
55  lhcinfoPerLSToken_(esConsumes<edm::Transition::BeginLuminosityBlock>(
56  edm::ESInputTag("", iConfig.getParameter<std::string>("lhcInfoPerLSLabel")))),
57  lhcinfoPerFillToken_(esConsumes<edm::Transition::BeginLuminosityBlock>(
58  edm::ESInputTag("", iConfig.getParameter<std::string>("lhcInfoPerFillLabel")))),
59  useNewLHCInfo_(iConfig.getParameter<bool>("useNewLHCInfo")) {
60  produces<nanoaod::MergeableCounterTable, edm::Transition::BeginLuminosityBlock>();
61  }
62  ~LHCInfoProducer() override {}
63 
64  // ------------ method called to produce the data ------------
65  void produce(edm::StreamID id, edm::Event& iEvent, const edm::EventSetup& iSetup) const override {}
66 
67  void globalBeginLuminosityBlockProduce(edm::LuminosityBlock& iLumi, edm::EventSetup const& iSetup) const override {
69  auto out = std::make_unique<nanoaod::MergeableCounterTable>();
70  out->addFloat("crossingAngle", "LHC crossing angle", lhcInfoCombined.crossingAngle());
71  out->addFloat("betaStar", "LHC beta star", lhcInfoCombined.betaStarX);
72  out->addFloat("energy", "LHC beam energy", lhcInfoCombined.energy);
73  iLumi.put(std::move(out));
74  }
75 
76  // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
77  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
79  desc.add<std::string>("lhcInfoLabel", "")->setComment("label used for LHCInfo");
80  desc.add<std::string>("lhcInfoPerLSLabel", "")->setComment("label of the LHCInfoPerLS record");
81  desc.add<std::string>("lhcInfoPerFillLabel", "")->setComment("label of the LHCInfoPerFill record");
82  desc.add<bool>("useNewLHCInfo", true)
83  ->setComment("flag whether to use new LHCInfoPerLS/Fill records or old LHCInfo");
84  descriptions.addWithDefaultLabel(desc);
85  }
90 };
91 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
float crossingAngle() const
int iEvent
Definition: GenABIO.cc:224
void produce(edm::StreamID id, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
void put(std::unique_ptr< PROD > product)
Put a new product.
Transition
Definition: Transition.h:12
edm::ESGetToken< LHCInfoPerFill, LHCInfoPerFillRcd > lhcinfoPerFillToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ESGetToken< LHCInfo, LHCInfoRcd > lhcinfoToken_
HLT enums.
~LHCInfoProducer() override
LHCInfoProducer(edm::ParameterSet const &iConfig)
edm::ESGetToken< LHCInfoPerLS, LHCInfoPerLSRcd > lhcinfoPerLSToken_
def move(src, dest)
Definition: eostools.py:511
void globalBeginLuminosityBlockProduce(edm::LuminosityBlock &iLumi, edm::EventSetup const &iSetup) const override