CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripSpyEventMatcher.cc
Go to the documentation of this file.
2 #ifdef SiStripMonitorHardware_BuildEventMatchingCode
3 
17 #include "boost/bind.hpp"
18 #include "boost/shared_ptr.hpp"
19 #include <algorithm>
20 #include <limits>
21 
22 using edm::LogInfo;
23 using edm::LogWarning;
24 using edm::LogError;
25 
26 namespace sistrip {
27 
28  const char* SpyEventMatcher::mlLabel_ = "SpyEventMatcher";
29 
30  SpyEventMatcher::EventKey::EventKey(const uint32_t eventId, const uint8_t apvAddress)
31  : eventId_(eventId), apvAddress_(apvAddress) {}
32 
34  outputRawData_(outputRawData),
35  outputTotalEventCounters_(sistrip::FED_ID_MAX+1),
36  outputL1ACounters_(sistrip::FED_ID_MAX+1),
37  outputAPVAddresses_(sistrip::FED_ID_MAX+1) {}
38 
40 
42  : rawDataTag_(config.getParameter<edm::InputTag>("RawSpyDataTag")),
43  totalEventCountersTag_(config.getParameter<edm::InputTag>("SpyTotalEventCountersTag")),
44  l1aCountersTag_(config.getParameter<edm::InputTag>("SpyL1ACountersTag")),
45  apvAddressesTag_(config.getParameter<edm::InputTag>("SpyAPVAddressesTag")),
46  scopeDigisTag_(config.getParameter<edm::InputTag>("SpyScopeDigisTag")),
47  payloadDigisTag_(config.getParameter<edm::InputTag>("SpyPayloadDigisTag")),
48  reorderedDigisTag_(config.getParameter<edm::InputTag>("SpyReorderedDigisTag")),
49  virginRawDigisTag_(config.getParameter<edm::InputTag>("SpyVirginRawDigisTag")),
50  source_(constructSource(config.getParameter<edm::ParameterSet>("SpySource"))),
51  counterDiffMax_(config.getParameter<uint32_t>("CounterDiffMaxAllowed"))
52  {}
53 
54  std::auto_ptr<SpyEventMatcher::Source> SpyEventMatcher::constructSource(const edm::ParameterSet& sourceConfig)
55  {
58  return sourceFactory->makeVectorInputSource(sourceConfig, description);
59  }
60 
62  {
63  //add spy events to the map until there are none left
64  source_->loopSequential(std::numeric_limits<size_t>::max(),boost::bind(&SpyEventMatcher::addNextEventToMap,this,_1));
65  //debug
66  std::ostringstream ss;
67  ss << "Events with possible matches (eventID,apvAddress): ";
68  for (std::map<EventKey,SpyEventList>::const_iterator iSpyEvent = eventMatches_.begin(); iSpyEvent != eventMatches_.end(); ++iSpyEvent) {
69  ss << "(" << iSpyEvent->first.eventId() << "," << uint16_t(iSpyEvent->first.apvAddress()) << ") ";
70  }
71  LogDebug(mlLabel_) << ss.str();
72  }
73 
75  {
76  edm::EventID spyEventId = nextSpyEvent.id();
77 
78  CountersPtr totalEventCounters = getCounters(nextSpyEvent,totalEventCountersTag_);
79  CountersPtr l1aCounters = getCounters(nextSpyEvent,l1aCountersTag_);
80  CountersPtr apvAddresses = getCounters(nextSpyEvent,apvAddressesTag_,false);
81  //loop over all FEDs. Maps should have same content and be in order so, avoid searches by iterating (and checking keys match)
82  //add all possible event keys to the map
83  std::vector<uint32_t>::const_iterator iTotalEventCount = totalEventCounters->begin();
84  std::vector<uint32_t>::const_iterator iL1ACount = l1aCounters->begin();
85  std::vector<uint32_t>::const_iterator iAPVAddress = apvAddresses->begin();
86  //for debug
87  std::map<EventKey,uint16_t> fedCounts;
88  unsigned int fedid = 0;
89  for (;
90  ( (iTotalEventCount != totalEventCounters->end()) && (iL1ACount != l1aCounters->end()) && (iAPVAddress != apvAddresses->end()) );
91  (++iTotalEventCount, ++iL1ACount, ++iAPVAddress, ++fedid)
92  ){
93  if (*iAPVAddress == 0) {
94  continue;
95  }
96 
97  if ( ((*iTotalEventCount) > (*iL1ACount) ) ||
98  ((*iL1ACount)-(*iTotalEventCount) > counterDiffMax_)
99  ) {
100  LogWarning(mlLabel_) << "Spy event " << spyEventId.event()
101  << " error in counter values for FED " << fedid
102  << ", totCount = " << *iTotalEventCount
103  << ", L1Acount = " << *iL1ACount
104  << std::endl;
105 
106  continue;
107  }
108 
109  for (uint32_t eventId = (*iTotalEventCount)+1; eventId <= (*iL1ACount)+1; ++eventId) {
110  EventKey key(eventId,*iAPVAddress);
111  eventMatches_[key].insert(spyEventId);
112  fedCounts[key]++;
113  }
114  }
115 
116  //for debug
117  std::ostringstream ss;
118  ss << "Spy event " << spyEventId.event() << " matches (eventID,apvAddress,nFEDs): ";
119  for (std::map<EventKey,uint16_t>::const_iterator iEventFEDCount = fedCounts.begin(); iEventFEDCount != fedCounts.end(); ++iEventFEDCount) {
120  ss << "(" << iEventFEDCount->first.eventId() << "," << uint16_t(iEventFEDCount->first.apvAddress()) << "," << iEventFEDCount->second << ") ";
121  }
122  LogDebug(mlLabel_) << ss.str();
123  }
124 
125  const SpyEventMatcher::SpyEventList* SpyEventMatcher::matchesForEvent(const uint32_t eventId, const uint8_t apvAddress) const
126  {
127  EventKey eventKey(eventId,apvAddress);
128  std::map<EventKey,SpyEventList>::const_iterator iMatch = eventMatches_.find(eventKey);
129  if (iMatch == eventMatches_.end()) {
130  LogDebug(mlLabel_) << "No match found for event " << eventId << " with APV address " << uint16_t(apvAddress);
131  return NULL;
132  }
133  else {
134  std::ostringstream ss;
135  ss << "Found matches to event " << eventId << " with address " << uint16_t(apvAddress) << " in spy events ";
136  for (SpyEventList::const_iterator iMatchingSpyEvent = iMatch->second.begin(); iMatchingSpyEvent != iMatch->second.end(); ++iMatchingSpyEvent) {
137  ss << iMatchingSpyEvent->event() << " ";
138  }
139  LogInfo(mlLabel_) << ss.str();
140  return &(iMatch->second);
141  }
142  }
143 
144  void SpyEventMatcher::getCollections(const edm::EventPrincipal& event, const uint32_t eventId,
145  const uint8_t apvAddress, const SiStripFedCabling& cabling,
146  MatchingOutput& mo) {
147 
148  //read the input collections from the event
149  const FEDRawDataCollection* inputRawDataPtr = getProduct< FEDRawDataCollection >(event,rawDataTag_);
150  if (!inputRawDataPtr) {
151  throw cms::Exception(mlLabel_) << "Failed to get raw spy data with tag " << rawDataTag_ << " from spy event";
152  }
153  const FEDRawDataCollection& inputRawData = *inputRawDataPtr;
154  CountersPtr inputTotalEventCounters = getCounters(event,totalEventCountersTag_);
155  CountersPtr inputL1ACounters = getCounters(event,l1aCountersTag_);
156  CountersPtr inputAPVAddresses = getCounters(event,apvAddressesTag_,false);
157  const edm::DetSetVector<SiStripRawDigi>* inputScopeDigis = getProduct< edm::DetSetVector<SiStripRawDigi> >(event,scopeDigisTag_);
158  const edm::DetSetVector<SiStripRawDigi>* inputPayloadDigis = getProduct< edm::DetSetVector<SiStripRawDigi> >(event,payloadDigisTag_);
159  const edm::DetSetVector<SiStripRawDigi>* inputReorderedDigis = getProduct< edm::DetSetVector<SiStripRawDigi> >(event,reorderedDigisTag_);
160  const edm::DetSetVector<SiStripRawDigi>* inputVirginRawDigis = getProduct< edm::DetSetVector<SiStripRawDigi> >(event,virginRawDigisTag_);
161  //construct the output vectors if the digis were found and they do not exist
162  if (inputScopeDigis && !mo.outputScopeDigisVector_.get() ) mo.outputScopeDigisVector_.reset(new std::vector< edm::DetSet<SiStripRawDigi> >);
163  if (inputPayloadDigis && !mo.outputPayloadDigisVector_.get() ) mo.outputPayloadDigisVector_.reset(new std::vector< edm::DetSet<SiStripRawDigi> >);
164  if (inputReorderedDigis && !mo.outputReorderedDigisVector_.get() ) mo.outputReorderedDigisVector_.reset(new std::vector< edm::DetSet<SiStripRawDigi> >);
165  if (inputVirginRawDigis && !mo.outputVirginRawDigisVector_.get() ) mo.outputVirginRawDigisVector_.reset(new std::vector< edm::DetSet<SiStripRawDigi> >);
166  //find matching FEDs
167  std::set<uint16_t> matchingFeds;
168  findMatchingFeds(eventId,apvAddress,inputTotalEventCounters,inputL1ACounters,inputAPVAddresses,matchingFeds);
169  LogInfo(mlLabel_) << "Spy event " << event.id() << " has " << matchingFeds.size() << " matching FEDs";
170  std::ostringstream ss;
171  ss << "Matching FEDs for event " << event.id() << ": ";
172  for (std::set<uint16_t>::const_iterator iFedId = matchingFeds.begin(); iFedId != matchingFeds.end(); ++iFedId) {
173  ss << *iFedId << " ";
174  }
175  LogDebug(mlLabel_) << ss.str();
176  //check there are no duplicates
177  std::vector<uint16_t> duplicateFeds( std::min(mo.alreadyMergedFeds_.size(),matchingFeds.size()) );
178  std::vector<uint16_t>::iterator duplicatesBegin = duplicateFeds.begin();
179  std::vector<uint16_t>::iterator duplicatesEnd = std::set_intersection(mo.alreadyMergedFeds_.begin(),mo.alreadyMergedFeds_.end(),
180  matchingFeds.begin(),matchingFeds.end(),
181  duplicatesBegin);
182  if ( (duplicatesEnd-duplicatesBegin) != 0 ) {
183  std::ostringstream ss;
184  ss << "Found a match for FEDs ";
185  for (std::vector<uint16_t>::const_iterator iDup = duplicatesBegin; iDup != duplicatesEnd; ++iDup) {
186  ss << *iDup << " ";
187  }
188  ss << ". Output SetSetVectors will be unusable!";
189  LogError(mlLabel_) << ss.str();
190  }
191  //merge the matching data
192  mergeMatchingData(matchingFeds,inputRawData,inputTotalEventCounters,inputL1ACounters,inputAPVAddresses,
193  inputScopeDigis,inputPayloadDigis,inputReorderedDigis,inputVirginRawDigis,
194  mo.outputRawData_,mo.outputTotalEventCounters_,mo.outputL1ACounters_,mo.outputAPVAddresses_,
195  mo.outputScopeDigisVector_.get(),mo.outputPayloadDigisVector_.get(),
196  mo.outputReorderedDigisVector_.get(),mo.outputVirginRawDigisVector_.get(),
197  cabling);
198  mo.alreadyMergedFeds_.insert(matchingFeds.begin(),matchingFeds.end());
199  }
200 
201  void SpyEventMatcher::getMatchedCollections(const uint32_t eventId, const uint8_t apvAddress,
202  const SpyEventList* matchingEvents, const SiStripFedCabling& cabling,
203  SpyDataCollections& collectionsToCreate)
204  {
205  if (!matchingEvents) return;
206  FEDRawDataCollection outputRawData;
207  MatchingOutput mo(outputRawData);
208  source_->loopSpecified(*matchingEvents,boost::bind(&SpyEventMatcher::getCollections,this,_1,
209  eventId,apvAddress,boost::cref(cabling),boost::ref(mo)));
210  SpyDataCollections collections(mo.outputRawData_,mo.outputTotalEventCounters_,mo.outputL1ACounters_,mo.outputAPVAddresses_,
211  mo.outputScopeDigisVector_.get(),mo.outputPayloadDigisVector_.get(),
212  mo.outputReorderedDigisVector_.get(),mo.outputVirginRawDigisVector_.get());
213  collectionsToCreate = collections;
214  }
215 
216  void SpyEventMatcher::findMatchingFeds(const uint32_t eventId, const uint8_t apvAddress,
217  SpyEventMatcher::CountersPtr totalEventCounters,
218  SpyEventMatcher::CountersPtr l1aCounters,
219  SpyEventMatcher::CountersPtr apvAddresses,
220  std::set<uint16_t>& matchingFeds)
221  {
222  //loop over all FEDs. Maps should have same content and be in order so, avoid searches by iterating (and checking keys match)
223  std::vector<uint32_t>::const_iterator iTotalEventCount = totalEventCounters->begin();
224  std::vector<uint32_t>::const_iterator iL1ACount = l1aCounters->begin();
225  std::vector<uint32_t>::const_iterator iAPVAddress = apvAddresses->begin();
226  for (;
227  ( (iTotalEventCount != totalEventCounters->end()) && (iL1ACount != l1aCounters->end()) && (iAPVAddress != apvAddresses->end()) );
228  (++iTotalEventCount, ++iL1ACount, ++iAPVAddress)
229  ){
230  if (*iAPVAddress == 0) {
231  continue;
232  }
233  if ( (eventId > *iTotalEventCount) && (eventId <= (*iL1ACount)+1) && (*iAPVAddress == apvAddress) ) {
234  matchingFeds.insert(matchingFeds.end(),iTotalEventCount-totalEventCounters->begin());
235  }
236  }
237  }
238 
239  void SpyEventMatcher::mergeMatchingData(const std::set<uint16_t>& matchingFeds,
240  const FEDRawDataCollection& inputRawData,
241  SpyEventMatcher::CountersPtr inputTotalEventCounters,
242  SpyEventMatcher::CountersPtr inputL1ACounters,
243  SpyEventMatcher::CountersPtr inputAPVAddresses,
244  const edm::DetSetVector<SiStripRawDigi>* inputScopeDigis,
245  const edm::DetSetVector<SiStripRawDigi>* inputPayloadDigis,
246  const edm::DetSetVector<SiStripRawDigi>* inputReorderedDigis,
247  const edm::DetSetVector<SiStripRawDigi>* inputVirginRawDigis,
248  FEDRawDataCollection& outputRawData,
249  std::vector<uint32_t>& outputTotalEventCounters,
250  std::vector<uint32_t>& outputL1ACounters,
251  std::vector<uint32_t>& outputAPVAddresses,
252  std::vector< edm::DetSet<SiStripRawDigi> >* outputScopeDigisVector,
253  std::vector< edm::DetSet<SiStripRawDigi> >* outputPayloadDigisVector,
254  std::vector< edm::DetSet<SiStripRawDigi> >* outputReorderedDigisVector,
255  std::vector< edm::DetSet<SiStripRawDigi> >* outputVirginRawDigisVector,
256  const SiStripFedCabling& cabling)
257  {
258  //reserve space in vectors
259  if (inputScopeDigis) {
260  outputScopeDigisVector->reserve(outputScopeDigisVector->size()+matchingFeds.size()*FEDCH_PER_FED); //maximum number of channels on matching FEDs
261  }
262  if (inputPayloadDigis) {
263  outputPayloadDigisVector->reserve(outputPayloadDigisVector->size()+matchingFeds.size()*FEDCH_PER_FED);
264  }
265  if (inputReorderedDigis) {
266  outputReorderedDigisVector->reserve(outputReorderedDigisVector->size()+matchingFeds.size()*FEDCH_PER_FED);
267  }
268  if (inputVirginRawDigis) {
269  outputVirginRawDigisVector->reserve(outputVirginRawDigisVector->size()+matchingFeds.size()*FEDCH_PER_FED/2); //maximum number of dets on matching FEDs
270  }
271  //copy the data into output collections
272  std::set<uint32_t> usedDetIds;
273  for (std::set<uint16_t>::const_iterator iFedId = matchingFeds.begin(); iFedId != matchingFeds.end(); ++iFedId) {
274  const uint32_t fedId = *iFedId;
275  LogDebug(mlLabel_) << "Copying data for FED " << fedId;
276  if (inputRawData.FEDData(fedId).size() && inputRawData.FEDData(fedId).data()) {
277  outputRawData.FEDData(fedId) = inputRawData.FEDData(fedId);
278  }
279  outputTotalEventCounters[fedId] = (*inputTotalEventCounters)[fedId];
280  outputL1ACounters[fedId] = (*inputL1ACounters)[fedId];
281  outputAPVAddresses[fedId] = (*inputAPVAddresses)[fedId];
282  for (uint8_t chan = 0; chan < FEDCH_PER_FED; ++chan) {
283  uint32_t fedIndex = SiStripFedKey::fedIndex(fedId,chan);
284  if (inputScopeDigis) {
285  edm::DetSetVector<SiStripRawDigi>::const_iterator iScopeDigis = inputScopeDigis->find(fedIndex);
286  if (iScopeDigis != inputScopeDigis->end()) {
287  outputScopeDigisVector->push_back(*iScopeDigis);
288  }
289  }
290  if (inputPayloadDigis) {
291  edm::DetSetVector<SiStripRawDigi>::const_iterator iPayloadDigis = inputPayloadDigis->find(fedIndex);
292  if (iPayloadDigis != inputPayloadDigis->end()) {
293  outputPayloadDigisVector->push_back(*iPayloadDigis);
294  }
295  }
296  if (inputReorderedDigis) {
297  edm::DetSetVector<SiStripRawDigi>::const_iterator iReorderedDigis = inputReorderedDigis->find(fedIndex);
298  if (iReorderedDigis != inputReorderedDigis->end()) {
299  outputReorderedDigisVector->push_back(*iReorderedDigis);
300  }
301  }
302  }
303  if (inputVirginRawDigis) {
304  std::set<uint32_t> fedDetIds;
305  const std::vector<FedChannelConnection>& conns = cabling.connections(fedId);
306  for (std::vector<FedChannelConnection>::const_iterator iConn = conns.begin(); iConn != conns.end(); ++iConn) {
307  if (!iConn->isConnected()) continue;
308  const uint32_t detId = iConn->detId();
309  if (usedDetIds.find(detId) != usedDetIds.end()) {
310  LogError(mlLabel_) << "Duplicate DetID found " << detId << " skipping data for this Det from FED " << fedId;
311  continue;
312  }
313  fedDetIds.insert(iConn->detId());
314  }
315  usedDetIds.insert(fedDetIds.begin(),fedDetIds.end());
316  for (std::set<uint32_t>::const_iterator iDetId = fedDetIds.begin(); iDetId != fedDetIds.end(); ++iDetId) {
317  edm::DetSetVector<SiStripRawDigi>::const_iterator iVirginRawDigis = inputVirginRawDigis->find(*iDetId);
318  if (iVirginRawDigis != inputVirginRawDigis->end()) {
319  outputVirginRawDigisVector->push_back(*iVirginRawDigis);
320  }
321  }
322  }
323  }
324  }
325 
326  SpyEventMatcher::CountersPtr SpyEventMatcher::getCounters(const edm::EventPrincipal& event, const edm::InputTag& tag, const bool mapKeyIsByFedID)
327  {
328  const std::vector<uint32_t>* vectorFromEvent = getProduct< std::vector<uint32_t> >(event,tag);
329  if (vectorFromEvent) {
330  //vector is from event so, will be deleted when the event is destroyed (and not before)
331  return CountersPtr(new CountersWrapper(vectorFromEvent) );
332  } else {
333  const std::map<uint32_t,uint32_t>* mapFromEvent = getProduct< std::map<uint32_t,uint32_t> >(event,tag);
334  if (mapFromEvent) {
335  std::vector<uint32_t>* newVector = new std::vector<uint32_t>(FED_ID_MAX+1,0);
336  if (mapKeyIsByFedID) {
337  for (std::map<uint32_t,uint32_t>::const_iterator iIdValue = mapFromEvent->begin(); iIdValue != mapFromEvent->end(); ++iIdValue) {
338  newVector->at(iIdValue->first) = iIdValue->second;
339  }
340  } else {
341  SpyUtilities::fillFEDMajorities(*mapFromEvent,*newVector);
342  }
343 // std::cout << " -- Map " << tag << std::endl;
344 // for (uint32_t lIt= 0;
345 // lIt < newVector->size();
346 // lIt++) {
347 // std::cout << lIt << " " << newVector->at(lIt) << std::endl;
348 // }
349  //vector was allocated here so, will need to be deleted when finished with
350  CountersPtr newCountersPtr( new CountersWrapper(newVector,true) );
351  return newCountersPtr;
352  } else {
353  throw cms::Exception(mlLabel_) << "Unable to get product " << tag << " from spy event";
354  }
355  }
356  }
357 
359  std::vector<uint32_t>& theTotalEventCounters,
360  std::vector<uint32_t>& theL1ACounters,
361  std::vector<uint32_t>& theAPVAddresses,
362  std::vector< edm::DetSet<SiStripRawDigi> >* theScopeDigisVector,
363  std::vector< edm::DetSet<SiStripRawDigi> >* thePayloadDigisVector,
364  std::vector< edm::DetSet<SiStripRawDigi> >* theReorderedDigisVector,
365  std::vector< edm::DetSet<SiStripRawDigi> >* theVirginRawDigisVector)
366  : rawData(new FEDRawDataCollection),
367  totalEventCounters(new std::vector<uint32_t>),
368  l1aCounters(new std::vector<uint32_t>),
369  apvAddresses(new std::vector<uint32_t>),
370  scopeDigis(theScopeDigisVector ? new edm::DetSetVector<SiStripRawDigi>(*theScopeDigisVector) : NULL),
371  payloadDigis(thePayloadDigisVector ? new edm::DetSetVector<SiStripRawDigi>(*thePayloadDigisVector) : NULL),
372  reorderedDigis(theReorderedDigisVector ? new edm::DetSetVector<SiStripRawDigi>(*theReorderedDigisVector) : NULL),
373  virginRawDigis(theVirginRawDigisVector ? new edm::DetSetVector<SiStripRawDigi>(*theVirginRawDigisVector) : NULL)
374  {
375  rawData->swap(theRawData);
376  totalEventCounters->swap(theTotalEventCounters);
377  l1aCounters->swap(theL1ACounters);
378  apvAddresses->swap(theAPVAddresses);
379  }
380 
382  : rawData(),
383  totalEventCounters(),
384  l1aCounters(),
385  apvAddresses(),
386  scopeDigis(),
387  payloadDigis(),
388  reorderedDigis(),
389  virginRawDigis()
390  {}
391 
392  SpyEventMatcher::SpyDataCollections& SpyEventMatcher::SpyDataCollections::operator = (SpyDataCollections original)
393  {
394  rawData = original.rawData;
395  totalEventCounters = original.totalEventCounters;
396  l1aCounters = original.l1aCounters;
397  apvAddresses = original.apvAddresses;
398  scopeDigis = original.scopeDigis;
399  payloadDigis = original.payloadDigis;
400  virginRawDigis = original.virginRawDigis;
401  return *this;
402  }
403 
405  : pConst(theCounters),
406  p(NULL),
407  deleteP(false)
408  {
409  }
410 
411  SpyEventMatcher::CountersWrapper::CountersWrapper(Counters* theCounters, const bool takeOwnership)
412  : pConst(theCounters),
413  p(theCounters),
414  deleteP(takeOwnership)
415  {
416 
417  }
418 
420  {
421  if (deleteP) delete p;
422  }
423 
424 }
425 
426 #endif //SiStripMonitorHardware_BuildEventMatchingCode
#define LogDebug(id)
CountersWrapper(const Counters *theCounters)
EventNumber_t event() const
Definition: EventID.h:44
iterator find(det_id_type id)
Definition: DetSetVector.h:285
const SpyEventList * matchesForEvent(const uint32_t eventId, const uint8_t apvAddress) const
boost::shared_ptr< CountersWrapper > CountersPtr
list original
Definition: definitions.py:60
std::auto_ptr< Source > source_
void getCollections(const edm::EventPrincipal &event, const uint32_t eventId, const uint8_t apvAddress, const SiStripFedCabling &cabling, MatchingOutput &matchingOutput)
EventID const & id() const
#define NULL
Definition: scimark2.h:8
#define min(a, b)
Definition: mlp_lapack.h:161
void getMatchedCollections(const uint32_t eventId, const uint8_t apvAddress, const SpyEventList *matchingEvents, const SiStripFedCabling &cabling, SpyDataCollections &collectionsToCreate)
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:49
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
const T & max(const T &a, const T &b)
std::set< EventID > SpyEventList
std::auto_ptr< edm::DetSetVector< SiStripRawDigi > > payloadDigis
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)
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:356
static std::auto_ptr< Source > constructSource(const edm::ParameterSet &sourceConfig)
tuple description
Definition: idDealer.py:66
EventKey(const uint32_t eventId, const uint8_t apvAddress)
static VectorInputSourceFactory * get()
std::auto_ptr< edm::DetSetVector< SiStripRawDigi > > scopeDigis
SpyDataCollections & operator=(SpyDataCollections original)
std::auto_ptr< FEDRawDataCollection > rawData
std::auto_ptr< VectorInputSource > makeVectorInputSource(ParameterSet const &, InputSourceDescription const &) const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
std::auto_ptr< edm::DetSetVector< SiStripRawDigi > > virginRawDigis
void addNextEventToMap(const edm::EventPrincipal &nextSpyEvent)
list key
Definition: combine.py:13
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:29
static void findMatchingFeds(const uint32_t eventId, const uint8_t apvAddress, CountersPtr totalEventCounters, CountersPtr l1aCounters, CountersPtr apvAddresses, std::set< uint16_t > &matchingFeds)
SpyEventMatcher(const edm::ParameterSet &config)
static const uint16_t FED_ID_MAX
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:106
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
std::map< EventKey, SpyEventList > eventMatches_
const std::vector< FedChannelConnection > & connections(uint16_t fed_id) const
static CountersPtr getCounters(const edm::EventPrincipal &event, const edm::InputTag &tag, const bool mapKeyIsByFedID=true)
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)