2 #ifdef SiStripMonitorHardware_BuildEventMatchingCode 37 : eventId_(eventId), apvAddress_(apvAddress) {}
40 outputRawData_(outputRawData),
48 :
rawDataTag_(config.getParameter<
edm::InputTag>(
"RawSpyDataTag")),
56 counterDiffMax_(config.getParameter<uint32_t>(
"CounterDiffMaxAllowed")),
67 std::make_shared<edm::BranchIDListHelper>(),
68 std::make_shared<edm::ThinnedAssociationsHelper>(),
82 size_t fileNameHash = 0
U;
86 nullptr,
nullptr,
false);
88 std::ostringstream ss;
89 ss <<
"Events with possible matches (eventID,apvAddress): ";
90 for (std::map<EventKey,SpyEventList>::const_iterator iSpyEvent =
eventMatches_.begin(); iSpyEvent !=
eventMatches_.end(); ++iSpyEvent) {
91 ss <<
"(" << iSpyEvent->first.eventId() <<
"," << uint16_t(iSpyEvent->first.apvAddress()) <<
") ";
105 std::vector<uint32_t>::const_iterator iTotalEventCount = totalEventCounters->begin();
106 std::vector<uint32_t>::const_iterator iL1ACount = l1aCounters->begin();
107 std::vector<uint32_t>::const_iterator iAPVAddress = apvAddresses->begin();
109 std::map<EventKey,uint16_t> fedCounts;
110 unsigned int fedid = 0;
112 ( (iTotalEventCount != totalEventCounters->end()) && (iL1ACount != l1aCounters->end()) && (iAPVAddress != apvAddresses->end()) );
113 (++iTotalEventCount, ++iL1ACount, ++iAPVAddress, ++fedid)
115 if (*iAPVAddress == 0) {
119 if ( ((*iTotalEventCount) > (*iL1ACount) ) ||
123 <<
" error in counter values for FED " << fedid
124 <<
", totCount = " << *iTotalEventCount
125 <<
", L1Acount = " << *iL1ACount
131 for (uint32_t eventId = (*iTotalEventCount)+1; eventId <= (*iL1ACount)+1; ++eventId) {
139 std::ostringstream ss;
140 ss <<
"Spy event " << spyEventId.
event() <<
" matches (eventID,apvAddress,nFEDs): ";
141 for (std::map<EventKey,uint16_t>::const_iterator iEventFEDCount = fedCounts.begin(); iEventFEDCount != fedCounts.end(); ++iEventFEDCount) {
142 ss <<
"(" << iEventFEDCount->first.eventId() <<
"," << uint16_t(iEventFEDCount->first.apvAddress()) <<
"," << iEventFEDCount->second <<
") ";
149 EventKey eventKey(eventId,apvAddress);
150 std::map<EventKey,SpyEventList>::const_iterator iMatch =
eventMatches_.find(eventKey);
152 LogDebug(
mlLabel_) <<
"No match found for event " << eventId <<
" with APV address " << uint16_t(apvAddress);
156 std::ostringstream ss;
157 ss <<
"Found matches to event " << eventId <<
" with address " << uint16_t(apvAddress) <<
" in spy events ";
158 for (SpyEventList::const_iterator iMatchingSpyEvent = iMatch->second.begin(); iMatchingSpyEvent != iMatch->second.end(); ++iMatchingSpyEvent) {
159 ss << iMatchingSpyEvent->event() <<
" ";
162 return &(iMatch->second);
172 if (!inputRawDataPtr) {
189 std::set<uint16_t> matchingFeds;
190 findMatchingFeds(eventId,apvAddress,inputTotalEventCounters,inputL1ACounters,inputAPVAddresses,matchingFeds);
191 LogInfo(
mlLabel_) <<
"Spy event " <<
event.id() <<
" has " << matchingFeds.size() <<
" matching FEDs";
192 std::ostringstream ss;
193 ss <<
"Matching FEDs for event " <<
event.id() <<
": ";
194 for (std::set<uint16_t>::const_iterator iFedId = matchingFeds.begin(); iFedId != matchingFeds.end(); ++iFedId) {
195 ss << *iFedId <<
" ";
200 std::vector<uint16_t>::iterator duplicatesBegin = duplicateFeds.begin();
202 matchingFeds.begin(),matchingFeds.end(),
204 if ( (duplicatesEnd-duplicatesBegin) != 0 ) {
205 std::ostringstream ss;
206 ss <<
"Found a match for FEDs ";
207 for (std::vector<uint16_t>::const_iterator iDup = duplicatesBegin; iDup != duplicatesEnd; ++iDup) {
210 ss <<
". Output SetSetVectors will be unusable!";
214 mergeMatchingData(matchingFeds,inputRawData,inputTotalEventCounters,inputL1ACounters,inputAPVAddresses,
215 inputScopeDigis,inputPayloadDigis,inputReorderedDigis,inputVirginRawDigis,
227 if (!matchingEvents)
return;
228 size_t fileNameHash = 0
U;
232 [&](
auto const& iE,
auto const&){ this->
getCollections(iE,eventId,apvAddress,cabling,mo); });
242 std::set<uint16_t>& matchingFeds)
245 std::vector<uint32_t>::const_iterator iTotalEventCount = totalEventCounters->begin();
246 std::vector<uint32_t>::const_iterator iL1ACount = l1aCounters->begin();
247 std::vector<uint32_t>::const_iterator iAPVAddress = apvAddresses->begin();
249 ( (iTotalEventCount != totalEventCounters->end()) && (iL1ACount != l1aCounters->end()) && (iAPVAddress != apvAddresses->end()) );
250 (++iTotalEventCount, ++iL1ACount, ++iAPVAddress)
252 if (*iAPVAddress == 0) {
255 if ( (eventId > *iTotalEventCount) && (eventId <= (*iL1ACount)+1) && (*iAPVAddress == apvAddress) ) {
256 matchingFeds.insert(matchingFeds.end(),iTotalEventCount-totalEventCounters->begin());
271 std::vector<uint32_t>& outputTotalEventCounters,
272 std::vector<uint32_t>& outputL1ACounters,
273 std::vector<uint32_t>& outputAPVAddresses,
281 if (inputScopeDigis) {
282 outputScopeDigisVector->reserve(outputScopeDigisVector->size()+matchingFeds.size()*
FEDCH_PER_FED);
284 if (inputPayloadDigis) {
285 outputPayloadDigisVector->reserve(outputPayloadDigisVector->size()+matchingFeds.size()*
FEDCH_PER_FED);
287 if (inputReorderedDigis) {
288 outputReorderedDigisVector->reserve(outputReorderedDigisVector->size()+matchingFeds.size()*
FEDCH_PER_FED);
290 if (inputVirginRawDigis) {
291 outputVirginRawDigisVector->reserve(outputVirginRawDigisVector->size()+matchingFeds.size()*
FEDCH_PER_FED/2);
294 std::set<uint32_t> usedDetIds;
295 for (std::set<uint16_t>::const_iterator iFedId = matchingFeds.begin(); iFedId != matchingFeds.end(); ++iFedId) {
296 const uint32_t
fedId = *iFedId;
301 outputTotalEventCounters[
fedId] = (*inputTotalEventCounters)[
fedId];
302 outputL1ACounters[
fedId] = (*inputL1ACounters)[
fedId];
303 outputAPVAddresses[
fedId] = (*inputAPVAddresses)[
fedId];
306 if (inputScopeDigis) {
308 if (iScopeDigis != inputScopeDigis->
end()) {
309 outputScopeDigisVector->push_back(*iScopeDigis);
312 if (inputPayloadDigis) {
314 if (iPayloadDigis != inputPayloadDigis->
end()) {
315 outputPayloadDigisVector->push_back(*iPayloadDigis);
318 if (inputReorderedDigis) {
320 if (iReorderedDigis != inputReorderedDigis->
end()) {
321 outputReorderedDigisVector->push_back(*iReorderedDigis);
325 if (inputVirginRawDigis) {
326 std::set<uint32_t> fedDetIds;
328 for (
auto iConn = conns.begin(); iConn != conns.end(); ++iConn) {
329 if (!iConn->isConnected())
continue;
330 const uint32_t detId = iConn->detId();
331 if (usedDetIds.find(detId) != usedDetIds.end()) {
332 LogError(
mlLabel_) <<
"Duplicate DetID found " << detId <<
" skipping data for this Det from FED " <<
fedId;
335 fedDetIds.insert(iConn->detId());
337 usedDetIds.insert(fedDetIds.begin(),fedDetIds.end());
338 for (std::set<uint32_t>::const_iterator iDetId = fedDetIds.begin(); iDetId != fedDetIds.end(); ++iDetId) {
340 if (iVirginRawDigis != inputVirginRawDigis->
end()) {
341 outputVirginRawDigisVector->push_back(*iVirginRawDigis);
350 const std::vector<uint32_t>* vectorFromEvent = getProduct< std::vector<uint32_t> >(
event,
tag);
351 if (vectorFromEvent) {
355 const std::map<uint32_t,uint32_t>* mapFromEvent = getProduct< std::map<uint32_t,uint32_t> >(
event,
tag);
357 std::vector<uint32_t>* newVector =
new std::vector<uint32_t>(
FED_ID_MAX+1,0);
358 if (mapKeyIsByFedID) {
359 for (std::map<uint32_t,uint32_t>::const_iterator iIdValue = mapFromEvent->begin(); iIdValue != mapFromEvent->end(); ++iIdValue) {
360 newVector->at(iIdValue->first) = iIdValue->second;
373 return newCountersPtr;
381 std::vector<uint32_t>& theTotalEventCounters,
382 std::vector<uint32_t>& theL1ACounters,
383 std::vector<uint32_t>& theAPVAddresses,
389 totalEventCounters(new
std::vector<uint32_t>),
390 l1aCounters(new
std::vector<uint32_t>),
391 apvAddresses(new
std::vector<uint32_t>),
394 reorderedDigis(theReorderedDigisVector ? new
edm::DetSetVector<
SiStripRawDigi>(*theReorderedDigisVector) :
nullptr),
415 : pConst(theCounters),
436 #endif //SiStripMonitorHardware_BuildEventMatchingCode
CountersWrapper(const Counters *theCounters)
EventNumber_t event() const
edm::InputTag virginRawDigisTag_
static void findMatchingFeds(const uint32_t eventId, const uint8_t apvAddress, CountersPtr totalEventCounters, CountersPtr l1aCounters, CountersPtr apvAddresses, std::set< uint16_t > &matchingFeds)
iterator find(det_id_type id)
static const char * mlLabel_
std::vector< uint32_t > Counters
std::unique_ptr< std::vector< uint32_t > > l1aCounters
boost::shared_ptr< CountersWrapper > CountersPtr
edm::InputTag rawDataTag_
std::unique_ptr< std::vector< uint32_t > > totalEventCounters
edm::InputTag payloadDigisTag_
std::unique_ptr< edm::EventPrincipal > eventPrincipal_
std::set< uint16_t > alreadyMergedFeds_
std::vector< uint32_t > outputL1ACounters_
void getCollections(const edm::EventPrincipal &event, const uint32_t eventId, const uint8_t apvAddress, const SiStripFedCabling &cabling, MatchingOutput &matchingOutput)
EventID const & id() const
static CountersPtr getCounters(const edm::EventPrincipal &event, const edm::InputTag &tag, const bool mapKeyIsByFedID=true)
FEDRawDataCollection & outputRawData_
std::unique_ptr< edm::ProcessConfiguration > processConfiguration_
void getMatchedCollections(const uint32_t eventId, const uint8_t apvAddress, const SpyEventList *matchingEvents, const SiStripFedCabling &cabling, SpyDataCollections &collectionsToCreate)
edm::InputTag apvAddressesTag_
edm::InputTag scopeDigisTag_
boost::shared_ptr< std::vector< edm::DetSet< SiStripRawDigi > > > outputReorderedDigisVector_
size_t size() const
Lenght of the data buffer in bytes.
std::unique_ptr< edm::DetSetVector< SiStripRawDigi > > virginRawDigis
std::vector< uint32_t > outputAPVAddresses_
boost::shared_ptr< std::vector< edm::DetSet< SiStripRawDigi > > > outputScopeDigisVector_
edm::InputTag l1aCountersTag_
static void fillFEDMajorities(const std::map< uint32_t, uint32_t > &channelValues, std::vector< uint32_t > &fedMajoritiesToFill)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
std::unique_ptr< Source > constructSource(const edm::ParameterSet &sourceConfig)
boost::shared_ptr< std::vector< edm::DetSet< SiStripRawDigi > > > outputPayloadDigisVector_
std::set< EventID > SpyEventList
std::shared_ptr< edm::ProductRegistry > productRegistry_
virtual ~SpyEventMatcher()
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
MatchingOutput(FEDRawDataCollection &outputRawData)
std::unique_ptr< edm::VectorInputSource > const source_
iterator end()
Return the off-the-end iterator.
edm::InputTag totalEventCountersTag_
const SpyEventList * matchesForEvent(const uint32_t eventId, const uint8_t apvAddress) const
std::string getReleaseVersion()
std::unique_ptr< FEDRawDataCollection > rawData
EventKey(const uint32_t eventId, const uint8_t apvAddress)
std::vector< uint32_t > outputTotalEventCounters_
std::unique_ptr< edm::DetSetVector< SiStripRawDigi > > scopeDigis
edm::InputTag reorderedDigisTag_
static const uint16_t invalid_
ConnsConstIterRange fedConnections(uint16_t fed_id) const
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
boost::shared_ptr< std::vector< edm::DetSet< SiStripRawDigi > > > outputVirginRawDigisVector_
void addNextEventToMap(const edm::EventPrincipal &nextSpyEvent)
static const uint16_t FEDCH_PER_FED
std::unique_ptr< std::vector< uint32_t > > apvAddresses
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
static void mergeMatchingData(const std::set< uint16_t > &matchingFeds, const FEDRawDataCollection &inputRawData, CountersPtr inputTotalEventCounters, CountersPtr inputL1ACounters, CountersPtr inputAPVAddresses, const edm::DetSetVector< SiStripRawDigi > *inputScopeDigis, const edm::DetSetVector< SiStripRawDigi > *inputPayloadDigis, const edm::DetSetVector< SiStripRawDigi > *inputReorderedDigis, const edm::DetSetVector< SiStripRawDigi > *inputVirginRawDigis, FEDRawDataCollection &outputRawData, std::vector< uint32_t > &outputTotalEventCounters, std::vector< uint32_t > &outputL1ACounters, std::vector< uint32_t > &outputAPVAddresses, std::vector< edm::DetSet< SiStripRawDigi > > *outputScopeDigisVector, std::vector< edm::DetSet< SiStripRawDigi > > *outputPayloadDigisVector, std::vector< edm::DetSet< SiStripRawDigi > > *outputReorderedDigisVector, std::vector< edm::DetSet< SiStripRawDigi > > *outputVirginRawDigisVector, const SiStripFedCabling &cabling)
SpyEventMatcher(const edm::ParameterSet &config)
static const uint16_t FED_ID_MAX
std::unique_ptr< edm::DetSetVector< SiStripRawDigi > > reorderedDigis
collection_type::const_iterator const_iterator
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
static ParameterSetID emptyParameterSetID()
std::unique_ptr< edm::DetSetVector< SiStripRawDigi > > payloadDigis
std::map< EventKey, SpyEventList > eventMatches_