Index: trunk/MagicSoft/Mars/mjobs/MJCalibTest.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibTest.cc	(revision 6846)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibTest.cc	(revision 6858)
@@ -50,4 +50,5 @@
 #include "MHCamera.h"
 
+#include "MSignalCam.h"
 #include "MPedestalCam.h"
 #include "MPedPhotCam.h"
@@ -56,6 +57,4 @@
 #include "MBadPixelsCalc.h"
 #include "MBadPixelsMerge.h"
-#include "MCerPhotEvt.h"
-#include "MArrivalTime.h"
 #include "MCalibrationChargeCam.h"
 #include "MCalibrationRelTimeCam.h"
@@ -392,5 +391,5 @@
   plist.AddToList(&tmcam);
 
-  MCerPhotEvt          cerphot;
+  MSignalCam           cerphot;
   MPedPhotCam          pedphot;
   MHCalibrationTestCam testcam;
@@ -479,12 +478,12 @@
   MHCamEvent evt0(0,"Signal", "Un-Calibrated Signal;;S [FADC cnts]" );
   MHCamEvent evt1(0,"CalSig", "Cal. and Interp. Sig. by Pixel Size Ratio;;S [phe]");
-  MHCamEvent evt2(0,"Times" , "Arrival Time;;T [slice]");
+  MHCamEvent evt2(6,"Times" , "Arrival Time;;T [slice]");
 
   MFillH fill0(&evt0, "MExtractedSignalCam", "FillUncalibrated");
-  MFillH fill1(&evt1, "MCerPhotEvt", "FillCalibrated");
-  MFillH fill2(&evt2, "MArrivalTime","FillTimes");
-  
-  MFillH fillcam("MHCalibrationTestCam",     "MCerPhotEvt" ,"FillTest");
-  MFillH filltme("MHCalibrationTestTimeCam", "MArrivalTime","FillTestTime");
+  MFillH fill1(&evt1, "MSignalCam", "FillCalibrated");
+  MFillH fill2(&evt2, "MSignalCam", "FillTimes");
+  
+  MFillH fillcam("MHCalibrationTestCam",     "MSignalCam" ,"FillTest");
+  MFillH filltme("MHCalibrationTestTimeCam", "MSignalCam", "FillTestTime");
   fillcam.SetBit(MFillH::kDoNotDisplay);
   filltme.SetBit(MFillH::kDoNotDisplay);
Index: trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 6846)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 6858)
@@ -53,4 +53,5 @@
 #include "MGeomCam.h"
 #include "MHCamEvent.h"
+//#include "MHCamEventTH.h"
 #include "MPedestalCam.h"
 #include "MBadPixelsCam.h"
@@ -610,8 +611,13 @@
     MHCamEvent evt5(0, "Interp'd",   "Interpolated Signal;;S [phe]");
     MHCamEvent evt6(2, "Unsuitable", "Fraction of unsuitable events per Pixel;;[1]");
-    MHCamEvent evt7(0, "Times",      "Calibrated Arrival Time;;T [fadc sl]");
+    MHCamEvent evt7(6, "Times",      "Calibrated Arrival Time;;T [fadc sl]");
     MHCamEvent evt8(0, "Conv",       "Calibration Conv. Factors;;[phe/fadc cnts]");
-    //MHCamEvent evt9(0, "PulsePos",   "Pulse Position of cosmics"); //Calibration Conv. Factors;;[phe/fadc cnts]
-
+    MHCamEvent evt9(7, "PulsePos",  "Pulse Position of cosmics (>15phe);;T"); //Calibration Conv. Factors;;[phe/fadc cnts]
+    /*
+     MHCamEventTH evt9(6, "PulsePos",  "Pulse Position of cosmics"); //Calibration Conv. Factors;;[phe/fadc cnts]
+     evt9.SetNameThreshold("MCerPhotEvt");
+     evt9.SetThreshold(15);
+     */
+/*
     evt0.EnableSqrtVariance();
     evt1.EnableSqrtVariance();
@@ -622,5 +628,5 @@
     evt7.EnableSqrtVariance();
     evt8.EnableSqrtVariance();
-
+  */
     MFillH fill0(&evt0, "MPedestalFundamental",    "FillPedFLG");
     MFillH fill1(&evt1, "MPedestalFromExtractorRndm", "FillPedRmsFLG");
