test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
FTSLuminosityFromScalers(edm::ParameterSet const &)
static Type parse(std::string const &type)
edm::EDGetTokenT< LumiScalersCollection > m_token
ParameterDescriptionBase * add(U const &iLabel, T const &value)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void analyze(edm::StreamID sid, edm::Event const &event, const edm::EventSetup &setup) const override
std::vector< LumiScalers > LumiScalersCollection
Definition: LumiScalers.h:160