CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
SiStripFEDMonitorPlugin Class Reference

#include <DQM/SiStripMonitorHardware/plugins/SiStripFEDMonitor.cc>

Inheritance diagram for SiStripFEDMonitorPlugin:
DQMOneEDAnalyzer< edm::LuminosityBlockCache< sifedmon::LumiErrors > > edm::one::EDProducer< edm::EndRunProducer, edm::one::WatchRuns, edm::Accumulator, Args... > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 SiStripFEDMonitorPlugin (const edm::ParameterSet &)
 
 ~SiStripFEDMonitorPlugin () override
 
- Public Member Functions inherited from DQMOneEDAnalyzer< edm::LuminosityBlockCache< sifedmon::LumiErrors > >
void accumulate (edm::Event const &event, edm::EventSetup const &setup) override
 
void beginRun (edm::Run const &run, edm::EventSetup const &setup) final
 
 DQMOneEDAnalyzer ()
 
void endRun (edm::Run const &, edm::EventSetup const &) final
 
void endRunProduce (edm::Run &run, edm::EventSetup const &setup) final
 
virtual bool getCanSaveByLumi ()
 
- Public Member Functions inherited from edm::one::EDProducer< edm::EndRunProducer, edm::one::WatchRuns, edm::Accumulator, Args... >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 
void getMajority (const std::vector< std::pair< unsigned int, unsigned int > > &aFeMajVec, unsigned int &aMajorityCounter, std::vector< unsigned int > &afedIds)
 
std::shared_ptr< sifedmon::LumiErrorsglobalBeginLuminosityBlock (const edm::LuminosityBlock &lumi, const edm::EventSetup &iSetup) const override
 
void globalEndLuminosityBlock (const edm::LuminosityBlock &lumi, const edm::EventSetup &iSetup) override
 
void updateCabling (const SiStripFedCablingRcd &cablingRcd)
 

Static Private Member Functions

static bool pairComparison (const std::pair< unsigned int, unsigned int > &pair1, const std::pair< unsigned int, unsigned int > &pair2)
 

Private Attributes

const SiStripFedCablingcabling_
 
bool doFEMajorityCheck_
 
bool doMedHists_
 
bool doTkHistoMap_
 
bool enableFEDerrLumi_
 
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcdfedCablingToken_
 
edm::ESWatcher< SiStripFedCablingRcdfedCablingWatcher_
 
FEDErrors fedErrors_
 
FEDHistograms fedHists_
 
bool fillAllDetailedHistograms_
 
bool fillWithEvtNum_
 
std::string folderName_
 
bool fullDebugMode_
 
edm::EDGetTokenT< EventWithHistoryheToken_
 
MonitorElementlumiErrfac_
 
unsigned int maxFedBufferSize_
 
unsigned int nEvt_
 
unsigned int printDebug_
 
edm::InputTag rawDataTag_
 
edm::EDGetTokenT< FEDRawDataCollectionrawDataToken_
 
edm::ESGetToken< TkDetMap, TrackerTopologyRcdtkDetMapToken_
 
std::string topFolderName_
 
edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtTopoToken_
 

Additional Inherited Members

- Public Types inherited from DQMOneEDAnalyzer< edm::LuminosityBlockCache< sifedmon::LumiErrors > >
typedef dqm::reco::DQMStore DQMStore
 
typedef dqm::reco::MonitorElement MonitorElement
 
- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from DQMOneEDAnalyzer< edm::LuminosityBlockCache< sifedmon::LumiErrors > >
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
virtual void dqmEndRun (edm::Run const &, edm::EventSetup const &)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 
- Protected Attributes inherited from DQMOneEDAnalyzer< edm::LuminosityBlockCache< sifedmon::LumiErrors > >
edm::EDPutTokenT< DQMTokenrunToken_
 

Detailed Description

Description: DQM source application to produce data integrety histograms for SiStrip data

Definition at line 69 of file SiStripFEDMonitor.cc.

Constructor & Destructor Documentation

◆ SiStripFEDMonitorPlugin()

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

Definition at line 139 of file SiStripFEDMonitor.cc.

References doFEMajorityCheck_, doMedHists_, doTkHistoMap_, enableFEDerrLumi_, edm::ParameterSet::exists(), fedHists_, fillAllDetailedHistograms_, fillWithEvtNum_, folderName_, edm::ParameterSet::getUntrackedParameter(), heToken_, ProducerED_cfi::InputTag, LogTrace, nEvt_, printDebug_, rawDataTag_, rawDataToken_, AlCaHLTBitMon_QueryRunRegistry::string, and topFolderName_.

140  : rawDataTag_(iConfig.getUntrackedParameter<edm::InputTag>("RawDataTag", edm::InputTag("source", ""))),
141  topFolderName_(iConfig.getUntrackedParameter<std::string>("TopFolderName", "SiStrip")),
142  fillAllDetailedHistograms_(iConfig.getUntrackedParameter<bool>("FillAllDetailedHistograms", false)),
143  fillWithEvtNum_(iConfig.getUntrackedParameter<bool>("FillWithEventNumber", false)),
144  printDebug_(iConfig.getUntrackedParameter<unsigned int>("PrintDebugMessages", 1)),
146  fedCablingToken_(esConsumes<>()),
147  tTopoToken_(esConsumes<>()),
148  tkDetMapToken_(esConsumes<edm::Transition::BeginRun>()),
150  fullDebugMode_(iConfig.getUntrackedParameter<bool>("FullDebugMode", false)) {
151  std::string subFolderName = iConfig.getUntrackedParameter<std::string>("HistogramFolderName", "ReadoutView");
152  folderName_ = topFolderName_ + "/" + subFolderName;
153 
154  rawDataToken_ = consumes<FEDRawDataCollection>(rawDataTag_);
155  heToken_ = consumes<EventWithHistory>(edm::InputTag("consecutiveHEs"));
156 
157  if (iConfig.exists("ErrorFractionByLumiBlockHistogramConfig")) {
158  const edm::ParameterSet& ps =
159  iConfig.getUntrackedParameter<edm::ParameterSet>("ErrorFractionByLumiBlockHistogramConfig");
160  enableFEDerrLumi_ = (ps.exists("Enabled") ? ps.getUntrackedParameter<bool>("Enabled") : true);
161  }
162  //print config to debug log
163  std::ostringstream debugStream;
164  if (printDebug_ > 1) {
165  debugStream << "[SiStripFEDMonitorPlugin]Configuration for SiStripFEDMonitorPlugin: " << std::endl
166  << "[SiStripFEDMonitorPlugin]\tRawDataTag: " << rawDataTag_ << std::endl
167  << "[SiStripFEDMonitorPlugin]\tHistogramFolderName: " << folderName_ << std::endl
168  << "[SiStripFEDMonitorPlugin]\tFillAllDetailedHistograms? "
169  << (fillAllDetailedHistograms_ ? "yes" : "no") << std::endl
170  << "[SiStripFEDMonitorPlugin]\tFillWithEventNumber?" << (fillWithEvtNum_ ? "yes" : "no") << std::endl
171  << "[SiStripFEDMonitorPlugin]\tPrintDebugMessages? " << (printDebug_ ? "yes" : "no") << std::endl;
172  }
173 
174  //don;t generate debug mesages if debug is disabled
175  std::ostringstream* pDebugStream = (printDebug_ > 1 ? &debugStream : nullptr);
176 
177  fedHists_.initialise(iConfig, pDebugStream);
178 
179  doTkHistoMap_ = fedHists_.tkHistoMapEnabled();
180 
181  doMedHists_ = fedHists_.cmHistosEnabled();
182 
183  doFEMajorityCheck_ = fedHists_.feMajHistosEnabled();
184 
185  if (printDebug_) {
186  LogTrace("SiStripMonitorHardware") << debugStream.str();
187  }
188 
189  nEvt_ = 0;
190 }
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
void updateCabling(const SiStripFedCablingRcd &cablingRcd)
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
#define LogTrace(id)
T getUntrackedParameter(std::string const &, T const &) const
edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapToken_
edm::ESWatcher< SiStripFedCablingRcd > fedCablingWatcher_
edm::EDGetTokenT< EventWithHistory > heToken_
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_

◆ ~SiStripFEDMonitorPlugin()

SiStripFEDMonitorPlugin::~SiStripFEDMonitorPlugin ( )
override

