CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripSpyEventMatcher.h
Go to the documentation of this file.
1 #define SiStripMonitorHardware_BuildEventMatchingCode
2 #ifdef SiStripMonitorHardware_BuildEventMatchingCode
3 
4 #ifndef DQM_SiStripMonitorHardware_SiStripSpyEventMatcher_H
5 #define DQM_SiStripMonitorHardware_SiStripSpyEventMatcher_H
6 
11 #include "boost/cstdint.hpp"
12 #include <set>
13 #include <map>
14 #include <memory>
15 #include <vector>
16 
17 //forward declarations
19 class SiStripRawDigi;
20 namespace edm {
21  template<class T> class DetSetVector;
22  template<class T> class DetSet;
23  class EventID;
24  class ParameterSet;
25 }
26 class SiStripFedCabling;
27 
28 namespace sistrip {
29 
31  {
32  public:
34  {
35  public:
36  std::auto_ptr< FEDRawDataCollection > rawData;
37  std::auto_ptr< std::vector<uint32_t> > totalEventCounters;
38  std::auto_ptr< std::vector<uint32_t> > l1aCounters;
39  std::auto_ptr< std::vector<uint32_t> > apvAddresses;
40  std::auto_ptr< edm::DetSetVector<SiStripRawDigi> > scopeDigis;
41  std::auto_ptr< edm::DetSetVector<SiStripRawDigi> > payloadDigis;
42  std::auto_ptr< edm::DetSetVector<SiStripRawDigi> > reorderedDigis;
43  std::auto_ptr< edm::DetSetVector<SiStripRawDigi> > virginRawDigis;
45  //NB. This will remove all elements in the containers pasted in. It does not copy the data.
47  std::vector<uint32_t>& theTotalEventCounters,
48  std::vector<uint32_t>& theL1ACounters,
49  std::vector<uint32_t>& theAPVAddresses,
50  std::vector< edm::DetSet<SiStripRawDigi> >* theScopeDigisVector,
51  std::vector< edm::DetSet<SiStripRawDigi> >* thePayloadDigisVector,
52  std::vector< edm::DetSet<SiStripRawDigi> >* theReorderedDigisVector,
53  std::vector< edm::DetSet<SiStripRawDigi> >* theVirginRawDigisVector);
54  //does not copy, orginal object looses ownership of collections
56  };
58  typedef std::set<EventID> SpyEventList;
59 
61  virtual ~SpyEventMatcher();
62  //set up the internal map of eventID, to apvAddress
63  void initialize();
64  //check if there is any data for an event. Returns NULL if not or a pointer to a list of matches if they exist
65  const SpyEventList* matchesForEvent(const uint32_t eventId, const uint8_t apvAddress) const;
66  //get data for matching FEDs (non-const because reading events from the source modifies it)
67  void getMatchedCollections(const uint32_t eventId, const uint8_t apvAddress, const SpyEventList* matchingEvents,
68  const SiStripFedCabling& cabling, SpyDataCollections& collectionsToCreate);
69  private:
70  class EventKey
71  {
72  public:
73  EventKey(const uint32_t eventId, const uint8_t apvAddress);
74  uint32_t eventId() const { return eventId_; }
75  uint8_t apvAddress() const { return apvAddress_; }
76  bool operator < (const EventKey& rhs) const;
77  private:
78  uint32_t eventId_;
79  uint8_t apvAddress_;
80  };
81  typedef std::vector<uint32_t> Counters;
82  //class to wrap counters that can take ownership of them or not.
83  //It behaves like the counters themself but, it actualy holds a pointer to them and dletes them if necessary
85  {
86  public:
87  CountersWrapper(const Counters* theCounters);
88  CountersWrapper(Counters* theCounters, const bool takeOwnership);
90  const Counters::value_type operator [] (const size_t i) const { return (*pConst)[i]; };
91  const Counters::value_type at(const size_t i) const { return pConst->at(i); };
92  Counters::const_iterator begin() const { return pConst->begin(); }
93  Counters::const_iterator end() const { return pConst->end(); }
94  private:
95  const Counters* pConst;
97  bool deleteP;
98  };
99  typedef boost::shared_ptr<CountersWrapper> CountersPtr;
100 
101  //source for spy events
103  //reference counted pointer to an event
105 
106  static std::auto_ptr<Source> constructSource(const edm::ParameterSet& sourceConfig);
107  bool addNextEventToMap();
108  template <class T> static const T* getProduct(const SpyEventPtr event, const edm::InputTag& tag);
109  static CountersPtr getCounters(const SpyEventPtr event, const edm::InputTag& tag, const bool mapKeyIsByFedID = true);
112  static void findMatchingFeds(const uint32_t eventId, const uint8_t apvAddress,
113  CountersPtr totalEventCounters,
114  CountersPtr l1aCounters,
115  CountersPtr apvAddresses,
116  std::set<uint16_t>& matchingFeds);
117  static void mergeMatchingData(const std::set<uint16_t>& matchingFeds,
118  const FEDRawDataCollection& inputRawData,
119  CountersPtr inputTotalEventCounters,
120  CountersPtr inputL1ACounters,
121  CountersPtr inputAPVAddresses,
122  const edm::DetSetVector<SiStripRawDigi>* inputScopeDigis,
123  const edm::DetSetVector<SiStripRawDigi>* inputPayloadDigis,
124  const edm::DetSetVector<SiStripRawDigi>* inputReorderedDigis,
125  const edm::DetSetVector<SiStripRawDigi>* inputVirginRawDigis,
126  FEDRawDataCollection& outputRawData,
127  std::vector<uint32_t>& outputTotalEventCounters,
128  std::vector<uint32_t>& outputL1ACounters,
129  std::vector<uint32_t>& outputAPVAddresses,
130  std::vector< edm::DetSet<SiStripRawDigi> >* outputScopeDigisVector,
131  std::vector< edm::DetSet<SiStripRawDigi> >* outputPayloadDigisVector,
132  std::vector< edm::DetSet<SiStripRawDigi> >* outputReorderedDigisVector,
133  std::vector< edm::DetSet<SiStripRawDigi> >* outputVirginRawDigisVector,
134  const SiStripFedCabling& cabling);
135 
136  std::map<EventKey,SpyEventList> eventMatches_;
145  std::auto_ptr<Source> source_;
146  uint32_t counterDiffMax_;
147  static const char* mlLabel_;
148  };
149 
150  template <class T> const T* SpyEventMatcher::getProduct(const SpyEventPtr event, const edm::InputTag& tag)
151  {
152  LogDebug(mlLabel_) << "Retrieving product " << tag;
153  const boost::shared_ptr< const edm::Wrapper<T> > productWrapper = edm::getProductByTag<T>(*event,tag);
154  if (productWrapper) {
155  return productWrapper->product();
156  } else {
157  return NULL;
158  }
159  }
160 
162  {
163  return ( (this->eventId_<rhs.eventId_) ? true : ( ((this->eventId_==rhs.eventId_) && (this->apvAddress_<rhs.apvAddress_)) ? true : false) );
164  }
165 
166 }
167 
168 #endif //ndef DQM_SiStripMonitorHardware_SiStripSpyEventMatcher_H
169 
170 #endif //SiStripMonitorHardware_BuildEventMatchingCode
#define LogDebug(id)
CountersWrapper(const Counters *theCounters)
edm::VectorInputSource Source
int i
Definition: DBlmapReader.cc:9
std::auto_ptr< std::vector< uint32_t > > apvAddresses
Source::EventPrincipalVectorElement SpyEventPtr
SpyEventPtr readSpecificEvent(const edm::EventID &id)
const SpyEventList * matchesForEvent(const uint32_t eventId, const uint8_t apvAddress) const
std::vector< uint32_t > Counters
boost::shared_ptr< CountersWrapper > CountersPtr
std::auto_ptr< Source > source_
const Counters::value_type operator[](const size_t i) const
#define NULL
Definition: scimark2.h:8
void getMatchedCollections(const uint32_t eventId, const uint8_t apvAddress, const SpyEventList *matchingEvents, const SiStripFedCabling &cabling, SpyDataCollections &collectionsToCreate)
std::auto_ptr< std::vector< uint32_t > > l1aCounters
std::auto_ptr< std::vector< uint32_t > > totalEventCounters
Counters::const_iterator end() const
std::auto_ptr< edm::DetSetVector< SiStripRawDigi > > reorderedDigis
static const T * getProduct(const SpyEventPtr event, const edm::InputTag &tag)
std::set< EventID > SpyEventList
bool operator<(const EventKey &rhs) const
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
Container::value_type value_type
static std::auto_ptr< Source > constructSource(const edm::ParameterSet &sourceConfig)
EventKey(const uint32_t eventId, const uint8_t apvAddress)
std::auto_ptr< edm::DetSetVector< SiStripRawDigi > > scopeDigis
SpyDataCollections & operator=(SpyDataCollections original)
std::auto_ptr< FEDRawDataCollection > rawData
SpyEventPtr readNextEvent()
Counters::const_iterator begin() const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
boost::shared_ptr< EventPrincipal > EventPrincipalVectorElement
std::auto_ptr< edm::DetSetVector< SiStripRawDigi > > virginRawDigis
const Counters::value_type at(const size_t i) const
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 SpyEventPtr event, const edm::InputTag &tag, const bool mapKeyIsByFedID=true)
SpyEventMatcher(const edm::ParameterSet &config)
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
long double T
std::map< EventKey, SpyEventList > eventMatches_
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)