CMS 3D CMS Logo

DataReducer.h
Go to the documentation of this file.
1 #ifndef DataReducer_h
2 #define DataReducer_h
3 
6 
7 // #include <list>
8 
9 #include <vector>
10 #include <string>
11 #include <map>
12 #include <iostream>
13 #include <list>
14 #include <cctype>
15 
16 // this class is used to reduce the DCS data to a
17 // reasonable amount of offline DB IOVs
18 
19 template <typename T>
20 class DataReducer {
21 public:
22  typedef DataReducer<T> self;
23  typedef typename std::pair<EcalLogicID, T> DataItem;
24  typedef typename std::map<EcalLogicID, T> DataMap;
25  typedef typename std::list<std::pair<Tm, DataMap> >::iterator list_iterator;
26  typedef typename std::map<EcalLogicID, T>::iterator map_iterator;
27 
28  template <typename U>
29  class MyData {
30  public:
31  typedef MyData<U> self;
32  bool operator<(const MyData& rhs) {
33  Tm t1 = m_iData.first;
34  Tm t2 = rhs.m_iData.first;
35  long long diff_time = (t1.microsTime() - t2.microsTime());
36  return (diff_time < 0);
37  };
38 
39  std::pair<Tm, std::pair<EcalLogicID, U> > m_iData;
40  };
41 
42  typedef typename std::list<MyData<T> >::iterator iterator;
43 
44  DataReducer() { m_printout = false; };
46 
47  static const int TIMELIMIT = 60; // the time limit in seconds to consider two events in the same IOV creation
48 
50  m_list = _list;
51  m_list.sort();
52  };
53 
54  void getReducedDataList(std::list<std::pair<Tm, DataMap> >* my_new_list) {
55  /* ***************************************
56  to get reduced data list
57  *************************************** */
58 
59  std::cout << " we are in getReducedDataList " << std::endl;
60  // std::list< std::pair< Tm, DataMap > > my_new_list ;
61  iterator i;
62  std::cout << " created iterator " << std::endl;
63 
64  bool firstpass = true;
65  unsigned int s_old = 0;
66  for (i = m_list.begin(); i != m_list.end(); i++) {
67  Tm t = (*i).m_iData.first;
68  DataItem d = (*i).m_iData.second;
69  bool new_time_change = true;
70 
71  DataMap the_data;
72  list_iterator it_good = my_new_list->end();
73 
74  if (!firstpass) {
75  list_iterator it;
76  int last_state = -1;
77  for (it = my_new_list->begin(); it != my_new_list->end(); ++it) {
78  // check on the state
79 
80  std::pair<Tm, DataMap> pair_new_list = *it;
81 
82  Tm t_l = pair_new_list.first;
83  DataMap dd = pair_new_list.second;
84  map_iterator ip;
85  for (ip = dd.begin(); ip != dd.end(); ++ip) {
86  EcalLogicID ecid = ip->first;
87  T dcs_dat = ip->second;
88  if (ecid.getLogicID() == d.first.getLogicID())
89  last_state = dcs_dat.getStatus();
90  }
91 
92  long long diff_time = (t.microsTime() - t_l.microsTime()) / 1000000;
93  if (diff_time < 0)
94  diff_time = -diff_time;
95  if (diff_time < TIMELIMIT) {
96  // data change happened at the same moment
97 
98  new_time_change = false;
99  // add data to the list
100  the_data = pair_new_list.second;
101  it_good = it;
102  }
103  }
104 
105  if (last_state != d.second.getStatus()) {
106  if (!new_time_change) {
107  std::pair<Tm, DataMap> pair_new_list = *it_good;
108  Tm t_good = pair_new_list.first;
109  the_data = pair_new_list.second;
110  the_data.insert(d);
111  std::pair<Tm, DataMap> pair_new_good;
112  pair_new_good.first = t_good;
113  pair_new_good.second = the_data;
114 
115  my_new_list->erase(it_good);
116  my_new_list->push_back(pair_new_good);
117 
118  } else if (new_time_change) {
119  std::pair<Tm, DataMap> p_new;
120  p_new.first = t;
121  DataMap a_map;
122  a_map.insert(d);
123  p_new.second = a_map;
124  my_new_list->push_back(p_new);
125  }
126  }
127  list_iterator it3;
128  if (my_new_list->size() > s_old) {
129  s_old = my_new_list->size();
130  if (m_printout) {
131  std::cout << "************" << std::endl;
132  for (it3 = my_new_list->begin(); it3 != my_new_list->end(); ++it3) {
133  std::pair<Tm, DataMap> pair_new_list3 = *it3;
134  Tm t3 = pair_new_list3.first;
135  std::cout << " T =" << t3.str() << std::endl;
136  }
137  std::cout << "************" << std::endl;
138  }
139  }
140 
141  } else {
142  // first pass write it anyway
143  std::pair<Tm, DataMap> p_new;
144  p_new.first = t;
145  DataMap a_map;
146  a_map.insert(d);
147  p_new.second = a_map;
148  my_new_list->insert(my_new_list->begin(), p_new);
149  firstpass = false;
150  }
151  }
152 
153  if (m_printout) {
154  list_iterator it3;
155  for (it3 = my_new_list->begin(); it3 != my_new_list->end(); ++it3) {
156  std::pair<Tm, DataMap> pair_new_list3 = *it3;
157  Tm t3 = pair_new_list3.first;
158  std::cout << " T =" << t3.str() << std::endl;
159  }
160  }
161  };
162 
163 private:
164  // std::list< std::pair< Tm, DataItem > > m_list;
165  std::list<MyData<T> > m_list;
167 };
168 
169 #endif
RandomServiceHelper.t2
t2
Definition: RandomServiceHelper.py:257
mps_fire.i
i
Definition: mps_fire.py:355
DataReducer::setDataList
void setDataList(std::list< MyData< T > > _list)
Definition: DataReducer.h:49
DataReducer::MyData::m_iData
std::pair< Tm, std::pair< EcalLogicID, U > > m_iData
Definition: DataReducer.h:37
DataReducer::TIMELIMIT
static const int TIMELIMIT
Definition: DataReducer.h:47
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DataReducer::map_iterator
std::map< EcalLogicID, T >::iterator map_iterator
Definition: DataReducer.h:26
DataReducer::MyData
Definition: DataReducer.h:29
EcalLogicID::getLogicID
int getLogicID() const
Definition: EcalLogicID.cc:28
DataReducer::m_printout
bool m_printout
Definition: DataReducer.h:166
DataReducer::DataItem
std::pair< EcalLogicID, T > DataItem
Definition: DataReducer.h:23
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
DataReducer::DataMap
std::map< EcalLogicID, T > DataMap
Definition: DataReducer.h:24
EcalLogicID
Definition: EcalLogicID.h:7
OrderedSet.t
t
Definition: OrderedSet.py:90
RandomServiceHelper.t3
t3
Definition: RandomServiceHelper.py:258
createTree.dd
string dd
Definition: createTree.py:154
Tm
Definition: Tm.h:13
DataReducer::list_iterator
std::list< std::pair< Tm, DataMap > >::iterator list_iterator
Definition: DataReducer.h:25
Tm.h
DataReducer::getReducedDataList
void getReducedDataList(std::list< std::pair< Tm, DataMap > > *my_new_list)
Definition: DataReducer.h:54
DataReducer::m_list
std::list< MyData< T > > m_list
Definition: DataReducer.h:161
Tm::microsTime
uint64_t microsTime() const
Definition: Tm.cc:96
DataReducer::MyData::operator<
bool operator<(const MyData &rhs)
Definition: DataReducer.h:32
DataReducer::DataReducer
DataReducer()
Definition: DataReducer.h:44
EcalLogicID.h
DataReducer::~DataReducer
~DataReducer()
Definition: DataReducer.h:45
T
long double T
Definition: Basic3DVectorLD.h:48
DataReducer::iterator
std::list< MyData< T > >::iterator iterator
Definition: DataReducer.h:42
DataReducer
Definition: DataReducer.h:20
ztail.d
d
Definition: ztail.py:151
list
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 list("!*", "!HLTx*" if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL. It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of "!*" before the partial wildcard feature was incorporated). Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run