Definition at line 192 of file SiStripFEDMonitor.cc.

192 {}

Member Function Documentation

◆ analyze()

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

Reimplemented from DQMOneEDAnalyzer< edm::LuminosityBlockCache< sifedmon::LumiErrors > >.

Definition at line 199 of file SiStripFEDMonitor.cc.

References SplitLinear::begin, cabling_, edm::ESWatcher< T >::check(), doFEMajorityCheck_, doMedHists_, doTkHistoMap_, relativeConstraints::empty, mps_fire::end, fedCablingWatcher_, FEDRawDataCollection::FEDData(), fedErrors_, fedHists_, l1tstage2_dqm_sourceclient-live_cfg::fedId, fillWithEvtNum_, fullDebugMode_, edm::EventSetup::getData(), getMajority(), Hcal_Conditions_forGlobalTag_cff::he, heToken_, iEvent, maxFedBufferSize_, FEDNumbering::MAXSiStripFEDID, FEDNumbering::MINSiStripFEDID, nEvt_, pairComparison(), printDebug_, rawDataToken_, FEDRawData::size(), findQualityFiles::size, jetUpdater_cfi::sort, and tTopoToken_.

199  {
200  const auto tTopo = &iSetup.getData(tTopoToken_);
201  fedCablingWatcher_.check(iSetup);
202 
203  //get raw data
204  edm::Handle<FEDRawDataCollection> rawDataCollectionHandle;
205  iEvent.getByToken(rawDataToken_, rawDataCollectionHandle);
206  const FEDRawDataCollection& rawDataCollection = *rawDataCollectionHandle;
207 
208  fedErrors_.initialiseEvent();
209 
210  //add the deltaBX value if the product exist
211 
213  iEvent.getByToken(heToken_, he);
214 
215  //get the fedErrors object for each LS
216  auto lumiErrors = luminosityBlockCache(iEvent.getLuminosityBlock().index());
217  auto& nToterr = lumiErrors->nTotal;
218  auto& nErr = lumiErrors->nErrors;
219 
220  if (he.isValid() && !he.failedToGet()) {
221  fedErrors_.fillEventProperties(he->deltaBX());
222  }
223 
224  //initialise map of fedId/bad channel number
225  std::map<unsigned int, std::pair<unsigned short, unsigned short> > badChannelFraction;
226 
227  unsigned int lNFEDMonitoring = 0;
228  unsigned int lNFEDUnpacker = 0;
229  unsigned int lNChannelMonitoring = 0;
230  unsigned int lNChannelUnpacker = 0;
231 
232  unsigned int lNTotBadFeds = 0;
233  unsigned int lNTotBadChannels = 0;
234  unsigned int lNTotBadActiveChannels = 0;
235 
236  std::vector<std::vector<std::pair<unsigned int, unsigned int> > > lFeMajFrac;
237  const unsigned int nParts = 4;
238  if (doFEMajorityCheck_) {
239  lFeMajFrac.resize(nParts);
240  //max nFE per partition
241  lFeMajFrac[0].reserve(912);
242  lFeMajFrac[1].reserve(1080);
243  lFeMajFrac[2].reserve(768);
244  lFeMajFrac[3].reserve(760);
245  }
246 
247  maxFedBufferSize_ = 0;
248 
249  //loop over siStrip FED IDs
251  fedId++) { //loop over FED IDs
252  unsigned int lNBadChannels_perFEDID = 0;
253  const FEDRawData& fedData = rawDataCollection.FEDData(fedId);
254 
255  //create an object to fill all errors
256  fedErrors_.initialiseFED(fedId, cabling_, tTopo);
257 
258  double aLumiSection = iEvent.orbitNumber() / 262144.0;
259 
260  //Do detailed check
261  //first check if data exists
262  bool lDataExist = fedErrors_.checkDataPresent(fedData);
263  if (!lDataExist) {
264  fedHists_.fillFEDHistograms(fedErrors_, 0, fullDebugMode_, aLumiSection, lNBadChannels_perFEDID);
265  continue;
266  }
267 
268  //check for problems and fill detailed histograms
269  fedErrors_.fillFEDErrors(fedData,
271  printDebug_,
272  lNChannelMonitoring,
273  lNChannelUnpacker,
274  doMedHists_,
275  fedHists_.cmHistPointer(false),
276  fedHists_.cmHistPointer(true),
278  lFeMajFrac);
279 
280  //check filled in previous method.
281  bool lFailUnpackerFEDcheck = fedErrors_.failUnpackerFEDCheck();
282 
283  fedErrors_.incrementFEDCounters();
284  unsigned int lSize = fedData.size();
285  if (lSize > maxFedBufferSize_) {
286  maxFedBufferSize_ = lSize;
287  }
288  //std::cout << " -- " << fedId << " " << lSize << std::endl;
289 
290  //fedHists_.fillFEDHistograms(fedErrors_,lSize,fullDebugMode_);
291 
292  bool lFailMonitoringFEDcheck = fedErrors_.failMonitoringFEDCheck();
293  if (lFailMonitoringFEDcheck)
294  lNTotBadFeds++;
295 
296  //sanity check: if something changed in the unpacking code
297  //but wasn't propagated here
298  //print only the summary, and more info if printDebug>1
299  if (lFailMonitoringFEDcheck != lFailUnpackerFEDcheck) {
300  if (printDebug_ > 1) {
301  std::ostringstream debugStream;
302  debugStream << " --- WARNING: FED " << fedId << std::endl << " ------ Monitoring FED check ";
303  if (lFailMonitoringFEDcheck)
304  debugStream << "failed." << std::endl;
305  else
306  debugStream << "passed." << std::endl;
307  debugStream << " ------ Unpacker FED check ";
308  if (lFailUnpackerFEDcheck)
309  debugStream << "failed." << std::endl;
310  else
311  debugStream << "passed." << std::endl;
312  edm::LogError("SiStripMonitorHardware") << debugStream.str();
313  }
314 
315  if (lFailMonitoringFEDcheck)
316  lNFEDMonitoring++;
317  else if (lFailUnpackerFEDcheck)
318  lNFEDUnpacker++;
319  }
320 
321  //Fill TkHistoMap:
322  //add an entry for all channels (good = 0),
323  //so that tkHistoMap knows which channels should be there.
324  if (doTkHistoMap_ && !fedHists_.tkHistoMapPointer()) {
325  edm::LogWarning("SiStripMonitorHardware")
326  << " -- Fedid " << fedId << ", TkHistoMap enabled but pointer is null." << std::endl;
327  }
328 
329  fedErrors_.fillBadChannelList(doTkHistoMap_,
330  fedHists_.tkHistoMapPointer(),
331  fedHists_.getFedvsAPVpointer(),
332  lNTotBadChannels,
333  lNTotBadActiveChannels,
334  lNBadChannels_perFEDID,
335  nToterr,
336  nErr);
337  fedHists_.fillFEDHistograms(fedErrors_, lSize, fullDebugMode_, aLumiSection, lNBadChannels_perFEDID);
338  } //loop over FED IDs
339 
340  if (doFEMajorityCheck_) {
341  for (unsigned int iP(0); iP < nParts; ++iP) {
342  //std::cout << " -- Partition " << iP << std::endl;
343  //std::cout << " --- Number of elements in vec = " << lFeMajFrac[iP].size() << std::endl;
344  if (lFeMajFrac[iP].empty())
345  continue;
346  std::sort(lFeMajFrac[iP].begin(), lFeMajFrac[iP].end(), SiStripFEDMonitorPlugin::pairComparison);
347 
348  unsigned int lMajorityCounter = 0;
349  std::vector<unsigned int> lfedIds;
350 
351  getMajority(lFeMajFrac[iP], lMajorityCounter, lfedIds);
352  //std::cout << " -- Found " << lfedIds.size() << " unique elements not matching the majority." << std::endl;
353  fedHists_.fillMajorityHistograms(iP, static_cast<float>(lMajorityCounter) / lFeMajFrac[iP].size(), lfedIds);
354  }
355  }
356 
357  if ((lNTotBadFeds > 0 || lNTotBadChannels > 0) && printDebug_ > 1) {
358  std::ostringstream debugStream;
359  debugStream << "[SiStripFEDMonitorPlugin] --- Total number of bad feds = " << lNTotBadFeds << std::endl
360  << "[SiStripFEDMonitorPlugin] --- Total number of bad channels = " << lNTotBadChannels << std::endl
361  << "[SiStripFEDMonitorPlugin] --- Total number of bad active channels = " << lNTotBadActiveChannels
362  << std::endl;
363  edm::LogInfo("SiStripMonitorHardware") << debugStream.str();
364  }
365 
366  if ((lNFEDMonitoring > 0 || lNFEDUnpacker > 0 || lNChannelMonitoring > 0 || lNChannelUnpacker > 0) && printDebug_) {
367  std::ostringstream debugStream;
368  debugStream
369  << "[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------"
370  << std::endl
371  << "[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------"
372  << std::endl
373  << "[SiStripFEDMonitorPlugin]-- Summary of differences between unpacker and monitoring at FED level : "
374  << std::endl
375  << "[SiStripFEDMonitorPlugin] ---- Number of times monitoring fails but not unpacking = " << lNFEDMonitoring
376  << std::endl
377  << "[SiStripFEDMonitorPlugin] ---- Number of times unpacking fails but not monitoring = " << lNFEDUnpacker
378  << std::endl
379  << "[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------"
380  << std::endl
381  << "[SiStripFEDMonitorPlugin]-- Summary of differences between unpacker and monitoring at Channel level : "
382  << std::endl
383  << "[SiStripFEDMonitorPlugin] ---- Number of times monitoring fails but not unpacking = " << lNChannelMonitoring
384  << std::endl
385  << "[SiStripFEDMonitorPlugin] ---- Number of times unpacking fails but not monitoring = " << lNChannelUnpacker
386  << std::endl
387  << "[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------"
388  << std::endl
389  << "[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------"
390  << std::endl;
391  edm::LogError("SiStripMonitorHardware") << debugStream.str();
392  }
393 
394  fedErrors_.getFEDErrorsCounters().nTotalBadChannels = lNTotBadChannels;
395  fedErrors_.getFEDErrorsCounters().nTotalBadActiveChannels = lNTotBadActiveChannels;
396 
397  //time in seconds since beginning of the run or event number
398  if (fillWithEvtNum_) {
399  // explicitely casting the event number unsigned long long to double here
400  double eventNumber = static_cast<double>(iEvent.id().event());
401  fedHists_.fillCountersHistograms(
402  fedErrors_.getFEDErrorsCounters(), fedErrors_.getChannelErrorsCounters(), maxFedBufferSize_, eventNumber);
403  } else {
404  double aTime = iEvent.orbitNumber() / 11223.;
405  fedHists_.fillCountersHistograms(
406  fedErrors_.getFEDErrorsCounters(), fedErrors_.getChannelErrorsCounters(), maxFedBufferSize_, aTime);
407  }
408 
409  nEvt_++;
410 
411 } //analyze method
size
Write out results.
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const SiStripFedCabling * cabling_
void getMajority(const std::vector< std::pair< unsigned int, unsigned int > > &aFeMajVec, unsigned int &aMajorityCounter, std::vector< unsigned int > &afedIds)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:48
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
Log< level::Error, false > LogError
int iEvent
Definition: GenABIO.cc:224
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Log< level::Info, false > LogInfo
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
static bool pairComparison(const std::pair< unsigned int, unsigned int > &pair1, const std::pair< unsigned int, unsigned int > &pair2)
edm::ESWatcher< SiStripFedCablingRcd > fedCablingWatcher_
Log< level::Warning, false > LogWarning
edm::EDGetTokenT< EventWithHistory > heToken_

