24 event_type_(pset.getParameter<
int>(
"eventType")),
26 useDBEMap_(pset.getParameter<
bool>(
"useDBEMap"))
28 produces<FEDRawDataCollection>();
35 desc.
add<
int>(
"eventType", 0);
36 desc.
add<
bool>(
"useDBEMap",
false);
37 descriptions.
add(
"gemPackerDefault", desc);
42 auto gemROmap = std::make_shared<GEMROMapping>();
46 auto gemEMap = std::make_unique<GEMeMap>(*(gemEMapRcd.
product()));
47 gemEMap->convert(*gemROmap);
52 auto gemEMap = std::make_unique<GEMeMap>();
53 gemEMap->convertDummy(*gemROmap);
61 auto fedRawDataCol = std::make_unique<FEDRawDataCollection>();
65 if (!gemDigis.isValid()) {
72 std::vector<std::unique_ptr<AMC13Event>> amc13Events;
76 std::unique_ptr<AMC13Event> amc13Event = std::make_unique<AMC13Event>();
79 std::unique_ptr<AMCdata> amcData = std::make_unique<AMCdata>();
82 std::unique_ptr<GEBdata> gebData = std::make_unique<GEBdata>();
85 if (!gemROMap->isValidChamber(geb_ec))
continue;
88 auto vfats = gemROMap->getVfats(geb_dc.
detId);
89 for (
auto vfat_ec : vfats) {
93 uint16_t vfatId = vfat_ec.vfatAdd;
104 const GEMDigi & digi = (*digiIt);
116 if (chMap.
chNum < 64) lsData |= 1UL << chMap.
chNum;
117 else msData |= 1UL << (chMap.
chNum-64);
121 <<
" amc:" <<
int(amcNum)
122 <<
" geb:" <<
int(gebId)
126 <<
" ch:"<< chMap.
chNum 127 <<
" st:"<< digi.
strip()
128 <<
" bx:"<< digi.
bx();
132 if (!hasDigi)
continue;
134 auto vfatData = std::make_unique<VFATdata>(geb_dc.
vfatVer, bc, 0, vfatId, lsData, msData);
135 gebData->addVFAT(*vfatData);
140 if (!gebData->vFATs()->empty()) {
141 gebData->setChamberHeader(gebData->vFATs()->size()*3, gebId);
142 gebData->setChamberTrailer(0, 0, gebData->vFATs()->size()*3);
143 amcData->addGEB(*gebData);
148 if (!amcData->gebs()->empty()) {
150 amcData->setAMCheader2(amcNum, 0, 1);
151 amcData->setGEMeventHeader(amcData->gebs()->size(), 0);
152 amc13Event->addAMCpayload(*amcData);
157 if (!amc13Event->getAMCpayloads()->empty()) {
159 uint32_t LV1_id = iEvent.
id().
event();
165 uint8_t nAMC = amc13Event->getAMCpayloads()->size();
167 amc13Event->setAMC13Header(CalTyp, nAMC, OrN);
169 for (
unsigned short i = 0;
i < amc13Event->nAMC(); ++
i) {
170 uint32_t AMC_size = 0;
173 uint16_t BoardID = 0;
174 amc13Event->addAMCheader(AMC_size, Blk_No, AMC_No, BoardID);
180 uint16_t BX_idT = BX_id;
181 amc13Event->setAMC13Trailer(Blk_NoT, LV1_idT, BX_idT);
183 uint32_t EvtLength = 0;
184 amc13Event->setCDFTrailer(EvtLength);
185 amc13Events.emplace_back(
std::move(amc13Event));
191 for (
const auto & amc13e : amc13Events) {
192 std::vector<uint64_t> words;
193 words.emplace_back(amc13e->getCDFHeader());
194 words.emplace_back(amc13e->getAMC13Header());
196 for (
const auto &
w: *amc13e->getAMCheaders())
197 words.emplace_back(
w);
199 for (
const auto &
amc : *amc13e->getAMCpayloads()) {
200 words.emplace_back(
amc.getAMCheader1());
201 words.emplace_back(
amc.getAMCheader2());
202 words.emplace_back(
amc.getGEMeventHeader());
204 for (
const auto & geb: *
amc.gebs()) {
205 words.emplace_back(geb.getChamberHeader());
207 for (
const auto & vfat: *geb.vFATs()) {
208 words.emplace_back(vfat.get_fw());
209 words.emplace_back(vfat.get_sw());
210 words.emplace_back(vfat.get_tw());
213 words.emplace_back(geb.getChamberTrailer());
216 words.emplace_back(
amc.getGEMeventTrailer());
217 words.emplace_back(
amc.getAMCTrailer());
220 words.emplace_back(amc13e->getAMC13Trailer());
221 words.emplace_back(amc13e->getCDFTrailer());
223 FEDRawData & fedRawData = fedRawDataCol->FEDData(amc13e->sourceId());
225 int dataSize = (words.size()) *
sizeof(
uint64_t);
226 fedRawData.
resize(dataSize);
229 for (
const auto & word: words) *(w++) = word;
231 LogDebug(
"GEMDigiToRawModule") <<
" words " << words.size();
EventNumber_t event() const
edm::EDGetTokenT< GEMDigiCollection > digi_token
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
int bunchCrossing() const
Run const & getRun() const
static const int maxChan_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void resize(size_t newsize)
std::shared_ptr< GEMROMapping > globalBeginRun(edm::Run const &, edm::EventSetup const &) const override
GEMDigiToRawModule(const edm::ParameterSet &pset)
Constructor.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static const int maxAMCs_
static const int maxGEBs_
unsigned long long uint64_t
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
std::vector< DigiType >::const_iterator const_iterator
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
std::pair< const_iterator, const_iterator > Range
T const * product() const