Index: trunk/FACT++/src/datalogger.cc
===================================================================
--- trunk/FACT++/src/datalogger.cc	(revision 14214)
+++ trunk/FACT++/src/datalogger.cc	(revision 14217)
@@ -80,8 +80,8 @@
 #include "DimNetwork.h"
 
-
 #ifdef HAVE_FITS
 #include "Fits.h"
 #endif
+
 
 //Dim structures
@@ -99,36 +99,12 @@
 ///Run number record. Used to keep track of which run numbers are still active
 struct RunNumberType {
-#ifdef RUN_LOGS
-    ///the run number log file
-    shared_ptr<ofstream> logFile;
-#endif
-    ///the run number report file
-    shared_ptr<ofstream> reportFile;
-#ifdef HAVE_FITS
-    ///the run number group fits file
-    shared_ptr<CCfits::FITS> runFitsFile;
-#endif
-#ifdef RUN_LOGS
-    ///the log filename
-    string logName;
-#endif
-    ///the report filename
-    string reportName;
+
     ///the actual run number
     int32_t runNumber;
     ///the time at which the run number was received
     Time time;
-    ///list of opened fits used to create the fits grouping when the run ends
-    map<string, vector<string> > openedFits;
     ///default constructor
     RunNumberType()
     {
-#ifdef RUN_LOGS
-        logFile = shared_ptr<ofstream>(new ofstream());
-#endif
-        reportFile = shared_ptr<ofstream>(new ofstream());
-#ifdef HAVE_FITS
-        runFitsFile = shared_ptr<CCfits::FITS>();
-#endif
         runNumber = 0;
     }
@@ -137,15 +113,4 @@
     {
 
-    }
-
-    void addServiceToOpenedFits(const string& fileName, const string& serviceName)
-    {
-         //most likely I should add this service name.
-         //the only case for which I should not add it is if a service disapeared, hence the file was closed
-         //and reopened again. Unlikely to happen, but well it may
-
-         if (find(openedFits[fileName].begin(), openedFits[fileName].end(),
-                  serviceName)==openedFits[fileName].end())
-            openedFits[fileName].push_back(serviceName);
     }
 };
@@ -156,6 +121,4 @@
     ///Nightly FITS output file
     Fits    nightlyFile;
-    ///run-specific FITS output file
-    Fits    runFile;
 #endif
     ///the server
@@ -171,10 +134,8 @@
     ///whether or not the fits buffer was allocated already
     bool fitsBufferAllocated;
-
     ///the actual dimInfo pointer (must be the last in the list to ensure
     /// that it is the first which is deleted -- and consequently none of
     /// the other members can still be in use in an infoHandler)
     shared_ptr<DimStampedInfo> dimInfo;
-
     ///Dim info constructor
     SubscriptionType(DimStampedInfo* info=NULL)
@@ -189,5 +150,4 @@
         dimInfo = shared_ptr<DimStampedInfo>(info);
     }
-
     ///default destructor
     ~SubscriptionType()
@@ -284,5 +244,5 @@
 #ifdef HAVE_FITS
     ///Open fits files
-    void OpenFITSFiles(SubscriptionType& sub, RunNumberType* cRunNumber);
+    void OpenFITSFiles(SubscriptionType& sub);
     ///Write data to FITS files
     void WriteToFITS(SubscriptionType& sub);
@@ -313,5 +273,4 @@
     ///configuration flags
     bool fDebugIsOn;
-//    float fStatsPeriodDuration;
     bool fOpenedFilesIsOn;
     bool fNumSubAndFitsIsOn;
@@ -331,5 +290,5 @@
     map<string, vector<string> > fOpenedNightlyFits;
     ///creates a group fits file based on a list of files to be grouped
-    void CreateFitsGrouping(map<string, vector<string> >& filesToGroup, int runNumber);
+    void CreateFitsGrouping(map<string, vector<string> >& filesToGroup);
 
     bool OpenStreamImp(ofstream &stream, const string &filename, bool mightbeopen);
@@ -349,7 +308,7 @@
     void AppendYearMonthDaytoPath(string& path);
     ///Form the files path
-    string CompileFileNameWithPath(const string &path, const string &service, const string & extension, uint32_t run=0/*, const Time &time=Time()*/);
+    string CompileFileNameWithPath(const string &path, const string &service, const string & extension);
     ///Form the file names only
