31 uint16_t numzeroes = 0, numsats = 0;
33 if (iDigi == endChannelDigis)
36 for (; iDigi != endChannelDigis; ++iDigi) {
37 const uint16_t
val = iDigi->adc();
49 if (!channelDigis.
empty())
54 const uint16_t
threshold =
static_cast<uint16_t
>((2.0 *
static_cast<double>(
max -
min)) / 3.0);
58 LogDebug(
"SiStripSpyUtilities") <<
"Channel with key: " << lFrame.
detId <<
" Min: " <<
min <<
" Max: " <<
max 61 if (numzeroes > 0 || numsats > 0) {
62 edm::LogWarning(
"SiStripSpyUtilities") <<
"Channel with key: " << lFrame.
detId <<
" has " << numzeroes
63 <<
" zero and " << numsats <<
" saturated samples.";
84 return static_cast<uint16_t
>((2.0 *
static_cast<double>(
range(aFrame))) / 3.0);
98 uint16_t& aFirstHeaderBit,
100 std::vector<uint16_t> lFirstBitVec;
101 lFirstBitVec.reserve(aInputDigis->
size());
105 for (; lDigis != aInputDigis->
end(); lDigis++) {
111 aFirstHeaderBit = lMaj.first;
112 uint32_t lMajorityCounter = lMaj.second;
118 LogInfo(
"SiStripSpyUtilities") <<
" -- Found majority position of first header (trailer) bit: " << aFirstHeaderBit
119 <<
" (" << lFirstTrailerBit <<
") for " << lMajorityCounter <<
" out of " 120 << lFirstBitVec.size() <<
" channels." << std::endl;
126 const uint16_t aExpectedPos) {
129 if (lRange < aQuality.minDigiRange || lRange > aQuality.
maxDigiRange) {
137 else if (aExpectedPos > 0 && (!(aFrame.
firstHeaderBit == aExpectedPos &&
150 uint8_t aboveThreshold = 0;
151 bool foundHeader =
false;
157 for (; iDigi != endChannelDigis; ++iDigi) {
163 if (aboveThreshold == 6) {
171 if (foundHeader &&
count < 5)
181 uint8_t aboveThreshold = 0;
182 bool foundTrailer =
false;
195 for (; iDigi != endChannelDigis; ++iDigi) {
201 if (aboveThreshold == 2) {
209 if (foundTrailer &&
count < 1)
219 const uint16_t aFirstBits) {
221 uint16_t
count = aFirstBits + 22;
223 std::pair<bool, bool> lPair = std::pair<bool, bool>(
false,
false);
233 if (iDigi == endChannelDigis)
241 if (iDigi == endChannelDigis)
242 return std::pair<bool, bool>(
false,
false);
253 const uint16_t aFirstBits) {
255 uint16_t
count = aFirstBits + 6;
256 std::pair<uint8_t, uint8_t> lPair = std::pair<uint8_t, uint8_t>(0, 0);
266 if (iDigi == endChannelDigis)
269 for (uint8_t
i = 0;
i < 16; ++
i) {
273 lPair.first |= (0x80 >>
static_cast<uint8_t
>(
i / 2));
275 lPair.second |= (0x80 >>
static_cast<uint8_t
>(
i / 2));
284 std::ostringstream lOs;
285 lOs <<
" ------------------------------------------------------" << std::endl
286 <<
" -- Error: " << aErr << std::endl
287 <<
" ------- Printing Frame for detId " << aFrame.
detId <<
" --------" << std::endl
290 <<
" -- digitalLow = " << aFrame.
digitalLow << std::endl
291 <<
" -- digitalHigh = " << aFrame.
digitalHigh << std::endl
292 <<
" -- baseline = " << aFrame.
baseline << std::endl
294 <<
" -- apvAddresses = " <<
static_cast<uint16_t
>(aFrame.
apvAddress.first) <<
" " 295 << static_cast<uint16_t>(aFrame.
apvAddress.second) << std::endl
296 <<
" ------------------------------------------------------" << std::endl;
312 uint32_t lTot =
values.size();
314 return std::pair<uint16_t, uint32_t>(0, 0);
317 uint32_t lMajorityCounter = 0;
320 std::vector<uint16_t>::iterator lIter =
values.begin();
321 for (; lIter !=
values.end();) {
323 if (lCounter > lMajorityCounter) {
324 lMajorityCounter = lCounter;
332 if (static_cast<float>(lMajorityCounter) / lTot < 0.5) {
333 LogError(
"SiStripSpyUtilities") <<
" -- Found majority position for index " << aFedId <<
": " << lMaj
334 <<
" for less than half the values : " << lMajorityCounter <<
" out of " << lTot
335 <<
" values." << std::endl;
338 return std::pair<uint16_t, uint32_t>(lMaj, lMajorityCounter);
342 std::vector<uint32_t>& fedMajoritiesToFill) {
343 std::map<uint32_t, uint32_t>::const_iterator lMapIter = channelValues.begin();
344 uint16_t lPreviousFedId = 0;
345 std::vector<uint16_t> lAddrVec;
348 uint32_t lChCount = 0;
350 for (; lMapIter != channelValues.end(); ++lMapIter, ++lChCount) {
353 if (lPreviousFedId == 0) {
354 lPreviousFedId = lFedId;
356 if (lFedId == lPreviousFedId) {
357 lAddrVec.push_back(lMapIter->second);
359 if (lFedId != lPreviousFedId || (lChCount == channelValues.size() - 1)) {
363 fedMajoritiesToFill[lPreviousFedId] = lMaj;
368 if (lFedId != lPreviousFedId) {
369 lAddrVec.push_back(lMapIter->second);
370 lPreviousFedId = lFedId;
const uint16_t findHeaderBits(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold)
void fillFEDMajorities(const std::map< uint32_t, uint32_t > &channelValues, std::vector< uint32_t > &fedMajoritiesToFill)
std::pair< uint8_t, uint8_t > apvAddress
static const uint16_t FED_ID_MIN
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
std::string print(const Frame &aFrame, std::string aErr)
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)
Log< level::Error, false > LogError
det_id_type detId() const
const uint16_t threshold(const Frame &aFrame)
const uint16_t range(const Frame &aFrame)
std::pair< bool, bool > apvErrorBit
size_type size() const
Return the number of contained DetSets.
void getMajorityHeader(const edm::DetSetVector< SiStripRawDigi > *aInputDigis, uint16_t &firstHeaderBit, bool printResult=true)
const uint8_t extractAPVaddress(const Frame &aFrame)
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.
Log< level::Info, false > LogInfo
static const uint16_t STRIPS_PER_FEDCH
static const uint16_t invalid_
const std::pair< bool, bool > findAPVErrorBits(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold, const uint16_t aFirstBits)
static const uint16_t FEDCH_PER_FED
iterator begin()
Return an iterator to the first DetSet.
static const uint16_t FED_ID_MAX
Log< level::Warning, false > LogWarning
collection_type::const_iterator const_iterator
collection_type::const_iterator const_iterator
const uint16_t findTrailerBits(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold)
const std::pair< uint8_t, uint8_t > findAPVAddresses(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold, const uint16_t aFirstBits)