CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Attributes
sistrip::SpyUtilities Class Reference

#include <SiStripSpyUtilities.h>

Classes

struct  Frame
 
struct  FrameQuality
 

Public Member Functions

const SiStripFedCablinggetCabling (const edm::EventSetup &)
 Updates the cabling object from the DB. More...
 
const SiStripDetCablinggetDetCabling (const edm::EventSetup &)
 Updates the det cabling object from the DB. More...
 
edm::ESHandle< SiStripNoisesgetNoiseHandle (const edm::EventSetup &eventSetup)
 
edm::ESHandle< SiStripPedestalsgetPedestalHandle (const edm::EventSetup &eventSetup)
 
 SpyUtilities ()
 
 ~SpyUtilities ()
 

Static Public Member Functions

static const uint8_t extractAPVaddress (const Frame &aFrame)
 
static const Frame extractFrameInfo (const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, bool aPrintDebug=false)
 
static void fedIndex (uint32_t aFedIndex, uint16_t &aFedId, uint16_t &aFedChannel)
 
static void fillFEDMajorities (const std::map< uint32_t, uint32_t > &channelValues, std::vector< uint32_t > &fedMajoritiesToFill)
 
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 std::pair< bool, bool > findAPVErrorBits (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)
 
static std::pair< uint16_t, uint32_t > findMajorityValue (std::vector< uint16_t > &values, const uint16_t aFedId=0)
 
static const uint16_t findTrailerBits (const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold)
 
static void getMajorityHeader (const edm::DetSetVector< SiStripRawDigi > *aInputDigis, uint16_t &firstHeaderBit, bool printResult=true)
 