-    string CompileFileName(const string& service, const string& extension, uint32_t run=0, const Time& time=Time()) const;
+    string CompileFileName(const string& service, const string& extension, const Time& time=Time()) const;
     ///Check whether service is in black and/or white list
     bool ShouldSubscribe(const string& server, const string& service);
@@ -498,5 +457,5 @@
 void DataLogger::RemoveService(string server, string service, bool isCmd)
 {
-    Info("Got request for removing service: "+server+"/"+service);
+    Info("Got request to remove service: "+server+"/"+service);
     if (fDestructing)//this function is called by the super class, after the destructor has deleted its own subscriptions
         return;
@@ -666,6 +625,5 @@
 //! @param extension the extension to add, if any
 //
-//string DataLogger::CompileFileName(const string &path, const string &service, const string & extension, const Time &time)
-string DataLogger::CompileFileName(const string& service, const string& extension, uint32_t run, const Time& time) const
+string DataLogger::CompileFileName(const string& service, const string& extension, const Time& time) const
 {
     ostringstream str;
@@ -674,7 +632,4 @@
     str << ftime.NightAsInt();
 
-    if (run>0)
-        str << '_' << setfill('0') << setw(3) << run;
-
     if (!service.empty())
         str << '.' << service;
@@ -686,5 +641,5 @@
 }
 
-string DataLogger::CompileFileNameWithPath(const string& path, const string& service, const string& extension, uint32_t run/*, const Time& time*/)
+string DataLogger::CompileFileNameWithPath(const string& path, const string& service, const string& extension)
 {
     ostringstream str;
@@ -702,5 +657,5 @@
         CreateDirectory(str.str());
 
-    str << '/' << CompileFileName(service, extension, run, time);
+    str << '/' << CompileFileName(service, extension, time);
 
     return str.str();
@@ -733,18 +688,4 @@
         Debug(str);
     }
-    CreateFitsGrouping(fRunNumber.front().openedFits, fRunNumber.front().runNumber);
-
-    //crawl through the subscriptions to see if there are still corresponding fits files opened.
-    for (SubscriptionsListType::iterator x=fServiceSubscriptions.begin();
-         x!=fServiceSubscriptions.end(); x++)
-        for (map<string, SubscriptionType>::iterator y=x->second.begin();
-             y!=x->second.end(); y++)
-            if (y->second.runFile.fRunNumber == fRunNumber.front().runNumber && y->second.runFile.IsOpen())
-            {
-                y->second.runFile.Close();
-            }
-    //if a grouping file is on, decrease the number of opened fits manually
-    if (fRunNumber.front().runFitsFile)
-        (fNumSubAndFitsData.numOpenFits)--;
     //remove the entry
     fRunNumber.pop_front();
@@ -787,13 +728,5 @@
         (bind(&DataLogger::GoToReady, this))
         ("Stop all data logging, close all files.");
-/*
-    AddEvent(kSM_Logging, "START_RUN", kSM_WaitingRun, kSM_BadRunConfig)
-        (bind(&DataLogger::StartRun, this))
-        ("Start the run logging. Run file location must be specified already.");
-
-    AddEvent(kSM_WaitingRun, "STOP_RUN", kSM_Logging)
-        (bind(&DataLogger::StopRunLogging, this))
-        ("Wait for a run to be started, open run-files as soon as a run number arrives.");
-*/
+
     AddEvent("RESET", kSM_Error, kSM_BadFolder, kSM_DailyWriteError, kSM_RunWriteError)
         (bind(&DataLogger::GoToReady, this))
@@ -808,16 +741,4 @@
         ("Go from the wait for run to nightly open state.");
 
-    /*
-    // Add the possible configurations for this machine
-    AddEvent("SET_FOLDER", "C", kSM_Ready, kSM_BadNightlyConfig)
-        (bind(&DataLogger::ConfigureNightlyFileName, this, placeholders::_1))
-        ("Configure the base folder for the nightly files."
-         "|Path[string]:Absolute or relative path name where the nightly files should be stored.");
-
-    AddEvent("SET_RUN_FOLDER", "C", kSM_Ready, kSM_BadNightlyConfig, kSM_NightlyOpen, kSM_WaitingRun, kSM_BadRunConfig)
-        (bind(&DataLogger::ConfigureRunFileName, this, placeholders::_1))
-        ("Configure the base folder for the run files."
-         "|Path[string]:Absolute or relative path name where the run files should be stored.");
-     */
      // Provide a print command
      AddEvent("PRINT_INFO")
@@ -909,15 +830,4 @@
     fDestructing = true;
 
-    //first, let's backup the datalogger/message service subscription
-//    shared_ptr<DimStampedInfo> messageBackup;
-//    const SubscriptionsListType::iterator x = fServiceSubscriptions.find("DATA_LOGGER");
-//    if (x != fServiceSubscriptions.end())
-//    {
-//        const map<string, SubscriptionType>::iterator y = x->second.find("MESSAGE");
-//        if (y != x->second.end())
-//            messageBackup = y->second.dimInfo;
-//    }
-
-
     //now clear the services subscriptions
     dim_lock();
@@ -933,5 +843,4 @@
     GoToReady();
 
-
     Info("Will soon close the daily log file");
 
@@ -940,14 +849,8 @@
     delete fNumSubAndFits;
 
-    //release message service before closing nightly log file
-//    if (messageBackup)
- //       messageBackup.reset();
-
     if (fNightlyLogFile.is_open())//this file is the only one that has not been closed by GoToReady
     {
-//        dim_lock();
         fNightlyLogFile << endl;
         fNightlyLogFile.close();
-//        dim_unlock();
     }
 
@@ -984,5 +887,7 @@
         SetCurrentState(Start());
     }
