CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FTSLuminosityFromLumiSummary.cc
Go to the documentation of this file.
1 // C++ headers
2 #include <string>
3 #include <cstring>
4 
5 // CMSSW headers
21 
23 public:
26 
27  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
28 
29 private:
30  enum class Type {
32  Pileup,
33  Invalid = -1
34  };
35 
36  static Type parse(std::string const & type) {
37  if (type == "InstantaneousLuminosity")
39  else if (type == "Pileup")
40  return Type::Pileup;
41  else
42  return Type::Invalid;
43  }
44 
48  unsigned int m_lumi_id;
49  std::vector<double> m_value; // values are per-stream, computed in the StreamBeginLuminosityBlock and used in each event
50 
51  virtual void preallocStreams(unsigned int size) override;
53  virtual void analyze(edm::StreamID sid, edm::Event const & event, const edm::EventSetup & setup) const override;
54 };
55 
57  m_token(consumes<LumiSummary, edm::InLumi>(config.getParameter<edm::InputTag>("source"))),
58  m_cross_section(config.getParameter<double>("crossSection")),
59  m_type(parse(config.getParameter<std::string>("type"))),
60  m_lumi_id((unsigned int) -1)
61 {
62  if (not edm::Service<FastTimerService>().isAvailable())
63  return;
64 
65  std::string const & name = config.getParameter<std::string>("name");
66  std::string const & title = config.getParameter<std::string>("title");
67  std::string const & label = config.getParameter<std::string>("label");
68  double range = config.getParameter<double>("range");
69  double resolution = config.getParameter<double>("resolution");
70 
71  m_lumi_id = edm::Service<FastTimerService>()->reserveLuminosityPlots(name, title, label, range, resolution);
72 }
73 
75 {
76 }
77 
79 {
80  m_value.resize(size, 0.);
81 }
82 
84 {
85  m_value[sid] = 0.;
86 
88  setup.getData(corrector);
89  if (not corrector.isValid()) {
90  edm::LogError("FTSLuminosityFromLumiSummary") << "unable to calibrate the raw luminosity values, please add a LumiCorrectionSource ESProducer to your configuration";
91  return;
92  }
93 
94  edm::Handle<LumiSummary> h_summary;
95  if (lumi.getByToken(m_token, h_summary)) {
96  double correction = corrector->getCorrection(h_summary->avgInsDelLumi());
97  /*
98  std::cerr << "LumiSummary loaded" << std::endl;
99  std::cerr << " uncorrected luminosity: " << h_summary->avgInsDelLumi() << std::endl;
100  std::cerr << " correction factor: " << correction << std::endl;
101  std::cerr << " corrected luminosity: " << h_summary->avgInsDelLumi() * correction * 1.e30 << std::endl;
102  std::cerr << " integrated luminosity: " << h_summary->intgDelLumi() * correction * 1.e30 << std::endl;
103  std::cerr << " colliding bunches: " << corrector->ncollidingbunches() << std::endl;
104  std::cerr << " orbits: " << h_summary->numOrbit() << std::endl;
105  std::cerr << " pileup: " << h_summary->intgDelLumi() * correction * m_cross_section * 1.e3 / h_summary->numOrbit() / corrector->ncollidingbunches() << std::endl;
106  */
107  switch (m_type) {
109  m_value[sid] = h_summary->avgInsDelLumi() * correction * 1.e30;
110  break;
111  case Type::Pileup:
112  // integrated luminosity [nb-1] * pp cross section [mb] * 10^6 nb/mb / 2^18 orbits / number of colliding bunches
113  m_value[sid] = h_summary->intgDelLumi() * correction * m_cross_section * 1.e3 / h_summary->numOrbit() / corrector->ncollidingbunches();
114  break;
115  case Type::Invalid:
116  m_value[sid] = 0.;
117  break;
118  }
119  }
120 }
121 
122 void
124 {
125  if (not edm::Service<FastTimerService>().isAvailable())
126  return;
127 
128  edm::Service<FastTimerService>()->setLuminosity(sid, m_lumi_id, m_value[sid]);
129 }
130 
131 void
133  // instantaneous luminosity
134  {
136  desc.add<edm::InputTag>("source", edm::InputTag("lumiProducer"));
137  desc.add<double>("crossSection", 69.3);
138  desc.add<std::string>("type", "InstantaneousLuminosity");
139  desc.add<std::string>("name", "luminosity");
140  desc.add<std::string>("title", "instantaneous luminosity");
141  desc.add<std::string>("label", "instantaneous luminosity [cm^{-2}s^{-1}]");
142  desc.add<double>("range", 8.e33);
143  desc.add<double>("resolution", 1.e31);
144  descriptions.add("ftsLuminosityFromLumiSummary", desc);
145  }
146  // pileup
147  {
149  desc.add<edm::InputTag>("source", edm::InputTag("lumiProducer"));
150  desc.add<double>("crossSection", 69.3);
151  desc.add<std::string>("type", "Pileup");
152  desc.add<std::string>("name", "pileup");
153  desc.add<std::string>("title", "pileup");
154  desc.add<std::string>("label", "pileup");
155  desc.add<double>("range", 40);
156  desc.add<double>("resolution", 1);
157  descriptions.add("ftsPileupFromLumiSummary", desc);
158  }
159 }
160 
161 //define this as a plug-in
type
Definition: HCALResponse.h:21
edm::EDGetTokenT< LumiSummary > m_token
T getParameter(std::string const &) const
virtual void analyze(edm::StreamID sid, edm::Event const &event, const edm::EventSetup &setup) const override
Evaluator * parse(const T &text)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
tuple lumi
Definition: fjr2json.py:35
virtual void preallocStreams(unsigned int size) override
void getData(T &iHolder) const
Definition: EventSetup.h:67
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 Type parse(std::string const &type)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
FTSLuminosityFromLumiSummary(edm::ParameterSet const &)
virtual void doStreamBeginLuminosityBlock_(edm::StreamID id, edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) override
bool isValid() const
Definition: ESHandle.h:37
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
tuple size
Write out results.