File indexing completed on 2024-04-06 12:25:31
0001 #include "FWCore/Framework/interface/MakerMacros.h"
0002 #include "RecoJets/JetProducers/plugins/CATopJetProducer.h"
0003
0004 #include <memory>
0005
0006 #include "RecoJets/JetProducers/plugins/FastjetJetProducer.h"
0007
0008 using namespace edm;
0009 using namespace cms;
0010 using namespace reco;
0011 using namespace std;
0012
0013 CATopJetProducer::CATopJetProducer(edm::ParameterSet const& conf)
0014 : FastjetJetProducer(conf),
0015 tagAlgo_(conf.getParameter<int>("tagAlgo")),
0016 ptMin_(conf.getParameter<double>("jetPtMin")),
0017 centralEtaCut_(conf.getParameter<double>("centralEtaCut")),
0018 verbose_(conf.getParameter<bool>("verbose")) {
0019 if (tagAlgo_ == CA_TOPTAGGER) {
0020 legacyCMSTopTagger_ = std::make_unique<CATopJetAlgorithm>(
0021 src_,
0022 conf.getParameter<bool>("verbose"),
0023 conf.getParameter<int>("algorithm"),
0024 conf.getParameter<int>("useAdjacency"),
0025
0026
0027
0028
0029 conf.getParameter<double>("centralEtaCut"),
0030 conf.getParameter<double>("jetPtMin"),
0031 conf.getParameter<std::vector<double>>(
0032 "sumEtBins"),
0033 conf.getParameter<std::vector<double>>("rBins"),
0034 conf.getParameter<std::vector<double>>("ptFracBins"),
0035 conf.getParameter<std::vector<double>>(
0036 "deltarBins"),
0037 conf.getParameter<std::vector<double>>(
0038 "nCellBins"),
0039 conf.getParameter<double>("inputEtMin"),
0040 conf.getParameter<bool>(
0041 "useMaxTower"),
0042 conf.getParameter<double>("sumEtEtaCut"),
0043 conf.getParameter<double>("etFrac")
0044 );
0045 } else if (tagAlgo_ == FJ_CMS_TOPTAG) {
0046 fjCMSTopTagger_ = std::make_unique<fastjet::CMSTopTagger>(conf.getParameter<double>("ptFrac"),
0047 conf.getParameter<double>("rFrac"),
0048 conf.getParameter<double>("adjacencyParam"));
0049 } else if (tagAlgo_ == FJ_JHU_TOPTAG) {
0050 fjJHUTopTagger_ = std::make_unique<fastjet::JHTopTagger>(conf.getParameter<double>("ptFrac"),
0051 conf.getParameter<double>("deltaRCut"),
0052 conf.getParameter<double>("cosThetaWMax"));
0053 } else if (tagAlgo_ == FJ_NSUB_TAG) {
0054 fastjet::JetDefinition::Plugin* plugin = new fastjet::SISConePlugin(0.6, 0.75);
0055 fastjet::JetDefinition NsubJetDef(plugin);
0056 fjNSUBTagger_ = std::make_unique<fastjet::RestFrameNSubjettinessTagger>(NsubJetDef,
0057 conf.getParameter<double>("tau2Cut"),
0058 conf.getParameter<double>("cosThetaSCut"),
0059 conf.getParameter<bool>("useExclusive"));
0060 }
0061 }
0062
0063 void CATopJetProducer::produce(edm::Event& e, const edm::EventSetup& c) { FastjetJetProducer::produce(e, c); }
0064
0065 void CATopJetProducer::runAlgorithm(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0066 if (!doAreaFastjet_ && !doRhoFastjet_) {
0067 fjClusterSeq_ = std::make_shared<fastjet::ClusterSequence>(fjInputs_, *fjJetDefinition_);
0068 } else if (voronoiRfact_ <= 0) {
0069 fjClusterSeq_ =
0070 ClusterSequencePtr(new fastjet::ClusterSequenceArea(fjInputs_, *fjJetDefinition_, *fjAreaDefinition_));
0071 } else {
0072 fjClusterSeq_ = ClusterSequencePtr(
0073 new fastjet::ClusterSequenceVoronoiArea(fjInputs_, *fjJetDefinition_, fastjet::VoronoiAreaSpec(voronoiRfact_)));
0074 }
0075
0076 if (tagAlgo_ == CA_TOPTAGGER) {
0077 (*legacyCMSTopTagger_).run(fjInputs_, fjJets_, fjClusterSeq_);
0078
0079 } else {
0080
0081 vector<fastjet::PseudoJet> inclusiveJets = fjClusterSeq_->inclusive_jets(ptMin_);
0082
0083 if (verbose_)
0084 cout << "Getting central jets" << endl;
0085
0086 vector<fastjet::PseudoJet> centralJets;
0087 for (unsigned int i = 0; i < inclusiveJets.size(); i++) {
0088 if (inclusiveJets[i].perp() > ptMin_ && fabs(inclusiveJets[i].rapidity()) < centralEtaCut_) {
0089 centralJets.push_back(inclusiveJets[i]);
0090 }
0091 }
0092
0093 fastjet::CMSTopTagger& CMSTagger = *fjCMSTopTagger_;
0094 fastjet::JHTopTagger& JHUTagger = *fjJHUTopTagger_;
0095 fastjet::RestFrameNSubjettinessTagger& NSUBTagger = *fjNSUBTagger_;
0096
0097 vector<fastjet::PseudoJet>::iterator jetIt = centralJets.begin(), centralJetsEnd = centralJets.end();
0098 if (verbose_)
0099 cout << "Loop over jets" << endl;
0100 for (; jetIt != centralJetsEnd; ++jetIt) {
0101 if (verbose_)
0102 cout << "CMS FJ jet pt: " << (*jetIt).perp() << endl;
0103
0104 fastjet::PseudoJet taggedJet;
0105 if (tagAlgo_ == FJ_CMS_TOPTAG)
0106 taggedJet = CMSTagger.result(*jetIt);
0107 else if (tagAlgo_ == FJ_JHU_TOPTAG)
0108 taggedJet = JHUTagger.result(*jetIt);
0109 else if (tagAlgo_ == FJ_NSUB_TAG)
0110 taggedJet = NSUBTagger.result(*jetIt);
0111 else
0112 cout << "NOT A VALID TAGGING ALGORITHM CHOICE!" << endl;
0113
0114 if (taggedJet != 0)
0115 fjJets_.push_back(taggedJet);
0116 }
0117 }
0118 }
0119
0120 void CATopJetProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0121 edm::ParameterSetDescription desc;
0122
0123 desc.add<int>("tagAlgo", 0);
0124 desc.add<double>("centralEtaCut", 2.5);
0125 desc.add<bool>("verbose", false);
0126 desc.add<string>("jetCollInstanceName", "caTopSubJets");
0127 desc.add<int>("algorithm", 1);
0128 desc.add<int>("useAdjacency", 2);
0129
0130
0131
0132
0133 vector<double> sumEtBinsDefault = {0., 1600., 2600.};
0134 desc.add<vector<double>>(
0135 "sumEtBins",
0136 sumEtBinsDefault);
0137 vector<double> rBinsDefault(3, 0.8);
0138 desc.add<vector<double>>("rBins", rBinsDefault);
0139 vector<double> ptFracBinsDefault(3, 0.05);
0140 desc.add<vector<double>>("ptFracBins", ptFracBinsDefault);
0141 vector<double> deltarBinsDefault(3, 0.019);
0142 desc.add<vector<double>>(
0143 "deltarBins", deltarBinsDefault);
0144 vector<double> nCellBinsDefault(3, 1.9);
0145 desc.add<vector<double>>(
0146 "nCellBins",
0147 nCellBinsDefault);
0148 desc.add<bool>("useMaxTower", false);
0149 desc.add<double>("sumEtEtaCut", 3.0);
0150 desc.add<double>("etFrac", 0.7);
0151 desc.add<double>("ptFrac", 0.05);
0152 desc.add<double>("rFrac", 0.);
0153 desc.add<double>("adjacencyParam", 0.);
0154 desc.add<double>("deltaRCut", 0.19);
0155 desc.add<double>("cosThetaWMax", 0.7);
0156 desc.add<double>("tau2Cut", 0.);
0157 desc.add<double>("cosThetaSCut", 0.);
0158 desc.add<bool>("useExclusive", false);
0159
0160 FastjetJetProducer::fillDescriptionsFromFastJetProducer(desc);
0161
0162 VirtualJetProducer::fillDescriptionsFromVirtualJetProducer(desc);
0163
0164 descriptions.add("CATopJetProducer", desc);
0165 }
0166
0167 DEFINE_FWK_MODULE(CATopJetProducer);