-    else {if (GetCurrentState() > kSM_Ready)
+    else
+    {
+        if (GetCurrentState() > kSM_Ready)
             fAutoStarted = true;
     }
@@ -1022,7 +927,7 @@
         return;
     }
-        // Make sure that getTimestampMillisecs is NEVER called before
-        // getTimestamp is properly called
-        // check that the message has been updated by something, i.e. must be different from its initial value
+    // Make sure that getTimestampMillisecs is NEVER called before
+    // getTimestamp is properly called
+    // check that the message has been updated by something, i.e. must be different from its initial value
     if (I->getTimestamp() == 0)
     {
@@ -1046,34 +951,4 @@
 // --------------------------------------------------------------------------
 //
-//! Open the text files associated with the given run number
-//! @param run the run number to be dealt with
-//
-int DataLogger::OpenRunFile(RunNumberType& run)
-{
-#ifdef RUN_LOGS
-    // open log file
-    run.logName = CompileFileName(fFilePath, "", "log", run.runNumber);
-    if (!OpenStream(run.logFile, run.logName))
-        return -1;
-#endif
-
-    // open report file
-    run.reportName = CompileFileNameWithPath(fFilePath, "", "rep", run.runNumber);
-    if (!OpenStream(run.reportFile, run.reportName))
-        return -1;
-
-    //get the size of the newly opened file.
-#ifdef RUN_LOGS
-    fFilesStats.FileOpened(run.logName);
-#endif
-    fFilesStats.FileOpened(run.reportName);
-    //TODO this notification scheme might be messed up now.... fix it !
-    const string baseFileName = CompileFileNameWithPath(fFilePath, "", "", run.runNumber);
-    NotifyOpenedFile(baseFileName, 3, fOpenedRunFiles);
-    run.openedFits.clear();
-    return 0;
-}
-// --------------------------------------------------------------------------
-//
 //! Add a new active run number
 //! @param newRun the new run number
@@ -1114,26 +989,4 @@
     if (GetCurrentState() != kSM_Logging && GetCurrentState() != kSM_WaitingRun )
         return;
-    //open the log and report files
-    if (fRunNumber.back().runNumber > 0)
-    if (OpenRunFile(fRunNumber.back()) != 0)
-    {//an error occured. close current run files and go to error state
-        for (list<RunNumberType>::iterator it=fRunNumber.begin(); it != fRunNumber.end(); it++)
-        {
-            if (it->reportFile->is_open())
-            {
-                it->reportFile->close();
-                Info("Closed: "+it->reportName);
-            }
-#ifdef RUN_LOGS
-            if (it->logFile->is_open())
-            {
-                it->logFile->close();
-                Info("Closed: "+it->logName);
-            }
-#endif
-        }
-        StopRunLogging();
-        SetCurrentState(kSM_BadFolder);
-    }
 
     if (newRun > 0 && GetCurrentState()  == kSM_WaitingRun)
@@ -1207,5 +1060,4 @@
     }
 
