Index: fact/tools/pyscripts/callisto2.py
===================================================================
--- fact/tools/pyscripts/callisto2.py	(revision 12717)
+++ fact/tools/pyscripts/callisto2.py	(revision 12717)
@@ -0,0 +1,143 @@
+#!/usr/bin/python
+#
+'''
+function callisto
+produce and save calibrated FACT data
+'''
+from ROOT import *
+
+# get the MARS library loaded
+gSystem.Load(  '/data02/scratch/Mars_20111207_2145_from_data/libmars.so' )
+from ROOT import *
+
+def callisto( drsfile, datafile, mapfile, plotfile = '~/res/t-callisto.root'):
+    """
+    write calibrated data files
+    """
+    if mapfile == '':
+        map = NULL
+    else:
+        usemap = True
+        map = mapfile
+
+    # signal extraction parameter
+    # Extraction range in slices. It will always(!) contain the full range of integration
+    first_slice, last_slice =  30, 250 # 15ns
+    # Integral range left and right of the maximum in slices
+    rise_time, fall_time = 13, 23
+
+    type = MExtralgoSpline.kIntegralRel
+
+    # Data files to be processed
+    read5 = MRawFitsRead()
+    read5.LoadMap( map )
+    read5.AddFile( datafile )
+
+    # create a display instance
+    d = MStatusDisplay()
+
+    loop = MEvtLoop()     # create an eventloop instance
+    loop.SetDisplay( d )  #
+
+    bad_pixel_list = [ 424, 583, 830, 923, 1208, 1388 ]  
+    badpixels = MBadPixelsCam()
+    badpixels.InitSize(1440)
+    for pixel in bad_pixel_list:
+        badpixels[ pixel ].SetUnsuitable(MBadPixelsPix.kUnsuitable)
+        
+    drscalib = MDrsCalibration()
+    if drscalib.ReadFits( drsfile ) != True :
+        print 'problems reading drsfile: ', drsfile
+        exit( -1 )
+
+    timecam = MCalibrationRelTimeCam()
+
+    tlist = MTaskList()
+    plist2 = MParList()
+
+    plist2.AddToList( tlist );
+    plist2.AddToList( drscalib );
+    plist2.AddToList( badpixels );
+    plist2.AddToList( timecam );
+
+    apply = MGeomApply()
+    drsapply = MDrsCalibApply()
+
+    cont = MContinue( 'MRawEvtHeader.GetTriggerID != 4' )
+
+    extractor = MExtractTimeAndChargeSpline()
+    extractor.SetRange( first_slice, last_slice )
+    extractor.SetRiseTimeHiGain( rise_time )
+    extractor.SetFallTimeHiGain( fall_time )
+    extractor.SetChargeType( type )
+    extractor.SetSaturationLimit(600000)
+    extractor.SetNoiseCalculation( kFALSE )
+
+    evtA1 = MHCamEvent(0, "Extra'd", "Extracted Calibration Signal;;S [cnts/sl]")
+    evtA2 = MHCamEvent(4, "ArrTm",   "Extracted ArrivalTime;;T")
+
+    fillA1 = MFillH(evtA1, "MExtractedSignalCam", "FillExtractedSignal")
+    fillA2 = MFillH(evtA2, "MArrivalTimeCam",     "FillArrivalTime")
+
+    # Use this for data, but not for calibration events
+    evtA1.SetErrorSpread( kFALSE )
+
+    conv = MCalibrateData()
+    conv.SetCalibrationMode( MCalibrateData.kNone )
+    conv.SetPedestalFlag( MCalibrateData.kNo )
+
+    calctm = MCalibrateRelTimes()
+
+    treat = MBadPixelsTreat()
+    treat.SetProcessPedestalRun( kFALSE )
+    treat.SetProcessPedestalEvt( kFALSE )
+
+    evtB1 = MHCamEvent(0, "Interp'd","Interpolated Signal scaled with A/A_{0};;S [phe]")
+    evtB1.SetErrorSpread( kFALSE )
+
+    fillB1 = MFillH(evtB1, "MSignalCam", "FillInterpolated")
+
+    # fname = TString( Form('s/([0-9]+_[0-9]+)[.]fits([.]gz)?$/%s\\/$1_C.root/', outpath ) )
+    # fname = TString()
+    fname = "s/([0-9]+_[0-9]+)[.]fits([.]gz)?$/.\\/$1_C.root/"
+    # print 'fname: ', fname
+
+
+    # The second rule is for the case reading raw-files!
+    write = MWriteRootFile(2, fname, "NEW", "Calibrated Data")
+    write.AddContainer("MRawRunHeader", "RunHeaders")
+    write.AddContainer("MGeomCam",      "RunHeaders")
+    write.AddContainer("MSignalCam",    "Events")
+    write.AddContainer("MTime",         "Events")
+    write.AddContainer("MRawEvtHeader", "Events")
+    # write.AddContainer("MTriggerPattern", "Events")
+
+    # ------------------ Setup histograms and fill tasks ----------------
+
+    tlist.AddToList( read5 )
+    tlist.AddToList( cont )
+    tlist.AddToList( apply )
+    tlist.AddToList( drsapply )
+    tlist.AddToList( extractor )
+    tlist.AddToList( fillA1 )
+    tlist.AddToList( fillA2 )
+    tlist.AddToList( conv )
+    tlist.AddToList( calctm )
+    tlist.AddToList( treat )
+    tlist.AddToList( fillB1 )
+    tlist.AddToList( write )
+
+    loop.SetParList( plist2 )
+    # if ( loop.Eventloop()  ): exit( -1 )
+    # if ( loop.GetDisplay() ): exit( -1 )
+    print 'loop.Eventloop(): ', loop.Eventloop()
+    print 'loop.GetDisplay(): ', loop.GetDisplay()
+
+    title = '--  Calibrate Signal: ' + drsfile + '  --'
+    d.SetTitle( title, kFALSE);
+
+    # TString path;
+    # path += Form("%s%s-callisto.root", outpath, TString(TString(strrchr(drsfile, '/'))(0, 13)).Data());
+    
+    d.SaveAs( plotfile )
+
Index: fact/tools/pyscripts/run2.py
===================================================================
--- fact/tools/pyscripts/run2.py	(revision 12717)
+++ fact/tools/pyscripts/run2.py	(revision 12717)
@@ -0,0 +1,44 @@
+#!/usr/bin/python
+#
+# Werner Lustermann
+# ETH Zurich
+#
+from ROOT import *
+
+# get the MARS library loaded
+gSystem.Load(  '/data02/scratch/Mars_20111207_2145_from_data/libmars.so' )
+from ROOT import *
+
+from numpy import loadtxt
+
+from callisto2 import callisto
+
+FACT_map_file_name = 'FACTmap111030.txt'
+
+df_extension = '.fits' # extension/format of the data file
+gzip = '.gz' # are the data compressed ? if not use ''
+
+data_path = '/data00/fact-construction/raw/' # path to the data
+res_path  = '~/res/' # path to the storage of the results
+res_tag   = '_callisto' # tag added to the filename with the results
+res_ext   = '.root'     # extension of the filename with the results
+
+rl_name = 'runlist_julia_dec2011.txt' # name of the file (inluding path) to the runlist
+# rl ... runlist
+rl = loadtxt( rl_name, dtype={'names':('drsf','df','dd','mm','yyyy'), 'formats': ('S3','S3','S2','S2','S4') } )
+
+for run in rl:
+    print 'processing run: ', run
+    dp = data_path + run['yyyy'] + '/' + run['mm'] + '/' + run['dd'] + '/'
+    fnd = run['yyyy'] + run['mm'] + run['dd'] + '_'
+    data_file_name = dp + fnd + run['df'] + df_extension + gzip
+    drs_file_name  = dp + fnd + run['drsf'] + '.drs' + df_extension + gzip
+    res_file_name  = res_path + fnd + run['df'] + res_tag + res_ext
+    print data_file_name
+    print drs_file_name
+    print res_file_name
+    print
+    # call the mars macro (converted to python) for doing the job
+    callisto( drs_file_name, data_file_name, FACT_map_file_name, res_file_name )
+
+print 'no matter what you do eventually it will be finished'
Index: fact/tools/pyscripts/runlist_20111124.txt
===================================================================
--- fact/tools/pyscripts/runlist_20111124.txt	(revision 12717)
+++ fact/tools/pyscripts/runlist_20111124.txt	(revision 12717)
@@ -0,0 +1,42 @@
+# DRS DAT DD MM YYYY
+  015 019 24 11 2011 
+  015 020 24 11 2011 
+  015 021 24 11 2011 
+  015 022 24 11 2011 
+  015 023 24 11 2011 
+  015 026 24 11 2011 
+  015 027 24 11 2011 
+  015 028 24 11 2011 
+  015 029 24 11 2011 
+  035 039 24 11 2011 
+  035 040 24 11 2011 
+  035 041 24 11 2011 
+  035 042 24 11 2011 
+  035 045 24 11 2011 
+  035 046 24 11 2011 
+  035 047 24 11 2011 
+  035 048 24 11 2011 
+  054 059 24 11 2011 
+  054 060 24 11 2011 
+  054 061 24 11 2011 
+  054 062 24 11 2011 
+  054 068 24 11 2011 
+  074 078 24 11 2011 
+  074 079 24 11 2011 
+  074 080 24 11 2011 
+  074 081 24 11 2011 
+  074 085 24 11 2011 
+  074 086 24 11 2011 
+  074 087 24 11 2011 
+  074 088 24 11 2011 
+  094 098 24 11 2011 
+  094 099 24 11 2011 
+  094 100 24 11 2011 
+  094 104 24 11 2011 
+  094 105 24 11 2011 
+  094 106 24 11 2011 
+  094 107 24 11 2011 
+  114 119 24 11 2011 
+  114 120 24 11 2011 
+  114 121 24 11 2011 
+
