48 template <
typename T1,
typename T2>
80 template <
typename T1,
typename T2>
82 : srcCandsToken_(consumes<edm::
View<T1>>(iConfig.getParameter<edm::
InputTag>(
"srcObject"))),
98 produces<std::vector<T1>>();
102 template <
typename T1,
typename T2>
110 template <
typename T1,
typename T2>
112 auto cleanObjects = std::make_unique<std::vector<T1>>();
115 iEvent.
getByToken(srcCandsToken_, candidates);
117 bool* isMatch =
new bool[candidates->size()];
118 for (
unsigned int iObject = 0; iObject < candidates->size(); iObject++)
119 isMatch[iObject] =
false;
121 for (
unsigned int iSrc = 0; iSrc < srcObjectsTokens_.size(); iSrc++) {
123 iEvent.
getByToken(srcObjectsTokens_[iSrc], objects);
125 if (objects->empty())
128 for (
unsigned int iObject = 0; iObject < candidates->size(); iObject++) {
129 const T1& candidate = candidates->at(iObject);
130 if (!objCut_(candidate))
133 for (
unsigned int iObj = 0; iObj < objects->size(); iObj++) {
134 const T2&
obj = objects->at(iObj);
135 if (!objMatchCut_(obj))
139 isMatch[iObject] =
true;
146 for (tIt = candidates->
begin(); tIt != endcands; ++tIt, ++
counter) {
147 if (isMatch[counter])
148 cleanObjects->push_back(*tIt);
151 nObjectsTot_ += candidates->size();
152 nObjectsMatch_ += cleanObjects->size();
159 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 <<
"++++++++++++++++++++++++++++++++++++++++++++++++++"
167 << ss.str() <<
"++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
StringCutObjectSelector< T2, true > objMatchCut_
unsigned int nObjectsMatch_
unsigned int nObjectsTot_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
std::vector< edm::EDGetTokenT< edm::View< T2 > > > srcObjectsTokens_
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
edm::EDGetTokenT< edm::View< T1 > > srcCandsToken_
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
StringCutObjectSelector< T1, true > objCut_
const_iterator begin() const
ObjectViewMatcher< reco::Photon, reco::Track > TrackMatchedPhotonProducer
ObjectViewMatcher< reco::Jet, reco::Track > TrackMatchedJetProducer
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
ObjectViewMatcher(const edm::ParameterSet &iConfig)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
static std::atomic< unsigned int > counter
~ObjectViewMatcher() override
deltaRMax_(iConfig.getParameter< double >("deltaRMax"))