CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
sistrip::SpyEventMatcher Class Reference

#include <SiStripSpyEventMatcher.h>

Classes

class  CountersWrapper
 
class  EventKey
 
struct  MatchingOutput
 
class  SpyDataCollections
 

Public Types

typedef edm::EventID EventID
 
typedef std::set< EventIDSpyEventList
 

Public Member Functions

void getCollections (const edm::EventPrincipal &event, const uint32_t eventId, const uint8_t apvAddress, const SiStripFedCabling &cabling, MatchingOutput &matchingOutput)
 
void getMatchedCollections (const uint32_t eventId, const uint8_t apvAddress, const SpyEventList *matchingEvents, const SiStripFedCabling &cabling, SpyDataCollections &collectionsToCreate)
 
void initialize ()
 
const SpyEventListmatchesForEvent (const uint32_t eventId, const uint8_t apvAddress) const
 
 SpyEventMatcher (const edm::ParameterSet &config)
 
virtual ~SpyEventMatcher ()
 

Private Types

typedef std::vector< uint32_t > Counters
 
typedef boost::shared_ptr
< CountersWrapper
CountersPtr
 
typedef edm::VectorInputSource Source
 

Private Member Functions

void addNextEventToMap (const edm::EventPrincipal &nextSpyEvent)
 
std::unique_ptr< SourceconstructSource (const edm::ParameterSet &sourceConfig)
 
void operator() (const edm::EventPrincipal &event)
 

Static Private Member Functions

static void findMatchingFeds (const uint32_t eventId, const uint8_t apvAddress, CountersPtr totalEventCounters, CountersPtr l1aCounters, CountersPtr apvAddresses, std::set< uint16_t > &matchingFeds)
 
static CountersPtr getCounters (const edm::EventPrincipal &event, const edm::InputTag &tag, const bool mapKeyIsByFedID=true)
 
template<class T >
static const TgetProduct (const edm::EventPrincipal &event, const edm::InputTag &tag)
 
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)
 

Private Attributes

edm::InputTag apvAddressesTag_
 
uint32_t counterDiffMax_
 
std::map< EventKey, SpyEventListeventMatches_
 
std::unique_ptr
< edm::EventPrincipal
eventPrincipal_
 
edm::InputTag l1aCountersTag_
 
edm::InputTag payloadDigisTag_
 
std::unique_ptr
< edm::ProcessConfiguration
processConfiguration_
 
std::unique_ptr
< edm::ProductRegistry
productRegistry_
 
edm::InputTag rawDataTag_
 
edm::InputTag reorderedDigisTag_
 
edm::InputTag scopeDigisTag_
 
std::unique_ptr
< edm::VectorInputSource >
const 
source_
 
edm::InputTag totalEventCountersTag_
 
edm::InputTag virginRawDigisTag_
 

Static Private Attributes

static const char * mlLabel_ = "SpyEventMatcher"
 

Detailed Description

Definition at line 30 of file SiStripSpyEventMatcher.h.

Member Typedef Documentation

typedef std::vector<uint32_t> sistrip::SpyEventMatcher::Counters
private

Definition at line 100 of file SiStripSpyEventMatcher.h.

typedef boost::shared_ptr<CountersWrapper> sistrip::SpyEventMatcher::CountersPtr
private

Definition at line 118 of file SiStripSpyEventMatcher.h.

Definition at line 71 of file SiStripSpyEventMatcher.h.

Definition at line 121 of file SiStripSpyEventMatcher.h.

Definition at line 72 of file SiStripSpyEventMatcher.h.

Constructor & Destructor Documentation

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

Definition at line 48 of file SiStripSpyEventMatcher.cc.

References edm::ParameterSet::emptyParameterSetID(), eventPrincipal_, processConfiguration_, productRegistry_, and source_.

49  : rawDataTag_(config.getParameter<edm::InputTag>("RawSpyDataTag")),
50  totalEventCountersTag_(config.getParameter<edm::InputTag>("SpyTotalEventCountersTag")),
51  l1aCountersTag_(config.getParameter<edm::InputTag>("SpyL1ACountersTag")),
52  apvAddressesTag_(config.getParameter<edm::InputTag>("SpyAPVAddressesTag")),
53  scopeDigisTag_(config.getParameter<edm::InputTag>("SpyScopeDigisTag")),
54  payloadDigisTag_(config.getParameter<edm::InputTag>("SpyPayloadDigisTag")),
55  reorderedDigisTag_(config.getParameter<edm::InputTag>("SpyReorderedDigisTag")),
56  virginRawDigisTag_(config.getParameter<edm::InputTag>("SpyVirginRawDigisTag")),
57  counterDiffMax_(config.getParameter<uint32_t>("CounterDiffMaxAllowed")),
62  {
63  // Use the empty parameter set for the parameter set ID of our "@MIXING" process.
65  productRegistry_->setFrozen();
66 
67  eventPrincipal_.reset(new edm::EventPrincipal(source_->productRegistry(),
68  source_->branchIDListHelper(),
69  source_->thinnedAssociationsHelper(),
71  nullptr));
72  }
T getParameter(std::string const &) const
std::string getPassID()
Definition: GetPassID.h:8
std::unique_ptr< edm::EventPrincipal > eventPrincipal_
std::unique_ptr< edm::ProcessConfiguration > processConfiguration_
std::unique_ptr< Source > constructSource(const edm::ParameterSet &sourceConfig)
std::unique_ptr< edm::VectorInputSource > const source_
std::string getReleaseVersion()
std::unique_ptr< edm::ProductRegistry > productRegistry_
static ParameterSetID emptyParameterSetID()
sistrip::SpyEventMatcher::~SpyEventMatcher ( )
virtual

Definition at line 46 of file SiStripSpyEventMatcher.cc.

46 {}

Member Function Documentation

void sistrip::SpyEventMatcher::addNextEventToMap ( const edm::EventPrincipal nextSpyEvent)
private

Definition at line 100 of file SiStripSpyEventMatcher.cc.

References apvAddressesTag_, counterDiffMax_, edm::EventID::event(), eventMatches_, getCounters(), edm::EventPrincipal::id(), combine::key, l1aCountersTag_, LogDebug, mlLabel_, contentValuesCheck::ss, and totalEventCountersTag_.

Referenced by initialize().

101  {
102  edm::EventID spyEventId = nextSpyEvent.id();
103 
104  CountersPtr totalEventCounters = getCounters(nextSpyEvent,totalEventCountersTag_);
105  CountersPtr l1aCounters = getCounters(nextSpyEvent,l1aCountersTag_);
106  CountersPtr apvAddresses = getCounters(nextSpyEvent,apvAddressesTag_,false);
107  //loop over all FEDs. Maps should have same content and be in order so, avoid searches by iterating (and checking keys match)
108  //add all possible event keys to the map
109  std::vector<uint32_t>::const_iterator iTotalEventCount = totalEventCounters->begin();
110  std::vector<uint32_t>::const_iterator iL1ACount = l1aCounters->begin();
111  std::vector<uint32_t>::const_iterator iAPVAddress = apvAddresses->begin();
112  //for debug
113  std::map<EventKey,uint16_t> fedCounts;
114  unsigned int fedid = 0;
115  for (;
116  ( (iTotalEventCount != totalEventCounters->end()) && (iL1ACount != l1aCounters->end()) && (iAPVAddress != apvAddresses->end()) );
117  (++iTotalEventCount, ++iL1ACount, ++iAPVAddress, ++fedid)
118  ){
119  if (*iAPVAddress == 0) {
120  continue;
121  }
122 
123  if ( ((*iTotalEventCount) > (*iL1ACount) ) ||
124  ((*iL1ACount)-(*iTotalEventCount) > counterDiffMax_)
125  ) {
126  LogWarning(mlLabel_) << "Spy event " << spyEventId.event()
127  << " error in counter values for FED " << fedid
128  << ", totCount = " << *iTotalEventCount
129  << ", L1Acount = " << *iL1ACount
130  << std::endl;
131 
132  continue;
133  }
134 
135  for (uint32_t eventId = (*iTotalEventCount)+1; eventId <= (*iL1ACount)+1; ++eventId) {
136  EventKey key(eventId,*iAPVAddress);
137  eventMatches_[key].insert(spyEventId);
138  fedCounts[key]++;
139  }
140  }
141 
142  //for debug
143  std::ostringstream ss;
144  ss << "Spy event " << spyEventId.event() << " matches (eventID,apvAddress,nFEDs): ";
145  for (std::map<EventKey,uint16_t>::const_iterator iEventFEDCount = fedCounts.begin(); iEventFEDCount != fedCounts.end(); ++iEventFEDCount) {
146  ss << "(" << iEventFEDCount->first.eventId() << "," << uint16_t(iEventFEDCount->first.apvAddress()) << "," << iEventFEDCount->second << ") ";
147  }
148  LogDebug(mlLabel_) << ss.str();
149  }
#define LogDebug(id)
EventNumber_t event() const
Definition: EventID.h:41
boost::shared_ptr< CountersWrapper > CountersPtr
EventID const & id() const
static CountersPtr getCounters(const edm::EventPrincipal &event, const edm::InputTag &tag, const bool mapKeyIsByFedID=true)
list key
Definition: combine.py:13
std::map< EventKey, SpyEventList > eventMatches_
std::unique_ptr< SpyEventMatcher::Source > sistrip::SpyEventMatcher::constructSource ( const edm::ParameterSet sourceConfig)
private

