Index: /trunk/MagicSoft/Mars/mtemp/mifae/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/Changelog	(revision 4138)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/Changelog	(revision 4139)
@@ -19,4 +19,10 @@
                                                  -*-*- END OF LINE -*-*-
 
+ 2004/05/24 Javier Rico
+   * library/MDisplay.[h,cc], library/MHillasDisplay.[h,cc]
+     programs/makeHillas.cc, programs/makehillas.datacard
+     - Add possibility to save a ps file
+     - Update documentation
+	
  2004/05/21 Oscar Blanch
    * makeHillas.cc
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/MDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MDisplay.cc	(revision 4138)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/MDisplay.cc	(revision 4139)
@@ -26,4 +26,14 @@
 // MDisplay
 //
+// Class to display camera events (MCamEvent)
+// You can set an event-by-event display with pause between two consecutive 
+// events. You can set an output PS file.
+//
+// Input containers (to be provided to the constructor):
+//
+//  MCamEvent
+//  MGeomCam
+//
+// Output containers:
 //
 //
@@ -33,4 +43,7 @@
 #include <math.h>
 
+#include "TCanvas.h"
+#include "TPostScript.h"
+
 #include "MParList.h"
 #include "MDisplay.h"
@@ -38,6 +51,4 @@
 #include "MGeomCam.h"
 #include "MHCamera.h"
-
-#include "TCanvas.h"
 
 #include "MLog.h"
@@ -48,13 +59,16 @@
 using namespace std;
 
-static const TString gsDefName  = "MDisplay";
-static const TString gsDefTitle = "Camera display task";
+static const TString gsDefName       = "MDisplay";
+static const TString gsDefTitle      = "Camera display task";
+static const TString gsDefPSFileName = "display.ps";
 
 // -------------------------------------------------------------------------
 //
-// Constructor.
+// Constructor. Need to provide the MCamEvent container to be displayed <event>
+// and camera geometry <geom>. Also the display type <type> can be specified
+// (see the MHCamera documentation for more details)
 //
 MDisplay::MDisplay(MCamEvent* event, MGeomCam* geom, Int_t type, const char* name, const char* title) 
-  :  fGeomCam(geom), fCamEvent(event),  fCanvas(NULL), fDisplayType(type)
+  :  fGeomCam(geom), fCamEvent(event),  fCanvas(NULL), fPSFile(NULL), fDisplayType(type), fCreatePSFile(kFALSE), fPause(kTRUE)
 {
   fName  = name  ? name  : gsDefName.Data();
@@ -63,4 +77,6 @@
   fDisplay = new MHCamera(*geom);
   fDisplay->SetPrettyPalette();
+  
+  fPSFileName = gsDefPSFileName;
 }
 // -------------------------------------------------------------------------
@@ -73,13 +89,19 @@
   if(fCanvas)
     delete fCanvas;
+  if(fPSFile)
+    delete fPSFile;
 }
 
 // -------------------------------------------------------------------------
 //
