Index: /tags/Mars_V0-8-5/Mars/mmc/MFadcDefine.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/MFadcDefine.h	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/MFadcDefine.h	(revision 9662)
@@ -0,0 +1,47 @@
+//
+//  --> Frist of all the WIDTH of the time slice of one FADC slice 
+//      this is 3.33333 nsec.
+//
+#define WIDTH_FADC_TIMESLICE   (50./15.)       //  this means 3.33 nsec 
+//
+//  --> Second the number of slices to fill in MFADC. This must by 
+//      connected to the MTrigger class. The time of interest must be
+//      equal in both classes. 
+//
+#define SLICES_MFADC           (TOTAL_TRIGGER_TIME / WIDTH_FADC_TIMESLICE)
+//
+//  --> The amount of FADC slice written to the raw format.
+//
+#define FADC_SLICES  15
+//
+//  --> The amount of ns before trigger that would be read from the ADC
+//      in oder to show also the start of the pulse before the
+//      the trigger time.
+//
+#define TIME_BEFORE_TRIGGER    10.
+//  --> like the trigger the FADC value will also have a standard response
+//      to one single Photo electron. This response is binned with smaller
+//      bins. The WIDTH of that response function is done here. 
+// 
+#define SUBBINS     5.
+#define WIDTH_RESPONSE_MFADC   (WIDTH_FADC_TIMESLICE /  SUBBINS )  
+// 5 sub-bin in one FADC slice 
+//
+//  --> the number of Response slices
+//
+#define RESPONSE_SLICES_MFADC   45         
+//
+//
+#define MFADC_RESPONSE_FWHM        5.0
+
+//
+//
+#define MFADC_RESPONSE_INTEGRAL   4.0
+//
+// -->  The maximum number of FADC channels
+//      Most likely it will be always equal to CAMERA_PIXELS 
+#define MFADC_CHANNELS  3500
+//
+// Ratio of high to low gain:
+//
+#define HIGH2LOWGAIN 10.
Index: /tags/Mars_V0-8-5/Mars/mmc/MMcConfigRunHeader.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/MMcConfigRunHeader.cc	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/MMcConfigRunHeader.cc	(revision 9662)
@@ -0,0 +1,120 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Oscar Blanch  11/2002 (blanch@ifae.es)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MMcConfigRunHeader
+//
+// Root storage container for the MONTE CARLO CONFIGURATION information
+//
+// It saves in a root file all the infromation about values in the configuration
+// files used in the Monte Carlo production: MagicDef (definition of the teslescope),
+// Reflectivity.dat (mirror reflectivities), qe.dat (PMT QEs), axisdev.dat (mirrors 
+// deviations) and lightguides.dat (Effect of the Light Guides).
+//
+//
+// Version 2: 
+// -----------
+// removed obsolete variables which are no longer used by reflector, 
+// nor present in the magic.def file:  fFocalStdev, fPointStdev, fDevAdjust
+//
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MMcConfigRunHeader.h"
+
+#include <fstream>
+#include <iomanip>
+
+#include <TArrayF.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MMcConfigRunHeader);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+//
+MMcConfigRunHeader::MMcConfigRunHeader(const char *name, const char *title)
+    : fNumMirrors(0), fNumPMTs(0), fIncidentTheta(181), fLightCollectionFactor(181), fLightCollectionFactorOuter(181)
+{
+    fName  = name  ? name  : "MMcConfigRunHeader";
+    fTitle = title ? title : "Mc Configuration Information";
+
+    fRadiusMirror=-1;
+    fFocalDist   =-1;
+    fPointSpread =-1;
+    fBlackSpot   =-1;
+    fCameraWidth =-1;
+
+    fMirrors = new TClonesArray("MGeomMirror", 0);
+    fPMTs = new TClonesArray("MGeomPMT", 0);
+
+}
+
+// --------------------------------------------------------------------------
+//
+// DESCRIPTION MISSING Please contact Oscar
+//
+void MMcConfigRunHeader::SetMagicDef(Float_t radius,
+				     Float_t focal,
+				     Float_t point,
+				     Float_t spot,
+				     Float_t camwidth)
+{
+    fRadiusMirror=radius;
+    fFocalDist=focal;
+    fPointSpread=point;
+    fBlackSpot=spot;
+    fCameraWidth=camwidth;
+    
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the values corresponding to the light collection efficiency due to
+// light guides, plexiglas, double crossing, collection of 1st dynode. These
+// are fed to the camera program via de Data/LightCollection.dat file (see
+// camera manual)
+// 
+void  MMcConfigRunHeader::SetLightCollection(const TArrayF &theta, const TArrayF &factor, const TArrayF &factor_outer)
+{
+    if (fIncidentTheta.GetSize()    !=theta.GetSize() ||
+        fLightCollectionFactor.GetSize()!=factor.GetSize() ||
+        fLightCollectionFactorOuter.GetSize()!=factor_outer.GetSize())
+    {
+        *fLog<< err << dbginf << "fIncidentTheta or fLightCollectionFactor";
+        *fLog << "or fLightCollectionFactorOuter" << endl;
+        *fLog << "do not have size of setting arrays" << endl;
+        return;
+    }
+
+    fIncidentTheta = theta;
+    fLightCollectionFactor = factor;
+    fLightCollectionFactorOuter = factor_outer;
+}
Index: /tags/Mars_V0-8-5/Mars/mmc/MMcConfigRunHeader.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/MMcConfigRunHeader.h	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/MMcConfigRunHeader.h	(revision 9662)
@@ -0,0 +1,105 @@
+#ifndef MARS_MMcConfigRunHeader
+#define MARS_MMcConfigRunHeader
+
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+
+#ifndef MARS_MGeomMirror
+#include "MGeomMirror.h"
+#endif
+#ifndef MARS_MGeomPMT
+#include "MGeomPMT.h"
+#endif
+
+class MGeomMirror;
+class MGeomPMT;
+
+class MMcConfigRunHeader : public MParContainer
+{
+private:
+    // Mirror Information
+    UShort_t      fNumMirrors;
+    Float_t       fRadiusMirror;// [cm] Radius of a single mirror
+    TClonesArray *fMirrors;     // FIXME: Change TClonesArray away from a pointer?
+
+    // Magic Def Parameters
+    Float_t fFocalDist;         // [cm] Focal distance
+    Float_t fPointSpread;       // [cm] Point spread function, sigma in x and y on the camera as simualted in the Reflector
+    Float_t fPointSpreadX;       // [cm] Point spread function, sigma in x on the camera adding gaussian in the Camera
+    Float_t fPointSpreadY;       // [cm] Point spread function, sigma in y on the camera adding gaussian in the Camera
+    Float_t fBlackSpot;         // [cm] Radius of black spot in the mirror center
+    Float_t fCameraWidth;       // [cm] Radius on the camera plain 
+                                // inside which the phe are kept.
+
+    Float_t fMissPointingX;     // [deg] Misspointing in deg added in he Camera 
+    Float_t fMissPointingY;     // [deg] simulation at rho (rotation FoV) = 0. 
+
+    // QE Information
+    UInt_t  fNumPMTs;
+    TClonesArray  *fPMTs;
+
+    // Light Collection Information (guides , plexiglas, 1st dynode) 
+
+    TArrayF fIncidentTheta;    // [deg] Angle (0-180 deg) between light 
+                               // direction and camera plane.
+    TArrayF fLightCollectionFactor;//   Inner pixels
+    TArrayF fLightCollectionFactorOuter;//  Outer pixels
+
+public:
+    MMcConfigRunHeader(const char *name=NULL, const char *title=NULL);
+    ~MMcConfigRunHeader() { delete fMirrors; delete fPMTs; }
+
+    void SetMagicDef(Float_t radius, Float_t focal, Float_t point,
+		     Float_t spot, Float_t camwidth);
+    void SetLightCollection(const TArrayF &theta, const TArrayF &factor, 
+			    const TArrayF &factor_outer);
+
+    UInt_t GetNumMirror() const { return fNumMirrors; }
+    void   InitSizeMirror(UInt_t num) { fMirrors->Expand(num); }
+
+    UInt_t GetNumPMTs() const { return fNumPMTs; }
+    void   InitSizePMTs(UInt_t num) { fPMTs->Expand(num); }
+
+    Float_t GetPointSpread() const { return fPointSpread; }
+    void    SetPointSpread(Float_t x) { fPointSpread = x; }
+
+    Float_t GetPointSpreadX() const { return fPointSpreadX; }
+    void    SetPointSpreadX(Float_t x) { fPointSpreadX = x; }
+    Float_t GetPointSpreadY() const { return fPointSpreadY; }
+    void    SetPointSpreadY(Float_t x) { fPointSpreadY = x; }
+
+    Float_t GetMissPointingX() const {return fMissPointingX;}
+    void    SetMissPointingX(Float_t x) {fMissPointingX=x;}
+
+    Float_t GetMissPointingY() const {return fMissPointingY;}
+    void    SetMissPointingY(Float_t x) {fMissPointingY=x;}
+
+    TArrayF GetLightCollectionFactor() const {return fLightCollectionFactor; }
+    TArrayF GetLightCollectionFactorOuter() const 
+      {return fLightCollectionFactorOuter; }
+    TArrayF GetIncidentTheta() const {return fIncidentTheta;}
+
+    void   AddMirror(Int_t id)
+    {
+        new ((*fMirrors)[fNumMirrors++]) MGeomMirror(id);
+    }
+
+    void   AddPMT(Int_t id)
+    {
+        new ((*fPMTs)[fNumPMTs++]) MGeomPMT(id);
+    }
+
+    MGeomMirror &GetMirror(int i)  { return *(MGeomMirror*)(fMirrors->UncheckedAt(i)); }
+    MGeomMirror &GetMirror(int i) const { return *(MGeomMirror*)(fMirrors->UncheckedAt(i)); }
+
+    TClonesArray *GetMirrors() { return fMirrors; }
+
+    MGeomPMT &GetPMT(int i)  { return *(MGeomPMT*)(fPMTs->UncheckedAt(i)); }
+    MGeomPMT &GetPMT(int i) const { return *(MGeomPMT*)(fPMTs->UncheckedAt(i)); }
+
+    ClassDef(MMcConfigRunHeader, 3)  // class for monte carlo configuration information
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mmc/MMcCorsikaRunHeader.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/MMcCorsikaRunHeader.cc	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/MMcCorsikaRunHeader.cc	(revision 9662)
@@ -0,0 +1,211 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Oscar Blanch  11/2002 (blanch@ifae.es)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MMcCorsikaRunHeader
+//
+// Root storage container for the CORSIKA run header
+//
+// It saves in a root file all variable that are in the CORSIKA run header, except
+// dummies.
+//
+////////////////////////////////////////////////////////////////////////////
+
+
+#include "MGeomCorsikaCT.h"
+#include "MMcCorsikaRunHeader.h"
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MMcCorsikaRunHeader);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+//
+MMcCorsikaRunHeader::MMcCorsikaRunHeader(const char *name, const char *title,
+					 int NumCT)
+  : fTelescopes(NumCT)
+{
+    fName  = name  ? name  : "MMcCorsikaRunHeader";
+    fTitle = title ? title : "Translation of the CORSIKA header";
+
+    fRunNumber = 0;
+    fDate = 0;
+    fCorsikaVersion = 0;
+    fNumObsLev = 0;
+
+    for (int i=0; i<10; i++)
+        fHeightLev[i]=0;
+
+    fSlopeSpec = 0;
+    fELowLim = 0;
+    fEUppLim = 0;
+    fEGS4flag = 0;
+    fNKGflag = 0;
+    fEcutoffh = 0;
+    fEcutoffm = 0;
+    fEcutoffe = 0;
+    fEcutoffg = 0;
+
+    for(int i=0; i<50; i++)  fC[i] = 0;
+    for(int i=0; i<40; i++)  fCKA[i] = 0;
+    for(int i=0; i<5; i++)  fCETA[i] = 0;
+    for(int i=0; i<11; i++)  fCSTRBA[i] = 0;
+    for(int i=0; i<5; i++)
+    {
+        fAATM[i] = 0;
+        fBATM[i] = 0;
+        fCATM[i] = 0;
+    }
+    for (int i=0;i<4; i++)  fNFL[i] = 0;
+
+    fViewconeAngles[0]=0.0;
+    fViewconeAngles[1]=0.0;
+
+    fWobbleMode=0;
+    fAtmosphericModel=0;
+
+    fNumCT=NumCT;
+
+    fTelescopes.SetOwner();
+
+    for  (int i=0;i<NumCT;i++)
+      {
+	MGeomCorsikaCT* dummy = new  MGeomCorsikaCT();
+	fTelescopes.Add(dummy);
+      }
+
+    SetReadyToSave();
+}
+
+// -------------------------------------------------------------------------
+//
+// Fill Corsika Run Header
+//
+void MMcCorsikaRunHeader::Fill(const Float_t  runnumber,
+                               const Float_t  date,
+			       const Float_t  vers,
+			       const Float_t  numobslev,
+			       const Float_t  height[10],
+			       const Float_t  slope,
+			       const Float_t  elow,
+			       const Float_t  eupp,
+			       const Float_t  egs4,
+			       const Float_t  nkg,
+			       const Float_t  eh,
+			       const Float_t  em,
+			       const Float_t  ee,
+			       const Float_t  eg,
+			       const Float_t  c[50],
+			       const Float_t  cka[40],
+			       const Float_t  ceta[5],
+			       const Float_t  cstrba[11],
+			       const Float_t  aatm[5],
+			       const Float_t  batm[5],
+			       const Float_t  catm[5],
+			       const Float_t  nfl[4],
+			       const Float_t  viewcone[2],
+			       const Float_t  wobble,
+			       const Float_t  atmospher
+			       )
+{
+    fRunNumber = runnumber;
+    fDate = date;
+    fCorsikaVersion = vers;
+    fNumObsLev = numobslev;
+
+    for (int i=0; i<10; i++)
+        fHeightLev[i]=height[i];
+
+    fSlopeSpec = slope;
+    fELowLim = elow;
+    fEUppLim = eupp;
+    fEGS4flag = egs4;
+    fNKGflag = nkg;
+    fEcutoffh = eh;
+    fEcutoffm = em;
+    fEcutoffe = ee;
+    fEcutoffg = eg;
+
+    for (int i=0; i<50; i++)  fC[i] = c[i];
+    for (int i=0; i<40; i++)  fCKA[i] = cka[i];
+    for (int i=0; i<5 ; i++)  fCETA[i] = ceta[i];
+    for (int i=0; i<11; i++)  fCSTRBA[i] = cstrba[i];
+    for (int i=0; i<5; i++)
+    {
+        fAATM[i] = aatm[i];
+        fBATM[i] = batm[i];
+        fCATM[i] = catm[i];
+    }
+    for (int i=0; i<4; i++)  fNFL[i] = nfl[i];
+
+    fViewconeAngles[0]=viewcone[0];
+    fViewconeAngles[1]=viewcone[1];
+
+    fWobbleMode=wobble;
+    fAtmosphericModel=atmospher;
+
+}
+
+// -------------------------------------------------------------------------
+//
+// Fill C Telescope information in Corsika Run Header
+//
+void MMcCorsikaRunHeader::FillCT(Float_t ctx, Float_t cty, Float_t ctz,
+				 Float_t cttheta, Float_t ctphi,
+				 Float_t ctdiam, Float_t ctfocal,
+				 Int_t CTnum){
+
+  static_cast<MGeomCorsikaCT*>(fTelescopes.UncheckedAt(CTnum))
+    ->Fill(ctx, cty, ctz, cttheta, ctphi, ctdiam, ctfocal);
+
+}
+
+// -------------------------------------------------------------------------
+//
+// Returns a reference of the i-th entry (the telescope with the index i)
+//
+MGeomCorsikaCT &MMcCorsikaRunHeader::operator[](Int_t i) const
+{
+    return *static_cast<MGeomCorsikaCT*>(fTelescopes.UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints the information of all telescopes
+//
+void MMcCorsikaRunHeader::Print(Option_t *) const
+{
+    //
+    //   Print Information about the Geometry of the camera
+    //
+  *fLog << all << GetTitle() <<". Number of Telescopes: " << fNumCT << endl;
+
+  fTelescopes.Print();
+} 
Index: /tags/Mars_V0-8-5/Mars/mmc/MMcCorsikaRunHeader.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/MMcCorsikaRunHeader.h	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/MMcCorsikaRunHeader.h	(revision 9662)
@@ -0,0 +1,115 @@
+#ifndef MARS_MMcCorsikaRunHeader
+#define MARS_MMcCorsikaRunHeader
+///////////////////////////////////////////////////////////////////////
+//                                                                   //
+// MMcCorsikaRunHeader                                               //
+//                                                                   //
+///////////////////////////////////////////////////////////////////////
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+
+class MGeomCorsikaCT;
+
+class MMcCorsikaRunHeader : public MParContainer
+{
+private:
+    // Header copied directly from CORSIKA header, skiping dummy values.
+    // The propouse of this container is being able to cmopare with
+    // Corsika run Header
+    // See CORSIKA manual for explanations
+    Float_t fRunNumber;
+    Float_t fDate;
+    Float_t fCorsikaVersion;
+    Float_t fNumObsLev;
+    Float_t fHeightLev[10];
+    Float_t fSlopeSpec;  // Slope of primaries' energy spectrum
+    Float_t fELowLim;
+    Float_t fEUppLim;    // Limits of energy range for generation
+    Float_t fEGS4flag;
+    Float_t fNKGflag;
+    Float_t fEcutoffh;
+    Float_t fEcutoffm;
+    Float_t fEcutoffe;
+    Float_t fEcutoffg;
+
+    // Physical constants and interaction flags (see CORSIKA manual):
+    Float_t fC[50];
+    Float_t fCKA[40];
+    Float_t fCETA[5];
+    Float_t fCSTRBA[11];
+    Float_t fAATM[5];
+    Float_t fBATM[5];
+    Float_t fCATM[5];
+    Float_t fNFL[4];
+
+    // (degrees) Inner and outer angles in Corsika's VIEWCONE option
+    Float_t fViewconeAngles[2]; 
+                                  
+
+    Float_t fWobbleMode;     // Indicates wobble mode with which
+                             //  reflector has been run 
+    Float_t fAtmosphericModel; // Indicates atmospheric model used in
+                               // absorption simulation. 0 = no atmosphere,
+                               // 1 = atm_90percent, 2 = atm_isothermal,
+                               // 3 = atm_corsika.
+    UInt_t fNumCT;
+    TObjArray fTelescopes;
+
+public:
+    MMcCorsikaRunHeader(const char *name=NULL, const char *title=NULL,
+			int NumCT=1);
+
+
+    void Fill(const Float_t  runnumber,
+              const Float_t  date,
+              const Float_t  vers,
+              const Float_t  fNumObsLev,
+              const Float_t  height[10],
+              const Float_t  slope,
+              const Float_t  elow,
+              const Float_t  eupp,
+              const Float_t  egs4,
+              const Float_t  nkg,
+              const Float_t  eh,
+              const Float_t  em,
+              const Float_t  ee,
+              const Float_t  eg,
+              const Float_t  c[50],
+              const Float_t  cka[40],
+              const Float_t  ceta[5],
+              const Float_t  cstrba[11],
+              const Float_t  aatm[5],
+              const Float_t  batm[5],
+              const Float_t  catm[5],
+              const Float_t  nfl[4],
+	      const Float_t  viewcone[2],
+	      const Float_t  wobble,
+	      const Float_t  atmospher
+             );
+
+    Float_t GetELowLim() const { return fELowLim; }
+    Float_t GetEUppLim() const { return fEUppLim; }
+    Float_t GetSlopeSpec() const { return fSlopeSpec; }
+
+    Int_t GetNumCT() const { return fNumCT; }
+
+    void FillCT(Float_t ctx, Float_t cty, Float_t ctz,
+		Float_t cttheta, Float_t ctphi,
+		Float_t ctdiam, Float_t ctfocal,
+		Int_t CTnum);
+
+    MGeomCorsikaCT &operator[](Int_t i) const;
+
+    virtual void Print(Option_t *opt=NULL) const;
+
+    ClassDef(MMcCorsikaRunHeader, 3) // storage container for corsika setup information
+};
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mmc/MMcEvt.cxx
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/MMcEvt.cxx	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/MMcEvt.cxx	(revision 9662)
@@ -0,0 +1,301 @@
+#include "MMcEvt.hxx"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+//==========
+// MMcEvt
+//    
+// This class handles and contains the MonteCarlo information
+// with which the events have been generated
+// This information exists for each event.
+//
+// Note: All the azimuth Phi angles in this and other MC classes follow
+// the convention in the Corsika program (see Corsika manual). There, phi
+// is the azimuth of the momentum vector of particles, and is measured
+// from the north direction, anticlockwise (i.e, west is phi=90 degrees).
+// When it refers to the telescope orientation, it is the azimuth of a 
+// vector along the telescope axis, going from the camera to the mirror. 
+// So, fTelescopeTheta=90, fTelescopePhi = 0 means the telescope is 
+// pointing horizontally towards South. For an explanation, see also 
+// TDAS 02-11. 
+//
+ClassImp(MMcEvt);
+
+using namespace std;
+
+
+MMcEvt::MMcEvt()
+{
+    //
+    //  default constructor
+    //  set all values to zero
+    fName  = "MMcEvt";
+    fTitle = "Event info from Monte Carlo";
+
+    Clear();
+}
+
+MMcEvt::MMcEvt( UInt_t  fEvtNum,
+		UShort_t usPId,
+		Float_t  fEner,
+		Float_t  fThi0,
+		Float_t  fFirTar,
+		Float_t  fzFirInt,
+		Float_t  fThet, 
+		Float_t  fPhii, 
+		Float_t  fCorD, 
+		Float_t  fCorX, 
+		Float_t  fCorY,
+		Float_t  fImpa,
+		Float_t  fTPhii,
+		Float_t  fTThet,
+		Float_t  fTFirst,
+		Float_t  fTLast,
+		Float_t  fL_Nmax,
+		Float_t  fL_t0,
+		Float_t  fL_tmax,
+		Float_t  fL_a,
+		Float_t  fL_b,
+		Float_t  fL_c,
+		Float_t  fL_chi2,
+		UInt_t   uiPin, 
+		UInt_t   uiPat,  
+		UInt_t   uiPre, 
+		UInt_t   uiPco,  
+		UInt_t   uiPelS,
+		UInt_t   uiPelC,
+		Float_t  elec,
+		Float_t  muon,
+		Float_t  other) {
+
+    fName  = "MMcEvt";
+    fTitle = "Event info from Monte Carlo";
+  //
+  //  constuctor II 
+  //
+  //  All datamembers are parameters. 
+  //
+  //  Don't use this memberfunction in analysis
+  //  
+
+  fEvtNumber = fEvtNum;
+  fPartId = usPId  ;
+  fEnergy  = fEner  ;
+  fThick0 = fThi0;
+  fFirstTarget = fFirTar;
+  fZFirstInteraction = fzFirInt;
+
+  fTheta   = fThet ;
+  fPhi     = fPhii ;
+
+  fCoreD   = fCorD ;
+  fCoreX   = fCorX ;
+  fCoreY   = fCorY ;
+  fImpact  = fImpa ;
+
+  fTelescopePhi = fTPhii;
+  fTelescopeTheta = fTThet;
+  fTimeFirst = fTFirst;
+  fTimeLast = fTLast;
+  fLongiNmax = fL_Nmax;
+  fLongit0 = fL_t0;
+  fLongitmax = fL_tmax;
+  fLongia = fL_a;
+  fLongib = fL_b;
+  fLongic = fL_c;
+  fLongichi2 = fL_chi2;
+
+
+  fPhotIni      = uiPin ;
+  fPassPhotAtm  = uiPat ;
+  fPassPhotRef  = uiPre ;
+  fPassPhotCone = uiPco ;
+  fPhotElfromShower = uiPelS ;
+  fPhotElinCamera   = uiPelC ;
+
+  fElecCphFraction=elec;
+  fMuonCphFraction=muon;
+  fOtherCphFraction=other;
+}
+
+
+
+MMcEvt::~MMcEvt() {
+  //
+  //  default destructor
+  //
+}
+
+
+
+
+void MMcEvt::Clear(Option_t *opt)
+{
+    //
+    //  reset all values to values as nonsense as possible
+    //
+    fPartId = 0;
+    fEnergy = -1;
+
+    fTheta = 0;
+    fPhi   = 0;
+
+    fCoreD  =  0;
+    fCoreX  =  0;
+    fCoreY  =  0;
+    fImpact = -1;
+
+    fPhotIni          = 0;
+    fPassPhotAtm      = 0;
+    fPassPhotRef      = 0;
+    fPassPhotCone     = 0;
+    fPhotElfromShower = 0;
+    fPhotElinCamera   = 0;
+
+    fElecCphFraction=0;
+    fMuonCphFraction=0;
+    fOtherCphFraction=0;
+}
+
+void MMcEvt::Fill( UInt_t  fEvtNum,
+		   UShort_t usPId, 
+		   Float_t  fEner, 
+		   Float_t  fThi0,
+		   Float_t  fFirTar,
+		   Float_t  fzFirInt,
+		   Float_t  fThet, 
+		   Float_t  fPhii, 
+		   Float_t  fCorD, 
+		   Float_t  fCorX, 
+		   Float_t  fCorY,
+		   Float_t  fImpa, 
+		   Float_t  fTPhii,
+		   Float_t  fTThet,
+		   Float_t  fTFirst,
+		   Float_t  fTLast,
+		   Float_t  fL_Nmax,
+		   Float_t  fL_t0,
+		   Float_t  fL_tmax,
+		   Float_t  fL_a,
+		   Float_t  fL_b,
+		   Float_t  fL_c,
+		   Float_t  fL_chi2,
+		   UInt_t   uiPin, 
+		   UInt_t   uiPat,  
+		   UInt_t   uiPre, 
+		   UInt_t   uiPco,  
+		   UInt_t   uiPelS,  
+		   UInt_t   uiPelC,
+		   Float_t  elec,
+		   Float_t  muon,
+		   Float_t  other ) {
+  //
+  //  All datamembers are filled with the correspondin parameters. 
+  //
+  //  Don't use this memberfunction in analysis
+  //  
+
+  fEvtNumber = fEvtNum;
+  fPartId = usPId  ;
+  fEnergy = fEner  ;
+  fThick0 = fThi0;
+  fFirstTarget = fFirTar;
+  fZFirstInteraction = fzFirInt;
+
+  fTheta  = fThet ;
+  fPhi    = fPhii ;
+
+  fCoreD  = fCorD ;
+  fCoreX  = fCorX ;
+  fCoreY  = fCorY ;
+  fImpact = fImpa ;
+
+  fTelescopePhi = fTPhii;
+  fTelescopeTheta = fTThet;
+  fTimeFirst = fTFirst;
+  fTimeLast = fTLast;
+  fLongiNmax = fL_Nmax;
+  fLongit0 = fL_t0;
+  fLongitmax = fL_tmax;
+  fLongia = fL_a;
+  fLongib = fL_b;
+  fLongic = fL_c;
+  fLongichi2 = fL_chi2;
+
+  fPhotIni      = uiPin ;
+  fPassPhotAtm  = fPhotIni-uiPat ;
+  fPassPhotRef  = fPassPhotAtm-uiPre ;
+  fPassPhotCone = uiPco ;
+  fPhotElfromShower = uiPelS ;
+  fPhotElinCamera = uiPelC ;
+
+  fElecCphFraction=elec;
+  fMuonCphFraction=muon;
+  fOtherCphFraction=other;
+
+}
+
+/*
+void MMcEvt::AsciiWrite(ofstream &fout) const
+{
+    fout << fEnergy << " ";
+    fout << fTheta ;
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+// Print the contents of the container.
+//
+//  if you specify an option only the requested data members are printed:
+//  allowed options are:
+//   id, energy, impact
+//
+void MMcEvt::Print(Option_t *opt) const
+{
+    //
+    //  print out the data member on screen
+    //
+    TString str(opt);
+    if (str.IsNull())
+    {
+        *fLog << all << endl;
+        *fLog << "Monte Carlo output:" << endl;
+        *fLog << " Particle Id:    ";
+        switch(fPartId)
+        {
+        case kGAMMA:
+            *fLog << "Gamma" << endl;
+            break;
+        case kPROTON:
+            *fLog << "Proton" << endl;
+            break;
+        case kHELIUM:
+            *fLog << "Helium" << endl;
+            break;
+        }
+        *fLog << " Energy:         " << fEnergy << "GeV" << endl;
+        *fLog << " Impactpar.:     " << fImpact/100 << "m" << endl;
+        *fLog << " Photoelectrons: " << fPhotElfromShower << endl;
+        *fLog << endl;
+        return;
+    }
+    if (str.Contains("id", TString::kIgnoreCase))
+        switch(fPartId)
+        {
+        case kGAMMA:
+            *fLog << "Particle: Gamma" << endl;
+            break;
+        case kPROTON:
+            *fLog << "Particle: Proton" << endl;
+            break;
+        case kHELIUM:
+            *fLog << "Particle: Helium" << endl;
+            break;
+        }
+    if (str.Contains("energy", TString::kIgnoreCase))
+        *fLog << "Energy: " << fEnergy << "GeV" << endl;
+    if (str.Contains("impact", TString::kIgnoreCase))
+        *fLog << "Impact: " << fImpact << "cm" << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/mmc/MMcEvt.hxx
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/MMcEvt.hxx	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/MMcEvt.hxx	(revision 9662)
@@ -0,0 +1,241 @@
+#ifndef __MMcEvt__
+#define __MMcEvt__
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MMcEvt : public MParContainer
+{
+public:
+    //
+    //     ParticleId for Monte Carlo simulation
+    //
+    enum ParticleId_t
+    {
+        kGAMMA    =  1,
+        kPOSITRON =  2,
+        kELECTRON =  3,
+        kANTIMUON =  5,
+        kMUON     =  6,
+        kPI0      =  7,
+        kNEUTRON  = 13,
+        kPROTON =   14,
+        kHELIUM =  402,
+        kOXYGEN = 1608,
+        kIRON   = 5626
+    };
+
+private:
+  UInt_t      fEvtNumber;
+  UShort_t     fPartId;             // Type of particle
+  Float_t      fEnergy;             // [GeV] Energy
+  Float_t      fThick0;             // [g/cm2]
+  Float_t      fFirstTarget;        // []
+  Float_t      fZFirstInteraction;  // [cm]
+
+  Float_t fTheta;           // [rad] Theta angle of event 
+  Float_t fPhi;             // [rad] Phi angle of event (see class description)
+
+  Float_t fCoreD;           // [cm] Core d pos
+  Float_t fCoreX;           // [cm] Core x pos
+  Float_t fCoreY;           // [cm] Core y pos
+  Float_t fImpact;          // [cm] impact parameter
+
+  // Up to here, the info from the CORSIKA event header. 
+
+  // Telescope orientation: 
+  Float_t	fTelescopePhi;    // [rad] (see class description)
+  Float_t	fTelescopeTheta;  // [rad]
+
+  // Time of first and last photon:
+  Float_t      fTimeFirst;   // [ns]
+  Float_t      fTimeLast;    // [ns]
+
+  // 6 parameters and chi2 of the NKG fit to the longitudinal 
+  // particle distribution. See CORSIKA manual for explanation,
+  // section 4.42 "Longitudinal shower development": 
+  //
+  Float_t       fLongiNmax;   // [particles]
+  Float_t       fLongit0;     // [g/cm2]
+  Float_t       fLongitmax;   // [g/cm2]
+  Float_t       fLongia;      // [g/cm2]
+  Float_t       fLongib;      // []
+  Float_t       fLongic;      // [cm2/g]
+  Float_t       fLongichi2;
+
+  UInt_t fPhotIni;          // [ph] Initial number of photons
+  UInt_t fPassPhotAtm;      // [ph] Passed atmosphere
+  UInt_t fPassPhotRef;      // [ph] Passed reflector(reflectivity + effective area)
+  UInt_t fPassPhotCone;     // [ph]  Within any valid pixel, before plexiglas
+  UInt_t fPhotElfromShower; // [phe] Passed qe, coming from the shower
+  UInt_t fPhotElinCamera;   // [phe] usPhotElfromShower + mean of phe
+                            // from NSB
+
+  // Now follow the fraction of photons reaching the camera produced by
+  // electrons, muons and other particles respectively:
+
+  Float_t  fElecCphFraction;
+  Float_t  fMuonCphFraction;
+  Float_t  fOtherCphFraction;
+  
+
+
+ public:
+  MMcEvt() ;
+  
+  MMcEvt( UInt_t, UShort_t, Float_t, Float_t, Float_t,
+	  Float_t, Float_t, Float_t, Float_t, Float_t, Float_t,
+	  Float_t, Float_t, Float_t, Float_t, Float_t, Float_t, 
+	  Float_t, Float_t, Float_t, Float_t, Float_t, Float_t, 
+	  UInt_t, UInt_t, UInt_t, UInt_t, UInt_t, UInt_t,
+	  Float_t, Float_t, Float_t) ; 
+  
+  ~MMcEvt(); 
+
+  void Clear(Option_t *opt=NULL);
+
+  void Fill( UInt_t, UShort_t, Float_t, Float_t, Float_t, 
+	     Float_t, Float_t, Float_t, Float_t, Float_t, Float_t,
+	     Float_t, Float_t, Float_t, Float_t, Float_t, Float_t,
+	     Float_t, Float_t, Float_t, Float_t, Float_t, Float_t,
+	     UInt_t, UInt_t, UInt_t, UInt_t, UInt_t, UInt_t,
+	     Float_t, Float_t, Float_t) ; 
+
+  //virtual void AsciiWrite(ofstream &fout) const;
+
+  void Print(Option_t *opt=NULL) const;
+
+  UInt_t GetEvtNumber() const { return fEvtNumber; }  //Get Event Number
+  Short_t GetPartId() const { return fPartId; }       //Get Type of particle
+  Float_t GetEnergy() const { return fEnergy; }        //Get Energy
+
+  Float_t GetTheta() const { return fTheta; }          //Get Theta angle
+  Float_t GetPhi() const { return fPhi ;  }            //Get Phi angle
+
+/*    Float_t GetCoreD() { return fCoreD; }          //Get Core d pos */
+  Float_t GetCoreX() { return fCoreX; }          //Get Core x pos
+  Float_t GetCoreY() { return fCoreY; }          //Get Core y pos
+  Float_t GetImpact() const { return fImpact;}         //Get impact parameter 
+
+  UInt_t GetPhotIni() { return fPhotIni; }           //Get Initial photons
+  UInt_t GetPassPhotAtm() { return fPassPhotAtm;}    //Get Passed atmosphere
+  UInt_t GetPassPhotRef() { return fPassPhotRef; }   //Get Passed reflector
+  UInt_t GetPassPhotCone() { return fPassPhotCone; } //Get Passed glas
+  UInt_t GetPhotElfromShower() { return fPhotElfromShower; }   //Get Passed qe from shower
+  UInt_t GetPhotElinCamera() { return fPhotElinCamera; }   //Get Passed qe total
+  Float_t GetZFirstInteraction() const { return fZFirstInteraction; }
+
+  Float_t GetTelescopePhi() const { return fTelescopePhi; }
+  Float_t GetTelescopeTheta() const { return fTelescopeTheta; }
+  Float_t GetOtherCphFraction() const { return fOtherCphFraction; }
+
+  Float_t GetLongiNmax() const { return fLongiNmax; }
+  Float_t GetLongia()    const { return fLongia; }
+  Float_t GetLongib()    const { return fLongib; }
+  Float_t GetLongic()    const { return fLongic; }
+  Float_t GetLongichi2() const { return fLongichi2; }
+  Float_t GetLongit0()   const { return fLongit0; }
+  Float_t GetLongitmax() const { return fLongitmax; }
+
+  void SetPartId(Short_t PartId)
+  {fPartId=PartId;}             //Set Type of particle 
+
+  TString GetParticleName() const
+  {
+      switch (fPartId)
+      {
+      case kGAMMA:    return "Gamma";
+      case kPOSITRON: return "Positron";
+      case kELECTRON: return "Electron";
+      case kANTIMUON: return "Anti-Muon";
+      case kMUON:     return "Muon";
+      case kPI0:      return "Pi-0";
+      case kNEUTRON:  return "Neutron";
+      case kPROTON:   return "Proton";
+      case kHELIUM:   return "Helium";
+      case kOXYGEN:   return "Oxygen";
+      case kIRON:     return "Iron";
+      }
+
+      return Form("Id:%d", fPartId);
+  }
+  TString GetParticleSymbol() const
+  {
+      switch (fPartId)
+      {
+      case kGAMMA:    return "\\gamma";
+      case kPOSITRON: return "e^{+}";
+      case kELECTRON: return "e^{-}";
+      case kANTIMUON: return "\\mu^{+}";
+      case kMUON:     return "\\mu^{-}";
+      case kPI0:      return "\\pi^{0}";
+      case kNEUTRON:  return "n";
+      case kPROTON:   return "p";
+      case kHELIUM:   return "He";
+      case kOXYGEN:   return "O";
+      case kIRON:     return "Fe";
+      }
+
+      return Form("Id:%d", fPartId);
+  }
+  TString GetEnergyStr() const
+  {
+      if (fEnergy>1000)
+          return Form("%.1fTeV", fEnergy/1000);
+
+      if (fEnergy>10)
+          return Form("%dGeV", (Int_t)(fEnergy+.5));
+
+      if (fEnergy>1)
+          return Form("%.1fGeV", fEnergy);
+
+      return Form("%dMeV", (Int_t)(fEnergy*1000+.5));
+  }
+
+  void SetEnergy(Float_t Energy)
+  { fEnergy=Energy; }              //Set Energy 
+ 
+  void SetTheta(Float_t Theta) 
+  { fTheta=Theta; }                //Set Theta angle 
+
+  void SetPhi(Float_t Phi) 
+  { fPhi=Phi;  }                   //Set Phi angle 
+ 
+  void SetCoreD(Float_t CoreD) 
+  { fCoreD=CoreD; }                //Set Core d pos
+
+  void SetCoreX(Float_t CoreX)
+  { fCoreX=CoreX; }                //Set Core x pos 
+
+  void SetCoreY(Float_t CoreY ) 
+  { fCoreY=CoreY; }                //Set Core y pos
+
+  void SetImpact(Float_t Impact) 
+  { fImpact=Impact;}               //Set impact parameter
+
+  // DO NOT USE THIS IS A WORKAROUND!
+  void SetTelescopeTheta(Float_t Theta) { fTelescopeTheta=Theta; }
+  void SetTelescopePhi(Float_t Phi)     { fTelescopePhi=Phi; }
+
+  
+/*    void SetPhotIni(Short_t PhotIni)  */
+/*      { fPhotIni=PhotIni; }                 //Set Initial photons */
+/*    void SetPassPhotAtm(Short_t PassPhotAtm)  */
+/*      { fPassPhotAtm=PassPhotAtm;}         //Set Passed atmosphere */
+/*    void SetPassPhotRef(Short_t PassPhotRef)  */
+/*      { fPassPhotRef=PassPhotRef ; }       //Set Passed reflector */
+/*    void SetPassPhotCone(Short_t PhotCon)  */
+/*      { fPassPhotCone=PhotCon; }           //Set Passed glas */
+
+
+  ClassDef(MMcEvt, 3)  //Stores Montecarlo Information of one event (eg. the energy)
+
+};
+
+#endif
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mmc/MMcFadcHeader.cxx
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/MMcFadcHeader.cxx	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/MMcFadcHeader.cxx	(revision 9662)
@@ -0,0 +1,71 @@
+#include "MMcFadcHeader.hxx"
+
+#include <iostream>
+
+//==========
+// MMcFadcHeader
+//    
+// This class contains the MonteCarlo information
+// of the FADC simulation for the current run.
+// The information is saved only once, whatever the
+// number of events is
+ 
+
+
+ClassImp(MMcFadcHeader);
+
+using namespace std;
+
+
+MMcFadcHeader::MMcFadcHeader(const char *name, const char *title) {
+  //
+  //  default constructor
+
+  fName  = name  ? name  : "MMcFadcHeader";
+  fTitle = title ? title : "Fadc Header Information from Monte Carlo";
+
+  //  set all values to zero
+
+  Int_t i;
+
+  fFadcShape=0.0; 
+  fAmplFadc=MFADC_RESPONSE_INTEGRAL;
+  fFwhmFadc=MFADC_RESPONSE_FWHM;
+  fAmplFadcOuter=MFADC_RESPONSE_INTEGRAL;
+  fFwhmFadcOuter=MFADC_RESPONSE_FWHM;
+
+  for(i=0;i<MFADC_CHANNELS;i++){
+    fPedesMean[i]= 0.0    ;
+    fPedesSigmaHigh[i]=-1.0    ;
+    fPedesSigmaLow[i]=-1.0    ;
+    fElecNoise[i]=-1.0   ;
+    fDigitalNoise[i]=-1.0   ;
+  }
+}
+
+MMcFadcHeader::~MMcFadcHeader(){
+  //
+  //  default destructor
+  //
+}
+
+
+void MMcFadcHeader::Print(Option_t *Option) const {
+  //
+  //  print out the data member on screen
+  //
+  cout << endl;
+  cout << "Monte Carlo Fadc output:" << endl;
+  cout << " Shape type of the signal: "       << fFadcShape << endl;
+  cout << " FADC integral for sphe [counts*ns]: " << fAmplFadc << endl;
+  cout << " Width of the signal in nsec: "    << fFwhmFadc << endl;
+  cout << " Outer FADC integral for sphe [counts*ns]: " << fAmplFadcOuter
+       << endl;
+  cout << " Width of the signal in nsec for outer: "    << fFwhmFadcOuter 
+       << endl;
+  cout << " Pedestals and ElecNoise in fadc counts: " << endl;
+  for (int i=0;i<MFADC_CHANNELS;i++){
+    cout << " Pixel "<<i<<": "<<fPedesMean[i]<<"  "<<fElecNoise[i]<<endl;
+  }
+  cout << endl ; 
+}
Index: /tags/Mars_V0-8-5/Mars/mmc/MMcFadcHeader.hxx
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/MMcFadcHeader.hxx	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/MMcFadcHeader.hxx	(revision 9662)
@@ -0,0 +1,118 @@
+#ifndef __MMcFadcHeader__
+#define __MMcFadcHeader__
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#include "MFadcDefine.h"
+
+class MMcFadcHeader : public MParContainer{
+ private:
+
+  Float_t  fFadcShape   ;   // a number that indicate the shape type of 
+                            // the signal   
+  Float_t  fFadcShapeOuter; // a number that indicate the shape type of 
+                            // the signal   
+                            // = 0 --> a gaussian  
+                            // = 1 --> from Pulpo set-up  
+ 
+  // NOTE : meaning of fAmplFadc, fAmplFadcOuter changed in camera 0.7, 
+  // 30/03/2004: before it was amplitude of (gaussian) pulse, now is 
+  // integral of pulse (which may be gaussian or not).
+
+  Float_t  fAmplFadc    ;   // the integral of single phe response [counts]
+  Float_t  fFwhmFadc    ;   // the width of the signal in nsec
+  Float_t  fAmplFadcOuter;  // the integral of single phe response [counts], 
+                            // outer pixels
+  Float_t  fFwhmFadcOuter;  // the width of the signal in nsec, outer
+
+  Float_t  fPedesMean[MFADC_CHANNELS]    ;  //  The mean value for the pedestal
+                                            //  of each pixel (channel)
+  Float_t  fPedesSigmaHigh[MFADC_CHANNELS]    ; //  The sigma for the pedestal
+                                                //  of each pixel (channel)
+  Float_t  fPedesSigmaLow[MFADC_CHANNELS]    ;  //  The sigma for the pedestal
+                                                //  of each pixel (channel)
+
+  // In camera 0.7, the meaning of fPedesSigmaHigh, fPedesSigmaLow changed:
+  // before it was the rms of the single FADC slice. Now we calculate the 
+  // RMS of the distribution of the sum of 14 FADC slices. The value we set 
+  // as fPedesSigmaHigh/Low is that RMS divided by sqrt(14). It can be seen
+  // that the fluctuations of the integrated pedestal, when adding n slices 
+  // to obtain the pixel signal, with n>~6, is more or less well 
+  // approximated by sqrt(n)*RMS(sum_14)slices)/sqrt(14).
+
+
+  Float_t  fElecNoise[MFADC_CHANNELS]   ;  //  The rms value in the pedestal 
+                                           //  due to the electronics for
+                                           //  each pixel (channel)
+  Float_t  fDigitalNoise[MFADC_CHANNELS];  //  The rms value in the pedestal 
+                                           //  due to the digital for
+                                           //  each pixel (channel)
+  Float_t fLow2HighGain;    // low gain factor 
+
+ public:
+  MMcFadcHeader(const char *name=NULL, const char *title=NULL);
+
+  ~MMcFadcHeader(); 
+
+  void Print(Option_t *opt=NULL) const;
+  
+  void SetShape(Float_t shape){
+    fFadcShape=shape;
+  }
+
+  void SetShapeOuter(Float_t shape){
+    fFadcShapeOuter=shape;
+  }
+
+  void SetLow2High(Float_t l2h){
+    fLow2HighGain=l2h;
+  }
+
+  void SetAmplitud(Float_t amp, Float_t ampout=0.0){
+    fAmplFadc=amp;
+    fAmplFadcOuter=ampout;
+ }
+
+  void SetFwhm(Float_t fwhm, Float_t fwhmout=0.0){
+    fFwhmFadc=fwhm;
+    fFwhmFadcOuter=fwhmout;
+  }
+
+  void SetPedestal(Float_t *mean, Int_t dim){
+    for (Int_t i=0;i<dim;i++)
+      fPedesMean[i]=mean[i];
+  }
+
+  void SetPedestalSigma(Float_t *sigmalo, Float_t *sigmahi, Int_t dim){
+    for (Int_t i=0;i<dim;i++){
+      fPedesSigmaLow[i]=sigmalo[i];
+      fPedesSigmaHigh[i]=sigmahi[i];
+    }
+  }
+
+  void SetElecNoise(Float_t *sigmae, Float_t *sigmad, Int_t dim){
+    for (Int_t i=0;i<dim;i++){
+      fElecNoise[i]=sigmae[i];
+      fDigitalNoise[i]=sigmad[i];
+    }
+  }
+  
+  Float_t GetPedestal(UInt_t i) const    { return fPedesMean[i]; }
+  Float_t GetPedestalRmsHigh(UInt_t i) const { return fPedesSigmaHigh[i]; }
+  Float_t GetPedestalRmsLow(UInt_t i) const { return fPedesSigmaLow[i]; }
+  Float_t GetElecNoise(UInt_t i) const { return fElecNoise[i]; }
+  Float_t GetDigitalNoise(UInt_t i) const { return fElecNoise[i]; }
+  Float_t GetAmplitud() const { return fAmplFadc; }
+  Float_t GetAmplitudOuter() const { return fAmplFadcOuter; }
+  Float_t GetLow2HighGain() const { return fLow2HighGain; }
+
+  UInt_t GetNumPixel() const { return MFADC_CHANNELS; }
+
+  ClassDef(MMcFadcHeader, 4)  //Stores Montecarlo Information describing the FADC behaviour
+
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mmc/MMcRunHeader.cxx
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/MMcRunHeader.cxx	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/MMcRunHeader.cxx	(revision 9662)
@@ -0,0 +1,258 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  12/2000 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MMcRunHeader
+//
+// Root storage container for the RUN MONTE CARLO HEADER information
+//
+// This the second version of this output class. Old root files, which have
+// a previous version of this class, are still compatibles and can be used.
+// But of course, you can no try to get infromatino in these old files about
+// the new data members.
+//
+// The following data member have been introduced in this second version 
+// and they do not exist in the previous one:
+//
+//  Float_t fMcRunNumber;      Run Number
+//  UInt_t  fProductionSite;   code to know where the run was generated
+//  Float_t fDateRunMMCs;      Date of the MMCs production
+//  Float_t fDateRunCamera;    Date, when the Camera program is run.
+//  Byte_t  fRawEvt;           RawEvt[Data,Hedaer] stored or not
+//  Byte_t  fElecNoise;        Electronic Noise simulated or not
+//  Byte_t  fStarFieldRotate;  Is the starfield rotation switched on (1) or
+//                             off (0)
+//  Float_t fCWaveLower;       Wavelength limits for the Cerenkov photons
+//  Float_t fCWaveUpper;
+//  UInt_t  fNumObsLev;        Observation levels
+//  Float_t fHeightLev[10];
+//  Float_t fSlopeSpec;        Spectral index
+//
+//  Third version:
+//
+//  Byte_t fOpticLinksNoise;   Flag to state if the optic noise is simualted or not
+//
+//
+// Note: All the azimuth Phi angles in this and other MC classes follow
+// the convention in the Corsika program (see Corsika manual). There, phi
+// is the azimuth of the momentum vector of particles, and is measured
+// from the north direction, anticlockwise (i.e, west is phi=90 degrees).
+// When it refers to the telescope orientation, it is the azimuth of a 
+// vector along the telescope axis, going from the camera to the mirror. 
+// So, fTelesTheta=90, fTelesPhi = 0 means the telescope is pointing 
+// horizontally towards South. For an explanation, see also TDAS 02-11. 
+//
+////////////////////////////////////////////////////////////////////////////
+
+#include "MMcRunHeader.hxx"
+
+#include <fstream>
+#include <iomanip>
+
+#include "MLog.h"
+
+ClassImp(MMcRunHeader);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+//
+MMcRunHeader::MMcRunHeader(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MMcRunHeader";
+    fTitle = title ? title : "Raw Run Header Information";
+
+    fMcRunNumber =0;
+    fProductionSite = 0;
+    fDateRunMMCs = 0;
+    fDateRunCamera = 0;
+    fNumTrigCond = 0;
+    fAllEvtsTriggered = 0 ;
+    fMcEvt = 0;
+    fMcTrig = 0;
+    fMcFadc = 0;
+    fRawEvt = 0;
+    fElecNoise = 0;
+    fStarFieldRotate = 0;
+    fNumAnalisedPixels = 0;
+    fNumSimulatedShowers = 0;
+    fNumStoredShowers = 0;
+    fNumEvents = 0;
+
+    fStarFieldRaH = 0;
+    fStarFieldRaM = 0;
+    fStarFieldRaS = 0;
+    fStarFieldDeD = 0;
+    fStarFieldDeM = 0;
+    fStarFieldDeS = 0;
+
+    fNumPheFromDNSB = 0.0;
+    fTelesTheta = 0.0;
+    fTelesPhi = 0.0;
+    fShowerThetaMax = 0.0;
+    fShowerThetaMin = 0.0;
+    fShowerPhiMax = 0.0;
+    fShowerPhiMin = 0.0;
+
+    fCWaveLower = 0.0;
+    fCWaveUpper = 0.0;
+
+    fNumObsLev = 0;
+    for (int i=0; i<10; i++){
+      fHeightLev[i]=0.0;
+    }
+    fSlopeSpec = 0.0;
+
+    fCorsikaVersion = 0;
+    fReflVersion = 0;
+    fCamVersion = 0;
+    fOpticLinksNoise= 0;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor.
+//
+MMcRunHeader::~MMcRunHeader()
+{
+
+}
+
+// -------------------------------------------------------------------------
+//
+// Fill. Put data in the container
+//
+void MMcRunHeader::Fill(const Float_t  runnumber,
+			const UInt_t   productionsite,
+			const Float_t  daterunMMCs,
+			const Float_t   daterunCamera,
+			const UInt_t   numtrigcond,
+			const Byte_t   allevts,
+			const Byte_t   mcevt,
+			const Byte_t   mctrig,
+			const Byte_t   mcfadc,
+			const Byte_t   rawevt,
+			const Byte_t   elecnoise, 
+			const Int_t    numanalpixels,
+			const UInt_t   numsim,
+			const UInt_t   numsto,
+			const Byte_t   starfieldrotate,
+			const Int_t    sfRaH,
+			const Int_t    sfRaM,
+			const Int_t    sfRaS,
+			const Int_t    sfDeD,
+			const Int_t    sfDeM,
+			const Int_t    sfDeS,
+			const Float_t  numdnsb,
+			const Float_t  telestheta,
+			const Float_t  telesphi,
+			const Float_t  shthetamax,
+			const Float_t  shthetamin,
+			const Float_t  shphimax,
+			const Float_t  shphimin,
+			const Float_t  impactmax,
+			const Float_t  cwavelower,
+			const Float_t  cwaveupper,
+			const Float_t  slopespec,
+			const UInt_t   numObslev,
+			const Float_t  heightlev[10],
+			const UInt_t   corsika,
+			const UInt_t   refl,
+			const UInt_t   cam,
+			const Byte_t   opticnoise)
+{
+    fMcRunNumber =runnumber;
+    fProductionSite = productionsite;
+    fDateRunMMCs = daterunMMCs;
+    fDateRunCamera = daterunCamera;
+    fNumTrigCond = numtrigcond;
+    fAllEvtsTriggered = allevts;
+    fMcEvt = mcevt;
+    fMcTrig = mctrig;
+    fMcFadc = mcfadc;
+    fRawEvt = rawevt;
+    fElecNoise = elecnoise;
+    fStarFieldRotate = starfieldrotate;
+    fNumAnalisedPixels = numanalpixels;
+    fNumSimulatedShowers = numsim;
+    fNumStoredShowers = numsto;
+    fNumEvents = numsto;
+
+    fStarFieldRaH = sfRaH;
+    fStarFieldRaM = sfRaM;
+    fStarFieldRaS = sfRaS;
+    fStarFieldDeD = sfDeD;
+    fStarFieldDeM = sfDeM;
+    fStarFieldDeS = sfDeS;
+
+    fNumPheFromDNSB = numdnsb;
+    fTelesTheta = telestheta;
+    fTelesPhi = telesphi;
+    fShowerThetaMax = shthetamax;
+    fShowerThetaMin = shthetamin;
+    fShowerPhiMax = shphimax;
+    fShowerPhiMin = shphimin;
+
+    fImpactMax=impactmax;
+
+    fCWaveLower = cwavelower;
+    fCWaveUpper = cwaveupper;
+
+    fNumObsLev = numObslev;
+    for (UInt_t i=0; i<numObslev; i++){
+      fHeightLev[i]=heightlev[i];
+    }
+    fSlopeSpec = slopespec;
+
+    fCorsikaVersion = corsika;
+    fReflVersion = refl;
+    fCamVersion = cam;
+    fOpticLinksNoise= opticnoise;
+}
+
+// -------------------------------------------------------------------------
+//
+// GetStarFieldRa. Get RA coordinates of the starfield
+//
+void MMcRunHeader::GetStarFieldRa(Int_t *hour, Int_t *minute, Int_t *second) const
+{
+    *hour   = fStarFieldRaH;
+    *minute = fStarFieldRaM;
+    *second = fStarFieldRaS;
+}
+// -------------------------------------------------------------------------
+//
+// GetStarFieldDec. Get DE coordinates of the starfield
+//
+void MMcRunHeader::GetStarFieldDec(Int_t *degree, Int_t *minute, Int_t *second) const
+{
+    *degree = fStarFieldDeD;
+    *minute = fStarFieldDeM;
+    *second = fStarFieldDeS;
+}
Index: /tags/Mars_V0-8-5/Mars/mmc/MMcRunHeader.hxx
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/MMcRunHeader.hxx	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/MMcRunHeader.hxx	(revision 9662)
@@ -0,0 +1,156 @@
+#ifndef MARS_MMcRunHeader
+#define MARS_MMcRunHeader
+///////////////////////////////////////////////////////////////////////
+//                                                                   //
+// MMcRunHeader                                                      //
+//                                                                   //
+// Version 5: removed members fSourceOffsetTheta, fSourceOffsetPhi   //
+//            (were no longer used)                                  //
+//                                                                   //
+///////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+
+class MMcRunHeader : public MParContainer
+{
+private:
+  UInt_t  fNumTrigCond;     // Number of trigger conditions in this file,
+  // zero means single condition mode
+  
+  //-- 0 means: MMcTrig
+  //-- 1 means: MMcTrig;1
+  //-- 2 means: MMcTrig;1 MMcTrig;2
+  
+  Byte_t  fAllEvtsTriggered;  // boolean that indicates is all images are 
+                              // saved or only the ones that trigger
+
+  Byte_t  fMcEvt;           // McEvt stored or not
+  Byte_t  fMcTrig;          // McTrig stored or not
+  Byte_t  fMcFadc;          // McFadc stored or not
+
+  Int_t   fNumAnalisedPixels;  // Number of analised pixels
+  
+  UInt_t  fNumSimulatedShowers; // Number of showers that were simualted
+  UInt_t  fNumStoredShowers;    // Number of store showers in this run
+  UInt_t  fNumEvents;           // Number of events in this root file
+  
+  //  Coordinates of the Starfield
+  
+  Int_t fStarFieldRaH;
+  Int_t fStarFieldRaM;
+  Int_t fStarFieldRaS;
+  Int_t fStarFieldDeD;
+  Int_t fStarFieldDeM;
+  Int_t fStarFieldDeS;
+
+  Float_t fNumPheFromDNSB;  // Number of phe/ns from diffuse NSB
+  
+  //  Telescope axis position (zenith and azimutal angle)
+  Float_t fTelesTheta;  // >180 (200) means that telescope is always pointing the shower. 
+                        // Otherwise it is Theta where Telescope is pointing.
+  Float_t fTelesPhi;    // See class description. > 360 (400) means that telescope is always pointing the shower.
+                        // Otherwise it is Phi where Telescope is pointing.
+  
+  //  Angular range used in the Corsika showers generation (degrees)
+  Float_t fShowerThetaMax; // [deg]
+  Float_t fShowerThetaMin; // [deg]
+  Float_t fShowerPhiMax; // [deg] See note in class description.
+  Float_t fShowerPhiMin; // [deg] See note in class description.
+
+  //  Maximum impact parameter in the input rfl file
+  Float_t fImpactMax; // [cm] 
+
+  UShort_t fCorsikaVersion;
+  UShort_t fReflVersion;
+  UShort_t fCamVersion;
+
+  /* ---- Run Header Informations ---- */
+  Float_t fMcRunNumber;     // Run Number
+  UInt_t  fProductionSite;  // code to know where the run was generated
+  Float_t fDateRunMMCs;     // Date of the MMCs production
+  Float_t fDateRunCamera;   // Date, when the Camera program is run.
+
+  Byte_t  fRawEvt;          // RawEvt[Data,Hedaer] stored or not
+
+  Byte_t  fElecNoise;       // Electronic Noise simulated or not
+  Byte_t  fStarFieldRotate; // Is the starfield rotation 
+                            // switched on (1) or off (0)
+
+  //  Wavelength limits for the Cerenkov photons
+  Float_t fCWaveLower;
+  Float_t fCWaveUpper;
+
+  //  Observation levels  
+  UInt_t    fNumObsLev;
+  Float_t   fHeightLev[10]; 
+
+  //  Spectral index
+  Float_t   fSlopeSpec;
+
+  // Noise from Optic Links
+  Byte_t  fOpticLinksNoise;  // Noise from Optic Links simualted or not.
+
+public:
+  MMcRunHeader(const char *name=NULL, const char *title=NULL);
+  ~MMcRunHeader();
+
+  void Fill(const Float_t  runnumber,
+	    const UInt_t   productionsite,
+	    const Float_t  daterunMMCs,
+	    const Float_t   daterunCamera,
+	    const UInt_t   numtrigcond,
+	    const Byte_t   allevts,
+	    const Byte_t   mcevt,
+	    const Byte_t   mctrig,
+	    const Byte_t   mcfadc,
+	    const Byte_t   rawevt,
+	    const Byte_t   elecnoise, 
+	    const Int_t    numanalpixels,
+	    const UInt_t   numsim,
+	    const UInt_t   numsto,
+	    const Byte_t   starfieldrotate,
+	    const Int_t    sfRaH,
+	    const Int_t    sfRaM,
+	    const Int_t    sfRaS,
+	    const Int_t    sfDeD,
+	    const Int_t    sfDeM,
+	    const Int_t    sfDeS,
+	    const Float_t  numdnsb,
+	    const Float_t  telestheta,
+	    const Float_t  telesphi,
+	    const Float_t  shthetamax,
+	    const Float_t  shthetamin,
+	    const Float_t  shphimax,
+	    const Float_t  shphimin,
+	    const Float_t  impactmax,
+	    const Float_t  cwavelower,
+	    const Float_t  cwaveupper,
+	    const Float_t  slopespec,
+	    const UInt_t   num0bslev,
+	    const Float_t  heightlev[10],
+	    const UInt_t   corsika,
+	    const UInt_t   refl,
+	    const UInt_t   cam,
+	    const Byte_t   opticnoise 
+	    );
+  
+  void     GetStarFieldRa(Int_t *hour, Int_t *minute, Int_t *second) const;
+  void     GetStarFieldDec(Int_t *degree, Int_t *minute, Int_t *second) const;
+
+  Float_t  GetNumPheFromDNSB() const      { return fNumPheFromDNSB; }
+  Float_t  GetTelesTheta() const          { return fTelesTheta; }
+  UShort_t GetCamVersion() const          { return fCamVersion; }
+  UShort_t GetReflVersion() const         { return fReflVersion; }
+  UInt_t   GetNumSimulatedShowers() const { return fNumSimulatedShowers; }
+  UInt_t   GetCorsikaVersion() const      { return fCorsikaVersion; }
+  Bool_t   GetAllEvtsTriggered() const    { return fAllEvtsTriggered ? kTRUE : kFALSE; }
+  Float_t GetImpactMax() const            {return fImpactMax;}
+
+  ClassDef(MMcRunHeader, 5)	// storage container for general run info
+};
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mmc/MMcTrig.cxx
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/MMcTrig.cxx	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/MMcTrig.cxx	(revision 9662)
@@ -0,0 +1,140 @@
+#include "MMcTrig.hxx"
+
+#include <iostream>
+
+
+//==========
+// MMcTrig
+//    
+// This class handles and contains the MonteCarlo information
+// with which the events have been generated
+// This information exists for each event.
+//
+// This the second version of this output class. Old root files, which have
+// a previous version of this class, are still compatibles and can be used.
+// But of course, you can no try to get infromatino in these old files about
+// the new data members.
+//
+// The fPixelsFirst array has been increased from 273 (which was the trigger 
+// zone) to 577 (which is the full Camera)
+//
+////////////////////////////////////////////////////////////// 
+
+
+ClassImp(MMcTrig);
+
+using namespace std;
+
+
+MMcTrig::MMcTrig(const char *name, const char *title) {
+  //
+  //  default constructor
+  //  set all values to zero
+
+  
+  fName  = name  ? name  : "MMcTrig";
+  fTitle = title ? title : "Trigger info from Monte Carlo";
+
+    
+  Int_t i,j;
+
+  fNumFirstLevel  = 0 ;
+
+  for(i=0;i<TOTAL_TRIGGER_TIME/LEVEL1_DEAD_TIME+1;i++){
+    fTimeFirst[i]    = -99.9;
+    for(j=0;j<CAMERA_PIXELS/8+1;j++){
+      fPixelsFirst[j][i]   = 0;
+    }
+  }
+
+  fNumSecondLevel = 0 ; 
+  for(i=0;i<TOTAL_TRIGGER_TIME/LEVEL2_DEAD_TIME+1;i++){
+    fFirstToSecond[i]=0;
+  }
+}
+
+MMcTrig::~MMcTrig() {
+  //
+  //  default destructor
+  //
+}
+
+void MMcTrig::SetTime(Float_t t, Int_t i)
+{
+    if (i>TOTAL_TRIGGER_TIME/LEVEL1_DEAD_TIME+1  || i<1)
+    {
+        cout << "fNumFirstLevel out of range. Time will be -99" << endl;
+        return;
+    }
+
+    fTimeFirst[i-1]=t;
+}
+
+void MMcTrig::Clear(Option_t *opt) {
+  //
+  //  
+  //  reset all values to zero
+  Int_t i,j;
+
+  fNumFirstLevel  = 0 ;
+  for(i=0;i<TOTAL_TRIGGER_TIME/LEVEL1_DEAD_TIME+1;i++){
+    fTimeFirst[i]    = -99.9;
+    for(j=0;j<CAMERA_PIXELS/8+1;j++){
+      fPixelsFirst[j][i]   = 0;
+    }
+  }
+
+  fNumSecondLevel = 0 ; 
+  for(i=0;i<TOTAL_TRIGGER_TIME/LEVEL2_DEAD_TIME+1;i++){
+    fFirstToSecond[i]=0;
+  }
+
+  //  cout << "MMcTrig::Clear() " << endl ; 
+}
+
+void MMcTrig::Print(Option_t *Option) const {
+  //
+  //  print out the data member on screen
+  //
+  Int_t i,j;
+
+  cout <<endl << "Monte Carlo Trigger output:" <<endl;
+  cout << " First  Level Trigger in this Event: "<<fNumFirstLevel<<endl; 
+  cout << " Times of first  Level Trigger in this Event: ";
+  for (i=0;i<fNumFirstLevel;i++){
+    cout<< fTimeFirst[i]<<"-";
+  }
+  cout<<endl;
+  cout << " Pixels of first  Level Trigger in this Event : ";
+  for (i=0;i<fNumFirstLevel;i++){
+    for(j=0;j<CAMERA_PIXELS/8+1;j++){
+      cout<<fPixelsFirst[j][i]<<"-";
+    }
+  }
+  cout<<endl;
+  cout << " Second Level Trigger in this Event: " << fNumSecondLevel << endl; 
+  cout << endl ; 
+}
+
+Byte_t MMcTrig::IsPixelFired(Int_t npix, Int_t nfirstlevel){
+  //======================================================================
+  //
+  //  It returns >1 if the pixel npix was fired when the nfirstlevel
+  //  first level trigger happened, 0 if not.
+  //
+  
+  const Int_t  body=npix/8;
+  const Byte_t reminder= 1<<(npix%8);
+
+  return reminder&fPixelsFirst[body][nfirstlevel];
+  /*
+  Byte_t ret=0;
+  Byte_t reminder;
+  Int_t body;
+
+  body=npix/8;
+  reminder=(Byte_t)(pow(2,npix%8));
+  ret=reminder&fPixelsFirst[body][nfirstlevel];
+  return(ret);
+  */
+}
Index: /tags/Mars_V0-8-5/Mars/mmc/MMcTrig.hxx
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/MMcTrig.hxx	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/MMcTrig.hxx	(revision 9662)
@@ -0,0 +1,63 @@
+#ifndef __MMcTrig__
+#define __MMcTrig__
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#include "MTriggerDefine.h"
+#include "Mdefine.h"
+
+class MMcTrig : public MParContainer {
+ private:
+
+  Short_t fNumFirstLevel  ;    // Number of First Level Trigger in this Event
+  Short_t fNumSecondLevel ;    // Number of Second Level Trigger in this Event
+
+  Float_t fTimeFirst[((Int_t)(TOTAL_TRIGGER_TIME/LEVEL1_DEAD_TIME))+1];
+                            // Time when it triggers
+  Byte_t fPixelsFirst[((Int_t)(CAMERA_PIXELS/8))+1][((Int_t)(TOTAL_TRIGGER_TIME/LEVEL1_DEAD_TIME))+1];
+                            // Pixel which are above threshold when trigger happens
+  Short_t fFirstToSecond[((Int_t)(TOTAL_TRIGGER_TIME/LEVEL2_DEAD_TIME))+1];
+
+ public:
+  MMcTrig(const char *name=NULL, const char *title=NULL);
+
+  ~MMcTrig(); 
+
+  void Clear(Option_t *opt=NULL);
+  
+  void Print(Option_t *opt=NULL) const;
+
+  void SetFirstLevel  ( Short_t nTr ) {
+    fNumFirstLevel = nTr ; 
+  } 
+  void SetSecondLevel ( Short_t nTr ) {
+    fNumSecondLevel = nTr ; 
+  } 
+
+  void SetTime( Float_t t, Int_t i);
+
+  void SetMapPixels(Byte_t *map,Int_t nfirst){
+    //  
+    //  It sets the map of pixel that are above the trheshold
+    //
+
+    int i;
+
+    for(i=0;i<((Int_t)(CAMERA_PIXELS/8))+1;i++){
+      fPixelsFirst[i][nfirst]=map[i];
+    }
+  }
+
+  Int_t GetFirstLevel() const {
+    return ( fNumFirstLevel );  
+  }
+
+  Byte_t IsPixelFired(Int_t npix, Int_t nfirstlevel);
+
+  ClassDef(MMcTrig, 3)  //Stores Montecarlo Information (number of 1st, 2nd level triggers)
+
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mmc/MMcTrigHeader.cxx
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/MMcTrigHeader.cxx	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/MMcTrigHeader.cxx	(revision 9662)
@@ -0,0 +1,74 @@
+#include "MMcTrigHeader.hxx"
+
+#include <iostream>
+
+
+//==========
+// MMcTrigHeader
+//    
+// This class contains the MonteCarlo information
+// of the trigger simulation for the current run.
+// The information is saved only once, whatever the
+// number of events is
+//
+// This is the second version of this output class. Old root files, which have
+// a previous version of this class, are still compatibles and can be used.
+// But of course, you can no try to get infromatino in these old files about
+// the new data members.
+//
+// The following data member have been introduced in this second version 
+// and they do not exist in the previous one:
+//
+//   Float_t  fElecNoiseTrig;  The width of the gaussian noise is that times
+//                             the amplitude of the single phe response 
+//                             for the trigger 
+//
+/////////////////////////
+
+ClassImp(MMcTrigHeader);
+
+using namespace std;
+
+
+MMcTrigHeader::MMcTrigHeader() {
+  //
+  //  default constructor
+  //  set all values to zero
+
+  Int_t i;
+
+  fTopology     = -1 ;
+  fMultiplicity = -1 ;
+  for(i=0;i<CAMERA_PIXELS;i++){
+    fThreshold[i] = -1.0;
+  }
+  
+  fTrigPattern[0]=0;
+  fTrigPattern[1]=0;
+
+  fTrigShape=0.0; 
+  fAmplTrig=RESPONSE_AMPLITUDE;
+  fFwhmTrig=RESPONSE_FWHM;
+  fOverlapingTime=TRIGGER_OVERLAPING;
+  fGateLeng=TRIGGER_GATE ;
+}
+
+MMcTrigHeader::~MMcTrigHeader() {
+  //
+  //  default destructor
+  //
+}
+
+
+void MMcTrigHeader::Print(Option_t *opt) const {
+  //
+  //  print out the data member on screen
+  //
+  cout << endl;
+  cout << "Monte Carlo Trigger output:" << endl;
+  cout << " XSTopology Trigger in this run: "   << fTopology << endl;
+  cout << " Multiplicity Trigger in this run: " << fMultiplicity << endl;
+  cout << " Trigger Pattern in this run: ";
+  cout << fTrigPattern[0] << ", " << fTrigPattern[1] << endl;
+  cout << endl; 
+}
Index: /tags/Mars_V0-8-5/Mars/mmc/MMcTrigHeader.hxx
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/MMcTrigHeader.hxx	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/MMcTrigHeader.hxx	(revision 9662)
@@ -0,0 +1,118 @@
+#ifndef __MMcTrigHeader__
+#define __MMcTrigHeader__
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#include "MTriggerDefine.h"
+#include "Mdefine.h"
+
+class MMcTrigHeader : public MParContainer{
+ private:
+
+  Short_t fTopology     ;      // Topology of the trigger
+                                   // 0 = N-1 neighbours of one pixel
+                                   // 1 = N neighbours
+                                   // 2 = N closed pack
+  Short_t fMultiplicity ;      // Pixel multiplicity of trigger configuration
+  Float_t fThreshold[CAMERA_PIXELS] ; // Threshold for trigger
+  UInt_t fTrigPattern[2];     // Used to inddentify with 
+                              // RawEvt::Trigger Pattern identification  
+  Float_t  fTrigShape   ;   // a number that indicate the shape type of 
+                            // the signal   
+                            // = 0 --> a gaussian  
+  Float_t  fAmplTrig    ;   // the amplitude of the trigger in mV
+  Float_t  fFwhmTrig    ;   // the width of the signal in nsec
+  Float_t  fOverlapingTime;// Minimum coincidence time
+  Float_t  fGateLeng;       // the length of the digital signal if analog 
+                            // signal is above threshold
+  Float_t  fElecNoiseTrig;  // The width of the gaussian noise is that times
+                            // the amplitude of the single phe response 
+                            // for the trigger
+
+ public:
+  MMcTrigHeader() ;
+
+  ~MMcTrigHeader(); 
+
+  void Print(Option_t *opt=NULL) const;
+  
+  void SetTopology(Short_t nTop) {
+    fTopology=nTop;
+  }
+
+  void SetMultiplicity(Short_t nMul) {
+    fMultiplicity=nMul;
+  }
+
+  void SetThreshold(Float_t fthr[]){
+    int i;
+    for(i=0;i<CAMERA_PIXELS;i++){
+      fThreshold[i]=fthr[i];
+    }
+  }
+
+  void SetTrigPattern (UInt_t upi, UInt_t loi){
+
+    if (upi==loi==0) {
+      fTrigPattern[0]= (UInt_t) fThreshold[0];
+      fTrigPattern[1]= (UInt_t) (100*fMultiplicity+fTopology);
+    }
+    else {
+      fTrigPattern[0]=upi;
+      fTrigPattern[1]=loi;
+    }
+  }
+
+  void SetShape(Float_t shape){
+    fTrigShape=shape;
+  }
+
+  void SetAmplitud(Float_t amp){
+    fAmplTrig=amp;
+ }
+
+  void SetFwhm(Float_t fwhm){
+    fFwhmTrig=fwhm;
+  }
+
+  void SetOverlap(Float_t overlap){
+    fOverlapingTime=overlap;
+  }
+
+  void SetGate(Float_t gate){
+    fGateLeng=gate;
+  }
+
+  void SetElecNoise( Float_t elecnoise){
+    fElecNoiseTrig = elecnoise;
+  }
+
+
+
+  Short_t GetMultiplicity() { return fMultiplicity; }
+
+  Float_t GetMeanThreshold()
+  {
+    int i;
+    Float_t sum = 0., trigpix = 0.;
+    for(i=0;i<CAMERA_PIXELS;i++)
+    {
+      if (fThreshold[i] < 1.e6 && fThreshold[i] > 0.)
+      {
+        sum += fThreshold[i];
+        trigpix += 1.;
+      }
+    }
+
+    return (sum / trigpix);
+  }
+
+
+  ClassDef(MMcTrigHeader, 3)  //Stores Montecarlo Information which describes the used trigger
+
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mmc/MTriggerDefine.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/MTriggerDefine.h	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/MTriggerDefine.h	(revision 9662)
@@ -0,0 +1,105 @@
+//
+//
+//      In this file are the fundamental definitions for the class MCTrigger
+//
+//
+#define TRIGGER_PIXELS_1      397
+#define TRIGGER_PIXELS_2      397
+#define TRIGGER_PIXELS_3      1657
+#define TRIGGER_PIXELS_5      397
+#define TRIGGER_PIXELS_6      1657
+#define TRIGGER_PIXELS_8      126
+#define TRIGGER_PIXELS_9      126
+//
+//      This is the number of Pixels contributing to the TRIGGER logic
+//      for each of the already implemented geometries.
+//      All Pixels-Id above that value don't do an trigger stuff. 
+//      Actually, not all of them are involved in TRIGGER logic, only the
+//      ones of them that are also in some TRIGGER_CELL 
+//   (MagicSoft/Simulation/Detector/include-MTrigger/TABLE_PIXELS_IN_CELLS)
+//
+#define TOTAL_TRIGGER_TIME    160 
+//
+//      This values defines the total range in that we try to find
+//      a trigger. 
+//
+#define LEVEL1_DEAD_TIME    50
+//
+//      Dead time of the detector after one first level trigger happens.
+//
+#define LEVEL2_DEAD_TIME    300
+//
+//      Dead time of the detector after second level trigger fires
+//
+#define SLICES_PER_NSEC         4
+//      
+//      Each nano second is divided into the number of this values slices. 
+//      So you can get the total number of timeslices for one Pixel by 
+//      ( TOTAL_TRIGGER_TIME * SLICES_PER_NSEC ). 
+//      In the current settings this are 1000 slices
+//
+#define TRIGGER_TIME_SLICES     (TOTAL_TRIGGER_TIME*SLICES_PER_NSEC) 
+//
+//
+//
+//
+//       ------>>>   SETTINGS for the RESPONSE FUNCTION
+// 
+#define RESPONSE_SLICES        40
+//
+//       This is for the standard response Signal to 1 Photoelectron
+//       that leaves the Photocathode
+//       The whole Timescale for the signal is 10 nsec
+//
+//       The Response function
+//
+//       These values are discussed with Eckart. We start from this point. 
+//
+#define RESPONSE_FWHM          2. 
+
+#define RESPONSE_AMPLITUDE     1. 
+//
+//       This are the Standard values of the response function for
+//       1 photo electron. ( 1 means 1 mV per phote electron ) 
+//
+//
+//       -------->>> SETTINGS for the DISKRIMINATORS
+//
+//
+#define CHANNEL_THRESHOLD      2.5 
+//
+//       This is the diskriminator threshold for each individual channel
+//       First we set the value to 2 unit of the RESPONSE_AMPLITUDE 
+//
+#define TRIGGER_GATE           3. 
+// 
+//       Here we set the width of the digital signal we get if the signal
+//       passes the diskriminator
+//
+//
+#define TRIGGER_OVERLAPING           0.25 
+// 
+//       Here we set the required overlaping time among pixels
+//       to be in coincidence.
+//
+//
+//      --------->>>> SETTINGS for the TRIGGER logic
+//
+//
+#define TRIGGER_CELLS          19  
+//
+//       Number of trigger cells that cover the trigger zone
+//
+#define TRIGGER_MULTI          4.  
+//
+//       We get a Level Zero Trigger, if we have a least TRIGGER_MULTI
+//       channels with a diskrimiator signal at the same time 
+//
+#define TRIGGER_GEOM           0
+//
+//      This defines the geometry required for a trigger. There exists 
+//      different meaning for this behaviour: 
+//         0 means a pixel with trigger_multi-1 neighbours
+//         1 means trigger_multi neighbours
+//         2 means trigger_multi closed neighbours
+//
Index: /tags/Mars_V0-8-5/Mars/mmc/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/Makefile	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/Makefile	(revision 9662)
@@ -0,0 +1,31 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+INCLUDES = -I.  -I../mbase -I../MBase -I../mgeom
+
+CINT     = Mc
+
+SRCFILES = MMcTrigHeader.cxx \
+	   MMcFadcHeader.cxx \
+	   MMcRunHeader.cxx \
+	   MMcEvt.cxx \
+           MMcTrig.cxx \
+	   MMcConfigRunHeader.cc \
+	   MMcCorsikaRunHeader.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules 
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mmc/McIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/McIncl.h	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/McIncl.h	(revision 9662)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mmc/McLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/McLinkDef.h	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/McLinkDef.h	(revision 9662)
@@ -0,0 +1,15 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+ 
+#pragma link C++ class MMcEvt+;
+#pragma link C++ class MMcTrig+;
+#pragma link C++ class MMcRunHeader+;
+#pragma link C++ class MMcTrigHeader+;
+#pragma link C++ class MMcFadcHeader+;
+#pragma link C++ class MMcConfigRunHeader+;
+#pragma link C++ class MMcCorsikaRunHeader+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mmc/Mdefine.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/Mdefine.h	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/Mdefine.h	(revision 9662)
@@ -0,0 +1,42 @@
+//
+//     Mdefine.h
+//
+//     defines some Values for the MAGIC telecope
+//
+
+//     Number of the Pixels in the Camera
+
+#define     CAMERA_PIXELS         3500
+
+//     Number of the Slices of one Fadc. Be carefull this is the number of 
+//     slices for one gain branch. We sample two times this number. 
+
+#define     FADC_SLICES            15
+
+//     ParticleId for Monte Carlo simulation
+
+#define  GAMMA 0
+#define  PROTON 14
+#define  HELIUM 402
+#define  OXIGEN 1608
+#define  IRON 5626
+
+
+//---------------------------------------------------------
+// definition of constants
+
+#define TRUE 1
+#define FALSE 0
+
+#define MAX_ADC 30  // nummber of ADC conversions per pixel
+
+//camera dimensions and definitions
+#define PIXEL_SIZE  0.00175  // radians
+#define PIXEL_DIST  10.0  //cm
+#define CAMERA_COLOR 13   //Background light grey
+#define DEFAULT_COLOR 1 //black
+//#define TRACK_WALL_COLOR 7   //light blue
+#define PIXEL_LINE_COLOR 15 //dark grey
+#define COLORTABLE_START 18 //Begin of colortable
+#define MAX_PH_EL 500 //upper limit for colortable
+
Index: /tags/Mars_V0-8-5/Mars/mmc/readme.txt
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmc/readme.txt	(revision 9662)
+++ /tags/Mars_V0-8-5/Mars/mmc/readme.txt	(revision 9662)
@@ -0,0 +1,6 @@
+
+ Please be aware of that this subdirectory is used in two CVS modules.
+ 
+ If you change something it can affect the Mars and/or Monte Carlo
+ code!
+ 
