23 double lenght( std::vector<int> );
29 std::vector < std::vector<float> >
AllDist;
50 #include <Math/VectorUtil.h>
56 using namespace ROOT::Math::VectorUtil;
57 using namespace stdcomb;
60 source_( cfg.getParameter<
InputTag>(
"src" ) ),
61 matched_( cfg.getParameter<
InputTag>(
"matched" ) ),
62 algoMethod_( cfg.getParameter<string>(
"algoMethod" ) ) {
63 produces<CandViewMatchMap>(
"src2mtc");
64 produces<CandViewMatchMap>(
"mtc2src");
77 edm::LogVerbatim(
"CandOneToOneDeltaRMatcher") <<
"======== Source Collection =======";
79 edm::LogVerbatim(
"CandOneToOneDeltaRMatcher") <<
" pt source " <<
c->pt() <<
" " <<
c->eta() <<
" " <<
c->phi() << endl;
81 edm::LogVerbatim(
"CandOneToOneDeltaRMatcher") <<
"======== Matched Collection =======";
83 edm::LogVerbatim(
"CandOneToOneDeltaRMatcher") <<
" 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() );
91 if( nMin < 1 )
return;
97 vector <float> tempAllDist;
99 iMt != matched->end();
101 tempAllDist.push_back(
DeltaR( iSr->p4() , iMt->p4() ) );
103 AllDist.push_back(tempAllDist);
108 iMt != matched->end();
110 vector <float> tempAllDist;
112 iSr != source->end();
114 tempAllDist.push_back(
DeltaR( iSr->p4() , iMt->p4() ) );
116 AllDist.push_back(tempAllDist);
132 int nLoopToDo = (int) ( TMath::Factorial(nMax) / TMath::Factorial(nMax - nMin) );
133 edm::LogVerbatim(
"CandOneToOneDeltaRMatcher") <<
"nLoop:" << nLoopToDo << endl;
150 if( nLoopToDo < 10000 ) {
157 throw cms::Exception(
"OneToOne Constructor") <<
"wrong matching method in ParameterSet";
160 for(
int i1=0; i1<nMin; i1++)
edm::LogVerbatim(
"CandOneToOneDeltaRMatcher") <<
"min: " << i1 <<
" " << bestCB[i1] <<
" " <<
AllDist[i1][bestCB[i1]];
172 for(
int c = 0;
c != nMin;
c ++ ) {
173 if( source->size() <= matched->size() ) {
174 matchMapSrMt->insert( source ->refAt(
c ), matched->refAt(bestCB[
c] ) );
175 matchMapMtSr->insert( matched->refAt(bestCB[c] ), source ->refAt(c ) );
177 matchMapSrMt->insert( source ->refAt(bestCB[
c] ), matched->refAt(c ) );
178 matchMapMtSr->insert( matched->refAt(c ), source ->refAt(bestCB[c] ) );
193 evt.
put( matchMapSrMt,
"src2mtc" );
194 evt.
put( matchMapMtSr,
"mtc2src" );
203 for(vector<int>::iterator it=best.begin(); it!=best.end(); it++ ) {
225 float BestTotalDeltaR=1000;
227 for(
int i1=0; i1<nMax; i1++) ca.push_back(i1);
228 for(
int i1=0; i1<nMin; i1++) cb.push_back(i1);
233 for(
int cnt=0;cnt<TMath::Factorial(nMin); cnt++)
236 if ( totalDeltaR < BestTotalDeltaR ) {
237 BestTotalDeltaR = totalDeltaR;
240 next_permutation( cb.begin() , cb.end() );
262 for(
int i1=0; i1<nMin; i1++) {
264 for(
int i2=1; i2<nMax; i2++)
if(
AllDist[i1][i2] <
AllDist[i1][minInd] ) minInd = i2;
265 bestCB.push_back(minInd);
271 for(
int i1=0;i1<nMin;i1++){
272 for(
int i2=i1+1;i2<nMin;i2++){
273 if ( bestCB[i1] == bestCB[i2] ) {
276 AllDist[i2][(bestCB[i2])]= 1000;
278 for(
int i3=1; i3<nMax; i3++)
if(
AllDist[i2][i3] <
AllDist[i2][minInd] ) minInd = i3;
281 AllDist[i1][(bestCB[i1])]= 1000;
283 for(
int i3=1; i3<nMax; i3++)
if(
AllDist[i1][i3] <
AllDist[i1][minInd] ) minInd = i3;
~CandOneToOneDeltaRMatcher()
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
std::vector< std::vector< float > > AllDist
#define DEFINE_FWK_MODULE(type)
std::vector< int > AlgoSwitchMethod(int, int)
std::vector< int > AlgoBruteForce(int, int)
CandOneToOneDeltaRMatcher(const edm::ParameterSet &)
const T & max(const T &a, const T &b)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
double lenght(std::vector< int >)
void produce(edm::Event &, const edm::EventSetup &)
bool next_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end)
edm::AssociationMap< edm::OneToOneGeneric< reco::CandidateView, reco::CandidateView > > CandViewMatchMap