00001 #include "TROOT.h"
00002 #include "TTabCom.h"
00003 #include "RawData/RawRecord.h"
00004 #include "Persistency/test/DemoInputModule.h"
00005 #include "MessageService/MsgService.h"
00006 #include "MinosObjectMap/MomNavigator.h"
00007
00008 TROOT root("DemoInput","MINOS Persistency Package Demo Input");
00009
00010 CVSID("$Id: DemoInput.cc,v 1.7 2002/10/21 03:12:56 kasahara Exp $");
00012
00013
00014
00015
00016
00017
00019
00020 int main() {
00021
00022 MsgStream& ms = MSGSTREAM("Per",Msg::kInfo);
00023 ms.SetLogLevel(Msg::kInfo);
00024
00025 DemoInputModule dinmod;
00026
00027
00028 dinmod.BeginJob();
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
00035 bool openok = dinmod.BeginFile("*","testdaq.root",Per::kRead);
00036
00037 ms.SetLogLevel(Msg::kVerbose);
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
00054 Int_t nent = 0;
00055 while ( ! dinmod.IsEnd() ) {
00056
00057 MomNavigator* mom = new MomNavigator();
00058 if (dinmod.Next(mom)) nent++;
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;
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();
00075
00076 dinmod.EndJob();
00077
00078 return 0;
00079
00080 }
00081
00082