static const bool isValid (const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
 
static std::string print (const Frame &aFrame, std::string aErr)
 
static const uint16_t range (const Frame &aFrame)
 
static const uint16_t threshold (const Frame &aFrame)
 

Private Attributes

const SiStripFedCablingcabling_
 The cabling object. More...
 
uint32_t cacheId_
 DB cache ID used to establish if the cabling has changed during the run. More...
 
uint32_t cacheIdDet_
 DB cache ID used to establish if the cabling has changed during the run. More...
 
const SiStripDetCablingdetCabling_
 The cabling object. More...
 
uint32_t noiseCacheId_
 
edm::ESHandle< SiStripNoisesnoiseHandle_
 
uint32_t pedsCacheId_
 
edm::ESHandle< SiStripPedestalspedsHandle_
 

Detailed Description

Definition at line 25 of file SiStripSpyUtilities.h.

Constructor & Destructor Documentation

sistrip::SpyUtilities::SpyUtilities ( )

Definition at line 21 of file SiStripSpyUtilities.cc.

21  :
22  cabling_(nullptr),
23  cacheId_(0),
24  detCabling_(nullptr),
25  cacheIdDet_(0),
26  pedsCacheId_(0),
27  pedsHandle_(nullptr),
28  noiseCacheId_(0),
29  noiseHandle_(nullptr)
30  {
31 
32  }
edm::ESHandle< SiStripNoises > noiseHandle_
uint32_t cacheIdDet_
DB cache ID used to establish if the cabling has changed during the run.
const SiStripDetCabling * detCabling_
The cabling object.
const SiStripFedCabling * cabling_
The cabling object.
edm::ESHandle< SiStripPedestals > pedsHandle_
uint32_t cacheId_
DB cache ID used to establish if the cabling has changed during the run.
sistrip::SpyUtilities::~SpyUtilities ( )

Definition at line 34 of file SiStripSpyUtilities.cc.

References cabling_, and detCabling_.

35  {
36  if ( cabling_ ) cabling_ = nullptr;
37  if ( detCabling_ ) detCabling_ = nullptr;
38  }
const SiStripDetCabling * detCabling_
The cabling object.
const SiStripFedCabling * cabling_
The cabling object.

Member Function Documentation

const uint8_t sistrip::SpyUtilities::extractAPVaddress ( const Frame aFrame)
static

Definition at line 199 of file SiStripSpyUtilities.cc.

References sistrip::SpyUtilities::Frame::apvAddress, and sistrip::SpyUtilities::Frame::apvErrorBit.

200  {
201 
202  if (aFrame.apvErrorBit.first == false) return aFrame.apvAddress.first;
203  else if (aFrame.apvErrorBit.second == false) {
204  return aFrame.apvAddress.second;
205  }
206  else {
207  return 0;
208  }
209 
210  }
const SpyUtilities::Frame sistrip::SpyUtilities::extractFrameInfo ( const edm::DetSetVector< SiStripRawDigi >::detset &  channelDigis,
bool  aPrintDebug = false 
)
static

Definition at line 121 of file SiStripSpyUtilities.cc.

References sistrip::SpyUtilities::Frame::apvAddress, sistrip::SpyUtilities::Frame::apvErrorBit, sistrip::SpyUtilities::Frame::baseline, edm::DetSet< T >::begin(), sistrip::SpyUtilities::Frame::detId, edm::DetSet< T >::detId(), sistrip::SpyUtilities::Frame::digitalHigh, sistrip::SpyUtilities::Frame::digitalLow, edm::DetSet< T >::empty(), edm::DetSet< T >::end(), findAPVAddresses(), findAPVErrorBits(), findHeaderBits(), findTrailerBits(), sistrip::SpyUtilities::Frame::firstHeaderBit, sistrip::SpyUtilities::Frame::firstTrailerBit, edm::isDebugEnabled(), LogDebug, SiStripPI::max, min(), edm::DetSet< T >::size(), threshold(), and heppy_batch::val.

Referenced by SiStripSpyMonitorModule::analyze(), sistrip::SpyDigiConverter::extractPayloadDigis(), and getMajorityHeader().

123  {
124 
125  SpyUtilities::Frame lFrame;
126  lFrame.detId = channelDigis.detId();
127  lFrame.firstHeaderBit = 0;
128  lFrame.firstTrailerBit = 0;
129  lFrame.digitalLow = 0;
130  lFrame.digitalHigh = 0;
131  lFrame.baseline = 0;
132  lFrame.apvErrorBit.first = false;
133  lFrame.apvErrorBit.second = false;
134  lFrame.apvAddress.first = 0;
135  lFrame.apvAddress.second = 0;
136 
137  uint16_t min = 0x3FF;
138  uint16_t max = 0;
140  const edm::DetSetVector<SiStripRawDigi>::detset::const_iterator endChannelDigis = channelDigis.end();
141 
142  //counters for outputting warnings
143  uint16_t numzeroes = 0, numsats = 0;
144 
145  if (iDigi == endChannelDigis) return lFrame;
146 
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++;
153  lFrame.baseline += val;
154 // std::cout<<"val : "<<val<<std::endl;
155  }
156 
157  if (!channelDigis.empty()) lFrame.baseline = lFrame.baseline/channelDigis.size();
158  lFrame.digitalLow = min;
159  lFrame.digitalHigh = max;
160 // std::cout<<"lFrame.digitalLow : "<<lFrame.digitalLow<<std::endl;
161 // std::cout<<"lFrame.digitalHigh : "<<lFrame.digitalHigh<<std::endl;
162 
163  const uint16_t threshold = static_cast<uint16_t>( (2.0 * static_cast<double>(max-min)) / 3.0 );
164 
165  if (aPrintDebug){
166  if ( edm::isDebugEnabled() ) {
167  LogDebug("SiStripSpyUtilities") << "Channel with key: " << lFrame.detId
168  << " Min: " << min << " Max: " << max
169  << " Range: " << (max-min) << " Threshold: " << threshold;
170  }
171  if (numzeroes>0 || numsats>0) {
172  edm::LogWarning("SiStripSpyUtilities") << "Channel with key: " << lFrame.detId << " has "
173  << numzeroes << " zero and "
174  << numsats << " saturated samples.";
175  }
176  }
177 
178  lFrame.firstHeaderBit = findHeaderBits(channelDigis,threshold);
179  lFrame.firstTrailerBit = findTrailerBits(channelDigis,threshold);
180 
181  lFrame.apvErrorBit = findAPVErrorBits(channelDigis,threshold,lFrame.firstHeaderBit);
182  lFrame.apvAddress = findAPVAddresses(channelDigis,threshold,lFrame.firstHeaderBit);
183 
184  return lFrame;
185 
186  }
#define LogDebug(id)
iterator end()
Definition: DetSet.h:60
bool isDebugEnabled()
det_id_type detId() const
Definition: DetSet.h:72
static const std::pair< bool, bool > findAPVErrorBits(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold, const uint16_t aFirstBits)
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)
size_type size() const
Definition: DetSet.h:63
T min(T a, T b)
Definition: MathUtil.h:58
static const uint16_t threshold(const Frame &aFrame)
iterator begin()
Definition: DetSet.h:59
static const uint16_t findTrailerBits(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold)
bool empty() const
Definition: DetSet.h:64
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
void sistrip::SpyUtilities::fedIndex ( uint32_t  aFedIndex,
uint16_t &  aFedId,
uint16_t &  aFedChannel 
)
static

