CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FTSLuminosityFromPileupSummaryInfo.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:
28  unsigned int m_lumi_id;
29 
30  void analyze(edm::StreamID sid, edm::Event const & event, const edm::EventSetup & setup) const override;
31 };
32 
34  m_token(consumes<std::vector<PileupSummaryInfo>>(config.getParameter<edm::InputTag>("source"))),
35  m_lumi_id((unsigned int) -1)
36 {
37  if (not edm::Service<FastTimerService>().isAvailable())
38  return;
39 
40  std::string const & name = config.getParameter<std::string>("name");
41  std::string const & title = config.getParameter<std::string>("title");
42  std::string const & label = config.getParameter<std::string>("label");
43  double range = config.getParameter<double>("range");
44  double resolution = config.getParameter<double>("resolution");
45 
46  m_lumi_id = edm::Service<FastTimerService>()->reserveLuminosityPlots(name, title, label, range, resolution);
47 }
48 
50 {
51 }
52 
53 void
55 {
56  if (not edm::Service<FastTimerService>().isAvailable())
57  return;
58 
59  double value = 0.;
61  if (event.getByToken(m_token, h_summary)) {
62  for (PileupSummaryInfo const & pileup: *h_summary) {
63  // only use the in-time pileup
64  if (pileup.getBunchCrossing() == 0) {
65  // use the per-event in-time pileup
66  value = pileup.getPU_NumInteractions();
67  // use the average pileup
68  // value = pileup.getTrueNumInteractions();
69  break;
70  }
71  }
72  }
73 
74  edm::Service<FastTimerService>()->setLuminosity(sid, m_lumi_id, value);
75 }
76 
77 void
80  desc.add<edm::InputTag>("source", edm::InputTag("addPileupInfo"));
81  desc.add<std::string>("name", "pileup");
82  desc.add<std::string>("title", "in-time pileup");
83  desc.add<std::string>("label", "in-time pileup");
84  desc.add<double>("range", 40);
85  desc.add<double>("resolution", 1);
86  descriptions.add("ftsLuminosityFromPileupSummaryInfo", desc);
87 }
88 
89 //define this as a plug-in
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
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > m_token
void analyze(edm::StreamID sid, edm::Event const &event, const edm::EventSetup &setup) const override
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 setup(std::vector< TH2F > &depth, std::string name, std::string units="")