CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
SiStripSpyMonitorModule Class Reference
Inheritance diagram for SiStripSpyMonitorModule:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 SiStripSpyMonitorModule (const edm::ParameterSet &)
 
 ~SiStripSpyMonitorModule ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
virtual void beginJob () override
 
virtual void endJob () override
 
edm::DetSetVector
< SiStripRawDigi >
::detset::const_iterator 
findTwoConsecutive (const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold, uint16_t &aCounter)
 
bool hasNegativePedSubtr (const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, uint16_t aPair)
 
bool identifyTickmarks (const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold)
 

Private Attributes

DQMStoredqm_
 
std::string dqmStoreFileName_
 
unsigned int evt_
 
bool fillAllDetailedHistograms_
 
bool fillWithEvtNum_
 
bool fillWithLocalEvtNum_
 
uint16_t firstHeaderBit_
 
uint16_t firstTrailerBit_
 
std::string folderName_
 
sistrip::SpyUtilities::FrameQuality frameQuality_
 
SPYHistograms histManager_
 
uint32_t maxDigiRange_
 
uint32_t maxDigitalHigh_
 
uint32_t maxDigitalLow_
 
uint32_t minDigiRange_
 
uint32_t minDigitalHigh_
 
uint32_t minDigitalLow_
 
std::ofstream outfile_ [20]
 
std::map< std::string,
unsigned int > 
outfileMap_
 
std::vector< std::string > outfileNames_
 
edm::InputTag spyAPVeTag_
 
edm::EDGetTokenT< std::vector
< uint32_t > > 
spyAPVeToken_
 
edm::InputTag spyL1Tag_
 
edm::EDGetTokenT< std::vector
< uint32_t > > 
spyL1Token_
 
edm::InputTag spyPedSubtrDigisTag_
 
edm::EDGetTokenT
< edm::DetSetVector
< SiStripRawDigi > > 
spyPedSubtrDigisToken_
 
edm::InputTag spyScopeRawDigisTag_
 
edm::EDGetTokenT
< edm::DetSetVector
< SiStripRawDigi > > 
spyScopeRawDigisToken_
 
edm::InputTag spyTotCountTag_
 
edm::EDGetTokenT< std::vector
< uint32_t > > 
spyTotCountToken_
 
sistrip::SpyUtilities utility_
 
bool writeCabling_
 
bool writeDQMStore_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 50 of file SiStripSpyMonitorModule.cc.

Constructor & Destructor Documentation

SiStripSpyMonitorModule::SiStripSpyMonitorModule ( const edm::ParameterSet iConfig)
explicit

Definition at line 140 of file SiStripSpyMonitorModule.cc.

References evt_, frameQuality_, edm::ParameterSet::getUntrackedParameter(), histManager_, i, SPYHistograms::initialise(), sistrip::SpyUtilities::FrameQuality::maxDigiRange, sistrip::SpyUtilities::FrameQuality::maxTickHeight, sistrip::SpyUtilities::FrameQuality::maxZeroLight, sistrip::SpyUtilities::FrameQuality::minDigiRange, sistrip::SpyUtilities::FrameQuality::minTickHeight, sistrip::SpyUtilities::FrameQuality::minZeroLight, dbtoconf::out, outfile_, outfileMap_, outfileNames_, spyAPVeTag_, spyAPVeToken_, spyL1Tag_, spyL1Token_, spyPedSubtrDigisTag_, spyPedSubtrDigisToken_, spyScopeRawDigisTag_, spyScopeRawDigisToken_, spyTotCountTag_, and spyTotCountToken_.

