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++;
163 const uint16_t
threshold =
static_cast<uint16_t
>( (2.0 *
static_cast<double>(max-
min)) / 3.0 );
167 LogDebug(
"SiStripSpyUtilities") <<
"Channel with key: " << lFrame.
detId 168 <<
" Min: " << min <<
" Max: " << max
169 <<
" Range: " << (max-
min) <<
" Threshold: " << threshold;
171 if (numzeroes>0 || numsats>0) {
173 << numzeroes <<
" zero and " 174 << numsats <<
" saturated samples.";
196 return static_cast<uint16_t
>( (2.0 *
static_cast<double>(
range(aFrame))) / 3.0 );
213 uint16_t & aFirstHeaderBit,
217 std::vector<uint16_t> lFirstBitVec;
218 lFirstBitVec.reserve(aInputDigis->
size());
222 for ( ; lDigis != aInputDigis->
end(); lDigis++){
228 aFirstHeaderBit = lMaj.first;
229 uint32_t lMajorityCounter = lMaj.second;
236 LogInfo(
"SiStripSpyUtilities") <<
" -- Found majority position of first header (trailer) bit: " 238 <<
" (" << lFirstTrailerBit
239 <<
") for " << lMajorityCounter <<
" out of " << lFirstBitVec.size() <<
" channels." 247 const uint16_t aExpectedPos)
252 if (lRange < aQuality.minDigiRange || lRange > aQuality.
maxDigiRange) {
262 else if ( aExpectedPos > 0 &&
283 uint8_t aboveThreshold = 0;
284 bool foundHeader =
false;
290 for (; iDigi != endChannelDigis; ++iDigi) {
297 if (aboveThreshold == 6) {foundHeader =
true;
break; }
302 if (foundHeader && count < 5)
return 0;
303 if (foundHeader)
return count-5;
313 uint8_t aboveThreshold = 0;
314 bool foundTrailer =
false;
326 for (; iDigi != endChannelDigis; ++iDigi) {
333 if (aboveThreshold == 2) {foundTrailer =
true;
break; }
338 if (foundTrailer && count < 1)
return 0;
339 if (foundTrailer)
return count-1;
346 const std::pair<bool,bool>
349 const uint16_t aFirstBits)
353 uint16_t
count = aFirstBits+22;
355 std::pair<bool,bool> lPair = std::pair<bool,bool>(
false,
false);
364 if (iDigi == endChannelDigis)
return lPair;
366 if ( iDigi->adc() <=
threshold) lPair.first =
true;
370 if (iDigi == endChannelDigis)
return std::pair<bool,bool>(
false,
false);
372 if ( iDigi->adc() <=
threshold) lPair.second =
true;
378 const std::pair<uint8_t,uint8_t>
381 const uint16_t aFirstBits)
385 uint16_t
count = aFirstBits+6;
386 std::pair<uint8_t,uint8_t> lPair = std::pair<uint8_t,uint8_t>(0,0);
395 if (iDigi == endChannelDigis)
return lPair;
397 for (uint8_t
i = 0;
i < 16; ++
i) {
401 lPair.first |= (0x80 >>
static_cast<uint8_t
>(
i/2));
403 lPair.second |= (0x80 >>
static_cast<uint8_t
>(
i/2));
417 std::ostringstream lOs;
418 lOs <<
" ------------------------------------------------------" << std::endl
419 <<
" -- Error: " << aErr << std::endl
420 <<
" ------- Printing Frame for detId " << aFrame.
detId <<
" --------" << std::endl
423 <<
" -- digitalLow = " << aFrame.
digitalLow << std::endl
424 <<
" -- digitalHigh = " << aFrame.
digitalHigh << std::endl
425 <<
" -- baseline = " << aFrame.
baseline << std::endl
426 <<
" -- apvErrorBits = " << aFrame.
apvErrorBit.first
428 <<
" -- apvAddresses = " <<
static_cast<uint16_t
>(aFrame.
apvAddress.first)
429 <<
" " << static_cast<uint16_t>(aFrame.
apvAddress.second) << std::endl
430 <<
" ------------------------------------------------------" << std::endl;
438 uint16_t & aFedChannel){
454 const uint16_t aFedId)
457 uint32_t lTot = values.size();
458 if (!lTot)
return std::pair<uint16_t,uint32_t>(0,0);
460 std::sort(values.begin(),values.end());
461 uint32_t lMajorityCounter = 0;
464 std::vector<uint16_t>::iterator lIter = values.begin();
465 for ( ; lIter != values.end(); ) {
466 uint32_t lCounter =
std::count(lIter,values.end(),*lIter);
467 if (lCounter > lMajorityCounter) {
468 lMajorityCounter = lCounter;
476 if (static_cast<float>(lMajorityCounter)/lTot < 0.5) {
477 LogError(
"SiStripSpyUtilities") <<
" -- Found majority position for index " 480 <<
" for less than half the values : " << lMajorityCounter <<
" out of " << lTot <<
" values." 484 return std::pair<uint16_t,uint32_t>(lMaj,lMajorityCounter);
489 std::vector<uint32_t> & fedMajoritiesToFill)
492 std::map<uint32_t,uint32_t>::const_iterator lMapIter = channelValues.begin();
493 uint16_t lPreviousFedId = 0;
494 std::vector<uint16_t> lAddrVec;
497 uint32_t lChCount = 0;
499 for ( ; lMapIter != channelValues.end(); ++lMapIter,++lChCount){
503 if (lPreviousFedId == 0) {
504 lPreviousFedId = lFedId;
506 if (lFedId == lPreviousFedId) {
507 lAddrVec.push_back(lMapIter->second);
509 if (lFedId != lPreviousFedId || (lChCount == channelValues.size()-1)) {
513 fedMajoritiesToFill[lPreviousFedId] = lMaj;
518 if (lFedId != lPreviousFedId) {
519 lAddrVec.push_back(lMapIter->second);
520 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
def setup(process, global_tag, zero_tesla=False)
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)
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)
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
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)