-// Look for needed containers.
+// Create the canvas, eventually set the batch mode and open ps file
 //
 Int_t MDisplay::PreProcess(MParList* pList)
 { 
   fCanvas = new TCanvas("myCanvas","Event Display",600,600);
+  if(fCreatePSFile) 
+    fPSFile = new TPostScript(fPSFileName,111);
+  if(!fPause)
+    fCanvas->SetBatch();
   fCanvas->cd(1);
   fDisplay->Draw();
@@ -90,9 +112,15 @@
 // -------------------------------------------------------------------------
 //
-// Call to compute a new position and then save it in the histogram (fMode==kOn) 
-// of to read the new position from the histogram (fMode==kOff)
+// Set the new containt of the camera event and update the display.
+// Set new page if ps file is requested
+// Pause execution if event-by-event display is chosen
 //
 Int_t MDisplay::Process()
 {  
+  // new page in ps file
+  if(fPSFile)
+    fPSFile->NewPage();
+
+  // update the display contents
   fDisplay->SetCamContent(*fCamEvent);
   fCanvas->GetPad(1)->Modified();
@@ -100,20 +128,24 @@
 
   // pause execution
-  cout << "Type 'q' to exit, <return> to go on: ";      
-  TString input;
-  input =cin.get(); 
-  
-  if (input=='q')
-    return kFALSE;
-  else
-    return kTRUE;
+  if(fPause)
+    {
+      cout << "Type 'q' to exit, <return> to go on: ";      
+      TString input;
+      input =cin.get(); 
+      
+      if (input=='q')
+	return kFALSE;
+    }
+
+  return kTRUE;
 }
 
 // -------------------------------------------------------------------------
 //
-// Dump 2D histo statistics
+// Close ps file if it was open
 //
 Int_t MDisplay::PostProcess()
 {
+  if(fPSFile) fPSFile->Close();
   return kTRUE;
 }
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/MDisplay.h
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MDisplay.h	(revision 4138)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/MDisplay.h	(revision 4139)
@@ -10,14 +10,20 @@
 class MGeomCam;
 class TCanvas;
+class TPostScript;
 
 class MDisplay : public MTask
 {
  private:
-  MHCamera*  fDisplay;     // pointer to the camera display
-  MGeomCam*  fGeomCam;     // pointer to the camera geometry
-  MCamEvent* fCamEvent;    // pointer to camera event
-  TCanvas*   fCanvas;      // pointer to the canvas
-  Int_t      fDisplayType; 
+  MHCamera*     fDisplay;      // pointer to the camera display
+  MGeomCam*     fGeomCam;      // pointer to the camera geometry
+  MCamEvent*    fCamEvent;     // pointer to camera event
+  TCanvas*      fCanvas;       // pointer to the canvas
+  TPostScript*  fPSFile;       // pointer to ps file
+  TString       fPSFileName;   // name for ps file
+  Int_t         fDisplayType;  // display type (see MHCamera)
+  Bool_t        fCreatePSFile; // flag to produce a ps file with events
+  Bool_t        fPause;        // flag to pause execution between events
   
+
   virtual Int_t PostProcess();
 
@@ -30,7 +36,14 @@
   virtual ~MDisplay();
 
-  MGeomCam*    GetGeomCam()               {return fGeomCam;}
-  void         SetDisplayType(Int_t type) {fDisplayType=type;}
-  virtual void Paint(Option_t* option)    {};
+  virtual void Paint(Option_t* option)     {};
+
+  MGeomCam*    GetGeomCam()                {return fGeomCam;}
+  Bool_t       GetPauseMode()              {return fPause;}
+  Bool_t       GetCreatePSFile()           {return fCreatePSFile;}
+
+  void         SetDisplayType(Int_t type)  {fDisplayType=type;}
+  void         SetPSFile(Bool_t set=kTRUE) {fCreatePSFile=set;}
+  void         SetPSFileName(TString name) {fPSFileName=name;}
+  void         SetPause(Bool_t set=kTRUE)  {fPause=set;}
 
   ClassDef(MDisplay, 0) // Task to display camera containers
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/MHillasDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MHillasDisplay.cc	(revision 4138)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/MHillasDisplay.cc	(revision 4139)
@@ -26,5 +26,17 @@
 // MDisplayHillas
 //
+// Display the camera event of type MCerPhotEvt plus the computed hillas
+// parameters.
 //
+// Input containers (in constructor):
+//  MCerPhotEvt
+//  MGeomCam
+//
+// Input containers
+//  MHillas
+//  [MSrcPosCam]
+//
+// Output containers
+//  [...]
 //
 //////////////////////////////////////////////////////////////////////////////
@@ -56,5 +68,5 @@
 // -------------------------------------------------------------------------
 //
-// Constructor.
+// Constructor (see MDisplay documentation for more information)
 //
 MHillasDisplay::MHillasDisplay(MCerPhotEvt* event, MGeomCam* geom, Int_t type, const char* name, const char* title) 
@@ -66,5 +78,6 @@
 // -------------------------------------------------------------------------
 //
-// Look for needed containers.
+// Call for MHillas::PreProcess and look for MHillas and look for the
+// needed containers
 //
 Int_t MHillasDisplay::PreProcess(MParList* pList)
@@ -99,5 +112,5 @@
 {
    // draw the hillas parameters
-  if(fHillas)
+  if(fHillas && GetPauseMode())
     fHillas->Print();
    
@@ -109,5 +122,5 @@
 // -------------------------------------------------------------------------
 //
-// Paint
+// Stuff to be painted when canvas will be updated
 //
 void MHillasDisplay::Paint(Option_t* option)
Index: /trunk/MagicSoft/Mars/mtemp/mifae/programs/makeHillas.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/programs/makeHillas.cc	(revision 4138)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/programs/makeHillas.cc	(revision 4139)
@@ -72,8 +72,9 @@
 TString  idirname;
 TString  filter;
+TString  psfilename("makehillas.ps");
 MRunIter caliter;
 MRunIter pediter;
 MRunIter datiter;
-Bool_t   display   = kFALSE;
+UInt_t   display   = 0;
 ULong_t  nmaxevents= 999999999;
 Short_t  calflag   = 1;
@@ -302,26 +303,22 @@
   MDisplay*  disphillas=NULL;
 
-  if(!display)
-    {
-      write = new MWriteRootFile(outname,"RECREATE");
-      
-      write->AddContainer("MHillas"        , "Parameters");
-      write->AddContainer("MHillasSrc"     , "Parameters");
-      write->AddContainer("MHillasExt"     , "Parameters");
-      write->AddContainer("MNewImagePar"   , "Parameters");
-      write->AddContainer("MRawEvtHeader"  , "Parameters");
-      write->AddContainer("MRawRunHeader"  , "Parameters");
-      write->AddContainer("MConcentration" , "Parameters");
-      write->AddContainer("MSrcPosCam"     , "Parameters");
-      
-      if (islflag == 1 || islflag == 2)
-	write->AddContainer("MIslands1" , "Parameters");
-      if (islflag == 2) 
-	write->AddContainer("MIslands2" , "Parameters");
-    }
-  else
-    {
-      disphillas = new MHillasDisplay(&nphot,&geomcam);
-    }
+  write = new MWriteRootFile(outname,"RECREATE");
+  
+  write->AddContainer("MHillas"        , "Parameters");
+  write->AddContainer("MHillasSrc"     , "Parameters");
+  write->AddContainer("MHillasExt"     , "Parameters");
+  write->AddContainer("MNewImagePar"   , "Parameters");
+  write->AddContainer("MRawEvtHeader"  , "Parameters");
+  write->AddContainer("MRawRunHeader"  , "Parameters");
+  write->AddContainer("MConcentration" , "Parameters");
+  write->AddContainer("MSrcPosCam"     , "Parameters");
+  
+  if (islflag == 1 || islflag == 2)
+    write->AddContainer("MIslands1" , "Parameters");
+  if (islflag == 2) 
+    write->AddContainer("MIslands2" , "Parameters");
+
+  if(display)
+    disphillas = new MHillasDisplay(&nphot,&geomcam);
 
   tlist4.AddToList(&read4);
@@ -348,8 +345,14 @@
   tlist4.AddToList(&csrc1);
   tlist4.AddToList(&applycut);
-  if(!display)
-    tlist4.AddToList(write);
-  else
-    tlist4.AddToList(disphillas);
+  tlist4.AddToList(write);
+  if(display)
+    {
+      disphillas->SetPSFile();
+      disphillas->SetPSFileName(psfilename);
+      if(display==2) 
+	disphillas->SetPause(kFALSE);	
+      tlist4.AddToList(disphillas);
+    }
+
 
   // Create and setup the eventloop
@@ -450,4 +453,8 @@
       if(strcmp(word.Data(),"DISPLAY")==0)
 	ifun >> display;
+
+      // ps file name
+      if(strcmp(word.Data(),"PSFILENAME")==0)
+	ifun >> psfilename;
 
       // calibration flag
@@ -499,6 +506,7 @@
   if(filter.Length())
     cout << "Applying rejection cut: " << filter << endl;
-  if(!display)
-    cout << "Output file name: " << outname << endl;
+  cout << "Output file name: " << outname << endl;
+  if(display)
+    cout << "Generating PS file: " << psfilename << endl;
   cout << "Calibration flag: " << calflag << endl;
   cout << "Cleaning level: ("<<lcore<<","<<ltail<<")" << endl;
Index: /trunk/MagicSoft/Mars/mtemp/mifae/programs/makehillas.datacard
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/programs/makehillas.datacard	(revision 4138)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/programs/makehillas.datacard	(revision 4139)
@@ -21,6 +21,12 @@
 FILTER (MHillas.fLength<100) && (MHillas.fLength>50)
 
-// Display flag (DISPLAY=1 will show event display and skip saving into output file)
-DISPLAY 1
+// Display flag 
+// DISPLAY 0 will simply produce the hillas parameters files
+// DISPLAY 1 will show event display and produce ps file
+// DISPLAY 2 will produce the ps files, no display
+DISPLAY 0
+
+// PS file name
+PSFILENAME makehillas.ps
 
 // calibration flag:
