DemoInput.cc File Reference

#include "TROOT.h"
#include "TTabCom.h"
#include "RawData/RawRecord.h"
#include "Persistency/test/DemoInputModule.h"
#include "MessageService/MsgService.h"
#include "MinosObjectMap/MomNavigator.h"

Go to the source code of this file.

Functions

TROOT root ("DemoInput","MINOS Persistency Package Demo Input")
 CVSID ("$Id: DemoInput.cc,v 1.7 2002/10/21 03:12:56 kasahara Exp $")
int main ()

Function Documentation

CVSID ( "$Id: DemoInput.  cc,
v 1.7 2002/10/21 03:12:56 kasahara Exp $"   
)
int main ( void   ) 

Definition at line 20 of file DemoInput.cc.

References DemoInputModule::BeginFile(), DemoInputModule::BeginJob(), DemoInputModule::EndFile(), DemoInputModule::EndJob(), Registry::GetCharString(), Registry::GetInt(), DataUtil::GetTempTags(), DemoInputModule::IsEnd(), Msg::kInfo, Per::kRead, Msg::kVerbose, Munits::ms, MSGSTREAM, DemoInputModule::Next(), and MsgStream::SetLogLevel().

00020            {
00021 
00022   MsgStream& ms = MSGSTREAM("Per",Msg::kInfo);
00023   ms.SetLogLevel(Msg::kInfo);
00024 
00025   DemoInputModule dinmod;  // create a demo input module object
00026 
00027 
00028   dinmod.BeginJob();  // performs input stream initialization
00029 
00030   ms << "\nThis demo program shows how the offline framework\n"
00031      << "could make use of the persistency classes to read data from\n"
00032      << "file.  It attempts to retrieve RawRecords from file testdaq.root\n"        << "generated by DemoDaq.\n" << endl;
00033 
00034   // tell all(="*") managed input streams to open file testdaq.root
00035   bool openok = dinmod.BeginFile("*","testdaq.root",Per::kRead);   
00036 
00037   ms.SetLogLevel(Msg::kVerbose); // I don't know why I have to do this
00038 
00039   if( !openok ) {
00040     ms << "Input file failed to open.  Demo program requires\n"
00041        << "that DemoDaq be run first to generate the test file\n"
00042        << "testdaq.root in the current working directory.  Please run\n"
00043        << "DemoDaq and then try again." << endl;
00044     dinmod.EndJob();
00045     return 0;
00046   }
00047   else {
00048     ms << "Successfully opened input file testdaq.root.\n"
00049        << "Status of input stream manager before retrieving entries:\n\n"
00050        << dinmod << endl; 
00051   }
00052 
00053   // Begin entry loop
00054   Int_t nent = 0;
00055   while ( ! dinmod.IsEnd() ) {
00056     //"mom" is a container for all records retrieved in the entry  
00057     MomNavigator* mom = new MomNavigator();
00058     if (dinmod.Next(mom)) nent++; //records are retrieved from the input stream
00059     if ( ! dinmod.IsEnd() ) {
00060     RawRecord* rawrecord = dynamic_cast<RawRecord*>(mom -> GetFragment("RawRecord"));
00061     ms << "Received rawrecord " << nent << " from stream "
00062                << rawrecord -> GetTempTags().GetCharString("stream")
00063                << " tree " << rawrecord -> GetTempTags().GetCharString("tree")
00064                << " index " << rawrecord -> GetTempTags().GetInt("index")
00065                << " file " << rawrecord -> GetTempTags().GetCharString("file")
00066                << endl;
00067     }
00068     delete mom; // clean up records managed by mom. 
00069   }
00070 
00071   ms << "Demo job finished record retrieval after " << nent << " entries." << endl;
00072   ms << "Status of input stream manager at end of job:\n\n" << dinmod << endl;
00073 
00074   dinmod.EndFile(); // close file on all managed streams
00075 
00076   dinmod.EndJob(); // close all streams
00077 
00078   return 0;
00079 
00080 }

TROOT root ( "DemoInput"  ,
"MINOS Persistency Package Demo Input"   
)

Generated on 19 Jan 2018 for loon by  doxygen 1.6.1