◆ bookHistograms()

void SiStripFEDMonitorPlugin::bookHistograms ( DQMStore::IBooker ibooker,
edm::Run const &  run,
edm::EventSetup const &  eSetup 
)
overrideprivatevirtual

Implements DQMOneEDAnalyzer< edm::LuminosityBlockCache< sifedmon::LumiErrors > >.

Definition at line 481 of file SiStripFEDMonitor.cc.

References dqm::implementation::IBooker::book1D(), dqm::implementation::NavigatorBase::cd(), enableFEDerrLumi_, fedHists_, fillAllDetailedHistograms_, folderName_, fullDebugMode_, edm::EventSetup::getData(), lumiErrfac_, dqm::impl::MonitorElement::setAxisTitle(), dqm::impl::MonitorElement::setBinLabel(), dqm::implementation::NavigatorBase::setCurrentFolder(), and tkDetMapToken_.

483  {
484  ibooker.setCurrentFolder(folderName_);
485 
486  const auto tkDetMap = &eSetup.getData(tkDetMapToken_);
487  fedHists_.bookTopLevelHistograms(ibooker, tkDetMap);
488 
490  fedHists_.bookAllFEDHistograms(ibooker, fullDebugMode_);
491 
492  if (enableFEDerrLumi_) {
493  ibooker.cd();
494  ibooker.setCurrentFolder("SiStrip/ReadoutView/PerLumiSection");
495  {
496  auto scope = DQMStore::IBooker::UseRunScope(ibooker);
497  lumiErrfac_ =
498  ibooker.book1D("lumiErrorFraction", "Fraction of error per lumi section vs subdetector", 6, 0.5, 6.5);
499  lumiErrfac_->setAxisTitle("SubDetId", 1);
500  lumiErrfac_->setBinLabel(1, "TECB");
501  lumiErrfac_->setBinLabel(2, "TECF");
502  lumiErrfac_->setBinLabel(3, "TIB");
503  lumiErrfac_->setBinLabel(4, "TIDB");
504  lumiErrfac_->setBinLabel(5, "TIDF");
505  lumiErrfac_->setBinLabel(6, "TOB");
506  }
507  } else {
508  lumiErrfac_ = nullptr;
509  }
510 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
MonitorElement * lumiErrfac_
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapToken_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
UseScope< MonitorElementData::Scope::RUN > UseRunScope
Definition: DQMStore.h:550
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)

