|
|
Go to the documentation of this file.
25 #include "fftjet/peakEtLifetime.hh"
45 #define make_param(type, varname) const type& varname(ps.getParameter<type>(#varname))
47 #define init_param(type, varname) varname(ps.getParameter<type>(#varname))
56 #define jet_type_switch(method, arg1, arg2) \
60 method<reco::CaloJet>(arg1, arg2); \
63 method<reco::PFJet>(arg1, arg2); \
66 method<reco::GenJet>(arg1, arg2); \
69 method<reco::TrackJet>(arg1, arg2); \
72 method<reco::BasicJet>(arg1, arg2); \
75 assert(!"ERROR in FFTJetProducer : invalid jet type."\
76 " This is a bug. Please report."); \
81 struct LocalSortByPt {
83 inline bool operator()(
const Jet&
l,
const Jet&
r)
const {
84 return l.pt() >
r.pt();
92 if (!
name.compare(
"fixed"))
94 else if (!
name.compare(
"maximallyStable"))
95 return MAXIMALLY_STABLE;
96 else if (!
name.compare(
"globallyAdaptive"))
97 return GLOBALLY_ADAPTIVE;
98 else if (!
name.compare(
"locallyAdaptive"))
99 return LOCALLY_ADAPTIVE;
100 else if (!
name.compare(
"fromGenJets"))
103 throw cms::Exception(
"FFTJetBadConfig") <<
"Invalid resolution specification \"" <<
name <<
"\"" << std::endl;
106 template <
typename T>
108 produces<std::vector<reco::FFTAnyJet<T> > >(
tag).setBranchAlias(
alias);
152 iterationsPerformed(1
U),
156 throw cms::Exception(
"FFTJetBadConfig") <<
"Can't resum constituents if they are not assigned" << std::endl;
158 produces<reco::FFTJetProducerSummary>(
outputLabel);
170 consumes<reco::PattRecoTree<fftjetcms::Real, reco::PattRecoPeak<fftjetcms::Real> > >(
treeLabel);
186 template <
class Real>
194 if (!
input->isSparse())
195 throw cms::Exception(
"FFTJetBadConfig") <<
"The stored clustering tree is not sparse" << std::endl;
205 const fftjet::Functor1<bool, fftjet::Peak>& peakSelect,
206 std::vector<fftjet::Peak>* preclusters) {
213 const unsigned sz =
input->size();
215 for (
unsigned i = 0;
i < sz; ++
i) {
217 fftjet::Peak
p(
jet.precluster());
218 const double scale(
p.scale());
219 p.setEtaPhi(
jet.vec().Eta(),
jet.vec().Phi());
228 const fftjet::Functor1<bool, fftjet::Peak>& peakSelect,
229 std::vector<fftjet::Peak>* preclusters) {
234 const unsigned nNodes =
nodes.size();
235 const SparseTree::NodeId* pnodes = nNodes ? &
nodes[0] :
nullptr;
237 for (
unsigned i = 0;
i < nNodes; ++
i)
242 fftjet::Peak*
clusters = nNodes ? &(*preclusters)[0] :
nullptr;
243 for (
unsigned i = 0;
i < nNodes; ++
i) {
250 const fftjet::Functor1<bool, fftjet::Peak>& peakSelect,
251 std::vector<SparseTree::NodeId>* mynodes) {
266 if (
tree.stableClusterCount(
278 const int maxlev =
tree.maxStoredLevel();
279 bool levelFound =
false;
281 for (
int ifac = 1; ifac > -2 && !levelFound; ifac -= 2) {
297 const unsigned maxlev =
tree.maxStoredLevel();
324 assert(!
"ERROR in FFTJetProducer::selectTreeNodes : "
325 "should never get here! This is a bug. Please report.");
337 for (
unsigned i = 0;
i < nClus; ++
i) {
338 clus[
i].setRecoScale(scaleCalc(clus[
i]));
339 clus[
i].setRecoScaleRatio(ratioCalc(clus[
i]));
340 clus[
i].setMembershipFactor(factorCalc(clus[
i]));
353 fftjet::DefaultRecombinationAlgFactory<Real, VectorLike, BgData, VBuilder> factory;
373 bool rebuildGrid =
flow.get() ==
nullptr;
380 flow = std::make_unique<fftjet::Grid2d<Real> >(
388 fftjet::Functor2<double, RecoFFTJet, RecoFFTJet>& distanceCalc(*
jetDistanceCalc);
390 const unsigned nJets =
previous.size();
391 if (nJets != nextSet.size())
398 bool converged =
true;
399 for (
unsigned i = 0;
i < nJets; ++
i) {
400 const double d = distanceCalc(prev[
i],
next[
i]);
401 next[
i].setConvergenceDistance(
d);
415 unsigned iterNum = 1
U;
416 bool converged =
false;
422 for (
unsigned i = 0;
i < nJets; ++
i) {
424 fftjet::Peak
p(
jet.precluster());
425 p.setEtaPhi(
jet.vec().Eta(),
jet.vec().Phi());
426 p.setRecoScale(scaleCalc(
jet));
427 p.setRecoScaleRatio(ratioCalc(
jet));
428 p.setMembershipFactor(factorCalc(
jet));
439 throw cms::Exception(
"FFTJetInterface") <<
"FFTJet algorithm failed" << std::endl;
461 for (
unsigned i = 0;
i < nJets; ++
i) {
463 jets[
i].setPeakEtaPhi(oldp.eta(), oldp.phi());
477 const unsigned nJets =
recoJets.size();
478 const unsigned* clusterMask =
gridAlg->getClusterMask();
483 const unsigned nInputs =
eventData.size();
486 for (
unsigned i = 0;
i < nInputs; ++
i) {
488 const int iPhi =
g.getPhiBin(
item.Phi());
489 const int iEta =
g.getEtaBin(
item.Eta());
497 const unsigned nJets =
recoJets.size();
498 const unsigned* clusterMask =
recoAlg->getClusterMask();
499 const unsigned maskLength =
recoAlg->getLastNData();
502 const unsigned* candIdx = maskLength ? &
candidateIndex[0] :
nullptr;
503 for (
unsigned i = 0;
i < maskLength; ++
i) {
508 const unsigned mask = clusterMask[
i];
516 template <
typename T>
518 using namespace reco;
534 auto jets = std::make_unique<OutputCollection>();
535 const unsigned nJets =
recoJets.size();
536 jets->reserve(nJets);
539 double previousPt = DBL_MAX;
540 for (
unsigned ijet = 0; ijet < nJets; ++ijet) {
549 for (
unsigned i = 0;
i < nCon; ++
i)
571 double ncells = myjet.ncells();
576 jet.setJetArea(cellArea * ncells);
585 jets->push_back(OutputJet(
jet, fj));
588 const double pt =
jet.pt();
612 for (
unsigned i = 0;
i < nCon; ++
i)
623 std::make_unique<reco::FFTJetProducerSummary>(
thresholds,
641 loadSparseTreeData<float>(
iEvent);
643 loadSparseTreeData<double>(
iEvent);
681 unsigned nPreclustersFound = 0
U;
683 for (
unsigned i = 0;
i < npre; ++
i)
694 throw cms::Exception(
"FFTJetInterface") <<
"FFTJet algorithm failed (first iteration)" << std::endl;
703 const unsigned nJets =
recoJets.size();
714 const unsigned nJets =
recoJets.size();
718 for (
unsigned i = 0;
i <= nJets; ++
i)
792 std::unique_ptr<fftjet::Functor2<double, FFTJetProducer::RecoFFTJet, FFTJetProducer::RecoFFTJet> >
815 fftjet::DefaultVectorRecombinationAlgFactory<VectorLike, BgData, VBuilder> factory;
848 "invalid spec for the "
849 "reconstruction scale calculator from peaks");
854 "invalid spec for the "
855 "reconstruction scale ratio calculator from peaks");
860 "invalid spec for the "
861 "membership function factor calculator from peaks");
867 "invalid spec for the "
868 "reconstruction scale calculator from jets");
872 "invalid spec for the "
873 "reconstruction scale ratio calculator from jets");
877 "invalid spec for the "
878 "membership function factor calculator from jets");
882 "invalid spec for the "
883 "jet distance calculator");
895 std::vector<int> matchTable;
905 for (
unsigned i = 0;
i < nmatched; ++
i)
929 const unsigned nEta =
g.nEta();
930 const unsigned nPhi =
g.nPhi();
933 const double eta(
g.etaBinCenter(
ieta));
937 const double phi(
g.phiBinCenter(
iphi));
941 const double pil = calc(
eta, 0.0,
s);
959 const bool phiDependent =
f->minDim() == 3
U;
962 const unsigned nEta =
g.nEta();
963 const unsigned nPhi =
g.nPhi();
965 double functorArg[3] = {0.0, 0.0, 0.0};
972 const double eta(
g.etaBinCenter(
ieta));
977 functorArg[1] =
g.phiBinCenter(
iphi);
978 g.uncheckedSetBin(
ieta,
iphi, (*
f)(functorArg, 3
U));
981 const double pil = (*f)(functorArg, 2
U);
991 assert(!
"Pile-up subtraction for fuzzy clustering "
992 "is not implemented yet");
995 const unsigned nJets =
recoJets.size();
1000 for (
unsigned i = 0;
i < nJets; ++
i)
1005 const unsigned nEta =
g.nEta();
1006 const unsigned nPhi =
g.nPhi();
1007 const double cellArea =
g.etaBinWidth() *
g.phiBinWidth();
1020 double* recoScaleRatios = recoScales + nJets;
1021 double* memFactors = recoScaleRatios + nJets;
1022 double*
dEta = memFactors + nJets;
1023 double* dPhiBuf =
dEta + nJets;
1029 for (
unsigned ijet = 0; ijet < nJets; ++ijet) {
1031 const fftjet::Peak& peak(
jet.precluster());
1035 fftjet::AbsMembershipFunction* m3d = dynamic_cast<fftjet::AbsMembershipFunction*>(peak.membershipFunction());
1039 assert(!
"Pile-up subtraction for 3-d membership functions "
1040 "is not implemented yet");
1042 fftjet::AbsKernel2d* m2d = dynamic_cast<fftjet::AbsKernel2d*>(peak.membershipFunction());
1046 memFcns2d[ijet] = m2d;
1048 recoScales[ijet] = scaleCalc(
jet);
1049 recoScaleRatios[ijet] = ratioCalc(
jet);
1050 memFactors[ijet] = factorCalc(
jet);
1051 cellCounts[ijet] = 0
U;
1057 dphi -= (2.0 *
M_PI);
1058 while (dphi < -
M_PI)
1059 dphi += (2.0 *
M_PI);
1060 dPhiBuf[
iphi * nJets + ijet] = dphi;
1068 const double eta(
g.etaBinCenter(
ieta));
1072 for (
unsigned ijet = 0; ijet < nJets; ++ijet)
1077 unsigned maxWJet(nJets);
1078 const double*
dPhi = dPhiBuf +
iphi * nJets;
1080 for (
unsigned ijet = 0; ijet < nJets; ++ijet) {
1081 if (recoScaleRatios[ijet] > 0.0)
1082 memFcns2d[ijet]->setScaleRatio(recoScaleRatios[ijet]);
1083 const double f = memFactors[ijet] * (*memFcns2d[ijet])(
dEta[ijet],
dPhi[ijet], recoScales[ijet]);
1090 if (maxWJet < nJets) {
1092 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
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
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
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
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)
T getParameter(std::string const &) const
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()