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> 62 bool operator()(
const fastjet::PseudoJet & t1,
const fastjet::PseudoJet &
t2 )
const {
63 return t1.perp2() > t2.perp2();
72 "BasicJet",
"GenJet",
"CaloJet",
"PFJet",
"TrackJet",
"PFClusterJet" 81 if (pos ==
names + LastJetType) {
82 std::string errorMessage=
"Requested jetType not supported: "+name+
"\n";
93 if ( writeCompound_ ) {
94 produces<reco::BasicJetCollection>();
97 if ( writeJetsWithConst_ ) {
98 produces<reco::PFCandidateCollection>(
tag).setBranchAlias(alias);
99 produces<reco::PFJetCollection>();
101 if (makeCaloJet(jetTypeE)) {
102 produces<reco::CaloJetCollection>(
tag).setBranchAlias(alias);
104 else if (makePFJet(jetTypeE)) {
105 produces<reco::PFJetCollection>(
tag).setBranchAlias(alias);
107 else if (makeGenJet(jetTypeE)) {
108 produces<reco::GenJetCollection>(
tag).setBranchAlias(alias);
110 else if (makeTrackJet(jetTypeE)) {
111 produces<reco::TrackJetCollection>(
tag).setBranchAlias(alias);
113 else if (makePFClusterJet(jetTypeE)) {
114 produces<reco::PFClusterJetCollection>(
tag).setBranchAlias(alias);
116 else if (makeBasicJet(jetTypeE)) {
117 produces<reco::BasicJetCollection>(
tag).setBranchAlias(alias);
129 moduleLabel_ = iConfig.
getParameter<
string> (
"@module_label");
133 jetAlgorithm_ = iConfig.
getParameter<
string> (
"jetAlgorithm");
135 inputEtMin_ = iConfig.
getParameter<
double> (
"inputEtMin");
136 inputEMin_ = iConfig.
getParameter<
double> (
"inputEMin");
138 doPVCorrection_ = iConfig.
getParameter<
bool> (
"doPVCorrection");
139 doAreaFastjet_ = iConfig.
getParameter<
bool> (
"doAreaFastjet");
140 doRhoFastjet_ = iConfig.
getParameter<
bool> (
"doRhoFastjet");
141 jetCollInstanceName_ = iConfig.
getParameter<
string> (
"jetCollInstanceName");
142 doPUOffsetCorr_ = iConfig.
getParameter<
bool> (
"doPUOffsetCorr");
143 puSubtractorName_ = iConfig.
getParameter<
string> (
"subtractorName");
144 useExplicitGhosts_ = iConfig.
getParameter<
bool> (
"useExplicitGhosts");
145 doAreaDiskApprox_ = iConfig.
getParameter<
bool> (
"doAreaDiskApprox");
146 voronoiRfact_ = iConfig.
getParameter<
double> (
"voronoiRfact");
147 rhoEtaMax_ = iConfig.
getParameter<
double> (
"Rho_EtaMax");
148 ghostEtaMax_ = iConfig.
getParameter<
double> (
"Ghost_EtaMax");
149 activeAreaRepeats_ = iConfig.
getParameter<
int> (
"Active_Area_Repeats");
150 ghostArea_ = iConfig.
getParameter<
double> (
"GhostArea");
151 restrictInputs_ = iConfig.
getParameter<
bool> (
"restrictInputs");
152 maxInputs_ = iConfig.
getParameter<
unsigned int>(
"maxInputs");
153 writeCompound_ = iConfig.
getParameter<
bool> (
"writeCompound");
154 writeJetsWithConst_ = iConfig.
getParameter<
bool>(
"writeJetsWithConst");
155 doFastJetNonUniform_ = iConfig.
getParameter<
bool> (
"doFastJetNonUniform");
156 puCenters_ = iConfig.
getParameter<vector<double> >(
"puCenters");
158 nExclude_ = iConfig.
getParameter<
unsigned int>(
"nExclude");
159 useDeterministicSeed_ = iConfig.
getParameter<
bool> (
"useDeterministicSeed");
160 minSeed_ = iConfig.
getParameter<
unsigned int>(
"minSeed");
163 anomalousTowerDef_ = auto_ptr<AnomalousTower>(
new AnomalousTower(iConfig));
165 input_vertex_token_ = consumes<reco::VertexCollection>(srcPVs_);
166 input_candidateview_token_ = consumes<reco::CandidateView>(src_);
167 input_candidatefwdptr_token_ = consumes<vector<edm::FwdPtr<reco::PFCandidate> > >(iConfig.
getParameter<
edm::InputTag>(
"src"));
168 input_packedcandidatefwdptr_token_ = consumes<vector<edm::FwdPtr<pat::PackedCandidate> > >(iConfig.
getParameter<
edm::InputTag>(
"src"));
169 input_gencandidatefwdptr_token_ = consumes<vector<edm::FwdPtr<reco::GenParticle> > >(iConfig.
getParameter<
edm::InputTag>(
"src"));
170 input_packedgencandidatefwdptr_token_ = consumes<vector<edm::FwdPtr<pat::PackedGenParticle> > >(iConfig.
getParameter<
edm::InputTag>(
"src"));
178 if (jetAlgorithm_==
"Kt")
179 fjJetDefinition_=
JetDefPtr(
new fastjet::JetDefinition(fastjet::kt_algorithm,rParam_));
181 else if (jetAlgorithm_==
"CambridgeAachen")
182 fjJetDefinition_=
JetDefPtr(
new fastjet::JetDefinition(fastjet::cambridge_algorithm,rParam_) );
184 else if (jetAlgorithm_==
"AntiKt")
185 fjJetDefinition_=
JetDefPtr(
new fastjet::JetDefinition(fastjet::antikt_algorithm,rParam_) );
187 else if (jetAlgorithm_==
"GeneralizedKt")
188 fjJetDefinition_=
JetDefPtr(
new fastjet::JetDefinition(fastjet::genkt_algorithm,rParam_,-2) );
190 else if (jetAlgorithm_==
"SISCone") {
192 fjPlugin_ =
PluginPtr(
new fastjet::SISConePlugin(rParam_,0.75,0,0.0,
false,fastjet::SISConePlugin::SM_pttilde) );
193 fjJetDefinition_=
JetDefPtr(
new fastjet::JetDefinition(&*fjPlugin_) );
195 }
else if (jetAlgorithm_==
"IterativeCone") {
197 fjPlugin_ =
PluginPtr(
new fastjet::CMSIterativeConePlugin(rParam_,1.0));
198 fjJetDefinition_=
JetDefPtr(
new fastjet::JetDefinition(&*fjPlugin_));
200 }
else if (jetAlgorithm_==
"CDFMidPoint") {
202 fjPlugin_ =
PluginPtr(
new fastjet::CDFMidPointPlugin(rParam_,0.75));
203 fjJetDefinition_=
JetDefPtr(
new fastjet::JetDefinition(&*fjPlugin_));
205 }
else if (jetAlgorithm_==
"ATLASCone") {
207 fjPlugin_ =
PluginPtr(
new fastjet::ATLASConePlugin(rParam_));
208 fjJetDefinition_=
JetDefPtr(
new fastjet::JetDefinition(&*fjPlugin_));
211 throw cms::Exception(
"Invalid jetAlgorithm") <<
"Jet algorithm for VirtualJetProducer is invalid, Abort!\n";
216 if ( doPUOffsetCorr_ ) {
217 if(puSubtractorName_.empty()){
218 LogWarning(
"VirtualJetProducer") <<
"Pile Up correction on; however, pile up type is not specified. Using default... \n";
219 subtractor_ = boost::shared_ptr<PileUpSubtractor>(
new PileUpSubtractor(iConfig, consumesCollector()));
220 }
else subtractor_ = boost::shared_ptr<PileUpSubtractor>(
225 if (doAreaDiskApprox_ && doAreaFastjet_)
226 throw cms::Exception(
"Conflicting area calculations") <<
"Both the calculation of jet area via fastjet and via an analytical disk approximation have been requested. Please decide on one.\n";
228 if ( doAreaFastjet_ || doRhoFastjet_ ) {
230 if (voronoiRfact_ <= 0) {
231 fjActiveArea_ =
ActiveAreaSpecPtr(
new fastjet::GhostedAreaSpec(ghostEtaMax_,activeAreaRepeats_,ghostArea_));
232 fjActiveArea_->set_fj2_placement(
true);
234 if ( !useExplicitGhosts_ ) {
235 fjAreaDefinition_ =
AreaDefinitionPtr(
new fastjet::AreaDefinition(fastjet::active_area, *fjActiveArea_ ) );
237 fjAreaDefinition_ =
AreaDefinitionPtr(
new fastjet::AreaDefinition(fastjet::active_area_explicit_ghosts, *fjActiveArea_ ) );
240 fjRangeDef_ =
RangeDefPtr(
new fastjet::RangeDefinition(rhoEtaMax_) );
243 if( ( doFastJetNonUniform_ ) && ( puCenters_.empty() ) )
244 throw cms::Exception(
"doFastJetNonUniform") <<
"Parameter puCenters for doFastJetNonUniform is not defined." << std::endl;
247 makeProduces( moduleLabel_, jetCollInstanceName_ );
248 produces<vector<double> >(
"rhos");
249 produces<vector<double> >(
"sigmas");
250 produces<double>(
"rho");
251 produces<double>(
"sigma");
275 if ( useDeterministicSeed_ ) {
276 fastjet::GhostedAreaSpec gas;
277 std::vector<int> seeds(2);
278 unsigned int runNum_uint = static_cast <
unsigned int> (iEvent.
id().
run());
279 unsigned int evNum_uint = static_cast <
unsigned int> (iEvent.
id().
event());
280 seeds[0] =
std::max(runNum_uint,minSeed_ + 3) + 3 * evNum_uint;
281 seeds[1] =
std::max(runNum_uint,minSeed_ + 5) + 5 * evNum_uint;
282 gas.set_random_status(seeds);
285 LogDebug(
"VirtualJetProducer") <<
"Entered produce\n";
288 if ( (makeCaloJet(jetTypeE) || makePFJet(jetTypeE)) &&doPVCorrection_) {
289 LogDebug(
"VirtualJetProducer") <<
"Adding PV info\n";
291 iEvent.
getByToken(input_vertex_token_ , pvCollection);
292 if (!pvCollection->empty()) vertex_=pvCollection->begin()->position();
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() );
339 else if ( (*pfinputsHandleAsFwdPtr)[
i].backPtr().isAvailable() ) {
340 inputs_.push_back( (*pfinputsHandleAsFwdPtr)[
i].backPtr() );
343 }
else if ( isPFFwdPtr ) {
344 if ( packedinputsHandleAsFwdPtr->empty()) {
348 for (
size_t i = 0;
i < packedinputsHandleAsFwdPtr->size(); ++
i) {
349 if ( (*packedinputsHandleAsFwdPtr)[
i].ptr().isAvailable() ) {
350 inputs_.push_back( (*packedinputsHandleAsFwdPtr)[
i].ptr() );
352 else if ( (*packedinputsHandleAsFwdPtr)[
i].backPtr().isAvailable() ) {
353 inputs_.push_back( (*packedinputsHandleAsFwdPtr)[
i].backPtr() );
356 }
else if ( isGen ) {
357 if ( geninputsHandleAsFwdPtr->empty()) {
361 for (
size_t i = 0;
i < geninputsHandleAsFwdPtr->size(); ++
i) {
362 if ( (*geninputsHandleAsFwdPtr)[
i].ptr().isAvailable() ) {
363 inputs_.push_back( (*geninputsHandleAsFwdPtr)[
i].ptr() );
365 else if ( (*geninputsHandleAsFwdPtr)[
i].backPtr().isAvailable() ) {
366 inputs_.push_back( (*geninputsHandleAsFwdPtr)[
i].backPtr() );
369 }
else if ( isGenFwdPtr ) {
370 if ( geninputsHandleAsFwdPtr->empty()) {
374 for (
size_t i = 0;
i < packedgeninputsHandleAsFwdPtr->size(); ++
i) {
375 if ( (*packedgeninputsHandleAsFwdPtr)[
i].ptr().isAvailable() ) {
376 inputs_.push_back( (*packedgeninputsHandleAsFwdPtr)[
i].ptr() );
378 else if ( (*packedgeninputsHandleAsFwdPtr)[
i].backPtr().isAvailable() ) {
379 inputs_.push_back( (*packedgeninputsHandleAsFwdPtr)[
i].backPtr() );
384 throw cms::Exception(
"Invalid Jet Inputs") <<
"Did not specify appropriate inputs for VirtualJetProducer, Abort!\n";
387 LogDebug(
"VirtualJetProducer") <<
"Got inputs\n";
392 fjInputs_.reserve(inputs_.size());
394 LogDebug(
"VirtualJetProducer") <<
"Inputted towers\n";
398 if ( doPUOffsetCorr_ ) {
399 subtractor_->setDefinition(fjJetDefinition_);
400 subtractor_->reset(inputs_,fjInputs_,fjJets_);
401 subtractor_->calculatePedestal(fjInputs_);
402 subtractor_->subtractPedestal(fjInputs_);
403 LogDebug(
"VirtualJetProducer") <<
"Subtracted pedestal\n";
407 runAlgorithm( iEvent, iSetup );
413 LogDebug(
"VirtualJetProducer") <<
"Ran algorithm\n";
420 if ( doPUOffsetCorr_ ) {
421 LogDebug(
"VirtualJetProducer") <<
"Do PUOffsetCorr\n";
422 vector<fastjet::PseudoJet> orphanInput;
423 subtractor_->calculateOrphanInput(orphanInput);
424 subtractor_->calculatePedestal(orphanInput);
425 subtractor_->offsetCorrectJets();
432 LogDebug(
"VirtualJetProducer") <<
"Wrote jets\n";
437 decltype(fjInputs_)().
swap(fjInputs_);
438 decltype(fjJets_)().
swap(fjJets_);
439 decltype(inputs_)().
swap(inputs_);
448 auto inBegin = inputs_.begin(),
449 inEnd = inputs_.end(),
i = inBegin;
450 for (;
i != inEnd; ++
i ) {
454 if (
input.et() <inputEtMin_)
continue;
455 if (
input.energy()<inputEMin_)
continue;
456 if (isAnomalousTower(*
i))
continue;
462 if (makeCaloJet(jetTypeE)&&doPVCorrection_) {
464 auto const & ct = tower.
p4(vertex_);
465 fjInputs_.emplace_back(ct.px(),ct.py(),ct.pz(),ct.energy());
478 fjInputs_.back().set_user_index(
i - inBegin);
481 if ( restrictInputs_ && fjInputs_.size() > maxInputs_ ) {
483 std::sort(fjInputs_.begin(), fjInputs_.end(), pTComparator);
484 fjInputs_.resize(maxInputs_);
485 edm::LogWarning(
"JetRecoTooManyEntries") <<
"Too many inputs in the event, limiting to first " << maxInputs_ <<
". Output is suspect.";
492 if (!makeCaloJet(jetTypeE))
495 return (*anomalousTowerDef_)(*input);
508 for (
unsigned int i=0;
i<fjConstituents.size();++
i) {
509 int index = fjConstituents[
i].user_index();
510 if ( index >= 0 && static_cast<unsigned int>(index) < inputs_.size() )
517 vector<reco::CandidatePtr>
520 vector<reco::CandidatePtr>
result; result.reserve(fjConstituents.size()/2);
521 for (
unsigned int i=0;
i<fjConstituents.size();
i++) {
522 auto index = fjConstituents[
i].user_index();
523 if (
index >= 0 && static_cast<unsigned int>(
index) < inputs_.size() ) {
524 result.emplace_back(inputs_[
index]);
538 if ( writeCompound_ ) {
542 writeCompoundJets<reco::CaloJet>(
iEvent, iSetup );
544 case JetType::PFJet :
545 writeCompoundJets<reco::PFJet>(
iEvent, iSetup );
548 writeCompoundJets<reco::GenJet>(
iEvent, iSetup );
550 case JetType::BasicJet :
551 writeCompoundJets<reco::BasicJet>(
iEvent, iSetup );
554 throw cms::Exception(
"InvalidInput") <<
"invalid jet type in CompoundJetProducer\n";
557 }
else if ( writeJetsWithConst_ ) {
559 writeJetsWithConstituents<reco::PFJet>(
iEvent, iSetup );
563 writeJets<reco::CaloJet>(
iEvent, iSetup);
565 case JetType::PFJet :
566 writeJets<reco::PFJet>(
iEvent, iSetup);
569 writeJets<reco::GenJet>(
iEvent, iSetup);
571 case JetType::TrackJet :
572 writeJets<reco::TrackJet>(
iEvent, iSetup);
574 case JetType::PFClusterJet :
575 writeJets<reco::PFClusterJet>(
iEvent, iSetup);
577 case JetType::BasicJet :
578 writeJets<reco::BasicJet>(
iEvent, iSetup);
581 throw cms::Exception(
"InvalidInput") <<
"invalid jet type in VirtualJetProducer\n";
589 template<
typename T >
590 struct Area {
static float get(
T const &) {
return 0;}};
594 return jet.getSpecific().mTowersArea;
599 template<
typename T >
611 std::vector<fastjet::PseudoJet> fjexcluded_jets;
612 fjexcluded_jets=fjJets_;
614 if(fjexcluded_jets.size()>2) fjexcluded_jets.resize(nExclude_);
616 if(doFastJetNonUniform_){
617 auto rhos = std::make_unique<std::vector<double>>();
618 auto sigmas = std::make_unique<std::vector<double>>();
619 int nEta = puCenters_.size();
621 sigmas->reserve(nEta);
622 fastjet::ClusterSequenceAreaBase
const* clusterSequenceWithArea =
623 dynamic_cast<fastjet::ClusterSequenceAreaBase
const *
> ( &*fjClusterSeq_ );
625 if (clusterSequenceWithArea ==
nullptr ){
626 if (!fjJets_.empty()) {
627 throw cms::Exception(
"LogicError")<<
"fjClusterSeq is not initialized while inputs are present\n ";
630 for(
int ie = 0; ie <
nEta; ++ie){
631 double eta = puCenters_[ie];
632 double etamin=eta-puWidth_;
633 double etamax=eta+puWidth_;
634 fastjet::RangeDefinition range_rho(etamin,etamax);
637 rhos->push_back(bkgestim.
rho());
638 sigmas->push_back(bkgestim.
sigma());
644 auto rho = std::make_unique<double>(0.0);
645 auto sigma = std::make_unique<double>(0.0);
646 double mean_area = 0;
648 fastjet::ClusterSequenceAreaBase
const* clusterSequenceWithArea =
649 dynamic_cast<fastjet::ClusterSequenceAreaBase
const *
> ( &*fjClusterSeq_ );
656 if (clusterSequenceWithArea ==
nullptr ){
657 if (!fjJets_.empty()) {
658 throw cms::Exception(
"LogicError")<<
"fjClusterSeq is not initialized while inputs are present\n ";
661 clusterSequenceWithArea->get_median_rho_and_sigma(*fjRangeDef_,
false,*rho,*sigma,mean_area);
663 edm::LogError(
"BadRho") <<
"rho value is " << *rho <<
" area:" << mean_area <<
" and n_empty_jets: " << clusterSequenceWithArea->n_empty_jets(*fjRangeDef_) <<
" with range " << fjRangeDef_->description()
664 <<
". Setting rho to rezo.";
675 using namespace reco;
678 auto jets = std::make_unique<std::vector<T>>(fjJets_.size());
681 using RIJ = std::pair<double,double>;
682 std::vector<RIJ> rijStorage(fjJets_.size()*(fjJets_.size()/2));
683 RIJ * rij[fjJets_.size()];
685 for (
unsigned int ijet=0;ijet<fjJets_.size();++ijet) {
686 rij[ijet] = &rijStorage[
k]; k+=ijet;
689 float etaJ[fjJets_.size()], phiJ[fjJets_.size()];
691 auto orParam_ = 1./rParam_;
693 for (
unsigned int ijet=0;ijet<fjJets_.size();++ijet) {
694 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);
711 constituents, iSetup);
712 phiJ[ijet] =
jet.phi();
713 etaJ[ijet] =
jet.eta();
717 for (
unsigned int ijet=0;ijet<fjJets_.size();++ijet) {
721 const auto & fjJet = fjJets_[ijet];
722 if ( doAreaFastjet_ && fjJet.has_area() ) {
723 jetArea = fjJet.area();
725 else if ( doAreaDiskApprox_ ) {
730 for (
unsigned jJet = 0; jJet < ijet; ++jJet) {
733 jetArea -=distance[jJet].second;
734 for (
unsigned kJet = 0; kJet < jJet; ++kJet) {
736 distance[jJet].
second, distance[kJet].second, rij[jJet][kJet].second);
739 jetArea *= (rParam_*rParam_);
741 auto &
jet = (*jets)[ijet];
742 jet.setJetArea (jetArea);
745 jet.setPileup(subtractor_->getPileUpEnergy(ijet));
762 if ( verbosity_ >= 1 ) {
763 std::cout <<
"<VirtualJetProducer::writeCompoundJets (moduleLabel = " << moduleLabel_ <<
")>:" << std::endl;
767 auto jetCollection = std::make_unique<reco::BasicJetCollection>();
769 auto subjetCollection = std::make_unique<std::vector<T>>();
774 std::vector< std::vector<int> > indices;
776 std::vector<math::XYZTLorentzVector> p4_hardJets;
778 std::vector<double> area_hardJets;
781 std::vector<fastjet::PseudoJet>::const_iterator it = fjJets_.begin(),
782 iEnd = fjJets_.end(),
783 iBegin = fjJets_.begin();
784 indices.resize( fjJets_.size() );
785 for ( ; it != iEnd; ++it ) {
786 fastjet::PseudoJet
const & localJet = *it;
787 unsigned int jetIndex = it - iBegin;
790 double localJetArea = 0.0;
791 if ( doAreaFastjet_ && localJet.has_area() ) {
792 localJetArea = localJet.area();
794 area_hardJets.push_back( localJetArea );
797 std::vector<fastjet::PseudoJet> constituents;
798 if ( it->has_pieces() ) {
799 constituents = it->pieces();
800 }
else if ( it->has_constituents() ) {
801 constituents = it->constituents();
804 std::vector<fastjet::PseudoJet>::const_iterator itSubJetBegin = constituents.begin(),
805 itSubJet = itSubJetBegin, itSubJetEnd = constituents.end();
806 for (; itSubJet != itSubJetEnd; ++itSubJet ){
808 fastjet::PseudoJet
const & subjet = *itSubJet;
809 if ( verbosity_ >= 1 ) {
810 std::cout <<
"subjet #" << (itSubJet - itSubJetBegin) <<
": Pt = " << subjet.pt() <<
", eta = " << subjet.eta() <<
", phi = " << subjet.phi() <<
", mass = " << subjet.m()
811 <<
" (#constituents = " << subjet.constituents().size() <<
")" << std::endl;
812 std::vector<fastjet::PseudoJet> subjet_constituents = subjet.constituents();
813 int idx_constituent = 0;
814 for ( std::vector<fastjet::PseudoJet>::const_iterator constituent = subjet_constituents.begin();
815 constituent != subjet_constituents.end(); ++constituent ) {
816 if ( constituent->pt() < 1.e-3 )
continue;
817 std::cout <<
" constituent #" << idx_constituent <<
": Pt = " << constituent->pt() <<
", eta = " << constituent->eta() <<
", phi = " << constituent->phi() <<
"," 818 <<
" mass = " << constituent->m() << std::endl;
823 if ( verbosity_ >= 1 ) {
824 std::cout <<
"subjet #" << (itSubJet - itSubJetBegin) <<
": Pt = " << subjet.pt() <<
", eta = " << subjet.eta() <<
", phi = " << subjet.phi() <<
", mass = " << subjet.m()
825 <<
" (#constituents = " << subjet.constituents().size() <<
")" << std::endl;
826 std::vector<fastjet::PseudoJet> subjet_constituents = subjet.constituents();
827 int idx_constituent = 0;
828 for ( std::vector<fastjet::PseudoJet>::const_iterator constituent = subjet_constituents.begin();
829 constituent != subjet_constituents.end(); ++constituent ) {
830 if ( constituent->pt() < 1.e-3 )
continue;
831 std::cout <<
" constituent #" << idx_constituent <<
": Pt = " << constituent->pt() <<
", eta = " << constituent->eta() <<
", phi = " << constituent->phi() <<
"," 832 <<
" mass = " << constituent->m() << std::endl;
841 std::vector<reco::CandidatePtr> subjetConstituents;
844 std::vector<fastjet::PseudoJet> subjetFastjetConstituents = subjet.constituents();
845 std::vector<reco::CandidatePtr> constituents =
846 getConstituents(subjetFastjetConstituents );
848 indices[jetIndex].push_back( subjetCollection->size() );
853 double subjetArea = 0.0;
854 if ( doAreaFastjet_ && itSubJet->has_area() ){
855 subjetArea = itSubJet->area();
857 jet.setJetArea( subjetArea );
858 subjetCollection->push_back( jet );
863 subjetHandleAfterPut = iEvent.
put(
std::move(subjetCollection), jetCollInstanceName_);
866 std::vector<math::XYZTLorentzVector>::const_iterator ip4 = p4_hardJets.begin(),
867 ip4Begin = p4_hardJets.begin(),
868 ip4End = p4_hardJets.end();
870 for ( ; ip4 != ip4End; ++ip4 ) {
871 int p4_index = ip4 - ip4Begin;
872 std::vector<int> & ind = indices[p4_index];
873 std::vector<reco::CandidatePtr> i_hardJetConstituents;
875 for( std::vector<int>::const_iterator isub = ind.begin();
876 isub != ind.end(); ++isub ) {
878 i_hardJetConstituents.push_back( candPtr );
882 toput.
setJetArea( area_hardJets[ip4 - ip4Begin] );
883 jetCollection->push_back( toput );
890 if (fromHTTTopJetProducer_){
891 addHTTTopJetTagInfoCollection( iEvent, iSetup, oh);
900 if ( verbosity_ >= 1 ) {
901 std::cout <<
"<VirtualJetProducer::writeJetsWithConstituents (moduleLabel = " << moduleLabel_ <<
")>:" << std::endl;
905 auto jetCollection = std::make_unique<reco::PFJetCollection>();
908 std::vector< std::vector<int> > indices;
910 std::vector<math::XYZTLorentzVector> p4_Jets;
912 std::vector<double> area_Jets;
915 auto constituentCollection = std::make_unique<reco::PFCandidateCollection>();
921 std::vector<fastjet::PseudoJet> constituentsSub;
922 std::vector<fastjet::PseudoJet>::const_iterator it = fjJets_.begin(),
923 iEnd = fjJets_.end(),
924 iBegin = fjJets_.begin();
925 indices.resize( fjJets_.size() );
927 for ( ; it != iEnd; ++it ) {
928 fastjet::PseudoJet
const & localJet = *it;
929 unsigned int jetIndex = it - iBegin;
932 double localJetArea = 0.0;
933 if ( doAreaFastjet_ && localJet.has_area() ) {
934 localJetArea = localJet.area();
936 area_Jets.push_back( localJetArea );
939 std::vector<fastjet::PseudoJet> constituents,ghosts;
940 if ( it->has_pieces() )
941 constituents = it->pieces();
942 else if ( it->has_constituents() )
943 fastjet::SelectorIsPureGhost().sift(it->constituents(), ghosts, constituents);
946 indices[jetIndex].reserve(constituents.size());
947 constituentsSub.reserve(constituentsSub.size()+constituents.size());
948 for (fastjet::PseudoJet
const& constit : constituents) {
949 indices[jetIndex].push_back( constituentsSub.size() );
950 constituentsSub.push_back(constit);
956 for (fastjet::PseudoJet
const& constit : constituentsSub) {
957 auto orig = inputs_[constit.user_index()];
961 pVec.SetPxPyPzE(constit.px(),constit.py(),constit.pz(),constit.e());
964 constituentCollection->push_back(pCand);
967 constituentHandleAfterPut = iEvent.
put(
std::move(constituentCollection), jetCollInstanceName_ );
970 std::vector<math::XYZTLorentzVector>::const_iterator ip4 = p4_Jets.begin(),
971 ip4Begin = p4_Jets.begin(),
972 ip4End = p4_Jets.end();
974 for ( ; ip4 != ip4End; ++ip4 ) {
975 int p4_index = ip4 - ip4Begin;
976 std::vector<int> & ind = indices[p4_index];
977 std::vector<reco::CandidatePtr> i_jetConstituents;
979 for( std::vector<int>::const_iterator iconst = ind.begin(); iconst != ind.end(); ++iconst ) {
981 i_jetConstituents.push_back( candPtr );
983 if(!i_jetConstituents.empty()) {
988 jetCollection->emplace_back( jet );
1000 fillDescriptionsFromVirtualJetProducer(desc);
1001 desc.
add<
string>(
"jetCollInstanceName",
"" );
1014 desc.
add<
string>(
"jetType",
"PFJet" );
1015 desc.
add<
string>(
"jetAlgorithm",
"AntiKt" );
1016 desc.
add<
double>(
"rParam", 0.4 );
1017 desc.
add<
double>(
"inputEtMin", 0.0 );
1018 desc.
add<
double>(
"inputEMin", 0.0 );
1019 desc.
add<
double>(
"jetPtMin", 5. );
1020 desc.
add<
bool> (
"doPVCorrection",
false );
1021 desc.
add<
bool> (
"doAreaFastjet",
false );
1022 desc.
add<
bool> (
"doRhoFastjet",
false );
1023 desc.
add<
bool> (
"doPUOffsetCorr",
false );
1024 desc.
add<
double>(
"puPtMin", 10.);
1025 desc.
add<
double>(
"nSigmaPU", 1.0 );
1026 desc.
add<
double>(
"radiusPU", 0.5 );
1027 desc.
add<
string>(
"subtractorName",
"" );
1028 desc.
add<
bool> (
"useExplicitGhosts",
false );
1029 desc.
add<
bool> (
"doAreaDiskApprox",
false );
1030 desc.
add<
double>(
"voronoiRfact", -0.9 );
1031 desc.
add<
double>(
"Rho_EtaMax", 4.4 );
1032 desc.
add<
double>(
"Ghost_EtaMax", 5. );
1033 desc.
add<
int> (
"Active_Area_Repeats", 1 );
1034 desc.
add<
double>(
"GhostArea", 0.01 );
1035 desc.
add<
bool> (
"restrictInputs",
false );
1036 desc.
add<
unsigned int> (
"maxInputs", 1 );
1037 desc.
add<
bool> (
"writeCompound",
false );
1038 desc.
add<
bool> (
"writeJetsWithConst",
false );
1039 desc.
add<
bool> (
"doFastJetNonUniform",
false );
1040 desc.
add<
bool> (
"useDeterministicSeed",
false );
1041 desc.
add<
unsigned int> (
"minSeed", 14327 );
1042 desc.
add<
int> (
"verbosity", 0 );
1043 desc.
add<
double>(
"puWidth", 0. );
1044 desc.
add<
unsigned int>(
"nExclude", 0 );
1045 desc.
add<
unsigned int>(
"maxBadEcalCells", 9999999 );
1046 desc.
add<
unsigned int>(
"maxBadHcalCells", 9999999 );
1047 desc.
add<
unsigned int>(
"maxProblematicEcalCells", 9999999 );
1048 desc.
add<
unsigned int>(
"maxProblematicHcalCells", 9999999 );
1049 desc.
add<
unsigned int>(
"maxRecoveredEcalCells", 9999999 );
1050 desc.
add<
unsigned int>(
"maxRecoveredHcalCells", 9999999 );
1051 vector<double> puCentersDefault;
1052 desc.
add<vector<double>>(
"puCenters", puCentersDefault);
boost::shared_ptr< fastjet::AreaDefinition > AreaDefinitionPtr
void writeJets(edm::Event &iEvent, edm::EventSetup const &iSetup)
T getParameter(std::string const &) const
EventNumber_t event() const
boost::shared_ptr< fastjet::JetDefinition > JetDefPtr
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Jets made from CaloTowers.
static const HistoName names[]
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
virtual void inputTowers()
Base class for all types of Jets.
boost::shared_ptr< fastjet::JetDefinition::Plugin > PluginPtr
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.
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
boost::shared_ptr< fastjet::RangeDefinition > RangeDefPtr
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)
auto const T2 &decltype(t1.eta()) t2
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)
double rho()
synonym for median rho [[do we have this? Both?]]
ParticleType translatePdgIdToType(int pdgid) const
static const char *const names[]
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
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)
boost::shared_ptr< fastjet::GhostedAreaSpec > ActiveAreaSpecPtr
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
T get(const Candidate &c)
*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