Index: trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 6798)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 6820)
@@ -159,6 +159,9 @@
 Bool_t MJCalibrateSignal::WriteResult(TObjArray &cont)
 {
-    const TString name(Form("signal%08d.root", fSequence.GetSequence()));
-    return WriteContainer(cont, name);
+  if (IsNoStorage())
+    return kTRUE;
+
+  const TString name(Form("signal%08d.root", fSequence.GetSequence()));
+  return WriteContainer(cont, name);
 }
 
@@ -367,24 +370,4 @@
 
     *fLog << all;
-    if (extractor1)
-    {
-        *fLog << underline << "Signal Extractor found in calibration file" << endl;
-        extractor1->Print();
-        *fLog << endl;
-	extractor3 = (MExtractor*)extractor1->Clone();
-        
-    }
-    else
-        *fLog << inf << "No Signal Extractor: ExtractSignal in file." << endl;
-
-    if (extractor2)
-    {
-        *fLog << underline << "Time Extractor found in calibration file" << endl;
-        extractor2->Print();
-        *fLog << endl;
-    }
-    else
-        *fLog << inf << "No Time Extractor: ExtractTime in file." << endl;
-
     if (!geom.IsNull())
         *fLog << inf << "Camera geometry found in file: " << geom << endl;
@@ -395,4 +378,23 @@
       if (!ReadExtractorCosmics(extractor1))
         *fLog << warn << "No extraction window update for signal extractor found" << endl;
+
+    if (extractor1)
+    {
+      *fLog << underline << "Signal Extractor found in calibration file" << endl;
+      extractor1->Print();
+      *fLog << endl;
+      extractor3 = (MExtractor*)extractor1->Clone();
+    }
+    else
+      *fLog << inf << "No Signal Extractor: ExtractSignal in file." << endl;
+
+    if (extractor2)
+    {
+        *fLog << underline << "Time Extractor found in calibration file" << endl;
+        extractor2->Print();
+        *fLog << endl;
+    }
+    else
+        *fLog << inf << "No Time Extractor: ExtractTime in file." << endl;
 
     // This is necessary for the case in which it is not in the files
@@ -436,9 +438,5 @@
     const TString fname(Form("%s{s/_D_/_Y_}{s/.raw$/.root}", fPathOut.Data()));
 
-    // Write the special MC tree
-    MWriteRootFile writemc(2, fname, fOverwrite?"RECREATE":"NEW");
-    writemc.SetName("WriteMC");
-    writemc.AddContainer("MMcEvtBasic", "OriginalMC");
-
+    
     // Skips empty MC events (Not necessary, but faster!)
     MContinue contmc("MRawEvtData.GetNumPixels<0.5", "ContEmptyMC");
@@ -689,4 +687,9 @@
     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
     MTaskList tlist2;
@@ -836,13 +839,13 @@
       interlacedcont.Add(&hilcam);
 
+    if (IsHistsStorage())
+      {
+        interlacedcont.Add(plist.FindObject("MHCalibrationHiLoCam"));
+        interlacedcont.Add(plist.FindObject("MHCalibrationPulseTimeCam"));
+      }
+    
     if (!WriteResult(interlacedcont))
       return kFALSE;
 
-    //    if (IsHistsStorage())
-    //      {
-    //        addcont.Add(plist.FindObject("MHCalibrationHiLoCam"));
-    //        addcont.Add(plist.FindObject("MHCalibrationPulseTimeCam"));
-    //      }
-    
     // return if job went ok
     *fLog << all << GetDescriptor() << ": Done." << endl;
Index: trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 6798)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 6820)
@@ -177,5 +177,5 @@
 const Int_t MJCalibration::gkThirdBlindPixelInstallation   = 43308;
 const TString MJCalibration::fgReferenceFile = "mjobs/calibrationref.rc";
-const TString MJCalibration::fgHiLoCalibFile = "mjobs/hilocalib_df6.root";
+const TString MJCalibration::fgHiLoCalibFile = "mjobs/hilocalib_df4.root";
 // --------------------------------------------------------------------------
 //
@@ -1482,4 +1482,7 @@
   MCalibrationHiLoCam hilocam;
   
+  *fLog << all << "Initializing High gain vs. Low gain intercalibration from " << fHiLoCalibFile << endl;
+  *fLog << all << endl;
+
   if (hilocam.Read()<=0)
   {
@@ -1712,10 +1715,4 @@
     }
 
