27 std::vector<uint32_t>* pAPVAddresses,
28 const bool discardDigisWithAPVAddrErr,
30 const uint16_t expectedPos) {
32 std::vector<DetSetRawDigis> outputData;
33 outputData.reserve(inputScopeDigis->
size());
37 std::vector<uint16_t> lAddrVec;
39 uint16_t lPreviousFedId = 0;
40 std::vector<uint16_t> lHeaderBitVec;
42 std::vector<uint16_t> lTrailBitVec;
46 std::vector<DSVRawDigis::const_iterator> lFedScopeDigis;
52 bool hasBeenProcessed =
false;
54 for (; inputChannel != endChannels; ++inputChannel) {
55 const uint32_t lFedIndex = inputChannel->detId();
56 const uint16_t
fedId =
static_cast<uint16_t
>((lFedIndex >> 16) & 0xFFFF);
61 if (lPreviousFedId == 0) {
62 lPreviousFedId =
fedId;
77 if (
fedId == lPreviousFedId) {
79 hasBeenProcessed =
false;
81 if (
fedId != lPreviousFedId) {
83 discardDigisWithAPVAddrErr,
90 lPreviousFedId =
fedId;
91 hasBeenProcessed =
true;
94 lFedScopeDigis.push_back(inputChannel);
103 if (!hasBeenProcessed) {
105 discardDigisWithAPVAddrErr,
115 return std::make_unique<DSVRawDigis>(outputData,
true);
120 const bool discardDigisWithAPVAddrErr,
121 std::vector<uint32_t>* pAPVAddresses,
122 std::vector<DetSetRawDigis>& outputData,
123 std::vector<uint16_t>& aAddrVec,
124 std::vector<uint16_t>& aHeaderBitVec,
125 std::vector<uint16_t>& aTrailBitVec,
126 std::vector<DSVRawDigis::const_iterator>& aFedScopeDigis) {
130 (*pAPVAddresses)[aPreviousFedId] = lMaj;
133 std::vector<DSVRawDigis::const_iterator>::iterator lIter;
134 unsigned int lCh = 0;
135 for (lIter = aFedScopeDigis.begin(); lIter != aFedScopeDigis.end(); ++lIter, ++lCh) {
139 if (discardDigisWithAPVAddrErr && aAddrVec[2 * lCh] != lMaj && aAddrVec[2 * lCh + 1] != lMaj) {
143 DetSetRawDigis::const_iterator iDigi = (*lIter)->begin();
144 const DetSetRawDigis::const_iterator endOfChannel = (*lIter)->end();
146 if (iDigi == endOfChannel) {
151 const DetSetRawDigis::const_iterator payloadBegin = iDigi + aHeaderBitVec[lCh] + 24;
152 const DetSetRawDigis::const_iterator payloadEnd = payloadBegin +
STRIPS_PER_FEDCH;
154 if (payloadEnd - iDigi >= endOfChannel - iDigi)
160 std::vector<SiStripRawDigi>& outputDetSetData = outputData.back().data;
162 std::vector<SiStripRawDigi>::iterator outputBegin = outputDetSetData.begin();
163 std::copy(payloadBegin, payloadEnd, outputBegin);
166 aFedScopeDigis.clear();
168 aHeaderBitVec.clear();
169 aTrailBitVec.clear();
179 std::vector<DetSetRawDigis> outputData;
180 outputData.reserve(inputPayloadDigis->
size());
184 inputChannel != inputPayloadDigis->
end();
186 const std::vector<SiStripRawDigi>& inputDetSetData = inputChannel->data;
188 std::vector<SiStripRawDigi>& outputDetSetData = outputData.back().data;
191 for (uint16_t readoutOrderStripIndex = 0; readoutOrderStripIndex < inputDetSetData.size();
192 ++readoutOrderStripIndex) {
193 const uint16_t physicalOrderStripIndex =
195 outputDetSetData.at(physicalOrderStripIndex) = inputDetSetData.at(readoutOrderStripIndex);
200 return std::make_unique<DSVRawDigis>(outputData,
true);
210 auto iFed = cabling.
fedIds().begin();
211 auto endFeds = cabling.
fedIds().end();
212 for (; iFed != endFeds; ++iFed) {
215 auto iConn = conns.begin();
216 auto endConns = conns.end();
217 for (; iConn != endConns; ++iConn) {
219 if (!iConn->isConnected())
227 if (iDetSet == inputPhysicalOrderChannelDigis->
end()) {
238 DetSetRawDigis::const_iterator iDigi = iDetSet->begin();
239 const DetSetRawDigis::const_iterator endDetSetDigis = iDetSet->end();
240 for (; iDigi != endDetSetDigis; ++iDigi) {
static uint8_t physicalOrderForStripInChannel(const uint8_t readoutOrderStripIndexInChannel)
std::pair< uint8_t, uint8_t > apvAddress
static const uint16_t FED_ID_MIN
iterator find(det_id_type id)
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
static std::unique_ptr< DSVRawDigis > reorderDigis(const DSVRawDigis *inputPayloadDigis)
static const uint32_t invalid32_
void newChannel(const uint32_t key, const uint16_t firstItem=0)
DSVRawDigis::detset DetSetRawDigis
static const uint16_t SPY_SAMPLES_PER_CHANNEL
const Frame extractFrameInfo(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, bool aPrintDebug=false)
void fedIndex(uint32_t aFedIndex, uint16_t &aFedId, uint16_t &aFedChannel)
static std::unique_ptr< DSVRawDigis > extractPayloadDigis(const DSVRawDigis *inputScopeDigis, std::vector< uint32_t > *pAPVAddresses, const bool discardDigisWithAPVAddrErr, const sistrip::SpyUtilities::FrameQuality &aQuality, const uint16_t expectedPos)
Extract frames from the scope digis.
size_type size() const
Return the number of contained DetSets.
std::unique_ptr< edm::DetSetVector< T > > createDetSetVector()
void addItem(const T &item)
static std::unique_ptr< DSVRawDigis > mergeModuleChannels(const DSVRawDigis *inputPhysicalOrderChannelDigis, const SiStripFedCabling &cabling)
std::pair< uint16_t, uint32_t > findMajorityValue(std::vector< uint16_t > &values, const uint16_t aFedId=0)
iterator end()
Return the off-the-end iterator.
static const uint16_t STRIPS_PER_FEDCH
Constants and enumerated types for FED/FEC systems.
static const uint16_t invalid_
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
static const uint16_t FEDCH_PER_FED
static void processFED(const uint16_t aPreviousFedId, const bool discardDigisWithAPVAddrErr, std::vector< uint32_t > *pAPVAddresses, std::vector< DetSetRawDigis > &outputData, std::vector< uint16_t > &aAddrVec, std::vector< uint16_t > &aHeaderBitVec, std::vector< uint16_t > &aTrailBitVec, std::vector< DSVRawDigis::const_iterator > &aFedScopeDigis)
iterator begin()
Return an iterator to the first DetSet.
static const uint16_t FED_ID_MAX
collection_type::const_iterator const_iterator
FedsConstIterRange fedIds() const
ConnsConstIterRange fedConnections(uint16_t fed_id) const