Index: trunk/MagicSoft/Mars/mjobs/MJCalib.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalib.cc	(revision 6689)
+++ trunk/MagicSoft/Mars/mjobs/MJCalib.cc	(revision 6699)
@@ -48,5 +48,5 @@
 // - fPixelCheck   to kFALSE
 //
-MJCalib::MJCalib() : fDataFlag(kIsUseRootData), fPixelCheck(kFALSE), fRuns(NULL)
+MJCalib::MJCalib() : fDataFlag(kIsUseRootData), fStorage(0), fPixelCheck(kFALSE), fRuns(NULL)
 {
   SetCheckedPixId();
Index: trunk/MagicSoft/Mars/mjobs/MJCalib.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalib.h	(revision 6689)
+++ trunk/MagicSoft/Mars/mjobs/MJCalib.h	(revision 6699)
@@ -24,4 +24,12 @@
     Byte_t fDataFlag;                    // Bit-field to store the data type
 
+    enum  Storage_t                        // Possible devices for calibration
+      {
+        kNoStorage,
+        kHistsStorage
+      };                                  // Possible flags for the storage of results
+    
+    Byte_t fStorage;                      // Bit-field for chosen storage type
+
 protected:
 
@@ -34,5 +42,9 @@
     Byte_t GetDataFlag() { return fDataFlag; }
 
+    Bool_t IsNoStorage    () const { return TESTBIT(fStorage,kNoStorage);    }
+    Bool_t IsHistsStorage () const { return TESTBIT(fStorage,kHistsStorage); }
+    
 public:
+
     MJCalib();
 
@@ -52,4 +64,7 @@
     void SetCheckedPixId( const Int_t i=fgCheckedPixId ) { fCheckedPixId = i; }
 
+    void SetNoStorage    ( const Bool_t b=kTRUE ) { b ? SETBIT(fStorage,kNoStorage)    : CLRBIT(fStorage,kNoStorage); }
+    void SetHistsStorage ( const Bool_t b=kTRUE ) { b ? SETBIT(fStorage,kHistsStorage) : CLRBIT(fStorage,kHistsStorage); }
+  
     ClassDef(MJCalib, 0) // Base class for calibration jobs
 };
Index: trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 6689)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 6699)
@@ -129,4 +129,26 @@
     fTitle = title ? title : "Tool to calibrate data";
 
+    //fCruns = NULL;
+}
+
+const char* MJCalibrateSignal::GetInputFile() const
+{
+    const TString name(GetInputFileName());
+    if (name.IsNull())
+        return "";
+
+    return Form("%s/%s", fPathIn.Data(), name.Data());
+}
+
+const char* MJCalibrateSignal::GetInputFileName() const
+{
+
+  if (fSequence.IsValid())
+    return Form("calib%08d.root", fSequence.GetSequence());
+  
+  if (!fRuns)
+    return "";
+  
+  //  return Form("%s-F1.root", (const char*)fCruns->GetRunsAsFileName());
 }
 
@@ -139,5 +161,6 @@
 Bool_t MJCalibrateSignal::ReadCalibration(TObjArray &l, MBadPixelsCam &cam, MExtractor* &ext1, MExtractor* &ext2, TString &geom) const
 {
-    const TString fname = Form("%s/calib%08d.root", fPathIn.Data(), fSequence.GetSequence());
+
+    const TString fname = GetInputFile();
 
     *fLog << inf << "Reading from file: " << fname << endl;
@@ -751,5 +774,5 @@
     if (fPixelCheck)
       {
-	MHCalibrationPulseTimeCam *pcam = (MHCalibrationPulseTimeCam*)plist.FindObject("MHCalibrationPulseCam");
+	MHCalibrationPulseTimeCam *pcam = (MHCalibrationPulseTimeCam*)plist.FindObject("MHCalibrationPulseTimeCam");
 	MHCalibrationPix &pix1 = (*pcam)[fCheckedPixId];
 	pix1.DrawClone("");
@@ -757,10 +780,9 @@
 	if (fIsHiLoCalibration)
 	  {
-	    MHCalibrationHiLoCam *hcam = (MHCalibrationHiLoCam*)plist.FindObject("MHCalibrationPulseCam");
+	    MHCalibrationHiLoCam *hcam = (MHCalibrationHiLoCam*)plist.FindObject("MHCalibrationHiLoCam");
 	    MHCalibrationPix &pix2 = (*hcam)[fCheckedPixId];
 	    pix2.DrawClone("");
 	  }
-}
-
+      }
 
     if (!WriteResult(interlacedcont))