@@ -630,15 +636,10 @@
     MFillH fill5(&evt5, "MCerPhotEvt",             "FillInterpolated");
     MFillH fill6(&evt6, "MBadPixelsCam",           "FillUnsuitable");
-    MFillH fill7(&evt7, "MArrivalTime",            "FillTimes");
+    MFillH fill7(&evt7, "MCerPhotEvt",             "FillTimes");
     MFillH fill8(&evt8, "MCalibConstCam",          "FillConv");
-    //MFillH fill9(&evt9, "MCalibConstCam",          "FillPulse");
+    MFillH fill9(&evt9, "MCerPhotEvt",             "FillPulse");
 
     MTaskEnv fillflorian("FinalFantasy");
     fillflorian.SetDefault();
-
-    // Write the special MC tree
-    MWriteRootFile writemc(2, fname, fOverwrite?"RECREATE":"NEW");
-    writemc.SetName("WriteMC");
-    writemc.AddContainer("MMcEvtBasic", "OriginalMC");
 
     // The second rule is for the case reading raw-files!
@@ -664,5 +665,5 @@
     write.AddContainer("MTime",                     "Events",     kFALSE);
     write.AddContainer("MRawEvtHeader",             "Events");
-    write.AddContainer("MArrivalTime",              "Events",     kFALSE);
+    //write.AddContainer("MArrivalTime",              "Events",     kFALSE);
     write.AddContainer("MPointingPos",              "Events",     kFALSE);
     // Slow-Control: Current-tree
@@ -688,4 +689,9 @@
     write.AddContainer("MReportCC",                 "CC",         kFALSE);
     write.AddContainer("MTimeCC",                   "CC",         kFALSE);
+
+    // Write the special MC tree
+    MWriteRootFile writemc(2, fname, fOverwrite?"RECREATE":"NEW");
+    writemc.SetName("WriteMC");
+    writemc.AddContainer("MMcEvtBasic", "OriginalMC");
 
     // Now setup tasklist for events
@@ -754,4 +760,5 @@
     if (extractor2 || extractor1->InheritsFrom("MExtractTimeAndCharge"))
       tlist2.AddToList(&fill7);
+    tlist2.AddToList(&fill9);
 
     tlist2.AddToList(&fillflorian);
Index: trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 6846)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 6858)
@@ -19,8 +19,9 @@
 !   Author(s): Markus Gaug, 02/2004 <mailto:markus@ifae.es>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2005
 !
 !
 \* ======================================================================== */
+
 /////////////////////////////////////////////////////////////////////////////
 //
@@ -178,4 +179,5 @@
 const TString MJCalibration::fgReferenceFile = "mjobs/calibrationref.rc";
 const TString MJCalibration::fgHiLoCalibFile = "mjobs/hilocalib_df4.root";
+
 // --------------------------------------------------------------------------
 //
@@ -1479,4 +1481,9 @@
 
   TFile file(fHiLoCalibFile,"READ");
+  if (!file.IsOpen())
+  {
+    *fLog << err << "ERROR - Couldn't open hi-lo intercalibration file " << fHiLoCalibFile << " for reading..." << endl;
+    return kFALSE;
+  }
 
   MCalibrationHiLoCam hilocam;
@@ -1774,8 +1781,9 @@
         plist.AddToList(&fIntensQECam);
         plist.AddToList(&fIntensCalibCam);
-        plist.AddToList(&fIntensBlindCam);
         //        plist.AddToList(&fIntensCalibrationPINDiode);
         plist.AddToList(&fIntensRelTimeCam);
         plist.AddToList(&fIntensBadCam);
+        if (IsUseBlindPixel())
+            plist.AddToList(&fIntensBlindCam);
     }
     else
@@ -1783,7 +1791,9 @@
         plist.AddToList(&fQECam);
         plist.AddToList(&fCalibrationCam);
-        plist.AddToList(&fCalibrationBlindCam);
-        plist.AddToList(&fCalibrationPINDiode);
         plist.AddToList(&fRelTimeCam);
+        if (IsUseBlindPixel())
+            plist.AddToList(&fCalibrationBlindCam);
+        if (IsUsePINDiode())
+            plist.AddToList(&fCalibrationPINDiode);
     }
 
@@ -1829,5 +1839,6 @@
     MExtractBlindPixel       blindext;
 
-    InitBlindPixel(blindext, blindcam);
+    if (IsUseBlindPixel())
+        InitBlindPixel(blindext, blindcam);
 
     MExtractSlidingWindow    extract2;
