Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:00

0001 
0002 
0003 #include "DataFormats/Luminosity/interface/LumiSummary.h"
0004 
0005 #include <iomanip>
0006 #include <ostream>
0007 #include <iostream>
0008 float LumiSummary::avgInsDelLumi() const {
0009   size_t iIndex = lumiversion_.rfind('v');
0010   //i.e. not "-1" and not "DIP", "-1" and "DIP" lumi are already corrected and unit conversion included in the raw data.
0011   if (iIndex != std::string::npos) {
0012     return avginsdellumi_ * 1000.0;
0013   }
0014   return avginsdellumi_;
0015 }
0016 float LumiSummary::intgDelLumi() const { return this->avgInsDelLumi() * float(this->lumiSectionLength()); }
0017 float LumiSummary::avgInsDelLumiErr() const { return avginsdellumierr_; }
0018 float LumiSummary::intgRecLumi() const { return this->avgInsRecLumi() * float(this->lumiSectionLength()); }
0019 short LumiSummary::lumiSecQual() const { return lumisecqual_; }
0020 unsigned long long LumiSummary::deadcount() const { return deadcount_; }
0021 unsigned long long LumiSummary::bitzerocount() const { return bitzerocount_; }
0022 float LumiSummary::deadFrac() const {
0023   //definition: deadcount/bitzerocount
0024   //if no trigger data, return deadfraction 1.0,mask out this LS
0025   //if bitzerocount=0, return -1.0 meaning no beam
0026   if (lumiversion_ == "DIP") {
0027     return float(deadcount_) / float(bitzerocount_);
0028   }
0029   if (l1data_.empty())
0030     return 1.0;
0031   if (bitzerocount_ == 0)
0032     return -1.0;
0033   return float(deadcount_) / float(bitzerocount_);
0034 }
0035 float LumiSummary::liveFrac() const {
0036   //1-deadfraction
0037   //else if deadfraction<0 meaning no beam, live fraction=0
0038   //
0039   if (deadFrac() < 0)
0040     return 0;
0041   return 1 - deadFrac();
0042 }
0043 float LumiSummary::lumiSectionLength() const {
0044   //numorbits*3564*24.95e-09
0045   return numorbit_ * 3564.0 * 24.95e-9;
0046 }
0047 unsigned int LumiSummary::lsNumber() const { return lsnumber_; }
0048 unsigned int LumiSummary::startOrbit() const { return startorbit_; }
0049 unsigned int LumiSummary::numOrbit() const { return numorbit_; }
0050 bool LumiSummary::isValid() const { return avginsdellumi_ > 0; }
0051 LumiSummary::L1 LumiSummary::l1info(unsigned int idx) const { return l1data_.at(idx); }
0052 LumiSummary::HLT LumiSummary::hltinfo(unsigned int idx) const { return hltdata_.at(idx); }
0053 size_t LumiSummary::nTriggerLine() const { return l1data_.size(); }
0054 size_t LumiSummary::nHLTPath() const { return hltdata_.size(); }
0055 float LumiSummary::avgInsRecLumi() const { return this->avgInsDelLumi() * liveFrac(); }
0056 float LumiSummary::avgInsRecLumiErr() const { return avginsdellumierr_ * liveFrac(); }
0057 bool LumiSummary::isProductEqual(LumiSummary const& next) const {
0058   return (avginsdellumi_ == next.avginsdellumi_ && avginsdellumierr_ == next.avginsdellumierr_ &&
0059           lumisecqual_ == next.lumisecqual_ && deadcount_ == next.deadcount_ && lsnumber_ == next.lsnumber_ &&
0060           startorbit_ == next.startorbit_ && numorbit_ == next.numorbit_ && l1data_.size() == next.l1data_.size() &&
0061           hltdata_.size() == next.hltdata_.size() && lumiversion_ == next.lumiversion_);
0062 }
0063 std::string LumiSummary::lumiVersion() const { return lumiversion_; }
0064 void LumiSummary::setLumiVersion(const std::string& lumiversion) { lumiversion_ = lumiversion; }
0065 void LumiSummary::setLumiData(float instlumi, float instlumierr, short lumiquality) {
0066   avginsdellumi_ = instlumi;
0067   avginsdellumierr_ = instlumierr;
0068   lumisecqual_ = lumiquality;
0069 }
0070 void LumiSummary::setDeadCount(unsigned long long deadcount) { deadcount_ = deadcount; }
0071 void LumiSummary::setBitZeroCount(unsigned long long bitzerocount) { bitzerocount_ = bitzerocount; }
0072 void LumiSummary::setlsnumber(unsigned int lsnumber) { lsnumber_ = lsnumber; }
0073 void LumiSummary::setOrbitData(unsigned int startorbit, unsigned int numorbit) {
0074   startorbit_ = startorbit;
0075   numorbit_ = numorbit;
0076 }
0077 void LumiSummary::swapL1Data(std::vector<L1>& l1data) { l1data_.swap(l1data); }
0078 void LumiSummary::swapHLTData(std::vector<HLT>& hltdata) { hltdata_.swap(hltdata); }
0079 void LumiSummary::copyL1Data(const std::vector<L1>& l1data) { l1data_.assign(l1data.begin(), l1data.end()); }
0080 void LumiSummary::copyHLTData(const std::vector<HLT>& hltdata) { hltdata_.assign(hltdata.begin(), hltdata.end()); }
0081 std::ostream& operator<<(std::ostream& s, const LumiSummary& lumiSummary) {
0082   s << "\nDumping LumiSummary\n\n";
0083   if (!lumiSummary.isValid()) {
0084     s << " === Invalid Lumi values === \n";
0085   }
0086   s << "  lumiVersion = " << lumiSummary.lumiVersion() << "\n";
0087   s << "  avgInsDelLumi = " << lumiSummary.avgInsDelLumi() << "\n";
0088   s << "  avgIntgDelLumi = " << lumiSummary.intgDelLumi() << "\n";
0089   s << "  avgInsDelLumiErr = " << lumiSummary.avgInsDelLumiErr() << "\n";
0090   s << "  lumiSecQual = " << lumiSummary.lumiSecQual() << "\n";
0091   s << "  deadCount = " << lumiSummary.deadcount() << "\n";
0092   s << "  bitZeroCount = " << lumiSummary.bitzerocount() << "\n";
0093   s << "  deadFrac = " << (float)lumiSummary.deadFrac() << "\n";
0094   s << "  liveFrac = " << (float)lumiSummary.liveFrac() << "\n";
0095   s << "  lsNumber = " << lumiSummary.lsNumber() << "\n";
0096   s << "  startOrbit = " << lumiSummary.startOrbit() << "\n";
0097   s << "  numOrbit = " << lumiSummary.numOrbit() << "\n";
0098   s << "  avgInsRecLumi = " << lumiSummary.avgInsRecLumi() << "\n";
0099   s << "  avgInsRecLumiErr = " << lumiSummary.avgInsRecLumiErr() << "\n\n";
0100   s << std::setw(15) << "l1nameidx";
0101   s << std::setw(15) << "l1prescale";
0102   s << "\n";
0103   size_t nTriggers = lumiSummary.nTriggerLine();
0104   size_t nHLTPath = lumiSummary.nHLTPath();
0105   for (unsigned int i = 0; i < nTriggers; ++i) {
0106     s << std::setw(15);
0107     s << lumiSummary.l1info(i).triggernameidx;
0108     s << std::setw(15);
0109     s << lumiSummary.l1info(i).prescale;
0110     s << "\n";
0111   }
0112   s << std::setw(15) << "hltpathidx";
0113   s << std::setw(15) << "hltprescale";
0114   s << "\n";
0115   for (unsigned int i = 0; i < nHLTPath; ++i) {
0116     s << std::setw(15);
0117     s << lumiSummary.hltinfo(i).pathnameidx;
0118     s << std::setw(15);
0119     s << lumiSummary.hltinfo(i).prescale;
0120     s << "\n";
0121   }
0122   return s << "\n";
0123 }