PerOutputStream Class Reference

#include <PerOutputStream.h>

Inheritance diagram for PerOutputStream:
PerStream

List of all members.

Public Member Functions

 PerOutputStream (std::string treename, std::string classname, std::string username="", std::string inputstreamname="", Int_t splitlevel=0, Int_t basketsize=64000, Int_t compress=-1)
virtual ~PerOutputStream ()
UInt_t GetAutoSaveInt () const
UInt_t GetAutoSaveTime () const
UInt_t GetAutoSaveBytes () const
Int_t GetSplitLevel () const
bool IsBasketSaveLinked () const
std::string GetUserName () const
std::string GetInputStreamName () const
std::ostream & Print (std::ostream &s) const
virtual void AutoSaveByTime (UInt_t currentVldTime)
virtual void Close ()
virtual void CloseFile ()
void SetAutoSave (UInt_t autoSaveInt=0, UInt_t autoSaveTime=0, UInt_t autoSaveBytes=0, bool basketSaveLinked=true)
bool SetFile (std::string fullfilepathname, Per::EAccessMode accessmode=Per::kRecreate)
bool SetObject (TObject *object)
Int_t Store ()
Int_t Write ()

Private Member Functions

bool IsFileChange () const
void ChangeFile ()

Private Attributes

std::string fUserName
std::string fInputStreamName
Int_t fSplitLevel
Int_t fBasketSize
Int_t fCompress
UInt_t fAutoSaveInt
UInt_t fAutoSaveTime
UInt_t fAutoSaveBytes
Int_t fLastEntrySaved
UInt_t fLastTimeSaved
UInt_t fLastBytesSaved
UInt_t fTotalBytes
bool fBasketSaveLinked

Detailed Description

Definition at line 24 of file PerOutputStream.h.


Constructor & Destructor Documentation

PerOutputStream::PerOutputStream ( std::string  treename,
std::string  classname,
std::string  username = "",
std::string  inputstreamname = "",
Int_t  splitlevel = 0,
Int_t  basketsize = 64000,
Int_t  compress = -1 
)
PerOutputStream::~PerOutputStream (  )  [virtual]

Definition at line 187 of file PerOutputStream.cxx.

00187                                   {
00188   //
00189   //  Purpose:  PerOutputStream destructor.  
00190   //
00191   //  Contact:   S. Kasahara
00192   // 
00193 
00194 }


Member Function Documentation

void PerOutputStream::AutoSaveByTime ( UInt_t  currentVldTime  )  [virtual]

Definition at line 44 of file PerOutputStream.cxx.

References cd(), Msg::kDebug, and MSG.

00044                                                           {
00045   //
00046   // Purpose: AutoSave stream if new entries on this tree and currentvldtime
00047   //          passed from manager satisfies autosavetime requirement. 
00048   //
00049 
00050 
00051   if ( !IsOpen() || fEntry == -1 ) return;
00052 
00053   TDirectory* savedir = gDirectory; // save current working directory
00054 
00055   if ( IsFileChange() ) ChangeFile();
00056 
00057   bool isAutoSave = false;
00058   
00059   if (!fLastTimeSaved) fLastTimeSaved = currentVldTime;
00060   // Save tree to file if requested on this entry and/or time interval
00061   bool isAutoSaveTime
00062      = (fAutoSaveTime > 0 && (currentVldTime - fLastTimeSaved) >= fAutoSaveTime);
00063   if ( isAutoSaveTime && fLastEntrySaved != fEntry ) isAutoSave = true;
00064   
00065   if ( isAutoSave && fBasketSaveLinked ) {
00066     // Reset basket size so baskets will be dumped on next TTree::Fill
00067     // if more than 1 kbyte of data in that buffer
00068     fTBranch -> SetBasketSize(1000);
00069   } else {
00070     fTBranch -> SetBasketSize(fBasketSize); // reset to default basketsize
00071   }
00072 
00073   if ( isAutoSave ) {
00074     Int_t savecompress = 9;
00075     if ( fCompress >= 0 ) {
00076       savecompress = fTFile -> GetCompressionLevel();
00077       fTFile -> SetCompressionLevel(fCompress);
00078     }
00079 
00080     // Save tree to file if requested on this entry interval
00081     MSG("Per",Msg::kDebug) << "AutoSaving tree " << fTreeName << " with " 
00082        << fTTree->GetEntries() << " entries to file " 
00083        << fFullFilePathName << " ByTime(sec) " 
00084        << currentVldTime << "." << endl;  
00085     fTFile -> cd();
00086     fTTree -> AutoSave();  // save tree to file
00087     fTFile -> SaveSelf();  // save file directory containing this tree
00088     fLastTimeSaved = currentVldTime;
00089     fLastEntrySaved = fEntry;
00090     fLastBytesSaved = fTotalBytes;
00091     if ( fCompress >= 0 )fTFile -> SetCompressionLevel(savecompress);
00092   }
00093     
00094   savedir -> cd(); // return to original working directory
00095 
00096   return;
00097 
00098 }

void PerOutputStream::ChangeFile (  )  [private]

Definition at line 100 of file PerOutputStream.cxx.

References PerFileManager::ChangeFile(), PerStream::fEntry, PerStream::fFullFilePathName, fLastBytesSaved, fLastEntrySaved, fLastTimeSaved, PerStream::fTFile, fTotalBytes, PerStream::fTreeName, PerStream::fTTree, Nav::GetName(), PerFileManager::Instance(), Msg::kInfo, Msg::kWarning, and MSG.

Referenced by CloseFile(), Store(), and Write().

00100                                  {
00101   //
00102   //  Purpose:  This private method is called internally when it is detected
00103   //            that TTree::Fill has closed the current file and opened
00104   //            a new one with extension _n because it has detected that
00105   //            the file limit of 2 GByte is near.
00106   //
00107   //  Arguments: none.
00108   //
00109   //  Return: none.
00110   //
00111   //  Contact:   S. Kasahara
00112   //
00113 
00114                          
00115   TFile* newFile = fTTree->GetCurrentFile();
00116   if ( !newFile ) {
00117     MSG("Per",Msg::kWarning) 
00118       << "ChangeFile requested for tree " << fTreeName << 
00119       " from old file " << fFullFilePathName << " but TTree has null file ptr."
00120       << endl;
00121     return;
00122   }
00123   std::string newFileName = newFile -> GetName();
00124   MSG("Per",Msg::kInfo) << "PerOutputStream::ChangeFile requested for tree " 
00125     << fTreeName << "\nfrom old file " << fFullFilePathName 
00126     << " total entries " << fEntry+1 
00127     << ", to new file " << newFileName << "." << endl; 
00128   PerFileManager& perfilemanager = PerFileManager::Instance();
00129   perfilemanager.ChangeFile(fFullFilePathName,newFileName,newFile);
00130 
00131   fFullFilePathName = newFileName;
00132   fTFile = newFile;
00133      
00134   // All tree parameters get reset upon start of new file
00135   fEntry = static_cast<Int_t>(fTTree->GetEntries()-1);
00136   // All counts start fresh in new file
00137   fLastEntrySaved = fEntry;
00138   fLastTimeSaved = 0; // will be set to 1st record time
00139   fLastBytesSaved = 0; fTotalBytes = 0;
00140 
00141   return;
00142 
00143 }

void PerOutputStream::Close (  )  [virtual]

Reimplemented from PerStream.

Definition at line 291 of file PerOutputStream.cxx.

References CloseFile().

00291                             {
00292   //
00293   //  Purpose:  Close the output stream.
00294   //
00295   //  Arguments: none.
00296   //
00297   //  Return:  none.
00298   //
00299   //  Contact:   S. Kasahara
00300   // 
00301 
00302   CloseFile();
00303 
00304 }

void PerOutputStream::CloseFile ( void   )  [virtual]

Reimplemented from PerStream.

Definition at line 306 of file PerOutputStream.cxx.

References ChangeFile(), fLastBytesSaved, fLastEntrySaved, fLastTimeSaved, fTotalBytes, and IsFileChange().

Referenced by Close().

00306                                 {
00307   //
00308   //  Purpose:  Close the file attached to the output stream.
00309   //
00310   //  Arguments: none.
00311   //
00312   //  Return:  none.
00313   //
00314   //  Contact:   S. Kasahara
00315   // 
00316 
00317   if ( IsFileChange() ) ChangeFile();
00318   fLastEntrySaved = -1;
00319   fLastTimeSaved = 0;
00320   fLastBytesSaved = 0;
00321   fTotalBytes = 0;
00322   PerStream::CloseFile();
00323 
00324 }

