75 event.getByToken(
token_, buffers);
78 std::vector<Registry> proc_work_registry;
79 std::vector<Phase2TrackerDigi> proc_work_digis;
81 size_t reserve_count = 0;
82 size_t reserve_digis = 0;
85 if (fed.
size() != 0) {
91 if (
buffer.channel(ichan).length() > 0) {
101 proc_work_registry.reserve(2 * reserve_count);
102 proc_work_digis.reserve(reserve_digis);
107 if (fed.
size() != 0) {
112 std::ostringstream
ss;
113 ss <<
" -------------------------------------------- " << endl;
114 ss <<
" buffer debug ------------------------------- " << endl;
115 ss <<
" -------------------------------------------- " << endl;
116 ss <<
" buffer size : " <<
buffer.bufferSize() << endl;
118 ss <<
" -------------------------------------------- " << endl;
119 ss <<
" tracker header debug ------------------------" << endl;
120 ss <<
" -------------------------------------------- " << endl;
121 LogTrace(
"Phase2TrackerDigiProducer") <<
ss.str();
125 Phase2TrackerFEDHeader tr_header =
buffer.trackerHeader();
126 ss <<
" Version : " << hex << setw(2) << (
int)tr_header.getDataFormatVersion() << endl;
127 ss <<
" Mode : " << hex << setw(2) << tr_header.getDebugMode() << endl;
128 ss <<
" Type : " << hex << setw(2) << (
int)tr_header.getEventType() << endl;
129 ss <<
" Readout : " << hex << setw(2) << tr_header.getReadoutMode() << endl;
130 ss <<
" Condition Data : " << (tr_header.getConditionData() ?
"Present" :
"Absent") <<
"\n";
131 ss <<
" Data Type : " << (tr_header.getDataType() ?
"Real" :
"Fake") <<
"\n";
132 ss <<
" Status : " << hex << setw(16) << (
int)tr_header.getGlibStatusCode() << endl;
134 for (
int i = 15;
i >= 0;
i--) {
135 if ((tr_header.frontendStatus())[
i]) {
142 ss <<
" Nr CBC : " << hex << setw(16) << (
int)tr_header.getNumberOfCBC() << endl;
143 ss <<
" CBC stat : ";
144 for (
int i = 0;
i < tr_header.getNumberOfCBC();
i++) {
145 ss << hex << setw(2) << (
int)tr_header.CBCStatus()[
i] <<
" ";
148 LogTrace(
"Phase2TrackerDigiProducer") <<
ss.str();
151 ss <<
" -------------------------------------------- " << endl;
152 ss <<
" Payload ----------------------------------- " << endl;
153 ss <<
" -------------------------------------------- " << endl;
160 const Phase2TrackerFEDChannel& channel =
buffer.channel(ichan);
161 if (channel.length() > 0) {
164 uint32_t detid =
mod.getDetid();
166 ss <<
dec <<
" id from cabling : " << detid << endl;
167 ss <<
dec <<
" reading channel : " << icbc <<
" on FE " << ife;
168 ss <<
dec <<
" with length : " << (
int)channel.length() << endl;
172 std::vector<Phase2TrackerDigi> stripsTop;
173 std::vector<Phase2TrackerDigi> stripsBottom;
176 Phase2TrackerFEDRawChannelUnpacker unpacker = Phase2TrackerFEDRawChannelUnpacker(channel);
177 while (unpacker.hasData()) {
178 if (unpacker.stripOn()) {
179 if (unpacker.stripIndex() % 2) {
185 stripsBottom.push_back(
200 LogTrace(
"Phase2TrackerDigiProducer") <<
ss.str();
207 proc_work_registry.emplace_back(
208 detid + 1,
STRIPS_PER_CBC * icbc / 2, proc_work_digis.size(), stripsTop.size());
209 proc_work_digis.insert(proc_work_digis.end(), stripsTop.begin(), stripsTop.end());
210 proc_work_registry.emplace_back(
211 detid + 2,
STRIPS_PER_CBC * icbc / 2, proc_work_digis.size(), stripsBottom.size());
212 proc_work_digis.insert(proc_work_digis.end(), stripsBottom.begin(), stripsBottom.end());
221 std::sort(proc_work_registry.begin(), proc_work_registry.end());
222 std::vector<edm::DetSet<Phase2TrackerDigi>> sorted_and_merged;
224 std::vector<Registry>::iterator
it = proc_work_registry.begin(), it2 =
it + 1,
end = proc_work_registry.end();
227 std::vector<Phase2TrackerDigi>& digis = sorted_and_merged.back().data;
229 size_t len =
it->length;
230 for (it2 =
it + 1; (it2 !=
end) && (it2->detid ==
it->detid); ++it2) {
236 for (it2 =
it + 0; (it2 !=
end) && (it2->detid ==
it->detid); ++it2) {
237 digis.insert(digis.end(), &proc_work_digis[it2->index], &proc_work_digis[it2->index + it2->length]);
241 event.emplace(
putToken_, sorted_and_merged,
true);
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
size_t size() const
Lenght of the data buffer in bytes.
static const uint16_t CMS_FED_ID_MAX
static const int MAX_CBC_PER_FE
const edm::EDGetTokenT< FEDRawDataCollection > token_
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
const edm::EDPutTokenT< edm::DetSetVector< Phase2TrackerDigi > > putToken_
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
static const int STRIPS_PER_CBC
const edm::ESGetToken< Phase2TrackerCabling, Phase2TrackerCablingRcd > ph2CablingESToken_
static const uint16_t FED_ID_MIN
T mod(const T &a, const T &b)
static const int MAX_FE_PER_FED
__host__ __device__ fedId_t fedIndex(fedId_t fed)
static const int STRIPS_PADDING