CMS 3D CMS Logo

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 
12 #include <set>
13 #include <map>
14 #include <memory>
15 #include <vector>
16 #include <cstdint>
17 
18 //forward declarations
20 class SiStripRawDigi;
21 namespace edm {
22  template <class T>
23  class DetSetVector;
24  template <class T>
25  struct DetSet;
26  class EventID;
27  class ParameterSet;
28 } // namespace edm
29 class SiStripFedCabling;
30 
31 namespace sistrip {
32 
34  public:
36  public:
37  std::unique_ptr<FEDRawDataCollection> rawData;
38  std::unique_ptr<std::vector<uint32_t> > totalEventCounters;
39  std::unique_ptr<std::vector<uint32_t> > l1aCounters;
40  std::unique_ptr<std::vector<uint32_t> > apvAddresses;
41  std::unique_ptr<edm::DetSetVector<SiStripRawDigi> > scopeDigis;
42  std::unique_ptr<edm::DetSetVector<SiStripRawDigi> > payloadDigis;
43  std::unique_ptr<edm::DetSetVector<SiStripRawDigi> > reorderedDigis;
44  std::unique_ptr<edm::DetSetVector<SiStripRawDigi> > virginRawDigis;
46  //NB. This will remove all elements in the containers pasted in. It does not copy the data.
48  std::vector<uint32_t>& theTotalEventCounters,
49  std::vector<uint32_t>& theL1ACounters,
50  std::vector<uint32_t>& theAPVAddresses,
51  std::vector<edm::DetSet<SiStripRawDigi> >* theScopeDigisVector,
52  std::vector<edm::DetSet<SiStripRawDigi> >* thePayloadDigisVector,
53  std::vector<edm::DetSet<SiStripRawDigi> >* theReorderedDigisVector,
54  std::vector<edm::DetSet<SiStripRawDigi> >* theVirginRawDigisVector);
55  };
56  struct MatchingOutput {
57  explicit MatchingOutput(FEDRawDataCollection& outputRawData);
59  std::vector<uint32_t> outputTotalEventCounters_;
60  std::vector<uint32_t> outputL1ACounters_;
61  std::vector<uint32_t> outputAPVAddresses_;
62  std::shared_ptr<std::vector<edm::DetSet<SiStripRawDigi> > > outputScopeDigisVector_;
63  std::shared_ptr<std::vector<edm::DetSet<SiStripRawDigi> > > outputPayloadDigisVector_;
64  std::shared_ptr<std::vector<edm::DetSet<SiStripRawDigi> > > outputReorderedDigisVector_;
65  std::shared_ptr<std::vector<edm::DetSet<SiStripRawDigi> > > outputVirginRawDigisVector_;
66  std::set<uint16_t> alreadyMergedFeds_;
67  };
68 
70  typedef std::set<EventID> SpyEventList;
71 
73  virtual ~SpyEventMatcher();
74  //set up the internal map of eventID, to apvAddress
75  void initialize();
76  //check if there is any data for an event. Returns NULL if not or a pointer to a list of matches if they exist
77  const SpyEventList* matchesForEvent(const uint32_t eventId, const uint8_t apvAddress) const;
78  //get data for matching FEDs (non-const because reading events from the source modifies it)
79  void getMatchedCollections(const uint32_t eventId,
80  const uint8_t apvAddress,
81  const SpyEventList* matchingEvents,
82  const SiStripFedCabling& cabling,
83  SpyDataCollections& collectionsToCreate);
84  //helper for getMatchedCollections()
85  void getCollections(const edm::EventPrincipal& event,
86  const uint32_t eventId,
87  const uint8_t apvAddress,
88  const SiStripFedCabling& cabling,
89  MatchingOutput& matchingOutput);
90 
91  private:
92  class EventKey {
93  public:
94  EventKey(const uint32_t eventId, const uint8_t apvAddress);
95  uint32_t eventId() const { return eventId_; }
96  uint8_t apvAddress() const { return apvAddress_; }
97  bool operator<(const EventKey& rhs) const;
98 
99  private:
100  uint32_t eventId_;
101  uint8_t apvAddress_;
102  };
103  typedef std::vector<uint32_t> Counters;
104  //class to wrap counters that can take ownership of them or not.
105  //It behaves like the counters themself but, it actualy holds a pointer to them and dletes them if necessary
107  public:
108  CountersWrapper(const Counters* theCounters);
109  CountersWrapper(Counters* theCounters, const bool takeOwnership);
110  ~CountersWrapper();
111  const Counters::value_type operator[](const size_t i) const { return (*pConst)[i]; };
112  const Counters::value_type at(const size_t i) const { return pConst->at(i); };
113  Counters::const_iterator begin() const { return pConst->begin(); }
114  Counters::const_iterator end() const { return pConst->end(); }
115 
116  private:
117  const Counters* pConst;
118  Counters* p;
119  bool deleteP;
120  };
121  typedef std::shared_ptr<CountersWrapper> CountersPtr;
122 
123  //source for spy events
125  //reference counted pointer to an event
126 
127  std::unique_ptr<Source> constructSource(const edm::ParameterSet& sourceConfig);
128  void addNextEventToMap(const edm::EventPrincipal& nextSpyEvent);
129  template <class T>
130  static const T* getProduct(const edm::EventPrincipal& event, const edm::InputTag& tag);
131  static CountersPtr getCounters(const edm::EventPrincipal& event,
132  const edm::InputTag& tag,
133  const bool mapKeyIsByFedID = true);
134  void operator()(const edm::EventPrincipal& event);
135  static void findMatchingFeds(const uint32_t eventId,
136  const uint8_t apvAddress,
137  CountersPtr totalEventCounters,
138  CountersPtr l1aCounters,
139  CountersPtr apvAddresses,
140  std::set<uint16_t>& matchingFeds);
141  static void mergeMatchingData(const std::set<uint16_t>& matchingFeds,
142  const FEDRawDataCollection& inputRawData,
143  CountersPtr inputTotalEventCounters,
144  CountersPtr inputL1ACounters,
145  CountersPtr inputAPVAddresses,
146  const edm::DetSetVector<SiStripRawDigi>* inputScopeDigis,
147  const edm::DetSetVector<SiStripRawDigi>* inputPayloadDigis,
148  const edm::DetSetVector<SiStripRawDigi>* inputReorderedDigis,
149  const edm::DetSetVector<SiStripRawDigi>* inputVirginRawDigis,
150  FEDRawDataCollection& outputRawData,
151  std::vector<uint32_t>& outputTotalEventCounters,
152  std::vector<uint32_t>& outputL1ACounters,
153  std::vector<uint32_t>& outputAPVAddresses,
154  std::vector<edm::DetSet<SiStripRawDigi> >* outputScopeDigisVector,
155  std::vector<edm::DetSet<SiStripRawDigi> >* outputPayloadDigisVector,
156  std::vector<edm::DetSet<SiStripRawDigi> >* outputReorderedDigisVector,
157  std::vector<edm::DetSet<SiStripRawDigi> >* outputVirginRawDigisVector,
158  const SiStripFedCabling& cabling);
159 
160  std::map<EventKey, SpyEventList> eventMatches_;
169  uint32_t counterDiffMax_;
170  std::shared_ptr<edm::ProductRegistry> productRegistry_;
171  std::unique_ptr<edm::VectorInputSource> const source_;
172  std::unique_ptr<edm::ProcessConfiguration> processConfiguration_;
173  std::unique_ptr<edm::EventPrincipal> eventPrincipal_;
174  static const char* mlLabel_;
175  };
176 
177  template <class T>
179  LogDebug(mlLabel_) << "Retrieving product " << tag;
180  // Note: The third argument to getProductByTag can be a nullptr
181  // as long as unscheduled execution of an EDProducer cannot occur
182  // as a result of this function call (and with the current implementation
183  // of SpyEventMatcher unscheduled execution never happens).
184  const std::shared_ptr<const edm::Wrapper<T> > productWrapper = edm::getProductByTag<T>(event, tag, nullptr);
185  if (productWrapper) {
186  return productWrapper->product();
187  } else {
188  return nullptr;
189  }
190  }
191 
193  return ((this->eventId_ < rhs.eventId_)
194  ? true
195  : (((this->eventId_ == rhs.eventId_) && (this->apvAddress_ < rhs.apvAddress_)) ? true : false));
196  }
197 
198 } // namespace sistrip
199 
200 #endif //ndef DQM_SiStripMonitorHardware_SiStripSpyEventMatcher_H
201 
202 #endif //SiStripMonitorHardware_BuildEventMatchingCode
#define LogDebug(id)
bool operator<(DetSet< T > const &x, DetSet< T > const &y)
Definition: DetSet.h:90
static AlgebraicMatrix initialize()
edm::VectorInputSource Source
std::unique_ptr< edm::DetSetVector< SiStripRawDigi > > payloadDigis
std::map< EventKey, SpyEventList > eventMatches_
std::shared_ptr< std::vector< edm::DetSet< SiStripRawDigi > > > outputVirginRawDigisVector_
std::vector< uint32_t > Counters
std::unique_ptr< edm::EventPrincipal > eventPrincipal_
const Counters::value_type operator[](const size_t i) const
T const * getProduct(RefCore const &ref)
Definition: RefCoreGet.h:37
std::unique_ptr< edm::ProcessConfiguration > processConfiguration_
Definition: config.py:1
std::shared_ptr< std::vector< edm::DetSet< SiStripRawDigi > > > outputScopeDigisVector_
sistrip classes
std::shared_ptr< std::vector< edm::DetSet< SiStripRawDigi > > > outputReorderedDigisVector_
std::unique_ptr< FEDRawDataCollection > rawData
std::shared_ptr< CountersWrapper > CountersPtr
std::unique_ptr< std::vector< uint32_t > > totalEventCounters
std::set< EventID > SpyEventList
std::shared_ptr< edm::ProductRegistry > productRegistry_
std::unique_ptr< std::vector< uint32_t > > apvAddresses
std::unique_ptr< edm::DetSetVector< SiStripRawDigi > > scopeDigis
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
std::unique_ptr< edm::VectorInputSource > const source_
std::unique_ptr< edm::DetSetVector< SiStripRawDigi > > reorderedDigis
Counters::const_iterator begin() const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
bool operator<(DTCELinkId const &lhs, DTCELinkId const &rhs)
Definition: DTCELinkId.h:69
HLT enums.
std::unique_ptr< edm::DetSetVector< SiStripRawDigi > > virginRawDigis
const Counters::value_type at(const size_t i) const
std::unique_ptr< std::vector< uint32_t > > l1aCounters
std::shared_ptr< std::vector< edm::DetSet< SiStripRawDigi > > > outputPayloadDigisVector_
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
long double T
Definition: event.py:1