CMS 3D CMS Logo

TkInstLumiTableProducer.cc
Go to the documentation of this file.
10 
12 public:
14  : m_name(params.getParameter<std::string>("name")),
15  m_doc(params.existsAs<std::string>("doc") ? params.getParameter<std::string>("doc") : ""),
16  m_extension(params.existsAs<bool>("extension") ? params.getParameter<bool>("extension") : false),
17  m_scalerToken(consumes<LumiScalersCollection>(params.getParameter<edm::InputTag>("lumiScalers"))),
18  m_metaDataToken(consumes<OnlineLuminosityRecord>(params.getParameter<edm::InputTag>("metadata"))) {
19  produces<nanoaod::FlatTable>();
20  }
21 
22  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
24  desc.add<std::string>("name", "");
25  desc.add<std::string>("doc", "");
26  desc.add<bool>("extension", false);
27  desc.add<edm::InputTag>("lumiScalers", edm::InputTag("scalersRawToDigi"));
28  desc.add<edm::InputTag>("metadata", edm::InputTag("onlineMetaDataDigis"));
29  descriptions.add("tkInstLumiTable", desc);
30  }
31 
32  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
33 
34 private:
38 
41 };
42 
44  auto out = std::make_unique<nanoaod::FlatTable>(1, m_name, true, m_extension);
45 
46  out->addColumnValue<int>("bx", iEvent.bunchCrossing(), "Bunch-crossing ID");
47 
48  float instLumi{0.}, pu{0.};
51 
52  if (lumiScalers.isValid() && !lumiScalers->empty()) {
53  if (lumiScalers->begin() != lumiScalers->end()) {
54  instLumi = lumiScalers->begin()->instantLumi();
55  pu = lumiScalers->begin()->pileup();
56  }
57  } else if (metaData.isValid()) {
58  instLumi = metaData->instLumi();
59  pu = metaData->avgPileUp();
60  } else {
61  edm::LogInfo("TkInstLumiTableProducer")
62  << "Luminosity related collections not found in the event; will write dummy values";
63  }
64 
65  out->addColumnValue<float>("instLumi", instLumi, "Instantaneous luminosity");
66  out->addColumnValue<float>("PU", pu, "Pileup");
67 
68  iEvent.put(std::move(out));
69 }
70 
const edm::EDGetTokenT< LumiScalersCollection > m_scalerToken
Class to contain the online luminosity from soft FED 1022.
float instLumi() const
Return the luminosity for the current nibble.
int iEvent
Definition: GenABIO.cc:224
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Log< level::Info, false > LogInfo
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
const edm::EDGetTokenT< OnlineLuminosityRecord > m_metaDataToken
std::vector< LumiScalers > LumiScalersCollection
Definition: LumiScalers.h:144
TkInstLumiTableProducer(const edm::ParameterSet &params)
float avgPileUp() const
Return the average pileup for th current nibble.
def move(src, dest)
Definition: eostools.py:511