55 : event_type_(
pset.getParameter<
int>(
"eventType")),
57 useDBEMap_(
pset.getParameter<
bool>(
"useDBEMap")) {
58 produces<FEDRawDataCollection>();
60 gemEMapToken_ = esConsumes<GEMeMap, GEMeMapRcd, edm::Transition::BeginRun>();
67 desc.add<
int>(
"eventType", 0);
68 desc.add<
bool>(
"useDBEMap",
false);
69 descriptions.
add(
"gemPackerDefault",
desc);
73 auto gemROmap = std::make_shared<GEMROMapping>();
76 auto gemEMap = std::make_unique<GEMeMap>(eMap);
77 gemEMap->convert(*gemROmap);
81 auto gemEMap = std::make_unique<GEMeMap>();
82 gemEMap->convertDummy(*gemROmap);
89 auto fedRawDataCol = std::make_unique<FEDRawDataCollection>();
98 auto gemROMap = runCache(
iEvent.getRun().index());
100 std::vector<std::unique_ptr<AMC13Event>> amc13Events;
103 int LV1_id =
iEvent.id().event();
104 uint8_t BX_id(
iEvent.bunchCrossing());
105 int OrN =
iEvent.orbitNumber();
109 std::map<int, GEMDigiCollection> gemBxMap;
110 for (
auto const& etaPart : *gemDigis) {
113 for (
auto digi = digis.first; digi != digis.second; ++digi) {
116 if (
search != gemBxMap.end()) {
117 search->second.insertDigi(gemId, *digi);
120 newGDC.insertDigi(gemId, *digi);
121 gemBxMap.insert(std::pair<int, GEMDigiCollection>(
bx, newGDC));
127 uint32_t amc13EvtLength = 0;
128 std::unique_ptr<AMC13Event> amc13Event = std::make_unique<AMC13Event>();
131 uint32_t amcSize = 0;
132 std::unique_ptr<AMCdata> amcData = std::make_unique<AMCdata>();
135 std::unique_ptr<GEBdata> gebData = std::make_unique<GEBdata>();
138 if (!gemROMap->isValidChamber(geb_ec))
142 auto vfats = gemROMap->getVfats(geb_dc.
detId);
143 for (
auto const& vfat_ec : vfats) {
146 uint16_t vfatId = vfat_ec.vfatAdd;
148 for (
auto const& gemBx : gemBxMap) {
149 int bc = BX_id + gemBx.first;
151 bool hasDigi =
false;
158 const GEMDigi& digi = (*digiIt);
170 if (chMap.
chNum < 64)
171 lsData |= 1UL << chMap.
chNum;
173 msData |= 1UL << (chMap.
chNum - 64);
176 <<
" fed: " <<
fedId <<
" amc:" <<
int(amcNum) <<
" geb:" <<
int(gebId)
177 <<
" vfat:" << vfat_dc.
localPhi <<
",type: " << vfat_dc.
vfatType <<
" id:" << gemId
178 <<
" ch:" << chMap.
chNum <<
" st:" << digi.
strip() <<
" bx:" << digi.
bx();
185 auto vfatData = std::make_unique<VFATdata>(geb_dc.
vfatVer, bc, 0, vfatId, lsData, msData);
186 gebData->addVFAT(*vfatData);
191 if (!gebData->vFATs()->empty()) {
193 gebData->setChamberHeader(gebData->vFATs()->size() * 3, gebId);
194 gebData->setChamberTrailer(LV1_id, BX_id, gebData->vFATs()->size() * 3);
195 amcData->addGEB(*gebData);
200 amcData->setAMCheader1(amcSize, BX_id, LV1_id, amcNum);
201 amcData->setAMCheader2(amcNum, OrN, 1);
202 amcData->setGEMeventHeader(amcData->gebs()->size(), 0);
203 amc13Event->addAMCpayload(*amcData);
205 amc13Event->addAMCheader(amcSize, 0, amcNum, 0);
206 amc13EvtLength += amcSize + 1;
210 if (!amc13Event->getAMCpayloads()->empty()) {
214 uint8_t nAMC = amc13Event->getAMCpayloads()->size();
215 amc13Event->setAMC13Header(1, nAMC, OrN);
216 amc13Event->setAMC13Trailer(BX_id, LV1_id, BX_id);
218 uint32_t EvtLength = amc13EvtLength + 4;
219 amc13Event->setCDFTrailer(EvtLength);
221 amc13Events.emplace_back(
std::move(amc13Event));
226 for (
const auto& amc13e : amc13Events) {
227 std::vector<uint64_t> words;
228 words.emplace_back(amc13e->getCDFHeader());
229 words.emplace_back(amc13e->getAMC13Header());
231 for (
const auto&
w : *amc13e->getAMCheaders())
232 words.emplace_back(
w);
234 for (
const auto&
amc : *amc13e->getAMCpayloads()) {
235 words.emplace_back(
amc.getAMCheader1());
236 words.emplace_back(
amc.getAMCheader2());
237 words.emplace_back(
amc.getGEMeventHeader());
239 for (
const auto& geb : *
amc.gebs()) {
240 words.emplace_back(geb.getChamberHeader());
242 for (
const auto& vfat : *geb.vFATs()) {
243 words.emplace_back(vfat.get_fw());
244 words.emplace_back(vfat.get_sw());
245 words.emplace_back(vfat.get_tw());
248 words.emplace_back(geb.getChamberTrailer());
251 words.emplace_back(
amc.getGEMeventTrailer());
252 words.emplace_back(
amc.getAMCTrailer());
255 words.emplace_back(amc13e->getAMC13Trailer());
256 words.emplace_back(amc13e->getCDFTrailer());
260 int dataSize = (words.size()) *
sizeof(
uint64_t);
264 for (
const auto&
word : words) {
267 LogDebug(
"GEMDigiToRawModule") <<
" words " << words.size();