Index: trunk/MagicSoft/include-Classes/MRawEvt.cxx
===================================================================
--- trunk/MagicSoft/include-Classes/MRawEvt.cxx	(revision 433)
+++ trunk/MagicSoft/include-Classes/MRawEvt.cxx	(revision 434)
@@ -6,4 +6,5 @@
 #include "MRawEvt.h"
 #include "MRawPixel.h"
+#include "MRawCrate.h"
 
 #include "Mdefine.h"
@@ -14,7 +15,8 @@
 // (Photomultipliers) from the Camera of MAGIC. So all data (FADC) of the 
 // interesting pixels are the modules of an event. To describe pixels the 
-// class MRawPixel is used.  To define a single events
-// some other data members are needed (Time of the events, kind of event..).
-//
+// class MRawPixel is used and the class MRawCrate to describe Crates.
+// To define a single events some other data members are needed 
+// (Time of the events, tirgger pattern of event..)
+// 
 // To describe one event on the level of FADC values the Class MRawEvt is
 // created. It has the following data members: 
@@ -22,5 +24,5 @@
 // ----------
 //
-// UInt_t    EvtNo    
+// UInt_t    DAQEvtNumber    
 //
 // This it the number of the Event in one 
@@ -37,5 +39,5 @@
 // ----------
 //
-// ULong_t   fTimeStamp
+// UInt_t   AbsTime[2]
 //   
 // Time of the event. 
@@ -43,5 +45,5 @@
 // the millenium. From that start point the time is
 // measured in 200ns-count. One day for example
-// contains 432.e9 counts. An unsigned Long is able to 
+// contains 432.e9 counts. An array of two unsigned Int is able to 
 // contain 1.8e19 200ns-counts. This corresponds to 41.e6
 // days. This should be more than the livetime of MAGIC.
@@ -49,13 +51,5 @@
 // ----------
 //
-// UChar_t   EvtStatus 
-//
-// Status of Event. 
-// This is a Byte (8 bit) to indicated the status of 
-// the event (Pedestal, Calibration, etc). 
-//
-// ----------
-//
-// UShort_t  Trig1st
+// UInt_t  FstLvlTrigNumber
 //
 // Number of first level trigger
@@ -70,24 +64,64 @@
 // ----------
 //
-// UShort_t  MultPixel
-//
-// Multiplicity of Pixels
-// Each event consists of a specific number of 
-// pixels. This is the number of pixels in one event. 
-// The array of ClonesPixels (taClonesArray) is of this
-// size. 
-//
-// ----------
-//
-// TClonesArray  *Pixels
-//
-// Array of Pixels 
+// UInt_t  SecLvlTrigNumber
+//
+// Number of second level trigger
+// This member counts the number of Second Level Trigger
+// between the last and this event. 
+//
+// ----------
+//
+// UInt_t  TriggerPattern[2]
+//
+// Trigger Pattern used for this event
+// Each event triggers for a particular configuration and each  
+// configuration shoul have an ID (which is not fixed yet).
+//
+// ----------
+//
+// Byte_t   TriggerType 
+//
+// Type of Trigger. 
+// This is a Byte (8 bit) to indicated the status of 
+// the event (Normal (0), Pedestal (1), Calibration (2), etc). 
+//
+// ----------
+//
+// Byte_t   AllLowGainOn
+//
+// Type of Trigger. 
+// This is a Byte (8 bit) to indicated if any of the pixels 
+// have a non-negligible low gain (1) or not (0) 
+//
+// ----------
+//
+// TClonesArray  *Crates
+//
+// Array of Crates
+// The Clones array is a list of the Crates used in one
+// event with the information about the Crate. 
+//
+// ----------
+//
+// TClonesArray  *PixelsHigh
+//
+// Array of Pixels for their high voltage channel
 // The Clones array is a list of the Pixels used in one
 // event with the information about the Pixels. 
 //
 //
-
-//
-void GetFadcNoise ( UChar_t asF[] ) 
+// ----------
+//
+// TClonesArray  *PixelsLow
+//
+// Array of Pixels for their low voltage channel
+// The Clones array is a list of the Pixels used in one
+// event that have a significant signal in the low gain channel
+// with the information about the Pixels. 
+//
+//
+
+//
+void GetFadcNoise ( Byte_t asF[] ) 
 {
   static TRandom Gen ; 
@@ -95,5 +129,5 @@
   for (Int_t i=0; i<FADC_SLICES; i++ ) {   
     Gen.Rannor(z1, z2) ;
-    asF[i] = 10 + (UChar_t)(z1*4) ;  
+    asF[i] = 10 + (Byte_t)(z1*4) ;  
     // if (asF[i] < 0 ) asF[i] = 0 ; 
   } 
@@ -108,9 +142,11 @@
   //   set all member to zero, init the pointer to ClonesArray, 
 
-  EvtNo      = 0 ; 
-  fTimeStamp  = 0 ; 
-  EvtStatus  = 0 ; 
-  Trig1st    = 0 ;
-  MultPixel  = 0 ; 
+  DAQEvtNumber      = 0 ; 
+  AbsTime[0] = AbsTime [1]  = 0 ; 
+  FstLvlTrigNumber = 0 ;
+  SecLvlTrigNumber = 0 ;
+  TriggerPattern[0] = TriggerPattern[1] = 0 ;
+  TriggerType = 0 ;
+  AllLowGainOn = 0 ;
 
   // 
@@ -120,5 +156,7 @@
   //   initialize the list to this global pointer
   
-  Pixels = new TClonesArray ("MRawPixel", 2*CAMERA_PIXELS ) ; 
+  PixelsHigh = new TClonesArray ("MRawPixel", 5*CAMERA_PIXELS ) ; 
+  PixelsLow = new TClonesArray ("MRawPixel", CAMERA_PIXELS ) ; 
+  Crates = new TClonesArray ("MRawCrate", 25 ) ; 
 
   cout << " default constructor " << endl ; 
@@ -130,5 +168,7 @@
   //   Implementation of the default destructor
   //
-  delete Pixels ; 
+  delete PixelsHigh ;
+  delete PixelsLow ;
+  delete Crates ;
   cout << " default destructor " << endl ; 
 }
@@ -140,11 +180,15 @@
   //   Resets all members to zero, clear the list of Pixels
   //
-  EvtNo      = 0 ; 
-  fTimeStamp  = 0 ; 
-  EvtStatus  = 0 ; 
-  Trig1st    = 0 ;
-  MultPixel  = 0 ; 
-
-  Pixels->Clear() ; 
+  DAQEvtNumber      = 0 ; 
+  AbsTime[0] = AbsTime [1]  = 0 ; 
+  FstLvlTrigNumber = 0 ;
+  SecLvlTrigNumber = 0 ;
+  TriggerPattern[0] = TriggerPattern[1] = 0 ;
+  TriggerType = 0 ;
+  AllLowGainOn = 0 ;
+
+  PixelsHigh->Clear() ; 
+  PixelsLow->Clear() ; 
+  Crates -> Clear() ;
 }
 
@@ -156,50 +200,53 @@
   //
 
+  Int_t i = 0;
+
   // Prints out the data of one Pixel
-  cout << endl << "EventNumber      " << EvtNo          ; 
-  cout << endl << "Event Time Stamp " << fTimeStamp      ;
-  cout << endl << "Event Status     " << (int) EvtStatus      ; 
-  cout << endl << "Trigger 1. Level " << Trig1st        ; 
-  cout << endl << "Number of Pixels " << MultPixel      ; 
-
-  for (Int_t i=0 ; i<MultPixel; i++ ) {
-    ((MRawPixel *)Pixels->At(i))->Print() ;    
+  cout << endl << "EventNumber      " << DAQEvtNumber          ; 
+  cout << endl << "Event Time Stamp " << (Float_t) AbsTime[0]*4294967296
+    +AbsTime[1]    ;
+  cout << endl << "Trigger 1. Level " << FstLvlTrigNumber        ; 
+  cout << endl << "Trigger 2. Level " << SecLvlTrigNumber        ; 
+  cout << endl << "Trigger Pattern " << (Float_t) TriggerPattern[0]*4294967296
+    +TriggerPattern[1]    ;
+  cout << endl << "Trigger Type ";
+  switch (TriggerType){
+  case 0:   
+    cout<<" Normal Trigger ";
+    break;
+  case 1:  
+    cout<<" Pedestal ";
+    break;
+  case 2:
+    cout<<" Calibration ";
+    break;
+  default:
+    cout<<TriggerType;
+    break;
   }
-}
-
-
-void MRawEvt::FillRandom ( UInt_t uiN, ULong_t ulT,  UShort_t usMuPi ) {
-  //
-  //  This is neccessary to fill the MRawEvt Class with randomized FADC
-  //  values. The EventNumber, EventTime and the Number of Pixels are given 
-  //  as parameters. 
-  // 
-
-  EvtNo      = uiN ; 
-  fTimeStamp  = ulT ; 
-
-  UChar_t   ucA[FADC_SLICES] ;
-
-  for (UShort_t i = 0 ; i< usMuPi; i++ ) {
-    GetFadcNoise ( ucA ) ;   
-  
-    TClonesArray &caP = *Pixels ;
-    new ( caP[MultPixel++] ) MRawPixel((MultPixel), 0, ucA) ; 
+
+  cout<<"High Voltage channel"<<endl;
+  while (PixelsHigh+i) {
+    ((MRawPixel *)PixelsHigh->At(i))->Print() ;
+    i++;    
   }
-}
-
-void MRawEvt::FillHeader ( UInt_t uiN, ULong_t ulT, UChar_t ucSta ) {
+  cout<<"Low Voltage channel"<<endl;
+  while (PixelsLow+i) {
+    ((MRawPixel *)PixelsLow->At(i))->Print() ;
+    i++;    
+  }
+}
+
+void MRawEvt::FillHeader ( UInt_t uiN, Float_t ulT, Float_t ulTP ) {
    
-  EvtNo      = uiN ; 
-  fTimeStamp  = ulT ; 
-  
-  EvtStatus  = ucSta ; 
-  Trig1st    = 0 ;
-  MultPixel  = 0   ; 
-
-  Pixels->Clear()  ; 
-}
-
-void MRawEvt::FillPixel ( UShort_t uiPix, Float_t *array ) {
+  DAQEvtNumber = uiN ; 
+  AbsTime[0]  = (UInt_t) (ulT/4294967296) ; 
+  AbsTime[1]  = (UInt_t) (ulT-AbsTime[0]*4294967296) ;
+  TriggerPattern[0]  = (UInt_t) (ulTP/4294967296) ;
+  TriggerPattern[1] = (UInt_t) (ulTP-TriggerPattern[0]*4294967296) ;
+
+}
+
+void MRawEvt::FillPixel ( Short_t siPix, UShort_t *MultPixel, Float_t *array ) {
   //
   //  This is to fill the data of one pixel to the MRawEvt Class. 
@@ -207,49 +254,41 @@
   // 
 
-  UChar_t   ucA[FADC_SLICES] ;
-
-  for (UShort_t i = 0 ; i< FADC_SLICES ; i++ ) {
-    ucA[i] = (UShort_t) array[i] ; 
+  Int_t i = 0;
+  Byte_t   ucA[FADC_SLICES] ;
+
+  for(i=0;i<FADC_SLICES;i++){
+    ucA[i] = (Byte_t) array[i] ; 
   } 
   
-  TClonesArray &caP = *Pixels ;
-  new ( caP[MultPixel++] ) MRawPixel((uiPix), 0, ucA) ; 
-}
-
-void MRawEvt::FillMontCarl ( UInt_t uiN, ULong_t ulT,  Float_t *array ) {
-  //
-  //  This is neccessary to fill the MRawEvt Class with randomized FADC
-  //  values. The EventNumber, EventTime and the Number of Pixels are given 
-  //  as parameters. 
+  TClonesArray &caP = *PixelsHigh ;
+  new ( caP[(*(MultPixel))++] ) MRawPixel((siPix), ucA) ; 
+}
+
+void MRawEvt::FillPixelLow ( Short_t siPix, UShort_t *MultPixel, Float_t *array ) {
+  //
+  //  This is to fill the data of one pixel to the MRawEvt Class. 
+  //  The parameters are the pixelnumber and the FADC_SLICES values of ADCs
   // 
 
-  EvtNo      = uiN ; 
-  fTimeStamp  = ulT ; 
-
-  MultPixel = 0 ; 
-
-  UChar_t   ucA[FADC_SLICES] ;
-
-  for (UShort_t i = 0 ; i< CAMERA_PIXELS; i++ ) {
-
-    if ( array[i] > 0. ) { 
-      for ( Int_t ii = 0 ; ii < FADC_SLICES ; ii++ ) { 
-	ucA[ii] = 0 ; 
-      }
-      ucA[5] = (UShort_t) (array[i]) ; 
-      
-      TClonesArray &caP = *Pixels ;
-      new ( caP[MultPixel++] ) MRawPixel(i, 0, ucA) ; 
-    }
-  }
-}
-
-UShort_t MRawEvt::GetMultPixel() {
-  //
-  //  returns the pixel multiplicity of the Event
-  //
-  return MultPixel;
-}
-
+  Int_t i = 0;
+  Byte_t   ucA[FADC_SLICES] ;
+
+  for(i=0;i<FADC_SLICES;i++){
+    ucA[i] = (Byte_t) array[i] ; 
+  } 
+  
+  TClonesArray &caP = *PixelsLow ;
+  new ( caP[(*(MultPixel))++] ) MRawPixel((siPix), ucA) ; 
+}
+
+UShort_t MRawEvt::GetMultPixel(){
+  //
+  // returns the number of pixells which are already in the list
+  //
+
+  UShort_t i =0;
+  while(PixelsHigh+i) i++;
+  return (i);
+}
 
 //  void MRawEvt::AddPixel ( UShort_t usP ) {
@@ -261,8 +300,5 @@
 //  }
 
-//  void MRawEvt::AddPixel ( UShort_t usP, UChar_t ucStat, UChar_t ausAR[] ) {
+//  void MRawEvt::AddPixel ( UShort_t usP, UChar_t ucStat, Byte_t ausAR[] ) {
 //    cout << " need implementation 2 " << endl ;  
 //  }
-
-
-
Index: trunk/MagicSoft/include-Classes/MRawEvt.h
===================================================================
--- trunk/MagicSoft/include-Classes/MRawEvt.h	(revision 433)
+++ trunk/MagicSoft/include-Classes/MRawEvt.h	(revision 434)
@@ -11,15 +11,26 @@
 
  private: 
-  UInt_t        EvtNo     ;  // Number of Event
+  UInt_t        DAQEvtNumber ;      // Number of Event
 
-  ULong_t       fTimeStamp ;  // Time of the Event
-  
-  UChar_t       EvtStatus ;  // Status of this event (DAQ, Pedestal, ..) 
+  UInt_t        AbsTime[2] ;        // Time of the Event
  
-  UShort_t      Trig1st   ;  // Number of 1st level tiggers between 2 events
+  UInt_t        FstLvlTrigNumber ;  // Number of 1st level tiggers between 2 events
 
-  UShort_t      MultPixel ;  // Multiplicity of the Pixels in this event   
+  UInt_t        SecLvlTrigNumber ;  // Number of 2nd level tiggers between 2 events
 
-  TClonesArray  *Pixels   ;  // list of the events
+  UInt_t        TriggerPattern[2] ; // Trigger configuration
+
+  Byte_t       TriggerType ;       // Normal trigger 0, pedestal 1, calibration 2
+
+  Byte_t       AllLowGainOn ;         // Flag indicating if any of the pixels have a 
+                                    // non-negligible low gain signal (1) or not (0)
+
+  TClonesArray  *Crates ;          // list of crates
+
+  TClonesArray  *PixelsHigh   ;         // list of the events for the
+                                        // high gain channel
+
+  TClonesArray  *PixelsLow   ;         // list of the events for the low gain
+                                       // channel if it has signifcant signal
 
  public: 
@@ -33,16 +44,11 @@
   void Print() ; 
 
-  void FillRandom( UInt_t, ULong_t, UShort_t   ) ; 
+  void FillHeader( UInt_t, Float_t, Float_t = 0 ) ; 
 
-  void FillHeader( UInt_t, ULong_t, UChar_t = 0  ) ; 
-
-  void FillPixel(  UShort_t, Float_t * ) ; 
+  void FillPixel(Short_t, UShort_t *, Float_t * ) ; 
  
-  void FillMontCarl ( UInt_t, ULong_t, Float_t * ) ;
+  void FillPixelLow(Short_t, UShort_t *, Float_t * ) ; 
 
   UShort_t GetMultPixel(); 
-
-  UShort_t GetPixelId( Int_t  ) 
-    {return 1 ) ; 
 
   TClonesArray *&GetPixelList() {
@@ -50,15 +56,15 @@
     //   returns a Pointer to the pixel list
     //
-    return  Pixels ; 
+    return  PixelsHigh ; 
   }
   
   ULong_t GetTimeStamp() {
-    return fTimeStamp ; 
+    return (ULong_t) AbsTime[0]*4294967296+AbsTime[1]; 
   }
   
   
-/*    void AddPixel( UShort_t  ) ;  */
+/*    void AddPixel( Short_t  ) ;  */
 
-/*    void AddPixel ( UShort_t, UChar_t, UChar_t * ) ;  */
+/*    void AddPixel ( Short_t, Byte_t, Byte_t * ) ;  */
 
 
@@ -68,17 +74,2 @@
 
 #endif
-
-
-
-
-
-  
-
-
-
-
-  
-
-
-
-
Index: trunk/MagicSoft/include-Classes/MRawPixel.cxx
===================================================================
--- trunk/MagicSoft/include-Classes/MRawPixel.cxx	(revision 433)
+++ trunk/MagicSoft/include-Classes/MRawPixel.cxx	(revision 434)
@@ -1,5 +1,4 @@
 #include <iostream.h>
 
-#include "TClonesArray.h"
 #include "TString.h"
 #include "TRandom.h"
@@ -26,5 +25,5 @@
 // ---------
 //
-// UShort_t     PixelId     ;   
+// Short_t     PixelId     ;   
 //
 // This is to identify the Pixel.
@@ -35,7 +34,8 @@
 // low-gain-branch of the Fadc´s only if there is a signal in. Then the 
 // PixelId is:
-//                   PixelId = 10000 + PixelId   . 
+//                   PixelId = - PixelId   . 
+// if there is an entry in the low gain list.
 //
-// For the high gain Fadc values the rule is:
+// Otherwise Fadc values the rule is:
 //                   PixelId = PixelId . 
 //
@@ -43,17 +43,10 @@
 // ---------
 //
-// UChar_t      PixelStatus ;   
-//
-// The PixelStatus may contain information if the Pixel has triggered 
-// this event. Also the kind of gain-branch (high or low) may be indicated 
-// by one bit of the PixelStatus. etc
-//
-// ---------
-//
-// UChar_t      Fadc[ FADC_SLICES ]  ; 
+// Byte_t    FADCSamples[FADC_SLICES] ; 
 //
 // The values of FADC_SLICES fadc-slices. This is the information of the 
 // measured ADC values for one branch (high gain or low gain). The typ of 
 // branch is indicated in the usPixelNumber and in the PixelStatus.
+// In this first version the number of FADC_SLICES is going to be fixed
 
 ClassImp(MRawPixel) 
@@ -66,13 +59,13 @@
   //
     
-    PixelId     = 0 ; 
-    PixelStatus = 0 ; 
-    
-    for (Int_t i = 0; i<FADC_SLICES; i++) 
-      Fadc[i]   = 0 ; 
+  PixelId     = 0 ; 
+
+  for (Int_t i = 0; i<FADC_SLICES; i++) 
+    FADCSamples[i]   = 0 ; 
+
 }
 
 
-MRawPixel::MRawPixel(UShort_t PId) {
+MRawPixel::MRawPixel(Short_t PId) {
   //
   //  constructor II  overloaded
@@ -81,23 +74,22 @@
   
   PixelId     = PId ; 
-  PixelStatus = 0 ; 
-  
   for (Int_t i = 0; i<FADC_SLICES; i++) 
-    Fadc[i]   = 0 ; 
+     FADCSamples[i]   = 0 ; 
+
 }
 
 
-MRawPixel::MRawPixel(UShort_t usPId, UChar_t ucSt, UChar_t ucF[]) {
+MRawPixel::MRawPixel(Short_t usPId, Byte_t ucF[]) {
   //
   // constructor III overloaded 
   //
-  // parameters are PixelId, Status and an array with Fadc numbers.
+  // parameters are PixelId and an array with Fadc values.
   
   PixelId     = usPId ; 
-  PixelStatus = ucSt  ; 
   
-  for (Int_t i = 0; i<FADC_SLICES; i++) 
-    Fadc[i]   = ucF[i] ; 
+   for (Int_t i = 0; i<FADC_SLICES; i++) 
+    FADCSamples[i]   = ucF[i] ; 
 }
+
 MRawPixel::~MRawPixel(){
   //
@@ -111,10 +103,9 @@
   //
   PixelId     = 0 ; 
-  PixelStatus = 0 ; 
-  
-  for (Int_t i = 0; i<FADC_SLICES; i++) 
-    Fadc[i]   = 0 ; 
+
+  for (Int_t i=0;i<FADC_SLICES; i++){
+  FADCSamples[i] = 0;
+  }
 } 
-
 
 void MRawPixel::Print() 
@@ -125,12 +116,24 @@
 
   cout << endl << "PixId " << PixelId          ; 
-  cout << " Stat " << (Int_t) PixelStatus << " --> "     ;
 
   for (Int_t i=0 ; i<FADC_SLICES ; i++ ) {
-    cout<<" / " << (int) Fadc[i] ; 
+    cout<<" / " << FADCSamples[i]; 
   } 
 }
-  
-UShort_t MRawPixel::GetPixelId() {
+
+void MRawPixel::FillPixel (Short_t usPId, Byte_t ucF[]){
+  //
+  //  Fills the event information
+  //
+
+  PixelId= usPId;
+
+  for (Int_t i = 0; i<FADC_SLICES; i++){
+    FADCSamples[i]= ucF[i];
+  } 
+
+}
+
+Short_t MRawPixel::GetPixelId() {
   //
   // returns back the PixelId of the Pixel
@@ -139,14 +142,9 @@
 }
 
-UChar_t MRawPixel::GetFadcSlice( Int_t iSli ) {
+Byte_t MRawPixel::GetFadcSlice( Int_t iSli ) {
   //
   // returns back the fadc content of the slice iSli 
   //
-  return ( Fadc[iSli] ) ; 
+
+    return (FADCSamples[iSli]) ;
 }
-
-
-
-
-
-
Index: trunk/MagicSoft/include-Classes/MRawPixel.h
===================================================================
--- trunk/MagicSoft/include-Classes/MRawPixel.h	(revision 433)
+++ trunk/MagicSoft/include-Classes/MRawPixel.h	(revision 434)
@@ -13,9 +13,8 @@
  private: 
 
-  UShort_t     PixelId     ;           //  Identification of PixelNumber and gain branch
+  Short_t     PixelId      ; //  Identification of PixelNumber and 
+                             //  flag for existency of low  gain branch
 
-  UChar_t      PixelStatus ;           //  The Status of the pixel
-
-  UChar_t      Fadc[ FADC_SLICES ]  ;  // The values of fadc-slices.
+  Byte_t      FADCSamples[FADC_SLICES] ; // The values of fadc-slices.
 
  public:
@@ -23,7 +22,7 @@
   MRawPixel() ; 
 
-  MRawPixel(UShort_t ) ; 
+  MRawPixel(Short_t ) ; 
 
-  MRawPixel(UShort_t , UChar_t , UChar_t * ) ; 
+  MRawPixel(Short_t ,  Byte_t* ) ; 
 
   ~MRawPixel() ; 
@@ -33,7 +32,9 @@
   void Print() ; 
 
-  UShort_t GetPixelId() ; 
+  void FillPixel( Short_t, Byte_t *);
 
-  UChar_t GetFadcSlice( Int_t  ) ; 
+  Short_t GetPixelId() ; 
+
+  Byte_t GetFadcSlice( Int_t  ) ; 
 
   ClassDef ( MRawPixel, 1 )
