46 #include "fastjet/SISConePlugin.hh" 47 #include "fastjet/CMSIterativeConePlugin.hh" 48 #include "fastjet/ATLASConePlugin.hh" 49 #include "fastjet/CDFMidPointPlugin.hh" 56 #include <vdt/vdtMath.h> 64 bool operator()(
const fastjet::PseudoJet&
t1,
const fastjet::PseudoJet&
t2)
const {
65 return t1.perp2() >
t2.perp2();
74 "BasicJet",
"GenJet",
"CaloJet",
"PFJet",
"TrackJet",
"PFClusterJet"};
80 std::string errorMessage =
"Requested jetType not supported: " +
name +
"\n";
88 produces<reco::BasicJetCollection>();
91 if (writeJetsWithConst_) {
92 produces<reco::PFCandidateCollection>(
tag).setBranchAlias(
alias);
93 produces<reco::PFJetCollection>();
95 if (makeCaloJet(jetTypeE)) {
96 produces<reco::CaloJetCollection>(
tag).setBranchAlias(
alias);
97 }
else if (makePFJet(jetTypeE)) {
98 produces<reco::PFJetCollection>(
tag).setBranchAlias(
alias);
99 }
else if (makeGenJet(jetTypeE)) {
100 produces<reco::GenJetCollection>(
tag).setBranchAlias(
alias);
101 }
else if (makeTrackJet(jetTypeE)) {
102 produces<reco::TrackJetCollection>(
tag).setBranchAlias(
alias);
103 }
else if (makePFClusterJet(jetTypeE)) {
104 produces<reco::PFClusterJetCollection>(
tag).setBranchAlias(
alias);
105 }
else if (makeBasicJet(jetTypeE)) {
106 produces<reco::BasicJetCollection>(
tag).setBranchAlias(
alias);
117 moduleLabel_ = iConfig.
getParameter<
string>(
"@module_label");
121 jetAlgorithm_ = iConfig.
getParameter<
string>(
"jetAlgorithm");
123 inputEtMin_ = iConfig.
getParameter<
double>(
"inputEtMin");
126 doPVCorrection_ = iConfig.
getParameter<
bool>(
"doPVCorrection");
127 doAreaFastjet_ = iConfig.
getParameter<
bool>(
"doAreaFastjet");
128 doRhoFastjet_ = iConfig.
getParameter<
bool>(
"doRhoFastjet");
129 jetCollInstanceName_ = iConfig.
getParameter<
string>(
"jetCollInstanceName");
130 doPUOffsetCorr_ = iConfig.
getParameter<
bool>(
"doPUOffsetCorr");
131 puSubtractorName_ = iConfig.
getParameter<
string>(
"subtractorName");
134 doAreaDiskApprox_ = iConfig.
getParameter<
bool>(
"doAreaDiskApprox");
139 ghostEtaMax_ = iConfig.
getParameter<
double>(
"Ghost_EtaMax");
140 activeAreaRepeats_ = iConfig.
getParameter<
int>(
"Active_Area_Repeats");
142 restrictInputs_ = iConfig.
getParameter<
bool>(
"restrictInputs");
143 maxInputs_ = iConfig.
getParameter<
unsigned int>(
"maxInputs");
146 writeJetsWithConst_ = iConfig.
getParameter<
bool>(
"writeJetsWithConst");
147 doFastJetNonUniform_ = iConfig.
getParameter<
bool>(
"doFastJetNonUniform");
148 puCenters_ = iConfig.
getParameter<vector<double>>(
"puCenters");
150 nExclude_ = iConfig.
getParameter<
unsigned int>(
"nExclude");
151 useDeterministicSeed_ = iConfig.
getParameter<
bool>(
"useDeterministicSeed");
152 minSeed_ = iConfig.
getParameter<
unsigned int>(
"minSeed");
154 applyWeight_ = iConfig.
getParameter<
bool>(
"applyWeight");
159 <<
"Particle and weights collection have the same label. You may be applying the same weights twice.\n";
164 anomalousTowerDef_ = std::make_unique<AnomalousTower>(iConfig);
166 input_vertex_token_ = consumes<reco::VertexCollection>(srcPVs_);
167 input_candidateview_token_ = consumes<reco::CandidateView>(src_);
168 input_candidatefwdptr_token_ =
170 input_packedcandidatefwdptr_token_ =
172 input_gencandidatefwdptr_token_ =
174 input_packedgencandidatefwdptr_token_ =
183 if (jetAlgorithm_ ==
"Kt")
184 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(fastjet::kt_algorithm, rParam_);
186 else if (jetAlgorithm_ ==
"CambridgeAachen")
187 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(fastjet::cambridge_algorithm, rParam_);
189 else if (jetAlgorithm_ ==
"AntiKt")
190 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(fastjet::antikt_algorithm, rParam_);
192 else if (jetAlgorithm_ ==
"GeneralizedKt")
193 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(fastjet::genkt_algorithm, rParam_, -2);
195 else if (jetAlgorithm_ ==
"SISCone") {
196 fjPlugin_ =
PluginPtr(
new fastjet::SISConePlugin(rParam_, 0.75, 0, 0.0,
false, fastjet::SISConePlugin::SM_pttilde));
197 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(&*fjPlugin_);
199 }
else if (jetAlgorithm_ ==
"IterativeCone") {
200 fjPlugin_ =
PluginPtr(
new fastjet::CMSIterativeConePlugin(rParam_, 1.0));
201 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(&*fjPlugin_);
203 }
else if (jetAlgorithm_ ==
"CDFMidPoint") {
204 fjPlugin_ =
PluginPtr(
new fastjet::CDFMidPointPlugin(rParam_, 0.75));
205 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(&*fjPlugin_);
207 }
else if (jetAlgorithm_ ==
"ATLASCone") {
208 fjPlugin_ =
PluginPtr(
new fastjet::ATLASConePlugin(rParam_));
209 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(&*fjPlugin_);
212 throw cms::Exception(
"Invalid jetAlgorithm") <<
"Jet algorithm for VirtualJetProducer is invalid, Abort!\n";
215 jetTypeE = JetType::byName(jetType_);
222 if (doPUOffsetCorr_) {
223 if (puSubtractorName_.empty()) {
225 <<
"Pile Up correction on; however, pile up type is not specified. Using default... \n";
226 subtractor_ = std::make_shared<PileUpSubtractor>(iConfig, consumesCollector());
228 subtractor_ = std::shared_ptr<PileUpSubtractor>(
233 if (doAreaDiskApprox_ && doAreaFastjet_)
235 <<
"Both the calculation of jet area via fastjet and via an analytical disk approximation have been requested. " 236 "Please decide on one.\n";
238 if (doAreaFastjet_ || doRhoFastjet_) {
239 if (voronoiRfact_ <= 0) {
240 fjActiveArea_ = std::make_shared<fastjet::GhostedAreaSpec>(ghostEtaMax_, activeAreaRepeats_, ghostArea_);
242 if (!useExplicitGhosts_) {
243 fjAreaDefinition_ = std::make_shared<fastjet::AreaDefinition>(fastjet::active_area, *fjActiveArea_);
246 std::make_shared<fastjet::AreaDefinition>(fastjet::active_area_explicit_ghosts, *fjActiveArea_);
249 fjSelector_ = std::make_shared<fastjet::Selector>(fastjet::SelectorAbsRapMax(rhoEtaMax_));
252 if ((doFastJetNonUniform_) && (puCenters_.empty()))
254 <<
"Parameter puCenters for doFastJetNonUniform is not defined." << std::endl;
257 makeProduces(moduleLabel_, jetCollInstanceName_);
258 produces<vector<double>>(
"rhos");
259 produces<vector<double>>(
"sigmas");
260 produces<double>(
"rho");
261 produces<double>(
"sigma");
278 if (useDeterministicSeed_) {
279 fastjet::GhostedAreaSpec gas;
280 std::vector<int>
seeds(2);
281 unsigned int runNum_uint =
static_cast<unsigned int>(
iEvent.id().run());
282 unsigned int evNum_uint =
static_cast<unsigned int>(
iEvent.id().event());
283 seeds[0] =
std::max(runNum_uint, minSeed_ + 3) + 3 * evNum_uint;
284 seeds[1] =
std::max(runNum_uint, minSeed_ + 5) + 5 * evNum_uint;
285 gas.set_random_status(
seeds);
288 LogDebug(
"VirtualJetProducer") <<
"Entered produce\n";
291 if ((makeCaloJet(jetTypeE) || makePFJet(jetTypeE)) && doPVCorrection_) {
292 LogDebug(
"VirtualJetProducer") <<
"Adding PV info\n";
300 if ((applyWeight_) && (!input_weights_token_.isUninitialized()))
301 weights_ =
iEvent.get(input_weights_token_);
305 if (doPUOffsetCorr_) {
306 subtractor_->setupGeometryMap(
iEvent, iSetup);
310 LogDebug(
"VirtualJetProducer") <<
"Clear data\n";
323 bool isView =
iEvent.getByToken(input_candidateview_token_, inputsHandle);
325 if (inputsHandle->
empty()) {
329 for (
size_t i = 0;
i < inputsHandle->
size(); ++
i) {
330 inputs_.push_back(inputsHandle->
ptrAt(
i));
333 bool isPF =
iEvent.getByToken(input_candidatefwdptr_token_, pfinputsHandleAsFwdPtr);
334 bool isPFFwdPtr =
iEvent.getByToken(input_packedcandidatefwdptr_token_, packedinputsHandleAsFwdPtr);
335 bool isGen =
iEvent.getByToken(input_gencandidatefwdptr_token_, geninputsHandleAsFwdPtr);
336 bool isGenFwdPtr =
iEvent.getByToken(input_packedgencandidatefwdptr_token_, packedgeninputsHandleAsFwdPtr);
339 if (pfinputsHandleAsFwdPtr->empty()) {
343 for (
size_t i = 0;
i < pfinputsHandleAsFwdPtr->size(); ++
i) {
344 if ((*pfinputsHandleAsFwdPtr)[
i].ptr().isAvailable()) {
345 inputs_.push_back((*pfinputsHandleAsFwdPtr)[
i].ptr());
346 }
else if ((*pfinputsHandleAsFwdPtr)[
i].backPtr().isAvailable()) {
347 inputs_.push_back((*pfinputsHandleAsFwdPtr)[
i].backPtr());
350 }
else if (isPFFwdPtr) {
351 if (packedinputsHandleAsFwdPtr->empty()) {
355 for (
size_t i = 0;
i < packedinputsHandleAsFwdPtr->size(); ++
i) {
356 if ((*packedinputsHandleAsFwdPtr)[
i].ptr().isAvailable()) {
357 inputs_.push_back((*packedinputsHandleAsFwdPtr)[
i].ptr());
358 }
else if ((*packedinputsHandleAsFwdPtr)[
i].backPtr().isAvailable()) {
359 inputs_.push_back((*packedinputsHandleAsFwdPtr)[
i].backPtr());
363 if (geninputsHandleAsFwdPtr->empty()) {
367 for (
size_t i = 0;
i < geninputsHandleAsFwdPtr->size(); ++
i) {
368 if ((*geninputsHandleAsFwdPtr)[
i].ptr().isAvailable()) {
369 inputs_.push_back((*geninputsHandleAsFwdPtr)[
i].ptr());
370 }
else if ((*geninputsHandleAsFwdPtr)[
i].backPtr().isAvailable()) {
371 inputs_.push_back((*geninputsHandleAsFwdPtr)[
i].backPtr());
374 }
else if (isGenFwdPtr) {
375 if (geninputsHandleAsFwdPtr->empty()) {
379 for (
size_t i = 0;
i < packedgeninputsHandleAsFwdPtr->size(); ++
i) {
380 if ((*packedgeninputsHandleAsFwdPtr)[
i].ptr().isAvailable()) {
381 inputs_.push_back((*packedgeninputsHandleAsFwdPtr)[
i].ptr());
382 }
else if ((*packedgeninputsHandleAsFwdPtr)[
i].backPtr().isAvailable()) {
383 inputs_.push_back((*packedgeninputsHandleAsFwdPtr)[
i].backPtr());
388 <<
"Did not specify appropriate inputs for VirtualJetProducer, Abort!\n";
391 LogDebug(
"VirtualJetProducer") <<
"Got inputs\n";
396 fjInputs_.reserve(inputs_.size());
398 LogDebug(
"VirtualJetProducer") <<
"Inputted towers\n";
402 if (doPUOffsetCorr_) {
403 subtractor_->setDefinition(fjJetDefinition_);
404 subtractor_->reset(inputs_, fjInputs_, fjJets_);
405 subtractor_->calculatePedestal(fjInputs_);
406 subtractor_->subtractPedestal(fjInputs_);
407 LogDebug(
"VirtualJetProducer") <<
"Subtracted pedestal\n";
411 runAlgorithm(
iEvent, iSetup);
417 LogDebug(
"VirtualJetProducer") <<
"Ran algorithm\n";
424 if (doPUOffsetCorr_) {
425 LogDebug(
"VirtualJetProducer") <<
"Do PUOffsetCorr\n";
426 vector<fastjet::PseudoJet> orphanInput;
427 subtractor_->calculateOrphanInput(orphanInput);
428 subtractor_->calculatePedestal(orphanInput);
429 subtractor_->offsetCorrectJets();
436 LogDebug(
"VirtualJetProducer") <<
"Wrote jets\n";
441 decltype(fjInputs_)().
swap(fjInputs_);
442 decltype(fjJets_)().
swap(fjJets_);
443 decltype(inputs_)().
swap(inputs_);
451 auto inBegin = inputs_.begin(), inEnd = inputs_.end(),
i = inBegin;
452 for (;
i != inEnd; ++
i) {
457 if (
input.et() < inputEtMin_)
459 if (
input.energy() < inputEMin_)
461 if (isAnomalousTower(*
i))
468 if (makeCaloJet(jetTypeE) && doPVCorrection_) {
470 auto const&
ct =
tower.p4(vertex_);
471 fjInputs_.emplace_back(
ct.px(),
ct.py(),
ct.pz(),
ct.energy());
472 fjInputs_.back().set_user_index(
i - inBegin);
483 fjInputs_.back().set_user_index(
i - inBegin);
485 if (input_weights_token_.isUninitialized())
487 <<
"applyWeight set to True, but no weights given in VirtualJetProducer\n";
488 float w = weights_[*
i];
491 fjInputs_.back().set_user_index(
i - inBegin);
497 if (restrictInputs_ && fjInputs_.size() > maxInputs_) {
499 std::sort(fjInputs_.begin(), fjInputs_.end(), pTComparator);
500 fjInputs_.resize(maxInputs_);
502 <<
"Too many inputs in the event, limiting to first " << maxInputs_ <<
". Output is suspect.";
508 if (!makeCaloJet(jetTypeE))
511 return (*anomalousTowerDef_)(*input);
522 for (
unsigned int i = 0;
i < fjConstituents.size(); ++
i) {
523 int index = fjConstituents[
i].user_index();
524 if (
index >= 0 && static_cast<unsigned int>(
index) < inputs_.size())
531 vector<reco::CandidatePtr>
result;
532 result.reserve(fjConstituents.size() / 2);
533 for (
unsigned int i = 0;
i < fjConstituents.size();
i++) {
534 auto index = fjConstituents[
i].user_index();
535 if (
index >= 0 && static_cast<unsigned int>(
index) < inputs_.size()) {
548 if (writeCompound_) {
552 writeCompoundJets<reco::CaloJet>(
iEvent, iSetup);
555 writeCompoundJets<reco::PFJet>(
iEvent, iSetup);
558 writeCompoundJets<reco::GenJet>(
iEvent, iSetup);
560 case JetType::BasicJet:
561 writeCompoundJets<reco::BasicJet>(
iEvent, iSetup);
564 throw cms::Exception(
"InvalidInput") <<
"invalid jet type in CompoundJetProducer\n";
567 }
else if (writeJetsWithConst_) {
569 writeJetsWithConstituents<reco::PFJet>(
iEvent, iSetup);
573 writeJets<reco::CaloJet>(
iEvent, iSetup);
576 writeJets<reco::PFJet>(
iEvent, iSetup);
579 writeJets<reco::GenJet>(
iEvent, iSetup);
581 case JetType::TrackJet:
582 writeJets<reco::TrackJet>(
iEvent, iSetup);
584 case JetType::PFClusterJet:
585 writeJets<reco::PFClusterJet>(
iEvent, iSetup);
587 case JetType::BasicJet:
588 writeJets<reco::BasicJet>(
iEvent, iSetup);
591 throw cms::Exception(
"InvalidInput") <<
"invalid jet type in VirtualJetProducer\n";
598 template <
typename T>
600 static float get(
T const&) {
return 0; }
609 template <
typename T>
620 std::vector<fastjet::PseudoJet> fjexcluded_jets;
621 fjexcluded_jets = fjJets_;
623 if (fjexcluded_jets.size() > 2)
624 fjexcluded_jets.resize(nExclude_);
626 if (doFastJetNonUniform_) {
627 auto rhos = std::make_unique<std::vector<double>>();
628 auto sigmas = std::make_unique<std::vector<double>>();
629 int nEta = puCenters_.size();
631 sigmas->reserve(
nEta);
632 fastjet::ClusterSequenceAreaBase
const* clusterSequenceWithArea =
633 dynamic_cast<fastjet::ClusterSequenceAreaBase
const*
>(fjClusterSeq_.get());
635 if (clusterSequenceWithArea ==
nullptr) {
636 if (!fjJets_.empty()) {
637 throw cms::Exception(
"LogicError") <<
"fjClusterSeq is not initialized while inputs are present\n ";
640 for (
int ie = 0; ie <
nEta; ++ie) {
641 double eta = puCenters_[ie];
647 rhos->push_back(bkgestim.
rho());
648 sigmas->push_back(bkgestim.
sigma());
654 auto rho = std::make_unique<double>(0.0);
655 auto sigma = std::make_unique<double>(0.0);
656 double mean_area = 0;
658 fastjet::ClusterSequenceAreaBase
const* clusterSequenceWithArea =
659 dynamic_cast<fastjet::ClusterSequenceAreaBase
const*
>(fjClusterSeq_.get());
660 if (clusterSequenceWithArea ==
nullptr) {
661 if (!fjJets_.empty()) {
662 throw cms::Exception(
"LogicError") <<
"fjClusterSeq is not initialized while inputs are present\n ";
665 clusterSequenceWithArea->get_median_rho_and_sigma(*fjSelector_,
false, *rho, *sigma, mean_area);
667 edm::LogError(
"BadRho") <<
"rho value is " << *rho <<
" area:" << mean_area
668 <<
" and n_empty_jets: " << clusterSequenceWithArea->n_empty_jets(*fjSelector_)
669 <<
" with range " << fjSelector_->description() <<
". Setting rho to rezo.";
680 using namespace reco;
683 auto jets = std::make_unique<std::vector<T>>(fjJets_.size());
685 if (!fjJets_.empty()) {
687 using RIJ = std::pair<double, double>;
688 std::vector<RIJ> rijStorage(fjJets_.size() * (fjJets_.size() / 2));
689 RIJ* rij[fjJets_.size()];
691 for (
unsigned int ijet = 0; ijet < fjJets_.size(); ++ijet) {
692 rij[ijet] = &rijStorage[
k];
696 float etaJ[fjJets_.size()], phiJ[fjJets_.size()];
698 auto orParam_ = 1. / rParam_;
700 [[maybe_unused]]
const CaloGeometry* pGeometry =
nullptr;
701 [[maybe_unused]]
const HcalTopology* pTopology =
nullptr;
702 if constexpr (std::is_same_v<T, reco::CaloJet>) {
703 pGeometry = &getGeometry(iSetup);
704 pTopology = &getTopology(iSetup);
706 for (
unsigned int ijet = 0; ijet < fjJets_.size(); ++ijet) {
707 auto&
jet = (*jets)[ijet];
710 const fastjet::PseudoJet& fjJet = fjJets_[ijet];
712 std::vector<fastjet::PseudoJet>
const& fjConstituents = fastjet::sorted_by_pt(fjJet.constituents());
714 std::vector<CandidatePtr>
const& constituents = getConstituents(fjConstituents);
719 if ((applyWeight_) && (makePFJet(jetTypeE)))
726 if constexpr (std::is_same_v<T, reco::CaloJet>) {
738 phiJ[ijet] =
jet.phi();
739 etaJ[ijet] =
jet.eta();
740 jet.setIsWeighted(applyWeight_);
744 for (
unsigned int ijet = 0; ijet < fjJets_.size(); ++ijet) {
748 const auto& fjJet = fjJets_[ijet];
749 if (doAreaFastjet_ && fjJet.has_area()) {
751 }
else if (doAreaDiskApprox_) {
756 for (
unsigned jJet = 0; jJet < ijet; ++jJet) {
760 for (
unsigned kJet = 0; kJet < jJet; ++kJet) {
763 rij[jJet][kJet].
first,
769 jetArea *= (rParam_ * rParam_);
771 auto&
jet = (*jets)[ijet];
774 if (doPUOffsetCorr_) {
775 jet.setPileup(subtractor_->getPileUpEnergy(ijet));
791 if (verbosity_ >= 1) {
792 std::cout <<
"<VirtualJetProducer::writeCompoundJets (moduleLabel = " << moduleLabel_ <<
")>:" << std::endl;
796 auto jetCollection = std::make_unique<reco::BasicJetCollection>();
798 auto subjetCollection = std::make_unique<std::vector<T>>();
803 std::vector<std::vector<int>>
indices;
805 std::vector<math::XYZTLorentzVector> p4_hardJets;
807 std::vector<double> area_hardJets;
810 std::vector<fastjet::PseudoJet>::const_iterator
it = fjJets_.begin(), iEnd = fjJets_.end(), iBegin = fjJets_.begin();
811 indices.resize(fjJets_.size());
812 for (;
it != iEnd; ++
it) {
813 fastjet::PseudoJet
const& localJet = *
it;
814 unsigned int jetIndex =
it - iBegin;
817 double localJetArea = 0.0;
818 if (doAreaFastjet_ && localJet.has_area()) {
819 localJetArea = localJet.area();
821 area_hardJets.push_back(localJetArea);
824 std::vector<fastjet::PseudoJet> constituents;
825 if (
it->has_pieces()) {
826 constituents =
it->pieces();
827 }
else if (
it->has_constituents()) {
828 constituents =
it->constituents();
831 std::vector<fastjet::PseudoJet>::const_iterator itSubJetBegin = constituents.begin(), itSubJet = itSubJetBegin,
832 itSubJetEnd = constituents.end();
833 for (; itSubJet != itSubJetEnd; ++itSubJet) {
834 fastjet::PseudoJet
const& subjet = *itSubJet;
835 if (verbosity_ >= 1) {
836 std::cout <<
"subjet #" << (itSubJet - itSubJetBegin) <<
": Pt = " << subjet.pt() <<
", eta = " << subjet.eta()
837 <<
", phi = " << subjet.phi() <<
", mass = " << subjet.m()
838 <<
" (#constituents = " << subjet.constituents().size() <<
")" << std::endl;
839 std::vector<fastjet::PseudoJet> subjet_constituents = subjet.constituents();
840 int idx_constituent = 0;
841 for (std::vector<fastjet::PseudoJet>::const_iterator constituent = subjet_constituents.begin();
842 constituent != subjet_constituents.end();
844 if (constituent->pt() < 1.e-3)
846 std::cout <<
" constituent #" << idx_constituent <<
": Pt = " << constituent->pt()
847 <<
", eta = " << constituent->eta() <<
", phi = " << constituent->phi() <<
"," 848 <<
" mass = " << constituent->m() << std::endl;
853 if (verbosity_ >= 1) {
854 std::cout <<
"subjet #" << (itSubJet - itSubJetBegin) <<
": Pt = " << subjet.pt() <<
", eta = " << subjet.eta()
855 <<
", phi = " << subjet.phi() <<
", mass = " << subjet.m()
856 <<
" (#constituents = " << subjet.constituents().size() <<
")" << std::endl;
857 std::vector<fastjet::PseudoJet> subjet_constituents = subjet.constituents();
858 int idx_constituent = 0;
859 for (std::vector<fastjet::PseudoJet>::const_iterator constituent = subjet_constituents.begin();
860 constituent != subjet_constituents.end();
862 if (constituent->pt() < 1.e-3)
864 std::cout <<
" constituent #" << idx_constituent <<
": Pt = " << constituent->pt()
865 <<
", eta = " << constituent->eta() <<
", phi = " << constituent->phi() <<
"," 866 <<
" mass = " << constituent->m() << std::endl;
875 std::vector<reco::CandidatePtr> subjetConstituents;
878 std::vector<fastjet::PseudoJet> subjetFastjetConstituents = subjet.constituents();
879 std::vector<reco::CandidatePtr> constituents = getConstituents(subjetFastjetConstituents);
881 indices[jetIndex].push_back(subjetCollection->size());
884 subjetCollection->push_back(*std::make_unique<T>());
885 auto&
jet = subjetCollection->back();
886 if ((applyWeight_) && (makePFJet(jetTypeE)))
888 else if constexpr (std::is_same_v<T, reco::CaloJet>) {
894 jet.setIsWeighted(applyWeight_);
895 double subjetArea = 0.0;
896 if (doAreaFastjet_ && itSubJet->has_area()) {
897 subjetArea = itSubJet->area();
899 jet.setJetArea(subjetArea);
904 subjetHandleAfterPut =
iEvent.put(
std::move(subjetCollection), jetCollInstanceName_);
907 std::vector<math::XYZTLorentzVector>::const_iterator ip4 = p4_hardJets.begin(), ip4Begin = p4_hardJets.begin(),
908 ip4End = p4_hardJets.end();
910 for (; ip4 != ip4End; ++ip4) {
911 int p4_index = ip4 - ip4Begin;
912 std::vector<int>& ind =
indices[p4_index];
913 std::vector<reco::CandidatePtr> i_hardJetConstituents;
915 for (std::vector<int>::const_iterator isub = ind.begin(); isub != ind.end(); ++isub) {
917 i_hardJetConstituents.push_back(candPtr);
921 toput.
setJetArea(area_hardJets[ip4 - ip4Begin]);
929 if (fromHTTTopJetProducer_) {
930 addHTTTopJetTagInfoCollection(
iEvent, iSetup, oh);
937 if (verbosity_ >= 1) {
938 std::cout <<
"<VirtualJetProducer::writeJetsWithConstituents (moduleLabel = " << moduleLabel_ <<
")>:" << std::endl;
942 auto jetCollection = std::make_unique<reco::PFJetCollection>();
945 std::vector<std::vector<int>>
indices;
947 std::vector<math::XYZTLorentzVector> p4_Jets;
949 std::vector<double> area_Jets;
952 auto constituentCollection = std::make_unique<reco::PFCandidateCollection>();
958 std::vector<fastjet::PseudoJet> constituentsSub;
959 std::vector<fastjet::PseudoJet>::const_iterator
it = fjJets_.begin(), iEnd = fjJets_.end(), iBegin = fjJets_.begin();
960 indices.resize(fjJets_.size());
962 for (;
it != iEnd; ++
it) {
963 fastjet::PseudoJet
const& localJet = *
it;
964 unsigned int jetIndex =
it - iBegin;
967 double localJetArea = 0.0;
968 if (doAreaFastjet_ && localJet.has_area()) {
969 localJetArea = localJet.area();
971 area_Jets.push_back(localJetArea);
974 std::vector<fastjet::PseudoJet> constituents, ghosts;
975 if (
it->has_pieces())
976 constituents =
it->pieces();
977 else if (
it->has_constituents())
978 fastjet::SelectorIsPureGhost().sift(
it->constituents(), ghosts, constituents);
981 indices[jetIndex].reserve(constituents.size());
982 constituentsSub.reserve(constituentsSub.size() + constituents.size());
983 for (fastjet::PseudoJet
const& constit : constituents) {
984 indices[jetIndex].push_back(constituentsSub.size());
985 constituentsSub.push_back(constit);
991 for (fastjet::PseudoJet
const& constit : constituentsSub) {
992 auto orig = inputs_[constit.user_index()];
996 pVec.SetPxPyPzE(constit.px(), constit.py(), constit.pz(), constit.e());
999 constituentCollection->push_back(pCand);
1002 constituentHandleAfterPut =
iEvent.put(
std::move(constituentCollection), jetCollInstanceName_);
1005 std::vector<math::XYZTLorentzVector>::const_iterator ip4 = p4_Jets.begin(), ip4Begin = p4_Jets.begin(),
1006 ip4End = p4_Jets.end();
1008 for (; ip4 != ip4End; ++ip4) {
1009 int p4_index = ip4 - ip4Begin;
1010 std::vector<int>& ind =
indices[p4_index];
1011 std::vector<reco::CandidatePtr> i_jetConstituents;
1013 for (std::vector<int>::const_iterator iconst = ind.begin(); iconst != ind.end(); ++iconst) {
1015 i_jetConstituents.push_back(candPtr);
1017 if (!i_jetConstituents.empty()) {
1021 jet.setJetArea(area_Jets[ip4 - ip4Begin]);
1031 return iSetup.
getData(geometry_token_);
1035 return iSetup.
getData(topology_token_);
1041 fillDescriptionsFromVirtualJetProducer(
desc);
1042 desc.add<
string>(
"jetCollInstanceName",
"");
1054 desc.add<
string>(
"jetType",
"PFJet");
1055 desc.add<
string>(
"jetAlgorithm",
"AntiKt");
1056 desc.add<
double>(
"rParam", 0.4);
1057 desc.add<
double>(
"inputEtMin", 0.0);
1058 desc.add<
double>(
"inputEMin", 0.0);
1059 desc.add<
double>(
"jetPtMin", 5.);
1060 desc.add<
bool>(
"doPVCorrection",
false);
1061 desc.add<
bool>(
"doAreaFastjet",
false);
1062 desc.add<
bool>(
"doRhoFastjet",
false);
1063 desc.add<
bool>(
"doPUOffsetCorr",
false);
1064 desc.add<
double>(
"puPtMin", 10.);
1065 desc.add<
double>(
"nSigmaPU", 1.0);
1066 desc.add<
double>(
"radiusPU", 0.5);
1067 desc.add<
string>(
"subtractorName",
"");
1068 desc.add<
bool>(
"useExplicitGhosts",
false);
1069 desc.add<
bool>(
"doAreaDiskApprox",
false);
1070 desc.add<
double>(
"voronoiRfact", -0.9);
1071 desc.add<
double>(
"Rho_EtaMax", 4.4);
1072 desc.add<
double>(
"Ghost_EtaMax", 5.);
1073 desc.add<
int>(
"Active_Area_Repeats", 1);
1074 desc.add<
double>(
"GhostArea", 0.01);
1075 desc.add<
bool>(
"restrictInputs",
false);
1076 desc.add<
unsigned int>(
"maxInputs", 1);
1077 desc.add<
bool>(
"writeCompound",
false);
1078 desc.add<
bool>(
"writeJetsWithConst",
false);
1079 desc.add<
bool>(
"doFastJetNonUniform",
false);
1080 desc.add<
bool>(
"useDeterministicSeed",
false);
1081 desc.add<
unsigned int>(
"minSeed", 14327);
1082 desc.add<
int>(
"verbosity", 0);
1083 desc.add<
double>(
"puWidth", 0.);
1084 desc.add<
unsigned int>(
"nExclude", 0);
1085 desc.add<
unsigned int>(
"maxBadEcalCells", 9999999);
1086 desc.add<
unsigned int>(
"maxBadHcalCells", 9999999);
1087 desc.add<
unsigned int>(
"maxProblematicEcalCells", 9999999);
1088 desc.add<
unsigned int>(
"maxProblematicHcalCells", 9999999);
1089 desc.add<
unsigned int>(
"maxRecoveredEcalCells", 9999999);
1090 desc.add<
unsigned int>(
"maxRecoveredHcalCells", 9999999);
1091 vector<double> puCentersDefault;
1092 desc.add<vector<double>>(
"puCenters", puCentersDefault);
1093 desc.add<
bool>(
"applyWeight",
false);
1095 desc.add<
double>(
"minimumTowersFraction", 0.);
void writeJets(edm::Event &iEvent, edm::EventSetup const &iSetup)
T getParameter(std::string const &) const
Jets made from CaloTowers.
Ptr< value_type > ptrAt(size_type i) const
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
HcalTopology const & getTopology(edm::EventSetup const &) const
virtual std::vector< reco::CandidatePtr > getConstituents(const std::vector< fastjet::PseudoJet > &fjConstituents)
constexpr bool isNotFinite(T x)
virtual void inputTowers()
Base class for all types of Jets.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void writeSpecific(reco::CaloJet &jet, reco::Particle::LorentzVector const &p4, reco::Particle::Point const &point, std::vector< reco::CandidatePtr > const &constituents, CaloGeometry const &geometry, HcalTopology const &topology)
void setSourceCandidatePtr(const PFCandidatePtr &ptr)
Log< level::Error, false > LogError
virtual void copyConstituents(const std::vector< fastjet::PseudoJet > &fjConstituents, reco::Jet *jet)
Jets made from CaloTowers.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void writeJetsWithConstituents(edm::Event &iEvent, edm::EventSetup const &iSetup)
function template to write out the outputs
Jets made from PFObjects.
const std::string names[nVars_]
void swap(Association< C > &lhs, Association< C > &rhs)
static std::string const input
void writeCompoundJets(edm::Event &iEvent, edm::EventSetup const &iSetup)
function template to write out the outputs
U second(std::pair< T, U > const &p)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
virtual bool isAnomalousTower(reco::CandidatePtr input)
virtual void setJetArea(float fArea)
set jet area
void addDefault(ParameterSetDescription const &psetDescription)
double intersection(double r12)
bool operator()(const fastjet::PseudoJet &t1, const fastjet::PseudoJet &t2) const
virtual void makeProduces(std::string s, std::string tag="")
math::XYZPoint Point
point in the space
void set_excluded_jets(const std::vector< PseudoJet > &excluded_jets)
CaloGeometry const & getGeometry(edm::EventSetup const &) const
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
double rho()
synonym for median rho [[do we have this? Both?]]
static const char *const names[]
std::shared_ptr< fastjet::JetDefinition::Plugin > PluginPtr
double sigma()
get the sigma
Particle reconstructed by the particle flow algorithm.
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
ParticleType translatePdgIdToType(int pdgid) const
VirtualJetProducer(const edm::ParameterSet &iConfig)
static void fillDescriptionsFromVirtualJetProducer(edm::ParameterSetDescription &desc)
virtual void output(edm::Event &iEvent, edm::EventSetup const &iSetup)
Log< level::Warning, false > LogWarning
static Type byName(const std::string &name)
void setP4(const LorentzVector &p4) final
set 4-momentum
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
math::PtEtaPhiELorentzVectorF LorentzVector
math::XYZPoint Point
point in the space
~VirtualJetProducer() override