Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-29 23:10:34

0001 
0002 #include "DQMServices/Core/interface/DQMStore.h"
0003 
0004 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0005 
0006 #include "FWCore/Common/interface/TriggerNames.h"
0007 #include "FWCore/Framework/interface/Frameworkfwd.h"
0008 #include "FWCore/Framework/interface/Event.h"
0009 #include "FWCore/Framework/interface/MakerMacros.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 
0013 #include "DataFormats/Common/interface/TriggerResults.h"
0014 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
0015 #include "DataFormats/HLTReco/interface/TriggerObject.h"
0016 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0017 
0018 #include "DQMOffline/Trigger/interface/HLTDQMTagAndProbeEff.h"
0019 
0020 #include <vector>
0021 #include <string>
0022 
0023 template <typename TagType, typename TagCollType, typename ProbeType = TagType, typename ProbeCollType = TagCollType>
0024 class HLTTagAndProbeOfflineSource : public DQMEDAnalyzer {
0025 public:
0026   explicit HLTTagAndProbeOfflineSource(const edm::ParameterSet&);
0027   ~HLTTagAndProbeOfflineSource() override = default;
0028   HLTTagAndProbeOfflineSource(const HLTTagAndProbeOfflineSource&) = delete;
0029   HLTTagAndProbeOfflineSource& operator=(const HLTTagAndProbeOfflineSource&) = delete;
0030 
0031   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0032 
0033   void analyze(const edm::Event&, const edm::EventSetup&) override;
0034   void bookHistograms(DQMStore::IBooker&, edm::Run const& run, edm::EventSetup const& c) override;
0035 
0036 private:
0037   std::vector<HLTDQMTagAndProbeEff<TagType, TagCollType, ProbeType, ProbeCollType> > tagAndProbeEffs_;
0038 };
0039 
0040 template <typename TagType, typename TagCollType, typename ProbeType, typename ProbeCollType>
0041 HLTTagAndProbeOfflineSource<TagType, TagCollType, ProbeType, ProbeCollType>::HLTTagAndProbeOfflineSource(
0042     const edm::ParameterSet& config) {
0043   auto histCollConfigs = config.getParameter<std::vector<edm::ParameterSet> >("tagAndProbeCollections");
0044   for (auto& histCollConfig : histCollConfigs) {
0045     tagAndProbeEffs_.emplace_back(
0046         HLTDQMTagAndProbeEff<TagType, TagCollType, ProbeType, ProbeCollType>(histCollConfig, consumesCollector()));
0047   }
0048 }
0049 
0050 template <typename TagType, typename TagCollType, typename ProbeType, typename ProbeCollType>
0051 void HLTTagAndProbeOfflineSource<TagType, TagCollType, ProbeType, ProbeCollType>::fillDescriptions(
0052     edm::ConfigurationDescriptions& descriptions) {
0053   edm::ParameterSetDescription desc;
0054   desc.add<edm::InputTag>("objs", edm::InputTag(""));
0055   desc.addVPSet("tagAndProbeCollections",
0056                 HLTDQMTagAndProbeEff<TagType, TagCollType, ProbeType, ProbeCollType>::makePSetDescription(),
0057                 std::vector<edm::ParameterSet>());
0058 
0059   // addDefault must be used here instead of add unless this function is specialized
0060   // for different sets of template parameter types. Each specialization would need
0061   // a different module label. Otherwise the generated cfi filenames will conflict
0062   // for the different plugins.
0063   descriptions.addDefault(desc);
0064 }
0065 
0066 template <typename TagType, typename TagCollType, typename ProbeType, typename ProbeCollType>
0067 void HLTTagAndProbeOfflineSource<TagType, TagCollType, ProbeType, ProbeCollType>::bookHistograms(
0068     DQMStore::IBooker& iBooker, const edm::Run& run, const edm::EventSetup& setup) {
0069   for (auto& tpEff : tagAndProbeEffs_)
0070     tpEff.bookHists(iBooker);
0071 }
0072 
0073 template <typename TagType, typename TagCollType, typename ProbeType, typename ProbeCollType>
0074 void HLTTagAndProbeOfflineSource<TagType, TagCollType, ProbeType, ProbeCollType>::analyze(
0075     const edm::Event& event, const edm::EventSetup& setup) {
0076   for (auto& tpEff : tagAndProbeEffs_)
0077     tpEff.fill(event, setup);
0078 }
0079 
0080 #include "FWCore/Framework/interface/MakerMacros.h"
0081 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0082 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
0083 #include "DataFormats/EgammaCandidates/interface/Photon.h"
0084 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
0085 #include "DataFormats/MuonReco/interface/Muon.h"
0086 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0087 using HLTEleTagAndProbeOfflineSource = HLTTagAndProbeOfflineSource<reco::GsfElectron, reco::GsfElectronCollection>;
0088 using HLTPhoTagAndProbeOfflineSource = HLTTagAndProbeOfflineSource<reco::Photon, reco::PhotonCollection>;
0089 using HLTElePhoTagAndProbeOfflineSource =
0090     HLTTagAndProbeOfflineSource<reco::GsfElectron, reco::GsfElectronCollection, reco::Photon, reco::PhotonCollection>;
0091 using HLTMuEleTagAndProbeOfflineSource =
0092     HLTTagAndProbeOfflineSource<reco::Muon, reco::MuonCollection, reco::GsfElectron, reco::GsfElectronCollection>;
0093 using HLTMuPhoTagAndProbeOfflineSource =
0094     HLTTagAndProbeOfflineSource<reco::Muon, reco::MuonCollection, reco::Photon, reco::PhotonCollection>;
0095 using HLTMuTagAndProbeOfflineSource = HLTTagAndProbeOfflineSource<reco::Muon, reco::MuonCollection>;
0096 DEFINE_FWK_MODULE(HLTEleTagAndProbeOfflineSource);
0097 DEFINE_FWK_MODULE(HLTPhoTagAndProbeOfflineSource);
0098 DEFINE_FWK_MODULE(HLTElePhoTagAndProbeOfflineSource);
0099 DEFINE_FWK_MODULE(HLTMuEleTagAndProbeOfflineSource);
0100 DEFINE_FWK_MODULE(HLTMuPhoTagAndProbeOfflineSource);
0101 DEFINE_FWK_MODULE(HLTMuTagAndProbeOfflineSource);