Definition at line 436 of file SiStripSpyUtilities.cc.

References sistrip::FED_ID_MAX, sistrip::FED_ID_MIN, sistrip::FEDCH_PER_FED, and sistrip::invalid_.

Referenced by sistrip::FEDEmulatorModule::produce().

438  {
439 
440  //find the corresponding detId (for the pedestals)
441  aFedId = static_cast<uint16_t>(aFedIndex/sistrip::FEDCH_PER_FED);
442  aFedChannel = static_cast<uint16_t>(aFedIndex%sistrip::FEDCH_PER_FED);
443 
444  if (aFedId < sistrip::FED_ID_MIN ||
445  aFedId > sistrip::FED_ID_MAX ||
446  aFedChannel >= sistrip::FEDCH_PER_FED ) {
447  aFedId = sistrip::invalid_;
448  aFedChannel = sistrip::invalid_;
449  }
450 
451  }
static const uint16_t FED_ID_MIN
static const uint16_t invalid_
Definition: Constants.h:16
static const uint16_t FEDCH_PER_FED
static const uint16_t FED_ID_MAX
void sistrip::SpyUtilities::fillFEDMajorities ( const std::map< uint32_t, uint32_t > &  channelValues,
std::vector< uint32_t > &  fedMajoritiesToFill 
)
static

Definition at line 488 of file SiStripSpyUtilities.cc.

References sistrip::FED_ID_MAX, sistrip::FED_ID_MIN, sistrip::FEDCH_PER_FED, and findMajorityValue().

Referenced by sistrip::SpyEventMatcher::getCounters().

490  {
491 
492  std::map<uint32_t,uint32_t>::const_iterator lMapIter = channelValues.begin();
493  uint16_t lPreviousFedId = 0;
494  std::vector<uint16_t> lAddrVec;
495  lAddrVec.reserve(sistrip::FEDCH_PER_FED);
496  fedMajoritiesToFill.resize(sistrip::FED_ID_MAX-sistrip::FED_ID_MIN+1,0);
497  uint32_t lChCount = 0;
498 
499  for ( ; lMapIter != channelValues.end(); ++lMapIter,++lChCount){
500 
501  uint16_t lFedId = static_cast<uint16_t>(lMapIter->first/sistrip::FEDCH_PER_FED);
502 
503  if (lPreviousFedId == 0) {
504  lPreviousFedId = lFedId;
505  }
506  if (lFedId == lPreviousFedId) {
507  lAddrVec.push_back(lMapIter->second);
508  }
509  if (lFedId != lPreviousFedId || (lChCount == channelValues.size()-1)) {
510  //extract majority address
511 
512  uint32_t lMaj = sistrip::SpyUtilities::findMajorityValue(lAddrVec,lPreviousFedId).first;
513  fedMajoritiesToFill[lPreviousFedId] = lMaj;
514 
515  lAddrVec.clear();
516 
517  //if new fed, fill the first channel
518  if (lFedId != lPreviousFedId) {
519  lAddrVec.push_back(lMapIter->second);
520  lPreviousFedId = lFedId;
521  }
522 
523  }
524  }
525 
526  }
static const uint16_t FED_ID_MIN
static std::pair< uint16_t, uint32_t > findMajorityValue(std::vector< uint16_t > &values, const uint16_t aFedId=0)
static const uint16_t FEDCH_PER_FED
static const uint16_t FED_ID_MAX
const std::pair< uint8_t, uint8_t > sistrip::SpyUtilities::findAPVAddresses ( const edm::DetSetVector< SiStripRawDigi >::detset &  channelDigis,
const uint16_t  threshold,
const uint16_t  aFirstBits 
)
static

Definition at line 379 of file SiStripSpyUtilities.cc.

References edm::DetSet< T >::begin(), KineDebug3::count(), edm::DetSet< T >::end(), mps_fire::i, sistrip::SPY_SAMPLES_PER_CHANNEL, and threshold().

Referenced by extractFrameInfo().

