Index: /trunk/FACT++/src/biasctrl.cc
===================================================================
--- /trunk/FACT++/src/biasctrl.cc	(revision 11859)
+++ /trunk/FACT++/src/biasctrl.cc	(revision 11860)
@@ -425,4 +425,26 @@
     }
 
+    bool SetReferenceVoltage(const vector<float> &volt)
+    {
+        if (volt.size()!=kNumChannels)
+        {
+            ostringstream out;
+            out << "SetReferenceVoltage - Given vector has " << volt.size() << " elements - expected " << kNumChannels << endl;
+            Error(out);
+            return false;
+        }
+
+        for (size_t i=0; i<volt.size(); i++)
+            fRefVolt[i] = volt[i]*4096/90;
+
+        return true;
+    }
+
+    void ApplyReferenceVoltage()
+    {
+        for (size_t i=0; i<fRefVolt.size(); i++)
+            SetVoltage(i, fRefVolt[i]);
+    }
+
     void SetVerbose(bool b)
     {
@@ -696,4 +718,8 @@
             ("");
 
+        AddEvent("APPLY_REFERENCE_VOLTAGE", kStateConnected)
+            (Wrapper(bind(&ConnectionBias::ApplyReferenceVoltage, &fBias)))
+            ("");
+
         AddEvent("ADAPT_VOLTAGES", kStateConnected)
             (Wrapper(bind(&ConnectionBias::AdaptVoltages, &fBias)))
@@ -711,4 +737,57 @@
         fBias.SetEndpoint(conf.Get<string>("dev"));
         T::Message("Setting device to "+fBias.URL());
+
+        // --------------------------------------------------------------------------
+
+        ifstream fin("FACTmapV5.txt");
+
+        int l = 0;
+
+        vector<float> vec(ConnectionBias::kNumChannels);
+
+        string buf;
+        while (getline(fin, buf, '\n'))
+        {
+            if (l>1439)
+                break;
+
+            buf = Tools::Trim(buf);
+            if (buf[0]=='#')
+                continue;
+
+            stringstream str(buf);
+
+            int   idummy, board, channel;
+            float fdummy, volt;
+
+            str >> idummy >> idummy >> idummy >> idummy >> idummy;
+            str >> volt;
+            str >> board;
+            str >> channel;
+            str >> fdummy >> fdummy >> fdummy;
+
+            if (channel+32*board>=ConnectionBias::kNumChannels)
+            {
+                T::Error("Invalid board/channel read from FACTmapV5.txt.");
+                return 1;
+            }
+
+            vec[channel+32*board] = volt;
+            l++;
+        }
+
+        if (l!=1440)
+        {
+            T::Error("Reading reference voltages from FACTmapV5.txt failed.");
+            return 2;
+        }
+
+        if (!fBias.SetReferenceVoltage(vec))
+        {
+            T::Error("Setting reference voltages failed.");
+            return 3;
+        }
+
+        // --------------------------------------------------------------------------
 
         fBias.Connect();
