CMS 3D CMS Logo

FTSLuminosityFromScalers.cc
Go to the documentation of this file.
1 // C++ headers
2 #include <string>
3 #include <cstring>
4 
5 // CMSSW headers
18 
20 public:
23 
24  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
25 
26 private:
27  enum class Type {
29  Pileup,
30  Invalid = -1
31  };
32 
33  static Type parse(std::string const & type) {
34  if (type == "InstantaneousLuminosity")
36  else if (type == "Pileup")
37  return Type::Pileup;
38  else
39  return Type::Invalid;
40  }
41 
44  unsigned int m_lumi_id;
45 
46  void analyze(edm::StreamID sid, edm::Event const & event, const edm::EventSetup & setup) const override;
47 };
48 
50  m_token(consumes<LumiScalersCollection>(config.getParameter<edm::InputTag>("source"))),
51  m_type(parse(config.getParameter<std::string>("type"))),
52  m_lumi_id((unsigned int) -1)
53 {
54  if (not edm::Service<FastTimerService>().isAvailable())
55  return;
56 
57  std::string const & name = config.getParameter<std::string>("name");
58  std::string const & title = config.getParameter<std::string>("title");
59  std::string const & label = config.getParameter<std::string>("label");
60  double range = config.getParameter<double>("range");
61  double resolution = config.getParameter<double>("resolution");
62 
63  m_lumi_id = edm::Service<FastTimerService>()->reserveLuminosityPlots(name, title, label, range, resolution);
64 }
65 
67 {
68 }
69 
70 void
72 {
73  if (not edm::Service<FastTimerService>().isAvailable())
74  return;
75 
76  double value = 0.;
78  if (event.getByToken(m_token, h_luminosity) and not h_luminosity->empty()) {
79  switch (m_type) {
81  value = h_luminosity->front().instantLumi() * 1.e30;
82  break;
83  case Type::Pileup:
84  value = h_luminosity->front().pileup();
85  break;
86  case Type::Invalid:
87  value = 0.;
88  break;
89  }
90  }
91 
92  edm::Service<FastTimerService>()->setLuminosity(sid, m_lumi_id, value);
93 }
94 
95 void
97  // instantaneous luminosity
98  {
100  desc.add<edm::InputTag>("source", edm::InputTag("scalersRawToDigi"));
101  desc.add<std::string>("type", "InstantaneousLuminosity");
102  desc.add<std::string>("name", "luminosity");
103  desc.add<std::string>("title", "instantaneous luminosity");
104  desc.add<std::string>("label", "instantaneous luminosity [cm^{-2}s^{-1}]");
105  desc.add<double>("range", 8.e33);
106  desc.add<double>("resolution", 1.e31);
107  descriptions.add("ftsLuminosityFromScalers", desc);
108  }
109  // pileup
110  {
112  desc.add<edm::InputTag>("source", edm::InputTag("scalersRawToDigi"));
113  desc.add<std::string>("type", "Pileup");
114  desc.add<std::string>("name", "pileup");
115  desc.add<std::string>("title", "pileup");
116  desc.add<std::string>("label", "pileup");
117  desc.add<double>("range", 40);
118  desc.add<double>("resolution", 1);
119  descriptions.add("ftsPileupFromScalers", desc);
120  }
121 }
122 
123 //define this as a plug-in
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
FTSLuminosityFromScalers(edm::ParameterSet const &)
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
Definition: config.py:1
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
static Type parse(std::string const &type)
edm::EDGetTokenT< LumiScalersCollection > m_token
Definition: value.py:1
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
std::vector< LumiScalers > LumiScalersCollection
Definition: LumiScalers.h:160
void analyze(edm::StreamID sid, edm::Event const &event, const edm::EventSetup &setup) const override
Definition: event.py:1