DemoDaq.cc File Reference

#include "TROOT.h"
#include "TTabCom.h"
#include "TTree.h"
#include "Persistency/test/DemoDaqOutputModule.h"
#include "MessageService/MsgService.h"
#include "MinosObjectMap/MomNavigator.h"
#include "RawData/RawRecord.h"
#include "RawData/RawDaqSnarlHeader.h"
#include "RawData/RawDigitDataBlock.h"

Go to the source code of this file.

Functions

TROOT root ("DemoDaq","MINOS Persistency Package Demo Daq")
MomNavigatorFillEntry (Int_t entry)
 CVSID ("$Id: DemoDaq.cc,v 1.12 2007/11/11 05:10:38 rhatcher Exp $")
int main (int argc, char **argv)

Function Documentation

CVSID ( "$Id: DemoDaq.  cc,
v 1.12 2007/11/11 05:10:38 rhatcher Exp $"   
)
MomNavigator * FillEntry ( Int_t  entry  ) 

Definition at line 87 of file DemoDaq.cc.

References Detector::kCalib, SimFlag::kData, and run().

Referenced by main().

00087                                      {
00088   //
00089   // Function FillEntry artificially fills a DaqSnarl and loads it
00090   // into a MomNavigator object.
00091   //
00092 
00093   // Create daq frame header
00094   Int_t run = 1; // run number
00095   Short_t subrun = 1; // subrun number
00096   Short_t runtype = 1;
00097   Detector::Detector_t dtype = Detector::kCalib;  // detector type
00098   SimFlag::SimFlag_t simflg = SimFlag::kData;  // data source
00099   VldTimeStamp tstamp((time_t)(snarl+1),0); // time stamp 
00100   VldContext vldc(dtype,simflg,tstamp);
00101   UInt_t trigsrc = 0x01;  // physics trigger
00102   UInt_t errcode = 1; //error code 
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   // Construct daq frame record passing it the header
00109   RawRecord* record = new RawRecord(hdr);
00110 
00111   // Construct block of data words
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   // Give record to Mom to be adopted, record, header, & datablock will be
00122   // deleted when Mom is deleted.
00123   MomNavigator* mom = new MomNavigator();
00124   mom -> AdoptFragment(record);
00125 
00126   // We could also create and store in Mom other records produced in this
00127   // entry
00128   return mom;
00129 
00130 }

int main ( int  argc,
char **  argv 
)

Definition at line 28 of file DemoDaq.cc.

References DemoDaqOutputModule::BeginFile(), DemoDaqOutputModule::BeginJob(), DemoDaqOutputModule::EndFile(), DemoDaqOutputModule::EndJob(), FillEntry(), Msg::kDebug, Msg::kInfo, Per::kRecreate, Munits::ms, MSGSTREAM, DemoDaqOutputModule::Put(), and MsgStream::SetLogLevel().

00028                                 {
00029 
00030   // gDebug = TTabCom::kDebug;  // Activate for extra debug printout
00031 
00032   MsgStream& ms = MSGSTREAM("Per",Msg::kInfo);
00033   ms.SetLogLevel(Msg::kInfo);
00034 
00035   Int_t nent = 1000;  // default number of entries
00036   if (argc > 1) {
00037     nent = atoi(argv[1]);
00038   }
00039 
00040   DemoDaqOutputModule daqmod;  // create a daq output module object
00041 
00042 
00043   daqmod.BeginJob();  // performs output stream initialization
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   //TTree::SetMaxTreeSize(10000); // to force file change
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   // Begin entry loop
00069   MomNavigator* mom; //"mom" is a container for all records produced in the entry
00070   for (Int_t ient=0; ient < nent; ient++) {
00071     mom = FillEntry(ient);  // artificially fills records  
00072     if ( mom ) daqmod.Put(mom); //records are persisted to the output streams
00073     delete mom; // clean up records managed by 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(); // close file on all managed streams
00080 
00081   daqmod.EndJob(); // close all streams
00082 
00083   return 0;
00084 
00085 }

TROOT root ( "DemoDaq"  ,
"MINOS Persistency Package Demo Daq"   
)

Generated on 25 Apr 2018 for loon by  doxygen 1.6.1