CMS 3D CMS Logo

RawToText.cc
Go to the documentation of this file.
1 
3 
4 // system
5 #include <fstream>
6 #include <iomanip>
7 #include <iostream>
8 #include <string>
9 // framework
12 // raw data collection
14 
16  : inputLabel_(iConfig.getParameter<edm::InputTag>("inputLabel")),
17  fedId_(iConfig.getUntrackedParameter<int>("fedId", 745)),
18  filename_(iConfig.getUntrackedParameter<std::string>("filename", "slinkOutput.txt")),
19  nevt_(0) {
20  edm::LogInfo("TextToDigi") << "Creating ASCII dump " << filename_ << std::endl;
21 }
22 
24 
25 void RawToText::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
26  nevt_++;
27 
28  // get raw data collection
30  iEvent.getByLabel(inputLabel_, feds);
31  const FEDRawData &gctRcd = feds->FEDData(fedId_);
32 
33  edm::LogInfo("GCT") << "Upacking FEDRawData of size " << std::dec << gctRcd.size() << std::endl;
34 
35  // do a simple check of the raw data
36  if (gctRcd.size() < 16) {
37  edm::LogWarning("Invalid Data") << "Empty/invalid GCT raw data, size = " << gctRcd.size() << std::endl;
38  return;
39  }
40 
41  const unsigned char *data = gctRcd.data();
42 
43  int eventSize = gctRcd.size() / 4;
44 
45  unsigned long d = 0;
46  for (int i = 0; i < eventSize; i++) {
47  d = 0;
48  // d = data[i*4+0] + (data[i*4+1]<<8) + (data[i*4+2]<<16) +
49  // (data[i*4+3]<<24);
50  for (int j = 0; j < 4; j++) {
51  d += ((data[i * 4 + j] & 0xff) << (8 * j));
52  }
53  file_ << std::setw(8) << std::setfill('0') << std::hex << d << std::endl;
54  }
55  file_ << std::flush << std::endl;
56 }
57 
59  // open VME file
60  file_.open(filename_.c_str(), std::ios::out);
61 
62  if (!file_.good()) {
63  edm::LogInfo("RawToText") << "Failed to open ASCII file " << filename_ << std::endl;
64  }
65 }
66 
67 void RawToText::endJob() { file_.close(); }
~RawToText() override
Definition: RawToText.cc:23
int fedId_
Definition: RawToText.h:39
void beginJob() override
Definition: RawToText.cc:58
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
RawToText(const edm::ParameterSet &)
Definition: RawToText.cc:15
std::ofstream file_
Definition: RawToText.h:43
std::string filename_
Definition: RawToText.h:42
int iEvent
Definition: GenABIO.cc:224
d
Definition: ztail.py:151
Log< level::Info, false > LogInfo
edm::InputTag inputLabel_
Definition: RawToText.h:36
int nevt_
Definition: RawToText.h:45
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
void endJob() override
Definition: RawToText.cc:67
Log< level::Warning, false > LogWarning
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: RawToText.cc:25