Index: trunk/MagicSoft/Simulation/Corsika/GuiSimone/MainFrameSimone.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Corsika/GuiSimone/MainFrameSimone.cxx	(revision 777)
+++ trunk/MagicSoft/Simulation/Corsika/GuiSimone/MainFrameSimone.cxx	(revision 778)
@@ -1,6 +1,27 @@
 //
-//
-//
-#define  START_DIRECTORY  "."
+////////////////////////////////////////////////////////////////////////////
+//
+// GuiSimone 
+//
+// Graphic User Interface for Simone (SIMultaed ONe Event) 
+//
+// Modification May 2001 by C.Domingo over the existing program:
+//   The header file MainFrameSimone.hxx has been changed: the ifsteam fCerFile
+//     and the string variable fCerFileName are now global  
+//   Some procedures in MainFrameSimone have been adapted to the "one
+//     file per run" Mmcs output
+//
+// GuiSimone reads Mmcs output files (one file per run version) and 
+// displays several histograms for each run and/or each event. Selection
+// of files is made through a window (frame) and graphics are displayed
+// in other windows (subframes)
+//
+// The ROOT package is needed
+//
+////////////////////////////////////////////////////////////////////////////
+//
+//
+
+#define  START_DIRECTORY  "/dat1"
 #define S_ISDIR(m) (((m)&(0170000)) == (0040000))  
 #define PI 3.1415926
@@ -10,5 +31,4 @@
 
 #include "MainFrameSimone.hxx"
-
 
 char NtupName[5][20] = {"WaveLen", "PosY:PosX", "Height", "Time", "DireY:DireX" } ;  
@@ -57,5 +77,5 @@
   fMenuBar = new TGMenuBar ( this, 1, 1, kHorizontalFrame ) ; 
   fMenuBar->AddPopup("File", fFileMenu, fLayMenuItem ) ; 
-  
+   
   AddFrame(fMenuBar, fLayMenuBar ) ; 
 
@@ -114,5 +134,5 @@
   
   fSelectButton = new TGTextButton(fTabF1b, "Select", M_BUTTON_SELECT );
-  fSelectButton->SetToolTipText("To select a path with Mmcs data files!");
+  fSelectButton->SetToolTipText("To select a Cerenkov data output file from Mmcs!");
   fSelectButton->SetState(kButtonDisabled); 
   fSelectButton->Associate(this) ; 
@@ -493,4 +513,13 @@
 // ======================================================================
 // ======================================================================
+//
+////////////////////////////////////////////////////////////////////////////
+//
+// Modification by C.Domingo May 2001
+//
+// Procedure CerFileExist NOT used at present
+//
+////////////////////////////////////////////////////////////////////////////
+//
 
 Bool_t MainFrameSimone::CerFileExist(Char_t *dir)
@@ -583,4 +612,15 @@
 // ======================================================================
 // ======================================================================        
+//
+////////////////////////////////////////////////////////////////////////////
+//
+// Modification by C.Domingo May 2001
+//
+// The fNtupFile is now the cerenkov FILE (not the directory where the
+// Cerenkov files are stored) which contains the information of a 
+// complete RUN
+//
+////////////////////////////////////////////////////////////////////////////
+//
 
 Bool_t MainFrameSimone::CheckNtup()
@@ -593,5 +633,5 @@
     new TGMsgBox(fClient->GetRoot(), this,
 		 "Warning", 
-		 "No Input Path specified\n Do this before!!", 
+		 "No Cerenkov Input File specified\n Do this before!!", 
 		 kMBIconExclamation, buttons, &retval);
     
