CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes | Private Types | Private Attributes
DEcompare< T > Class Template Reference

#include <DEcompare.h>

Public Member Functions

bool CompareCollections (std::ostream &, int dump=0)
 
int de_type () const
 
 DEcompare ()
 
 DEcompare (typeT dt, typeT em)
 
bool do_compare (std::ostream &, int dump=0)
 
bool DumpCandidate (col_cit itd, col_cit itm, std::ostream &, int mode=0)
 
bool get_match () const
 
int get_ncand (typeT) const
 
int get_ncand (int i) const
 
L1DEDigiCollection getDEDigis () const
 
std::string GetName (int i=0) const
 
bool is_empty (col_cit it) const
 
std::string print (col_cit it) const
 
std::string print () const
 
bool SortCollections (cand_vec &dg, cand_vec &eg, cand_vec &db, cand_vec &eb)
 
 ~DEcompare ()
 

Static Public Attributes

static const int debug_ = 0
 

Private Types

typedef std::pair< cand_type, cand_typecand_pair
 
typedef de_trait::cand_type cand_type
 
typedef std::vector< cand_typecand_vec
 
typedef T::const_iterator col_cit
 
typedef T::iterator col_it
 
typedef T::size_type col_sz
 
typedef de_trait::coll_type coll_type
 
typedef DEtrait< Tde_trait
 
typedef de_trait::coll_type const * typeT
 

Private Attributes

typeT data_
 
DEutils< Tde_utils
 
L1DEDigiCollection deDigiColl_
 
typeT emul_
 
int ncand_ [2]
 
bool t_match
 

Detailed Description

template<typename T>
class DEcompare< T >

Definition at line 25 of file DEcompare.h.

Member Typedef Documentation

◆ cand_pair

template<typename T>
typedef std::pair<cand_type, cand_type> DEcompare< T >::cand_pair
private

Definition at line 33 of file DEcompare.h.

◆ cand_type

template<typename T>
typedef de_trait::cand_type DEcompare< T >::cand_type
private

Definition at line 31 of file DEcompare.h.

◆ cand_vec

template<typename T>
typedef std::vector<cand_type> DEcompare< T >::cand_vec
private

Definition at line 32 of file DEcompare.h.

◆ col_cit

template<typename T>
typedef T::const_iterator DEcompare< T >::col_cit
private

Definition at line 27 of file DEcompare.h.

◆ col_it

template<typename T>
typedef T::iterator DEcompare< T >::col_it
private

Definition at line 28 of file DEcompare.h.

◆ col_sz

template<typename T>
typedef T::size_type DEcompare< T >::col_sz
private

Definition at line 26 of file DEcompare.h.

◆ coll_type

template<typename T>
typedef de_trait::coll_type DEcompare< T >::coll_type
private

Definition at line 30 of file DEcompare.h.

◆ de_trait

template<typename T>
typedef DEtrait<T> DEcompare< T >::de_trait
private

Definition at line 29 of file DEcompare.h.

◆ typeT

template<typename T>
typedef de_trait::coll_type const* DEcompare< T >::typeT
private

Definition at line 34 of file DEcompare.h.

Constructor & Destructor Documentation

◆ DEcompare() [1/2]

template<typename T>
DEcompare< T >::DEcompare ( )
inline

Definition at line 37 of file DEcompare.h.

37 {};

◆ ~DEcompare()

template<typename T>
DEcompare< T >::~DEcompare ( )
inline

Definition at line 38 of file DEcompare.h.

38 {};

◆ DEcompare() [2/2]

template<typename T>
DEcompare< T >::DEcompare ( typeT  dt,
typeT  em 
)
inline

Definition at line 40 of file DEcompare.h.

References DEcompare< T >::data_, DEcompare< T >::debug_, DEcompare< T >::deDigiColl_, dt, DEcompare< T >::emul_, DEcompare< T >::get_ncand(), DEcompare< T >::GetName(), LogDebug, and DEcompare< T >::ncand_.

