49 template<
typename T1,
typename T2>
84 template<
typename T1,
typename T2>
86 : srcCands_ (iConfig.getParameter<edm::InputTag> (
"srcObject"))
87 , srcObjects_ (iConfig.getParameter<std::vector<edm::InputTag> >(
"srcObjectsToMatch"))
88 , deltaRMax_ (iConfig.getParameter<double> (
"deltaRMax"))
89 , moduleLabel_(iConfig.getParameter<std::
string> (
"@module_label"))
90 , objCut_(iConfig.existsAs<std::
string>(
"srcObjectSelection") ? iConfig.getParameter<std::
string>(
"srcObjectSelection") :
"",
true)
91 ,objMatchCut_(iConfig.existsAs<std::
string>(
"srcObjectsToMatchSelection") ? iConfig.getParameter<std::
string>(
"srcObjectsToMatchSelection") :
"",
true)
95 produces<std::vector<T1> >();
100 template<
typename T1,
typename T2>
110 template<
typename T1,
typename T2>
113 std::auto_ptr<std::vector<T1> > cleanObjects(
new std::vector<T1 >);
118 bool* isMatch =
new bool[candidates->size()];
119 for (
unsigned int iObject=0;iObject<candidates->size();iObject++) isMatch[iObject] =
false;
121 for (
unsigned int iSrc=0;iSrc<srcObjects_.size();iSrc++) {
125 if(objects->size()==0)
continue;
127 for (
unsigned int iObject=0;iObject<candidates->size();iObject++) {
128 const T1& candidate = candidates->at(iObject);
129 if (!objCut_(candidate))
continue;
132 for (
unsigned int iObj=0;iObj<objects->size();iObj++) {
133 const T2&
obj = objects->at(iObj);
134 if (!objMatchCut_(obj))
continue;
136 if (deltaR<deltaRMax_) isMatch[iObject] =
true;
143 unsigned int counter=0;
145 for (tIt = candidates->begin(); tIt != endcands; ++tIt, ++counter) {
146 if(isMatch[counter]) cleanObjects->push_back( *tIt );
149 nObjectsTot_ +=candidates->size();
150 nObjectsMatch_+=cleanObjects->size();
153 iEvent.
put(cleanObjects);
158 template<
typename T1,
typename T2>
161 std::stringstream ss;
162 ss<<
"nObjectsTot="<<nObjectsTot_<<
" nObjectsMatched="<<nObjectsMatch_
163 <<
" fObjectsMatch="<<100.*(nObjectsMatch_/(double)nObjectsTot_)<<
"%\n";
164 std::cout<<
"++++++++++++++++++++++++++++++++++++++++++++++++++"
165 <<
"\n"<<moduleLabel_<<
"(ObjectViewMatcher) SUMMARY:\n"<<ss.str()
166 <<
"++++++++++++++++++++++++++++++++++++++++++++++++++"
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) override
ObjectViewMatcher< reco::Photon, reco::Track > TrackMatchedPhotonProducer
ObjectViewMatcher< reco::Jet, reco::Track > TrackMatchedJetProducer
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
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_