◆ getMajority()

void SiStripFEDMonitorPlugin::getMajority ( const std::vector< std::pair< unsigned int, unsigned int > > &  aFeMajVec,
unsigned int &  aMajorityCounter,
std::vector< unsigned int > &  afedIds 
)
private

Definition at line 418 of file SiStripFEDMonitor.cc.

References gather_cfg::cout, jetUpdater_cfi::sort, and tier0::unique().

Referenced by analyze().

420  {
421  unsigned int lMajAddress = 0;
422  std::vector<std::pair<unsigned int, unsigned int> >::const_iterator lIter = aFeMajVec.begin();
423  unsigned int lMajAddr = (*lIter).second;
424  unsigned int lCounter = 0;
425 
426  //std::cout << " --- First element: addr = " << lMajAddr << " counter = " << lCounter << std::endl;
427  unsigned int iele = 0;
428  //bool foundMaj = false;
429  for (; lIter != aFeMajVec.end(); ++lIter, ++iele) {
430  //std::cout << " ---- Ele " << iele << " " << (*lIter).first << " " << (*lIter).second << " ref " << lMajAddr << std::endl;
431  if ((*lIter).second == lMajAddr) {
432  ++lCounter;
433  //std::cout << " ----- =ref: Counter = " << lCounter << std::endl;
434  } else {
435  //std::cout << " ----- !=ref: Counter = " << lCounter << " Majority = " << aMajorityCounter << std::endl;
436  if (lCounter > aMajorityCounter) {
437  //std::cout << " ------ >Majority: " << std::endl;
438  aMajorityCounter = lCounter;
439  // AV bug here??
440  lMajAddress = lMajAddr;
441  // lMajAddress = (*lIter).second;
442  //foundMaj=true;
443  }
444  lCounter = 0;
445  lMajAddr = (*lIter).second;
446  --lIter;
447  --iele;
448  }
449  }
450  // AV Bug here? The check has to be done regardless foundMaj == false or true
451  // if (!foundMaj) {
452  if (lCounter > aMajorityCounter) {
453  //std::cout << " ------ >Majority: " << std::endl;
454  aMajorityCounter = lCounter;
455  lMajAddress = lMajAddr;
456  }
457  // }
458  //std::cout << " -- found majority value for " << aMajorityCounter << " elements out of " << aFeMajVec.size() << "." << std::endl;
459  //get list of feds with address different from majority in partition:
460  lIter = aFeMajVec.begin();
461  afedIds.reserve(135);
462  for (; lIter != aFeMajVec.end(); ++lIter) {
463  if ((*lIter).second != lMajAddress) {
464  afedIds.push_back((*lIter).first);
465  } else {
466  lIter += aMajorityCounter - 1;
467  if (lIter >= aFeMajVec.end()) {
468  std::cout << "Here it is a bug: " << aMajorityCounter << " " << aFeMajVec.size() << " "
469  << lIter - aFeMajVec.end() << std::endl;
470  }
471  }
472  }
473  //std::cout << " -- Found " << lfedIds.size() << " elements not matching the majority." << std::endl;
474  if (!afedIds.empty()) {
475  std::sort(afedIds.begin(), afedIds.end());
476  std::vector<unsigned int>::iterator lIt = std::unique(afedIds.begin(), afedIds.end());
477  afedIds.erase(lIt, afedIds.end());
478  }
479 }
def unique(seq, keepstr=True)
Definition: tier0.py:24

