CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DataFormats/Luminosity/src/LumiSummary.cc

Go to the documentation of this file.
00001 
00002 // $Id: LumiSummary.cc,v 1.21 2010/10/12 10:54:59 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   return avginsdellumi_;
00012 }
00013 float
00014 LumiSummary::intgDelLumi()const{
00015   return avginsdellumi_*float(this->lumiSectionLength());
00016 }
00017 float
00018 LumiSummary::avgInsDelLumiErr()const{ 
00019   return  avginsdellumierr_;
00020 }
00021 float 
00022 LumiSummary::intgRecLumi()const{
00023   return this->avgInsRecLumi() *float(this->lumiSectionLength());
00024 }
00025 short
00026 LumiSummary::lumiSecQual()const {
00027   return lumisecqual_; 
00028 }
00029 unsigned long long
00030 LumiSummary::deadcount() const{
00031   return deadcount_;
00032 }
00033 float 
00034 LumiSummary::deadFrac() const {
00035   //definition: deadcount/bizerocount
00036   //if no trigger data, return deadfraction 1.0,mask out this LS
00037   //if bitzerocount=0, return -1.0 meaning no beam
00038   if (l1data_.size()==0) return 1.0;
00039   if (l1data_.begin()->ratecount==0) return -1.0;
00040   return float(deadcount_)/float(l1data_.begin()->ratecount*l1data_.begin()->prescale);
00041 }
00042 float 
00043 LumiSummary::liveFrac() const { 
00044   //1-deadfraction
00045   //else if deadfraction<0 meaning no beam, live fraction=0
00046   //
00047   if (deadFrac()<0) return 0;
00048   return 1-deadFrac();
00049 }
00050 float
00051 LumiSummary::lumiSectionLength() const {
00052   //numorbits*3564*25e-09
00053   return numorbit_*3564.0*25.0*10e-9;
00054 }
00055 unsigned int 
00056 LumiSummary::lsNumber() const{
00057   return lsnumber_; 
00058 }
00059 unsigned int
00060 LumiSummary::startOrbit() const{
00061   return startorbit_; 
00062 }
00063 unsigned int
00064 LumiSummary::numOrbit() const{
00065   return numorbit_;
00066 }
00067 bool 
00068 LumiSummary::isValid() const {
00069   return (lumiversion_!="-1"); 
00070 }
00071 LumiSummary::L1   
00072 LumiSummary::l1info(const std::string& name) const{
00073   for(std::vector<L1>::const_iterator it=l1data_.begin();it!=l1data_.end();++it){
00074     if(it->triggername==name) return *it;
00075   }
00076   return LumiSummary::L1();
00077 }
00078 LumiSummary::L1  
00079 LumiSummary::l1info(unsigned int idx)const{
00080   return l1data_.at(idx);
00081 }
00082 LumiSummary::HLT  
00083 LumiSummary::hltinfo(unsigned int idx) const {
00084   return hltdata_.at(idx);
00085 }
00086 LumiSummary::HLT  
00087 LumiSummary::hltinfo(const std::string& pathname) const {
00088   for(std::vector<HLT>::const_iterator it=hltdata_.begin();it!=hltdata_.end();++it){
00089     if(it->pathname==pathname) return *it;
00090   }
00091   return LumiSummary::HLT();
00092 }
00093 size_t
00094 LumiSummary::nTriggerLine()const{
00095   return l1data_.size();
00096 }
00097 size_t
00098 LumiSummary::nHLTPath()const{
00099   return hltdata_.size();
00100 }
00101 std::vector<std::string>
00102 LumiSummary::HLTPaths()const{
00103   std::vector<std::string> result;
00104   for(std::vector<HLT>::const_iterator it=hltdata_.begin();it!=hltdata_.end();++it){
00105     result.push_back(it->pathname);
00106   }
00107   return result;
00108 }
00109 float
00110 LumiSummary::avgInsRecLumi() const {
00111   return avginsdellumi_ * liveFrac(); 
00112 }
00113 float
00114 LumiSummary::avgInsRecLumiErr() const {
00115   return avginsdellumierr_ * liveFrac(); 
00116 }
00117 bool
00118 LumiSummary::isProductEqual(LumiSummary const& next) const {
00119   return (avginsdellumi_ == next.avginsdellumi_ &&
00120           avginsdellumierr_ == next.avginsdellumierr_ &&
00121           lumisecqual_ == next.lumisecqual_ &&
00122           deadcount_ == next.deadcount_ &&
00123           lsnumber_ == next.lsnumber_ &&
00124           startorbit_== next.startorbit_ &&
00125           numorbit_==next.numorbit_&&
00126           l1data_.size() == next.l1data_.size() &&
00127           hltdata_.size() == next.hltdata_.size() &&
00128           lumiversion_ == next.lumiversion_ );
00129 }
00130 std::string 
00131 LumiSummary::lumiVersion()const{
00132   return lumiversion_;
00133 }
00134 void
00135 LumiSummary::setLumiVersion(const std::string& lumiversion){
00136   lumiversion_=lumiversion;
00137 }
00138 void 
00139 LumiSummary::setLumiData(float instlumi,float instlumierr,short lumiquality){
00140   avginsdellumi_=instlumi;
00141   avginsdellumierr_=instlumierr;
00142   lumisecqual_=lumiquality;
00143 }
00144 void 
00145 LumiSummary::setDeadtime(unsigned long long deadcount){
00146   deadcount_=deadcount;
00147 }
00148 void 
00149 LumiSummary::setlsnumber(unsigned int lsnumber){
00150   lsnumber_=lsnumber;
00151 }
00152 void 
00153 LumiSummary::setOrbitData(unsigned int startorbit,unsigned int numorbit){
00154   startorbit_=startorbit;
00155   numorbit_=numorbit;
00156 }
00157 void 
00158 LumiSummary::swapL1Data(std::vector<L1>& l1data){
00159   l1data_.swap(l1data);
00160 }
00161 void 
00162 LumiSummary::swapHLTData(std::vector<HLT>& hltdata){
00163   hltdata_.swap(hltdata);
00164 }
00165 void 
00166 LumiSummary::copyL1Data(const std::vector<L1>& l1data){
00167   l1data_.assign(l1data.begin(),l1data.end());
00168 }
00169 void 
00170 LumiSummary::copyHLTData(const std::vector<HLT>& hltdata){
00171   hltdata_.assign(hltdata.begin(),hltdata.end());
00172 }
00173 std::ostream& operator<<(std::ostream& s, const LumiSummary& lumiSummary) {
00174   s << "\nDumping LumiSummary\n\n";
00175   if(!lumiSummary.isValid()){
00176     s << " === Invalid Lumi values === \n";
00177   }
00178   s << "  lumiVersion = " << lumiSummary.lumiVersion()  << "\n";
00179   s << "  avgInsDelLumi = " << lumiSummary.avgInsDelLumi() << "\n";
00180   s << "  avgInsDelLumiErr = " << lumiSummary.avgInsDelLumiErr() << "\n";
00181   s << "  lumiSecQual = " << lumiSummary.lumiSecQual() << "\n";
00182   s << "  deadCount = " << lumiSummary.deadcount() << "\n";
00183   s << "  deadFrac = " << (float)lumiSummary.deadFrac() << "\n";
00184   s << "  liveFrac = " << (float)lumiSummary.liveFrac() << "\n";
00185   s << "  lsNumber = " << lumiSummary.lsNumber() << "\n";
00186   s << "  startOrbit = " << lumiSummary.startOrbit() <<"\n";
00187   s << "  numOrbit = " << lumiSummary.numOrbit() <<"\n";
00188   s << "  avgInsRecLumi = " << lumiSummary.avgInsRecLumi() << "\n";
00189   s << "  avgInsRecLumiErr = "  << lumiSummary.avgInsRecLumiErr() << "\n\n";
00190   s << std::setw(15) << "l1name";
00191   s << std::setw(15) << "l1count";
00192   s << std::setw(15) << "l1prescale";
00193   s << "\n";
00194   size_t nTriggers=lumiSummary.nTriggerLine();
00195   size_t nHLTPath=lumiSummary.nHLTPath();
00196   for(unsigned int i = 0; i < nTriggers; ++i) {
00197     s << std::setw(15);
00198     s << lumiSummary.l1info(i).triggername;
00199     
00200     s << std::setw(15);
00201     s << lumiSummary.l1info(i).ratecount;
00202     
00203     s << std::setw(15);
00204     s << lumiSummary.l1info(i).prescale;
00205     s<<"\n";
00206   }
00207   s << std::setw(15) << "hltpath";
00208   s << std::setw(15) << "hltcount";
00209   s << std::setw(15) << "hltprescale";
00210   s << std::setw(15) << "hltinput";
00211   s << "\n";
00212   for(unsigned int i = 0; i < nHLTPath; ++i) {
00213     s << std::setw(15);
00214     s << lumiSummary.hltinfo(i).pathname;
00215     s << std::setw(15);
00216     s << lumiSummary.hltinfo(i).ratecount;
00217     s << std::setw(15);
00218     s << lumiSummary.hltinfo(i).prescale;
00219     s << std::setw(15);
00220     s << lumiSummary.hltinfo(i).inputcount;
00221     s << "\n";
00222   }
00223   return s << "\n";
00224 }