UInt_t PerOutputStream::GetAutoSaveBytes (  )  const [inline]

Definition at line 41 of file PerOutputStream.h.

References fAutoSaveBytes.

Referenced by PerOutputStreamManager::Print().

00041 { return fAutoSaveBytes; }

UInt_t PerOutputStream::GetAutoSaveInt (  )  const [inline]

Definition at line 39 of file PerOutputStream.h.

References fAutoSaveInt.

Referenced by PerOutputStreamManager::Print().

00039 { return fAutoSaveInt; }

UInt_t PerOutputStream::GetAutoSaveTime (  )  const [inline]

Definition at line 40 of file PerOutputStream.h.

References fAutoSaveTime.

Referenced by PerOutputStreamManager::Print().

00040 { return fAutoSaveTime; }

std::string PerOutputStream::GetInputStreamName (  )  const [inline]

Definition at line 45 of file PerOutputStream.h.

References fInputStreamName.

Referenced by PerOutputStreamManager::Print().

00045 { return fInputStreamName; }

Int_t PerOutputStream::GetSplitLevel (  )  const [inline]

Definition at line 42 of file PerOutputStream.h.

References fSplitLevel.

Referenced by PerOutputStreamManager::Print().

00042 { return fSplitLevel; }

std::string PerOutputStream::GetUserName (  )  const [inline]

Definition at line 44 of file PerOutputStream.h.

References fUserName.

Referenced by PerOutputStreamManager::Print().

00044 { return fUserName; }

bool PerOutputStream::IsBasketSaveLinked (  )  const [inline]

Definition at line 43 of file PerOutputStream.h.

References fBasketSaveLinked.

00043 { return fBasketSaveLinked; }

bool PerOutputStream::IsFileChange (  )  const [inline, private]

Definition at line 62 of file PerOutputStream.h.

References PerStream::fTFile, PerStream::fTTree, and PerStream::IsOpen().

Referenced by CloseFile(), Store(), and Write().

00062                             {
00063     return ( IsOpen() && (fTTree->GetCurrentFile() != fTFile) ) ? true : false;
00064   }

std::ostream & PerOutputStream::Print ( std::ostream &  s  )  const [virtual]

Reimplemented from PerStream.

Definition at line 196 of file PerOutputStream.cxx.

References fAutoSaveBytes, fAutoSaveInt, fAutoSaveTime, fBasketSaveLinked, fBasketSize, fCompress, fSplitLevel, and fUserName.

Referenced by operator<<().

00196                                                        {
00197   //
00198   //  Purpose:  Print status of stream on std::ostream.
00199   //
00200   //  Arguments: ms std::ostream to display on.
00201   //
00202   //  Return:  std::ostream reference.
00203   //
00204   //  Contact:   S. Kasahara
00205   //
00206 
00207   ms << "  PerOutput"; 
00208   PerStream::Print(ms);
00209 
00210   if (!fUserName.empty()) ms << "  This stream serves objects of username " 
00211                              << fUserName << "." << endl;
00212  
00213   ms << "  TTree SplitLevel = " << fSplitLevel << endl;
00214  
00215   if ( fAutoSaveInt && fAutoSaveTime ) {
00216     ms << "  AutoSaves were requested in intervals of " << fAutoSaveInt
00217        << " entries or " << fAutoSaveTime 
00218        << " seconds,\n  whichever comes first." << endl;
00219   }
00220   else if (fAutoSaveInt) {
00221     ms << "  AutoSaves were requested in intervals of " << fAutoSaveInt 
00222        << " entries." << endl;
00223   }
00224   else if (fAutoSaveTime) {
00225     ms << "  AutoSaves were requested in time intervals of " << fAutoSaveTime
00226        << " seconds." << endl;
00227   }
00228   else if (fAutoSaveBytes) {
00229     ms << "  AutoSaves were requested in byte intervals of " << fAutoSaveBytes
00230        << " bytes." << endl;
00231   }
00232   else {
00233     ms << "  AutoSaves were not requested." << endl;
00234   }
00235 
00236   if (fBasketSaveLinked) {
00237     ms << "  Branch basket dumps are requested to occur at the same\n"
00238        << "  interval as the tree AutoSaves or when the branch basket size\n  "
00239        << fBasketSize << " is reached, whichever comes first." << endl;
00240   }
00241   else {
00242     ms << "  Branch basket dumps were not requested at regular intervals.\n" 
00243        << "  Basket dumps will occur when the basket size "
00244        << fBasketSize << " is reached." << endl;
00245   }
00246   if (fCompress >= 0) {
00247     ms << "  Compression level " << fCompress 
00248        << " was requested for this stream." << endl;
00249   }
00250 
00251   return ms;
00252 
00253 }

