CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

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 40 of file ErrorStreamSource.cc.


Constructor & Destructor Documentation

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

Definition at line 76 of file ErrorStreamSource.cc.

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

  : ExternalInputSource(pset,desc)
{
  itFileName_=fileNames().begin();
  openFile(*itFileName_);
  produces<FEDRawDataCollection>();
}
ErrorStreamSource::~ErrorStreamSource ( ) [virtual]

Definition at line 87 of file ErrorStreamSource.cc.

{

}

Member Function Documentation

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

Reimplemented from edm::ConfigurableInputSource.

Definition at line 55 of file ErrorStreamSource.cc.

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

Reimplemented from edm::ConfigurableInputSource.

Definition at line 53 of file ErrorStreamSource.cc.

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

Reimplemented from edm::ConfigurableInputSource.

Definition at line 56 of file ErrorStreamSource.cc.

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

Reimplemented from edm::ConfigurableInputSource.

Definition at line 54 of file ErrorStreamSource.cc.

{;} 
bool ErrorStreamSource::openFile ( const std::string &  fileName) [private]
bool ErrorStreamSource::produce ( edm::Event e) [private, virtual]

Implements edm::ConfigurableInputSource.

Definition at line 138 of file ErrorStreamSource.cc.

References FEDRawData::data(), edm::ConfigurableInputSource::event(), fedt_struct::eventsize, evf::evtn::evm_board_setformat(), fin_, evf::evtn::getgpshigh(), evf::evtn::getgpslow(), errorstreamsource::gtpEvmId_, i, edm::Event::put(), FEDRawData::resize(), query::result, edm::ConfigurableInputSource::setTime(), fedh_struct::sourceid, and cond::rpcobgas::time.

{
  unsigned int totalEventSize = 0;
  if (!fin_.is_open()) return false;
  
  auto_ptr<FEDRawDataCollection> result(new FEDRawDataCollection());
  
  uint32_t fedSize[1024];
  fin_.read((char*)fedSize,1024*sizeof(uint32_t));
  for (unsigned int i=0;i<1024;i++) {
    totalEventSize += fedSize[i];
  }
  unsigned int gtpevmsize = fedSize[errorstreamsource::gtpEvmId_];
  if(gtpevmsize>0)
    evf::evtn::evm_board_setformat(gtpevmsize);
  char *event = new char[totalEventSize];
  fin_.read(event,totalEventSize);
  while(totalEventSize>0) {
    totalEventSize -= 8;
    fedt_t *fedt = (fedt_t*)(event+totalEventSize);
    unsigned int fedsize = FED_EVSZ_EXTRACT(fedt->eventsize);
    fedsize *= 8; // fed size in bytes
    totalEventSize -= (fedsize - 8);
    fedh_t *fedh = (fedh_t *)(event+totalEventSize);
    unsigned int soid = FED_SOID_EXTRACT(fedh->sourceid);
    if(soid==errorstreamsource::gtpEvmId_){
      unsigned int gpsl = evf::evtn::getgpslow((unsigned char*)fedh);
      unsigned int gpsh = evf::evtn::getgpshigh((unsigned char*)fedh);
      edm::TimeValue_t time = gpsh;
      time = (time << 32) + gpsl;
      setTime(time);
    }
    FEDRawData& fedData=result->FEDData(soid);
    fedData.resize(fedsize);
    memcpy(fedData.data(),event+totalEventSize,fedsize);
  }
  e.put(result);
  delete[] event;
  return true;
}
void ErrorStreamSource::setRunAndEventInfo ( ) [private, virtual]

Reimplemented from edm::ConfigurableInputSource.

Definition at line 98 of file ErrorStreamSource.cc.

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

{
  uint32_t version(1);
  uint32_t runNumber(0);
  uint32_t lumiNumber(1);
  uint32_t evtNumber(0);
  bool status;
  status = fin_.read((char*)&runNumber,sizeof(uint32_t));
  if (runNumber < 32) {
      version = runNumber;
      status = fin_.read((char*)&runNumber,sizeof(uint32_t));
  }
  if (version >= 2) {
      status = fin_.read((char*)&lumiNumber,sizeof(uint32_t));
  }
  status = fin_.read((char*)&evtNumber,sizeof(uint32_t));
  
  if (!status) {
    itFileName_++; if (itFileName_==fileNames().end()) { fin_.close(); return; }
    openFile(*itFileName_);
    status = fin_.read((char*)&runNumber,sizeof(uint32_t));
    if (runNumber < 32) {
        version = runNumber;
        status = fin_.read((char*)&runNumber,sizeof(uint32_t));
    }
    if (version >= 2) {
        status = fin_.read((char*)&lumiNumber,sizeof(uint32_t));
    }
    status = fin_.read((char*)&evtNumber,sizeof(uint32_t));
    if (!status) { fin_.close(); return; }
  }
  
  runNumber = (runNumber==0) ? 1 : runNumber;
  
  setRunNumber(runNumber);
  setEventNumber(evtNumber);
}

Member Data Documentation

std::ifstream ErrorStreamSource::fin_ [private]

Definition at line 64 of file ErrorStreamSource.cc.

Referenced by CalibrationXML::openFile(), produce(), and setRunAndEventInfo().

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

Definition at line 63 of file ErrorStreamSource.cc.

Referenced by ErrorStreamSource(), and setRunAndEventInfo().