Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 5868)
+++ trunk/MagicSoft/Mars/Changelog	(revision 5869)
@@ -21,52 +21,82 @@
                                                  -*-*- END OF LINE -*-*-
 
+ 2005/01/17 Thomas Bretz
+ 
+   * manalysis/MEnergyEstimate.[h,cc]:
+     - changed to be more general. Energy is now estimated from a rule
+       (MDataChain) The default behaviour is still the same as before
+       to copy the energy from MMcEvt
+
+   * mbase/MTask.cc:
+     - changed to write out the descriptor istead of the task-name only
+       in Pre/PostProcess
+
+   * mhbase/MH.cc:
+     - initialize fSerialNumber and fNumExecutions in constructor
+
+   * mhflux/MHFalseSource.cc:
+     - according to a suggestion by Markus Mayer I have changed
+       \\sigma_{max}=f to S_{max}=f\\sigma
+
+   * mjobs/MJCalibrateSignal.cc:
+     - as discussed with Markus and Abelardo fixed the MFTriggerPattern
+       call.
+
+   * mtrigger/MFTriggerPattern.cc, mtrigger/MTriggerPattern.cc,
+     mtrigger/MTriggerPatternDecode.cc:
+     - added some comment about file version
+
+
+
  2005/01/17 Markus Gaug
 
-  * msignal/MExtractTimeAndChargeDigitalFilter.cc
-    - remove a situation where the high-gain signal can be 0.
-
-  * mtrigger/MTriggerPattern.h
-    - fixed a bug in defining the trigger bit pattern (Have to start
-      from 0 instead of 1)
+   * msignal/MExtractTimeAndChargeDigitalFilter.cc
+     - remove a situation where the high-gain signal can be 0.
+
+   * mtrigger/MTriggerPattern.h
+     - fixed a bug in defining the trigger bit pattern (Have to start
+       from 0 instead of 1)
+
 
 
  2005/01/16 Markus Gaug
 
-  * mhcalib/MHCalibrationCam.[h,cc]
-  * mhcalib/MHCalibrationRelTimeCam.[h,cc]
-  * mhcalib/MHCalibrationChargeCam.[h,cc]
-    - put overflow management and results camera initialization into 
-      base class
+   * mhcalib/MHCalibrationCam.[h,cc], mhcalib/MHCalibrationRelTimeCam.[h,cc],
+     mhcalib/MHCalibrationChargeCam.[h,cc]
+     - put overflow management and results camera initialization into 
+       base class
  
-  * mcalib/MCalibrateData.[h,cc]
-    - added possibility to re-normalize signal to equiv. photo-electrons
-      ( SetSignalType(MCalibrateData::kPhe) ). 
-      Default is old version in photons
-    - speed up Process by storing pre-calculated calibration constants
-      in arrays (needed 40% of CPU time of the eventloop before, now: 23%) 
-    - added new pointer to different MCalibrationChargeCam used for 
-      updates
-    - added possibility to update the conversion factors using the 
-      MCalibrationChargeCam stored in fCalibUpdate. 
-    - added Print() function
-
-  * mcalib/MCalibCalcFromPast.[h,cc]
-    - committed final version, now also in the Makefile
-
- 
-  * mjobs/MJCalibrateSignalFromOutside.[h,cc]
-  * macros/calibration.C
-    - committed final version, now able to calibrate interlaced cal. 
-      events.
+   * mcalib/MCalibrateData.[h,cc]
+     - added possibility to re-normalize signal to equiv. photo-electrons
+       ( SetSignalType(MCalibrateData::kPhe) ). 
+       Default is old version in photons
+     - speed up Process by storing pre-calculated calibration constants
+       in arrays (needed 40% of CPU time of the eventloop before, now: 23%) 
+     - added new pointer to different MCalibrationChargeCam used for 
+       updates
+     - added possibility to update the conversion factors using the 
+       MCalibrationChargeCam stored in fCalibUpdate. 
+     - added Print() function
+
+   * mcalib/MCalibCalcFromPast.[h,cc]
+     - committed final version, now also in the Makefile
+
+   * mjobs/MJCalibrateSignalFromOutside.[h,cc], macros/calibration.C
+     - committed final version, now able to calibrate interlaced cal. 
+       events.
+
 
 
  2005/01/14 Hendrik Bartko
 