Definition at line 74 of file SiStripSpyEventMatcher.cc.

References idDealer::description, edm::VectorInputSourceFactory::get(), edm::VectorInputSourceFactory::makeVectorInputSource(), and productRegistry_.

75  {
79  std::make_shared<edm::BranchIDListHelper>(),
80  std::make_shared<edm::ThinnedAssociationsHelper>(),
81  std::make_shared<edm::ActivityRegistry>(),
82  -1, -1, -1,
84  return sourceFactory->makeVectorInputSource(sourceConfig, description);
85  }
std::unique_ptr< VectorInputSource > makeVectorInputSource(ParameterSet const &, InputSourceDescription const &) const
tuple description
Definition: idDealer.py:66
std::unique_ptr< edm::ProductRegistry > productRegistry_
static VectorInputSourceFactory const * get()
void sistrip::SpyEventMatcher::findMatchingFeds ( const uint32_t  eventId,
const uint8_t  apvAddress,
SpyEventMatcher::CountersPtr  totalEventCounters,
SpyEventMatcher::CountersPtr  l1aCounters,
SpyEventMatcher::CountersPtr  apvAddresses,
std::set< uint16_t > &  matchingFeds 
)
staticprivate

Definition at line 242 of file SiStripSpyEventMatcher.cc.

Referenced by getCollections().

247  {
248  //loop over all FEDs. Maps should have same content and be in order so, avoid searches by iterating (and checking keys match)
249  std::vector<uint32_t>::const_iterator iTotalEventCount = totalEventCounters->begin();
250  std::vector<uint32_t>::const_iterator iL1ACount = l1aCounters->begin();
251  std::vector<uint32_t>::const_iterator iAPVAddress = apvAddresses->begin();
252  for (;
253  ( (iTotalEventCount != totalEventCounters->end()) && (iL1ACount != l1aCounters->end()) && (iAPVAddress != apvAddresses->end()) );
254  (++iTotalEventCount, ++iL1ACount, ++iAPVAddress)
255  ){
256  if (*iAPVAddress == 0) {
257  continue;
258  }
259  if ( (eventId > *iTotalEventCount) && (eventId <= (*iL1ACount)+1) && (*iAPVAddress == apvAddress) ) {
260  matchingFeds.insert(matchingFeds.end(),iTotalEventCount-totalEventCounters->begin());
261  }
262  }
263  }
void sistrip::SpyEventMatcher::getCollections ( const edm::EventPrincipal event,
const uint32_t  eventId,
const uint8_t  apvAddress,
const SiStripFedCabling cabling,
MatchingOutput matchingOutput 
)

Definition at line 170 of file SiStripSpyEventMatcher.cc.

References sistrip::SpyEventMatcher::MatchingOutput::alreadyMergedFeds_, apvAddressesTag_, event(), edm::hlt::Exception, findMatchingFeds(), getCounters(), l1aCountersTag_, LogDebug, mergeMatchingData(), min(), mlLabel_, sistrip::SpyEventMatcher::MatchingOutput::outputAPVAddresses_, sistrip::SpyEventMatcher::MatchingOutput::outputL1ACounters_, sistrip::SpyEventMatcher::MatchingOutput::outputPayloadDigisVector_, sistrip::SpyEventMatcher::MatchingOutput::outputRawData_, sistrip::SpyEventMatcher::MatchingOutput::outputReorderedDigisVector_, sistrip::SpyEventMatcher::MatchingOutput::outputScopeDigisVector_, sistrip::SpyEventMatcher::MatchingOutput::outputTotalEventCounters_, sistrip::SpyEventMatcher::MatchingOutput::outputVirginRawDigisVector_, payloadDigisTag_, rawDataTag_, reorderedDigisTag_, scopeDigisTag_, contentValuesCheck::ss, totalEventCountersTag_, and virginRawDigisTag_.