void PerOutputStream::SetAutoSave ( UInt_t  autoSaveInt = 0,
UInt_t  autoSaveTime = 0,
UInt_t  autoSaveBytes = 0,
bool  basketSaveLinked = true 
)

Definition at line 255 of file PerOutputStream.cxx.

References fAutoSaveBytes, fAutoSaveInt, fAutoSaveTime, and fBasketSaveLinked.

Referenced by IoOutputModule::DefineStream(), RotoServer::OpenFile(), OltNewModule::OpenFile(), OltNewModule::OpenSpy(), and PerOutputStreamManager::SetAutoSave().

00256                                                                              {
00257   //
00258   //  Purpose:  Set AutoSave interval for this stream.  The TTree will
00259   //            be saved to file every fAutoSaveInt entries OR 
00260   //            OR every fAutoSaveTime (sec) OR every fAutoSaveBytes
00261   //            bytes filled to the tree, whichever comes first.
00262   //            Any or all of the autosave intervals may be set. An autosave
00263   //            parameter set to zero will be ignored.
00264   //
00265   //  Arguments: 
00266   //           autoSaveInt   UInt_t  TTree save entry interval     (default=0 
00267   //                              => no AutoSave requested at entry intervals) 
00268   //           autoSaveTime  UInt_t  TTree save time interval(sec) (default=0 
00269   //                              => no AutoSave requested at time intervals) 
00270   //           autoSaveBytes UInt_t  TTree save byte interval      (default=0 
00271   //                              => no AutoSave requested at byte intervals) 
00272   //        basketSaveLinked bool    tie basket dumps to TTree saves so that
00273   //                                 all branch baskets are dumped just before
00274   //                                 the tree header is saved to disk. 
00275   //                                 (default = true)
00276   //
00277   //  Return:  none
00278   //
00279   //  Contact:   S. Kasahara
00280   //
00281 
00282   fAutoSaveInt   = autoSaveInt;
00283   fAutoSaveTime  = autoSaveTime;
00284   fAutoSaveBytes = autoSaveBytes;
00285   fBasketSaveLinked = basketSaveLinked;
00286   
00287   return;
00288 
00289 }

bool PerOutputStream::SetFile ( std::string  fullfilepathname,
Per::EAccessMode  accessmode = Per::kRecreate 
) [virtual]

Implements PerStream.

bool PerOutputStream::SetObject ( TObject *  object  ) 

Definition at line 447 of file PerOutputStream.cxx.

References PerStream::fClassName, fInputStreamName, fUserName, Registry::Get(), PerStream::GetFullFilePathName(), PerStream::GetStreamName(), PerStream::GetTreeName(), PerStream::IsEnabled(), PerStream::IsModified(), PerStream::IsOpen(), Msg::kWarning, MSG, and PerStream::Reset().

Referenced by OltNewModule::Reco(), OltNewModule::WriteMom(), and RotoServer::WriteRawRecord().

