Index: trunk/MagicSoft/Simulation/Detector/include-MC/MCCphoton.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/include-MC/MCCphoton.cxx	(revision 295)
+++ trunk/MagicSoft/Simulation/Detector/include-MC/MCCphoton.cxx	(revision 295)
@@ -0,0 +1,23 @@
+/////////////////////////////////////////////////////////////////
+//
+// MCCphoton
+//
+//  Created: Tue Apr 28 16:43:30 1998
+//  Author:  Jose Carlos Gonzales
+//  Purpose: Base class for Particles/Cherenkov photons
+//  Notes:   
+//
+/////////////////////////////////////////////////////////////////
+
+// @T \newpage
+
+// @section Source code of {\tt MCCphoton.cxx}
+
+// @subsection Class {\em MCCphoton}: Implementation
+
+// @code
+
+#include "MCCphoton.hxx"
+
+// @endcode
+
Index: trunk/MagicSoft/Simulation/Detector/include-MC/MCCphoton.hxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/include-MC/MCCphoton.hxx	(revision 295)
+++ trunk/MagicSoft/Simulation/Detector/include-MC/MCCphoton.hxx	(revision 295)
@@ -0,0 +1,135 @@
+/////////////////////////////////////////////////////////////////
+//
+// MCCphoton
+//
+//  Created: Tue Apr 28 16:43:30 1998
+//  Author:  Jose Carlos Gonzales
+//  Purpose: Base class for Particles/Cherenkov photons
+//  Notes:   
+//
+/////////////////////////////////////////////////////////////////
+
+// @T \newpage
+
+// @section Source code of {\tt MCCphoton.hxx}
+
+/* @text
+This section shows the include file {\tt MCCphoton.hxx}
+@endtext */
+
+#ifndef MCCphoton_Class
+#define MCCphoton_Class
+
+// @subsection Include files
+
+// @code
+#ifdef __ROOT__
+#include "TROOT.h"
+#include "TObject.h"
+#else // not __ROOT__
+#include "Rtypes.h"
+#endif
+
+#include <iostream.h>
+#include <iomanip.h>
+#include <fstream.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include "jcmacros.h"
+
+// const char variables to use in MCCphoton::isA() function
+
+const char FLAG_START_OF_RUN[]   = "START-RUN-START-RUN-START-RUN-START-RUN-";
+const char FLAG_START_OF_EVENT[] = "START-EVENT-START-EVENT-START-EVENT-STAR";
+const char FLAG_END_OF_EVENT[] =   "END-EVENT-END-EVENT-END-EVENT-END-EVENT-";
+const char FLAG_END_OF_RUN[] =     "END-RUN-END-RUN-END-RUN-END-RUN-END-RUN-";
+const char FLAG_END_OF_FILE[] =    "END-FILE-END-FILE-END-FILE-END-FILE-END-";
+const char FLAG_END_OF_STDIN[] =   "END-STDIN-END-STDIN-END-STDIN-END-STDIN-";
+
+#define SIZE_OF_FLAGS  40
+
+// @endcode
+
+// @subsection Class {\em MCCphoton}: Definition
+
+// @code
+
+class MCCphoton {
+
+public:
+  Float_t     w;                // wavelength [nm/-] +
+                                //   1000*(id_generator)
+  Float_t     x, y;             // position in the camera [cm]
+  Float_t     u, v;             // director cosines 
+  Float_t     t;                // time since first interaction [ns]
+                                // till the camera
+  Float_t     h;                // height [cm]
+  Float_t     phi;              // incident angle in the camera [rad]
+
+public:
+  MCCphoton() {} // default constructor
+
+  // overloaded constructor
+  MCCphoton( ifstream &is ) { MCCphoton::read( is ); }
+
+  virtual ~MCCphoton() {} // default destructor
+
+  // reads photon from binary input stream
+  Int_t read ( ifstream &is ) {
+    int n;
+    is.read (  (char *)this, mysize() );
+    return is.gcount();
+  }
+
+  // writes photon to binary output stream
+  Int_t write ( ofstream &os ) {
+    os.write ( (char *)this, mysize() );
+    return 0;
+  }
+
+  // get information about the photon
+  inline Float_t get_wl( void ) { return ( w - 1000.*((int)floor(w/1000.))); }
+  inline Int_t get_particle( void ) { 
+    return ( (int)floor(w/1000.) );
+  }
+
+  inline Float_t get_x( void ) { return ( x ); }
+  inline Float_t get_y( void ) { return ( y ); }
+  inline Float_t get_u( void ) { return ( u ); }
+  inline Float_t get_v( void ) { return ( v ); }
+  inline Float_t get_h( void ) { return ( h ); }
+  inline Float_t get_t( void ) { return ( t ); }
+  inline Float_t get_phi( void ) { return ( phi ); }
+                  
+  inline Float_t get_r( void ) { return ( sqrt( x*x + y*y ) ); }
+  inline Float_t get_w( void ) { return ( sqrt( 1.0 - u*u - v*v ) ); }
+
+  inline void fill(Float_t thew, 
+                   Float_t thex, Float_t they,
+                   Float_t theu, Float_t thev, 
+                   Float_t theh, Float_t thet,
+                   Float_t thephi) {
+    w = thew;
+    x = thex;
+    y = they;
+    u = theu;
+    v = thev;
+    h = theh;
+    t = thet;
+    phi = thephi;
+  }
+
+  int isA( const char * flag ) {
+    return ( (strncmp((char *)this, flag, 8)==0) ? TRUE : FALSE );
+  }
+
+  inline int mysize(void) { return ( sizeof(*this) ); }
+
+};
+
+// @endcode
+
+#endif  // not defined MCCphoton_Class
+
Index: trunk/MagicSoft/Simulation/Detector/include-MC/MCEventHeader.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/include-MC/MCEventHeader.cxx	(revision 295)
+++ trunk/MagicSoft/Simulation/Detector/include-MC/MCEventHeader.cxx	(revision 295)
@@ -0,0 +1,53 @@
+/////////////////////////////////////////////////////////////////
+//
+// MCEventHeader
+//
+//  Created: Tue Apr 28 16:27:14 1998
+//  Author:  Jose Carlos Gonzales
+//  Purpose: Base class for EventHeader-classes
+//  Notes:   
+//
+/////////////////////////////////////////////////////////////////
+
+// @T \newpage
+
+// @section Source code of {\tt MCEventHeader.cxx}
+
+// @subsection Class {\em MCEventHeader}: Implementation
+
+// @code
+
+#include "MCEventHeader.hxx"
+
+void MCEventHeader::transport( COREventHeader *e )
+{
+  EvtNumber      = e->EvtNumber;
+  PrimaryID      = e->PrimaryID;
+  Etotal         = e->Etotal;
+  Thick0         = e->Thick0;
+  FirstTarget    = e->FirstTarget;
+  zFirstInt      = e->zFirstInt;
+  Theta          = e->Theta;
+  Phi            = e->Phi;
+  NumRndSeq      = e->NumRndSeq;
+  RunNumber      = e->RunNumber;
+  DateRun        = e->DateRun;
+  VersionPGM     = e->VersionPGM;
+  NumObsLev      = e->NumObsLev;
+  SlopeSpec      = e->SlopeSpec;
+  ELowLim        = e->ELowLim;
+  EUppLim        = e->EUppLim;
+  ThetaMin       = e->ThetaMin;
+  ThetaMax       = e->ThetaMax;
+  PhiMin         = e->PhiMin;
+  PhiMax         = e->PhiMax;
+  CWaveLower     = e->CWaveLower;
+  CWaveUpper     = e->CWaveUpper;
+
+  memcpy( p, e->p, 3*sizeof(Float_t) );
+  memcpy( RndData, e->RndData, 30*sizeof(Float_t) );
+  memcpy( HeightLev, e->HeightLev, 10*sizeof(Float_t) );
+  memcpy( CorePos, e->CorePos, 40*sizeof(Float_t) );
+}
+
+// @endcode
Index: trunk/MagicSoft/Simulation/Detector/include-MC/MCEventHeader.hxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/include-MC/MCEventHeader.hxx	(revision 295)
+++ trunk/MagicSoft/Simulation/Detector/include-MC/MCEventHeader.hxx	(revision 295)
@@ -0,0 +1,200 @@
+/////////////////////////////////////////////////////////////////
+//
+// MCEventHeader
+//
+//  Created: Tue Apr 28 16:27:14 1998
+//  Author:  Jose Carlos Gonzales
+//  Purpose: Base class for EventHeader-classes
+//  Notes:   
+//
+/////////////////////////////////////////////////////////////////
+
+// @T \newpage
+
+// @section Source code of {\tt MCEventHeader.hxx}
+
+/* @text
+This section shows the include file {\tt MCEventHeader.hxx}
+@endtext */
+
+#ifndef MCEventHeader_Class
+#define MCEventHeader_Class
+
+// @subsection Include files
+
+// @code
+#ifdef __ROOT__
+#include "TROOT.h"
+#include "TObject.h"
+#else // not __ROOT__
+#include "Rtypes.h"
+#endif
+
+#include <iostream.h>
+#include <iomanip.h>
+#include <fstream.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include "COREventHeader.hxx"
+
+#define SIZE_OF_MCEVENTHEADER    110   /* floats */
+
+// @endcode
+
+// @subsection Class {\em MCEventHeader}: Definition
+
+// @code
+class MCEventHeader {
+
+protected:
+  Float_t      EvtNumber;
+  Float_t      PrimaryID;
+  Float_t      Etotal;   
+  Float_t      Thick0;   
+  Float_t      FirstTarget;
+  Float_t      zFirstInt;
+  Float_t      p[3];     
+  Float_t      Theta; 
+  Float_t      Phi; 
+
+  Float_t      NumRndSeq;
+  Float_t      RndData[10][3];
+  
+  Float_t      RunNumber;
+  Float_t      DateRun;
+  Float_t      VersionPGM;
+
+  Float_t      NumObsLev;
+  Float_t      HeightLev[10]; 
+
+  Float_t      SlopeSpec;
+  Float_t      ELowLim;   
+  Float_t      EUppLim;   
+
+  Float_t      ThetaMin;
+  Float_t      ThetaMax;
+  Float_t      PhiMin;
+  Float_t      PhiMax;
+
+  Float_t      CWaveLower;       
+  Float_t      CWaveUpper;       
+  Float_t      CorePos[2][20];   
+  Float_t      TimeFirst;
+  Float_t      TimeLast;
+
+  Float_t      deviationPhi;
+  Float_t      deviationTheta;
+  
+  Float_t      Trigger;      // 110 floats
+
+public:
+  MCEventHeader(void) {}  // default constructor
+
+  virtual ~MCEventHeader(void) {}  // default destructor
+  
+  // reads EventHeader from binary input stream
+  Int_t read ( ifstream &is ) {
+    is.read ( (char *)this, mysize() ); 
+    return is.gcount();
+  }
+
+  // writes EventHeader to binary output stream
+  Int_t write ( ofstream &os ) {
+    os.write ( (char *)this, mysize() ); 
+    return 0;
+  }
+  
+  // get information about the EventHeader
+
+  // get the primary type (GEANT code)
+  inline Float_t get_primary ( void ) { return ( PrimaryID ); }
+
+  // get the total primary energy
+  inline Float_t get_energy ( void ) { return ( Etotal ); }
+  
+  // get the initial zenith angle
+  inline Float_t get_theta ( void ) { return ( Theta ); }
+
+  // get the initial phi angle
+  inline Float_t get_phi ( void ) { return ( Phi ); }
+
+  // get the spectrum slope
+  inline Float_t get_slope ( void ) { return ( SlopeSpec ); }
+
+  // get height of first interaction (in cm)
+  inline Float_t get_height ( void ) { return ( zFirstInt ); }
+
+  // get the energy range of this run
+  inline void get_energy_range ( Float_t *elow, Float_t *eup ) { 
+    *elow = ELowLim;   
+    *eup = EUppLim;
+  }
+
+  // get the core position
+  inline Float_t get_core ( Float_t *x, Float_t *y, Int_t ncore = 0 ) {
+    *x = CorePos[0][ncore];
+    *y = CorePos[1][ncore];
+    return ( (Float_t) sqrt ( (*x)*(*x) + (*y)*(*y) ) );
+  }
+
+  // get the core position
+  inline Float_t get_core ( Int_t ncore = 0 ) {
+    return ( (Float_t) sqrt ( ((CorePos[0][ncore])*(CorePos[0][ncore]))+
+                              ((CorePos[1][ncore])*(CorePos[1][ncore])) ) );
+  }
+
+  // transport from COREventHeader to MCEventHeader
+  void transport ( COREventHeader *e );
+
+  // write extreme times
+  inline void put_times ( Float_t t1, Float_t t2 ) {
+    TimeFirst = t1;
+    TimeLast  = t2;
+  }
+
+  // get extreme times
+  inline Float_t get_times ( Float_t *t1, Float_t *t2 ) {
+    *t1 = TimeFirst;
+    *t2 = TimeLast;
+    return ( TimeLast - TimeFirst );
+  }
+
+  // get/set trigger
+  inline void set_trigger( Int_t flag ) { Trigger = (Float_t)flag; }
+  inline Int_t get_trigger( void ) { return( (Int_t)Trigger ); }
+
+  inline int mysize(void) 
+    { return ( sizeof( float ) * SIZE_OF_MCEVENTHEADER ); }
+
+  // put deviations of the CT from the original shower direction
+  inline void put_deviations ( Float_t t1, Float_t t2 ) {
+    deviationTheta = t1;
+    deviationPhi   = t2;
+    //cerr << '\n' << deviationTheta << ' ' << deviationPhi << '\n';
+  }
+
+  // get deviations of the CT from the original shower direction
+  inline Float_t get_deviations ( Float_t *t1, Float_t *t2 ) {
+
+    float r;
+
+    r = sqrt(deviationTheta*deviationTheta + deviationPhi*deviationPhi);
+    *t1 = deviationTheta;
+    *t2 = deviationPhi;
+
+    // cerr << '\n' << deviationTheta << ' ' << deviationPhi << '\n' << flush;
+
+    return ( r );
+  }
+
+  inline void print ( void ) {
+    float *ptr = (float *)this;
+    for(int i=0; i<SIZE_OF_MCEVENTHEADER; ++i,++ptr)
+      cerr << i << ':' << *ptr << '\n';
+  }
+
+};
+// @endcode
+
+#endif  // not defined MCEventHeader_Class