-    //if (!CheckEnv())
-    //    return kFALSE;
-
-    if (!CheckEnv())
-      return kFALSE;
-
     // --------------------------------------------------------------------------------
 
@@ -1732,4 +1729,9 @@
     // --------------------------------------------------------------------------------
     
+    if (!CheckEnv())
+      return kFALSE;
+
+    // --------------------------------------------------------------------------------
+
     // Setup Tasklist
     MParList plist;
@@ -1975,33 +1977,35 @@
     tlist.PrintStatistics();
 
-  if (fIsPixelCheck)
-    {
-      MHCalibrationChargeCam *hcam = (MHCalibrationChargeCam*)plist.FindObject("MHCalibrationChargeCam");
-      MHCalibrationChargePix &pix1 = (MHCalibrationChargePix&)(*hcam)[fCheckedPixId];
-      pix1.DrawClone("");
-      
-      MHCalibrationChargePix &pix2 = (MHCalibrationChargePix&)(*hcam)(fCheckedPixId);
-      pix2.DrawClone("");
-      
-      if (IsRelTimes())
-	{
-	  MHCalibrationRelTimeCam *hccam = (MHCalibrationRelTimeCam*)plist.FindObject("MHCalibrationRelTimeCam");
-	  MHCalibrationPix &pix11 = (*hccam)[fCheckedPixId];
-	  pix11.DrawClone("");
-	  MHCalibrationPix &pix12 = (*hccam)(fCheckedPixId);
-	  pix12.DrawClone("");
-	}
-    }
-
+    // --------------------------------------------------------------------------------
+
+    if (fIsPixelCheck)
+      {
+        MHCalibrationChargeCam *hcam = (MHCalibrationChargeCam*)plist.FindObject("MHCalibrationChargeCam");
+        MHCalibrationChargePix &pix1 = (MHCalibrationChargePix&)(*hcam)[fCheckedPixId];
+        pix1.DrawClone("");
+        
+        MHCalibrationChargePix &pix2 = (MHCalibrationChargePix&)(*hcam)(fCheckedPixId);
+        pix2.DrawClone("");
+        
+        if (IsRelTimes())
+          {
+            MHCalibrationRelTimeCam *hccam = (MHCalibrationRelTimeCam*)plist.FindObject("MHCalibrationRelTimeCam");
+            MHCalibrationPix &pix11 = (*hccam)[fCheckedPixId];
+            pix11.DrawClone("");
+            MHCalibrationPix &pix12 = (*hccam)(fCheckedPixId);
+            pix12.DrawClone("");
+          }
+      }
+    
     if (!fCalibrationPINDiode.IsValid())
-        SetUsePINDiode(kFALSE);
-
+      SetUsePINDiode(kFALSE);
+    
     DisplayResult(plist);
-
+    
     if (!WriteResult(plist))
-        return kFALSE;
-
+      return kFALSE;
+    
     *fLog << all << GetDescriptor() << ": Done." << endl;
-
+    
     return kTRUE;
 }
Index: trunk/MagicSoft/Mars/mjobs/MJCut.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 6798)
+++ trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 6820)
@@ -347,6 +347,6 @@
     TString fname0(path);
     TString fname1(path);
-    fname0 += fNameSummary.IsNull() ? Form("ganymed%08d-summary.root", set.GetNumAnalysis()) : fNameSummary;
-    fname1 += fNameResult.IsNull()  ? Form("ganymed%08d-result.root",  set.GetNumAnalysis()) : fNameResult;
+    fname0 += fNameSummary.IsNull() ?  (TString) Form("ganymed%08d-summary.root", set.GetNumAnalysis()) : fNameSummary;
+    fname1 += fNameResult.IsNull()  ?  (TString) Form("ganymed%08d-result.root",  set.GetNumAnalysis()) : fNameResult;
 
     MWriteRootFile write0(fPathOut.IsNull()?0:fname0.Data(), fOverwrite?"RECREATE":"NEW");
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 6798)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 6820)
@@ -179,4 +179,11 @@
     const TString fname = GetOutputFile();
 
+    const Bool_t fileexist = !gSystem->AccessPathName(fname, kFileExists);
+    if (!fileexist)
+      {
+        *fLog << inf << "Input file " << fname << " not found, will create pedestals" << endl;
+        return kFALSE;
+      }
+
     *fLog << inf << "Reading pedestals from file: " << fname << endl;
 
@@ -242,8 +249,9 @@
   *fLog << inf << "Updating extractor in file: " << fname << endl;
 