382  {
383 
384  // Loop over digis looking for firstHeader+6
385  uint16_t count = aFirstBits+6;
386  std::pair<uint8_t,uint8_t> lPair = std::pair<uint8_t,uint8_t>(0,0);
387 
388  //check enough room to have 16 values....
389  if (count >= sistrip::SPY_SAMPLES_PER_CHANNEL-15) return lPair;
390 
392  const edm::DetSetVector<SiStripRawDigi>::detset::const_iterator endChannelDigis = channelDigis.end();
393 
394  //double check....
395  if (iDigi == endChannelDigis) return lPair;
396 
397  for (uint8_t i = 0; i < 16; ++i) {
398  if ( iDigi->adc() > threshold) {
399  //data is MSB first
400  if (i%2==0)
401  lPair.first |= (0x80 >> static_cast<uint8_t>(i/2));
402  else
403  lPair.second |= (0x80 >> static_cast<uint8_t>(i/2));
404  }
405  ++iDigi;
406  }
407 
408  return lPair;
409 
410  }
iterator end()
Definition: DetSet.h:60
static const uint16_t SPY_SAMPLES_PER_CHANNEL
static const uint16_t threshold(const Frame &aFrame)
iterator begin()
Definition: DetSet.h:59
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
const std::pair< bool, bool > sistrip::SpyUtilities::findAPVErrorBits ( const edm::DetSetVector< SiStripRawDigi >::detset &  channelDigis,
const uint16_t  threshold,
const uint16_t  aFirstBits 
)
static

Definition at line 347 of file SiStripSpyUtilities.cc.

References edm::DetSet< T >::begin(), KineDebug3::count(), edm::DetSet< T >::end(), reco::if(), sistrip::SPY_SAMPLES_PER_CHANNEL, and threshold().

Referenced by extractFrameInfo().

350  {
351 
352  // Loop over digis looking for firstHeader+6+16
353  uint16_t count = aFirstBits+22;
354 
355  std::pair<bool,bool> lPair = std::pair<bool,bool>(false,false);
356 
357  //if header invalid: we don't know what apverr is....
358  if (count >= sistrip::SPY_SAMPLES_PER_CHANNEL-1) return lPair;
359 
361  const edm::DetSetVector<SiStripRawDigi>::detset::const_iterator endChannelDigis = channelDigis.end();
362 
363  //double check....
364  if (iDigi == endChannelDigis) return lPair;
365 
366  if ( iDigi->adc() <= threshold) lPair.first = true;
367  ++iDigi;
368 
369  //triple check...
370  if (iDigi == endChannelDigis) return std::pair<bool,bool>(false,false);
371 
372  if ( iDigi->adc() <= threshold) lPair.second = true;
373 
374  return lPair;
375  }
iterator end()
Definition: DetSet.h:60
static const uint16_t SPY_SAMPLES_PER_CHANNEL
static const uint16_t threshold(const Frame &aFrame)
iterator begin()
Definition: DetSet.h:59
if(dp >Float(M_PI)) dp-
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
const uint16_t sistrip::SpyUtilities::findHeaderBits ( const edm::DetSetVector< SiStripRawDigi >::detset &  channelDigis,
const uint16_t  threshold 
)
static

Definition at line 278 of file SiStripSpyUtilities.cc.

References edm::DetSet< T >::begin(), KineDebug3::count(), edm::DetSet< T >::end(), sistrip::SPY_SAMPLES_PER_CHANNEL, and threshold().

Referenced by extractFrameInfo().

280  {
281 
282  // Loop over digis looking for first above threshold
283  uint8_t aboveThreshold = 0;
284  bool foundHeader = false;
285  uint16_t count = 0;
286 
288  const edm::DetSetVector<SiStripRawDigi>::detset::const_iterator endChannelDigis = channelDigis.end();
289 
290  for (; iDigi != endChannelDigis; ++iDigi) {
291  if ( iDigi->adc() > threshold) {
292  aboveThreshold++;
293  }
294  else {
295  aboveThreshold = 0;
296  }
297  if (aboveThreshold == 6) {foundHeader = true; break; }
298  count++;
299  }//end of loop over digis
300 
301  //break before incrementing the last time... so count-5 is the first header sample.
302  if (foundHeader && count < 5) return 0;
303  if (foundHeader) return count-5;
305 
306  }
iterator end()
Definition: DetSet.h:60
static const uint16_t SPY_SAMPLES_PER_CHANNEL
static const uint16_t threshold(const Frame &aFrame)
iterator begin()
Definition: DetSet.h:59
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
std::pair< uint16_t, uint32_t > sistrip::SpyUtilities::findMajorityValue ( std::vector< uint16_t > &  values,
const uint16_t  aFedId = 0 
)
static

