CMS 3D CMS Logo

TotemTriggerRawToDigi.cc
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * This is a part of TOTEM offline software.
4 * Authors:
5 * Jan Kašpar (jan.kaspar@gmail.com)
6 *
7 ****************************************************************************/
8 
14 
18 
20 
21 #include <string>
22 #include <iostream>
23 
25 public:
26  explicit TotemTriggerRawToDigi(const edm::ParameterSet &);
27  ~TotemTriggerRawToDigi() override;
28 
29  void produce(edm::Event &, const edm::EventSetup &) override;
30 
31 private:
32  unsigned int fedId;
33 
35 
37  int ProcessLoneGFrame(uint64_t *oBuf, unsigned long size, TotemTriggerCounters &data);
38 };
39 
40 using namespace edm;
41 using namespace std;
42 
44  : fedId(conf.getParameter<unsigned int>("fedId")) {
45  fedDataToken = consumes<FEDRawDataCollection>(conf.getParameter<edm::InputTag>("rawDataTag"));
46 
47  if (fedId == 0)
49 
50  produces<TotemTriggerCounters>();
51 }
52 
54 
56  // raw data handle
58  event.getByToken(fedDataToken, rawData);
59 
60  // book output products
61  TotemTriggerCounters totemTriggerCounters;
62 
63  // unpack trigger data
64  const FEDRawData &data = rawData->FEDData(fedId);
65  uint64_t *buf = (uint64_t *)data.data();
66  unsigned int sizeInWords = data.size() / 8; // bytes -> words
67  if (data.size() > 0)
68  ProcessLoneGFrame(buf + 2, sizeInWords - 4, totemTriggerCounters);
69 
70  // commit products to event
71  event.put(make_unique<TotemTriggerCounters>(totemTriggerCounters));
72 }
73 
75  if (size != 20) {
76  LogError("Totem") << "Error in TotemTriggerRawToDigi::ProcessLoneGFrame > "
77  << "Wrong LoneG frame size: " << size << " (shall be 20)." << endl;
78  return 1;
79  }
80 
81  // buffer mapping: OptoRx buffer --> LoneG buffer
82  uint64_t buf[5];
83  for (unsigned int i = 0; i < 5; i++)
84  buf[i] = 0;
85 
86  for (unsigned int i = 0; i < 20; i++) {
87  int row = i / 4;
88  int col = i % 4;
89  buf[row] |= (oBuf[i] & 0xFFFF) << (col * 16);
90  }
91 
92  td.type = (buf[0] >> 56) & 0xF;
93  td.event_num = (buf[0] >> 32) & 0xFFFFFF;
94  td.bunch_num = (buf[0] >> 20) & 0xFFF;
95  td.src_id = (buf[0] >> 8) & 0xFFF;
96 
97  td.orbit_num = (buf[1] >> 32) & 0xFFFFFFFF;
98  td.revision_num = (buf[1] >> 24) & 0xFF;
99 
100  td.run_num = (buf[2] >> 32) & 0xFFFFFFFF;
101  td.trigger_num = (buf[2] >> 0) & 0xFFFFFFFF;
102 
103  td.inhibited_triggers_num = (buf[3] >> 32) & 0xFFFFFFFF;
104  td.input_status_bits = (buf[3] >> 0) & 0xFFFFFFFF;
105 
106 #ifdef DEBUG
107  printf(">> RawDataUnpacker::ProcessLoneGFrame > size = %li\n", size);
108  printf(
109  "\ttype = %x, event number = %x, bunch number = %x, id = %x\n", td.type, td.event_num, td.bunch_num, td.src_id);
110  printf("\torbit number = %x, revision = %x\n", td.orbit_num, td.revision_num);
111  printf("\trun number = %x, trigger number = %x\n", td.run_num, td.trigger_num);
112  printf("\tinhibited triggers = %x, input status bits = %x\n", td.inhibited_triggers_num, td.input_status_bits);
113 #endif
114 
115  return 0;
116 }
117 
FEDNumbering.h
TotemTriggerCounters::orbit_num
unsigned int orbit_num
Definition: TotemTriggerCounters.h:22
mps_fire.i
i
Definition: mps_fire.py:428
edm::EDGetTokenT< FEDRawDataCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
cuy.col
col
Definition: cuy.py:1009
l1tstage2_dqm_sourceclient-live_cfg.rawData
rawData
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:163
TotemTriggerCounters::event_num
unsigned int event_num
Definition: TotemTriggerCounters.h:21
FEDNumbering::MINTotemTriggerFEDID
Definition: FEDNumbering.h:33
EDProducer.h
TotemTriggerCounters::revision_num
unsigned char revision_num
Definition: TotemTriggerCounters.h:23
TotemTriggerRawToDigi::ProcessLoneGFrame
int ProcessLoneGFrame(uint64_t *oBuf, unsigned long size, TotemTriggerCounters &data)
Process one LoneG frame.
Definition: TotemTriggerRawToDigi.cc:73
FEDRawData.h
edm::Handle< FEDRawDataCollection >
TotemTriggerRawToDigi::TotemTriggerRawToDigi
TotemTriggerRawToDigi(const edm::ParameterSet &)
Definition: TotemTriggerRawToDigi.cc:42
FEDRawData
Definition: FEDRawData.h:19
MakerMacros.h
TotemTriggerCounters::trigger_num
unsigned int trigger_num
Definition: TotemTriggerCounters.h:24
TotemTriggerRawToDigi::fedId
unsigned int fedId
Definition: TotemTriggerRawToDigi.cc:36
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TotemTriggerCounters::type
unsigned char type
Definition: TotemTriggerCounters.h:20
TotemTriggerRawToDigi
Definition: TotemTriggerRawToDigi.cc:23
TotemTriggerRawToDigi::fedDataToken
edm::EDGetTokenT< FEDRawDataCollection > fedDataToken
Definition: TotemTriggerRawToDigi.cc:38
edm::ParameterSet
Definition: ParameterSet.h:47
TotemTriggerCounters.h
Event.h
TotemTriggerCounters::input_status_bits
unsigned int input_status_bits
Definition: TotemTriggerCounters.h:24
createfilelist.int
int
Definition: createfilelist.py:10
FEDRawDataCollection.h
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
l1tstage2_dqm_sourceclient-live_cfg.fedId
fedId
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:89
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
visDQMUpload.buf
buf
Definition: visDQMUpload.py:160
InputTag.h
std
Definition: JetResolutionObject.h:76
TotemTriggerCounters::bunch_num
unsigned int bunch_num
Definition: TotemTriggerCounters.h:21
TotemTriggerCounters
Definition: TotemTriggerCounters.h:14
TotemTriggerRawToDigi::~TotemTriggerRawToDigi
~TotemTriggerRawToDigi() override
Definition: TotemTriggerRawToDigi.cc:52
TotemTriggerCounters::run_num
unsigned int run_num
Definition: TotemTriggerCounters.h:24
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
TotemTriggerCounters::src_id
unsigned int src_id
Definition: TotemTriggerCounters.h:21
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
TotemTriggerRawToDigi::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: TotemTriggerRawToDigi.cc:54
edm::InputTag
Definition: InputTag.h:15
TotemTriggerCounters::inhibited_triggers_num
unsigned int inhibited_triggers_num
Definition: TotemTriggerCounters.h:24
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443