-  TFile file(fname, "UPDATE");
+  TFile file(fname, fOverwrite?"RECREATE":"NEW");
   if (!file.IsOpen())
     {
       *fLog << err << dbginf << "ERROR - Could not open file " << fname << endl;
+      *fLog << err << dbginf << "Maybe, file " << fname << " already exists, call callisto with option -f then." << endl;
       return kFALSE;
     }
@@ -252,5 +260,5 @@
   cont.Add(fExtractor);
 
-  return WriteContainer(cont,name, fOverwrite?"RECREATE":"NEW");
+  return WriteContainer(cont);
 }
 
@@ -914,5 +922,6 @@
         if (fRuns && fRuns->GetNumRuns() != fRuns->GetNumEntries())
         {
-            *fLog << err << "Number of files found doesn't match number of runs... abort." << endl;
+            *fLog << err << "Number of files found doesn't match number of runs... abort."
+                << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl;
             return kFALSE;
         }
@@ -1007,7 +1016,9 @@
     
     MHPedestalCam hpedcam;
-    hpedcam.SetRenorm(kTRUE);
+    if (fExtractionType != kFundamental)
+      hpedcam.SetRenorm(kTRUE);
     //    fPedestalHist.SetRenorm(kTRUE);
     //    fPedestalHist.SetPedestalsOut(&fPedestalCamOut);
+    hpedcam.SetPedestalsOut(&fPedestalCamOut);
 
     MPedestalCam pedinter;
@@ -1038,5 +1049,5 @@
     sel.SetNumSelectEvts(0);
      
-    if (fExtractionType!=kFundamental && fExtractor)
+    if (fExtractor)
       {
         fExtractor->SetFilter(&sel);
@@ -1077,5 +1088,8 @@
     
     if (fIsUseHists)
-    {
+      {
+        if (fExtractor->InheritsFrom("MExtractTimeAndCharge"))
+          hpedcam.SetFitStart(-10.*((MExtractTimeAndCharge*)fExtractor)->GetWindowSizeHiGain());
+        
         pedcalc.SetIntermediateStorage();
         pedlogain.SetIntermediateStorage();
@@ -1248,5 +1262,5 @@
             const Float_t meanpulsetime = cam->GetAverageArea(0).GetHiGainMean();
             const Float_t rmspulsetime = cam->GetAverageArea(0).GetHiGainRms();
-            *fLog << inf << "Mean pulse time (cosmics): " << meanpulsetime << "+-" << rmspulsetime << endl;
+            *fLog << all << "Mean pulse time (cosmics): " << meanpulsetime << "+-" << rmspulsetime << endl;
             const Int_t newfirst = (Int_t)(meanpulsetime-fExtractWinLeft);
             Int_t wshigain = fExtractor->InheritsFrom("MExtractTimeAndCharge") 
@@ -1255,10 +1269,13 @@
             if (wshigain > 6)
               wshigain = 6;
-            const Int_t wslogain = fExtractor->InheritsFrom("MExtractTimeAndCharge") 
+            Int_t wslogain = fExtractor->InheritsFrom("MExtractTimeAndCharge") 
               ? ((MExtractTimeAndCharge*)fExtractor)->GetWindowSizeLoGain()
               : 6;
+            if (wslogain > 6)
+              wslogain = 6;
             const Int_t newlast  = (Int_t)(meanpulsetime+fExtractWinRight);
-            *fLog << inf << "Try to set new range limits: ("<<newfirst<<","<<newlast<<"+"<<wshigain
-                  <<","<<newfirst<<","<<newlast<<"+"<<wslogain<<")"<<endl;
+            *fLog << all << underline 
+                  << "Try to set new range limits: ("<<newfirst<<","<<newlast<<"+"<<wshigain
+                  <<","<<newfirst-1<<","<<newlast<<"+"<<wslogain<<")"<<endl;
             if (newfirst < 0)
               {
@@ -1274,9 +1291,15 @@
             if (newlast+wslogain > data->GetNumLoGainSamples())
               {
-                *fLog << err << "Pulse is too much to the right, cannot go beyond logain limits! " 
-                      << " Try to use a different extractor ... " << endl;
+                *fLog << err << "Pulse is too much to the right, cannot go beyond logaie 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,data->GetNumLoGainSamples()-1);
+            fExtractor->SetRange(newfirst,newlast+wshigain,
+                                 newfirst>0?newfirst-1:newfirst,data->GetNumLoGainSamples()-1);
             if (!WriteExtractor())
               {