Definition at line 453 of file SiStripSpyUtilities.cc.

References KineDebug3::count().

Referenced by fillFEDMajorities(), getMajorityHeader(), and sistrip::SpyDigiConverter::processFED().

455  {
456 
457  uint32_t lTot = values.size();
458  if (!lTot) return std::pair<uint16_t,uint32_t>(0,0);
459 
460  std::sort(values.begin(),values.end());
461  uint32_t lMajorityCounter = 0;
462  uint16_t lMaj = 0;
463 
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;
469  lMaj = *lIter;
470  }
471  lIter += lCounter;
472  }
473 
474  //std::cout << " -- Found majority value " << lMaj << " for " << lMajorityCounter << " elements out of " << values.size() << "." << std::endl;
475 
476  if (static_cast<float>(lMajorityCounter)/lTot < 0.5) {
477  LogError("SiStripSpyUtilities") << " -- Found majority position for index "
478  << aFedId
479  << ": " << lMaj
480  << " for less than half the values : " << lMajorityCounter << " out of " << lTot << " values."
481  << std::endl;
482  }
483 
484  return std::pair<uint16_t,uint32_t>(lMaj,lMajorityCounter);
485 
486  }
const uint16_t sistrip::SpyUtilities::findTrailerBits ( const edm::DetSetVector< SiStripRawDigi >::detset &  channelDigis,
const uint16_t  threshold 
)
static

Definition at line 308 of file SiStripSpyUtilities.cc.

References edm::DetSet< T >::begin(), KineDebug3::count(), edm::DetSet< T >::end(), sistrip::SPY_SAMPLES_PER_CHANNEL, sistrip::STRIPS_PER_FEDCH, and threshold().

Referenced by extractFrameInfo().

310  {
311 
312  // Loop over digis looking for last above threshold
313  uint8_t aboveThreshold = 0;
314  bool foundTrailer = false;
315 
316  //discard the first 30 values, which will have some digital high in them...
317  //start searching from the expected position : sometimes after 24+256 samples,
318  //normally at 6+24+256 if 6-bit low before tickmark header bits...
319  uint16_t count = 24+sistrip::STRIPS_PER_FEDCH;
320 
322 
324  const edm::DetSetVector<SiStripRawDigi>::detset::const_iterator endChannelDigis = channelDigis.end();
325 
326  for (; iDigi != endChannelDigis; ++iDigi) {
327  if ( iDigi->adc() > threshold) {
328  aboveThreshold++;
329  }
330  else {
331  aboveThreshold = 0;
332  }
333  if (aboveThreshold == 2) {foundTrailer = true; break; }
334  count++;
335  }//end of loop over digis
336 
337  //break before incrementing the last time... so count-1 is the first trailer sample.
338  if (foundTrailer && count < 1) return 0;
339  if (foundTrailer) return count-1;
341 
342  }
iterator end()
Definition: DetSet.h:60
static const uint16_t SPY_SAMPLES_PER_CHANNEL
static const uint16_t threshold(const Frame &aFrame)
iterator begin()
Definition: DetSet.h:59
static const uint16_t STRIPS_PER_FEDCH
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
const SiStripFedCabling * sistrip::SpyUtilities::getCabling ( const edm::EventSetup setup)

Updates the cabling object from the DB.

Definition at line 40 of file SiStripSpyUtilities.cc.

References EnergyCorrector::c, cabling_, cacheId_, edm::EventSetup::get(), and edm::ESHandle< T >::product().

Referenced by SiStripSpyMonitorModule::analyze(), sistrip::SpyDigiConverterModule::produce(), sistrip::SpyUnpackerModule::produce(), and sistrip::FEDEmulatorModule::produce().