◆ globalBeginLuminosityBlock()

std::shared_ptr< sifedmon::LumiErrors > SiStripFEDMonitorPlugin::globalBeginLuminosityBlock ( const edm::LuminosityBlock lumi,
const edm::EventSetup iSetup 
) const
overrideprivate

Definition at line 512 of file SiStripFEDMonitor.cc.

513  {
514  auto lumiErrors = std::make_shared<sifedmon::LumiErrors>();
515  lumiErrors->nTotal.resize(6, 0);
516  lumiErrors->nErrors.resize(6, 0);
517  return lumiErrors;
518 }

◆ globalEndLuminosityBlock()

void SiStripFEDMonitorPlugin::globalEndLuminosityBlock ( const edm::LuminosityBlock lumi,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 520 of file SiStripFEDMonitor.cc.

References enableFEDerrLumi_, dqm::impl::MonitorElement::Fill(), and lumiErrfac_.

521  {
522  auto lumiErrors = luminosityBlockCache(lumi.index());
524  for (unsigned int iD(0); iD < lumiErrors->nTotal.size(); iD++) {
525  if (lumiErrors->nTotal[iD] > 0)
526  lumiErrfac_->Fill(iD + 1, static_cast<float>(lumiErrors->nErrors[iD]) / lumiErrors->nTotal[iD]);
527  }
528  }
529 }
void Fill(long long x)
MonitorElement * lumiErrfac_