141  : spyScopeRawDigisTag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyScopeRawDigisTag",edm::InputTag("SiStripSpyUnpacker","ScopeRawDigis"))),
142  spyPedSubtrDigisTag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyPedSubtrDigisTag",edm::InputTag("SiStripFEDEmulator",""))),
143  spyL1Tag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyL1Tag",edm::InputTag("SiStripSpyDigiConverter","L1ACount"))),
144  spyTotCountTag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyTotalEventCountTag",edm::InputTag("SiStripSpyDigiConverter","TotalEventCount"))),
145  spyAPVeTag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyAPVeTag",edm::InputTag("SiStripSpyDigiConverter","APVAddress"))),
146  dqm_(0),
147  folderName_(iConfig.getUntrackedParameter<std::string>("HistogramFolderName","SiStrip/ReadoutView/SpyMonitoringSummary")),
148  fillAllDetailedHistograms_(iConfig.getUntrackedParameter<bool>("FillAllDetailedHistograms",false)),
149  fillWithEvtNum_(iConfig.getUntrackedParameter<bool>("FillWithEventNumber",false)),
150  fillWithLocalEvtNum_(iConfig.getUntrackedParameter<bool>("FillWithLocalEventNumber",false)),
151  writeDQMStore_(iConfig.getUntrackedParameter<bool>("WriteDQMStore",false)),
152  dqmStoreFileName_(iConfig.getUntrackedParameter<std::string>("DQMStoreFileName","DQMStore.root")),
153  firstHeaderBit_(0),
154  firstTrailerBit_(0),
155  outfileNames_(iConfig.getUntrackedParameter<std::vector<std::string> >("OutputErrors")),
156  writeCabling_(iConfig.getUntrackedParameter<bool>("WriteCabling",false))
157 {
158 
159  spyScopeRawDigisToken_ = consumes<edm::DetSetVector<SiStripRawDigi> >(spyScopeRawDigisTag_);
160  spyPedSubtrDigisToken_ = consumes<edm::DetSetVector<SiStripRawDigi> >(spyPedSubtrDigisTag_);
161 
162  spyL1Token_ = consumes<std::vector<uint32_t> >(spyL1Tag_);
163  spyTotCountToken_ = consumes<std::vector<uint32_t> >(spyTotCountTag_);
164  spyAPVeToken_ = consumes<std::vector<uint32_t> >(spyAPVeTag_);
165 
166  evt_ = 0;
167  std::ostringstream pDebugStream;
168  histManager_.initialise(iConfig,&pDebugStream);
169  const unsigned int nFiles = outfileNames_.size();
170 
171  for (unsigned int i(0); i<nFiles; i++){
172  std::ostringstream lName;
173  lName << outfileNames_.at(i) << ".out";
174  if (i<20) outfile_[i].open(lName.str().c_str(),std::ios::out);
175  outfileMap_[outfileNames_.at(i)] = i;
176  }
177 
178  frameQuality_.minDigiRange = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MinDigiRange",100));
179  frameQuality_.maxDigiRange = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MaxDigiRange",1024));
180  frameQuality_.minZeroLight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MinZeroLight",0));
181  frameQuality_.maxZeroLight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MaxZeroLight",1024));
182  frameQuality_.minTickHeight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MinTickHeight",0));
183  frameQuality_.maxTickHeight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MaxTickHeight",1024));
184 
185 }
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void initialise(const edm::ParameterSet &iConfig, std::ostringstream *pDebugStream)
edm::EDGetTokenT< std::vector< uint32_t > > spyAPVeToken_
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyPedSubtrDigisToken_
std::map< std::string, unsigned int > outfileMap_
sistrip::SpyUtilities::FrameQuality frameQuality_
std::vector< std::string > outfileNames_
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyScopeRawDigisToken_
tuple out
Definition: dbtoconf.py:99
edm::EDGetTokenT< std::vector< uint32_t > > spyL1Token_
edm::EDGetTokenT< std::vector< uint32_t > > spyTotCountToken_
SiStripSpyMonitorModule::~SiStripSpyMonitorModule ( )

Definition at line 187 of file SiStripSpyMonitorModule.cc.

References i, outfile_, outfileMap_, and outfileNames_.

188 {
189  const unsigned int nFiles = outfileNames_.size();
190  for (unsigned int i(0); i<nFiles; i++){
191  outfile_[i].close();
192  }
193 
194  outfileMap_.clear();
195  outfileNames_.clear();
196 
197 }
int i
Definition: DBlmapReader.cc:9
std::map< std::string, unsigned int > outfileMap_
std::vector< std::string > outfileNames_

Member Function Documentation

void SiStripSpyMonitorModule::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 229 of file SiStripSpyMonitorModule.cc.

References sistrip::SpyUtilities::Frame::apvAddress, sistrip::SpyUtilities::Frame::apvErrorBit, FedChannelConnection::apvPairNumber(), FedChannelConnection::detId(), sistrip::SpyUtilities::Frame::digitalHigh, sistrip::SpyUtilities::Frame::digitalLow, alignCSCRings::e, edm::DetSetVector< T >::end(), edm::EventID::event(), evt_, sistrip::SpyUtilities::extractFrameInfo(), sistrip::FED_ID_MAX, sistrip::FED_ID_MIN, sistrip::FEDCH_PER_FED, SiStripFedCabling::fedConnection(), SPYHistograms::fillCountersHistograms(), SPYHistograms::fillDetailedHistograms(), SPYHistograms::fillFEDHistograms(), fillWithLocalEvtNum_, edm::DetSetVector< T >::find(), create_complex_test_file0_cfg::firstEvent, sistrip::SpyUtilities::Frame::firstHeaderBit, firstHeaderBit_, sistrip::SpyUtilities::Frame::firstTrailerBit, firstTrailerBit_, frameQuality_, edm::Event::getByToken(), sistrip::SpyUtilities::getCabling(), sistrip::SpyUtilities::getMajorityHeader(), SPYHistograms::Errors::hasAPVAddressError0, SPYHistograms::Errors::hasAPVAddressError1, SPYHistograms::Errors::hasErrorBit0, SPYHistograms::Errors::hasErrorBit1, SPYHistograms::Errors::hasHighPb, SPYHistograms::Errors::hasHighRange, SPYHistograms::Errors::hasLowPb, SPYHistograms::Errors::hasLowRange, SPYHistograms::Errors::hasMaxSat, SPYHistograms::Errors::hasMinZero, hasNegativePedSubtr(), SPYHistograms::Errors::hasNegPeds, SPYHistograms::Errors::hasNoData, SPYHistograms::Errors::hasOOS, SPYHistograms::Errors::hasOtherPbs, histManager_, i, edm::EventBase::id(), identifyTickmarks(), FedChannelConnection::isConnected(), LogDebug, sistrip::SpyUtilities::FrameQuality::maxDigiRange, sistrip::SpyUtilities::FrameQuality::maxTickHeight, sistrip::SpyUtilities::FrameQuality::maxZeroLight, sistrip::SpyUtilities::FrameQuality::minDigiRange, sistrip::SpyUtilities::FrameQuality::minTickHeight, sistrip::SpyUtilities::FrameQuality::minZeroLight, SPYHistograms::ErrorCounters::nAPVAddressError, SPYHistograms::ErrorCounters::nAPVError, SPYHistograms::ErrorCounters::nHighPb, SPYHistograms::ErrorCounters::nHighRange, SPYHistograms::ErrorCounters::nLowPb, SPYHistograms::ErrorCounters::nLowRange, SPYHistograms::ErrorCounters::nMaxSat, SPYHistograms::ErrorCounters::nMinZero, SPYHistograms::ErrorCounters::nNegPeds, SPYHistograms::ErrorCounters::nNoData, SPYHistograms::ErrorCounters::nOOS, SPYHistograms::ErrorCounters::nOtherPbs, dbtoconf::out, outfile_, outfileMap_, outfileNames_, edm::Handle< T >::product(), sistrip::SpyUtilities::range(), sistrip::SPY_SAMPLES_PER_CHANNEL, spyAPVeToken_, spyL1Token_, spyPedSubtrDigisToken_, spyScopeRawDigisToken_, spyTotCountToken_, sistrip::STRIPS_PER_FEDCH, sistrip::SpyUtilities::threshold(), utility_, cms::Exception::what(), and writeCabling_.

