Changeset 4139


Ignore:
Timestamp:
05/24/04 11:26:25 (21 years ago)
Author:
rico
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mtemp/mifae
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mtemp/mifae/Changelog

    r4138 r4139  
    1919                                                 -*-*- END OF LINE -*-*-
    2020
     21 2004/05/24 Javier Rico
     22   * library/MDisplay.[h,cc], library/MHillasDisplay.[h,cc]
     23     programs/makeHillas.cc, programs/makehillas.datacard
     24     - Add possibility to save a ps file
     25     - Update documentation
     26       
    2127 2004/05/21 Oscar Blanch
    2228   * makeHillas.cc
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MDisplay.cc

    r4117 r4139  
    2626// MDisplay
    2727//
     28// Class to display camera events (MCamEvent)
     29// You can set an event-by-event display with pause between two consecutive
     30// events. You can set an output PS file.
     31//
     32// Input containers (to be provided to the constructor):
     33//
     34//  MCamEvent
     35//  MGeomCam
     36//
     37// Output containers:
    2838//
    2939//
     
    3343#include <math.h>
    3444
     45#include "TCanvas.h"
     46#include "TPostScript.h"
     47
    3548#include "MParList.h"
    3649#include "MDisplay.h"
     
    3851#include "MGeomCam.h"
    3952#include "MHCamera.h"
    40 
    41 #include "TCanvas.h"
    4253
    4354#include "MLog.h"
     
    4859using namespace std;
    4960
    50 static const TString gsDefName  = "MDisplay";
    51 static const TString gsDefTitle = "Camera display task";
     61static const TString gsDefName       = "MDisplay";
     62static const TString gsDefTitle      = "Camera display task";
     63static const TString gsDefPSFileName = "display.ps";
    5264
    5365// -------------------------------------------------------------------------
    5466//
    55 // Constructor.
     67// Constructor. Need to provide the MCamEvent container to be displayed <event>
     68// and camera geometry <geom>. Also the display type <type> can be specified
     69// (see the MHCamera documentation for more details)
    5670//
    5771MDisplay::MDisplay(MCamEvent* event, MGeomCam* geom, Int_t type, const char* name, const char* title)
    58   :  fGeomCam(geom), fCamEvent(event),  fCanvas(NULL), fDisplayType(type)
     72  :  fGeomCam(geom), fCamEvent(event),  fCanvas(NULL), fPSFile(NULL), fDisplayType(type), fCreatePSFile(kFALSE), fPause(kTRUE)
    5973{
    6074  fName  = name  ? name  : gsDefName.Data();
     
    6377  fDisplay = new MHCamera(*geom);
    6478  fDisplay->SetPrettyPalette();
     79 
     80  fPSFileName = gsDefPSFileName;
    6581}
    6682// -------------------------------------------------------------------------
     
    7389  if(fCanvas)
    7490    delete fCanvas;
     91  if(fPSFile)
     92    delete fPSFile;
    7593}
    7694
    7795// -------------------------------------------------------------------------
    7896//
    79 // Look for needed containers.
     97// Create the canvas, eventually set the batch mode and open ps file
    8098//
    8199Int_t MDisplay::PreProcess(MParList* pList)
    82100{
    83101  fCanvas = new TCanvas("myCanvas","Event Display",600,600);
     102  if(fCreatePSFile)
     103    fPSFile = new TPostScript(fPSFileName,111);
     104  if(!fPause)
     105    fCanvas->SetBatch();
    84106  fCanvas->cd(1);
    85107  fDisplay->Draw();
     
    90112// -------------------------------------------------------------------------
    91113//
    92 // Call to compute a new position and then save it in the histogram (fMode==kOn)
    93 // of to read the new position from the histogram (fMode==kOff)
     114// Set the new containt of the camera event and update the display.
     115// Set new page if ps file is requested
     116// Pause execution if event-by-event display is chosen
    94117//
    95118Int_t MDisplay::Process()
    96119
     120  // new page in ps file
     121  if(fPSFile)
     122    fPSFile->NewPage();
     123
     124  // update the display contents
    97125  fDisplay->SetCamContent(*fCamEvent);
    98126  fCanvas->GetPad(1)->Modified();
     
    100128
    101129  // pause execution
    102   cout << "Type 'q' to exit, <return> to go on: ";     
    103   TString input;
    104   input =cin.get();
    105  
    106   if (input=='q')
    107     return kFALSE;
    108   else
    109     return kTRUE;
     130  if(fPause)
     131    {
     132      cout << "Type 'q' to exit, <return> to go on: ";     
     133      TString input;
     134      input =cin.get();
     135     
     136      if (input=='q')
     137        return kFALSE;
     138    }
     139
     140  return kTRUE;
    110141}
    111142
    112143// -------------------------------------------------------------------------
    113144//
    114 // Dump 2D histo statistics
     145// Close ps file if it was open
    115146//
    116147Int_t MDisplay::PostProcess()
    117148{
     149  if(fPSFile) fPSFile->Close();
    118150  return kTRUE;
    119151}
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MDisplay.h

    r4117 r4139  
    1010class MGeomCam;
    1111class TCanvas;
     12class TPostScript;
    1213
    1314class MDisplay : public MTask
    1415{
    1516 private:
    16   MHCamera*  fDisplay;     // pointer to the camera display
    17   MGeomCam*  fGeomCam;     // pointer to the camera geometry
    18   MCamEvent* fCamEvent;    // pointer to camera event
    19   TCanvas*   fCanvas;      // pointer to the canvas
    20   Int_t      fDisplayType;
     17  MHCamera*     fDisplay;      // pointer to the camera display
     18  MGeomCam*     fGeomCam;      // pointer to the camera geometry
     19  MCamEvent*    fCamEvent;     // pointer to camera event
     20  TCanvas*      fCanvas;       // pointer to the canvas
     21  TPostScript*  fPSFile;       // pointer to ps file
     22  TString       fPSFileName;   // name for ps file
     23  Int_t         fDisplayType;  // display type (see MHCamera)
     24  Bool_t        fCreatePSFile; // flag to produce a ps file with events
     25  Bool_t        fPause;        // flag to pause execution between events
    2126 
     27
    2228  virtual Int_t PostProcess();
    2329
     
    3036  virtual ~MDisplay();
    3137
    32   MGeomCam*    GetGeomCam()               {return fGeomCam;}
    33   void         SetDisplayType(Int_t type) {fDisplayType=type;}
    34   virtual void Paint(Option_t* option)    {};
     38  virtual void Paint(Option_t* option)     {};
     39
     40  MGeomCam*    GetGeomCam()                {return fGeomCam;}
     41  Bool_t       GetPauseMode()              {return fPause;}
     42  Bool_t       GetCreatePSFile()           {return fCreatePSFile;}
     43
     44  void         SetDisplayType(Int_t type)  {fDisplayType=type;}
     45  void         SetPSFile(Bool_t set=kTRUE) {fCreatePSFile=set;}
     46  void         SetPSFileName(TString name) {fPSFileName=name;}
     47  void         SetPause(Bool_t set=kTRUE)  {fPause=set;}
    3548
    3649  ClassDef(MDisplay, 0) // Task to display camera containers
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MHillasDisplay.cc

    r4117 r4139  
    2626// MDisplayHillas
    2727//
     28// Display the camera event of type MCerPhotEvt plus the computed hillas
     29// parameters.
    2830//
     31// Input containers (in constructor):
     32//  MCerPhotEvt
     33//  MGeomCam
     34//
     35// Input containers
     36//  MHillas
     37//  [MSrcPosCam]
     38//
     39// Output containers
     40//  [...]
    2941//
    3042//////////////////////////////////////////////////////////////////////////////
     
    5668// -------------------------------------------------------------------------
    5769//
    58 // Constructor.
     70// Constructor (see MDisplay documentation for more information)
    5971//
    6072MHillasDisplay::MHillasDisplay(MCerPhotEvt* event, MGeomCam* geom, Int_t type, const char* name, const char* title)
     
    6678// -------------------------------------------------------------------------
    6779//
    68 // Look for needed containers.
     80// Call for MHillas::PreProcess and look for MHillas and look for the
     81// needed containers
    6982//
    7083Int_t MHillasDisplay::PreProcess(MParList* pList)
     
    99112{
    100113   // draw the hillas parameters
    101   if(fHillas)
     114  if(fHillas && GetPauseMode())
    102115    fHillas->Print();
    103116   
     
    109122// -------------------------------------------------------------------------
    110123//
    111 // Paint
     124// Stuff to be painted when canvas will be updated
    112125//
    113126void MHillasDisplay::Paint(Option_t* option)
  • trunk/MagicSoft/Mars/mtemp/mifae/programs/makeHillas.cc

    r4118 r4139  
    7272TString  idirname;
    7373TString  filter;
     74TString  psfilename("makehillas.ps");
    7475MRunIter caliter;
    7576MRunIter pediter;
    7677MRunIter datiter;
    77 Bool_t   display   = kFALSE;
     78UInt_t   display   = 0;
    7879ULong_t  nmaxevents= 999999999;
    7980Short_t  calflag   = 1;
     
    302303  MDisplay*  disphillas=NULL;
    303304
    304   if(!display)
    305     {
    306       write = new MWriteRootFile(outname,"RECREATE");
    307      
    308       write->AddContainer("MHillas"        , "Parameters");
    309       write->AddContainer("MHillasSrc"     , "Parameters");
    310       write->AddContainer("MHillasExt"     , "Parameters");
    311       write->AddContainer("MNewImagePar"   , "Parameters");
    312       write->AddContainer("MRawEvtHeader"  , "Parameters");
    313       write->AddContainer("MRawRunHeader"  , "Parameters");
    314       write->AddContainer("MConcentration" , "Parameters");
    315       write->AddContainer("MSrcPosCam"     , "Parameters");
    316      
    317       if (islflag == 1 || islflag == 2)
    318         write->AddContainer("MIslands1" , "Parameters");
    319       if (islflag == 2)
    320         write->AddContainer("MIslands2" , "Parameters");
    321     }
    322   else
    323     {
    324       disphillas = new MHillasDisplay(&nphot,&geomcam);
    325     }
     305  write = new MWriteRootFile(outname,"RECREATE");
     306 
     307  write->AddContainer("MHillas"        , "Parameters");
     308  write->AddContainer("MHillasSrc"     , "Parameters");
     309  write->AddContainer("MHillasExt"     , "Parameters");
     310  write->AddContainer("MNewImagePar"   , "Parameters");
     311  write->AddContainer("MRawEvtHeader"  , "Parameters");
     312  write->AddContainer("MRawRunHeader"  , "Parameters");
     313  write->AddContainer("MConcentration" , "Parameters");
     314  write->AddContainer("MSrcPosCam"     , "Parameters");
     315 
     316  if (islflag == 1 || islflag == 2)
     317    write->AddContainer("MIslands1" , "Parameters");
     318  if (islflag == 2)
     319    write->AddContainer("MIslands2" , "Parameters");
     320
     321  if(display)
     322    disphillas = new MHillasDisplay(&nphot,&geomcam);
    326323
    327324  tlist4.AddToList(&read4);
     
    348345  tlist4.AddToList(&csrc1);
    349346  tlist4.AddToList(&applycut);
    350   if(!display)
    351     tlist4.AddToList(write);
    352   else
    353     tlist4.AddToList(disphillas);
     347  tlist4.AddToList(write);
     348  if(display)
     349    {
     350      disphillas->SetPSFile();
     351      disphillas->SetPSFileName(psfilename);
     352      if(display==2)
     353        disphillas->SetPause(kFALSE);   
     354      tlist4.AddToList(disphillas);
     355    }
     356
    354357
    355358  // Create and setup the eventloop
     
    450453      if(strcmp(word.Data(),"DISPLAY")==0)
    451454        ifun >> display;
     455
     456      // ps file name
     457      if(strcmp(word.Data(),"PSFILENAME")==0)
     458        ifun >> psfilename;
    452459
    453460      // calibration flag
     
    499506  if(filter.Length())
    500507    cout << "Applying rejection cut: " << filter << endl;
    501   if(!display)
    502     cout << "Output file name: " << outname << endl;
     508  cout << "Output file name: " << outname << endl;
     509  if(display)
     510    cout << "Generating PS file: " << psfilename << endl;
    503511  cout << "Calibration flag: " << calflag << endl;
    504512  cout << "Cleaning level: ("<<lcore<<","<<ltail<<")" << endl;
  • trunk/MagicSoft/Mars/mtemp/mifae/programs/makehillas.datacard

    r4117 r4139  
    2121FILTER (MHillas.fLength<100) && (MHillas.fLength>50)
    2222
    23 // Display flag (DISPLAY=1 will show event display and skip saving into output file)
    24 DISPLAY 1
     23// Display flag
     24// DISPLAY 0 will simply produce the hillas parameters files
     25// DISPLAY 1 will show event display and produce ps file
     26// DISPLAY 2 will produce the ps files, no display
     27DISPLAY 0
     28
     29// PS file name
     30PSFILENAME makehillas.ps
    2531
    2632// calibration flag:
Note: See TracChangeset for help on using the changeset viewer.