25 double lenght(
const std::vector<int>&);
50 #include <Math/VectorUtil.h> 63 produces<CandViewMatchMap>(
"src2mtc");
64 produces<CandViewMatchMap>(
"mtc2src");
75 edm::LogVerbatim(
"CandOneToOneDeltaRMatcher") <<
"======== Source Collection =======";
78 <<
" pt source " <<
c->pt() <<
" " <<
c->eta() <<
" " <<
c->phi() << endl;
80 edm::LogVerbatim(
"CandOneToOneDeltaRMatcher") <<
"======== Matched Collection =======";
83 <<
" pt source " <<
c->pt() <<
" " <<
c->eta() <<
" " <<
c->phi() << endl;
86 const int nSrc = source->
size();
87 const int nMtc = matched->
size();
96 vector<float> tempAllDist;
98 tempAllDist.push_back(
DeltaR(iSr->p4(), iMt->p4()));
100 AllDist.push_back(tempAllDist);
105 vector<float> tempAllDist;
107 tempAllDist.push_back(
DeltaR(iSr->p4(), iMt->p4()));
109 AllDist.push_back(tempAllDist);
125 int nLoopToDo = (
int)(TMath::Factorial(nMax) / TMath::Factorial(nMax - nMin));
126 edm::LogVerbatim(
"CandOneToOneDeltaRMatcher") <<
"nLoop:" << nLoopToDo << endl;
140 if (nLoopToDo < 10000) {
147 throw cms::Exception(
"OneToOne Constructor") <<
"wrong matching method in ParameterSet";
152 <<
"min: " <<
i1 <<
" " << bestCB[
i1] <<
" " <<
AllDist[
i1][bestCB[
i1]];
161 auto matchMapSrMt = std::make_unique<CandViewMatchMap>();
162 auto matchMapMtSr = std::make_unique<CandViewMatchMap>();
164 for (
int c = 0;
c !=
nMin;
c++) {
165 if (source->
size() <= matched->
size()) {
166 matchMapSrMt->insert(source->
refAt(
c), matched->
refAt(bestCB[
c]));
167 matchMapMtSr->insert(matched->
refAt(bestCB[c]), source->
refAt(c));
169 matchMapSrMt->insert(source->
refAt(bestCB[
c]), matched->
refAt(c));
170 matchMapMtSr->insert(matched->
refAt(c), source->
refAt(bestCB[c]));
194 for (vector<int>::const_iterator it = best.begin(); it != best.end(); it++) {
214 float totalDeltaR = 0;
215 float BestTotalDeltaR = 1000;
224 for (
int cnt = 0; cnt < TMath::Factorial(nMin); cnt++) {
226 if (totalDeltaR < BestTotalDeltaR) {
227 BestTotalDeltaR = totalDeltaR;
230 next_permutation(cb.begin(), cb.end());
255 bestCB.push_back(minInd);
263 if (bestCB[
i1] == bestCB[
i2]) {
edm::EDGetTokenT< reco::CandidateView > sourceToken_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
~CandOneToOneDeltaRMatcher() override
std::vector< int > AlgoSwitchMethod(int, int)
std::vector< int > AlgoBruteForce(int, int)
CandOneToOneDeltaRMatcher(const edm::ParameterSet &)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
RefToBase< value_type > refAt(size_type i) const
#define DEFINE_FWK_MODULE(type)
const_iterator begin() const
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< std::vector< float > > AllDist
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
const_iterator end() const
double lenght(const std::vector< int > &)
bool next_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end)
static std::string const source
edm::EDGetTokenT< reco::CandidateView > matchedToken_