123 uint16_t
min = 0x3FF;
129 uint16_t numzeroes = 0, numsats = 0;
131 if (iDigi == endChannelDigis)
134 for (; iDigi != endChannelDigis; ++iDigi) {
135 const uint16_t
val = iDigi->adc();
147 if (!channelDigis.
empty())
152 const uint16_t
threshold =
static_cast<uint16_t
>((2.0 *
static_cast<double>(max -
min)) / 3.0);
156 LogDebug(
"SiStripSpyUtilities") <<
"Channel with key: " << lFrame.
detId <<
" Min: " << min <<
" Max: " << max
157 <<
" Range: " << (max -
min) <<
" Threshold: " << threshold;
159 if (numzeroes > 0 || numsats > 0) {
160 edm::LogWarning(
"SiStripSpyUtilities") <<
"Channel with key: " << lFrame.
detId <<
" has " << numzeroes
161 <<
" zero and " << numsats <<
" saturated samples.";
182 return static_cast<uint16_t
>((2.0 *
static_cast<double>(
range(aFrame))) / 3.0);
196 uint16_t& aFirstHeaderBit,
198 std::vector<uint16_t> lFirstBitVec;
199 lFirstBitVec.reserve(aInputDigis->
size());
203 for (; lDigis != aInputDigis->
end(); lDigis++) {
209 aFirstHeaderBit = lMaj.first;
210 uint32_t lMajorityCounter = lMaj.second;
216 LogInfo(
"SiStripSpyUtilities") <<
" -- Found majority position of first header (trailer) bit: " << aFirstHeaderBit
217 <<
" (" << lFirstTrailerBit <<
") for " << lMajorityCounter <<
" out of " 218 << lFirstBitVec.size() <<
" channels." << std::endl;
224 const uint16_t aExpectedPos) {
227 if (lRange < aQuality.minDigiRange || lRange > aQuality.
maxDigiRange) {
235 else if (aExpectedPos > 0 && (!(aFrame.
firstHeaderBit == aExpectedPos &&
248 uint8_t aboveThreshold = 0;
249 bool foundHeader =
false;
255 for (; iDigi != endChannelDigis; ++iDigi) {
261 if (aboveThreshold == 6) {
269 if (foundHeader && count < 5)
279 uint8_t aboveThreshold = 0;
280 bool foundTrailer =
false;
293 for (; iDigi != endChannelDigis; ++iDigi) {
299 if (aboveThreshold == 2) {
307 if (foundTrailer && count < 1)
317 const uint16_t aFirstBits) {
319 uint16_t
count = aFirstBits + 22;
321 std::pair<bool, bool> lPair = std::pair<bool, bool>(
false,
false);
331 if (iDigi == endChannelDigis)
339 if (iDigi == endChannelDigis)
340 return std::pair<bool, bool>(
false,
false);
351 const uint16_t aFirstBits) {
353 uint16_t
count = aFirstBits + 6;
354 std::pair<uint8_t, uint8_t> lPair = std::pair<uint8_t, uint8_t>(0, 0);
364 if (iDigi == endChannelDigis)
367 for (uint8_t
i = 0;
i < 16; ++
i) {
371 lPair.first |= (0x80 >>
static_cast<uint8_t
>(
i / 2));
373 lPair.second |= (0x80 >>
static_cast<uint8_t
>(
i / 2));
382 std::ostringstream lOs;
383 lOs <<
" ------------------------------------------------------" << std::endl
384 <<
" -- Error: " << aErr << std::endl
385 <<
" ------- Printing Frame for detId " << aFrame.
detId <<
" --------" << std::endl
388 <<
" -- digitalLow = " << aFrame.
digitalLow << std::endl
389 <<
" -- digitalHigh = " << aFrame.
digitalHigh << std::endl
390 <<
" -- baseline = " << aFrame.
baseline << std::endl
392 <<
" -- apvAddresses = " <<
static_cast<uint16_t
>(aFrame.
apvAddress.first) <<
" " 393 << static_cast<uint16_t>(aFrame.
apvAddress.second) << std::endl
394 <<
" ------------------------------------------------------" << std::endl;
410 uint32_t lTot = values.size();
412 return std::pair<uint16_t, uint32_t>(0, 0);
414 std::sort(values.begin(), values.end());
415 uint32_t lMajorityCounter = 0;
418 std::vector<uint16_t>::iterator lIter = values.begin();
419 for (; lIter != values.end();) {
420 uint32_t lCounter =
std::count(lIter, values.end(), *lIter);
421 if (lCounter > lMajorityCounter) {
422 lMajorityCounter = lCounter;
430 if (static_cast<float>(lMajorityCounter) / lTot < 0.5) {
431 LogError(
"SiStripSpyUtilities") <<
" -- Found majority position for index " << aFedId <<
": " << lMaj
432 <<
" for less than half the values : " << lMajorityCounter <<
" out of " << lTot
433 <<
" values." << std::endl;
436 return std::pair<uint16_t, uint32_t>(lMaj, lMajorityCounter);
440 std::vector<uint32_t>& fedMajoritiesToFill) {
441 std::map<uint32_t, uint32_t>::const_iterator lMapIter = channelValues.begin();
442 uint16_t lPreviousFedId = 0;
443 std::vector<uint16_t> lAddrVec;
446 uint32_t lChCount = 0;
448 for (; lMapIter != channelValues.end(); ++lMapIter, ++lChCount) {
451 if (lPreviousFedId == 0) {
452 lPreviousFedId = lFedId;
454 if (lFedId == lPreviousFedId) {
455 lAddrVec.push_back(lMapIter->second);
457 if (lFedId != lPreviousFedId || (lChCount == channelValues.size() - 1)) {
461 fedMajoritiesToFill[lPreviousFedId] = lMaj;
466 if (lFedId != lPreviousFedId) {
467 lAddrVec.push_back(lMapIter->second);
468 lPreviousFedId = lFedId;
static void fedIndex(uint32_t aFedIndex, uint16_t &aFedId, uint16_t &aFedChannel)
std::pair< uint8_t, uint8_t > apvAddress
edm::ESHandle< SiStripNoises > noiseHandle_
static const uint16_t FED_ID_MIN
static const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
det_id_type detId() const
edm::ESHandle< SiStripNoises > getNoiseHandle(const edm::EventSetup &eventSetup)
static const std::pair< bool, bool > findAPVErrorBits(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold, const uint16_t aFirstBits)
static const uint16_t SPY_SAMPLES_PER_CHANNEL
const SiStripDetCabling * getDetCabling(const edm::EventSetup &)
Updates the det cabling object from the DB.
edm::ESHandle< SiStripPedestals > getPedestalHandle(const edm::EventSetup &eventSetup)
uint32_t cacheIdDet_
DB cache ID used to establish if the cabling has changed during the run.
static const std::pair< uint8_t, uint8_t > findAPVAddresses(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold, const uint16_t aFirstBits)
static const uint16_t findHeaderBits(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold)
const SiStripDetCabling * detCabling_
The cabling object.
static void fillFEDMajorities(const std::map< uint32_t, uint32_t > &channelValues, std::vector< uint32_t > &fedMajoritiesToFill)
std::pair< bool, bool > apvErrorBit
static const Frame extractFrameInfo(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, bool aPrintDebug=false)
static const uint16_t range(const Frame &aFrame)
iterator end()
Return the off-the-end iterator.
size_type size() const
Return the number of contained DetSets.
static std::pair< uint16_t, uint32_t > findMajorityValue(std::vector< uint16_t > &values, const uint16_t aFedId=0)
static const uint16_t threshold(const Frame &aFrame)
static const uint16_t STRIPS_PER_FEDCH
const SiStripFedCabling * cabling_
The cabling object.
const SiStripFedCabling * getCabling(const edm::EventSetup &)
Updates the cabling object from the DB.
static const uint16_t invalid_
static const uint16_t findTrailerBits(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold)
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
static const uint16_t FEDCH_PER_FED
static void getMajorityHeader(const edm::DetSetVector< SiStripRawDigi > *aInputDigis, uint16_t &firstHeaderBit, bool printResult=true)
iterator begin()
Return an iterator to the first DetSet.
static const uint16_t FED_ID_MAX
edm::ESHandle< SiStripPedestals > pedsHandle_
collection_type::const_iterator const_iterator
static std::string print(const Frame &aFrame, std::string aErr)
collection_type::const_iterator const_iterator
T const * product() const
uint32_t cacheId_
DB cache ID used to establish if the cabling has changed during the run.
static const uint8_t extractAPVaddress(const Frame &aFrame)