CMS 3D CMS Logo

PixelClusterCounts.h
Go to the documentation of this file.
1 #ifndef DataFormats_Luminosity_PixelClusterCounts_h
2 #define DataFormats_Luminosity_PixelClusterCounts_h
3 
11 #include <algorithm>
12 #include <string>
13 #include <sstream>
14 #include <iostream>
15 #include <vector>
16 
19 
20 namespace reco {
22  public:
24 
25  void increment(int mD, unsigned int bxID, int count) {
26  size_t modIndex = std::distance(m_ModID.begin(), std::find(m_ModID.begin(), m_ModID.end(), mD));
27  if (modIndex == m_ModID.size()) {
28  m_ModID.push_back(mD);
29  m_counts.resize(m_counts.size() + LumiConstants::numBX, 0);
30  }
31  m_counts.at(LumiConstants::numBX * modIndex + bxID - 1) += count;
32  }
33 
34  void eventCounter(unsigned int bxID) { m_events.at(bxID - 1)++; }
35 
36  void add(reco::PixelClusterCountsInEvent const& pccInEvent) {
37  std::vector<int> const& countsInEvent = pccInEvent.counts();
38  std::vector<int> const& modIDInEvent = pccInEvent.modID();
39  int bxIDInEvent = pccInEvent.bxID();
40  for (unsigned int i = 0; i < modIDInEvent.size(); i++) {
41  increment(modIDInEvent[i], bxIDInEvent, countsInEvent.at(i));
42  }
43  }
44 
45  void merge(reco::PixelClusterCounts const& pcc) {
46  std::vector<int> const& counts = pcc.readCounts();
47  std::vector<int> const& modIDs = pcc.readModID();
48  std::vector<int> const& events = pcc.readEvents();
49  for (unsigned int i = 0; i < modIDs.size(); i++) {
50  for (unsigned int bxID = 0; bxID < LumiConstants::numBX; ++bxID) {
51  increment(modIDs[i], bxID + 1, counts.at(i * LumiConstants::numBX + bxID));
52  }
53  }
54  for (unsigned int i = 0; i < LumiConstants::numBX; ++i) {
55  m_events[i] += events[i];
56  }
57  }
58 
59  void reset() {
60  m_counts.clear();
61  m_ModID.clear();
62  m_events.clear();
63  m_events.resize(LumiConstants::numBX, 0);
64  }
65 
66  std::vector<int> const& readCounts() const { return (m_counts); }
67  std::vector<int> const& readEvents() const { return (m_events); }
68  std::vector<int> const& readModID() const { return (m_ModID); }
69 
70  private:
71  std::vector<int> m_counts;
72  std::vector<int> m_events;
73  std::vector<int> m_ModID;
74  };
75 
76 } // namespace reco
77 #endif
std::vector< int > const & readModID() const
unsigned int const & bxID() const
static const unsigned int numBX
Definition: LumiConstants.h:8
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void add(reco::PixelClusterCountsInEvent const &pccInEvent)
std::vector< int > const & readEvents() const
std::vector< int > m_events
void merge(reco::PixelClusterCounts const &pcc)
std::vector< int > const & readCounts() const
void increment(int mD, unsigned int bxID, int count)
std::vector< int > const & modID() const
fixed size matrix
std::vector< int > m_counts
void eventCounter(unsigned int bxID)
std::vector< int > m_ModID
int events
std::vector< int > const & counts() const