Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 2001)
+++ trunk/MagicSoft/Mars/Changelog	(revision 2002)
@@ -3,15 +3,28 @@
  2003/04/24: Thomas Bretz
     
-    * mfilter/MFCT1Supercuts.[h,cc]:
-      - removed
-
-    * manalysis/MPadSchweizer.[h,cc]:
-      - renamed arguments of SetHistograms to Mars style
-      - removed default argument for SetHistograms (usage would result
-        in a crash)
-      - removed empty destructor
-
-    * mhistmc/MHMcTriggerLvl2.h:
-      - removed the wrong f in GetHistf
+   * mfilter/MFCT1Supercuts.[h,cc]:
+     - removed
+   
+   * manalysis/MPadSchweizer.[h,cc]:
+     - renamed arguments of SetHistograms to Mars style
+     - removed default argument for SetHistograms (usage would result
+       in a crash)
+     - removed empty destructor
+
+   * mhistmc/MHMcTriggerLvl2.h:
+     - removed the wrong f in GetHistf
+
+   * manalysis/MSigmabarParam.h:
+     - added const qualifiers to getters
+     
+   * mfileio/MWriteRootFile.[h,cc]:
+     - fixed support for UPDATE
+     
+   * mfilter/MFEnergySlope.cc:
+     - cleaned
+     - removed empty PostProcess
+     
+   * mhist/MHCerPhotEvt.cc:
+     - removed ratio from Fill
 
 
Index: trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 2001)
+++ trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 2002)
@@ -208,9 +208,9 @@
 Bool_t MWriteRootFile::GetContainer(MParList *pList)
 {
+    //
+    // loop over all branches which are 'marked' as branches to get written.
+    //
     MRootFileBranch *entry;
 
-    //
-    // loop over all branches which are 'marked' as branches to get written.
-    //
     TIter Next(&fBranches);
     while ((entry=(MRootFileBranch*)Next()))
@@ -274,4 +274,10 @@
             fTrees.AddLast(tree);
 
+            //
+            // If the tree does not already exist in the file mark this
+            // tree as a branch created by MWriteRootFile
+            //
+            entry->SetBit(kIsNewTree);
+
             gDirectory = save;
 
@@ -280,15 +286,17 @@
 
         //
+        // In case the file is opened as 'UPDATE' the tree may still not
+        // be in the list. Because it neither was created previously,
+        // nor this time, so the corresponding entries is marked as a
+        // single branch to be filled. --> Add it to the list of trees.
+        //
+        if (!fTrees.FindObject(tree))
+            fTrees.AddLast(tree);
+
+        //
         // Now we have a valid tree. Search the list of trees for this tree
-        // (either it is already there, or we created and add it previously)
         // Add a pointer to the entry in the tree list to this branch-entry
         //
-        TObject *obj;
-        TIter NextTree(&fTrees);
-        while ((obj=NextTree()))
-        {
-            if (obj == tree)
-                entry->SetTree((TTree*)obj);
-        }
+        entry->SetTree(tree);
 
         //
@@ -315,6 +323,4 @@
         branch = tree->Branch(branchname, cont->ClassName(), entry->GetAddress());
 
-        *fLog << "Created Branch " << cname << " of " << cont->ClassName() << "." << endl;
-
         //
         // If the branch couldn't be created we have a problem.
@@ -325,4 +331,11 @@
             return kFALSE;
         }
+
+        //
+        // Tell the entry also which branch belongs to it (this is necessary
+        // for branches belonging to already existing tree, UPDATE-mode)
+        //
+        entry->SetBranch(branch);
+        *fLog << "Created Branch " << cname << " of " << cont->ClassName() << "." << endl;
     }
     return kTRUE;
@@ -333,6 +346,11 @@
 // Checks all given containers (branch entries) for the write flag.
 // If the write flag is set the corresponding Tree is marked to get filled.
-// All Trees which are marked to be filled are filled with the corresponding
+// All Trees which are marked to be filled are filled with all their
 // branches.
+// In case of a file opened in 'UPDATE' mode, single branches can be
+// filled, too. WARNING - for the moment there is no check whether
+// you filled the correct number of events into the branch, so that
+// each of the other branches in the tree has the correct corresponding
+// number of new entries in the new branch!
 // Be carefull: If only one container (corresponding to a branch) of a tree
 // has the write flag, all containers in this tree are filled!
@@ -362,5 +380,8 @@
         // the corresponding tree entry.
         //
-        b->GetTree()->SetBit(kFillTree);
+        if (b->TestBit(kIsNewTree))
+            b->GetTree()->SetBit(kFillTree);
+        else
+            b->GetBranch()->Fill();
     }
 
