50 template<
typename T1,
typename T2>
85 template<
typename T1,
typename T2>
87 : srcCands_ (iConfig.getParameter<edm::InputTag> (
"srcObject"))
88 , srcObjects_ (iConfig.getParameter<std::vector<edm::InputTag> >(
"srcObjectsToMatch"))
89 , deltaRMax_ (iConfig.getParameter<double> (
"deltaRMax"))
90 , moduleLabel_(iConfig.getParameter<std::string> (
"@module_label"))
91 , objCut_(iConfig.existsAs<std::string>(
"srcObjectSelection") ? iConfig.getParameter<std::string>(
"srcObjectSelection") :
"",
true)
92 ,objMatchCut_(iConfig.existsAs<std::string>(
"srcObjectsToMatchSelection") ? iConfig.getParameter<std::string>(
"srcObjectsToMatchSelection") :
"",
true)
96 produces<std::vector<T1> >();
101 template<
typename T1,
typename T2>
111 template<
typename T1,
typename T2>
114 std::auto_ptr<std::vector<T1> > cleanObjects(
new std::vector<T1 >);
119 bool* isMatch =
new bool[candidates->size()];
120 for (
unsigned int iObject=0;iObject<candidates->size();iObject++) isMatch[iObject] =
false;
122 for (
unsigned int iSrc=0;iSrc<srcObjects_.size();iSrc++) {
126 if(objects->size()==0)
continue;
128 for (
unsigned int iObject=0;iObject<candidates->size();iObject++) {
129 const T1& candidate = candidates->at(iObject);
130 if (!objCut_(candidate))
continue;
133 for (
unsigned int iObj=0;iObj<objects->size();iObj++) {
134 const T2&
obj = objects->at(iObj);
135 if (!objMatchCut_(obj))
continue;
137 if (deltaR<deltaRMax_) isMatch[iObject] =
true;
144 unsigned int counter=0;
146 for (tIt = candidates->begin(); tIt != endcands; ++tIt, ++counter) {
147 if(isMatch[counter]) cleanObjects->push_back( *tIt );
150 nObjectsTot_ +=candidates->size();
151 nObjectsMatch_+=cleanObjects->size();
154 iEvent.
put(cleanObjects);
159 template<
typename T1,
typename T2>
162 std::stringstream ss;
163 ss<<
"nObjectsTot="<<nObjectsTot_<<
" nObjectsMatched="<<nObjectsMatch_
164 <<
" fObjectsMatch="<<100.*(nObjectsMatch_/(double)nObjectsTot_)<<
"%\n";
165 std::cout<<
"++++++++++++++++++++++++++++++++++++++++++++++++++"
166 <<
"\n"<<moduleLabel_<<
"(ObjectViewMatcher) SUMMARY:\n"<<ss.str()
167 <<
"++++++++++++++++++++++++++++++++++++++++++++++++++"
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
virtual ~ObjectViewMatcher()
unsigned int nObjectsMatch_
unsigned int nObjectsTot_
#define DEFINE_FWK_MODULE(type)
StringCutObjectSelector< T2, true > objMatchCut_
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
double deltaR(double eta1, double phi1, double eta2, double phi2)
ObjectViewMatcher< reco::Photon, reco::Track > TrackMatchedPhotonProducer
ObjectViewMatcher< reco::Jet, reco::Track > TrackMatchedJetProducer
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
double deltaR(double eta1, double eta2, double phi1, double phi2)
ObjectViewMatcher(const edm::ParameterSet &iConfig)
std::vector< edm::InputTag > srcObjects_
StringCutObjectSelector< T1, true > objCut_