Index: trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.cc	(revision 4640)
+++ trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.cc	(revision 4641)
@@ -474,32 +474,27 @@
       return (*this)[idx].GetInfo()[0];
     case 1:
-      if  ((*this)[idx].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
-        val = 1;
-      else
-        return kFALSE;
+      if  (!(*this)[idx].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        return kFALSE;
+      val = 1;
       break;
     case 2:
-      if  ((*this)[idx].IsUnsuitable(MBadPixelsPix::kUnsuitableEvt))
-        val = 1;
-      else
-        return kFALSE;
+      if  (!(*this)[idx].IsUnsuitable(MBadPixelsPix::kUnsuitableEvt))
+        return kFALSE;
+      val = 1;
       break;
     case 3:
-      if  ((*this)[idx].IsUnsuitable(MBadPixelsPix::kUnreliableRun))
-        val = 1;
-      else
-        return kFALSE;
+      if  (!(*this)[idx].IsUnsuitable(MBadPixelsPix::kUnreliableRun))
+          return kFALSE;
+      val = 1;
       break;
     case 4:
-      if  ((*this)[idx].IsHiGainBad())
-        val = 1;
-      else
-        return kFALSE;
+      if  (!(*this)[idx].IsHiGainBad())
+        return kFALSE;
+      val = 1;
       break;
     case 5:
-      if  ((*this)[idx].IsLoGainBad())
-        val = 1;
-      else
-        return kFALSE;
+      if  (!(*this)[idx].IsLoGainBad())
+        return kFALSE;
+      val = 1;
       break;
     case 6:
@@ -516,86 +511,72 @@
       break;
     case 8:
-      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kHiGainNotFitted))
-        val = 1;
-      else
-        return kFALSE;
+      if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kHiGainNotFitted))
+        return kFALSE;
+      val = 1;
       break;
     case 9:
-      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainNotFitted))
-        val = 1;
-      else
-        return kFALSE;
+      if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainNotFitted))
+        return kFALSE;
+      val = 1;
       break;
     case 10:
-      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kHiGainOscillating))
-        val = 1;
-      else
-        return kFALSE;
+      if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kHiGainOscillating))
+        return kFALSE;
+      val = 1;
       break;
     case 11:
-      if ((*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainOscillating))
-        val = 1;
-      else
-        return kFALSE;
+      if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainOscillating))
+        return kFALSE;
+      val = 1;
       break;
     case 12:
-      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainSaturation ))
-        val = 1;
-      else
-        return kFALSE;
+      if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainSaturation ))
+        return kFALSE;
+      val = 1;
       break;
     case 13:
-      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeIsPedestal ))
-        val = 1;
-      else
-        return kFALSE;
+      if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeIsPedestal ))
+        return kFALSE;
+      val = 1;
       break;
     case 14:
-      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeErrNotValid))
-        val = 1;
-      else
-        return kFALSE;
+      if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeErrNotValid))
+        return kFALSE;
+      val = 1;
       break;
     case 15:
-      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeRelErrNotValid))
-        val = 1;
-      else
-        return kFALSE;
+      if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeRelErrNotValid))
+        return kFALSE;
+      val = 1;
       break;
     case 16:
-      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid ))
-        val = 1;
-      else
-        return kFALSE;
+      if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid ))
+        return kFALSE;
+      val = 1;
       break;
     case 17:
-      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin  ))
-        val = 1;
-      else
-        return kFALSE;
+      if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin  ))
+        return kFALSE;
+      val = 1;
       break;
     case 18:
-      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins ))
-        val = 1;
-      else
-        return kFALSE;
+      if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins ))
+        return kFALSE;
+      val = 1;
       break;
     case 19:
-      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kDeviatingNumPhes ))
-        val = 1;
-      else
-        return kFALSE;
+      if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kDeviatingNumPhes ))
+        return kFALSE;
+      val = 1;
       break;
     case 20:
-      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kRelTimeNotFitted ))
-        val = 1;
-      else
-        return kFALSE;
+      if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kRelTimeNotFitted ))
+        return kFALSE;
+      val = 1;
       break;
     case 21:
-      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kRelTimeOscillating))
-        val = 1;
-      else
-        return kFALSE;
+      if  (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kRelTimeOscillating))
+        return kFALSE;
+      val = 1;
       break;
     default:
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeBlindPix.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeBlindPix.cc	(revision 4640)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeBlindPix.cc	(revision 4641)
@@ -632,5 +632,5 @@
   const Stat_t   entries      = fHGausHist.Integral("width");
   const Double_t lambda_guess = 0.5;
-  const Double_t maximum_bin  = fHGausHist.GetBinCenter(fHGausHist.GetMaximumBin());
+  //const Double_t maximum_bin  = fHGausHist.GetBinCenter(fHGausHist.GetMaximumBin());
   const Double_t norm         = entries/TMath::Sqrt(TMath::TwoPi());
 
Index: trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 4640)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 4641)
@@ -686,5 +686,4 @@
       pave->ConvertNDCtoPad();
       pave->SetTextSize(0.05);
