CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TRateHelper.h
Go to the documentation of this file.
1 #ifndef L1TRateHelper_H
2 #define L1TRateHelper_H
3 
7 #include <map>
8 
9 namespace L1TRateHelper {
10 
11  struct TRateStruct {
13  void add(int orbit) {
14  if (orbit < m_orbitLow || m_orbitLow==-1) m_orbitLow=orbit;
15  if (orbit > m_orbitHigh || m_orbitHigh==-1) m_orbitHigh=orbit;
16  ++m_events;
17  };
18  int getTime() { return (m_orbitHigh+m_orbitLow)/2/m_timeBin; }
19  static int getTimeForOrbit(const int &orbit) {return orbit/m_timeBin; };
20  static const int m_timeBin = 11224;
21  int m_orbitLow;
23  int m_events;
24  // (1 s) / (25 ns)) / 3564 = 11 223,3446
25  bool operator()(const int &o1, const int &o2) const {
26  return getTimeForOrbit(o1) < getTimeForOrbit(o2);
27  };
28 
29  };
30 
31  class L1TRateHelper {
32 
33  public:
35 
36 
41  std::pair<int, int> removeAndGetRateForEarliestTime();
42 
44  void addOrbit(int orbit) { if (orbit > m_lastRemovedOrbit) m_rateMap[orbit].add(orbit);};
45 
48  if (m_rateMap.begin() == m_rateMap.end() ) return -1;
49  return m_rateMap.begin()->second.getTime();
50  };
51 
53  int getLastTime() {
54  if (m_rateMap.begin() == m_rateMap.end() ) return -1;
55  return m_rateMap.rbegin()->second.getTime();
56  };
57 
59  int getTimeForOrbit(int orbit) {return TRateStruct::getTimeForOrbit(orbit); };
60 
61  private:
62  typedef std::map <int, TRateStruct, TRateStruct > TRateMap;
66 
67 
68 
69  };
70 }
71 
72 
73 
74 #endif
std::pair< int, int > removeAndGetRateForEarliestTime()
Definition: L1TRateHelper.cc:7
bool operator()(const int &o1, const int &o2) const
Definition: L1TRateHelper.h:25
int getTimeForOrbit(int orbit)
Definition: L1TRateHelper.h:59
static int getTimeForOrbit(const int &orbit)
Definition: L1TRateHelper.h:19
void addOrbit(int orbit)
Adds event with specified orbit. If the event for some reason comes late (after removal of corespondi...
Definition: L1TRateHelper.h:44
std::map< int, TRateStruct, TRateStruct > TRateMap
Definition: L1TRateHelper.h:59
int getEarliestTime()
gets time of earliest event (orbit) recorded in event. Returned time -1 is invalid ...
Definition: L1TRateHelper.h:47
int getLastTime()
gets time of latest event (orbit) recorded in event. Returned time -1 is invalid
Definition: L1TRateHelper.h:53
static const int m_timeBin
Definition: L1TRateHelper.h:20