Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:21:02

0001 #include "DataFormats/HLTReco/interface/TriggerObject.h"
0002 #include "DataFormats/Math/interface/LorentzVector.h"
0003 #include "FWCore/Common/interface/TriggerNames.h"
0004 #include "FWCore/Framework/interface/Frameworkfwd.h"
0005 #include "FWCore/Framework/interface/MakerMacros.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "HLTriggerOffline/SUSYBSM/interface/SUSY_HLT_Muon_BJet.h"
0008 
0009 SUSY_HLT_Muon_BJet::SUSY_HLT_Muon_BJet(const edm::ParameterSet &ps) {
0010   edm::LogInfo("SUSY_HLT_Muon_BJet") << "Constructor SUSY_HLT_Muon_BJet::SUSY_HLT_Muon_BJet " << std::endl;
0011   // Get parameters from configuration file

0012   theTrigSummary_ = consumes<trigger::TriggerEvent>(ps.getParameter<edm::InputTag>("trigSummary"));
0013   theMuonCollection_ = consumes<reco::MuonCollection>(ps.getParameter<edm::InputTag>("MuonCollection"));
0014   thePfJetCollection_ = consumes<reco::PFJetCollection>(ps.getParameter<edm::InputTag>("pfJetCollection"));
0015   theCaloJetCollection_ = consumes<reco::CaloJetCollection>(ps.getParameter<edm::InputTag>("caloJetCollection"));
0016   triggerResults_ = consumes<edm::TriggerResults>(ps.getParameter<edm::InputTag>("TriggerResults"));
0017   HLTProcess_ = ps.getParameter<std::string>("HLTProcess");
0018   triggerPath_ = ps.getParameter<std::string>("TriggerPath");
0019   triggerFilterMuon_ = ps.getParameter<edm::InputTag>("TriggerFilterMuon");
0020   triggerFilterJet_ = ps.getParameter<edm::InputTag>("TriggerFilterJet");
0021   ptThrJet_ = ps.getUntrackedParameter<double>("PtThrJet");
0022   etaThrJet_ = ps.getUntrackedParameter<double>("EtaThrJet");
0023 }
0024 
0025 SUSY_HLT_Muon_BJet::~SUSY_HLT_Muon_BJet() {
0026   edm::LogInfo("SUSY_HLT_Muon_BJet") << "Destructor SUSY_HLT_Muon_BJet::~SUSY_HLT_Muon_BJet " << std::endl;
0027 }
0028 
0029 void SUSY_HLT_Muon_BJet::dqmBeginRun(edm::Run const &run,
0030                                      edm::EventSetup const &e)  //