◆ pairComparison()

bool SiStripFEDMonitorPlugin::pairComparison ( const std::pair< unsigned int, unsigned int > &  pair1,
const std::pair< unsigned int, unsigned int > &  pair2 
)
staticprivate

Definition at line 413 of file SiStripFEDMonitor.cc.

Referenced by analyze().

414  {
415  return (pair1.second < pair2.second);
416 }

◆ updateCabling()

void SiStripFEDMonitorPlugin::updateCabling ( const SiStripFedCablingRcd cablingRcd)
private

Definition at line 531 of file SiStripFEDMonitor.cc.

References cabling_, fedCablingToken_, and edm::eventsetup::EventSetupRecordImplementation< T >::get().

531  {
532  cabling_ = &cablingRcd.get(fedCablingToken_);
533 }
const SiStripFedCabling * cabling_
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_

Member Data Documentation

◆ cabling_

const SiStripFedCabling* SiStripFEDMonitorPlugin::cabling_
private

Definition at line 111 of file SiStripFEDMonitor.cc.

Referenced by analyze(), and updateCabling().

◆ doFEMajorityCheck_

bool SiStripFEDMonitorPlugin::doFEMajorityCheck_
private

Definition at line 121 of file SiStripFEDMonitor.cc.

Referenced by analyze(), and SiStripFEDMonitorPlugin().

◆ doMedHists_

bool SiStripFEDMonitorPlugin::doMedHists_
private

Definition at line 120 of file SiStripFEDMonitor.cc.

Referenced by analyze(), and SiStripFEDMonitorPlugin().

◆ doTkHistoMap_

bool SiStripFEDMonitorPlugin::doTkHistoMap_
private

Definition at line 119 of file SiStripFEDMonitor.cc.

Referenced by analyze(), and SiStripFEDMonitorPlugin().

◆ enableFEDerrLumi_

bool SiStripFEDMonitorPlugin::enableFEDerrLumi_
private

◆ fedCablingToken_

