CMS 3D CMS Logo

ErrorStreamSource Class Reference

Inheritance diagram for ErrorStreamSource:

edm::ExternalInputSource edm::ConfigurableInputSource edm::InputSource edm::ProductRegistryHelper

List of all members.

Public Member Functions

 ErrorStreamSource (edm::ParameterSet const &pset, edm::InputSourceDescription const &desc)
virtual ~ErrorStreamSource ()

Private Member Functions

void beginLuminosityBlock (edm::LuminosityBlock &lb)
void beginRun (edm::Run &r)
void endLuminosityBlock (edm::LuminosityBlock &lb)
void endRun (edm::Run &r)
bool openFile (const std::string &fileName)
bool produce (edm::Event &e)
void setRunAndEventInfo ()

Private Attributes

std::ifstream fin_
std::vector< std::string >
::const_iterator 
itFileName_


Detailed Description

Definition at line 29 of file ErrorStreamSource.cc.


Constructor & Destructor Documentation

ErrorStreamSource::ErrorStreamSource ( edm::ParameterSet const &  pset,
edm::InputSourceDescription const &  desc 
)

Definition at line 65 of file ErrorStreamSource.cc.

References edm::ExternalInputSource::fileNames(), itFileName_, and openFile().

00067   : ExternalInputSource(pset,desc)
00068 {
00069   itFileName_=fileNames().begin();
00070   openFile(*itFileName_);
00071   produces<FEDRawDataCollection>();
00072 }

ErrorStreamSource::~ErrorStreamSource (  )  [virtual]

Definition at line 76 of file ErrorStreamSource.cc.

00077 {
00078 
00079 }


Member Function Documentation

void ErrorStreamSource::beginLuminosityBlock ( edm::LuminosityBlock lb  )  [inline, private, virtual]

Reimplemented from edm::ConfigurableInputSource.

Definition at line 44 of file ErrorStreamSource.cc.

00044 {;}

void ErrorStreamSource::beginRun ( edm::Run r  )  [inline, private, virtual]

Reimplemented from edm::ConfigurableInputSource.

Definition at line 42 of file ErrorStreamSource.cc.

00042 {;}

void ErrorStreamSource::endLuminosityBlock ( edm::LuminosityBlock lb  )  [inline, private, virtual]

Reimplemented from edm::ConfigurableInputSource.

Definition at line 45 of file ErrorStreamSource.cc.

00045 {;}

void ErrorStreamSource::endRun ( edm::Run r  )  [inline, private, virtual]

Reimplemented from edm::ConfigurableInputSource.

Definition at line 43 of file ErrorStreamSource.cc.

00043 {;} 

bool ErrorStreamSource::openFile ( const std::string &  fileName  )  [private]

Referenced by ErrorStreamSource(), and setRunAndEventInfo().

bool ErrorStreamSource::produce ( edm::Event e  )  [private, virtual]

Implements edm::ConfigurableInputSource.

Definition at line 127 of file ErrorStreamSource.cc.

References FEDRawData::data(), edm::ConfigurableInputSource::event(), fedt_struct::eventsize, fin_, i, edm::Event::put(), FEDRawData::resize(), HLT_VtxMuL3::result, and fedh_struct::sourceid.

00128 {
00129   unsigned int totalEventSize = 0;
00130   if (!fin_.is_open()) return false;
00131   
00132   auto_ptr<FEDRawDataCollection> result(new FEDRawDataCollection());
00133   
00134   uint32_t fedSize[1024];
00135   fin_.read((char*)fedSize,1024*sizeof(uint32_t));
00136   for (unsigned int i=0;i<1024;i++) {
00137     totalEventSize += fedSize[i];
00138   }
00139   char *event = new char[totalEventSize];
00140   fin_.read(event,totalEventSize);
00141   while(totalEventSize>0) {
00142     totalEventSize -= 8;
00143     fedt_t *fedt = (fedt_t*)(event+totalEventSize);
00144     unsigned int fedsize = FED_EVSZ_EXTRACT(fedt->eventsize);
00145     fedsize *= 8; // fed size in bytes
00146     totalEventSize -= (fedsize - 8);
00147     fedh_t *fedh = (fedh_t *)(event+totalEventSize);
00148     unsigned int soid = FED_SOID_EXTRACT(fedh->sourceid);
00149     FEDRawData& fedData=result->FEDData(soid);
00150     fedData.resize(fedsize);
00151     memcpy(fedData.data(),event+totalEventSize,fedsize);
00152   }
00153   e.put(result);
00154   delete[] event;
00155   return true;
00156 }

void ErrorStreamSource::setRunAndEventInfo (  )  [private, virtual]

Reimplemented from edm::ConfigurableInputSource.

Definition at line 87 of file ErrorStreamSource.cc.

References end, edm::ExternalInputSource::fileNames(), fin_, itFileName_, openFile(), edm::ConfigurableInputSource::setEventNumber(), edm::InputSource::setRunNumber(), StDecayID::status, and version().

00088 {
00089   uint32_t version(1);
00090   uint32_t runNumber(0);
00091   uint32_t lumiNumber(1);
00092   uint32_t evtNumber(0);
00093   bool status;
00094   status = fin_.read((char*)&runNumber,sizeof(uint32_t));
00095   if (runNumber < 32) {
00096       version = runNumber;
00097       status = fin_.read((char*)&runNumber,sizeof(uint32_t));
00098   }
00099   if (version >= 2) {
00100       status = fin_.read((char*)&lumiNumber,sizeof(uint32_t));
00101   }
00102   status = fin_.read((char*)&evtNumber,sizeof(uint32_t));
00103   
00104   if (!status) {
00105     itFileName_++; if (itFileName_==fileNames().end()) { fin_.close(); return; }
00106     openFile(*itFileName_);
00107     status = fin_.read((char*)&runNumber,sizeof(uint32_t));
00108     if (runNumber < 32) {
00109         version = runNumber;
00110         status = fin_.read((char*)&runNumber,sizeof(uint32_t));
00111     }
00112     if (version >= 2) {
00113         status = fin_.read((char*)&lumiNumber,sizeof(uint32_t));
00114     }
00115     status = fin_.read((char*)&evtNumber,sizeof(uint32_t));
00116     if (!status) { fin_.close(); return; }
00117   }
00118   
00119   runNumber = (runNumber==0) ? 1 : runNumber;
00120   
00121   setRunNumber(runNumber);
00122   setEventNumber(evtNumber);
00123 }


Member Data Documentation

std::ifstream ErrorStreamSource::fin_ [private]

Definition at line 53 of file ErrorStreamSource.cc.

Referenced by produce(), and setRunAndEventInfo().

std::vector<std::string>::const_iterator ErrorStreamSource::itFileName_ [private]

Definition at line 52 of file ErrorStreamSource.cc.

Referenced by ErrorStreamSource(), and setRunAndEventInfo().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:20:24 2009 for CMSSW by  doxygen 1.5.4