CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/DQMOffline/Trigger/src/EgHLTOffEgSel.cc

Go to the documentation of this file.
00001 #include "DQMOffline/Trigger/interface/EgHLTOffEgSel.h"
00002 
00003 #include "DQMOffline/Trigger/interface/EgHLTEgCutCodes.h"
00004 #include "DQMOffline/Trigger/interface/EgHLTOffEle.h"
00005 #include "DQMOffline/Trigger/interface/EgHLTOffPho.h"
00006 
00007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00008 
00009 using namespace egHLT;
00010 
00011 void OffEgSel::setup(const edm::ParameterSet& iConfig)
00012 { 
00013   ebCutValues_.setup(iConfig.getParameter<edm::ParameterSet>("barrel"));
00014   eeCutValues_.setup(iConfig.getParameter<edm::ParameterSet>("endcap"));
00015 }
00016 
00017 
00018 int OffEgSel::getCutCode(const OffEle& ele,int cutMask)const
00019 {
00020   if(fabs(ele.detEta())<1.5) return getCutCode(ele,ebCutValues_,cutMask);
00021   else return getCutCode(ele,eeCutValues_,cutMask);
00022 }
00023 
00024 int OffEgSel::getCutCode(const OffEle& ele,const EgCutValues& cuts,int cutMask)
00025 { 
00026   int cutCode = 0x0;
00027   //kinematic cuts
00028   if(ele.et() < cuts.minEt) cutCode |= EgCutCodes::ET;
00029   if(fabs(ele.etaSC()) < cuts.minEta || fabs(ele.etaSC()) > cuts.maxEta) cutCode |= EgCutCodes::DETETA;
00030   if(ele.isGap()) cutCode |= EgCutCodes::CRACK;
00031   //track cuts
00032   if(fabs(ele.dEtaIn()) > cuts.maxDEtaIn ) cutCode |=EgCutCodes::DETAIN;
00033   if(fabs(ele.dPhiIn()) > cuts.maxDPhiIn ) cutCode |=EgCutCodes::DPHIIN;
00034   if(ele.invEInvP() > cuts.maxInvEInvP) cutCode |= EgCutCodes::INVEINVP;
00035   //supercluster cuts
00036   if(ele.hOverE() > cuts.maxHadem && ele.hOverE()*ele.caloEnergy() > cuts.maxHadEnergy) cutCode |= EgCutCodes::HADEM;
00037   if(ele.sigmaIEtaIEta() > cuts.maxSigmaIEtaIEta) cutCode |= EgCutCodes::SIGMAIETAIETA;
00038   if(ele.sigmaEtaEta() > cuts.maxSigmaEtaEta) cutCode |= EgCutCodes::SIGMAETAETA;
00039   //---Morse-------
00040   //if(ele.r9()<cuts.minR9) cutCode |= EgCutCodes::R9;
00041   if(ele.r9() < cuts.minR9) cutCode |= EgCutCodes::MINR9;
00042   if(ele.r9() > cuts.maxR9) cutCode |= EgCutCodes::MAXR9;
00043   //----------------
00044   
00045   //std isolation cuts
00046   if(ele.isolEm()>( cuts.isolEmConstTerm + cuts.isolEmGradTerm*(ele.et()<cuts.isolEmGradStart ? 0. : (ele.et()-cuts.isolEmGradStart)))) cutCode |=EgCutCodes::ISOLEM;
00047   if(ele.isolHad()> (cuts.isolHadConstTerm + cuts.isolHadGradTerm*(ele.et()<cuts.isolHadGradStart ? 0. : (ele.et()-cuts.isolHadGradStart)))) cutCode |=EgCutCodes::ISOLHAD;
00048   if(ele.isolPtTrks() > (cuts.isolPtTrksConstTerm + cuts.isolPtTrksGradTerm*(ele.et()<cuts.isolPtTrksGradStart ? 0. : (ele.et()-cuts.isolPtTrksGradStart))))cutCode |=EgCutCodes::ISOLPTTRKS; 
00049   //ele Nr trks not defined, assume it passes
00050   //hlt isolation cuts
00051   if(ele.et()<=0.){//even it if et<=0, we give it a shot at passing isolation. Note this should be an impossible case
00052     if(ele.hltIsolTrksEle() > cuts.maxHLTIsolTrksEle) cutCode |=EgCutCodes::HLTISOLTRKSELE;
00053     if(ele.hltIsolTrksPho() > cuts.maxHLTIsolTrksPho) cutCode |=EgCutCodes::HLTISOLTRKSPHO;
00054     if(ele.hltIsolHad() > cuts.maxHLTIsolHad) cutCode |=EgCutCodes::HLTISOLHAD;
00055     if(ele.hltIsolEm() > cuts.maxHLTIsolEm) cutCode |=EgCutCodes::HLTISOLEM;
00056   }else{ 
00057     if(ele.hltIsolTrksEle() > cuts.maxHLTIsolTrksEle && ele.hltIsolTrksEle()/ele.et() > cuts.maxHLTIsolTrksEleOverPt &&
00058        ele.hltIsolTrksEle()/ele.et()/ele.et() > cuts.maxHLTIsolTrksEleOverPt2 ) cutCode |=EgCutCodes::HLTISOLTRKSELE;
00059     if(ele.hltIsolTrksPho() > cuts.maxHLTIsolTrksPho && ele.hltIsolTrksPho()/ele.et() > cuts.maxHLTIsolTrksPhoOverPt &&
00060        ele.hltIsolTrksPho()/ele.et()/ele.et() > cuts.maxHLTIsolTrksPhoOverPt2 ) cutCode |=EgCutCodes::HLTISOLTRKSPHO;
00061     if(ele.hltIsolHad() > cuts.maxHLTIsolHad && ele.hltIsolHad()/ele.et() > cuts.maxHLTIsolHadOverEt &&
00062        ele.hltIsolHad()/ele.et()/ele.et() > cuts.maxHLTIsolHadOverEt2) cutCode |=EgCutCodes::HLTISOLHAD;
00063     if(ele.hltIsolEm() > cuts.maxHLTIsolEm && ele.hltIsolEm()/ele.et() > cuts.maxHLTIsolEmOverEt &&
00064        ele.hltIsolEm()/ele.et()/ele.et() > cuts.maxHLTIsolEmOverEt2) cutCode |=EgCutCodes::HLTISOLEM;
00065   }
00066  
00067  
00068   //cuts on CTF track, HLT tracking doesnt handle poor quaility tracks
00069   if(ele.validCTFTrack()){
00070     if(!(ele.ctfTrkOuterRadius() >= cuts.minCTFTrkOuterRadius && //note I'm NOTing the result of the AND
00071          ele.ctfTrkInnerRadius() <= cuts.maxCTFTrkInnerRadius &&
00072          
00073          ele.ctfTrkHitsFound() >= cuts.minNrCTFTrkHits && 
00074          ele.ctfTrkHitsLost() <= cuts.maxNrCTFTrkHitsLost)) cutCode |=EgCutCodes::CTFTRACK; //the next line can also set this bit
00075     if(cuts.requirePixelHitsIfOuterInOuter){
00076       DetId innerDetId(ele.ctfTrack()->extra()->innerDetId());
00077       DetId outerDetId(ele.ctfTrack()->extra()->outerDetId());
00078     
00079       if(outerDetId.subdetId()>=5 && innerDetId.subdetId()>=3) cutCode |=EgCutCodes::CTFTRACK; //1,2 = pixel, 3,4,5,6 sistrip
00080     }
00081     // std::cout <<"eta "<<ele.detEta()<<" max inner "<<cuts.maxCTFTrkInnerRadius<<" inner "<<ele.ctfTrkInnerRadius()<<std::endl;
00082   }else cutCode |=EgCutCodes::CTFTRACK;
00083 
00084   if(fabs(ele.hltDEtaIn()) > cuts.maxHLTDEtaIn) cutCode |=EgCutCodes::HLTDETAIN;
00085   if(fabs(ele.hltDPhiIn()) > cuts.maxHLTDPhiIn) cutCode |=EgCutCodes::HLTDPHIIN;
00086   if(fabs(ele.hltInvEInvP()) > cuts.maxHLTInvEInvP) cutCode |=EgCutCodes::HLTINVEINVP;
00087 
00088   return (cutCode & cuts.cutMask & cutMask);
00089 }
00090 
00091 int OffEgSel::getCutCode(const OffPho& pho,int cutMask)const
00092 {
00093   if(fabs(pho.detEta())<1.5) return getCutCode(pho,ebCutValues_,cutMask);
00094   else return getCutCode(pho,eeCutValues_,cutMask);
00095 }
00096 
00097 //photons automatically fail any track cut
00098 int OffEgSel::getCutCode(const OffPho& pho,const EgCutValues& cuts,int cutMask)
00099 { 
00100   int cutCode = 0x0;
00101   //kinematic cuts
00102   if(pho.et()< cuts.minEt) cutCode |= EgCutCodes::ET;
00103   if(fabs(pho.etaSC())< cuts.minEta || fabs(pho.etaSC())>cuts.maxEta) cutCode |= EgCutCodes::DETETA;
00104   if(pho.isGap()) cutCode |= EgCutCodes::CRACK;
00105   //track cuts (all fail)
00106   cutCode |=EgCutCodes::DETAIN;
00107   cutCode |=EgCutCodes::DPHIIN;
00108   cutCode |=EgCutCodes::INVEINVP;
00109   //supercluster cuts
00110   if(pho.hOverE()> cuts.maxHadem && pho.hOverE()*pho.energy()>cuts.maxHadEnergy) cutCode |= EgCutCodes::HADEM;
00111   if(pho.sigmaIEtaIEta()>cuts.maxSigmaIEtaIEta) cutCode |= EgCutCodes::SIGMAIETAIETA; 
00112   if(pho.sigmaEtaEta()>cuts.maxSigmaEtaEta) cutCode |= EgCutCodes::SIGMAETAETA; 
00113   //----Morse--------
00114   //if(pho.r9()<cuts.minR9) cutCode |= EgCutCodes::R9;
00115   if(pho.r9()<cuts.minR9) cutCode |= EgCutCodes::MINR9;
00116   if(pho.r9()>cuts.maxR9) cutCode |= EgCutCodes::MAXR9;
00117   //----------------
00118   //std isolation cuts
00119   if(pho.isolEm()>( cuts.isolEmConstTerm + cuts.isolEmGradTerm*(pho.et()<cuts.isolEmGradStart ? 0. : (pho.et()-cuts.isolEmGradStart)))) cutCode |=EgCutCodes::ISOLEM;
00120   if(pho.isolHad()> (cuts.isolHadConstTerm + cuts.isolHadGradTerm*(pho.et()<cuts.isolHadGradStart ? 0. : (pho.et()-cuts.isolHadGradStart)))) cutCode |=EgCutCodes::ISOLHAD;
00121   if(pho.isolPtTrks() > (cuts.isolPtTrksConstTerm + cuts.isolPtTrksGradTerm*(pho.et()<cuts.isolPtTrksGradStart ? 0. : (pho.et()-cuts.isolPtTrksGradStart))))cutCode |=EgCutCodes::ISOLPTTRKS;
00122   if(pho.isolNrTrks() > cuts.isolNrTrksConstTerm) cutCode |=EgCutCodes::ISOLNRTRKS;
00123 
00124   //hlt isolation cuts
00125   cutCode |=EgCutCodes::HLTISOLTRKSELE; //automatically fails ele track isolation
00126   if(pho.et()<=0.){ //even it if et<=0, we give it a shot at passing isolation. Note this should be an impossible case
00127     if(pho.hltIsolTrks() > cuts.maxHLTIsolTrksPho) cutCode |=EgCutCodes::HLTISOLTRKSPHO;
00128     if(pho.hltIsolHad() > cuts.maxHLTIsolHad) cutCode |=EgCutCodes::HLTISOLHAD;
00129     if(pho.hltIsolEm() > cuts.maxHLTIsolEm) cutCode |=EgCutCodes::HLTISOLEM;
00130   }else{ 
00131     if(pho.hltIsolTrks() > cuts.maxHLTIsolTrksPho && pho.hltIsolTrks()/pho.et() > cuts.maxHLTIsolTrksPhoOverPt &&
00132        pho.hltIsolTrks()/pho.et()/pho.et() > cuts.maxHLTIsolTrksPhoOverPt2 ) cutCode |=EgCutCodes::HLTISOLTRKSPHO;
00133     if(pho.hltIsolHad() > cuts.maxHLTIsolHad && pho.hltIsolHad()/pho.et() > cuts.maxHLTIsolHadOverEt &&
00134        pho.hltIsolHad()/pho.et()/pho.et() > cuts.maxHLTIsolHadOverEt2) cutCode |=EgCutCodes::HLTISOLHAD;
00135     if(pho.hltIsolEm() > cuts.maxHLTIsolEm && pho.hltIsolEm()/pho.et() > cuts.maxHLTIsolEmOverEt &&
00136        pho.hltIsolEm()/pho.et()/pho.et() > cuts.maxHLTIsolEmOverEt2) cutCode |=EgCutCodes::HLTISOLEM;
00137   }
00138 
00139   //track cuts, photon will automatically fail them (for now)
00140   cutCode |=EgCutCodes::CTFTRACK;
00141   cutCode |=EgCutCodes::HLTDETAIN;
00142   cutCode |=EgCutCodes::HLTDPHIIN;
00143   cutCode |=EgCutCodes::HLTINVEINVP;
00144   
00145   return (cutCode & cuts.cutMask & cutMask) ;
00146 }