#include <L1MuGMTHWFileReader.h>
Public Member Functions | |
L1MuGMTHWFileReader (edm::ParameterSet const &, edm::InputSourceDescription const &) | |
void | readNextEvent () |
~L1MuGMTHWFileReader () | |
Private Member Functions | |
virtual void | produce (edm::Event &) |
virtual bool | setRunAndEventInfo (edm::EventID &id, edm::TimeValue_t &time) |
Private Attributes | |
L1MuGMTInputEvent | m_evt |
std::ifstream | m_in |
Definition at line 41 of file L1MuGMTHWFileReader.h.
L1MuGMTHWFileReader::L1MuGMTHWFileReader | ( | edm::ParameterSet const & | ps, |
edm::InputSourceDescription const & | desc | ||
) | [explicit] |
Definition at line 39 of file L1MuGMTHWFileReader.cc.
References edm::ProducerSourceFromFiles::fileNames(), spr::find(), and m_in.
: ProducerSourceFromFiles(ps, desc, true) { produces<std::vector<L1MuRegionalCand> >("DT"); produces<std::vector<L1MuRegionalCand> >("CSC"); produces<std::vector<L1MuRegionalCand> >("RPCb"); produces<std::vector<L1MuRegionalCand> >("RPCf"); produces<L1CaloRegionCollection>(); if(!fileNames().size()) { throw std::runtime_error("L1MuGMTHWFileReader: no input file"); } edm::LogInfo("GMT_HWFileReader_info") << "opening file " << fileNames()[0]; m_in.open((fileNames()[0].substr(fileNames()[0].find(":")+1)).c_str()); if(!m_in) { throw std::runtime_error("L1MuGMTHWFileReader: file " + fileNames()[0] + " could not be openned"); } }
L1MuGMTHWFileReader::~L1MuGMTHWFileReader | ( | ) |
void L1MuGMTHWFileReader::produce | ( | edm::Event & | e | ) | [private, virtual] |
Implements edm::ProducerSourceBase.
Definition at line 82 of file L1MuGMTHWFileReader.cc.
References L1MuGMTInputEvent::getInputMuon(), L1MuGMTInputEvent::getIsoBit(), L1MuGMTInputEvent::getMipBit(), i, m_evt, RPCpg::mu, and edm::Event::put().
{ L1MuRegionalCand empty_mu; std::auto_ptr<std::vector<L1MuRegionalCand> > DTCands(new std::vector<L1MuRegionalCand>); for (unsigned i = 0; i < 4; i++) { const L1MuRegionalCand *mu = m_evt.getInputMuon("IND", i); if (!mu) mu = &empty_mu; DTCands->push_back(*mu); } e.put(DTCands,"DT"); std::auto_ptr<std::vector<L1MuRegionalCand> > CSCCands(new std::vector<L1MuRegionalCand>); for (unsigned i = 0; i < 4; i++) { const L1MuRegionalCand *mu = m_evt.getInputMuon("INC", i); if (!mu) mu = &empty_mu; CSCCands->push_back(*mu); } e.put(CSCCands,"CSC"); std::auto_ptr<std::vector<L1MuRegionalCand> > RPCbCands(new std::vector<L1MuRegionalCand>); for (unsigned i = 0; i < 4; i++) { const L1MuRegionalCand *mu = m_evt.getInputMuon("INB", i); if (!mu) mu = &empty_mu; RPCbCands->push_back(*mu); } e.put(RPCbCands,"RPCb"); std::auto_ptr<std::vector<L1MuRegionalCand> > RPCfCands(new std::vector<L1MuRegionalCand>); for (unsigned i = 0; i < 4; i++) { const L1MuRegionalCand *mu = m_evt.getInputMuon("INF", i); if (!mu) mu = &empty_mu; RPCfCands->push_back(*mu); } e.put(RPCfCands,"RPCf"); std::auto_ptr<L1CaloRegionCollection> rctRegions (new L1CaloRegionCollection); for(int ieta = 4; ieta < 18; ieta++) { for(int iphi = 0; iphi < 18; iphi++) { rctRegions->push_back(L1CaloRegion(0,false,true,m_evt.getMipBit(ieta-4,iphi),m_evt.getIsoBit(ieta-4,iphi),ieta,iphi)); } } e.put(rctRegions); }
void L1MuGMTHWFileReader::readNextEvent | ( | ) |
Definition at line 128 of file L1MuGMTHWFileReader.cc.
References L1MuGMTInputEvent::addInputMuon(), eta(), i, m_evt, m_in, phi, L1MuGMTInputEvent::reset(), L1MuRegionalCand::setBx(), L1MuGMTInputEvent::setEventNumber(), L1MuGMTInputEvent::setIsoBit(), L1MuGMTInputEvent::setMipBit(), L1MuGMTInputEvent::setRunNumber(), L1MuRegionalCand::setType(), and AlCaHLTBitMon_QueryRunRegistry::string.
{ m_evt.reset(); std::string line_id; do { int bx = 0; m_in >> line_id; if (line_id == "--") continue; if (line_id == "RUN") { unsigned long runnr; m_in >> runnr; m_evt.setRunNumber(runnr); } if (line_id == "EVT") { unsigned long evtnr; m_in >> evtnr; m_evt.setEventNumber(evtnr); } if (line_id == "DT" || line_id == "CSC" || line_id == "BRPC" || line_id == "FRPC") { // decode input muon unsigned inpmu = 0; unsigned val; m_in >> val; inpmu |= (val & 0x01) << 24; // valid charge m_in >> val; inpmu |= (val & 0x01) << 23; // charge m_in >> val; inpmu |= (val & 0x01) << 22; // halo / fine m_in >> val; inpmu |= (val & 0x3f) << 16; // eta m_in >> val; inpmu |= (val & 0x07) << 13; // quality m_in >> val; inpmu |= (val & 0x1f) << 8; // pt m_in >> val; inpmu |= (val & 0xff) ; // phi std::string chipid("IN"); chipid += line_id[0]; int type=0; if (line_id == "DT") type = 0; if (line_id == "CSC") type = 2; if (line_id == "BRPC") type = 1; if (line_id == "FRPC") type = 3; L1MuRegionalCand cand(inpmu); cand.setType(type); cand.setBx(bx); m_evt.addInputMuon(chipid, cand); } if (line_id == "MIP") { int nPairs; m_in >> nPairs; for (int i=0; i<nPairs; i++) { unsigned eta; unsigned phi; m_in >> eta; m_in >> phi; if (phi >= 9) phi-=9; else phi+=9; m_evt.setMipBit(eta, phi, true); } } if (line_id == "NQ") { int nPairs; m_in >> nPairs; for (int i=0; i<nPairs; i++) { unsigned eta; unsigned phi; m_in >> eta; m_in >> phi; if (phi >= 9) phi-=9; else phi+=9; m_evt.setIsoBit(eta, phi, false); } } //read the rest of the line const int sz=4000; char buf[sz]; m_in.getline(buf, sz); } while (line_id != "NQ" && !m_in.eof()); }
bool L1MuGMTHWFileReader::setRunAndEventInfo | ( | edm::EventID & | id, |
edm::TimeValue_t & | time | ||
) | [private, virtual] |
Implements edm::ProducerSourceBase.
Definition at line 109 of file HcalTBSource.cc.
References edm::ProducerSourceFromFiles::fileNames(), CDFEventInfo::getEventNumber(), CDFEventInfo::getRunNumber(), edm::ProducerSourceBase::luminosityBlock(), HcalTBSource::m_eventInfo, HcalTBSource::m_eventNumberOffset, HcalTBSource::m_file, HcalTBSource::m_fileCounter, HcalTBSource::m_i, HcalTBSource::m_tree, HcalTBSource::openFile(), edm::ProducerSourceBase::presentTime(), findQualityFiles::size, and edm::ProducerSourceBase::timeBetweenEvents().
{ bool is_new=false; while (m_tree==0 || m_i==m_tree->GetEntries()) { m_fileCounter++; if (m_file!=0) { m_file->Close(); m_file=0; m_tree=0; } if (m_fileCounter>=int(fileNames().size())) return false; // nothing good openFile(fileNames()[m_fileCounter]); is_new=true; } if (m_tree==0 || m_i==m_tree->GetEntries()) return false; //nothing good m_tree->GetEntry(m_i); m_i++; if (m_eventInfo!=0) { if (is_new) { if (m_eventInfo->getEventNumber()==0) m_eventNumberOffset=1; else m_eventNumberOffset=0; } // ZERO is unacceptable for a run number from a technical point of view id = EventID((m_eventInfo->getRunNumber()==0 ? 1 : m_eventInfo->getRunNumber()), id.luminosityBlock(), m_eventInfo->getEventNumber()+m_eventNumberOffset); } else { id = EventID(m_fileCounter+10, id.luminosityBlock(), m_i+1); } // time is a hack edm::TimeValue_t present_time = presentTime(); unsigned long time_between_events = timeBetweenEvents(); time = present_time + time_between_events; return true; }
L1MuGMTInputEvent L1MuGMTHWFileReader::m_evt [private] |
Definition at line 59 of file L1MuGMTHWFileReader.h.
Referenced by produce(), and readNextEvent().
std::ifstream L1MuGMTHWFileReader::m_in [private] |
Definition at line 58 of file L1MuGMTHWFileReader.h.
Referenced by L1MuGMTHWFileReader(), readNextEvent(), and ~L1MuGMTHWFileReader().