Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef JetAnalyzer_HeavyIons_matching_H
0002 #define JetAnalyzer_HeavyIons_matching_H
0003 
0004 //
0005 // Jet Tester class for heavy ion jets. for DQM jet analysis monitoring
0006 // For CMSSW_7_5_X, especially reading background subtracted jets
0007 // author: Raghav Kunnawalkam Elayavalli,
0008 //         April 6th 2015
0009 //         Rutgers University, email: raghav.k.e at CERN dot CH
0010 //
0011 // The logic for the matching is taken from Pawan Kumar Netrakanti's macro analysis level macro available here
0012 // https://github.com/pawannetrakanti/UserCode/blob/master/JetRAA/jetmatch.C
0013 //
0014 
0015 #include <memory>
0016 #include <fstream>
0017 #include "FWCore/Framework/interface/Frameworkfwd.h"
0018 #include "FWCore/Framework/interface/Event.h"
0019 #include "FWCore/Framework/interface/MakerMacros.h"
0020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0021 #include "DQMServices/Core/interface/DQMStore.h"
0022 
0023 #include "DataFormats/Common/interface/TriggerResults.h"
0024 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
0025 #include "DataFormats/HLTReco/interface/TriggerObject.h"
0026 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0027 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0028 #include "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h"
0029 #include "FWCore/Utilities/interface/EDGetToken.h"
0030 
0031 #include "DataFormats/JetReco/interface/Jet.h"
0032 #include "DataFormats/JetReco/interface/CaloJet.h"
0033 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
0034 #include "DataFormats/JetReco/interface/GenJet.h"
0035 #include "DataFormats/JetReco/interface/GenJetCollection.h"
0036 #include "DataFormats/JetReco/interface/JPTJet.h"
0037 #include "DataFormats/JetReco/interface/JPTJetCollection.h"
0038 #include "DataFormats/JetReco/interface/PFJet.h"
0039 
0040 #include "DataFormats/CaloTowers/interface/CaloTower.h"
0041 #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
0042 #include "DataFormats/Candidate/interface/Candidate.h"
0043 #include "DataFormats/Candidate/interface/CandidateFwd.h"
0044 #include "DataFormats/Candidate/interface/CandidateWithRef.h"
0045 
0046 // include the basic jet for the PuPF jets.
0047 #include "DataFormats/JetReco/interface/BasicJet.h"
0048 #include "DataFormats/JetReco/interface/BasicJetCollection.h"
0049 // include the pf candidates
0050 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0051 // include the voronoi subtraction
0052 #include "DataFormats/HeavyIonEvent/interface/VoronoiBackground.h"
0053 #include "RecoHI/HiJetAlgos/interface/UEParameters.h"
0054 // include the centrality variables
0055 #include "DataFormats/HeavyIonEvent/interface/Centrality.h"
0056 
0057 #include "JetMETCorrections/Objects/interface/JetCorrector.h"
0058 #include "RecoJets/JetProducers/interface/JetIDHelper.h"
0059 #include "DQMOffline/JetMET/interface/JetMETDQMDCSFilter.h"
0060 #include "DataFormats/VertexReco/interface/Vertex.h"
0061 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0062 #include "DataFormats/DetId/interface/DetId.h"
0063 
0064 #include "DataFormats/Scalers/interface/DcsStatus.h"
0065 #include "PhysicsTools/SelectorUtils/interface/JetIDSelectionFunctor.h"
0066 #include "PhysicsTools/SelectorUtils/interface/PFJetIDSelectionFunctor.h"
0067 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0068 #include <map>
0069 #include <string>
0070 #include <vector>
0071 #include <algorithm>
0072 #include <set>
0073 #include <utility>
0074 
0075 class JetAnalyzer_HeavyIons_matching : public DQMEDAnalyzer {
0076 public:
0077   explicit JetAnalyzer_HeavyIons_matching(const edm::ParameterSet &);
0078   ~JetAnalyzer_HeavyIons_matching() override;
0079 
0080   void analyze(const edm::Event &, const edm::EventSetup &) override;
0081   void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
0082 
0083   // calojet1token = vscalo
0084   // calojet2token = pucalo
0085 
0086 private:
0087   edm::InputTag mInputJet1Collection;
0088   edm::InputTag mInputJet2Collection;
0089 
0090   std::string mOutputFile;
0091   std::string JetType1;
0092   std::string JetType2;
0093   double mRecoJetPtThreshold;
0094   double mRecoDelRMatch;
0095   double mRecoJetEtaCut;
0096 
0097   //Tokens
0098   edm::EDGetTokenT<reco::CaloJetCollection> caloJet1Token_;
0099   edm::EDGetTokenT<reco::CaloJetCollection> caloJet2Token_;
0100   edm::EDGetTokenT<reco::PFJetCollection> pfJetsToken_;
0101   edm::EDGetTokenT<reco::BasicJetCollection> basicJetsToken_;
0102   edm::EDGetTokenT<reco::JPTJetCollection> jptJetsToken_;
0103 
0104   MonitorElement *mpT_ratio_Jet1Jet2;
0105   MonitorElement *mpT_Jet1_matched;
0106   MonitorElement *mpT_Jet2_matched;
0107   MonitorElement *mpT_Jet1_unmatched;
0108   MonitorElement *mpT_Jet2_unmatched;
0109 
0110   MonitorElement *mHadEnergy_Jet1_unmatched;
0111   MonitorElement *mEmEnergy_Jet1_unmatched;
0112   MonitorElement *mChargedHadronEnergy_Jet1_unmatched;
0113   MonitorElement *mNeutralHadronEnergy_Jet1_unmatched;
0114   MonitorElement *mChargedEmEnergy_Jet1_unmatched;
0115   MonitorElement *mNeutralEmEnergy_Jet1_unmatched;
0116   MonitorElement *mChargedMuEnergy_Jet1_unmatched;
0117 
0118   MonitorElement *mChargedHadEnergyFraction_Jet1_unmatched;
0119   MonitorElement *mNeutralHadEnergyFraction_Jet1_unmatched;
0120   MonitorElement *mPhotonEnergyFraction_Jet1_unmatched;
0121   MonitorElement *mElectronEnergyFraction_Jet1_unmatched;
0122   MonitorElement *mMuonEnergyFraction_Jet1_unmatched;
0123 
0124   MonitorElement *mHadEnergy_Jet2_unmatched;
0125   MonitorElement *mEmEnergy_Jet2_unmatched;
0126   MonitorElement *mChargedHadronEnergy_Jet2_unmatched;
0127   MonitorElement *mNeutralHadronEnergy_Jet2_unmatched;
0128   MonitorElement *mChargedEmEnergy_Jet2_unmatched;
0129   MonitorElement *mNeutralEmEnergy_Jet2_unmatched;
0130   MonitorElement *mChargedMuEnergy_Jet2_unmatched;
0131 
0132   MonitorElement *mChargedHadEnergyFraction_Jet2_unmatched;
0133   MonitorElement *mNeutralHadEnergyFraction_Jet2_unmatched;
0134   MonitorElement *mPhotonEnergyFraction_Jet2_unmatched;
0135   MonitorElement *mElectronEnergyFraction_Jet2_unmatched;
0136   MonitorElement *mMuonEnergyFraction_Jet2_unmatched;
0137 
0138   struct MyJet {
0139     int id;
0140     float pt;
0141     float eta;
0142     float phi;
0143   };
0144 
0145   typedef std::pair<MyJet, MyJet> ABJetPair;
0146 
0147   struct CompareMatchedJets {
0148     //! A-B jet match
0149     bool operator()(const ABJetPair &A1, const ABJetPair &A2) const {
0150       MyJet jet1_pair1 = A1.first;   //! Jet1 1st pair
0151       MyJet jet2_pair1 = A1.second;  //! Jet2 1st pair
0152       MyJet jet1_pair2 = A2.first;   //! Jet1 2nd pair
0153       MyJet jet2_pair2 = A2.second;  //! Jet2 2nd pair
0154       float delr1 = deltaRR(jet1_pair1.eta, jet1_pair1.phi, jet2_pair1.eta, jet2_pair1.phi);
0155       float delr2 = deltaRR(jet1_pair2.eta, jet1_pair2.phi, jet2_pair2.eta, jet2_pair2.phi);
0156 
0157       return ((delr1 < delr2) && (jet1_pair1.pt > jet1_pair2.pt));
0158     }
0159   };
0160 
0161   typedef std::multiset<ABJetPair, CompareMatchedJets> ABMatchedJets;
0162   typedef std::multiset<ABJetPair>::iterator ABItr;
0163 
0164   static float deltaRR(float eta1, float phi1, float eta2, float phi2) {
0165     float deta = eta1 - eta2;
0166     float dphi = fabs(phi1 - phi2);
0167     if (dphi > M_PI)
0168       dphi -= 2 * M_PI;
0169     float dr = sqrt(deta * deta + dphi * dphi);
0170     return dr;
0171   }
0172 };
0173 
0174 #endif