CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
GctDigiToPsbText Class Reference

#include <GctDigiToPsbText.h>

Inheritance diagram for GctDigiToPsbText:
edm::EDAnalyzer

Public Member Functions

 GctDigiToPsbText (const edm::ParameterSet &)
 
 ~GctDigiToPsbText ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 

Private Attributes

std::ofstream fdebug
 handle for debug file More...
 
std::ofstream m_file [4]
 handles for output files More...
 
edm::InputTag m_gctInputLabel
 label for input digis More...
 
bool m_hexUpperCase
 write upper case hex words More...
 
std::string m_textFileName
 basename for output files More...
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

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 edm::hlt::Exception, convertXMLtoSQLite_cfg::fileName, i, m_file, m_textFileName, and dbtoconf::out.

8  :
9  m_gctInputLabel(iConfig.getParameter<edm::InputTag>("GctInputLabel")),
10  m_textFileName(iConfig.getParameter<std::string>("TextFileName")),
11  m_hexUpperCase(iConfig.getUntrackedParameter<bool>("HexUpperCase",false)) {
13  for (unsigned i=0; i<4; i++){
14  std::stringstream fileStream;
15  int ii = (i<2)?i:i+4;
16  fileStream << m_textFileName << ii << ".txt";
17  std::string fileName(fileStream.str());
18  m_file[i].open(fileName.c_str(),std::ios::out);
19  if(!m_file[i].good()) {
20  throw cms::Exception("GctDigiToPsbTextTextFileOpenError")
21  << "GctDigiToPsbText::GctDigiToPsbText : "
22  << " couldn't create the file " << fileName
23  << std::endl;
24  }
25  }
26 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::ofstream m_file[4]
handles for output files
std::string m_textFileName
basename for output files
edm::InputTag m_gctInputLabel
label for input digis
tuple out
Definition: dbtoconf.py:99
bool m_hexUpperCase
write upper case hex words
GctDigiToPsbText::~GctDigiToPsbText ( )

close files

Definition at line 28 of file GctDigiToPsbText.cc.

References i, and m_file.

28  {
30  for (unsigned i=0; i<4; i++)
31  m_file[i].close();
32 }
int i
Definition: DBlmapReader.cc:9
std::ofstream m_file[4]
handles for output files

Member Function Documentation

void GctDigiToPsbText::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

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.

36  {
37 
38  //static int nevt = -1; nevt++;
39 
40  // get digis
43  iEvent.getByLabel(m_gctInputLabel.label(), "isoEm", gctIsolaEm);
44  iEvent.getByLabel(m_gctInputLabel.label(), "nonIsoEm", gctNoIsoEm);
45 
47  uint16_t data[4][2]= {{0}};
48  for (int i=0; i<4; i++)
49  for (int j=0; j<2; j++)
50  data[i][j]=0;
51 
52  std::stringstream sstrm;
53  if(m_hexUpperCase)
54  sstrm << std::uppercase;
55  else
56  sstrm.unsetf(std::ios::uppercase);
57 
58  // specify cycle bit sequence 1 0 1 0 ... or 0 1 0 1 ...
59  unsigned short cbs[2] = {1,0};
60 
61  unsigned int ifile;
62  unsigned int cycle;
63  unsigned iIsola, iNoIso;
64 
65  for(int i=0; i<4; i++) {
66  cycle = i/2;
67  ifile = i%2;
68  iIsola = ifile+2;
69  iNoIso = ifile;
70 
71  //get the data
72  data[iIsola][cycle] = gctIsolaEm->at(i).raw();
73  data[iNoIso][cycle] = gctNoIsoEm->at(i).raw();
74 
75  //print electrons
76  sstrm.str("");
77  sstrm << setw(4) << setfill('0') << std::hex
78  << (data[iIsola][cycle] & 0x7fff) + ((cbs[cycle]&0x1)<<15);
79  m_file[iIsola] << sstrm.str() << std::endl;
80  sstrm.str("");
81  sstrm << setw(4) << setfill('0') << std::hex
82  << (data[iNoIso][cycle] & 0x7fff) + ((cbs[cycle]&0x1)<<15);
83  m_file[iNoIso] << sstrm.str() << std::endl;
84  }
85 
87  for (unsigned i=0; i<4; i++)
88  m_file[i] << std::flush;
89 
90 }
int i
Definition: DBlmapReader.cc:9
int cycle
std::ofstream m_file[4]
handles for output files
int j
Definition: DBlmapReader.cc:9
edm::InputTag m_gctInputLabel
label for input digis
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
bool m_hexUpperCase
write upper case hex words
std::string const & label() const
Definition: InputTag.h:25
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82

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

edm::InputTag GctDigiToPsbText::m_gctInputLabel
private

label for input digis

Definition at line 35 of file GctDigiToPsbText.h.

Referenced by analyze().

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