Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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_PhotonHT.h"
0007 
0008 SUSY_HLT_PhotonHT::SUSY_HLT_PhotonHT(const edm::ParameterSet &ps) {
0009   edm::LogInfo("SUSY_HLT_PhotonHT") << "Constructor SUSY_HLT_PhotonHT::SUSY_HLT_PhotonHT " << 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   thePhotonCollection_ = consumes<reco::PhotonCollection>(ps.getParameter<edm::InputTag>("photonCollection"));
0014   triggerResults_ = consumes<edm::TriggerResults>(ps.getParameter<edm::InputTag>("TriggerResults"));
0015   triggerPath_ = ps.getParameter<std::string>("TriggerPath");
0016   triggerPathAuxiliaryForHadronic_ = ps.getParameter<std::string>("TriggerPathAuxiliaryForHadronic");
0017   triggerFilterPhoton_ = ps.getParameter<edm::InputTag>("TriggerFilterPhoton");
0018   triggerFilterHt_ = ps.getParameter<edm::InputTag>("TriggerFilterHt");
0019   ptThrOffline_ = ps.getUntrackedParameter<double>("ptThrOffline");
0020   htThrOffline_ = ps.getUntrackedParameter<double>("htThrOffline");
0021 }
0022 
0023 SUSY_HLT_PhotonHT::~SUSY_HLT_PhotonHT() {
0024   edm::LogInfo("SUSY_HLT_PhotonHT") << "Destructor SUSY_HLT_PhotonHT::~SUSY_HLT_PhotonHT " << std::endl;
0025 }
0026 
0027 void SUSY_HLT_PhotonHT::bookHistograms(DQMStore::IBooker &ibooker_, edm::Run const &, edm::EventSetup const &) {
0028   edm::LogInfo("SUSY_HLT_PhotonHT") << "SUSY_HLT_PhotonHT::bookHistograms" << std::endl;
0029   // book at beginRun
0030   bookHistos(ibooker_);
0031 }
0032 
0033 void SUSY_HLT_PhotonHT::analyze(edm::Event const &e, edm::EventSetup const &eSetup) {
0034   edm::LogInfo("SUSY_HLT_PhotonHT") << "SUSY_HLT_PhotonHT::analyze" << std::endl;
0035 
0036   //-------------------------------
0037   //--- MET / HT
0038   //-------------------------------
0039   edm::Handle<reco::PFMETCollection> pfMETCollection;
0040   e.getByToken(thePfMETCollection_, pfMETCollection);
0041   if (!pfMETCollection.isValid()) {
0042     edm::LogError("SUSY_HLT_PhotonHT") << "invalid met collection"
0043                                        << "\n";
0044     return;
0045   }
0046   //-------------------------------
0047   //--- Photon
0048   //-------------------------------
0049   edm::Handle<reco::PhotonCollection> photonCollection;
0050   e.getByToken(thePhotonCollection_, photonCollection);
0051   if (!photonCollection.isValid()) {
0052     edm::LogError("SUSY_HLT_PhotonHT") << "invalid egamma collection"
0053                                        << "\n";
0054     return;
0055   }
0056 
0057   // check what is in the menu
0058   edm::Handle<edm::TriggerResults> hltresults;
0059   e.getByToken(triggerResults_, hltresults);
0060   if (!hltresults.isValid()) {
0061     edm::LogError("SUSY_HLT_PhotonHT") << "invalid collection: TriggerResults"
0062                                        << "\n";
0063     return;
0064   }
0065 
0066   //-------------------------------
0067   //--- Trigger
0068   //-------------------------------
0069   edm::Handle<trigger::TriggerEvent> triggerSummary;
0070   e.getByToken(theTrigSummary_, triggerSummary);
0071   if (!triggerSummary.isValid()) {
0072     edm::LogError("SUSY_HLT_PhotonHT") << "invalid collection: TriggerSummary"
0073                                        << "\n";
0074     return;
0075   }
0076 
0077   // get online objects
0078   trigger::TriggerObjectCollection triggerObjects = triggerSummary->getObjects();
0079 
0080   // get the photon object
0081   size_t filterIndexPhoton = triggerSummary->filterIndex(triggerFilterPhoton_);
0082   if (filterIndexPhoton < triggerSummary->sizeFilters()) {
0083     const trigger::Keys &keys = triggerSummary->filterKeys(filterIndexPhoton);
0084     if (!keys.empty()) {
0085       // take the leading photon
0086       float pt = triggerObjects[keys[0]].pt();
0087       h_photonPt->Fill(pt);
0088     }
0089   }
0090 
0091   // get ht
0092   size_t filterIndexHt = triggerSummary->filterIndex(triggerFilterHt_);
0093   if (filterIndexHt < triggerSummary->sizeFilters()) {
0094     const trigger::Keys &keys = triggerSummary->filterKeys(filterIndexHt);
0095     if (!keys.empty()) {
0096       float ht = triggerObjects[keys[0]].pt();
0097       h_ht->Fill(ht);
0098     }
0099   }
0100 
0101   bool hasFired = false, hasFiredAuxiliaryForHadronicLeg = false;
0102   const edm::TriggerNames &trigNames = e.triggerNames(*hltresults);
0103   unsigned int numTriggers = trigNames.size();
0104   for (unsigned int hltIndex = 0; hltIndex < numTriggers; ++hltIndex) {
0105     if (trigNames.triggerName(hltIndex).find(triggerPath_) != std::string::npos && hltresults->wasrun(hltIndex) &&
0106         hltresults->accept(hltIndex))
0107       hasFired = true;
0108     if (trigNames.triggerName(hltIndex).find(triggerPathAuxiliaryForHadronic_) != std::string::npos &&
0109         hltresults->wasrun(hltIndex) && hltresults->accept(hltIndex))
0110       hasFiredAuxiliaryForHadronicLeg = true;
0111   }
0112 
0113   if (hasFiredAuxiliaryForHadronicLeg || !e.isRealData()) {
0114     float recoPhotonPt = !photonCollection->empty() ? photonCollection->begin()->et() : 0;
0115     float recoHt = !pfMETCollection->empty() ? pfMETCollection->begin()->et() : 0;
0116 
0117     if (hasFired) {
0118       if (!photonCollection->empty() && recoHt >= htThrOffline_)
0119         h_photonTurnOn_num->Fill(recoPhotonPt);
0120       if (!pfMETCollection->empty() && recoPhotonPt >= ptThrOffline_)
0121         h_htTurnOn_num->Fill(recoHt);
0122     }
0123     if (!photonCollection->empty() && recoHt >= htThrOffline_)
0124       h_photonTurnOn_den->Fill(recoPhotonPt);
0125     if (!pfMETCollection->empty() && recoPhotonPt >= ptThrOffline_)
0126       h_htTurnOn_den->Fill(recoPhotonPt);
0127   }
0128 }
0129 
0130 void SUSY_HLT_PhotonHT::bookHistos(DQMStore::IBooker &ibooker_) {
0131   ibooker_.cd();
0132   ibooker_.setCurrentFolder("HLT/SUSYBSM/" + triggerPath_);
0133 
0134   // offline quantities
0135   h_photonPt = ibooker_.book1D("photonPt", "Photon transverse momentum; p_{T} (GeV)", 20, 0, 500);
0136   h_ht = ibooker_.book1D("ht", "Hadronic activity;H_{T} (GeV)", 20, 0, 2000);
0137   h_htTurnOn_num = ibooker_.book1D("pfHtTurnOn_num", "PF HT Turn On Numerator", 20, 300, 800);
0138   h_htTurnOn_den = ibooker_.book1D("pfHtTurnOn_den", "PF HT Turn On Denominator", 20, 300, 800);
0139   h_photonTurnOn_num = ibooker_.book1D("photonTurnOn_num", "Photon Turn On Numerator", 20, 70, 130);
0140   h_photonTurnOn_den = ibooker_.book1D("photonTurnOn_den", "Photon Turn On Denominator", 20, 70, 130);
0141 
0142   ibooker_.cd();
0143 }
0144 
0145 // define this as a plug-in
0146 DEFINE_FWK_MODULE(SUSY_HLT_PhotonHT);