19 useDBEMap_(
pset.getParameter<
bool>(
"useDBEMap")),
20 unPackStatusDigis_(
pset.getParameter<
bool>(
"unPackStatusDigis")) {
22 gemEMapToken_ = esConsumes<GEMeMap, GEMeMapRcd, edm::Transition::BeginRun>();
24 produces<GEMDigiCollection>();
26 produces<GEMVfatStatusDigiCollection>(
"vfatStatus");
27 produces<GEMGEBdataCollection>(
"gebStatus");
28 produces<GEMAMCdataCollection>(
"AMCdata");
29 produces<GEMAMC13EventCollection>(
"AMC13Event");
36 desc.
add<
bool>(
"useDBEMap",
false);
37 desc.
add<
bool>(
"unPackStatusDigis",
false);
38 descriptions.
add(
"muonGEMDigisDefault", desc);
42 auto gemROmap = std::make_shared<GEMROMapping>();
45 auto gemEMap = std::make_unique<GEMeMap>(eMap);
46 gemEMap->convert(*gemROmap);
50 auto gemEMap = std::make_unique<GEMeMap>();
51 gemEMap->convertDummy(*gemROmap);
58 auto outGEMDigis = std::make_unique<GEMDigiCollection>();
59 auto outVFATStatus = std::make_unique<GEMVfatStatusDigiCollection>();
60 auto outGEBStatus = std::make_unique<GEMGEBdataCollection>();
61 auto outAMCdata = std::make_unique<GEMAMCdataCollection>();
62 auto outAMC13Event = std::make_unique<GEMAMC13EventCollection>();
68 auto gemROMap = runCache(
iEvent.getRun().index());
74 LogDebug(
"GEMRawToDigiModule") <<
" words " << nWords;
78 const unsigned char*
data = fedData.
data();
80 auto amc13Event = std::make_unique<AMC13Event>();
84 amc13Event->setCDFHeader(*
word);
85 amc13Event->setAMC13Header(*(++
word));
88 for (uint8_t
i = 0;
i < amc13Event->nAMC(); ++
i)
89 amc13Event->addAMCheader(*(++
word));
92 for (uint8_t
i = 0;
i < amc13Event->nAMC(); ++
i) {
93 auto amcData = std::make_unique<AMCdata>();
94 amcData->setAMCheader1(*(++
word));
95 amcData->setAMCheader2(*(++
word));
96 amcData->setGEMeventHeader(*(++
word));
97 uint16_t amcBx = amcData->bx();
98 uint8_t amcNum = amcData->amcNum();
101 for (uint8_t
j = 0;
j < amcData->davCnt(); ++
j) {
102 auto gebData = std::make_unique<GEBdata>();
103 gebData->setChamberHeader(*(++
word));
105 uint8_t gebId = gebData->inputID();
110 for (uint16_t
k = 0;
k < gebData->vfatWordCnt() / 3;
k++) {
111 auto vfatData = std::make_unique<VFATdata>();
112 vfatData->read_fw(*(++
word));
113 vfatData->read_sw(*(++
word));
114 vfatData->read_tw(*(++
word));
116 vfatData->setVersion(geb_dc.
vfatVer);
117 uint16_t vfatId = vfatData->vfatId();
121 if (!gemROMap->isValidChipID(vfat_ec)) {
123 <<
"InValid: amcNum " <<
int(amcNum) <<
" gebId " <<
int(gebId) <<
" vfatId " <<
int(vfatId)
124 <<
" vfat Pos " <<
int(vfatData->position());
128 if (vfatData->quality()) {
130 <<
"Quality " <<
int(vfatData->quality()) <<
" b1010 " <<
int(vfatData->b1010()) <<
" b1100 "
131 <<
int(vfatData->b1100()) <<
" b1110 " <<
int(vfatData->b1110());
132 if (vfatData->crc() != vfatData->checkCRC()) {
134 <<
"DIFFERENT CRC :" << vfatData->crc() <<
" " << vfatData->checkCRC();
142 uint16_t bc = vfatData->bc();
149 chan0xf = ((vfatData->lsData() >>
chan) & 0
x1);
151 chan0xf = ((vfatData->msData() >> (
chan - 64)) & 0x1);
165 <<
" fed: " <<
fedId <<
" amc:" <<
int(amcNum) <<
" geb:" <<
int(gebId) <<
" vfat:" << vfat_dc.
localPhi
166 <<
",type: " << vfat_dc.
vfatType <<
" id:" << gemId <<
" ch:" << chMap.
chNum <<
" st:" << digi.
strip()
167 <<
" bx:" << digi.
bx();
169 outGEMDigis.get()->insertDigi(gemId, digi);
179 gebData->setChamberTrailer(*(++
word));
182 outGEBStatus.get()->insertDigi(gemChId.
chamberId(), (*gebData));
187 amcData->setGEMeventTrailer(*(++
word));
188 amcData->setAMCTrailer(*(++
word));
191 outAMCdata.get()->insertDigi(amcData->boardId(), (*amcData));
196 amc13Event->setAMC13Trailer(*(++
word));
197 amc13Event->setCDFTrailer(*(++
word));
200 outAMC13Event.get()->insertDigi(amc13Event->bxId(),
AMC13Event(*amc13Event));