@@ -2157,42 +2168,42 @@
 Bool_t MJCalibration::WriteResult(MParList &plist)
 {
+    if (IsNoStorage())
+        return kTRUE;
+
     TObjArray cont;
 
-    if (!IsNoStorage())
-    {
-        if (IsIntensity())
-        {
-            cont.Add(&fIntensBadCam);
-            cont.Add(&fIntensCalibCam);
-            cont.Add(&fIntensQECam);
-            cont.Add(&fIntensBlindCam);
-        }
-        else
-        {
-            cont.Add(&fBadPixels);
-            cont.Add(&fCalibrationCam);
-            cont.Add(&fQECam);
-            cont.Add(&fCalibrationBlindCam);
-        }
-        cont.Add(&fCalibrationPINDiode);
-
-        //if (IsRelTimes())
-        cont.Add(IsIntensity() ? (TObject*)&fIntensRelTimeCam : (TObject*)&fRelTimeCam);
-
-	if (fExtractorCam.GetSize() != 0)
-	  cont.Add(&fExtractorCam);
-	
-	TObject *pedcam = plist.FindObject("MPedestalCam");
-        if (!pedcam)
-	  *fLog << warn << " - WARNING - MPedestalCam (fundamental)... not found for writing!" << endl;
-        else
-	  cont.Add(pedcam);
-	
-        TObject *geom = plist.FindObject("MGeomCam");
-        if (!geom)
-            *fLog << warn << " - WARNING - MGeomCam... not found for writing!" << endl;
-        else
-            cont.Add(geom);
-    }
+    if (IsIntensity())
+    {
+        cont.Add(&fIntensBadCam);
+        cont.Add(&fIntensCalibCam);
+        cont.Add(&fIntensQECam);
+        cont.Add(&fIntensBlindCam);
+    }
+    else
+    {
+        cont.Add(&fBadPixels);
+        cont.Add(&fCalibrationCam);
+        cont.Add(&fQECam);
+        cont.Add(&fCalibrationBlindCam);
+    }
+    cont.Add(&fCalibrationPINDiode);
+
+    //if (IsRelTimes())
+    cont.Add(IsIntensity() ? (TObject*)&fIntensRelTimeCam : (TObject*)&fRelTimeCam);
+
+    if (fExtractorCam.GetSize() != 0)
+        cont.Add(&fExtractorCam);
+
+    TObject *pedcam = plist.FindObject("MPedestalCam");
+    if (!pedcam)
+        *fLog << warn << " - WARNING - MPedestalCam (fundamental)... not found for writing!" << endl;
+    else
+        cont.Add(pedcam);
+
+    TObject *geom = plist.FindObject("MGeomCam");
+    if (!geom)
+        *fLog << warn << " - WARNING - MGeomCam... not found for writing!" << endl;
+    else
+        cont.Add(geom);
 
     if (IsHistsStorage())
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 6846)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 6858)
@@ -1233,72 +1233,112 @@
     if (fIsPulsePosCheck)
       {
-
-        MHCalibrationPulseTimeCam *hcam = (MHCalibrationPulseTimeCam*)plist.FindObject("MHCalibrationPulseTimeCam");
-        if (fIsPixelCheck)
+        
+        Int_t numhigainsamples = 0;
+        Int_t numlogainsamples = 0;
+        Float_t meanpulsetime  = 0.;
+        Float_t rmspulsetime   = 0.;
+
+        if (IsUseMC())
           {
-            hcam->DrawClone();
-            gPad->SaveAs(Form("%s/PulsePosTest_all.root",fPathOut.Data()));
-            MHCalibrationPix &pix = (*hcam)[fCheckedPixId];
-            pix.DrawClone();
-            gPad->SaveAs(Form("%s/PulsePosTest_Pixel%04d.root",fPathOut.Data(),fCheckedPixId));
-          }
-        
-        MCalibrationPulseTimeCam *cam = (MCalibrationPulseTimeCam*)plist.FindObject("MCalibrationPulseTimeCam");
-        MRawEvtData *data = (MRawEvtData*)plist.FindObject("MRawEvtData");
-        if (cam)
-          {
-            const Float_t meanpulsetime = cam->GetAverageArea(0).GetHiGainMean();
-            const Float_t rmspulsetime = cam->GetAverageArea(0).GetHiGainRms();
-            *fLog << all << "Mean pulse time (cosmics): " << meanpulsetime << "+-" << rmspulsetime << endl;
-            const Int_t newfirst = (Int_t)(meanpulsetime-fExtractWinLeft);
-            Int_t wshigain = fExtractor->InheritsFrom("MExtractTimeAndCharge") 
-              ?  ((MExtractTimeAndCharge*)fExtractor)->GetWindowSizeHiGain()
-              : 6;
-            if (wshigain > 6)
-              wshigain = 6;
-            Int_t wslogain = fExtractor->InheritsFrom("MExtractTimeAndCharge") 
-              ? ((MExtractTimeAndCharge*)fExtractor)->GetWindowSizeLoGain()
-              : 6;
-            if (wslogain > 6)
-              wslogain = 6;
-            const Int_t newlast  = (Int_t)(meanpulsetime+fExtractWinRight);
-            *fLog << all << underline 
-                  << "Try to set new range limits: ("<<newfirst<<","<<newlast<<"+"<<wshigain
-                  <<","<<newfirst-1<<","<<newlast<<"+"<<wslogain<<")"<<endl;
-            if (newfirst < 0)
-              {
-                *fLog << err << "Pulse is too much to the left, cannot go below 0! " << endl;
-                return kFALSE;
-              }
-            if (newlast+wshigain > data->GetNumHiGainSamples()+data->GetNumLoGainSamples()-1)
-              {
-                *fLog << err << "Pulse is too much to the right, cannot go beyond limits! " << endl;
-                *fLog << " Cannot extract at all! ... " << endl;
-                return kFALSE;
-              }
-            if (newlast+wslogain > data->GetNumLoGainSamples())
-              {
-                *fLog << err << "Pulse is too much to the right, cannot go beyond logain limits! " << endl;
-                *fLog << endl;
-                *fLog << "Try to use a different extractor (e.g. with a window size of only 4 sl.) or:" << endl;
-                *fLog << "Set the limit to a lower value (callisto.rc: line 310): " << endl;
-                *fLog << "    MJPedestalY2:ExtractWinRight: 5.0           " << endl;
-                *fLog << "(ATTENTION, you will lose late cosmics pulses!)" << endl;
-                *fLog << endl;
-                return kFALSE;
-              }
-            fExtractor->SetRange(newfirst,newlast+wshigain,
-                                 newfirst>0?newfirst-1:newfirst,data->GetNumLoGainSamples()-1);
-            /*if (!WriteExtractor())
-              {
-                *fLog << err << "Could not write the changes to disk, abort... " << endl;
-                return kFALSE;
-              }*/
+            //
+            // FIXME:
+            // The MC cannot run over the first 2000 pedestal events since almost all
+            // events are empty, therefore a pulse pos. check is not possible, either. 
+            // For the moment, have to fix the problem hardcoded...
+            //
+            //            MMcEvt *evt = (MMcEvt*)plist.FindObject("MMcEvt");
+            //            const Float_t meanpulsetime = evt->GetFadcTimeJitter();
+            meanpulsetime = 4.5;
+            rmspulsetime  = 1.0;
+
+            *fLog << all << "Mean pulse time (MC): " << meanpulsetime << "+-" << rmspulsetime << endl;
+
+            numhigainsamples = 15;
+            numlogainsamples = 15;
+
           }
         else
           {
-            *fLog << err << "Could not determine mean pulse position, abort... " << endl;
+            MHCalibrationPulseTimeCam *hcam = (MHCalibrationPulseTimeCam*)plist.FindObject("MHCalibrationPulseTimeCam");
+            if (fIsPixelCheck)
+              {
+                hcam->DrawClone();
+                gPad->SaveAs(Form("%s/PulsePosTest_all.root",fPathOut.Data()));
+                MHCalibrationPix &pix = (*hcam)[fCheckedPixId];
+                pix.DrawClone();
+                gPad->SaveAs(Form("%s/PulsePosTest_Pixel%04d.root",fPathOut.Data(),fCheckedPixId));
+              }
+            
+            MCalibrationPulseTimeCam *cam = (MCalibrationPulseTimeCam*)plist.FindObject("MCalibrationPulseTimeCam");
+            if (!cam)
+              {
+                *fLog << err << "Could not determine mean pulse position, abort... " << endl;
+                return kFALSE;
+              }
+            
+            meanpulsetime = cam->GetAverageArea(0).GetHiGainMean();
+            rmspulsetime  = cam->GetAverageArea(0).GetHiGainRms();
+
+            *fLog << all << "Mean pulse time (cosmics): " << meanpulsetime << "+-" << rmspulsetime << endl;
+
+            MRawEvtData *data = (MRawEvtData*)plist.FindObject("MRawEvtData");
+
+            numhigainsamples = data->GetNumHiGainSamples();
+            numlogainsamples = data->GetNumLoGainSamples();
+          }
+        
+        //
+        // Get the ranges for the new extractor setting
+        //
+        const Int_t newfirst = (Int_t)(meanpulsetime-fExtractWinLeft);
+        Int_t wshigain = fExtractor->InheritsFrom("MExtractTimeAndCharge") 
+          ?  ((MExtractTimeAndCharge*)fExtractor)->GetWindowSizeHiGain()
+          : 6;
+
+        if (wshigain > 6)
+          wshigain = 6;
+
+        Int_t wslogain = fExtractor->InheritsFrom("MExtractTimeAndCharge") 
+          ? ((MExtractTimeAndCharge*)fExtractor)->GetWindowSizeLoGain()
+          : 6;
+        if (wslogain > 6)
+          wslogain = 6;
+
+        const Int_t newlast  = (Int_t)(meanpulsetime+fExtractWinRight);
+
+        *fLog << all << underline 
+              << "Try to set new range limits: ("<<newfirst<<","<<newlast<<"+"<<wshigain
+              <<","<<newfirst-1<<","<<newlast<<"+"<<wslogain<<")"<<endl;
+        //
+        // Check the ranges for the new extractor setting
+        //
+        if (newfirst < 0)
+          {
+            *fLog << err << "Pulse is too much to the left, cannot go below 0! " << endl;
             return kFALSE;
           }
+        if (newlast+wshigain > numhigainsamples+numlogainsamples-1)
+          {
+            *fLog << err << "Pulse is too much to the right, cannot go beyond limits: " 
+                  << numhigainsamples << "+" << numlogainsamples << "-1" << endl;
+            *fLog << " Cannot extract at all! ... " << endl;
+            return kFALSE;
+          }
+        if (newlast+wslogain > numlogainsamples)
+          {
+            *fLog << err << "Pulse is too much to the right, cannot go beyond logain limits! " << endl;
+            *fLog << endl;
+            *fLog << "Try to use a different extractor (e.g. with a window size of only 4 sl.) or:" << endl;
+            *fLog << "Set the limit to a lower value (callisto.rc: line 329): " << endl;
+            *fLog << "    MJPedestalY2:ExtractWinRight: 5.0           " << endl;
+            *fLog << "(ATTENTION, you will lose late cosmics pulses!)" << endl;
+            *fLog << endl;
+            return kFALSE;
+          }
+        //
+        // Set and store the new ranges 
+        //
+        fExtractor->SetRange(newfirst,newlast+wshigain,
+                             newfirst>0?newfirst-1:newfirst,numlogainsamples-1);
       }
     
