29 produces<FEDRawDataCollection>();
54 auto fed_product = std::make_unique<FEDRawDataCollection>(
data);
71 for (
int w_i = 0; w_i <
nfeds_; ++w_i) {
91 for (dttax = digis->begin(); dttax != digis->end(); ++dttax){
96 int wheelId = dttal.
wheel();
97 int sectorId = dttal.
sector();
98 int stationId = dttal.
station();
100 int layerId = dttal.
layer();
101 int cellId = (*ta).wire();
103 int dduId, rosId, robId, tdcId, tdcChannel;
104 if ( ! mapping->
geometryToReadOut(wheelId, stationId, sectorId, slId, layerId, cellId,
105 dduId, rosId, robId, tdcId, tdcChannel)) {
107 int crate =
theCRT(dduId, rosId);
109 if (crate != DTuROSFED)
continue;
111 int slot =
theSLT(dduId, rosId, robId);
112 int link =
theLNK(dduId, rosId, robId);
114 int tdcTime = (*ta).countsTDC();
118 int word = ( (link&0x7F)<<21)
119 + ( (tdcId&0x03)<<19)
120 + ((tdcChannel&0x1F)<<14)
121 + ( tdcTime&0x3FFF );
123 wslts[slot-1].push_back(word);
133 for (
int sltit = 0; sltit <
DOCESLOTS; sltit++) {
135 if (
bslts[sltit] == 0)
continue;
140 lines +=
dslts[sltit];
145 unsigned char* lineFED=dttfdata.
data();
147 int dataWord1, dataWord2;
151 dataWord1 = 0x50000000
153 dataWord2 = (DTuROSFED&0xFFF)<<8;
158 *((
int*)lineFED)=dataWord2;
160 *((
int*)lineFED)=dataWord1;
164 dataWord1 = (nslts&0xF)<<20;
170 *((
int*)lineFED)=dataWord2;
172 *((
int*)lineFED)=dataWord1;
174 for (
int sltit = 0; sltit <
DOCESLOTS; sltit++) {
176 if (
bslts[sltit] == 0)
continue;
178 dataWord1 = (
dslts[sltit]&0xFFFFFF);
179 dataWord2 = ((sltit+1)&0xF)<<16;
184 *((
int*)lineFED)=dataWord2;
186 *((
int*)lineFED)=dataWord1;
191 for (
int sltit = 0; sltit <
DOCESLOTS; sltit++) {
193 if (
bslts[sltit] == 0)
continue;
195 dataWord1 = ((sltit+1)&0xF)<<24;
201 *((
int*)lineFED)=dataWord2;
203 *((
int*)lineFED)=dataWord1;
211 *((
int*)lineFED)=dataWord2;
213 *((
int*)lineFED)=dataWord1;
215 for (
int nhit = 0; nhit <
bslts[sltit]/2; nhit++) {
217 dataWord1 = 0x20000000
218 +
wslts[sltit].at(nhit*2);
219 dataWord2 =
wslts[sltit].at(nhit*2+1);
224 *((
int*)lineFED)=dataWord2;
226 *((
int*)lineFED)=dataWord1;
229 if (
bslts[sltit]%2 == 1) {
231 dataWord1 = 0x20000000
233 dataWord2 = 0x1FFFFFFF;
238 *((
int*)lineFED)=dataWord2;
240 *((
int*)lineFED)=dataWord1;
243 dataWord1 = 0x40000000;
249 *((
int*)lineFED)=dataWord2;
251 *((
int*)lineFED)=dataWord1;
253 dataWord1 = 0x40000000;
259 *((
int*)lineFED)=dataWord2;
261 *((
int*)lineFED)=dataWord1;
264 dataWord2 = (
dslts[sltit]&0xFFFFF);
269 *((
int*)lineFED)=dataWord2;
271 *((
int*)lineFED)=dataWord1;
282 *((
int*)lineFED)=dataWord2;
284 *((
int*)lineFED)=dataWord1;
288 dataWord1 = 0xA0000000
294 dataWord2 += (newCRC&0xFFFF)<<16;
297 *((
int*)lineFED)=dataWord2;
299 *((
int*)lineFED)=dataWord1;
307 for (
int sltit = 0; sltit <
DOCESLOTS; sltit++) {
311 wslts[sltit].clear();
320 if (ros > 6 && ddu > 774) ddu = ddu - 5;
331 if (ros > 6 && ddu > 774) ddu = ddu - 5;
333 int slot = ((ros-1)/3)+1;
334 if (rob == 23) slot = 5;
335 if (ddu == 771) slot += 6;
336 else if (ddu == 774) slot += 6;
344 if (rob > 14) link = rob+1;
345 if (rob == 24) link = 15;
346 link += ((ros-1)%3)*24;
347 if (rob == 23) link = ros-1;
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::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.
std::pair< const_iterator, const_iterator > Range
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)