-      TText *t0 = pave->AddText("  ");
       TText *t1 = pave->AddText("Signal smaller 3 Pedestal RMS");
       t1->SetTextColor(gStyle->GetColorPalette(Int_t(1./max*numcol)));
@@ -739,5 +738,4 @@
       pave2->ConvertNDCtoPad();
       pave2->SetTextSize(0.05);
-      TText *tt0 = pave2->AddText("  ");
       TText *tt1 = pave2->AddText("High Gain Signals could not be fitted");
       tt1->SetTextColor(gStyle->GetColorPalette(Int_t(1./max2*numcol)));
@@ -1761,4 +1759,5 @@
     TFile file(oname, "UPDATE");
 
+    *fLog << inf << " - MStatusDisplay..." << flush;
     if (fDisplay && fDisplay->Write()<=0)
     {
@@ -1766,5 +1765,7 @@
         return kFALSE;
     }
-
+    *fLog << inf << "ok." << endl;
+
+    *fLog << inf << " - MCalibrationChargeCam..." << flush;
     if (fCalibrationCam.Write()<=0)
     {
@@ -1772,5 +1773,7 @@
         return kFALSE;
     }
-
+    *fLog << inf << "ok." << endl;
+
+    *fLog << inf << " - MCalibrationChargeBlindCam..." << flush;
     if (fCalibrationBlindCam.Write()<=0)
     {
@@ -1778,5 +1781,7 @@
         return kFALSE;
     }
-
+    *fLog << inf << "ok." << endl;
+
+    *fLog << inf << " - MCalibrationChargePINDiode..." << flush;
     if (fCalibrationPINDiode.Write()<=0)
     {
@@ -1784,5 +1789,7 @@
         return kFALSE;
     }
-
+    *fLog << inf << "ok." << endl;
+
+    *fLog << inf << " - MCalibrationQECam..." << flush;
     if (fQECam.Write()<=0)
     {
@@ -1790,6 +1797,17 @@
         return kFALSE;
     }
+    *fLog << inf << "ok." << endl;
+
+    *fLog << inf << " - MBadPixelsCam..." << flush;
+    if (fBadPixels.Write()<=0)
+    {
+        *fLog << err << "Unable to write MBadPixelsCam to " << oname << endl;
+        return kFALSE;
+    }
+    *fLog << inf << "ok." << endl;
 
     if (fRelTimes)
+    {
+        *fLog << inf << " - MCalibrationRelTimeCam..." << flush;
 	if (fRelTimeCam.Write()<=0)
 	{
@@ -1797,9 +1815,5 @@
 	    return kFALSE;
 	}
-
-    if (fBadPixels.Write()<=0)
-    {
-        *fLog << err << "Unable to write MBadPixelsCam to " << oname << endl;
-        return kFALSE;
+        *fLog << inf << "ok." << endl;
     }
 
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 4640)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 4641)
@@ -91,5 +91,5 @@
 MJPedestal::MJPedestal(const char *name, const char *title) 
     : fEnv(0), fRuns(0), fSequence(0), fExtractor(NULL), fDisplayType(kNormalDisplay),
-      fDataCheck(kFALSE)
+      fDataCheck(kFALSE), fUseData(kFALSE), fMaxEvents(0)
 {
     fName  = name  ? name  : "MJPedestal";
@@ -507,4 +507,7 @@
         SetOutputPath(e1);
     }
+
+    fMaxEvents = fEnv->GetValue("MJPedestal.MaxEvents", fMaxEvents);
+    fUseData   = fEnv->GetValue("MJPedestal.UseData",   fUseData);
 }
 
@@ -545,5 +548,5 @@
     MDirIter iter;
     if (fSequence)
-        fSequence->SetupPedRuns(iter);
+        fUseData ? fSequence->SetupDatRuns(iter) : fSequence->SetupPedRuns(iter);
 
     if (fDataCheck)
@@ -603,5 +606,5 @@
 
     // Execute first analysis