-  * msignal/calibration_weights_UV.dat
-    - fixed a small bug in the noise autocorrelation of the AB-noise
-  * msignal/calibration_weights_blue.dat	
-    - new weights file for blue calibration pulses
-  * cosmics_weights.dat
-    - fixed a small bug in the noise autocorrelation of the AB-noise
+   * msignal/calibration_weights_UV.dat
+     - fixed a small bug in the noise autocorrelation of the AB-noise
+
+   * msignal/calibration_weights_blue.dat	
+     - new weights file for blue calibration pulses
+
+   * cosmics_weights.dat
+     - fixed a small bug in the noise autocorrelation of the AB-noise
+
 
 
@@ -89,4 +119,5 @@
      - Use now the new class MTriggerPattern directly to recognize an 
        interlaced pedestal event.     
+
 
 
Index: trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.cc	(revision 5868)
+++ trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.cc	(revision 5869)
@@ -25,10 +25,20 @@
 
 /////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MEnergyEstimate                                                         //
-//                                                                         //
-// Task to estimate the energy                                             //
-//                                                                         //
-//                                                                         //
+//
+// MEnergyEstimate
+//
+// Task to estimate the energy by a rule, eg:
+//
+// MEnergyEstimate est;
+// est.SetRule("0.5 + (1.1*MHillas.fLength) + (2.2*MHillasSrc.fDist) + (3.3*MHillas.fSize) +"
+//             "(4.4*MHillas.fSize*MHillas.fLength) + (5.5*MHillasSrc.fDist*MHillas.fLength)");
+//
+// For description of rules, see MDataChain.
+//
+// The default rule is "MMcEvt.fEnergy"
+//
+// Output:
+//   MEnergyEst
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MEnergyEstimate.h"
@@ -36,6 +46,5 @@
 #include "MParList.h"
 
-#include "MMcEvt.hxx"
-#include "MHillas.h"
+#include "MDataChain.h"
 #include "MEnergyEst.h"
 
@@ -47,44 +56,80 @@
 using namespace std;
 
+// --------------------------------------------------------------------------
+//
+// Default constructor. Initialize fData with default rule "MMcEvt.fEnergy"
+//
+MEnergyEstimate::MEnergyEstimate(const char *name, const char *title)
+    : fData(0), fEnergy(0)
+{
+    fName  = name  ? name  : "MEnergyEstimate";
+    fTitle = title ? title : "Task to estimate the energy by a rule";
+
+    fData = new MDataChain("MMcEvt.fEnergy");
+}
 
 // --------------------------------------------------------------------------
 //
-// Default constructor.
+// delete fData
 //
-MEnergyEstimate::MEnergyEstimate(const char *name, const char *title)
+MEnergyEstimate::~MEnergyEstimate()
 {
-    fName  = name  ? name  : "MEnergyEstimate";
-    fTitle = title ? title : "Task to estimate the energy";
-
-    AddToBranchList("MMcEvt.fEnergy");
+    delete fData;
 }
 
