Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 7429)
+++ trunk/MagicSoft/Mars/Changelog	(revision 7430)
@@ -25,4 +25,52 @@
    * datacenter/macros/plotdb.C:
      - added new tabs for new columns
+
+   * mcamera/CameraLinkDef.h, mcamera/Makefile:
+     - added new classes MCameraTH, MCameraTD and MCameraRecTemp
+
+   * mhcalib/MHCalibrationPulseTimeCam.[h,cc]:
+     - added some const-qualifiers
+
+   * mreport/MReportCC.[h,cc]:
+     - updated to allow reading new CC reports 
+
+   * merpp.cc:
+     - added contentent of new CC report to CC output tree
+
+
+
+ 2005/11/25 Daniel Mazin (2005/11/02)
+
+   * mreflector/MRflEvtHeader.h
+     - added parameters first interaction point, telescope phi and theta,
+       fitted quantities from CORSIKA (number of particles in the shower 
+       maximum, t0, tmax, chi2), fraction of electrons, muons and other 
+       particles. Added getters and setters.
+
+   * mfileio/MReadRflFile.cc
+     - filled in the variables above
+
+
+
+ 2005/11/25 A. Moralejo (2005/10/14)
+
+   * mreflector/MRflEvtHeader.h
+     - added parameters: energy, versor of primary's momentum and core 
+       position on ground. Added getters and setters.
+
+   * mfileio/MReadRflFile.cc
+     - filled in the variables above
+
+
+
+ 2005/11/25 Toni Coarasa (09/09/2005)
+
+  * msignal/MExtractTimeAndChargeDigitalFilter.cc
+    - fix a bug in the calculation of the high-gain times:
+      They were all shifted by the same amount "fHiGainFirst". This
+      caused an offset of usually 3 FADC slices in the times calculated
+      from high-gain and from low-gain. The bug did not have any effect
+      on the calibration runs because there, fHiGainFirst was set to 0.
+      The bug was there since 30.1.2005.
 
 
Index: trunk/MagicSoft/Mars/mcamera/MCameraRecTemp.cc
===================================================================
--- trunk/MagicSoft/Mars/mcamera/MCameraRecTemp.cc	(revision 7430)
+++ trunk/MagicSoft/Mars/mcamera/MCameraRecTemp.cc	(revision 7430)
@@ -0,0 +1,87 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Florian Goebel 11/2005 <mailto:fgoebel@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2005
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCameraRecTemp (PRELIMINARY)
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCameraRecTemp.h"
+
+#include <TMath.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MCameraRecTemp);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MCameraRecTemp::MCameraRecTemp(Int_t size, const char *name, const char *title)
+    : fRecTemp(size)
+{
+    fName  = name  ? name  : "MCameraRecTemp";
+    fTitle = title ? title : "Storage container for the receiver board temperatures";
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the dc currents
+//
+void MCameraRecTemp::Print(Option_t *) const
+{
+    *fLog << all << underline << GetDescriptor() << endl;
+    for (int i=0; i<fRecTemp.GetSize(); i++)
+        *fLog << " " << GetRecTemp(i);
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the minimum receiver board temperature
+//
+Float_t MCameraRecTemp::GetMin() const
+{
+    Float_t val = (UInt_t)-1;
+    for (int i=0; i<fRecTemp.GetSize(); i++)
+        val = TMath::Min(val, GetRecTemp(i));
+    return val;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the maximum receiver board temperature
+//
+Float_t MCameraRecTemp::GetMax() const
+{
+    Float_t val = 0;
+    for (int i=0; i<fRecTemp.GetSize(); i++)
+        val = TMath::Max(val, GetRecTemp(i));
+    return val;
+}
Index: trunk/MagicSoft/Mars/mcamera/MCameraRecTemp.h
===================================================================
--- trunk/MagicSoft/Mars/mcamera/MCameraRecTemp.h	(revision 7430)
+++ trunk/MagicSoft/Mars/mcamera/MCameraRecTemp.h	(revision 7430)
@@ -0,0 +1,34 @@
+#ifndef MARS_MCameraRecTemp
+#define MARS_MCameraRecTemp
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+class MCameraRecTemp : public MParContainer
+{
+    friend class MReportCC;
+private:
+    TArrayF fRecTemp; // [deg C] receiver board temperatures
+
+public:
+    MCameraRecTemp(Int_t size=76, const char *name=NULL, const char *title=NULL);
+
+    void SetRecTemp(Int_t i, Float_t val) { fRecTemp[i] = (Int_t)val; }
+    Float_t GetRecTemp(Int_t i) const { return (*this)[i]; }
+    Float_t &operator[](Int_t i) { return (Float_t&)fRecTemp[i]; }
+    const Float_t &operator[](Int_t i) const { return (*const_cast<MCameraRecTemp*>(this))[i]; }
+
+    Float_t GetMin() const;
+    Float_t GetMax() const;
+
+    void Print(Option_t *opt=NULL) const;
+
+    ClassDef(MCameraRecTemp, 1) // Storage Container for Receiver Board Temperature
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mcamera/MCameraTD.cc
===================================================================
--- trunk/MagicSoft/Mars/mcamera/MCameraTD.cc	(revision 7430)
+++ trunk/MagicSoft/Mars/mcamera/MCameraTD.cc	(revision 7430)
@@ -0,0 +1,87 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Florian Goebel 11/2005 <mailto:fgoebel@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2005
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCameraTD (PRELIMINARY)
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCameraTD.h"
+
+#include <TMath.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MCameraTD);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MCameraTD::MCameraTD(Int_t size, const char *name, const char *title)
+    : fTD(size)
+{
+    fName  = name  ? name  : "MCameraTD";
+    fTitle = title ? title : "Storage container for the pixel discriminator delays";
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the dc currents
+//
+void MCameraTD::Print(Option_t *) const
+{
+    *fLog << all << underline << GetDescriptor() << endl;
+    for (int i=0; i<fTD.GetSize(); i++)
+        *fLog << " " << GetDelay(i);
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the minimum discriminator delays
+//
+Float_t MCameraTD::GetMin() const
+{
+    Float_t val = (UInt_t)-1;
+    for (int i=0; i<fTD.GetSize(); i++)
+        val = TMath::Min(val, GetDelay(i));
+    return val;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the maximum discriminator delays
+//
+Float_t MCameraTD::GetMax() const
+{
+    Float_t val = 0;
+    for (int i=0; i<fTD.GetSize(); i++)
+        val = TMath::Max(val, GetDelay(i));
+    return val;
+}
Index: trunk/MagicSoft/Mars/mcamera/MCameraTD.h
===================================================================
--- trunk/MagicSoft/Mars/mcamera/MCameraTD.h	(revision 7430)
+++ trunk/MagicSoft/Mars/mcamera/MCameraTD.h	(revision 7430)
@@ -0,0 +1,46 @@
+#ifndef MARS_MCameraTD
+#define MARS_MCameraTD
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+#ifndef ROOT_TArrayS
+#include <TArrayS.h>
+#endif
+
+class MCameraTD : public MParContainer, public MCamEvent
+{
+    friend class MReportCC;
+private:
+    TArrayS fTD; // [au] discriminator delays
+
+public:
+    MCameraTD(Int_t size=577, const char *name=NULL, const char *title=NULL);
+
+    void SetDelay(Int_t i, Float_t val) { fTD[i] = (Int_t)val; }
+    Float_t GetDelay(Int_t i) const { return (*this)[i]; }
+    Float_t &operator[](Int_t i) { return (Float_t&)fTD[i]; }
+    const Float_t &operator[](Int_t i) const { return (*const_cast<MCameraTD*>(this))[i]; }
+
+    Float_t GetMin() const;
+    Float_t GetMax() const;
+
+    void Print(Option_t *opt=NULL) const;
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+        val = fTD[idx];
+        return val>0;
+    }
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MCameraTD, 1) // Storage Container for Discriminator Delays
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mcamera/MCameraTH.cc
===================================================================
--- trunk/MagicSoft/Mars/mcamera/MCameraTH.cc	(revision 7430)
+++ trunk/MagicSoft/Mars/mcamera/MCameraTH.cc	(revision 7430)
@@ -0,0 +1,87 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Florian Goebel 11/2005 <mailto:fgoebel@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2005
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCameraTH (PRELIMINARY)
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCameraTH.h"
+
+#include <TMath.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MCameraTH);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MCameraTH::MCameraTH(Int_t size, const char *name, const char *title)
+    : fTH(size)
+{
+    fName  = name  ? name  : "MCameraTH";
+    fTitle = title ? title : "Storage container for the pixel discriminator threshold";
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the dc currents
+//
+void MCameraTH::Print(Option_t *) const
+{
+    *fLog << all << underline << GetDescriptor() << endl;
+    for (int i=0; i<fTH.GetSize(); i++)
+        *fLog << " " << GetThreshold(i);
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the minimum dc current
+//
+Float_t MCameraTH::GetMin() const
+{
+    Float_t val = (UInt_t)-1;
+    for (int i=0; i<fTH.GetSize(); i++)
+        val = TMath::Min(val, GetThreshold(i));
+    return val;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the maximum dc current
+//
+Float_t MCameraTH::GetMax() const
+{
+    Float_t val = 0;
+    for (int i=0; i<fTH.GetSize(); i++)
+        val = TMath::Max(val, GetThreshold(i));
+    return val;
+}
Index: trunk/MagicSoft/Mars/mcamera/MCameraTH.h
===================================================================
--- trunk/MagicSoft/Mars/mcamera/MCameraTH.h	(revision 7430)
+++ trunk/MagicSoft/Mars/mcamera/MCameraTH.h	(revision 7430)
@@ -0,0 +1,46 @@
+#ifndef MARS_MCameraTH
+#define MARS_MCameraTH
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+#ifndef ROOT_TArrayS
+#include <TArrayS.h>
+#endif
+
+class MCameraTH : public MParContainer, public MCamEvent
+{
+    friend class MReportCC;
+private:
+    TArrayS fTH; // [au] discriminator thresholds
+
+public:
+    MCameraTH(Int_t size=577, const char *name=NULL, const char *title=NULL);
+
+    void SetThreshold(Int_t i, Float_t val) { fTH[i] = (Int_t)val; }
+    Float_t GetThreshold(Int_t i) const { return (*this)[i]; }
+    Float_t &operator[](Int_t i) { return (Float_t&)fTH[i]; }
+    const Float_t &operator[](Int_t i) const { return (*const_cast<MCameraTH*>(this))[i]; }
+
+    Float_t GetMin() const;
+    Float_t GetMax() const;
+
+    void Print(Option_t *opt=NULL) const;
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+        val = fTH[idx];
+        return val>0;
+    }
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MCameraTH, 1) // Storage Container for the discriminator thresholds
+};
+
+#endif
Index: trunk/MagicSoft/Mars/merpp.cc
===================================================================
--- trunk/MagicSoft/Mars/merpp.cc	(revision 7429)
+++ trunk/MagicSoft/Mars/merpp.cc	(revision 7430)
@@ -346,4 +346,7 @@
             w->AddContainer("MTimeDrive",         "Drive");
             w->AddContainer("MReportCC",          "CC");
+            w->AddContainer("MCameraTH",          "CC");
+            w->AddContainer("MCameraTD",          "CC");
+            w->AddContainer("MCameraRecTemp",     "CC");
             w->AddContainer("MTimeCC",            "CC");
             w->AddContainer("MReportStarguider",  "Starguider");
Index: trunk/MagicSoft/Mars/mfileio/MReadRflFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadRflFile.cc	(revision 7429)
+++ trunk/MagicSoft/Mars/mfileio/MReadRflFile.cc	(revision 7430)
@@ -76,8 +76,4 @@
         fIn->read((char*)&revth, sizeof(RflEventHeader_old));
         fEvtHeader->SetEvtNumber((int)revth.EvtNumber);
-//        *fLog << "Event Number: " << revth.EvtNumber;
-//        *fLog << "  Primary ID: " << revth.PrimaryID;
-//        *fLog << "  Run Number: " << revth.RunNumber << endl;
-        return (bool)*fIn;
     }
     else
@@ -86,21 +82,25 @@
         fIn->read((char*)&revth, sizeof(RflEventHeader));
         fEvtHeader->SetEvtNumber((int)revth.EvtNumber);
-//        *fLog << "Event Number: " << revth.EvtNumber;
-//        *fLog << "  Primary ID: " << revth.PrimaryID;
-//        *fLog << "  Run Number: " << revth.RunNumber << endl;
-        return (bool)*fIn;
-    }
-}
-
-enum {
-    kError,
-    kEndOfFile,
-    kStartOfRun,
-    kEndOfRun,
-    kStartOfEvtData,
-    kEndOfEvtData,
-    kUndefined
-};
-
+        fEvtHeader->SetEnergy((int)revth.Etotal);
+        fEvtHeader->SetMomentum(revth.p[0], revth.p[1], revth.p[2]);
+        fEvtHeader->SetCorePosition(revth.CorePos[0][0], revth.CorePos[1][0]);
+        
+        fEvtHeader->SetHeightFirstInt((Float_t)revth.zFirstInt);
+
+        fEvtHeader->SetPhi((Float_t)revth.telescopePhi);
+        fEvtHeader->SetTheta((Float_t)revth.telescopeTheta);
+
+        fEvtHeader->SetNmax((Float_t)revth.longi_Nmax);
+        fEvtHeader->SetT0((Float_t)revth.longi_t0);
+        fEvtHeader->SetTmax((Float_t)revth.longi_tmax);
+        fEvtHeader->SetChi2((Float_t)revth.longi_chi2);
+
+        fEvtHeader->SetEFraction((Float_t)revth.elec_cph_fraction);
+        fEvtHeader->SetMFraction((Float_t)revth.muon_cph_fraction);
+        fEvtHeader->SetOFraction((Float_t)revth.other_cph_fraction);
+    }
+
+    return (bool)*fIn;
+}
 
 int MReadRflFile::ReadFlag()
@@ -111,6 +111,4 @@
     if (!fIn)
         return kError;
-
-    //*fLog << "<" << TString(&flag[1], 11)  << ">" <<endl;
 
     if (FlagIsA(flag, FLAG_END_OF_FILE))
Index: trunk/MagicSoft/Mars/mfileio/MReadRflFile.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadRflFile.h	(revision 7429)
+++ trunk/MagicSoft/Mars/mfileio/MReadRflFile.h	(revision 7430)
@@ -18,16 +18,26 @@
 {
 private:
-    ifstream *fIn;          // the inputfile
-    TList    *fFileNames;   // Array which stores the \0-terminated filenames
+    enum {
+        kError,
+        kEndOfFile,
+        kStartOfRun,
+        kEndOfRun,
+        kStartOfEvtData,
+        kEndOfEvtData,
+        kUndefined
+    };
 
-    MRflEvtData *fEvtData;        //!
-    MRflEvtHeader *fEvtHeader;
-    MRflRunHeader *fRunHeader;
+    ifstream *fIn;              // the inputfile
+    TList    *fFileNames;       // Array which stores the \0-terminated filenames
 
-    UInt_t fNumFile;
-    UInt_t fEntries; // TO BE IMPLEMENTED
+    MRflEvtData   *fEvtData;    //!
+    MRflEvtHeader *fEvtHeader;  //!
+    MRflRunHeader *fRunHeader;  //!
+
+    UInt_t  fNumFile;
+    UInt_t  fEntries;           // TO BE IMPLEMENTED
     TString fFileName;
 
-    Float_t fCurrentVersion; //! Version of currently open rfl file
+    Float_t fCurrentVersion;    //! Version of currently open rfl file
 
     float  ReadVersion();
Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationPulseTimeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationPulseTimeCam.cc	(revision 7429)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationPulseTimeCam.cc	(revision 7430)
@@ -102,32 +102,4 @@
 #include "MHCalibrationCam.h"
 
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MParList.h"
-
-#include "MHCalibrationPix.h"
-
-#include "MCalibrationIntensityCam.h"
-#include "MCalibrationChargeCam.h"
-#include "MCalibrationChargePix.h"
-
-#include "MGeomCam.h"
-#include "MGeomPix.h"
-
-#include "MBadPixelsIntensityCam.h"
-#include "MBadPixelsCam.h"
-#include "MBadPixelsPix.h"
-
-#include "MRawEvtData.h"
-#include "MRawRunHeader.h"
-#include "MRawEvtPixelIter.h"
-
-#include "MExtractedSignalCam.h"
-#include "MExtractedSignalPix.h"
-
-#include "MArrayI.h"
-#include "MArrayD.h"
-
 #include <TOrdCollection.h>
 #include <TPad.h>
@@ -140,4 +112,32 @@
 #include <TGraph.h>
 #include <TEnv.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MHCalibrationPix.h"
+
+#include "MCalibrationIntensityCam.h"
+#include "MCalibrationChargeCam.h"
+#include "MCalibrationChargePix.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MBadPixelsIntensityCam.h"
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
+#include "MRawEvtData.h"
+#include "MRawRunHeader.h"
+#include "MRawEvtPixelIter.h"
+
+#include "MExtractedSignalCam.h"
+#include "MExtractedSignalPix.h"
+
+#include "MArrayI.h"
+#include "MArrayD.h"
 
 ClassImp(MHCalibrationPulseTimeCam);
@@ -512,5 +512,5 @@
   *fLog << endl;
 
-  MCalibrationCam *calcam  = fIntensCam ? fIntensCam->GetCam() : fCam;
+  MCalibrationCam &calcam  = *(fIntensCam ? fIntensCam->GetCam() : fCam);
   //
   // Perform the fitting for the High Gain (done in MHCalibrationCam)
@@ -524,5 +524,5 @@
         continue;
       
-      MCalibrationPix &pix    = (*calcam)[i];
+      MCalibrationPix &pix    = calcam[i];
       CalcHists(hist,pix);
     }
@@ -534,6 +534,6 @@
     {
       
-      MHCalibrationPix &hist = GetAverageHiGainArea(j);      
-      MCalibrationPix  &pix  = calcam->GetAverageArea(j);
+      MHCalibrationPix &hist = GetAverageHiGainArea(j);
+      MCalibrationPix  &pix  = calcam.GetAverageArea(j);
       CalcHists(hist,pix);
   }
@@ -541,6 +541,6 @@
   for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
     {
-      MHCalibrationPix &hist = GetAverageHiGainSector(j);      
-      MCalibrationPix  &pix  = calcam->GetAverageSector(j);
+      MHCalibrationPix &hist = GetAverageHiGainSector(j);
+      MCalibrationPix  &pix  = calcam.GetAverageSector(j);
       CalcHists(hist,pix);
     }
@@ -549,5 +549,5 @@
 }
 
-void MHCalibrationPulseTimeCam::CalcHists(MHCalibrationPix &hist, MCalibrationPix &pix)
+void MHCalibrationPulseTimeCam::CalcHists(MHCalibrationPix &hist, MCalibrationPix &pix) const
 {
 
Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationPulseTimeCam.h
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationPulseTimeCam.h	(revision 7429)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationPulseTimeCam.h	(revision 7430)
@@ -61,5 +61,5 @@
   void   DrawDataCheckPixel(MHCalibrationPix &pix, const Float_t refline);
   void   DisplayRefLines   ( const TH1F *hist,           const Float_t refline) const;
-  void   CalcHists         (MHCalibrationPix &hist, MCalibrationPix &pix);
+  void   CalcHists         (MHCalibrationPix &hist, MCalibrationPix &pix) const;
 
   Int_t ReadEnv        ( const TEnv &env, TString prefix, Bool_t print);
Index: trunk/MagicSoft/Mars/mreflector/MRflEvtHeader.cc
===================================================================
--- trunk/MagicSoft/Mars/mreflector/MRflEvtHeader.cc	(revision 7429)
+++ trunk/MagicSoft/Mars/mreflector/MRflEvtHeader.cc	(revision 7430)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 5/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: MAGIC Software Development, 2000-2005
 !
 !
Index: trunk/MagicSoft/Mars/mreflector/MRflEvtHeader.h
===================================================================
--- trunk/MagicSoft/Mars/mreflector/MRflEvtHeader.h	(revision 7429)
+++ trunk/MagicSoft/Mars/mreflector/MRflEvtHeader.h	(revision 7430)
@@ -6,15 +6,81 @@
 #endif
 
+#ifndef ROOT_TVector3
+#include <TVector3.h>
+#endif
+
 class MRflEvtHeader : public MParContainer
 {
     Int_t fEvtNumber;
 
+    Float_t fEnergy;         // [GeV] of primary
+
+    TVector3 fMomentum;      // versor of momentum of primary
+    TVector2 fCorePosition;  // shower core position on ground
+
+    Float_t fHeightFirstInt; // [cm] z coordinate (height) of first interaction
+
+    Float_t fPhi;            // Phi of the telescope
+    Float_t fTheta;          // Theta of the telescope [rad]
+
+    Float_t fNmax;           // number of particles in shower maximum fitted by CORSIKA
+    Float_t fT0;             // depth of first interaction point fitted by CORSIKA
+    Float_t fTmax;           // depth of the shower maximum fitted by CORSIKA
+    Float_t fChi2;           // quality of the fit to longit shower development
+
+    /* Now follow the fraction of photons reaching the camera produced by  *
+     * electrons, muons and other particles respectively:                  */
+    Float_t fEFraction;      // elec_cph_fraction
+    Float_t fMFraction;      // muon_cph_fraction
+    Float_t fOFraction;      // other_cph_fraction
+
 public:
     MRflEvtHeader(const char *name=NULL, const char *title=NULL);
 
+    // Getter
     Int_t GetEvtNumber() const { return fEvtNumber; }
+
+    Float_t GetEnergy() const { return fEnergy; }
+
+    const TVector3 &GetMomentum() const { return fMomentum; }
+    const TVector2 &GetCorePosition() const { return fCorePosition; }
+
+    Float_t GetHeightFirstInt() const { return fHeightFirstInt; }
+
+    Float_t GetPhi() const   { return fPhi; }
+    Float_t GetTheta() const { return fTheta; }
+
+    Float_t GetNmax() const  { return fNmax; }
+    Float_t GetT0() const    { return fT0; }
+    Float_t GetTmax() const  { return fTmax; }
+    Float_t GetChi2() const  { return fChi2; }
+
+    Float_t GetEFraction() const { return fEFraction; }
+    Float_t GetMFraction() const { return fMFraction; }
+    Float_t GetOFraction() const { return fOFraction; }
+
+    // Setter
     void SetEvtNumber(Int_t n) { fEvtNumber = n; }
+    void SetEnergy(Float_t x) { fEnergy = x; }
+    void SetMomentum(const TVector3 &v) { fMomentum = v; }
+    void SetCorePosition(const TVector2 &v) { fCorePosition = v; }
 
-    ClassDef(MRflEvtHeader, 0) // Header of an event from the reflector program
+    void SetMomentum(Float_t px, Float_t py, Float_t pz) { fMomentum = TVector3(px, py, pz); }
+    void SetCorePosition(Float_t cx, Float_t cy) { fCorePosition = TVector2(cx, cy); }
+    void SetHeightFirstInt(Float_t x) { fHeightFirstInt = x; }
+
+    void SetPhi(Float_t x)   { fPhi = x; }
+    void SetTheta(Float_t x) { fTheta = x; }
+     
+    void SetNmax(Float_t x)  { fNmax = x ; }
+    void SetT0(Float_t x)    { fT0 = x; }
+    void SetTmax(Float_t x)  { fTmax = x ; }
+    void SetChi2(Float_t x)  { fChi2 = x ; }
+     
+    void SetEFraction(Float_t x) { fEFraction = x ; }
+    void SetMFraction(Float_t x) { fMFraction = x ; }
+    void SetOFraction(Float_t x) { fOFraction = x ; }
+     
+    ClassDef(MRflEvtHeader, 1) // Header of an event from the reflector program
 };
 
Index: trunk/MagicSoft/Mars/mreport/MReportCC.cc
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportCC.cc	(revision 7429)
+++ trunk/MagicSoft/Mars/mreport/MReportCC.cc	(revision 7430)
@@ -43,5 +43,9 @@
 #include "MLogManip.h"
 
-#include "MAstro.h"
+#include "MParList.h"
+
+#include "MCameraTH.h"
+#include "MCameraTD.h"
+#include "MCameraRecTemp.h"
 
 ClassImp(MReportCC);
@@ -62,17 +66,51 @@
 // --------------------------------------------------------------------------
 //
+// FindCreate the following objects:
+//  - MCameraTH
+//
+Bool_t MReportCC::SetupReading(MParList &plist)
+{
+    fTH = (MCameraTH*)plist.FindCreateObj("MCameraTH");
+    if (!fTH)
+        return kFALSE;
+
+    fTD = (MCameraTD*)plist.FindCreateObj("MCameraTD");
+    if (!fTD)
+        return kFALSE;
+
+    fRecTemp = (MCameraRecTemp*)plist.FindCreateObj("MCameraRecTemp");
+    if (!fRecTemp)
+        return kFALSE;
+
+    return MReport::SetupReading(plist);
+}
+
+// --------------------------------------------------------------------------
+//
+// Check whether the given TString begins with the given tag. Remove
+// the tag from the string.
+//
+Bool_t MReportCC::CheckTag(TString &str, const char *tag) const
+{
+    if (!str.BeginsWith(tag))
+    {
+        *fLog << warn << "WARNING - '" << tag << "' tag not found." << endl;
+        return kFALSE;
+    }
+    str.Remove(0, strlen(tag)); // Remove Tag
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
 // Interprete the body of the CC-REPORT string
 //
-Int_t MReportCC::InterpreteBody(TString &str, Int_t ver)
-{
-    if (ver<200404070)
-    {
-        *fLog << err << "ERROR - MReportCC::InterpreteBody not prepared for ";
-        *fLog << " report-files with version<200404070" << endl;
-        return kFALSE;
-    }
-
+Bool_t MReportCC::InterpreteCC(TString &str, Int_t ver)
+{
     const Int_t skip = ver<200407270 ? 30 : 31;
 
+    // Remove the 30/31 tokens of the subsystem status
+    //  table 12.1 p59
     for (int i=0; i<skip; i++)
         str.Remove(0, str.First(' ')+1);
@@ -86,15 +124,131 @@
     {
         *fLog << warn << "WARNING - Wrong number of arguments." << endl;
-        return kCONTINUE;
+        return kFALSE;
     }
 
     str.Remove(0, len);
 
-    for (int i=0; i<4; i++)  // 2*UPS, TH, 577%x, TD, 577%x
-        str.Remove(0, str.First(' ')+1);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the TH (discriminator thresholds) part of the report
+//
+Bool_t MReportCC::InterpreteTH(TString &str)
+{
+    if (!CheckTag(str, "TH "))
+        return kFALSE;
+
+    const char *pos = str.Data();
+    const char *end = str.Data()+577*2;
+
+    Int_t i=0;
+    while (pos<end)
+    {
+        const Char_t hex[2] = { pos[0], pos[1] };
+        pos += 2;
+
+        const Int_t n=sscanf(hex, "%2hx", &fTH->fTH[i++]);
+        if (n==1)
+            continue;
+
+        *fLog << warn << "WARNING - Reading hexadecimal TH information." << endl;
+        return kFALSE;
+    }
+
+    str.Remove(0, end-str.Data()); // Remove TH
+    str=str.Strip(TString::kLeading);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the TD (discriminator delays) part of the report
+//
+Bool_t MReportCC::InterpreteTD(TString &str, Int_t ver)
+{
+    if (!CheckTag(str, "TD "))
+        return kFALSE;
+
+    const Int_t numpix = ver<200510250 ? 500 : 577;
+
+    const char *pos = str.Data();
+    const char *end = str.Data()+numpix*2;
+
+    Int_t i=0;
+    while (pos<end)
+    {
+        const Char_t hex[3] = { pos[0], pos[1], 0 };
+        pos += 2;
+
+        const Int_t n=sscanf(hex, "%2hx", &fTD->fTD[i++]);
+        if (n==1)
+            continue;
+
+        *fLog << warn << "WARNING - Reading hexadecimal TD information." << endl;
+        return kFALSE;
+    }
+
+    str.Remove(0, end-str.Data()); // Remove TD
+    str=str.Strip(TString::kLeading);
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Interprete the receiver board temperature part of the report
+//
+Bool_t MReportCC::InterpreteRecTemp(TString &str)
+{
+    if (!CheckTag(str, "RECTEMP "))
+        return kFALSE;
+
+    Int_t len;
+    for (Int_t i=0; i<76; i++)
+    {
+        const Int_t n=sscanf(str.Data(), "%f %n", &fRecTemp->fRecTemp[i], &len);
+        str.Remove(0, len);
+
+        if (n==1)
+            continue;
+
+        *fLog << warn << "WARNING - Reading Receiver Board Temperature information." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the body of the CC-REPORT string
+//
+Int_t MReportCC::InterpreteBody(TString &str, Int_t ver)
+{
+    if (ver<200404070)
+    {
+        *fLog << err << "ERROR - MReportCC::InterpreteBody not prepared for ";
+        *fLog << " report-files with version<200404070" << endl;
+        return kFALSE;
+    }
+
+    if (!InterpreteCC(str, ver))
+        return kCONTINUE;
+
+    if (!InterpreteTH(str))
+        return kCONTINUE;
+
+    if (!InterpreteTD(str, ver))
+        return kCONTINUE;
+
+    if (ver>200510250)
+        if (!InterpreteRecTemp(str))
+            return kCONTINUE;
 
     if (str.Strip(TString::kBoth)!=(TString)"OVER")
     {
-        *fLog << err << "ERROR - Termination (OVER) too far away." << endl;
+        *fLog << warn << "WARNING - 'OVER' tag not found." << endl;
         return kCONTINUE;
     }
Index: trunk/MagicSoft/Mars/mreport/MReportCC.h
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportCC.h	(revision 7429)
+++ trunk/MagicSoft/Mars/mreport/MReportCC.h	(revision 7430)
@@ -6,15 +6,33 @@
 #endif
 
+class MCameraTH;
+class MCameraTD;
+class MCameraRecTemp;
+
 class MReportCC : public MReport
 {
 private:
-    Float_t fHumidity;       // [%]
-    Float_t fTemperature;    // [deg] celsius
-    Float_t fWindSpeed;      // [km/h]
-    Float_t fSolarRadiation; // [W/m^2] IR-Radiation
+    Float_t fHumidity;        // [%]
+    Float_t fTemperature;     // [deg] celsius
+    Float_t fWindSpeed;       // [km/h]
+    Float_t fSolarRadiation;  // [W/m^2] IR-Radiation
 
-    Float_t fUPSStatus;      // arbitrary units (still not properly defined)
-    Float_t fDifRubGPS;      // [us] Difference between the Rubidium clock time and the time provided by the GPS receiver
+    Float_t fUPSStatus;       // arbitrary units (still not properly defined)
+    Float_t fDifRubGPS;       // [us] Difference between the Rubidium clock time and the time provided by the GPS receiver
 
+    MCameraTH      *fTH;      //! Discriminator thresholds
+    MCameraTD      *fTD;      //! Discriminator delays
+    MCameraRecTemp *fRecTemp; //! Receiver Board temperatures
+
+    // Internal
+    Bool_t SetupReading(MParList &plist);
+    Bool_t CheckTag(TString &str, const char *tag) const;
+
+    Bool_t InterpreteCC(TString &str, Int_t ver);
+    Bool_t InterpreteTH(TString &str);
+    Bool_t InterpreteTD(TString &str, Int_t ver);
+    Bool_t InterpreteRecTemp(TString &str);
+
+    // MReport
     Int_t InterpreteBody(TString &str, Int_t ver);
 
Index: trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc	(revision 7429)
+++ trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc	(revision 7430)
@@ -232,5 +232,10 @@
     }
 
-    // New weights set
+    //
+    // shift the times back to the right reference (start counting from 0)
+    //
+    // The high-gain has the extraction offset (fHiGainFirst) already included
+    // here for speed reason. The low-gain has a changing extraction offset,
+    // so it will be added at every event (in FindTimeAndChargeLoGain)
     fTimeShiftHiGain = 0.5 + 1./fBinningResolutionHiGain + fHiGainFirst;
     fTimeShiftLoGain = 0.5 + 1./fBinningResolutionLoGain;
@@ -474,6 +479,6 @@
       return;
 
-  time = max_p + fTimeShiftHiGain + (Float_t)fHiGainFirst /* this shifts the time to the start of the rising edge */
-      - ((Float_t)t_iter)/fBinningResolutionHiGain;
+  // here, the first high-gain slice is already included in the fTimeShiftHiGain
+  time = fTimeShiftHiGain + max_p - Float_t(t_iter)/fBinningResolutionHiGain;
 
   const Float_t timefineadjust = time_sum/sum;
