diff --git a/DQMOffline/Trigger/interface/HLTDQMFilterTnPEffHists.h b/DQMOffline/Trigger/interface/HLTDQMFilterTnPEffHists.h index a213da589d007..ecc8698690950 100644 --- a/DQMOffline/Trigger/interface/HLTDQMFilterTnPEffHists.h +++ b/DQMOffline/Trigger/interface/HLTDQMFilterTnPEffHists.h @@ -24,7 +24,7 @@ #include -template +template class HLTDQMFilterTnPEffHists { public: HLTDQMFilterTnPEffHists(const edm::ParameterSet& config, @@ -35,18 +35,18 @@ class HLTDQMFilterTnPEffHists { hltProcess_(hltProcess){} static edm::ParameterSetDescription makePSetDescription(){ - edm::ParameterSetDescription desc = HLTDQMFilterEffHists::makePSetDescription(); + edm::ParameterSetDescription desc = HLTDQMFilterEffHists::makePSetDescription(); desc.add("tagExtraFilter",""); return desc; } static edm::ParameterSetDescription makePSetDescriptionHistConfigs(){ - return HLTDQMFilterEffHists::makePSetDescriptionHistConfigs(); + return HLTDQMFilterEffHists::makePSetDescriptionHistConfigs(); } void bookHists(DQMStore::IBooker& iBooker,const std::vector& histConfigs){ histColl_.bookHists(iBooker,histConfigs); } - void fillHists(const ObjType& tag,const ObjType& probe, + void fillHists(const TagType& tag,const ProbeType& probe, const edm::Event& event,const edm::EventSetup& setup, const trigger::TriggerEvent& trigEvt){ if(tagExtraFilter_.empty() || hltdqm::passTrig(tag.eta(),tag.phi(),trigEvt,tagExtraFilter_,hltProcess_)){ @@ -54,7 +54,8 @@ class HLTDQMFilterTnPEffHists { } } private: - HLTDQMFilterEffHists histColl_; + //these hists take the probe as input hence they are of ProbeType + HLTDQMFilterEffHists histColl_; std::string tagExtraFilter_; //really wondering whether to put an accessor to HLTDQMFilterEffHists for this //feels ineligant though so I made another copy here diff --git a/DQMOffline/Trigger/interface/HLTDQMTagAndProbeEff.h b/DQMOffline/Trigger/interface/HLTDQMTagAndProbeEff.h index eedd72d0dd268..da29686476f77 100644 --- a/DQMOffline/Trigger/interface/HLTDQMTagAndProbeEff.h +++ b/DQMOffline/Trigger/interface/HLTDQMTagAndProbeEff.h @@ -35,8 +35,9 @@ #include "DataFormats/Common/interface/ValueMap.h" #include "DataFormats/Common/interface/Handle.h" -#include "DataFormats/HLTReco/interface/TriggerEvent.h" #include "DataFormats/Common/interface/Ref.h" +#include "DataFormats/HLTReco/interface/TriggerEvent.h" +#include "DataFormats/Math/interface/deltaR.h" #include "DQMOffline/Trigger/interface/UtilFuncs.h" #include "DQMOffline/Trigger/interface/VarRangeCutColl.h" @@ -55,7 +56,7 @@ namespace{ } } -template +template class HLTDQMTagAndProbeEff { public: @@ -68,6 +69,7 @@ class HLTDQMTagAndProbeEff { void fill(const edm::Event& event,const edm::EventSetup& setup); private: + template std::vector > getPassingRefs(const edm::Handle& objCollHandle, const trigger::TriggerEvent& trigEvt, @@ -76,7 +78,8 @@ class HLTDQMTagAndProbeEff { const edm::Handle >& vidHandle, const VarRangeCutColl& rangeCuts); private: - edm::EDGetTokenT objToken_; + edm::EDGetTokenT tagToken_; + edm::EDGetTokenT probeToken_; edm::EDGetTokenT trigEvtToken_; edm::EDGetTokenT >tagVIDToken_; edm::EDGetTokenT >probeVIDToken_; @@ -87,32 +90,34 @@ class HLTDQMTagAndProbeEff { std::vector tagFilters_; bool tagFiltersORed_;//true=ORed, false=ANDed - VarRangeCutColl tagRangeCuts_; + VarRangeCutColl tagRangeCuts_; std::vector probeFilters_; bool probeFiltersORed_;//true=ORed, false=ANDed - VarRangeCutColl probeRangeCuts_; + VarRangeCutColl probeRangeCuts_; + float minTagProbeDR2_; float minMass_; float maxMass_; bool requireOpSign_; std::vector histConfigs_; - std::vector > filterHists_; + std::vector > filterHists_; GenericTriggerEventFlag sampleTrigRequirements_; }; -template -HLTDQMTagAndProbeEff::HLTDQMTagAndProbeEff(const edm::ParameterSet& pset,edm::ConsumesCollector && cc): +template +HLTDQMTagAndProbeEff::HLTDQMTagAndProbeEff(const edm::ParameterSet& pset,edm::ConsumesCollector && cc): tagRangeCuts_(pset.getParameter >("tagRangeCuts")), probeRangeCuts_(pset.getParameter >("probeRangeCuts")), sampleTrigRequirements_(pset.getParameter("sampleTrigRequirements"),cc) { edm::InputTag trigEvtTag = pset.getParameter("trigEvent"); - objToken_ = cc.consumes(pset.getParameter("objColl")); + tagToken_ = cc.consumes(pset.getParameter("tagColl")); + probeToken_ = cc.consumes(pset.getParameter("probeColl")); trigEvtToken_ = cc.consumes(trigEvtTag); tagVIDToken_ = cc.consumes >(pset.getParameter("tagVIDCuts")); probeVIDToken_ = cc.consumes >(pset.getParameter("probeVIDCuts")); @@ -124,7 +129,8 @@ HLTDQMTagAndProbeEff::HLTDQMTagAndProbeEff(const edm::Param probeFilters_ = pset.getParameter >("probeFilters"); probeFiltersORed_ = pset.getParameter("tagFiltersORed"); - + double minDR = pset.getParameter("minTagProbeDR"); + minTagProbeDR2_ = minDR*minDR; minMass_ = pset.getParameter("minMass"); maxMass_ = pset.getParameter("maxMass"); requireOpSign_ = pset.getParameter("requireOpSign"); @@ -135,30 +141,33 @@ HLTDQMTagAndProbeEff::HLTDQMTagAndProbeEff(const edm::Param std::string baseHistName = pset.getParameter("baseHistName"); for(auto& config: filterConfigs){ - filterHists_.emplace_back(HLTDQMFilterTnPEffHists(config,baseHistName,hltProcess_)); + filterHists_.emplace_back(HLTDQMFilterTnPEffHists(config,baseHistName,hltProcess_)); } } -template -edm::ParameterSetDescription HLTDQMTagAndProbeEff:: +template +edm::ParameterSetDescription HLTDQMTagAndProbeEff:: makePSetDescription() { edm::ParameterSetDescription desc; - desc.addVPSet("tagRangeCuts",VarRangeCut::makePSetDescription(),std::vector()); - desc.addVPSet("probeRangeCuts",VarRangeCut::makePSetDescription(),std::vector()); + //it does not matter for makePSetDescription whether tag or probe types are used + desc.addVPSet("tagRangeCuts",VarRangeCut::makePSetDescription(),std::vector()); + desc.addVPSet("probeRangeCuts",VarRangeCut::makePSetDescription(),std::vector()); desc.add("trigEvent",edm::InputTag("hltTriggerSummaryAOD","","HLT")); - desc.add("objColl",edm::InputTag()); + desc.add("tagColl",edm::InputTag()); + desc.add("probeColl",edm::InputTag()); desc.add("tagVIDCuts",edm::InputTag()); desc.add("probeVIDCuts",edm::InputTag()); desc.add >("tagFilters",std::vector()); desc.add >("probeFilters",std::vector()); desc.add("tagFiltersORed",true);//default to OR probe filters (use case is multiple tag triggers, eg Ele27, Ele32, Ele35 tight etc) desc.add("probeFiltersORed",false); //default to AND probe filters (cant think why you would want to OR them but made if configurable just in case) + desc.add("minTagProbeDR",0); desc.add("minMass"); desc.add("maxMass"); desc.add("requireOpSign"); - desc.addVPSet("histConfigs",HLTDQMFilterTnPEffHists::makePSetDescriptionHistConfigs(),std::vector()); - desc.addVPSet("filterConfigs",HLTDQMFilterTnPEffHists::makePSetDescription(),std::vector()); + desc.addVPSet("histConfigs",HLTDQMFilterTnPEffHists::makePSetDescriptionHistConfigs(),std::vector()); + desc.addVPSet("filterConfigs",HLTDQMFilterTnPEffHists::makePSetDescription(),std::vector()); desc.add("baseHistName"); edm::ParameterSetDescription trigEvtFlagDesc; @@ -179,50 +188,59 @@ makePSetDescription() return desc; } -template -void HLTDQMTagAndProbeEff::bookHists(DQMStore::IBooker& iBooker) +template +void HLTDQMTagAndProbeEff::bookHists(DQMStore::IBooker& iBooker) { for(auto& filterHist: filterHists_) filterHist.bookHists(iBooker,histConfigs_); } -template -void HLTDQMTagAndProbeEff:: +template +void HLTDQMTagAndProbeEff:: beginRun(const edm::Run& run,const edm::EventSetup& setup) { if(sampleTrigRequirements_.on()) sampleTrigRequirements_.initRun(run,setup); } -template -void HLTDQMTagAndProbeEff::fill(const edm::Event& event,const edm::EventSetup& setup) +template +void HLTDQMTagAndProbeEff::fill(const edm::Event& event,const edm::EventSetup& setup) { - auto objCollHandle = getHandle(event,objToken_); + auto tagCollHandle = getHandle(event,tagToken_); + auto probeCollHandle = getHandle(event,probeToken_); auto trigEvtHandle = getHandle(event,trigEvtToken_); auto tagVIDHandle = getHandle(event,tagVIDToken_); auto probeVIDHandle = getHandle(event,probeVIDToken_); //we need the object collection and trigger info at the minimum - if(!objCollHandle.isValid() || !trigEvtHandle.isValid()) return; + if(!tagCollHandle.isValid() || !probeCollHandle.isValid() || !trigEvtHandle.isValid()) return; //if GenericTriggerEventFlag is "off", it'll return true regardless //if so if its off, we auto pass which is the behaviour we wish to have //if its null, we auto fail (because that shouldnt happen) if(sampleTrigRequirements_.accept(event,setup)==false) return; - std::vector > tagRefs = getPassingRefs(objCollHandle,*trigEvtHandle, + std::vector > tagRefs = getPassingRefs(tagCollHandle,*trigEvtHandle, tagFilters_,tagFiltersORed_, tagVIDHandle,tagRangeCuts_); - std::vector > probeRefs = getPassingRefs(objCollHandle,*trigEvtHandle, - probeFilters_,probeFiltersORed_, - probeVIDHandle,probeRangeCuts_); + std::vector > probeRefs = getPassingRefs(probeCollHandle,*trigEvtHandle, + probeFilters_,probeFiltersORed_, + probeVIDHandle,probeRangeCuts_); for(auto& tagRef : tagRefs){ + float tagEta = tagRef->eta(); + float tagPhi = tagRef->phi(); for(auto& probeRef : probeRefs){ - if(tagRef==probeRef) continue; //otherwise its the same object... + //first check if its the same object via its memory localation + //note for different collections another method is needed to determine + //if the probe and tag are the same object just recoed differently + //suggest dR cut (although mass cut should also help here) + if(static_cast(&*tagRef)==static_cast(&*probeRef)) continue; + float dR2 = reco::deltaR2(tagEta,tagPhi,probeRef->eta(),probeRef->phi()); float mass = (tagRef->p4()+probeRef->p4()).mag(); - if( ( mass>minMass_ || minMass_<0 ) && + if( ( mass>=minMass_ || minMass_<0 ) && ( mass=minTagProbeDR2_ ) && ( !requireOpSign_ || tagRef->charge()!=probeRef->charge()) ){ for(auto& filterHist : filterHists_){ filterHist.fillHists(*tagRef,*probeRef,event,setup,*trigEvtHandle); @@ -232,8 +250,18 @@ void HLTDQMTagAndProbeEff::fill(const edm::Event& event,con }//end of tag loop } +//yo dawg, I heard you like templates... +//okay this might be a little confusing to the student expected to maintain this +//here we have a templated function inside a templated class as it needs to be able to take probe or tag types +//so this is function of a class HLTDQMTagAndProbeEff +//hence why it needs to specify that those types even if it doesnt use them +//However also templated to take a type of ObjCollType +//(which we know will either be ProbeCollType or TagCollType but c++ doesnt and therefore it can anything) +//this is why there are two seperate template declarations +template template -std::vector > HLTDQMTagAndProbeEff:: +std::vector > +HLTDQMTagAndProbeEff:: getPassingRefs(const edm::Handle& objCollHandle, const trigger::TriggerEvent& trigEvt, const std::vector& filterNames, diff --git a/DQMOffline/Trigger/plugins/HLTTagAndProbeOfflineSource.cc b/DQMOffline/Trigger/plugins/HLTTagAndProbeOfflineSource.cc index 61c18ee318ecc..16bac625c8312 100644 --- a/DQMOffline/Trigger/plugins/HLTTagAndProbeOfflineSource.cc +++ b/DQMOffline/Trigger/plugins/HLTTagAndProbeOfflineSource.cc @@ -26,7 +26,7 @@ #include -template +template class HLTTagAndProbeOfflineSource : public DQMEDAnalyzer { public: explicit HLTTagAndProbeOfflineSource(const edm::ParameterSet&); @@ -41,43 +41,43 @@ class HLTTagAndProbeOfflineSource : public DQMEDAnalyzer { virtual void dqmBeginRun(edm::Run const& run, edm::EventSetup const& c) override{} private: - std::vector > tagAndProbeEffs_; + std::vector > tagAndProbeEffs_; }; -template -HLTTagAndProbeOfflineSource:: +template +HLTTagAndProbeOfflineSource:: HLTTagAndProbeOfflineSource(const edm::ParameterSet& config) { auto histCollConfigs = config.getParameter >("tagAndProbeCollections"); for(auto& histCollConfig : histCollConfigs){ - tagAndProbeEffs_.emplace_back(HLTDQMTagAndProbeEff(histCollConfig,consumesCollector())); + tagAndProbeEffs_.emplace_back(HLTDQMTagAndProbeEff(histCollConfig,consumesCollector())); } } -template -void HLTTagAndProbeOfflineSource:: +template +void HLTTagAndProbeOfflineSource:: fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.add("objs", edm::InputTag("")); desc.addVPSet("tagAndProbeCollections", - HLTDQMTagAndProbeEff::makePSetDescription(), + HLTDQMTagAndProbeEff::makePSetDescription(), std::vector()); descriptions.add("hltTagAndProbeOfflineSource", desc); } -template -void HLTTagAndProbeOfflineSource:: +template +void HLTTagAndProbeOfflineSource:: bookHistograms(DQMStore::IBooker& iBooker,const edm::Run& run,const edm::EventSetup& setup) { for(auto& tpEff : tagAndProbeEffs_) tpEff.bookHists(iBooker); } -template -void HLTTagAndProbeOfflineSource:: +template +void HLTTagAndProbeOfflineSource:: analyze(const edm::Event& event,const edm::EventSetup& setup) { for(auto& tpEff : tagAndProbeEffs_) tpEff.fill(event,setup); @@ -86,5 +86,18 @@ analyze(const edm::Event& event,const edm::EventSetup& setup) #include "FWCore/Framework/interface/MakerMacros.h" #include "DataFormats/EgammaCandidates/interface/GsfElectron.h" #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" +#include "DataFormats/EgammaCandidates/interface/Photon.h" +#include "DataFormats/EgammaCandidates/interface/PhotonFwd.h" +#include "DataFormats/MuonReco/interface/Muon.h" +#include "DataFormats/MuonReco/interface/MuonFwd.h" using HLTEleTagAndProbeOfflineSource = HLTTagAndProbeOfflineSource; +using HLTPhoTagAndProbeOfflineSource = HLTTagAndProbeOfflineSource; +using HLTElePhoTagAndProbeOfflineSource = HLTTagAndProbeOfflineSource; +using HLTMuEleTagAndProbeOfflineSource = HLTTagAndProbeOfflineSource; +using HLTMuTagAndProbeOfflineSource = HLTTagAndProbeOfflineSource; DEFINE_FWK_MODULE(HLTEleTagAndProbeOfflineSource); +DEFINE_FWK_MODULE(HLTPhoTagAndProbeOfflineSource); +DEFINE_FWK_MODULE(HLTElePhoTagAndProbeOfflineSource); +DEFINE_FWK_MODULE(HLTMuEleTagAndProbeOfflineSource); +DEFINE_FWK_MODULE(HLTMuTagAndProbeOfflineSource); + diff --git a/DQMOffline/Trigger/python/HLTEGTnPMonitor_cfi.py b/DQMOffline/Trigger/python/HLTEGTnPMonitor_cfi.py index a97425291cad6..af6d78a2e9e80 100644 --- a/DQMOffline/Trigger/python/HLTEGTnPMonitor_cfi.py +++ b/DQMOffline/Trigger/python/HLTEGTnPMonitor_cfi.py @@ -38,7 +38,8 @@ tagAndProbeConfigEle27WPTight = cms.PSet( trigEvent = cms.InputTag("hltTriggerSummaryAOD","","HLT"), - objColl = cms.InputTag("gedGsfElectrons"), + tagColl = cms.InputTag("gedGsfElectrons"), + probeColl = cms.InputTag("gedGsfElectrons"), tagVIDCuts = cms.InputTag("egmGsfElectronIDsForDQM:cutBasedElectronID-Summer16-80X-V1-tight"), probeVIDCuts = cms.InputTag("egmGsfElectronIDsForDQM:cutBasedElectronID-Summer16-80X-V1-tight"), sampleTrigRequirements = cms.PSet( @@ -60,6 +61,7 @@ probeFilters = cms.vstring(), probeFiltersORed = cms.bool(False), probeRangeCuts = cms.VPSet(ecalBarrelAndEndcapEtaCut), + minTagProbeDR = cms.double(0), minMass = cms.double(70.0), maxMass = cms.double(110.0), requireOpSign = cms.bool(False), @@ -78,7 +80,22 @@ hcalNegEtaCut, hcalPhi17Cut, )) - + +tagAndProbeElePhoConfigEle27WPTight = tagAndProbeConfigEle27WPTight.clone( + probeColl=cms.InputTag("gedPhotons"), + probeVIDCuts=cms.InputTag(""), + minTagProbeDR=cms.double(0.1) +) +tagAndProbeElePhoConfigEle27WPTightHEP17 = tagAndProbeElePhoConfigEle27WPTight.clone( + probeRangeCuts = cms.VPSet( + hcalPosEtaCut, + hcalPhi17Cut, +)) +tagAndProbeElePhoConfigEle27WPTightHEM17 = tagAndProbeElePhoConfigEle27WPTight.clone( + probeRangeCuts = cms.VPSet( + hcalNegEtaCut, + hcalPhi17Cut, +)) egammaStdHistConfigs = cms.VPSet( cms.PSet( @@ -348,6 +365,29 @@ ) ) +egHLTElePhoDQMOfflineTnPSource = cms.EDAnalyzer("HLTElePhoTagAndProbeOfflineSource", + tagAndProbeCollections = cms.VPSet( + cms.PSet( + tagAndProbeConfigEle27WPTight.clone(probeColl=cms.InputTag("gedPhotons"), + histConfigs = egammaStdHistConfigs, + baseHistName = cms.string("eleWPTightTag_"), + filterConfigs = egammaStdFiltersToMonitor, + ), + cms.PSet( + tagAndProbeConfigEle27WPTightHEM17, + histConfigs = egammaStdHistConfigs, + baseHistName = cms.string("eleWPTightTag-HEM17_"), + filterConfigs = egammaStdFiltersToMonitor, + ), + cms.PSet( + tagAndProbeConfigEle27WPTightHEP17, + histConfigs = egammaStdHistConfigs, + baseHistName = cms.string("eleWPTightTag-HEP17_"), + filterConfigs = egammaStdFiltersToMonitor, + ), + + ) + from RecoEgamma.ElectronIdentification.egmGsfElectronIDs_cff import egmGsfElectronIDs egmGsfElectronIDsForDQM = egmGsfElectronIDs.clone()