41  {
42 
43  uint32_t cache_id = setup.get<SiStripFedCablingRcd>().cacheIdentifier();
44 
45  if ( cacheId_ != cache_id ) { // If the cache ID has changed since the last update...
46  // Update the cabling object
48  setup.get<SiStripFedCablingRcd>().get( c );
49  cabling_ = c.product();
50 
51 // if ( edm::isDebugEnabled() ) {
52 // if ( !cacheId_ ) { // First time cabling has been retrieved - print it out in full.
53 // std::stringstream ss;
54 // ss << "[sistrip::SpyChannelUnpackerModule::" << __func__ << "]"
55 // << " Updating cabling for first time..." << std::endl
56 // << " Terse print out of FED cabling:" << std::endl;
57 // //cabling_->terse(ss);
58 // //LogTrace("SiStripMonitorHardwareUnpacker") << ss.str();
59 // } // end of cacheId_ check
60 // } // end of debugEnabled check
61 
62 // if ( edm::isDebugEnabled() ) {
63 // std::stringstream sss;
64 // sss << "[sistrip::SpyUtilities::" << __func__ << "]"
65 // << " Summary of FED cabling:" << std::endl;
66 // cabling_->summary(sss);
67 // LogTrace("SiStripSpyUtilities") << sss.str();
68 // }
69 
70  // Update the cache ID with the new value.
71  cacheId_ = cache_id;
72 
73  } // end of new cache ID check
74 
75  return cabling_;
76  }
const SiStripFedCabling * cabling_
The cabling object.
const T & get() const
Definition: EventSetup.h:59
T const * product() const
Definition: ESHandle.h:86
uint32_t cacheId_
DB cache ID used to establish if the cabling has changed during the run.
const SiStripDetCabling * sistrip::SpyUtilities::getDetCabling ( const edm::EventSetup setup)

Updates the det cabling object from the DB.

Definition at line 78 of file SiStripSpyUtilities.cc.

References EnergyCorrector::c, cacheIdDet_, detCabling_, edm::EventSetup::get(), and edm::ESHandle< T >::product().

Referenced by SiStripSpyDisplayModule::analyze().

79  {
80 
81  uint32_t cache_id = setup.get<SiStripDetCablingRcd>().cacheIdentifier();//.get( cabling_ );
82 
83  if ( cacheIdDet_ != cache_id ) { // If the cache ID has changed since the last update...
84  // Update the cabling object
86  setup.get<SiStripDetCablingRcd>().get( c );
87  detCabling_ = c.product();
88  cacheIdDet_ = cache_id;
89  } // end of new cache ID check
90 
91  return detCabling_;
92  }
uint32_t cacheIdDet_
DB cache ID used to establish if the cabling has changed during the run.
const SiStripDetCabling * detCabling_
The cabling object.
const T & get() const
Definition: EventSetup.h:59
T const * product() const
Definition: ESHandle.h:86
void sistrip::SpyUtilities::getMajorityHeader ( const edm::DetSetVector< SiStripRawDigi > *  aInputDigis,
uint16_t &  firstHeaderBit,
bool  printResult = true 
)
static

Definition at line 212 of file SiStripSpyUtilities.cc.

References edm::DetSetVector< T >::begin(), edm::DetSetVector< T >::end(), extractFrameInfo(), findMajorityValue(), sistrip::SpyUtilities::Frame::firstHeaderBit, edm::DetSetVector< T >::size(), and sistrip::STRIPS_PER_FEDCH.

Referenced by SiStripSpyMonitorModule::analyze(), and sistrip::SpyDigiConverterModule::produce().

215  {
216 
217  std::vector<uint16_t> lFirstBitVec;
218  lFirstBitVec.reserve(aInputDigis->size());
219  aFirstHeaderBit = 0;
221 
222  for ( ; lDigis != aInputDigis->end(); lDigis++){
224  lFirstBitVec.push_back(lFrame.firstHeaderBit);
225  }
226 
227  std::pair<uint16_t,uint32_t> lMaj = sistrip::SpyUtilities::findMajorityValue(lFirstBitVec);
228  aFirstHeaderBit = lMaj.first;
229  uint32_t lMajorityCounter = lMaj.second;
230 
231  //header is 24-sample long (2*8+2+6)
232  uint16_t lFirstTrailerBit = aFirstHeaderBit+24+sistrip::STRIPS_PER_FEDCH;
233 
234  if (printResult)
235  {
236  LogInfo("SiStripSpyUtilities") << " -- Found majority position of first header (trailer) bit: "
237  << aFirstHeaderBit
238  << " (" << lFirstTrailerBit
239  << ") for " << lMajorityCounter << " out of " << lFirstBitVec.size() << " channels."
240  << std::endl;
241  }
242  }
static const Frame extractFrameInfo(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, bool aPrintDebug=false)
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:361
size_type size() const
Return the number of contained DetSets.
Definition: DetSetVector.h:283
static std::pair< uint16_t, uint32_t > findMajorityValue(std::vector< uint16_t > &values, const uint16_t aFedId=0)
static const uint16_t STRIPS_PER_FEDCH
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:346
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:104
edm::ESHandle< SiStripNoises > sistrip::SpyUtilities::getNoiseHandle ( const edm::EventSetup eventSetup)

