Index: /fact/tools/pyscripts/new_pyfact/pyfact.py
===================================================================
--- /fact/tools/pyscripts/new_pyfact/pyfact.py	(revision 17808)
+++ /fact/tools/pyscripts/new_pyfact/pyfact.py	(revision 17809)
@@ -6,63 +6,88 @@
 import os
 import sys
-import ctypes
-from ctypes import *
 import numpy as np
-import pprint # for SlowData
-from scipy import signal
-
 import ROOT
-hostname = ROOT.gSystem.HostName()
-
-libz_path_dict = {
-    # hostname  :   /path/to/libz.so
-    'isdc'          : "/usr/lib64/libz.so",
-    'neiseLenovo'   : "/usr/lib/libz.so",
-    'factcontrol'   : "/usr/lib/libz.so",
-    "max-K50AB"     : "/usr/lib/x86_64-linux-gnu/libz.so",
-    "watz"          : "/usr/lib/x86_64-linux-gnu/libz.so",
-    "grolsch"       : "/usr/lib/i386-linux-gnu/libz.so",
-}
-libz_loaded = False
-for my_hostname in libz_path_dict:
-    if my_hostname in hostname:
-        ROOT.gSystem.Load(libz_path_dict[my_hostname])
-        libz_loaded = True
-if not libz_loaded:
-    print """Warning - Warning - Warning - Warning - Warning - Warning - Warning
-    I most probably need to load libz.so but I don't know where it is.
-    
-    Please edit pyfact.py around line 16-24 and insert your hostname and your
-    path to your libz.so 
-    Sorry for the inconvenience.
+
+
+########## BUILDING OF THE SHARED OBJECT FILES ###############################
+if __name__ == '__main__' and len(sys.argv) > 1 and 'build' in sys.argv[1]:
+    hostname = ROOT.gSystem.HostName()
+    libz_path_dict = {
+        # hostname  :   /path/to/libz.so
+        'isdc'          : "/usr/lib64/libz.so",
+        'neiseLenovo'   : "/usr/lib/libz.so",
+        'factcontrol'   : "/usr/lib/libz.so",
+        "max-K50AB"     : "/usr/lib/x86_64-linux-gnu/libz.so",
+        "watz"          : "/usr/lib/x86_64-linux-gnu/libz.so",
+        "grolsch"       : "/usr/lib/i386-linux-gnu/libz.so",
+    }
+    libz_loaded = False
+    for my_hostname in libz_path_dict:
+        if my_hostname in hostname:
+            ROOT.gSystem.Load(libz_path_dict[my_hostname])
+            libz_loaded = True
+    if not libz_loaded:
+        print """Warning - Warning - Warning - Warning - Warning - Warning - Warning
+        I most probably need to load libz.so but I don't know where it is.
+        
+        Please edit pyfact.py around line 16-24 and insert your hostname and your
+        path to your libz.so 
+        Sorry for the inconvenience.
+        """
+        sys.exit(-1)
+
+        
+    root_make_string = ROOT.gSystem.GetMakeSharedLib()
+    if not "-std=c++0x" in root_make_string:
+        make_string = root_make_string.replace('$Opt', '$Opt -std=c++0x -D HAVE_ZLIB')
+    ROOT.gSystem.SetMakeSharedLib(make_string)
+    ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/izstream.h+O")
+    ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/fits.h+O")
+    ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/zfits.h+O")
+    ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/factfits.h+O")
+    if not "-std=c++0x" in root_make_string:
+        make_string = root_make_string.replace('$Opt', "$Opt -std=c++0x -D HAVE_ZLIB -D'PACKAGE_NAME=\"PACKAGE_NAME\"' "
+                                                        "-D'PACKAGE_VERSION=\"PACKAGE_VERSION\"' -D'REVISION=\"REVISION\"' ")
+    ROOT.gSystem.SetMakeSharedLib(make_string)
+    ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/DrsCalib.h+O")
+
+    ROOT.gInterpreter.GenerateDictionary("map<string,fits::Entry>","map;string;extern_Mars_mcore/fits.h")
+    ROOT.gInterpreter.GenerateDictionary("pair<string,fits::Entry>","map;string;extern_Mars_mcore/fits.h")
+    ROOT.gInterpreter.GenerateDictionary("map<string,fits::Table::Column>","map;string;extern_Mars_mcore/fits.h")
+    ROOT.gInterpreter.GenerateDictionary("pair<string,fits::Table::Column>","map;string;extern_Mars_mcore/fits.h")
+    ROOT.gInterpreter.GenerateDictionary("vector<DrsCalibrate::Step>","vector;extern_Mars_mcore/DrsCalib.h")
+
+########## USAGE #############################################################
+if __name__ == '__main__' and len(sys.argv) < 3:
+    print """ Usage:
+    ----------------------------------------------------------------------
+    To just build the shared object libs call:
+    python pyfact.py build
+    
+    To build (if necessary) and open an example file
+    python -i pyfact.py /path/to/data_file.zfits /path/to/calib_file.drs.fits.gz
+    
+    Any of the 3 file 'types': fits.gz    zfits    fits
+    should be supported.
+    
+    To clean all of automatically built files, do something like:
+    rm *.so *.d AutoDict_* extern_Mars_mcore/*.so extern_Mars_mcore/*.d
+    ----------------------------------------------------------------------
     """
-    sys.exit(-1)
-
-    
-root_make_string = ROOT.gSystem.GetMakeSharedLib()
-if not "-std=c++0x" in root_make_string:
-    make_string = root_make_string.replace('$Opt', '$Opt -std=c++0x -D HAVE_ZLIB')
-ROOT.gSystem.SetMakeSharedLib(make_string)
-ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/izstream.h+O")
-ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/fits.h+O")
-ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/zfits.h+O")
-ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/factfits.h+O")
-if not "-std=c++0x" in root_make_string:
-    make_string = root_make_string.replace('$Opt', "$Opt -std=c++0x -D HAVE_ZLIB -D'PACKAGE_NAME=\"PACKAGE_NAME\"' -D'PACKAGE_VERSION=\"PACKAGE_VERSION\"' -D'REVISION=\"REVISION\"' ")
-ROOT.gSystem.SetMakeSharedLib(make_string)
-ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/DrsCalib.h+O")
-
-ROOT.gInterpreter.GenerateDictionary("map<string,fits::Entry>","map;string;extern_Mars_mcore/fits.h")
-ROOT.gInterpreter.GenerateDictionary("pair<string,fits::Entry>","map;string;extern_Mars_mcore/fits.h")
-ROOT.gInterpreter.GenerateDictionary("map<string,fits::Table::Column>","map;string;extern_Mars_mcore/fits.h")
-ROOT.gInterpreter.GenerateDictionary("pair<string,fits::Table::Column>","map;string;extern_Mars_mcore/fits.h")
-ROOT.gInterpreter.GenerateDictionary("vector<DrsCalibrate::Step>","vector;extern_Mars_mcore/DrsCalib.h")
-
-ROOT.gSystem.Load('extern_Mars_mcore/fits_h.so')
-ROOT.gSystem.Load('extern_Mars_mcore/izstream_h.so')
-ROOT.gSystem.Load('extern_Mars_mcore/zfits_h.so')
-ROOT.gSystem.Load('extern_Mars_mcore/factfits_h.so')
-ROOT.gSystem.Load('extern_Mars_mcore/DrsCalib_h.so')
-from ROOT import *
+    sys.exit(1)
+
+#########  START OF PYFACT MODULE ############################################
+path = os.path.dirname(os.path.realpath(__file__))
+ROOT.gSystem.Load(path+'/AutoDict_map_string_fits__Entry__cxx.so')
+ROOT.gSystem.Load(path+'/AutoDict_map_string_fits__Table__Column__cxx.so')
+ROOT.gSystem.Load(path+'/AutoDict_pair_string_fits__Entry__cxx.so')
+ROOT.gSystem.Load(path+'/AutoDict_pair_string_fits__Table__Column__cxx.so')
+ROOT.gSystem.Load(path+'/AutoDict_vector_DrsCalibrate__Step__cxx.so')
+ROOT.gSystem.Load(path+'/extern_Mars_mcore/fits_h.so')
+ROOT.gSystem.Load(path+'/extern_Mars_mcore/izstream_h.so')
+ROOT.gSystem.Load(path+'/extern_Mars_mcore/zfits_h.so')
+ROOT.gSystem.Load(path+'/extern_Mars_mcore/factfits_h.so')
+ROOT.gSystem.Load(path+'/extern_Mars_mcore/DrsCalib_h.so')
+del path
 
 class Fits( object ):
@@ -79,5 +104,5 @@
         if not os.path.exists(path):
             raise IOError(path+' was not found')
-        self.f = factfits(path)
+        self.f = ROOT.factfits(path)
         self._make_header()
         self._setup_columns()
@@ -142,8 +167,8 @@
         if not self.cols['CalibData2D'].base is self.cols['CalibData']:
             print "Error seomthing went wrong!"
-        self.drs_calibration = DrsCalibration()
+        self.drs_calibration = ROOT.DrsCalibration()
         self.drs_calibration.ReadFitsImp( calib_path )
         
-        self.drs_calibrate = DrsCalibrate()
+        self.drs_calibrate = ROOT.DrsCalibrate()
         self.list_of_previous_start_cells = []
 
@@ -189,22 +214,5 @@
 
 if __name__ == '__main__':
-    """ tests  """
-    if len(sys.argv) < 3:
-        print """ Usage:
-        ----------------------------------------------------------------------
-        To just build the shared object libs call:
-        python pyfact.py
-        
-        To build (if necessary) and open an example file
-        python -i pyfact.py /path/to/data_file.zfits /path/to/calib_file.drs.fits.gz
-        
-        Any of the 3 file 'types': fits.gz    zfits    fits
-        should be supported.
-        
-        To clean all of automatically built files, do something like:
-        rm *.so *.d AutoDict_* extern_Mars_mcore/*.so extern_Mars_mcore/*.d
-        ----------------------------------------------------------------------
-        """
-        sys.exit(1)
+    """ Example """
     print "Example for calibrated raw-file"
     f = RawData(sys.argv[1], sys.argv[2])
