9 |
|
#include "UserCode/L1RpcTriggerAnalysis/interface/CSCDigiSpec.h" |
10 |
|
#include "UserCode/L1RpcTriggerAnalysis/interface/RPCDigiSpec.h" |
11 |
|
|
12 |
+ |
bool Pattern::operator==(const Pattern& o) const |
13 |
+ |
{ |
14 |
+ |
unsigned int thissize = theData.size(); |
15 |
+ |
if (thissize != o.size()) return false; |
16 |
+ |
|
17 |
+ |
for (unsigned int idx=0; idx<thissize; idx++) { |
18 |
+ |
if (theData[idx].first != o.theData[idx].first) return false; |
19 |
+ |
if (theData[idx].second != o.theData[idx].second) return false; |
20 |
+ |
} |
21 |
+ |
|
22 |
+ |
return true; |
23 |
+ |
} |
24 |
|
|
25 |
< |
bool Pattern::add ( std::pair<uint32_t, unsigned int > aData) |
25 |
> |
Pattern Pattern::addOrCopy( std::pair<uint32_t, unsigned int > aData) |
26 |
|
{ |
27 |
< |
for (DataType::const_iterator it=theData.begin(); it!= theData.end(); it++) { |
28 |
< |
if (it->first == aData.first) { |
29 |
< |
return false; |
27 |
> |
|
28 |
> |
for (unsigned int idx=0; idx < theData.size(); ++idx) { |
29 |
> |
if (theData[idx].first == aData.first) { |
30 |
> |
Pattern modified = *this; |
31 |
> |
modified.theData[idx].second = aData.second; |
32 |
> |
return modified; |
33 |
> |
// if (*this == modified) return Pattern(); // nothing to do |
34 |
> |
// else return modified; // really duplicate |
35 |
|
} |
36 |
|
} |
37 |
|
theData.push_back(aData); |
38 |
< |
return true; |
38 |
> |
return Pattern(); |
39 |
|
} |
40 |
|
|
41 |
< |
bool Pattern::add ( std::vector<Pattern> & vpat, std::pair<uint32_t, unsigned int > aData) |
41 |
> |
void Pattern::add ( std::vector<Pattern> & vpat, std::pair<uint32_t, unsigned int > aData) |
42 |
|
{ |
26 |
– |
bool allOK = true; |
43 |
|
std::vector<Pattern> copied; |
44 |
|
for (std::vector<Pattern>::iterator ip = vpat.begin(); ip != vpat.end(); ++ip) { |
45 |
< |
if (! ip->add(aData) ) { |
46 |
< |
allOK = false; |
31 |
< |
Pattern modified = *ip; |
32 |
< |
for (auto ic =modified.theData.begin(); ic!=modified.theData.end(); ic++) { |
33 |
< |
if (ic->first==aData.first) {ic->second = aData.second; break; } |
34 |
< |
} |
35 |
< |
copied.push_back(modified); |
36 |
< |
} |
45 |
> |
Pattern modified = ip->addOrCopy(aData); |
46 |
> |
if (modified && (find(copied.begin(), copied.end(), modified) == copied.end()) ) copied.push_back(modified); |
47 |
|
} |
48 |
|
if (copied.size() != 0) vpat.insert(vpat.end(), copied.begin(), copied.end()); |
39 |
– |
return allOK; |
49 |
|
} |
50 |
|
|
51 |
|
|