Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

DemoDaqOutputModule.cc

Go to the documentation of this file.
00001 
00002 //
00003 // DemoDaqOutputModule
00004 //
00005 // Package: Per (Persistency) Demo class
00006 //
00007 // S. Kasahara 01/2001
00008 //
00009 // Purpose: Simple DemoDaqOutputModule class to show use of Persistency
00010 //          output streams within context of the write of the raw data.
00011 //          This is for use with the DaqDemo.cc program that comes with
00012 //          the Persistency package.
00013 //
00015 #include <string>
00016 #include "MessageService/MsgService.h"
00017 #include "MinosObjectMap/MomNavigator.h"
00018 #include "Persistency/test/DemoDaqOutputModule.h"
00019 #include "Persistency/PerOutputStream.h"
00020 using namespace std;
00021 
00022 ostream& operator<<(ostream& ms, const DemoDaqOutputModule& dm) { 
00023   return dm.Print(ms); 
00024 }
00025 
00026 //   Definition of static data members
00027 //   *********************************
00028 
00029 //CVSID("$Id: DemoDaqOutputModule.cc,v 1.10 2002/11/19 18:42:37 kasahara Exp $");
00030 
00031 // Definition of methods (alphabetical order)
00032 // ******************************************
00033 
00034 bool DemoDaqOutputModule::BeginFile(string fullfilepathname, Per::EAccessMode accessmode) {
00035   //
00036   //  Purpose:  Begin new file for all streams managed by output stream
00037   //            manager.
00038   //
00039   //  Argument: fullfilepathname  full file path name of output file
00040   //            accessmode        accessmode in which file is to be opened
00041   //                              (default = kNew)
00042   //
00043   //  Return:  return true if successfully opened file.
00044   //
00045   //  Contact:   S. Kasahara
00046   //
00047 
00048   string streamname="*";  // apply SetFile to all managed streams
00049   bool openok = fOutputStreamManager.SetFile(streamname,fullfilepathname, accessmode);
00050 
00051   return openok;  // returns true if successful
00052 
00053 }
00054 
00055 void DemoDaqOutputModule::BeginJob() {
00056   //
00057   // Purpose: Perform initialization of streams required at Daq startup.
00058   //
00059   // Arguments: none.
00060   //
00061   // Return: none.
00062   //
00063   // Contact:  S. Kasahara
00064   //
00065 
00066   PerOutputStream* outstream;
00067   // Open stream w/name "DaqSnarl" to fill tree "DaqSnarl" (but note
00068   // that streamname need not be the same as treename) with objects
00069   // of class "RawRecord" (for now).  One main branch is created with
00070   // splitlevel = Per::kRecSplit. 
00071   outstream = fOutputStreamManager.OpenStream("DaqSnarl","DaqSnarl",
00072                                            "RawRecord","","",Per::kRecSplit);
00073   if ( outstream ) {
00074     // Set the AutoSave event interval of this stream.  This will automatically
00075     // configure the BasketSave event interval of each branch attached to 
00076     // stream to dump baskets just before the tree save.
00077     outstream -> SetAutoSave(100,10);
00078   }
00079   outstream = fOutputStreamManager.OpenStream("DaqMonitor","DaqMonitor",
00080                                            "RawRecord","","",Per::kRecSplit);
00081   if ( outstream ) {
00082     // Set the AutoSave event interval of this stream.  This will automatically
00083     // configure the BasketSave event interval of each branch attached to 
00084     // stream to dump baskets just before the tree save.
00085     outstream -> SetAutoSave(100,10);
00086   }
00087 
00088 }
00089 
00090 void DemoDaqOutputModule::EndFile() {
00091   //
00092   //  Purpose:  Close current file for all streams managed by output stream
00093   //            manager.
00094   //
00095   //  Argument: none.
00096   //
00097   //  Return:  none.
00098   //
00099   //  Contact:   S. Kasahara
00100   //
00101 
00102   fOutputStreamManager.Write(); // write the trees on all streams to file
00103   fOutputStreamManager.CloseFile(); // close files on all streams
00104 
00105 }
00106 
00107 void DemoDaqOutputModule::EndJob() {
00108   // 
00109   // Purpose: Close all streams at Daq finish.
00110   //
00111   // Arguments: none.
00112   //
00113   // Return: none.
00114   //
00115   // Contact:  S. Kasahara
00116   //
00117 
00118   fOutputStreamManager.CloseStream();
00119 
00120 }
00121 
00122 ostream& DemoDaqOutputModule::Print(ostream& ms) const {
00123   //
00124   //  Purpose:  Print status of daq output module on ostream.
00125   //
00126   //  Arguments: ms ostream to display on.
00127   //
00128   //  Return:  ostream reference.
00129   //
00130   //  Contact:   S. Kasahara
00131   //
00132 
00133   fOutputStreamManager.Print(ms);
00134 
00135   return ms;
00136 
00137 }
00138 
00139 
00140 Int_t DemoDaqOutputModule::Put(const MomNavigator* mom) {
00141   //  Purpose:  Store new entry with use of output stream manager.
00142   //
00143   //  Argument: mom  pointer to MomNavigator
00144   //
00145   //  Return:  number of objects actually persisted.
00146   //
00147   //  Contact:   S. Kasahara
00148   //
00149 
00150   // Persist the records from Mom into the appropriate stream(s).
00151   Int_t nobject = fOutputStreamManager.Put(mom);
00152   return nobject;
00153 
00154 }
00155 
00156 
00157 
00158 
00159 
00160 
00161 
00162 
00163 
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 
00198 
00199 
00200 
00201 
00202 
00203 

Generated on Mon Feb 15 11:06:36 2010 for loon by  doxygen 1.3.9.1