Referenced by getMatchedCollections().

172  {
173 
174  //read the input collections from the event
175  const FEDRawDataCollection* inputRawDataPtr = getProduct< FEDRawDataCollection >(event,rawDataTag_);
176  if (!inputRawDataPtr) {
177  throw cms::Exception(mlLabel_) << "Failed to get raw spy data with tag " << rawDataTag_ << " from spy event";
178  }
179  const FEDRawDataCollection& inputRawData = *inputRawDataPtr;
180  CountersPtr inputTotalEventCounters = getCounters(event,totalEventCountersTag_);
181  CountersPtr inputL1ACounters = getCounters(event,l1aCountersTag_);
182  CountersPtr inputAPVAddresses = getCounters(event,apvAddressesTag_,false);
183  const edm::DetSetVector<SiStripRawDigi>* inputScopeDigis = getProduct< edm::DetSetVector<SiStripRawDigi> >(event,scopeDigisTag_);
184  const edm::DetSetVector<SiStripRawDigi>* inputPayloadDigis = getProduct< edm::DetSetVector<SiStripRawDigi> >(event,payloadDigisTag_);
185  const edm::DetSetVector<SiStripRawDigi>* inputReorderedDigis = getProduct< edm::DetSetVector<SiStripRawDigi> >(event,reorderedDigisTag_);
186  const edm::DetSetVector<SiStripRawDigi>* inputVirginRawDigis = getProduct< edm::DetSetVector<SiStripRawDigi> >(event,virginRawDigisTag_);
187  //construct the output vectors if the digis were found and they do not exist
188  if (inputScopeDigis && !mo.outputScopeDigisVector_.get() ) mo.outputScopeDigisVector_.reset(new std::vector< edm::DetSet<SiStripRawDigi> >);
189  if (inputPayloadDigis && !mo.outputPayloadDigisVector_.get() ) mo.outputPayloadDigisVector_.reset(new std::vector< edm::DetSet<SiStripRawDigi> >);
190  if (inputReorderedDigis && !mo.outputReorderedDigisVector_.get() ) mo.outputReorderedDigisVector_.reset(new std::vector< edm::DetSet<SiStripRawDigi> >);
191  if (inputVirginRawDigis && !mo.outputVirginRawDigisVector_.get() ) mo.outputVirginRawDigisVector_.reset(new std::vector< edm::DetSet<SiStripRawDigi> >);
192  //find matching FEDs
193  std::set<uint16_t> matchingFeds;
194  findMatchingFeds(eventId,apvAddress,inputTotalEventCounters,inputL1ACounters,inputAPVAddresses,matchingFeds);
195  LogInfo(mlLabel_) << "Spy event " << event.id() << " has " << matchingFeds.size() << " matching FEDs";
196  std::ostringstream ss;
197  ss << "Matching FEDs for event " << event.id() << ": ";
198  for (std::set<uint16_t>::const_iterator iFedId = matchingFeds.begin(); iFedId != matchingFeds.end(); ++iFedId) {
199  ss << *iFedId << " ";
200  }
201  LogDebug(mlLabel_) << ss.str();
202  //check there are no duplicates
203  std::vector<uint16_t> duplicateFeds( std::min(mo.alreadyMergedFeds_.size(),matchingFeds.size()) );
204  std::vector<uint16_t>::iterator duplicatesBegin = duplicateFeds.begin();
205  std::vector<uint16_t>::iterator duplicatesEnd = std::set_intersection(mo.alreadyMergedFeds_.begin(),mo.alreadyMergedFeds_.end(),
206  matchingFeds.begin(),matchingFeds.end(),
207  duplicatesBegin);
208  if ( (duplicatesEnd-duplicatesBegin) != 0 ) {
209  std::ostringstream ss;
210  ss << "Found a match for FEDs ";
211  for (std::vector<uint16_t>::const_iterator iDup = duplicatesBegin; iDup != duplicatesEnd; ++iDup) {
212  ss << *iDup << " ";
213  }
214  ss << ". Output SetSetVectors will be unusable!";
215  LogError(mlLabel_) << ss.str();
216  }
217  //merge the matching data
218  mergeMatchingData(matchingFeds,inputRawData,inputTotalEventCounters,inputL1ACounters,inputAPVAddresses,
219  inputScopeDigis,inputPayloadDigis,inputReorderedDigis,inputVirginRawDigis,
220  mo.outputRawData_,mo.outputTotalEventCounters_,mo.outputL1ACounters_,mo.outputAPVAddresses_,
221  mo.outputScopeDigisVector_.get(),mo.outputPayloadDigisVector_.get(),
222  mo.outputReorderedDigisVector_.get(),mo.outputVirginRawDigisVector_.get(),
223  cabling);
224  mo.alreadyMergedFeds_.insert(matchingFeds.begin(),matchingFeds.end());
225  }
#define LogDebug(id)
static void findMatchingFeds(const uint32_t eventId, const uint8_t apvAddress, CountersPtr totalEventCounters, CountersPtr l1aCounters, CountersPtr apvAddresses, std::set< uint16_t > &matchingFeds)
boost::shared_ptr< CountersWrapper > CountersPtr
static CountersPtr getCounters(const edm::EventPrincipal &event, const edm::InputTag &tag, const bool mapKeyIsByFedID=true)
T min(T a, T b)
Definition: MathUtil.h:58
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 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::CountersPtr sistrip::SpyEventMatcher::getCounters ( const edm::EventPrincipal event,
const edm::InputTag tag,
const bool  mapKeyIsByFedID = true 
)
staticprivate

