25 double lenght(
const std::vector<int>&);
50 #include <Math/VectorUtil.h>
56 using namespace ROOT::Math::VectorUtil;
57 using namespace stdcomb;
62 algoMethod_(cfg.getParameter<
string>(
"algoMethod")) {
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();
89 const int nMin =
min(source->size(), matched->size());
90 const int nMax =
max(source->size(), 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";
150 for (
int i1 = 0; i1 < nMin; i1++)
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;
218 for (
int i1 = 0; i1 < nMax; i1++)
221 for (
int i1 = 0; i1 < nMin; i1++)
226 for (
int cnt = 0; cnt < TMath::Factorial(nMin); cnt++) {
228 if (totalDeltaR < BestTotalDeltaR) {
229 BestTotalDeltaR = totalDeltaR;
232 next_permutation(cb.begin(), cb.end());
252 for (
int i1 = 0; i1 < nMin; i1++) {
254 for (
int i2 = 1; i2 < nMax; i2++)
257 bestCB.push_back(minInd);
263 for (
int i1 = 0; i1 < nMin; i1++) {
264 for (
int i2 = i1 + 1; i2 < nMin; i2++) {
265 if (bestCB[i1] == bestCB[i2]) {
268 AllDist[i2][(bestCB[i2])] = 1000;
270 for (
int i3 = 1; i3 < nMax; i3++)
275 AllDist[i1][(bestCB[i1])] = 1000;
277 for (
int i3 = 1; i3 < nMax; i3++)
Log< level::Info, true > LogVerbatim
edm::EDGetTokenT< reco::CandidateView > sourceToken_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const edm::EventSetup & c
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
~CandOneToOneDeltaRMatcher() override
std::vector< int > AlgoSwitchMethod(int, int)
std::vector< int > AlgoBruteForce(int, int)
CandOneToOneDeltaRMatcher(const edm::ParameterSet &)
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< std::vector< float > > AllDist
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
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_