edm::ESGetToken<SiStripFedCabling, SiStripFedCablingRcd> SiStripFEDMonitorPlugin::fedCablingToken_
private

Definition at line 114 of file SiStripFEDMonitor.cc.

Referenced by updateCabling().

◆ fedCablingWatcher_

edm::ESWatcher<SiStripFedCablingRcd> SiStripFEDMonitorPlugin::fedCablingWatcher_
private

Definition at line 113 of file SiStripFEDMonitor.cc.

Referenced by analyze().

◆ fedErrors_

FEDErrors SiStripFEDMonitorPlugin::fedErrors_
private

Definition at line 127 of file SiStripFEDMonitor.cc.

Referenced by analyze().

◆ fedHists_

FEDHistograms SiStripFEDMonitorPlugin::fedHists_
private

Definition at line 100 of file SiStripFEDMonitor.cc.

Referenced by analyze(), bookHistograms(), and SiStripFEDMonitorPlugin().

◆ fillAllDetailedHistograms_

bool SiStripFEDMonitorPlugin::fillAllDetailedHistograms_
private

Definition at line 105 of file SiStripFEDMonitor.cc.

Referenced by bookHistograms(), and SiStripFEDMonitorPlugin().

◆ fillWithEvtNum_

bool SiStripFEDMonitorPlugin::fillWithEvtNum_
private

Definition at line 107 of file SiStripFEDMonitor.cc.

Referenced by analyze(), and SiStripFEDMonitorPlugin().

◆ folderName_

std::string SiStripFEDMonitorPlugin::folderName_
private

Definition at line 103 of file SiStripFEDMonitor.cc.

Referenced by bookHistograms(), and SiStripFEDMonitorPlugin().

◆ fullDebugMode_

bool SiStripFEDMonitorPlugin::fullDebugMode_
private

Definition at line 129 of file SiStripFEDMonitor.cc.

Referenced by analyze(), and bookHistograms().

◆ heToken_

edm::EDGetTokenT<EventWithHistory> SiStripFEDMonitorPlugin::heToken_
private

Definition at line 97 of file SiStripFEDMonitor.cc.

Referenced by analyze(), and SiStripFEDMonitorPlugin().

◆ lumiErrfac_

MonitorElement* SiStripFEDMonitorPlugin::lumiErrfac_
private

Definition at line 132 of file SiStripFEDMonitor.cc.

Referenced by bookHistograms(), and globalEndLuminosityBlock().

◆ maxFedBufferSize_

unsigned int SiStripFEDMonitorPlugin::maxFedBufferSize_
private

Definition at line 128 of file SiStripFEDMonitor.cc.

Referenced by analyze().

◆ nEvt_

unsigned int SiStripFEDMonitorPlugin::nEvt_
private

Definition at line 123 of file SiStripFEDMonitor.cc.

Referenced by analyze(), and SiStripFEDMonitorPlugin().

◆ printDebug_

unsigned int SiStripFEDMonitorPlugin::printDebug_
private

Definition at line 109 of file SiStripFEDMonitor.cc.

Referenced by analyze(), and SiStripFEDMonitorPlugin().

◆ rawDataTag_

edm::InputTag SiStripFEDMonitorPlugin::rawDataTag_
private

Definition at line 95 of file SiStripFEDMonitor.cc.

Referenced by SiStripFEDMonitorPlugin().

◆ rawDataToken_

edm::EDGetTokenT<FEDRawDataCollection> SiStripFEDMonitorPlugin::rawDataToken_
private

Definition at line 96 of file SiStripFEDMonitor.cc.

Referenced by analyze(), and SiStripFEDMonitorPlugin().

◆ tkDetMapToken_

edm::ESGetToken<TkDetMap, TrackerTopologyRcd> SiStripFEDMonitorPlugin::tkDetMapToken_
private

Definition at line 116 of file SiStripFEDMonitor.cc.

Referenced by bookHistograms().

◆ topFolderName_

std::string SiStripFEDMonitorPlugin::topFolderName_
private

Definition at line 102 of file SiStripFEDMonitor.cc.

Referenced by SiStripFEDMonitorPlugin().

◆ tTopoToken_

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> SiStripFEDMonitorPlugin::tTopoToken_
private

Definition at line 115 of file SiStripFEDMonitor.cc.

Referenced by analyze().