231 {
232 
233  static bool firstEvent = true;
234  //update cabling and pedestals
235  const SiStripFedCabling* lCabling = utility_.getCabling( iSetup );
236  if (firstEvent && writeCabling_){
237  std::ofstream lOutCabling;
238  lOutCabling.open("trackerDetId_FEDIdChNum_list.txt",std::ios::out);
239  for (uint16_t lFedId = sistrip::FED_ID_MIN; lFedId <= sistrip::FED_ID_MAX; ++lFedId) {//loop on feds
240  for (uint16_t lFedChannel = 0; lFedChannel < sistrip::FEDCH_PER_FED; lFedChannel++){//loop on channels
241  const FedChannelConnection & lConnection = lCabling->fedConnection(lFedId,lFedChannel);
242  if (!lConnection.isConnected()) continue;
243  uint32_t lDetId = lConnection.detId();
244  lOutCabling << "FED ID = " << lFedId
245  << ", Channel = " << lFedChannel
246  << ",fedkey = " << sistrip::FEDCH_PER_FED*lFedId + lFedChannel
247  << ", detId = " << lDetId
248  << std::endl;
249  }
250  }
251  lOutCabling.close();
252  }
253 
254  //For spy data
255  //get map of TotalEventCount and L1ID, indexed by fedId, and APVaddress indexed by fedIndex.
256  edm::Handle<std::vector<uint32_t> > lSpyL1IDHandle,lSpyTotCountHandle,lSpyAPVeHandle;
257  try {
258  /*
259  iEvent.getByLabel(spyL1Tag_,lSpyL1IDHandle);
260  iEvent.getByLabel(spyTotCountTag_,lSpyTotCountHandle);
261  iEvent.getByLabel(spyAPVeTag_,lSpyAPVeHandle);
262  */
263  iEvent.getByToken(spyL1Token_,lSpyL1IDHandle);
264  iEvent.getByToken(spyTotCountToken_,lSpyTotCountHandle);
265  iEvent.getByToken(spyAPVeToken_,lSpyAPVeHandle);
266  }
267  catch (const cms::Exception& e) {
268  LogError("SiStripSpyMonitorModule") << e.what() ;
269  return;
270  }
271  //const std::map<uint32_t,uint32_t> & lSpyMaxCountMap = *lSpyL1IDHandle;
272  //const std::map<uint32_t,uint32_t> & lSpyMinCountMap = *lSpyTotCountHandle;
273  const std::vector<uint32_t> & lSpyAPVeVec = *lSpyAPVeHandle;
274 
275  //retrieve the scope digis
277  try {
278  // iEvent.getByLabel(spyScopeRawDigisTag_, digisHandle);
279  iEvent.getByToken(spyScopeRawDigisToken_, digisHandle);
280  }
281  catch (const cms::Exception& e) {
282  LogError("SiStripSpyMonitorModule") << e.what() ;
283  return;
284  }
285  const edm::DetSetVector<SiStripRawDigi> * lInputDigis = digisHandle.product();
286 
287  //retrieve the reordered payload digis
289  try {
290  // iEvent.getByLabel(spyPedSubtrDigisTag_, payloadHandle);
291  iEvent.getByToken(spyPedSubtrDigisToken_, payloadHandle);
292  }
293  catch (const cms::Exception& e) {
294  LogError("SiStripSpyMonitorModule") << e.what() ;
295  return;
296  }
297  const edm::DetSetVector<SiStripRawDigi> * lPayloadDigis = payloadHandle.product();
298 
299 
300  //for first event only
301  //loop first on channels to calculate majority value of when the first header bit is found.
302  //output info message to give the value found
303  //should currently be 6 but may vary in the futur
304  //then we can check firstTrailerBit is +256+24 after
305 
306  if (firstEvent){
309  }
310 
311  //initialise some counters, filled in histos eventually
313  lCounters.nNoData = 0;
314  lCounters.nLowRange = 0;
315  lCounters.nHighRange = 0;
316  lCounters.nMinZero = 0;
317  lCounters.nMaxSat = 0;
318  lCounters.nLowPb = 0;
319  lCounters.nHighPb = 0;
320  lCounters.nOOS = 0;
321  lCounters.nOtherPbs = 0;
322  lCounters.nAPVError = 0;
323  lCounters.nAPVAddressError = 0;
324  lCounters.nNegPeds = 0;
325 
326 
327 
328  //fill event number for output text files
329  const unsigned int nFiles = outfileNames_.size();
330  for (unsigned int i(0); i<nFiles; i++){
331  outfile_[i] << "**** evt "<< iEvent.id().event() << " ****" << std::endl ;
332  }
333 
334 
335  //loop over all FEDs and channels
336 
337  for (uint16_t lFedId = sistrip::FED_ID_MIN; lFedId <= sistrip::FED_ID_MAX; ++lFedId) {//loop on feds
338 
339  SPYHistograms::Errors lFEDErrors;
340  lFEDErrors.hasNoData = false;
341  lFEDErrors.hasLowRange = false;
342  lFEDErrors.hasHighRange = false;
343  lFEDErrors.hasMinZero = false;
344  lFEDErrors.hasMaxSat = false;
345  lFEDErrors.hasLowPb = false;
346  lFEDErrors.hasHighPb = false;
347  lFEDErrors.hasOOS = false;
348  lFEDErrors.hasOtherPbs = false;
349  lFEDErrors.hasErrorBit0 = false;
350  lFEDErrors.hasErrorBit1 = false;
351  lFEDErrors.hasAPVAddressError0 = false;
352  lFEDErrors.hasAPVAddressError1 = false;
353  lFEDErrors.hasNegPeds = false;
354 
355  uint32_t lAPVAddrRef = lSpyAPVeVec.at(lFedId);
356 
357  for (uint16_t lFedChannel = 0; lFedChannel < sistrip::FEDCH_PER_FED; lFedChannel++){//loop on channels
358 
359  uint32_t lFedIndex = sistrip::FEDCH_PER_FED*lFedId + lFedChannel;
360 
361  const FedChannelConnection & lConnection = lCabling->fedConnection(lFedId,lFedChannel);
362 
363  if (!lConnection.isConnected()) continue;
364 
365  uint32_t lDetId = lConnection.detId();
366  //uint16_t lNPairs = lConnection.nApvPairs();
367  uint16_t lPair = lConnection.apvPairNumber();
368 
369  edm::DetSetVector<SiStripRawDigi>::const_iterator lDigis = lInputDigis->find(lFedIndex);
370 
371  //pedsubtr digis
372  edm::DetSetVector<SiStripRawDigi>::const_iterator lPayload = lPayloadDigis->find(lDetId);
373 
374  //no digis found, continue.
375  if (lDigis == lInputDigis->end()) {
376  LogDebug("SiStripSpyMonitorModule") << " -- digis not found in ScopeRawDigis map for FEDID "
377  << lFedId << " and FED channel " << lFedChannel << std::endl;
378  continue;
379  }
380 
382 
383  SPYHistograms::Errors lErrors;
384  lErrors.hasNoData = false;
385  lErrors.hasLowRange = false;
386  lErrors.hasHighRange = false;
387  lErrors.hasMinZero = false;
388  lErrors.hasMaxSat = false;
389  lErrors.hasLowPb = false;
390  lErrors.hasHighPb = false;
391  lErrors.hasOOS = false;
392  lErrors.hasOtherPbs = false;
393  lErrors.hasErrorBit0 = false;
394  lErrors.hasErrorBit1 = false;
395  lErrors.hasAPVAddressError0 = false;
396  lErrors.hasAPVAddressError1 = false;
397  lErrors.hasNegPeds = false;
398 
399  uint16_t lRange = sistrip::SpyUtilities::range(lFrame);
400  uint16_t lThreshold = sistrip::SpyUtilities::threshold(lFrame);
401 
402  if (lRange == 0) {
403  lCounters.nNoData++;
404  lErrors.hasNoData = true;
405  lFEDErrors.hasNoData = true;
406  if (outfileMap_.find("NoData") != outfileMap_.end()) outfile_[outfileMap_["NoData"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
407  }
408  else if (lFrame.digitalLow == 0 && lRange > 0) {
409  lCounters.nMinZero++;
410  lErrors.hasMinZero = true;
411  lFEDErrors.hasMinZero = true;
412  if (outfileMap_.find("MinZero") != outfileMap_.end()) outfile_[outfileMap_["MinZero"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
413  }
414  else if (lFrame.digitalHigh >= 1023){
415  lCounters.nMaxSat++;
416  lErrors.hasMaxSat = true;
417  lFEDErrors.hasMaxSat = true;
418  if (outfileMap_.find("MaxSat") != outfileMap_.end()) outfile_[outfileMap_["MaxSat"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
419  }
420  else if (lRange > 0 && lRange < frameQuality_.minDigiRange) {
421  lCounters.nLowRange++;
422  lErrors.hasLowRange = true;
423  lFEDErrors.hasLowRange = true;
424  if (outfileMap_.find("LowRange") != outfileMap_.end()) outfile_[outfileMap_["LowRange"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
425  }
426  else if (lRange > frameQuality_.maxDigiRange) {
427  lCounters.nHighRange++;
428  lErrors.hasHighRange = true;
429  lFEDErrors.hasHighRange = true;
430  if (outfileMap_.find("HighRange") != outfileMap_.end()) outfile_[outfileMap_["HighRange"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
431  }
433  lCounters.nLowPb++;
434  lErrors.hasLowPb = true;
435  lFEDErrors.hasLowPb = true;
436  if (outfileMap_.find("LowPb") != outfileMap_.end()) outfile_[outfileMap_["LowPb"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
437  }
439  lCounters.nHighPb++;
440  lErrors.hasHighPb = true;
441  lFEDErrors.hasHighPb = true;
442  if (outfileMap_.find("HighPb") != outfileMap_.end()) outfile_[outfileMap_["HighPb"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
443  }
444  else if ( lFrame.firstHeaderBit != firstHeaderBit_ && //header in wrong position
445  ( (lFrame.firstHeaderBit != sistrip::SPY_SAMPLES_PER_CHANNEL && //header and
446  lFrame.firstTrailerBit != sistrip::SPY_SAMPLES_PER_CHANNEL && //trailer found
447  lFrame.firstTrailerBit-lFrame.firstHeaderBit == 280) || //+ right distance between them
448  (lFrame.firstHeaderBit != sistrip::SPY_SAMPLES_PER_CHANNEL && // or header found
449  lFrame.firstTrailerBit == sistrip::SPY_SAMPLES_PER_CHANNEL && // and trailer not found
450  lFrame.firstHeaderBit > 16 ) || // corresponding to back-to-back frame late enough
451  (lFrame.firstHeaderBit == sistrip::SPY_SAMPLES_PER_CHANNEL && // or header not found
452  identifyTickmarks(*lDigis,lThreshold) ) // but such that tickmark compatible with OOS frame
453  )
454  ){
455  lCounters.nOOS++;
456  lErrors.hasOOS = true;
457  lFEDErrors.hasOOS = true;
458  if (outfileMap_.find("OOS") != outfileMap_.end()) outfile_[outfileMap_["OOS"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
459  }
460  else if ( !(lFrame.firstHeaderBit == firstHeaderBit_ && lFrame.firstTrailerBit == firstTrailerBit_) ){
461  lCounters.nOtherPbs++;
462  lErrors.hasOtherPbs = true;
463  lFEDErrors.hasOtherPbs = true;
464  if (outfileMap_.find("OtherPbs") != outfileMap_.end()) outfile_[outfileMap_["OtherPbs"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
465  }
466  else if (lFrame.apvErrorBit.first || lFrame.apvErrorBit.second) {
467  if (lFrame.apvErrorBit.first) {
468  lCounters.nAPVError++;
469  lErrors.hasErrorBit0 = true;
470  lFEDErrors.hasErrorBit0 = true;
471  }
472  if (lFrame.apvErrorBit.second) {
473  lCounters.nAPVError++;
474  lErrors.hasErrorBit1 = true;
475  lFEDErrors.hasErrorBit1 = true;
476  }
477  if (outfileMap_.find("APVError") != outfileMap_.end()) {
478  outfile_[outfileMap_["APVError"]] << lFedId << " " << lFedChannel << " " << lDetId ;
479  if (lFrame.apvErrorBit.first) outfile_[outfileMap_["APVError"]] << " APV0" << std::endl;
480  if (lFrame.apvErrorBit.second) outfile_[outfileMap_["APVError"]] << " APV1" << std::endl;
481  }
482  }
483  else if ( lFrame.apvAddress.first != lAPVAddrRef ||
484  lFrame.apvAddress.second != lAPVAddrRef ) {
485  if (lFrame.apvAddress.first != lAPVAddrRef){
486  lCounters.nAPVAddressError++;
487  lErrors.hasAPVAddressError0 = true;
488  lFEDErrors.hasAPVAddressError0 = true;
489  }
490  if (lFrame.apvAddress.second != lAPVAddrRef){
491  lCounters.nAPVAddressError++;
492  lErrors.hasAPVAddressError1 = true;
493  lFEDErrors.hasAPVAddressError1 = true;
494  }
495  if (outfileMap_.find("APVAddressError") != outfileMap_.end()){
496  outfile_[outfileMap_["APVAddressError"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
497  if (lFrame.apvAddress.first != lAPVAddrRef) outfile_[outfileMap_["APVAddressError"]] << " APV0" << std::endl;
498  if (lFrame.apvAddress.second != lAPVAddrRef) outfile_[outfileMap_["APVAddressError"]] << " APV1" << std::endl;
499  }
500  }
501  else if (lPayload != lPayloadDigis->end() && hasNegativePedSubtr(*lPayload,lPair)){
502  lCounters.nNegPeds++;
503  lErrors.hasNegPeds = true;
504  lFEDErrors.hasNegPeds = true;
505  if (outfileMap_.find("NegPeds") != outfileMap_.end()) outfile_[outfileMap_["NegPeds"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
506  }
507 
508  histManager_.fillDetailedHistograms(lErrors,lFrame,lFedId,lFedChannel);
509 
510  }//loop on channels
511 
512 
513  histManager_.fillFEDHistograms(lFEDErrors,lFedId);
514 
515  }//loop on feds
516 
517  double lTime;
518  //if (fillWithEvtNum_)
519  //lTime = iEvent.id().event();
520  //else if (fillWithLocalEvtNum_) lTime = evt_;
521  //no orbit number for spy data !!
522  //else lTime = iEvent.orbitNumber()/11223.;
523  lTime = iEvent.id().event();
524  if (fillWithLocalEvtNum_) lTime = evt_;
525 
526  histManager_.fillCountersHistograms(lCounters,lTime);
527 
528 
529  //used to fill histo vs time with local event number....
530  evt_++;
531  firstEvent = false;
532 
533 }//analyze method
#define LogDebug(id)
virtual char const * what() const
Definition: Exception.cc:141
EventNumber_t event() const
Definition: EventID.h:44
int i
Definition: DBlmapReader.cc:9
static const uint16_t FED_ID_MIN
iterator find(det_id_type id)
Definition: DetSetVector.h:292
FedChannelConnection fedConnection(uint16_t fed_id, uint16_t fed_ch) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
uint16_t apvPairNumber() const
bool identifyTickmarks(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold)
static const uint16_t SPY_SAMPLES_PER_CHANNEL
std::pair< uint8_t, uint8_t > apvAddress
bool hasNegativePedSubtr(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, uint16_t aPair)
edm::EDGetTokenT< std::vector< uint32_t > > spyAPVeToken_
void fillCountersHistograms(const ErrorCounters &aCounter, const double aTime)
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyPedSubtrDigisToken_
static const Frame extractFrameInfo(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, bool aPrintDebug=false)
const uint32_t & detId() const
std::map< std::string, unsigned int > outfileMap_
Class containning control, module, detector and connection information, at the level of a FED channel...
sistrip::SpyUtilities::FrameQuality frameQuality_
static const uint16_t range(const Frame &aFrame)
std::vector< std::string > outfileNames_
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyScopeRawDigisToken_
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:363
static const uint16_t threshold(const Frame &aFrame)
tuple out
Definition: dbtoconf.py:99
static const uint16_t STRIPS_PER_FEDCH
const SiStripFedCabling * getCabling(const edm::EventSetup &)
Updates the cabling object from the DB.
void fillFEDHistograms(const Errors &aErr, const unsigned int aFedId)
std::pair< bool, bool > apvErrorBit
T const * product() const
Definition: Handle.h:81
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
edm::EventID id() const
Definition: EventBase.h:56
static const uint16_t FEDCH_PER_FED
void fillDetailedHistograms(const Errors &aErr, const sistrip::SpyUtilities::Frame &aFrame, const unsigned int aFedId, const unsigned int aFedChannel)
static void getMajorityHeader(const edm::DetSetVector< SiStripRawDigi > *aInputDigis, uint16_t &firstHeaderBit, bool printResult=true)
static const uint16_t FED_ID_MAX
edm::EDGetTokenT< std::vector< uint32_t > > spyL1Token_
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:106
sistrip::SpyUtilities utility_
edm::EDGetTokenT< std::vector< uint32_t > > spyTotCountToken_
void SiStripSpyMonitorModule::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 202 of file SiStripSpyMonitorModule.cc.

References SPYHistograms::bookAllFEDHistograms(), SPYHistograms::bookTopLevelHistograms(), dqm_, evt_, fillAllDetailedHistograms_, firstHeaderBit_, firstTrailerBit_, folderName_, histManager_, DQMStore::pwd(), and DQMStore::setCurrentFolder().

203 {
204 
205  //get DQM store
208 
209  LogInfo("SiStripSpyMonitorModule") << " Histograms will be written in "
210  << folderName_
211  << ". Current folder is : "
212  << dqm_->pwd()
213  << std::endl;
214 
215  //this propagates dqm_ to the histoclass, must be called !
217 
219 
220  evt_ = 0;
221  firstHeaderBit_ = 0;
222  firstTrailerBit_ = 0;
223 }
void bookAllFEDHistograms()
void bookTopLevelHistograms(DQMStore *dqm)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
const std::string & pwd(void) const
Definition: DQMStore.cc:627
void SiStripSpyMonitorModule::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 539 of file SiStripSpyMonitorModule.cc.

References dqm_, dqmStoreFileName_, i, outfile_, outfileMap_, outfileNames_, DQMStore::save(), and writeDQMStore_.

540 {
541 
542  LogInfo("SiStripSpyMonitorModule") << "WriteDQMStore ? " << writeDQMStore_
543  << " file name = " << dqmStoreFileName_
544  << std::endl;
546 
547  const unsigned int nFiles = outfileNames_.size();
548  for (unsigned int i(0); i<nFiles; i++){
549  outfile_[i].close();
550  }
551 
552  outfileMap_.clear();
553  outfileNames_.clear();
554 
555 }
int i
Definition: DBlmapReader.cc:9
std::map< std::string, unsigned int > outfileMap_
std::vector< std::string > outfileNames_
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE", const bool resetMEsAfterWriting=false)
Definition: DQMStore.cc:2490
edm::DetSetVector< SiStripRawDigi >::detset::const_iterator SiStripSpyMonitorModule::findTwoConsecutive ( const edm::DetSetVector< SiStripRawDigi >::detset &  channelDigis,
const uint16_t  threshold,
uint16_t &  aCounter 
)
private

Definition at line 611 of file SiStripSpyMonitorModule.cc.

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

Referenced by identifyTickmarks().

614 {
615  const edm::DetSetVector<SiStripRawDigi>::detset::const_iterator endChannelDigis = channelDigis.end();
616  edm::DetSetVector<SiStripRawDigi>::detset::const_iterator lStart = channelDigis.begin()+aCounter;
617 
618  bool foundTrailer = false;
619  // Loop over digis looking for last two above threshold
620  uint8_t aboveThreshold = 0;
621 
622  for (; lStart != endChannelDigis; ++lStart) {
623  if ( lStart->adc() > threshold) {
624  aboveThreshold++;
625  }
626  else {
627  aboveThreshold = 0;
628  }
629  if (aboveThreshold == 2) {foundTrailer = true; break; }
630  aCounter++;
631  }//end of loop over digis
632 
633  if (foundTrailer) return lStart;
634  else {
636  return endChannelDigis;
637  }
638 }
iterator end()
Definition: DetSet.h:60
static const uint16_t SPY_SAMPLES_PER_CHANNEL
iterator begin()
Definition: DetSet.h:59
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
bool SiStripSpyMonitorModule::hasNegativePedSubtr ( const edm::DetSetVector< SiStripRawDigi >::detset &  channelDigis,
uint16_t  aPair 
)
private

Definition at line 559 of file SiStripSpyMonitorModule.cc.

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

Referenced by analyze().

561 {
563  const edm::DetSetVector<SiStripRawDigi>::detset::const_iterator endChannelDigis = channelDigis.end();
564 
565  uint32_t count = 0;
566  for (; iDigi != endChannelDigis; ++iDigi) {
567  const uint16_t val = iDigi->adc();
568  uint16_t lPair = static_cast<uint16_t>(count/sistrip::STRIPS_PER_FEDCH);
569  if (val == 0 && lPair == aPair) return true;
570  count++;
571  }
572 
573  return false;
574 
575 }
iterator end()
Definition: DetSet.h:60
iterator begin()
Definition: DetSet.h:59
static const uint16_t STRIPS_PER_FEDCH
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
bool SiStripSpyMonitorModule::identifyTickmarks ( const edm::DetSetVector< SiStripRawDigi >::detset &  channelDigis,
const uint16_t  threshold 
)
private

Definition at line 577 of file SiStripSpyMonitorModule.cc.

References prof2calltree::count, edm::DetSet< T >::detId(), edm::DetSet< T >::end(), evt_, findTwoConsecutive(), LogDebug, and sistrip::SPY_SAMPLES_PER_CHANNEL.

Referenced by analyze().

579 {
580 
581  //start from the end
583  uint16_t lastPos = sistrip::SPY_SAMPLES_PER_CHANNEL;
584  uint16_t nTrailers = 0;
586 
587  for ( ; count == 0; count--){
588  iDigi = findTwoConsecutive(channelDigis,threshold,count);
589  //if found, in different position = 70 before than previous value, go and look 70 before
590  if (iDigi != channelDigis.end() &&
591  (lastPos == sistrip::SPY_SAMPLES_PER_CHANNEL || count == lastPos+1-70)) {
592  nTrailers++;
593  lastPos = count-1;
594  count -= 70;
595  }
596  //else keep looking
597  else count--;
598  }
599 
600  if (nTrailers > 1) LogDebug("SiStripSpyMonitorModule") << " -- Found "
601  << nTrailers << " trailers every 70 clock cycles for channel "
602  << channelDigis.detId()
603  << ", evt " << evt_
604  << std::endl;
605  //if only one found, should be < 280 otherwise header should have been found and this method would not be called
606  return (nTrailers > 1) || (nTrailers == 1 && lastPos < 280);
607 
608 }
#define LogDebug(id)
iterator end()
Definition: DetSet.h:60
edm::DetSetVector< SiStripRawDigi >::detset::const_iterator findTwoConsecutive(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold, uint16_t &aCounter)
det_id_type detId() const
Definition: DetSet.h:72
static const uint16_t SPY_SAMPLES_PER_CHANNEL
collection_type::const_iterator const_iterator
Definition: DetSet.h:33

Member Data Documentation

DQMStore* SiStripSpyMonitorModule::dqm_
private

Definition at line 104 of file SiStripSpyMonitorModule.cc.

Referenced by beginJob(), and endJob().

std::string SiStripSpyMonitorModule::dqmStoreFileName_
private

Definition at line 114 of file SiStripSpyMonitorModule.cc.

Referenced by endJob().

unsigned int SiStripSpyMonitorModule::evt_
private
bool SiStripSpyMonitorModule::fillAllDetailedHistograms_
private

Definition at line 108 of file SiStripSpyMonitorModule.cc.

Referenced by beginJob().

bool SiStripSpyMonitorModule::fillWithEvtNum_
private

Definition at line 110 of file SiStripSpyMonitorModule.cc.

bool SiStripSpyMonitorModule::fillWithLocalEvtNum_
private

Definition at line 111 of file SiStripSpyMonitorModule.cc.

Referenced by analyze().

uint16_t SiStripSpyMonitorModule::firstHeaderBit_
private

Definition at line 117 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and beginJob().

uint16_t SiStripSpyMonitorModule::firstTrailerBit_
private

Definition at line 118 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and beginJob().

std::string SiStripSpyMonitorModule::folderName_
private

Definition at line 106 of file SiStripSpyMonitorModule.cc.

Referenced by beginJob().

sistrip::SpyUtilities::FrameQuality SiStripSpyMonitorModule::frameQuality_
private

Definition at line 121 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and SiStripSpyMonitorModule().

SPYHistograms SiStripSpyMonitorModule::histManager_
private

Definition at line 116 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), beginJob(), and SiStripSpyMonitorModule().

uint32_t SiStripSpyMonitorModule::maxDigiRange_
private

Definition at line 96 of file SiStripSpyMonitorModule.cc.

uint32_t SiStripSpyMonitorModule::maxDigitalHigh_
private

Definition at line 100 of file SiStripSpyMonitorModule.cc.

uint32_t SiStripSpyMonitorModule::maxDigitalLow_
private

Definition at line 98 of file SiStripSpyMonitorModule.cc.

uint32_t SiStripSpyMonitorModule::minDigiRange_
private

Definition at line 95 of file SiStripSpyMonitorModule.cc.

uint32_t SiStripSpyMonitorModule::minDigitalHigh_
private

Definition at line 99 of file SiStripSpyMonitorModule.cc.

uint32_t SiStripSpyMonitorModule::minDigitalLow_
private

Definition at line 97 of file SiStripSpyMonitorModule.cc.

std::ofstream SiStripSpyMonitorModule::outfile_[20]
private
std::map<std::string,unsigned int> SiStripSpyMonitorModule::outfileMap_
private
std::vector<std::string> SiStripSpyMonitorModule::outfileNames_
private
edm::InputTag SiStripSpyMonitorModule::spyAPVeTag_
private

Definition at line 88 of file SiStripSpyMonitorModule.cc.

Referenced by SiStripSpyMonitorModule().

edm::EDGetTokenT<std::vector<uint32_t> > SiStripSpyMonitorModule::spyAPVeToken_
private

Definition at line 92 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and SiStripSpyMonitorModule().

edm::InputTag SiStripSpyMonitorModule::spyL1Tag_
private

Definition at line 86 of file SiStripSpyMonitorModule.cc.

Referenced by SiStripSpyMonitorModule().

edm::EDGetTokenT<std::vector<uint32_t> > SiStripSpyMonitorModule::spyL1Token_
private

Definition at line 90 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and SiStripSpyMonitorModule().

edm::InputTag SiStripSpyMonitorModule::spyPedSubtrDigisTag_
private

Definition at line 79 of file SiStripSpyMonitorModule.cc.

Referenced by SiStripSpyMonitorModule().

edm::EDGetTokenT<edm::DetSetVector<SiStripRawDigi> > SiStripSpyMonitorModule::spyPedSubtrDigisToken_
private

Definition at line 82 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and SiStripSpyMonitorModule().

edm::InputTag SiStripSpyMonitorModule::spyScopeRawDigisTag_
private

Definition at line 78 of file SiStripSpyMonitorModule.cc.

Referenced by SiStripSpyMonitorModule().

edm::EDGetTokenT<edm::DetSetVector<SiStripRawDigi> > SiStripSpyMonitorModule::spyScopeRawDigisToken_
private

Definition at line 81 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and SiStripSpyMonitorModule().

edm::InputTag SiStripSpyMonitorModule::spyTotCountTag_
private

Definition at line 87 of file SiStripSpyMonitorModule.cc.

Referenced by SiStripSpyMonitorModule().

edm::EDGetTokenT<std::vector<uint32_t> > SiStripSpyMonitorModule::spyTotCountToken_
private

Definition at line 91 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and SiStripSpyMonitorModule().

sistrip::SpyUtilities SiStripSpyMonitorModule::utility_
private

Definition at line 120 of file SiStripSpyMonitorModule.cc.

Referenced by analyze().

bool SiStripSpyMonitorModule::writeCabling_
private

Definition at line 127 of file SiStripSpyMonitorModule.cc.

Referenced by analyze().

bool SiStripSpyMonitorModule::writeDQMStore_
private

Definition at line 113 of file SiStripSpyMonitorModule.cc.

Referenced by endJob().