+// --------------------------------------------------------------------------
+//
+// Delete fData. Initialize a new MDataChain with rule.
+// Returns if fData->IsValid()
+//
+Bool_t MEnergyEstimate::SetRule(const char *rule)
+{
+    delete fData;
+    fData = new MDataChain(rule);
+
+    return fData->IsValid();
+}
+
+// --------------------------------------------------------------------------
+//
+// Forwards SetVariables to fData to allow optimizations.
+//
+void MEnergyEstimate::SetVariables(const TArrayD &arr)
+{
+    fData->SetVariables(arr);
+}
+
+// --------------------------------------------------------------------------
+//
+// FindCreate "MEnergyEst"
+// PreProcess fData.
+//
 Int_t MEnergyEstimate::PreProcess(MParList *plist)
 {
-   fHillas = (MHillas*)plist->FindObject("MHillas");
-   if (!fHillas)
-   {
-       *fLog << err << dbginf << "MHillas not found... aborting." << endl;
-       return kFALSE;
-   }
+    fEnergy = (MEnergyEst*)plist->FindCreateObj("MEnergyEst");
+    if (!fEnergy)
+        return kFALSE;
 
-   fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
-   if (!fMcEvt)
-   {
-       *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
-       return kFALSE;
-   }
+    if (!fData->PreProcess(plist))
+        return kFALSE;
 
-   fEnergy = (MEnergyEst*)plist->FindCreateObj("MEnergyEst");
-   if (!fEnergy)
-      return kFALSE;
+    *fLog << inf << "Rule for energy estimation: " << fData->GetRule() << endl;
 
-   return kTRUE;    
+    return kTRUE;
 }
 
+// --------------------------------------------------------------------------
+//
+// Get value from fData and set it to fEnergy. SetReadyToSave for fEnergy.
+// Return kCONTINUE if value is NaN (Not a Number)
+//
 Int_t MEnergyEstimate::Process()
 {
-  //fEnergy->SetEnergy(fHillas->GetSize());
-  fEnergy->SetEnergy(fMcEvt->GetEnergy());
-  return kTRUE;
+    const Double_t val = fData->GetValue();
+    if (TMath::IsNaN(val))
+        return kCONTINUE;
+
+    fEnergy->SetEnergy(val);
+    fEnergy->SetReadyToSave();
+    return kTRUE;
 }
Index: trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.h	(revision 5868)
+++ trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.h	(revision 5869)
@@ -6,6 +6,5 @@
 #endif
 
-class MMcEvt;
-class MHillas;
+class MData;
 class MEnergyEst;
 
@@ -13,15 +12,19 @@
 {
 private:
-    MMcEvt     *fMcEvt;
-    MHillas    *fHillas;
+    MData      *fData;    //->
     MEnergyEst *fEnergy;
 
 public:
     MEnergyEstimate(const char *name=NULL, const char *title=NULL);
+    ~MEnergyEstimate();
+
+    Bool_t SetRule(const char *rule);
 
     Int_t PreProcess(MParList *plist);
     Int_t Process();
 
-    ClassDef(MEnergyEstimate, 0) // Task to copy the MC energy (preliminary)
+    void SetVariables(const TArrayD &);
+
+    ClassDef(MEnergyEstimate, 0) // Task to estimate the energy by a rule
 };
 
Index: trunk/MagicSoft/Mars/mbase/MTask.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 5868)
+++ trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 5869)
@@ -207,5 +207,5 @@
     fNumExec0 = GetNumExecutionsTotal();
 
-    *fLog << all << fName << "... " << flush;
+    *fLog << all << GetDescriptor() << "... " << flush;
     if (fDisplay)
         fDisplay->SetStatusLine2(*this);
@@ -270,5 +270,5 @@
     fIsPreprocessed = kFALSE;
 
-    *fLog << all << fName << "... " << flush;
+    *fLog << all << GetDescriptor() << "... " << flush;
     if (fDisplay)
         fDisplay->SetStatusLine2(*this);
Index: trunk/MagicSoft/Mars/mhbase/MH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 5868)
+++ trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 5869)
@@ -86,4 +86,6 @@
 //
 MH::MH(const char *name, const char *title)
