52 template <
typename T1,
typename T2>
62 template <
typename T1,
typename T2>
95 template <
typename T1,
typename T2>
97 : srcCandsToken_(this->consumes(iConfig.getParameter<
edm::
InputTag>(
"srcObject"))),
101 deltaRMax_(iConfig.getParameter<
double>(
"deltaRMax")),
102 moduleLabel_(iConfig.getParameter<
std::string>(
"@module_label")),
103 cut_(iConfig.getParameter<
std::string>(
"srcObjectSelection")),
104 match_(iConfig.getParameter<
std::string>(
"srcObjectsToMatchSelection")),
107 this->
template produces<std::vector<T1>>();
111 template <
typename T1,
typename T2>
119 template <
typename T1,
typename T2>
121 return std::make_unique<ovm::StreamCache<T1, T2>>(cut_, match_);
125 template <
typename T1,
typename T2>
127 auto cleanObjects = std::make_unique<std::vector<T1>>();
133 for (
unsigned int iObject = 0; iObject <
candidates->size(); iObject++)
134 isMatch[iObject] =
false;
136 auto& objCut = this->streamCache(iID)->objCut_;
137 auto& objMatchCut = this->streamCache(iID)->objMatchCut_;
138 for (
unsigned int iSrc = 0; iSrc < srcObjectsTokens_.size(); iSrc++) {
145 for (
unsigned int iObject = 0; iObject <
candidates->size(); iObject++) {
146 const T1& candidate =
candidates->at(iObject);
147 if (!objCut(candidate))
150 for (
unsigned int iObj = 0; iObj <
objects->size(); iObj++) {
152 if (!objMatchCut(
obj))
156 isMatch[iObject] =
true;
165 cleanObjects->push_back(*tIt);
169 nObjectsMatch_ += cleanObjects->size();
176 template <
typename T1,
typename T2>
178 std::stringstream
ss;
179 ss <<
"nObjectsTot=" << nObjectsTot_ <<
" nObjectsMatched=" << nObjectsMatch_
180 <<
" fObjectsMatch=" << 100. * (nObjectsMatch_ / (double)nObjectsTot_) <<
"%\n";
181 std::cout <<
"++++++++++++++++++++++++++++++++++++++++++++++++++" 183 << moduleLabel_ <<
"(ObjectViewMatcher) SUMMARY:\n" 184 <<
ss.str() <<
"++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
188 template <
typename T1,
typename T2>
192 pset.add<std::vector<edm::InputTag>>(
"srcObjectsToMatch");
193 pset.add<
double>(
"deltaRMax");
std::unique_ptr< ovm::StreamCache< T1, T2 > > beginStream(edm::StreamID) const override
std::vector< edm::EDGetTokenT< edm::View< T2 > > > srcObjectsTokens_
void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const 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 >
static void fillDescriptions(edm::ConfigurationDescriptions &)
StringCutObjectSelector< T1, true > objCut_
StreamCache(std::string const &cut, std::string const &match)
std::atomic< unsigned int > nObjectsMatch_
StringCutObjectSelector< T2, true > objMatchCut_
ObjectViewMatcher< reco::Photon, reco::Track > TrackMatchedPhotonProducer
ObjectViewMatcher< reco::Jet, reco::Track > TrackMatchedJetProducer
std::atomic< unsigned int > nObjectsTot_
#define DEFINE_FWK_MODULE(type)
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