Index: trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h	(revision 2001)
+++ trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h	(revision 2002)
@@ -57,4 +57,5 @@
     void SetContainer(MParContainer *cont) { fContainer = cont; }
     void SetTree(TTree *tree)              { fTree = tree; }
+    void SetBranch(TBranch *branch)        { fBranch = branch; }
 
     ClassDef(MRootFileBranch, 1) // Storage container for MWriteRootFile to store TBranch informations
@@ -69,4 +70,6 @@
     TObjArray fTrees;     //!
 
+    //UInt_t fNumEvents; //! Number of events written in a run
+
     void        CheckAndWrite() const;
     Bool_t      IsFileOpen() const;
@@ -75,4 +78,9 @@
 
     void StreamPrimitive(ofstream &out) const;
+    //Bool_t ReInit(MParList *pList);
+
+    enum {
+        kIsNewTree = BIT(15)
+    };
 
 public:
Index: trunk/MagicSoft/Mars/mfilter/MFEnergySlope.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFEnergySlope.cc	(revision 2001)
+++ trunk/MagicSoft/Mars/mfilter/MFEnergySlope.cc	(revision 2002)
@@ -20,5 +20,4 @@
 !   Copyright: MAGIC Software Development, 2000-2003
 !
-!   Filter to select events with a energy slope. 02/2003
 !
 \* ======================================================================== */
@@ -43,5 +42,5 @@
 //                                                                         //
 //  With this filter the statistics of the MC sample is reduced.           //
-//  camera ver.0.6 and reflector ver.0.6 are required to fetch            //
+//  camera ver.0.6 and reflector ver.0.6 are required to fetch             //
 //   the correct MC information                                            //
 //                                                                         //
@@ -49,5 +48,5 @@
 #include "MFEnergySlope.h"
 
-//#include <fstream.h>
+#include <fstream.h>
 #include <TRandom.h>
 
@@ -56,5 +55,4 @@
 #include "MLog.h"
 #include "MLogManip.h"
-
 
 #include "MMcEvt.hxx"
@@ -73,12 +71,4 @@
   fName  = name  ? name  : "MFEnergySlope";
   fTitle = title ? title : "Filter to select energy with given slope";
-}
-
-// --------------------------------------------------------------------------
-//
-// Destructor
-//
-MFEnergySlope::~MFEnergySlope()
-{
 }
 
@@ -110,9 +100,10 @@
       fMcMaxEnergy = runheader->GetEUppLim();
 
-    *fLog << "MFEnergySlope::PreProcess; fetched MC info:" << endl <<
-      "  E Slope: "<< fMcSlope << endl << 
-      "  E Min:   "<< fMcMinEnergy << endl <<  
-      "  E Max:   "<< fMcMaxEnergy << endl <<
-      "  New E Slope: "<< fNewSlope << endl;
+    *fLog << inf;
+    *fLog << "MFEnergySlope::PreProcess: fetched MC info:" << endl;
+    *fLog << "  E Slope:     " << fMcSlope << endl;
+    *fLog << "  E Min:       " << fMcMinEnergy << endl;
+    *fLog << "  E Max:       " << fMcMaxEnergy << endl;
+    *fLog << "  New E Slope: " << fNewSlope << endl;
     
     // Slope is used with positive values in the code
@@ -180,49 +171,9 @@
   fResult = Nexp > Nrnd;
 
-    if (fResult)
-    {
-        fNumSelectedEvts++;
-        return kTRUE;
-    }
-    
+  if (!fResult)
+      return kTRUE;
+
+  fNumSelectedEvts++;
   return kTRUE;
 }
 
-
-// --------------------------------------------------------------------------
-//
-//  Postprocess all filters.
-//
-Bool_t MFEnergySlope::PostProcess()
-{
-    //---------------------------------
-
-    return kTRUE;
-}
-
-void MFEnergySlope::StreamPrimitive(ofstream &out) const
-{
-  /*
-   if (fEvt)
-        fEvt->SavePrimitive(out);
-
-    out << "   MFEnergySlope " << GetUniqueName() << "(";
-
-    if (fEvt)
-        out << "&" << fEvt->GetUniqueName();
-    else
-        out << "\"" << fContName << "\"";
-
-    out << ", New Energy Slope= " << fValue << "  Normalization factor: " 
-	<< fN0 <<" );" << endl;
-  */
-}
-
-
-
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc	(revision 2001)
+++ trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc	(revision 2002)
@@ -131,10 +131,6 @@
         const Int_t id = pix.GetPixId();
 
-        const Double_t ratio = fCam ? fCam->GetPixRatio(id) : 1;
-
-        const Double_t val = pix.GetNumPhotons()/ratio;
-
         fSum[id].SetPixelUsed();
-        fSum[id].AddNumPhotons(val);
+        fSum[id].AddNumPhotons(pix.GetNumPhotons());
     }
 
