CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/DQM/TrackingMonitor/src/GetLumi.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2012/08/23 13:27:32 $
00005  *  $Revision: 1.3 $
00006  *  \author:  Mia Tosi,40 3-B32,+41227671609 
00007  */
00008 
00009 #include "DQM/TrackingMonitor/interface/GetLumi.h"
00010 
00011 #include "FWCore/Framework/interface/LuminosityBlock.h"
00012 #include "DataFormats/Luminosity/interface/LumiDetails.h"
00013 #include "DataFormats/Luminosity/interface/LumiSummary.h"
00014 
00015 GetLumi::GetLumi(const edm::ParameterSet& iConfig)
00016   : lumiInputTag_ ( iConfig.getParameter<edm::InputTag>("lumi")  )
00017   , lumiScale_    ( iConfig.getParameter<double>("lumiScale")    )
00018 {
00019 }
00020 
00021 GetLumi::GetLumi(edm::InputTag lumiInputTag, double lumiScale)
00022   : lumiInputTag_ ( lumiInputTag )
00023   , lumiScale_    ( lumiScale    )
00024 {
00025 }
00026 
00027 GetLumi::~GetLumi()
00028 {
00029 }
00030 
00031 double
00032 GetLumi::getRawValue(const edm::Event& iEvent)
00033 {
00034 
00035   // taken from 
00036   // DPGAnalysis/SiStripTools/src/DigiLumiCorrHistogramMaker.cc
00037   // the scale factor 6.37 should follow the lumi prescriptions
00038   edm::Handle<LumiDetails> lumi;
00039   iEvent.getLuminosityBlock().getByLabel(lumiInputTag_,lumi);
00040 
00041   double bxlumi = -1.;
00042   if(lumi->isValid()) {
00043     bxlumi = lumi->lumiValue(LumiDetails::kOCC1,iEvent.bunchCrossing());
00044   }
00045 
00046   return bxlumi;
00047 
00048 }
00049 
00050 
00051 double
00052 GetLumi::getValue(const edm::Event& iEvent)
00053 {
00054   //    bxlumi = lumi->lumiValue(LumiDetails::kOCC1,iEvent.bunchCrossing())*6.37;
00055   return getRawValue(iEvent)*lumiScale_;
00056 }
00057 
00058 double
00059 GetLumi::getRawValue(edm::LuminosityBlock const& lumiBlock,
00060                      edm::EventSetup const&eSetup)
00061 {
00062   
00063   double lumi = -1.;
00064   double intDelLumi = -1.;
00065 
00066   //  size_t LS = lumiBlock.luminosityBlockAuxiliary().luminosityBlock();
00067   // accumulate HF data at every LS as it is closed. 
00068   // note: lumi unit from DIPLumiSummary and Detail is microbarns
00069   edm::Handle<LumiSummary> lumiSummary_;
00070   lumiBlock.getByLabel(lumiInputTag_, lumiSummary_);
00071   if(lumiSummary_->isValid()){
00072     lumi = lumiSummary_->avgInsDelLumi();
00073     intDelLumi = lumiSummary_->intgDelLumi();
00074     std::cout << "Luminosity in this Lumi Section " << lumi << " --> " << intDelLumi << std::endl;
00075   } else {
00076     std::cout << "No valid data found!" << std::endl;
00077   }
00078 
00079 
00080   return lumi;
00081 
00082 }
00083 
00084 
00085 double
00086 GetLumi::getValue(edm::LuminosityBlock const& lumiBlock,
00087                   edm::EventSetup const&eSetup)
00088 {
00089   return getRawValue(lumiBlock,eSetup)*lumiScale_;
00090 }
00091 
00092 
00093 double
00094 GetLumi::convert2PU(double instLumi, double inelastic_xSec = GetLumi::INELASTIC_XSEC_8TeV) // inelastic_xSec in mb
00095 {
00096 
00097   // from https://cmswbm.web.cern.ch/cmswbm/images/pileup.png
00098   return instLumi*inelastic_xSec/FREQ_ORBIT;
00099 }
00100 
00101 double
00102 GetLumi::convert2PU(double instLumi, int sqrt_s = GetLumi::SQRT_S_8TeV)
00103 {
00104   
00105   double inelastic_xSec = 0.;
00106   
00107   switch(sqrt_s) {
00108   case GetLumi::SQRT_S_7TeV :
00109     inelastic_xSec = GetLumi::INELASTIC_XSEC_7TeV;
00110     break;
00111   case GetLumi::SQRT_S_8TeV :
00112     inelastic_xSec = GetLumi::INELASTIC_XSEC_8TeV;
00113     break;
00114   default :
00115     break;
00116   }
00117   
00118   return convert2PU(instLumi,inelastic_xSec);
00119 
00120 }