@@ -600,5 +640,5 @@
   
 
-  if ( ! strcmp ( fInputPath, fNtupPath ) ) {
+  if ( ! strcmp ( fCerFileName, fNtupFile ) ) {
     return (kTRUE) ; 
   }
@@ -615,26 +655,43 @@
 // ======================================================================
 // ======================================================================
-
+//
+////////////////////////////////////////////////////////////////////////////
+//
+// Modification by C.Domingo May 2001
+//
+// Major changes to procedure ReadDataToNtup
+//   One simone.root file per each RUN file is generated now
+//   One cerenkov file is read instead of all cerenkov files in a given directory
+//   All events in the cerenkov file selected are read, and all the photons of these
+//     events are skipped to proceed to next event
+//   
+//
+////////////////////////////////////////////////////////////////////////////
+//
 Bool_t MainFrameSimone::ReadDataToNtup()
 {
   FILE  *unit ; 
   Char_t  rootfile[256] ; 
-  Char_t  cername[256] ; 
   Char_t  datname[256] ;
   
-  ifstream   cerfile ; 
-  
-  COREventHeader Event ;  
+  Float_t lambda ;
+  Float_t energyofevent ;
+  Int_t iPhotonInShower ;
+  
+  COREventHeader Event ;
+  CORParticle Photon ;
+
+  Int_t buttons = 4, retval ;
   
   fNtup->Reset() ; 
 
-  sprintf (rootfile, "%s/simone.root", fInputPath ) ; 
-
-  //
-  //   check if there is a file simone.root in the directory fInputPath
+  sprintf (rootfile, "%s/simone%s.root", fInputPath, fRunSuffix ) ; 
+
+  //
+  //   check if there is a file simone######.root in the directory fInputPath
   //
   //   if the file is there open it an read the ntuple in, 
-  //   else open all cerenkov files and fill the histograms and store 
-  //   the ntuple as simone.root in the directory fInputPath
+  //   else open the selected cerenkov file and fill the histograms and store 
+  //   the ntuple as simone######.root in the directory fInputPath
   //
 
@@ -663,6 +720,4 @@
 
     //delete hfile ;
-
-    
 
     fNumEvents = (Int_t) fNtup->GetEntries()  ;
@@ -683,44 +738,42 @@
 
     
-    for (int i_cer = 1; i_cer <= 100000; i_cer++ ) {
-
-      //   inform about progress
-      
-      if (!( i_cer %1000) )
-	{
-	  cout << i_cer << endl ; 
-	  sprintf ( datname, "%d", fNumEvents ) ; 
+    fNumEvents = 0 ;
+      
+    fCerFile.open( fCerFileName );
+          
+    if ( fCerFile.bad() ) {         
+      new TGMsgBox(fClient->GetRoot(), this,
+		   "Warning", 
+		   "Could not open Cerenkov file\n file = bad (sataus)", 
+		   kMBIconExclamation, buttons, &retval);
+      return (kFALSE) ;
+    }
+      
+    // Dirty trick to read run header, as by chance it has the same structure 
+    // of an event header
+      
+    Event.read(fCerFile) ;
+      
+    // Now reading the events truly
+      
+    while ( ! (fCerFile.eof() || fCerFile.bad() ) ) { 
+      
+      Event.read( fCerFile );
+      energyofevent = Event.get_energy() ;
+      if (energyofevent == 0) break ;
+      fNumEvents++ ;
+
+      //
+      // Inform about progress
+      //
+
+      if (!( fNumEvents %1000) ) {
+        sprintf ( datname, "%d", fNumEvents ) ; 
 	  
-	  fDirNum->RemoveEntry(1) ; 
-	  fDirNum->AddEntry(datname,1) ; 	    
-	  fDirNum->MapSubwindows() ; 
-	  fDirNum->Layout() ;  
-	}
-      
-      
-      //   create the file names 
-      
-      sprintf ( cername, "%s/cer%06d", fInputPath, i_cer ) ; 
-      sprintf ( datname, "%s/dat%06d", fInputPath, i_cer ) ; 
-      
-      //   try to open the files
-      
-      cerfile.open( cername );
-    
-      if ( cerfile.bad() ) { 
-
-	fNumEvents = i_cer -1 ;
-	
-	sprintf ( datname, "%d", fNumEvents ) ; 
-	
-	fDirNum->RemoveEntry(1) ; 
-	fDirNum->AddEntry(datname,1) ; 	    
-	fDirNum->MapSubwindows() ; 
-	fDirNum->Layout() ;  
-	
-	break ; 
-      }
-      
-      Event.read( cerfile );
+        fDirNum->RemoveEntry(1) ; 
+        fDirNum->AddEntry(datname,1) ; 	    
+        fDirNum->MapSubwindows() ; 
+        fDirNum->Layout() ; 
+      } 
 
       //
@@ -729,19 +782,84 @@
       
       fNtup->Fill( Event.get_primary() ,
-		   Event.get_energy() , 
-		   Event.get_coreX(), 
-		   Event.get_coreY(), 
-		   Event.get_theta(),
-		   Event.get_phi(), 
-		   Event.get_firstInt() ) ;  
-
- 
-      cerfile.close();
-    
+	           Event.get_energy() , 
+	           Event.get_coreX(), 
+	           Event.get_coreY(), 
+	           Event.get_theta(),
+	           Event.get_phi(), 
+	           Event.get_firstInt() ) ;  
+
+      //
+      //   loop over the particles (cerenkov photons) in 
+      //   the file 
+      //
+    
+      iPhotonInShower = 0 ; 
+    
+      while( ! (fCerFile.eof() || fCerFile.bad() )) {
+
+        //
+        //   read in the particles
+        //
+      
+        Photon.read ( fCerFile ) ; 
+      
+        //
+        //   only if the wavelength lambda is greater than 
+        //   1.0 it is a real cerenkov photon 
+        //
+        lambda = Photon.get_wl() ; 
+      
+        //      Photon.print() ; 
+      
+        if ( lambda < 1.0 ) { 
+	  // here we got to the next event reading in all the ZERO 
+	  // from the file 
+	  while ( lambda < 1. && ! (fCerFile.eof() || fCerFile.bad() ) ) { 
+	  
+	    Photon.read ( fCerFile ) ; 
+	    lambda = Photon.get_wl() ;	
+	    //	  cout << lambda << endl ; 
+	  } 
+	
+          //	go back in the file, because when the zeroes have finished
+          //    the following record has already been read as it were
+	  //    a cerenkov foton. The pointer should be repositioned to
+	  //    read the event end record
+	
+          fCerFile.seekg( -28, ios::cur  ) ; 
+	
+	  //  read in the event end record. Again, it has the same structure (by
+	  //  chance) thant the event header
+
+	  Event.read( fCerFile );
+	
+	  break ; 
+        } 
+
+        iPhotonInShower++ ; 
+      
+      }
+    
+      // cout << " Event " << fNumEvents << ": Photons " << iPhotonInShower << endl ;
+
     }
 
+    fCerFile.close();
+      
+    //
+    //  Refresh information on the screen window
+    //
+
+    sprintf ( datname, "%d", fNumEvents ) ; 
+	  
+    fDirNum->RemoveEntry(1) ; 
+    fDirNum->AddEntry(datname,1) ; 	    
+    fDirNum->MapSubwindows() ; 
+    fDirNum->Layout() ;     
+
     //
     //  write Ntuple to the file
     //
+  
     fNtup->Write() ; 
 
@@ -749,4 +867,5 @@
     //  write the root file
     //
+  
     hfile->Write();
     
@@ -754,9 +873,9 @@
   }
 
-
   //
   //    set some value of this class
   //
-  sprintf ( fNtupPath, "%s", fInputPath) ;
+
+  sprintf ( fNtupFile, "%s", fCerFileName) ;
   
   return (kTRUE) ; 
@@ -766,4 +885,17 @@
 // ======================================================================
 // ======================================================================
+//
+////////////////////////////////////////////////////////////////////////////
+//
+// Modification by C.Domingo May 2001
+//
+// Major changes to procedure ReadInEvt
+//   Reads the photons from inside the selected cerenkov file (which contains 
+//     generated for a given run) instead of opening one file per event
+//   Checks if it must read the first event of a file, in such a case the 
+//     file is open
+//   
+////////////////////////////////////////////////////////////////////////////
+//
 
 Bool_t MainFrameSimone::ReadinEvt()
@@ -773,8 +905,5 @@
   Char_t  wort[256] ; 
   FILE  *unit ; 
-  Char_t  filename[256] ; 
-
-  ifstream   cerfile ; 
-  
+
   COREventHeader Event ;   
   CORParticle    Photon ; 
@@ -791,5 +920,5 @@
     new TGMsgBox(fClient->GetRoot(), this,
 		 "Warning", 
-		 "No Input Path specified\n Do this before!!", 
+		 "No Cerenkov Input File specified\n Do this before!!", 
 		 kMBIconExclamation, buttons, &retval);
     
@@ -802,30 +931,47 @@
   }
 
