00001 #include "TROOT.h"
00002 #include "TTabCom.h"
00003 #include "TTree.h"
00004 #include "Persistency/test/DemoDaqOutputModule.h"
00005 #include "MessageService/MsgService.h"
00006 #include "MinosObjectMap/MomNavigator.h"
00007 #include "RawData/RawRecord.h"
00008 #include "RawData/RawDaqSnarlHeader.h"
00009 #include "RawData/RawDigitDataBlock.h"
00010
00011 TROOT root("DemoDaq","MINOS Persistency Package Demo Daq");
00012 MomNavigator* FillEntry(Int_t entry);
00013
00014 CVSID("$Id: DemoDaq.cc,v 1.12 2007/11/11 05:10:38 rhatcher Exp $");
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00027
00028 int main(int argc, char **argv) {
00029
00030
00031
00032 MsgStream& ms = MSGSTREAM("Per",Msg::kInfo);
00033 ms.SetLogLevel(Msg::kInfo);
00034
00035 Int_t nent = 1000;
00036 if (argc > 1) {
00037 nent = atoi(argv[1]);
00038 }
00039
00040 DemoDaqOutputModule daqmod;
00041
00042
00043 daqmod.BeginJob();
00044
00045 ms << "\nThis demo shows how the Daq could make use of the\n"
00046 << "persistency classes to write data to file. "
00047 << nent << " RawRecords\n"
00048 << "are artificially filled and written to stream DaqSnarl in\n"
00049 << "file testdaq.root.\n" << endl;
00050
00051
00052 bool openok = daqmod.BeginFile("testdaq.root",Per::kRecreate);
00053
00054 if( !openok ) {
00055 ms << "Output file failed to open. Demo program requires\n"
00056 << " ability to write to current working directory. Please check\n"
00057 << " write access and try again." << endl;
00058 daqmod.EndJob();
00059 return 0;
00060 }
00061 else {
00062 ms << "Successfully opened output file testdaq.root.\n"
00063 << "Status of output stream manager before filling entries:\n\n"
00064 << daqmod << endl;
00065 }
00066
00067 ms.SetLogLevel(Msg::kDebug);
00068
00069 MomNavigator* mom;
00070 for (Int_t ient=0; ient < nent; ient++) {
00071 mom = FillEntry(ient);
00072 if ( mom ) daqmod.Put(mom);
00073 delete mom;
00074 }
00075
00076 ms << "\nStatus of output stream manager after filling "<< nent
00077 << " entries in stream DaqSnarl:\n\n" << daqmod << endl;
00078
00079 daqmod.EndFile();
00080
00081 daqmod.EndJob();
00082
00083 return 0;
00084
00085 }
00086
00087 MomNavigator* FillEntry(Int_t snarl) {
00088
00089
00090
00091
00092
00093
00094 Int_t run = 1;
00095 Short_t subrun = 1;
00096 Short_t runtype = 1;
00097 Detector::Detector_t dtype = Detector::kCalib;
00098 SimFlag::SimFlag_t simflg = SimFlag::kData;
00099 VldTimeStamp tstamp((time_t)(snarl+1),0);
00100 VldContext vldc(dtype,simflg,tstamp);
00101 UInt_t trigsrc = 0x01;
00102 UInt_t errcode = 1;
00103 UInt_t timeframe = 2;
00104 UInt_t nrawdigits = 10;
00105 UInt_t spilltype = 0;
00106 RawDaqSnarlHeader* hdr = new RawDaqSnarlHeader(vldc,run,subrun,runtype,
00107 timeframe,snarl,trigsrc,errcode,nrawdigits,spilltype);
00108
00109 RawRecord* record = new RawRecord(hdr);
00110
00111
00112 const Int_t nwords = 100;
00113 Int_t array[nwords];
00114 for (Int_t iwrd = 0; iwrd < nwords; iwrd++) {
00115 array[iwrd]=1;
00116 }
00117 RawDigitDataBlock* dblock = new RawDigitDataBlock(array);
00118
00119 record -> AdoptRawBlock(dblock);
00120
00121
00122
00123 MomNavigator* mom = new MomNavigator();
00124 mom -> AdoptFragment(record);
00125
00126
00127
00128 return mom;
00129
00130 }
00131
00132
00133