/** * \file Score.h \brief A class for profile storing and computation * * Copyright 2007-2010 IMP Inventors. All rights reserved. * */ #include #include #include #include #include #define IMP_SAXS_DELTA_LIMIT 1.0e-15 IMPSAXS_BEGIN_NAMESPACE Score::Score(const Profile& exp_profile) : exp_profile_(exp_profile) {} void Score::resample(const Profile& model_profile, Profile& resampled_profile) const { // map of q values for fast search std::map q_mapping; for (unsigned int k=0; k::iterator it = q_mapping.lower_bound(q); if(it == q_mapping.end()) break; unsigned int i = it->second; if(i == 0) { resampled_profile.add_entry(q, model_profile.get_intensity(i)); } else { Float delta_q = model_profile.get_q(i)-model_profile.get_q(i-1); if(delta_q <= 1.0e-16) { resampled_profile.add_entry(q, model_profile.get_intensity(i)); } else { Float alpha = (q - model_profile.get_q(i-1)) / delta_q; if(alpha > 1.0) alpha = 1.0; // handle rounding errors Float intensity = model_profile.get_intensity(i-1) + (alpha)*(model_profile.get_intensity(i) - model_profile.get_intensity(i-1)); resampled_profile.add_entry(q, intensity); } } } } Float Score::compute_scale_factor(const Profile& model_profile, const Float offset) const { Float sum1=0.0, sum2=0.0; unsigned int profile_size = std::min(model_profile.size(), exp_profile_.size()); for (unsigned int k=0; k