Ignore:
Timestamp:
02/26/04 17:22:46 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mfileio
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mfileio/MWriteAsciiFile.cc

    r3238 r3336  
    188188// a warning message is print.
    189189//
    190 void MWriteAsciiFile::CheckAndWrite() const
     190Bool_t MWriteAsciiFile::CheckAndWrite() const
    191191{
    192192    Bool_t written = kFALSE;
     
    219219    }
    220220
    221     if (!written)
    222         return;
    223 
    224     *fOut << endl;
    225 
    226     if (num!=0)
    227         *fLog << warn << "Warning - given number of objects doesn't fit number of written objects." << endl;
     221    if (written)
     222    {
     223        *fOut << endl;
     224
     225        if (num!=0)
     226            *fLog << warn << "Warning - given number of objects doesn't fit number of written objects." << endl;
     227    }
     228    return kTRUE;
    228229}
    229230
  • trunk/MagicSoft/Mars/mfileio/MWriteAsciiFile.h

    r1664 r3336  
    2121    TObjArray fAutoDel; //! List of object to be deleted in the destructor
    2222
    23     virtual void  CheckAndWrite() const;
     23    virtual Bool_t CheckAndWrite() const;
    2424    virtual Bool_t IsFileOpen() const;
    2525    virtual Bool_t GetContainer(MParList *pList);
  • trunk/MagicSoft/Mars/mfileio/MWriteFile.cc

    r2958 r3336  
    7878    // write the container if it is already in changed state
    7979    //
    80     CheckAndWrite();
    81 
    82     return kTRUE;
     80    return CheckAndWrite();
    8381}
    8482
     
    9088Bool_t MWriteFile::ReInit(MParList *pList)
    9189{
    92     CheckAndWrite();
    93     return kTRUE;
     90    return CheckAndWrite();
    9491}
    9592
     
    10198Int_t MWriteFile::Process()
    10299{
    103     CheckAndWrite();
    104     return kTRUE;
     100    return CheckAndWrite();
    105101}
    106102
     
    115111    // check if the container changed state is set
    116112    //
    117     CheckAndWrite();
    118     return kTRUE;
     113    return CheckAndWrite();
    119114}
  • trunk/MagicSoft/Mars/mfileio/MWriteFile.h

    r2959 r3336  
    1515
    1616    virtual Bool_t      IsFileOpen() const = 0;
    17     virtual void        CheckAndWrite() const = 0;
     17    virtual Bool_t      CheckAndWrite() const = 0;
    1818    virtual Bool_t      GetContainer(MParList *pList) = 0;
    1919    virtual const char *GetFileName() const = 0;
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc

    r3199 r3336  
    338338        entry->SetTree(tree);
    339339
     340        TString branchname(cname);
     341        branchname.Append(".");
     342
    340343        //
    341344        // Try to get the branch from the file.
    342345        // If the branch already exists the user specified one branch twice.
    343346        //
    344         TBranch *branch = tree->GetBranch(cname);
     347        TBranch *branch = tree->GetBranch(branchname);
    345348        if (branch)
    346349        {
    347             *fLog << err << "Branch '" << cname << "' already existing." << endl;
    348             return kFALSE;
    349         }
    350 
    351         //
    352         // Create a new branch in the actual tree. The branch has the name
    353         // container name. The type of the container is given by the
    354         // ClassName entry in the container. The Address is the address of a
    355         // pointer to the container (gotten from the branch entry). As
    356         // Basket size we specify a (more or less) common default value.
    357         // The containers should be written in Splitlevel=1
    358         //
    359         *fLog << inf << "Creating Branch " << cname << " of " << cont->ClassName() << "... " << flush;
    360 
    361         TString branchname(cname);
    362         branchname.Append(".");
    363         branch = tree->Branch(branchname, cont->ClassName(), entry->GetAddress());
    364 
    365         //
    366         // If the branch couldn't be created we have a problem.
    367         //
    368         if (!branch)
    369         {
    370             *fLog << endl;
    371             *fLog << err << "Unable to create branch '" << cname << "'." << endl;
    372             return kFALSE;
    373         }
    374 
    375         *fLog << "done." << endl;
     350            *fLog << inf << "Branch '" << cname << "' already existing... updating." << endl;
     351            branch->SetAddress(entry->GetAddress());
     352        }
     353        else
     354        {
     355            //
     356            // Create a new branch in the actual tree. The branch has the name
     357            // container name. The type of the container is given by the
     358            // ClassName entry in the container. The Address is the address of a
     359            // pointer to the container (gotten from the branch entry). As
     360            // Basket size we specify a (more or less) common default value.
     361            // The containers should be written in Splitlevel=1
     362            //
     363            *fLog << inf << "Creating Branch " << cname << " of " << cont->ClassName();
     364            *fLog << " in tree " << tree->GetName() << "... " << flush;
     365
     366            branch = tree->Branch(branchname, cont->ClassName(), entry->GetAddress());
     367            //
     368            // If the branch couldn't be created we have a problem.
     369            //
     370            if (!branch)
     371            {
     372                *fLog << endl;
     373                *fLog << err << "Unable to create branch '" << cname << "'." << endl;
     374                return kFALSE;
     375            }
     376
     377            *fLog << "done." << endl;
     378        }
    376379
    377380        //
     
    398401// has the write flag, all containers in this tree are filled!
    399402//
    400 void MWriteRootFile::CheckAndWrite() const
     403Bool_t MWriteRootFile::CheckAndWrite() const
    401404{
    402405    TObject *obj;
     
    423426            b->GetTree()->SetBit(kFillTree);
    424427        else
    425             b->GetBranch()->Fill();
     428        {
     429            if (!b->GetBranch()->Fill())
     430            {
     431                *fLog << err << "ERROR - Zero bytes written to branch '" << b->GetBranch()->GetName() << "'... abort." << endl;
     432                return kFALSE;
     433            }
     434        }
    426435    }
    427436
     
    445454        // of written/filled entries.
    446455        //
    447         t->Fill();
    448456        t->ResetBit(kFillTree);
    449     }
     457        if (!t->Fill())
     458        {
     459            *fLog << err << "ERROR - Zero bytes written to tree '" << t->GetName() << "'... abort." << endl;
     460            return kFALSE;
     461        }
     462    }
     463    return kTRUE;
    450464}
    451465
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h

    r2604 r3336  
    7575    //UInt_t fNumEvents; //! Number of events written in a run
    7676
    77     void        CheckAndWrite() const;
     77    Bool_t      CheckAndWrite() const;
    7878    Bool_t      IsFileOpen() const;
    7979    Bool_t      GetContainer(MParList *pList);
Note: See TracChangeset for help on using the changeset viewer.