Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed PTStatisitcs class static to const #2776

Merged
merged 1 commit into from
Mar 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Validation/MuonRPCGeometry/interface/PTStatistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class PTStatistics: public std::vector<long long> {
long double eff(int ptCut);
std::string toString();

static bool rateInitilized;
static std::vector<long double> m_rates; // used for pur calculation
static const std::vector<long double> m_rates; // used for pur calculation

};

Expand Down
47 changes: 23 additions & 24 deletions Validation/MuonRPCGeometry/src/PTStatistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,35 @@
//-----------------------------------------------------------------------------
// PTStatistics
//-----------------------------------------------------------------------------
bool PTStatistics::rateInitilized = false;
std::vector<long double> PTStatistics::m_rates = std::vector<long double>(RPCpg::ptBins_s,0);
static std::vector<long double> initializeRates()
{
std::vector<long double> rates(RPCpg::ptBins_s,0);
//std::cout << "Initilizing rates" << std::endl;

// 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 < 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);

PTStatistics::PTStatistics(){
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
/* std::cout << "PtCode " << i
<< " " << low
<< " " << high
<< " " << rt
<< std::endl;*/
this->m_rates.at(i) = rt;
}
rates[i] = rt;
}
return rates;
}

}
const std::vector<long double> PTStatistics::m_rates = initializeRates();

PTStatistics::PTStatistics(){
this->assign(RPCpg::ptBins_s,0);
}

}

void PTStatistics::update(PTStatistics & otherPtStats){

Expand All @@ -51,7 +50,7 @@ std::string PTStatistics::toString(){
std::stringstream ss;
ss << "PTStats:";
for (unsigned int i=0; i<this->size();++i){
ss << " " << this->at(i);
ss << " " << (*this)[i];
}

return ss.str();
Expand Down