CMS 3D CMS Logo

Public Member Functions | Static Public Attributes

PTStatistics Class Reference

#include <PTStatistics.h>

Inheritance diagram for PTStatistics:
vector

List of all members.

Public Member Functions

long double eff (int ptCut)
 PTStatistics ()
long int sum () const
long int sum (const int &ptCut) const
long double sumR () const
long double sumR (const int &ptCut) const
std::string toString ()
void update (PTStatistics &otherPtStats)

Static Public Attributes

static std::vector< long double > m_rates = std::vector<long double>(RPCpg::ptBins_s,0)
static bool rateInitilized = false

Detailed Description

Definition at line 12 of file PTStatistics.h.


Constructor & Destructor Documentation

PTStatistics::PTStatistics ( )

Definition at line 12 of file PTStatistics.cc.

References assign(), i, m_rates, RPCpg::ptBins_s, RPCpg::pts, RPCpg::rate(), and rateInitilized.

                          {
   this->assign(RPCpg::ptBins_s,0);
   
   if(!rateInitilized){
     //std::cout << "Initilizing rates" << std::endl;
     rateInitilized = true;
     m_rates.assign(RPCpg::ptBins_s,0);
     
     // Note bin=0 is empty during generation
     // bin=0 is used only when calculating efficiencies (for storing muons,that werent found)
     for (unsigned int i = 1;i < this->m_rates.size(); ++i ){

        long double low =  RPCpg::pts[i];
        long double high =  RPCpg::pts[i+1];
        long double rt = RPCpg::rate(low)-RPCpg::rate(high);

       /* std::cout << "PtCode " << i
              << " " << low
              << " " << high
              << " " << rt
              << std::endl;*/
        this->m_rates.at(i) = rt;
     }

   }

}

Member Function Documentation

long double PTStatistics::eff ( int  ptCut)

Definition at line 60 of file PTStatistics.cc.

References sum().

                                      {  // ptCut=0 -> total rate
   //int eqOrAbovePtCut = 0;
   //for(unsigned int i=ptCut;i<this->size();++i) eqOrAbovePtCut += this->at(i);
   // return double(eqOrAbovePtCut)/this->sum();
   return double(sum(ptCut))/this->sum();
}
long int PTStatistics::sum ( const int &  ptCut) const

Definition at line 68 of file PTStatistics.cc.

References i, and findQualityFiles::size.

                                                 {
//inline int PTStatistics::sum(const int & ptCut) const{  
   //return std::accumulate(this->begin(),this->end(),0);
   long int eqOrAbovePtCut = 0;
   unsigned int size = this->size();
   //for(unsigned int i=ptCut;i<size;++i) eqOrAbovePtCut += this->at(i);
   for(unsigned int i=ptCut;i<size;++i) eqOrAbovePtCut += (*this)[i];
   return eqOrAbovePtCut;
}
long int PTStatistics::sum ( ) const

Definition at line 79 of file PTStatistics.cc.

References begin, and end.

Referenced by eff().

                                {  
   //return std::accumulate(this->begin(),this->end(),0);
   long int eqOrAbovePtCut = 0;
   //unsigned int size = this->size();
   //for(unsigned int i=ptCut;i<size;++i) eqOrAbovePtCut += this->at(i);
   //for(unsigned int i=ptCut;i<size;++i) eqOrAbovePtCut += (*this)[i];
   PTStatistics::const_iterator it = this->begin();
   PTStatistics::const_iterator itend = this->end();
   for(;it!=itend;++it) eqOrAbovePtCut += *it;
   
   return eqOrAbovePtCut;
}
long double PTStatistics::sumR ( const int &  ptCut) const

Definition at line 92 of file PTStatistics.cc.

References i, m_rates, and findQualityFiles::size.

                                                     { 
   //return std::accumulate(this->begin(),this->end(),0);
   long double eqOrAbovePtCut = 0;
   unsigned int size = this->size();
   //for(unsigned int i=ptCut;i<size;++i) eqOrAbovePtCut += this->at(i);
   for(unsigned int i=ptCut;i<size;++i) eqOrAbovePtCut += (*this)[i]*m_rates[i];
   return eqOrAbovePtCut;
}
long double PTStatistics::sumR ( ) const

Definition at line 101 of file PTStatistics.cc.

References i, m_rates, and findQualityFiles::size.

                                    { 
   //return std::accumulate(this->begin(),this->end(),0);
   long double eqOrAbovePtCut = 0;
   //unsigned int size = this->size();
   //for(unsigned int i=ptCut;i<size;++i) eqOrAbovePtCut += this->at(i);
   //for(unsigned int i=ptCut;i<size;++i) eqOrAbovePtCut += (*this)[i];
   //PTStatistics::const_iterator it = this->begin();
   //PTStatistics::const_iterator itend = this->end();
   //PtCode 0 - muons not found
   unsigned int size = this->size();
   for(unsigned int i=1;i<size;++i) eqOrAbovePtCut += (*this)[i]*m_rates[i];
   //for(;it!=itend;++it) eqOrAbovePtCut += *it*m_rates[i];
   
   return eqOrAbovePtCut;
}
std::string PTStatistics::toString ( )

Definition at line 49 of file PTStatistics.cc.

References asciidump::at, i, and findQualityFiles::size.

                                {
   
   std::stringstream ss;
   ss << "PTStats:";
   for (unsigned int i=0; i<this->size();++i){
      ss << " " << this->at(i);
   }
   
   return ss.str();
}
void PTStatistics::update ( PTStatistics otherPtStats)

Definition at line 40 of file PTStatistics.cc.

References i, and findQualityFiles::size.

                                                    {
   
   for (unsigned int i=0; i<this->size();++i){
      //this->at(i)+=otherPtStats.at(i);
      (*this)[i]+=otherPtStats[i];
   }
   

}

Member Data Documentation

std::vector< long double > PTStatistics::m_rates = std::vector<long double>(RPCpg::ptBins_s,0) [static]

Definition at line 26 of file PTStatistics.h.

Referenced by PTStatistics(), and sumR().

bool PTStatistics::rateInitilized = false [static]

Definition at line 25 of file PTStatistics.h.

Referenced by PTStatistics().