-  sprintf ( filename, "%s/cer%06d", fInputPath, fEvtNb ) ;
-
   fNtupEvt->Reset() ; 
   
   //
-  //   open the file
-  // 
-  
-  cerfile.open( filename );
-    
-  if ( cerfile.bad() ) { 
-
+  //   if first event, open the file and read run header
+  //  
+  
+  if ( fEvtNb == 1) {
+    fCerFile.open( fCerFileName );    
+    if ( fCerFile.bad() ) { 
+
+      new TGMsgBox(fClient->GetRoot(), this,
+  		   "ERROR", 
+		   "Can't open the cer file!!", 
+		   kMBIconExclamation, buttons, &retval);
+    
+      return (kFALSE) ; 
+    }
+
+    // Dirty trick to read run header (see comment in RaedDataToNtup for
+    // further details)
+      
+    Event.read(fCerFile) ;
+      
+  }
+  
+  //
+  //  For all events, read in event header
+  //
+      
+  Event.read( fCerFile );
+  
+  //
+  //  Check for RUN end (an ENDRUN record will return a 0 value of the energy)
+  //
+
+  if (Event.get_energy() == 0) {
     new TGMsgBox(fClient->GetRoot(), this,
-		 "ERROR", 
-		 "Can't open the cer file!!", 
-		 kMBIconExclamation, buttons, &retval);
-    
-    return (kFALSE) ; 
-  }
-
-  //
-  //   read in the header
-  //
-      
-  Event.read( cerfile );
-  
+		"Information", 
+		"End of file detected",
+	        kMBIconAsterisk, buttons, &retval);
+    fCerFile.close () ;
+    return (kFALSE) ;
+  }
 
   //
