Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 5386)
+++ trunk/MagicSoft/Mars/Changelog	(revision 5387)
@@ -33,8 +33,11 @@
 
 
+
  2004/11/11: Thomas Bretz
 
    * callisto.cc:
      - fixed a typo in the screen output
+     - added setting of input path to second call to MJPedestal
+       to get the extraction window from the calibration file
 
    * mastro/MAstroCamera.cc:
@@ -76,4 +79,15 @@
      - simplified a complicated if-else-construction towards a
        correct setting of ranges also for the calibration of the signal.
+     - added reading of extraction window from calibration file
+       (ReadCalibration)
+     - made sure that in the case of an extractor from a calibration file
+       the extraction window for pedestals is correctly set
+
+   * mbase/MEvtLoop.cc:
+     - updated a comment
+
+   * msignal/MExtractor.cc:
+     - added printing hi-gain samples
+
 
 
@@ -87,4 +101,6 @@
        on the text messages. At high energies the underestimation of Q
        could be as large as a 20%.
+
+
 
  2004/11/10: Markus Gaug
Index: trunk/MagicSoft/Mars/callisto.cc
===================================================================
--- trunk/MagicSoft/Mars/callisto.cc	(revision 5386)
+++ trunk/MagicSoft/Mars/callisto.cc	(revision 5387)
@@ -343,5 +343,5 @@
         job1.SetEnvDebug(kDebugEnv);
         job1.SetDisplay(d);;
-        //job1.SetPathIn(kInpathY);     // not yet needed
+        job1.SetPathIn(kInpathY);
         //job1.SetPathOut(kOutpathY);   // not yet needed
         job1.SetPathData(kInpathD);
Index: trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 5386)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 5387)
@@ -336,5 +336,6 @@
     pedlo.SetPedestalUpdate(kTRUE);
     // FIXME: How to get the fixed value 15 automatically?
-    pedlo.SetExtractWindow(15, (Int_t)static_cast<MExtractor*>(extractor1)->GetNumHiGainSamples());
+    const Float_t win = static_cast<MExtractor*>(extractor1)->GetNumHiGainSamples();
+    pedlo.SetExtractWindow(15, (UShort_t)TMath::Nint(win));
 
     MMcPedestalCopy        pcopy;
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 5386)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 5387)
@@ -165,4 +165,26 @@
 }
 
+MExtractor *MJPedestal::ReadCalibration() const
+{
+    const TString fname = Form("%s/calib%06d.root", fPathIn.Data(), fSequence.GetSequence());
+
+    *fLog << inf << "Reading from file: " << fname << endl;
+
+    TFile file(fname, "READ");
+    if (!file.IsOpen())
+    {
+        *fLog << err << dbginf << "ERROR - Could not open file " << fname << endl;
+        return NULL;
+    }
+
+    TObject *o = file.Get("ExtractSignal");
+    if (o && !o->InheritsFrom(MExtractor::Class()))
+    {
+        *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
+        return NULL;
+    }
+    return o ? (MExtractor*)o->Clone() : NULL;
+}
+
 //---------------------------------------------------------------------------------
 //
@@ -664,4 +686,16 @@
     MPedCalcFromLoGain pedlogain;
 
+    if (!fPathIn.IsNull())
+    {
+        fExtractor = ReadCalibration();
+        if (!fExtractor)
+            return kFALSE;
+
+        *fLog << all;
+        *fLog << underline << "Signal Extractor found in calibration file" << endl;
+        fExtractor->Print();
+        *fLog << endl;
+    }
+
     MTaskEnv taskenv("ExtractPedestal");
     switch (fExtractType)
@@ -671,5 +705,5 @@
         if (!fExtractor)
             break;
-        pedlogain.SetExtractWindow(15,(Int_t)fExtractor->GetNumHiGainSamples());
+        pedlogain.SetExtractWindow(15, (Int_t)TMath::Nint(fExtractor->GetNumHiGainSamples()));
         break;
 
@@ -678,5 +712,5 @@
             break;
         taskenv.SetDefault(&pedcalc);
-        pedcalc.SetWindowSize((Int_t)fExtractor->GetNumHiGainSamples());
+        pedcalc.SetWindowSize((Int_t)TMath::Nint(fExtractor->GetNumHiGainSamples()));
         pedcalc.SetRange(fExtractor->GetHiGainFirst(), fExtractor->GetHiGainLast());
         break;
@@ -699,4 +733,10 @@
     }
 
+    if (!fPathIn.IsNull())
+    {
+        delete fExtractor;
+        fExtractor = 0;
+    }
+
     tlist.AddToList(&geomapl);
     tlist.AddToList(&merge);
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 5386)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 5387)
@@ -58,4 +58,5 @@
   Extract_t fExtractType;                              // Chosen extractor type
   
+  MExtractor *ReadCalibration() const;
   Bool_t ReadPedestalCam();
   Bool_t WriteResult();
@@ -67,5 +68,5 @@
   void   FixDataCheckHist(TH1D *hist) const;
   
-  Bool_t IsNoStorage    () const { return TESTBIT(fStorage,kNoStorage);     }
+  Bool_t IsNoStorage() const { return TESTBIT(fStorage, kNoStorage); }
   
   Bool_t CheckEnvLocal();
@@ -78,29 +79,28 @@
   const MBadPixelsCam &GetBadPixels() const { return fBadPixels;   }
   
