CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DataFormats/Luminosity/src/LumiSummary.cc

Go to the documentation of this file.
00001 
00002 // $Id: LumiSummary.cc,v 1.26 2012/04/17 14:53:33 xiezhen Exp $
00003 
00004 #include "DataFormats/Luminosity/interface/LumiSummary.h"
00005 
00006 #include <iomanip>
00007 #include <ostream>
00008 #include <iostream>
00009 float
00010 LumiSummary::avgInsDelLumi()const{ 
00011   if(lumiversion_=="v2"){
00012     return avginsdellumi_*1000.0;
00013   }
00014   return avginsdellumi_;
00015 }
00016 float
00017 LumiSummary::intgDelLumi()const{
00018   return this->avgInsDelLumi()*float(this->lumiSectionLength());
00019 }
00020 float
00021 LumiSummary::avgInsDelLumiErr()const{ 
00022   return  avginsdellumierr_;
00023 }
00024 float 
00025 LumiSummary::intgRecLumi()const{
00026   return this->avgInsRecLumi()*float(this->lumiSectionLength());
00027 }
00028 short
00029 LumiSummary::lumiSecQual()const {
00030   return lumisecqual_; 
00031 }
00032 unsigned long long
00033 LumiSummary::deadcount() const{
00034   return deadcount_;
00035 }
00036 unsigned long long
00037 LumiSummary::bitzerocount() const{
00038   return bitzerocount_;
00039 }
00040 float 
00041 LumiSummary::deadFrac() const {
00042   //definition: deadcount/bitzerocount
00043   //if no trigger data, return deadfraction 1.0,mask out this LS
00044   //if bitzerocount=0, return -1.0 meaning no beam
00045   if(lumiversion_=="DIP"){
00046     return float(deadcount_)/float(bitzerocount_);
00047   }
00048   if (l1data_.size()==0) return 1.0;
00049   if (bitzerocount_==0) return -1.0;
00050   return float(deadcount_)/float(bitzerocount_);
00051 }
00052 float 
00053 LumiSummary::liveFrac() const { 
00054   //1-deadfraction
00055   //else if deadfraction<0 meaning no beam, live fraction=0
00056   //
00057   if (deadFrac()<0) return 0;
00058   return 1-deadFrac();
00059 }
00060 float
00061 LumiSummary::lumiSectionLength() const {
00062   //numorbits*3564*24.95e-09
00063   return numorbit_*3564.0*24.95e-9;
00064 }
00065 unsigned int 
00066 LumiSummary::lsNumber() const{
00067   return lsnumber_; 
00068 }
00069 unsigned int
00070 LumiSummary::startOrbit() const{
00071   return startorbit_; 
00072 }
00073 unsigned int
00074 LumiSummary::numOrbit() const{
00075   return numorbit_;
00076 }
00077 bool 
00078 LumiSummary::isValid() const {
00079   return avginsdellumi_>0;
00080 }
00081 LumiSummary::L1  
00082 LumiSummary::l1info(unsigned int idx)const{
00083   return l1data_.at(idx);
00084 }
00085 LumiSummary::HLT  
00086 LumiSummary::hltinfo(unsigned int idx) const {
00087   return hltdata_.at(idx);
00088 }
00089 size_t
00090 LumiSummary::nTriggerLine()const{
00091   return l1data_.size();
00092 }
00093 size_t
00094 LumiSummary::nHLTPath()const{
00095   return hltdata_.size();
00096 }
00097 float
00098 LumiSummary::avgInsRecLumi() const {
00099   return this->avgInsDelLumi() * liveFrac(); 
00100 }
00101 float
00102 LumiSummary::avgInsRecLumiErr() const {
00103   return avginsdellumierr_ * liveFrac(); 
00104 }
00105 bool
00106 LumiSummary::isProductEqual(LumiSummary const& next) const {
00107   return (avginsdellumi_ == next.avginsdellumi_ &&
00108           avginsdellumierr_ == next.avginsdellumierr_ &&
00109           lumisecqual_ == next.lumisecqual_ &&
00110           deadcount_ == next.deadcount_ &&
00111           lsnumber_ == next.lsnumber_ &&
00112           startorbit_== next.startorbit_ &&
00113           numorbit_==next.numorbit_&&
00114           l1data_.size() == next.l1data_.size() &&
00115           hltdata_.size() == next.hltdata_.size() &&
00116           lumiversion_ == next.lumiversion_ );
00117 }
00118 std::string 
00119 LumiSummary::lumiVersion()const{
00120   return lumiversion_;
00121 }
00122 void
00123 LumiSummary::setLumiVersion(const std::string& lumiversion){
00124   lumiversion_=lumiversion;
00125 }
00126 void 
00127 LumiSummary::setLumiData(float instlumi,float instlumierr,short lumiquality){
00128   avginsdellumi_=instlumi;
00129   avginsdellumierr_=instlumierr;
00130   lumisecqual_=lumiquality;
00131 }
00132 void 
00133 LumiSummary::setDeadCount(unsigned long long deadcount){
00134   deadcount_=deadcount;
00135 }
00136 void 
00137 LumiSummary::setBitZeroCount(unsigned long long bitzerocount){
00138   bitzerocount_=bitzerocount;
00139 }
00140 void 
00141 LumiSummary::setlsnumber(unsigned int lsnumber){
00142   lsnumber_=lsnumber;
00143 }
00144 void 
00145 LumiSummary::setOrbitData(unsigned int startorbit,unsigned int numorbit){
00146   startorbit_=startorbit;
00147   numorbit_=numorbit;
00148 }
00149 void 
00150 LumiSummary::swapL1Data(std::vector<L1>& l1data){
00151   l1data_.swap(l1data);
00152 }
00153 void 
00154 LumiSummary::swapHLTData(std::vector<HLT>& hltdata){
00155   hltdata_.swap(hltdata);
00156 }
00157 void 
00158 LumiSummary::copyL1Data(const std::vector<L1>& l1data){
00159   l1data_.assign(l1data.begin(),l1data.end());
00160 }
00161 void 
00162 LumiSummary::copyHLTData(const std::vector<HLT>& hltdata){
00163   hltdata_.assign(hltdata.begin(),hltdata.end());
00164 }
00165 std::ostream& operator<<(std::ostream& s, const LumiSummary& lumiSummary) {
00166   s << "\nDumping LumiSummary\n\n";
00167   if(!lumiSummary.isValid()){
00168     s << " === Invalid Lumi values === \n";
00169   }
00170   s << "  lumiVersion = " << lumiSummary.lumiVersion()  << "\n";
00171   s << "  avgInsDelLumi = " << lumiSummary.avgInsDelLumi() << "\n";
00172   s << "  avgIntgDelLumi = " << lumiSummary.intgDelLumi() <<"\n";
00173   s << "  avgInsDelLumiErr = " << lumiSummary.avgInsDelLumiErr() << "\n";
00174   s << "  lumiSecQual = " << lumiSummary.lumiSecQual() << "\n";
00175   s << "  deadCount = " << lumiSummary.deadcount() << "\n";
00176   s << "  bitZeroCount = " << lumiSummary.bitzerocount() << "\n";
00177   s << "  deadFrac = " << (float)lumiSummary.deadFrac() << "\n";
00178   s << "  liveFrac = " << (float)lumiSummary.liveFrac() << "\n";
00179   s << "  lsNumber = " << lumiSummary.lsNumber() << "\n";
00180   s << "  startOrbit = " << lumiSummary.startOrbit() <<"\n";
00181   s << "  numOrbit = " << lumiSummary.numOrbit() <<"\n";
00182   s << "  avgInsRecLumi = " << lumiSummary.avgInsRecLumi() << "\n";
00183   s << "  avgInsRecLumiErr = "  << lumiSummary.avgInsRecLumiErr() << "\n\n";
00184   s << std::setw(15) << "l1nameidx";
00185   s << std::setw(15) << "l1prescale";
00186   s << "\n";
00187   size_t nTriggers=lumiSummary.nTriggerLine();
00188   size_t nHLTPath=lumiSummary.nHLTPath();
00189   for(unsigned int i = 0; i < nTriggers; ++i) {
00190     s << std::setw(15);
00191     s << lumiSummary.l1info(i).triggernameidx;
00192     s << std::setw(15);
00193     s << lumiSummary.l1info(i).prescale;
00194     s<<"\n";
00195   }
00196   s << std::setw(15) << "hltpathidx";
00197   s << std::setw(15) << "hltprescale";
00198   s << "\n";
00199   for(unsigned int i = 0; i < nHLTPath; ++i) {
00200     s << std::setw(15);
00201     s << lumiSummary.hltinfo(i).pathnameidx;
00202     s << std::setw(15);
00203     s << lumiSummary.hltinfo(i).prescale;
00204     s << "\n";
00205   }
00206   return s << "\n";
00207 }