![]() |
![]() |
#include <HcalTBSource.h>
Public Member Functions | |
HcalTBSource (const edm::ParameterSet &pset, edm::InputSourceDescription const &desc) | |
virtual | ~HcalTBSource () |
Private Member Functions | |
void | openFile (const std::string &filename) |
virtual void | produce (edm::Event &e) |
virtual bool | setRunAndEventInfo (edm::EventID &id, edm::TimeValue_t &time) |
void | unpackSetup (const std::vector< std::string > ¶ms) |
Private Attributes | |
int | m_chunkIds [CHUNK_COUNT] |
CDFChunk * | m_chunks [CHUNK_COUNT] |
CDFEventInfo * | m_eventInfo |
int | m_eventNumberOffset |
TFile * | m_file |
int | m_fileCounter |
int | m_i |
bool | m_onlyRemapped |
bool | m_quiet |
std::map< std::string, int > | m_sourceIdRemap |
TTree * | m_tree |
int | n_chunks |
Static Private Attributes | |
static const int | CHUNK_COUNT = 64 |
Definition at line 27 of file HcalTBSource.h.
HcalTBSource::HcalTBSource | ( | const edm::ParameterSet & | pset, |
edm::InputSourceDescription const & | desc | ||
) | [explicit] |
Definition at line 17 of file HcalTBSource.cc.
: edm::ProducerSourceFromFiles(pset,desc, true), m_quiet( pset.getUntrackedParameter<bool>("quiet",true)), m_onlyRemapped( pset.getUntrackedParameter<bool>("onlyRemapped",false)) { m_tree=0; m_fileCounter=-1; m_file=0; m_i=0; unpackSetup(pset.getUntrackedParameter<std::vector<std::string> >("streams",std::vector<std::string>())); produces<FEDRawDataCollection>(); }
HcalTBSource::~HcalTBSource | ( | ) | [virtual] |
void HcalTBSource::openFile | ( | const std::string & | filename | ) | [private] |
Definition at line 55 of file HcalTBSource.cc.
References b, i, m_chunkIds, m_chunks, m_eventInfo, m_file, m_i, m_onlyRemapped, m_quiet, m_sourceIdRemap, m_tree, and n_chunks.
Referenced by L1MuGMTHWFileReader::setRunAndEventInfo().
{ if (m_file!=0) { m_file->Close(); m_file=0; m_tree=0; } // try { m_file=TFile::Open(filename.c_str()); if (m_file==0) { edm::LogError("HCAL") << "Unable to open " << filename << endl; m_tree=0; return; } m_tree=(TTree*)m_file->Get("CMSRAW"); if (m_tree==0) { m_file->Close(); m_file=0; edm::LogError("HCAL") << "Unable to find CMSRAW tree" << endl; return; } if (!m_quiet) { edm::LogInfo("HCAL") << "Opening '" << filename << "' with " << m_tree->GetEntries() << " events.\n"; } TObjArray* lb=m_tree->GetListOfBranches(); n_chunks=0; for (int i=0; i<lb->GetSize(); i++) { TBranch* b=(TBranch*)lb->At(i); if (b==0) continue; if (!strcmp(b->GetClassName(),"CDFEventInfo")) { m_eventInfo=0; b->SetAddress(&m_eventInfo); } else { if (strcmp(b->GetClassName(),"CDFChunk")) continue; if (m_sourceIdRemap.find(b->GetName())==m_sourceIdRemap.end()) { if (m_onlyRemapped) continue; m_sourceIdRemap.insert(std::pair<std::string,int>(b->GetName(),-1)); if (!m_quiet) edm::LogInfo("HCAL") << "Also reading branch " << b->GetName(); } m_chunks[n_chunks]=0; // allow ROOT to allocate b->SetAddress(&(m_chunks[n_chunks])); m_chunkIds[n_chunks]=m_sourceIdRemap[b->GetName()]; n_chunks++; } } m_i=0; }
void HcalTBSource::produce | ( | edm::Event & | e | ) | [private, virtual] |
Implements edm::ProducerSourceBase.
Definition at line 147 of file HcalTBSource.cc.
References FEDRawData::data(), data, AlCaHLTBitMon_QueryRunRegistry::getData(), CDFChunk::getDataLength(), CDFChunk::getSourceId(), i, m_chunkIds, m_chunks, m_quiet, n_chunks, edm::Event::put(), and FEDRawData::resize().
{ std::auto_ptr<FEDRawDataCollection> bare_product(new FEDRawDataCollection()); for (int i=0; i<n_chunks; i++) { const unsigned char* data=(const unsigned char*)m_chunks[i]->getData(); int len=m_chunks[i]->getDataLength()*8; int natId=m_chunks[i]->getSourceId(); int id=(m_chunkIds[i]>0)?(m_chunkIds[i]):(natId); FEDRawData& fed=bare_product->FEDData(id); fed.resize(len); memcpy(fed.data(),data,len); // patch the SourceId... if (natId!=id) { unsigned int* header=(unsigned int*)fed.data(); header[0]=(header[0]&0xFFF000FFu)|(id<<8); // TODO: patch CRC after this change! } if (!m_quiet) edm::LogInfo("HCAL") << "Reading " << len << " bytes for FED " << id << std::endl; } e.put(bare_product); }
virtual bool HcalTBSource::setRunAndEventInfo | ( | edm::EventID & | id, |
edm::TimeValue_t & | time | ||
) | [private, virtual] |
Implements edm::ProducerSourceBase.
void HcalTBSource::unpackSetup | ( | const std::vector< std::string > & | params | ) | [private] |
Definition at line 31 of file HcalTBSource.cc.
References i, m_sourceIdRemap, pos, and AlCaHLTBitMon_QueryRunRegistry::string.
{ for (std::vector<std::string>::const_iterator i=params.begin(); i!=params.end(); i++) { unsigned long pos=i->find(':'); std::string streamName=i->substr(0,pos); int remapTo=-1; if (pos!=std::string::npos) remapTo=atoi(i->c_str()+pos+1); m_sourceIdRemap.insert(std::pair<std::string,int>(streamName,remapTo)); if (remapTo!=-1) edm::LogInfo("HCAL") << streamName << " --> " << remapTo << endl; else edm::LogInfo("HCAL") << streamName << " using fedid in file" << endl; } }
const int HcalTBSource::CHUNK_COUNT = 64 [static, private] |
Definition at line 41 of file HcalTBSource.h.
int HcalTBSource::m_chunkIds[CHUNK_COUNT] [private] |
Definition at line 43 of file HcalTBSource.h.
Referenced by openFile(), and produce().
CDFChunk* HcalTBSource::m_chunks[CHUNK_COUNT] [private] |
Definition at line 42 of file HcalTBSource.h.
Referenced by openFile(), and produce().
CDFEventInfo* HcalTBSource::m_eventInfo [private] |
Definition at line 45 of file HcalTBSource.h.
Referenced by openFile(), and L1MuGMTHWFileReader::setRunAndEventInfo().
int HcalTBSource::m_eventNumberOffset [private] |
Definition at line 46 of file HcalTBSource.h.
Referenced by L1MuGMTHWFileReader::setRunAndEventInfo().
TFile* HcalTBSource::m_file [private] |
Definition at line 37 of file HcalTBSource.h.
Referenced by openFile(), L1MuGMTHWFileReader::setRunAndEventInfo(), and ~HcalTBSource().
int HcalTBSource::m_fileCounter [private] |
Definition at line 38 of file HcalTBSource.h.
Referenced by L1MuGMTHWFileReader::setRunAndEventInfo().
int HcalTBSource::m_i [private] |
Definition at line 38 of file HcalTBSource.h.
Referenced by openFile(), and L1MuGMTHWFileReader::setRunAndEventInfo().
bool HcalTBSource::m_onlyRemapped [private] |
Definition at line 39 of file HcalTBSource.h.
Referenced by openFile().
bool HcalTBSource::m_quiet [private] |
Definition at line 39 of file HcalTBSource.h.
Referenced by openFile(), and produce().
std::map<std::string,int> HcalTBSource::m_sourceIdRemap [private] |
Definition at line 44 of file HcalTBSource.h.
Referenced by openFile(), and unpackSetup().
TTree* HcalTBSource::m_tree [private] |
Definition at line 36 of file HcalTBSource.h.
Referenced by openFile(), L1MuGMTHWFileReader::setRunAndEventInfo(), and ~HcalTBSource().
int HcalTBSource::n_chunks [private] |
Definition at line 40 of file HcalTBSource.h.
Referenced by openFile(), and produce().