Changeset 1664 for trunk/MagicSoft


Ignore:
Timestamp:
11/21/02 16:20:21 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1662 r1664  
    1919   * macros/collarea.C:
    2020     - some simplifications
     21
     22   * mhist/MHMcRate.h, mhist/MHMcIntRate.h, mhist/MHEnergyTime.h,
     23     mhist/MHEnergyTheta.h, mfileio/MCTReadPreProc.cc, mfileio/MChain.h,
     24     mfileio/MReadMarsFile.h, mfileio/MReadTree.cc, mfileio/MWriteAsciiFile.h,
     25     mfileio/MWriteRoootFile.[h,cc], manalysis/MMatrixLoop.h,
     26     manalysis/MEnergyEstimate.h, mbase/MGGroupFrame.h, mbase/MGTask.h,
     27     mfilter/MFParticleId.h:
     28     - updated documentation
     29
     30   * mfileio/MCT1ReadPreProc.cc:
     31     - Changed MSrcPosCam name from Source to MSrcPosCam
     32     - changed the way the MC data is filled into the MC container
     33     - updated algorithm to read preproc files
     34
     35   * mfileio/MReadMarsFile.cc:
     36     - printed a warning to the screen in case Camera=V0.5
     37
     38   * mfileio/structures.h:
     39     - changed to version 0.6
     40
     41   * mmc/MMcEvt.hxx:
     42     - added GetTelescopePhi
     43     - added GetTelescopeTheta
    2144
    2245   * mdata/MDataChain.[h,cc]:
  • trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.h

    r1211 r1664  
    2323    Bool_t Process();
    2424
    25     ClassDef(MEnergyEstimate, 0) // Task to estimate the energy
     25    ClassDef(MEnergyEstimate, 0) // Task to copy the MC energy (preliminary)
    2626};
    2727
  • trunk/MagicSoft/Mars/manalysis/MMatrixLoop.h

    r1525 r1664  
    3030    Bool_t Process();
    3131
    32     ClassDef(MMatrixLoop, 0)
     32    ClassDef(MMatrixLoop, 0) // Task 'reading' events from a MHMatrix
    3333};
    3434
  • trunk/MagicSoft/Mars/mbase/MGGroupFrame.h

    r1076 r1664  
    3737    virtual Bool_t ProcessMessage(Long_t msg, Long_t param1, Long_t param2);
    3838
    39     ClassDef(MGGroupFrame, 0)
     39    ClassDef(MGGroupFrame, 0) // A interface to widgets in a group frame (makes live easier)
    4040};
    4141
  • trunk/MagicSoft/Mars/mbase/MGTask.h

    r1080 r1664  
    4545    void CreateGui(TGCompositeFrame *f, TGLayoutHints *layout=NULL);
    4646
    47     ClassDef(MGTask, 0)         //Abstract base class for a task
     47    ClassDef(MGTask, 0) // Abstract base class for a task having a gui
    4848};
    4949
  • trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.h

    r1013 r1664  
    4444                 UInt_t w=800, UInt_t h=500,
    4545                 UInt_t options = kMainFrame|kVerticalFrame);
    46 
    4746    ~MGDisplayAdc();
    4847
  • trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc

    r1663 r1664  
    112112void MCT1ReadPreProc::AddFile(const char *txt)
    113113{
    114     ifstream *store = fIn;
    115 
    116     fIn = new ifstream(gSystem->ExpandPathName(txt));
    117 
    118     if (!(*fIn))
    119     {
    120         *fLog << warn << "Cannot open file '" << txt << "'... ignored." << endl;
    121         fIn = store;
     114    const TString fname = gSystem->ExpandPathName(txt);
     115
     116    if (!CheckHeader(fname))
     117    {
     118        *fLog << warn << "WARNING - Problem reading header... ignored." << endl;
    122119        return;
    123120    }
    124121
    125     fEntries += GetNumEvents();
    126 
    127     delete fIn;
    128 
    129     fIn = store;
     122    const Int_t n = GetNumEvents(fname);
     123    if (n==0)
     124    {
     125        *fLog << warn << "WARNING - File contains no data... ignored." << endl;
     126        return;
     127    }
     128
     129    fEntries += n;
     130
     131    *fLog << inf << "File " << txt << " contains " << n << " events (Total=" << fEntries << ")" << endl;
    130132
    131133    fFileNames->AddLast(new TNamed(txt, ""));
     
    390392           &dummy/*&outpars.eruntype*/,   &outpars.iproc_mjdate);
    391393
    392     if (STRUCT_VERSION != structversion)
     394    if (fpreprocversion<0.6)
     395    {
     396        *fLog << err << "Sorry only files from PreProc V0.6 and newer are supported." << endl;
     397        return kFALSE;
     398    }
     399
     400    //
     401    // This is a stupid way of getting rid of numerical uncertanties when
     402    // comparing floating point numbers (Argh...)
     403    //
     404    TString s1 = Form("%.2f", structversion);
     405    TString s2 = Form("%.2f", STRUCT_VERSION);
     406
     407    if (s1 != s2)
    393408    {
    394409        *fLog << warn << "WARNING: Version of C-structures of file (V";
    395         *fLog << structversion << ") not identical with current structures (V";
    396         *fLog << STRUCT_VERSION << ")" << endl;
     410        *fLog << s1 << ") not identical with current structures (V";
     411        *fLog << s2 << ")" << endl;
    397412    }
    398413
     
    404419}
    405420
    406 Bool_t MCT1ReadPreProc::ReadRunFooter()
     421Int_t MCT1ReadPreProc::ReadRunFooter()
    407422{
    408423    char cheadertitle[iHEADERTITLELENGTH];
     
    420435    {
    421436        fIn->seekg(-iHEADERTITLELENGTH, ios::cur);
    422         return kFALSE;
     437        return 0;
    423438    }
    424439
     
    444459     */
    445460
    446     fNumFilterEvts += filterres.ifilter_passed_evts;
     461    if (fNumEventsInRun!=(UInt_t)filterres.ifilter_passed_evts)
     462    {
     463        *fLog << err << "ERROR! Number of events in run (" << (UInt_t)filterres.ifilter_passed_evts;
     464        *fLog << ") doesn't match number of read events (";
     465        *fLog << fNumEventsInRun << ")" << endl;
     466        *fLog << "       File corrupted." << endl;
     467        return -1;
     468    }
     469
     470    fNumFilterEvts += fNumEventsInRun;
    447471    fNumRuns++;
    448472
    449     *fLog << inf << "Read " << fNumEventsInRun << " events from run." << endl;
    450 
    451     if (fNumEventsInRun!=(UInt_t)filterres.ifilter_passed_evts)
    452     {
    453         *fLog << warn << "WARNING! Number of events in run doesn't match number of read events." << endl;
    454         *fLog << "         File might be corrupt." << endl;
    455     }
    456 
    457     return kTRUE;
     473    *fLog << inf << "Read " << fNumEventsInRun << " events from run (Total=";
     474    *fLog << fNumFilterEvts << "/" << fEntries << " [";
     475    *fLog << 100*fNumFilterEvts/fEntries << "%], Runs=" << fNumRuns << ")";
     476    *fLog << endl;
     477
     478    return 1;
    458479}
    459480
     
    481502    // open the file which is the first one in the chain
    482503    //
    483     const char *name = file->GetName();
    484 
    485     fIn = new ifstream(gSystem->ExpandPathName(name));
    486 
    487     if (!(*fIn))
    488     {
    489         *fLog << dbginf << "Cannot open file '" << name << "'" << endl;
    490         return kFALSE;
    491     }
    492 
    493     *fLog << "Open file: '" << name << "'" << endl;
     504    const TString name  = file->GetName();
     505    const TString fname = gSystem->ExpandPathName(name);
    494506
    495507    //
     
    498510    fFileNames->Remove(file);
    499511
     512    *fLog << inf << "Open file: '" << name << "'" << endl;
     513
     514    if (!CheckHeader(fname))
     515        return kFALSE;
     516
     517    fIn = new ifstream(fname);
     518
    500519    *fLog << inf << "-----------------------------------------------------------------------" << endl;
    501520
    502     *fLog << "File contains " << GetNumEvents() << " events." << endl;
    503 
    504     // WORKAROUND for not working seekg(0) in GetNumEvents
    505     fIn->close();
    506     fIn->open(gSystem->ExpandPathName(name));
    507 
    508     Bool_t rc = ReadRunHeader();
    509 
    510     if (!rc)
     521    if (!ReadRunHeader())
     522    {
    511523        *fLog << warn << "Unable to read first run header... skipping file." << endl;
    512 
    513     return rc;
    514 }
    515 
    516 Int_t MCT1ReadPreProc::GetNumEvents()
    517 {
    518     *fLog << inf << "Scanning file for size" << flush;
     524        return kFALSE;
     525    }
     526
     527    return kTRUE;
     528}
     529
     530Bool_t MCT1ReadPreProc::CheckHeader(const TString fname) const
     531{
     532    ifstream fin(fname);
     533    if (!fin)
     534    {
     535        *fLog << dbginf << err << "ERROR - Cannot open file '" << fname << "'" << endl;
     536        return kFALSE;
     537    }
     538
     539    char cheadertitle[iHEADERTITLELENGTH];
     540    fin.read(cheadertitle, iHEADERTITLELENGTH);
     541
     542    Float_t fpreprocversion, structversion, dummy;
     543
     544    sscanf(cheadertitle, cTITLE_TEMPLATE,
     545           &fpreprocversion, &structversion,
     546           &dummy, &dummy, &dummy, &dummy);
     547
     548    if (fpreprocversion < 0.6)
     549    {
     550        *fLog << dbginf << err << "ERROR - You must use PreProc V0.6 or higher." << endl;
     551        return kFALSE;
     552    }
     553
     554    if (STRUCT_VERSION > structversion)
     555    {
     556        *fLog << warn << "WARNING: Version of C-structures of file (V";
     557        *fLog << structversion << ") newer than current structures (V";
     558        *fLog << STRUCT_VERSION << ")" << endl;
     559    }
     560
     561    *fLog << "Current structures: " << STRUCT_VERSION << "  ";
     562    *fLog << "Structures in file: " << structversion << "  ";
     563    *fLog << "Used preproc version: " << fpreprocversion << endl;
     564
     565    return kTRUE;
     566}
     567
     568
     569Int_t MCT1ReadPreProc::GetNumEvents(const TString fname) const
     570{
     571    *fLog << inf << "Scanning file " << fname << " for size" << flush;
     572
     573    ifstream fin(fname);
     574    if (!fin)
     575    {
     576        *fLog << dbginf << err << "ERROR - Opening file." << endl;
     577        return 0;
     578    }
    519579
    520580    const TString m(cEND_EVENTS_TEMPLATE);
     
    525585    Int_t nruns = 0;
    526586
    527     while (!fIn->eof())
    528     {
    529         fIn->seekg(iHEADERTITLELENGTH, ios::cur);
    530         fIn->seekg(sizeof(struct outputpars), ios::cur);
     587    while (!fin.eof() && fin.peek()!=EOF)
     588    {
     589        fin.seekg(iHEADERTITLELENGTH, ios::cur);
     590        fin.seekg(sizeof(struct outputpars), ios::cur);
    531591
    532592        while (1)
    533593        {
    534             if (fIn->peek()==cEND_EVENTS_TEMPLATE[0])
     594            if (fin.peek()==cEND_EVENTS_TEMPLATE[0])
    535595            {
    536596                char cheadertitle[iHEADERTITLELENGTH];
    537                 fIn->read(cheadertitle, iHEADERTITLELENGTH);
     597                fin.read(cheadertitle, iHEADERTITLELENGTH);
    538598
    539599                const TString s = cheadertitle;
    540600                if (s.BeginsWith(test))
    541601                {
    542                     fIn->seekg(sizeof(struct filterresults), ios::cur);
     602                    fin.seekg(sizeof(struct filterresults), ios::cur);
    543603                    nruns++;
    544604                    break;
    545605                }
    546606
    547                 fIn->seekg(-iHEADERTITLELENGTH, ios::cur);
     607                fin.seekg(-iHEADERTITLELENGTH, ios::cur);
    548608            }
    549609
    550             fIn->seekg(sizeof(struct eventrecord), ios::cur);
    551             if (fIn->eof())
     610            fin.seekg(sizeof(struct eventrecord), ios::cur);
     611            if (fin.eof())
    552612                break;
     613
    553614            nevts++;
    554615        }
     
    746807        // must be an event
    747808        //
    748         if (!ReadRunFooter())
     809        switch (ReadRunFooter())
     810        {
     811        case -1:
     812            return kFALSE;
     813        case 0:
    749814            return kTRUE;
     815        }
    750816
    751817        *fLog << inf << "Footer found." << endl;
     818
     819        const char c = fIn->peek();
    752820
    753821        //
    754822        // No after reading the footer check if we reached the end of the file
    755823        //
    756         if (fIn->eof())
     824        if (fIn->eof() || c==EOF)
    757825        {
    758826            *fLog << "End of file." << endl;
     
    763831        // If the eof isn't reached a new header must follow. Check for it.
    764832        //
    765         if (fIn->peek()!=cTITLE_TEMPLATE[0])
     833        if (c!=cTITLE_TEMPLATE[0])
    766834        {
    767835            *fLog << inf << "Error finding new run header in file (possible EOF)... skipping rest of file." << endl;
     
    813881    *fLog << "Number of Events read from file: " << fNumEvents << endl;
    814882    *fLog << "Number of Runs read from file:   " << fNumRuns << endl;
     883    *fLog << "Number of events detected first: " << fEntries << endl;
    815884
    816885    if (fNumEvents!=fNumFilterEvts)
  • trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h

    r1663 r1664  
    4242    Bool_t OpenNextFile();
    4343
    44     Int_t  GetNumEvents();
     44    Int_t  GetNumEvents(const TString name) const;
     45    Bool_t CheckHeader(const TString fname) const;
    4546
    4647    void   ReadPedestals();
    4748    Bool_t ReadRunHeader();
    48     Bool_t ReadRunFooter();
     49    Int_t ReadRunFooter();
    4950    Bool_t CheckFilePosition();
    5051    void   ProcessRunHeader(const struct outputpars &outpars);
  • trunk/MagicSoft/Mars/mfileio/MChain.h

    r1472 r1664  
    2222    Int_t LoadTree(Int_t entry);
    2323
    24     ClassDef(MChain, 1)
     24    ClassDef(MChain, 1) // Class derived from TChain to give access to Notify-return value
    2525};
    2626
  • trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc

    r1600 r1664  
    160160            *fLog << "in this case you may get less photons than you would expect." << endl;
    161161        }
     162        if (mcheader->GetCamVersion==50)
     163        {
     164            *fLog << warn << "Warning - You are using a file created with Camera 0.5." << endl;
     165            *fLog << "In this camera version some events have undefined Impact-Values" << endl;
     166            *fLog << "(MMcEvt::fImpact) Please don't use it for MC studies using the" << endl;
     167            *fLog << "impact parameter." << endl;
     168        }
    162169    }
    163170
  • trunk/MagicSoft/Mars/mfileio/MReadMarsFile.h

    r1472 r1664  
    2626    Int_t AddFile(const char *fname);
    2727
    28     ClassDef(MReadMarsFile, 1)  // Reads a tree from file(s)
     28    ClassDef(MReadMarsFile, 1)  // Reads a tree from file(s) and the information from the 'RunHeader'-tree
    2929};
    3030
  • trunk/MagicSoft/Mars/mfileio/MReadTree.cc

    r1600 r1664  
    5555#include <TFile.h>           // TFile::GetName
    5656#include <TSystem.h>         // gSystem->ExpandPath
    57 //#include <TGProgressBar.h>
    5857#include <TChainElement.h>
    5958#include <TOrdCollection.h>
  • trunk/MagicSoft/Mars/mfileio/MWriteAsciiFile.h

    r1408 r1664  
    4040    void AddColumns(MParContainer *cont);
    4141
    42     ClassDef(MWriteAsciiFile, 0) // Class to write one container to an ascii file
     42    ClassDef(MWriteAsciiFile, 0) // Class to write data into an ascii file
    4343};
    4444
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc

    r1600 r1664  
    131131    //
    132132
    133     *fLog << inf << "Output File closed and deleted." << endl;
     133    *fLog << inf << "Output File closed and object deleted." << endl;
    134134}
    135135
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h

    r1477 r1664  
    9595    void Print(Option_t *t=NULL) const;
    9696
    97     ClassDef(MWriteRootFile, 1) // Class to write one container to a root file
     97    ClassDef(MWriteRootFile, 1) // Task to write data into a root file
    9898};
    9999
  • trunk/MagicSoft/Mars/mfileio/structures.h

    r1583 r1664  
    3333#define _structures_h_ "__structures_h__"
    3434
    35 #define STRUCT_VERSION 0.5
     35#define STRUCT_VERSION 0.6
    3636
    3737#define iHEADERTITLELENGTH 60
  • trunk/MagicSoft/Mars/mfilter/MFParticleId.h

    r1481 r1664  
    4242    Bool_t Process();
    4343
    44     ClassDef(MFParticleId, 1)           // A Filter for the Level 1 Trigger
     44    ClassDef(MFParticleId, 1) // A Filter for the (corsika) particle Id
    4545};
    4646
Note: See TracChangeset for help on using the changeset viewer.