CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GctDigiToPsbText.cc
Go to the documentation of this file.
1 
2 #include "GctDigiToPsbText.h"
3 
4 #include <iomanip>
5 using std::setw;
6 using std::setfill;
7 
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 }
27 
30  for (unsigned i=0; i<4; i++)
31  m_file[i].close();
32 }
33 
34 
35 void
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 iEvent
Definition: GenABIO.cc:243
int cycle
std::ofstream m_file[4]
handles for output files
int j
Definition: DBlmapReader.cc:9
std::string m_textFileName
basename for output files
edm::InputTag m_gctInputLabel
label for input digis
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
tuple out
Definition: dbtoconf.py:99
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
virtual void analyze(const edm::Event &, const edm::EventSetup &)
GctDigiToPsbText(const edm::ParameterSet &)