Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 6499)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 6500)
@@ -40,4 +40,5 @@
 
 
+
  2005/02/15 Thomas Bretz
 
@@ -69,4 +70,39 @@
        parameters
      - added a flag to keep single core pixels
+
+   * manalysis/MMatrixLoop.[h,cc], mfileio/MReadReports.[h,cc],
+     mfileio/MReadRflFile.[h,cc], mfileio/MReadTree.[h,cc],
+     mraw/MRawFileRead.[h,cc], mraw/MRawSocketRead.h:
+     - renamed GetFileName to GetFullFileName
+
+   * mbase/MInputStreamID.h:
+     - added new member function HasStreamId
+
+   * mbase/MParContainer.[h,cc]:
+     - added a static list to keep track of all created
+       TMathodCall objects
+
+   * mbase/MTask.cc:
+     - enhanced PrintStatistics
+
+   * mfileio/MRead.[h,cc]:
+     - new abstract function GetFullFileName
+     - added implementatio of GetFileName based on GetFullFileName
+
+   * mfileio/MWriteRootFile.[h,cc]:
+     - moved open of a new file to new common member function
+       OpenFile
+     - allow to use an already existing file also when using rules
+     - added a new option which can be used to copy an existing
+       tree (without any change) from the old file into the new file.
+       (in principal you can also do this for some of its branches only)
+       This is done by AddCopySource
+
+   * mjobs/MJCalibrateSignal.cc:
+     - in case of MonteCarlo files write an independant tree
+       'MonteCarlo' for 'MMcEvtBasic'
+
+   * mjobs/MJStar.cc:
+     - copy tree 'MonteCarlo' from old into new files
 
 
Index: /trunk/MagicSoft/Mars/NEWS
===================================================================
--- /trunk/MagicSoft/Mars/NEWS	(revision 6499)
+++ /trunk/MagicSoft/Mars/NEWS	(revision 6500)
@@ -78,4 +78,7 @@
       (MFSupercuts) && (MHillas.fSize>100)
 
+    - fixed a lot of stuff to allow all programs to process MonteCarlo
+      camera files.
+
 
 
Index: /trunk/MagicSoft/Mars/mbase/MParContainer.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 6499)
+++ /trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 6500)
@@ -80,7 +80,10 @@
 using namespace std;
 
+TObjArray MParContainer::fgListMethodCall;
+
 MParContainer::MParContainer(const char *name, const char *title) :
     fName(name), fTitle(title), fLog(&gLog), fDisplay(NULL), fReadyToSave(kFALSE)
 {
+    fgListMethodCall.SetOwner();
 }
 
@@ -88,4 +91,5 @@
     fName(name), fTitle(title), fLog(&gLog), fDisplay(NULL), fReadyToSave(kFALSE)
 {
+    fgListMethodCall.SetOwner();
 }
 
@@ -630,22 +634,32 @@
     }
 
-    *fLog << warn << "No standard access for '" << part1 << "' in ";
+    *fLog << inf << "No standard access for '" << part1 << "' in ";
     *fLog << GetDescriptor() << " or one of its base classes." << endl;
 
     TMethodCall *call = NULL;
 
-    *fLog << warn << "Trying to find MethodCall '" << ClassName();
-    *fLog << "::Get" << part1 << "' instead <LEAKS MEMORY>" << endl;
+    *fLog << "Trying to find MethodCall '" << ClassName();
+    *fLog << "::Get" << part1 << "' instead..." << flush;
     call = new TMethodCall(IsA(), (TString)"Get"+part1, "");
     if (call->GetMethod())
+    {
+        fgListMethodCall.Add(call);
+        *fLog << "found." << endl;
         return call;
+    }
+    *fLog << endl;
 
     delete call;
 
-    *fLog << warn << "Trying to find MethodCall '" << ClassName();
-    *fLog << "::" << part1 << "' instead <LEAKS MEMORY>" << endl;
+    *fLog << "Trying to find MethodCall '" << ClassName();
+    *fLog << "::" << part1 << "' instead..." << flush;
     call = new TMethodCall(IsA(), part1, "");
     if (call->GetMethod())
+    {
+        fgListMethodCall.Add(call);
+        *fLog << "found." << endl;
         return call;
+    }
+    *fLog << endl;
 
     delete call;
Index: /trunk/MagicSoft/Mars/mbase/MParContainer.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 6499)
+++ /trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 6500)
@@ -34,4 +34,7 @@
 class MParContainer : public TObject
 {
+private:
+    static TObjArray fgListMethodCall; //!
+
 protected:
     TString fName;        // parameter container identifier (name)
Index: /trunk/MagicSoft/Mars/mbase/MTask.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 6499)
+++ /trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 6500)
@@ -428,4 +428,7 @@
     else
         *fLog << "       ";
+
+    if (HasStreamId())
+        *fLog << GetStreamId() << ":";
     *fLog << GetDescriptor() << "\t";
     *fLog << dec << GetNumExecutions();
