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::beginJob
void beginJob() override
Definition: RawToText.cc:58
l1tstage2emulator_dqm_sourceclient-live_cfg.feds
feds
Definition: l1tstage2emulator_dqm_sourceclient-live_cfg.py:153
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
edm
HLT enums.
Definition: AlignableModifier.h:19
RawToText::inputLabel_
edm::InputTag inputLabel_
Definition: RawToText.h:36
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:85964
RawToText::nevt_
int nevt_
Definition: RawToText.h:45
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
FEDRawData
Definition: FEDRawData.h:19
RawToText.h
RawToText::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: RawToText.cc:25
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RawToText::endJob
void endJob() override
Definition: RawToText.cc:67
edm::ParameterSet
Definition: ParameterSet.h:47
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
FEDRawDataCollection.h
edm::EventSetup
Definition: EventSetup.h:57
RawToText::filename_
std::string filename_
Definition: RawToText.h:42
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
RawToText::RawToText
RawToText(const edm::ParameterSet &)
Definition: RawToText.cc:15
RawToText::~RawToText
~RawToText() override
Definition: RawToText.cc:23
RawToText::fedId_
int fedId_
Definition: RawToText.h:39
std
Definition: JetResolutionObject.h:76
Exception.h
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
ztail.d
d
Definition: ztail.py:151
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::Event
Definition: Event.h:73
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
RawToText::file_
std::ofstream file_
Definition: RawToText.h:43