Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:09:55

0001 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0002 #include "DQMServices/Core/interface/DQMStore.h"
0003 #include "DQMOffline/Trigger/interface/HLTDQMTagAndProbeEff.h"
0004 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0007 
0008 #include <vector>
0009 
0010 template <typename TagType, typename TagCollType, typename ProbeType = TagType, typename ProbeCollType = TagCollType>
0011 class HLTTagAndProbeOfflineSource : public DQMEDAnalyzer {
0012 public:
0013   explicit HLTTagAndProbeOfflineSource(const edm::ParameterSet&);
0014   ~HLTTagAndProbeOfflineSource() override = default;
0015   HLTTagAndProbeOfflineSource(const HLTTagAndProbeOfflineSource&) = delete;
0016   HLTTagAndProbeOfflineSource& operator=(const HLTTagAndProbeOfflineSource&) = delete;
0017 
0018   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0019 
0020   void analyze(const edm::Event&, const edm::EventSetup&) override;
0021   void bookHistograms(DQMStore::IBooker&, edm::Run const& run, edm::EventSetup const& c) override;
0022 
0023 private:
0024   std::vector<HLTDQMTagAndProbeEff<TagType, TagCollType, ProbeType, ProbeCollType>> tagAndProbeEffs_;
0025 };
0026 
0027 template <typename TagType, typename TagCollType, typename ProbeType, typename ProbeCollType>
0028 HLTTagAndProbeOfflineSource<TagType, TagCollType, ProbeType, ProbeCollType>::HLTTagAndProbeOfflineSource(
0029     const edm::ParameterSet& config) {
0030   auto histCollConfigs = config.getParameter<std::vector<edm::ParameterSet>>("tagAndProbeCollections");
0031   for (auto& histCollConfig : histCollConfigs) {
0032     tagAndProbeEffs_.emplace_back(
0033         HLTDQMTagAndProbeEff<TagType, TagCollType, ProbeType, ProbeCollType>(histCollConfig, consumesCollector()));
0034   }
0035 }
0036 
0037 template <typename TagType, typename TagCollType, typename ProbeType, typename ProbeCollType>
0038 void HLTTagAndProbeOfflineSource<TagType, TagCollType, ProbeType, ProbeCollType>::fillDescriptions(
0039     edm::ConfigurationDescriptions& descriptions) {
0040   edm::ParameterSetDescription desc;
0041   desc.addVPSet("tagAndProbeCollections",
0042                 HLTDQMTagAndProbeEff<TagType, TagCollType, ProbeType, ProbeCollType>::makePSetDescription(),
0043                 {});
0044   descriptions.addWithDefaultLabel(desc);
0045 }
0046 
0047 template <typename TagType, typename TagCollType, typename ProbeType, typename ProbeCollType>
0048 void HLTTagAndProbeOfflineSource<TagType, TagCollType, ProbeType, ProbeCollType>::bookHistograms(
0049     DQMStore::IBooker& iBooker, const edm::Run& run, const edm::EventSetup& setup) {
0050   for (auto& tpEff : tagAndProbeEffs_)
0051     tpEff.bookHists(iBooker);
0052 }
0053 
0054 template <typename TagType, typename TagCollType, typename ProbeType, typename ProbeCollType>
0055 void HLTTagAndProbeOfflineSource<TagType, TagCollType, ProbeType, ProbeCollType>::analyze(
0056     const edm::Event& event, const edm::EventSetup& setup) {
0057   for (auto& tpEff : tagAndProbeEffs_)
0058     tpEff.fill(event, setup);
0059 }
0060 
0061 #include "FWCore/Framework/interface/MakerMacros.h"
0062 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0063 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
0064 #include "DataFormats/EgammaCandidates/interface/Photon.h"
0065 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
0066 #include "DataFormats/MuonReco/interface/Muon.h"
0067 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0068 using HLTEleTagAndProbeOfflineSource = HLTTagAndProbeOfflineSource<reco::GsfElectron, reco::GsfElectronCollection>;
0069 using HLTPhoTagAndProbeOfflineSource = HLTTagAndProbeOfflineSource<reco::Photon, reco::PhotonCollection>;
0070 using HLTElePhoTagAndProbeOfflineSource =
0071     HLTTagAndProbeOfflineSource<reco::GsfElectron, reco::GsfElectronCollection, reco::Photon, reco::PhotonCollection>;
0072 using HLTMuEleTagAndProbeOfflineSource =
0073     HLTTagAndProbeOfflineSource<reco::Muon, reco::MuonCollection, reco::GsfElectron, reco::GsfElectronCollection>;
0074 using HLTMuPhoTagAndProbeOfflineSource =
0075     HLTTagAndProbeOfflineSource<reco::Muon, reco::MuonCollection, reco::Photon, reco::PhotonCollection>;
0076 using HLTMuTagAndProbeOfflineSource = HLTTagAndProbeOfflineSource<reco::Muon, reco::MuonCollection>;
0077 DEFINE_FWK_MODULE(HLTEleTagAndProbeOfflineSource);
0078 DEFINE_FWK_MODULE(HLTPhoTagAndProbeOfflineSource);
0079 DEFINE_FWK_MODULE(HLTElePhoTagAndProbeOfflineSource);
0080 DEFINE_FWK_MODULE(HLTMuEleTagAndProbeOfflineSource);
0081 DEFINE_FWK_MODULE(HLTMuPhoTagAndProbeOfflineSource);
0082 DEFINE_FWK_MODULE(HLTMuTagAndProbeOfflineSource);