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 gemORmap = std::make_shared<GEMROmap>();
46 auto gemEMap = std::make_unique<GEMELMap>(*(gemEMapRcd.
product()));
47 gemEMap->convert(*gemORmap);
52 auto gemEMap = std::make_unique<GEMELMap>();
53 gemEMap->convertDummy(*gemORmap);
61 auto fedRawDataCol = std::make_unique<FEDRawDataCollection>();
69 std::vector<std::unique_ptr<AMC13Event>> amc13Events;
71 amc13Events.reserve(1);
73 auto amc13Event = std::make_unique<AMC13Event>();
75 uint16_t amcId = 0, gebId = 0;
76 std::unique_ptr<AMCdata> amcData;
77 std::unique_ptr<GEBdata> gebData;
79 const std::map<GEMROmap::eCoord,GEMROmap::dCoord> *roMapED = gemROMap->getRoMap();
80 for (
auto ro=roMapED->begin(); ro!=roMapED->end(); ++ro){
84 if (amcId != ec.
amcId || !amcData){
86 amcData = std::make_unique<AMCdata>();
87 amcData->setBID(amcId);
91 if (gebId != ec.
gebId || !gebData){
93 gebData = std::make_unique<GEBdata>();
94 gebData->setInputID(gebId);
97 uint16_t vfatId = ec.
vfatId;
101 bool hasDigi =
false;
110 bool isBlockGood=
false;
114 uint16_t crc_calc =0;
119 const GEMDigi & digi = (*digiIt);
136 if (chan < 64) lsData = lsData | (oneBit <<
chan);
137 else msData = msData | (oneBit << (chan-64));
140 <<
" gemDetId "<< gemId
141 <<
" chan "<< chMap.
chNum 142 <<
" strip "<< stMap.
stNum 143 <<
" bx "<< digi.
bx();
147 if (!hasDigi)
continue;
149 auto vfatData = std::make_unique<VFATdata>(b1010, BC, b1100, EC,
Flag, b1110, vfatId, lsData, msData,
150 crc, crc_calc, SlotNumber, isBlockGood);
151 gebData->addVFAT(*vfatData);
154 bool saveGeb =
false;
155 bool saveAMC =
false;
158 if (nx == roMapED->end()){
165 if (ecNext.
gebId != gebId) saveGeb =
true;
166 if (ecNext.
amcId != amcId) saveAMC =
true;
169 if (!gebData->vFATs()->empty() && saveGeb){
170 gebData->setVwh(gebData->vFATs()->size()*3);
171 amcData->addGEB(*gebData);
173 if (!amcData->gebs()->empty() && saveAMC){
174 amcData->setGDcount(amcData->gebs()->size());
175 amc13Event->addAMCpayload(*amcData);
182 uint32_t LV1_id = iEvent.
id().
event();
185 amc13Event->setCDFHeader(cb5, Evt_ty, LV1_id, BX_id, Source_id);
189 uint8_t nAMC = amc13Event->getAMCpayloads()->size();
191 uint8_t cb0 = 0b0000;
192 amc13Event->setAMC13header(CalTyp, nAMC, OrN, cb0);
194 for (
unsigned short i = 0;
i < amc13Event->nAMC(); ++
i){
195 uint32_t AMC_size = 0;
198 uint16_t BoardID = 0;
199 amc13Event->addAMCheader(AMC_size, Blk_No, AMC_No, BoardID);
203 uint32_t CRC_amc13 = 0;
206 uint16_t BX_idT = BX_id;
207 amc13Event->setAMC13trailer(CRC_amc13, Blk_NoT, LV1_idT, BX_idT);
210 uint32_t EvtLength = 0;
211 uint16_t CRC_cdf = 0;
212 amc13Event->setCDFTrailer(cbA, EvtLength, CRC_cdf);
213 amc13Events.emplace_back(
std::move(amc13Event));
217 for (
const auto & amc13e : amc13Events){
218 std::vector<uint64_t> words;
219 words.emplace_back(amc13e->getCDFHeader());
220 words.emplace_back(amc13e->getAMC13header());
222 for (
const auto &
w: *amc13e->getAMCheaders())
223 words.emplace_back(
w);
225 for (
const auto &
amc : *amc13e->getAMCpayloads()){
226 words.emplace_back(
amc.getAMCheader1());
227 words.emplace_back(
amc.getAMCheader2());
228 words.emplace_back(
amc.getGEMeventHeader());
230 for (
const auto & geb: *
amc.gebs()){
231 words.emplace_back(geb.getChamberHeader());
233 for (
const auto & vfat: *geb.vFATs()){
234 words.emplace_back(vfat.get_fw());
235 words.emplace_back(vfat.get_sw());
236 words.emplace_back(vfat.get_tw());
239 words.emplace_back(geb.getChamberTrailer());
242 words.emplace_back(
amc.getGEMeventTrailer());
243 words.emplace_back(
amc.getAMCTrailer());
246 words.emplace_back(amc13e->getAMC13trailer());
247 words.emplace_back(amc13e->getCDFTrailer());
249 FEDRawData & fedRawData = fedRawDataCol->FEDData(amc13e->source_id());
251 int dataSize = (words.size()) *
sizeof(
uint64_t);
252 fedRawData.
resize(dataSize);
255 for (
const auto & word: words) *(w++) = word;
257 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 maxVFatGE21_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static const int maxChan_
void resize(size_t newsize)
int station() const
Station id : the station is the pair of chambers at same disk.
GEMDigiToRawModule(const edm::ParameterSet &pset)
Constructor.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::shared_ptr< GEMROmap > globalBeginRun(edm::Run const &, edm::EventSetup const &) const override
unsigned long long uint64_t
static const int maxVFatGE11_
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
std::vector< GEMDigi >::const_iterator const_iterator
void add(std::string const &label, ParameterSetDescription const &psetDescription)
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
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