27 produces<FEDRawDataCollection>();
49 auto fed_product = std::make_unique<FEDRawDataCollection>(
data);
63 for (
int w_i = 0; w_i <
nfeds_; ++w_i) {
79 for (dttax = digis->begin(); dttax != digis->end(); ++dttax) {
83 int wheelId = dttal.
wheel();
84 int sectorId = dttal.
sector();
85 int stationId = dttal.
station();
87 int layerId = dttal.
layer();
88 int cellId = (*ta).wire();
90 int dduId, rosId, robId, tdcId, tdcChannel;
92 wheelId, stationId, sectorId, slId, layerId, cellId, dduId, rosId, robId, tdcId, tdcChannel)) {
93 int crate =
theCRT(dduId, rosId);
95 if (crate != DTuROSFED)
98 int slot =
theSLT(dduId, rosId, robId);
101 int tdcTime = (*ta).countsTDC();
105 int word = ((link & 0x7F) << 21) + ((tdcId & 0x03) << 19) + ((tdcChannel & 0x1F) << 14) + (tdcTime & 0x3FFF);
107 wslts[slot - 1].push_back(word);
115 for (
int sltit = 0; sltit <
DOCESLOTS; sltit++) {
116 if (
bslts[sltit] == 0)
122 lines +=
dslts[sltit];
126 dttfdata.
resize(lines * 8);
127 unsigned char* lineFED = dttfdata.
data();
129 int dataWord1, dataWord2;
133 dataWord1 = 0x50000000 + (
eventNum & 0xFFFFFF);
134 dataWord2 = (DTuROSFED & 0xFFF) << 8;
139 *((
int*)lineFED) = dataWord2;
141 *((
int*)lineFED) = dataWord1;
145 dataWord1 = (nslts & 0xF) << 20;
151 *((
int*)lineFED) = dataWord2;
153 *((
int*)lineFED) = dataWord1;
155 for (
int sltit = 0; sltit <
DOCESLOTS; sltit++) {
156 if (
bslts[sltit] == 0)
159 dataWord1 = (
dslts[sltit] & 0xFFFFFF);
160 dataWord2 = ((sltit + 1) & 0xF) << 16;
165 *((
int*)lineFED) = dataWord2;
167 *((
int*)lineFED) = dataWord1;
172 for (
int sltit = 0; sltit <
DOCESLOTS; sltit++) {
173 if (
bslts[sltit] == 0)
176 dataWord1 = ((sltit + 1) & 0xF) << 24;
182 *((
int*)lineFED) = dataWord2;
184 *((
int*)lineFED) = dataWord1;
192 *((
int*)lineFED) = dataWord2;
194 *((
int*)lineFED) = dataWord1;
196 for (
int nhit = 0; nhit <
bslts[sltit] / 2; nhit++) {
197 dataWord1 = 0x20000000 +
wslts[sltit].at(nhit * 2);
198 dataWord2 =
wslts[sltit].at(nhit * 2 + 1);
203 *((
int*)lineFED) = dataWord2;
205 *((
int*)lineFED) = dataWord1;
208 if (
bslts[sltit] % 2 == 1) {
209 dataWord1 = 0x20000000 +
wslts[sltit].at(
bslts[sltit] - 1);
210 dataWord2 = 0x1FFFFFFF;
215 *((
int*)lineFED) = dataWord2;
217 *((
int*)lineFED) = dataWord1;
220 dataWord1 = 0x40000000;
226 *((
int*)lineFED) = dataWord2;
228 *((
int*)lineFED) = dataWord1;
230 dataWord1 = 0x40000000;
236 *((
int*)lineFED) = dataWord2;
238 *((
int*)lineFED) = dataWord1;
241 dataWord2 = (
dslts[sltit] & 0xFFFFF);
246 *((
int*)lineFED) = dataWord2;
248 *((
int*)lineFED) = dataWord1;
259 *((
int*)lineFED) = dataWord2;
261 *((
int*)lineFED) = dataWord1;
265 dataWord1 = 0xA0000000 + (lines & 0xFFFFFF);
270 dataWord2 += (newCRC & 0xFFFF) << 16;
273 *((
int*)lineFED) = dataWord2;
275 *((
int*)lineFED) = dataWord1;
281 for (
int sltit = 0; sltit <
DOCESLOTS; sltit++) {
284 wslts[sltit].clear();
291 if (ros > 6 && ddu > 774)
304 if (ros > 6 && ddu > 774)
307 int slot = ((ros - 1) / 3) + 1;
323 link += ((ros - 1) % 3) * 24;
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
~DTuROSDigiToRaw() override
Destructor.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::InputTag DTDigiInputTag_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< int > wslts[DOCESLOTS]
int layer() const
Return the layer number.
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.
#define DEFINE_FWK_MODULE(type)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
int theLNK(int ddu, int ros, int rob)
int geometryToReadOut(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, int &dduId, int &rosId, int &robId, int &tdcId, int &channelId) const
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
void process(int DTuROSFED, edm::Handle< DTDigiCollection > digis, edm::ESHandle< DTReadOutMapping > mapping, FEDRawDataCollection &data)
void calcCRC(long, int &)
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 station() const
Return the station number.
int wheel() const
Return the wheel number.
int theCRT(int ddu, int ros)