40  : data_(dt), emul_(em), t_match(false) {
41  ncand_[0] = get_ncand(dt);
42  ncand_[1] = get_ncand(em);
43  deDigiColl_.clear();
44  if (debug_)
45  LogDebug("DEcompare") << "DEcompare"
46  << ": creating instance of type: " << GetName(0) << ", data size:" << data_->size()
47  << " ncand:" << ncand_[0] << ", emul size:" << emul_->size() << " ncand:" << ncand_[1]
48  << ".\n"
49  << std::flush;
50  };
float dt
Definition: AMPTWrapper.h:136
static const int debug_
Definition: DEcompare.h:93
typeT data_
Definition: DEcompare.h:96
int get_ncand(typeT) const
Definition: DEcompare.h:120
int ncand_[2]
Definition: DEcompare.h:100
std::string GetName(int i=0) const
Definition: DEcompare.h:73
bool t_match
Definition: DEcompare.h:99
typeT emul_
Definition: DEcompare.h:97
#define LogDebug(id)
L1DEDigiCollection deDigiColl_
Definition: DEcompare.h:101

Member Function Documentation

◆ CompareCollections()

template<typename T >
bool DEcompare< T >::CompareCollections ( std::ostream &  os,
int  dump = 0 
)

-— treat NON-AGREEING candidates -—

-— treat AGREEING candidates -—

Definition at line 131 of file DEcompare.h.

References funct::abs(), cms::cuda::assert(), gather_cfg::cout, submitPVValidationJobs::dump, mps_fire::i, and match().

131  {
132  if (debug_)
133  std::cout << " DEcompare::CompareCollections...\n" << std::flush;
134  bool match = true;
135  int ndata = get_ncand(0);
136  int nemul = get_ncand(1);
137  assert(ndata || nemul);
138 
139  cand_vec data_good, emul_good, data_bad, emul_bad;
140  data_good.reserve(data_->size());
141  emul_good.reserve(emul_->size());
142  data_bad.reserve(data_->size());
143  emul_bad.reserve(emul_->size());
144 
145  // find matching candidates -- tbd report order match
146  match &= SortCollections(data_good, emul_good, data_bad, emul_bad);
147 
148  if (debug_)
149  std::cout << "\tDEcompare stats2:"
150  << " data_bad:" << data_bad.size() << " emul_bad:" << emul_bad.size() << " data_good:" << data_good.size()
151  << " emul_good:" << emul_good.size() << " data_:" << data_->size() << " emul_:" << emul_->size() << ".\n"
152  << std::flush;
153 
154  if (dump == -1 || (dump == 1 && !match)) {
155  os << " number of candidates: " << ndata;
156  if (ndata != nemul) {
157  match &= false;
158  os << " (data) " << nemul << " (emul) disagree";
159  }
160  os << std::endl;
161  }
162 
163  col_cit itd, itm;
164  int prtmode = 0;
165  col_sz ndt = 0, nem = 0, nde = 0;
166  deDigiColl_.clear();
167 
169 
170  ndt = data_bad.size();
171  nem = emul_bad.size();
172  nde = (ndt > nem) ? ndt : nem;
173 
174  itd = data_bad.begin();
175  itm = emul_bad.begin();
176 
177  if (dump == -1)
178  os << " un-matched (" << nde << ")\n";
179 
180  for (col_sz i = 0; i < nde; i++) {
181  if (i < ndt && i < nem)
182  prtmode = 0; //dt+em
183  else if (i < ndt && i >= nem)
184  prtmode = 1; //dt
185  else if (i >= ndt && i < nem)
186  prtmode = 2; //em
187  else
188  assert(0);
189 
190  if (abs(dump) == 1)
191  DumpCandidate(itd, itm, os, prtmode);
192  else if (prtmode == 0) {
193  if ((dump == 2 && !de_utils.de_equal_loc(*itd, *itm)) || (dump == 3 && de_utils.de_equal_loc(*itd, *itm)))
194  DumpCandidate(itd, itm, os, prtmode);
195  }
196 
197  // Fill in DEdigi collection
198  if (prtmode == 0) {
199  if (de_utils.de_equal_loc(*itd, *itm)) {
200  deDigiColl_.push_back(de_utils.DEDigi(itd, itm, 1));
201  } else {
202  deDigiColl_.push_back(de_utils.DEDigi(itd, itm, 2));
203  }
204  } else if (prtmode == 1) {
205  deDigiColl_.push_back(de_utils.DEDigi(itd, itd, 3));
206  } else if (prtmode == 2) {
207  deDigiColl_.push_back(de_utils.DEDigi(itm, itm, 4));
208  }
209 
210  itd++;
211  itm++;
212  }
213 
215 
216  itd = data_good.begin();
217  itm = emul_good.begin();
218 
219  assert(data_good.size() == emul_good.size());
220  if (dump == -1)
221  os << " matched (" << data_good.size() << ")\n";
222 
223  for (col_sz i = 0; i < data_good.size(); i++) {
224  assert(de_utils.de_equal(*itd, *itm));
225  if (dump == -1)
226  DumpCandidate(itd, itm, os, prtmode);
227  deDigiColl_.push_back(de_utils.DEDigi(itd, itm, 0));
228  itd++;
229  itm++;
230  }
231 
232  if (debug_)
233  std::cout << "DEcompare<T>::CompareCollections end.\n" << std::flush;
234 
235  return match;
236 }
bool DumpCandidate(col_cit itd, col_cit itm, std::ostream &, int mode=0)
Definition: DEcompare.h:304
static const int debug_
Definition: DEcompare.h:93
typeT data_
Definition: DEcompare.h:96
bool SortCollections(cand_vec &dg, cand_vec &eg, cand_vec &db, cand_vec &eb)
Definition: DEcompare.h:239
assert(be >=bs)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< cand_type > cand_vec
Definition: DEcompare.h:32
int get_ncand(typeT) const
Definition: DEcompare.h:120
T::size_type col_sz
Definition: DEcompare.h:26
T::const_iterator col_cit
Definition: DEcompare.h:27
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
DEutils< T > de_utils
Definition: DEcompare.h:98
typeT emul_
Definition: DEcompare.h:97
L1DEDigiCollection deDigiColl_
Definition: DEcompare.h:101

