Index: fact/tools/rootmacros/PulseTemplates/FPulseOverlay.C
===================================================================
--- fact/tools/rootmacros/PulseTemplates/FPulseOverlay.C	(revision 13779)
+++ fact/tools/rootmacros/PulseTemplates/FPulseOverlay.C	(revision 13852)
@@ -70,4 +70,6 @@
 //#include "pixel.C"
 
+#include "configfile.h"
+
 
 //----------------------------------------------------------------------------
@@ -193,13 +195,9 @@
 //----------------------------------------------------------------------------
 int FPulseOverlay(
-        TString     datafilename        = "raw/2012/03/09/20120309_018.fits.gz",
-        TString     drsfilename         = "raw/2012/03/09/20120309_012.drs.fits.gz",
-        TString     OutRootFileName     = "analysis/FPulseTemplate/20120309_018/Overlay/20120309_018.root",
-        bool            ProduceGraphic      = false,
-        bool            spikeDebug          = false,
-        bool            debugPixel          = false,
-        bool            testmode            = false,
-        bool            saveResults         = true,
-        int             verbosityLevel      = 1,        // different verbosity levels can be implemented here
+        TString         inputPath           = "raw/2012/03/09/",
+        TString         datafilename        = "20120309_018.fits.gz",
+        TString         drsfilename         = "20120309_012.drs.fits.gz",
+        TString         OutputPath          = "analysis/FPulseTemplate/20120309_018/Overlay/",
+        TString         OutRootFileName     = "20120309_018.root",
         int             firstevent          = 1,        // Hast to be between 1 and infinity NOT 0!!!!
         int             nevents             = -1,
@@ -208,6 +206,7 @@
         int             pixelSetSize       = 150,
         int             maxPulseOrder       = 5,
+        int             verbosityLevel      = 1,        // different verbosity levels can be implemented here
+        TString         histoOptions        = "SRM",
         int             AmplWindowWidth     = 16,       //Width of Window for selection of pulses to histograms
-        TString         histoOptions        = "SRM",
         float           GainMean            = 9,
         float           BSLMean             = -1,        //4 Histogramms will be drawn, decide how far pulsehights differ from eachother
@@ -216,4 +215,10 @@
         int             OverlayWindowLeft   = 70,
         int             OverlayWindowRight  = 230,
+        bool            ProduceGraphic      = false,
+        bool            spikeDebug          = false,
+        bool            debugPixel          = false,
+        bool            stats               = false,
+        bool            saveResults         = true,
+        bool            testmode            = false,
         int             refresh_rate        = 500      //refresh rate for canvases
         )
@@ -223,7 +228,17 @@
 //	Save-Root-File Settings
 //----------------------------------------------------------------------------
-    datafilename        = SetHostsPaths(false,   datafilename );
-    drsfilename         = SetHostsPaths(false,   drsfilename );
-    OutRootFileName     = SetHostsPaths(true,  OutRootFileName );
+
+    inputPath       = SetHostsPaths(false, inputPath );
+    OutputPath      = SetHostsPaths(true, OutputPath );
+    datafilename.Prepend(inputPath);
+    drsfilename.Prepend(inputPath);
+    OutRootFileName.Prepend(OutputPath);
+//    drsfilename         = SetHostsPaths(false,   drsfilename );
+//    OutRootFileName     = SetHostsPaths(true,  OutRootFileName );
+    cout <<  endl;
+    cout << "drs filename:\t" << drsfilename << endl;
+    cout << "data filename:\t" << datafilename << endl;
+    cout << "out filename:\t" << OutRootFileName << endl;
+
 
     if (saveResults)
@@ -403,5 +418,8 @@
 // Main Cycle
 //-----------------------------------------------------------------------------
-
+    if ( pixelSetSize == -1 )
+    {
+        pixelSetSize = firstpixel +npixel;
+    }
 //----------------------------------------------------------------------------
 // Initialize Pixel
@@ -422,4 +440,8 @@
     {
         lastPixelOfSet = firstPixelOfSet + pixelSetSize-1;
+        if (lastPixelOfSet > firstpixel + npixel)
+        {
+            lastPixelOfSet = firstpixel + npixel;
+        }
         if (lastPixelOfSet > 1439)
         {
@@ -484,7 +506,6 @@
                                 maxPulseOrder,
                                 verbosityLevel,
-                                false,
+                                stats,
                                 histoOptions,
-                                NULL,
                                 gPixelOverlayXaxisLeft,
                                 gPixelOverlayXaxisRight,
@@ -1218,9 +1239,105 @@
 
 
-int main()
+int main(int argc,char *argv[])
 {
 
-FPulseOverlay();
-return 0;
+    TString     test;
+    TString     rcFileName;
+    TString     processType             = "overlay";
+    bool        rcFileNameCmdSet        = false;
+    int         verbLevel               = 0; // different verbosity levels can be implemented here
+    bool        verbLevelCmdSet         = false;
+    bool        save                    = false;
+    bool        produceGraphic          = false;
+
+    // decode arguments
+    if(argc < 2)
+    {
+        printf("no arguements given, using standard arguments\n");
+    }
+
+    // set conditions for functions arguments
+    for (int i=1;i<argc;i++)
+    {
+        test = argv[i];
+
+        if (test.Contains("--config_file") || test.Contains("-c"))
+        {
+            cout << "RC-File: \"" << argv[i + 1] << "\"" << endl;
+            rcFileName = argv[i + 1];
+            rcFileNameCmdSet = true;
+            continue;
+        }
+
+        if (test.Contains("--verbosity") || test.Contains("-v"))
+        {
+            cout << "Verbosity Level: \"" << argv[i + 1] << "\"" << endl;
+            verbLevel = atoi(argv[i + 1]);
+            continue;
+        }
+
+        if (test.Contains("--save") || test.Contains("-s"))
+        {
+            cout << "will save results" << endl;
+            save = true;
+            continue;
+        }
+
+        if (test.Contains("--graphics") || test.Contains("-g"))
+        {
+            cout << "will produce graphics" << endl;
+            produceGraphic = true;
+            continue;
+        }
+    }
+
+    // reading rc-File:
+    configfile rcfile( rcFileName, processType );
+
+    if (save)
+    {
+        rcfile.mSave = save;
+    }
+
+    if (verbLevelCmdSet)
+    {
+        rcfile.mVerbLevel = verbLevel;
+    }
+
+    if (produceGraphic)
+    {
+        rcfile.mProduceGraphic = produceGraphic;
+    }
+
+    FPulseOverlay(
+                rcfile.mInputPath,
+                rcfile.mDataFileName,
+                rcfile.mDrsFileName,
+                rcfile.mOutputPath,
+                rcfile.mOutputFile,
+                rcfile.mFirstEvent,
+                rcfile.mNumEvents,
+                rcfile.mFirstPixel,
+                rcfile.mNumPixel,
+                rcfile.mPixelSetSize,
+                rcfile.mMaxOrder,
+                rcfile.mVerbLevel,
+                rcfile.mHistoOptions,
+                rcfile.mAmplWindowWidth,
+                rcfile.mGainMean,
+                rcfile.mBSLMean,
+                rcfile.mAvg1,
+                rcfile.mAvg2,
+                rcfile.mOverlayWindowLeft,
+                rcfile.mOverlayWindowRight,
+                rcfile.mProduceGraphic,
+                rcfile.mSpikeDebug,
+                rcfile.mDbgPixel,
+                rcfile.mPrintStats,
+                rcfile.mSave,
+                rcfile.mTestMode,
+                rcfile.mRefreshRate
+                );
+    return 0;
 
 }
