CMS 3D CMS Logo

EgHLTOffEleSel.cc

Go to the documentation of this file.
00001 #include "DQMOffline/Trigger/interface/EgHLTOffEleSel.h"
00002 
00003 #include "DQMOffline/Trigger/interface/CutCodes.h"
00004 #include "DQMOffline/Trigger/interface/EleTypeCodes.h"
00005 
00006 EgHLTOffEleSel::EgHLTOffEleSel()
00007 {
00008 
00009 }
00010 
00011 
00012 int EgHLTOffEleSel::getCutCode(const EgHLTOffEle& ele,int cutMask)const
00013 {
00014   const CutValues& cuts = getCuts(ele.classification());
00015   if(&cuts!=NULL) return getCutCode(ele,cuts,cutMask);
00016   else return ~0x0;
00017 }
00018 
00019 
00020 const CutValues& EgHLTOffEleSel::getCuts(int type)const
00021 {
00022   int cutIndex=0;
00023   int nrMatches = 0;
00024   for(unsigned index=0;index<cutValues_.size();index++){
00025     //std::cout <<"valid ele type code "<<std::hex<<cutValues_[index].validEleTypes<<" ele type code "<< EleTypeCodes::makeTypeCode(type) <<" should have code "<<EleTypeCodes::getCode("barrel:golden:narrow:bigBrem:showering")<<std::dec<<" ele type "<<type<<std::endl;
00026     if( (EleTypeCodes::makeTypeCode(type) & cutValues_[index].validEleTypes) == EleTypeCodes::makeTypeCode(type)){
00027       if(nrMatches==0) cutIndex = index;
00028       nrMatches++;
00029     }
00030   }
00031   if(nrMatches>=1){
00032     if(nrMatches>1) std::cout <<"EgHLTOffEleSel::getCuts: Warning have "<<nrMatches<<" for electron type "<<type<<std::endl;
00033     return cutValues_[cutIndex];
00034   }else{
00035     //std::cout <<"EgHLTOffEleSel::getCuts: Warning have "<<nrMatches<<" for electron type "<<type<<std::endl;
00036     CutValues* nullPointer=0; //there has to be a better way, basically I'm in a dire need of a way to return a null object safely when I dont have it and I'm not using exceptions
00037     return *nullPointer;
00038   }
00039 }
00040 
00041 CutValues& EgHLTOffEleSel::getCuts(int type)
00042 {
00043   const EgHLTOffEleSel* constThis = this;
00044   const CutValues& constCuts = constThis->getCuts(type);
00045   CutValues& cuts = *(const_cast<CutValues*>(&constCuts)); //is this evil code? Possibly, but I think its safe as all I'm doing is basically code reuse by using the const function and then casting the returned value to non const as in this case the object is really non-const 
00046   return cuts;
00047 
00048 }
00049 
00050 int EgHLTOffEleSel::getCutCode(const EgHLTOffEle& ele,const CutValues& cuts,int cutMask)
00051 { 
00052   int cutCode = 0x0;
00053   if(ele.et()< cuts.minEtCut) cutCode |= CutCodes::ET;
00054   if(fabs(ele.etaSC())< cuts.minEtaCut || fabs(ele.etaSC())>cuts.maxEtaCut) cutCode |= CutCodes::DETETA;
00055   if(ele.classification()==40 && cuts.rejectCracks) cutCode |= CutCodes::CRACK;
00056   if((ele.epIn()< cuts.minEpInCut || ele.epIn()> cuts.maxEpInCut) &&  ele.etSC()<cuts.epInReleaseEtCut ) cutCode |=CutCodes::EPIN;
00057   if(fabs(ele.dEtaIn()) > cuts.maxDEtaInCut ) cutCode |=CutCodes::DETAIN;
00058   if(fabs(ele.dPhiIn()) > cuts.maxDPhiInCut ) cutCode |=CutCodes::DPHIIN;
00059   if(ele.hOverE()> cuts.maxHademCut) cutCode |= CutCodes::HADEM;
00060   if(ele.epOut()< cuts.minEpOutCut || ele.epOut()>cuts.maxEpOutCut) cutCode |=CutCodes::EPOUT;
00061   if(fabs(ele.dPhiOut()) > cuts.maxDPhiOutCut) cutCode |=CutCodes::DPHIOUT;
00062   if(ele.invEOverInvP() > cuts.maxInvEInvPCut) cutCode |= CutCodes::INVEINVP;
00063   if(ele.bremFrac() < cuts.minBremFracCut) cutCode |= CutCodes::BREMFRAC;
00064   //if(ele.e9OverE25() < cuts.minE9E25Cut) cutCode |= CutCodes::E9OVERE25;
00065   if(ele.sigmaEtaEta()<cuts.minSigmaEtaEtaCut || ele.sigmaEtaEta()>cuts.maxSigmaEtaEtaCut) cutCode |= CutCodes::SIGMAETAETA;
00066   //if(ele.sigmaPhiPhi()<cuts.minSigmaPhiPhiCut || ele.sigmaPhiPhi()>cuts.maxSigmaPhiPhiCut) cutCode |= CutCodes::SIGMAPHIPHI;
00067   if(ele.isolEm()>( cuts.minIsolEmConstCut + cuts.isolEmGradCut*ele.et())) cutCode |=CutCodes::ISOLEM;
00068   if(ele.isolHad()> (cuts.minIsolHadConstCut + cuts.isolHadGradCut*ele.et())) cutCode |=CutCodes::ISOLHAD;
00069   if(ele.isolPtTrks() > (cuts.minIsolPtTrksConstCut + cuts.isolPtTrksGradCut*ele.et())) cutCode |=CutCodes::ISOLPTTRKS;
00070   if(ele.isolNrTrks() > cuts.minIsolNrTrksConstCut) cutCode |=CutCodes::ISOLNRTRKS;
00071 
00072   return (cutCode & cuts.cutMask & cutMask) ;
00073 }
00074 
00075 
00076 void EgHLTOffEleSel::setHighNrgy()
00077 {
00078   clearCuts();
00079  
00080   CutValues ebCuts;
00081   CutValues eeCuts;
00082   ebCuts.setEBHighNrgy(CutCodes::getCode("et:detEta:crack:dEtaIn:dPhiIn:hadem:sigmaEtaEta:isolEm:isolHad:isolPtTrks"));
00083   ebCuts.validEleTypes = EleTypeCodes::getCode("barrel:golden:narrow:bigBrem:showering:crack");
00084   eeCuts.setEEHighNrgy(CutCodes::getCode("et:detEta:crack:dEtaIn:dPhiIn:hadem:sigmaEtaEta:isolEm:isolHad:isolPtTrks"));
00085   eeCuts.validEleTypes = EleTypeCodes::getCode("endcap:golden:narrow:bigBrem:showering:crack");
00086   addCuts(ebCuts);
00087   addCuts(eeCuts);
00088 }  
00089 
00090 
00091 void EgHLTOffEleSel::setPreSel()
00092 {
00093   clearCuts();
00094  
00095   CutValues ebCuts;
00096   CutValues eeCuts;
00097   ebCuts.setEBPreSel(CutCodes::getCode("et:detEta:crack:dEtaIn:dPhiIn:hadem"));
00098   ebCuts.validEleTypes = EleTypeCodes::getCode("barrel:golden:narrow:bigBrem:showering:crack");
00099   eeCuts.setEEPreSel(CutCodes::getCode("et:detEta:crack:dEtaIn:dPhiIn:hadem"));
00100   eeCuts.validEleTypes = EleTypeCodes::getCode("endcap:golden:narrow:bigBrem:showering:crack");
00101   addCuts(ebCuts);
00102   addCuts(eeCuts);
00103 }  
00104 
00105 void EgHLTOffEleSel::setPreSelWithEp()
00106 {
00107   clearCuts();
00108  
00109   CutValues ebCuts;
00110   CutValues eeCuts;
00111   ebCuts.setEBPreSel(CutCodes::getCode("et:detEta:crack:dEtaIn:dPhiIn:hadem:epIn"));
00112   ebCuts.validEleTypes = EleTypeCodes::getCode("barrel:golden:narrow:bigBrem:showering:crack");
00113   eeCuts.setEEPreSel(CutCodes::getCode("et:detEta:crack:dEtaIn:dPhiIn:hadem:epIn"));
00114   eeCuts.validEleTypes = EleTypeCodes::getCode("endcap:golden:narrow:bigBrem:showering:crack");
00115   addCuts(ebCuts);
00116   addCuts(eeCuts);
00117 }
00118 
00119 void EgHLTOffEleSel::setCutMask(int cutMask,int eleType)
00120 {
00121   for(size_t cutValNr=0;cutValNr<cutValues_.size();cutValNr++){
00122     if((eleType&cutValues_[cutValNr].validEleTypes)!=0){
00123       cutValues_[cutValNr].cutMask = cutMask;
00124     }
00125   }
00126    
00127 }
00128 
00129 void EgHLTOffEleSel::removeCuts(int cutCode,int eleType)
00130 {
00131   for(size_t cutValNr=0;cutValNr<cutValues_.size();cutValNr++){
00132     if((eleType&cutValues_[cutValNr].validEleTypes)!=0){
00133       cutValues_[cutValNr].cutMask &= ~cutCode;
00134     }
00135   }
00136 }
00137 
00138 void EgHLTOffEleSel::setMinEt(float minEt,int eleType)
00139 {
00140   for(size_t cutValNr=0;cutValNr<cutValues_.size();cutValNr++){
00141     if((eleType&cutValues_[cutValNr].validEleTypes)!=0){
00142       cutValues_[cutValNr].minEtCut = minEt;
00143     }
00144   }
00145 }
00146   

Generated on Tue Jun 9 17:34:09 2009 for CMSSW by  doxygen 1.5.4