@@ -773,6 +795,13 @@
       addcont.Add(&hilcam);
 
+    if (IsHistsStorage())
+      {
+        addcont.Add(plist.FindObject("MHCalibrationHiLoCam"));
+        addcont.Add(plist.FindObject("MHCalibrationPulseTimeCam"));
+      }
+    
     if (!WriteResult(addcont))
       return kFALSE;
+
 
     // return if job went ok
Index: trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.h	(revision 6689)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.h	(revision 6699)
@@ -15,4 +15,5 @@
 class MPedestalCam;
 class MBadPixelsCam;
+class MRunIter;
 
 class MJCalibrateSignal : public MJCalib
@@ -20,4 +21,6 @@
 private:
 
+  //    MRunIter *fCruns;                   // Calibration run iter
+  
     Bool_t fIsInterlaced;               // Distinguish interlaced from other calibration
     Bool_t fIsRelTimesUpdate;           // Choose to update relative times from interlaced
@@ -32,4 +35,7 @@
                            MExtractor* &ext1, MExtractor* &ext2, TString &geom) const;
 
+    const char*  GetInputFileName() const;
+    const char*  GetInputFile() const;
+    
 public:
 
@@ -42,4 +48,6 @@
     void SetHiLoCalibration( const Bool_t b=kTRUE )  { fIsHiLoCalibration = b; }
 
+    //    void SetInputCal    ( MRunIter *iter       )  { fCruns = iter; }
+  
     ClassDef(MJCalibrateSignal, 0) // Tool to create a pedestal file (MPedestalCam)
 };
Index: trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 6689)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 6699)
@@ -200,7 +200,4 @@
   SetDebug(kFALSE);
   SetIntensity(kFALSE);
-
-  SetNoStorage(kFALSE);
-  SetHistsStorage(kFALSE);
 
   SetReferenceFile();
Index: trunk/MagicSoft/Mars/mjobs/MJCalibration.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibration.h	(revision 6689)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibration.h	(revision 6699)
@@ -131,12 +131,4 @@
   Byte_t fDevices;                                     // Bit-field for used devices for calibration
 
-  enum  Storage_t                                       // Possible devices for calibration
-    {
-      kNoStorage,
-      kHistsStorage
-    };                                                 // Possible flags for the storage of results
-  
-  Byte_t fStorage;                                     // Bit-field for chosen storage type
-
   enum { kRelTimes, kDebug, kIntensity };  // Possible flags
 
@@ -151,7 +143,4 @@
   Bool_t IsDebug        () const { return TESTBIT(fFlags,kDebug);          }
   Bool_t IsIntensity    () const { return TESTBIT(fFlags,kIntensity);      }
-
-  Bool_t IsNoStorage    () const { return TESTBIT(fStorage,kNoStorage);    }
-  Bool_t IsHistsStorage () const { return TESTBIT(fStorage,kHistsStorage); }
 
   void   DrawTab(MParList &plist, const char *cont, const char *name, Option_t *opt);
@@ -218,7 +207,4 @@
 
   // Storage
-  void SetNoStorage    ( const Bool_t b=kTRUE ) { b ? SETBIT(fStorage,kNoStorage)    : CLRBIT(fStorage,kNoStorage); }
-  void SetHistsStorage ( const Bool_t b=kTRUE ) { b ? SETBIT(fStorage,kHistsStorage) : CLRBIT(fStorage,kHistsStorage); }
-  
   void SetReferenceFile( const TString ref=fgReferenceFile ) { fReferenceFile = ref; }
 
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 6689)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 6699)
@@ -101,10 +101,9 @@
 MJPedestal::MJPedestal(const char *name, const char *title) 
     : fExtractor(NULL), fDisplayType(kDisplayDataCheck),
-      fExtractType(kUsePedRun), fExtractionType(kFundamental), fIsUseHists(kFALSE)
+      fExtractType(kUsePedRun), fExtractionType(kFundamental)
 {
     fName  = name  ? name  : "MJPedestal";
     fTitle = title ? title : "Tool to create a pedestal file (MPedestalCam)";
 
-    SetNormalStorage();
     SetUsePedRun();
     SetPathIn("");
@@ -954,9 +953,9 @@
     // 
     if (!fBadPixelsFile.IsNull())
-    {
+      {
         *fLog << inf << "Excluding: " << fBadPixelsFile << endl;
         ifstream fin(fBadPixelsFile.Data());
         fBadPixels.AsciiRead((istream&)fin);
-    }
+      }
 
     MGeomApply geomapl;
@@ -1037,8 +1036,17 @@
     {
 
+      if (fExtractionType!=kFundamental)
+        {
+          pedcalc.SetRandomCalculation(fExtractionType==kWithExtractorRndm);
+          pedlogain.SetRandomCalculation(fExtractionType==kWithExtractorRndm);
+          
+          pedcalc.SetExtractor((MExtractTimeAndCharge*)fExtractor);
+          pedlogain.SetExtractor((MExtractTimeAndCharge*)fExtractor);
+        }
+      
       if (fExtractor->InheritsFrom("MExtractTimeAndCharge"))
         {
 
-          const Float_t f = 0.5+fExtractor->GetHiGainFirst();
+          const Float_t f = 0.1+fExtractor->GetHiGainFirst();
           const Int_t win = ((MExtractTimeAndCharge*)fExtractor)->GetWindowSizeHiGain();
           pedcalc.SetExtractWindow((Int_t)f, win);
@@ -1048,6 +1056,6 @@
       else
         {
-          const Float_t f = 0.5+fExtractor->GetHiGainFirst();
-          const Float_t n = 0.5+fExtractor->GetNumHiGainSamples();
+          const Float_t f = 0.1+fExtractor->GetHiGainFirst();
+          const Float_t n = 0.1+fExtractor->GetNumHiGainSamples();
           pedcalc.SetExtractWindow((Int_t)f, (Int_t)n);
           pedlogain.SetExtractWindow((Int_t)(15+f), (Int_t)n);
@@ -1063,12 +1071,4 @@
       
       
-      if (fExtractionType!=kFundamental)
-        {
-          pedcalc.SetRandomCalculation(fExtractionType==kWithExtractorRndm);
-          pedlogain.SetRandomCalculation(fExtractionType==kWithExtractorRndm);
-          
-          pedcalc.SetExtractor((MExtractTimeAndCharge*)fExtractor);
-          pedlogain.SetExtractor((MExtractTimeAndCharge*)fExtractor);
-        }
     }
     else
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 6689)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 6699)
@@ -60,7 +60,4 @@
     Display_t fDisplayType;                  // Chosen Display type
 
-    enum Storage_t { kNoStorage };           // Possible flags for the storage of results
-    Byte_t fStorage;                         // Bit-field for chosen storage type
-
     enum Extract_t { kUseData, kUsePedRun }; // Possible flags for the extraction of the pedestal
     Extract_t fExtractType;                  // Chosen extractor type
@@ -80,6 +77,4 @@
     void   DisplayOutliers(TH1D *hist) const;
     void   FixDataCheckHist(TH1D *hist) const;
-
-    Bool_t IsNoStorage() const { return TESTBIT(fStorage, kNoStorage); }
 
     Bool_t CheckEnvLocal();
@@ -124,8 +119,4 @@
     MExtractor *GetExtractor() const { return fExtractor; }
 
-    // Storage
-    void SetNoStorage(const Bool_t b=kTRUE)     { b ? SETBIT(fStorage, kNoStorage) : CLRBIT(fStorage,kNoStorage); }
-    void SetNormalStorage()                     { CLRBIT(fStorage, kNoStorage); }
-
     ClassDef(MJPedestal, 0) // Tool to create a pedestal file (MPedestalCam)
 };