◆ de_type()

template<typename T>
int DEcompare< T >::de_type ( ) const
inline

Definition at line 76 of file DEcompare.h.

76 { return de_trait::de_type(); }

◆ do_compare()

template<typename T >
bool DEcompare< T >::do_compare ( std::ostream &  os,
int  dump = 0 
)

Definition at line 105 of file DEcompare.h.

References gather_cfg::cout, submitPVValidationJobs::dump, convertSQLiteXML::ok, and AlCaHLTBitMon_QueryRunRegistry::string.

105  {
106  if (debug_)
107  std::cout << " DEcompare::do_compare... " << GetName() << "\n" << std::flush;
109  std::string ok;
110  if (t_match)
111  ok = "successful";
112  else
113  ok = "failed";
114  if (dump == -1 || (dump == 1 && !t_match))
115  os << " ..." << GetName() << " data and emulator comparison: " << ok.c_str() << std::endl;
116  return t_match;
117 }
bool CompareCollections(std::ostream &, int dump=0)
Definition: DEcompare.h:131
static const int debug_
Definition: DEcompare.h:93
std::string GetName(int i=0) const
Definition: DEcompare.h:73
bool t_match
Definition: DEcompare.h:99

◆ DumpCandidate()

template<typename T >
bool DEcompare< T >::DumpCandidate ( col_cit  itd,
col_cit  itm,
std::ostream &  os,
int  mode = 0 
)

Definition at line 304 of file DEcompare.h.

References ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, and print().

304  {
305  if (mode != 2)
306  os << " data: " << print(itd);
307  if (mode != 1)
308  os << " emul: " << print(itm) << std::endl;
309  if (mode == 0)
310  if (!de_utils.de_equal(*itd, *itm))
311  return false;
312  return true;
313 }
std::string print() const
Definition: DEcompare.h:81
DEutils< T > de_utils
Definition: DEcompare.h:98

◆ get_match()

template<typename T>
bool DEcompare< T >::get_match ( ) const
inline

Definition at line 77 of file DEcompare.h.

References DEcompare< T >::t_match.

77 { return t_match; }
bool t_match
Definition: DEcompare.h:99

◆ get_ncand() [1/2]

template<typename T >
int DEcompare< T >::get_ncand ( typeT  col) const

Definition at line 120 of file DEcompare.h.

References cuy::col, and utils::is_empty().

Referenced by DEcompare< T >::DEcompare().

