Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DataFormats/HLTReco/interface/TriggerObject.h"
0002 #include "FWCore/Common/interface/TriggerNames.h"
0003 #include "FWCore/Framework/interface/Frameworkfwd.h"
0004 #include "FWCore/Framework/interface/MakerMacros.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "HLTriggerOffline/SUSYBSM/interface/SUSY_HLT_InclusiveHT.h"
0007 
0008 SUSY_HLT_InclusiveHT::SUSY_HLT_InclusiveHT(const edm::ParameterSet &ps) {
0009   edm::LogInfo("SUSY_HLT_InclusiveHT") << "Constructor SUSY_HLT_InclusiveHT::SUSY_HLT_InclusiveHT " << std::endl;
0010   // Get parameters from configuration file
0011   theTrigSummary_ = consumes<trigger::TriggerEvent>(ps.getParameter<edm::InputTag>("trigSummary"));
0012   thePfMETCollection_ = consumes<reco::PFMETCollection>(ps.getParameter<edm::InputTag>("pfMETCollection"));
0013   thePfJetCollection_ = consumes<reco::PFJetCollection>(ps.getParameter<edm::InputTag>("pfJetCollection"));
0014   theCaloJetCollection_ = consumes<reco::CaloJetCollection>(ps.getParameter<edm::InputTag>("caloJetCollection"));
0015   triggerResults_ = consumes<edm::TriggerResults>(ps.getParameter<edm::InputTag>("TriggerResults"));
0016   triggerPath_ = ps.getParameter<std::string>("TriggerPath");
0017   triggerPathAuxiliaryForHadronic_ = ps.getParameter<std::string>("TriggerPathAuxiliaryForHadronic");
0018   triggerFilter_ = ps.getParameter<edm::InputTag>("TriggerFilter");
0019   ptThrJet_ = ps.getUntrackedParameter<double>("PtThrJet");
0020   etaThrJet_ = ps.getUntrackedParameter<double>("EtaThrJet");
0021 }
0022 
0023 SUSY_HLT_InclusiveHT::~SUSY_HLT_InclusiveHT() {
0024   edm::LogInfo("SUSY_HLT_InclusiveHT") << "Destructor SUSY_HLT_InclusiveHT::~SUSY_HLT_InclusiveHT " << std::endl;
0025 }
0026 
0027 void SUSY_HLT_InclusiveHT::bookHistograms(DQMStore::IBooker &ibooker_, edm::Run const &, edm::EventSetup const &) {
0028   edm::LogInfo("SUSY_HLT_InclusiveHT") << "SUSY_HLT_InclusiveHT::bookHistograms" << std::endl;
0029   // book at beginRun
0030   bookHistos(ibooker_);
0031 }
0032 
0033 void SUSY_HLT_InclusiveHT::analyze(edm::Event const &e, edm::EventSetup const &eSetup) {
0034   edm::LogInfo("SUSY_HLT_InclusiveHT") << "SUSY_HLT_InclusiveHT::analyze" << std::endl;
0035 
0036   //-------------------------------
0037   //--- MET
0038   //-------------------------------
0039   edm::Handle<reco::PFMETCollection> pfMETCollection;
0040   e.getByToken(thePfMETCollection_, pfMETCollection);
0041   if (!pfMETCollection.isValid()) {
0042     edm::LogError("SUSY_HLT_InclusiveHT") << "invalid collection: PFMET"
0043                                           << "\n";
0044     return;
0045   }
0046   //-------------------------------
0047   //--- Jets
0048   //-------------------------------
0049   edm::Handle<reco::PFJetCollection> pfJetCollection;
0050   e.getByToken(thePfJetCollection_, pfJetCollection);
0051   if (!pfJetCollection.isValid()) {
0052     edm::LogError("SUSY_HLT_InclusiveHT") << "invalid collection: PFJets"
0053                                           << "\n";
0054     return;
0055   }
0056   edm::Handle<reco::CaloJetCollection> caloJetCollection;
0057   e.getByToken(theCaloJetCollection_, caloJetCollection);
0058   if (!caloJetCollection.isValid()) {
0059     edm::LogError("SUSY_HLT_InclusiveHT") << "invalid collection: CaloJets"
0060                                           << "\n";
0061     return;
0062   }
0063 
0064   // check what is in the menu
0065   edm::Handle<edm::TriggerResults> hltresults;
0066   e.getByToken(triggerResults_, hltresults);
0067   if (!hltresults.isValid()) {
0068     edm::LogError("SUSY_HLT_InclusiveHT") << "invalid collection: TriggerResults"
0069                                           << "\n";
0070     return;
0071   }
0072 
0073   //-------------------------------
0074   //--- Trigger
0075   //-------------------------------
0076   edm::Handle<trigger::TriggerEvent> triggerSummary;
0077   e.getByToken(theTrigSummary_, triggerSummary);
0078   if (!triggerSummary.isValid()) {
0079     edm::LogError("SUSY_HLT_InclusiveHT") << "invalid collection: TriggerSummary"
0080                                           << "\n";
0081     return;
0082   }
0083 
0084   // get online objects
0085   size_t filterIndex = triggerSummary->filterIndex(triggerFilter_);
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(foundObject.id() == 85 && foundObject.pt() > 40.0 &&
0092       // fabs(foundObject.eta()) < 3.0){
0093       //  h_triggerJetPt->Fill(foundObject.pt());
0094       //  h_triggerJetEta->Fill(foundObject.eta());
0095       //  h_triggerJetPhi->Fill(foundObject.phi());
0096       //}
0097       if (foundObject.id() == 87) {
0098         h_triggerMetPt->Fill(foundObject.pt());
0099         h_triggerMetPhi->Fill(foundObject.phi());
0100       }
0101       if (foundObject.id() == 89) {
0102         h_triggerHT->Fill(foundObject.pt());
0103       }
0104     }
0105   }
0106 
0107   bool hasFired = false, hasFiredAuxiliaryForHadronicLeg = false;
0108   const edm::TriggerNames &trigNames = e.triggerNames(*hltresults);
0109   unsigned int numTriggers = trigNames.size();
0110   for (unsigned int hltIndex = 0; hltIndex < numTriggers; ++hltIndex) {
0111     if (trigNames.triggerName(hltIndex).find(triggerPath_) != std::string::npos && hltresults->wasrun(hltIndex) &&
0112         hltresults->accept(hltIndex))
0113       hasFired = true;
0114     if (trigNames.triggerName(hltIndex).find(triggerPathAuxiliaryForHadronic_) != std::string::npos &&
0115         hltresults->wasrun(hltIndex) && hltresults->accept(hltIndex))
0116       hasFiredAuxiliaryForHadronicLeg = true;
0117   }
0118 
0119   if (hasFiredAuxiliaryForHadronicLeg || !e.isRealData()) {
0120     float caloHT = 0.0;
0121     float pfHT = 0.0;
0122     for (reco::PFJetCollection::const_iterator i_pfjet = pfJetCollection->begin(); i_pfjet != pfJetCollection->end();
0123          ++i_pfjet) {
0124       if (i_pfjet->pt() < ptThrJet_)
0125         continue;
0126       if (fabs(i_pfjet->eta()) > etaThrJet_)
0127         continue;
0128       pfHT += i_pfjet->pt();
0129     }
0130 
0131     if (hasFired) {
0132       for (reco::CaloJetCollection::const_iterator i_calojet = caloJetCollection->begin();
0133            i_calojet != caloJetCollection->end();
0134            ++i_calojet) {
0135         if (i_calojet->pt() < ptThrJet_)
0136           continue;
0137         if (fabs(i_calojet->eta()) > etaThrJet_)
0138           continue;
0139         h_caloJetPt->Fill(i_calojet->pt());
0140         h_caloJetEta->Fill(i_calojet->eta());
0141         h_caloJetPhi->Fill(i_calojet->phi());
0142         caloHT += i_calojet->pt();
0143       }
0144       for (reco::PFJetCollection::const_iterator i_pfjet = pfJetCollection->begin(); i_pfjet != pfJetCollection->end();
0145            ++i_pfjet) {
0146         if (i_pfjet->pt() < ptThrJet_)
0147           continue;
0148         if (fabs(i_pfjet->eta()) > etaThrJet_)
0149           continue;
0150         h_pfJetPt->Fill(i_pfjet->pt());
0151         h_pfJetEta->Fill(i_pfjet->eta());
0152         h_pfJetPhi->Fill(i_pfjet->phi());
0153       }
0154       h_pfMet->Fill(pfMETCollection->begin()->et());
0155       h_pfMetPhi->Fill(pfMETCollection->begin()->phi());
0156       h_pfHT->Fill(pfHT);
0157       h_caloHT->Fill(caloHT);
0158 
0159       h_pfMetTurnOn_num->Fill(pfMETCollection->begin()->et());
0160       h_pfHTTurnOn_num->Fill(pfHT);
0161     }
0162     // fill denominator histograms for all events, used for turn on curves
0163     h_pfMetTurnOn_den->Fill(pfMETCollection->begin()->et());
0164     h_pfHTTurnOn_den->Fill(pfHT);
0165   }
0166 }
0167 
0168 void SUSY_HLT_InclusiveHT::bookHistos(DQMStore::IBooker &ibooker_) {
0169   ibooker_.cd();
0170   ibooker_.setCurrentFolder("HLT/SUSYBSM/" + triggerPath_);
0171 
0172   // offline quantities
0173   h_pfMet = ibooker_.book1D("pfMet", "PF Missing E_{T}; GeV", 20, 0.0, 500.0);
0174   h_pfMetPhi = ibooker_.book1D("pfMetPhi", "PF MET Phi", 20, -3.5, 3.5);
0175   h_pfHT = ibooker_.book1D("pfHT", "PF H_{T}; GeV", 30, 0.0, 1500.0);
0176   h_caloHT = ibooker_.book1D("caloHT", "Calo H_{T}; GeV", 30, 0.0, 1500.0);
0177   h_pfJetPt = ibooker_.book1D("pfJetPt", "PFJet P_{T}; GeV", 20, 0.0, 500.0);
0178   h_pfJetEta = ibooker_.book1D("pfJetEta", "PFJet Eta", 20, -3.0, 3.0);
0179   h_pfJetPhi = ibooker_.book1D("pfJetPhi", "PFJet Phi", 20, -3.5, 3.5);
0180   h_caloJetPt = ibooker_.book1D("caloJetPt", "CaloJet P_{T}; GeV", 20, 0.0, 500.0);
0181   h_caloJetEta = ibooker_.book1D("caloJetEta", "CaloJet Eta", 20, -3.0, 3.0);
0182   h_caloJetPhi = ibooker_.book1D("caloJetPhi", "CaloJet Phi", 20, -3.5, 3.5);
0183 
0184   // online quantities
0185   // h_triggerJetPt = ibooker_.book1D("triggerJetPt", "Trigger Jet Pt; GeV", 20,
0186   // 0.0, 500.0); h_triggerJetEta = ibooker_.book1D("triggerJetEta", "Trigger
0187   // Jet Eta", 20, -3.0, 3.0); h_triggerJetPhi =
0188   // ibooker_.book1D("triggerJetPhi", "Trigger Jet Phi", 20, -3.5, 3.5);
0189   h_triggerMetPt = ibooker_.book1D("triggerMetPt", "Trigger Met Pt; GeV", 20, 0.0, 500.0);
0190   h_triggerMetPhi = ibooker_.book1D("triggerMetPhi", "Trigger Met Phi", 20, -3.5, 3.5);
0191   h_triggerHT = ibooker_.book1D("triggerHT", "Trigger HT; GeV", 30, 0.0, 1500.0);
0192 
0193   // num and den hists to be divided in harvesting step to make turn on curves
0194   h_pfMetTurnOn_num = ibooker_.book1D("pfMetTurnOn_num", "PF MET Turn On Numerator", 20, 0.0, 500.0);
0195   h_pfMetTurnOn_den = ibooker_.book1D("pfMetTurnOn_den", "PF MET Turn OnDenominator", 20, 0.0, 500.0);
0196   h_pfHTTurnOn_num = ibooker_.book1D("pfHTTurnOn_num", "PF HT Turn On Numerator", 30, 0.0, 1500.0);
0197   h_pfHTTurnOn_den = ibooker_.book1D("pfHTTurnOn_den", "PF HT Turn On Denominator", 30, 0.0, 1500.0);
0198 
0199   ibooker_.cd();
0200 }
0201 
0202 // define this as a plug-in
0203 DEFINE_FWK_MODULE(SUSY_HLT_InclusiveHT);