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_Electron_BJet.h"
0008 
0009 SUSY_HLT_Electron_BJet::SUSY_HLT_Electron_BJet(const edm::ParameterSet &ps) {
0010   edm::LogInfo("SUSY_HLT_Electron_BJet") << "Constructor SUSY_HLT_Electron_BJet::SUSY_HLT_Electron_BJet " << std::endl;
0011   // Get parameters from configuration file

0012   theTrigSummary_ = consumes<trigger::TriggerEvent>(ps.getParameter<edm::InputTag>("trigSummary"));
0013   theElectronCollection_ = consumes<reco::GsfElectronCollection>(ps.getParameter<edm::InputTag>("ElectronCollection"));
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   triggerFilterEle_ = ps.getParameter<edm::InputTag>("TriggerFilterEle");
0020   triggerFilterJet_ = ps.getParameter<edm::InputTag>("TriggerFilterJet");
0021   ptThrJet_ = ps.getUntrackedParameter<double>("PtThrJet");
0022   etaThrJet_ = ps.getUntrackedParameter<double>("EtaThrJet");
0023 }
0024 
0025 SUSY_HLT_Electron_BJet::~SUSY_HLT_Electron_BJet() {
0026   edm::LogInfo("SUSY_HLT_Electron_BJet") << "Destructor SUSY_HLT_Electron_BJet::~SUSY_HLT_Electron_BJet " << std::endl;
0027 }
0028 
0029 void SUSY_HLT_Electron_BJet::dqmBeginRun(edm::Run const &run, edm::EventSetup const &e) {
0030   bool changed;
0031 
0032   if (!fHltConfig.init(run, e, HLTProcess_, changed)) {
0033     edm::LogError("SUSY_HLT_Electron_BJet") << "Initialization of HLTConfigProvider failed!!";
0034     return;
0035   }
0036 
0037   bool pathFound = false;
0038   const std::vector<std::string> allTrigNames = fHltConfig.triggerNames();
0039   for (size_t j = 0; j < allTrigNames.size(); ++j) {
0040     if (allTrigNames[j].find(triggerPath_) != std::string::npos) {
0041       pathFound = true;
0042     }
0043   }
0044 
0045   if (!pathFound) {
0046     LogDebug("SUSY_HLT_Electron_BJet") << "Path not found"
0047                                        << "\n";
0048     return;
0049   }
0050 
0051   edm::LogInfo("SUSY_HLT_Electron_BJet") << "SUSY_HLT_Electron_BJet::beginRun" << std::endl;
0052 }
0053 
0054 void SUSY_HLT_Electron_BJet::bookHistograms(DQMStore::IBooker &ibooker_, edm::Run const &, edm::EventSetup const &) {
0055   edm::LogInfo("SUSY_HLT_Electron_BJet") << "SUSY_HLT_Electron_BJet::bookHistograms" << std::endl;
0056   // book at beginRun

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

0064   //--- Trigger

0065   //-------------------------------

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

0082   std::vector<float> ptElectron;  //, etaElectron, phiElectron;

0083   size_t filterIndex = triggerSummary->filterIndex(triggerFilterEle_);
0084   trigger::TriggerObjectCollection triggerObjects = triggerSummary->getObjects();
0085   if (!(filterIndex >= triggerSummary->sizeFilters())) {
0086     const trigger::Keys &keys = triggerSummary->filterKeys(filterIndex);
0087     for (size_t j = 0; j < keys.size(); ++j) {
0088       trigger::TriggerObject foundObject = triggerObjects[keys[j]];
0089       if (fabs(foundObject.id()) == 11) {  // It's an electron

0090 
0091         bool same = false;
0092         for (unsigned int x = 0; x < ptElectron.size(); x++) {
0093           if (fabs(ptElectron[x] - foundObject.pt()) < 0.01)
0094             same = true;
0095         }
0096 
0097         if (!same) {
0098           h_triggerElePt->Fill(foundObject.pt());
0099           h_triggerEleEta->Fill(foundObject.eta());
0100           h_triggerElePhi->Fill(foundObject.phi());
0101           ptElectron.push_back(foundObject.pt());
0102         }
0103       }
0104     }
0105   }
0106 
0107   size_t filterIndex2 = triggerSummary->filterIndex(triggerFilterJet_);
0108   if (!(filterIndex2 >= triggerSummary->sizeFilters())) {
0109     const trigger::Keys &keys = triggerSummary->filterKeys(filterIndex2);
0110     for (size_t j = 0; j < keys.size(); ++j) {
0111       trigger::TriggerObject foundObject = triggerObjects[keys[j]];
0112       h_triggerJetPt->Fill(foundObject.pt());
0113       h_triggerJetEta->Fill(foundObject.eta());
0114       h_triggerJetPhi->Fill(foundObject.phi());
0115     }
0116   }
0117 }
0118 
0119 void SUSY_HLT_Electron_BJet::bookHistos(DQMStore::IBooker &ibooker_) {
0120   ibooker_.cd();
0121   ibooker_.setCurrentFolder("HLT/SUSYBSM/" + triggerPath_);
0122 
0123   // offline quantities

0124 
0125   // online quantities

0126   h_triggerElePt = ibooker_.book1D("triggerElePt", "Trigger Electron Pt; GeV", 50, 0.0, 500.0);
0127   h_triggerEleEta = ibooker_.book1D("triggerEleEta", "Trigger Electron Eta", 20, -3.0, 3.0);
0128   h_triggerElePhi = ibooker_.book1D("triggerElePhi", "Trigger Electron Phi", 20, -3.5, 3.5);
0129 
0130   h_triggerJetPt = ibooker_.book1D("triggerJetPt", "Trigger Jet Pt; GeV", 50, 0.0, 500.0);
0131   h_triggerJetEta = ibooker_.book1D("triggerJetEta", "Trigger Jet Eta", 20, -3.0, 3.0);
0132   h_triggerJetPhi = ibooker_.book1D("triggerJetPhi", "Trigger Jet Phi", 20, -3.5, 3.5);
0133 
0134   ibooker_.cd();
0135 }
0136 
0137 // define this as a plug-in

0138 DEFINE_FWK_MODULE(SUSY_HLT_Electron_BJet);