CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
sistrip::SpyEventMatcherModule Class Reference
Inheritance diagram for sistrip::SpyEventMatcherModule:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void beginJob () override
 
bool filter (edm::Event &event, const edm::EventSetup &eventSetup) override
 
 SpyEventMatcherModule (const edm::ParameterSet &config)
 
 ~SpyEventMatcherModule () override
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilter () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void copyData (const uint32_t eventId, const uint8_t apvAddress, const SpyEventMatcher::SpyEventList *matches, edm::Event &event, const SiStripFedCabling &cabling) const
 
void findL1IDandAPVAddress (const edm::Event &event, const SiStripFedCabling &cabling, uint32_t &l1ID, uint8_t &apvAddress) const
 

Private Attributes

const bool doMerge_
 
const bool filterNonMatchingEvents_
 
const edm::InputTag primaryStreamRawDataTag_
 
edm::EDGetTokenT< FEDRawDataCollectionprimaryStreamRawDataToken_
 
std::unique_ptr< SpyEventMatcherspyEventMatcher_
 
std::unique_ptr< SpyUtilitiesutils_
 

Static Private Attributes

static const char * messageLabel_ = "SiStripSpyDataMergeModule"
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
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::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
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)
 
template<Transition B>
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 (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 29 of file SiStripSpyEventMatcherModule.cc.

Constructor & Destructor Documentation

◆ SpyEventMatcherModule()

sistrip::SpyEventMatcherModule::SpyEventMatcherModule ( const edm::ParameterSet config)

Definition at line 62 of file SiStripSpyEventMatcherModule.cc.

63  : filterNonMatchingEvents_(config.getParameter<bool>("FilterNonMatchingEvents")),
64  doMerge_(config.getParameter<bool>("MergeData")),
65  primaryStreamRawDataTag_(config.getParameter<edm::InputTag>("PrimaryEventRawDataTag")),
66  spyEventMatcher_(new SpyEventMatcher(config)),
67  utils_(new SpyUtilities) {
68  primaryStreamRawDataToken_ = consumes<FEDRawDataCollection>(primaryStreamRawDataTag_);
69  if (doMerge_) {
70  produces<FEDRawDataCollection>("RawSpyData");
71  produces<std::vector<uint32_t> >("SpyTotalEventCount");
72  produces<std::vector<uint32_t> >("SpyL1ACount");
73  produces<std::vector<uint32_t> >("SpyAPVAddress");
74  produces<edm::DetSetVector<SiStripRawDigi> >("SpyScope");
75  produces<edm::DetSetVector<SiStripRawDigi> >("SpyPayload");
76  produces<edm::DetSetVector<SiStripRawDigi> >("SpyReordered");
77  produces<edm::DetSetVector<SiStripRawDigi> >("SpyVirginRaw");
78  }
79  }

References doMerge_, primaryStreamRawDataTag_, and primaryStreamRawDataToken_.

◆ ~SpyEventMatcherModule()

sistrip::SpyEventMatcherModule::~SpyEventMatcherModule ( )
override

Definition at line 81 of file SiStripSpyEventMatcherModule.cc.

81 {}

Member Function Documentation

◆ beginJob()

void sistrip::SpyEventMatcherModule::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDFilter.

Definition at line 83 of file SiStripSpyEventMatcherModule.cc.

83 { spyEventMatcher_->initialize(); }

References spyEventMatcher_.

◆ copyData()

void sistrip::SpyEventMatcherModule::copyData ( const uint32_t  eventId,
const uint8_t  apvAddress,
const SpyEventMatcher::SpyEventList matches,
edm::Event event,
const SiStripFedCabling cabling 
) const
private

Definition at line 160 of file SiStripSpyEventMatcherModule.cc.

164  {
165  SpyEventMatcher::SpyDataCollections matchedCollections;
166  spyEventMatcher_->getMatchedCollections(eventId, apvAddress, matches, cabling, matchedCollections);
167  if (matchedCollections.rawData.get())
168  event.put(std::move(matchedCollections.rawData), "RawSpyData");
169  if (matchedCollections.totalEventCounters.get())
170  event.put(std::move(matchedCollections.totalEventCounters), "SpyTotalEventCount");
171  if (matchedCollections.l1aCounters.get())
172  event.put(std::move(matchedCollections.l1aCounters), "SpyL1ACount");
173  if (matchedCollections.apvAddresses.get())
174  event.put(std::move(matchedCollections.apvAddresses), "SpyAPVAddress");
175  if (matchedCollections.scopeDigis.get())
176  event.put(std::move(matchedCollections.scopeDigis), "SpyScope");
177  if (matchedCollections.payloadDigis.get())
178  event.put(std::move(matchedCollections.payloadDigis), "SpyPayload");
179  if (matchedCollections.reorderedDigis.get())
180  event.put(std::move(matchedCollections.reorderedDigis), "SpyReordered");
181  if (matchedCollections.virginRawDigis.get())
182  event.put(std::move(matchedCollections.virginRawDigis), "SpyVirginRaw");
183  }

References sistrip::SpyEventMatcher::SpyDataCollections::apvAddresses, sistrip::SpyEventMatcher::SpyDataCollections::l1aCounters, patCandidatesForDimuonsSequences_cff::matches, eostools::move(), sistrip::SpyEventMatcher::SpyDataCollections::payloadDigis, sistrip::SpyEventMatcher::SpyDataCollections::rawData, sistrip::SpyEventMatcher::SpyDataCollections::reorderedDigis, sistrip::SpyEventMatcher::SpyDataCollections::scopeDigis, spyEventMatcher_, sistrip::SpyEventMatcher::SpyDataCollections::totalEventCounters, and sistrip::SpyEventMatcher::SpyDataCollections::virginRawDigis.

Referenced by filter().

◆ filter()

bool sistrip::SpyEventMatcherModule::filter ( edm::Event event,
const edm::EventSetup eventSetup 
)
overridevirtual

Implements edm::EDFilter.

Definition at line 85 of file SiStripSpyEventMatcherModule.cc.

85  {
86  const SiStripFedCabling& cabling = *(utils_->getCabling(eventSetup));
87  uint8_t apvAddress = 0;
88  uint32_t eventId = 0;
89  try {
90  findL1IDandAPVAddress(event, cabling, eventId, apvAddress);
91  } catch (const cms::Exception& e) {
92  LogError(messageLabel_) << e.what();
93  return (filterNonMatchingEvents_ ? false : true);
94  }
95  const SpyEventMatcher::SpyEventList* matches = spyEventMatcher_->matchesForEvent(eventId, apvAddress);
96  if (matches) {
97  if (doMerge_) {
98  copyData(eventId, apvAddress, matches, event, cabling);
99  }
100  return true;
101  } else {
102  return (filterNonMatchingEvents_ ? false : true);
103  }
104  }

References copyData(), doMerge_, MillePedeFileConverter_cfg::e, filterNonMatchingEvents_, findL1IDandAPVAddress(), patCandidatesForDimuonsSequences_cff::matches, messageLabel_, spyEventMatcher_, and utils_.

◆ findL1IDandAPVAddress()

void sistrip::SpyEventMatcherModule::findL1IDandAPVAddress ( const edm::Event event,
const SiStripFedCabling cabling,
uint32_t &  l1ID,
uint8_t &  apvAddress 
) const
private

Definition at line 106 of file SiStripSpyEventMatcherModule.cc.

109  {
110  edm::Handle<FEDRawDataCollection> fedRawDataHandle;
111  event.getByToken(primaryStreamRawDataToken_, fedRawDataHandle);
112  const FEDRawDataCollection& fedRawData = *fedRawDataHandle;
113  for (auto iFedId = cabling.fedIds().begin(); iFedId != cabling.fedIds().end(); ++iFedId) {
114  const FEDRawData& data = fedRawData.FEDData(*iFedId);
115  const auto st_buffer = preconstructCheckFEDBuffer(data);
116  if (FEDBufferStatusCode::SUCCESS != st_buffer) {
117  LogInfo(messageLabel_) << "Failed to build FED buffer for FED ID " << *iFedId
118  << ". Exception was: An exception of category 'FEDBuffer' occurred.\n"
119  << st_buffer << " (see debug output for details)";
120  continue;
121  }
122  FEDBuffer buffer{data};
123  const auto st_chan = buffer.findChannels();
124  if (FEDBufferStatusCode::SUCCESS != st_chan) {
125  LogDebug(messageLabel_) << "Failed to build FED buffer for FED ID " << *iFedId << ". Exception was " << st_chan
126  << " (see above for more details)";
127  continue;
128  }
129  if (!buffer.doChecks(true)) {
130  LogDebug(messageLabel_) << "Buffer check failed for FED ID " << *iFedId;
131  continue;
132  }
133  l1ID = buffer.daqLvl1ID();
134  apvAddress = buffer.trackerSpecialHeader().apveAddress();
135  if (apvAddress != 0) {
136  return;
137  } else {
138  if (buffer.trackerSpecialHeader().headerType() != HEADER_TYPE_FULL_DEBUG) {
139  continue;
140  }
141  const FEDFullDebugHeader* header = dynamic_cast<const FEDFullDebugHeader*>(buffer.feHeader());
142  auto connections = cabling.fedConnections(*iFedId);
143  for (auto iConn = connections.begin(); iConn != connections.end(); ++iConn) {
144  if (!iConn->isConnected()) {
145  continue;
146  }
147  if (!buffer.channelGood(iConn->fedCh(), true)) {
148  continue;
149  } else {
150  apvAddress = header->feUnitMajorityAddress(iConn->fedCh() / FEDCH_PER_FEUNIT);
151  return;
152  }
153  }
154  }
155  }
156  //if we haven't already found an acceptable alternative, throw an exception
157  throw cms::Exception(messageLabel_) << "Failed to get L1ID/APV address from any FED";
158  }

References edmScanValgrind::buffer, data, Exception, sistrip::FEDCH_PER_FEUNIT, SiStripFedCabling::fedConnections(), SiStripFedCabling::fedIds(), l1t_dqm_sourceclient-live_cfg::fedRawData, RecoTauValidation_cfi::header, sistrip::HEADER_TYPE_FULL_DEBUG, LogDebug, messageLabel_, sistrip::preconstructCheckFEDBuffer(), primaryStreamRawDataToken_, and sistrip::SUCCESS.

Referenced by filter().

Member Data Documentation

◆ doMerge_

const bool sistrip::SpyEventMatcherModule::doMerge_
private

Definition at line 49 of file SiStripSpyEventMatcherModule.cc.

Referenced by filter(), and SpyEventMatcherModule().

◆ filterNonMatchingEvents_

const bool sistrip::SpyEventMatcherModule::filterNonMatchingEvents_
private

Definition at line 48 of file SiStripSpyEventMatcherModule.cc.

Referenced by filter().

◆ messageLabel_

const char * sistrip::SpyEventMatcherModule::messageLabel_ = "SiStripSpyDataMergeModule"
staticprivate

Definition at line 47 of file SiStripSpyEventMatcherModule.cc.

Referenced by filter(), and findL1IDandAPVAddress().

◆ primaryStreamRawDataTag_

const edm::InputTag sistrip::SpyEventMatcherModule::primaryStreamRawDataTag_
private

Definition at line 50 of file SiStripSpyEventMatcherModule.cc.

Referenced by SpyEventMatcherModule().

◆ primaryStreamRawDataToken_

edm::EDGetTokenT<FEDRawDataCollection> sistrip::SpyEventMatcherModule::primaryStreamRawDataToken_
private

Definition at line 51 of file SiStripSpyEventMatcherModule.cc.

Referenced by findL1IDandAPVAddress(), and SpyEventMatcherModule().

◆ spyEventMatcher_

std::unique_ptr<SpyEventMatcher> sistrip::SpyEventMatcherModule::spyEventMatcher_
private

Definition at line 52 of file SiStripSpyEventMatcherModule.cc.

Referenced by beginJob(), copyData(), and filter().

◆ utils_

std::unique_ptr<SpyUtilities> sistrip::SpyEventMatcherModule::utils_
private

Definition at line 53 of file SiStripSpyEventMatcherModule.cc.

Referenced by filter().

sistrip::SpyEventMatcherModule::primaryStreamRawDataToken_
edm::EDGetTokenT< FEDRawDataCollection > primaryStreamRawDataToken_
Definition: SiStripSpyEventMatcherModule.cc:51
sistrip::SpyEventMatcherModule::findL1IDandAPVAddress
void findL1IDandAPVAddress(const edm::Event &event, const SiStripFedCabling &cabling, uint32_t &l1ID, uint8_t &apvAddress) const
Definition: SiStripSpyEventMatcherModule.cc:106
FEDRawDataCollection
Definition: FEDRawDataCollection.h:18
edm::LogInfo
Definition: MessageLogger.h:254
SiStripFedCabling
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses,...
Definition: SiStripFedCabling.h:25
sistrip::SpyEventMatcherModule::utils_
std::unique_ptr< SpyUtilities > utils_
Definition: SiStripSpyEventMatcherModule.cc:53
edm::Handle
Definition: AssociativeIterator.h:50
FEDRawData
Definition: FEDRawData.h:19
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
config
Definition: config.py:1
sistrip::SpyEventMatcherModule::messageLabel_
static const char * messageLabel_
Definition: SiStripSpyEventMatcherModule.cc:47
l1t_dqm_sourceclient-live_cfg.fedRawData
fedRawData
Definition: l1t_dqm_sourceclient-live_cfg.py:182
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::LogError
Definition: MessageLogger.h:183
sistrip::HEADER_TYPE_FULL_DEBUG
Definition: SiStripFEDBufferComponents.h:39
sistrip::SpyEventMatcher::SpyEventList
std::set< EventID > SpyEventList
Definition: SiStripSpyEventMatcher.h:70
sistrip::FEDBufferStatusCode::SUCCESS
sistrip::SpyEventMatcherModule::filterNonMatchingEvents_
const bool filterNonMatchingEvents_
Definition: SiStripSpyEventMatcherModule.cc:48
sistrip::preconstructCheckFEDBuffer
FEDBufferStatusCode preconstructCheckFEDBuffer(const FEDRawData &fedBuffer, bool allowBadBuffer=false)
Definition: SiStripFEDBuffer.h:131
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:246
sistrip::SpyEventMatcherModule::copyData
void copyData(const uint32_t eventId, const uint8_t apvAddress, const SpyEventMatcher::SpyEventList *matches, edm::Event &event, const SiStripFedCabling &cabling) const
Definition: SiStripSpyEventMatcherModule.cc:160
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
patCandidatesForDimuonsSequences_cff.matches
matches
Definition: patCandidatesForDimuonsSequences_cff.py:131
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
SiStripFedCabling::fedIds
FedsConstIterRange fedIds() const
Definition: SiStripFedCabling.h:154
sistrip::FEDCH_PER_FEUNIT
static const uint16_t FEDCH_PER_FEUNIT
Definition: ConstantsForHardwareSystems.h:28
sistrip::SpyEventMatcherModule::doMerge_
const bool doMerge_
Definition: SiStripSpyEventMatcherModule.cc:49
cms::Exception
Definition: Exception.h:70
sistrip::SpyEventMatcherModule::spyEventMatcher_
std::unique_ptr< SpyEventMatcher > spyEventMatcher_
Definition: SiStripSpyEventMatcherModule.cc:52
event
Definition: event.py:1
SiStripFedCabling::fedConnections
ConnsConstIterRange fedConnections(uint16_t fed_id) const
Definition: SiStripFedCabling.cc:160
edm::InputTag
Definition: InputTag.h:15
sistrip::SpyEventMatcherModule::primaryStreamRawDataTag_
const edm::InputTag primaryStreamRawDataTag_
Definition: SiStripSpyEventMatcherModule.cc:50
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37