IMP  2.0.1
The Integrative Modeling Platform
WeightScore.h
Go to the documentation of this file.
1 /**
2  * \file IMP/score_functor/WeightScore.h
3  * \brief A Score on the distance between a pair of particles.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPSCORE_FUNCTOR_WEIGHT_SCORE_H
9 #define IMPSCORE_FUNCTOR_WEIGHT_SCORE_H
10 
11 #include <IMP/score_functor/score_functor_config.h>
12 #include <IMP/algebra/utility.h>
13 IMPSCOREFUNCTOR_BEGIN_NAMESPACE
14 
15 
16 /** A shift the distance by subtracting x0 and pass it to the base
17  class.*/
18 template <class BaseDistanceScore>
19 class WeightScore: public BaseDistanceScore {
20  typedef BaseDistanceScore P;
21  double w_;
22 public:
23  WeightScore(double w, BaseDistanceScore base): P(base),
24  w_(w){}
25  template <unsigned int D>
26  double get_score(Model *m, const base::Array<D, ParticleIndex>&pi,
27  double distance) const {
28  return w_*P::get_score(m,pi, distance);
29  }
30  template <unsigned int D>
31  DerivativePair get_score_and_derivative(Model *m,
33  double distance) const {
34  DerivativePair ret=P::get_score_and_derivative(m, p, distance);
35  ret.first*=w_;
36  ret.second*=w_;
37  return ret;
38  }
39 };
40 
41 IMPSCOREFUNCTOR_END_NAMESPACE
42 
43 #endif /* IMPSCORE_FUNCTOR_WEIGHT_SCORE_H */