Index: trunk/MagicSoft/Mars/mjobs/MJStar.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 6846)
+++ trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 6858)
@@ -203,5 +203,5 @@
     // ------------------ Setup histograms and fill tasks ----------------
     MHCamEvent evt0a(0, "Cleaned", "Signal after Cleaning;;S [\\gamma]");
-    MHCamEvent evt0b(0, "UsedPix", "Pixels marked Used;;Used [%]");
+    MHCamEvent evt0b(0, "UsedPix", "Fraction of Events in which Pixels are used;;Fraction");
     evt0b.SetThreshold(0);
 
Index: trunk/MagicSoft/Mars/mjobs/MSequence.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 6846)
+++ trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 6858)
@@ -175,6 +175,6 @@
 const TString MSequence::GetStandardPath(Bool_t raw) const
 {
-    TString d = MString::Form("/data/MAGIC/Period%03d/", fPeriod);
-    d += raw ? "rawdata/" : "rootdata/";
+    TString d("/magic/data/");
+    d += raw ? "rawfiles/" : "merpp/";
     return d;
 }
@@ -188,5 +188,5 @@
     {
         d = GetStandardPath(raw);
-        d += fNight.GetStringFmt("%Y_%m_%d");
+        d += fNight.GetStringFmt("%Y/%m/%d");
     }
     else