120  {
121  int ncand = 0;
122  for (col_cit it = col->begin(); it != col->end(); it++) {
123  if (!is_empty(it)) {
124  ncand++;
125  }
126  }
127  return ncand;
128 }
bool is_empty(col_cit it) const
Definition: DEcompare.h:75
T::const_iterator col_cit
Definition: DEcompare.h:27
col
Definition: cuy.py:1009

◆ get_ncand() [2/2]

template<typename T>
int DEcompare< T >::get_ncand ( int  i) const
inline

Definition at line 67 of file DEcompare.h.

References DEcompare< T >::debug_, mps_fire::i, LogDebug, and DEcompare< T >::ncand_.

67  {
68  if (debug_ && (i < 0 || i > 2))
69  LogDebug("DEcompare") << "DEcompare illegal number of candidates request flag:" << i << "\n";
70  return ncand_[i];
71  }
static const int debug_
Definition: DEcompare.h:93
int ncand_[2]
Definition: DEcompare.h:100
#define LogDebug(id)

◆ getDEDigis()

template<typename T>
L1DEDigiCollection DEcompare< T >::getDEDigis ( ) const
inline

Definition at line 79 of file DEcompare.h.

References DEcompare< T >::deDigiColl_.

79 { return deDigiColl_; }
L1DEDigiCollection deDigiColl_
Definition: DEcompare.h:101

◆ GetName()

template<typename T>
std::string DEcompare< T >::GetName ( int  i = 0) const
inline

Definition at line 73 of file DEcompare.h.

References DEcompare< T >::de_utils, and mps_fire::i.

Referenced by DEcompare< T >::DEcompare().

73 { return de_utils.GetName(i); }
DEutils< T > de_utils
Definition: DEcompare.h:98

◆ is_empty()

template<typename T>
bool DEcompare< T >::is_empty ( col_cit  it) const
inline

Definition at line 75 of file DEcompare.h.

References DEcompare< T >::de_utils.

Referenced by dirstructure.Directory::__repr__(), utils_v2.StatisticalTest::do_test(), and DEcompare< T >::print().

75 { return de_utils.is_empty(it); }
DEutils< T > de_utils
Definition: DEcompare.h:98

◆ print() [1/2]

template<typename T>
std::string DEcompare< T >::print ( col_cit  it) const
inline

Definition at line 74 of file DEcompare.h.

References DEcompare< T >::de_utils.

74 { return de_utils.print(it); }
DEutils< T > de_utils
Definition: DEcompare.h:98

◆ print() [2/2]

template<typename T>
std::string DEcompare< T >::print ( void  ) const
inline

Definition at line 81 of file DEcompare.h.

References DEcompare< T >::data_, DEcompare< T >::emul_, DEcompare< T >::is_empty(), and contentValuesCheck::ss.

81  {
82  std::stringstream ss("");
83  for (col_cit itd = data_->begin(); itd != data_->end(); itd++)
84  if (!is_empty(itd))
85  ss << " data: " << print(itd);
86  for (col_cit itm = emul_->begin(); itm != emul_->end(); itm++)
87  if (!is_empty(itm))
88  ss << " emul: " << print(itm);
89  return ss.str();
90  }
bool is_empty(col_cit it) const
Definition: DEcompare.h:75
typeT data_
Definition: DEcompare.h:96
std::string print() const
Definition: DEcompare.h:81
T::const_iterator col_cit
Definition: DEcompare.h:27
typeT emul_
Definition: DEcompare.h:97

◆ SortCollections()

template<typename T >
bool DEcompare< T >::SortCollections ( cand_vec dg,
cand_vec eg,
cand_vec db,
cand_vec eb 
)

Definition at line 239 of file DEcompare.h.

References gather_cfg::cout, utils::is_empty(), match(), and jetUpdater_cfi::sort.

