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"};
76 if (pos ==
names + LastJetType) {
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");
152 anomalousTowerDef_ = unique_ptr<AnomalousTower>(
new AnomalousTower(iConfig));
154 input_vertex_token_ = consumes<reco::VertexCollection>(srcPVs_);
155 input_candidateview_token_ = consumes<reco::CandidateView>(src_);
156 input_candidatefwdptr_token_ =
158 input_packedcandidatefwdptr_token_ =
160 input_gencandidatefwdptr_token_ =
162 input_packedgencandidatefwdptr_token_ =
171 if (jetAlgorithm_ ==
"Kt")
172 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(fastjet::kt_algorithm, rParam_);
174 else if (jetAlgorithm_ ==
"CambridgeAachen")
175 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(fastjet::cambridge_algorithm, rParam_);
177 else if (jetAlgorithm_ ==
"AntiKt")
178 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(fastjet::antikt_algorithm, rParam_);
180 else if (jetAlgorithm_ ==
"GeneralizedKt")
181 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(fastjet::genkt_algorithm, rParam_, -2);
183 else if (jetAlgorithm_ ==
"SISCone") {
184 fjPlugin_ =
PluginPtr(
new fastjet::SISConePlugin(rParam_, 0.75, 0, 0.0,
false, fastjet::SISConePlugin::SM_pttilde));
185 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(&*fjPlugin_);
187 }
else if (jetAlgorithm_ ==
"IterativeCone") {
188 fjPlugin_ =
PluginPtr(
new fastjet::CMSIterativeConePlugin(rParam_, 1.0));
189 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(&*fjPlugin_);
191 }
else if (jetAlgorithm_ ==
"CDFMidPoint") {
192 fjPlugin_ =
PluginPtr(
new fastjet::CDFMidPointPlugin(rParam_, 0.75));
193 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(&*fjPlugin_);
195 }
else if (jetAlgorithm_ ==
"ATLASCone") {
196 fjPlugin_ =
PluginPtr(
new fastjet::ATLASConePlugin(rParam_));
197 fjJetDefinition_ = std::make_shared<fastjet::JetDefinition>(&*fjPlugin_);
200 throw cms::Exception(
"Invalid jetAlgorithm") <<
"Jet algorithm for VirtualJetProducer is invalid, Abort!\n";
205 if (doPUOffsetCorr_) {
206 if (puSubtractorName_.empty()) {
208 <<
"Pile Up correction on; however, pile up type is not specified. Using default... \n";
209 subtractor_ = std::make_shared<PileUpSubtractor>(iConfig, consumesCollector());
211 subtractor_ = std::shared_ptr<PileUpSubtractor>(
216 if (doAreaDiskApprox_ && doAreaFastjet_)
218 <<
"Both the calculation of jet area via fastjet and via an analytical disk approximation have been requested. " 219 "Please decide on one.\n";
221 if (doAreaFastjet_ || doRhoFastjet_) {
222 if (voronoiRfact_ <= 0) {
223 fjActiveArea_ = std::make_shared<fastjet::GhostedAreaSpec>(ghostEtaMax_, activeAreaRepeats_, ghostArea_);
225 if (!useExplicitGhosts_) {
226 fjAreaDefinition_ = std::make_shared<fastjet::AreaDefinition>(fastjet::active_area, *fjActiveArea_);
229 std::make_shared<fastjet::AreaDefinition>(fastjet::active_area_explicit_ghosts, *fjActiveArea_);
232 fjSelector_ = std::make_shared<fastjet::Selector>(fastjet::SelectorAbsRapMax(rhoEtaMax_));
235 if ((doFastJetNonUniform_) && (puCenters_.empty()))
237 <<
"Parameter puCenters for doFastJetNonUniform is not defined." << std::endl;
240 makeProduces(moduleLabel_, jetCollInstanceName_);
241 produces<vector<double>>(
"rhos");
242 produces<vector<double>>(
"sigmas");
243 produces<double>(
"rho");
244 produces<double>(
"sigma");
261 if (useDeterministicSeed_) {
262 fastjet::GhostedAreaSpec gas;
263 std::vector<int> seeds(2);
264 unsigned int runNum_uint =
static_cast<unsigned int>(iEvent.
id().
run());
265 unsigned int evNum_uint =
static_cast<unsigned int>(iEvent.
id().
event());
266 seeds[0] =
std::max(runNum_uint, minSeed_ + 3) + 3 * evNum_uint;
267 seeds[1] =
std::max(runNum_uint, minSeed_ + 5) + 5 * evNum_uint;
268 gas.set_random_status(seeds);
271 LogDebug(
"VirtualJetProducer") <<
"Entered produce\n";
274 if ((makeCaloJet(jetTypeE) || makePFJet(jetTypeE)) && doPVCorrection_) {
275 LogDebug(
"VirtualJetProducer") <<
"Adding PV info\n";
277 iEvent.
getByToken(input_vertex_token_, pvCollection);
278 if (!pvCollection->empty())
279 vertex_ = pvCollection->begin()->position();
284 if (doPUOffsetCorr_) {
285 subtractor_->setupGeometryMap(iEvent, iSetup);
289 LogDebug(
"VirtualJetProducer") <<
"Clear data\n";
302 bool isView = iEvent.
getByToken(input_candidateview_token_, inputsHandle);
304 if (inputsHandle->
empty()) {
308 for (
size_t i = 0;
i < inputsHandle->
size(); ++
i) {
309 inputs_.push_back(inputsHandle->
ptrAt(
i));
312 bool isPF = iEvent.
getByToken(input_candidatefwdptr_token_, pfinputsHandleAsFwdPtr);
313 bool isPFFwdPtr = iEvent.
getByToken(input_packedcandidatefwdptr_token_, packedinputsHandleAsFwdPtr);
314 bool isGen = iEvent.
getByToken(input_gencandidatefwdptr_token_, geninputsHandleAsFwdPtr);
315 bool isGenFwdPtr = iEvent.
getByToken(input_packedgencandidatefwdptr_token_, packedgeninputsHandleAsFwdPtr);
318 if (pfinputsHandleAsFwdPtr->empty()) {
322 for (
size_t i = 0;
i < pfinputsHandleAsFwdPtr->size(); ++
i) {
323 if ((*pfinputsHandleAsFwdPtr)[
i].ptr().isAvailable()) {
324 inputs_.push_back((*pfinputsHandleAsFwdPtr)[
i].ptr());
325 }
else if ((*pfinputsHandleAsFwdPtr)[
i].backPtr().isAvailable()) {
326 inputs_.push_back((*pfinputsHandleAsFwdPtr)[
i].backPtr());
329 }
else if (isPFFwdPtr) {
330 if (packedinputsHandleAsFwdPtr->empty()) {
334 for (
size_t i = 0;
i < packedinputsHandleAsFwdPtr->size(); ++
i) {
335 if ((*packedinputsHandleAsFwdPtr)[
i].ptr().isAvailable()) {
336 inputs_.push_back((*packedinputsHandleAsFwdPtr)[
i].ptr());
337 }
else if ((*packedinputsHandleAsFwdPtr)[
i].backPtr().isAvailable()) {
338 inputs_.push_back((*packedinputsHandleAsFwdPtr)[
i].backPtr());
342 if (geninputsHandleAsFwdPtr->empty()) {
346 for (
size_t i = 0;
i < geninputsHandleAsFwdPtr->size(); ++
i) {
347 if ((*geninputsHandleAsFwdPtr)[
i].ptr().isAvailable()) {
348 inputs_.push_back((*geninputsHandleAsFwdPtr)[
i].ptr());
349 }
else if ((*geninputsHandleAsFwdPtr)[
i].backPtr().isAvailable()) {
350 inputs_.push_back((*geninputsHandleAsFwdPtr)[
i].backPtr());
353 }
else if (isGenFwdPtr) {
354 if (geninputsHandleAsFwdPtr->empty()) {
358 for (
size_t i = 0;
i < packedgeninputsHandleAsFwdPtr->size(); ++
i) {
359 if ((*packedgeninputsHandleAsFwdPtr)[
i].ptr().isAvailable()) {
360 inputs_.push_back((*packedgeninputsHandleAsFwdPtr)[
i].ptr());
361 }
else if ((*packedgeninputsHandleAsFwdPtr)[
i].backPtr().isAvailable()) {
362 inputs_.push_back((*packedgeninputsHandleAsFwdPtr)[
i].backPtr());
367 <<
"Did not specify appropriate inputs for VirtualJetProducer, Abort!\n";
370 LogDebug(
"VirtualJetProducer") <<
"Got inputs\n";
375 fjInputs_.reserve(inputs_.size());
377 LogDebug(
"VirtualJetProducer") <<
"Inputted towers\n";
381 if (doPUOffsetCorr_) {
382 subtractor_->setDefinition(fjJetDefinition_);
383 subtractor_->reset(inputs_, fjInputs_, fjJets_);
384 subtractor_->calculatePedestal(fjInputs_);
385 subtractor_->subtractPedestal(fjInputs_);
386 LogDebug(
"VirtualJetProducer") <<
"Subtracted pedestal\n";
390 runAlgorithm(iEvent, iSetup);
396 LogDebug(
"VirtualJetProducer") <<
"Ran algorithm\n";
403 if (doPUOffsetCorr_) {
404 LogDebug(
"VirtualJetProducer") <<
"Do PUOffsetCorr\n";
405 vector<fastjet::PseudoJet> orphanInput;
406 subtractor_->calculateOrphanInput(orphanInput);
407 subtractor_->calculatePedestal(orphanInput);
408 subtractor_->offsetCorrectJets();
415 LogDebug(
"VirtualJetProducer") <<
"Wrote jets\n";
420 decltype(fjInputs_)().
swap(fjInputs_);
421 decltype(fjJets_)().
swap(fjJets_);
422 decltype(inputs_)().
swap(inputs_);
430 auto inBegin = inputs_.begin(), inEnd = inputs_.end(),
i = inBegin;
431 for (;
i != inEnd; ++
i) {
436 if (
input.et() < inputEtMin_)
438 if (
input.energy() < inputEMin_)
440 if (isAnomalousTower(*
i))
447 if (makeCaloJet(jetTypeE) && doPVCorrection_) {
449 auto const& ct = tower.
p4(vertex_);
450 fjInputs_.emplace_back(ct.px(), ct.py(), ct.pz(), ct.energy());
461 fjInputs_.back().set_user_index(
i - inBegin);
464 if (restrictInputs_ && fjInputs_.size() > maxInputs_) {
466 std::sort(fjInputs_.begin(), fjInputs_.end(), pTComparator);
467 fjInputs_.resize(maxInputs_);
469 <<
"Too many inputs in the event, limiting to first " << maxInputs_ <<
". Output is suspect.";
475 if (!makeCaloJet(jetTypeE))
478 return (*anomalousTowerDef_)(*input);
489 for (
unsigned int i = 0;
i < fjConstituents.size(); ++
i) {
490 int index = fjConstituents[
i].user_index();
491 if (index >= 0 && static_cast<unsigned int>(index) < inputs_.size())
498 vector<reco::CandidatePtr>
result;
499 result.reserve(fjConstituents.size() / 2);
500 for (
unsigned int i = 0;
i < fjConstituents.size();
i++) {
501 auto index = fjConstituents[
i].user_index();
502 if (
index >= 0 && static_cast<unsigned int>(
index) < inputs_.size()) {
503 result.emplace_back(inputs_[
index]);
515 if (writeCompound_) {
519 writeCompoundJets<reco::CaloJet>(
iEvent, iSetup);
522 writeCompoundJets<reco::PFJet>(
iEvent, iSetup);
525 writeCompoundJets<reco::GenJet>(
iEvent, iSetup);
527 case JetType::BasicJet:
528 writeCompoundJets<reco::BasicJet>(
iEvent, iSetup);
531 throw cms::Exception(
"InvalidInput") <<
"invalid jet type in CompoundJetProducer\n";
534 }
else if (writeJetsWithConst_) {
536 writeJetsWithConstituents<reco::PFJet>(
iEvent, iSetup);
540 writeJets<reco::CaloJet>(
iEvent, iSetup);
543 writeJets<reco::PFJet>(
iEvent, iSetup);
546 writeJets<reco::GenJet>(
iEvent, iSetup);
548 case JetType::TrackJet:
549 writeJets<reco::TrackJet>(
iEvent, iSetup);
551 case JetType::PFClusterJet:
552 writeJets<reco::PFClusterJet>(
iEvent, iSetup);
554 case JetType::BasicJet:
555 writeJets<reco::BasicJet>(
iEvent, iSetup);
558 throw cms::Exception(
"InvalidInput") <<
"invalid jet type in VirtualJetProducer\n";
565 template <
typename T>
567 static float get(
T const&) {
return 0; }
576 template <
typename T>
587 std::vector<fastjet::PseudoJet> fjexcluded_jets;
588 fjexcluded_jets = fjJets_;
590 if (fjexcluded_jets.size() > 2)
591 fjexcluded_jets.resize(nExclude_);
593 if (doFastJetNonUniform_) {
594 auto rhos = std::make_unique<std::vector<double>>();
595 auto sigmas = std::make_unique<std::vector<double>>();
596 int nEta = puCenters_.size();
598 sigmas->reserve(nEta);
599 fastjet::ClusterSequenceAreaBase
const* clusterSequenceWithArea =
600 dynamic_cast<fastjet::ClusterSequenceAreaBase
const*
>(fjClusterSeq_.get());
602 if (clusterSequenceWithArea ==
nullptr) {
603 if (!fjJets_.empty()) {
604 throw cms::Exception(
"LogicError") <<
"fjClusterSeq is not initialized while inputs are present\n ";
607 for (
int ie = 0; ie <
nEta; ++ie) {
608 double eta = puCenters_[ie];
609 double etamin = eta - puWidth_;
610 double etamax = eta + puWidth_;
611 fastjet::RangeDefinition range_rho(etamin, etamax);
614 rhos->push_back(bkgestim.
rho());
615 sigmas->push_back(bkgestim.
sigma());
621 auto rho = std::make_unique<double>(0.0);
622 auto sigma = std::make_unique<double>(0.0);
623 double mean_area = 0;
625 fastjet::ClusterSequenceAreaBase
const* clusterSequenceWithArea =
626 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 clusterSequenceWithArea->get_median_rho_and_sigma(*fjSelector_,
false, *rho, *sigma, mean_area);
634 edm::LogError(
"BadRho") <<
"rho value is " << *rho <<
" area:" << mean_area
635 <<
" and n_empty_jets: " << clusterSequenceWithArea->n_empty_jets(*fjSelector_)
636 <<
" with range " << fjSelector_->description() <<
". Setting rho to rezo.";
647 using namespace reco;
650 auto jets = std::make_unique<std::vector<T>>(fjJets_.size());
652 if (!fjJets_.empty()) {
654 using RIJ = std::pair<double, double>;
655 std::vector<RIJ> rijStorage(fjJets_.size() * (fjJets_.size() / 2));
656 RIJ* rij[fjJets_.size()];
658 for (
unsigned int ijet = 0; ijet < fjJets_.size(); ++ijet) {
659 rij[ijet] = &rijStorage[
k];
663 float etaJ[fjJets_.size()], phiJ[fjJets_.size()];
665 auto orParam_ = 1. / rParam_;
667 for (
unsigned int ijet = 0; ijet < fjJets_.size(); ++ijet) {
668 auto&
jet = (*jets)[ijet];
670 const fastjet::PseudoJet& fjJet = fjJets_[ijet];
672 std::vector<fastjet::PseudoJet>
const& fjConstituents = fastjet::sorted_by_pt(fjJet.constituents());
674 std::vector<CandidatePtr>
const& constituents = getConstituents(fjConstituents);
681 phiJ[ijet] =
jet.phi();
682 etaJ[ijet] =
jet.eta();
686 for (
unsigned int ijet = 0; ijet < fjJets_.size(); ++ijet) {
688 double jetArea = 0.0;
690 const auto& fjJet = fjJets_[ijet];
691 if (doAreaFastjet_ && fjJet.has_area()) {
692 jetArea = fjJet.area();
693 }
else if (doAreaDiskApprox_) {
698 for (
unsigned jJet = 0; jJet < ijet; ++jJet) {
699 distance[jJet].first =
std::sqrt(
reco::deltaR2(etaJ[ijet], phiJ[ijet], etaJ[jJet], phiJ[jJet])) * orParam_;
701 jetArea -= distance[jJet].second;
702 for (
unsigned kJet = 0; kJet < jJet; ++kJet) {
704 distance[kJet].first,
705 rij[jJet][kJet].first,
707 distance[kJet].second,
708 rij[jJet][kJet].second);
711 jetArea *= (rParam_ * rParam_);
713 auto&
jet = (*jets)[ijet];
714 jet.setJetArea(jetArea);
716 if (doPUOffsetCorr_) {
717 jet.setPileup(subtractor_->getPileUpEnergy(ijet));
733 if (verbosity_ >= 1) {
734 std::cout <<
"<VirtualJetProducer::writeCompoundJets (moduleLabel = " << moduleLabel_ <<
")>:" << std::endl;
738 auto jetCollection = std::make_unique<reco::BasicJetCollection>();
740 auto subjetCollection = std::make_unique<std::vector<T>>();
745 std::vector<std::vector<int>>
indices;
747 std::vector<math::XYZTLorentzVector> p4_hardJets;
749 std::vector<double> area_hardJets;
752 std::vector<fastjet::PseudoJet>::const_iterator it = fjJets_.begin(), iEnd = fjJets_.end(), iBegin = fjJets_.begin();
753 indices.resize(fjJets_.size());
754 for (; it != iEnd; ++it) {
755 fastjet::PseudoJet
const& localJet = *it;
756 unsigned int jetIndex = it - iBegin;
759 double localJetArea = 0.0;
760 if (doAreaFastjet_ && localJet.has_area()) {
761 localJetArea = localJet.area();
763 area_hardJets.push_back(localJetArea);
766 std::vector<fastjet::PseudoJet> constituents;
767 if (it->has_pieces()) {
768 constituents = it->pieces();
769 }
else if (it->has_constituents()) {
770 constituents = it->constituents();
773 std::vector<fastjet::PseudoJet>::const_iterator itSubJetBegin = constituents.begin(), itSubJet = itSubJetBegin,
774 itSubJetEnd = constituents.end();
775 for (; itSubJet != itSubJetEnd; ++itSubJet) {
776 fastjet::PseudoJet
const& subjet = *itSubJet;
777 if (verbosity_ >= 1) {
778 std::cout <<
"subjet #" << (itSubJet - itSubJetBegin) <<
": Pt = " << subjet.pt() <<
", eta = " << subjet.eta()
779 <<
", phi = " << subjet.phi() <<
", mass = " << subjet.m()
780 <<
" (#constituents = " << subjet.constituents().size() <<
")" << std::endl;
781 std::vector<fastjet::PseudoJet> subjet_constituents = subjet.constituents();
782 int idx_constituent = 0;
783 for (std::vector<fastjet::PseudoJet>::const_iterator constituent = subjet_constituents.begin();
784 constituent != subjet_constituents.end();
786 if (constituent->pt() < 1.e-3)
788 std::cout <<
" constituent #" << idx_constituent <<
": Pt = " << constituent->pt()
789 <<
", eta = " << constituent->eta() <<
", phi = " << constituent->phi() <<
"," 790 <<
" mass = " << constituent->m() << std::endl;
795 if (verbosity_ >= 1) {
796 std::cout <<
"subjet #" << (itSubJet - itSubJetBegin) <<
": Pt = " << subjet.pt() <<
", eta = " << subjet.eta()
797 <<
", phi = " << subjet.phi() <<
", mass = " << subjet.m()
798 <<
" (#constituents = " << subjet.constituents().size() <<
")" << std::endl;
799 std::vector<fastjet::PseudoJet> subjet_constituents = subjet.constituents();
800 int idx_constituent = 0;
801 for (std::vector<fastjet::PseudoJet>::const_iterator constituent = subjet_constituents.begin();
802 constituent != subjet_constituents.end();
804 if (constituent->pt() < 1.e-3)
806 std::cout <<
" constituent #" << idx_constituent <<
": Pt = " << constituent->pt()
807 <<
", eta = " << constituent->eta() <<
", phi = " << constituent->phi() <<
"," 808 <<
" mass = " << constituent->m() << std::endl;
817 std::vector<reco::CandidatePtr> subjetConstituents;
820 std::vector<fastjet::PseudoJet> subjetFastjetConstituents = subjet.constituents();
821 std::vector<reco::CandidatePtr> constituents = getConstituents(subjetFastjetConstituents);
823 indices[jetIndex].push_back(subjetCollection->size());
828 double subjetArea = 0.0;
829 if (doAreaFastjet_ && itSubJet->has_area()) {
830 subjetArea = itSubJet->area();
832 jet.setJetArea(subjetArea);
833 subjetCollection->push_back(jet);
838 subjetHandleAfterPut = iEvent.
put(
std::move(subjetCollection), jetCollInstanceName_);
841 std::vector<math::XYZTLorentzVector>::const_iterator ip4 = p4_hardJets.begin(), ip4Begin = p4_hardJets.begin(),
842 ip4End = p4_hardJets.end();
844 for (; ip4 != ip4End; ++ip4) {
845 int p4_index = ip4 - ip4Begin;
846 std::vector<int>& ind = indices[p4_index];
847 std::vector<reco::CandidatePtr> i_hardJetConstituents;
849 for (std::vector<int>::const_iterator isub = ind.begin(); isub != ind.end(); ++isub) {
851 i_hardJetConstituents.push_back(candPtr);
855 toput.
setJetArea(area_hardJets[ip4 - ip4Begin]);
863 if (fromHTTTopJetProducer_) {
864 addHTTTopJetTagInfoCollection(iEvent, iSetup, oh);
871 if (verbosity_ >= 1) {
872 std::cout <<
"<VirtualJetProducer::writeJetsWithConstituents (moduleLabel = " << moduleLabel_ <<
")>:" << std::endl;
876 auto jetCollection = std::make_unique<reco::PFJetCollection>();
879 std::vector<std::vector<int>>
indices;
881 std::vector<math::XYZTLorentzVector> p4_Jets;
883 std::vector<double> area_Jets;
886 auto constituentCollection = std::make_unique<reco::PFCandidateCollection>();
892 std::vector<fastjet::PseudoJet> constituentsSub;
893 std::vector<fastjet::PseudoJet>::const_iterator it = fjJets_.begin(), iEnd = fjJets_.end(), iBegin = fjJets_.begin();
894 indices.resize(fjJets_.size());
896 for (; it != iEnd; ++it) {
897 fastjet::PseudoJet
const& localJet = *it;
898 unsigned int jetIndex = it - iBegin;
901 double localJetArea = 0.0;
902 if (doAreaFastjet_ && localJet.has_area()) {
903 localJetArea = localJet.area();
905 area_Jets.push_back(localJetArea);
908 std::vector<fastjet::PseudoJet> constituents, ghosts;
909 if (it->has_pieces())
910 constituents = it->pieces();
911 else if (it->has_constituents())
912 fastjet::SelectorIsPureGhost().sift(it->constituents(), ghosts, constituents);
915 indices[jetIndex].reserve(constituents.size());
916 constituentsSub.reserve(constituentsSub.size() + constituents.size());
917 for (fastjet::PseudoJet
const& constit : constituents) {
918 indices[jetIndex].push_back(constituentsSub.size());
919 constituentsSub.push_back(constit);
925 for (fastjet::PseudoJet
const& constit : constituentsSub) {
926 auto orig = inputs_[constit.user_index()];
930 pVec.SetPxPyPzE(constit.px(), constit.py(), constit.pz(), constit.e());
933 constituentCollection->push_back(pCand);
936 constituentHandleAfterPut = iEvent.
put(
std::move(constituentCollection), jetCollInstanceName_);
939 std::vector<math::XYZTLorentzVector>::const_iterator ip4 = p4_Jets.begin(), ip4Begin = p4_Jets.begin(),
940 ip4End = p4_Jets.end();
942 for (; ip4 != ip4End; ++ip4) {
943 int p4_index = ip4 - ip4Begin;
944 std::vector<int>& ind = indices[p4_index];
945 std::vector<reco::CandidatePtr> i_jetConstituents;
947 for (std::vector<int>::const_iterator iconst = ind.begin(); iconst != ind.end(); ++iconst) {
949 i_jetConstituents.push_back(candPtr);
951 if (!i_jetConstituents.empty()) {
967 fillDescriptionsFromVirtualJetProducer(desc);
968 desc.
add<
string>(
"jetCollInstanceName",
"");
980 desc.
add<
string>(
"jetType",
"PFJet");
981 desc.
add<
string>(
"jetAlgorithm",
"AntiKt");
982 desc.
add<
double>(
"rParam", 0.4);
983 desc.
add<
double>(
"inputEtMin", 0.0);
984 desc.
add<
double>(
"inputEMin", 0.0);
985 desc.
add<
double>(
"jetPtMin", 5.);
986 desc.
add<
bool>(
"doPVCorrection",
false);
987 desc.
add<
bool>(
"doAreaFastjet",
false);
988 desc.
add<
bool>(
"doRhoFastjet",
false);
989 desc.
add<
bool>(
"doPUOffsetCorr",
false);
990 desc.
add<
double>(
"puPtMin", 10.);
991 desc.
add<
double>(
"nSigmaPU", 1.0);
992 desc.
add<
double>(
"radiusPU", 0.5);
993 desc.
add<
string>(
"subtractorName",
"");
994 desc.
add<
bool>(
"useExplicitGhosts",
false);
995 desc.
add<
bool>(
"doAreaDiskApprox",
false);
996 desc.
add<
double>(
"voronoiRfact", -0.9);
997 desc.
add<
double>(
"Rho_EtaMax", 4.4);
998 desc.
add<
double>(
"Ghost_EtaMax", 5.);
999 desc.
add<
int>(
"Active_Area_Repeats", 1);
1000 desc.
add<
double>(
"GhostArea", 0.01);
1001 desc.
add<
bool>(
"restrictInputs",
false);
1002 desc.
add<
unsigned int>(
"maxInputs", 1);
1003 desc.
add<
bool>(
"writeCompound",
false);
1004 desc.
add<
bool>(
"writeJetsWithConst",
false);
1005 desc.
add<
bool>(
"doFastJetNonUniform",
false);
1006 desc.
add<
bool>(
"useDeterministicSeed",
false);
1007 desc.
add<
unsigned int>(
"minSeed", 14327);
1008 desc.
add<
int>(
"verbosity", 0);
1009 desc.
add<
double>(
"puWidth", 0.);
1010 desc.
add<
unsigned int>(
"nExclude", 0);
1011 desc.
add<
unsigned int>(
"maxBadEcalCells", 9999999);
1012 desc.
add<
unsigned int>(
"maxBadHcalCells", 9999999);
1013 desc.
add<
unsigned int>(
"maxProblematicEcalCells", 9999999);
1014 desc.
add<
unsigned int>(
"maxProblematicHcalCells", 9999999);
1015 desc.
add<
unsigned int>(
"maxRecoveredEcalCells", 9999999);
1016 desc.
add<
unsigned int>(
"maxRecoveredHcalCells", 9999999);
1017 vector<double> puCentersDefault;
1018 desc.
add<vector<double>>(
"puCenters", puCentersDefault);
void writeJets(edm::Event &iEvent, edm::EventSetup const &iSetup)
T getParameter(std::string const &) const
EventNumber_t event() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Jets made from CaloTowers.
math::PtEtaPhiMLorentzVector p4(double vtxZ) const
virtual std::vector< reco::CandidatePtr > getConstituents(const std::vector< fastjet::PseudoJet > &fjConstituents)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Ptr< value_type > ptrAt(size_type i) const
constexpr bool isNotFinite(T x)
virtual void inputTowers()
Base class for all types of Jets.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void setSourceCandidatePtr(const PFCandidatePtr &ptr)
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_]
static std::string const input
void writeCompoundJets(edm::Event &iEvent, edm::EventSetup const &iSetup)
function template to write out the outputs
bool operator()(const fastjet::PseudoJet &t1, const fastjet::PseudoJet &t2) const
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)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
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)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
double rho()
synonym for median rho [[do we have this? Both?]]
ParticleType translatePdgIdToType(int pdgid) const
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
VirtualJetProducer(const edm::ParameterSet &iConfig)
void addDaughter(const CandidatePtr &)
add a daughter via a reference
static void fillDescriptionsFromVirtualJetProducer(edm::ParameterSetDescription &desc)
virtual void output(edm::Event &iEvent, edm::EventSetup const &iSetup)
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
void writeSpecific(reco::CaloJet &jet, reco::Particle::LorentzVector const &p4, reco::Particle::Point const &point, std::vector< reco::CandidatePtr > const &constituents, edm::EventSetup const &c)
~VirtualJetProducer() override