Ignore:
Timestamp:
04/02/01 15:08:48 (24 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/manalysis
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.cc

    r705 r716  
    99#include <fstream.h>
    1010
     11#include <TArrayC.h>
     12
    1113#include "MLog.h"
    1214#include "MLogManip.h"
     
    2830    // remember file name for opening the file in the preprocessor
    2931    //
    30     fFileName = fname;
     32    fFileNames = new TArrayC;
     33    if (fname)
     34        AddFile(fname);
     35}
     36
     37MCT1ReadAscii::~MCT1ReadAscii()
     38{
     39    delete fFileNames;
     40    if (fIn)
     41        delete fIn;
     42}
     43
     44void MCT1ReadAscii::AddFile(const char *txt)
     45{
     46    //
     47    // Add this file as the last entry in the chain
     48    //
     49    const int   sz  = fFileNames->GetSize();
     50    const int   tsz = strlen(txt)+1;
     51
     52    fFileNames->Set(sz+tsz);
     53
     54    memcpy(fFileNames->GetArray()+sz, txt, tsz);
     55}
     56
     57Bool_t MCT1ReadAscii::OpenNextFile()
     58{
     59    //
     60    // open the input stream and check if it is really open (file exists?)
     61    //
     62    if (fIn)
     63        delete fIn;
     64    fIn = NULL;
     65
     66    const int arrsz = fFileNames->GetSize();
     67
     68    if (arrsz<1)
     69        return kFALSE;
     70
     71    //
     72    // open the file which is the first one in the chain
     73    //
     74    const char *name = fFileNames->GetArray();
     75
     76    fIn = new ifstream(name);
     77    if (!(*fIn))
     78    {
     79        *fLog << dbginf << "Cannot open file '" << name << "'" << endl;
     80        return kFALSE;
     81    }
     82
     83    //
     84    // remove the first entry from the chain
     85    //
     86    *fLog << "Open file: '" << name << "'" << endl;
     87
     88    //
     89    // create the new char array containing the filenames to process
     90    //
     91    const int sz  = strlen(name)+1;
     92
     93    char *dummy = new char[arrsz-sz];
     94    memcpy(dummy, name+sz, arrsz-sz);
     95
     96    //
     97    // dummy will be deleted by the destructor of fFileNames
     98    //
     99    fFileNames->Adopt(arrsz-sz, dummy);
     100
     101    return kTRUE;
     102
    31103}
    32104
     
    38110
    39111    //
    40     // open the input stream and check if it is really open (file exists?)
    41     //
    42     fIn = new ifstream(fFileName);
    43     if (!(*fIn))
    44     {
    45         *fLog << dbginf << "Cannot open file." << endl;
    46         return kFALSE;
    47     }
     112    // Try to open at least one (the first) file
     113    //
     114    if (!OpenNextFile())
     115        return kFALSE;
    48116
    49117    //
     
    141209
    142210    //
    143     // check if we are done
     211    // check if we are done. Try to open the next file in chain.
     212    // If it was possible start reading. If not break the event loop
    144213    //
    145214    if (fIn->eof())
    146         return kFALSE;
     215        return OpenNextFile() ? kCONTINUE : kFALSE;
    147216
    148217    //
     
    163232}
    164233
    165 Bool_t MCT1ReadAscii::PostProcess()
    166 {
    167     //
    168     // close and delete the input stream
    169     //
    170     delete fIn;
    171 
    172     return kTRUE;
    173 }
    174 
  • trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.h

    r705 r716  
    66#endif
    77
     8class TArrayC;
    89class MCerPhotEvt;
    910class MPedestalCam;
     
    1213{
    1314private:
    14     TString       fFileName;    //! the file name of the string
    15     ifstream     *fIn;          //! the inputfile
    16     MCerPhotEvt  *fNphot;       //! the data container for all data.
    17     MPedestalCam *fPedest;      //! ct1 pedestals
     15    TString       fFileName;    // the file name of the string
     16    ifstream     *fIn;          // the inputfile
     17    MCerPhotEvt  *fNphot;       // the data container for all data.
     18    MPedestalCam *fPedest;      // ct1 pedestals
     19    TArrayC      *fFileNames;   // Array which stores the \0-terminated filenames
     20
     21    Bool_t OpenNextFile();
    1822
    1923    void ReadPedestals();
     
    2125
    2226public:
    23     MCT1ReadAscii(const char *filename,
     27    MCT1ReadAscii(const char *filename=NULL,
    2428                  const char *name=NULL,
    2529                  const char *title=NULL);
    2630
     31    ~MCT1ReadAscii();
     32
     33    void AddFile(const char *fname);
     34
    2735    Bool_t PreProcess(MParList *pList);
    2836    Bool_t Process();
    29     Bool_t PostProcess();
    3037
    3138    ClassDef(MCT1ReadAscii, 0)  // Reads the CT1 data file
  • trunk/MagicSoft/Mars/manalysis/MHillas.cc

    r713 r716  
    9999Bool_t MHillas::Calc(MGeomCam &geom, MCerPhotEvt &evt)
    100100{
     101    //
     102    // Calculate the Hillas parameters from a cerenkov photon event
     103    // (The calcualtion is some kind of two dimentional statistics)
     104    //
     105
    101106    const UInt_t nevt = evt.GetNumPixels();
    102107
     
    104109    // sanity check
    105110    //
    106     if (nevt<2)
     111    if (nevt <= 2)
    107112        return kFALSE;
    108113
     
    115120    fSize = 0;
    116121
     122    //
     123    // FIXME! npix should be retrieved from MCerPhotEvt
     124    //
     125    UShort_t npix=0;
    117126    for (UInt_t i=0; i<nevt; i++)
    118127    {
     
    129138        xmean += nphot * gpix.GetX(); // [mm]
    130139        ymean += nphot * gpix.GetY(); // [mm]
     140
     141        npix++;
    131142    }
     143
     144    //
     145    // sanity check
     146    //
     147    if (fSize==0 || npix<=2)
     148        return kFALSE;
    132149
    133150    xmean /= fSize; // [mm]
  • trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc

    r715 r716  
    1111ClassImp(MImgCleanStd)
    1212
    13 MImgCleanStd::MImgCleanStd(const char *name, const char *title)
     13MImgCleanStd::MImgCleanStd(const Float_t lvl1, const Float_t lvl2,
     14                           const char *name, const char *title)
     15    : fCleanLvl1(lvl1), fCleanLvl2(lvl2)
    1416{
    1517    //
     
    1820 
    1921    *fName  = name  ? name  : "MImgCleanStd";
    20     *fTitle = name  ? name : "Task which does a standard image cleaning";
    21 }
    22 
    23 void MImgCleanStd::CleanLevel1()
     22    *fTitle = title ? title : "Task which does a standard image cleaning";
     23}
     24
     25void MImgCleanStd::CleanStep1()
    2426{
    2527    //
    2628    //  This method looks for all pixels with an entry (photons)
    2729    //  that is three times bigger than the noise of the pixel
     30    //  (std: 3 sigma, clean level 1)
    2831    //
    2932
     
    4144        const Float_t noise = pix.GetErrorPhot();
    4245
    43         if (entry < 3 * noise )
     46        if (entry < fCleanLvl1 * noise )
    4447            pix.SetPixelUnused();
    4548    }
    4649}
    4750
    48 void MImgCleanStd::CleanLevel2()
     51void MImgCleanStd::CleanStep2()
    4952{
    5053    //
     
    113116}
    114117
    115 void MImgCleanStd::CleanLevel3()
     118void MImgCleanStd::CleanStep3()
    116119{
    117120    //
    118121    //   Look for the boundary pixels around the core pixels
    119     //   if a pixel has more than 2.5 sigma, and a core neigbor
    120     //   it is declared as used.
     122    //   if a pixel has more than 2.5 (clean level 2) sigma, and
     123    //   a core neigbor it is declared as used.
    121124    //
    122125    const Int_t entries = fEvt->GetNumPixels();
     
    141144        const Float_t noise = pix.GetErrorPhot();
    142145
    143         if (entry <= 2.5 * noise )
     146        if (entry <= fCleanLvl2 * noise )
    144147            continue;
    145148
     
    198201Bool_t MImgCleanStd::Process()
    199202{
    200     CleanLevel1();
    201     CleanLevel2();
    202     CleanLevel3();
     203    CleanStep1();
     204    CleanStep2();
     205    CleanStep3();
    203206
    204207    return kTRUE;
  • trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h

    r715 r716  
    1818    MCerPhotEvt *fEvt;
    1919
     20    Float_t fCleanLvl1;
     21    Float_t fCleanLvl2;
     22
    2023public:
    21     MImgCleanStd(const char *name=NULL, const char *title=NULL) ;
     24    MImgCleanStd(const Float_t lvl1=3.0, const Float_t lvl2=2.5,
     25                 const char *name=NULL, const char *title=NULL);
    2226
    23     void CleanLevel1();
    24     void CleanLevel2();
    25     void CleanLevel3();
     27    void CleanStep1();
     28    void CleanStep2();
     29    void CleanStep3();
    2630
    2731    Bool_t PreProcess (MParList *pList);
Note: See TracChangeset for help on using the changeset viewer.