-  const char*  GetOutputFile() const;
-  const Bool_t IsDataCheck  () const    { return fDataCheck; }
-  const Bool_t IsUseData    () const    { return fExtractType == kUseData;   }
-  const Bool_t IsUseExtractor () const    { return fExtractType == kUseExtractor;   }
-  const Bool_t IsUsePedRun   () const    { return fExtractType == kUsePedRun;   }  
+  const char*  GetOutputFile()  const;
+  const Bool_t IsDataCheck()    const { return fDataCheck; }
+  const Bool_t IsUseData()      const { return fExtractType == kUseData;   }
+  const Bool_t IsUseExtractor() const { return fExtractType == kUseExtractor;   }
+  const Bool_t IsUsePedRun()    const { return fExtractType == kUsePedRun;   }
   
   Bool_t Process    ();
   Bool_t ProcessFile();
   
-  void SetBadPixels ( const MBadPixelsCam &bad) { bad.Copy(fBadPixels); }
-  void SetExtractor (       MExtractor* ext   ) { fExtractor = ext;     }
-  void SetInput     (       MRunIter  *iter   ) { fRuns      = iter;    }
-  void SetUseData     ()                        { fExtractType = kUseData;      }
-  void SetUseExtractor()                        { fExtractType = kUseExtractor; }
-  void SetUsePedRun   ()                        { fExtractType = kUsePedRun;    }
-  void SetDataCheck   ( const Bool_t b=kTRUE  ) { fDataCheck = b; 
-                                                  b ? SetDataCheckDisplay() : SetNormalDisplay(); }
-  void SetDataCheckDisplay()                    { fDisplayType = kDataCheckDisplay; }
-  void SetNormalDisplay   ()                    { fDisplayType = kNormalDisplay;    }
+  void SetBadPixels(const MBadPixelsCam &bad) { bad.Copy(fBadPixels); }
+  void SetExtractor(MExtractor* ext)          { fExtractor = ext;     }
+  void SetInput(MRunIter  *iter)              { fRuns      = iter;    }
+  void SetUseData()                           { fExtractType = kUseData;      }
+  void SetUseExtractor()                      { fExtractType = kUseExtractor; }
+  void SetUsePedRun()                         { fExtractType = kUsePedRun;    }
+  void SetDataCheck(const Bool_t b=kTRUE)     { fDataCheck = b; b ? SetDataCheckDisplay() : SetNormalDisplay(); }
+  void SetDataCheckDisplay()                  { fDisplayType = kDataCheckDisplay; }
+  void SetNormalDisplay()                     { fDisplayType = kNormalDisplay;    }
   
-  void SetPedContainerName(const char *name)    { fPedestalCam.SetName(name); }
+  void SetPedContainerName(const char *name)  { fPedestalCam.SetName(name); }
   
   // Storage
-  void SetNoStorage    ( const Bool_t b ) { b ? SETBIT(fStorage,kNoStorage) : CLRBIT(fStorage,kNoStorage); }
-  void SetNormalStorage()                 {                                   CLRBIT(fStorage,kNoStorage); }
+  void SetNoStorage(const Bool_t b)           { b ? SETBIT(fStorage, kNoStorage) : CLRBIT(fStorage,kNoStorage); }
+  void SetNormalStorage()                     { CLRBIT(fStorage, kNoStorage); }
   
   ClassDef(MJPedestal, 0) // Tool to create a pedestal file (MPedestalCam)
Index: trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc	(revision 5386)
+++ trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc	(revision 5387)
@@ -325,5 +325,4 @@
 Int_t MPedCalcFromLoGain::PreProcess(MParList *pList)
 {
-
     Clear();
 
@@ -441,5 +440,5 @@
 
   // 2. Scale the variance to the number of slices:
-  var /= (Float_t)(fExtractWinSize);
+  var /= fExtractWinSize;
   
   // 3. Calculate the RMS from the Variance:
@@ -648,6 +647,6 @@
     *fLog << GetDescriptor() << ":" << endl;
     *fLog << "Parameters used for pedestal calculation from " << fNamePedestalCam << ":"<<endl;
-    *fLog << "CheckWindow   from slice " << fCheckWinFirst   << " to " << fCheckWinLast << endl;
-    *fLog << "ExtractWindow from slice " << fExtractWinFirst << " to " << fExtractWinLast << endl;
+    *fLog << "CheckWindow from slice " << fCheckWinFirst   << " to " << fCheckWinLast << " included." << endl;
+    *fLog << "ExtractWindow from slice " << fExtractWinFirst << " to " << fExtractWinLast << " included." << endl;
     *fLog << "Max allowed signal variation: " << fMaxSignalVar << endl;
     *fLog << "Pedestal Update is " << (fPedestalUpdate?"on":"off") << endl;
Index: trunk/MagicSoft/Mars/msignal/MExtractor.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractor.cc	(revision 5386)
+++ trunk/MagicSoft/Mars/msignal/MExtractor.cc	(revision 5387)
@@ -416,4 +416,6 @@
     *fLog << " Hi Gain Range:  " << (int)fHiGainFirst << " " << (int)fHiGainLast << endl;
     *fLog << " Lo Gain Range:  " << (int)fLoGainFirst << " " << (int)fLoGainLast << endl;
+    *fLog << " Num Samples Hi: " << fNumHiGainSamples << endl;
+    *fLog << " Num Samples Lo: " << fNumHiGainSamples << endl;
     *fLog << " Saturation Lim: " << (int)fSaturationLimit << endl;
 }