Definition at line 352 of file SiStripSpyEventMatcher.cc.

References event(), edm::hlt::Exception, sistrip::FED_ID_MAX, sistrip::SpyUtilities::fillFEDMajorities(), mlLabel_, and GlobalPosition_Frontier_DevDB_cff::tag.

Referenced by addNextEventToMap(), and getCollections().

353  {
354  const std::vector<uint32_t>* vectorFromEvent = getProduct< std::vector<uint32_t> >(event,tag);
355  if (vectorFromEvent) {
356  //vector is from event so, will be deleted when the event is destroyed (and not before)
357  return CountersPtr(new CountersWrapper(vectorFromEvent) );
358  } else {
359  const std::map<uint32_t,uint32_t>* mapFromEvent = getProduct< std::map<uint32_t,uint32_t> >(event,tag);
360  if (mapFromEvent) {
361  std::vector<uint32_t>* newVector = new std::vector<uint32_t>(FED_ID_MAX+1,0);
362  if (mapKeyIsByFedID) {
363  for (std::map<uint32_t,uint32_t>::const_iterator iIdValue = mapFromEvent->begin(); iIdValue != mapFromEvent->end(); ++iIdValue) {
364  newVector->at(iIdValue->first) = iIdValue->second;
365  }
366  } else {
367  SpyUtilities::fillFEDMajorities(*mapFromEvent,*newVector);
368  }
369 // std::cout << " -- Map " << tag << std::endl;
370 // for (uint32_t lIt= 0;
371 // lIt < newVector->size();
372 // lIt++) {
373 // std::cout << lIt << " " << newVector->at(lIt) << std::endl;
374 // }
375  //vector was allocated here so, will need to be deleted when finished with
376  CountersPtr newCountersPtr( new CountersWrapper(newVector,true) );
377  return newCountersPtr;
378  } else {
379  throw cms::Exception(mlLabel_) << "Unable to get product " << tag << " from spy event";
380  }
381  }
382  }
boost::shared_ptr< CountersWrapper > CountersPtr
static void fillFEDMajorities(const std::map< uint32_t, uint32_t > &channelValues, std::vector< uint32_t > &fedMajoritiesToFill)
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 FED_ID_MAX
void sistrip::SpyEventMatcher::getMatchedCollections ( const uint32_t  eventId,
const uint8_t  apvAddress,
const SpyEventList matchingEvents,
const SiStripFedCabling cabling,
SpyDataCollections collectionsToCreate 
)

Definition at line 227 of file SiStripSpyEventMatcher.cc.

References eventPrincipal_, getCollections(), sistrip::SpyEventMatcher::MatchingOutput::outputAPVAddresses_, sistrip::SpyEventMatcher::MatchingOutput::outputL1ACounters_, sistrip::SpyEventMatcher::MatchingOutput::outputPayloadDigisVector_, sistrip::SpyEventMatcher::MatchingOutput::outputRawData_, sistrip::SpyEventMatcher::MatchingOutput::outputReorderedDigisVector_, sistrip::SpyEventMatcher::MatchingOutput::outputScopeDigisVector_, sistrip::SpyEventMatcher::MatchingOutput::outputTotalEventCounters_, sistrip::SpyEventMatcher::MatchingOutput::outputVirginRawDigisVector_, and source_.

