Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:13:38

0001 #include <cmath>
0002 
0003 #include "DQMOffline/Trigger/interface/EgHLTOffEgSel.h"
0004 
0005 #include "DQMOffline/Trigger/interface/EgHLTEgCutCodes.h"
0006 #include "DQMOffline/Trigger/interface/EgHLTOffEle.h"
0007 #include "DQMOffline/Trigger/interface/EgHLTOffPho.h"
0008 
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 
0011 using namespace egHLT;
0012 
0013 void OffEgSel::setup(const edm::ParameterSet& iConfig) {
0014   ebCutValues_.setup(iConfig.getParameter<edm::ParameterSet>("barrel"));
0015   eeCutValues_.setup(iConfig.getParameter<edm::ParameterSet>("endcap"));
0016 }
0017 
0018 int OffEgSel::getCutCode(const OffEle& ele, int cutMask) const {
0019   if (std::fabs(ele.detEta()) < 1.5)
0020     return getCutCode(ele, ebCutValues_, cutMask);
0021   else
0022     return getCutCode(ele, eeCutValues_, cutMask);
0023 }
0024 
0025 int OffEgSel::getCutCode(const OffEle& ele, const EgCutValues& cuts, int cutMask) {
0026   int cutCode = 0x0;
0027   //kinematic cuts
0028   if (ele.et() < cuts.minEt)
0029     cutCode |= EgCutCodes::ET;
0030   if (std::fabs(ele.etaSC()) < cuts.minEta || std::fabs(ele.etaSC()) > cuts.maxEta)
0031     cutCode |= EgCutCodes::DETETA;
0032   if (ele.isGap())
0033     cutCode |= EgCutCodes::CRACK;
0034   //track cuts
0035   if (std::fabs(ele.dEtaIn()) > cuts.maxDEtaIn)
0036     cutCode |= EgCutCodes::DETAIN;
0037   if (std::fabs(ele.dPhiIn()) > cuts.maxDPhiIn)
0038     cutCode |= EgCutCodes::DPHIIN;
0039   if (ele.invEInvP() > cuts.maxInvEInvP)
0040     cutCode |= EgCutCodes::INVEINVP;
0041   //supercluster cuts
0042   if (ele.hOverE() > cuts.maxHadem && ele.hOverE() * ele.caloEnergy() > cuts.maxHadEnergy)
0043     cutCode |= EgCutCodes::HADEM;
0044   if (ele.sigmaIEtaIEta() > cuts.maxSigmaIEtaIEta)
0045     cutCode |= EgCutCodes::SIGMAIETAIETA;
0046   if (ele.sigmaEtaEta() > cuts.maxSigmaEtaEta)
0047     cutCode |= EgCutCodes::SIGMAETAETA;
0048   //---Morse-------
0049   //if(ele.r9()<cuts.minR9) cutCode |= EgCutCodes::R9;
0050   if (ele.r9() < cuts.minR9)
0051     cutCode |= EgCutCodes::MINR9;
0052   if (ele.r9() > cuts.maxR9)
0053     cutCode |= EgCutCodes::MAXR9;
0054   //----------------
0055 
0056   //std isolation cuts
0057   if (ele.isolEm() > (cuts.isolEmConstTerm +
0058                       cuts.isolEmGradTerm * (ele.et() < cuts.isolEmGradStart ? 0. : (ele.et() - cuts.isolEmGradStart))))
0059     cutCode |= EgCutCodes::ISOLEM;
0060   if (ele.isolHad() >
0061       (cuts.isolHadConstTerm +
0062        cuts.isolHadGradTerm * (ele.et() < cuts.isolHadGradStart ? 0. : (ele.et() - cuts.isolHadGradStart))))
0063     cutCode |= EgCutCodes::ISOLHAD;
0064   if (ele.isolPtTrks() >
0065       (cuts.isolPtTrksConstTerm +
0066        cuts.isolPtTrksGradTerm * (ele.et() < cuts.isolPtTrksGradStart ? 0. : (ele.et() - cuts.isolPtTrksGradStart))))
0067     cutCode |= EgCutCodes::ISOLPTTRKS;
0068   //ele Nr trks not defined, assume it passes
0069   //hlt isolation cuts
0070   if (ele.et() <=
0071       0.) {  //even it if et<=0, we give it a shot at passing isolation. Note this should be an impossible case
0072     if (ele.hltIsolTrksEle() > cuts.maxHLTIsolTrksEle)
0073       cutCode |= EgCutCodes::HLTISOLTRKSELE;
0074     if (ele.hltIsolTrksPho() > cuts.maxHLTIsolTrksPho)
0075       cutCode |= EgCutCodes::HLTISOLTRKSPHO;
0076     if (ele.hltIsolHad() > cuts.maxHLTIsolHad)
0077       cutCode |= EgCutCodes::HLTISOLHAD;
0078     if (ele.hltIsolEm() > cuts.maxHLTIsolEm)
0079       cutCode |= EgCutCodes::HLTISOLEM;
0080   } else {
0081     if (ele.hltIsolTrksEle() > cuts.maxHLTIsolTrksEle &&
0082         ele.hltIsolTrksEle() / ele.et() > cuts.maxHLTIsolTrksEleOverPt &&
0083         ele.hltIsolTrksEle() / ele.et() / ele.et() > cuts.maxHLTIsolTrksEleOverPt2)
0084       cutCode |= EgCutCodes::HLTISOLTRKSELE;
0085     if (ele.hltIsolTrksPho() > cuts.maxHLTIsolTrksPho &&
0086         ele.hltIsolTrksPho() / ele.et() > cuts.maxHLTIsolTrksPhoOverPt &&
0087         ele.hltIsolTrksPho() / ele.et() / ele.et() > cuts.maxHLTIsolTrksPhoOverPt2)
0088       cutCode |= EgCutCodes::HLTISOLTRKSPHO;
0089     if (ele.hltIsolHad() > cuts.maxHLTIsolHad && ele.hltIsolHad() / ele.et() > cuts.maxHLTIsolHadOverEt &&
0090         ele.hltIsolHad() / ele.et() / ele.et() > cuts.maxHLTIsolHadOverEt2)
0091       cutCode |= EgCutCodes::HLTISOLHAD;
0092     if (ele.hltIsolEm() > cuts.maxHLTIsolEm && ele.hltIsolEm() / ele.et() > cuts.maxHLTIsolEmOverEt &&
0093         ele.hltIsolEm() / ele.et() / ele.et() > cuts.maxHLTIsolEmOverEt2)
0094       cutCode |= EgCutCodes::HLTISOLEM;
0095   }
0096 
0097   //cuts on CTF track, HLT tracking doesnt handle poor quaility tracks
0098   if (ele.validCTFTrack()) {
0099     if (!(ele.ctfTrkOuterRadius() >= cuts.minCTFTrkOuterRadius &&  //note I'm NOTing the result of the AND
0100           ele.ctfTrkInnerRadius() <= cuts.maxCTFTrkInnerRadius &&
0101 
0102           ele.ctfTrkHitsFound() >= cuts.minNrCTFTrkHits && ele.ctfTrkHitsLost() <= cuts.maxNrCTFTrkHitsLost))
0103       cutCode |= EgCutCodes::CTFTRACK;  //the next line can also set this bit
0104     if (cuts.requirePixelHitsIfOuterInOuter) {
0105       DetId innerDetId(ele.ctfTrack()->extra()->innerDetId());
0106       DetId outerDetId(ele.ctfTrack()->extra()->outerDetId());
0107 
0108       if (outerDetId.subdetId() >= 5 && innerDetId.subdetId() >= 3)
0109         cutCode |= EgCutCodes::CTFTRACK;  //1,2 = pixel, 3,4,5,6 sistrip
0110     }
0111     // std::cout <<"eta "<<ele.detEta()<<" max inner "<<cuts.maxCTFTrkInnerRadius<<" inner "<<ele.ctfTrkInnerRadius()<<std::endl;
0112   } else
0113     cutCode |= EgCutCodes::CTFTRACK;
0114 
0115   if (std::fabs(ele.hltDEtaIn()) > cuts.maxHLTDEtaIn)
0116     cutCode |= EgCutCodes::HLTDETAIN;
0117   if (std::fabs(ele.hltDPhiIn()) > cuts.maxHLTDPhiIn)
0118     cutCode |= EgCutCodes::HLTDPHIIN;
0119   if (std::fabs(ele.hltInvEInvP()) > cuts.maxHLTInvEInvP)
0120     cutCode |= EgCutCodes::HLTINVEINVP;
0121 
0122   return (cutCode & cuts.cutMask & cutMask);
0123 }
0124 
0125 int OffEgSel::getCutCode(const OffPho& pho, int cutMask) const {
0126   if (std::fabs(pho.detEta()) < 1.5)
0127     return getCutCode(pho, ebCutValues_, cutMask);
0128   else
0129     return getCutCode(pho, eeCutValues_, cutMask);
0130 }
0131 
0132 //photons automatically fail any track cut
0133 int OffEgSel::getCutCode(const OffPho& pho, const EgCutValues& cuts, int cutMask) {
0134   int cutCode = 0x0;
0135   //kinematic cuts
0136   if (pho.et() < cuts.minEt)
0137     cutCode |= EgCutCodes::ET;
0138   if (std::fabs(pho.etaSC()) < cuts.minEta || std::fabs(pho.etaSC()) > cuts.maxEta)
0139     cutCode |= EgCutCodes::DETETA;
0140   if (pho.isGap())
0141     cutCode |= EgCutCodes::CRACK;
0142   //track cuts (all fail)
0143   cutCode |= EgCutCodes::DETAIN;
0144   cutCode |= EgCutCodes::DPHIIN;
0145   cutCode |= EgCutCodes::INVEINVP;
0146   //supercluster cuts
0147   if (pho.hOverE() > cuts.maxHadem && pho.hOverE() * pho.energy() > cuts.maxHadEnergy)
0148     cutCode |= EgCutCodes::HADEM;
0149   if (pho.sigmaIEtaIEta() > cuts.maxSigmaIEtaIEta)
0150     cutCode |= EgCutCodes::SIGMAIETAIETA;
0151   if (pho.sigmaEtaEta() > cuts.maxSigmaEtaEta)
0152     cutCode |= EgCutCodes::SIGMAETAETA;
0153   //----Morse--------
0154   //if(pho.r9()<cuts.minR9) cutCode |= EgCutCodes::R9;
0155   if (pho.r9() < cuts.minR9)
0156     cutCode |= EgCutCodes::MINR9;
0157   if (pho.r9() > cuts.maxR9)
0158     cutCode |= EgCutCodes::MAXR9;
0159   //----------------
0160   //std isolation cuts
0161   if (pho.isolEm() > (cuts.isolEmConstTerm +
0162                       cuts.isolEmGradTerm * (pho.et() < cuts.isolEmGradStart ? 0. : (pho.et() - cuts.isolEmGradStart))))
0163     cutCode |= EgCutCodes::ISOLEM;
0164   if (pho.isolHad() >
0165       (cuts.isolHadConstTerm +
0166        cuts.isolHadGradTerm * (pho.et() < cuts.isolHadGradStart ? 0. : (pho.et() - cuts.isolHadGradStart))))
0167     cutCode |= EgCutCodes::ISOLHAD;
0168   if (pho.isolPtTrks() >
0169       (cuts.isolPtTrksConstTerm +
0170        cuts.isolPtTrksGradTerm * (pho.et() < cuts.isolPtTrksGradStart ? 0. : (pho.et() - cuts.isolPtTrksGradStart))))
0171     cutCode |= EgCutCodes::ISOLPTTRKS;
0172   if (pho.isolNrTrks() > cuts.isolNrTrksConstTerm)
0173     cutCode |= EgCutCodes::ISOLNRTRKS;
0174 
0175   //hlt isolation cuts
0176   cutCode |= EgCutCodes::HLTISOLTRKSELE;  //automatically fails ele track isolation
0177   if (pho.et() <=
0178       0.) {  //even it if et<=0, we give it a shot at passing isolation. Note this should be an impossible case
0179     if (pho.hltIsolTrks() > cuts.maxHLTIsolTrksPho)
0180       cutCode |= EgCutCodes::HLTISOLTRKSPHO;
0181     if (pho.hltIsolHad() > cuts.maxHLTIsolHad)
0182       cutCode |= EgCutCodes::HLTISOLHAD;
0183     if (pho.hltIsolEm() > cuts.maxHLTIsolEm)
0184       cutCode |= EgCutCodes::HLTISOLEM;
0185   } else {
0186     if (pho.hltIsolTrks() > cuts.maxHLTIsolTrksPho && pho.hltIsolTrks() / pho.et() > cuts.maxHLTIsolTrksPhoOverPt &&
0187         pho.hltIsolTrks() / pho.et() / pho.et() > cuts.maxHLTIsolTrksPhoOverPt2)
0188       cutCode |= EgCutCodes::HLTISOLTRKSPHO;
0189     if (pho.hltIsolHad() > cuts.maxHLTIsolHad && pho.hltIsolHad() / pho.et() > cuts.maxHLTIsolHadOverEt &&
0190         pho.hltIsolHad() / pho.et() / pho.et() > cuts.maxHLTIsolHadOverEt2)
0191       cutCode |= EgCutCodes::HLTISOLHAD;
0192     if (pho.hltIsolEm() > cuts.maxHLTIsolEm && pho.hltIsolEm() / pho.et() > cuts.maxHLTIsolEmOverEt &&
0193         pho.hltIsolEm() / pho.et() / pho.et() > cuts.maxHLTIsolEmOverEt2)
0194       cutCode |= EgCutCodes::HLTISOLEM;
0195   }
0196 
0197   //track cuts, photon will automatically fail them (for now)
0198   cutCode |= EgCutCodes::CTFTRACK;
0199   cutCode |= EgCutCodes::HLTDETAIN;
0200   cutCode |= EgCutCodes::HLTDPHIIN;
0201   cutCode |= EgCutCodes::HLTINVEINVP;
0202 
0203   return (cutCode & cuts.cutMask & cutMask);
0204 }