Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:18:54

0001 #ifndef HLTriggerOffline_Higgs_HLTHiggsSubAnalysis_H
0002 #define HLTriggerOffline_Higgs_HLTHiggsSubAnalysis_H
0003 
0004 /** \class HLTHiggsSubAnalysis
0005 *  Generate histograms for trigger efficiencies Higgs related
0006 *  Documentation available on the CMS TWiki:
0007 *  https://twiki.cern.ch/twiki/bin/view/CMS/HiggsWGHLTValidate
0008 *
0009 *  \author  J. Duarte Campderros (based and adapted on J. Klukas,
0010 *           M. Vander Donckt and J. Alcaraz code from the 
0011 *           HLTriggerOffline/Muon package)
0012 *
0013 */
0014 
0015 #include "FWCore/Framework/interface/Frameworkfwd.h"
0016 #include "FWCore/Framework/interface/Event.h"
0017 #include "FWCore/Framework/interface/MakerMacros.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019 #include "FWCore/Utilities/interface/InputTag.h"
0020 #include "FWCore/Framework/interface/ConsumesCollector.h"
0021 
0022 #include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h"
0023 #include "DataFormats/HLTReco/interface/TriggerEventWithRefs.h"
0024 #include "DataFormats/MuonReco/interface/Muon.h"
0025 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0026 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0027 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
0028 #include "DataFormats/METReco/interface/CaloMET.h"
0029 #include "DataFormats/METReco/interface/CaloMETFwd.h"
0030 #include "DataFormats/METReco/interface/PFMET.h"
0031 #include "DataFormats/METReco/interface/PFMETFwd.h"
0032 #include "DataFormats/TauReco/interface/PFTau.h"
0033 #include "DataFormats/TauReco/interface/PFTauFwd.h"
0034 #include "DataFormats/EgammaCandidates/interface/Photon.h"
0035 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
0036 #include "DataFormats/TrackReco/interface/Track.h"
0037 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0038 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0039 #include "DataFormats/JetReco/interface/GenJet.h"
0040 #include "DataFormats/JetReco/interface/GenJetCollection.h"
0041 #include "DataFormats/JetReco/interface/PFJet.h"
0042 #include "DataFormats/BTauReco/interface/JetTag.h"
0043 #include "CommonTools/Utils/interface/StringCutObjectSelector.h"
0044 
0045 #include "DQMServices/Core/interface/DQMStore.h"
0046 
0047 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0048 
0049 #include "HLTHiggsPlotter.h"
0050 
0051 #include <vector>
0052 #include <set>
0053 #include <map>
0054 #include <cstring>
0055 
0056 struct EVTColContainer;
0057 
0058 class HLTHiggsSubAnalysis {
0059 public:
0060   typedef dqm::legacy::DQMStore DQMStore;
0061   typedef dqm::legacy::MonitorElement MonitorElement;
0062 
0063   enum { GEN, RECO };
0064 
0065   HLTHiggsSubAnalysis(const edm::ParameterSet &pset, const std::string &analysisname, edm::ConsumesCollector &&iC);
0066   ~HLTHiggsSubAnalysis();
0067   void beginJob();
0068   void beginRun(const edm::Run &iRun, const edm::EventSetup &iEventSetup);
0069   void analyze(const edm::Event &iEvent, const edm::EventSetup &iEventSetup, EVTColContainer *cols);
0070   void bookHistograms(DQMStore::IBooker &);
0071 
0072   //! Extract what objects need this analysis
0073   const std::vector<unsigned int> getObjectsType(const std::string &hltpath) const;
0074 
0075 private:
0076   void bookobjects(const edm::ParameterSet &anpset, edm::ConsumesCollector &iC);
0077   void initobjects(const edm::Event &iEvent, EVTColContainer *col);
0078   void InitSelector(const unsigned int &objtype);
0079   void initAndInsertJets(const edm::Event &iEvent, EVTColContainer *cols, std::vector<MatchStruct> *matches);
0080   void passJetCuts(std::vector<MatchStruct> *matches,
0081                    std::map<std::string, bool> &jetCutResult,
0082                    float &dEtaqq,
0083                    float &mqq,
0084                    float &dPhibb,
0085                    float &CSV1,
0086                    float &CSV2,
0087                    float &CSV3);
0088   void passOtherCuts(const std::vector<MatchStruct> &matches, std::map<std::string, bool> &jetCutResult);
0089   void insertcandidates(const unsigned int &objtype, const EVTColContainer *col, std::vector<MatchStruct> *matches);
0090 
0091   void bookHist(const std::string &source, const std::string &objType, const std::string &variable, DQMStore::IBooker &);
0092   void fillHist(const std::string &source, const std::string &objType, const std::string &variable, const float &value);
0093 
0094   edm::ParameterSet _pset;
0095 
0096   std::string _analysisname;
0097 
0098   //! The minimum number of reco/gen candidates needed by the analysis
0099   unsigned int _minCandidates;
0100 
0101   double _HtJetPtMin;
0102   double _HtJetEtaMax;
0103 
0104   bool _bookHtPlots;
0105 
0106   std::string _hltProcessName;
0107   std::string _histDirectory;
0108 
0109   //! the hlt paths with regular expressions
0110   std::vector<std::string> _hltPathsToCheck;
0111   //! the hlt paths found in the hltConfig
0112   std::set<std::string> _hltPaths;
0113 
0114   //! Relation between the short version of a path
0115   std::map<std::string, std::string> _shortpath2long;
0116 
0117   // The name of the object collections to be used in this
0118   // analysis.
0119   edm::EDGetTokenT<reco::GenParticleCollection> _genParticleLabel;
0120   edm::EDGetTokenT<reco::GenJetCollection> _genJetLabel;
0121   edm::EDGetTokenT<reco::PFJetCollection> _recoHtJetLabel;
0122 
0123   std::map<unsigned int, std::string> _recLabels;
0124   edm::EDGetTokenT<reco::MuonCollection> _recLabelsMuon;
0125   edm::EDGetTokenT<reco::GsfElectronCollection> _recLabelsElec;
0126   edm::EDGetTokenT<reco::PhotonCollection> _recLabelsPhoton;
0127   edm::EDGetTokenT<reco::CaloMETCollection> _recLabelsCaloMET;
0128   edm::EDGetTokenT<reco::PFMETCollection> _recLabelsPFMET;
0129   edm::EDGetTokenT<reco::PFTauCollection> _recLabelsPFTau;
0130   edm::EDGetTokenT<reco::PFJetCollection> _recLabelsPFJet;
0131   edm::EDGetTokenT<reco::JetTagCollection> _recTagPFJet;
0132   edm::EDGetTokenT<std::vector<PileupSummaryInfo> > _puSummaryInfo;
0133 
0134   //! Some kinematical parameters
0135   std::vector<double> _parametersEta;
0136   std::vector<double> _parametersPhi;
0137   std::vector<double> _parametersPu;
0138   std::vector<double> _parametersHt;
0139   std::vector<double> _parametersTurnOn;
0140   edm::EDGetTokenT<edm::TriggerResults> _trigResultsTag;
0141 
0142   std::map<unsigned int, double> _cutMinPt;
0143   std::map<unsigned int, double> _cutMaxEta;
0144   std::map<unsigned int, unsigned int> _cutMotherId;     //TO BE DEPRECATED (HLTMATCH)
0145   std::map<unsigned int, std::vector<double> > _cutsDr;  // TO BE DEPRECATED (HLTMATCH)
0146   //! gen/rec objects cuts
0147   std::map<unsigned int, std::string> _genCut;
0148   std::map<unsigned int, std::string> _recCut;
0149 
0150   //! The concrete String selectors (use the string cuts introduced
0151   //! via the config python)
0152   std::map<unsigned int, StringCutObjectSelector<reco::GenParticle> *> _genSelectorMap;
0153   StringCutObjectSelector<reco::GenJet> *_genJetSelector;
0154   StringCutObjectSelector<reco::Muon> *_recMuonSelector;
0155   StringCutObjectSelector<reco::GsfElectron> *_recElecSelector;
0156   StringCutObjectSelector<reco::CaloMET> *_recCaloMETSelector;
0157   StringCutObjectSelector<reco::PFMET> *_recPFMETSelector;
0158   StringCutObjectSelector<reco::PFTau> *_recPFTauSelector;
0159   StringCutObjectSelector<reco::Photon> *_recPhotonSelector;
0160   StringCutObjectSelector<reco::PFJet> *_recPFJetSelector;
0161   StringCutObjectSelector<reco::Track> *_recTrackSelector;
0162 
0163   //N-1 cut values
0164   std::vector<double> _NminOneCuts;
0165   bool _useNminOneCuts;
0166   unsigned int NptPlots;
0167 
0168   // The plotters: managers of each hlt path where the plots are done
0169   std::vector<HLTHiggsPlotter> _analyzers;
0170 
0171   HLTConfigProvider _hltConfig;
0172   std::map<std::string, MonitorElement *> _elements;
0173 };
0174 #endif