-//    if (Time().h() == 12 && !fDailyFileDayChangedAlready)
     if (newDayNumber !=  fCurrentDay)
     {
@@ -1249,10 +1101,5 @@
             return;
         }
-
- //       fDailyFileDayChangedAlready = true;
-    }
-//    if (Time().h() != 12 && fDailyFileDayChangedAlready)
-//        fDailyFileDayChangedAlready = false;
-
+    }
     //create the converter for that service
     if (!sub.fConv)
@@ -1282,42 +1129,4 @@
     fMjD = cTime.Mjd() ? cTime.Mjd()-40587 : 0;
 
-    //figure out which run file should be used
-    ofstream* targetRunFile = NULL;
-    RunNumberType* cRunNumber = NULL;
-    if (GetCurrentState() == kSM_Logging || GetCurrentState() == kSM_WaitingRun)
-    {
-        list<RunNumberType>::reverse_iterator rit;
-        for (rit=fRunNumber.rbegin(); rit!=fRunNumber.rend(); rit++)
-        {
-            if (rit->time < cTime) //this is the run number that we want to use
-            {
-                //Find something better to convert iterator to pointer than the ugly line below....
-                cRunNumber = &(*rit);
-                sub.runNumber = rit->runNumber;
-
-                if (rit->runNumber <= 0)//take only positive numbers.
-                    break;
-#ifdef RUN_LOGS
-                targetRunFile = isItaReport ? (rit->reportFile).get() : (rit->logFile).get();
-#else
-                targetRunFile = isItaReport ? (rit->reportFile).get() : NULL;
-#endif
-                break;
-            }
-        }
-        if (rit == fRunNumber.rend() && fRunNumber.size() != 0)
-        {
-            Error("Could not find an appropriate run number for info coming at time "+cTime.GetAsStr());
-            Error("Active run numbers: ");
-            for (rit=fRunNumber.rbegin(); rit != fRunNumber.rend(); rit++)
-            {
-                ostringstream str;
-                str << " -> " << rit->runNumber;
-                Error(str);
-            }
-
-        }
-    }
-
     if (isItaReport)
     {
@@ -1342,7 +1151,4 @@
             //because these operators use references to elements, and because they're supposed here to erase these objects on the way, I'm not too sure... so duplicate the names !
             RemoveService(sub.server, sub.service, false);
-//            string server = sub.server;
-//            string service = sub.service;
-//            fServiceSubscriptions.find(server)->second.erase(service);
             return;
         }
@@ -1366,23 +1172,11 @@
                 return;
         }
-        //write entry to run-report
-        if (targetRunFile && targetRunFile->is_open())
-        {
-            *targetRunFile << header.str() << text << endl;
-            if (!CheckForOfstreamError(*targetRunFile, false))
-                return;
-        }
 #ifdef HAVE_FITS
         //check if the last received event was before noon and if current one is after noon.
         //if so, close the file so that it gets reopened.
-//        if (sub.nightlyFile.IsOpen())
-//            if ((sub.lastReceivedEvent != Time::None) && (sub.lastReceivedEvent.h() < 12) && (cTime.h() >= 12))
-//            {
-//                sub.nightlyFile.Close();
-//            }
-        sub.lastReceivedEvent = cTime;//ici
-        if (!sub.nightlyFile.IsOpen() || !sub.runFile.IsOpen() || sub.runNumber != sub.runFile.fRunNumber)
+        sub.lastReceivedEvent = cTime;
+        if (!sub.nightlyFile.IsOpen())
             if (GetCurrentState() != kSM_Ready)
-                OpenFITSFiles(sub, cRunNumber);
+                OpenFITSFiles(sub);
         WriteToFITS(sub);
 #endif
@@ -1404,7 +1198,4 @@
             //because these operators use references to elements, and because they're supposed here to erase these objects on the way, I'm not too sure... so duplicate the names !
             RemoveService(sub.server, sub.service, false);
-//            string server = sub.server;
-//            string service = sub.service;
-//            fServiceSubscriptions.find(server)->second.erase(service);
             return;
         }
@@ -1424,15 +1215,9 @@
                 return;
         }
-        if (targetRunFile && targetRunFile->is_open())
-        {
-            MessageImp(*targetRunFile).Write(cTime, msg.str().c_str(),  fQuality);
-            if (!CheckForOfstreamError(*targetRunFile, false))
-                return;
-        }
-
-        sub.lastReceivedEvent = cTime;//ici
-        if (!sub.nightlyFile.IsOpen() || !sub.runFile.IsOpen() || sub.runNumber != sub.runFile.fRunNumber)
+
+        sub.lastReceivedEvent = cTime;
+        if (!sub.nightlyFile.IsOpen())
             if (GetCurrentState() != kSM_Ready)
-                OpenFITSFiles(sub, cRunNumber);
+                OpenFITSFiles(sub);
         WriteToFITS(sub);
     }
@@ -1482,14 +1267,4 @@
         Message("Nightly report-file: "+fFullNightlyReportFileName);
 
-    for (list<RunNumberType>::const_iterator it=fRunNumber.begin(); it!=fRunNumber.end(); it++)
-    {
-#ifdef RUN_LOGS
-        if (it->logFile->is_open())
-            Message("Run log-file:    " + it->logName);
-#endif
-        if (it->reportFile->is_open())
-            Message("Run report-file: " + it->reportName);
-    }
-
     const DimWriteStatistics::Stats statVar = fFilesStats.GetTotalSizeWritten();
  //   /*const bool statWarning =*/ calculateTotalSizeWritten(statVar, true);
@@ -1670,37 +1445,4 @@
 // --------------------------------------------------------------------------
 //
-//!    Sets the path to use for the Nightly log file.
-//! @param evt
-//!     the event transporting the path
-//! @returns
-//!        currently only the current state.
-/*
-int DataLogger::ConfigureFilePath(const Event& evt)
-{
-    if (!evt.GetText())
-    {
-        Error("Empty folder given. Please specify a valid path.");
-        return GetCurrentState();
-    }
-
-    const string givenPath = evt.GetText();
-    if (!DoesPathExist(givenPath))
-    {
-        Error("Provided path '"+givenPath+"' is not a valid folder... ignored.");
-        return GetCurrentState();
-    }
-
-    Message("New folder: "+givenPath);
-
-    fFilePath = givenPath;
-
-    fFilesStats.SetCurrentFolder(givenPath);
-
-    return GetCurrentState();
-}
-*/
-
-// --------------------------------------------------------------------------
-//
 //! Notifies the DIM service that a particular file was opened
 //! @ param name the base name of the opened file, i.e. without path nor extension. 
@@ -1783,28 +1525,8 @@
 //! @param sub
 //!     the current DimInfo subscription being examined