Definition at line 107 of file SiStripSpyUtilities.cc.

References edm::EventSetup::get(), noiseCacheId_, and noiseHandle_.

Referenced by sistrip::FEDEmulatorModule::produce().

108  {
109  //check if new noise values are available
110  uint32_t lCacheId = eventSetup.get<SiStripNoisesRcd>().cacheIdentifier();
111  if (lCacheId != noiseCacheId_) {
112  eventSetup.get<SiStripNoisesRcd>().get(noiseHandle_);
113  noiseCacheId_ = lCacheId;
114  }
115 
116  return noiseHandle_;
117  }
edm::ESHandle< SiStripNoises > noiseHandle_
const T & get() const
Definition: EventSetup.h:59
edm::ESHandle< SiStripPedestals > sistrip::SpyUtilities::getPedestalHandle ( const edm::EventSetup eventSetup)

Definition at line 94 of file SiStripSpyUtilities.cc.

References edm::EventSetup::get(), pedsCacheId_, and pedsHandle_.

Referenced by sistrip::FEDEmulatorModule::produce().

95  {
96  //check if new pedestal values are available
97  uint32_t lCacheId = eventSetup.get<SiStripPedestalsRcd>().cacheIdentifier();
98  if (lCacheId != pedsCacheId_) {
99  eventSetup.get<SiStripPedestalsRcd>().get(pedsHandle_);
100  pedsCacheId_ = lCacheId;
101  }
102 
103  return pedsHandle_;
104  }
const T & get() const
Definition: EventSetup.h:59
edm::ESHandle< SiStripPedestals > pedsHandle_
const bool sistrip::SpyUtilities::isValid ( const Frame aFrame,
const FrameQuality aQuality,
const uint16_t  aExpectedPos 
)
static

Definition at line 245 of file SiStripSpyUtilities.cc.

References sistrip::SpyUtilities::Frame::apvErrorBit, sistrip::SpyUtilities::Frame::digitalHigh, sistrip::SpyUtilities::Frame::digitalLow, sistrip::SpyUtilities::Frame::firstHeaderBit, sistrip::SpyUtilities::Frame::firstTrailerBit, sistrip::SpyUtilities::FrameQuality::maxDigiRange, sistrip::SpyUtilities::FrameQuality::maxTickHeight, sistrip::SpyUtilities::FrameQuality::maxZeroLight, sistrip::SpyUtilities::FrameQuality::minTickHeight, sistrip::SpyUtilities::FrameQuality::minZeroLight, range(), and sistrip::STRIPS_PER_FEDCH.

Referenced by ntupleDataFormat._Object::_checkIsValid(), sistrip::SpyDigiConverter::extractPayloadDigis(), and core.AutoHandle.AutoHandle::ReallyLoad().

248  {
249 
250  uint16_t lRange = sistrip::SpyUtilities::range(aFrame);
251 
252  if (lRange < aQuality.minDigiRange || lRange > aQuality.maxDigiRange) {
253  return false;
254  }
255  else if (aFrame.digitalLow < aQuality.minZeroLight || aFrame.digitalLow > aQuality.maxZeroLight) {
256  return false;
257  }
258  else if (aFrame.digitalHigh < aQuality.minTickHeight || aFrame.digitalHigh > aQuality.maxTickHeight){
259  return false;
260  }
261  //if expectedPos=0: return true whatever the position of header is...
262  else if ( aExpectedPos > 0 &&
263  (
264  !(aFrame.firstHeaderBit == aExpectedPos &&
265  aFrame.firstTrailerBit == aExpectedPos+24+sistrip::STRIPS_PER_FEDCH)
266  )
267  ) {
268  return false;
269  }
270  else if (aFrame.apvErrorBit.first && aFrame.apvErrorBit.second) {
271  return false;
272  }
273 
274  return true;
275  }
static const uint16_t range(const Frame &aFrame)
static const uint16_t STRIPS_PER_FEDCH
std::string sistrip::SpyUtilities::print ( const Frame aFrame,
std::string  aErr 
)
static

