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

Made static a member data in DeterministicAnnealing #3579

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions RecoVertex/VertexTools/interface/DeterministicAnnealing.h
Expand Up @@ -54,6 +54,7 @@ class DeterministicAnnealing : public AnnealingSchedule {
};

private:
std::vector<float> theTemperatures;
unsigned int theIndex;
double theChi2cut;
bool theIsAnnealed;
Expand Down
28 changes: 9 additions & 19 deletions RecoVertex/VertexTools/src/DeterministicAnnealing.cc
Expand Up @@ -6,30 +6,20 @@

using namespace std;

namespace {
vector < float > temperatures;
}

DeterministicAnnealing::DeterministicAnnealing ( float cutoff ) :
theTemperatures({256,64,16,4,2,1}),
theIndex(0), theChi2cut ( cutoff*cutoff ), theIsAnnealed ( false )
{
temperatures.push_back(256);
temperatures.push_back(64);
temperatures.push_back(16);
temperatures.push_back(4);
temperatures.push_back(2);
temperatures.push_back(1);
}

DeterministicAnnealing::DeterministicAnnealing( const vector < float > & sched,
float cutoff ) : theIndex(0), theChi2cut ( cutoff*cutoff ), theIsAnnealed ( false )
DeterministicAnnealing::DeterministicAnnealing( const vector < float > & sched, float cutoff ) :
theTemperatures(sched),theIndex(0), theChi2cut ( cutoff*cutoff ), theIsAnnealed ( false )
{
temperatures = sched;
}

void DeterministicAnnealing::anneal()
{
if ( theIndex < ( temperatures.size() - 1 ) )
if ( theIndex < ( theTemperatures.size() - 1 ) )
{
theIndex++;
} else {
Expand Down Expand Up @@ -62,7 +52,7 @@ void DeterministicAnnealing::resetAnnealing()

inline double DeterministicAnnealing::phi( double chi2 ) const
{
return exp ( -.5 * chi2 / temperatures[theIndex] );
return exp ( -.5 * chi2 / theTemperatures[theIndex] );
}

double DeterministicAnnealing::cutoff() const
Expand All @@ -72,12 +62,12 @@ double DeterministicAnnealing::cutoff() const

double DeterministicAnnealing::currentTemp() const
{
return temperatures[theIndex];
return theTemperatures[theIndex];
}

double DeterministicAnnealing::initialTemp() const
{
return temperatures[0];
return theTemperatures[0];
}

bool DeterministicAnnealing::isAnnealed() const
Expand All @@ -88,8 +78,8 @@ bool DeterministicAnnealing::isAnnealed() const
void DeterministicAnnealing::debug() const
{
cout << "[DeterministicAnnealing] schedule=";
for ( vector< float >::const_iterator i=temperatures.begin();
i!=temperatures.end() ; ++i )
for ( vector< float >::const_iterator i=theTemperatures.begin();
i!=theTemperatures.end() ; ++i )
{
cout << *i << " ";
};
Expand Down