22 using AllDist = std::vector<std::vector<float>>;
54 #include <Math/VectorUtil.h> 65 return Algo::kBruteForce;
66 }
else if (
algoName ==
"SwitchMode") {
67 return Algo::kSwitchMode;
69 return Algo::kMixMode;
71 throw cms::Exception(
"OneToOne Constructor") <<
"wrong matching method in ParameterSet";
77 case Algo::kBruteForce:
79 case Algo::kSwitchMode:
92 produces<CandViewMatchMap>(
"src2mtc");
93 produces<CandViewMatchMap>(
"mtc2src");
102 edm::LogVerbatim(
"CandOneToOneDeltaRMatcher") <<
"======== Source Collection =======";
105 <<
" pt source " <<
c->pt() <<
" " <<
c->eta() <<
" " <<
c->phi() << endl;
107 edm::LogVerbatim(
"CandOneToOneDeltaRMatcher") <<
"======== Matched Collection =======";
110 <<
" pt source " <<
c->pt() <<
" " <<
c->eta() <<
" " <<
c->phi() << endl;
113 const int nSrc =
source->size();
114 const int nMtc =
matched->size();
121 std::vector<std::vector<float>> allDist;
124 allDist.reserve(
source->size());
126 vector<float> tempAllDist;
127 tempAllDist.reserve(
matched->size());
129 tempAllDist.push_back(
DeltaR(iSr->p4(), iMt->p4()));
131 allDist.emplace_back(
std::move(tempAllDist));
134 allDist.reserve(
matched->size());
136 vector<float> tempAllDist;
137 tempAllDist.reserve(
source->size());
139 tempAllDist.push_back(
DeltaR(iSr->p4(), iMt->p4()));
141 allDist.emplace_back(
std::move(tempAllDist));
156 int nLoopToDo = (
int)(TMath::Factorial(
nMax) / TMath::Factorial(
nMax -
nMin));
157 edm::LogVerbatim(
"CandOneToOneDeltaRMatcher") <<
"nLoop:" << nLoopToDo << endl;
171 if (nLoopToDo < 10000) {
180 <<
"min: " <<
i1 <<
" " << bestCB[
i1] <<
" " << allDist[
i1][bestCB[
i1]];
189 auto matchMapSrMt = std::make_unique<CandViewMatchMap>();
190 auto matchMapMtSr = std::make_unique<CandViewMatchMap>();
192 for (
int c = 0;
c !=
nMin;
c++) {
220 for (vector<int>::const_iterator it = best.begin(); it != best.end(); it++) {
221 myLength += allDist[row][*it];
240 float totalDeltaR = 0;
241 float BestTotalDeltaR = 1000;
252 for (
int cnt = 0; cnt < TMath::Factorial(
nMin); cnt++) {
253 totalDeltaR =
length(cb, allDist);
254 if (totalDeltaR < BestTotalDeltaR) {
255 BestTotalDeltaR = totalDeltaR;
258 next_permutation(cb.begin(), cb.end());
281 if (allDist[
i1][
i2] < allDist[
i1][minInd])
283 bestCB.push_back(minInd);
291 if (bestCB[
i1] == bestCB[
i2]) {
293 if (allDist[
i1][(bestCB[
i1])] <= allDist[
i2][(bestCB[
i2])]) {
294 allDist[
i2][(bestCB[
i2])] = 1000;
297 if (allDist[
i2][
i3] < allDist[
i2][minInd])
301 allDist[
i1][(bestCB[
i1])] = 1000;
304 if (allDist[
i1][
i3] < allDist[
i1][minInd])
Log< level::Info, true > LogVerbatim
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::vector< int > AlgoBruteForce(int, int, const AllDist &) const
double length(const std::vector< int > &, const AllDist &) const
#define DEFINE_FWK_MODULE(type)
std::vector< std::vector< float > > AllDist
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
CandOneToOneDeltaRMatcher(const edm::ParameterSet &)
std::vector< int > AlgoSwitchMethod(int, int, AllDist &) const
static Algo algo(std::string const &)
const edm::EDGetTokenT< reco::CandidateView > sourceToken_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
const edm::EDGetTokenT< reco::CandidateView > matchedToken_
static const char * algoName(Algo)
bool next_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end)
static std::string const source