CMS 3D CMS Logo

GetLumi.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author: Mia Tosi,40 3-B32,+41227671609
5  */
6 
8 
12 
14  : lumiInputTag_(iConfig.getParameter<edm::InputTag>("lumi")),
15  lumiScale_(iConfig.getParameter<double>("lumiScale")) {}
16 
18  : lumiInputTag_(lumiInputTag), lumiScale_(lumiScale) {}
19 
23 }
24 
29 }
30 
31 GetLumi::~GetLumi() = default;
32 
34  // taken from
35  // DPGAnalysis/SiStripTools/src/DigiLumiCorrHistogramMaker.cc
36  // the scale factor 6.37 should follow the lumi prescriptions
38  iEvent.getLuminosityBlock().getByToken(lumiSummaryToken_, lumi);
39 
40  double bxlumi = -1.;
41  if (lumi->isValid()) {
42  bxlumi = lumi->lumiValue(LumiDetails::kOCC1, iEvent.bunchCrossing());
43  }
44 
45  return bxlumi;
46 }
47 
49  // bxlumi = lumi->lumiValue(LumiDetails::kOCC1,iEvent.bunchCrossing())*6.37;
50  return getRawValue(iEvent) * lumiScale_;
51 }
52 
53 double GetLumi::getRawValue(edm::LuminosityBlock const& lumiBlock, edm::EventSetup const& eSetup) {
54  double lumi = -1.;
55  double intDelLumi = -1.;
56 
57  // size_t LS = lumiBlock.luminosityBlockAuxiliary().luminosityBlock();
58  // accumulate HF data at every LS as it is closed.
59  // note: lumi unit from DIPLumiSummary and Detail is microbarns
60  edm::Handle<LumiSummary> lumiSummary_;
61  lumiBlock.getByToken(lumiSummaryToken_, lumiSummary_);
62  if (lumiSummary_->isValid()) {
63  lumi = lumiSummary_->avgInsDelLumi();
64  intDelLumi = lumiSummary_->intgDelLumi();
65  edm::LogInfo("GetLumi") << "Luminosity in this Lumi Section " << lumi << " --> " << intDelLumi << std::endl;
66  } else {
67  edm::LogWarning("GetLumi") << "No valid data found!" << std::endl;
68  }
69 
70  return lumi;
71 }
72 
73 double GetLumi::getValue(edm::LuminosityBlock const& lumiBlock, edm::EventSetup const& eSetup) {
74  return getRawValue(lumiBlock, eSetup) * lumiScale_;
75 }
76 
78  double inelastic_xSec = GetLumi::INELASTIC_XSEC_8TeV) // inelastic_xSec in mb
79 {
80  // from https://cmswbm.web.cern.ch/cmswbm/images/pileup.png
81  return instLumi * inelastic_xSec / FREQ_ORBIT;
82 }
83 
84 double GetLumi::convert2PU(double instLumi, int sqrt_s = GetLumi::SQRT_S_8TeV) {
85  double inelastic_xSec = 0.;
86 
87  switch (sqrt_s) {
89  inelastic_xSec = GetLumi::INELASTIC_XSEC_7TeV;
90  break;
92  inelastic_xSec = GetLumi::INELASTIC_XSEC_8TeV;
93  break;
94  default:
95  break;
96  }
97 
98  return convert2PU(instLumi, inelastic_xSec);
99 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
bool isValid() const
Definition: LumiSummary.cc:50
float intgDelLumi() const
Definition: LumiSummary.cc:16
static constexpr double FREQ_ORBIT
Definition: GetLumi.h:23
edm::EDGetTokenT< LumiDetails > lumiDetailsToken_
Definition: GetLumi.h:62
virtual ~GetLumi()
double getValue(const edm::Event &)
Definition: GetLumi.cc:48
int iEvent
Definition: GenABIO.cc:224
float avgInsDelLumi() const
Definition: LumiSummary.cc:8
edm::EDGetTokenT< LumiSummary > lumiSummaryToken_
Definition: GetLumi.h:63
static constexpr double INELASTIC_XSEC_7TeV
Definition: GetLumi.h:26
double getRawValue(const edm::Event &)
Definition: GetLumi.cc:33
static constexpr double INELASTIC_XSEC_8TeV
Definition: GetLumi.h:27
Log< level::Info, false > LogInfo
bool getByToken(EDGetToken token, Handle< PROD > &result) const
GetLumi(const edm::ParameterSet &)
Definition: GetLumi.cc:13
double convert2PU(double, double)
Definition: GetLumi.cc:77
HLT enums.
edm::InputTag lumiInputTag_
Definition: GetLumi.h:59
Log< level::Warning, false > LogWarning
double lumiScale_
Definition: GetLumi.h:60