+    : fSerialNumber(0), fNumExecutions(0)
+
 {
     //
Index: trunk/MagicSoft/Mars/mhflux/MHFalseSource.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHFalseSource.cc	(revision 5868)
+++ trunk/MagicSoft/Mars/mhflux/MHFalseSource.cc	(revision 5869)
@@ -624,5 +624,5 @@
             // Than for their projections
             TH1 *h = fHist.ProjectionZ("Alpha_z", maxx, maxx, maxy, maxy);
-            h->SetTitle(Form("Distribution of \\alpha for x=%.2f y=%.2f (\\sigma_{max}=%.1f)", x, y, s));
+            h->SetTitle(Form("Distribution of \\alpha for x=%.2f y=%.2f (S_{max}=%.1f\\sigma)", x, y, s));
 
             TH1D *h0=0;
@@ -1104,5 +1104,5 @@
     if (maxx>0 && maxy>0)
     {
-        const char *title = Form(" \\alpha for x=%.2f y=%.2f (\\sigma_{max}=%.1f) ",
+        const char *title = Form(" \\alpha for x=%.2f y=%.2f (S_{max}=%.1f\\sigma) ",
                                  hist->GetXaxis()->GetBinCenter(maxx),
                                  hist->GetYaxis()->GetBinCenter(maxy), maxs);
@@ -1211,5 +1211,5 @@
         leg->SetBorderSize(1);
         leg->SetTextSize(0.1);
-        leg->AddText(Form("\\sigma_{max}=%.1f at \\alpha_{max}=%d\\circ", maxsig, max));
+        leg->AddText(Form("S_{max}=%.1f\\sigma at \\alpha_{max}=%d\\circ", maxsig, max));
         leg->SetBit(kCanDelete);
         leg->Draw();
Index: trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 5868)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 5869)
@@ -335,7 +335,5 @@
 
     MFTriggerPattern ftp;
-    ftp.DenyCalibration();
-    ftp.DenyPedestal();
-    ftp.DenyPinDiode();
+    ftp.RequireCalibration();
 
     MContinue conttp(&ftp, "ContTrigPattern");
Index: trunk/MagicSoft/Mars/mtrigger/MFTriggerPattern.cc
===================================================================
--- trunk/MagicSoft/Mars/mtrigger/MFTriggerPattern.cc	(revision 5868)
+++ trunk/MagicSoft/Mars/mtrigger/MFTriggerPattern.cc	(revision 5869)
@@ -27,5 +27,7 @@
 //   MFTriggerPattern
 //
-//  A Filter for testing the trigger performance using Trigger Pattern
+//  A Filter for testing the trigger performance using Trigger Pattern.
+//
+// For files before file version 5 the trigger pattern is set to 00000000.
 //
 /////////////////////////////////////////////////////////////////////////////
Index: trunk/MagicSoft/Mars/mtrigger/MTriggerPattern.cc
===================================================================
--- trunk/MagicSoft/Mars/mtrigger/MTriggerPattern.cc	(revision 5868)
+++ trunk/MagicSoft/Mars/mtrigger/MTriggerPattern.cc	(revision 5869)
@@ -38,4 +38,6 @@
 // class version number (ClassDef) and document your change HERE.
 //
+// For files before file version 5 the trigger pattern is set to 00000000.
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MTriggerPattern.h"
Index: trunk/MagicSoft/Mars/mtrigger/MTriggerPatternDecode.cc
===================================================================
--- trunk/MagicSoft/Mars/mtrigger/MTriggerPatternDecode.cc	(revision 5868)
+++ trunk/MagicSoft/Mars/mtrigger/MTriggerPatternDecode.cc	(revision 5869)
@@ -28,4 +28,7 @@
 //
 //  Decodes the trigger pattern from MRawEvtData into MTriggerPattern.
+//
+// For files before file version 5 the trigger pattern is set to 00000000.
+// This can be changed using the information about the file-type.
 //
 // Input:
@@ -91,6 +94,11 @@
 // --------------------------------------------------------------------------
 //
+// For files before file version 5 the trigger pattern is set to 00000000.
+// This can be changed using the information about the file-type.
+//
 Int_t MTriggerPatternDecode::Process()
 {
+    // No setting necessary because MTriggerPattern::reset() has
+    // been called just before
     if (fRunHeader->GetFormatVersion()<5)
         return kTRUE;