230  {
231  if (!matchingEvents) return;
232  FEDRawDataCollection outputRawData;
233  MatchingOutput mo(outputRawData);
234  source_->loopSpecified(*eventPrincipal_,*matchingEvents,boost::bind(&SpyEventMatcher::getCollections,this,_1,
235  eventId,apvAddress,boost::cref(cabling),boost::ref(mo)));
236  SpyDataCollections collections(mo.outputRawData_,mo.outputTotalEventCounters_,mo.outputL1ACounters_,mo.outputAPVAddresses_,
237  mo.outputScopeDigisVector_.get(),mo.outputPayloadDigisVector_.get(),
238  mo.outputReorderedDigisVector_.get(),mo.outputVirginRawDigisVector_.get());
239  collectionsToCreate = collections;
240  }
std::unique_ptr< edm::EventPrincipal > eventPrincipal_
void getCollections(const edm::EventPrincipal &event, const uint32_t eventId, const uint8_t apvAddress, const SiStripFedCabling &cabling, MatchingOutput &matchingOutput)
std::unique_ptr< edm::VectorInputSource > const source_
template<class T >
const T * sistrip::SpyEventMatcher::getProduct ( const edm::EventPrincipal event,
const edm::InputTag tag 
)
staticprivate

Definition at line 170 of file SiStripSpyEventMatcher.h.

References event(), LogDebug, mlLabel_, NULL, and GlobalPosition_Frontier_DevDB_cff::tag.

171  {
172  LogDebug(mlLabel_) << "Retrieving product " << tag;
173  // Note: The third argument to getProductByTag can be a nullptr
174  // as long as unscheduled execution of an EDProducer cannot occur
175  // as a result of this function call (and with the current implementation
176  // of SpyEventMatcher unscheduled execution never happens).
177  const std::shared_ptr< const edm::Wrapper<T> > productWrapper = edm::getProductByTag<T>(event,tag,nullptr);
178  if (productWrapper) {
179  return productWrapper->product();
180  } else {
181  return NULL;
182  }
183  }
#define LogDebug(id)
#define NULL
Definition: scimark2.h:8
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
void sistrip::SpyEventMatcher::initialize ( )

Definition at line 87 of file SiStripSpyEventMatcher.cc.

References addNextEventToMap(), eventMatches_, eventPrincipal_, LogDebug, bookConverter::max, mlLabel_, source_, and contentValuesCheck::ss.

88  {
89  //add spy events to the map until there are none left
91  //debug
92  std::ostringstream ss;
93  ss << "Events with possible matches (eventID,apvAddress): ";
94  for (std::map<EventKey,SpyEventList>::const_iterator iSpyEvent = eventMatches_.begin(); iSpyEvent != eventMatches_.end(); ++iSpyEvent) {
95  ss << "(" << iSpyEvent->first.eventId() << "," << uint16_t(iSpyEvent->first.apvAddress()) << ") ";
96  }
97  LogDebug(mlLabel_) << ss.str();
98  }
#define LogDebug(id)
std::unique_ptr< edm::EventPrincipal > eventPrincipal_
std::unique_ptr< edm::VectorInputSource > const source_
void addNextEventToMap(const edm::EventPrincipal &nextSpyEvent)
std::map< EventKey, SpyEventList > eventMatches_
const SpyEventMatcher::SpyEventList * sistrip::SpyEventMatcher::matchesForEvent ( const uint32_t  eventId,
const uint8_t  apvAddress 
) const

Definition at line 151 of file SiStripSpyEventMatcher.cc.

References eventMatches_, LogDebug, mlLabel_, NULL, and contentValuesCheck::ss.

