Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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 "RecoJets/JetProducers/interface/JetIDHelper.h"
0058 #include "DQMOffline/JetMET/interface/JetMETDQMDCSFilter.h"
0059 #include "DataFormats/VertexReco/interface/Vertex.h"
0060 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0061 #include "DataFormats/DetId/interface/DetId.h"
0062 
0063 #include "DataFormats/Scalers/interface/DcsStatus.h"
0064 #include "PhysicsTools/SelectorUtils/interface/JetIDSelectionFunctor.h"
0065 #include "PhysicsTools/SelectorUtils/interface/PFJetIDSelectionFunctor.h"
0066 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0067 #include <map>
0068 #include <string>
0069 #include <vector>
0070 #include <algorithm>
0071 #include <set>
0072 #include <utility>
0073 
0074 class JetAnalyzer_HeavyIons_matching : public DQMEDAnalyzer {
0075 public:
0076   explicit JetAnalyzer_HeavyIons_matching(const edm::ParameterSet &);
0077   ~JetAnalyzer_HeavyIons_matching() override;
0078 
0079   void analyze(const edm::Event &, const edm::EventSetup &) override;
0080   void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
0081 
0082   // calojet1token = vscalo
0083   // calojet2token = pucalo
0084 
0085 private:
0086   edm::InputTag mInputJet1Collection;
0087   edm::InputTag mInputJet2Collection;
0088 
0089   std::string mOutputFile;
0090   std::string JetType1;
0091   std::string JetType2;
0092   double mRecoJetPtThreshold;
0093   double mRecoDelRMatch;
0094   double mRecoJetEtaCut;
0095 
0096   //Tokens
0097   edm::EDGetTokenT<reco::CaloJetCollection> caloJet1Token_;
0098   edm::EDGetTokenT<reco::CaloJetCollection> caloJet2Token_;
0099   edm::EDGetTokenT<reco::PFJetCollection> pfJetsToken_;
0100   edm::EDGetTokenT<reco::BasicJetCollection> basicJetsToken_;
0101   edm::EDGetTokenT<reco::JPTJetCollection> jptJetsToken_;
0102 
0103   MonitorElement *mpT_ratio_Jet1Jet2;
0104   MonitorElement *mpT_Jet1_matched;
0105   MonitorElement *mpT_Jet2_matched;
0106   MonitorElement *mpT_Jet1_unmatched;
0107   MonitorElement *mpT_Jet2_unmatched;
0108 
0109   MonitorElement *mHadEnergy_Jet1_unmatched;
0110   MonitorElement *mEmEnergy_Jet1_unmatched;
0111   MonitorElement *mChargedHadronEnergy_Jet1_unmatched;
0112   MonitorElement *mNeutralHadronEnergy_Jet1_unmatched;
0113   MonitorElement *mChargedEmEnergy_Jet1_unmatched;
0114   MonitorElement *mNeutralEmEnergy_Jet1_unmatched;
0115   MonitorElement *mChargedMuEnergy_Jet1_unmatched;
0116 
0117   MonitorElement *mChargedHadEnergyFraction_Jet1_unmatched;
0118   MonitorElement *mNeutralHadEnergyFraction_Jet1_unmatched;
0119   MonitorElement *mPhotonEnergyFraction_Jet1_unmatched;
0120   MonitorElement *mElectronEnergyFraction_Jet1_unmatched;
0121   MonitorElement *mMuonEnergyFraction_Jet1_unmatched;
0122 
0123   MonitorElement *mHadEnergy_Jet2_unmatched;
0124   MonitorElement *mEmEnergy_Jet2_unmatched;
0125   MonitorElement *mChargedHadronEnergy_Jet2_unmatched;
0126   MonitorElement *mNeutralHadronEnergy_Jet2_unmatched;
0127   MonitorElement *mChargedEmEnergy_Jet2_unmatched;
0128   MonitorElement *mNeutralEmEnergy_Jet2_unmatched;
0129   MonitorElement *mChargedMuEnergy_Jet2_unmatched;
0130 
0131   MonitorElement *mChargedHadEnergyFraction_Jet2_unmatched;
0132   MonitorElement *mNeutralHadEnergyFraction_Jet2_unmatched;
0133   MonitorElement *mPhotonEnergyFraction_Jet2_unmatched;
0134   MonitorElement *mElectronEnergyFraction_Jet2_unmatched;
0135   MonitorElement *mMuonEnergyFraction_Jet2_unmatched;
0136 
0137   struct MyJet {
0138     int id;
0139     float pt;
0140     float eta;
0141     float phi;
0142   };
0143 
0144   typedef std::pair<MyJet, MyJet> ABJetPair;
0145 
0146   struct CompareMatchedJets {
0147     //! A-B jet match
0148     bool operator()(const ABJetPair &A1, const ABJetPair &A2) const {
0149       MyJet jet1_pair1 = A1.first;   //! Jet1 1st pair
0150       MyJet jet2_pair1 = A1.second;  //! Jet2 1st pair
0151       MyJet jet1_pair2 = A2.first;   //! Jet1 2nd pair
0152       MyJet jet2_pair2 = A2.second;  //! Jet2 2nd pair
0153       float delr1 = deltaRR(jet1_pair1.eta, jet1_pair1.phi, jet2_pair1.eta, jet2_pair1.phi);
0154       float delr2 = deltaRR(jet1_pair2.eta, jet1_pair2.phi, jet2_pair2.eta, jet2_pair2.phi);
0155 
0156       return ((delr1 < delr2) && (jet1_pair1.pt > jet1_pair2.pt));
0157     }
0158   };
0159 
0160   typedef std::multiset<ABJetPair, CompareMatchedJets> ABMatchedJets;
0161   typedef std::multiset<ABJetPair>::iterator ABItr;
0162 
0163   static float deltaRR(float eta1, float phi1, float eta2, float phi2) {
0164     float deta = eta1 - eta2;
0165     float dphi = fabs(phi1 - phi2);
0166     if (dphi > M_PI)
0167       dphi -= 2 * M_PI;
0168     float dr = sqrt(deta * deta + dphi * dphi);
0169     return dr;
0170   }
0171 };
0172 
0173 #endif