00447                                                {
00448   //
00449   //  Purpose:  Set object to be persisted to ROOT TTree main branch.
00450   //            The object is not actually filled into the branch until the
00451   //            PerOutputStream::Store() method is invoked.
00452   //
00453   //  Arguments: object:  pointer to object to be stored.  Must be of same
00454   //                      type as "ClassName" with which PerOutputStream
00455   //                      was created.  
00456   //
00457   //  Return:  true if stream is successfully updated.
00458   //
00459   //  Contact:   S. Kasahara
00460   // 
00461 
00462   if ( !IsEnabled() ) return false;
00463 
00464   if( IsModified() ) {
00465     // Reset object cache managed by this stream
00466     Reset();
00467   }
00468 
00469   if ( !IsOpen() ) {
00470     MSG("Per",Msg::kWarning) 
00471       << "Attempting to SetObject in an unopened output stream." << endl;
00472     return false;
00473   }
00474 
00475   if ( !object ) {
00476     MSG("Per",Msg::kWarning)
00477       << "PerOutputStream called with null object pointer." << endl;
00478     return false;
00479   }
00480 
00481   if (strcmp(fClassName.c_str(),object->IsA()->GetName())) {
00482     // object is of wrong classname for this stream
00483     return false;
00484   }
00485 
00486   if (!fUserName.empty() && strcmp(fUserName.c_str(),object->GetName())) {
00487     // object is of wrong username for this stream
00488     return false;
00489   }
00490 
00491   Registry* temptags = 0;
00492   bool isPersisted = false;
00493   bool isInputStream = true;
00494   if ( !fInputStreamName.empty() ) isInputStream = false;
00495   if ( RecMinos* record = dynamic_cast<RecMinos*>(object) ) {
00496     temptags = &(record->GetTempTags());
00497     if ( !isInputStream && temptags ) {
00498       const char* objectInputStream = 0;
00499       if ( temptags->Get("stream",objectInputStream) ) {
00500         if ( !strcmp(fInputStreamName.c_str(),objectInputStream) )
00501                                               isInputStream = true;
00502       }
00503     }
00504     // test if object is of wrong input stream name for this stream
00505     if ( !isInputStream ) return false;
00506     // test to see if object has already been persisted to this stream
00507     isPersisted = record->IsPersistedToOutputStream(
00508              this->GetStreamName().c_str(),this->GetFullFilePathName().c_str(),
00509              this->GetTreeName().c_str());
00510   }
00511   else if ( RecRecord* record = dynamic_cast<RecRecord*>(object) ) {
00512     temptags = &(record->GetTempTags());
00513     if ( !isInputStream && temptags ) {
00514       const char* objectInputStream = 0;
00515       if ( temptags->Get("stream",objectInputStream) ) {
00516         if ( !strcmp(fInputStreamName.c_str(),objectInputStream) )
00517                                               isInputStream=true;
00518       }
00519     }
00520     // test if object is of wrong input stream name for this stream
00521     if ( !isInputStream ) return false;
00522     // test if object has already been persisted to this stream
00523     isPersisted = record->IsPersistedToOutputStream(
00524              this->GetStreamName().c_str(),this->GetFullFilePathName().c_str(),
00525              this->GetTreeName().c_str());
00526   }
00527 
00528   if ( !isInputStream || isPersisted ) return false; 
00529 
00530   fTObject = object;
00531   return true; 
00532 
00533 }

Int_t PerOutputStream::Store (  ) 

Definition at line 535 of file PerOutputStream.cxx.

References cd(), ChangeFile(), fAutoSaveBytes, fAutoSaveInt, fAutoSaveTime, fBasketSaveLinked, fCompress, PerStream::fEntry, PerStream::fFullFilePathName, fLastBytesSaved, fLastEntrySaved, fLastTimeSaved, PerStream::fTBranch, PerStream::fTFile, fTotalBytes, PerStream::fTreeName, PerStream::fTTree, PerStream::GetFullFilePathName(), VldTimeStamp::GetSec(), PerStream::GetStreamName(), VldContext::GetTimeStamp(), PerStream::GetTreeName(), GetVldContext(), PerStream::IsEnabled(), IsFileChange(), PerStream::IsModified(), PerStream::IsOpen(), Msg::kDebug, Msg::kWarning, and MSG.

Referenced by OltNewModule::Reco(), OltNewModule::WriteMom(), and RotoServer::WriteRawRecord().

