IMP  2.0.0
The Integrative Modeling Platform
Shift.h
Go to the documentation of this file.
1 /**
2  * \file IMP/score_functor/Shift.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_SHIFT_H
9 #define IMPSCORE_FUNCTOR_SHIFT_H
10 
11 #include <IMP/score_functor/score_functor_config.h>
12 #include <IMP/algebra/utility.h>
13 #include <IMP/Model.h>
14 #include <IMP/particle_index.h>
15 IMPSCOREFUNCTOR_BEGIN_NAMESPACE
16 
17 
18 /** A shift the distance by subtracting x0 and pass it to the base
19  class.*/
20 template <class BaseDistanceScore>
21 class Shift: public BaseDistanceScore {
22  typedef BaseDistanceScore P;
23  double x0_;
24 public:
25  Shift(double x0, BaseDistanceScore base): P(base),
26  x0_(x0){}
27  template <unsigned int D>
28  double get_score(Model *m, const base::Array<D, ParticleIndex>&pi,
29  double distance) const {
30  return P::get_score(m,pi, distance-x0_);
31  }
32  template <unsigned int D>
33  DerivativePair get_score_and_derivative(Model *m,
35  double distance) const {
36  return P::get_score_and_derivative(m, p, distance-x0_);
37  }
38  template <unsigned int D>
39  double get_maximum_range(Model *m,
40  const base::Array<D, ParticleIndex>& pi) const {
41  return P::get_maximum_range(m, pi)-x0_;
42  }
43  bool get_is_trivially_zero(Model *m, const ParticleIndexPair& pi,
44  double squared_distance) const {
45  return squared_distance
46  > algebra::get_squared(P::get_maximum_range(m,pi)+x0_);
47  }
48 };
49 
50 IMPSCOREFUNCTOR_END_NAMESPACE
51 
52 #endif /* IMPSCORE_FUNCTOR_SHIFT_H */