Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-11-09 11:30:00

0001 #ifndef PhysicsTools_SelectorUtils_interface_PFJetIDSelectionFunctor_h
0002 #define PhysicsTools_SelectorUtils_interface_PFJetIDSelectionFunctor_h
0003 
0004 /**
0005   \class    PFJetIDSelectionFunctor PFJetIDSelectionFunctor.h "PhysicsTools/SelectorUtils/interface/PFJetIDSelectionFunctor.h"
0006   \brief    PF Jet selector for pat::Jets
0007 
0008   Selector functor for pat::Jets that implements quality cuts based on
0009   studies of noise patterns.
0010 
0011   Please see https://twiki.cern.ch/twiki/bin/view/CMS/SWGuidePATSelectors
0012   for a general overview of the selectors.
0013 */
0014 
0015 #ifndef __GCCXML__
0016 #include "FWCore/Framework/interface/ConsumesCollector.h"
0017 #endif
0018 #include "DataFormats/PatCandidates/interface/Jet.h"
0019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0020 
0021 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0022 #include "FWCore/ParameterSet/interface/allowedValues.h"
0023 
0024 #include "PhysicsTools/SelectorUtils/interface/Selector.h"
0025 
0026 #include <TMath.h>
0027 
0028 class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
0029 public:  // interface
0030   enum Version_t {
0031     FIRSTDATA,
0032     RUNIISTARTUP,
0033     WINTER16,
0034     WINTER17,
0035     WINTER17PUPPI,
0036     SUMMER18,
0037     SUMMER18PUPPI,
0038     RUN2UL16CHS,
0039     RUN2UL16PUPPI,
0040     RUN2ULCHS,
0041     RUN2ULPUPPI,
0042     N_VERSIONS
0043   };
0044   enum Quality_t { LOOSE, TIGHT, TIGHTLEPVETO, N_QUALITY };
0045 
0046   PFJetIDSelectionFunctor() {}
0047 
0048 #ifndef __GCCXML__
0049   PFJetIDSelectionFunctor(edm::ParameterSet const &params, edm::ConsumesCollector &iC)
0050       : PFJetIDSelectionFunctor(params) {}
0051 #endif
0052 
0053   PFJetIDSelectionFunctor(edm::ParameterSet const &params) {
0054     std::string versionStr = params.getParameter<std::string>("version");
0055     std::string qualityStr = params.getParameter<std::string>("quality");
0056 
0057     if (versionStr == "FIRSTDATA")
0058       version_ = FIRSTDATA;
0059     else if (versionStr == "RUNIISTARTUP")
0060       version_ = RUNIISTARTUP;
0061     else if (versionStr == "WINTER16")
0062       version_ = WINTER16;
0063     else if (versionStr == "WINTER17")
0064       version_ = WINTER17;
0065     else if (versionStr == "WINTER17PUPPI")
0066       version_ = WINTER17PUPPI;
0067     else if (versionStr == "SUMMER18")
0068       version_ = SUMMER18;
0069     else if (versionStr == "SUMMER18PUPPI")
0070       version_ = SUMMER18PUPPI;
0071     else if (versionStr == "RUN2UL16CHS")
0072       version_ = RUN2UL16CHS;
0073     else if (versionStr == "RUN2UL16PUPPI")
0074       version_ = RUN2UL16PUPPI;
0075     else if (versionStr == "RUN2ULCHS")
0076       version_ = RUN2ULCHS;
0077     else if (versionStr == "RUN2ULPUPPI")
0078       version_ = RUN2ULPUPPI;
0079     else
0080       version_ = RUN2ULCHS;  //set RUN2ULCHS as default //this is extremely unsafe
0081 
0082     if (qualityStr == "LOOSE")
0083       quality_ = LOOSE;
0084     else if (qualityStr == "TIGHT")
0085       quality_ = TIGHT;
0086     else if (qualityStr == "TIGHTLEPVETO")
0087       quality_ = TIGHTLEPVETO;
0088     else
0089       quality_ = TIGHT;  //this is extremely unsafe
0090 
0091     initCuts();
0092 
0093     // loop over the std::string in bits_ and check for what was overwritten.
0094     const auto strings_set = this->bits_.strings();
0095     for (auto i = strings_set.begin(); i != strings_set.end(); ++i) {
0096       const std::string &item = *i;
0097       if (params.exists(item)) {
0098         if (params.existsAs<int>(item))
0099           set(item, params.getParameter<int>(item));
0100         else
0101           set(item, params.getParameter<double>(item));
0102       }
0103     }
0104 
0105     if (params.exists("cutsToIgnore"))
0106       setIgnoredCuts(params.getParameter<std::vector<std::string>>("cutsToIgnore"));
0107 
0108     initIndex();
0109   }
0110 
0111   PFJetIDSelectionFunctor(Version_t version, Quality_t quality) : version_(version), quality_(quality) {
0112     initCuts();
0113     initIndex();
0114   }
0115 
0116   //
0117   // give a configuration description for derived class
0118   //
0119   static edm::ParameterSetDescription getDescription() {
0120     edm::ParameterSetDescription desc;
0121 
0122     desc.ifValue(edm::ParameterDescription<std::string>("version", "RUN2ULCHS", true, edm::Comment("")),
0123                  edm::allowedValues<std::string>("FIRSTDATA",
0124                                                  "RUNIISTARTUP",
0125                                                  "WINTER16",
0126                                                  "WINTER17",
0127                                                  "WINTER17PUPPI",
0128                                                  "SUMMER18",
0129                                                  "SUMMER18PUPPI",
0130                                                  "RUN2UL16CHS",
0131                                                  "RUN2UL16PUPPI",
0132                                                  "RUN2ULCHS",
0133                                                  "RUN2ULPUPPI"));
0134     desc.ifValue(edm::ParameterDescription<std::string>("quality", "TIGHT", true, edm::Comment("")),
0135                  edm::allowedValues<std::string>("LOOSE", "TIGHT", "TIGHTLEPVETO"));
0136     desc.addOptional<std::vector<std::string>>("cutsToIgnore")->setComment("");
0137 
0138     edm::ParameterDescription<double> CHF("CHF", true, edm::Comment(""));
0139     edm::ParameterDescription<double> NHF("NHF", true, edm::Comment(""));
0140     edm::ParameterDescription<double> NHF_FW("NHF_FW", true, edm::Comment(""));
0141     edm::ParameterDescription<double> NHF_EC("NHF_EC", true, edm::Comment(""));
0142     edm::ParameterDescription<double> NHF_TR("NHF_TR", true, edm::Comment(""));
0143 
0144     edm::ParameterDescription<double> CEF("CEF", true, edm::Comment(""));
0145     edm::ParameterDescription<double> CEF_TR("CEF_TR", true, edm::Comment(""));
0146 
0147     edm::ParameterDescription<double> NEF("NEF", true, edm::Comment(""));
0148     edm::ParameterDescription<double> NEF_FW("NEF_FW", true, edm::Comment(""));
0149     edm::ParameterDescription<double> NEF_EC_L("NEF_EC_L", true, edm::Comment(""));
0150     edm::ParameterDescription<double> NEF_EC_U("NEF_EC_U", true, edm::Comment(""));
0151     edm::ParameterDescription<double> NEF_TR("NEF_TR", true, edm::Comment(""));
0152 
0153     edm::ParameterDescription<int> NCH("NCH", true, edm::Comment(""));
0154 
0155     edm::ParameterDescription<double> MUF("MUF", true, edm::Comment(""));
0156     edm::ParameterDescription<double> MUF_TR("MUF_TR", true, edm::Comment(""));
0157 
0158     edm::ParameterDescription<int> nConstituents("nConstituents", true, edm::Comment(""));
0159     edm::ParameterDescription<int> nNeutrals_FW("nNeutrals_FW", true, edm::Comment(""));
0160     edm::ParameterDescription<int> nNeutrals_FW_L("nNeutrals_FW_L", true, edm::Comment(""));
0161     edm::ParameterDescription<int> nNeutrals_FW_U("nNeutrals_FW_U", true, edm::Comment(""));
0162     edm::ParameterDescription<int> nnNeutrals_EC("nNeutrals_EC", true, edm::Comment(""));
0163 
0164     desc.addOptionalNode(CHF, false);
0165     desc.addOptionalNode(NHF, false);
0166     desc.addOptionalNode(NHF_FW, false);
0167     desc.addOptionalNode(NHF_EC, false);
0168     desc.addOptionalNode(NHF_TR, false);
0169 
0170     desc.addOptionalNode(CEF, false);
0171     desc.addOptionalNode(CEF_TR, false);
0172 
0173     desc.addOptionalNode(NEF, false);
0174     desc.addOptionalNode(NEF_FW, false);
0175     desc.addOptionalNode(NEF_EC_L, false);
0176     desc.addOptionalNode(NEF_EC_U, false);
0177     desc.addOptionalNode(NEF_TR, false);
0178 
0179     desc.addOptionalNode(NCH, false);
0180 
0181     desc.addOptionalNode(MUF, false);
0182     desc.addOptionalNode(MUF_TR, false);
0183 
0184     desc.addOptionalNode(nConstituents, false);
0185     desc.addOptionalNode(nNeutrals_FW, false);
0186     desc.addOptionalNode(nNeutrals_FW_L, false);
0187     desc.addOptionalNode(nNeutrals_FW_U, false);
0188     desc.addOptionalNode(nnNeutrals_EC, false);
0189 
0190     return desc;
0191   }
0192   //
0193   // Accessor from PAT jets
0194   //
0195   bool operator()(const pat::Jet &jet, pat::strbitset &ret) override {
0196     if (version_ == FIRSTDATA || version_ == RUNIISTARTUP || version_ == WINTER16 || version_ == WINTER17 ||
0197         version_ == WINTER17PUPPI || version_ == SUMMER18 || version_ == SUMMER18PUPPI || version_ == RUN2UL16CHS ||
0198         version_ == RUN2UL16PUPPI || version_ == RUN2ULCHS || version_ == RUN2ULPUPPI) {
0199       if (jet.currentJECLevel() == "Uncorrected" || !jet.jecSetsAvailable())
0200         return firstDataCuts(jet, ret, version_);
0201       else
0202         return firstDataCuts(jet.correctedJet("Uncorrected"), ret, version_);
0203     } else {
0204       return false;
0205     }
0206   }
0207   using Selector<pat::Jet>::operator();
0208 
0209   //
0210   // Accessor from *CORRECTED* 4-vector, EMF, and Jet ID.
0211   // This can be used with reco quantities.
0212   //
0213   bool operator()(const reco::PFJet &jet, pat::strbitset &ret) {
0214     if (version_ == FIRSTDATA || version_ == RUNIISTARTUP || version_ == WINTER16 || version_ == WINTER17 ||
0215         version_ == WINTER17PUPPI || version_ == SUMMER18 || version_ == SUMMER18PUPPI || version_ == RUN2UL16CHS ||
0216         version_ == RUN2UL16PUPPI || version_ == RUN2ULCHS || version_ == RUN2ULPUPPI) {
0217       return firstDataCuts(jet, ret, version_);
0218     } else {
0219       return false;
0220     }
0221   }
0222 
0223   bool operator()(const reco::PFJet &jet) {
0224     retInternal_.set(false);
0225     operator()(jet, retInternal_);
0226     setIgnored(retInternal_);
0227     return (bool)retInternal_;
0228   }
0229 
0230   //
0231   // cuts based on craft 08 analysis.
0232   //
0233   bool firstDataCuts(reco::Jet const &jet, pat::strbitset &ret, Version_t version_) {
0234     ret.set(false);
0235 
0236     // cache some variables
0237     double chf = 0.0;
0238     double nhf = 0.0;
0239     double cef = 0.0;
0240     double nef = 0.0;
0241     double muf = 0.0;
0242 
0243     int nch = 0;
0244     int nconstituents = 0;
0245     int nneutrals = 0;
0246 
0247     // Have to do this because pat::Jet inherits from reco::Jet but not reco::PFJet
0248     reco::PFJet const *pfJet = dynamic_cast<reco::PFJet const *>(&jet);
0249     pat::Jet const *patJet = dynamic_cast<pat::Jet const *>(&jet);
0250     reco::BasicJet const *basicJet = dynamic_cast<reco::BasicJet const *>(&jet);
0251 
0252     if (patJet != nullptr) {
0253       if (patJet->isPFJet()) {
0254         chf = patJet->chargedHadronEnergyFraction();
0255         nhf = patJet->neutralHadronEnergyFraction();
0256         cef = patJet->chargedEmEnergyFraction();
0257         nef = patJet->neutralEmEnergyFraction();
0258         nch = patJet->chargedMultiplicity();
0259         muf = patJet->muonEnergyFraction();
0260         nconstituents = patJet->neutralMultiplicity() + patJet->chargedMultiplicity();
0261         nneutrals = patJet->neutralMultiplicity();
0262       }
0263       // Handle the special case where this is a composed jet for
0264       // subjet analyses
0265       else if (patJet->isBasicJet()) {
0266         double e_chf = 0.0;
0267         double e_nhf = 0.0;
0268         double e_cef = 0.0;
0269         double e_nef = 0.0;
0270         double e_muf = 0.0;
0271         nch = 0;
0272         nconstituents = 0;
0273         nneutrals = 0;
0274 
0275         for (reco::Jet::const_iterator ibegin = patJet->begin(), iend = patJet->end(), isub = ibegin; isub != iend;
0276              ++isub) {
0277           reco::PFJet const *pfsub = dynamic_cast<reco::PFJet const *>(&*isub);
0278           pat::Jet const *patsub = dynamic_cast<pat::Jet const *>(&*isub);
0279           if (patsub) {
0280             e_chf += patsub->chargedHadronEnergy();
0281             e_nhf += patsub->neutralHadronEnergy();
0282             e_cef += patsub->chargedEmEnergy();
0283             e_nef += patsub->neutralEmEnergy();
0284             e_muf += patsub->muonEnergy();
0285             nch += patsub->chargedMultiplicity();
0286             nconstituents += patsub->neutralMultiplicity() + patsub->chargedMultiplicity();
0287             nneutrals += patsub->neutralMultiplicity();
0288           } else if (pfsub) {
0289             e_chf += pfsub->chargedHadronEnergy();
0290             e_nhf += pfsub->neutralHadronEnergy();
0291             e_cef += pfsub->chargedEmEnergy();
0292             e_nef += pfsub->neutralEmEnergy();
0293             e_muf += pfsub->muonEnergy();
0294             nch += pfsub->chargedMultiplicity();
0295             nconstituents += pfsub->neutralMultiplicity() + pfsub->chargedMultiplicity();
0296             nneutrals += pfsub->neutralMultiplicity();
0297           } else
0298             assert(0);
0299         }
0300         double e = patJet->energy();
0301         if (e > 0.000001) {
0302           chf = e_chf / e;
0303           nhf = e_nhf / e;
0304           cef = e_cef / e;
0305           nef = e_nef / e;
0306           muf = e_muf / e;
0307         } else {
0308           chf = nhf = cef = nef = muf = 0.0;
0309         }
0310       }
0311     }  // end if pat jet
0312     else if (pfJet != nullptr) {
0313       // CV: need to compute energy fractions in a way that works for corrected as well as for uncorrected PFJets
0314       double jetEnergyUncorrected = pfJet->chargedHadronEnergy() + pfJet->neutralHadronEnergy() +
0315                                     pfJet->photonEnergy() + pfJet->electronEnergy() + pfJet->muonEnergy() +
0316                                     pfJet->HFEMEnergy();
0317       if (jetEnergyUncorrected > 0.) {
0318         chf = pfJet->chargedHadronEnergy() / jetEnergyUncorrected;
0319         nhf = pfJet->neutralHadronEnergy() / jetEnergyUncorrected;
0320         cef = pfJet->chargedEmEnergy() / jetEnergyUncorrected;
0321         nef = pfJet->neutralEmEnergy() / jetEnergyUncorrected;
0322         muf = pfJet->muonEnergy() / jetEnergyUncorrected;
0323       }
0324       nch = pfJet->chargedMultiplicity();
0325       nconstituents = pfJet->neutralMultiplicity() + pfJet->chargedMultiplicity();
0326       nneutrals = pfJet->neutralMultiplicity();
0327     }  // end if PF jet
0328     // Handle the special case where this is a composed jet for
0329     // subjet analyses
0330     else if (basicJet != nullptr) {
0331       double e_chf = 0.0;
0332       double e_nhf = 0.0;
0333       double e_cef = 0.0;
0334       double e_nef = 0.0;
0335       double e_muf = 0.0;
0336       nch = 0;
0337       nconstituents = 0;
0338       for (reco::Jet::const_iterator ibegin = basicJet->begin(), iend = basicJet->end(), isub = ibegin; isub != iend;
0339            ++isub) {
0340         reco::PFJet const *pfsub = dynamic_cast<reco::PFJet const *>(&*isub);
0341         e_chf += pfsub->chargedHadronEnergy();
0342         e_nhf += pfsub->neutralHadronEnergy();
0343         e_cef += pfsub->chargedEmEnergy();
0344         e_nef += pfsub->neutralEmEnergy();
0345         e_muf += pfsub->muonEnergy();
0346         nch += pfsub->chargedMultiplicity();
0347         nconstituents += pfsub->neutralMultiplicity() + pfsub->chargedMultiplicity();
0348         nneutrals += pfsub->neutralMultiplicity();
0349       }
0350       double e = basicJet->energy();
0351       if (e > 0.000001) {
0352         chf = e_chf / e;
0353         nhf = e_nhf / e;
0354         cef = e_cef / e;
0355         nef = e_nef / e;
0356         muf = e_muf / e;
0357       }
0358     }  // end if basic jet
0359 
0360     float etaB = 2.4;
0361     // Cuts for |eta| < 2.6 for Summer18
0362     if (version_ == SUMMER18 || version_ == SUMMER18PUPPI || version_ == RUN2ULCHS || version_ == RUN2ULPUPPI)
0363       etaB = 2.6;
0364     if ((version_ != WINTER17 && version_ != WINTER17PUPPI && version_ != SUMMER18 && version_ != SUMMER18PUPPI &&
0365          version_ != RUN2UL16CHS && version_ != RUN2UL16PUPPI && version_ != RUN2ULCHS && version_ != RUN2ULPUPPI) ||
0366         quality_ != TIGHT) {
0367       if (ignoreCut(indexCEF_) || (cef < cut(indexCEF_, double()) || std::abs(jet.eta()) > etaB))
0368         passCut(ret, indexCEF_);
0369     }
0370     if (ignoreCut(indexCHF_) || (chf > cut(indexCHF_, double()) || std::abs(jet.eta()) > etaB))
0371       passCut(ret, indexCHF_);
0372     if (ignoreCut(indexNCH_) || (nch > cut(indexNCH_, int()) || std::abs(jet.eta()) > etaB))
0373       passCut(ret, indexNCH_);
0374     if (version_ == FIRSTDATA) {  // Cuts for all eta for FIRSTDATA
0375       if (ignoreCut(indexNConstituents_) || (nconstituents > cut(indexNConstituents_, int())))
0376         passCut(ret, indexNConstituents_);
0377       if (ignoreCut(indexNEF_) || (nef < cut(indexNEF_, double())))
0378         passCut(ret, indexNEF_);
0379       if (ignoreCut(indexNHF_) || (nhf < cut(indexNHF_, double())))
0380         passCut(ret, indexNHF_);
0381     } else if (version_ == RUNIISTARTUP) {
0382       // Cuts for |eta| <= 3.0 for RUNIISTARTUP scenario
0383       if (ignoreCut(indexNConstituents_) ||
0384           (nconstituents > cut(indexNConstituents_, int()) || std::abs(jet.eta()) > 3.0))
0385         passCut(ret, indexNConstituents_);
0386       if (ignoreCut(indexNEF_) || (nef < cut(indexNEF_, double()) || std::abs(jet.eta()) > 3.0))
0387         passCut(ret, indexNEF_);
0388       if (ignoreCut(indexNHF_) || (nhf < cut(indexNHF_, double()) || std::abs(jet.eta()) > 3.0))
0389         passCut(ret, indexNHF_);
0390       // Cuts for |eta| > 3.0 for RUNIISTARTUP scenario
0391       if (ignoreCut(indexNEF_FW_) || (nef < cut(indexNEF_FW_, double()) || std::abs(jet.eta()) <= 3.0))
0392         passCut(ret, indexNEF_FW_);
0393       if (ignoreCut(indexNNeutrals_FW_) || (nneutrals > cut(indexNNeutrals_FW_, int()) || std::abs(jet.eta()) <= 3.0))
0394         passCut(ret, indexNNeutrals_FW_);
0395     } else if (version_ == WINTER16) {
0396       // Cuts for |eta| <= 2.7 for WINTER16 scenario
0397       if (ignoreCut(indexNConstituents_) ||
0398           (nconstituents > cut(indexNConstituents_, int()) || std::abs(jet.eta()) > 2.7))
0399         passCut(ret, indexNConstituents_);
0400       if (ignoreCut(indexNEF_) || (nef < cut(indexNEF_, double()) || std::abs(jet.eta()) > 2.7))
0401         passCut(ret, indexNEF_);
0402       if (ignoreCut(indexNHF_) || (nhf < cut(indexNHF_, double()) || std::abs(jet.eta()) > 2.7))
0403         passCut(ret, indexNHF_);
0404       if (quality_ == TIGHTLEPVETO) {
0405         if (ignoreCut(indexMUF_) || (muf < cut(indexMUF_, double()) || std::abs(jet.eta()) > 2.7))
0406           passCut(ret, indexMUF_);
0407       }
0408 
0409       // Cuts for 2.7 < |eta| <= 3.0 for WINTER16 scenario
0410       if (ignoreCut(indexNHF_EC_) ||
0411           (nhf < cut(indexNHF_EC_, double()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0))
0412         passCut(ret, indexNHF_EC_);
0413       if (ignoreCut(indexNEF_EC_) ||
0414           (nef > cut(indexNEF_EC_, double()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0))
0415         passCut(ret, indexNEF_EC_);
0416       if (ignoreCut(indexNNeutrals_EC_) ||
0417           (nneutrals > cut(indexNNeutrals_EC_, int()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0))
0418         passCut(ret, indexNNeutrals_EC_);
0419 
0420       // Cuts for |eta| > 3.0 for WINTER16 scenario
0421       if (ignoreCut(indexNEF_FW_) || (nef < cut(indexNEF_FW_, double()) || std::abs(jet.eta()) <= 3.0))
0422         passCut(ret, indexNEF_FW_);
0423       if (ignoreCut(indexNNeutrals_FW_) || (nneutrals > cut(indexNNeutrals_FW_, int()) || std::abs(jet.eta()) <= 3.0))
0424         passCut(ret, indexNNeutrals_FW_);
0425     } else if (version_ == WINTER17) {
0426       // Cuts for |eta| <= 2.7 for WINTER17 scenario
0427       if (ignoreCut(indexNConstituents_) ||
0428           (nconstituents > cut(indexNConstituents_, int()) || std::abs(jet.eta()) > 2.7))
0429         passCut(ret, indexNConstituents_);
0430       if (ignoreCut(indexNEF_) || (nef < cut(indexNEF_, double()) || std::abs(jet.eta()) > 2.7))
0431         passCut(ret, indexNEF_);
0432       if (ignoreCut(indexNHF_) || (nhf < cut(indexNHF_, double()) || std::abs(jet.eta()) > 2.7))
0433         passCut(ret, indexNHF_);
0434       if (quality_ == TIGHTLEPVETO) {
0435         if (ignoreCut(indexMUF_) || (muf < cut(indexMUF_, double()) || std::abs(jet.eta()) > 2.7))
0436           passCut(ret, indexMUF_);
0437       }
0438 
0439       // Cuts for 2.7 < |eta| <= 3.0 for WINTER17 scenario
0440 
0441       if (ignoreCut(indexNEF_EC_L_) ||
0442           (nef > cut(indexNEF_EC_L_, double()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0))
0443         passCut(ret, indexNEF_EC_L_);
0444       if (ignoreCut(indexNEF_EC_U_) ||
0445           (nef < cut(indexNEF_EC_U_, double()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0))
0446         passCut(ret, indexNEF_EC_U_);
0447       if (ignoreCut(indexNNeutrals_EC_) ||
0448           (nneutrals > cut(indexNNeutrals_EC_, int()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0))
0449         passCut(ret, indexNNeutrals_EC_);
0450 
0451       // Cuts for |eta| > 3.0 for WINTER17 scenario
0452       if (ignoreCut(indexNHF_FW_) || (nhf > cut(indexNHF_FW_, double()) || std::abs(jet.eta()) <= 3.0))
0453         passCut(ret, indexNHF_FW_);
0454       if (ignoreCut(indexNEF_FW_) || (nef < cut(indexNEF_FW_, double()) || std::abs(jet.eta()) <= 3.0))
0455         passCut(ret, indexNEF_FW_);
0456       if (ignoreCut(indexNNeutrals_FW_) || (nneutrals > cut(indexNNeutrals_FW_, int()) || std::abs(jet.eta()) <= 3.0))
0457         passCut(ret, indexNNeutrals_FW_);
0458 
0459     } else if (version_ == WINTER17PUPPI) {
0460       // Cuts for |eta| <= 2.7 for WINTER17 scenario
0461       if (ignoreCut(indexNConstituents_) ||
0462           (nconstituents > cut(indexNConstituents_, int()) || std::abs(jet.eta()) > 2.7))
0463         passCut(ret, indexNConstituents_);
0464       if (ignoreCut(indexNEF_) || (nef < cut(indexNEF_, double()) || std::abs(jet.eta()) > 2.7))
0465         passCut(ret, indexNEF_);
0466       if (ignoreCut(indexNHF_) || (nhf < cut(indexNHF_, double()) || std::abs(jet.eta()) > 2.7))
0467         passCut(ret, indexNHF_);
0468       if (quality_ == TIGHTLEPVETO) {
0469         if (ignoreCut(indexMUF_) || (muf < cut(indexMUF_, double()) || std::abs(jet.eta()) > 2.7))
0470           passCut(ret, indexMUF_);
0471       }
0472 
0473       // Cuts for 2.7 < |eta| <= 3.0 for WINTER17 scenario
0474 
0475       if (ignoreCut(indexNHF_EC_) ||
0476           (nhf < cut(indexNHF_EC_, double()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0))
0477         passCut(ret, indexNHF_EC_);
0478 
0479       // Cuts for |eta| > 3.0 for WINTER17 scenario
0480       if (ignoreCut(indexNHF_FW_) || (nhf > cut(indexNHF_FW_, double()) || std::abs(jet.eta()) <= 3.0))
0481         passCut(ret, indexNHF_FW_);
0482       if (ignoreCut(indexNEF_FW_) || (nef < cut(indexNEF_FW_, double()) || std::abs(jet.eta()) <= 3.0))
0483         passCut(ret, indexNEF_FW_);
0484       if (ignoreCut(indexNNeutrals_FW_L_) ||
0485           (nneutrals > cut(indexNNeutrals_FW_L_, int()) || std::abs(jet.eta()) <= 3.0))
0486         passCut(ret, indexNNeutrals_FW_L_);
0487       if (ignoreCut(indexNNeutrals_FW_U_) ||
0488           (nneutrals < cut(indexNNeutrals_FW_U_, int()) || std::abs(jet.eta()) <= 3.0))
0489         passCut(ret, indexNNeutrals_FW_U_);
0490 
0491     } else if (version_ == RUN2UL16CHS) {
0492       // Cuts for |eta| <= 2.4 for RUN2UL16CHS scenario
0493       if (ignoreCut(indexNConstituents_) ||
0494           (nconstituents > cut(indexNConstituents_, int()) || std::abs(jet.eta()) > 2.4))
0495         passCut(ret, indexNConstituents_);
0496       if (ignoreCut(indexNEF_) || (nef < cut(indexNEF_, double()) || std::abs(jet.eta()) > 2.4))
0497         passCut(ret, indexNEF_);
0498       if (ignoreCut(indexNHF_) || (nhf < cut(indexNHF_, double()) || std::abs(jet.eta()) > 2.4))
0499         passCut(ret, indexNHF_);
0500       if (quality_ == TIGHTLEPVETO) {
0501         if (ignoreCut(indexMUF_) || (muf < cut(indexMUF_, double()) || std::abs(jet.eta()) > 2.4))
0502           passCut(ret, indexMUF_);
0503       }
0504 
0505       // Cuts for 2.4 <= |eta| <= 2.7 for RUN2UL16CHS scenario
0506       if (ignoreCut(indexNHF_TR_) ||
0507           (nhf < cut(indexNHF_TR_, double()) || std::abs(jet.eta()) <= 2.4 || std::abs(jet.eta()) > 2.7))
0508         passCut(ret, indexNHF_TR_);
0509       if (ignoreCut(indexNEF_TR_) ||
0510           (nef < cut(indexNEF_TR_, double()) || std::abs(jet.eta()) <= 2.4 || std::abs(jet.eta()) > 2.7))
0511         passCut(ret, indexNEF_TR_);
0512 
0513       // Cuts for 2.7 < |eta| <= 3.0 for RUN2UL16CHS scenario
0514       if (ignoreCut(indexNHF_EC_) ||
0515           (nhf < cut(indexNHF_EC_, double()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0))
0516         passCut(ret, indexNHF_EC_);
0517       if (ignoreCut(indexNEF_EC_L_) ||
0518           (nef > cut(indexNEF_EC_L_, double()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0))
0519         passCut(ret, indexNEF_EC_L_);
0520       if (ignoreCut(indexNEF_EC_U_) ||
0521           (nef < cut(indexNEF_EC_U_, double()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0))
0522         passCut(ret, indexNEF_EC_U_);
0523       if (ignoreCut(indexNNeutrals_EC_) ||
0524           (nneutrals > cut(indexNNeutrals_EC_, int()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0))
0525         passCut(ret, indexNNeutrals_EC_);
0526 
0527       // Cuts for |eta| > 3.0 for RUN2UL16CHS scenario
0528       if (ignoreCut(indexNHF_FW_) || (nhf > cut(indexNHF_FW_, double()) || std::abs(jet.eta()) <= 3.0))
0529         passCut(ret, indexNHF_FW_);
0530       if (ignoreCut(indexNEF_FW_) || (nef < cut(indexNEF_FW_, double()) || std::abs(jet.eta()) <= 3.0))
0531         passCut(ret, indexNEF_FW_);
0532       if (ignoreCut(indexNNeutrals_FW_) || (nneutrals > cut(indexNNeutrals_FW_, int()) || std::abs(jet.eta()) <= 3.0))
0533         passCut(ret, indexNNeutrals_FW_);
0534 
0535     } else if (version_ == RUN2UL16PUPPI) {
0536       // Cuts for |eta| <= 2.4 for RUN2UL16PUPPI scenario
0537       if (ignoreCut(indexNConstituents_) ||
0538           (nconstituents > cut(indexNConstituents_, int()) || std::abs(jet.eta()) > 2.4))
0539         passCut(ret, indexNConstituents_);
0540       if (ignoreCut(indexNEF_) || (nef < cut(indexNEF_, double()) || std::abs(jet.eta()) > 2.4))
0541         passCut(ret, indexNEF_);
0542       if (ignoreCut(indexNHF_) || (nhf < cut(indexNHF_, double()) || std::abs(jet.eta()) > 2.4))
0543         passCut(ret, indexNHF_);
0544       if (quality_ == TIGHTLEPVETO) {
0545         if (ignoreCut(indexMUF_) || (muf < cut(indexMUF_, double()) || std::abs(jet.eta()) > 2.4))
0546           passCut(ret, indexMUF_);
0547       }
0548 
0549       // Cuts for 2.4 <= |eta| <= 2.7 for RUN2UL16PUPPI scenario
0550       if (ignoreCut(indexNHF_TR_) ||
0551           (nhf < cut(indexNHF_TR_, double()) || std::abs(jet.eta()) <= 2.4 || std::abs(jet.eta()) > 2.7))
0552         passCut(ret, indexNHF_TR_);
0553       if (ignoreCut(indexNEF_TR_) ||
0554           (nef < cut(indexNEF_TR_, double()) || std::abs(jet.eta()) <= 2.4 || std::abs(jet.eta()) > 2.7))
0555         passCut(ret, indexNEF_TR_);
0556 
0557       // Cuts for 2.7 < |eta| <= 3.0 for RUN2UL16PUPPI scenario
0558       if (ignoreCut(indexNNeutrals_EC_) ||
0559           (nneutrals > cut(indexNNeutrals_EC_, int()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0))
0560         passCut(ret, indexNNeutrals_EC_);
0561 
0562       // Cuts for |eta| > 3.0 for RUN2UL16PUPPI scenario
0563       if (ignoreCut(indexNEF_FW_) || (nef < cut(indexNEF_FW_, double()) || std::abs(jet.eta()) <= 3.0))
0564         passCut(ret, indexNEF_FW_);
0565       if (ignoreCut(indexNNeutrals_FW_L_) ||
0566           (nneutrals > cut(indexNNeutrals_FW_L_, int()) || std::abs(jet.eta()) <= 3.0))
0567         passCut(ret, indexNNeutrals_FW_L_);
0568       if (ignoreCut(indexNNeutrals_FW_U_) ||
0569           (nneutrals < cut(indexNNeutrals_FW_U_, int()) || std::abs(jet.eta()) <= 3.0))
0570         passCut(ret, indexNNeutrals_FW_U_);
0571 
0572     } else if ((version_ == SUMMER18) || (version_ == RUN2ULCHS)) {
0573       // Cuts for |eta| <= 2.6 for SUMMER18 scenario
0574       if (ignoreCut(indexNConstituents_) ||
0575           (nconstituents > cut(indexNConstituents_, int()) || std::abs(jet.eta()) > 2.6))
0576         passCut(ret, indexNConstituents_);
0577       if (ignoreCut(indexNEF_) || (nef < cut(indexNEF_, double()) || std::abs(jet.eta()) > 2.6))
0578         passCut(ret, indexNEF_);
0579       if (ignoreCut(indexNHF_) || (nhf < cut(indexNHF_, double()) || std::abs(jet.eta()) > 2.6))
0580         passCut(ret, indexNHF_);
0581       if (quality_ == TIGHTLEPVETO) {
0582         if (ignoreCut(indexMUF_) || (muf < cut(indexMUF_, double()) || std::abs(jet.eta()) > 2.6))
0583           passCut(ret, indexMUF_);
0584       }
0585 
0586       // Cuts for 2.6 <= |eta| <= 2.7 for SUMMER18 scenario
0587       if (ignoreCut(indexNHF_TR_) ||
0588           (nhf < cut(indexNHF_TR_, double()) || std::abs(jet.eta()) <= 2.6 || std::abs(jet.eta()) > 2.7))
0589         passCut(ret, indexNHF_TR_);
0590       if (ignoreCut(indexNEF_TR_) ||
0591           (nef < cut(indexNEF_TR_, double()) || std::abs(jet.eta()) <= 2.6 || std::abs(jet.eta()) > 2.7))
0592         passCut(ret, indexNEF_TR_);
0593       if (ignoreCut(indexNCH_TR_) ||
0594           (nch > cut(indexNCH_TR_, double()) || std::abs(jet.eta()) <= 2.6 || std::abs(jet.eta()) > 2.7))
0595         passCut(ret, indexNCH_TR_);
0596       if (quality_ == TIGHTLEPVETO) {
0597         if (ignoreCut(indexMUF_TR_) ||
0598             (muf < cut(indexMUF_TR_, double()) || std::abs(jet.eta()) <= 2.6 || std::abs(jet.eta()) > 2.7))
0599           passCut(ret, indexMUF_TR_);
0600         if (ignoreCut(indexCEF_TR_) ||
0601             (cef < cut(indexCEF_TR_, double()) || std::abs(jet.eta()) <= 2.6 || std::abs(jet.eta()) > 2.7))
0602           passCut(ret, indexCEF_TR_);
0603       }
0604 
0605       // Cuts for 2.7 < |eta| <= 3.0 for SUMMER18 scenario
0606       if (ignoreCut(indexNEF_EC_L_) ||
0607           (nef > cut(indexNEF_EC_L_, double()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0))
0608         passCut(ret, indexNEF_EC_L_);
0609       if (ignoreCut(indexNEF_EC_U_) ||
0610           (nef < cut(indexNEF_EC_U_, double()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0))
0611         passCut(ret, indexNEF_EC_U_);
0612       if (ignoreCut(indexNNeutrals_EC_) ||
0613           (nneutrals > cut(indexNNeutrals_EC_, int()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0))
0614         passCut(ret, indexNNeutrals_EC_);
0615 
0616       // Cuts for |eta| > 3.0 for SUMMER18 scenario
0617       if (ignoreCut(indexNHF_FW_) || (nhf > cut(indexNHF_FW_, double()) || std::abs(jet.eta()) <= 3.0))
0618         passCut(ret, indexNHF_FW_);
0619       if (ignoreCut(indexNEF_FW_) || (nef < cut(indexNEF_FW_, double()) || std::abs(jet.eta()) <= 3.0))
0620         passCut(ret, indexNEF_FW_);
0621       if (ignoreCut(indexNNeutrals_FW_) || (nneutrals > cut(indexNNeutrals_FW_, int()) || std::abs(jet.eta()) <= 3.0))
0622         passCut(ret, indexNNeutrals_FW_);
0623     }
0624 
0625     else if ((version_ == SUMMER18PUPPI) || (version_ == RUN2ULPUPPI)) {
0626       // Cuts for |eta| <= 2.6 for SUMMER18PUPPI scenario
0627       if (ignoreCut(indexNConstituents_) ||
0628           (nconstituents > cut(indexNConstituents_, int()) || std::abs(jet.eta()) > 2.6))
0629         passCut(ret, indexNConstituents_);
0630       if (ignoreCut(indexNEF_) || (nef < cut(indexNEF_, double()) || std::abs(jet.eta()) > 2.6))
0631         passCut(ret, indexNEF_);
0632       if (ignoreCut(indexNHF_) || (nhf < cut(indexNHF_, double()) || std::abs(jet.eta()) > 2.6))
0633         passCut(ret, indexNHF_);
0634       if (quality_ == TIGHTLEPVETO) {
0635         if (ignoreCut(indexMUF_) || (muf < cut(indexMUF_, double()) || std::abs(jet.eta()) > 2.6))
0636           passCut(ret, indexMUF_);
0637       }
0638 
0639       // Cuts for 2.6 <= |eta| <= 2.7 for SUMMER18PUPPI scenario
0640       if (ignoreCut(indexNHF_TR_) ||
0641           (nhf < cut(indexNHF_TR_, double()) || std::abs(jet.eta()) <= 2.6 || std::abs(jet.eta()) > 2.7))
0642         passCut(ret, indexNHF_TR_);
0643       if (ignoreCut(indexNEF_TR_) ||
0644           (nef < cut(indexNEF_TR_, double()) || std::abs(jet.eta()) <= 2.6 || std::abs(jet.eta()) > 2.7))
0645         passCut(ret, indexNEF_TR_);
0646       if (quality_ == TIGHTLEPVETO) {
0647         if (ignoreCut(indexMUF_TR_) ||
0648             (muf < cut(indexMUF_TR_, double()) || std::abs(jet.eta()) <= 2.6 || std::abs(jet.eta()) > 2.7))
0649           passCut(ret, indexMUF_TR_);
0650         if (ignoreCut(indexCEF_TR_) ||
0651             (cef < cut(indexCEF_TR_, double()) || std::abs(jet.eta()) <= 2.6 || std::abs(jet.eta()) > 2.7))
0652           passCut(ret, indexCEF_TR_);
0653       }
0654 
0655       // Cuts for 2.7 < |eta| <= 3.0 for SUMMER18PUPPI scenario
0656       if (ignoreCut(indexNHF_EC_) ||
0657           (nhf < cut(indexNHF_EC_, double()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0))
0658         passCut(ret, indexNHF_EC_);
0659 
0660       // Cuts for |eta| > 3.0 for SUMMER18PUPPI scenario
0661       if (ignoreCut(indexNHF_FW_) || (nhf > cut(indexNHF_FW_, double()) || std::abs(jet.eta()) <= 3.0))
0662         passCut(ret, indexNHF_FW_);
0663       if (ignoreCut(indexNEF_FW_) || (nef < cut(indexNEF_FW_, double()) || std::abs(jet.eta()) <= 3.0))
0664         passCut(ret, indexNEF_FW_);
0665       if (ignoreCut(indexNNeutrals_FW_L_) ||
0666           (nneutrals > cut(indexNNeutrals_FW_L_, int()) || std::abs(jet.eta()) <= 3.0))
0667         passCut(ret, indexNNeutrals_FW_L_);
0668       if (ignoreCut(indexNNeutrals_FW_U_) ||
0669           (nneutrals < cut(indexNNeutrals_FW_U_, int()) || std::abs(jet.eta()) <= 3.0))
0670         passCut(ret, indexNNeutrals_FW_U_);
0671     }
0672 
0673     //std::cout << "<PFJetIDSelectionFunctor::firstDataCuts>:" << std::endl;
0674     //std::cout << " jet: Pt = " << jet.pt() << ", eta = " << jet.eta() << ", phi = " << jet.phi() << std::endl;
0675     //ret.print(std::cout);
0676     setIgnored(ret);
0677     return (bool)ret;
0678   }
0679 
0680 private:  // member variables
0681   void initCuts() {
0682     push_back("CHF");
0683     push_back("NHF");
0684     if ((version_ != WINTER17 && version_ != WINTER17PUPPI && version_ != SUMMER18 && version_ != SUMMER18PUPPI &&
0685          version_ != RUN2UL16CHS && version_ != RUN2UL16PUPPI && version_ != RUN2ULCHS && version_ != RUN2ULPUPPI) ||
0686         quality_ != TIGHT)
0687       push_back("CEF");
0688     push_back("NEF");
0689     push_back("NCH");
0690     push_back("nConstituents");
0691     if (version_ == RUNIISTARTUP) {
0692       push_back("NEF_FW");
0693       push_back("nNeutrals_FW");
0694     }
0695     if (version_ == WINTER16) {
0696       push_back("NHF_EC");
0697       push_back("NEF_EC");
0698       push_back("nNeutrals_EC");
0699       push_back("NEF_FW");
0700       push_back("nNeutrals_FW");
0701       if (quality_ == TIGHTLEPVETO)
0702         push_back("MUF");
0703     }
0704     if (version_ == WINTER17) {
0705       push_back("NEF_EC_L");
0706       push_back("NEF_EC_U");
0707       push_back("nNeutrals_EC");
0708       push_back("NEF_FW");
0709       push_back("NHF_FW");
0710       push_back("nNeutrals_FW");
0711       if (quality_ == TIGHTLEPVETO)
0712         push_back("MUF");
0713     }
0714     if (version_ == WINTER17PUPPI) {
0715       push_back("NHF_EC");
0716       push_back("NEF_FW");
0717       push_back("NHF_FW");
0718       push_back("nNeutrals_FW_L");
0719       push_back("nNeutrals_FW_U");
0720       if (quality_ == TIGHTLEPVETO)
0721         push_back("MUF");
0722     }
0723     if (version_ == RUN2UL16CHS) {
0724       push_back("NHF_TR");
0725       push_back("NEF_TR");
0726       push_back("NHF_EC");
0727       push_back("NEF_EC_L");
0728       push_back("NEF_EC_U");
0729       push_back("nNeutrals_EC");
0730       push_back("NEF_FW");
0731       push_back("NHF_FW");
0732       push_back("nNeutrals_FW");
0733 
0734       if (quality_ == TIGHTLEPVETO) {
0735         push_back("MUF");
0736       }
0737     }
0738     if (version_ == RUN2UL16PUPPI) {
0739       push_back("NHF_TR");
0740       push_back("NEF_TR");
0741       push_back("nNeutrals_EC");
0742       push_back("NEF_FW");
0743       push_back("nNeutrals_FW_L");
0744       push_back("nNeutrals_FW_U");
0745 
0746       if (quality_ == TIGHTLEPVETO) {
0747         push_back("MUF");
0748       }
0749     }
0750     if ((version_ == SUMMER18) || (version_ == RUN2ULCHS)) {
0751       push_back("NHF_TR");
0752       push_back("NEF_TR");
0753       push_back("NCH_TR");
0754       push_back("NEF_EC_L");
0755       push_back("NEF_EC_U");
0756       push_back("nNeutrals_EC");
0757       push_back("NEF_FW");
0758       push_back("NHF_FW");
0759       push_back("nNeutrals_FW");
0760 
0761       if (quality_ == TIGHTLEPVETO) {
0762         push_back("MUF");
0763         push_back("MUF_TR");
0764         push_back("CEF_TR");
0765       }
0766     }
0767     if ((version_ == SUMMER18PUPPI) || (version_ == RUN2ULPUPPI)) {
0768       push_back("NHF_TR");
0769       push_back("NEF_TR");
0770       push_back("NHF_EC");
0771       push_back("NEF_FW");
0772       push_back("NHF_FW");
0773       push_back("nNeutrals_FW_L");
0774       push_back("nNeutrals_FW_U");
0775 
0776       if (quality_ == TIGHTLEPVETO) {
0777         push_back("MUF");
0778         push_back("MUF_TR");
0779         push_back("CEF_TR");
0780       }
0781     }
0782 
0783     if ((version_ == WINTER17 || version_ == WINTER17PUPPI || version_ == SUMMER18 || version_ == SUMMER18PUPPI ||
0784          version_ == RUN2UL16CHS || version_ == RUN2UL16PUPPI || version_ == RUN2ULCHS || version_ == RUN2ULPUPPI) &&
0785         quality_ == LOOSE) {
0786       edm::LogWarning("BadJetIDVersion")
0787           << "The LOOSE operating point is only supported for the WINTER16 JetID version -- defaulting to TIGHT";
0788       quality_ = TIGHT;
0789     }
0790 
0791     // Set some default cuts for LOOSE, TIGHT
0792     if (quality_ == LOOSE) {
0793       set("CHF", 0.0);
0794       set("NHF", 0.99);
0795       set("CEF", 0.99);
0796       set("NEF", 0.99);
0797       set("NCH", 0);
0798       set("nConstituents", 1);
0799       if (version_ == RUNIISTARTUP) {
0800         set("NEF_FW", 0.90);
0801         set("nNeutrals_FW", 10);
0802       } else if (version_ == WINTER16) {
0803         set("NHF_EC", 0.98);
0804         set("NEF_EC", 0.01);
0805         set("nNeutrals_EC", 2);
0806         set("NEF_FW", 0.90);
0807         set("nNeutrals_FW", 10);
0808       }
0809     } else if (quality_ == TIGHT) {
0810       set("CHF", 0.0);
0811       set("NHF", 0.9);
0812       if (version_ != WINTER17 && version_ != WINTER17PUPPI && version_ != SUMMER18 && version_ != SUMMER18PUPPI &&
0813           version_ != RUN2UL16CHS && version_ != RUN2UL16PUPPI && version_ != RUN2ULCHS && version_ != RUN2ULPUPPI)
0814         set("CEF", 0.99);
0815       set("NEF", 0.9);
0816       set("NCH", 0);
0817       set("nConstituents", 1);
0818       if (version_ == RUNIISTARTUP) {
0819         set("NEF_FW", 0.90);
0820         set("nNeutrals_FW", 10);
0821       } else if (version_ == WINTER16) {
0822         set("NHF_EC", 0.98);
0823         set("NEF_EC", 0.01);
0824         set("nNeutrals_EC", 2);
0825         set("NEF_FW", 0.90);
0826         set("nNeutrals_FW", 10);
0827       } else if (version_ == WINTER17) {
0828         set("NEF_EC_L", 0.02);
0829         set("NEF_EC_U", 0.99);
0830         set("nNeutrals_EC", 2);
0831         set("NHF_FW", 0.02);
0832         set("NEF_FW", 0.90);
0833         set("nNeutrals_FW", 10);
0834       } else if (version_ == WINTER17PUPPI) {
0835         set("NHF_EC", 0.99);
0836         set("NHF_FW", 0.02);
0837         set("NEF_FW", 0.90);
0838         set("nNeutrals_FW_L", 2);
0839         set("nNeutrals_FW_U", 15);
0840       } else if (version_ == SUMMER18) {
0841         set("NHF_TR", 0.9);
0842         set("NEF_TR", 0.99);
0843         set("NCH_TR", 0);
0844         set("NEF_EC_L", 0.02);
0845         set("NEF_EC_U", 0.99);
0846         set("nNeutrals_EC", 2);
0847         set("NHF_FW", 0.2);
0848         set("NEF_FW", 0.90);
0849         set("nNeutrals_FW", 10);
0850       } else if (version_ == SUMMER18PUPPI) {
0851         set("NHF_TR", 0.9);
0852         set("NEF_TR", 0.99);
0853         set("NHF_EC", 0.99);
0854         set("NHF_FW", 0.02);
0855         set("NEF_FW", 0.90);
0856         set("nNeutrals_FW_L", 2);
0857         set("nNeutrals_FW_U", 15);
0858       } else if (version_ == RUN2UL16CHS) {
0859         set("NHF_TR", 0.9);
0860         set("NEF_TR", 0.99);
0861         set("NHF_EC", 0.9);
0862         set("NEF_EC_L", 0.);
0863         set("NEF_EC_U", 0.99);
0864         set("nNeutrals_EC", 1);
0865         set("NHF_FW", 0.2);
0866         set("NEF_FW", 0.90);
0867         set("nNeutrals_FW", 10);
0868       } else if (version_ == RUN2UL16PUPPI) {
0869         set("NHF_TR", 0.98);
0870         set("NEF_TR", 0.99);
0871         set("nNeutrals_EC", 1);
0872         set("NEF_FW", 0.90);
0873         set("nNeutrals_FW_L", 2);
0874         set("nNeutrals_FW_U", 999999);
0875       } else if (version_ == RUN2ULCHS) {
0876         set("NHF_TR", 0.9);
0877         set("NEF_TR", 0.99);
0878         set("NCH_TR", 0);
0879         set("NEF_EC_L", 0.01);
0880         set("NEF_EC_U", 0.99);
0881         set("nNeutrals_EC", 2);
0882         set("NHF_FW", 0.2);
0883         set("NEF_FW", 0.90);
0884         set("nNeutrals_FW", 10);
0885       } else if (version_ == RUN2ULPUPPI) {
0886         set("NHF_TR", 0.9);
0887         set("NEF_TR", 0.99);
0888         set("NHF_EC", 0.9999);
0889         set("NHF_FW", -1.0);
0890         set("NEF_FW", 0.90);
0891         set("nNeutrals_FW_L", 2);
0892         set("nNeutrals_FW_U", 999999);
0893       }
0894     } else if (quality_ == TIGHTLEPVETO) {
0895       set("CHF", 0.0);
0896       set("NHF", 0.9);
0897       set("NEF", 0.9);
0898       set("NCH", 0);
0899       set("nConstituents", 1);
0900       if (version_ == WINTER17) {
0901         set("CEF", 0.8);
0902         set("NEF_EC_L", 0.02);
0903         set("NEF_EC_U", 0.99);
0904         set("nNeutrals_EC", 2);
0905         set("NHF_FW", 0.02);
0906         set("NEF_FW", 0.90);
0907         set("nNeutrals_FW", 10);
0908         set("MUF", 0.8);
0909       } else if (version_ == WINTER17PUPPI) {
0910         set("CEF", 0.8);
0911         set("NHF_EC", 0.99);
0912         set("NHF_FW", 0.02);
0913         set("NEF_FW", 0.90);
0914         set("nNeutrals_FW_L", 2);
0915         set("nNeutrals_FW_U", 15);
0916         set("MUF", 0.8);
0917       } else if (version_ == WINTER16) {
0918         set("CEF", 0.9);
0919         set("NEF_EC", 0.01);
0920         set("NHF_EC", 0.98);
0921         set("nNeutrals_EC", 2);
0922         set("nNeutrals_FW", 10);
0923         set("NEF_FW", 0.90);
0924         set("MUF", 0.8);
0925       } else if (version_ == WINTER17PUPPI) {
0926         set("CEF", 0.8);
0927         set("NHF_EC", 0.99);
0928         set("NHF_FW", 0.02);
0929         set("NEF_FW", 0.90);
0930         set("nNeutrals_FW_L", 2);
0931         set("nNeutrals_FW_U", 15);
0932         set("MUF", 0.8);
0933       } else if (version_ == WINTER16) {
0934         set("CEF", 0.9);
0935         set("NEF_EC", 0.01);
0936         set("NHF_EC", 0.98);
0937         set("nNeutrals_EC", 2);
0938         set("nNeutrals_FW", 10);
0939         set("NEF_FW", 0.90);
0940         set("MUF", 0.8);
0941       } else if (version_ == SUMMER18) {
0942         set("CEF", 0.8);
0943         set("MUF", 0.8);
0944         set("NHF_TR", 0.9);
0945         set("NEF_TR", 0.99);
0946         set("MUF_TR", 0.8);
0947         set("NCH_TR", 0);
0948         set("CEF_TR", 0.8);
0949         set("NEF_EC_L", 0.02);
0950         set("NEF_EC_U", 0.99);
0951         set("nNeutrals_EC", 2);
0952         set("NHF_FW", 0.2);
0953         set("NEF_FW", 0.90);
0954         set("nNeutrals_FW", 10);
0955       } else if (version_ == SUMMER18PUPPI) {
0956         set("CEF", 0.8);
0957         set("MUF", 0.8);
0958         set("NHF_TR", 0.9);
0959         set("NEF_TR", 0.99);
0960         set("MUF_TR", 0.8);
0961         set("CEF_TR", 0.8);
0962         set("NHF_EC", 0.99);
0963         set("NHF_FW", 0.02);
0964         set("NEF_FW", 0.90);
0965         set("nNeutrals_FW_L", 2);
0966         set("nNeutrals_FW_U", 15);
0967       } else if (version_ == RUN2UL16CHS) {
0968         set("MUF", 0.8);
0969         set("CEF", 0.8);
0970         set("NHF_TR", 0.9);
0971         set("NEF_TR", 0.99);
0972         set("NHF_EC", 0.9);
0973         set("NEF_EC_L", 0.);
0974         set("NEF_EC_U", 0.99);
0975         set("nNeutrals_EC", 1);
0976         set("NHF_FW", 0.2);
0977         set("NEF_FW", 0.90);
0978         set("nNeutrals_FW", 10);
0979       } else if (version_ == RUN2UL16PUPPI) {
0980         set("MUF", 0.8);
0981         set("CEF", 0.8);
0982         set("NHF_TR", 0.98);
0983         set("NEF_TR", 0.99);
0984         set("nNeutrals_EC", 1);
0985         set("NEF_FW", 0.90);
0986         set("nNeutrals_FW_L", 2);
0987         set("nNeutrals_FW_U", 999999);
0988       } else if (version_ == RUN2ULCHS) {
0989         set("CEF", 0.8);
0990         set("MUF", 0.8);
0991         set("NHF_TR", 0.9);
0992         set("NEF_TR", 0.99);
0993         set("MUF_TR", 0.8);
0994         set("NCH_TR", 0);
0995         set("CEF_TR", 0.8);
0996         set("NEF_EC_L", 0.01);
0997         set("NEF_EC_U", 0.99);
0998         set("nNeutrals_EC", 2);
0999         set("NHF_FW", 0.2);
1000         set("NEF_FW", 0.90);
1001         set("nNeutrals_FW", 10);
1002       } else if (version_ == RUN2ULPUPPI) {
1003         set("CEF", 0.8);
1004         set("MUF", 0.8);
1005         set("NHF_TR", 0.9);
1006         set("NEF_TR", 0.99);
1007         set("MUF_TR", 0.8);
1008         set("CEF_TR", 0.8);
1009         set("NHF_EC", 0.9999);
1010         set("NHF_FW", -1.0);
1011         set("NEF_FW", 0.90);
1012         set("nNeutrals_FW_L", 2);
1013         set("nNeutrals_FW_U", 999999);
1014       }
1015     }
1016   }
1017 
1018   void initIndex() {
1019     indexNConstituents_ = index_type(&bits_, "nConstituents");
1020     indexNEF_ = index_type(&bits_, "NEF");
1021     indexNHF_ = index_type(&bits_, "NHF");
1022     if ((version_ != WINTER17 && version_ != WINTER17PUPPI && version_ != SUMMER18 && version_ != SUMMER18PUPPI &&
1023          version_ != RUN2UL16CHS && version_ != RUN2UL16PUPPI && version_ != RUN2ULCHS && version_ != RUN2ULPUPPI) ||
1024         quality_ != TIGHT)
1025       indexCEF_ = index_type(&bits_, "CEF");
1026 
1027     indexCHF_ = index_type(&bits_, "CHF");
1028     indexNCH_ = index_type(&bits_, "NCH");
1029     if (version_ == RUNIISTARTUP) {
1030       indexNEF_FW_ = index_type(&bits_, "NEF_FW");
1031       indexNNeutrals_FW_ = index_type(&bits_, "nNeutrals_FW");
1032     }
1033     if (version_ == WINTER16) {
1034       indexNHF_EC_ = index_type(&bits_, "NHF_EC");
1035       indexNEF_EC_ = index_type(&bits_, "NEF_EC");
1036       indexNNeutrals_EC_ = index_type(&bits_, "nNeutrals_EC");
1037       indexNEF_FW_ = index_type(&bits_, "NEF_FW");
1038       indexNNeutrals_FW_ = index_type(&bits_, "nNeutrals_FW");
1039       if (quality_ == TIGHTLEPVETO) {
1040         indexMUF_ = index_type(&bits_, "MUF");
1041       }
1042     }
1043     if (version_ == WINTER17) {
1044       indexNEF_EC_L_ = index_type(&bits_, "NEF_EC_L");
1045       indexNEF_EC_U_ = index_type(&bits_, "NEF_EC_U");
1046       indexNNeutrals_EC_ = index_type(&bits_, "nNeutrals_EC");
1047       indexNHF_FW_ = index_type(&bits_, "NHF_FW");
1048       indexNEF_FW_ = index_type(&bits_, "NEF_FW");
1049       indexNNeutrals_FW_ = index_type(&bits_, "nNeutrals_FW");
1050       if (quality_ == TIGHTLEPVETO) {
1051         indexMUF_ = index_type(&bits_, "MUF");
1052       }
1053     }
1054     if (version_ == WINTER17PUPPI) {
1055       indexNHF_EC_ = index_type(&bits_, "NHF_EC");
1056       indexNHF_FW_ = index_type(&bits_, "NHF_FW");
1057       indexNEF_FW_ = index_type(&bits_, "NEF_FW");
1058       indexNNeutrals_FW_L_ = index_type(&bits_, "nNeutrals_FW_L");
1059       indexNNeutrals_FW_U_ = index_type(&bits_, "nNeutrals_FW_U");
1060       if (quality_ == TIGHTLEPVETO) {
1061         indexMUF_ = index_type(&bits_, "MUF");
1062       }
1063     }
1064     if ((version_ == SUMMER18) || (version_ == RUN2ULCHS)) {
1065       indexNHF_TR_ = index_type(&bits_, "NHF_TR");
1066       indexNEF_TR_ = index_type(&bits_, "NEF_TR");
1067       indexNCH_TR_ = index_type(&bits_, "NCH_TR");
1068       indexNEF_EC_L_ = index_type(&bits_, "NEF_EC_L");
1069       indexNEF_EC_U_ = index_type(&bits_, "NEF_EC_U");
1070       indexNNeutrals_EC_ = index_type(&bits_, "nNeutrals_EC");
1071       indexNHF_FW_ = index_type(&bits_, "NHF_FW");
1072       indexNEF_FW_ = index_type(&bits_, "NEF_FW");
1073       indexNNeutrals_FW_ = index_type(&bits_, "nNeutrals_FW");
1074       if (quality_ == TIGHTLEPVETO) {
1075         indexMUF_ = index_type(&bits_, "MUF");
1076         indexMUF_TR_ = index_type(&bits_, "MUF_TR");
1077         indexCEF_TR_ = index_type(&bits_, "CEF_TR");
1078       }
1079     }
1080     if ((version_ == SUMMER18PUPPI) || (version_ == RUN2ULPUPPI)) {
1081       indexNHF_TR_ = index_type(&bits_, "NHF_TR");
1082       indexNEF_TR_ = index_type(&bits_, "NEF_TR");
1083       indexNHF_EC_ = index_type(&bits_, "NHF_EC");
1084       indexNHF_FW_ = index_type(&bits_, "NHF_FW");
1085       indexNEF_FW_ = index_type(&bits_, "NEF_FW");
1086       indexNNeutrals_FW_L_ = index_type(&bits_, "nNeutrals_FW_L");
1087       indexNNeutrals_FW_U_ = index_type(&bits_, "nNeutrals_FW_U");
1088       if (quality_ == TIGHTLEPVETO) {
1089         indexMUF_ = index_type(&bits_, "MUF");
1090         indexMUF_TR_ = index_type(&bits_, "MUF_TR");
1091         indexCEF_TR_ = index_type(&bits_, "CEF_TR");
1092       }
1093     }
1094     if (version_ == RUN2UL16CHS) {
1095       indexNHF_TR_ = index_type(&bits_, "NHF_TR");
1096       indexNEF_TR_ = index_type(&bits_, "NEF_TR");
1097       indexNHF_EC_ = index_type(&bits_, "NHF_EC");
1098       indexNEF_EC_L_ = index_type(&bits_, "NEF_EC_L");
1099       indexNEF_EC_U_ = index_type(&bits_, "NEF_EC_U");
1100       indexNNeutrals_EC_ = index_type(&bits_, "nNeutrals_EC");
1101       indexNHF_FW_ = index_type(&bits_, "NHF_FW");
1102       indexNEF_FW_ = index_type(&bits_, "NEF_FW");
1103       indexNNeutrals_FW_ = index_type(&bits_, "nNeutrals_FW");
1104       if (quality_ == TIGHTLEPVETO) {
1105         indexMUF_ = index_type(&bits_, "MUF");
1106       }
1107     }
1108     if (version_ == RUN2UL16PUPPI) {
1109       indexNHF_TR_ = index_type(&bits_, "NHF_TR");
1110       indexNEF_TR_ = index_type(&bits_, "NEF_TR");
1111       indexNNeutrals_EC_ = index_type(&bits_, "nNeutrals_EC");
1112       indexNEF_FW_ = index_type(&bits_, "NEF_FW");
1113       indexNNeutrals_FW_L_ = index_type(&bits_, "nNeutrals_FW_L");
1114       indexNNeutrals_FW_U_ = index_type(&bits_, "nNeutrals_FW_U");
1115       if (quality_ == TIGHTLEPVETO) {
1116         indexMUF_ = index_type(&bits_, "MUF");
1117       }
1118     }
1119     retInternal_ = getBitTemplate();
1120   }
1121 
1122   Version_t version_;
1123   Quality_t quality_;
1124 
1125   index_type indexNConstituents_;
1126   index_type indexNEF_;
1127   index_type indexMUF_;
1128   index_type indexNHF_;
1129   index_type indexCEF_;
1130   index_type indexCHF_;
1131   index_type indexNCH_;
1132 
1133   index_type indexNHF_TR_;
1134   index_type indexNEF_TR_;
1135   index_type indexNCH_TR_;
1136   index_type indexMUF_TR_;
1137   index_type indexCEF_TR_;
1138 
1139   index_type indexNHF_FW_;
1140   index_type indexNEF_FW_;
1141   index_type indexNNeutrals_FW_;
1142   index_type indexNNeutrals_FW_L_;
1143   index_type indexNNeutrals_FW_U_;
1144 
1145   index_type indexNHF_EC_;
1146   index_type indexNEF_EC_;
1147   index_type indexNEF_EC_L_;
1148   index_type indexNEF_EC_U_;
1149   index_type indexNNeutrals_EC_;
1150 };
1151 
1152 #endif