-    if (!evtloop.Eventloop())
+    if (!evtloop.Eventloop(fMaxEvents))
     {
         *fLog << err << GetDescriptor() << ": Failed." << endl;
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 4640)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 4641)
@@ -21,76 +21,78 @@
 {
 private:
+    static const Double_t fgPedestalMin;
+    static const Double_t fgPedestalMax;
+    static const Double_t fgPedRmsMin;
+    static const Double_t fgPedRmsMax;
 
-  static const Double_t fgPedestalMin;
-  static const Double_t fgPedestalMax;
-  static const Double_t fgPedRmsMin;
-  static const Double_t fgPedRmsMax;
-  
-  static const Float_t  fgRefPedClosedLids;
-  static const Float_t  fgRefPedExtraGalactic;
-  static const Float_t  fgRefPedGalactic;
+    static const Float_t  fgRefPedClosedLids;
+    static const Float_t  fgRefPedExtraGalactic;
+    static const Float_t  fgRefPedGalactic;
 
-  static const Float_t  fgRefPedRmsClosedLidsInner;
-  static const Float_t  fgRefPedRmsExtraGalacticInner;
-  static const Float_t  fgRefPedRmsGalacticInner;
-  
-  static const Float_t  fgRefPedRmsClosedLidsOuter;
-  static const Float_t  fgRefPedRmsExtraGalacticOuter;
-  static const Float_t  fgRefPedRmsGalacticOuter;
-  
-  TString fOutputPath;        // Directory where the F0-files get stored
-  
-  TEnv       *fEnv;           // Input setup-file
-  MRunIter   *fRuns;          // Used pedestal runs
-  MSequence  *fSequence;      // Sequence
+    static const Float_t  fgRefPedRmsClosedLidsInner;
+    static const Float_t  fgRefPedRmsExtraGalacticInner;
+    static const Float_t  fgRefPedRmsGalacticInner;
 
-  MExtractor *fExtractor;     // Signal extractor, used to find the nr. of used FADC slices
-  
-  MPedestalCam  fPedestalCam; // Created pedestal results
-  MBadPixelsCam fBadPixels;   // Bad Pixels
-  
-  enum  Display_t { kDataCheckDisplay, kNormalDisplay }; // Possible Display types
+    static const Float_t  fgRefPedRmsClosedLidsOuter;
+    static const Float_t  fgRefPedRmsExtraGalacticOuter;
+    static const Float_t  fgRefPedRmsGalacticOuter;
+    
+    TString fOutputPath;        // Directory where the F0-files get stored
 
-  Display_t fDisplayType;     // Chosen Display type    
-  
-  Bool_t fDataCheck;          // Flag if the data check is run on raw data
-  
-  Bool_t ReadPedestalCam();
-  Bool_t WriteResult();
-  
-  void   DisplayResult(MParList &plist);
-  void   DisplayReferenceLines(MHCamera *cam, const Int_t what) const;
-  void   DisplayOutliers(TH1D *hist) const;
-  void   FixDataCheckHist(TH1D *hist) const;
-  
-  void   CheckEnv();
-  
+    TEnv       *fEnv;           // Input setup-file
+    MRunIter   *fRuns;          // Used pedestal runs
+    MSequence  *fSequence;      // Sequence
+
+    MExtractor *fExtractor;     // Signal extractor, used to find the nr. of used FADC slices
+
+    MPedestalCam  fPedestalCam; // Created pedestal results
+    MBadPixelsCam fBadPixels;   // Bad Pixels
+
+    enum  Display_t { kDataCheckDisplay, kNormalDisplay }; // Possible Display types
+
+    Display_t fDisplayType;     // Chosen Display type    
+    
+    Bool_t fDataCheck;          // Flag if the data check is run on raw data
+    Bool_t fUseData;            // Use data-runs from sequence instead of pedestal runs
+
+    Int_t fMaxEvents;           // Maximum number of events
+
+    Bool_t ReadPedestalCam();
+    Bool_t WriteResult();
+
+    void   DisplayResult(MParList &plist);
+    void   DisplayReferenceLines(MHCamera *cam, const Int_t what) const;
+    void   DisplayOutliers(TH1D *hist) const;
+    void   FixDataCheckHist(TH1D *hist) const;
+    
+    void   CheckEnv();
+
 public:
+    MJPedestal(const char *name=NULL, const char *title=NULL);
+    ~MJPedestal();
 
-  MJPedestal(const char *name=NULL, const char *title=NULL);
-  ~MJPedestal();
-  
-  MPedestalCam &GetPedestalCam()            { return fPedestalCam; }
-  const MBadPixelsCam &GetBadPixels() const { return fBadPixels;   }
-  
-  const char* GetOutputFile() const;
-  const Bool_t IsDataCheck() const    { return fDataCheck;  }
-  
-  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 SetSequence(MSequence *seq) { fSequence = seq; }
-  void SetOutputPath(const char *path=".");
-  void SetEnv(const char *env);
-  
-  void SetDataCheck(const Bool_t b=kTRUE) { fDataCheck = b; SetDataCheckDisplay(); }
-  
-  void SetDataCheckDisplay() { fDisplayType = kDataCheckDisplay; }
-  void SetNormalDisplay()    { fDisplayType = kNormalDisplay;    }
-  
-  ClassDef(MJPedestal, 0) // Tool to create a pedestal file (MPedestalCam)
+    MPedestalCam &GetPedestalCam()            { return fPedestalCam; }
+    const MBadPixelsCam &GetBadPixels() const { return fBadPixels;   }
+
+    const char* GetOutputFile() const;
+    const Bool_t IsDataCheck() const    { return fDataCheck;  }
+
+    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 SetSequence(MSequence *seq, Bool_t usedata=kFALSE) { fSequence = seq; }
+    void SetOutputPath(const char *path=".");
+    void SetEnv(const char *env);
+    void SetMaxEvents(Int_t max) { fMaxEvents = max; }
+
+    void SetDataCheck(const Bool_t b=kTRUE) { fDataCheck = b; SetDataCheckDisplay(); }
+
+    void SetDataCheckDisplay() { fDisplayType = kDataCheckDisplay; }
+    void SetNormalDisplay()    { fDisplayType = kNormalDisplay;    }
+
+    ClassDef(MJPedestal, 0) // Tool to create a pedestal file (MPedestalCam)
 };
 
