25 produces<FEDRawDataCollection>();
29 debug_ =
pset.getUntrackedParameter<
bool>(
"debug",
false);
37 mapping_token_ = esConsumes<DTReadOutMapping, DTReadOutMappingRcd>();
48 auto fed_product = std::make_unique<FEDRawDataCollection>(
data);
61 for (
int w_i = 0; w_i <
nfeds_; ++w_i) {
77 for (dttax = digis->begin(); dttax != digis->end(); ++dttax) {
81 int wheelId = dttal.
wheel();
82 int sectorId = dttal.
sector();
83 int stationId = dttal.
station();
85 int layerId = dttal.
layer();
86 int cellId = (*ta).wire();
88 int dduId, rosId, robId, tdcId, tdcChannel;
89 if (!
mapping->geometryToReadOut(
90 wheelId, stationId, sectorId, slId, layerId, cellId, dduId, rosId, robId, tdcId, tdcChannel)) {
91 int crate =
theCRT(dduId, rosId);
93 if (crate != DTuROSFED)
96 int slot =
theSLT(dduId, rosId, robId);
97 int link =
theLNK(dduId, rosId, robId);
99 int tdcTime = (*ta).countsTDC();
103 int word = ((link & 0x7F) << 21) + ((tdcId & 0x03) << 19) + ((tdcChannel & 0x1F) << 14) + (tdcTime & 0x3FFF);
113 for (
int sltit = 0; sltit <
DOCESLOTS; sltit++) {
114 if (
bslts[sltit] == 0)
125 unsigned char* lineFED = dttfdata.
data();
127 int dataWord1, dataWord2;
131 dataWord1 = 0x50000000 + (
eventNum & 0xFFFFFF);
132 dataWord2 = (DTuROSFED & 0xFFF) << 8;
137 *((
int*)lineFED) = dataWord2;
139 *((
int*)lineFED) = dataWord1;
143 dataWord1 = (nslts & 0xF) << 20;
149 *((
int*)lineFED) = dataWord2;
151 *((
int*)lineFED) = dataWord1;
153 for (
int sltit = 0; sltit <
DOCESLOTS; sltit++) {
154 if (
bslts[sltit] == 0)
157 dataWord1 = (
dslts[sltit] & 0xFFFFFF);
158 dataWord2 = ((sltit + 1) & 0xF) << 16;
163 *((
int*)lineFED) = dataWord2;
165 *((
int*)lineFED) = dataWord1;
170 for (
int sltit = 0; sltit <
DOCESLOTS; sltit++) {
171 if (
bslts[sltit] == 0)
174 dataWord1 = ((sltit + 1) & 0xF) << 24;
180 *((
int*)lineFED) = dataWord2;
182 *((
int*)lineFED) = dataWord1;
190 *((
int*)lineFED) = dataWord2;
192 *((
int*)lineFED) = dataWord1;
194 for (
int nhit = 0; nhit <
bslts[sltit] / 2; nhit++) {
195 dataWord1 = 0x20000000 +
wslts[sltit].at(nhit * 2);
196 dataWord2 =
wslts[sltit].at(nhit * 2 + 1);
201 *((
int*)lineFED) = dataWord2;
203 *((
int*)lineFED) = dataWord1;
206 if (
bslts[sltit] % 2 == 1) {
207 dataWord1 = 0x20000000 +
wslts[sltit].at(
bslts[sltit] - 1);
208 dataWord2 = 0x1FFFFFFF;
213 *((
int*)lineFED) = dataWord2;
215 *((
int*)lineFED) = dataWord1;
218 dataWord1 = 0x40000000;
224 *((
int*)lineFED) = dataWord2;
226 *((
int*)lineFED) = dataWord1;
228 dataWord1 = 0x40000000;
234 *((
int*)lineFED) = dataWord2;
236 *((
int*)lineFED) = dataWord1;
239 dataWord2 = (
dslts[sltit] & 0xFFFFF);
244 *((
int*)lineFED) = dataWord2;
246 *((
int*)lineFED) = dataWord1;
257 *((
int*)lineFED) = dataWord2;
259 *((
int*)lineFED) = dataWord1;
263 dataWord1 = 0xA0000000 + (
lines & 0xFFFFFF);
268 dataWord2 += (newCRC & 0xFFFF) << 16;
271 *((
int*)lineFED) = dataWord2;
273 *((
int*)lineFED) = dataWord1;
279 for (
int sltit = 0; sltit <
DOCESLOTS; sltit++) {
282 wslts[sltit].clear();
289 if (ros > 6 && ddu > 774)
302 if (ros > 6 && ddu > 774)
305 int slot = ((ros - 1) / 3) + 1;
321 link += ((ros - 1) % 3) * 24;
int station() const
Return the station number.
~DTuROSDigiToRaw() override
Destructor.
edm::ESGetToken< DTReadOutMapping, DTReadOutMappingRcd > mapping_token_
edm::InputTag DTDigiInputTag_
std::vector< int > wslts[DOCESLOTS]
int theSLT(int ddu, int ros, int rob)
void produce(edm::Event &e, const edm::EventSetup &c) override
Produce digis out of raw data.
static const int DOCESLOTS
bool fillRawData(edm::Event &e, const edm::EventSetup &c, FEDRawDataCollection &data)
Generate and fill FED raw data for a full event.
void resize(size_t newsize)
#define DEFINE_FWK_MODULE(type)
int theLNK(int ddu, int ros, int rob)
int superlayer() const
Return the superlayer number (deprecated method name)
edm::EDGetTokenT< DTDigiCollection > Raw_token
std::pair< const_iterator, const_iterator > Range
std::vector< DigiType >::const_iterator const_iterator
int layer() const
Return the layer number.
void process(int DTuROSFED, edm::Handle< DTDigiCollection > digis, edm::ESHandle< DTReadOutMapping > mapping, FEDRawDataCollection &data)
void calcCRC(long, int &)
int wheel() const
Return the wheel number.
char data[epos_bytes_allocation]
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
DTuROSDigiToRaw(const edm::ParameterSet &pset)
Constructor.
int theCRT(int ddu, int ros)