00535                              {
00536   //
00537   //  Purpose:  Fill data in stream tree.
00538   //
00539   //  Arguments: none.
00540   //
00541   //  Return:  number of bytes filled.
00542   //
00543   //  Contact:   S. Kasahara
00544   // 
00545   //  Notes:  This method fills the data into the stream tree. If fAutoSaveInt
00546   //          or fAutoSaveTime interval has been set, it will also
00547   //          invoke the proper methods to save the baskets and tree to file
00548   //          at correct entry and/or time interval.
00549   //
00550 
00551   Int_t nBytes = 0;
00552 
00553   TDirectory* savedir = gDirectory; // save current working directory
00554 
00555   if ( !IsEnabled() || !IsModified() ) {
00556     // disabled streams or streams in which an object has not been loaded
00557     // are not persisted
00558     return nBytes;
00559   }
00560 
00561   if ( !IsOpen() ) {
00562     MSG("Per",Msg::kWarning) 
00563       << "Attempting to store data on unopened output stream." << endl;
00564     return nBytes;
00565   } 
00566 
00567   if ( IsFileChange() ) ChangeFile();
00568 
00569   fEntry++;  // increment current entry number for this stream
00570 
00571   // Determine record validity time in secs
00572   UInt_t recordTime = 0;
00573   if ( RecMinos* record = dynamic_cast<RecMinos*>(fTObject) ) {
00574     recordTime = (record -> GetVldContext() -> GetTimeStamp()).GetSec();
00575     record->PersistedToOutputStream(this->GetStreamName().c_str(),
00576      this->GetFullFilePathName().c_str(),this->GetTreeName().c_str(),fEntry);
00577   }
00578   else if ( RecRecord* record = dynamic_cast<RecRecord*>(fTObject) ) {
00579     recordTime = (record->GetHeader()).GetVldContext().GetTimeStamp().GetSec();
00580     record->PersistedToOutputStream(this->GetStreamName().c_str(),
00581        this->GetFullFilePathName().c_str(),this->GetTreeName().c_str(),fEntry);
00582   }
00583 
00584   if ( !recordTime && fAutoSaveTime ) {
00585     // Records are required to derive from RecMinos class to use autosave
00586     // by time interval.
00587     MSG("Per",Msg::kWarning) << "Using AutoSaveTime requires records\n"
00588     << "to derive from RecMinos or RecRecord class.  Option will be ignored." 
00589     << endl;
00590     fAutoSaveTime = 0;
00591   }
00592 
00593   bool isAutoSave = false;
00594   if (!fLastTimeSaved) fLastTimeSaved = recordTime;
00595   // Save tree to file if requested on this entry and/or time interval
00596   bool isAutoSaveInt 
00597      = (fAutoSaveInt > 0 && (fEntry - fLastEntrySaved) >= (int)fAutoSaveInt);
00598   bool isAutoSaveTime
00599      = (fAutoSaveTime > 0 && (recordTime - fLastTimeSaved) >= fAutoSaveTime);
00600   bool isAutoSaveBytes
00601      = (fAutoSaveBytes > 0 && (fTotalBytes - fLastBytesSaved)>=fAutoSaveBytes);
00602   
00603   if ( isAutoSaveInt || isAutoSaveTime || isAutoSaveBytes ) {
00604      isAutoSave = true;
00605   }
00606  
00607   if ( isAutoSave && fBasketSaveLinked ) {
00608     // Reset basket size so baskets will be dumped on next TTree::Fill
00609     // if more than 1 kbyte of data in that buffer
00610     fTBranch -> SetBasketSize(1000);
00611   } else {
00612     fTBranch -> SetBasketSize(fBasketSize); // reset to default basketsize
00613   }
00614 
00615   // Must do this so that if AutoSave is invoked it knows the compression
00616   // level of the tree
00617   Int_t savecompress = 9;
00618   if ( fCompress >= 0 ) {
00619     savecompress = fTFile -> GetCompressionLevel();
00620     fTFile -> SetCompressionLevel(fCompress);
00621   }
00622 
00623   // Fill tree
00624   nBytes = fTTree -> Fill();
00625 
00626   fTotalBytes += nBytes;
00627   // Test for new file pointer in case ChangeFile was invoked
00628   if ( IsFileChange() ) {
00629     if ( savedir->GetFile() == fTFile ) {
00630       // This shouldn't happen
00631       MSG("Per",Msg::kWarning) << "gDirectory points to old file and\n"
00632         << "ChangeFile requested, will switch to:" << gDirectory->GetPath()
00633                                << endl;
00634       savedir = gDirectory; 
00635     }
00636     ChangeFile();
00637   }
00638   else if ( isAutoSave ) {
00639     // Save tree to file if requested on this entry interval
00640     MSG("Per",Msg::kDebug) << "AutoSaving tree " << fTreeName << " with " 
00641        << fTTree->GetEntries() << " entries to file " 
00642        << fFullFilePathName << " IsAutoSaveInt/Time/Bytes " 
00643        << isAutoSaveInt << "/" << isAutoSaveTime << "/" << isAutoSaveBytes 
00644        << endl;  
00645     fTFile -> cd();
00646     fTTree -> AutoSave();  // save tree to file
00647     fTFile -> SaveSelf();  // save file directory containing this tree
00648     fLastTimeSaved = recordTime;
00649     fLastEntrySaved = fEntry;
00650     fLastBytesSaved = fTotalBytes;
00651   }
00652 
00653   if ( fCompress >= 0 )fTFile -> SetCompressionLevel(savecompress);
00654     
00655   savedir -> cd(); // return to original working directory
00656 
00657   return nBytes;
00658 
00659 }