@@ -860,52 +1006,90 @@
   //   loop over the particles
   //
-  
     
   iPhotonInShower = 0 ; 
-    
-  while( ! (cerfile.eof() || cerfile.bad() )) {
-      
+      
+  while( ! (fCerFile.eof() || fCerFile.bad() )) {
+
     //
     //   read in the particles
     //
       
-    Photon.read ( cerfile ) ; 
-          //
+    Photon.read ( fCerFile ) ; 
+      
+    //
     //   only if the wavelength lambda is greater than 
     //   1.0 it is a real cerenkov photon 
-    //
     
     lambda = Photon.get_wl() ; 
-    
-    if ( lambda < 1.0 ) 
-      break ; 
-    
-    iPhotonInShower++ ; 
-    
-    fNtupEvt->Fill(Photon.get_wl(), 
-		   Photon.get_x(), 
-		   Photon.get_y(), 
-		   Photon.get_h(), 
-		   Photon.get_t(), 
-		   Photon.get_u(), 
-		   Photon.get_v()  ) ; 
-
+ 
+    if ( lambda >= 1.0 ) {     
+      iPhotonInShower++ ; 
+      fNtupEvt->Fill(Photon.get_wl(), 
+		     Photon.get_x(), 
+		     Photon.get_y(), 
+		     Photon.get_h(), 
+		     Photon.get_t(), 
+		     Photon.get_u(), 
+		     Photon.get_v()  ) ;     
     }
-  
-  
+
+    // here we got to the next event reading in all the ZERO 
+    // from the file 
+
+    else {
+      while ( lambda < 1. && ! (fCerFile.eof() || fCerFile.bad() ) ) {     
+       	Photon.read ( fCerFile ) ; 
+	lambda = Photon.get_wl() ;	
+      } 
+	
+      //    go back in the file, because when the zeroes have finished
+      //    the following record has already been read as it were
+      //    a cerenkov foton. The pointer should be repositioned to
+      //    read the event end record
+
+      fCerFile.seekg( -28, ios::cur  ) ; 
+	
+      //  read in the event end record. Again, it has the same structure (by
+      //  chance) thant the event header
+
+      Event.read( fCerFile );
+      break ;
+    }
+
+  }
+    
   //
   //   close the file
   //
-    
-  cerfile.close();
- 
+
   sprintf( wort," %10d", iPhotonInShower ) ; 
-  fInfoNbPhot->SetText( wort ) ; 
-
+  fInfoNbPhot->SetText( wort ) ;      
+
+  //  fCerFile.close();
+  
+  //  sprintf( wort," %10d", iPhotonInShower ) ; 
+  //  fInfoNbPhot->SetText( wort ) ; 
+  
   return (kTRUE) ; 
-
 }