239  {
240  if (debug_)
241  std::cout << " DEcompare::SortCollections...\n" << std::flush;
242 
243  bool match = true;
244  cand_vec data_tmp, emul_tmp;
245 
246  data_good.clear();
247  emul_good.clear();
248  data_bad.clear();
249  emul_bad.clear();
250  data_tmp.clear();
251  emul_tmp.clear();
252 
253  for (col_cit ite = emul_->begin(); ite != emul_->end(); ite++) {
254  if (!is_empty(ite)) {
255  emul_tmp.push_back(*ite);
256  }
257  }
258 
259  for (col_cit itd = data_->begin(); itd != data_->end(); itd++) {
260  if (is_empty(itd))
261  continue;
262  col_it ite = emul_tmp.end();
263  ite = de_utils.de_find(emul_tmp.begin(), emul_tmp.end(), *itd);
264  if (ite != emul_tmp.end()) {
265  data_good.push_back(*itd);
266  emul_good.push_back(*ite);
267  ite = emul_tmp.erase(ite);
268  } else {
269  data_tmp.push_back(*itd);
270  match &= false;
271  }
272  }
273 
274  for (col_it itd = data_tmp.begin(); itd != data_tmp.end(); itd++) {
275  for (col_it ite = emul_tmp.begin(); ite != emul_tmp.end(); ite++) {
276  if (de_utils.de_equal_loc(*itd, *ite)) {
277  data_bad.push_back(*itd);
278  emul_bad.push_back(*ite);
279  itd = data_tmp.erase(itd) - 1;
280  ite = emul_tmp.erase(ite) - 1;
281  break;
282  }
283  }
284  }
285 
286  sort(data_tmp.begin(), data_tmp.end(), de_rank<coll_type>());
287  sort(emul_tmp.begin(), emul_tmp.end(), de_rank<coll_type>());
288 
289  data_bad.insert(data_bad.end(), data_tmp.begin(), data_tmp.end());
290  emul_bad.insert(emul_bad.end(), emul_tmp.begin(), emul_tmp.end());
291 
292  if (debug_)
293  std::cout << "\tDEcompare stats1:"
294  << " data_bad:" << data_bad.size() << " emul_bad:" << emul_bad.size() << " data_good:" << data_good.size()
295  << " emul_good:" << emul_good.size() << " data: " << get_ncand(data_) << " emul: " << get_ncand(emul_)
296  << "\n"
297  << std::flush;
298  if (debug_)
299  std::cout << "DEcompare<T>::SortCollections end.\n" << std::flush;
300  return match;
301 }
bool is_empty(col_cit it) const
Definition: DEcompare.h:75
— order candidates —
Definition: DEcompare.h:18
static const int debug_
Definition: DEcompare.h:93
typeT data_
Definition: DEcompare.h:96
std::vector< cand_type > cand_vec
Definition: DEcompare.h:32
int get_ncand(typeT) const
Definition: DEcompare.h:120
T::const_iterator col_cit
Definition: DEcompare.h:27
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
DEutils< T > de_utils
Definition: DEcompare.h:98
T::iterator col_it
Definition: DEcompare.h:28
typeT emul_
Definition: DEcompare.h:97

Member Data Documentation

◆ data_

template<typename T>
typeT DEcompare< T >::data_
private

Definition at line 96 of file DEcompare.h.

Referenced by DEcompare< T >::DEcompare(), and DEcompare< T >::print().

◆ de_utils

template<typename T>
DEutils<T> DEcompare< T >::de_utils
private

◆ debug_

template<typename T>
const int DEcompare< T >::debug_ = 0
static

Definition at line 93 of file DEcompare.h.

Referenced by DEcompare< T >::DEcompare(), and DEcompare< T >::get_ncand().

◆ deDigiColl_

template<typename T>
L1DEDigiCollection DEcompare< T >::deDigiColl_
private

Definition at line 101 of file DEcompare.h.

Referenced by DEcompare< T >::DEcompare(), and DEcompare< T >::getDEDigis().

◆ emul_

template<typename T>
typeT DEcompare< T >::emul_
private

Definition at line 97 of file DEcompare.h.

Referenced by DEcompare< T >::DEcompare(), and DEcompare< T >::print().

◆ ncand_

template<typename T>
int DEcompare< T >::ncand_[2]
private

Definition at line 100 of file DEcompare.h.

Referenced by DEcompare< T >::DEcompare(), and DEcompare< T >::get_ncand().

◆ t_match

template<typename T>
bool DEcompare< T >::t_match
private

Definition at line 99 of file DEcompare.h.

Referenced by DEcompare< T >::get_match().