Index: /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 6499)
+++ /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 6500)
@@ -116,4 +116,10 @@
     {
         file = new TFile(name, option, title, comp);
+        if (!file->IsOpen())
+        {
+            delete file;
+            return NULL;
+        }
+
         file->SetOption(option); // IMPORTANT!
         ResetBit(kIsNotOwner);
@@ -873,5 +879,5 @@
 // TTree::CloneTree()
 //
-void MWriteRootFile::CopyTree(TTree &t)
+void MWriteRootFile::CopyTree(TTree &t) const
 {
     *fLog << "Copy of tree " << t.GetName() << " in progress..." << flush;
Index: /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h	(revision 6499)
+++ /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h	(revision 6500)
@@ -96,5 +96,5 @@
     Bool_t  ChangeFile(const char *fname);
     TFile  *OpenFile(const char *name, Option_t *option, const char *title, Int_t comp);
-    void    CopyTree(TTree &t);
+    void    CopyTree(TTree &t) const;
     Bool_t  MakeCopies(const char *oldname) const;
 
Index: /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 6499)
+++ /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 6500)
@@ -357,16 +357,22 @@
     MRawFileRead rawread(NULL);
 
+    MRead *read = 0;
     switch (GetDataFlag())
     {
-    case kIsUseRawData:
-        rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns);
-        break;
-    case kIsUseMC:
-        readmc.AddFiles(fSequence.IsValid() ? iter : *fRuns);
-        break;
-    case kIsUseRootData:
-        readreal.AddFiles(fSequence.IsValid() ? iter : *fRuns);
-        break;
-    }
+    case kIsUseRawData:  read = &rawread;  break;
+    case kIsUseMC:       read = &readmc;   break;
+    case kIsUseRootData: read = &readreal; break;
+    }
+    read->AddFiles(fSequence.IsValid() ? iter : *fRuns);
+
+    const TString fname(Form("%s{s/_D_/_Y_}{s/.raw$/.root}", fPathOut.Data()));
+
+    // Write the special MC tree
+    MWriteRootFile writemc(2, fname, fOverwrite?"RECREATE":"NEW");
+    writemc.SetName("WriteMC");
+    writemc.AddContainer("MMcEvtBasic", "MonteCarlo");
+
+    // Skips empty MC events (Not necessary, but faster!)
+    MContinue contmc("MRawEvtData.GetNumPixels<0.5", "ContEmptyMC");
 
     MPointingPosInterpolate pextr;
@@ -563,5 +569,5 @@
 
     // The second rule is for the case reading raw-files!
-    MWriteRootFile write(2, Form("%s{s/_D_/_Y_}{s/.raw$/.root}", fPathOut.Data()), fOverwrite?"RECREATE":"NEW");
+    MWriteRootFile write(2, fname, fOverwrite?"RECREATE":"NEW");
     // Run Header
     write.AddContainer("MRawRunHeader",             "RunHeaders");
@@ -682,17 +688,9 @@
 
     // Now setup main tasklist
-    switch (GetDataFlag())
-    {
-    case kIsUseRawData:
-        tlist.AddToList(&rawread);
-        break;
-    case kIsUseMC:
-        tlist.AddToList(&readmc);
-        break;
-    case kIsUseRootData:
-        tlist.AddToList(&readreal);
-        break;
-    }
-    //tlist.AddToList(IsUseRawData() ? (MTask*)&rawread : (MTask*)&readreal);
+    tlist.AddToList(read);
+    if (IsUseMC())
+        tlist.AddToList(&writemc);
+    tlist.AddToList(&contmc);
+
     if (IsUseRootData())
       tlist2.AddToList(&pextr);
Index: /trunk/MagicSoft/Mars/mjobs/MJStar.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 6499)
+++ /trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 6500)
@@ -273,4 +273,5 @@
         write.AddContainer("MMcConfigRunHeader",   "RunHeaders");
         write.AddContainer("MMcCorsikaRunHeader",  "RunHeaders");
+        write.AddCopySource("MonteCarlo");
     }
     else
Index: /trunk/MagicSoft/Mars/mraw/MRawFileRead.cc
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawFileRead.cc	(revision 6499)
+++ /trunk/MagicSoft/Mars/mraw/MRawFileRead.cc	(revision 6500)
@@ -259,5 +259,5 @@
 // Return file name of current file.
 //
-TString MRawFileRead::GetFileName() const
+TString MRawFileRead::GetFullFileName() const
 {
     const TObject *file = fFileNames->At(fNumFile-1);
Index: /trunk/MagicSoft/Mars/mraw/MRawFileRead.h
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawFileRead.h	(revision 6499)
+++ /trunk/MagicSoft/Mars/mraw/MRawFileRead.h	(revision 6500)
@@ -38,5 +38,5 @@
     void SetInterleave(UInt_t i) { fInterleave = i; }
 
-    TString GetFileName() const;
+    TString GetFullFileName() const;
 
     Int_t  AddFile(const char *fname, Int_t entries=-1);
Index: /trunk/MagicSoft/Mars/mraw/MRawSocketRead.h
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawSocketRead.h	(revision 6499)
+++ /trunk/MagicSoft/Mars/mraw/MRawSocketRead.h	(revision 6500)
@@ -31,5 +31,5 @@
     void SetPort(int port) { fPort = port; }
 
-    TString GetFileName() const { return "<socket>"; }
+    TString GetFullFileName() const { return "<socket>"; }
 
     ClassDef(MRawSocketRead, 0)	//Task to read DAQ binary data from tcp/ip socket
