CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

ErrorStreamSource Class Reference

Inheritance diagram for ErrorStreamSource:
edm::ProducerSourceFromFiles edm::ProducerSourceBase edm::FromFiles 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)
virtual void produce (edm::Event &e)
virtual bool setRunAndEventInfo (edm::EventID &id, edm::TimeValue_t &theTime)

Private Attributes

std::ifstream fin_
std::vector< std::string >
::const_iterator 
itFileName_
std::auto_ptr
< FEDRawDataCollection
result_

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

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

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

Definition at line 84 of file ErrorStreamSource.cc.

{

}

Member Function Documentation

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

Reimplemented from edm::ProducerSourceBase.

Definition at line 55 of file ErrorStreamSource.cc.

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

Reimplemented from edm::ProducerSourceBase.

Definition at line 53 of file ErrorStreamSource.cc.

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

Reimplemented from edm::ProducerSourceBase.

Definition at line 56 of file ErrorStreamSource.cc.

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

Reimplemented from edm::ProducerSourceBase.

Definition at line 54 of file ErrorStreamSource.cc.

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

Definition at line 174 of file ErrorStreamSource.cc.

References fin_, recoMuon::in, pos, prof2calltree::prefix, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by ErrorStreamSource(), and setRunAndEventInfo().

{
  fin_.close();
  fin_.clear();
  size_t pos = fileName.find(':');
  if (pos!=std::string::npos) {
    std::string prefix = fileName.substr(0,pos);
    if (prefix!="file") return false;
    pos++;
  }
  else pos=0;

  fin_.open(fileName.substr(pos).c_str(),std::ios::in|std::ios::binary);
  return fin_.is_open();
}
void ErrorStreamSource::produce ( edm::Event e) [private, virtual]

Implements edm::ProducerSourceBase.

Definition at line 169 of file ErrorStreamSource.cc.

References edm::Event::put(), and result_.

                                           {
  e.put(result_);
}
bool ErrorStreamSource::setRunAndEventInfo ( edm::EventID id,
edm::TimeValue_t theTime 
) [private, virtual]

Implements edm::ProducerSourceBase.

Definition at line 95 of file ErrorStreamSource.cc.

References FEDRawData::data(), end, edm::ProducerSourceBase::event(), fedt_struct::eventsize, evf::evtn::evm_board_setformat(), edm::FromFiles::fileNames(), fin_, evf::evtn::getgpshigh(), evf::evtn::getgpslow(), errorstreamsource::gtpEvmId_, i, itFileName_, openFile(), FEDRawData::resize(), result_, convertSQLiteXML::runNumber, fedh_struct::sourceid, ntuplemaker::status, cond::rpcobgas::time, 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 false; }
    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 false; }
  }
  
  runNumber = (runNumber==0) ? 1 : runNumber;
  
  id = edm::EventID(runNumber, lumiNumber, evtNumber);

//______________________________________________________________________________
  unsigned int totalEventSize = 0;
  
  result_.reset(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;
      theTime = time;
    }
    FEDRawData& fedData=result_->FEDData(soid);
    fedData.resize(fedsize);
    memcpy(fedData.data(),event+totalEventSize,fedsize);
  }
  delete[] event;
  return true;
}

Member Data Documentation

std::ifstream ErrorStreamSource::fin_ [private]

Definition at line 64 of file ErrorStreamSource.cc.

Referenced by openFile(), and setRunAndEventInfo().

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

Definition at line 63 of file ErrorStreamSource.cc.

Referenced by ErrorStreamSource(), and setRunAndEventInfo().

Definition at line 65 of file ErrorStreamSource.cc.

Referenced by produce(), and setRunAndEventInfo().