diff --git a/src/reference/DotProductDistance.cpp b/src/reference/DotProductDistance.cpp
index 5340689cc68cd1d18c989945ba95ab5626c61721..bfda1290c59aa8a5a51e9189a032ce6c57565405 100644
--- a/src/reference/DotProductDistance.cpp
+++ b/src/reference/DotProductDistance.cpp
@@ -29,7 +29,7 @@ class DotProductDistance : public ArgumentOnlyDistance {
 public:
   explicit DotProductDistance( const ReferenceConfigurationOptions& ro );
   void read( const PDB& );
-  double calc( const std::vector<Value*>& vals, const std::vector<double>& arg, const bool& squared );
+  double calculateArgumentDistance( const std::vector<Value*> & vals, const std::vector<double>& arg, ReferenceValuePack& myder, const bool& squared ) const ;
 };
 
 PLUMED_REGISTER_METRIC(DotProductDistance,"DOTPRODUCT")
@@ -44,9 +44,11 @@ void DotProductDistance::read( const PDB& pdb ){
   readArgumentsFromPDB( pdb );
 }
 
-double DotProductDistance::calc( const std::vector<Value*>& vals, const std::vector<double>& arg, const bool& squared ){
+double DotProductDistance::calculateArgumentDistance( const std::vector<Value*> & vals, const std::vector<double>& arg, 
+                                                      ReferenceValuePack& myder, const bool& squared ) const {
   double dot=0.0; 
   for (unsigned long i=0; i<vals.size(); ++i) dot+=getReferenceArgument(i)*arg[i];
+  for (unsigned long i=0; i<vals.size(); ++i) myder.setArgumentDerivatives( i, -getReferenceArgument(i)/dot );
   return -log(dot);
 }
 
diff --git a/src/reference/ReferenceArguments.h b/src/reference/ReferenceArguments.h
index 96b7a3ce9f4153a14118b53aae61e5609e1bbdee..af56b08c8776bcd467fecce75b62778698c68de7 100644
--- a/src/reference/ReferenceArguments.h
+++ b/src/reference/ReferenceArguments.h
@@ -64,9 +64,6 @@ protected:
   void readArgumentsFromPDB( const PDB& pdb );
 /// Set the values of the colvars based on their current instantanous values (used in Analysis)
   void setReferenceArguments();
-/// Calculate the euclidean/malanobius distance the atoms have moved from the reference
-/// configuration in CV space
-  double calculateArgumentDistance( const std::vector<Value*> & vals, const std::vector<double>& arg, ReferenceValuePack& myder, const bool& squared ) const ;
 public:
   explicit ReferenceArguments( const ReferenceConfigurationOptions& ro );
 /// Get the number of reference arguments
@@ -86,6 +83,9 @@ public:
   const std::vector<double>& getReferenceMetric();
 /// Return names
   const std::vector<std::string>& getArgumentNames();
+/// Calculate the euclidean/malanobius distance the atoms have moved from the reference
+/// configuration in CV space
+  virtual double calculateArgumentDistance( const std::vector<Value*> & vals, const std::vector<double>& arg, ReferenceValuePack& myder, const bool& squared ) const ;
 };
 
 inline