23 typedef typename T::const_iterator
col_cit;
28 typedef typename std::vector<cand_type>
cand_vec;
29 typedef typename std::pair<cand_type,cand_type>
cand_pair;
30 typedef typename de_trait::coll_type
const*
typeT;
45 <<
": creating instance of type: " <<
GetName(0)
46 <<
", data size:" <<
data_->size() <<
" ncand:" <<
ncand_[0]
47 <<
", emul size:" <<
emul_->size() <<
" ncand:" <<
ncand_[1]
48 <<
".\n" << std::flush;
67 if(
debug_ && (i<0 || i>2) )
69 <<
"DEcompare illegal number of candidates request flag:"<<i<<
"\n";
76 inline int de_type()
const {
return de_trait::de_type();}
82 std::stringstream
ss(
"");
105 template <
typename T>
108 std::cout <<
" DEcompare::do_compare... "
109 << GetName() <<
"\n" << std::flush;
110 t_match = CompareCollections(os,dump);
112 if(t_match) sprintf(ok,
"successful");
113 else sprintf(ok,
"failed");
114 if(dump==-1 || (dump==1 && !t_match))
115 os <<
" ..." << GetName()
116 <<
" data and emulator comparison: " << ok << std::endl;
120 template <
typename T>
123 for (
col_cit it = col->begin(); it!=col->end(); it++) {
131 template <
typename T>
135 std::cout <<
" DEcompare::CompareCollections...\n"<< std::flush;
137 int ndata = get_ncand(0);
138 int nemul = get_ncand(1);
139 assert (ndata || nemul);
141 cand_vec data_good, emul_good, data_bad, emul_bad;
142 data_good.reserve(data_->size());
143 emul_good.reserve(emul_->size());
144 data_bad .reserve(data_->size());
145 emul_bad .reserve(emul_->size());
148 match &= SortCollections(data_good,emul_good,data_bad,emul_bad);
152 <<
" data_bad:" << data_bad .size()
153 <<
" emul_bad:" << emul_bad .size()
154 <<
" data_good:" << data_good.size()
155 <<
" emul_good:" << emul_good.size()
156 <<
" data_:" << data_->size()
157 <<
" emul_:" << emul_->size()
158 <<
".\n" <<std::flush;
160 if(dump==-1 || (dump==1 && !match)) {
161 os <<
" number of candidates: " << ndata;
164 os <<
" (data) " << nemul <<
" (emul) disagree";
172 col_sz ndt=0, nem=0, nde=0;
177 ndt = data_bad.size();
178 nem = emul_bad.size();
179 nde = (ndt>nem)?ndt:nem;
181 itd = data_bad.begin();
182 itm = emul_bad.begin();
185 os <<
" un-matched (" << nde <<
")\n";
189 if (
i< ndt &&
i< nem) prtmode=0;
190 else if(i< ndt && i>=nem) prtmode=1;
191 else if(
i>=ndt &&
i< nem) prtmode=2;
195 DumpCandidate(itd,itm,os,prtmode);
196 else if(prtmode==0) {
197 if( (dump==2 && !de_utils.de_equal_loc(*itd,*itm)) ||
198 (dump==3 && de_utils.de_equal_loc(*itd,*itm)) )
199 DumpCandidate(itd,itm,os,prtmode);
204 if(de_utils.de_equal_loc(*itd,*itm)) {
205 deDigiColl_.push_back( de_utils.DEDigi(itd,itm,1) );
207 deDigiColl_.push_back( de_utils.DEDigi(itd,itm,2) );
209 }
else if (prtmode==1) {
210 deDigiColl_.push_back( de_utils.DEDigi(itd,itd,3) );
211 }
else if (prtmode==2) {
212 deDigiColl_.push_back( de_utils.DEDigi(itm,itm,4) );
220 itd = data_good.begin();
221 itm = emul_good.begin();
223 assert(data_good.size()==emul_good.size());
225 os <<
" matched (" << data_good.size() <<
")\n";
227 for(
col_sz i=0;
i<data_good.size();
i++) {
228 assert(de_utils.de_equal(*itd,*itm));
230 DumpCandidate(itd,itm,os,prtmode);
231 deDigiColl_.push_back( de_utils.DEDigi(itd,itm,0) );
236 std::cout <<
"DEcompare<T>::CompareCollections end.\n"<< std::flush;
242 template <
typename T>
246 std::cout <<
" DEcompare::SortCollections...\n"<< std::flush;
258 for(
col_cit ite = emul_->begin(); ite != emul_->end(); ite++) {
260 emul_tmp.push_back(*ite);
264 for(
col_cit itd = data_->begin(); itd != data_->end(); itd++) {
266 col_it ite = emul_tmp.end();
267 ite = de_utils.de_find(emul_tmp.begin(),emul_tmp.end(),*itd);
268 if(ite!=emul_tmp.end()) {
269 data_good.push_back(*itd);
270 emul_good.push_back(*ite);
271 ite=emul_tmp.erase(ite);
273 data_tmp.push_back(*itd);
278 for(
col_it itd = data_tmp.begin(); itd != data_tmp.end(); itd++) {
279 for(
col_it ite = emul_tmp.begin(); ite != emul_tmp.end(); ite++) {
280 if(de_utils.de_equal_loc(*itd,*ite)) {
281 data_bad.push_back(*itd);
282 emul_bad.push_back(*ite);
283 itd = data_tmp.erase(itd)-1;
284 ite = emul_tmp.erase(ite)-1;
293 data_bad.insert(data_bad.end(),data_tmp.begin(),data_tmp.end());
294 emul_bad.insert(emul_bad.end(),emul_tmp.begin(),emul_tmp.end());
298 <<
" data_bad:" << data_bad .size()
299 <<
" emul_bad:" << emul_bad .size()
300 <<
" data_good:" << data_good.size()
301 <<
" emul_good:" << emul_good.size()
302 <<
" data: " << get_ncand(data_)
303 <<
" emul: " << get_ncand(emul_)
304 <<
"\n" << std::flush;
306 std::cout <<
"DEcompare<T>::SortCollections end.\n"<< std::flush;
310 template <
typename T>
313 os <<
" data: " <<
print(itd);
315 os <<
" emul: " <<
print(itm) << std::endl;
317 if( !de_utils.de_equal(*itd,*itm) )
bool CompareCollections(std::ofstream &, int dump=0)
std::string print(col_cit it) const
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
de_trait::coll_type const * typeT
int get_ncand(typeT) const
de_trait::cand_type cand_type
bool SortCollections(cand_vec &dg, cand_vec &eg, cand_vec &db, cand_vec &eb)
std::vector< L1DataEmulDigi > L1DEDigiCollection
L1DEDigiCollection getDEDigis() const
int get_ncand(int i) const
std::pair< cand_type, cand_type > cand_pair
Abs< T >::type abs(const T &t)
std::string print() const
std::vector< cand_type > cand_vec
std::string GetName(int i=0) const
bool do_compare(std::ofstream &, int dump=0)
bool DumpCandidate(col_cit itd, col_cit itm, std::ofstream &, int mode=0)
bool is_empty(col_cit it) const
T::const_iterator col_cit
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
volatile std::atomic< bool > shutdown_flag false
de_trait::coll_type coll_type
DEcompare(typeT dt, typeT em)
L1DEDigiCollection deDigiColl_