test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
7 #include <iostream>
9 
13 
15  : lumiInputTag_ ( iConfig.getParameter<edm::InputTag>("lumi") )
16  , lumiScale_ ( iConfig.getParameter<double>("lumiScale") )
17 {
18 }
19 
20 GetLumi::GetLumi(const edm::InputTag& lumiInputTag, double lumiScale)
21  : lumiInputTag_ ( lumiInputTag )
22  , lumiScale_ ( lumiScale )
23 {
24 }
25 
27 {
30 }
31 
32 GetLumi::GetLumi(const edm::InputTag& lumiInputTag, double lumiScale, edm::ConsumesCollector& iC) : GetLumi(lumiInputTag,lumiScale)
33 {
36 }
37 
39 {
40 }
41 
42 double
44 {
45 
46  // taken from
47  // DPGAnalysis/SiStripTools/src/DigiLumiCorrHistogramMaker.cc
48  // the scale factor 6.37 should follow the lumi prescriptions
51 
52 
53  double bxlumi = -1.;
54  if(lumi->isValid()) {
55  bxlumi = lumi->lumiValue(LumiDetails::kOCC1,iEvent.bunchCrossing());
56  }
57 
58  return bxlumi;
59 
60 }
61 
62 
63 double
65 {
66  // bxlumi = lumi->lumiValue(LumiDetails::kOCC1,iEvent.bunchCrossing())*6.37;
67  return getRawValue(iEvent)*lumiScale_;
68 }
69 
70 double
72  edm::EventSetup const&eSetup)
73 {
74 
75  double lumi = -1.;
76  double intDelLumi = -1.;
77 
78  // size_t LS = lumiBlock.luminosityBlockAuxiliary().luminosityBlock();
79  // accumulate HF data at every LS as it is closed.
80  // note: lumi unit from DIPLumiSummary and Detail is microbarns
81  edm::Handle<LumiSummary> lumiSummary_;
82  lumiBlock.getByToken(lumiSummaryToken_, lumiSummary_);
83  if(lumiSummary_->isValid()){
84  lumi = lumiSummary_->avgInsDelLumi();
85  intDelLumi = lumiSummary_->intgDelLumi();
86  std::cout << "Luminosity in this Lumi Section " << lumi << " --> " << intDelLumi << std::endl;
87  } else {
88  std::cout << "No valid data found!" << std::endl;
89  }
90 
91 
92  return lumi;
93 
94 }
95 
96 
97 double
99  edm::EventSetup const&eSetup)
100 {
101  return getRawValue(lumiBlock,eSetup)*lumiScale_;
102 }
103 
104 
105 double
106 GetLumi::convert2PU(double instLumi, double inelastic_xSec = GetLumi::INELASTIC_XSEC_8TeV) // inelastic_xSec in mb
107 {
108 
109  // from https://cmswbm.web.cern.ch/cmswbm/images/pileup.png
110  return instLumi*inelastic_xSec/FREQ_ORBIT;
111 }
112 
113 double
114 GetLumi::convert2PU(double instLumi, int sqrt_s = GetLumi::SQRT_S_8TeV)
115 {
116 
117  double inelastic_xSec = 0.;
118 
119  switch(sqrt_s) {
120  case GetLumi::SQRT_S_7TeV :
121  inelastic_xSec = GetLumi::INELASTIC_XSEC_7TeV;
122  break;
123  case GetLumi::SQRT_S_8TeV :
124  inelastic_xSec = GetLumi::INELASTIC_XSEC_8TeV;
125  break;
126  default :
127  break;
128  }
129 
130  return convert2PU(instLumi,inelastic_xSec);
131 
132 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
tuple lumi
Definition: fjr2json.py:35
static double INELASTIC_XSEC_8TeV
Definition: GetLumi.h:36
static double INELASTIC_XSEC_7TeV
Definition: GetLumi.h:35
int bunchCrossing() const
Definition: EventBase.h:65
edm::EDGetTokenT< LumiDetails > lumiDetailsToken_
Definition: GetLumi.h:70
virtual ~GetLumi()
Definition: GetLumi.cc:38
double getValue(const edm::Event &)
Definition: GetLumi.cc:64
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< LumiSummary > lumiSummaryToken_
Definition: GetLumi.h:71
LuminosityBlock const & getLuminosityBlock() const
Definition: Event.h:85
bool isValid() const
Definition: HandleBase.h:75
double getRawValue(const edm::Event &)
Definition: GetLumi.cc:43
GetLumi(const edm::ParameterSet &)
Definition: GetLumi.cc:14
double convert2PU(double, double)
Definition: GetLumi.cc:106
tuple cout
Definition: gather_cfg.py:145
edm::InputTag lumiInputTag_
Definition: GetLumi.h:67
static double FREQ_ORBIT
Definition: GetLumi.h:32
double lumiScale_
Definition: GetLumi.h:68