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"));
175 if (jetAlgorithm_==
"Kt")
176 fjJetDefinition_=
JetDefPtr(
new fastjet::JetDefinition(fastjet::kt_algorithm,rParam_));
178 else if (jetAlgorithm_==
"CambridgeAachen")
179 fjJetDefinition_=
JetDefPtr(
new fastjet::JetDefinition(fastjet::cambridge_algorithm,rParam_) );
181 else if (jetAlgorithm_==
"AntiKt")
182 fjJetDefinition_=
JetDefPtr(
new fastjet::JetDefinition(fastjet::antikt_algorithm,rParam_) );
184 else if (jetAlgorithm_==
"GeneralizedKt")
185 fjJetDefinition_=
JetDefPtr(
new fastjet::JetDefinition(fastjet::genkt_algorithm,rParam_,-2) );
187 else if (jetAlgorithm_==
"SISCone") {
189 fjPlugin_ =
PluginPtr(
new fastjet::SISConePlugin(rParam_,0.75,0,0.0,
false,fastjet::SISConePlugin::SM_pttilde) );
190 fjJetDefinition_=
JetDefPtr(
new fastjet::JetDefinition(&*fjPlugin_) );
192 }
else if (jetAlgorithm_==
"IterativeCone") {
194 fjPlugin_ =
PluginPtr(
new fastjet::CMSIterativeConePlugin(rParam_,1.0));
195 fjJetDefinition_=
JetDefPtr(
new fastjet::JetDefinition(&*fjPlugin_));
197 }
else if (jetAlgorithm_==
"CDFMidPoint") {
199 fjPlugin_ =
PluginPtr(
new fastjet::CDFMidPointPlugin(rParam_,0.75));
200 fjJetDefinition_=
JetDefPtr(
new fastjet::JetDefinition(&*fjPlugin_));
202 }
else if (jetAlgorithm_==
"ATLASCone") {
204 fjPlugin_ =
PluginPtr(
new fastjet::ATLASConePlugin(rParam_));
205 fjJetDefinition_=
JetDefPtr(
new fastjet::JetDefinition(&*fjPlugin_));
208 throw cms::Exception(
"Invalid jetAlgorithm") <<
"Jet algorithm for VirtualJetProducer is invalid, Abort!\n";
213 if ( doPUOffsetCorr_ ) {
214 if(puSubtractorName_.empty()){
215 LogWarning(
"VirtualJetProducer") <<
"Pile Up correction on; however, pile up type is not specified. Using default... \n";
216 subtractor_ = boost::shared_ptr<PileUpSubtractor>(
new PileUpSubtractor(iConfig, consumesCollector()));
217 }
else subtractor_ = boost::shared_ptr<PileUpSubtractor>(
222 if (doAreaDiskApprox_ && doAreaFastjet_)
223 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";
225 if ( doAreaFastjet_ || doRhoFastjet_ ) {
227 if (voronoiRfact_ <= 0) {
228 fjActiveArea_ =
ActiveAreaSpecPtr(
new fastjet::GhostedAreaSpec(ghostEtaMax_,activeAreaRepeats_,ghostArea_));
229 fjActiveArea_->set_fj2_placement(
true);
231 if ( !useExplicitGhosts_ ) {
232 fjAreaDefinition_ =
AreaDefinitionPtr(
new fastjet::AreaDefinition(fastjet::active_area, *fjActiveArea_ ) );
234 fjAreaDefinition_ =
AreaDefinitionPtr(
new fastjet::AreaDefinition(fastjet::active_area_explicit_ghosts, *fjActiveArea_ ) );
237 fjRangeDef_ =
RangeDefPtr(
new fastjet::RangeDefinition(rhoEtaMax_) );
240 if( ( doFastJetNonUniform_ ) && ( puCenters_.size() == 0 ) )
241 throw cms::Exception(
"doFastJetNonUniform") <<
"Parameter puCenters for doFastJetNonUniform is not defined." << std::endl;
244 makeProduces( moduleLabel_, jetCollInstanceName_ );
245 produces<vector<double> >(
"rhos");
246 produces<vector<double> >(
"sigmas");
247 produces<double>(
"rho");
248 produces<double>(
"sigma");
272 if ( useDeterministicSeed_ ) {
273 fastjet::GhostedAreaSpec gas;
274 std::vector<int> seeds(2);
275 unsigned int runNum_uint = static_cast <
unsigned int> (iEvent.
id().
run());
276 unsigned int evNum_uint = static_cast <
unsigned int> (iEvent.
id().
event());
277 seeds[0] =
std::max(runNum_uint,minSeed_ + 3) + 3 * evNum_uint;
278 seeds[1] =
std::max(runNum_uint,minSeed_ + 5) + 5 * evNum_uint;
279 gas.set_random_status(seeds);
282 LogDebug(
"VirtualJetProducer") <<
"Entered produce\n";
285 if ( (makeCaloJet(jetTypeE) || makePFJet(jetTypeE)) &&doPVCorrection_) {
286 LogDebug(
"VirtualJetProducer") <<
"Adding PV info\n";
288 iEvent.
getByToken(input_vertex_token_ , pvCollection);
289 if (pvCollection->size()>0) vertex_=pvCollection->begin()->position();
294 if ( doPUOffsetCorr_ ) {
295 subtractor_->setupGeometryMap(iEvent, iSetup);
299 LogDebug(
"VirtualJetProducer") <<
"Clear data\n";
310 bool isView = iEvent.
getByToken(input_candidateview_token_, inputsHandle);
312 if ( inputsHandle->
size() == 0) {
316 for (
size_t i = 0;
i < inputsHandle->
size(); ++
i) {
317 inputs_.push_back(inputsHandle->
ptrAt(
i));
320 bool isPF = iEvent.
getByToken(input_candidatefwdptr_token_, pfinputsHandleAsFwdPtr);
322 if ( pfinputsHandleAsFwdPtr->size() == 0) {
326 for (
size_t i = 0;
i < pfinputsHandleAsFwdPtr->size(); ++
i) {
327 if ( (*pfinputsHandleAsFwdPtr)[
i].ptr().isAvailable() ) {
328 inputs_.push_back( (*pfinputsHandleAsFwdPtr)[
i].ptr() );
330 else if ( (*pfinputsHandleAsFwdPtr)[
i].backPtr().isAvailable() ) {
331 inputs_.push_back( (*pfinputsHandleAsFwdPtr)[
i].backPtr() );
335 iEvent.
getByToken(input_packedcandidatefwdptr_token_, packedinputsHandleAsFwdPtr);
336 if ( packedinputsHandleAsFwdPtr->size() == 0) {
340 for (
size_t i = 0;
i < packedinputsHandleAsFwdPtr->size(); ++
i) {
341 if ( (*packedinputsHandleAsFwdPtr)[
i].ptr().isAvailable() ) {
342 inputs_.push_back( (*packedinputsHandleAsFwdPtr)[
i].ptr() );
344 else if ( (*packedinputsHandleAsFwdPtr)[
i].backPtr().isAvailable() ) {
345 inputs_.push_back( (*packedinputsHandleAsFwdPtr)[
i].backPtr() );
350 LogDebug(
"VirtualJetProducer") <<
"Got inputs\n";
355 fjInputs_.reserve(inputs_.size());
357 LogDebug(
"VirtualJetProducer") <<
"Inputted towers\n";
361 if ( doPUOffsetCorr_ ) {
362 subtractor_->setDefinition(fjJetDefinition_);
363 subtractor_->reset(inputs_,fjInputs_,fjJets_);
364 subtractor_->calculatePedestal(fjInputs_);
365 subtractor_->subtractPedestal(fjInputs_);
366 LogDebug(
"VirtualJetProducer") <<
"Subtracted pedestal\n";
370 runAlgorithm( iEvent, iSetup );
376 LogDebug(
"VirtualJetProducer") <<
"Ran algorithm\n";
383 if ( doPUOffsetCorr_ ) {
384 LogDebug(
"VirtualJetProducer") <<
"Do PUOffsetCorr\n";
385 vector<fastjet::PseudoJet> orphanInput;
386 subtractor_->calculateOrphanInput(orphanInput);
387 subtractor_->calculatePedestal(orphanInput);
388 subtractor_->offsetCorrectJets();
395 LogDebug(
"VirtualJetProducer") <<
"Wrote jets\n";
400 decltype(fjInputs_)().
swap(fjInputs_);
401 decltype(fjJets_)().
swap(fjJets_);
402 decltype(inputs_)().
swap(inputs_);
411 auto inBegin = inputs_.begin(),
412 inEnd = inputs_.end(),
i = inBegin;
413 for (;
i != inEnd; ++
i ) {
417 if (
input.et() <inputEtMin_)
continue;
418 if (
input.energy()<inputEMin_)
continue;
419 if (isAnomalousTower(*
i))
continue;
425 if (makeCaloJet(jetTypeE)&&doPVCorrection_) {
427 auto const & ct = tower.
p4(vertex_);
428 fjInputs_.emplace_back(ct.px(),ct.py(),ct.pz(),ct.energy());
441 fjInputs_.back().set_user_index(
i - inBegin);
444 if ( restrictInputs_ && fjInputs_.size() > maxInputs_ ) {
446 std::sort(fjInputs_.begin(), fjInputs_.end(), pTComparator);
447 fjInputs_.resize(maxInputs_);
448 edm::LogWarning(
"JetRecoTooManyEntries") <<
"Too many inputs in the event, limiting to first " << maxInputs_ <<
". Output is suspect.";
455 if (!makeCaloJet(jetTypeE))
458 return (*anomalousTowerDef_)(*input);
471 for (
unsigned int i=0;
i<fjConstituents.size();++
i) {
472 int index = fjConstituents[
i].user_index();
473 if ( index >= 0 && static_cast<unsigned int>(index) < inputs_.size() )
480 vector<reco::CandidatePtr>
483 vector<reco::CandidatePtr>
result; result.reserve(fjConstituents.size()/2);
484 for (
unsigned int i=0;
i<fjConstituents.size();
i++) {
485 auto index = fjConstituents[
i].user_index();
486 if (
index >= 0 && static_cast<unsigned int>(
index) < inputs_.size() ) {
487 result.emplace_back(inputs_[
index]);
501 if ( writeCompound_ ) {
505 writeCompoundJets<reco::CaloJet>(
iEvent, iSetup );
507 case JetType::PFJet :
508 writeCompoundJets<reco::PFJet>(
iEvent, iSetup );
510 case JetType::GenJet :
511 writeCompoundJets<reco::GenJet>(
iEvent, iSetup );
513 case JetType::BasicJet :
514 writeCompoundJets<reco::BasicJet>(
iEvent, iSetup );
517 throw cms::Exception(
"InvalidInput") <<
"invalid jet type in CompoundJetProducer\n";
520 }
else if ( writeJetsWithConst_ ) {
522 writeJetsWithConstituents<reco::PFJet>(
iEvent, iSetup );
526 writeJets<reco::CaloJet>(
iEvent, iSetup);
528 case JetType::PFJet :
529 writeJets<reco::PFJet>(
iEvent, iSetup);
531 case JetType::GenJet :
532 writeJets<reco::GenJet>(
iEvent, iSetup);
534 case JetType::TrackJet :
535 writeJets<reco::TrackJet>(
iEvent, iSetup);
537 case JetType::PFClusterJet :
538 writeJets<reco::PFClusterJet>(
iEvent, iSetup);
540 case JetType::BasicJet :
541 writeJets<reco::BasicJet>(
iEvent, iSetup);
544 throw cms::Exception(
"InvalidInput") <<
"invalid jet type in VirtualJetProducer\n";
552 template<
typename T >
553 struct Area {
static float get(
T const &) {
return 0;}};
557 return jet.getSpecific().mTowersArea;
562 template<
typename T >
574 std::vector<fastjet::PseudoJet> fjexcluded_jets;
575 fjexcluded_jets=fjJets_;
577 if(fjexcluded_jets.size()>2) fjexcluded_jets.resize(nExclude_);
579 if(doFastJetNonUniform_){
580 auto rhos = std::make_unique<std::vector<double>>();
581 auto sigmas = std::make_unique<std::vector<double>>();
582 int nEta = puCenters_.size();
584 sigmas->reserve(nEta);
585 fastjet::ClusterSequenceAreaBase
const* clusterSequenceWithArea =
586 dynamic_cast<fastjet::ClusterSequenceAreaBase
const *
> ( &*fjClusterSeq_ );
588 if (clusterSequenceWithArea ==
nullptr ){
589 if (fjJets_.size() > 0) {
590 throw cms::Exception(
"LogicError")<<
"fjClusterSeq is not initialized while inputs are present\n ";
593 for(
int ie = 0; ie <
nEta; ++ie){
594 double eta = puCenters_[ie];
595 double etamin=eta-puWidth_;
596 double etamax=eta+puWidth_;
597 fastjet::RangeDefinition range_rho(etamin,etamax);
600 rhos->push_back(bkgestim.
rho());
601 sigmas->push_back(bkgestim.
sigma());
607 auto rho = std::make_unique<double>(0.0);
608 auto sigma = std::make_unique<double>(0.0);
609 double mean_area = 0;
611 fastjet::ClusterSequenceAreaBase
const* clusterSequenceWithArea =
612 dynamic_cast<fastjet::ClusterSequenceAreaBase
const *
> ( &*fjClusterSeq_ );
619 if (clusterSequenceWithArea ==
nullptr ){
620 if (fjJets_.size() > 0) {
621 throw cms::Exception(
"LogicError")<<
"fjClusterSeq is not initialized while inputs are present\n ";
624 clusterSequenceWithArea->get_median_rho_and_sigma(*fjRangeDef_,
false,*rho,*sigma,mean_area);
626 edm::LogError(
"BadRho") <<
"rho value is " << *rho <<
" area:" << mean_area <<
" and n_empty_jets: " << clusterSequenceWithArea->n_empty_jets(*fjRangeDef_) <<
" with range " << fjRangeDef_->description()
627 <<
". Setting rho to rezo.";
638 using namespace reco;
641 auto jets = std::make_unique<std::vector<T>>(fjJets_.size());
644 using RIJ = std::pair<double,double>;
645 std::vector<RIJ> rijStorage(fjJets_.size()*(fjJets_.size()/2));
646 RIJ * rij[fjJets_.size()];
648 for (
unsigned int ijet=0;ijet<fjJets_.size();++ijet) {
649 rij[ijet] = &rijStorage[
k]; k+=ijet;
652 float etaJ[fjJets_.size()], phiJ[fjJets_.size()];
654 auto orParam_ = 1./rParam_;
656 for (
unsigned int ijet=0;ijet<fjJets_.size();++ijet) {
657 auto &
jet = (*jets)[ijet];
659 const fastjet::PseudoJet& fjJet = fjJets_[ijet];
661 std::vector<fastjet::PseudoJet>
const & fjConstituents = fastjet::sorted_by_pt(fjJet.constituents());
663 std::vector<CandidatePtr>
const & constituents = getConstituents(fjConstituents);
674 constituents, iSetup);
675 phiJ[ijet] =
jet.phi();
676 etaJ[ijet] =
jet.eta();
680 for (
unsigned int ijet=0;ijet<fjJets_.size();++ijet) {
684 const auto & fjJet = fjJets_[ijet];
685 if ( doAreaFastjet_ && fjJet.has_area() ) {
686 jetArea = fjJet.area();
688 else if ( doAreaDiskApprox_ ) {
693 for (
unsigned jJet = 0; jJet < ijet; ++jJet) {
696 jetArea -=distance[jJet].second;
697 for (
unsigned kJet = 0; kJet < jJet; ++kJet) {
699 distance[jJet].
second, distance[kJet].second, rij[jJet][kJet].second);
702 jetArea *= (rParam_*rParam_);
704 auto &
jet = (*jets)[ijet];
705 jet.setJetArea (jetArea);
708 jet.setPileup(subtractor_->getPileUpEnergy(ijet));
725 if ( verbosity_ >= 1 ) {
726 std::cout <<
"<VirtualJetProducer::writeCompoundJets (moduleLabel = " << moduleLabel_ <<
")>:" << std::endl;
730 auto jetCollection = std::make_unique<reco::BasicJetCollection>();
732 auto subjetCollection = std::make_unique<std::vector<T>>();
737 std::vector< std::vector<int> > indices;
739 std::vector<math::XYZTLorentzVector> p4_hardJets;
741 std::vector<double> area_hardJets;
744 std::vector<fastjet::PseudoJet>::const_iterator it = fjJets_.begin(),
745 iEnd = fjJets_.end(),
746 iBegin = fjJets_.begin();
747 indices.resize( fjJets_.size() );
748 for ( ; it != iEnd; ++it ) {
749 fastjet::PseudoJet
const & localJet = *it;
750 unsigned int jetIndex = it - iBegin;
753 double localJetArea = 0.0;
754 if ( doAreaFastjet_ && localJet.has_area() ) {
755 localJetArea = localJet.area();
757 area_hardJets.push_back( localJetArea );
760 std::vector<fastjet::PseudoJet> constituents;
761 if ( it->has_pieces() ) {
762 constituents = it->pieces();
763 }
else if ( it->has_constituents() ) {
764 constituents = it->constituents();
767 std::vector<fastjet::PseudoJet>::const_iterator itSubJetBegin = constituents.begin(),
768 itSubJet = itSubJetBegin, itSubJetEnd = constituents.end();
769 for (; itSubJet != itSubJetEnd; ++itSubJet ){
771 fastjet::PseudoJet
const & subjet = *itSubJet;
772 if ( verbosity_ >= 1 ) {
773 std::cout <<
"subjet #" << (itSubJet - itSubJetBegin) <<
": Pt = " << subjet.pt() <<
", eta = " << subjet.eta() <<
", phi = " << subjet.phi() <<
", mass = " << subjet.m()
774 <<
" (#constituents = " << subjet.constituents().size() <<
")" << std::endl;
775 std::vector<fastjet::PseudoJet> subjet_constituents = subjet.constituents();
776 int idx_constituent = 0;
777 for ( std::vector<fastjet::PseudoJet>::const_iterator constituent = subjet_constituents.begin();
778 constituent != subjet_constituents.end(); ++constituent ) {
779 if ( constituent->pt() < 1.e-3 )
continue;
780 std::cout <<
" constituent #" << idx_constituent <<
": Pt = " << constituent->pt() <<
", eta = " << constituent->eta() <<
", phi = " << constituent->phi() <<
"," 781 <<
" mass = " << constituent->m() << std::endl;
786 if ( verbosity_ >= 1 ) {
787 std::cout <<
"subjet #" << (itSubJet - itSubJetBegin) <<
": Pt = " << subjet.pt() <<
", eta = " << subjet.eta() <<
", phi = " << subjet.phi() <<
", mass = " << subjet.m()
788 <<
" (#constituents = " << subjet.constituents().size() <<
")" << std::endl;
789 std::vector<fastjet::PseudoJet> subjet_constituents = subjet.constituents();
790 int idx_constituent = 0;
791 for ( std::vector<fastjet::PseudoJet>::const_iterator constituent = subjet_constituents.begin();
792 constituent != subjet_constituents.end(); ++constituent ) {
793 if ( constituent->pt() < 1.e-3 )
continue;
794 std::cout <<
" constituent #" << idx_constituent <<
": Pt = " << constituent->pt() <<
", eta = " << constituent->eta() <<
", phi = " << constituent->phi() <<
"," 795 <<
" mass = " << constituent->m() << std::endl;
804 std::vector<reco::CandidatePtr> subjetConstituents;
807 std::vector<fastjet::PseudoJet> subjetFastjetConstituents = subjet.constituents();
808 std::vector<reco::CandidatePtr> constituents =
809 getConstituents(subjetFastjetConstituents );
811 indices[jetIndex].push_back( subjetCollection->size() );
816 double subjetArea = 0.0;
817 if ( doAreaFastjet_ && itSubJet->has_area() ){
818 subjetArea = itSubJet->area();
820 jet.setJetArea( subjetArea );
821 subjetCollection->push_back( jet );
826 subjetHandleAfterPut = iEvent.
put(
std::move(subjetCollection), jetCollInstanceName_);
829 std::vector<math::XYZTLorentzVector>::const_iterator ip4 = p4_hardJets.begin(),
830 ip4Begin = p4_hardJets.begin(),
831 ip4End = p4_hardJets.end();
833 for ( ; ip4 != ip4End; ++ip4 ) {
834 int p4_index = ip4 - ip4Begin;
835 std::vector<int> & ind = indices[p4_index];
836 std::vector<reco::CandidatePtr> i_hardJetConstituents;
838 for( std::vector<int>::const_iterator isub = ind.begin();
839 isub != ind.end(); ++isub ) {
841 i_hardJetConstituents.push_back( candPtr );
845 toput.
setJetArea( area_hardJets[ip4 - ip4Begin] );
846 jetCollection->push_back( toput );
853 if (fromHTTTopJetProducer_){
854 addHTTTopJetTagInfoCollection( iEvent, iSetup, oh);
863 if ( verbosity_ >= 1 ) {
864 std::cout <<
"<VirtualJetProducer::writeJetsWithConstituents (moduleLabel = " << moduleLabel_ <<
")>:" << std::endl;
868 auto jetCollection = std::make_unique<reco::PFJetCollection>();
871 std::vector< std::vector<int> > indices;
873 std::vector<math::XYZTLorentzVector> p4_Jets;
875 std::vector<double> area_Jets;
878 auto constituentCollection = std::make_unique<reco::PFCandidateCollection>();
884 std::vector<fastjet::PseudoJet> constituentsSub;
885 std::vector<fastjet::PseudoJet>::const_iterator it = fjJets_.begin(),
886 iEnd = fjJets_.end(),
887 iBegin = fjJets_.begin();
888 indices.resize( fjJets_.size() );
890 for ( ; it != iEnd; ++it ) {
891 fastjet::PseudoJet
const & localJet = *it;
892 unsigned int jetIndex = it - iBegin;
895 double localJetArea = 0.0;
896 if ( doAreaFastjet_ && localJet.has_area() ) {
897 localJetArea = localJet.area();
899 area_Jets.push_back( localJetArea );
902 std::vector<fastjet::PseudoJet> constituents,ghosts;
903 if ( it->has_pieces() )
904 constituents = it->pieces();
905 else if ( it->has_constituents() )
906 fastjet::SelectorIsPureGhost().sift(it->constituents(), ghosts, constituents);
909 indices[jetIndex].reserve(constituents.size());
910 constituentsSub.reserve(constituentsSub.size()+constituents.size());
911 for (fastjet::PseudoJet
const& constit : constituents) {
912 indices[jetIndex].push_back( constituentsSub.size() );
913 constituentsSub.push_back(constit);
919 for (fastjet::PseudoJet
const& constit : constituentsSub) {
920 auto orig = inputs_[constit.user_index()];
924 pVec.SetPxPyPzE(constit.px(),constit.py(),constit.pz(),constit.e());
927 constituentCollection->push_back(pCand);
930 constituentHandleAfterPut = iEvent.
put(
std::move(constituentCollection), jetCollInstanceName_ );
933 std::vector<math::XYZTLorentzVector>::const_iterator ip4 = p4_Jets.begin(),
934 ip4Begin = p4_Jets.begin(),
935 ip4End = p4_Jets.end();
937 for ( ; ip4 != ip4End; ++ip4 ) {
938 int p4_index = ip4 - ip4Begin;
939 std::vector<int> & ind = indices[p4_index];
940 std::vector<reco::CandidatePtr> i_jetConstituents;
942 for( std::vector<int>::const_iterator iconst = ind.begin(); iconst != ind.end(); ++iconst ) {
944 i_jetConstituents.push_back( candPtr );
946 if(i_jetConstituents.size()>0) {
951 jetCollection->emplace_back( jet );
963 fillDescriptionsFromVirtualJetProducer(desc);
964 desc.
add<
string>(
"jetCollInstanceName",
"" );
977 desc.
add<
string>(
"jetType",
"PFJet" );
978 desc.
add<
string>(
"jetAlgorithm",
"AntiKt" );
979 desc.
add<
double>(
"rParam", 0.4 );
980 desc.
add<
double>(
"inputEtMin", 0.0 );
981 desc.
add<
double>(
"inputEMin", 0.0 );
982 desc.
add<
double>(
"jetPtMin", 5. );
983 desc.
add<
bool> (
"doPVCorrection",
false );
984 desc.
add<
bool> (
"doAreaFastjet",
false );
985 desc.
add<
bool> (
"doRhoFastjet",
false );
986 desc.
add<
bool> (
"doPUOffsetCorr",
false );
987 desc.
add<
double>(
"puPtMin", 10.);
988 desc.
add<
double>(
"nSigmaPU", 1.0 );
989 desc.
add<
double>(
"radiusPU", 0.5 );
990 desc.
add<
string>(
"subtractorName",
"" );
991 desc.
add<
bool> (
"useExplicitGhosts",
false );
992 desc.
add<
bool> (
"doAreaDiskApprox",
false );
993 desc.
add<
double>(
"voronoiRfact", -0.9 );
994 desc.
add<
double>(
"Rho_EtaMax", 4.4 );
995 desc.
add<
double>(
"Ghost_EtaMax", 5. );
996 desc.
add<
int> (
"Active_Area_Repeats", 1 );
997 desc.
add<
double>(
"GhostArea", 0.01 );
998 desc.
add<
bool> (
"restrictInputs",
false );
999 desc.
add<
unsigned int> (
"maxInputs", 1 );
1000 desc.
add<
bool> (
"writeCompound",
false );
1001 desc.
add<
bool> (
"writeJetsWithConst",
false );
1002 desc.
add<
bool> (
"doFastJetNonUniform",
false );
1003 desc.
add<
bool> (
"useDeterministicSeed",
false );
1004 desc.
add<
unsigned int> (
"minSeed", 14327 );
1005 desc.
add<
int> (
"verbosity", 0 );
1006 desc.
add<
double>(
"puWidth", 0. );
1007 desc.
add<
unsigned int>(
"nExclude", 0 );
1008 desc.
add<
unsigned int>(
"maxBadEcalCells", 9999999 );
1009 desc.
add<
unsigned int>(
"maxBadHcalCells", 9999999 );
1010 desc.
add<
unsigned int>(
"maxProblematicEcalCells", 9999999 );
1011 desc.
add<
unsigned int>(
"maxProblematicHcalCells", 9999999 );
1012 desc.
add<
unsigned int>(
"maxRecoveredEcalCells", 9999999 );
1013 desc.
add<
unsigned int>(
"maxRecoveredHcalCells", 9999999 );
1014 vector<double> puCentersDefault;
1015 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)
virtual ~VirtualJetProducer()
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)
virtual void setP4(const LorentzVector &p4) final
set 4-momentum
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.
virtual 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)
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)