File indexing completed on 2024-04-06 12:27:48
0001
0002
0003
0004
0005
0006
0007 #include <FWCore/ParameterSet/interface/ConfigurationDescriptions.h>
0008 #include <FWCore/ParameterSet/interface/ParameterSetDescription.h>
0009
0010 #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h"
0011 #include "DataFormats/TrackReco/interface/Track.h"
0012
0013 namespace {
0014
0015 using namespace reco;
0016
0017 class PFRecoTauDiscriminationAgainstElectron final : public PFTauDiscriminationProducerBase {
0018 public:
0019 explicit PFRecoTauDiscriminationAgainstElectron(const edm::ParameterSet& iConfig)
0020 : PFTauDiscriminationProducerBase(iConfig) {
0021 emFraction_maxValue_ = iConfig.getParameter<double>("EmFraction_maxValue");
0022 applyCut_emFraction_ = iConfig.getParameter<bool>("ApplyCut_EmFraction");
0023 hcalTotOverPLead_minValue_ = iConfig.getParameter<double>("HcalTotOverPLead_minValue");
0024 applyCut_hcalTotOverPLead_ = iConfig.getParameter<bool>("ApplyCut_HcalTotOverPLead");
0025 hcalMaxOverPLead_minValue_ = iConfig.getParameter<double>("HcalMaxOverPLead_minValue");
0026 applyCut_hcalMaxOverPLead_ = iConfig.getParameter<bool>("ApplyCut_HcalMaxOverPLead");
0027 hcal3x3OverPLead_minValue_ = iConfig.getParameter<double>("Hcal3x3OverPLead_minValue");
0028
0029 applyCut_hcal3x3OverPLead_ = iConfig.getParameter<bool>("ApplyCut_Hcal3x3OverPLead");
0030 EOverPLead_minValue_ = iConfig.getParameter<double>("EOverPLead_minValue");
0031 EOverPLead_maxValue_ = iConfig.getParameter<double>("EOverPLead_maxValue");
0032 applyCut_EOverPLead_ = iConfig.getParameter<bool>("ApplyCut_EOverPLead");
0033 bremsRecoveryEOverPLead_minValue_ = iConfig.getParameter<double>("BremsRecoveryEOverPLead_minValue");
0034 bremsRecoveryEOverPLead_maxValue_ = iConfig.getParameter<double>("BremsRecoveryEOverPLead_maxValue");
0035
0036 applyCut_bremsRecoveryEOverPLead_ = iConfig.getParameter<bool>("ApplyCut_BremsRecoveryEOverPLead");
0037
0038 applyCut_electronPreID_ = iConfig.getParameter<bool>("ApplyCut_ElectronPreID");
0039
0040 applyCut_electronPreID_2D_ = iConfig.getParameter<bool>("ApplyCut_ElectronPreID_2D");
0041
0042 elecPreID0_EOverPLead_maxValue_ = iConfig.getParameter<double>("ElecPreID0_EOverPLead_maxValue");
0043 elecPreID0_HOverPLead_minValue_ = iConfig.getParameter<double>("ElecPreID0_HOverPLead_minValue");
0044 elecPreID1_EOverPLead_maxValue_ = iConfig.getParameter<double>("ElecPreID1_EOverPLead_maxValue");
0045 elecPreID1_HOverPLead_minValue_ = iConfig.getParameter<double>("ElecPreID1_HOverPLead_minValue");
0046
0047 applyCut_PFElectronMVA_ = iConfig.getParameter<bool>("ApplyCut_PFElectronMVA");
0048 pfelectronMVA_maxValue_ = iConfig.getParameter<double>("PFElectronMVA_maxValue");
0049
0050 applyCut_ecalCrack_ = iConfig.getParameter<bool>("ApplyCut_EcalCrackCut");
0051
0052 applyCut_bremCombined_ = iConfig.getParameter<bool>("ApplyCut_BremCombined");
0053 bremCombined_fraction_ = iConfig.getParameter<double>("BremCombined_Fraction");
0054 bremCombined_maxHOP_ = iConfig.getParameter<double>("BremCombined_HOP");
0055 bremCombined_minMass_ = iConfig.getParameter<double>("BremCombined_Mass");
0056 bremCombined_stripSize_ = iConfig.getParameter<double>("BremCombined_StripSize");
0057 }
0058
0059 double discriminate(const PFTauRef& pfTau) const override;
0060
0061 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0062
0063 ~PFRecoTauDiscriminationAgainstElectron() override {}
0064
0065 private:
0066 bool isInEcalCrack(double) const;
0067 edm::InputTag PFTauProducer_;
0068 bool applyCut_emFraction_;
0069 double emFraction_maxValue_;
0070 bool applyCut_hcalTotOverPLead_;
0071 double hcalTotOverPLead_minValue_;
0072 bool applyCut_hcalMaxOverPLead_;
0073 double hcalMaxOverPLead_minValue_;
0074 bool applyCut_hcal3x3OverPLead_;
0075 double hcal3x3OverPLead_minValue_;
0076
0077 bool applyCut_EOverPLead_;
0078 double EOverPLead_minValue_;
0079 double EOverPLead_maxValue_;
0080 bool applyCut_bremsRecoveryEOverPLead_;
0081 double bremsRecoveryEOverPLead_minValue_;
0082 double bremsRecoveryEOverPLead_maxValue_;
0083
0084 bool applyCut_electronPreID_;
0085
0086 bool applyCut_electronPreID_2D_;
0087 double elecPreID0_EOverPLead_maxValue_;
0088 double elecPreID0_HOverPLead_minValue_;
0089 double elecPreID1_EOverPLead_maxValue_;
0090 double elecPreID1_HOverPLead_minValue_;
0091
0092 bool applyCut_PFElectronMVA_;
0093 double pfelectronMVA_maxValue_;
0094 bool applyCut_ecalCrack_;
0095
0096 bool applyCut_bremCombined_;
0097 double bremCombined_fraction_;
0098 double bremCombined_maxHOP_;
0099 double bremCombined_minMass_;
0100 double bremCombined_stripSize_;
0101 };
0102
0103 double PFRecoTauDiscriminationAgainstElectron::discriminate(const PFTauRef& thePFTauRef) const {
0104
0105
0106 if ((*thePFTauRef).leadPFChargedHadrCand().isNull()) {
0107 return 0.;
0108 } else {
0109
0110 TrackRef myleadTk;
0111 myleadTk = (*thePFTauRef).leadPFChargedHadrCand()->trackRef();
0112 math::XYZPointF myleadTkEcalPos = (*thePFTauRef).leadPFChargedHadrCand()->positionAtECALEntrance();
0113 if (myleadTk.isNonnull()) {
0114 if (applyCut_ecalCrack_ && isInEcalCrack(myleadTkEcalPos.eta())) {
0115 return 0.;
0116 }
0117 }
0118 }
0119
0120 bool decision = false;
0121 bool emfPass = true, htotPass = true, hmaxPass = true;
0122 bool h3x3Pass = true, estripPass = true, erecovPass = true;
0123 bool epreidPass = true, epreid2DPass = true;
0124 bool mvaPass = true, bremCombinedPass = true;
0125
0126 if (applyCut_emFraction_) {
0127 if ((*thePFTauRef).emFraction() > emFraction_maxValue_) {
0128 emfPass = false;
0129 }
0130 }
0131 if (applyCut_hcalTotOverPLead_) {
0132 if ((*thePFTauRef).hcalTotOverPLead() < hcalTotOverPLead_minValue_) {
0133 htotPass = false;
0134 }
0135 }
0136 if (applyCut_hcalMaxOverPLead_) {
0137 if ((*thePFTauRef).hcalMaxOverPLead() < hcalMaxOverPLead_minValue_) {
0138 hmaxPass = false;
0139 }
0140 }
0141 if (applyCut_hcal3x3OverPLead_) {
0142 if ((*thePFTauRef).hcal3x3OverPLead() < hcal3x3OverPLead_minValue_) {
0143 h3x3Pass = false;
0144 }
0145 }
0146 if (applyCut_EOverPLead_) {
0147 if ((*thePFTauRef).ecalStripSumEOverPLead() > EOverPLead_minValue_ &&
0148 (*thePFTauRef).ecalStripSumEOverPLead() < EOverPLead_maxValue_) {
0149 estripPass = false;
0150 } else {
0151 estripPass = true;
0152 }
0153 }
0154 if (applyCut_bremsRecoveryEOverPLead_) {
0155 if ((*thePFTauRef).bremsRecoveryEOverPLead() > bremsRecoveryEOverPLead_minValue_ &&
0156 (*thePFTauRef).bremsRecoveryEOverPLead() < bremsRecoveryEOverPLead_maxValue_) {
0157 erecovPass = false;
0158 } else {
0159 erecovPass = true;
0160 }
0161 }
0162 if (applyCut_electronPreID_) {
0163 if ((*thePFTauRef).electronPreIDDecision()) {
0164 epreidPass = false;
0165 } else {
0166 epreidPass = true;
0167 }
0168 }
0169
0170 if (applyCut_electronPreID_2D_) {
0171 if (((*thePFTauRef).electronPreIDDecision() &&
0172 ((*thePFTauRef).ecalStripSumEOverPLead() < elecPreID1_EOverPLead_maxValue_ ||
0173 (*thePFTauRef).hcal3x3OverPLead() > elecPreID1_HOverPLead_minValue_)) ||
0174 (!(*thePFTauRef).electronPreIDDecision() &&
0175 ((*thePFTauRef).ecalStripSumEOverPLead() < elecPreID0_EOverPLead_maxValue_ ||
0176 (*thePFTauRef).hcal3x3OverPLead() > elecPreID0_HOverPLead_minValue_))) {
0177 epreid2DPass = true;
0178 } else {
0179 epreid2DPass = false;
0180 }
0181 }
0182
0183 if (applyCut_PFElectronMVA_) {
0184 if ((*thePFTauRef).electronPreIDOutput() > pfelectronMVA_maxValue_) {
0185 mvaPass = false;
0186 }
0187 }
0188 if (applyCut_bremCombined_) {
0189 if (thePFTauRef->leadPFChargedHadrCand()->trackRef().isNull()) {
0190
0191 return 0;
0192 }
0193 if (thePFTauRef->signalPFChargedHadrCands().size() == 1 && thePFTauRef->signalPFGammaCands().empty()) {
0194 if (thePFTauRef->leadPFChargedHadrCand()->hcalEnergy() / thePFTauRef->leadPFChargedHadrCand()->trackRef()->p() <
0195 bremCombined_maxHOP_)
0196 bremCombinedPass = false;
0197 } else if (thePFTauRef->signalPFChargedHadrCands().size() == 1 && !thePFTauRef->signalPFGammaCands().empty()) {
0198
0199 float bremEnergy = 0.;
0200 float emEnergy = 0.;
0201 for (unsigned int Nc = 0; Nc < thePFTauRef->signalPFGammaCands().size(); ++Nc) {
0202 PFCandidatePtr cand = thePFTauRef->signalPFGammaCands().at(Nc);
0203 if (fabs(thePFTauRef->leadPFChargedHadrCand()->trackRef()->eta() - cand->eta()) < bremCombined_stripSize_)
0204 bremEnergy += cand->energy();
0205 emEnergy += cand->energy();
0206 }
0207 if (bremEnergy / emEnergy > bremCombined_fraction_ && thePFTauRef->mass() < bremCombined_minMass_)
0208 bremCombinedPass = false;
0209 }
0210 }
0211
0212 decision = emfPass && htotPass && hmaxPass && h3x3Pass && estripPass && erecovPass && epreidPass && epreid2DPass &&
0213 mvaPass && bremCombinedPass;
0214
0215 return (decision ? 1. : 0.);
0216 }
0217
0218 bool PFRecoTauDiscriminationAgainstElectron::isInEcalCrack(double eta) const {
0219 eta = fabs(eta);
0220 return (eta < 0.018 || (eta > 0.423 && eta < 0.461) || (eta > 0.770 && eta < 0.806) ||
0221 (eta > 1.127 && eta < 1.163) || (eta > 1.460 && eta < 1.558));
0222 }
0223 }
0224
0225 void PFRecoTauDiscriminationAgainstElectron::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0226
0227 edm::ParameterSetDescription desc;
0228 desc.add<bool>("ApplyCut_ElectronPreID_2D", false);
0229 desc.add<double>("ElecPreID0_HOverPLead_minValue", 0.05);
0230 desc.add<edm::InputTag>("PFTauProducer", edm::InputTag("pfRecoTauProducer"));
0231 desc.add<bool>("ApplyCut_ElectronPreID", false);
0232 desc.add<bool>("ApplyCut_HcalTotOverPLead", false);
0233 desc.add<double>("EOverPLead_minValue", 0.8);
0234 desc.add<double>("ElecPreID1_EOverPLead_maxValue", 0.8);
0235 desc.add<double>("HcalMaxOverPLead_minValue", 0.1);
0236 desc.add<double>("BremCombined_HOP", 0.1);
0237 desc.add<bool>("ApplyCut_EmFraction", false);
0238 desc.add<double>("EmFraction_maxValue", 0.9);
0239 desc.add<double>("BremCombined_Mass", 0.55);
0240 desc.add<bool>("ApplyCut_PFElectronMVA", true);
0241 desc.add<double>("PFElectronMVA_maxValue", -0.1);
0242 desc.add<bool>("ApplyCut_HcalMaxOverPLead", false);
0243 {
0244 edm::ParameterSetDescription psd0;
0245 psd0.add<std::string>("BooleanOperator", "and");
0246 {
0247 edm::ParameterSetDescription psd1;
0248 psd1.add<double>("cut");
0249 psd1.add<edm::InputTag>("Producer");
0250 psd0.addOptional<edm::ParameterSetDescription>("leadTrack", psd1);
0251 }
0252 desc.add<edm::ParameterSetDescription>("Prediscriminants", psd0);
0253 }
0254 desc.add<bool>("ApplyCut_BremCombined", false);
0255 desc.add<double>("Hcal3x3OverPLead_minValue", 0.1);
0256 desc.add<double>("ElecPreID1_HOverPLead_minValue", 0.15);
0257 desc.add<double>("ElecPreID0_EOverPLead_maxValue", 0.95);
0258 desc.add<double>("BremsRecoveryEOverPLead_minValue", 0.8);
0259 desc.add<bool>("ApplyCut_EcalCrackCut", false);
0260 desc.add<double>("BremCombined_StripSize", 0.03);
0261 desc.add<double>("EOverPLead_maxValue", 1.8);
0262 desc.add<double>("HcalTotOverPLead_minValue", 0.1);
0263 desc.add<bool>("ApplyCut_BremsRecoveryEOverPLead", false);
0264 desc.add<bool>("ApplyCut_Hcal3x3OverPLead", false);
0265 desc.add<bool>("ApplyCut_EOverPLead", false);
0266 desc.add<double>("BremCombined_Fraction", 0.99);
0267 desc.add<double>("BremsRecoveryEOverPLead_maxValue", 1.8);
0268 descriptions.add("pfRecoTauDiscriminationAgainstElectron", desc);
0269 }
0270
0271 DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstElectron);