Index: branches/start/MagicSoft/Mars/mdatacheck/DataCheckIncl.h
===================================================================
--- branches/start/MagicSoft/Mars/mdatacheck/DataCheckIncl.h	(revision 4308)
+++ branches/start/MagicSoft/Mars/mdatacheck/DataCheckIncl.h	(revision 4308)
@@ -0,0 +1,14 @@
+#ifndef __CINT__
+
+#include "MParList.h"
+
+#include "MRawRunHeader.h"
+#include "MRawEvtHeader.h"
+#include "MRawEvtData.h"
+#include "MRawCrateArray.h"
+#include "MTime.h"
+#include "MInputStreamID.h"
+
+#include "MReadTree.h"
+
+#endif // __CINT__
Index: branches/start/MagicSoft/Mars/mdatacheck/DataCheckLinkDef.h
===================================================================
--- branches/start/MagicSoft/Mars/mdatacheck/DataCheckLinkDef.h	(revision 4308)
+++ branches/start/MagicSoft/Mars/mdatacheck/DataCheckLinkDef.h	(revision 4308)
@@ -0,0 +1,14 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MDumpEvtHeader;
+#pragma link C++ class MFillAdcSpect;
+#pragma link C++ class MShowSpect;
+
+#pragma link C++ class MHistosAdc;
+#pragma link C++ class MGDisplayAdc;
+
+#endif
Index: branches/start/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.cc
===================================================================
--- branches/start/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.cc	(revision 4308)
+++ branches/start/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.cc	(revision 4308)
@@ -0,0 +1,47 @@
+#include "MDumpEvtHeader.h"
+
+//ClassImp(MDumpEvtHeader)
+
+Bool_t MDumpEvtHeader::PreProcess (MParList *pList)
+{
+  fRawEvtHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
+  if (!fRawEvtHeader)
+    {
+      cout << "MRawFileRead::PreProcess - WARNING: MRawEvtHeader not found... creating." << endl;
+      exit(123) ;  
+    }
+  
+  fRawEvtData = (MRawEvtData*)pList->FindObject("MRawEvtData");
+  
+  if (!fRawEvtData)
+    {
+      cout << "MRawFileRead::PreProcess - WARNING: MRawEvtData not found... creating." << endl;
+      exit(123) ;  
+    }
+
+  fPixelIter = new MRawEvtPixelIter( fRawEvtData );
+  
+  return kTRUE ; 
+
+} 
+
+    
+Bool_t MDumpEvtHeader::Process()
+{
+  fRawEvtHeader->Print() ; 
+
+  //fRawEvtData->Print() ; 
+
+  fPixelIter->Reset() ; 
+
+  while ( fPixelIter->Next() )
+    { 
+      cout << " " << fPixelIter->GetPixelId() ; 
+      
+    } 
+
+  cout << endl ; 
+  
+  return kTRUE;
+
+} 
Index: branches/start/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.h
===================================================================
--- branches/start/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.h	(revision 4308)
+++ branches/start/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.h	(revision 4308)
@@ -0,0 +1,35 @@
+#ifndef MDUMPEVTHEADER_H
+#define MDUMPEVTHEADER_H
+
+#ifndef MTASK_H
+#include "MTask.h"
+#endif
+
+#include "MParList.h"
+#include <TSystem.h>
+
+#include "MRawEvtHeader.h"
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+
+class MDumpEvtHeader : public MTask {
+ private:
+  MRawEvtHeader    *fRawEvtHeader;
+
+  MRawEvtData      *fRawEvtData;
+
+  MRawEvtPixelIter *fPixelIter ; 
+
+ public:   
+  MDumpEvtHeader () { 
+    fRawEvtHeader = NULL ; 
+  } ; 
+
+  Bool_t PreProcess(MParList *pList);
+  Bool_t Process() ;
+  
+  //  ClassDef(MDumpEvtHeader, 1)	// Task to read the raw data binary file
+
+};
+    
+#endif
Index: branches/start/MagicSoft/Mars/mdatacheck/MFillAdcSpect.cc
===================================================================
--- branches/start/MagicSoft/Mars/mdatacheck/MFillAdcSpect.cc	(revision 4308)
+++ branches/start/MagicSoft/Mars/mdatacheck/MFillAdcSpect.cc	(revision 4308)
@@ -0,0 +1,74 @@
+#include "MFillAdcSpect.h"
+
+//ClassImp(MFillAdcSpect)
+
+MFillAdcSpect::MFillAdcSpect (const char *name, const char *title)
+{
+  *fName  = name  ? name  : "MFillAdcSpect";
+  *fTitle = title ? title : "Task to fill the adc spectra with  raw data";
+
+
+  
+  fRawEvtData   = NULL ; 
+  fPixelIter    = NULL ; 
+}
+
+
+
+Bool_t MFillAdcSpect::PreProcess (MParList *pList)
+{
+  // connect the raw data with this task
+  
+  fRawEvtData = (MRawEvtData*)pList->FindObject("MRawEvtData");
+  
+  if (!fRawEvtData)
+    {
+      cout << "MRawFileRead::PreProcess - WARNING: MRawEvtData not found... creating." << endl;
+      exit(123) ;  
+    }
+
+  fPixelIter = new MRawEvtPixelIter( fRawEvtData );
+  
+  fHistos = (MHistosAdc*)pList->FindObject("MHistosAdc");
+  
+  if (!fHistos) 
+    {
+      cout << "MRawFileRead::PreProcess - WARNING: MHistosAdc not found... exit..." << endl;
+      return kFALSE ;  
+    }
+
+
+  return kTRUE ; 
+
+} 
+
+    
+Bool_t MFillAdcSpect::Process()
+{
+  //  loop over the pixels and fill the values in the histograms
+  
+  fPixelIter->Reset() ; 
+
+  Int_t iHighSamples = fRawEvtData->GetNumHiGainSamples() ; 
+  Int_t iLowSamples  = fRawEvtData->GetNumLoGainSamples() ; 
+
+  //  cout << "HighSamples " << iHighSamples ;
+
+  while ( fPixelIter->Next() )
+    { 
+      for (Int_t i=0 ; i< iHighSamples ; i++ )
+	{ 
+	  fHistos->FillAdcHistHigh ( fPixelIter->GetPixelId(),
+				     fPixelIter->GetHiGainFadcSamples()[i] );
+	}
+
+      for (Int_t i=0 ; i< iLowSamples ; i++ )
+	{ 
+	  fHistos->FillAdcHistLow ( fPixelIter->GetPixelId(),
+				    fPixelIter->GetLoGainFadcSamples()[i] );
+	}
+    } 
+  
+  return kTRUE;
+  
+} 
Index: branches/start/MagicSoft/Mars/mdatacheck/MFillAdcSpect.h
===================================================================
--- branches/start/MagicSoft/Mars/mdatacheck/MFillAdcSpect.h	(revision 4308)
+++ branches/start/MagicSoft/Mars/mdatacheck/MFillAdcSpect.h	(revision 4308)
@@ -0,0 +1,34 @@
+#ifndef MFILLADCSPECT_H
+#define MFILLADCSPECT_H
+
+#ifndef MTASK_H
+#include "MTask.h"
+#endif
+
+#include "MParList.h"
+#include <TSystem.h>
+
+#include "MRawEvtHeader.h"
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+#include "MHistosAdc.h"
+
+class MFillAdcSpect : public MTask {
+ private:
+  MRawEvtData      *fRawEvtData;
+  MRawEvtPixelIter *fPixelIter ; 
+
+  MHistosAdc       *fHistos ; 
+
+ public:   
+  MFillAdcSpect (const char *name=NULL, const char *title=NULL); 
+
+  Bool_t PreProcess(MParList *pList);
+  Bool_t Process() ;
+  
+  //  ClassDef(MFillAdcSpect, 1)	// Task to read the raw data binary file
+
+};
+    
+#endif
+
Index: branches/start/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc
===================================================================
--- branches/start/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc	(revision 4308)
+++ branches/start/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc	(revision 4308)
@@ -0,0 +1,548 @@
+
+#include "MGDisplayAdc.h"
+
+MGDisplayAdc::MGDisplayAdc ( MHistosAdc *Histos,
+			    const TGWindow *p, const TGWindow *main, 
+			    UInt_t w, UInt_t h, 
+			    UInt_t options) 
+	: TGTransientFrame(p, main, w, h, options ) 
+{
+	//   default constructor
+	// 
+	fHists = Histos ; 
+	
+	//   the top frame for the list and some buttons and the Canvas 
+  
+	fFrameTop = new TGHorizontalFrame (this, 60,20,  kFitWidth ) ;
+  
+  
+	//    left part of top frame
+	fFT1 =  new TGVerticalFrame (fFrameTop, 80,300,  kFitWidth ) ; 
+  
+	fHistoList = new TGListBox ( fFT1, M_LIST_HISTO ) ; 
+	fHistoList->Associate( this ) ;
+	fFT1->AddFrame ( fHistoList, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 10, 10 ) )  ;
+	
+	fHistoList->Resize(80, 405 ) ; 
+	
+	
+	fFrameTop->AddFrame (fFT1, new TGLayoutHints ( kLHintsTop , 10, 10, 10, 10 ) ) ; 
+	
+	//    middle part of top frame
+	// 
+  
+	fFT2 =  new TGVerticalFrame (fFrameTop, 80,20,  kFitWidth ) ;  
+	
+	fButtonPrev = new TGTextButton ( fFT2, "Prev Histo", M_BUTTON_PREV ) ; 
+	fButtonPrev->Associate (this) ; 
+	fFT2->AddFrame ( fButtonPrev, new TGLayoutHints (kLHintsLeft | kLHintsTop,10, 10, 0, 10 ) )  ; 
+	
+  
+	fVslider1 = new TGVSlider (fFT2, 250, kSlider1 | kScaleBoth, M_VSId1);
+	
+	fVslider1->Associate(this);
+	fVslider1->SetRange(0, 576);
+	fFT2->AddFrame(fVslider1);   	
+	
+	fButtonNext = new TGTextButton ( fFT2, "Next Histo", M_BUTTON_NEXT ) ;
+	fButtonNext->Associate (this) ;
+	fFT2->AddFrame ( fButtonNext, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 10, 5 ) )  ;  		
+	
+	fFrameTop->AddFrame (fFT2, new TGLayoutHints ( kLHintsTop , 10, 10, 10, 10 ) ) ; 	
+	
+
+
+	// Radio buttons, used to select the high, low anh high/low display
+		
+	fRadio[0] = new  TGRadioButton(fFT2, "&High Gain", M_RADIO_HIGH);                       
+	fFT2->AddFrame ( fRadio[0], new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 10, 5 ) )  ; 
+	fRadio[0]->Associate(this); 
+	fRadio[0]->SetState(kButtonDown);
+	fHistoLock = kFALSE;
+	fHistoType=1;  	
+	
+        fRadio[1] = new  TGRadioButton(fFT2, "&Low Gain", M_RADIO_LOW);  
+	fFT2->AddFrame ( fRadio[1], new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 10, 5 ) )  ;
+	fRadio[1]->Associate(this); 
+	
+	fRadio[2] = new  TGRadioButton(fFT2, "H&igh/Low Gain", M_RADIO_LH); 
+	fFT2->AddFrame ( fRadio[2], new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 10, 5 ) )  ; 
+	fRadio[2]->Associate(this); 
+       
+	
+	
+	//    right part of top frame
+	// 
+	fFT3 =  new TGVerticalFrame (fFrameTop, 60, 60,  kFitWidth ) ;
+  
+    
+	
+	fECanv = new TRootEmbeddedCanvas("fECanv", fFT3, 400, 400 ) ;	 
+	
+	fFT3->AddFrame( fECanv, new TGLayoutHints ( kLHintsCenterX | kLHintsCenterY | kLHintsExpandX | kLHintsExpandY , 10, 10, 10, 10 ) ) ;
+	
+	
+	//the button for reseting the histogram
+        fButtonReset = new TGTextButton ( fFT3, "Reset histo", M_BUTTON_RESET ) ;
+        fButtonReset->Associate (this) ;
+        fFT3->AddFrame ( fButtonReset, new TGLayoutHints (kLHintsCenterX | kLHintsTop,10, 10, 0, 10 ) )  ;
+	//
+	 
+	  
+	
+	fCanv = fECanv->GetCanvas() ; 
+	
+	fFrameTop->AddFrame (fFT3, new TGLayoutHints ( kLHintsCenterX | kLHintsCenterY | kLHintsExpandX | kLHintsExpandY , 10, 10, 10, 10 ) ) ; 
+	
+	AddFrame ( fFrameTop, new TGLayoutHints ( kLHintsTop | kLHintsExpandX , 10, 10, 10, 10 ) ) ; 
+ 
+	
+	//  fHists->GetHighList()->At( fHistoList->GetSelected()-1)->Draw() ;  
+	//
+	//   the low frame for the control buttons
+	//
+	fFrameLow = new TGHorizontalFrame (this, 60,20, kFixedWidth ) ;
+  
+	fButtonSave = new TGTextButton ( fFrameLow, "Save", M_BUTTON_SAVE ) ; 
+	fButtonSave->Associate (this) ; 
+	fFrameLow->AddFrame ( fButtonSave, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) )  ;
+	
+	fButtonPrint = new TGTextButton ( fFrameLow, "Print", M_BUTTON_PRINT ) ; 
+	fButtonPrint->Associate (this) ; 
+	fFrameLow->AddFrame ( fButtonPrint, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) )  ; 
+  
+	fButtonPrintAll = new TGTextButton ( fFrameLow, "PrintAll", M_BUTTON_PRINTALL ) ; 
+	fButtonPrintAll->Associate (this) ; 
+	fFrameLow->AddFrame ( fButtonPrintAll, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) )  ;
+  
+  
+  
+	fButtonClose = new TGTextButton ( fFrameLow, "Close", M_BUTTON_CLOSE ) ; 
+	fButtonClose->Associate (this) ; 
+	fFrameLow->AddFrame ( fButtonClose, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) )  ; 
+	AddFrame ( fFrameLow, new TGLayoutHints ( kLHintsBottom | kLHintsExpandX , 10, 10, 10, 10 ) ) ; 
+	
+	//
+	//
+	//
+	BuildHistoList() ; 
+  
+	MapSubwindows();
+ 
+	Layout();
+	
+	SetWindowName("ADC Spectra");
+	SetIconName("ADC Spectra");
+
+	//Here the initial display is set to hitogram 0
+	
+	fHistoList->Select(1, kTRUE);
+	fHists->GetHighList()->At( fHistoList->GetSelected()-1)->Draw() ;
+	fHistoList->SetTopEntry(fHistoList->GetSelected());
+	fCanv->Modified() ;
+	fCanv->Update() ;
+	fVslider1->SetPosition( fHistoList->GetSelected()-1);
+	 
+	
+	MapWindow();
+	SetWMSizeHints(550, 550, 1000, 1000, 1, 1); 
+
+}  
+
+// ======================================================================
+// ======================================================================
+// 
+// 
+
+MGDisplayAdc::~MGDisplayAdc () 
+{ 
+
+		
+	delete fButtonSave ; 
+	delete fButtonPrint ; 
+	delete fButtonPrintAll ; 
+	delete fButtonClose ; 
+	
+	delete fButtonPrev; 
+	delete fButtonNext ; 
+	delete fButtonReset ;
+	
+	delete fVslider1; 
+	delete fECanv ;
+	
+
+	delete fHists; 
+	delete fHistoList ;
+	delete fRadio[2];
+	delete fRadio[1];
+	delete fRadio[0]; 
+	delete fFT1 ; 
+	delete fFT2 ; 
+	delete fFT3 ; 
+	delete fFrameLow ; 
+	delete fFrameTop ; 
+	
+	
+}  
+
+// ======================================================================
+// ======================================================================
+
+void MGDisplayAdc::CloseWindow()
+{
+  // Got close message for this MainFrame. Calls parent CloseWindow()
+  // (which destroys the window) and terminate the application.
+  // The close message is generated by the window manager when its close
+  // window menu item is selected.
+  // 
+  delete this ; 
+  //  TGTransientFrame::CloseWindow();
+  //  TGMainFrame::CloseWindow();
+  //   gROOT->GetApplication()->Terminate(0)  ; 
+}
+
+
+
+// ======================================================================
+// ======================================================================
+
+Bool_t MGDisplayAdc::BuildHistoList(Int_t type ) 
+{ 
+	//   looks in the container of the AdcSpectra and reads in the 
+	//   Histogramms in there. 
+	//
+	//   In the class MHistosAdc are in fact two lists. One for the high and
+	//   one for the low gain. Here we will use only the high gain list!!!
+	//   With some special options (settings in the gui) we will also be able
+	//   to plot the low gain
+	// 
+	for ( Int_t i=0 ; i < fHists->GetHighEntries(); i++ ) {	       				
+		fHistoList->AddEntry(fHists->GetHighList()->At(i)->GetName(), i+1) ;
+		
+	} 
+	
+	fHistoList->MapSubwindows() ;
+	fHistoList->Layout() ;
+	return (kTRUE) ; 
+} 
+
+// ======================================================================
+// ======================================================================
+
+Bool_t MGDisplayAdc::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+{     
+	
+	// Process events generated by the buttons in the frame.
+	// 
+	Int_t   buttons = 4, retval = 0 ; 
+	Char_t  wort[100] ;
+	Char_t  extens[5] ;
+	Char_t  command[110] ;
+	
+	TGFileItem *item ;     // to process items in the file view container
+	void *np = NULL ;      // null pointer
+	
+	switch (GET_MSG(msg)) 
+	{
+	    case kC_COMMAND:
+		switch (GET_SUBMSG(msg)) 
+		{
+		    case kCM_BUTTON:
+			
+			switch (parm1)
+			{  
+				
+			    case M_BUTTON_SAVE:
+				new TGMsgBox(fClient->GetRoot(), this,
+					     "WARNING!",
+					     "Not implemented yet.",
+					     kMBIconExclamation, buttons, &retval); 
+				
+				break ; 
+				
+			    case M_BUTTON_PRINT:
+				break;
+				
+			    case M_BUTTON_RESET:
+				new TGMsgBox(fClient->GetRoot(), this,
+					     "WARNING!",
+                                             "Not implemented yet.",
+					     kMBIconExclamation, buttons, &retval);  												
+				
+				break;
+				
+				
+			    case M_BUTTON_CLOSE: 
+				CloseWindow() ; 
+				break ; 
+				
+				// The selection for "Next Histogram".
+				// There is also a link for the sicronisation with the slider 
+				// 
+			    case M_BUTTON_PREV:
+								
+				if (!( fHistoList->GetSelected()-1 ) == 0)
+				{
+				    if (fHistoLock == kTRUE )
+				    {
+					    fCanvas->cd(1);
+					    fHistoList->Select(fHistoList->GetSelected()-1, kTRUE); 
+					    fHists->GetHighList()->At( fHistoList->GetSelected()-1)->Draw() ;
+					    fCanvas->cd(2);
+					    fHists->GetLowList()->At( fHistoList->GetSelected()-1)->Draw() ; 
+				    }
+					else
+					{
+						fCanv->cd();
+						fHistoList->Select(fHistoList->GetSelected()-1, kTRUE);
+						fHists->GetHighList()->At( fHistoList->GetSelected()-1)->Draw() ; 
+					}
+					
+					fHistoList->SetTopEntry(fHistoList->GetSelected());  
+					fCanv->Modified() ;
+					fCanv->Update() ;
+					fVslider1->SetPosition( fHistoList->GetSelected()-1);
+				}
+				if ((fRadio[1]->GetState()) == kButtonDown)
+				{
+					fRadio[0]->SetState(kButtonDown);
+					fRadio[1]->SetState(kButtonUp);
+				} 
+				
+
+				break;
+				
+				//The same as above, but for next histogram
+				
+			    case M_BUTTON_NEXT:
+			        
+				if (!((fHistoList->GetSelected()-1)==576))
+					
+                                {
+					if (fHistoLock == kTRUE )
+					{
+						fCanvas->cd(1);
+						fHistoList->Select(fHistoList->GetSelected()+1, kTRUE);
+						fHists->GetHighList()->At( fHistoList->GetSelected()-1)->Draw() ;
+						fCanvas->cd(2);
+						fHists->GetLowList()->At( fHistoList->GetSelected()-1)->Draw() ;  
+					}										
+					else
+                                        {  
+						fCanv->cd();
+                                                fHistoList->Select(fHistoList->GetSelected()+1, kTRUE);
+                                                fHists->GetHighList()->At( fHistoList->GetSelected()-1)->Draw() ; 
+						
+					}
+						fHistoList->SetTopEntry(fHistoList->GetSelected());
+						fCanv->Modified() ;
+						fCanv->Update() ;
+						fVslider1->SetPosition( fHistoList->GetSelected()-1);
+					
+				}
+				if ((fRadio[1]->GetState()) == kButtonDown)
+					{
+						fRadio[0]->SetState(kButtonDown);
+						fRadio[1]->SetState(kButtonUp);
+					}
+				break;
+			    default:
+				break ;
+			} 
+			
+		    case kCM_MENU:
+			switch (parm1)
+			{
+			}
+			break ;
+			
+		    default:
+			break ;
+		
+		
+			
+		    case kCM_RADIOBUTTON:
+	  
+			switch(parm1)
+			{
+			    case M_RADIO_HIGH:
+				fRadio[1]->SetState(kButtonUp);
+				fRadio[2]->SetState(kButtonUp);
+				fHistoLock = kFALSE;
+				fHistoType=1;
+                                fCanv->cd();
+				fHistoList->Select(fHistoList->GetSelected(), kTRUE);
+                                fHists->GetHighList()->At( fHistoList->GetSelected()-1)->Draw() ;
+                                fHistoList->SetTopEntry(fHistoList->GetSelected());
+                                fCanv->Modified() ;
+                                fCanv->Update() ;
+                                fVslider1->SetPosition( fHistoList->GetSelected()-1);
+				
+				
+				break;
+				
+			    case M_RADIO_LOW:
+				fRadio[0]->SetState(kButtonUp);
+				fRadio[2]->SetState(kButtonUp);
+				fCanv->cd(); 
+				fHistoLock = kFALSE;
+				fHistoType = 2;
+				
+				fHistoList->Select(fHistoList->GetSelected(), kTRUE);
+				fHists->GetLowList()->At( fHistoList->GetSelected()-1)->Draw() ;
+				fHistoList->SetTopEntry(fHistoList->GetSelected());
+				
+				fCanv->Modified() ;
+				fCanv->Update() ;
+				fVslider1->SetPosition( fHistoList->GetSelected()-1);
+				
+				break;
+			    case M_RADIO_LH:
+				fRadio[0]->SetState(kButtonUp);
+                                fRadio[1]->SetState(kButtonUp); 
+				
+				if (fHistoLock == kFALSE)
+				{
+					fCanvas = fECanv->GetCanvas(); 
+					fCanvas->Divide(1,2, 0, 0 ,0);
+
+					fCanv->Modified() ;
+					fCanv->Update() ;  
+					fHistoLock = kTRUE;
+					fHistoType = 3; 
+				
+				}
+			       
+				fCanvas->cd(1);
+ 
+				fHistoList->Select(fHistoList->GetSelected(), kTRUE);
+                                fHists->GetHighList()->At( fHistoList->GetSelected()-1)->Draw() ;
+                                fHistoList->SetTopEntry(fHistoList->GetSelected());
+				
+				
+				
+				
+				fCanvas->cd(2);
+                                fHistoList->Select(fHistoList->GetSelected(), kTRUE);
+                                fHists->GetLowList()->At( fHistoList->GetSelected()-1)->Draw() ;
+                                fHistoList->SetTopEntry(fHistoList->GetSelected());     
+				
+				
+				
+                                fCanv->Modified() ;
+                                fCanv->Update();
+				
+			    default:
+				break;
+			}
+			break;
+		   
+			
+		}
+		
+	    case kCM_LISTBOX:
+	      switch  (GET_SUBMSG(msg)) 
+		{
+		    case M_LIST_HISTO: 
+			
+			if (fHistoLock == kTRUE ) 
+			{
+				fCanvas->cd(1);
+				fHists->GetHighList()->At( fHistoList->GetSelected()-1)->Draw() ;
+				fCanvas->cd(2);
+				fHists->GetLowList()->At( fHistoList->GetSelected()-1)->Draw() ; 				
+				
+			}
+			else
+			{
+			
+				fCanv->cd() ; 
+			
+				fHists->GetHighList()->At( fHistoList->GetSelected()-1)->Draw() ; 
+			
+			}
+			fCanv->Modified() ; 
+			fCanv->Update() ;
+			fVslider1->SetPosition( fHistoList->GetSelected()-1);
+		  
+		  
+		  
+		default:
+		  break ;
+		}
+	      
+		
+	case kC_CONTAINER: 
+	  switch (GET_SUBMSG(msg)) 
+	    {
+	      
+	    case kCT_ITEMDBLCLICK: 
+	      
+	      break; 
+			
+	    default:
+	      break ;
+	    }
+	  
+	  
+	  
+	default:
+	  break;
+	  
+	case kC_VSLIDER:
+	  switch(GET_SUBMSG(msg))
+	    {
+	    case kSL_POS:
+	      {
+		switch(parm1)
+		  {
+		      case M_VSId1:
+
+			  // Check for the slider movement and sicronise with TGListBox		    
+			  if ((parm2 >= 0) && (parm2) <= 576)
+			  {
+				  
+				  if (fHistoLock==kTRUE)
+				  {
+					  fCanvas->cd(1) ;
+					  fHists->GetHighList()->At(parm2)->Draw() ;
+					  fHistoList->Select(parm2+1, kTRUE);
+					 
+					  fCanvas->cd(2) ; 
+					  fHists->GetLowList()->At(parm2)->Draw() ;
+                                          fHistoList->Select(parm2+1, kTRUE);
+					  fHistoList->SetTopEntry(fHistoList->GetSelected()); 
+					  
+				  }
+				  
+				  else 
+				  {
+					  fCanv->cd() ;  
+					  fHists->GetHighList()->At(parm2)->Draw() ;
+					  fHistoList->Select(parm2+1, kTRUE); 
+					  
+					  fHistoList->SetTopEntry(fHistoList->GetSelected());
+					  
+				  }
+					  fCanv->Modified() ;
+					  fCanv->Update() ;
+				  
+				  if ((fRadio[1]->GetState()) == kButtonDown)
+				  {
+					  fRadio[0]->SetState(kButtonDown);
+					  fRadio[1]->SetState(kButtonUp);
+				  }   
+				  
+				  
+			  }
+		    break;
+		  }
+		break;				
+	      }					
+	      break;
+	    }
+	  break;
+	  
+	}
+	return kTRUE;
+} 
Index: branches/start/MagicSoft/Mars/mdatacheck/MGDisplayAdc.h
===================================================================
--- branches/start/MagicSoft/Mars/mdatacheck/MGDisplayAdc.h	(revision 4308)
+++ branches/start/MagicSoft/Mars/mdatacheck/MGDisplayAdc.h	(revision 4308)
@@ -0,0 +1,115 @@
+#ifndef MGDISPLAYADC_H
+#define MGDISPLAYADC_H
+
+#include <iostream.h>
+#include <TROOT.h> 
+#include <TApplication.h> 
+#include <TSystem.h> 
+#include <TGClient.h> 
+#include <TGButton.h>
+#include <TGMenu.h>
+#include <TGTab.h> 
+#include <TGListBox.h> 
+#include <TGPicture.h>
+#include <TRootEmbeddedCanvas.h>
+#include <TCanvas.h>
+#include <TGFSContainer.h>
+#include <TGMsgBox.h>
+#include <TVirtualX.h>
+#include <TGFrame.h>
+#include <TGTextEntry.h>
+#include <TGSlider.h>
+#include <TGDoubleSlider.h>
+#include <TGScrollBar.h>
+#include <TSlider.h>
+
+
+#include <TVirtualX.h>
+#include <TGClient.h>   
+    
+#include "MHistosAdc.h"
+	
+    class MHistosAdc;
+
+
+
+enum ComIdentDisplayAdc {
+	M_BUTTON_SAVE,
+		M_BUTTON_PRINT,
+		M_BUTTON_PRINTALL,
+		M_BUTTON_CLOSE , 
+		
+		M_BUTTON_PREV, 
+		M_BUTTON_NEXT,
+
+		M_LIST_HISTO,
+		M_RADIO_HIGH,
+		M_RADIO_LOW,
+		M_RADIO_LH,
+		M_BUTTON_RESET,
+		M_VSId1
+} ; 
+
+class MGDisplayAdc : public TGTransientFrame {
+    private:
+	
+	MHistosAdc *fHists;		// Pointer to Container with the histograms
+	
+	// Create a main frame with a number of different buttons.
+	//   
+	TGCompositeFrame  *fFrameTop ;   // top part of the main window
+	TGCompositeFrame  *fFrameLow ;   // low part of the main window
+  
+	TGVerticalFrame   *fFT1, *fFT2, *fFT3 ;
+	
+	TGListBox         *fHistoList ;
+	TGTextButton      *fButtonPrev, *fButtonNext , *fButtonReset ;
+	
+	TRootEmbeddedCanvas  *fECanv , *fECanvLow;
+
+	TGTextButton   *fButtonSave, *fButtonPrint, *fButtonPrintAll, *fButtonClose ; 
+	
+	TCanvas            *fCanv ;	
+	
+	
+	//for sliders
+	
+	TGVSlider       *fVslider1;
+	
+       
+	
+  
+    public:
+	
+	//for radio buttons
+
+	TGRadioButton *fRadio[3];
+
+	
+        Int_t    fHistoType;
+        Bool_t    fHistoLock; 
+	//
+			
+	
+	TGPicture *fPicture;  
+	TCanvas *fCanvas;
+	
+	MGDisplayAdc(MHistosAdc *fHists , 
+		     const TGWindow *p, const TGWindow *main, 
+		     UInt_t w, UInt_t h, 
+		     UInt_t options = kMainFrame | kVerticalFrame ) ;
+	
+	~MGDisplayAdc(); 
+  
+	void  CloseWindow()  ;
+       
+	
+	Bool_t BuildHistoList(Int_t type=1) ;
+	
+	Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+  
+} ; 
+
+#endif
+
+
Index: branches/start/MagicSoft/Mars/mdatacheck/MHistosAdc.cc
===================================================================
--- branches/start/MagicSoft/Mars/mdatacheck/MHistosAdc.cc	(revision 4308)
+++ branches/start/MagicSoft/Mars/mdatacheck/MHistosAdc.cc	(revision 4308)
@@ -0,0 +1,110 @@
+///////////////////////////////////////////////////////////////////////
+//
+// MHistosAdc
+//
+// This class contains a list of all ADC spektra histograms
+//
+///////////////////////////////////////////////////////////////////////
+
+#include "MHistosAdc.h"
+
+#include <iostream.h>
+
+#include <TH1.h>
+#include <TFile.h>
+
+ClassImp(MHistosAdc)
+
+MHistosAdc::MHistosAdc (const char *name, const char *title)
+{
+    //
+    //  default constructor
+    //  creates an a list of histograms for all pixels and both gain channels
+    //
+
+    fHistHigh = new TObjArray(577);
+    fHistLow  = new TObjArray(577);
+
+    //
+    //   set the name and title of this object
+    //
+    
+    *fName  = name  ? name  : "MHistosAdc" ;
+    *fTitle = title ? title : "Container for ADC spectra histograms" ;
+
+    //
+    //   loop over all Pixels and create two histograms
+    //   one for the Low and one for the High gain
+    //   connect all the histogram with the container fHist
+    //
+
+    Char_t  tmp1[40];
+    Char_t  tmp2[40];
+    TH1F    *h1;
+
+    for ( Int_t i = 0 ; i < 577 ; i++)
+    {
+        sprintf ( tmp1, "high%d", i ) ;
+        sprintf ( tmp2, "high gain Pixel %d", i ) ;
+
+        h1 = new TH1F ( tmp1, tmp2, 256, 0., 255. ) ;
+
+        fHistHigh->Add( h1 ) ;
+
+        sprintf ( tmp1, "low %d", i ) ;
+        sprintf ( tmp2, "low gain Pixel %d", i ) ;
+
+        h1 = new TH1F ( tmp1, tmp2, 256, 0., 255. ) ;
+
+        fHistLow->Add( h1 ) ;
+
+    }
+}
+
+MHistosAdc::~MHistosAdc ()
+{
+  
+  //   default destructor 
+  //
+  delete fHistHigh ; 
+  delete fHistLow  ; 
+}
+
+void MHistosAdc::Print(Option_t *)
+{
+  for ( Int_t i = 0 ; i < 576 ; i++)
+    {
+      fHistHigh[i].Print() ;
+    }
+}
+
+void MHistosAdc::FillAdcHistHigh ( Int_t iPix, Byte_t data)
+{
+  //
+  
+  ((TH1F*) (fHistHigh->At(iPix)))->Fill( (Float_t) data ) ;
+}
+
+void MHistosAdc::FillAdcHistLow ( Int_t iPix, Byte_t data)
+{
+  //
+  
+  ((TH1F*) (fHistLow->At(iPix)))->Fill( (Float_t) data ) ;
+}
+
+void MHistosAdc::SaveHist ( char *name )
+{
+    //
+    //   save all histogram in this class to a root file
+    //
+
+    TFile out( name, "recreate") ;
+
+    //
+    //  loop over all pixels and write the files out
+    //
+
+    fHistLow->Write() ;
+    fHistHigh->Write() ;
+}
+
Index: branches/start/MagicSoft/Mars/mdatacheck/MHistosAdc.h
===================================================================
--- branches/start/MagicSoft/Mars/mdatacheck/MHistosAdc.h	(revision 4308)
+++ branches/start/MagicSoft/Mars/mdatacheck/MHistosAdc.h	(revision 4308)
@@ -0,0 +1,53 @@
+#ifndef MHISTOSADC_H
+#define MHISTOSADC_H
+
+#include "MAGIC.h"
+
+#include <TObjArray.h>
+
+#include "MParContainer.h"
+
+class MHistosAdc : public MParContainer
+{
+private:
+    TObjArray *fHistHigh;	// List of High gain Histograms
+    TObjArray *fHistLow;	// List of Low  gain Histograms
+
+public:
+     MHistosAdc(const char *name=NULL, const char *title=NULL);
+    ~MHistosAdc();
+
+    void FillAdcHistHigh(Int_t iPix, Byte_t data); 
+    void FillAdcHistLow (Int_t iPix, Byte_t data); 
+
+    void SaveHist(char *name);
+
+    void Print(Option_t * t = NULL);
+
+
+    TObjArray* GetHighList() 
+      { 
+	return ( fHistHigh ) ; 
+      }   
+
+    TObjArray* GetLowList() 
+      { 
+	return ( fHistLow ) ; 
+      } 
+    
+    Int_t GetHighEntries() 
+      { 
+	return (fHistHigh->GetEntries() ) ;  
+      } 
+
+    Int_t GetLowEntries() 
+      { 
+	return (fHistLow->GetEntries() ) ;  
+      } 
+
+      
+    ClassDef(MHistosAdc, 1)	// list of Histograms with ADC spectra
+};
+
+#endif
+
Index: branches/start/MagicSoft/Mars/mdatacheck/MShowSpect.cc
===================================================================
--- branches/start/MagicSoft/Mars/mdatacheck/MShowSpect.cc	(revision 4308)
+++ branches/start/MagicSoft/Mars/mdatacheck/MShowSpect.cc	(revision 4308)
@@ -0,0 +1,70 @@
+#include "MShowSpect.h"
+
+#include <stdlib.h>
+
+#include <TROOT.h> 
+#include <TApplication.h> 
+#include <TSystem.h> 
+#include <TGClient.h> 
+#include <TGFileDialog.h> 
+#include <TVirtualX.h>
+
+#include "MParList.h"
+#include "MHistosAdc.h"
+
+
+////////////////////////////////////////////////////////////////////////
+//
+//  MGShowSpect.h
+//
+//  A Gui Task to show the raw ADC values in the histograms
+//
+
+ClassImp(MShowSpect)
+
+MShowSpect::MShowSpect(char *nameHist ) 
+{ 
+  // default constructor 
+
+  sprintf (fHistName, "%s", nameHist ) ; 
+} 
+
+
+Bool_t MShowSpect::PreProcess(MParList *pList)
+{
+  //
+  //   Do the preprocessing for MShowSpect
+  // 
+  //   Connects Histogramms in the MHistosAdc container as the input
+  //
+
+  fHists = (MHistosAdc*) pList->FindObject( fHistName );
+  
+  if (!fHists)
+    {
+      cout << "ERROR: MShowSpect::PreProc(): " << fHistName << " not found!" << endl;
+      exit(1);
+    }
+  
+  return (kTRUE) ; 
+} 
+
+
+Bool_t MShowSpect::PostProcess()
+{
+  //   just start the gui for displaying the adc spectra
+
+  new MGDisplayAdc(fHists, gClient->GetRoot(), gClient->GetRoot(), 600, 600);
+
+  return (kTRUE) ; 
+} 
+
+
+
+
+
+
+
+
+
+
Index: branches/start/MagicSoft/Mars/mdatacheck/MShowSpect.h
===================================================================
--- branches/start/MagicSoft/Mars/mdatacheck/MShowSpect.h	(revision 4308)
+++ branches/start/MagicSoft/Mars/mdatacheck/MShowSpect.h	(revision 4308)
@@ -0,0 +1,35 @@
+#ifndef MSHOWSPECT_H
+#define MSHOWSPECT_H
+
+#include "MAGIC.h"
+
+#include "MTask.h"
+#include "MGDisplayAdc.h"
+
+class MGDisplayAdc ; 
+
+class MHistosAdc;
+class MHistosTdc; 
+class MParList ;
+
+class MShowSpect : public MTask 
+{
+private:
+  char       fHistName[256] ; 
+
+  MHistosAdc *fHists;		// Pointer to Container with the histograms
+  
+ public:
+  
+  MShowSpect(char* histName );
+  
+  Bool_t PreProcess(MParList * pList); 
+  Bool_t PostProcess();
+  
+  ClassDef(MShowSpect, 1)	// Fill the raw ADC in the histograms
+};
+
+#endif
+
+
+
Index: branches/start/MagicSoft/Mars/mdatacheck/MViewAdcSpectra.cc
===================================================================
--- branches/start/MagicSoft/Mars/mdatacheck/MViewAdcSpectra.cc	(revision 4308)
+++ branches/start/MagicSoft/Mars/mdatacheck/MViewAdcSpectra.cc	(revision 4308)
@@ -0,0 +1,97 @@
+#include "MViewAdcSpectra.h" 
+
+#include <iostream.h>
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MRawRunHeader.h"
+#include "MRawEvtHeader.h"
+#include "MRawEvtData.h"
+#include "MRawCrateArray.h"
+#include "MTime.h"
+
+#include "MReadTree.h" 
+#include "MDumpEvtHeader.h" 
+#include "MFillAdcSpect.h" 
+#include "MShowSpect.h" 
+#include "MHistosAdc.h" 
+
+MViewAdcSpectra::MViewAdcSpectra() 
+{
+  // default constructor  
+} 
+
+MViewAdcSpectra::~MViewAdcSpectra() 
+{
+  // default destructor  
+} 
+
+
+// ================================================================================
+Bool_t MViewAdcSpectra::PedAdcSpectra ( Char_t *inputfile ) 
+{
+  //   This job reads in the FADC data from all events and fills
+  //   the spectrum for each pmt pixel.
+  //
+
+  cout << "PedAdcSpectra:: Analyse the file " << inputfile << endl ;
+  
+  // create a (empty) list of parameters which can be used by the tasks
+  // and an (empty) list of tasks which should be executed
+  // connect them in the required way. 
+ 
+  MParList *plist  = new MParList;
+  MTaskList *tasks = new MTaskList;
+  plist->AddToList(tasks);
+
+  //   create the data containers for the raw data 
+  
+  MRawRunHeader *runheader = new MRawRunHeader;
+  plist->AddToList(runheader);
+
+  MRawEvtHeader *evtheader = new MRawEvtHeader;
+  plist->AddToList(evtheader);
+  
+  MRawEvtData *evtdata = new MRawEvtData;
+  plist->AddToList(evtdata);
+  
+  MRawCrateArray *cratearray = new MRawCrateArray;
+  plist->AddToList(cratearray);
+  
+  MTime *evttime = new MTime("MTime");
+  plist->AddToList(evttime);
+
+  MHistosAdc *histosAdc = new MHistosAdc() ; 
+  plist->AddToList( histosAdc ) ; 
+  
+  //    set up the tasks for this job
+
+  MReadTree *readin  =  new MReadTree ( inputfile, "Data") ; 
+  tasks->AddToList( readin ) ; 
+
+  //  MDumpEvtHeader *dumpheader = new MDumpEvtHeader() ; 
+  //  tasks->AddToList( dumpheader ) ; 
+ 
+  MFillAdcSpect *fillspect = new MFillAdcSpect() ; 
+  tasks->AddToList( fillspect ) ; 
+
+  MShowSpect *showspect = new MShowSpect( "MHistosAdc" ) ; 
+  tasks->AddToList( showspect ) ;
+
+  //    set up the loop for the processing 
+  
+  MEvtLoop magic;
+  magic.SetParList(plist);
+
+  //    start the loop running 
+
+  magic.Eventloop() ; 
+  
+
+  cout << " End of this job " << endl ; 
+
+  return kTRUE ; 
+
+} 
Index: branches/start/MagicSoft/Mars/mdatacheck/MViewAdcSpectra.h
===================================================================
--- branches/start/MagicSoft/Mars/mdatacheck/MViewAdcSpectra.h	(revision 4308)
+++ branches/start/MagicSoft/Mars/mdatacheck/MViewAdcSpectra.h	(revision 4308)
@@ -0,0 +1,27 @@
+#ifndef MVIEWADCSPECTRA_H
+#define MVIEWADCSPECTRA_H
+
+#ifndef MAGIC_H
+#include "MAGIC.h"
+#endif
+
+class MViewAdcSpectra {
+
+ private:
+  
+ public:
+  
+  MViewAdcSpectra() ; 
+  
+  ~MViewAdcSpectra() ; 
+  
+  Bool_t PedAdcSpectra( Char_t *inputFile ) ; 
+
+  //  Bool_t CrAdcSpectra ( Char_t *inputFile ) ; 
+
+  //  Bool_t PedTdcSpectra( Char_t *inputFile ) ; 
+  //  Bool_t CrTdcSpectra ( Char_t *inputFile ) ; 
+
+} ;
+
+#endif 
Index: branches/start/MagicSoft/Mars/mdatacheck/Makefile
===================================================================
--- branches/start/MagicSoft/Mars/mdatacheck/Makefile	(revision 4308)
+++ branches/start/MagicSoft/Mars/mdatacheck/Makefile	(revision 4308)
@@ -0,0 +1,127 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+# @maintitle
+
+# @code
+
+#
+#  please change all system depend values in the 
+#  config.mk.${OSTYPE} file 
+#
+#
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+# @endcode 
+
+# @code 
+
+LIB   = libmdatacheck.a
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../ -I../mbase -I../mraw
+
+#
+#  ----->>>   root libraries
+#
+
+ROOTLIBS   =  `root-config --libs`
+ROOTGLIBS  =  `root-config --glibs`
+ROOTCFLAGS =  `root-config --cflags`
+
+#
+#  compiler flags
+#
+
+CXXFLAGS  = $(ROOTCFLAGS) $(INCLUDES) $(OPTIM) $(DEBUG)
+CFLAGS    = $(CXXFLAGS)
+FFLAGS    = $(CXXFLAGS)
+
+#------------------------------------------------------------------------------
+
+#.SILENT:
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+
+SRCFILES = MViewAdcSpectra.cc \
+	   MFillAdcSpect.cc \
+	   MDumpEvtHeader.cc \
+	   MShowSpect.cc \
+	   MHistosAdc.cc \
+	   MGDisplayAdc.cc
+
+SRCS    = $(SRCFILES)
+HEADERS = $(SRCFILES:.cc=.h)
+OBJS    = $(SRCFILES:.cc=.o) 
+
+############################################################
+
+all: $(LIB)
+
+depend:
+	@makedepend $(SRCS) $(INCLUDES) $(ROOTCFLAGS) \
+        -f../Makefile.depend 2> kk.kk ; cat kk.kk
+
+$(LIB): $(OBJS) DataCheckCint.o
+	@echo " - Building Library $(LIB) ... "
+	$(AR) $(LIB) *.o
+
+DataCheckCint.cc: $(HEADERS) 
+	@echo 
+	@echo " - Generating dictionary DataCheckCint.cc ..."
+
+	$(ROOTSYS)/bin/rootcint -f DataCheckCint.cc \
+	-c $(INCLUDES) $(HEADERS) DataCheckIncl.h DataCheckLinkDef.h 
+
+.cxx.o:	
+	@echo " - Compiling " $<
+	$(CXX) $(CXXFLAGS) -c $< -o $@
+
+.cc.o:	
+	@echo " - Compiling " $<
+	$(CXX) $(CXXFLAGS) -c $< -o $@
+
+.c.o:	
+	@echo " - Compiling " $<
+	$(CC) $(CFLAGS) -c $< -o $@
+
+#
+# The cleaning facility
+#
+
+rmlib:	
+	@echo "Removing libraries..."
+	@rm -f lib*.a
+
+rmcint:	
+	@echo "Removing cint-stuff..."
+	@rm -f DataCheckCint.*
+
+rmobjs:	
+	@echo "Removing object files..."
+	@rm -f *.o
+
+rmbin:	
+	@echo "Removing binary files..."
+	@rm -f core
+
+
+clean:	rmlib rmcint rmobjs rmbin
+
+mrproper:	clean
+	@echo "Removing *~ kk.kk html/..."
+	@rm -f *~ kk.kk
+
+cflags: 
+	@echo $(INCLUDES) $(CXXFLAGS)
+
+# @endcode
+
Index: branches/start/MagicSoft/Mars/mgui/GuiIncl.h
===================================================================
--- branches/start/MagicSoft/Mars/mgui/GuiIncl.h	(revision 4308)
+++ branches/start/MagicSoft/Mars/mgui/GuiIncl.h	(revision 4308)
@@ -0,0 +1,12 @@
+#ifndef __CINT__
+
+#include <TGButton.h>       // TGPictureButton
+#include <TGTab.h>          // TGTab
+#include <TGMenu.h>         // TGPopupMenu
+#include <TGMsgBox.h>       // TGMsgBox
+#include <TGListBox.h>      // TGListBox
+#include <TGListView.h>     // TGListBox
+#include <TGSplitter.h>     // TGHorizontal3DLine
+#include <TGFSContainer.h>  // TGFileContainer
+
+#endif // __CINT__
Index: branches/start/MagicSoft/Mars/mgui/GuiLinkDef.h
===================================================================
--- branches/start/MagicSoft/Mars/mgui/GuiLinkDef.h	(revision 4308)
+++ branches/start/MagicSoft/Mars/mgui/GuiLinkDef.h	(revision 4308)
@@ -0,0 +1,11 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MGMarsMain;
+#pragma link C++ class MGDataCheckMain;
+//#pragma link C++ class MDumpEvtHeader;
+
+#endif
Index: branches/start/MagicSoft/Mars/mgui/MGDataCheckMain.cc
===================================================================
--- branches/start/MagicSoft/Mars/mgui/MGDataCheckMain.cc	(revision 4308)
+++ branches/start/MagicSoft/Mars/mgui/MGDataCheckMain.cc	(revision 4308)
@@ -0,0 +1,439 @@
+#include "MGDataCheckMain.h"
+
+#include <TSystem.h>        // gSystem
+
+#include <TGTab.h>          // TGTab
+#include <TGMenu.h>         // TGPopupMenu
+#include <TGButton.h>       // TGTextButton
+#include <TGMsgBox.h>       // TGMsgBox
+#include <TGListBox.h>      // TGListBox
+#include <TGFSContainer.h>  // TGFileContainer
+
+// FIXME: Move to MAGIC.h
+#define S_ISDIR(m) (((m)&(0170000)) == (0040000))  
+
+ClassImp(MGDataCheckMain)
+
+MGDataCheckMain::MGDataCheckMain(const TGWindow *p, const TGWindow *main, 
+                            UInt_t w, UInt_t h ) 
+        : TGTransientFrame(p, main, w, h ) 
+{
+  //
+  //    Main window to controll the october test
+  //
+
+  //    set non-gui members to starting values 
+
+  sprintf ( fInputFile, "\n" ) ; 
+
+  //
+  //    First create the MenuBar.   
+  //
+
+  //     Layout objects for menue. 
+
+  fLayMenuBar = new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2 ) ; 
+  fLayMenuItem = new TGLayoutHints ( kLHintsTop | kLHintsLeft , 0, 4, 0, 0 ) ; 
+  
+  //  crate the menu bar
+
+  fFileMenu = new TGPopupMenu ( fClient->GetRoot() ) ; 
+  fFileMenu->AddEntry ("Close", M_FILE_CLOSE ) ; 
+  fFileMenu->Associate(this) ; 
+  
+  //  the button messages are handled by main frame (this) 
+
+  fMenuBar = new TGMenuBar ( this, 1, 1, kHorizontalFrame ) ; 
+  fMenuBar->AddPopup("File", fFileMenu, fLayMenuItem ) ;   
+  AddFrame(fMenuBar, fLayMenuBar ) ; 
+  
+  //
+  //    Create the top window with a lot of buttons 
+  //
+
+  fFrameTop = new TGCompositeFrame (this, 300,100, kVerticalFrame ) ; 
+  
+  fTop1 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ; 
+   
+  fFrameTop->AddFrame (fTop1, new TGLayoutHints(kLHintsCenterX, 10, 10, 5, 5) );
+
+  fTop2 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ; 
+ 
+  fButPedADC = new TGTextButton(fTop2, "ADC Spectra of Pedestals", M_BUTTON_PEDADC );
+  fButPedADC->Associate(this) ;   
+  fTop2->AddFrame (fButPedADC, new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 10, 5, 5) );
+  
+  fButCrADC = new TGTextButton(fTop2, "ADC Specta of Cosmics", M_BUTTON_CRADC );
+  fButCrADC->Associate(this) ;   
+  fTop2->AddFrame (fButCrADC, new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 10, 5, 5) );
+
+  fFrameTop->AddFrame (fTop2, new TGLayoutHints(kLHintsCenterX, 10, 10, 5, 5) );
+
+  fTop3 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ; 
+ 
+  fButPedTDC = new TGTextButton(fTop3, "TDC Spectra of Pedestals", M_BUTTON_PEDTDC );
+  fButPedTDC->Associate(this) ;   
+  fTop3->AddFrame (fButPedTDC, new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 10, 5, 5) );
+  
+  fButCrTDC = new TGTextButton(fTop3, "TDC Specta of Cosmics", M_BUTTON_CRTDC );
+  fButCrTDC->Associate(this) ;   
+  fTop3->AddFrame (fButCrTDC, new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 10, 5, 5) );
+
+  fFrameTop->AddFrame (fTop3, new TGLayoutHints(kLHintsCenterX, 10, 10, 5, 5) );
+
+  AddFrame(fFrameTop, new TGLayoutHints (kLHintsTop ) ) ;   
+
+
+  //
+  //    Create the low window with a tabs in it
+  //
+
+  fFrameLow = new TGCompositeFrame (this, 300,100, kHorizontalFrame ) ; 
+  
+  fLayTab = new TGLayoutHints ( kLHintsExpandX   , 5, 5, 5, 5 ) ;
+
+  //    create the first tab
+
+  fTab = new TGTab ( fFrameLow, 400, 400 ) ;   
+
+  TGCompositeFrame *tf = fTab->AddTab("Input File") ; 
+  
+  fTabF1 = new TGCompositeFrame (tf, 100, 100, kHorizontalFrame) ; 
+  //  tf->AddFrame(fTabF1, fLayTab ) ; 
+
+  
+  fTabF1a = new TGCompositeFrame (tf, 100, 100, kHorizontalFrame) ; 
+  tf->AddFrame(fTabF1a,  new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ; 
+
+  fTabF1b = new TGCompositeFrame (tf, 100, 100, kVerticalFrame) ; 
+  //  tf->AddFrame(fTabF1b,  new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY  , 5, 5, 5, 5 ) ) ; 
+  tf->AddFrame(fTabF1b,  new TGLayoutHints ( kLHintsExpandX | kLHintsExpandY  , 5, 5, 5, 5 ) ) ; 
+
+  
+  fDir = new TGListBox(fTabF1a, -1) ; 
+  fDir->Resize(350,20) ;
+  char temp[100] ; 
+  //  sprintf ( temp, "%s", START_DIRECTORY ) ; 
+  sprintf ( temp, "%s", gSystem->WorkingDirectory()  ) ; 
+  fDir->AddEntry(temp, 1) ; 
+  fTabF1a->AddFrame( fDir, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ; 
+
+
+  fPicCdup = fClient->GetPicture("tb_uplevel.xpm") ; 
+  fCdup = new TGPictureButton(fTabF1a, fPicCdup, M_PBUTTON_CDIR_UP ) ; 
+  fCdup->SetToolTipText("One Level up!") ; 
+  fCdup->Associate(this) ; 
+  fTabF1a->AddFrame (fCdup, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5) ) ; 
+
+  fPicList = fClient->GetPicture("tb_list.xpm") ; 
+  fListMode = new TGPictureButton(fTabF1a, fPicList, M_PBUTTON_LIST_MODE ) ; 
+  fListMode->SetToolTipText("List Mode") ; 
+  fListMode->Associate(this) ; 
+  fListMode->SetState(kButtonUp) ; 
+  fListMode->AllowStayDown(kTRUE) ; 
+  fListMode->AllowStayDown(kTRUE) ;  fTabF1a->AddFrame (fListMode, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5) ) ;
+
+  fPicDetail = fClient->GetPicture("tb_details.xpm") ; 
+  fDetail = new TGPictureButton(fTabF1a, fPicDetail, M_PBUTTON_DETAIL_MODE ) ; 
+  fDetail->SetToolTipText("Details Mode") ; 
+  fDetail->Associate(this) ; 
+  fDetail->SetState(kButtonEngaged) ; 
+  fDetail->AllowStayDown(kTRUE) ; 
+  fTabF1a->AddFrame (fDetail, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5) ) ; 
+
+    
+  fFileView = new TGListView(fTabF1b, 540, 380 ) ; 
+  fFileCont = new TGFileContainer(fFileView->GetViewPort(), 100, 100,
+				  kVerticalFrame, fgWhitePixel) ; 
+
+  fFileCont->Associate(this) ; 
+  fFileView->GetViewPort()->SetBackgroundColor(fgWhitePixel) ; 
+  fFileView->SetContainer(fFileCont) ; 
+  fFileCont->SetFilter("*") ; 
+  //  fFileCont->ChangeDirectory(START_DIRECTORY) ; 
+  fFileCont->ChangeDirectory(gSystem->WorkingDirectory()) ; 
+  fFileView->SetViewMode(kLVDetails); 
+  fFileCont->Sort(kSortByName) ; 
+  
+  fTabF1b->AddFrame(fFileView, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 5, 5, 5, 5) ) ; 
+
+  tf->AddFrame(fTabF1, fLayTab) ;
+ 
+  fFrameLow->AddFrame ( fTab, new TGLayoutHints(kLHintsBottom | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5) ); 
+
+  AddFrame(fFrameLow, new TGLayoutHints (kLHintsExpandX|kLHintsExpandY) ) ; 
+
+  //
+  //   Map the window, set up the layout, etc. 
+  //
+
+  SetWMSizeHints(400, 650, 1000, 1000, 10, 10 ) ;      // set the smallest and biggest size of the Main frame
+
+  MapSubwindows();
+  
+  Layout();
+  
+  SetWindowName("DataCheck Window");
+  SetIconName("DataCheck");
+  
+  MapWindow();
+
+} 
+
+
+// ======================================================================
+// ======================================================================
+
+MGDataCheckMain::~MGDataCheckMain()
+{
+  //delete  fPicCdup, fPicList, fPicDetail; 
+  delete  fLayTab, fLayMenuBar, fLayMenuItem; 
+  delete  fFileView; 
+  delete  fFileCont; 
+  delete  fCdup, fListMode, fDetail; 
+  delete  fDir ; 
+  delete  fTabF1b, fTabF1a, fTabF1; 
+  delete  fButPedADC, fButCrADC, fButPedTDC, fButCrTDC; 
+  delete  fTop3, fTop2, fTop1; 
+  delete  fTab; 
+  delete  fFrameTop, fFrameLow ; 
+  delete  fFileMenu; 
+  delete  fMenuBar; 
+
+} 
+
+
+// ======================================================================
+// ======================================================================
+
+void MGDataCheckMain::CloseWindow()
+{
+   // Got close message for this MainFrame. Calls parent CloseWindow()
+   // (which destroys the window) and terminate the application.
+   // The close message is generated by the window manager when its close
+   // window menu item is selected.
+
+  delete this ; 
+}
+
+
+// ======================================================================
+// ======================================================================
+
+Bool_t MGDataCheckMain::InputFileSelected() 
+{
+  //   Checks if there is a selected input root file
+  
+  if ( strcmp ( fInputFile, "\n") == 0 )
+    { 
+      return ( kFALSE ) ; 
+    } 
+  
+  return (kTRUE) ; 
+} 
+
+
+// ======================================================================
+// ======================================================================
+
+Bool_t MGDataCheckMain::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
+{     
+  // Process events generated by the buttons in the frame.
+  
+  Int_t   buttons = 4, retval = 0 ; 
+  Char_t  wort[100] ;
+  Char_t  extens[5] ;
+  Char_t  command[110] ;
+ 
+  TGFileItem *item ;     // to process items in the file view container
+  void *np = NULL ;      // null pointer
+
+  switch (GET_MSG(msg)) 
+    {
+    case kC_COMMAND:
+      switch (GET_SUBMSG(msg)) 
+	{
+	case kCM_BUTTON:
+	  
+	  switch (parm1)
+	    {  
+
+	    case M_BUTTON_PEDADC:
+	      	
+	      if ( InputFileSelected() == kFALSE ) {              // it is not selected
+		
+		new TGMsgBox(fClient->GetRoot(), this, "ERROR!", 
+			     "No Input (root) File selected!", kMBIconExclamation, buttons, &retval);
+		break ; 
+	      }      
+	      
+	      fViewAdc.PedAdcSpectra(fInputFile) ; 
+
+	      break ; 
+		  
+
+	    case M_BUTTON_CRADC:
+	      
+	      if ( InputFileSelected() == kFALSE ) {              // it is not selected
+		
+		new TGMsgBox(fClient->GetRoot(), this, "ERROR!", 
+			     "No Input (root) File selected!", kMBIconExclamation, buttons, &retval);
+		break ; 
+	      }
+	      
+	      //	      fOctober.CrAdcSpectra(fInputFile) ; 
+
+	      break ; 
+      
+	    case M_BUTTON_PEDTDC:
+	      
+	      if ( InputFileSelected() == kFALSE ) {              // it is not selected
+		
+		new TGMsgBox(fClient->GetRoot(), this, "ERROR!", 
+			     "No Input (root) File selected!", kMBIconExclamation, buttons, &retval);
+		break ; 
+	      }
+	      
+	      //	      fOctober.PedTdcSpectra(fInputFile) ; 
+
+	      break ; 
+      
+	    case M_BUTTON_CRTDC:
+	      
+	      if ( InputFileSelected() == kFALSE ) {              // it is not selected
+		
+		new TGMsgBox(fClient->GetRoot(), this, "ERROR!", 
+			     "No Input (root) File selected!", kMBIconExclamation, buttons, &retval);
+		break ; 
+	      }
+	      
+	      //	      fOctober.CrTdcSpectra(fInputFile) ; 
+
+	      break ; 
+      
+	    case M_PBUTTON_CDIR_UP :
+
+	      //  goto the parent directory
+	      
+	      gSystem->ChangeDirectory("..") ; 
+	      fDir->RemoveEntry(1) ; 
+	      sprintf (wort, "%s", gSystem->WorkingDirectory() ) ; 
+	      fDir->AddEntry(wort,1) ; 
+	      fDir->MapSubwindows() ; 
+	      fDir->Layout() ; 
+	      fFileCont->ChangeDirectory( wort ) ; 
+	      fFileCont->DisplayDirectory() ; 
+	      
+	      break ; 
+	    
+	    case M_PBUTTON_LIST_MODE:
+	      fFileView->SetViewMode(kLVList) ; 
+	      fDetail->SetState(kButtonUp) ; 
+	      
+	      break ; 
+	      
+	    case M_PBUTTON_DETAIL_MODE:
+	      fFileView->SetViewMode(kLVDetails) ; 
+	      fListMode->SetState(kButtonUp) ; 
+	      
+	      break ;
+	      
+	    default:
+	      break ;
+	    } 
+
+	case kCM_MENU:
+
+	  switch (parm1) {
+	  case M_FILE_CLOSE:
+	    CloseWindow() ; 
+
+	    break; 
+	  }
+	  break ;
+	  
+	default:
+	  break ;
+	  
+	}
+      
+    case kC_CONTAINER: 
+      switch (GET_SUBMSG(msg)) {
+	
+	//      case kCT_ITEMCLICK:
+	// 	printf ("itemclick\n"); 
+	//      break; 
+	
+      
+      case kCT_ITEMDBLCLICK: 
+	//
+	//  process the double click in the file view container
+	//
+	
+	if ( parm1 == kButton1) {
+	  if ( fFileCont->NumSelected() == 1 ) {   
+	    //
+	    //  one file selected
+	    //	  
+	    item = (TGFileItem *) fFileCont->GetNextSelected(&np) ; 
+	    
+	    if ( S_ISDIR(item->GetType()) )   // file is directory
+	      {  
+		//  goto directory 
+		
+		sprintf (wort, "%s", item->GetItemName()->GetString()) ;
+		fFileCont->ChangeDirectory ( wort ) ; 
+		gSystem->ChangeDirectory( wort ) ; 
+		
+		sprintf (wort, "%s", gSystem->WorkingDirectory() ) ; 
+		fDir->RemoveEntry(1) ; 
+		fDir->AddEntry( wort, 1 ) ; 
+		fDir->MapSubwindows() ; 
+		fDir->Layout() ; 
+	      }
+	    else                              // file is no directory, is a file 
+	      { 
+		sprintf (wort, "%s", item->GetItemName()->GetString() ) ; 
+	    
+		//    determine the file type by extensions
+		
+		for (Int_t i = 0 ; i<5; i++) 
+		  extens[i] = '\0' ; 
+		
+		for ( Int_t i=0; wort[i] != '\0'; i++) {
+		  if ( wort[i] == '.') {
+		    strncpy (extens, &wort[i+1], 4 ) ; 
+		    break ; 
+		  }
+		}
+		
+		if ( ! strcmp(extens, "ps") ) {              //     postscript file
+		  sprintf ( command, "gv %s/%s &", 
+			    gSystem->WorkingDirectory(), 
+			    wort ) ; 
+		  gSystem->Exec(command) ; 
+		  break ; 
+		}
+		else if  ( ! strcmp(extens, "root") ) {      //     root file
+		  sprintf ( fInputFile, "%s/%s" , gSystem->WorkingDirectory(), wort ) ;  
+
+		  printf (" %s \n", fInputFile ) ; 
+		  break ; 
+		}
+		
+	      } 
+	  }
+	}
+	break; 
+	
+      default:
+	break ;
+      }
+      
+      
+      
+    default:
+      break;
+    }
+  return kTRUE;
+} 
Index: branches/start/MagicSoft/Mars/mgui/MGDataCheckMain.h
===================================================================
--- branches/start/MagicSoft/Mars/mgui/MGDataCheckMain.h	(revision 4308)
+++ branches/start/MagicSoft/Mars/mgui/MGDataCheckMain.h	(revision 4308)
@@ -0,0 +1,107 @@
+#ifndef MGDATACHECKMAIN_H
+#define MGDATACHECKMAIN_H
+
+#ifndef MAGIC_H
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TGFrame
+#include <TGFrame.h>
+#endif
+
+#ifndef MVIEWADCSPECTRA_H
+#include "MViewAdcSpectra.h"
+#endif
+
+class TGMenuBar;
+class TGPopupMenu;
+class TGTab;
+class TGTextButton;
+class TGListBox;
+class TGPictureButton;
+class TGFileContainer;
+class TGListView;
+
+enum CommandDataChecker {
+  M_FILE_CLOSE , 
+  M_BUTTON_PEDADC, 
+  M_BUTTON_CRADC, 
+  M_BUTTON_PEDTDC, 
+  M_BUTTON_CRTDC, 
+
+  M_PBUTTON_CDIR_UP, 
+  M_PBUTTON_LIST_MODE, 
+  M_PBUTTON_DETAIL_MODE 
+} ; 
+
+
+class MGDataCheckMain : public TGTransientFrame {
+ private:
+  
+  //
+  // Create a main frame with a number of different buttons.
+  //
+
+  //   some member not connected with Gui 
+  
+  Char_t            fInputFile[256] ; 
+  MViewAdcSpectra   fViewAdc ; 
+
+  //  the things for the menu bar 
+    
+  TGMenuBar         *fMenuBar ; 
+  TGPopupMenu       *fFileMenu ;
+
+  //   divide the Window in two different parts
+  
+  TGCompositeFrame  *fFrameTop ;   // top part of the main window
+  TGCompositeFrame  *fFrameLow ;   // low part of the main window
+  TGTab             *fTab      ;   // different tabs in the low window
+  
+  //     the horizontal frame in the top part
+
+  TGHorizontalFrame *fTop1, *fTop2, *fTop3 ; 
+  
+  //   the buttons in the Top Part
+  
+  TGTextButton      *fButPedADC, *fButCrADC  ; 
+  TGTextButton      *fButPedTDC, *fButCrTDC  ; 
+  
+  //   the things in the file selector
+
+  TGCompositeFrame  *fTabF1 ;                       // first tab of low part 
+  TGCompositeFrame  *fTabF1a, *fTabF1b ;            // subpart of the file selector in low window
+  TGListBox         *fDir ; 
+  TGPictureButton   *fCdup, *fListMode, *fDetail ; 
+  TGFileContainer   *fFileCont ; 
+  TGListView        *fFileView ;
+
+  //     Layout hints for different uses 
+  
+  TGLayoutHints     *fLayMenuBar, *fLayMenuItem ; 
+  TGLayoutHints     *fLayTab ; 
+  
+  //     some icons and pictures often used
+  
+  const TGPicture   *fPicCdup;   //!
+  const TGPicture   *fPicList;   //!
+  const TGPicture   *fPicDetail; //!
+  
+ public: 
+  MGDataCheckMain(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h) ;
+  
+  ~MGDataCheckMain(); 
+  
+  void   CloseWindow()  ; 
+
+  Bool_t InputFileSelected() ; 
+  
+  Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+  ClassDef(MGDataCheckMain, 1)
+
+} ; 
+
+#endif
+
+
Index: branches/start/MagicSoft/Mars/mgui/MGMarsMain.cc
===================================================================
--- branches/start/MagicSoft/Mars/mgui/MGMarsMain.cc	(revision 4308)
+++ branches/start/MagicSoft/Mars/mgui/MGMarsMain.cc	(revision 4308)
@@ -0,0 +1,232 @@
+#include "MGMarsMain.h"
+
+#include <TApplication.h>  // gROOT->GetApplication()->...
+
+#include <TGTab.h>         // TGTab
+#include <TGMenu.h>        // TGPopupMenu
+#include <TGMsgBox.h>      // TGMsgBox
+#include <TGButton.h>      // TGPictureButton
+#include <TGSplitter.h>    // TGHorizontal3DLine
+
+#include "MGDataCheckMain.h"
+
+ClassImp(MGMarsMain)
+
+MGMarsMain::MGMarsMain(const TGWindow *p, UInt_t w, UInt_t h)
+  : TGMainFrame(p, w, h)
+{ 
+  //    First create the MenuBar.   
+  
+  //     Layout objects for menue. 
+
+  fLayMenuBar = new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2 ) ; 
+  fLayMenuItem = new TGLayoutHints ( kLHintsTop | kLHintsLeft , 0, 4, 0, 0 ) ; 
+  
+  //  crate the menu bar
+  
+  fFileMenu = new TGPopupMenu ( fClient->GetRoot() ) ; 
+  fFileMenu->AddEntry ("Exit", M_FILE_EXIT ) ; 
+  fFileMenu->Associate(this) ; 
+  
+  //  the button messages are handled by main frame (this) 
+  
+  fMenuBar = new TGMenuBar ( this, 1, 1, kHorizontalFrame ) ; 
+  fMenuBar->AddPopup("File", fFileMenu, fLayMenuItem ) ;   
+  AddFrame(fMenuBar, fLayMenuBar ) ; 
+
+  fLineSep = new TGHorizontal3DLine(this) ; 
+  AddFrame(fLineSep, new TGLayoutHints(kLHintsTop | kLHintsExpandX) );
+  
+  //   set up the top part of the main window with the logos
+
+  fTop = new TGHorizontalFrame (this, 300, 100 ) ;
+
+  fPicMagic = new TGPictureButton(fTop, 
+                                  gClient->GetPicture("magiclogo.xpm"), M_PICTURE_MAGIC );
+  fPicMagic->Associate(this) ; 
+  fTop->AddFrame ( fPicMagic, new TGLayoutHints(kLHintsLeft, 10., 10., 20., 10.) ) ; 
+
+  fPicMars = new TGPictureButton(fTop, 
+				 gClient->GetPicture("marslogo.xpm"), M_PICTURE_MARS );
+  fPicMars->Associate(this) ;
+  fTop->AddFrame ( fPicMars, new TGLayoutHints(kLHintsLeft, 10., 10., 10., 10.) ) ; 
+
+  AddFrame(fTop, new TGLayoutHints(kLHintsTop | kLHintsExpandX ) );  
+  
+  //  a seperator 
+
+  fLineSep2 = new TGHorizontal3DLine(this) ; 
+  AddFrame(fLineSep2, new TGLayoutHints(kLHintsTop | kLHintsExpandX) );
+
+  //   the low part of the frame 
+
+  fLow = new TGHorizontalFrame (this, 300, 100 ) ;
+
+  //    create the first tab
+
+  fTab = new TGTab ( fLow, 400, 400 ) ;   
+
+  TGCompositeFrame *tf = fTab->AddTab("Control") ; 
+ 
+  fTabF1 = new TGVerticalFrame (tf, 300, 100) ; 
+
+  tf->AddFrame(fTabF1, new TGLayoutHints(kLHintsTop | kLHintsExpandX) ) ; 
+
+  //     the buttons to go in the new window
+
+  fTabF2 = new TGVerticalFrame (tf, 300, 100) ; 
+  
+  fButLayout  = new TGLayoutHints(kLHintsTop | kLHintsCenterX , 10, 10, 10, 10) ; 
+
+  fButEvtDisp = new TGTextButton(fTabF2, "EventDisplay", M_BUTTON_EVTDISP  );
+  fButEvtDisp->Associate(this) ;  
+  fTabF2->AddFrame(fButEvtDisp, fButLayout ) ; 
+ 
+  fButDataCheck = new TGTextButton(fTabF2, "Data Check", M_BUTTON_DATACHECK  );
+  fButDataCheck->Associate(this) ;
+  fTabF2->AddFrame(fButDataCheck, fButLayout ) ; 
+
+  fButAnalys = new TGTextButton(fTabF2, "Analysis", M_BUTTON_ANALYSE  );
+  fButAnalys->Associate(this) ;
+  fTabF2->AddFrame(fButAnalys, fButLayout ) ; 
+
+  fButMonteCarlo = new TGTextButton(fTabF2, "MonteCarlo", M_BUTTON_MONTECARLO  );
+  fButMonteCarlo->Associate(this) ;
+  fTabF2->AddFrame(fButMonteCarlo, fButLayout ) ; 
+
+
+   
+
+  tf->AddFrame(fTabF2, new TGLayoutHints(kLHintsTop | kLHintsExpandX) ) ; 
+  
+  
+
+  fLow->AddFrame ( fTab, new TGLayoutHints(kLHintsBottom | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5) );   
+  AddFrame(fLow, new TGLayoutHints(kLHintsTop | kLHintsExpandX ) );
+  
+  //   Map the window, set up the layout, etc. 
+  
+  SetWMSizeHints(400, 650, 1000, 1000, 10, 10 ) ;  // set the smallest and biggest size of the Main frame
+  
+  MapSubwindows();
+  
+  Layout();
+  
+  SetWindowName("MARS Main Window");
+  SetIconName("MARS");
+  
+  MapWindow();
+
+} 
+
+// ======================================================================
+
+MGMarsMain::~MGMarsMain()
+{
+  
+  delete  fButLayout, fLayMenuBar, fLayMenuItem ; 
+  delete  fButEvtDisp, fButDataCheck, fButAnalys, fButMonteCarlo; 
+  delete  fPicMagic, fPicMars; 
+  delete  fTabF1, fTabF2; 
+  delete  fTab; 
+  delete  fLow, fTop; 
+  delete  fLineSep2, fLineSep; 
+  delete  fFileMenu; 
+  delete  fMenuBar; 
+}  
+// ======================================================================
+
+void MGMarsMain::CloseWindow()
+{
+   // Got close message for this MainFrame. Calls parent CloseWindow()
+   // (which destroys the window) and terminate the application.
+   // The close message is generated by the window manager when its close
+   // window menu item is selected.
+
+   TGMainFrame::CloseWindow();
+   gROOT->GetApplication()->Terminate(0)  ; 
+}
+
+Bool_t MGMarsMain::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
+{     
+  // Process events generated by the buttons in the frame.
+  //  printf (" process Message \n" ) ; 
+
+  Int_t   buttons = 4, retval = 0 ; 
+
+  
+  switch (GET_MSG(msg)) 
+    {
+    case kC_COMMAND:
+      switch (GET_SUBMSG(msg)) 
+	{
+	case kCM_BUTTON:
+	  
+	  switch (parm1)
+	    {  
+
+	    case M_BUTTON_EVTDISP:
+	      new TGMsgBox(fClient->GetRoot(), this,
+			   "WARNING!", 
+			   "EventDisplay not yet implemented!", 
+			   kMBIconExclamation, buttons, &retval);
+	      break ;
+	      
+	    case M_BUTTON_DATACHECK:
+	      new MGDataCheckMain(fClient->GetRoot(), this, 1, 1 ) ; 
+	      break ;
+
+	    case M_BUTTON_ANALYSE:
+	      new TGMsgBox(fClient->GetRoot(), this,
+			   "WARNING!", 
+			   "Analysis not yet implemented!", 
+			   kMBIconExclamation, buttons, &retval);
+	      break ;
+
+	    case M_BUTTON_MONTECARLO:
+	      new TGMsgBox(fClient->GetRoot(), this,
+			   "WARNING!", 
+			   "MONTECARLO not yet implemented!", 
+			   kMBIconExclamation, buttons, &retval);
+	      break ;
+
+	    case M_PICTURE_MAGIC:
+	      new TGMsgBox(fClient->GetRoot(), this,
+			   "WARNING!", 
+			   "Please open a Netscape to the MAGIC homepage", 
+			   kMBIconExclamation, buttons, &retval);
+	      break ;
+
+	    case M_PICTURE_MARS:
+	      new TGMsgBox(fClient->GetRoot(), this,
+			   "WARNING!", 
+			   "Please open a Netscape to the MARS homepage", 
+			   kMBIconExclamation, buttons, &retval);
+	      break ;
+
+	      
+	    default:
+	      break ; 
+	    } 
+
+
+	case kCM_MENU:
+	
+	  switch (parm1) {
+	  case M_FILE_EXIT: 
+	    CloseWindow() ;
+	    break; 
+	  }
+
+
+	default:
+	  break ;
+	}
+    
+    default:
+      break ;
+    }
+
+   return kTRUE;
+  
+}
Index: branches/start/MagicSoft/Mars/mgui/MGMarsMain.h
===================================================================
--- branches/start/MagicSoft/Mars/mgui/MGMarsMain.h	(revision 4308)
+++ branches/start/MagicSoft/Mars/mgui/MGMarsMain.h	(revision 4308)
@@ -0,0 +1,79 @@
+#ifndef MGMARSMAIN_H
+#define MGMARSMAIN_H
+
+#ifndef MAGIC_H
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TGFrame
+#include <TGFrame.h>
+#endif
+
+class TGTab;
+class TGMenuBar;
+class TGPopupMenu;
+class TGTextButton;
+class TGPictureButton;
+class TGHorizontal3DLine;
+
+enum CommandIdentifiers {
+  M_FILE_EXIT  ,
+  M_FILE_ABOUT  ,
+
+  M_PICTURE_MAGIC , 
+  M_PICTURE_MARS ,
+
+  M_BUTTON_EVTDISP ,
+  M_BUTTON_DATACHECK ,
+  M_BUTTON_ANALYSE ,
+  M_BUTTON_MONTECARLO 
+} ; 
+
+
+class MGMarsMain : public TGMainFrame {
+ private:
+  
+  //
+  // Create a main frame with a number of different buttons.
+  //
+
+  //  the things for the menu bar 
+    
+  TGMenuBar         *fMenuBar ; 
+  TGPopupMenu       *fFileMenu ;
+  TGLayoutHints     *fLayMenuBar, *fLayMenuItem ; 
+  TGHorizontal3DLine *fLineSep ; 
+
+  //   divide the Window in two different parts
+  
+  TGHorizontalFrame  *fTop ;   // top part of the main window
+  TGHorizontal3DLine *fLineSep2 ;
+  TGHorizontalFrame  *fLow ;   // low part of the main window
+  TGTab              *fTab ;   // different tabs in the low window
+  
+  //   the object in the top part of the frame
+  
+  TGPictureButton *fPicMagic, *fPicMars ;
+ 
+  //   the object in the low part of the frame
+ 
+  TGVerticalFrame  *fTabF1, *fTabF2 ; 
+  
+  TGTextButton     *fButEvtDisp, *fButDataCheck, *fButAnalys, *fButMonteCarlo ;
+  TGLayoutHints    *fButLayout ; 
+ 
+ public: 
+  MGMarsMain(const TGWindow *p, UInt_t w, UInt_t h) ;
+  
+  ~MGMarsMain(); 
+  
+  void CloseWindow()  ; 
+
+  Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+  ClassDef(MGMarsMain, 1)
+} ; 
+
+#endif
+
+
Index: branches/start/MagicSoft/Mars/mgui/Makefile
===================================================================
--- branches/start/MagicSoft/Mars/mgui/Makefile	(revision 4308)
+++ branches/start/MagicSoft/Mars/mgui/Makefile	(revision 4308)
@@ -0,0 +1,124 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+# @maintitle
+
+# @code
+
+#
+#  please change all system depend values in the 
+#  config.mk.${OSTYPE} file 
+#
+#
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+# @endcode 
+
+# @code 
+
+LIB   = libmgui.a
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mraw -I../mdatacheck
+
+#
+#  ----->>>   root libraries
+#
+
+ROOTLIBS   =  `root-config --libs`
+ROOTGLIBS  =  `root-config --glibs`
+ROOTCFLAGS =  `root-config --cflags`
+
+#
+#  compiler flags
+#
+
+CXXFLAGS  = $(ROOTCFLAGS) $(INCLUDES) $(OPTIM) $(DEBUG)
+CFLAGS    = $(CXXFLAGS)
+FFLAGS    = $(CXXFLAGS)
+
+#------------------------------------------------------------------------------
+
+#.SILENT:
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+
+SRCFILES = MGMarsMain.cc \
+	   MGDataCheckMain.cc
+
+
+SRCS    = $(SRCFILES)
+HEADERS = $(SRCFILES:.cc=.h)
+OBJS    = $(SRCFILES:.cc=.o) 
+
+############################################################
+
+all: $(LIB)
+
+depend:
+	@makedepend $(SRCS) $(INCLUDES) $(ROOTCFLAGS) \
+        -f../Makefile.depend 2> kk.kk ; cat kk.kk
+
+$(LIB): $(OBJS) GuiCint.o
+	@echo " - Building Library $(LIB) ... "
+	$(AR) $(LIB) *.o 
+
+GuiCint.cc: $(HEADERS) 
+	@echo 
+	@echo " - Generating dictionary GuiCint.cc ..."
+
+	$(ROOTSYS)/bin/rootcint -f GuiCint.cc \
+	-c $(INCLUDES) $(HEADERS) GuiIncl.h GuiLinkDef.h 
+
+.cxx.o:	
+	@echo " - Compiling " $<
+	$(CXX) $(CXXFLAGS) -c $< -o $@
+
+.cc.o:	
+	@echo " - Compiling " $<
+	$(CXX) $(CXXFLAGS) -c $< -o $@
+
+.c.o:	
+	@echo " - Compiling " $<
+	$(CC) $(CFLAGS) -c $< -o $@
+
+#
+# The cleaning facility
+#
+
+rmlib:	
+	@echo "Removing libraries..."
+	@rm -f lib*.a
+
+rmcint:	
+	@echo "Removing cint-stuff..."
+	@rm -f GuiCint.*
+
+rmobjs:	
+	@echo "Removing object files..."
+	@rm -f *.o
+
+rmbin:	
+	@echo "Removing binary files..."
+	@rm -f core
+
+
+clean:	rmlib rmcint rmobjs rmbin
+
+mrproper:	clean
+	@echo "Removing *~ kk.kk html/..."
+	@rm -f *~ kk.kk
+
+cflags: 
+	@echo $(INCLUDES) $(CXXFLAGS)
+
+# @endcode
+