152  {
153  EventKey eventKey(eventId,apvAddress);
154  std::map<EventKey,SpyEventList>::const_iterator iMatch = eventMatches_.find(eventKey);
155  if (iMatch == eventMatches_.end()) {
156  LogDebug(mlLabel_) << "No match found for event " << eventId << " with APV address " << uint16_t(apvAddress);
157  return NULL;
158  }
159  else {
160  std::ostringstream ss;
161  ss << "Found matches to event " << eventId << " with address " << uint16_t(apvAddress) << " in spy events ";
162  for (SpyEventList::const_iterator iMatchingSpyEvent = iMatch->second.begin(); iMatchingSpyEvent != iMatch->second.end(); ++iMatchingSpyEvent) {
163  ss << iMatchingSpyEvent->event() << " ";
164  }
165  LogInfo(mlLabel_) << ss.str();
166  return &(iMatch->second);
167  }
168  }
#define LogDebug(id)
#define NULL
Definition: scimark2.h:8
std::map< EventKey, SpyEventList > eventMatches_
void sistrip::SpyEventMatcher::mergeMatchingData ( const std::set< uint16_t > &  matchingFeds,
const FEDRawDataCollection inputRawData,
SpyEventMatcher::CountersPtr  inputTotalEventCounters,
SpyEventMatcher::CountersPtr  inputL1ACounters,
SpyEventMatcher::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 
)
staticprivate

Definition at line 265 of file SiStripSpyEventMatcher.cc.

References FEDRawData::data(), edm::DetSetVector< T >::end(), sistrip::FEDCH_PER_FED, SiStripFedCabling::fedConnections(), FEDRawDataCollection::FEDData(), SiStripFedKey::fedIndex(), edm::DetSetVector< T >::find(), LogDebug, mlLabel_, and FEDRawData::size().

Referenced by getCollections().

283  {
284  //reserve space in vectors
285  if (inputScopeDigis) {
286  outputScopeDigisVector->reserve(outputScopeDigisVector->size()+matchingFeds.size()*FEDCH_PER_FED); //maximum number of channels on matching FEDs
287  }
288  if (inputPayloadDigis) {
289  outputPayloadDigisVector->reserve(outputPayloadDigisVector->size()+matchingFeds.size()*FEDCH_PER_FED);
290  }
291  if (inputReorderedDigis) {
292  outputReorderedDigisVector->reserve(outputReorderedDigisVector->size()+matchingFeds.size()*FEDCH_PER_FED);
293  }
294  if (inputVirginRawDigis) {
295  outputVirginRawDigisVector->reserve(outputVirginRawDigisVector->size()+matchingFeds.size()*FEDCH_PER_FED/2); //maximum number of dets on matching FEDs
296  }
297  //copy the data into output collections
298  std::set<uint32_t> usedDetIds;
299  for (std::set<uint16_t>::const_iterator iFedId = matchingFeds.begin(); iFedId != matchingFeds.end(); ++iFedId) {
300  const uint32_t fedId = *iFedId;
301  LogDebug(mlLabel_) << "Copying data for FED " << fedId;
302  if (inputRawData.FEDData(fedId).size() && inputRawData.FEDData(fedId).data()) {
303  outputRawData.FEDData(fedId) = inputRawData.FEDData(fedId);
304  }
305  outputTotalEventCounters[fedId] = (*inputTotalEventCounters)[fedId];
306  outputL1ACounters[fedId] = (*inputL1ACounters)[fedId];
307  outputAPVAddresses[fedId] = (*inputAPVAddresses)[fedId];
308  for (uint8_t chan = 0; chan < FEDCH_PER_FED; ++chan) {
309  uint32_t fedIndex = SiStripFedKey::fedIndex(fedId,chan);
310  if (inputScopeDigis) {
311  edm::DetSetVector<SiStripRawDigi>::const_iterator iScopeDigis = inputScopeDigis->find(fedIndex);
312  if (iScopeDigis != inputScopeDigis->end()) {
313  outputScopeDigisVector->push_back(*iScopeDigis);
314  }
315  }
316  if (inputPayloadDigis) {
317  edm::DetSetVector<SiStripRawDigi>::const_iterator iPayloadDigis = inputPayloadDigis->find(fedIndex);
318  if (iPayloadDigis != inputPayloadDigis->end()) {
319  outputPayloadDigisVector->push_back(*iPayloadDigis);
320  }
321  }
322  if (inputReorderedDigis) {
323  edm::DetSetVector<SiStripRawDigi>::const_iterator iReorderedDigis = inputReorderedDigis->find(fedIndex);
324  if (iReorderedDigis != inputReorderedDigis->end()) {
325  outputReorderedDigisVector->push_back(*iReorderedDigis);
326  }
327  }
328  }
329  if (inputVirginRawDigis) {
330  std::set<uint32_t> fedDetIds;
331  auto conns = cabling.fedConnections(fedId);
332  for (auto iConn = conns.begin(); iConn != conns.end(); ++iConn) {
333  if (!iConn->isConnected()) continue;
334  const uint32_t detId = iConn->detId();
335  if (usedDetIds.find(detId) != usedDetIds.end()) {
336  LogError(mlLabel_) << "Duplicate DetID found " << detId << " skipping data for this Det from FED " << fedId;
337  continue;
338  }
339  fedDetIds.insert(iConn->detId());
340  }
341  usedDetIds.insert(fedDetIds.begin(),fedDetIds.end());
342  for (std::set<uint32_t>::const_iterator iDetId = fedDetIds.begin(); iDetId != fedDetIds.end(); ++iDetId) {
343  edm::DetSetVector<SiStripRawDigi>::const_iterator iVirginRawDigis = inputVirginRawDigis->find(*iDetId);
344  if (iVirginRawDigis != inputVirginRawDigis->end()) {
345  outputVirginRawDigisVector->push_back(*iVirginRawDigis);
346  }
347  }
348  }
349  }
350  }
#define LogDebug(id)
iterator find(det_id_type id)
Definition: DetSetVector.h:294
static uint32_t fedIndex(const uint16_t &fed_id, const uint16_t &fed_ch)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:365
ConnsConstIterRange fedConnections(uint16_t fed_id) const
static const uint16_t FEDCH_PER_FED
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:108
void sistrip::SpyEventMatcher::operator() ( const edm::EventPrincipal event)
private

