CMS 3D CMS Logo

GctDigiToPsbText.cc
Go to the documentation of this file.
1 
2 #include "GctDigiToPsbText.h"
3 
4 #include <iomanip>
5 using std::setfill;
6 using std::setw;
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 << std::endl;
23  }
24  }
25 }
26 
29  for (unsigned i = 0; i < 4; i++)
30  m_file[i].close();
31 }
32 
34  // static int nevt = -1; nevt++;
35 
36  // get digis
39  iEvent.getByLabel(m_gctInputLabel.label(), "isoEm", gctIsolaEm);
40  iEvent.getByLabel(m_gctInputLabel.label(), "nonIsoEm", gctNoIsoEm);
41 
43  uint16_t data[4][2] = {{0}};
44  for (int i = 0; i < 4; i++)
45  for (int j = 0; j < 2; j++)
46  data[i][j] = 0;
47 
48  std::stringstream sstrm;
49  if (m_hexUpperCase)
50  sstrm << std::uppercase;
51  else
52  sstrm.unsetf(std::ios::uppercase);
53 
54  // specify cycle bit sequence 1 0 1 0 ... or 0 1 0 1 ...
55  unsigned short cbs[2] = {1, 0};
56 
57  unsigned int ifile;
58  unsigned int cycle;
59  unsigned iIsola, iNoIso;
60 
61  for (int i = 0; i < 4; i++) {
62  cycle = i / 2;
63  ifile = i % 2;
64  iIsola = ifile + 2;
65  iNoIso = ifile;
66 
67  // get the data
68  data[iIsola][cycle] = gctIsolaEm->at(i).raw();
69  data[iNoIso][cycle] = gctNoIsoEm->at(i).raw();
70 
71  // print electrons
72  sstrm.str("");
73  sstrm << setw(4) << setfill('0') << std::hex << (data[iIsola][cycle] & 0x7fff) + ((cbs[cycle] & 0x1) << 15);
74  m_file[iIsola] << sstrm.str() << std::endl;
75  sstrm.str("");
76  sstrm << setw(4) << setfill('0') << std::hex << (data[iNoIso][cycle] & 0x7fff) + ((cbs[cycle] & 0x1) << 15);
77  m_file[iNoIso] << sstrm.str() << std::endl;
78  }
79 
81  for (unsigned i = 0; i < 4; i++)
82  m_file[i] << std::flush;
83 }
GctDigiToPsbText::m_gctInputLabel
edm::InputTag m_gctInputLabel
label for input digis
Definition: GctDigiToPsbText.h:33
good
const auto good
min quality of good
Definition: CAHitNtupletGeneratorKernelsImpl.h:760
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
funct::false
false
Definition: Factorize.h:29
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
GctDigiToPsbText.h
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
GctDigiToPsbText::~GctDigiToPsbText
~GctDigiToPsbText() override
Definition: GctDigiToPsbText.cc:27
edm::Handle
Definition: AssociativeIterator.h:50
GctDigiToPsbText::m_hexUpperCase
bool m_hexUpperCase
write upper case hex words
Definition: GctDigiToPsbText.h:39
GctDigiToPsbText::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: GctDigiToPsbText.cc:33
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
compare_using_db.ifile
ifile
Definition: compare_using_db.py:251
GctDigiToPsbText::GctDigiToPsbText
GctDigiToPsbText(const edm::ParameterSet &)
Definition: GctDigiToPsbText.cc:8
edm::ParameterSet
Definition: ParameterSet.h:47
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
std
Definition: JetResolutionObject.h:76
Exception
Definition: hltDiff.cc:245
GctDigiToPsbText::m_file
std::ofstream m_file[4]
handles for output files
Definition: GctDigiToPsbText.h:42
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
GctDigiToPsbText::m_textFileName
std::string m_textFileName
basename for output files
Definition: GctDigiToPsbText.h:36
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::Event
Definition: Event.h:73
cuy.ii
ii
Definition: cuy.py:589