0031 {
0032   bool changed;
0033 
0034   if (!fHltConfig.init(run, e, HLTProcess_, changed)) {
0035     edm::LogError("SUSY_HLT_Muon_BJet") << "Initialization of HLTConfigProvider failed!!";
0036     return;
0037   }
0038 
0039   bool pathFound = false;
0040   const std::vector<std::string> allTrigNames = fHltConfig.triggerNames();
0041   for (size_t j = 0; j < allTrigNames.size(); ++j) {
0042     if (allTrigNames[j].find(triggerPath_) != std::string::npos) {
0043       pathFound = true;
0044     }
0045   }
0046 
0047   if (!pathFound) {
0048     LogDebug("SUSY_HLT_Muon_BJet") << "Path not found"
0049                                    << "\n";
0050     return;
0051   }
0052 
0053   edm::LogInfo("SUSY_HLT_Muon_BJet") << "SUSY_HLT_Muon_BJet::beginRun" << std::endl;
0054 }
0055 
0056 void SUSY_HLT_Muon_BJet::bookHistograms(DQMStore::IBooker &ibooker_, edm::Run const &, edm::EventSetup const &) {
0057   edm::LogInfo("SUSY_HLT_Muon_BJet") << "SUSY_HLT_Muon_BJet::bookHistograms" << std::endl;
0058   // book at beginRun

0059   bookHistos(ibooker_);
0060 }
0061 
0062 void SUSY_HLT_Muon_BJet::analyze(edm::Event const &e, edm::EventSetup const &eSetup) {
0063   edm::LogInfo("SUSY_HLT_Muon_BJet") << "SUSY_HLT_Muon_BJet::analyze" << std::endl;
0064 
0065   //-------------------------------

0066   //--- Trigger

0067   //-------------------------------

0068   edm::Handle<edm::TriggerResults> hltresults;
0069   e.getByToken(triggerResults_, hltresults);
0070   if (!hltresults.isValid()) {
0071     edm::LogError("SUSY_HLT_Muon_BJet") << "invalid collection: TriggerResults"
0072                                         << "\n";
0073     return;
0074   }
0075   edm::Handle<trigger::TriggerEvent> triggerSummary;
0076   e.getByToken(theTrigSummary_, triggerSummary);
0077   if (!triggerSummary.isValid()) {
0078     edm::LogError("SUSY_HLT_Muon_BJet") << "invalid collection: TriggerSummary"
0079                                         << "\n";
0080     return;
0081   }
0082 
0083   // get online objects

0084   // std::vector<float> ptMuon, etaMuon, phiMuon;

0085   size_t filterIndex = triggerSummary->filterIndex(triggerFilterMuon_);
0086   trigger::TriggerObjectCollection triggerObjects = triggerSummary->getObjects();
0087   if (!(filterIndex >= triggerSummary->sizeFilters())) {
0088     const trigger::Keys &keys = triggerSummary->filterKeys(filterIndex);
0089     for (size_t j = 0; j < keys.size(); ++j) {
0090       trigger::TriggerObject foundObject = triggerObjects[keys[j]];
0091       if (fabs(foundObject.id()) == 13) {  // It's a muon

0092         h_triggerMuPt->Fill(foundObject.pt());
0093         h_triggerMuEta->Fill(foundObject.eta());
0094         h_triggerMuPhi->Fill(foundObject.phi());
0095         //  ptMuon.push_back(foundObject.pt());

0096         // etaMuon.push_back(foundObject.eta());

0097         // phiMuon.push_back(foundObject.phi());

0098       }
0099     }
0100   }
0101 
0102   size_t filterIndex2 = triggerSummary->filterIndex(triggerFilterJet_);
0103   if (!(filterIndex2 >= triggerSummary->sizeFilters())) {
0104     const trigger::Keys &keys = triggerSummary->filterKeys(filterIndex2);
0105     for (size_t j = 0; j < keys.size(); ++j) {
0106       trigger::TriggerObject foundObject = triggerObjects[keys[j]];
0107       h_triggerJetPt->Fill(foundObject.pt());
0108       h_triggerJetEta->Fill(foundObject.eta());
0109       h_triggerJetPhi->Fill(foundObject.phi());
0110     }
0111   }
0112 }
0113 
0114 void SUSY_HLT_Muon_BJet::bookHistos(DQMStore::IBooker &ibooker_) {
0115   ibooker_.cd();
0116   ibooker_.setCurrentFolder("HLT/SUSYBSM/" + triggerPath_);
0117 
0118   // offline quantities

0119 
0120   // online quantities

0121   h_triggerMuPt = ibooker_.book1D("triggerMuPt", "Trigger Muon Pt; GeV", 50, 0.0, 500.0);
0122   h_triggerMuEta = ibooker_.book1D("triggerMuEta", "Trigger Muon Eta", 20, -3.0, 3.0);
0123   h_triggerMuPhi = ibooker_.book1D("triggerMuPhi", "Trigger Muon Phi", 20, -3.5, 3.5);
0124 
0125   h_triggerJetPt = ibooker_.book1D("triggerJetPt", "Trigger Jet Pt; GeV", 50, 0.0, 500.0);
0126   h_triggerJetEta = ibooker_.book1D("triggerJetEta", "Trigger Jet Eta", 20, -3.0, 3.0);
0127   h_triggerJetPhi = ibooker_.book1D("triggerJetPhi", "Trigger Jet Phi", 20, -3.5, 3.5);
0128 
0129   ibooker_.cd();
0130 }
0131 
0132 // define this as a plug-in

0133 DEFINE_FWK_MODULE(SUSY_HLT_Muon_BJet);