Ignore:
Timestamp:
06/20/09 10:14:33 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mbase
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbase/MLut.cc

    r9318 r9462  
    7070//
    7171// Check if it is a default lut which would just map every entry to itself
    72 // An empty Lut is a default lut
    73 //
    74 Bool_t MLut::IsDefault() const
     72// An empty Lut is a default column
     73//
     74Bool_t MLut::IsDefaultCol() const
    7575{
    7676    if (IsEmpty())
     
    9292// Setup a default lut which just maps n-entris to themself
    9393//
    94 void MLut::SetDefault(UInt_t n)
     94void MLut::SetDefaultCol(UInt_t n)
    9595{
    9696    Delete();
     
    106106    fMinEntries = 1;
    107107    fMaxEntries = 1;
     108
     109    fMaxIndex = n;
     110}
     111
     112// --------------------------------------------------------------------------
     113//
     114// Check if it is a default lut which would just map all entries to one.
     115// An empty Lut is a default row
     116//
     117Bool_t MLut::IsDefaultRow() const
     118{
     119    if (IsEmpty())
     120        return kTRUE;
     121
     122    if (GetEntriesFast()!=1)
     123        return kFALSE;
     124
     125    const MArrayI &idx = GetRow(0);
     126
     127    // Loop over all rows
     128    for (UInt_t x=0; x<idx.GetSize(); x++)
     129        if (UInt_t(idx[x])!=x)
     130            return kFALSE;
     131
     132    return kTRUE;
     133}
     134
     135
     136// --------------------------------------------------------------------------
     137//
     138// Setup a default lut which maps all n-entris to one
     139//
     140void MLut::SetDefaultRow(UInt_t n)
     141{
     142    Delete();
     143
     144    MArrayI &idx = *new MArrayI(n);
     145
     146    for (UInt_t y=0; y<n; y++)
     147        idx[y] = y;
     148
     149    Add(&idx);
     150
     151    fMinEntries = n;
     152    fMaxEntries = n;
    108153
    109154    fMaxIndex = n;
     
    288333// Write a lut to a stream.
    289334//
    290 Int_t MLut::WriteStream(ostream &out)
     335Int_t MLut::WriteStream(ostream &out) const
    291336{
    292337    const Int_t n = GetEntriesFast();
     
    329374// Write a lut to a file
    330375//
    331 Int_t MLut::WriteFile(const char *fname)
     376Int_t MLut::WriteFile(const char *fname) const
    332377{
    333378    TString expname(fname);
     
    344389    return WriteStream(fout);
    345390}
     391
     392void MLut::Print(const Option_t *o) const
     393{
     394    gLog << all;
     395    WriteStream(gLog);
     396}
  • trunk/MagicSoft/Mars/mbase/MLut.h

    r9318 r9462  
    3636    Bool_t HasConstantLength() const { return fMinEntries==fMaxEntries; }
    3737    Bool_t IsEmpty() const { return fMaxEntries==0; }
    38     Bool_t IsDefault() const;
     38    Bool_t IsDefaultCol() const;
     39    Bool_t IsDefaultRow() const;
    3940
    4041    // MLut conversions
     
    4344
    4445    // Setter
    45     void SetDefault(UInt_t n);
     46    void SetDefaultCol(UInt_t n);
     47    void SetDefaultRow(UInt_t n);
    4648
    4749    // MLut I/O
    4850    Int_t ReadStream(istream &in);
    49     Int_t WriteStream(ostream &out);
     51    Int_t WriteStream(ostream &out) const;
    5052
    5153    Int_t ReadFile(const char *fname);
    52     Int_t WriteFile(const char *fname);
     54    Int_t WriteFile(const char *fname) const;
     55
     56    // TObject
     57    void Print(const Option_t *o="") const;
     58    void Print(const Option_t *o, const Option_t *o2) const { Print(o); }
    5359
    5460    ClassDef(MLut, 1) // A simple and fast easy-to-use look-up-table
  • trunk/MagicSoft/Mars/mbase/MParList.cc

    r9347 r9462  
    184184        return kFALSE;
    185185
     186    if (cont==this)
     187    {
     188        *fLog << err << dbginf << "Error: It is not allowed to add a parameter list to itself." << endl;
     189        return kFALSE;
     190    }
     191
    186192    //
    187193    // Get Name of new container
     
    223229        if (!fContainer->FindObject(where))
    224230        {
    225             *fLog << dbginf << "Error: Cannot find parameter container after which the new one should be added!" << endl;
     231            *fLog << err << dbginf << "Error: Cannot find parameter container after which the new one should be added!" << endl;
    226232            return kFALSE;
    227233        }
     
    230236    if (!cont->InheritsFrom(MParContainer::Class()))
    231237    {
    232         *fLog << dbginf << "Error: Cantainer MUST derive from MParContainer!" << endl;
     238        *fLog << err << dbginf << "Error: Cantainer MUST derive from MParContainer!" << endl;
    233239        return kFALSE;
    234240    }
Note: See TracChangeset for help on using the changeset viewer.