Index: trunk/MagicSoft/Mars/mtemp/mwuerzburg/tools/dcconverter/DCCurrentEvent.cpp
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mwuerzburg/tools/dcconverter/DCCurrentEvent.cpp	(revision 4091)
+++ trunk/MagicSoft/Mars/mtemp/mwuerzburg/tools/dcconverter/DCCurrentEvent.cpp	(revision 4091)
@@ -0,0 +1,83 @@
+// DCCurrentEvent.cpp: Implementiberung der Klasse DCCurrentEvent.
+//
+//////////////////////////////////////////////////////////////////////
+
+#ifndef DCCURRENTEVENT_INCLUDED
+#include "DCCurrentEvent.h"
+#endif
+#ifndef GLOBALS_INCLUDED
+#include "Globals.h"
+#endif
+
+#include <sstream>
+#include <istream>
+#include <ostream>
+#include <iostream>
+#include <iomanip>
+#include <iterator>
+#include <vector>
+
+extern int gYear, gMonth, gDay;
+
+//////////////////////////////////////////////////////////////////////
+// Konstruktion/Destruktion
+//////////////////////////////////////////////////////////////////////
+
+DCCurrentEvent::DCCurrentEvent()
+{
+    m_dcValues.reserve( Globals::CAMERA_PIXELS );
+    
+}
+
+DCCurrentEvent::~DCCurrentEvent()
+{
+}
+
+std::istream& operator >> ( std::istream& in, DCCurrentEvent& event )
+{
+    using std::string;
+    using std::getline;
+
+    // read the starting tag
+    string tag;
+    in >> tag;
+    if ( tag != "DC")
+    {
+        in.clear( std::ios_base::badbit);
+        return in;
+    }
+
+    // read error codes
+    in >> event.m_dcError1 >> event.m_dcError2;
+
+    // read in the timestamp
+    in >> event.m_dcHour >> event.m_dcMin >> event.m_dcSec >> event.m_dcMSec;
+
+    getline( in, event.m_dcCurr );
+
+    return in;
+}
+
+std::ostream& operator << ( std::ostream& out, const DCCurrentEvent& event )
+{
+    using namespace std;
+
+    out << "DC-REPORT ";
+    out << setfill('0') << right << resetiosflags(ios_base::showpos);
+    out << setw(2) << 0 << ' ';
+    out << setw(4) << gYear << ' ';
+    out << setw(2) << gMonth << ' ';
+    out << setw(2) << gDay << ' ';
+    out << setw(2) << event.m_dcHour << ' ';
+    out << setw(2) << event.m_dcMin  << ' ';
+    out << setw(2) << event.m_dcSec  << ' ';
+    out << setw(3) << event.m_dcMSec << ' ';
+
+    out << setfill('0') << internal << setiosflags(ios_base::showpos);
+    out << setw(3) << event.m_dcError1 << " ";
+    out << setw(3) << event.m_dcError2;
+    out << setfill('0') << right << resetiosflags(ios_base::showpos);
+
+    out << event.m_dcCurr;
+    return out;
+}
Index: trunk/MagicSoft/Mars/mtemp/mwuerzburg/tools/dcconverter/DCCurrentEvent.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mwuerzburg/tools/dcconverter/DCCurrentEvent.h	(revision 4091)
+++ trunk/MagicSoft/Mars/mtemp/mwuerzburg/tools/dcconverter/DCCurrentEvent.h	(revision 4091)
@@ -0,0 +1,38 @@
+// DCCurrentEvent.h: Schnittstelle für die Klasse DCCurrentEvent.
+//
+//////////////////////////////////////////////////////////////////////
+
+#if !defined(DCCURRENTEVENT_INCLUDED)
+#define DCCURRENTEVENT_INCLUDED
+
+#include <ctime>
+#include <vector>
+#include <string>
+#include <istream>
+#include <ostream>
+
+class DCCurrentEvent
+{
+    friend std::istream& operator >> ( std::istream& in, DCCurrentEvent& event );
+    friend std::ostream& operator << ( std::ostream& out, const DCCurrentEvent& event );
+
+private:
+    int	       		m_dcError1;
+    int	       		m_dcError2;
+    int	       		m_dcHour;
+    int	       		m_dcMin;
+    int	       		m_dcSec;
+    int	       		m_dcMSec;
+    time_t     		m_dcTime;
+    std::string       m_dcCurr;
+    std::vector<int>	m_dcValues;
+
+public:
+	DCCurrentEvent();
+	virtual ~DCCurrentEvent();
+};
+
+std::istream& operator >> ( std::istream& in, DCCurrentEvent& event );
+std::ostream& operator << ( std::ostream& out, const DCCurrentEvent& event );
+
+#endif // !defined(DCCURRENTEVENT_INCLUDED)
Index: trunk/MagicSoft/Mars/mtemp/mwuerzburg/tools/dcconverter/Globals.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mwuerzburg/tools/dcconverter/Globals.h	(revision 4091)
+++ trunk/MagicSoft/Mars/mtemp/mwuerzburg/tools/dcconverter/Globals.h	(revision 4091)
@@ -0,0 +1,20 @@
+// Globals.h: Global variables
+//            We use a class to hold these global values
+//            in order not to pollute the global namespace
+//
+//////////////////////////////////////////////////////////////////////
+
+#if !defined(GLOBALS_INCLUDED)
+#define GLOBALS_INCLUDED
+
+class Globals  
+{
+public:
+	enum {CAMERA_PIXELS = 577};
+
+private:
+	Globals();				// prevent inadvertent instantiation
+
+};
+
+#endif // !defined(GLOBALS_INCLUDED)
Index: trunk/MagicSoft/Mars/mtemp/mwuerzburg/tools/dcconverter/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mwuerzburg/tools/dcconverter/Makefile	(revision 4091)
+++ trunk/MagicSoft/Mars/mtemp/mwuerzburg/tools/dcconverter/Makefile	(revision 4091)
@@ -0,0 +1,116 @@
+##################################################################
+#
+# makefile
+#
+# @file        makefile
+# @title       Converter of DCCurrent files to new format
+# @author      M Merck
+# @email       merck@astro.uni-wuerzburg.de
+# @date        Wed Dec 17 11:51:11 MET 2003
+#
+#_______________________________________________________________
+#
+# Created: Wed Dec 17 11:51:11 MET 2003
+# Author:  Martin Merck
+# Purpose: Makefile for the compilation of dcconvertor
+# Notes:   
+#    
+##################################################################
+
+# @code
+
+# compilers & tools
+
+CC            = gcc
+CXX           = g++
+F77           = g77
+
+INCLUDES = -I.
+
+OPTIM    =
+DEBUG    = -g
+
+# compilation and linking flags
+
+CXXFLAGS  = ${INCLUDES} ${OPTIM} ${DEBUG}
+CFLAGS    = ${CXXFLAGS}
+FFLAGS    = ${CXXFLAGS}
+LIBS      =
+
+#------------------------------------------------------------------------------
+
+#.SILENT:
+
+.SUFFIXES: .c .cxx .cpp .C .c++ .h .hxx .H .h++ .o .so .f
+
+SRCS = \
+	main.cpp \
+	DCCurrentEvent.cpp
+
+HEADERS = \
+	DCCurrentEvent.h \
+	Globals.h
+
+OBJS = \
+	DCCurrentEvent.o \
+	main.o
+
+PROGRAM=dcconvertor
+
+############################################################
+
+all: ${PROGRAM}
+
+depend:
+	@makedepend $(SRCS) -fMakefile 2> /dev/null
+
+${PROGRAM}: $(OBJS)
+	@echo "Linking..." $@
+	$(CXX) $(CXXFLAGS) $(OBJS) $(LIBS) -o $@
+	@echo "done."
+
+.cxx.o:
+	@echo "Compiling " $<
+	$(CXX) $(CXXFLAGS) -c $< -o $@
+
+.c.o:
+	@echo "Compiling " $<
+	$(CC) $(CFLAGS) -c $< -o $@
+
+.f.o:
+	@echo "Compiling " $<
+	$(F77) $(FFLAGS) -c $< -o $@
+
+lclean:
+	@echo "Cleanning..."
+	@rm -f *.o core
+
+clean:
+	@echo "Cleanning..."
+	@rm -f $(OBJS) core 
+
+mrproper: clean
+	@echo "Mr.Proper in action . . ."
+	@rm -f $(PROGRAM)
+
+ctags:
+	@echo "Creating CTAGS file . . ."
+	@ctags -txw $(SRCS) $(HEADERS) > CTAGS
+
+etags:
+	@echo "Creating TAGS file . . ."
+	@etags -C $(SRCS) $(HEADERS)
+
+listsrc:
+	@ls -m $(SRCS) $(HEADERS) | sed 's/,//g'
+
+redo: clean all
+
+# @endcode
+# DO NOT DELETE
+
+main.o: Globals.h /usr/include/stdlib.h /usr/include/features.h
+main.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
+main.o: /usr/lib/gcc-lib/i486-suse-linux/3.3/include/stddef.h
+main.o: DCCurrentEvent.h
+DCCurrentEvent.o: DCCurrentEvent.h Globals.h
Index: trunk/MagicSoft/Mars/mtemp/mwuerzburg/tools/dcconverter/main.cpp
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mwuerzburg/tools/dcconverter/main.cpp	(revision 4091)
+++ trunk/MagicSoft/Mars/mtemp/mwuerzburg/tools/dcconverter/main.cpp	(revision 4091)
@@ -0,0 +1,57 @@
+/***************************************************************************
+                          main.cpp  -  description
+                             -------------------
+    begin                : Tue Dec  9 12:05:18 CET 2003
+    copyright            : (C) 2003 by Martin Merck
+    email                : merck@astro.uni-wuerzburg.de
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is part of the MAGIC Software  * ***************************************************************************/
+
+#ifndef GLOBALS_INCLUDED
+#include "Globals.h"
+#endif
+
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <iterator>
+#include <string>
+#include <stdlib.h>
+#include "DCCurrentEvent.h"
+
+using namespace std;
+
+int gYear, gMonth, gDay;
+
+void usage();
+
+int main(int argc, char *argv[])
+{
+  if (argc != 3)
+     usage();
+
+  string dcFileName( argv[1] );
+  string date = dcFileName.substr( dcFileName.rfind( "dc_" ) + 3, 10 );
+  sscanf( date.c_str(), "%d_%d_%d", &gYear, &gMonth, &gDay);
+  cout << gYear << ":" << gMonth << ":" << gDay << endl;
+  
+  
+  std::ifstream input( argv[1] );
+  ofstream output( const_cast<const char *> (argv[2]) );
+
+  copy( istream_iterator<DCCurrentEvent>( input ),
+        istream_iterator<DCCurrentEvent>(),
+        ostream_iterator<DCCurrentEvent>( output, "\n") );
+
+  return EXIT_SUCCESS;
+}
+
+void usage()
+{
+  cerr << "USAGE: dcconvertor <input file> <output file>" << endl;
+  exit( EXIT_FAILURE );
+}
+  
Index: trunk/MagicSoft/Mars/mtemp/mwuerzburg/tools/dcconverter/rundcconv
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mwuerzburg/tools/dcconverter/rundcconv	(revision 4091)
+++ trunk/MagicSoft/Mars/mtemp/mwuerzburg/tools/dcconverter/rundcconv	(revision 4091)
@@ -0,0 +1,43 @@
+#!/bin/sh
+# Script to convert DC current files from the old format to the new format
+#
+PS3="Select the Date for which MERPP should run? "
+DATES=`ls -d -1 ./cacodata_old/20* | cut -d/ -f3 '-'`
+select DATE in $DATES "Exit"; do
+	break
+done
+if [ "$DATE" = "Exit" ]
+then
+  exit
+fi
+
+INDIR=./cacodata_old/$DATE
+OUTDIR=./cacodata/$DATE
+if [ -d $OUTDIR ]
+then
+  echo "An output directory for the date $DATE already"
+  echo "exists. Please be sure that you selected the"
+  echo "correct date. If you want to rerun MERPP on this"
+  echo "date please delete the directory and all files it"
+  echo "contains from the rootfiles directory."
+  exit
+fi
+echo $DATE
+mkdir ./cacodata/$DATE
+
+LOGFILE=$OUTDIR/dcconv.log
+CACOFILES=`ls -1 $INDIR/dc_*.txt`
+
+TIME=`date`
+echo "-----------------------------------------------------------------" > $LOGFILE
+echo " dcconvertor run started $TIME" >> $LOGFILE
+echo "-----------------------------------------------------------------" >> $LOGFILE
+
+for i in $CACOFILES
+do
+  IN_FILE=$i
+  OUT_FILE=$OUTDIR/$i
+  dcconvertor $IN_FILE $OUT_FILE
+  echo $IN_FILE >> $LOGFILE
+  echo "Processed file $IN_FILE in $SECONDS secs."
+done
