#include <L1Trigger/TextToDigi/plugins/GctDigiToPsbText.h>
Public Member Functions | |
GctDigiToPsbText (const edm::ParameterSet &) | |
~GctDigiToPsbText () | |
Private Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
Private Attributes | |
std::ofstream | fdebug |
handle for debug file | |
std::ofstream | m_file [4] |
handles for output files | |
edm::InputTag | m_gctInputLabel |
label for input digis | |
bool | m_hexUpperCase |
write upper case hex words | |
std::string | m_textFileName |
basename for output files |
Definition at line 24 of file GctDigiToPsbText.h.
GctDigiToPsbText::GctDigiToPsbText | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
open output text files
Definition at line 8 of file GctDigiToPsbText.cc.
References lat::endl(), Exception, aod_PYTHIA_cfg::fileName, i, m_file, m_textFileName, and out.
00008 : 00009 m_gctInputLabel(iConfig.getParameter<edm::InputTag>("GctInputLabel")), 00010 m_textFileName(iConfig.getParameter<std::string>("TextFileName")), 00011 m_hexUpperCase(iConfig.getUntrackedParameter<bool>("HexUpperCase",false)) { 00013 for (unsigned i=0; i<4; i++){ 00014 std::stringstream fileStream; 00015 int ii = (i<2)?i:i+4; 00016 fileStream << m_textFileName << ii << ".txt"; 00017 std::string fileName(fileStream.str()); 00018 m_file[i].open(fileName.c_str(),std::ios::out); 00019 if(!m_file[i].good()) { 00020 throw cms::Exception("GctDigiToPsbTextTextFileOpenError") 00021 << "GctDigiToPsbText::GctDigiToPsbText : " 00022 << " couldn't create the file " << fileName 00023 << std::endl; 00024 } 00025 } 00026 }
GctDigiToPsbText::~GctDigiToPsbText | ( | ) |
void GctDigiToPsbText::analyze | ( | const edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [private, virtual] |
buffer
flush data to files
Implements edm::EDAnalyzer.
Definition at line 36 of file GctDigiToPsbText.cc.
References cycle, data, lat::endl(), flush(), edm::Event::getByLabel(), i, indexGen::ifile, j, edm::InputTag::label(), m_file, m_gctInputLabel, and m_hexUpperCase.
00036 { 00037 00038 //static int nevt = -1; nevt++; 00039 00040 // get digis 00041 edm::Handle<L1GctEmCandCollection> gctIsolaEm; 00042 edm::Handle<L1GctEmCandCollection> gctNoIsoEm; 00043 iEvent.getByLabel(m_gctInputLabel.label(), "isoEm", gctIsolaEm); 00044 iEvent.getByLabel(m_gctInputLabel.label(), "nonIsoEm", gctNoIsoEm); 00045 00047 uint16_t data[4][2]= {{0}}; 00048 for (int i=0; i<4; i++) 00049 for (int j=0; j<2; j++) 00050 data[i][j]=0; 00051 00052 std::stringstream sstrm; 00053 if(m_hexUpperCase) 00054 sstrm << std::uppercase; 00055 else 00056 sstrm.unsetf(std::ios::uppercase); 00057 00058 // specify cycle bit sequence 1 0 1 0 ... or 0 1 0 1 ... 00059 unsigned short cbs[2] = {1,0}; 00060 00061 unsigned int ifile; 00062 unsigned int cycle; 00063 unsigned iIsola, iNoIso; 00064 00065 for(int i=0; i<4; i++) { 00066 cycle = i/2; 00067 ifile = i%2; 00068 iIsola = ifile+2; 00069 iNoIso = ifile; 00070 00071 //get the data 00072 data[iIsola][cycle] = gctIsolaEm->at(i).raw(); 00073 data[iNoIso][cycle] = gctNoIsoEm->at(i).raw(); 00074 00075 //print electrons 00076 sstrm.str(""); 00077 sstrm << setw(4) << setfill('0') << std::hex 00078 << (data[iIsola][cycle] & 0x7fff) + ((cbs[cycle]&0x1)<<15); 00079 m_file[iIsola] << sstrm.str() << std::endl; 00080 sstrm.str(""); 00081 sstrm << setw(4) << setfill('0') << std::hex 00082 << (data[iNoIso][cycle] & 0x7fff) + ((cbs[cycle]&0x1)<<15); 00083 m_file[iNoIso] << sstrm.str() << std::endl; 00084 } 00085 00087 for (unsigned i=0; i<4; i++) 00088 m_file[i] << std::flush; 00089 00090 }
std::ofstream GctDigiToPsbText::fdebug [private] |
std::ofstream GctDigiToPsbText::m_file[4] [private] |
handles for output files
Definition at line 44 of file GctDigiToPsbText.h.
Referenced by analyze(), GctDigiToPsbText(), and ~GctDigiToPsbText().
bool GctDigiToPsbText::m_hexUpperCase [private] |
write upper case hex words
Definition at line 41 of file GctDigiToPsbText.h.
Referenced by analyze().
std::string GctDigiToPsbText::m_textFileName [private] |
basename for output files
Definition at line 38 of file GctDigiToPsbText.h.
Referenced by GctDigiToPsbText().