Member Data Documentation

edm::InputTag sistrip::SpyEventMatcher::apvAddressesTag_
private

Definition at line 157 of file SiStripSpyEventMatcher.h.

Referenced by addNextEventToMap(), and getCollections().

uint32_t sistrip::SpyEventMatcher::counterDiffMax_
private

Definition at line 162 of file SiStripSpyEventMatcher.h.

Referenced by addNextEventToMap().

std::map<EventKey,SpyEventList> sistrip::SpyEventMatcher::eventMatches_
private

Definition at line 153 of file SiStripSpyEventMatcher.h.

Referenced by addNextEventToMap(), initialize(), and matchesForEvent().

std::unique_ptr<edm::EventPrincipal> sistrip::SpyEventMatcher::eventPrincipal_
private

Definition at line 166 of file SiStripSpyEventMatcher.h.

Referenced by getMatchedCollections(), initialize(), and SpyEventMatcher().

edm::InputTag sistrip::SpyEventMatcher::l1aCountersTag_
private

Definition at line 156 of file SiStripSpyEventMatcher.h.

Referenced by addNextEventToMap(), and getCollections().

const char * sistrip::SpyEventMatcher::mlLabel_ = "SpyEventMatcher"
staticprivate
edm::InputTag sistrip::SpyEventMatcher::payloadDigisTag_
private

Definition at line 159 of file SiStripSpyEventMatcher.h.

Referenced by getCollections().

std::unique_ptr<edm::ProcessConfiguration> sistrip::SpyEventMatcher::processConfiguration_
private

Definition at line 165 of file SiStripSpyEventMatcher.h.

Referenced by SpyEventMatcher().

std::unique_ptr<edm::ProductRegistry> sistrip::SpyEventMatcher::productRegistry_
private

Definition at line 163 of file SiStripSpyEventMatcher.h.

Referenced by constructSource(), and SpyEventMatcher().

edm::InputTag sistrip::SpyEventMatcher::rawDataTag_
private

Definition at line 154 of file SiStripSpyEventMatcher.h.

Referenced by getCollections().

edm::InputTag sistrip::SpyEventMatcher::reorderedDigisTag_
private

Definition at line 160 of file SiStripSpyEventMatcher.h.

Referenced by getCollections().

edm::InputTag sistrip::SpyEventMatcher::scopeDigisTag_
private

Definition at line 158 of file SiStripSpyEventMatcher.h.

Referenced by getCollections().

std::unique_ptr<edm::VectorInputSource> const sistrip::SpyEventMatcher::source_
private
edm::InputTag sistrip::SpyEventMatcher::totalEventCountersTag_
private

Definition at line 155 of file SiStripSpyEventMatcher.h.

Referenced by addNextEventToMap(), and getCollections().

edm::InputTag sistrip::SpyEventMatcher::virginRawDigisTag_
private

Definition at line 161 of file SiStripSpyEventMatcher.h.

Referenced by getCollections().