CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

GctDigiToPsbText Class Reference

#include <GctDigiToPsbText.h>

Inheritance diagram for GctDigiToPsbText:
edm::EDAnalyzer

List of all members.

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

Detailed Description

Definition at line 24 of file GctDigiToPsbText.h.


Constructor & Destructor Documentation

GctDigiToPsbText::GctDigiToPsbText ( const edm::ParameterSet iConfig) [explicit]

open output text files

Definition at line 8 of file GctDigiToPsbText.cc.

References Exception, convertXMLtoSQLite_cfg::fileName, i, m_file, m_textFileName, and dbtoconf::out.

                                                                 : 
  m_gctInputLabel(iConfig.getParameter<edm::InputTag>("GctInputLabel")),
  m_textFileName(iConfig.getParameter<std::string>("TextFileName")), 
  m_hexUpperCase(iConfig.getUntrackedParameter<bool>("HexUpperCase",false)) {
  for (unsigned i=0; i<4; i++){
    std::stringstream fileStream;
    int ii = (i<2)?i:i+4;
    fileStream << m_textFileName << ii << ".txt";
    std::string fileName(fileStream.str());
    m_file[i].open(fileName.c_str(),std::ios::out);
    if(!m_file[i].good()) {
      throw cms::Exception("GctDigiToPsbTextTextFileOpenError")
        << "GctDigiToPsbText::GctDigiToPsbText : "
        << " couldn't create the file " << fileName 
        << std::endl;
    }
  }
}
GctDigiToPsbText::~GctDigiToPsbText ( )

close files

Definition at line 28 of file GctDigiToPsbText.cc.

References i, and m_file.

                                    {
  for (unsigned i=0; i<4; i++) 
    m_file[i].close();
}

Member Function Documentation

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, edm::Event::getByLabel(), i, compare_using_db::ifile, j, edm::InputTag::label(), m_file, m_gctInputLabel, and m_hexUpperCase.

                                                                             {
  
  //static int nevt = -1; nevt++;

  // get digis
  edm::Handle<L1GctEmCandCollection> gctIsolaEm;
  edm::Handle<L1GctEmCandCollection> gctNoIsoEm;
  iEvent.getByLabel(m_gctInputLabel.label(), "isoEm",    gctIsolaEm);
  iEvent.getByLabel(m_gctInputLabel.label(), "nonIsoEm", gctNoIsoEm);

  uint16_t data[4][2]= {{0}};
  for (int i=0; i<4; i++)
    for (int j=0; j<2; j++)
      data[i][j]=0;
  
  std::stringstream sstrm;
  if(m_hexUpperCase)
    sstrm << std::uppercase;
  else  
    sstrm.unsetf(std::ios::uppercase);

  // specify cycle bit sequence 1 0 1 0 ... or 0 1 0 1 ...
  unsigned short cbs[2] = {1,0};

  unsigned int ifile;
  unsigned int cycle;
  unsigned iIsola, iNoIso;

  for(int i=0; i<4; i++) {
    cycle = i/2;
    ifile = i%2;
    iIsola = ifile+2;
    iNoIso = ifile;
    
    //get the data
    data[iIsola][cycle] = gctIsolaEm->at(i).raw();
    data[iNoIso][cycle] = gctNoIsoEm->at(i).raw();
    
    //print electrons
    sstrm.str("");
    sstrm << setw(4) << setfill('0') << std::hex 
          << (data[iIsola][cycle] & 0x7fff) + ((cbs[cycle]&0x1)<<15);
    m_file[iIsola] << sstrm.str() << std::endl;
    sstrm.str("");
    sstrm << setw(4) << setfill('0') << std::hex 
          << (data[iNoIso][cycle] & 0x7fff) + ((cbs[cycle]&0x1)<<15);
    m_file[iNoIso] << sstrm.str() << std::endl;
  }
  
  for (unsigned i=0; i<4; i++)
    m_file[i] << std::flush;
  
}

Member Data Documentation

std::ofstream GctDigiToPsbText::fdebug [private]

handle for debug file

Definition at line 47 of file GctDigiToPsbText.h.

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().

label for input digis

Definition at line 35 of file GctDigiToPsbText.h.

Referenced by analyze().

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().