Definition at line 413 of file SiStripSpyUtilities.cc.

References sistrip::SpyUtilities::Frame::apvAddress, sistrip::SpyUtilities::Frame::apvErrorBit, sistrip::SpyUtilities::Frame::baseline, sistrip::SpyUtilities::Frame::detId, sistrip::SpyUtilities::Frame::digitalHigh, sistrip::SpyUtilities::Frame::digitalLow, sistrip::SpyUtilities::Frame::firstHeaderBit, and sistrip::SpyUtilities::Frame::firstTrailerBit.

Referenced by sistrip::SpyDigiConverter::extractPayloadDigis().

415  {
416 
417  std::ostringstream lOs;
418  lOs << " ------------------------------------------------------" << std::endl
419  << " -- Error: " << aErr << std::endl
420  << " ------- Printing Frame for detId " << aFrame.detId << " --------" << std::endl
421  << " -- firstHeaderBit = " << aFrame.firstHeaderBit << std::endl
422  << " -- firstTrailerBit = " << aFrame.firstTrailerBit << 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
427  << " " << aFrame.apvErrorBit.second << std::endl
428  << " -- apvAddresses = " << static_cast<uint16_t>(aFrame.apvAddress.first)
429  << " " << static_cast<uint16_t>(aFrame.apvAddress.second) << std::endl
430  << " ------------------------------------------------------" << std::endl;
431  return lOs.str();
432 
433  }
const uint16_t sistrip::SpyUtilities::range ( const Frame aFrame)
static

Definition at line 188 of file SiStripSpyUtilities.cc.

References sistrip::SpyUtilities::Frame::digitalHigh, and sistrip::SpyUtilities::Frame::digitalLow.

Referenced by SiStripSpyMonitorModule::analyze(), SPYHistograms::fillDetailedHistograms(), isValid(), and threshold().

189  {
190  if (aFrame.digitalHigh < aFrame.digitalLow) return 0;
191  else return aFrame.digitalHigh-aFrame.digitalLow;
192  }
const uint16_t sistrip::SpyUtilities::threshold ( const Frame aFrame)
static

Definition at line 194 of file SiStripSpyUtilities.cc.

References range().

Referenced by SiStripSpyMonitorModule::analyze(), extractFrameInfo(), findAPVAddresses(), findAPVErrorBits(), findHeaderBits(), and findTrailerBits().

195  {
196  return static_cast<uint16_t>( (2.0 * static_cast<double>(range(aFrame))) / 3.0 );
197  }
static const uint16_t range(const Frame &aFrame)

Member Data Documentation

const SiStripFedCabling* sistrip::SpyUtilities::cabling_
private

The cabling object.

Definition at line 112 of file SiStripSpyUtilities.h.

Referenced by getCabling(), and ~SpyUtilities().

uint32_t sistrip::SpyUtilities::cacheId_
private

DB cache ID used to establish if the cabling has changed during the run.

Definition at line 113 of file SiStripSpyUtilities.h.

Referenced by getCabling().

uint32_t sistrip::SpyUtilities::cacheIdDet_
private

DB cache ID used to establish if the cabling has changed during the run.

Definition at line 117 of file SiStripSpyUtilities.h.

Referenced by getDetCabling().

const SiStripDetCabling* sistrip::SpyUtilities::detCabling_
private

The cabling object.

Definition at line 116 of file SiStripSpyUtilities.h.

Referenced by getDetCabling(), and ~SpyUtilities().

uint32_t sistrip::SpyUtilities::noiseCacheId_
private

Definition at line 124 of file SiStripSpyUtilities.h.

Referenced by getNoiseHandle().

edm::ESHandle<SiStripNoises> sistrip::SpyUtilities::noiseHandle_
private

Definition at line 125 of file SiStripSpyUtilities.h.

Referenced by getNoiseHandle().

uint32_t sistrip::SpyUtilities::pedsCacheId_
private

Definition at line 120 of file SiStripSpyUtilities.h.

Referenced by getPedestalHandle().

edm::ESHandle<SiStripPedestals> sistrip::SpyUtilities::pedsHandle_
private

Definition at line 121 of file SiStripSpyUtilities.h.

Referenced by getPedestalHandle().