CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
17 
18 // this class is used to reduce the DCS data to a
19 // reasonable amount of offline DB IOVs
20 
21 
22 template < typename T >
24 {
25 
26  public:
27 
28  typedef DataReducer<T> self;
29  typedef typename std::pair< EcalLogicID, T > DataItem;
30  typedef typename std::map< EcalLogicID, T > DataMap ;
31  typedef typename std::list< std::pair< Tm, DataMap > >::iterator list_iterator;
32  typedef typename std::map< EcalLogicID, T >::iterator map_iterator;
33 
34 
35  template < typename U >
36  class MyData
37  {
38  public:
39  typedef MyData<U> self;
40  bool operator < (const MyData& rhs)
41  {
42  Tm t1=m_iData.first;
43  Tm t2=rhs.m_iData.first;
44  long long diff_time= (t1.microsTime() - t2.microsTime()) ;
45  return ( diff_time<0 );
46  };
47 
48  std::pair< Tm, std::pair< EcalLogicID, U > > m_iData;
49 
50  };
51 
52  typedef typename std::list< MyData<T> >::iterator iterator;
53 
54 
55  DataReducer() { m_printout=false; };
57 
58  static const int TIMELIMIT=60; // the time limit in seconds to consider two events in the same IOV creation
59 
60  void setDataList( std::list< MyData<T> > _list ){
61 
62  m_list = _list;
63  m_list.sort();
64 
65  };
66 
67  void getReducedDataList(std::list< std::pair< Tm, DataMap > >* my_new_list) {
68  /* ***************************************
69  to get reduced data list
70  *************************************** */
71 
72  std::cout << " we are in getReducedDataList "<< std::endl;
73  // std::list< std::pair< Tm, DataMap > > my_new_list ;
74  iterator i;
75  std::cout << " created iterator "<< std::endl;
76 
77  bool firstpass=true;
78  unsigned int s_old=0;
79  for ( i=m_list.begin(); i!=m_list.end(); i++){
80 
81  Tm t = (*i).m_iData.first;
82  DataItem d = (*i).m_iData.second;
83  bool new_time_change=true;
84 
85  DataMap the_data;
86  list_iterator it_good=my_new_list->end();
87 
88 
89  if(!firstpass) {
90 
91  list_iterator it;
92  int last_state=-1;
93  for(it =my_new_list->begin(); it!= my_new_list->end(); ++it) {
94 
95  // check on the state
96 
97 
98  std::pair< Tm, DataMap > pair_new_list = *it;
99 
100  Tm t_l = pair_new_list.first;
101  DataMap dd = pair_new_list.second;
102  map_iterator ip;
103  for(ip =dd.begin(); ip!= dd.end(); ++ip) {
104  EcalLogicID ecid = ip->first;
105  T dcs_dat = ip->second;
106  if(ecid.getLogicID()==d.first.getLogicID() ) last_state= dcs_dat.getStatus();
107  }
108 
109  long long diff_time= (t.microsTime() - t_l.microsTime()) /1000000 ;
110  if(diff_time<0) diff_time=-diff_time;
111  if( diff_time < TIMELIMIT ) {
112  // data change happened at the same moment
113 
114 
115  new_time_change=false;
116  // add data to the list
117  the_data = pair_new_list.second;
118  it_good=it;
119 
120  }
121 
122  }
123 
124  if(last_state != d.second.getStatus()){
125  if(!new_time_change ) {
126  std::pair< Tm, DataMap > pair_new_list = *it_good;
127  Tm t_good = pair_new_list.first;
128  the_data = pair_new_list.second;
129  the_data.insert(d);
130  std::pair< Tm, DataMap > pair_new_good;
131  pair_new_good.first=t_good;
132  pair_new_good.second=the_data;
133 
134  my_new_list->erase(it_good);
135  my_new_list->push_back(pair_new_good);
136 
137 
138  } else if(new_time_change) {
139 
140  std::pair< Tm, DataMap > p_new;
141  p_new.first=t;
142  DataMap a_map;
143  a_map.insert( d );
144  p_new.second=a_map;
145  my_new_list->push_back(p_new);
146 
147  }
148  }
149  list_iterator it3;
150  if(my_new_list->size() > s_old) {
151  s_old=my_new_list->size();
152  if(m_printout){
153  std::cout << "************"<< std::endl;
154  for(it3 =my_new_list->begin(); it3!= my_new_list->end(); ++it3) {
155  std::pair< Tm, DataMap > pair_new_list3 = *it3;
156  Tm t3 = pair_new_list3.first;
157  std::cout << " T =" << t3.str()<< std::endl;
158  }
159  std::cout << "************"<< std::endl;
160  }
161  }
162 
163 
164  } else {
165  // first pass write it anyway
166  std::pair< Tm, DataMap > p_new;
167  p_new.first=t;
168  DataMap a_map;
169  a_map.insert( d );
170  p_new.second=a_map;
171  my_new_list->insert(my_new_list->begin(),p_new);
172  firstpass=false;
173 
174  }
175 
176  }
177 
178 
179  if(m_printout) {
180  list_iterator it3;
181  for(it3 =my_new_list->begin(); it3!= my_new_list->end(); ++it3) {
182  std::pair< Tm, DataMap > pair_new_list3 = *it3;
183  Tm t3 = pair_new_list3.first;
184  std::cout << " T =" << t3.str()<< std::endl;
185  }
186  }
187 
188  };
189 
190 
191  private:
192  // std::list< std::pair< Tm, DataItem > > m_list;
193  std::list< MyData<T> > m_list;
195 };
196 
197 
198 #endif
199 
static const int TIMELIMIT
Definition: DataReducer.h:58
void setDataList(std::list< MyData< T > > _list)
Definition: DataReducer.h:60
int i
Definition: DBlmapReader.cc:9
std::list< MyData< T > > m_list
Definition: DataReducer.h:188
uint64_t microsTime() const
Definition: Tm.cc:126
tuple d
Definition: ztail.py:151
bool m_printout
Definition: DataReducer.h:194
std::list< MyData< T > >::iterator iterator
Definition: DataReducer.h:52
int getLogicID() const
Definition: EcalLogicID.cc:41
void getReducedDataList(std::list< std::pair< Tm, DataMap > > *my_new_list)
Definition: DataReducer.h:67
bool operator<(const MyData &rhs)
Definition: DataReducer.h:40
std::pair< EcalLogicID, T > DataItem
Definition: DataReducer.h:29
std::map< EcalLogicID, T >::iterator map_iterator
Definition: DataReducer.h:32
std::pair< Tm, std::pair< EcalLogicID, U > > m_iData
Definition: DataReducer.h:46
std::string str() const
Definition: Tm.cc:89
std::map< EcalLogicID, T > DataMap
Definition: DataReducer.h:30
std::list< std::pair< Tm, DataMap > >::iterator list_iterator
Definition: DataReducer.h:31
tuple cout
Definition: gather_cfg.py:121
long double T
Definition: Tm.h:13
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