137 uint16_t
min = 0x3FF;
143 uint16_t numzeroes = 0, numsats = 0;
145 if (iDigi == endChannelDigis)
return lFrame;
147 for (; iDigi != endChannelDigis; ++iDigi) {
148 const uint16_t val = iDigi->adc();
149 if (val < min) min = val;
150 if (val > max) max = val;
151 if (val==0) numzeroes++;
152 if (val==0x3FF) numsats++;
160 const uint16_t
threshold =
static_cast<uint16_t
>( (2.0 *
static_cast<double>(max-
min)) / 3.0 );
168 if (numzeroes>0 || numsats>0) {
170 << numzeroes <<
" zero and "
171 << numsats <<
" saturated samples.";
193 return static_cast<uint16_t
>( (2.0 *
static_cast<double>(
range(aFrame))) / 3.0 );
210 uint16_t & aFirstHeaderBit,
214 std::vector<uint16_t> lFirstBitVec;
215 lFirstBitVec.reserve(aInputDigis->
size());
219 for ( ; lDigis != aInputDigis->
end(); lDigis++){
225 aFirstHeaderBit = lMaj.first;
226 uint32_t lMajorityCounter = lMaj.second;
233 LogInfo(
"SiStripSpyUtilities") <<
" -- Found majority position of first header (trailer) bit: "
235 <<
" (" << lFirstTrailerBit
236 <<
") for " << lMajorityCounter <<
" out of " << lFirstBitVec.size() <<
" channels."
244 const uint16_t aExpectedPos)
249 if (lRange < aQuality.minDigiRange || lRange > aQuality.
maxDigiRange) {
259 else if ( aExpectedPos > 0 &&
280 uint8_t aboveThreshold = 0;
281 bool foundHeader =
false;
287 for (; iDigi != endChannelDigis; ++iDigi) {
294 if (aboveThreshold == 6) {foundHeader =
true;
break; }
299 if (foundHeader && count < 5)
return 0;
300 if (foundHeader)
return count-5;
310 uint8_t aboveThreshold = 0;
311 bool foundTrailer =
false;
323 for (; iDigi != endChannelDigis; ++iDigi) {
330 if (aboveThreshold == 2) {foundTrailer =
true;
break; }
335 if (foundTrailer && count < 1)
return 0;
336 if (foundTrailer)
return count-1;
343 const std::pair<bool,bool>
346 const uint16_t aFirstBits)
350 uint16_t
count = aFirstBits+22;
352 std::pair<bool,bool> lPair = std::pair<bool,bool>(
false,
false);
361 if (iDigi == endChannelDigis)
return lPair;
363 if ( iDigi->adc() <=
threshold) lPair.first =
true;
367 if (iDigi == endChannelDigis)
return std::pair<bool,bool>(
false,
false);
369 if ( iDigi->adc() <=
threshold) lPair.second =
true;
375 const std::pair<uint8_t,uint8_t>
378 const uint16_t aFirstBits)
382 uint16_t
count = aFirstBits+6;
383 std::pair<uint8_t,uint8_t> lPair = std::pair<uint8_t,uint8_t>(0,0);
392 if (iDigi == endChannelDigis)
return lPair;
394 for (uint8_t
i = 0;
i < 16; ++
i) {
398 lPair.first |= (0x80 >>
static_cast<uint8_t
>(
i/2));
400 lPair.second |= (0x80 >>
static_cast<uint8_t
>(
i/2));
414 std::ostringstream lOs;
415 lOs <<
" ------------------------------------------------------" << std::endl
416 <<
" -- Error: " << aErr << std::endl
417 <<
" ------- Printing Frame for detId " << aFrame.
detId <<
" --------" << std::endl
420 <<
" -- digitalLow = " << aFrame.
digitalLow << std::endl
421 <<
" -- digitalHigh = " << aFrame.
digitalHigh << std::endl
422 <<
" -- baseline = " << aFrame.
baseline << std::endl
423 <<
" -- apvErrorBits = " << aFrame.
apvErrorBit.first
425 <<
" -- apvAddresses = " <<
static_cast<uint16_t
>(aFrame.
apvAddress.first)
426 <<
" " << static_cast<uint16_t>(aFrame.
apvAddress.second) << std::endl
427 <<
" ------------------------------------------------------" << std::endl;
435 uint16_t & aFedChannel){
451 const uint16_t aFedId)
454 uint32_t lTot = values.size();
455 if (!lTot)
return std::pair<uint16_t,uint32_t>(0,0);
458 uint32_t lMajorityCounter = 0;
461 std::vector<uint16_t>::iterator lIter = values.begin();
462 for ( ; lIter != values.end(); ) {
463 uint32_t lCounter =
std::count(lIter,values.end(),*lIter);
464 if (lCounter > lMajorityCounter) {
465 lMajorityCounter = lCounter;
473 if (static_cast<float>(lMajorityCounter)/lTot < 0.5) {
474 LogError(
"SiStripSpyUtilities") <<
" -- Found majority position for index "
477 <<
" for less than half the values : " << lMajorityCounter <<
" out of " << lTot <<
" values."
481 return std::pair<uint16_t,uint32_t>(lMaj,lMajorityCounter);
486 std::vector<uint32_t> & fedMajoritiesToFill)
489 std::map<uint32_t,uint32_t>::const_iterator lMapIter = channelValues.begin();
490 uint16_t lPreviousFedId = 0;
491 std::vector<uint16_t> lAddrVec;
494 uint32_t lChCount = 0;
496 for ( ; lMapIter != channelValues.end(); ++lMapIter,++lChCount){
500 if (lPreviousFedId == 0) {
501 lPreviousFedId = lFedId;
503 if (lFedId == lPreviousFedId) {
504 lAddrVec.push_back(lMapIter->second);
506 if (lFedId != lPreviousFedId || (lChCount == channelValues.size()-1)) {
510 fedMajoritiesToFill[lPreviousFedId] = lMaj;
515 if (lFedId != lPreviousFedId) {
516 lAddrVec.push_back(lMapIter->second);
517 lPreviousFedId = lFedId;
static void fedIndex(uint32_t aFedIndex, uint16_t &aFedId, uint16_t &aFedChannel)
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)
std::pair< uint8_t, uint8_t > apvAddress
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)
static const Frame extractFrameInfo(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, bool aPrintDebug=false)
static const uint16_t range(const Frame &aFrame)
if(c.getParameter< edm::InputTag >("puppiValueMap").label().size()!=0)
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.
T const * product() const
static const uint16_t invalid_
static const uint16_t findTrailerBits(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold)
std::pair< bool, bool > apvErrorBit
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
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
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)