43 #include "fastjet/SISConePlugin.hh"
44 #include "fastjet/CMSIterativeConePlugin.hh"
45 #include "fastjet/ATLASConePlugin.hh"
46 #include "fastjet/CDFMidPointPlugin.hh"
53 #include <vdt/vdtMath.h>
61 bool operator()(
const fastjet::PseudoJet&
t1,
const fastjet::PseudoJet&
t2)
const {
62 return t1.perp2() >
t2.perp2();
71 "BasicJet",
"GenJet",
"CaloJet",
"PFJet",
"TrackJet",
"PFClusterJet"};
77 std::string errorMessage =
"Requested jetType not supported: " +
name +
"\n";
85 produces<reco::BasicJetCollection>();
88 if (writeJetsWithConst_) {
89 produces<reco::PFCandidateCollection>(
tag).setBranchAlias(
alias);
90 produces<reco::PFJetCollection>();
92 if (makeCaloJet(jetTypeE)) {
93 produces<reco::CaloJetCollection>(
tag).setBranchAlias(
alias);
94 }
else if (makePFJet(jetTypeE)) {
95 produces<reco::PFJetCollection>(
tag).setBranchAlias(
alias);
96 }
else if (makeGenJet(jetTypeE)) {
97 produces<reco::GenJetCollection>(
tag).setBranchAlias(
alias);
98 }
else if (makeTrackJet(jetTypeE)) {
99 produces<reco::TrackJetCollection>(
tag).setBranchAlias(
alias);
100 }
else if (makePFClusterJet(jetTypeE)) {
101 produces<reco::PFClusterJetCollection>(
tag).setBranchAlias(
alias);
102 }
else if (makeBasicJet(jetTypeE)) {
103 produces<reco::BasicJetCollection>(
tag).setBranchAlias(
alias);
114 moduleLabel_ = iConfig.
getParameter<
string>(
"@module_label");
118 jetAlgorithm_ = iConfig.
getParameter<
string>(
"jetAlgorithm");
120 inputEtMin_ = iConfig.
getParameter<
double>(
"inputEtMin");
123 doPVCorrection_ = iConfig.
getParameter<
bool>(
"doPVCorrection");
124 doAreaFastjet_ = iConfig.
getParameter<
bool>(
"doAreaFastjet");
125 doRhoFastjet_ = iConfig.
getParameter<
bool>(
"doRhoFastjet");
126 jetCollInstanceName_ = iConfig.
getParameter<
string>(
"jetCollInstanceName");
127 doPUOffsetCorr_ = iConfig.
getParameter<
bool>(
"doPUOffsetCorr");
128 puSubtractorName_ = iConfig.
getParameter<
string>(
"subtractorName");
131 doAreaDiskApprox_ = iConfig.
getParameter<
bool>(
"doAreaDiskApprox");
136 ghostEtaMax_ = iConfig.
getParameter<
double>(
"Ghost_EtaMax");
137 activeAreaRepeats_ = iConfig.
getParameter<
int>(
"Active_Area_Repeats");
139 restrictInputs_ = iConfig.
getParameter<
bool>(
"restrictInputs");
140 maxInputs_ = iConfig.
getParameter<
unsigned int>(
"maxInputs");
143 writeJetsWithConst_ = iConfig.
getParameter<
bool>(
"writeJetsWithConst");
144 doFastJetNonUniform_ = iConfig.
getParameter<
bool>(
"doFastJetNonUniform");
145 puCenters_ = iConfig.
getParameter<vector<double>>(
"puCenters");
147 nExclude_ = iConfig.
getParameter<
unsigned int>(
"nExclude");
148 useDeterministicSeed_ = iConfig.
getParameter<
bool>(
"useDeterministicSeed");
149 minSeed_ = iConfig.
getParameter<
unsigned int>(
"minSeed");
151 applyWeight_ = iConfig.
getParameter<
bool>(
"applyWeight");
156 <<
"Particle and weights collection have the same label. You may be applying the same weights twice.\n";
161 anomalousTowerDef_ = std::make_unique<AnomalousTower>(iConfig);
163 input_vertex_token_ = consumes<reco::VertexCollection>(srcPVs_);
164 input_candidateview_token_ = consumes<reco::CandidateView>(src_);
165 input_candidatefwdptr_token_ =
167 input_packedcandidatefwdptr_token_ =
169 input_gencandidatefwdptr_token_ =
171 input_packedgencandidatefwdptr_token_ =
180 if (jetAlgorithm_ ==
"Kt")
181 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(fastjet::kt_algorithm, rParam_);
183 else if (jetAlgorithm_ ==
"CambridgeAachen")
184 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(fastjet::cambridge_algorithm, rParam_);
186 else if (jetAlgorithm_ ==
"AntiKt")
187 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(fastjet::antikt_algorithm, rParam_);
189 else if (jetAlgorithm_ ==
"GeneralizedKt")
190 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(fastjet::genkt_algorithm, rParam_, -2);
192 else if (jetAlgorithm_ ==
"SISCone") {
193 fjPlugin_ =
PluginPtr(
new fastjet::SISConePlugin(rParam_, 0.75, 0, 0.0,
false, fastjet::SISConePlugin::SM_pttilde));
194 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(&*fjPlugin_);
196 }
else if (jetAlgorithm_ ==
"IterativeCone") {
197 fjPlugin_ =
PluginPtr(
new fastjet::CMSIterativeConePlugin(rParam_, 1.0));
198 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(&*fjPlugin_);
200 }
else if (jetAlgorithm_ ==
"CDFMidPoint") {
201 fjPlugin_ =
PluginPtr(
new fastjet::CDFMidPointPlugin(rParam_, 0.75));
202 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(&*fjPlugin_);
204 }
else if (jetAlgorithm_ ==
"ATLASCone") {
205 fjPlugin_ =
PluginPtr(
new fastjet::ATLASConePlugin(rParam_));
206 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(&*fjPlugin_);
209 throw cms::Exception(
"Invalid jetAlgorithm") <<
"Jet algorithm for VirtualJetProducer is invalid, Abort!\n";
212 jetTypeE = JetType::byName(jetType_);
214 if (doPUOffsetCorr_) {
215 if (puSubtractorName_.empty()) {
217 <<
"Pile Up correction on; however, pile up type is not specified. Using default... \n";
218 subtractor_ = std::make_shared<PileUpSubtractor>(iConfig, consumesCollector());
220 subtractor_ = std::shared_ptr<PileUpSubtractor>(
225 if (doAreaDiskApprox_ && doAreaFastjet_)
227 <<
"Both the calculation of jet area via fastjet and via an analytical disk approximation have been requested. "
228 "Please decide on one.\n";
230 if (doAreaFastjet_ || doRhoFastjet_) {
231 if (voronoiRfact_ <= 0) {
232 fjActiveArea_ = std::make_shared<fastjet::GhostedAreaSpec>(ghostEtaMax_, activeAreaRepeats_, ghostArea_);
234 if (!useExplicitGhosts_) {
235 fjAreaDefinition_ = std::make_shared<fastjet::AreaDefinition>(fastjet::active_area, *fjActiveArea_);
238 std::make_shared<fastjet::AreaDefinition>(fastjet::active_area_explicit_ghosts, *fjActiveArea_);
241 fjSelector_ = std::make_shared<fastjet::Selector>(fastjet::SelectorAbsRapMax(rhoEtaMax_));
244 if ((doFastJetNonUniform_) && (puCenters_.empty()))
246 <<
"Parameter puCenters for doFastJetNonUniform is not defined." << std::endl;
249 makeProduces(moduleLabel_, jetCollInstanceName_);
250 produces<vector<double>>(
"rhos");
251 produces<vector<double>>(
"sigmas");
252 produces<double>(
"rho");
253 produces<double>(
"sigma");
270 if (useDeterministicSeed_) {
271 fastjet::GhostedAreaSpec gas;
272 std::vector<int>
seeds(2);
273 unsigned int runNum_uint = static_cast<unsigned int>(
iEvent.id().run());
274 unsigned int evNum_uint = static_cast<unsigned int>(
iEvent.id().event());
275 seeds[0] =
std::max(runNum_uint, minSeed_ + 3) + 3 * evNum_uint;
276 seeds[1] =
std::max(runNum_uint, minSeed_ + 5) + 5 * evNum_uint;
277 gas.set_random_status(
seeds);
280 LogDebug(
"VirtualJetProducer") <<
"Entered produce\n";
283 if ((makeCaloJet(jetTypeE) || makePFJet(jetTypeE)) && doPVCorrection_) {
284 LogDebug(
"VirtualJetProducer") <<
"Adding PV info\n";
292 if ((applyWeight_) && (!input_weights_token_.isUninitialized()))
293 weights_ =
iEvent.get(input_weights_token_);
297 if (doPUOffsetCorr_) {
298 subtractor_->setupGeometryMap(
iEvent, iSetup);
302 LogDebug(
"VirtualJetProducer") <<
"Clear data\n";
315 bool isView =
iEvent.getByToken(input_candidateview_token_, inputsHandle);
317 if (inputsHandle->
empty()) {
321 for (
size_t i = 0;
i < inputsHandle->
size(); ++
i) {
322 inputs_.push_back(inputsHandle->
ptrAt(
i));
325 bool isPF =
iEvent.getByToken(input_candidatefwdptr_token_, pfinputsHandleAsFwdPtr);
326 bool isPFFwdPtr =
iEvent.getByToken(input_packedcandidatefwdptr_token_, packedinputsHandleAsFwdPtr);
327 bool isGen =
iEvent.getByToken(input_gencandidatefwdptr_token_, geninputsHandleAsFwdPtr);
328 bool isGenFwdPtr =
iEvent.getByToken(input_packedgencandidatefwdptr_token_, packedgeninputsHandleAsFwdPtr);
331 if (pfinputsHandleAsFwdPtr->empty()) {
335 for (
size_t i = 0;
i < pfinputsHandleAsFwdPtr->size(); ++
i) {
336 if ((*pfinputsHandleAsFwdPtr)[
i].ptr().isAvailable()) {
337 inputs_.push_back((*pfinputsHandleAsFwdPtr)[
i].ptr());
338 }
else if ((*pfinputsHandleAsFwdPtr)[
i].backPtr().isAvailable()) {
339 inputs_.push_back((*pfinputsHandleAsFwdPtr)[
i].backPtr());
342 }
else if (isPFFwdPtr) {
343 if (packedinputsHandleAsFwdPtr->empty()) {
347 for (
size_t i = 0;
i < packedinputsHandleAsFwdPtr->size(); ++
i) {
348 if ((*packedinputsHandleAsFwdPtr)[
i].ptr().isAvailable()) {
349 inputs_.push_back((*packedinputsHandleAsFwdPtr)[
i].ptr());
350 }
else if ((*packedinputsHandleAsFwdPtr)[
i].backPtr().isAvailable()) {
351 inputs_.push_back((*packedinputsHandleAsFwdPtr)[
i].backPtr());
355 if (geninputsHandleAsFwdPtr->empty()) {
359 for (
size_t i = 0;
i < geninputsHandleAsFwdPtr->size(); ++
i) {
360 if ((*geninputsHandleAsFwdPtr)[
i].ptr().isAvailable()) {
361 inputs_.push_back((*geninputsHandleAsFwdPtr)[
i].ptr());
362 }
else if ((*geninputsHandleAsFwdPtr)[
i].backPtr().isAvailable()) {
363 inputs_.push_back((*geninputsHandleAsFwdPtr)[
i].backPtr());
366 }
else if (isGenFwdPtr) {
367 if (geninputsHandleAsFwdPtr->empty()) {
371 for (
size_t i = 0;
i < packedgeninputsHandleAsFwdPtr->size(); ++
i) {
372 if ((*packedgeninputsHandleAsFwdPtr)[
i].ptr().isAvailable()) {
373 inputs_.push_back((*packedgeninputsHandleAsFwdPtr)[
i].ptr());
374 }
else if ((*packedgeninputsHandleAsFwdPtr)[
i].backPtr().isAvailable()) {
375 inputs_.push_back((*packedgeninputsHandleAsFwdPtr)[
i].backPtr());
380 <<
"Did not specify appropriate inputs for VirtualJetProducer, Abort!\n";
383 LogDebug(
"VirtualJetProducer") <<
"Got inputs\n";
388 fjInputs_.reserve(inputs_.size());
390 LogDebug(
"VirtualJetProducer") <<
"Inputted towers\n";
394 if (doPUOffsetCorr_) {
395 subtractor_->setDefinition(fjJetDefinition_);
396 subtractor_->reset(inputs_, fjInputs_, fjJets_);
397 subtractor_->calculatePedestal(fjInputs_);
398 subtractor_->subtractPedestal(fjInputs_);
399 LogDebug(
"VirtualJetProducer") <<
"Subtracted pedestal\n";
403 runAlgorithm(
iEvent, iSetup);
409 LogDebug(
"VirtualJetProducer") <<
"Ran algorithm\n";
416 if (doPUOffsetCorr_) {
417 LogDebug(
"VirtualJetProducer") <<
"Do PUOffsetCorr\n";
418 vector<fastjet::PseudoJet> orphanInput;
419 subtractor_->calculateOrphanInput(orphanInput);
420 subtractor_->calculatePedestal(orphanInput);
421 subtractor_->offsetCorrectJets();
428 LogDebug(
"VirtualJetProducer") <<
"Wrote jets\n";
433 decltype(fjInputs_)().
swap(fjInputs_);
434 decltype(fjJets_)().
swap(fjJets_);
435 decltype(inputs_)().
swap(inputs_);
443 auto inBegin = inputs_.begin(), inEnd = inputs_.end(),
i = inBegin;
444 for (;
i != inEnd; ++
i) {
449 if (
input.et() < inputEtMin_)
451 if (
input.energy() < inputEMin_)
453 if (isAnomalousTower(*
i))
460 if (makeCaloJet(jetTypeE) && doPVCorrection_) {
462 auto const& ct =
tower.p4(vertex_);
463 fjInputs_.emplace_back(ct.px(), ct.py(), ct.pz(), ct.energy());
464 fjInputs_.back().set_user_index(
i - inBegin);
475 fjInputs_.back().set_user_index(
i - inBegin);
477 if (input_weights_token_.isUninitialized())
479 <<
"applyWeight set to True, but no weights given in VirtualJetProducer\n";
480 float w = weights_[*
i];
483 fjInputs_.back().set_user_index(
i - inBegin);
489 if (restrictInputs_ && fjInputs_.size() > maxInputs_) {
491 std::sort(fjInputs_.begin(), fjInputs_.end(), pTComparator);
492 fjInputs_.resize(maxInputs_);
494 <<
"Too many inputs in the event, limiting to first " << maxInputs_ <<
". Output is suspect.";
500 if (!makeCaloJet(jetTypeE))
503 return (*anomalousTowerDef_)(*input);
514 for (
unsigned int i = 0;
i < fjConstituents.size(); ++
i) {
515 int index = fjConstituents[
i].user_index();
516 if (
index >= 0 && static_cast<unsigned int>(
index) < inputs_.size())
523 vector<reco::CandidatePtr>
result;
524 result.reserve(fjConstituents.size() / 2);
525 for (
unsigned int i = 0;
i < fjConstituents.size();
i++) {
526 auto index = fjConstituents[
i].user_index();
527 if (
index >= 0 && static_cast<unsigned int>(
index) < inputs_.size()) {
540 if (writeCompound_) {
544 writeCompoundJets<reco::CaloJet>(
iEvent, iSetup);
547 writeCompoundJets<reco::PFJet>(
iEvent, iSetup);
550 writeCompoundJets<reco::GenJet>(
iEvent, iSetup);
552 case JetType::BasicJet:
553 writeCompoundJets<reco::BasicJet>(
iEvent, iSetup);
556 throw cms::Exception(
"InvalidInput") <<
"invalid jet type in CompoundJetProducer\n";
559 }
else if (writeJetsWithConst_) {
561 writeJetsWithConstituents<reco::PFJet>(
iEvent, iSetup);
565 writeJets<reco::CaloJet>(
iEvent, iSetup);
568 writeJets<reco::PFJet>(
iEvent, iSetup);
571 writeJets<reco::GenJet>(
iEvent, iSetup);
573 case JetType::TrackJet:
574 writeJets<reco::TrackJet>(
iEvent, iSetup);
576 case JetType::PFClusterJet:
577 writeJets<reco::PFClusterJet>(
iEvent, iSetup);
579 case JetType::BasicJet:
580 writeJets<reco::BasicJet>(
iEvent, iSetup);
583 throw cms::Exception(
"InvalidInput") <<
"invalid jet type in VirtualJetProducer\n";
590 template <
typename T>
592 static float get(
T const&) {
return 0; }
601 template <
typename T>
612 std::vector<fastjet::PseudoJet> fjexcluded_jets;
613 fjexcluded_jets = fjJets_;
615 if (fjexcluded_jets.size() > 2)
616 fjexcluded_jets.resize(nExclude_);
618 if (doFastJetNonUniform_) {
619 auto rhos = std::make_unique<std::vector<double>>();
620 auto sigmas = std::make_unique<std::vector<double>>();
621 int nEta = puCenters_.size();
623 sigmas->reserve(
nEta);
624 fastjet::ClusterSequenceAreaBase
const* clusterSequenceWithArea =
625 dynamic_cast<fastjet::ClusterSequenceAreaBase const*>(fjClusterSeq_.get());
627 if (clusterSequenceWithArea ==
nullptr) {
628 if (!fjJets_.empty()) {
629 throw cms::Exception(
"LogicError") <<
"fjClusterSeq is not initialized while inputs are present\n ";
632 for (
int ie = 0; ie <
nEta; ++ie) {
633 double eta = puCenters_[ie];
639 rhos->push_back(bkgestim.
rho());
640 sigmas->push_back(bkgestim.
sigma());
646 auto rho = std::make_unique<double>(0.0);
647 auto sigma = std::make_unique<double>(0.0);
648 double mean_area = 0;
650 fastjet::ClusterSequenceAreaBase
const* clusterSequenceWithArea =
651 dynamic_cast<fastjet::ClusterSequenceAreaBase const*>(fjClusterSeq_.get());
652 if (clusterSequenceWithArea ==
nullptr) {
653 if (!fjJets_.empty()) {
654 throw cms::Exception(
"LogicError") <<
"fjClusterSeq is not initialized while inputs are present\n ";
657 clusterSequenceWithArea->get_median_rho_and_sigma(*fjSelector_,
false, *rho, *sigma, mean_area);
659 edm::LogError(
"BadRho") <<
"rho value is " << *rho <<
" area:" << mean_area
660 <<
" and n_empty_jets: " << clusterSequenceWithArea->n_empty_jets(*fjSelector_)
661 <<
" with range " << fjSelector_->description() <<
". Setting rho to rezo.";
672 using namespace reco;
675 auto jets = std::make_unique<std::vector<T>>(fjJets_.size());
677 if (!fjJets_.empty()) {
679 using RIJ = std::pair<double, double>;
680 std::vector<RIJ> rijStorage(fjJets_.size() * (fjJets_.size() / 2));
681 RIJ* rij[fjJets_.size()];
683 for (
unsigned int ijet = 0; ijet < fjJets_.size(); ++ijet) {
684 rij[ijet] = &rijStorage[
k];
688 float etaJ[fjJets_.size()], phiJ[fjJets_.size()];
690 auto orParam_ = 1. / rParam_;
692 for (
unsigned int ijet = 0; ijet < fjJets_.size(); ++ijet) {
693 auto&
jet = (*jets)[ijet];
696 const fastjet::PseudoJet& fjJet = fjJets_[ijet];
698 std::vector<fastjet::PseudoJet>
const& fjConstituents = fastjet::sorted_by_pt(fjJet.constituents());
700 std::vector<CandidatePtr>
const& constituents = getConstituents(fjConstituents);
705 if ((applyWeight_) && (makePFJet(jetTypeE)))
715 phiJ[ijet] =
jet.phi();
716 etaJ[ijet] =
jet.eta();
717 jet.setIsWeighted(applyWeight_);
721 for (
unsigned int ijet = 0; ijet < fjJets_.size(); ++ijet) {
723 double jetArea = 0.0;
725 const auto& fjJet = fjJets_[ijet];
726 if (doAreaFastjet_ && fjJet.has_area()) {
727 jetArea = fjJet.area();
728 }
else if (doAreaDiskApprox_) {
733 for (
unsigned jJet = 0; jJet < ijet; ++jJet) {
737 for (
unsigned kJet = 0; kJet < jJet; ++kJet) {
740 rij[jJet][kJet].
first,
746 jetArea *= (rParam_ * rParam_);
748 auto&
jet = (*jets)[ijet];
749 jet.setJetArea(jetArea);
751 if (doPUOffsetCorr_) {
752 jet.setPileup(subtractor_->getPileUpEnergy(ijet));
768 if (verbosity_ >= 1) {
769 std::cout <<
"<VirtualJetProducer::writeCompoundJets (moduleLabel = " << moduleLabel_ <<
")>:" << std::endl;
773 auto jetCollection = std::make_unique<reco::BasicJetCollection>();
775 auto subjetCollection = std::make_unique<std::vector<T>>();
780 std::vector<std::vector<int>>
indices;
782 std::vector<math::XYZTLorentzVector> p4_hardJets;
784 std::vector<double> area_hardJets;
787 std::vector<fastjet::PseudoJet>::const_iterator it = fjJets_.begin(), iEnd = fjJets_.end(), iBegin = fjJets_.begin();
788 indices.resize(fjJets_.size());
789 for (; it != iEnd; ++it) {
790 fastjet::PseudoJet
const& localJet = *it;
791 unsigned int jetIndex = it - iBegin;
794 double localJetArea = 0.0;
795 if (doAreaFastjet_ && localJet.has_area()) {
796 localJetArea = localJet.area();
798 area_hardJets.push_back(localJetArea);
801 std::vector<fastjet::PseudoJet> constituents;
802 if (it->has_pieces()) {
803 constituents = it->pieces();
804 }
else if (it->has_constituents()) {
805 constituents = it->constituents();
808 std::vector<fastjet::PseudoJet>::const_iterator itSubJetBegin = constituents.begin(), itSubJet = itSubJetBegin,
809 itSubJetEnd = constituents.end();
810 for (; itSubJet != itSubJetEnd; ++itSubJet) {
811 fastjet::PseudoJet
const& subjet = *itSubJet;
812 if (verbosity_ >= 1) {
813 std::cout <<
"subjet #" << (itSubJet - itSubJetBegin) <<
": Pt = " << subjet.pt() <<
", eta = " << subjet.eta()
814 <<
", phi = " << subjet.phi() <<
", mass = " << subjet.m()
815 <<
" (#constituents = " << subjet.constituents().size() <<
")" << std::endl;
816 std::vector<fastjet::PseudoJet> subjet_constituents = subjet.constituents();
817 int idx_constituent = 0;
818 for (std::vector<fastjet::PseudoJet>::const_iterator constituent = subjet_constituents.begin();
819 constituent != subjet_constituents.end();
821 if (constituent->pt() < 1.e-3)
823 std::cout <<
" constituent #" << idx_constituent <<
": Pt = " << constituent->pt()
824 <<
", eta = " << constituent->eta() <<
", phi = " << constituent->phi() <<
","
825 <<
" mass = " << constituent->m() << std::endl;
830 if (verbosity_ >= 1) {
831 std::cout <<
"subjet #" << (itSubJet - itSubJetBegin) <<
": Pt = " << subjet.pt() <<
", eta = " << subjet.eta()
832 <<
", phi = " << subjet.phi() <<
", mass = " << subjet.m()
833 <<
" (#constituents = " << subjet.constituents().size() <<
")" << std::endl;
834 std::vector<fastjet::PseudoJet> subjet_constituents = subjet.constituents();
835 int idx_constituent = 0;
836 for (std::vector<fastjet::PseudoJet>::const_iterator constituent = subjet_constituents.begin();
837 constituent != subjet_constituents.end();
839 if (constituent->pt() < 1.e-3)
841 std::cout <<
" constituent #" << idx_constituent <<
": Pt = " << constituent->pt()
842 <<
", eta = " << constituent->eta() <<
", phi = " << constituent->phi() <<
","
843 <<
" mass = " << constituent->m() << std::endl;
852 std::vector<reco::CandidatePtr> subjetConstituents;
855 std::vector<fastjet::PseudoJet> subjetFastjetConstituents = subjet.constituents();
856 std::vector<reco::CandidatePtr> constituents = getConstituents(subjetFastjetConstituents);
858 indices[jetIndex].push_back(subjetCollection->size());
861 subjetCollection->push_back(*std::make_unique<T>());
862 auto&
jet = subjetCollection->back();
863 if ((applyWeight_) && (makePFJet(jetTypeE)))
867 jet.setIsWeighted(applyWeight_);
868 double subjetArea = 0.0;
869 if (doAreaFastjet_ && itSubJet->has_area()) {
870 subjetArea = itSubJet->area();
872 jet.setJetArea(subjetArea);
877 subjetHandleAfterPut =
iEvent.put(
std::move(subjetCollection), jetCollInstanceName_);
880 std::vector<math::XYZTLorentzVector>::const_iterator ip4 = p4_hardJets.begin(), ip4Begin = p4_hardJets.begin(),
881 ip4End = p4_hardJets.end();
883 for (; ip4 != ip4End; ++ip4) {
884 int p4_index = ip4 - ip4Begin;
885 std::vector<int>& ind =
indices[p4_index];
886 std::vector<reco::CandidatePtr> i_hardJetConstituents;
888 for (std::vector<int>::const_iterator isub = ind.begin(); isub != ind.end(); ++isub) {
890 i_hardJetConstituents.push_back(candPtr);
894 toput.
setJetArea(area_hardJets[ip4 - ip4Begin]);
902 if (fromHTTTopJetProducer_) {
903 addHTTTopJetTagInfoCollection(
iEvent, iSetup, oh);
910 if (verbosity_ >= 1) {
911 std::cout <<
"<VirtualJetProducer::writeJetsWithConstituents (moduleLabel = " << moduleLabel_ <<
")>:" << std::endl;
915 auto jetCollection = std::make_unique<reco::PFJetCollection>();
918 std::vector<std::vector<int>>
indices;
920 std::vector<math::XYZTLorentzVector> p4_Jets;
922 std::vector<double> area_Jets;
925 auto constituentCollection = std::make_unique<reco::PFCandidateCollection>();
931 std::vector<fastjet::PseudoJet> constituentsSub;
932 std::vector<fastjet::PseudoJet>::const_iterator it = fjJets_.begin(), iEnd = fjJets_.end(), iBegin = fjJets_.begin();
933 indices.resize(fjJets_.size());
935 for (; it != iEnd; ++it) {
936 fastjet::PseudoJet
const& localJet = *it;
937 unsigned int jetIndex = it - iBegin;
940 double localJetArea = 0.0;
941 if (doAreaFastjet_ && localJet.has_area()) {
942 localJetArea = localJet.area();
944 area_Jets.push_back(localJetArea);
947 std::vector<fastjet::PseudoJet> constituents, ghosts;
948 if (it->has_pieces())
949 constituents = it->pieces();
950 else if (it->has_constituents())
951 fastjet::SelectorIsPureGhost().sift(it->constituents(), ghosts, constituents);
954 indices[jetIndex].reserve(constituents.size());
955 constituentsSub.reserve(constituentsSub.size() + constituents.size());
956 for (fastjet::PseudoJet
const& constit : constituents) {
957 indices[jetIndex].push_back(constituentsSub.size());
958 constituentsSub.push_back(constit);
964 for (fastjet::PseudoJet
const& constit : constituentsSub) {
965 auto orig = inputs_[constit.user_index()];
969 pVec.SetPxPyPzE(constit.px(), constit.py(), constit.pz(), constit.e());
972 constituentCollection->push_back(pCand);
975 constituentHandleAfterPut =
iEvent.put(
std::move(constituentCollection), jetCollInstanceName_);
978 std::vector<math::XYZTLorentzVector>::const_iterator ip4 = p4_Jets.begin(), ip4Begin = p4_Jets.begin(),
979 ip4End = p4_Jets.end();
981 for (; ip4 != ip4End; ++ip4) {
982 int p4_index = ip4 - ip4Begin;
983 std::vector<int>& ind =
indices[p4_index];
984 std::vector<reco::CandidatePtr> i_jetConstituents;
986 for (std::vector<int>::const_iterator iconst = ind.begin(); iconst != ind.end(); ++iconst) {
988 i_jetConstituents.push_back(candPtr);
990 if (!i_jetConstituents.empty()) {
994 jet.setJetArea(area_Jets[ip4 - ip4Begin]);
1006 fillDescriptionsFromVirtualJetProducer(
desc);
1007 desc.add<
string>(
"jetCollInstanceName",
"");
1019 desc.add<
string>(
"jetType",
"PFJet");
1020 desc.add<
string>(
"jetAlgorithm",
"AntiKt");
1021 desc.add<
double>(
"rParam", 0.4);
1022 desc.add<
double>(
"inputEtMin", 0.0);
1023 desc.add<
double>(
"inputEMin", 0.0);
1024 desc.add<
double>(
"jetPtMin", 5.);
1025 desc.add<
bool>(
"doPVCorrection",
false);
1026 desc.add<
bool>(
"doAreaFastjet",
false);
1027 desc.add<
bool>(
"doRhoFastjet",
false);
1028 desc.add<
bool>(
"doPUOffsetCorr",
false);
1029 desc.add<
double>(
"puPtMin", 10.);
1030 desc.add<
double>(
"nSigmaPU", 1.0);
1031 desc.add<
double>(
"radiusPU", 0.5);
1032 desc.add<
string>(
"subtractorName",
"");
1033 desc.add<
bool>(
"useExplicitGhosts",
false);
1034 desc.add<
bool>(
"doAreaDiskApprox",
false);
1035 desc.add<
double>(
"voronoiRfact", -0.9);
1036 desc.add<
double>(
"Rho_EtaMax", 4.4);
1037 desc.add<
double>(
"Ghost_EtaMax", 5.);
1038 desc.add<
int>(
"Active_Area_Repeats", 1);
1039 desc.add<
double>(
"GhostArea", 0.01);
1040 desc.add<
bool>(
"restrictInputs",
false);
1041 desc.add<
unsigned int>(
"maxInputs", 1);
1042 desc.add<
bool>(
"writeCompound",
false);
1043 desc.add<
bool>(
"writeJetsWithConst",
false);
1044 desc.add<
bool>(
"doFastJetNonUniform",
false);
1045 desc.add<
bool>(
"useDeterministicSeed",
false);
1046 desc.add<
unsigned int>(
"minSeed", 14327);
1047 desc.add<
int>(
"verbosity", 0);
1048 desc.add<
double>(
"puWidth", 0.);
1049 desc.add<
unsigned int>(
"nExclude", 0);
1050 desc.add<
unsigned int>(
"maxBadEcalCells", 9999999);
1051 desc.add<
unsigned int>(
"maxBadHcalCells", 9999999);
1052 desc.add<
unsigned int>(
"maxProblematicEcalCells", 9999999);
1053 desc.add<
unsigned int>(
"maxProblematicHcalCells", 9999999);
1054 desc.add<
unsigned int>(
"maxRecoveredEcalCells", 9999999);
1055 desc.add<
unsigned int>(
"maxRecoveredHcalCells", 9999999);
1056 vector<double> puCentersDefault;
1057 desc.add<vector<double>>(
"puCenters", puCentersDefault);
1058 desc.add<
bool>(
"applyWeight",
false);
1060 desc.add<
double>(
"minimumTowersFraction", 0.);