CMS 3D CMS Logo

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