Int_t PerOutputStream::Write (  ) 

Definition at line 661 of file PerOutputStream.cxx.

References cd(), ChangeFile(), fCompress, PerStream::fFullFilePathName, PerStream::fTFile, PerStream::fTreeName, PerStream::fTTree, PerStream::IsEnabled(), IsFileChange(), PerStream::IsOpen(), Msg::kDebug, and MSG.

00661                              {
00662   //
00663   //  Purpose:  Write the tree to file.  By default this overwrites any
00664   //            previous version of the tree in the file.
00665   //
00666   //  Arguments: none.
00667   //
00668   //  Return:  number of bytes written to file.
00669   //
00670   //  Contact:   S. Kasahara
00671   // 
00672 
00673   Int_t nBytes = 0;
00674 
00675   if ( !IsOpen() || !IsEnabled() ) return nBytes;
00676 
00677   TDirectory* savedir = gDirectory; // save current working directory
00678 
00679   // Check to see if root has changed the file from underneath us
00680   if ( IsFileChange() ) ChangeFile();
00681 
00682   fTFile -> cd(); // move to directory of current file
00683 
00684   Int_t savecompress = 9;
00685   if (fCompress >= 0) {
00686     savecompress = fTFile -> GetCompressionLevel();
00687     fTFile -> SetCompressionLevel(fCompress);
00688   }
00689 
00690   nBytes = fTTree -> Write(NULL,TObject::kOverwrite); // save tree to this file
00691   MSG("Per",Msg::kDebug) << "Wrote tree " << fTreeName 
00692     << " with " << fTTree->GetEntries() << " entries " 
00693     << " to file " << fFullFilePathName << "." << endl;
00694 
00695   if (fCompress >= 0) fTFile -> SetCompressionLevel(savecompress);
00696 
00697   savedir -> cd();  // return to original directory
00698 
00699   return nBytes;
00700 
00701 }


Member Data Documentation

Definition at line 76 of file PerOutputStream.h.

Referenced by GetAutoSaveBytes(), Print(), SetAutoSave(), and Store().

Definition at line 74 of file PerOutputStream.h.

Referenced by GetAutoSaveInt(), Print(), SetAutoSave(), and Store().

Definition at line 75 of file PerOutputStream.h.

Referenced by GetAutoSaveTime(), Print(), SetAutoSave(), and Store().

Definition at line 81 of file PerOutputStream.h.

Referenced by IsBasketSaveLinked(), Print(), SetAutoSave(), and Store().

Definition at line 72 of file PerOutputStream.h.

Referenced by Print().

Int_t PerOutputStream::fCompress [private]

Definition at line 73 of file PerOutputStream.h.

Referenced by Print(), Store(), and Write().

std::string PerOutputStream::fInputStreamName [private]

Definition at line 70 of file PerOutputStream.h.

Referenced by GetInputStreamName(), and SetObject().

Definition at line 79 of file PerOutputStream.h.

Referenced by ChangeFile(), CloseFile(), and Store().

Definition at line 77 of file PerOutputStream.h.

Referenced by ChangeFile(), CloseFile(), and Store().

Definition at line 78 of file PerOutputStream.h.

Referenced by ChangeFile(), CloseFile(), and Store().

Definition at line 71 of file PerOutputStream.h.

Referenced by GetSplitLevel(), and Print().

UInt_t PerOutputStream::fTotalBytes [private]

Definition at line 80 of file PerOutputStream.h.

Referenced by ChangeFile(), CloseFile(), and Store().

std::string PerOutputStream::fUserName [private]

Definition at line 69 of file PerOutputStream.h.

Referenced by GetUserName(), Print(), and SetObject().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1