4 #ifdef SiStripMonitorHardware_BuildEventMatchingCode
6 #include "boost/cstdint.hpp"
33 virtual ~SpyEventMatcherModule();
41 static const char* messageLabel_;
42 const bool filterNonMatchingEvents_;
45 std::auto_ptr<SpyEventMatcher> spyEventMatcher_;
46 std::auto_ptr<SpyUtilities> utils_;
53 const char* SpyEventMatcherModule::messageLabel_ =
"SiStripSpyDataMergeModule";
56 : filterNonMatchingEvents_( config.getParameter<bool>(
"FilterNonMatchingEvents") ),
57 doMerge_( config.getParameter<bool>(
"MergeData") ),
58 primaryStreamRawDataTag_( config.getParameter<edm::InputTag>(
"PrimaryEventRawDataTag") ),
59 spyEventMatcher_(new SpyEventMatcher(config)),
60 utils_(new SpyUtilities)
63 produces<FEDRawDataCollection>(
"RawSpyData");
64 produces< std::vector<uint32_t> >(
"SpyTotalEventCount");
65 produces< std::vector<uint32_t> >(
"SpyL1ACount");
66 produces< std::vector<uint32_t> >(
"SpyAPVAddress");
67 produces< edm::DetSetVector<SiStripRawDigi> >(
"SpyScope");
68 produces< edm::DetSetVector<SiStripRawDigi> >(
"SpyPayload");
69 produces< edm::DetSetVector<SiStripRawDigi> >(
"SpyReordered");
70 produces< edm::DetSetVector<SiStripRawDigi> >(
"SpyVirginRaw");
74 SpyEventMatcherModule::~SpyEventMatcherModule()
80 spyEventMatcher_->initialize();
86 uint8_t apvAddress = 0;
89 findL1IDandAPVAddress(event,cabling,eventId,apvAddress);
91 LogError(messageLabel_) << e.
what();
92 return ( filterNonMatchingEvents_ ?
false :
true );
94 const SpyEventMatcher::SpyEventList* matches = spyEventMatcher_->matchesForEvent(eventId,apvAddress);
97 copyData(eventId,apvAddress,matches,event,cabling);
101 return ( filterNonMatchingEvents_ ?
false :
true );
105 void SpyEventMatcherModule::findL1IDandAPVAddress(
const edm::Event& event,
const SiStripFedCabling& cabling, uint32_t& l1ID, uint8_t& apvAddress)
const
108 event.getByLabel(primaryStreamRawDataTag_,fedRawDataHandle);
110 for (std::vector<uint16_t>::const_iterator iFedId = cabling.
feds().begin(); iFedId != cabling.
feds().end(); ++iFedId) {
112 if ( (!data.
data()) || (!data.
size()) ) {
113 LogDebug(messageLabel_) <<
"Failed to get FED data for FED ID " << *iFedId;
116 std::auto_ptr<FEDBuffer> buffer;
118 buffer.reset(
new FEDBuffer(data.
data(),data.
size()));
120 LogDebug(messageLabel_) <<
"Failed to build FED buffer for FED ID " << *iFedId <<
". Exception was " << e.
what();
123 if (!buffer->doChecks()) {
124 LogDebug(messageLabel_) <<
"Buffer check failed for FED ID " << *iFedId;
127 l1ID = buffer->daqLvl1ID();
128 apvAddress = buffer->trackerSpecialHeader().apveAddress();
129 if (apvAddress != 0) {
135 const FEDFullDebugHeader*
header =
dynamic_cast<const FEDFullDebugHeader*
>(buffer->feHeader());
136 const std::vector<FedChannelConnection>& connections = cabling.
connections(*iFedId);
137 for (std::vector<FedChannelConnection>::const_iterator iConn = connections.begin(); iConn != connections.end(); ++iConn) {
138 if (!iConn->isConnected()) {
141 if ( !buffer->channelGood(iConn->fedCh()) ) {
144 apvAddress = header->feUnitMajorityAddress(iConn->fedCh()/
FEDCH_PER_FEUNIT);
151 throw cms::Exception(messageLabel_) <<
"Failed to get L1ID/APV address from any FED";
154 void SpyEventMatcherModule::copyData(
const uint32_t eventId,
const uint8_t apvAddress,
const SpyEventMatcher::SpyEventList* matches,
edm::Event& event,
157 SpyEventMatcher::SpyDataCollections matchedCollections;
158 spyEventMatcher_->getMatchedCollections(eventId,apvAddress,matches,cabling,matchedCollections);
159 if (matchedCollections.rawData.get()) event.
put(matchedCollections.rawData,
"RawSpyData");
160 if (matchedCollections.totalEventCounters.get()) event.
put(matchedCollections.totalEventCounters,
"SpyTotalEventCount");
161 if (matchedCollections.l1aCounters.get()) event.
put(matchedCollections.l1aCounters,
"SpyL1ACount");
162 if (matchedCollections.apvAddresses.get()) event.
put(matchedCollections.apvAddresses,
"SpyAPVAddress");
163 if (matchedCollections.scopeDigis.get()) event.
put(matchedCollections.scopeDigis,
"SpyScope");
164 if (matchedCollections.payloadDigis.get()) event.
put(matchedCollections.payloadDigis,
"SpyPayload");
165 if (matchedCollections.reorderedDigis.get()) event.
put(matchedCollections.reorderedDigis,
"SpyReordered");
166 if (matchedCollections.virginRawDigis.get()) event.
put(matchedCollections.virginRawDigis,
"SpyVirginRaw");
172 typedef sistrip::SpyEventMatcherModule SiStripSpyEventMatcherModule;
175 #endif //SiStripMonitorHardware_BuildEventMatchingCode
virtual char const * what() const
const std::vector< uint16_t > & feds() const
#define DEFINE_FWK_MODULE(type)
size_t size() const
Lenght of the data buffer in bytes.
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
std::set< EventID > SpyEventList
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
static const uint16_t FEDCH_PER_FEUNIT
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
char data[epos_bytes_allocation]
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
const std::vector< FedChannelConnection > & connections(uint16_t fed_id) const