Changeset 2523 for trunk


Ignore:
Timestamp:
11/18/03 01:42:56 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mreport
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mreport/MReport.cc

    r2520 r2523  
    3838using namespace std;
    3939
    40 Bool_t MReport::Interprete(TString &str)
    41 {
    42     if (!InterpreteHeader(str))
    43         return kFALSE;
    44 
    45     return InterpreteBody(str);
    46 }
    47 
    48 Bool_t MReport::InterpreteBody(TString &str)
    49 {
    50     *fLog << warn << "No interpreter existing for: " << fIdentifier << endl;
    51     return kTRUE;
    52 }
    53 
    5440Bool_t MReport::InterpreteHeader(TString &str)
    5541{
     
    7561    return kTRUE;
    7662}
     63
     64Bool_t MReport::InterpreteBody(TString &str)
     65{
     66    *fLog << warn << "No interpreter existing for: " << fIdentifier << endl;
     67    return kTRUE;
     68}
     69
     70Bool_t MReport::Interprete(TString &str)
     71{
     72    if (!InterpreteHeader(str))
     73        return kFALSE;
     74
     75    if (!InterpreteBody(str))
     76        return kFALSE;
     77
     78    SetReadyToSave();
     79    if (fTime)
     80        fTime->SetReadyToSave();
     81
     82    return kTRUE;
     83}
  • trunk/MagicSoft/Mars/mreport/MReportFileRead.cc

    r2520 r2523  
    4141#include "MParList.h"
    4242
    43 /*
    44 #include "MTime.h"
    45 #include "MParList.h"
    46 #include "MRawRunHeader.h"
    47 #include "MRawEvtHeader.h"
    48 #include "MRawEvtData.h"
    49 #include "MRawCrateData.h"
    50 #include "MRawCrateArray.h"
    51 */
    5243ClassImp(MReportFileRead);
    5344
     
    6152private:
    6253    MReport *fReport;
     54    ULong_t  fNumReports;
    6355
    6456public:
    65     MReportHelp(MReport *rep) : fReport(rep) { }
     57    MReportHelp(MReport *rep) : fReport(rep), fNumReports(0) { }
    6658    const char *GetName() const { return fReport->GetIdentifier(); }
     59    ULong_t GetNumReports() const { return fNumReports; }
    6760    ULong_t Hash() const { return fReport->GetIdentifier().Hash(); }
    6861    MReport *GetReport() { return fReport; }
    6962    void SetTime(MTime *t) { fReport->SetTime(t); }
     63    Bool_t Interprete(TString &str)
     64    {
     65        if (!fReport->Interprete(str))
     66            return kFALSE;
     67
     68        fNumReports++;
     69        return kTRUE;
     70    }
    7071};
    7172
     
    9596}
    9697
     98MReportHelp *MReportFileRead::GetReportHelp(const TString &str) const
     99{
     100    return (MReportHelp*)fList->FindObject(str);
     101}
     102
     103MReport *MReportFileRead::GetReport(MReportHelp *help) const
     104{
     105    return help ? help->GetReport() : 0;
     106}
     107
    97108MReport *MReportFileRead::GetReport(const TString &str) const
    98109{
    99     MReportHelp *rep = (MReportHelp*)fList->FindObject(str);
    100     return rep ? rep->GetReport() : 0;
     110    return GetReport(GetReportHelp(str));
    101111}
    102112
     
    201211    TString str;
    202212
    203     MReport *rep=NULL;
    204     while (!rep)
     213    MReportHelp *rep=NULL;
     214    while (!GetReport(rep))
    205215    {
    206216        str.ReadLine(*fIn);
     
    215225            continue;
    216226
    217         rep = GetReport(str(0,pos));
    218         if (rep)
     227        rep = GetReportHelp(str(0,pos));
     228        if (GetReport(rep))
    219229            str.Remove(0, pos);
    220230    }
     
    222232    if (!rep->Interprete(str))
    223233    {
    224         *fLog << err << "ERROR - Interpretation of '" << rep->GetIdentifier() << "' failed." << endl;
     234        *fLog << err << "ERROR - Interpretation of '" << rep->GetName() << "' failed." << endl;
    225235        return kFALSE;
    226236    }
     
    237247Int_t MReportFileRead::PostProcess()
    238248{
    239     /*
    240     //
    241     // Sanity check for the number of events
    242     //
    243     if (fRawRunHeader->GetNumEvents() == GetNumExecutions()-1)
    244         return kTRUE;
    245 
    246     *fLog << warn << "Warning - number of read events (" << GetNumExecutions()-1;
    247     *fLog << ") doesn't match number in run header (";
    248     *fLog << fRawRunHeader->GetNumEvents() << ")." << endl;
    249     */
    250249    fIn->close();
    251     return kTRUE;
    252 }
     250
     251    *fLog << inf << endl;
     252    *fLog << GetDescriptor() << " statistics:" << endl;
     253    *fLog << dec << setfill(' ');
     254
     255    TIter Next(fList);
     256    MReportHelp *rep=0;
     257
     258    while ((rep=(MReportHelp*)Next()))
     259    {
     260        *fLog << " " << setw(7) << rep->GetNumReports() << " (";
     261        *fLog << setw(3) << (int)(100.*rep->GetNumReports()/GetNumExecutions());
     262        *fLog << "%): " << rep->GetName() << endl;
     263    }
     264
     265    return kTRUE;
     266}
  • trunk/MagicSoft/Mars/mreport/MReportFileRead.h

    r2520 r2523  
    1414class MTime;
    1515class MReport;
     16class MReportHelp;
    1617
    1718class MReportFileRead : public MTask
     
    2122    static const TString gsVersionPrefix;
    2223
    23     TString         fFileName;
    24     ifstream       *fIn;            //! buffered input stream (file to read from)
     24    TString     fFileName;
     25    ifstream   *fIn;         //! buffered input stream (file to read from)
    2526
    2627    THashTable *fList;
     
    3233    Bool_t CheckFileHeader() const;
    3334    MReport *GetReport(const TString &str) const;
     35    MReport *GetReport(MReportHelp *help) const;
     36    MReportHelp *GetReportHelp(const TString &str) const;
    3437
    3538public:
Note: See TracChangeset for help on using the changeset viewer.