Go to the documentation of this file.00001 #ifndef DQMOFFLINE_TRIGGER_EGHLTTRIGTOOLS
00002 #define DQMOFFLINE_TRIGGER_EGHLTTRIGTOOLS
00003
00004 #include "DQMOffline/Trigger/interface/EgHLTTrigCodes.h"
00005 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
00006 #include "DataFormats/Common/interface/Handle.h"
00007 #include "DataFormats/Math/interface/deltaR.h"
00008
00009 class HLTConfigProvider;
00010
00011 namespace egHLT {
00012
00013 namespace trigTools {
00014 TrigCodes::TrigBitSet getFiltersPassed(const std::vector<std::pair<std::string,int> >& filters,const trigger::TriggerEvent* trigEvt,const std::string& hltTag);
00015 template<class T> void setFiltersObjPasses(std::vector<T>& objs,const std::vector<std::string>& filters,const std::vector<std::pair<std::string,std::string> >& l1PreAndSeedFilters,const TrigCodes::TrigBitSet& evtTrigBits,const trigger::TriggerEvent* trigEvt,const std::string& hltTag );
00016 int getMinNrObjsRequiredByFilter(const std::string& filterName);
00017
00018
00019 void getActiveFilters(const HLTConfigProvider& hltConfig,std::vector<std::string>& activeFilters,std::vector<std::string>& activeEleFilters,std::vector<std::string>& activeEle2LegFilters,std::vector<std::string>& activePhoFilters,std::vector<std::string>& activePho2LegFilters);
00020
00021
00022
00023
00024 void filterInactiveTriggers(std::vector<std::string>& namesToFilter,std::vector<std::string>& activeFilters);
00025
00026 void filterInactiveTightLooseTriggers(std::vector<std::string>& namesToFilter,const std::vector<std::string>& activeFilters);
00027
00028 void translateFiltersToPathNames(const HLTConfigProvider& hltConfig,const std::vector<std::string>& filters,std::vector<std::string>& paths);
00029 std::string getL1SeedFilterOfPath(const HLTConfigProvider& hltConfig,const std::string& path);
00030
00031
00032
00033 float getEtThresFromName(const std::string& trigName);
00034 float getSecondEtThresFromName(const std::string& trigName);
00035 }
00036
00037
00038
00039
00040
00041
00042
00043 template <class T>
00044 void trigTools::setFiltersObjPasses(std::vector<T>& particles,const std::vector<std::string>& filters,
00045 const std::vector<std::pair<std::string,std::string> >& l1PreAndSeedFilters,
00046 const TrigCodes::TrigBitSet& evtTrigBits,
00047 const trigger::TriggerEvent* trigEvt,const std::string& hltTag)
00048 {
00049 std::vector<TrigCodes::TrigBitSet> partTrigBits(particles.size());
00050 const double maxDeltaR=0.1;
00051 for(size_t filterNrInVec=0;filterNrInVec<filters.size();filterNrInVec++){
00052 size_t filterNrInEvt = trigEvt->filterIndex(edm::InputTag(filters[filterNrInVec],"",hltTag).encode());
00053 const TrigCodes::TrigBitSet filterCode = TrigCodes::getCode(filters[filterNrInVec].c_str());
00054
00055 if(filterNrInEvt<trigEvt->sizeFilters()){
00056 const trigger::Keys& trigKeys = trigEvt->filterKeys(filterNrInEvt);
00057 const trigger::TriggerObjectCollection & trigObjColl(trigEvt->getObjects());
00058 for(size_t partNr=0;partNr<particles.size();partNr++){
00059 for(trigger::Keys::const_iterator keyIt=trigKeys.begin();keyIt!=trigKeys.end();++keyIt){
00060 float trigObjEta = trigObjColl[*keyIt].eta();
00061 float trigObjPhi = trigObjColl[*keyIt].phi();
00062 if (reco::deltaR(particles[partNr].eta(),particles[partNr].phi(),trigObjEta,trigObjPhi) < maxDeltaR){
00063 partTrigBits[partNr] |= filterCode;
00064 }
00065 }
00066 }
00067 }
00068 }
00069
00070
00071 for(size_t l1FilterNrInVec=0;l1FilterNrInVec<l1PreAndSeedFilters.size();l1FilterNrInVec++){
00072 const TrigCodes::TrigBitSet filterCode = TrigCodes::getCode(l1PreAndSeedFilters[l1FilterNrInVec].first.c_str());
00073 if((filterCode&evtTrigBits)==filterCode){
00074
00075 size_t filterNrInEvt = trigEvt->filterIndex(edm::InputTag(l1PreAndSeedFilters[l1FilterNrInVec].second,"",hltTag).encode());
00076
00077 if(filterNrInEvt<trigEvt->sizeFilters()){
00078 const trigger::Keys& trigKeys = trigEvt->filterKeys(filterNrInEvt);
00079 const trigger::TriggerObjectCollection & trigObjColl(trigEvt->getObjects());
00080 for(size_t partNr=0;partNr<particles.size();partNr++){
00081 for(trigger::Keys::const_iterator keyIt=trigKeys.begin();keyIt!=trigKeys.end();++keyIt){
00082 float trigObjEta = trigObjColl[*keyIt].eta();
00083 float trigObjPhi = trigObjColl[*keyIt].phi();
00084 if (reco::deltaR(particles[partNr].eta(),particles[partNr].phi(),trigObjEta,trigObjPhi) < maxDeltaR){
00085 partTrigBits[partNr] |= filterCode;
00086 }
00087 }
00088 }
00089 }
00090 }
00091 }
00092
00093 for(size_t partNr=0;partNr<particles.size();partNr++) particles[partNr].setTrigBits(partTrigBits[partNr]);
00094
00095 }
00096 }
00097 #endif
00098