+
+
 // ======================================================================
 // ======================================================================
+//
+////////////////////////////////////////////////////////////////////////////
+//
+// Modification by C.Domingo May 2001
+//
+// Minor changes to procedure ProcessMessage
+//   case M_BUTTON_SELECT takes into account that we no longer select 
+//     directories, but files.
+//   case M_BUTTON_PREV functionality has (temporarily) been removed
+//   case kCT_ITEMDBLCLICK takes into account that we deal with are going to
+//     select cerenkov files, not directories containing them. Test for detection
+//     of possible cerenkov files is added.
+//   
+////////////////////////////////////////////////////////////////////////////
+//
 
 Bool_t MainFrameSimone::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
@@ -916,4 +1100,5 @@
   Char_t  testfile[100] ;
   Char_t  extens[5] ;
+  Char_t  idcer[5] ;
   Char_t  command[110] ;
  
@@ -985,29 +1170,50 @@
 	  //	  
 	  item = (TGFileItem *) fFileCont->GetNextSelected(&np) ; 
-
-	  if ( S_ISDIR(item->GetType()) ) {   // file is directory
-	    
-	    sprintf (fInputPath, "%s/%s",
-		     gSystem->WorkingDirectory(), 
-		     item->GetItemName()->GetString()) ;
-
-	    fDir2->RemoveEntry(1) ; 
-	    fDir2->AddEntry(fInputPath,1) ; 	    
-	    fDir2->MapSubwindows() ; 
-	    fDir2->Layout() ;   
+	   
+          // cout << "fCerFileName =" << fCerFileName ;
+ 
+          //
+	  // Check if fCerFile is already declared and open
+	  // If so, close it before selecting next file
+	  //
+
+          if (fCerFileName != "\0" &&  fCerFile ) 
+              fCerFile.close();
+
+	  //
+	  //  Compose the InputPath name and the Cerenkov filename
+	  //
+
+          sprintf (fInputPath, "%s",
+		   gSystem->WorkingDirectory() ) ;
+
+          sprintf (fCerFileName, "%s/%s" ,
+		   gSystem->WorkingDirectory(), 
+		   item->GetItemName()->GetString()) ;           
+            
+          //cout << fInputPath << endl;
+          //cout << fCerFileName << endl ;
+
+	  // 
+	  //  Refresh values in the frames
+	  //	     
+
+	  fDir2->RemoveEntry(1) ;     
+	  fDir2->AddEntry(fCerFileName,1) ;
+	  fDir2->MapSubwindows() ; 
+	  fDir2->Layout() ;   
 	      
-	    fDir3->RemoveEntry(1) ; 
-	    fDir3->AddEntry(fInputPath,1) ; 	    
-	    fDir3->MapSubwindows() ; 
-	    fDir3->Layout() ;   	      
-
-	    fEvtNb = 0 ; 
-	    sprintf (wort2, "%d", fEvtNb ) ; 
-	    fDirEvtNb->RemoveEntry(1) ;
-	    fDirEvtNb->AddEntry( wort2, 1 ) ; 
-	    fDirEvtNb->MapSubwindows() ; 
-	    fDirEvtNb->Layout() ; 
-
-	  }
+	  fDir3->RemoveEntry(1) ;     
+	  fDir3->AddEntry(fCerFileName,1) ; 	    
+	  fDir3->MapSubwindows() ; 
+	  fDir3->Layout() ;   	      
+
+	  fEvtNb = 0 ; 
+	  sprintf (wort2, "%d", fEvtNb ) ; 
+	  fDirEvtNb->RemoveEntry(1) ;
+	  fDirEvtNb->AddEntry( wort2, 1 ) ; 
+	  fDirEvtNb->MapSubwindows() ; 
+	  fDirEvtNb->Layout() ; 
+
 	}
 	break;
@@ -1044,26 +1250,33 @@
 
 
-
       case M_BUTTON_PREV:
-	fEvtNb-- ; 
-	
+//	fEvtNb-- ; 
+//	
 	if (fEvtNb < 1 ) {
 	  fEvtNb++ ; 
 	  
 	}
-	  
-	sprintf (wort2, "%d", fEvtNb ) ; 
-	fDirEvtNb->RemoveEntry(1) ;
-	fDirEvtNb->AddEntry( wort2, 1 ) ; 
-	fDirEvtNb->MapSubwindows() ; 
-	fDirEvtNb->Layout() ; 
-
-	ReadinEvt() ; 
-
-	DrawEvtParam() ; 
-
+//	  
+//	sprintf (wort2, "%d", fEvtNb ) ; 
+//	fDirEvtNb->RemoveEntry(1) ;
+//	fDirEvtNb->AddEntry( wort2, 1 ) ; 
+//	fDirEvtNb->MapSubwindows() ; 
+//	fDirEvtNb->Layout() ; 
+//
+//	ReadinEvt() ; 
+//
+//	DrawEvtParam() ; 
+//
+//
+//      Do nothing !!
+//
+        new TGMsgBox(fClient->GetRoot(), this,
+		     "Warning", 
+		     "This button is not operational at present!!", 
+		     kMBIconExclamation, buttons, &retval);
+ 
 	break; 	
-
-
+//
+//
       case M_BUTTON_NEXT:
 	fEvtNb++ ; 
@@ -1080,6 +1293,4 @@
 
 	break; 	
-
-
 
       case M_CTRL_EXIT:
@@ -1153,50 +1364,33 @@
 	    sprintf (wort, "%s", item->GetItemName()->GetString()) ;
 	    
+	    sprintf (fInputPath,"\0") ; 
+	    fSelectButton->SetState(kButtonDisabled) ;
+	    fDir2->RemoveEntry(1) ; 
+	    fDir2->AddEntry(fInputPath,1) ;
+	    fDir2->MapSubwindows() ; 
+	    fDir2->Layout() ;
+	      
+	    fDir3->RemoveEntry(1) ; 
+	    fDir3->AddEntry(fInputPath,1) ;
+	    fDir3->MapSubwindows() ; 
+	    fDir3->Layout() ;
+
+            sprintf (wort2, "\0" ) ; 
+	    fDirEvtNb->RemoveEntry(1) ;
+            fDirEvtNb->AddEntry( wort2, 1 ) ; 
+            fDirEvtNb->MapSubwindows() ; 
+            fDirEvtNb->Layout() ; 
+ 
+            //
+            //  goto directory 
 	    //
-	    //  check if in this directory the file cer000001 exits
-	    //  if it exists, do not open the stuff
-	    //
-
-	    if ( CerFileExist( wort ) ) {
-
-	      fSelectButton->SetState(kButtonUp) ; 
+            fFileCont->ChangeDirectory ( wort ) ; 
+            gSystem->ChangeDirectory( wort ) ; 
 	      
-	      new TGMsgBox(fClient->GetRoot(), this,
-			   "Information", 
-			   "This is a directory containing cer files\n click on select to chose it!",
-			   kMBIconAsterisk, buttons, &retval);
-
-	    }  
-	    else {
-	      sprintf (fInputPath,"\0") ; 
-	      fSelectButton->SetState(kButtonDisabled) ;
-	      fDir2->RemoveEntry(1) ; 
-	      fDir2->AddEntry(fInputPath,1) ;
-	      fDir2->MapSubwindows() ; 
-	      fDir2->Layout() ;
-	      
-	      fDir3->RemoveEntry(1) ; 
-	      fDir3->AddEntry(fInputPath,1) ;
-	      fDir3->MapSubwindows() ; 
-	      fDir3->Layout() ;
-
-	      sprintf (wort2, "\0" ) ; 
-	      fDirEvtNb->RemoveEntry(1) ;
-	      fDirEvtNb->AddEntry( wort2, 1 ) ; 
-	      fDirEvtNb->MapSubwindows() ; 
-	      fDirEvtNb->Layout() ; 
- 
-	      //
-	      //  goto directory 
-	      //
-	      fFileCont->ChangeDirectory ( wort ) ; 
-	      gSystem->ChangeDirectory( wort ) ; 
-	      
-	      sprintf (wort, "%s", gSystem->WorkingDirectory() ) ; 
-	      fDir->RemoveEntry(1) ; 
-	      fDir->AddEntry( wort, 1 ) ; 
-	      fDir->MapSubwindows() ; 
-	      fDir->Layout() ; 
-	    }
+	    sprintf (wort, "%s", gSystem->WorkingDirectory() ) ; 
+	    fDir->RemoveEntry(1) ; 
+	    fDir->AddEntry( wort, 1 ) ; 
+	    fDir->MapSubwindows() ; 
+            fDir->Layout() ; 
 	    
 	  }