-void DataLogger::OpenFITSFiles(SubscriptionType& sub, RunNumberType* cRunNumber)
+void DataLogger::OpenFITSFiles(SubscriptionType& sub)
 {
     string serviceName(sub.dimInfo->getName());
 
-    //if run number has changed, reopen a new fits file with the correct run number.
-     if (sub.runFile.IsOpen() && sub.runFile.fRunNumber != sub.runNumber)
-     {
-         sub.runFile.Close();
-         Info("Closed: "+sub.runFile.GetName()+" (new run number)");
-     }
-
-     //we must check if we should group this service subscription to a single fits file before we replace the / by _
-    bool hasGrouping = false;
-    if (!sub.runFile.IsOpen() && ((GetCurrentState() == kSM_Logging) || (GetCurrentState() == kSM_WaitingRun)))
-    {//will we find this service in the grouping list ?
-        for (set<string>::const_iterator it=fGrouping.begin(); it!=fGrouping.end(); it++)
-        {
-            if (serviceName.find(*it) != string::npos)
-            {
-                hasGrouping = true;
-                break;
-            }
-        }
-    }
     for (unsigned int i=0;i<serviceName.size(); i++)
     {
@@ -1843,66 +1565,5 @@
             fNumSubAndFits->Update();
     }
-    //do the actual file open
-    if (!sub.runFile.IsOpen() && (GetCurrentState() == kSM_WaitingRun || GetCurrentState() == kSM_Logging) && sub.runNumber > 0)
-    {//buffer for the run file have already been allocated when doing the Nightly file
-
-        const string partialName =
-            CompileFileNameWithPath(fFilePath, hasGrouping ? "" : serviceName, "fits", sub.runNumber);
-
-        const string fileNameOnly =
-            partialName.substr(partialName.find_last_of('/')+1, partialName.size());
-
-        //get the size of the file we're about to open
-        if (fFilesStats.FileOpened(partialName))
-            cRunNumber->openedFits[fileNameOnly].push_back(serviceName);
-        else
-            if (hasGrouping)
-            {
-             cRunNumber->addServiceToOpenedFits(fileNameOnly, serviceName);
-            }
-
-        if (hasGrouping && (!cRunNumber->runFitsFile.get()))
-            try
-            {
-                cRunNumber->runFitsFile = shared_ptr<CCfits::FITS>(new CCfits::FITS(partialName, CCfits::RWmode::Write));
-                (fNumSubAndFitsData.numOpenFits)++;
-            }    
-            catch (CCfits::FitsException e)
-            {
-                ostringstream str;
-                str << "Open FITS file " << partialName << ": " << e.message();
-                Error(str);
-                cRunNumber->runFitsFile = shared_ptr<CCfits::FITS>();
-                GoToRunWriteErrorState();
-                return;
-            }
-
-        const string baseFileName = CompileFileNameWithPath(fFilePath, "", "", sub.runNumber);
-        NotifyOpenedFile(baseFileName, 7, fOpenedRunFiles);
-
-        if (hasGrouping)
-        {
-            if (!sub.runFile.Open(partialName, serviceName, &fNumSubAndFitsData.numOpenFits, this, sub.runNumber, cRunNumber->runFitsFile.get()))
-            {
-                GoToRunWriteErrorState();
-                return;
-            }
-        }
-        else
-        {
-            if (!sub.runFile.Open(partialName, serviceName, &fNumSubAndFitsData.numOpenFits, this, sub.runNumber))
-            {
-                GoToRunWriteErrorState();
-                return;
-            }
-        }
-
-        ostringstream str;
-        str << "Opened: " << partialName << " (Nfits=" << fNumSubAndFitsData.numOpenFits << ")";
-        Info(str);
-
-        if (fNumSubAndFitsIsOn)
-            fNumSubAndFits->Update();
-    }
+
 }    
 // --------------------------------------------------------------------------
@@ -1916,9 +1577,7 @@
     Description dateDesc(string("Time"), string("Modified Julian Date"), string("MJD"));
     sub.nightlyFile.AddStandardColumn(dateDesc, "1D", &fMjD, sizeof(double));
-    sub.runFile.AddStandardColumn(dateDesc, "1D", &fMjD, sizeof(double));
 
     Description QoSDesc("QoS", "Quality of service", "");
     sub.nightlyFile.AddStandardColumn(QoSDesc, "1J", &fQuality, sizeof(int));
-    sub.runFile.AddStandardColumn(QoSDesc, "1J", &fQuality, sizeof(int));
 
     // Compilation failed
@@ -1937,5 +1596,4 @@
     Info(str);
     sub.nightlyFile.InitDataColumns(GetDescription(sub.server, sub.service), dataFormatsLocal, sub.dimInfo->getData(), this);
-    sub.runFile.InitDataColumns(GetDescription(sub.server, sub.service), dataFormatsLocal, sub.dimInfo->getData(), this);
 
     sub.fitsBufferAllocated = true;
@@ -1952,22 +1610,9 @@
             if (!sub.nightlyFile.Write(*sub.fConv.get()))
             {
-                //sub.nightlyFile.Close();
                 RemoveService(sub.server, sub.service, false);
                 GoToNightlyWriteErrorState();
                 return;
             }
- //           sub.nightlyFile.Flush();
          }
-
-        if (sub.runFile.IsOpen())
-        {
-            if (!sub.runFile.Write(*sub.fConv.get()))
-            {
-                sub.runFile.Close();
-                RemoveService(sub.server, sub.service, false);
-                GoToRunWriteErrorState();
-                return;
-            }
-        }
 }
 #endif //if has_fits
@@ -1992,29 +1637,5 @@
 }
 
-/*
-// --------------------------------------------------------------------------
-//
-//! Implements the StartRun transition.
-//! Concatenates the given path for the run file and the filename itself (based on the run number),
-//! and tries to open it.
-//! @returns
-//!        kSM_Logging if success, kSM_BadRunConfig if failure.
-int DataLogger::StartRun()
-{
-    if (fDebugIsOn)
-    {
-        Debug("Starting Run Logging...");    
-    }
-    //open all the relevant run-files. i.e. all the files associated with run numbers.
-    for (list<RunNumberType>::iterator it=fRunNumber.begin(); it != fRunNumber.end(); it++)
-        if (OpenRunFile(*it) != 0)
-        {
-            StopRun();
-            return kSM_BadRunConfig;
-        }
-
-    return kSM_Logging;
-}
-*/
+
 #ifdef HAVE_FITS
 // --------------------------------------------------------------------------
