Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:02

0001 #include "DQM/DataScouting/plugins/RazorVarAnalyzer.h"
0002 
0003 #include "DataFormats/JetReco/interface/CaloJet.h"
0004 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
0005 
0006 #include "DataFormats/EgammaCandidates/interface/Electron.h"
0007 #include "DataFormats/EgammaCandidates/interface/ElectronFwd.h"
0008 
0009 #include "DataFormats/MuonReco/interface/Muon.h"
0010 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
0011 
0012 #include <cmath>
0013 
0014 // A simple constructor which takes as inoput only the name of the PF jet
0015 // collection
0016 RazorVarAnalyzer::RazorVarAnalyzer(const edm::ParameterSet &conf)
0017     : ScoutingAnalyzerBase(conf),
0018       m_eleCollectionTag(conf.getUntrackedParameter<edm::InputTag>("eleCollectionName",
0019                                                                    edm::InputTag("hltPixelMatchElectronsActivity"))),
0020       m_jetCollectionTag(
0021           conf.getUntrackedParameter<edm::InputTag>("jetCollectionName", edm::InputTag("hltCaloJetIDPassed"))),
0022       m_muCollectionTag(
0023           conf.getUntrackedParameter<edm::InputTag>("muCollectionName", edm::InputTag("hltL3MuonCandidates"))),
0024       m_razorVarCollectionTag(conf.getUntrackedParameter<edm::InputTag>("razorVarCollectionName")) {
0025   // set Token(-s)
0026   m_jetCollectionTagToken_ = consumes<reco::CaloJetCollection>(
0027       conf.getUntrackedParameter<edm::InputTag>("jetCollectionName", edm::InputTag("hltCaloJetIDPassed")));
0028   m_muCollectionTagToken_ = consumes<std::vector<reco::RecoChargedCandidate>>(
0029       conf.getUntrackedParameter<edm::InputTag>("muCollectionName", edm::InputTag("hltL3MuonCandidates")));
0030   m_eleCollectionTagToken_ = consumes<reco::ElectronCollection>(
0031       conf.getUntrackedParameter<edm::InputTag>("eleCollectionName", edm::InputTag("hltPixelMatchElectronsActivity")));
0032   m_razorVarCollectionTagToken_ =
0033       consumes<std::vector<double>>(conf.getUntrackedParameter<edm::InputTag>("razorVarCollectionName"));
0034 }
0035 
0036 RazorVarAnalyzer::~RazorVarAnalyzer() {}
0037 
0038 // Function to book the Monitoring Elements.
0039 void RazorVarAnalyzer::bookHistograms(DQMStore::IBooker &iBooker, edm::Run const &, edm::EventSetup const &) {
0040   ScoutingAnalyzerBase::prepareBooking(iBooker);
0041   // the full inclusive histograms
0042   m_rsqMRFullyInc = bookH2withSumw2(
0043       iBooker, "rsqMRFullyInc", "M_{R} vs R^{2} (All Events)", 400, 0., 4000., 50, 0., 1., "M_{R} [GeV]", "R^{2}");
0044   m_rsqMRInc4J = bookH2withSumw2(
0045       iBooker, "rsqMRInc4J", "M_{R} vs R^{2} (>= 4j)", 400, 0., 4000., 50, 0., 1., "M_{R} [GeV]", "R^{2}");
0046   m_rsqMRInc6J = bookH2withSumw2(
0047       iBooker, "rsqMRInc6J", "M_{R} vs R^{2} (>= 6j)", 400, 0., 4000., 50, 0., 1., "M_{R} [GeV]", "R^{2}");
0048   m_rsqMRInc8J = bookH2withSumw2(
0049       iBooker, "rsqMRInc8J", "M_{R} vs R^{2} (>= 8j)", 400, 0., 4000., 50, 0., 1., "M_{R} [GeV]", "R^{2}");
0050   m_rsqMRInc10J = bookH2withSumw2(
0051       iBooker, "rsqMRInc10J", "M_{R} vs R^{2} (>= 10j)", 400, 0., 4000., 50, 0., 1., "M_{R} [GeV]", "R^{2}");
0052   m_rsqMRInc12J = bookH2withSumw2(
0053       iBooker, "rsqMRInc12J", "M_{R} vs R^{2} (>= 12j)", 400, 0., 4000., 50, 0., 1., "M_{R} [GeV]", "R^{2}");
0054   m_rsqMRInc14J = bookH2withSumw2(
0055       iBooker, "rsqMRInc14J", "M_{R} vs R^{2} (>= 14j)", 400, 0., 4000., 50, 0., 1., "M_{R} [GeV]", "R^{2}");
0056 
0057   // the by box histograms
0058   m_rsqMREleMu = bookH2withSumw2(
0059       iBooker, "rsqMREleMu", "M_{R} vs R^{2} (EleMu box)", 400, 0., 4000., 50, 0., 1., "M_{R} [GeV]", "R^{2}");
0060   m_rsqMRMuMu = bookH2withSumw2(
0061       iBooker, "rsqMRMuMu", "M_{R} vs R^{2} (MuMu box)", 400, 0., 4000., 50, 0., 1., "M_{R} [GeV]", "R^{2}");
0062   m_rsqMREleEle = bookH2withSumw2(
0063       iBooker, "rsqMREleEle", "M_{R} vs R^{2} (EleEle box)", 400, 0., 4000., 50, 0., 1., "M_{R} [GeV]", "R^{2}");
0064   m_rsqMRMu = bookH2withSumw2(
0065       iBooker, "rsqMRMu", "M_{R} vs R^{2} (Mu box)", 400, 0., 4000., 50, 0., 1., "M_{R} [GeV]", "R^{2}");
0066   m_rsqMREle = bookH2withSumw2(
0067       iBooker, "rsqMREle", "M_{R} vs R^{2} (Ele box)", 400, 0., 4000., 50, 0., 1., "M_{R} [GeV]", "R^{2}");
0068   m_rsqMRHad = bookH2withSumw2(
0069       iBooker, "rsqMRHad", "M_{R} vs R^{2} (Had box)", 400, 0., 4000., 50, 0., 1., "M_{R} [GeV]", "R^{2}");
0070 
0071   // the by box histograms
0072   m_rsqMRMuMJ = bookH2withSumw2(
0073       iBooker, "rsqMRMuMJ", "M_{R} vs R^{2} (Mu box >= 4j)", 400, 0., 4000., 50, 0., 1., "M_{R} [GeV]", "R^{2}");
0074   m_rsqMREleMJ = bookH2withSumw2(
0075       iBooker, "rsqMREleMJ", "M_{R} vs R^{2} (Ele box >= 5j)", 400, 0., 4000., 50, 0., 1., "M_{R} [GeV]", "R^{2}");
0076   m_rsqMRHadMJ = bookH2withSumw2(
0077       iBooker, "rsqMRHadMJ", "M_{R} vs R^{2} (Had box >= 6j)", 400, 0., 4000., 50, 0., 1., "M_{R} [GeV]", "R^{2}");
0078 }
0079 
0080 // Usual analyze method
0081 void RazorVarAnalyzer::analyze(const edm::Event &iEvent, const edm::EventSetup &c) {
0082   // count the number of jets with a minimal selection
0083   edm::Handle<reco::CaloJetCollection> calojets_handle;
0084   iEvent.getByToken(m_jetCollectionTagToken_, calojets_handle);
0085 
0086   unsigned int njets = 0;
0087   for (reco::CaloJetCollection::const_iterator it = calojets_handle->begin(); it != calojets_handle->end(); ++it) {
0088     if (it->pt() >= 30. && fabs(it->eta()) <= 3.0) {
0089       njets++;
0090     }
0091   }
0092 
0093   // count the number of muons
0094   edm::Handle<std::vector<reco::RecoChargedCandidate>> muon_handle;
0095   iEvent.getByToken(m_muCollectionTagToken_, muon_handle);
0096 
0097   unsigned int nmu_loose = 0;
0098   unsigned int nmu_tight = 0;
0099   if (muon_handle.isValid()) {
0100     for (std::vector<reco::RecoChargedCandidate>::const_iterator it = muon_handle->begin(); it != muon_handle->end();
0101          ++it) {
0102       if (it->pt() >= 15 && fabs(it->eta()) <= 2.1)
0103         nmu_tight++;
0104       if (it->pt() >= 10 && fabs(it->eta()) <= 2.4)
0105         nmu_loose++;
0106     }
0107   }
0108 
0109   // count the number of electrons
0110   edm::Handle<reco::ElectronCollection> ele_handle;
0111   iEvent.getByToken(m_eleCollectionTagToken_, ele_handle);
0112 
0113   unsigned int nele_loose = 0;
0114   unsigned int nele_tight = 0;
0115   if (ele_handle.isValid()) {
0116     for (reco::ElectronCollection::const_iterator it = ele_handle->begin(); it != ele_handle->end(); ++it) {
0117       if (it->pt() >= 20 && fabs(it->eta()) <= 2.5)
0118         nele_tight++;
0119       if (it->pt() >= 10 && fabs(it->eta()) <= 2.5)
0120         nele_loose++;
0121     }
0122   }
0123 
0124   // now get the box number:
0125   // {'MuEle':0,'MuMu':1,'EleEle':2,'Mu':3,'Ele':4,'Had':5}
0126   unsigned int box_num = 5;
0127   if (nmu_tight > 0 && nele_tight > 0) {
0128     box_num = 0;
0129   } else if (nmu_tight > 0 && nmu_loose > 1) {
0130     box_num = 1;
0131   } else if (nele_tight > 0 && nele_loose > 1) {
0132     box_num = 2;
0133   } else if (nmu_tight > 0) {
0134     box_num = 3;
0135   } else if (nele_tight > 0) {
0136     box_num = 4;
0137   }
0138 
0139   edm::Handle<std::vector<double>> razorvar_handle;
0140   iEvent.getByToken(m_razorVarCollectionTagToken_, razorvar_handle);
0141   if (razorvar_handle->size() > 1) {
0142     const double MR = razorvar_handle->at(0);
0143     const double R = razorvar_handle->at(1);
0144     m_rsqMRFullyInc->Fill(MR, R * R);
0145     if (njets >= 4)
0146       m_rsqMRInc4J->Fill(MR, R * R);
0147     if (njets >= 6)
0148       m_rsqMRInc6J->Fill(MR, R * R);
0149     if (njets >= 8)
0150       m_rsqMRInc8J->Fill(MR, R * R);
0151     if (njets >= 10)
0152       m_rsqMRInc10J->Fill(MR, R * R);
0153     if (njets >= 12)
0154       m_rsqMRInc12J->Fill(MR, R * R);
0155     if (njets >= 14)
0156       m_rsqMRInc14J->Fill(MR, R * R);
0157 
0158     // now fill the boxes
0159     if (box_num == 0)
0160       m_rsqMREleMu->Fill(MR, R * R);
0161     if (box_num == 1)
0162       m_rsqMRMuMu->Fill(MR, R * R);
0163     if (box_num == 2)
0164       m_rsqMREleEle->Fill(MR, R * R);
0165     if (box_num == 3)
0166       m_rsqMRMu->Fill(MR, R * R);
0167     if (box_num == 4)
0168       m_rsqMREle->Fill(MR, R * R);
0169     if (box_num == 5)
0170       m_rsqMRHad->Fill(MR, R * R);
0171 
0172     // finally the multijet boxes - think ttbar
0173     // muon boxes: muons are not in jets
0174     if (box_num == 3 && njets >= 4)
0175       m_rsqMRMuMJ->Fill(MR, R * R);
0176     // ele boxes: electrons are in jets
0177     else if (box_num == 4 && njets >= 5)
0178       m_rsqMREleMJ->Fill(MR, R * R);
0179     // fill the Had box
0180     else if (box_num == 5 && njets >= 6)
0181       m_rsqMRHadMJ->Fill(MR, R * R);
0182   }
0183 }