@@ -1204,31 +1398,63 @@
 	    sprintf (testfile, "%s", item->GetItemName()->GetString() ) ; 
 	    
-	    //
-	    //    determine the file type by extensions
-	    //
+            //
+            //   Is it a Cerenkov file?
+            //
+            
+	    for (Int_t i = 0 ; i<5; i++) 
+	        idcer[i] = '\0' ;
+	    for (Int_t i = 0 ; i<10; i++)
+	        fRunSuffix[i]= '\0' ;
+
+            strncpy (idcer, &testfile[0], 3 ) ;
+            if ( ! strcmp (idcer , "cer" ) ) {
+	      for ( Int_t i=3; 15; i++) {
+	        if ( testfile[i] == '\0') {
+		  strncpy (fRunSuffix, &testfile[3], i-3 ) ; 
+		  break ; 
+	        }
+	      }
+
+              // cout << "fRunSuffix = "<< fRunSuffix << endl ;
+
+	      fSelectButton->SetState(kButtonUp) ; 
+	      
+	      new TGMsgBox(fClient->GetRoot(), this,
+			   "Information", 
+			   "This file probably contains CERENKOV events\n click on the SELECT button to chose it!",
+			   kMBIconAsterisk, buttons, &retval);                                    
+            }
+            
+            else {
+
+	      fSelectButton->SetState(kButtonDisabled) ;
+	      
+ 	      //
+	      //    determine the file type by extensions
+	      //
 	    
-	    for (Int_t i = 0 ; i<5; i++) 
-	      extens[i] = '\0' ; 
+	      for (Int_t i = 0 ; i<5; i++) 
+	        extens[i] = '\0' ; 
 	    
-	    for ( Int_t i=0; testfile[i] != '\0'; i++) {
-	      if ( testfile[i] == '.') {
-		strncpy (extens, &testfile[i+1], 4 ) ; 
-		break ; 
+	      for ( Int_t i=0; testfile[i] != '\0'; i++) {
+	        if ( testfile[i] == '.') {
+		  strncpy (extens, &testfile[i+1], 4 ) ; 
+		  break ; 
+	        }
 	      }
-	    }
-
-	    //
-	    //     postscript file
-	    //
+
+	      //
+	      //     postscript file
+	      //
 	    
-	    if ( ! strcmp(extens, "ps") ) {
-	      sprintf ( command, "gv %s/%s &", 
-			gSystem->WorkingDirectory(), 
-			testfile ) ; 
-	      gSystem->Exec(command) ; 
-	      break ; 
-	    }
+	      if ( ! strcmp(extens, "ps") ) {
+	        sprintf ( command, "gv %s/%s &", 
+			  gSystem->WorkingDirectory(), 
+			  testfile ) ; 
+	        gSystem->Exec(command) ; 
+	        break ; 
+	      }
 	    
-		
+	    }	
 	    
 	      
@@ -1248,6 +1474,9 @@
   default:
     break;
-  }
+
+  }
+
   return kTRUE;
+
 }
 
Index: trunk/MagicSoft/Simulation/Corsika/GuiSimone/MainFrameSimone.hxx
===================================================================
--- trunk/MagicSoft/Simulation/Corsika/GuiSimone/MainFrameSimone.hxx	(revision 777)
+++ trunk/MagicSoft/Simulation/Corsika/GuiSimone/MainFrameSimone.hxx	(revision 778)
@@ -56,6 +56,10 @@
   Char_t            fInputPath[200] ; 
   Int_t             fNumEvents ; 
-  Char_t            fNtupPath[200] ; 
+//  Char_t            fNtupPath[200] ;
+  Char_t            fNtupFile[256] ;
+  Char_t            fCerFileName[256] ;
+  Char_t            fRunSuffix[10] ;
 
+  ifstream          fCerFile ; 
   Int_t             fEvtNb ; 
 