@@ -2025,14 +1646,10 @@
 //! @param runNumber the run number that should be used for grouping. 0 means nightly group
 //
-void DataLogger::CreateFitsGrouping(map<string, vector<string> > & filesToGroup, int runNumber)
+void DataLogger::CreateFitsGrouping(map<string, vector<string> > & filesToGroup)
 {
     if (fDebugIsOn)
     {
         ostringstream str;
-        str << "Creating fits group for ";
-        if (runNumber != 0)
-            str << "run files";
-        else
-            str << "nightly files";
+        str << "Creating fits group for nightly files";
         Debug(str);
     }
@@ -2064,10 +1681,10 @@
         return;
     }
-    const string groupName = CompileFileNameWithPath(fFilePath, "", "fits", runNumber);
+    const string groupName = CompileFileNameWithPath(fFilePath, "", "fits");
 
     Info("Creating FITS group in: "+groupName);
 
     CCfits::Table* groupTable;
-//    const int maxCharLength = FILENAME_MAX;
+
     try
     {
@@ -2122,6 +1739,4 @@
     char *startOfLocation  = realBuffer.data()+8+3;
     char *startOfName      = realBuffer.data()+8+3+maxCharLength;
- //   char* startOfMemVer    = reinterpret_cast<char*>(&fitsBuffer[8+3+2*maxCharLength]);
- //   char* startOfMemPos    = reinterpret_cast<char*>(&fitsBuffer[8+3+2*maxCharLength+1]);
 
     strcpy(startOfExtension, "BINTABLE");
@@ -2181,33 +1796,5 @@
         Debug("Stopping Run Logging...");    
     }
-    //it may be that dim tries to write a dimInfo at the same time as we're closing files. Prevent this
-
-//    dim_lock();
-    for (list<RunNumberType>::const_iterator it=fRunNumber.begin(); it != fRunNumber.end(); it++)
-    {
-#ifdef RUN_LOGS
-        if (!it->logFile->is_open() || !it->reportFile->is_open())
-#else
-        if (!it->reportFile->is_open())
-#endif
-            return kSM_FatalError;
-#ifdef RUN_LOGS
-        it->logFile->close();
-        Info("Closed: "+it->logName);
-
-#endif
-        it->reportFile->close();
-        Info("Closed: "+it->reportName);
-    }
-
-#ifdef HAVE_FITS
-    for (SubscriptionsListType::iterator i = fServiceSubscriptions.begin(); i != fServiceSubscriptions.end(); i++)
-        for (map<string, SubscriptionType>::iterator j = i->second.begin(); j != i->second.end(); j++)
-        {
-            if (j->second.runFile.IsOpen())
-                j->second.runFile.Close();
-        }
-#endif
-    NotifyOpenedFile("", 0, fOpenedRunFiles);
+
     if (fNumSubAndFitsIsOn)
         fNumSubAndFits->Update();
@@ -2217,5 +1804,4 @@
         RemoveOldestRunNumber();
     }
-//    dim_unlock();
     return kSM_WaitingRun;
 }
@@ -2260,5 +1846,5 @@
     }
 #ifdef HAVE_FITS
-    CreateFitsGrouping(fOpenedNightlyFits, 0);
+    CreateFitsGrouping(fOpenedNightlyFits);
 #endif
     return kSM_Ready;
@@ -2274,7 +1860,4 @@
 {
     int cState = GetCurrentState();
-
-//    if (cState == kSM_Logging)
-//        cState = kSM_NightlyOpen;
 
     if (cState == kSM_Ready)
@@ -2473,5 +2056,4 @@
         return 127;
 
-//    try
     {
         // No console access at all
@@ -2485,9 +2067,5 @@
             return RunShell<LocalConsole>(conf);
     }
-/*    catch (exception& e)
-    {
-        cerr << "Exception: " << e.what() << endl;
-        return -1;
-    }*/
+
 
     return 0;
