45 template <
class JetType,
class CandType>
67 template <
class JetType,
class CandType>
69 : moduleLabel_(
cfg.getParameter<
std::
string>(
"@module_label")) {
73 verbosity_ = (
cfg.exists(
"verbosity")) ?
cfg.getParameter<
int>(
"verbosity") : 0;
75 produces<JetTypeCollection>();
76 produces<JetToPFCandidateAssociation>(
"pfCandAssocMapForIsolation");
81 typedef std::vector<std::unordered_set<uint32_t>> JetToConstitMap;
83 template <
class JetType,
class CandType>
87 double chargedHadronEnergy = 0.;
88 double neutralHadronEnergy = 0.;
89 double chargedEmEnergy = 0.;
90 double neutralEmEnergy = 0.;
91 double chargedMuEnergy = 0.;
92 int chargedMultiplicity = 0;
93 int neutralMultiplicity = 0;
95 for (
auto const& jetConstituent : jetConstituents) {
96 const CandType* pfCandidate =
dynamic_cast<const CandType*
>(jetConstituent.get());
98 switch (
std::abs(pfCandidate->pdgId())) {
100 chargedHadronEnergy += pfCandidate->energy();
101 ++chargedMultiplicity;
104 chargedEmEnergy += pfCandidate->energy();
105 ++chargedMultiplicity;
108 chargedMuEnergy += pfCandidate->energy();
109 ++chargedMultiplicity;
114 neutralEmEnergy += pfCandidate->energy();
115 ++neutralMultiplicity;
119 neutralHadronEnergy += pfCandidate->energy();
120 ++neutralMultiplicity;
123 edm::LogWarning(
"convertToPFJet") <<
"PFCandidate: Pt = " << pfCandidate->pt()
124 <<
", eta = " << pfCandidate->eta() <<
", phi = " << pfCandidate->phi()
125 <<
" has invalid pdgID = " << pfCandidate->pdgId() <<
" !!" << std::endl;
130 <<
"Jet constituent: Pt = " << jetConstituent->pt() <<
", eta = " << jetConstituent->eta()
131 <<
", phi = " << jetConstituent->phi() <<
" is not of type PFCandidate !!" << std::endl;
152 for (
auto const& jetConstituent : jetConstituents) {
155 getJetConstituents(*subjet, jet_and_subjetConstituents);
157 jet_and_subjetConstituents.push_back(jetConstituent);
162 template <
class CandType>
163 std::vector<edm::Ref<std::vector<CandType>>> getPFCandidates_exclJetConstituents(
168 auto const& collection_cand = (*pfCandidates);
169 std::vector<edm::Ref<std::vector<CandType>>> pfCandidates_exclJetConstituents;
171 for (
size_t pfCandidateIdx = 0; pfCandidateIdx < numPFCandidates; ++pfCandidateIdx) {
172 if (!(
deltaR2(collection_cand[pfCandidateIdx],
jet) < 1.0))
174 bool isJetConstituent = constitmap.count(pfCandidateIdx);
175 if (!(isJetConstituent ^
invert)) {
177 pfCandidates_exclJetConstituents.push_back(pfCandidate);
180 return pfCandidates_exclJetConstituents;
184 std::cout <<
"#" <<
label <<
" = " << jetConstituents.size() <<
":" << std::endl;
186 for (
auto const& jetConstituent : jetConstituents) {
187 std::cout <<
" jetConstituent #" <<
idx <<
": Pt = " << (*jetConstituent).pt()
188 <<
", eta = " << (*jetConstituent).eta() <<
", phi = " << (*jetConstituent).phi() << std::endl;
194 template <
class JetType,
class CandType>
196 if (verbosity_ >= 1) {
197 std::cout <<
"<BoostedTauSeedsProducer::produce (moduleLabel = " << moduleLabel_ <<
")>:" << std::endl;
202 if (verbosity_ >= 1) {
203 std::cout <<
"#subjets = " << subjets->size() << std::endl;
205 assert((subjets->size() % 2) == 0);
209 if (verbosity_ >= 1) {
213 auto selectedSubjets = std::make_unique<JetTypeCollection>();
216 auto selectedSubjetPFCandidateAssociationForIsolation =
217 std::make_unique<JetToPFCandidateAssociation>(&evt.
productGetter());
221 JetToConstitMap constitmap(subjets->size());
224 const auto& thesubjets = *subjets;
225 for (
unsigned i = 0;
i < thesubjets.size(); ++
i) {
226 for (
unsigned j = 0;
j < thesubjets[
i].numberOfDaughters(); ++
j) {
227 constitmap[
i].emplace(thesubjets[
i].daughterPtr(
j).
key());
231 for (
size_t idx = 0;
idx < (subjets->size() / 2); ++
idx) {
234 assert(subjet1 && subjet2);
235 if (verbosity_ >= 1) {
236 std::cout <<
"processing jet #" <<
idx <<
":" << std::endl;
237 std::cout <<
" subjet1: Pt = " << subjet1->
pt() <<
", eta = " << subjet1->
eta() <<
", phi = " << subjet1->
phi()
238 <<
", mass = " << subjet1->
mass() <<
" (#constituents = " << subjet1->
nConstituents()
239 <<
", area = " << subjet1->
jetArea() <<
")" << std::endl;
240 std::cout <<
" subjet2: Pt = " << subjet2->
pt() <<
", eta = " << subjet2->
eta() <<
", phi = " << subjet2->
phi()
241 <<
", mass = " << subjet2->
mass() <<
" (#constituents = " << subjet2->
nConstituents()
242 <<
", area = " << subjet2->
jetArea() <<
")" << std::endl;
250 getJetConstituents(*subjet1, subjetConstituents1);
252 getJetConstituents(*subjet2, subjetConstituents2);
253 if (verbosity_ >= 1) {
254 printJetConstituents(
"subjetConstituents1", subjetConstituents1);
255 printJetConstituents(
"subjetConstituents2", subjetConstituents2);
258 selectedSubjets->push_back(convertToPFJet<JetType, CandType>(*subjet1, subjetConstituents1));
260 selectedSubjets->push_back(convertToPFJet<JetType, CandType>(*subjet2, subjetConstituents2));
264 std::vector<edm::Ref<std::vector<CandType>>> pfCandidatesNotInSubjet1 =
265 getPFCandidates_exclJetConstituents<CandType>(*subjet1,
pfCandidates, constitmap[2 *
idx + 1],
false);
266 std::vector<edm::Ref<std::vector<CandType>>> pfCandidatesNotInSubjet2 =
267 getPFCandidates_exclJetConstituents<CandType>(*subjet2,
pfCandidates, constitmap[2 *
idx],
false);
268 if (verbosity_ >= 1) {
269 std::cout <<
"#pfCandidatesNotInSubjet1 = " << pfCandidatesNotInSubjet1.size() << std::endl;
270 std::cout <<
"#pfCandidatesNotInSubjet2 = " << pfCandidatesNotInSubjet2.size() << std::endl;
275 for (
auto const& pfCandidate : pfCandidatesNotInSubjet1) {
276 selectedSubjetPFCandidateAssociationForIsolation->insert(subjetRef1, pfCandidate);
278 for (
auto const& pfCandidate : pfCandidatesNotInSubjet2) {
279 selectedSubjetPFCandidateAssociationForIsolation->insert(subjetRef2, pfCandidate);
284 evt.
put(
std::move(selectedSubjetPFCandidateAssociationForIsolation),
"pfCandAssocMapForIsolation");
GenericBoostedTauSeedsProducer< reco::PFJet, reco::PFCandidate > BoostedTauSeedsProducer
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
double pt() const final
transverse momentum
Base class for all types of Jets.
std::vector< Constituent > Constituents
bool getByToken(EDGetToken token, Handle< PROD > &result) const
float mNeutralHadronEnergy
edm::View< reco::Jet > JetView
~GenericBoostedTauSeedsProducer() override
Jets made from PFObjects.
float mChargedHadronEnergy
virtual float jetArea() const
get jet area
EDProductGetter const & productGetter() const
virtual void setJetArea(float fArea)
set jet area
GenericBoostedTauSeedsProducer(const edm::ParameterSet &)
std::vector< CandType > CandTypeCollection
Container::value_type value_type
virtual int nConstituents() const
of constituents
Abs< T >::type abs(const T &t)
key
prepare the HTCondor submission files and eventually submit them
#define DEFINE_FWK_MODULE(type)
RefProd< PROD > getRefBeforePut()
void produce(edm::Event &, const edm::EventSetup &) override
edm::AssociationMap< edm::OneToMany< std::vector< JetType >, std::vector< CandType >, unsigned int > > JetToPFCandidateAssociation
edm::EDGetTokenT< JetView > srcSubjets_
double mass() const final
mass
Log< level::Warning, false > LogWarning
double phi() const final
momentum azimuthal angle
edm::EDGetTokenT< CandTypeCollection > srcPFCandidates_
std::vector< JetType > JetTypeCollection
GenericBoostedTauSeedsProducer< pat::Jet, pat::PackedCandidate > PATBoostedTauSeedsProducer
double eta() const final
momentum pseudorapidity