|
|
Go to the documentation of this file.
24 #include "fftjet/peakEtLifetime.hh"
44 #define make_param(type, varname) const type& varname(ps.getParameter<type>(#varname))
46 #define init_param(type, varname) varname(ps.getParameter<type>(#varname))
55 #define jet_type_switch(method, arg1, arg2) \
59 method<reco::CaloJet>(arg1, arg2); \
62 method<reco::PFJet>(arg1, arg2); \
65 method<reco::GenJet>(arg1, arg2); \
68 method<reco::TrackJet>(arg1, arg2); \
71 method<reco::BasicJet>(arg1, arg2); \
74 assert(!"ERROR in FFTJetProducer : invalid jet type."\
75 " This is a bug. Please report."); \
80 struct LocalSortByPt {
82 inline bool operator()(
const Jet&
l,
const Jet&
r)
const {
83 return l.pt() >
r.pt();
91 if (!
name.compare(
"fixed"))
93 else if (!
name.compare(
"maximallyStable"))
94 return MAXIMALLY_STABLE;
95 else if (!
name.compare(
"globallyAdaptive"))
96 return GLOBALLY_ADAPTIVE;
97 else if (!
name.compare(
"locallyAdaptive"))
98 return LOCALLY_ADAPTIVE;
99 else if (!
name.compare(
"fromGenJets"))
102 throw cms::Exception(
"FFTJetBadConfig") <<
"Invalid resolution specification \"" <<
name <<
"\"" << std::endl;
105 template <
typename T>
107 produces<std::vector<reco::FFTAnyJet<T> > >(
tag).setBranchAlias(
alias);
151 iterationsPerformed(1
U),
155 throw cms::Exception(
"FFTJetBadConfig") <<
"Can't resum constituents if they are not assigned" << std::endl;
157 produces<reco::FFTJetProducerSummary>(
outputLabel);
169 consumes<reco::PattRecoTree<fftjetcms::Real, reco::PattRecoPeak<fftjetcms::Real> > >(
treeLabel);
185 template <
class Real>
193 if (!
input->isSparse())
194 throw cms::Exception(
"FFTJetBadConfig") <<
"The stored clustering tree is not sparse" << std::endl;
204 const fftjet::Functor1<bool, fftjet::Peak>& peakSelect,
205 std::vector<fftjet::Peak>* preclusters) {
212 const unsigned sz =
input->size();
214 for (
unsigned i = 0;
i < sz; ++
i) {
216 fftjet::Peak
p(
jet.precluster());
217 const double scale(
p.scale());
218 p.setEtaPhi(
jet.vec().Eta(),
jet.vec().Phi());
227 const fftjet::Functor1<bool, fftjet::Peak>& peakSelect,
228 std::vector<fftjet::Peak>* preclusters) {
233 const unsigned nNodes =
nodes.size();
234 const SparseTree::NodeId* pnodes = nNodes ? &
nodes[0] :
nullptr;
236 for (
unsigned i = 0;
i < nNodes; ++
i)
241 fftjet::Peak*
clusters = nNodes ? &(*preclusters)[0] :
nullptr;
242 for (
unsigned i = 0;
i < nNodes; ++
i) {
249 const fftjet::Functor1<bool, fftjet::Peak>& peakSelect,
250 std::vector<SparseTree::NodeId>* mynodes) {
265 if (
tree.stableClusterCount(
277 const int maxlev =
tree.maxStoredLevel();
278 bool levelFound =
false;
280 for (
int ifac = 1; ifac > -2 && !levelFound; ifac -= 2) {
296 const unsigned maxlev =
tree.maxStoredLevel();
323 assert(!
"ERROR in FFTJetProducer::selectTreeNodes : "
324 "should never get here! This is a bug. Please report.");
336 for (
unsigned i = 0;
i < nClus; ++
i) {
337 clus[
i].setRecoScale(scaleCalc(clus[
i]));
338 clus[
i].setRecoScaleRatio(ratioCalc(clus[
i]));
339 clus[
i].setMembershipFactor(factorCalc(clus[
i]));
352 fftjet::DefaultRecombinationAlgFactory<Real, VectorLike, BgData, VBuilder> factory;
372 bool rebuildGrid =
flow.get() ==
nullptr;
379 flow = std::unique_ptr<fftjet::Grid2d<Real> >(
new fftjet::Grid2d<Real>(
387 fftjet::Functor2<double, RecoFFTJet, RecoFFTJet>& distanceCalc(*
jetDistanceCalc);
389 const unsigned nJets = previous.size();
390 if (nJets != nextSet.size())
397 bool converged =
true;
398 for (
unsigned i = 0;
i < nJets; ++
i) {
399 const double d = distanceCalc(prev[
i],
next[
i]);
400 next[
i].setConvergenceDistance(
d);
414 unsigned iterNum = 1
U;
415 bool converged =
false;
421 for (
unsigned i = 0;
i < nJets; ++
i) {
423 fftjet::Peak
p(
jet.precluster());
424 p.setEtaPhi(
jet.vec().Eta(),
jet.vec().Phi());
425 p.setRecoScale(scaleCalc(
jet));
426 p.setRecoScaleRatio(ratioCalc(
jet));
427 p.setMembershipFactor(factorCalc(
jet));
438 throw cms::Exception(
"FFTJetInterface") <<
"FFTJet algorithm failed" << std::endl;
460 for (
unsigned i = 0;
i < nJets; ++
i) {
462 jets[
i].setPeakEtaPhi(oldp.eta(), oldp.phi());
476 const unsigned nJets =
recoJets.size();
477 const unsigned* clusterMask =
gridAlg->getClusterMask();
482 const unsigned nInputs =
eventData.size();
485 for (
unsigned i = 0;
i < nInputs; ++
i) {
487 const int iPhi =
g.getPhiBin(
item.Phi());
488 const int iEta =
g.getEtaBin(
item.Eta());
496 const unsigned nJets =
recoJets.size();
497 const unsigned* clusterMask =
recoAlg->getClusterMask();
498 const unsigned maskLength =
recoAlg->getLastNData();
501 const unsigned* candIdx = maskLength ? &
candidateIndex[0] :
nullptr;
502 for (
unsigned i = 0;
i < maskLength; ++
i) {
507 const unsigned mask = clusterMask[
i];
515 template <
typename T>
517 using namespace reco;
533 auto jets = std::make_unique<OutputCollection>();
534 const unsigned nJets =
recoJets.size();
535 jets->reserve(nJets);
538 double previousPt = DBL_MAX;
539 for (
unsigned ijet = 0; ijet < nJets; ++ijet) {
548 for (
unsigned i = 0;
i < nCon; ++
i)
570 double ncells = myjet.ncells();
575 jet.setJetArea(cellArea * ncells);
584 jets->push_back(OutputJet(
jet, fj));
587 const double pt =
jet.pt();
595 std::sort(
jets->begin(),
jets->end(), LocalSortByPt());
611 for (
unsigned i = 0;
i < nCon; ++
i)
622 std::make_unique<reco::FFTJetProducerSummary>(
thresholds,
640 loadSparseTreeData<float>(
iEvent);
642 loadSparseTreeData<double>(
iEvent);
680 unsigned nPreclustersFound = 0
U;
682 for (
unsigned i = 0;
i < npre; ++
i)
693 throw cms::Exception(
"FFTJetInterface") <<
"FFTJet algorithm failed (first iteration)" << std::endl;
702 const unsigned nJets =
recoJets.size();
713 const unsigned nJets =
recoJets.size();
717 for (
unsigned i = 0;
i <= nJets; ++
i)
791 std::unique_ptr<fftjet::Functor2<double, FFTJetProducer::RecoFFTJet, FFTJetProducer::RecoFFTJet> >
814 fftjet::DefaultVectorRecombinationAlgFactory<VectorLike, BgData, VBuilder> factory;
847 "invalid spec for the "
848 "reconstruction scale calculator from peaks");
853 "invalid spec for the "
854 "reconstruction scale ratio calculator from peaks");
859 "invalid spec for the "
860 "membership function factor calculator from peaks");
866 "invalid spec for the "
867 "reconstruction scale calculator from jets");
871 "invalid spec for the "
872 "reconstruction scale ratio calculator from jets");
876 "invalid spec for the "
877 "membership function factor calculator from jets");
881 "invalid spec for the "
882 "jet distance calculator");
894 std::vector<int> matchTable;
904 for (
unsigned i = 0;
i < nmatched; ++
i)
928 const unsigned nEta =
g.nEta();
929 const unsigned nPhi =
g.nPhi();
932 const double eta(
g.etaBinCenter(
ieta));
936 const double phi(
g.phiBinCenter(
iphi));
940 const double pil = calc(
eta, 0.0,
s);
958 const bool phiDependent =
f->minDim() == 3
U;
961 const unsigned nEta =
g.nEta();
962 const unsigned nPhi =
g.nPhi();
964 double functorArg[3] = {0.0, 0.0, 0.0};
971 const double eta(
g.etaBinCenter(
ieta));
976 functorArg[1] =
g.phiBinCenter(
iphi);
977 g.uncheckedSetBin(
ieta,
iphi, (*
f)(functorArg, 3
U));
980 const double pil = (*f)(functorArg, 2
U);
990 assert(!
"Pile-up subtraction for fuzzy clustering "
991 "is not implemented yet");
994 const unsigned nJets =
recoJets.size();
999 for (
unsigned i = 0;
i < nJets; ++
i)
1004 const unsigned nEta =
g.nEta();
1005 const unsigned nPhi =
g.nPhi();
1006 const double cellArea =
g.etaBinWidth() *
g.phiBinWidth();
1019 double* recoScaleRatios = recoScales + nJets;
1020 double* memFactors = recoScaleRatios + nJets;
1021 double*
dEta = memFactors + nJets;
1022 double* dPhiBuf =
dEta + nJets;
1028 for (
unsigned ijet = 0; ijet < nJets; ++ijet) {
1030 const fftjet::Peak& peak(
jet.precluster());
1034 fftjet::AbsMembershipFunction* m3d = dynamic_cast<fftjet::AbsMembershipFunction*>(peak.membershipFunction());
1038 assert(!
"Pile-up subtraction for 3-d membership functions "
1039 "is not implemented yet");
1041 fftjet::AbsKernel2d* m2d = dynamic_cast<fftjet::AbsKernel2d*>(peak.membershipFunction());
1045 memFcns2d[ijet] = m2d;
1047 recoScales[ijet] = scaleCalc(
jet);
1048 recoScaleRatios[ijet] = ratioCalc(
jet);
1049 memFactors[ijet] = factorCalc(
jet);
1050 cellCounts[ijet] = 0
U;
1056 dphi -= (2.0 *
M_PI);
1057 while (dphi < -
M_PI)
1058 dphi += (2.0 *
M_PI);
1059 dPhiBuf[
iphi * nJets + ijet] = dphi;
1067 const double eta(
g.etaBinCenter(
ieta));
1071 for (
unsigned ijet = 0; ijet < nJets; ++ijet)
1076 unsigned maxWJet(nJets);
1077 const double*
dPhi = dPhiBuf +
iphi * nJets;
1079 for (
unsigned ijet = 0; ijet < nJets; ++ijet) {
1080 if (recoScaleRatios[ijet] > 0.0)
1081 memFcns2d[ijet]->setScaleRatio(recoScaleRatios[ijet]);
1082 const double f = memFactors[ijet] * (*memFcns2d[ijet])(
dEta[ijet],
dPhi[ijet], recoScales[ijet]);
1089 if (maxWJet < nJets) {
1091 cellCounts[maxWJet]++;
std::unique_ptr< fftjet::Functor1< double, fftjet::Peak > > fftjet_PeakFunctor_parser(const edm::ParameterSet &ps)
virtual void selectPreclusters(const SparseTree &tree, const fftjet::Functor1< bool, fftjet::Peak > &peakSelector, std::vector< fftjet::Peak > *preclusters)
constexpr unsigned int minBin
void setFourVec(const math::XYZTLorentzVector &p)
std::unique_ptr< fftjet::ScaleSpaceKernel > fftjet_MembershipFunction_parser(const edm::ParameterSet &ps)
const bool useGriddedAlgorithm
std::vector< double > doubleBuf
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > pileupEnergyFlow
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)
static const std::string input
const bool assignConstituents
void checkConfig(const Ptr &ptr, const char *message)
virtual std::unique_ptr< fftjet::Functor1< bool, fftjet::Peak > > parse_peakSelector(const edm::ParameterSet &)
std::unique_ptr< RecoAlg > recoAlg
void loadInputCollection(const edm::Event &)
virtual std::unique_ptr< fftjet::Functor1< double, RecoFFTJet > > parse_recoScaleRatioCalcJet(const edm::ParameterSet &)
const std::string outputLabel
#define init_param(type, varname)
const double recombinationDataCutoff
std::unique_ptr< std::vector< double > > fftjet_ScaleSet_parser(const edm::ParameterSet &ps)
const edm::ParameterSet myConfiguration
std::vector< RecoFFTJet > recoJets
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
virtual std::unique_ptr< fftjet::Functor1< double, fftjet::Peak > > parse_recoScaleRatioCalcPeak(const edm::ParameterSet &)
edm::Handle< reco::CandidateView > inputCollection
unsigned matchOneToOne(const std::vector< T1 > &v1, const std::vector< T2 > &v2, const DistanceCalculator &calc, std::vector< int > *matchFrom1To2, const double maxMatchingDistance=1.0e300)
std::string pileupTableCategory
std::unique_ptr< fftjet::Functor1< double, fftjet::Peak > > recoScaleRatioCalcPeak
fftjet::RecombinedJet< fftjetcms::VectorLike > RecoFFTJet
math::XYZTLorentzVector VectorLike
std::unique_ptr< fftjet::Functor2< double, fftjet::RecombinedJet< VectorLike >, fftjet::RecombinedJet< VectorLike > > > fftjet_JetDistance_parser(const edm::ParameterSet &ps)
virtual bool isPhiDependent() const =0
double getEventScale() const
void loadSparseTreeData(const edm::Event &)
virtual std::unique_ptr< fftjet::Functor1< double, fftjet::Peak > > parse_recoScaleCalcPeak(const edm::ParameterSet &)
T getUntrackedParameter(std::string const &, T const &) const
std::unique_ptr< fftjet::Functor1< double, RecoFFTJet > > recoScaleRatioCalcJet
def create(alignables, pedeDump, additionalData, outputFile, config)
#define jet_type_switch(method, arg1, arg2)
const double convergenceDistance
const edm::InputTag treeLabel
std::unique_ptr< AbsBgFunctor > fftjet_BgFunctor_parser(const edm::ParameterSet &ps)
void selectTreeNodes(const SparseTree &tree, const fftjet::Functor1< bool, fftjet::Peak > &peakSelect, std::vector< SparseTree::NodeId > *nodes)
const std::string recombinationAlgorithm
const reco::Particle::Point & vertexUsed() const
std::vector< unsigned > candidateIndex
virtual std::unique_ptr< fftjetcms::AbsBgFunctor > parse_bgMembershipFunction(const edm::ParameterSet &)
~FFTJetProducer() override
#define DEFINE_FWK_MODULE(type)
void prepareRecombinationScales()
void produce(edm::Event &, const edm::EventSetup &) override
std::unique_ptr< fftjet::Functor1< bool, fftjet::Peak > > peakSelector
virtual void genJetPreclusters(const SparseTree &tree, edm::Event &, const edm::EventSetup &, const fftjet::Functor1< bool, fftjet::Peak > &peakSelector, std::vector< fftjet::Peak > *preclusters)
Summary info for pile-up determined by Gaussian filtering.
edm::EDGetTokenT< reco::FFTJetPileupSummary > input_pusummary_token_
void sparsePeakTreeFromStorable(const reco::PattRecoTree< Real, reco::PattRecoPeak< Real > > &in, const std::vector< double > *scaleSetIfNotAdaptive, double completeEventScale, fftjet::SparseClusteringTree< fftjet::Peak, long > *out)
std::unique_ptr< fftjet::Functor1< double, fftjet::Peak > > recoScaleCalcPeak
std::unique_ptr< std::vector< double > > iniScales
const double maxStableScale
void setNCells(const double nc)
std::unique_ptr< fftjet::ScaleSpaceKernel > jetMembershipFunction
fftjetcms::VectorLike unclustered
std::vector< double > thresholds
Class for storing FFTJet sparse clustering trees.
std::vector< fftjetcms::VectorLike > pileup
virtual std::unique_ptr< fftjet::Functor2< double, RecoFFTJet, RecoFFTJet > > parse_jetDistanceCalc(const edm::ParameterSet &)
const bool subtractPileupAs4Vec
void clear(HadCaloObj &c)
std::unique_ptr< fftjet::Functor1< double, fftjet::Peak > > memberFactorCalcPeak
virtual void determinePileupDensityFromDB(const edm::Event &iEvent, const edm::EventSetup &iSetup, std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > &density)
unsigned iterateJetReconstruction()
constexpr unsigned int maxBin
static const Mapper & instance()
unsigned iterationsPerformed
static Resolution parse_resolution(const std::string &name)
const bool resumConstituents
math::XYZTLorentzVector adjustForPileup(const math::XYZTLorentzVector &jet, const math::XYZTLorentzVector &pileup, bool subtractPileupAs4Vec)
Implements inheritance relationships for FFTJet jets.
const edm::InputTag pileupLabel
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
const double stabilityAlpha
bool storeInSinglePrecision() const
void writeJets(edm::Event &iEvent, const edm::EventSetup &)
std::vector< unsigned > occupancy
const edm::InputTag genJetsLabel
std::unique_ptr< fftjet::Functor2< double, RecoFFTJet, RecoFFTJet > > jetDistanceCalc
const double gridScanMaxEta
std::unique_ptr< fftjet::Grid2d< Real > > fftjet_Grid2d_parser(const edm::ParameterSet &ps)
void setPileup(const math::XYZTLorentzVector &p)
const bool reuseExistingGrid
fftjet::SparseClusteringTree< fftjet::Peak, long > SparseTree
void makeProduces(const std::string &alias, const std::string &tag)
edm::EDGetTokenT< std::vector< reco::FFTAnyJet< reco::GenJet > > > input_genjet_token_
virtual void determinePileupDensityFromConfig(const edm::Event &iEvent, std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > &density)
const double unlikelyBgWeight
static void setJetStatusBit(RecoFFTJet *jet, int mask, bool value)
const bool subtractPileup
std::unique_ptr< fftjet::Functor1< double, RecoFFTJet > > recoScaleCalcJet
std::vector< std::vector< reco::CandidatePtr > > constituents
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
T getParameter(std::string const &) const
std::unique_ptr< fftjet::Functor1< double, RecoFFTJet > > memberFactorCalcJet
std::vector< fftjetcms::VectorLike > eventData
void removeFakePreclusters()
bool checkConvergence(const std::vector< RecoFFTJet > &previousIterResult, std::vector< RecoFFTJet > &thisIterResult)
edm::EDGetTokenT< reco::DiscretizedEnergyFlow > input_energyflow_token_
std::vector< RecoFFTJet > iterJets
virtual std::unique_ptr< fftjet::Functor1< double, fftjet::Peak > > parse_memberFactorCalcPeak(const edm::ParameterSet &)
std::unique_ptr< fftjetcms::AbsBgFunctor > bgMembershipFunction
std::vector< unsigned > cellCountsVec
fftjet::RecombinedJet< VectorLike > jetFromStorable(const reco::FFTJet< Real > &jet)
virtual std::unique_ptr< fftjet::Functor1< double, RecoFFTJet > > parse_memberFactorCalcJet(const edm::ParameterSet &)
std::unique_ptr< AbsPileupCalculator > fftjet_PileupCalculator_parser(const edm::ParameterSet &ps)
std::unique_ptr< GridAlg > gridAlg
bool loadEnergyFlow(const edm::Event &iEvent, std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > &flow)
const unsigned maxInitialPreclusters
std::string pileupTableName
void discretizeEnergyFlow()
const unsigned nClustersRequested
const bool calculatePileup
virtual std::unique_ptr< fftjet::ScaleSpaceKernel > parse_jetMembershipFunction(const edm::ParameterSet &)
std::unique_ptr< fftjet::Functor1< double, fftjet::RecombinedJet< VectorLike > > > fftjet_JetFunctor_parser(const edm::ParameterSet &ps)
edm::EDGetTokenT< reco::PattRecoTree< fftjetcms::Real, reco::PattRecoPeak< fftjetcms::Real > > > input_recotree_token_
virtual std::unique_ptr< fftjetcms::AbsPileupCalculator > parse_pileupDensityCalc(const edm::ParameterSet &ps)
std::vector< fftjet::AbsKernel2d * > memFcns2dVec
std::vector< fftjet::Peak > iterPreclusters
void determineVectorConstituents()
const double minStableScale
std::string pileupTableRecord
void saveResults(edm::Event &iEvent, const edm::EventSetup &, unsigned nPreclustersFound)
const unsigned maxIterations
std::vector< fftjet::Peak > preclusters
std::unique_ptr< fftjetcms::AbsPileupCalculator > pileupDensityCalc
virtual void assignMembershipFunctions(std::vector< fftjet::Peak > *preclusters)
virtual std::unique_ptr< fftjet::Functor1< double, RecoFFTJet > > parse_recoScaleCalcJet(const edm::ParameterSet &)
std::vector< SparseTree::NodeId > nodes
std::unique_ptr< fftjet::Functor1< bool, fftjet::Peak > > fftjet_PeakSelector_parser(const edm::ParameterSet &ps)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
void determineGriddedConstituents()