CMS 3D CMS Logo

SUSY_HLT_PhotonHT.cc
Go to the documentation of this file.
7 
9  edm::LogInfo("SUSY_HLT_PhotonHT") << "Constructor SUSY_HLT_PhotonHT::SUSY_HLT_PhotonHT " << std::endl;
10  // Get parameters from configuration file
11  theTrigSummary_ = consumes<trigger::TriggerEvent>(ps.getParameter<edm::InputTag>("trigSummary"));
12  thePfMETCollection_ = consumes<reco::PFMETCollection>(ps.getParameter<edm::InputTag>("pfMETCollection"));
13  thePhotonCollection_ = consumes<reco::PhotonCollection>(ps.getParameter<edm::InputTag>("photonCollection"));
14  triggerResults_ = consumes<edm::TriggerResults>(ps.getParameter<edm::InputTag>("TriggerResults"));
15  triggerPath_ = ps.getParameter<std::string>("TriggerPath");
16  triggerPathAuxiliaryForHadronic_ = ps.getParameter<std::string>("TriggerPathAuxiliaryForHadronic");
17  triggerFilterPhoton_ = ps.getParameter<edm::InputTag>("TriggerFilterPhoton");
18  triggerFilterHt_ = ps.getParameter<edm::InputTag>("TriggerFilterHt");
19  ptThrOffline_ = ps.getUntrackedParameter<double>("ptThrOffline");
20  htThrOffline_ = ps.getUntrackedParameter<double>("htThrOffline");
21 }
22 
24  edm::LogInfo("SUSY_HLT_PhotonHT") << "Destructor SUSY_HLT_PhotonHT::~SUSY_HLT_PhotonHT " << std::endl;
25 }
26 
28  edm::LogInfo("SUSY_HLT_PhotonHT") << "SUSY_HLT_PhotonHT::beginRun" << std::endl;
29 }
30 
32  edm::LogInfo("SUSY_HLT_PhotonHT") << "SUSY_HLT_PhotonHT::bookHistograms" << std::endl;
33  // book at beginRun
34  bookHistos(ibooker_);
35 }
36 
38  edm::LogInfo("SUSY_HLT_PhotonHT") << "SUSY_HLT_PhotonHT::analyze" << std::endl;
39 
40  //-------------------------------
41  //--- MET / HT
42  //-------------------------------
43  edm::Handle<reco::PFMETCollection> pfMETCollection;
44  e.getByToken(thePfMETCollection_, pfMETCollection);
45  if (!pfMETCollection.isValid()) {
46  edm::LogError("SUSY_HLT_PhotonHT") << "invalid met collection"
47  << "\n";
48  return;
49  }
50  //-------------------------------
51  //--- Photon
52  //-------------------------------
54  e.getByToken(thePhotonCollection_, photonCollection);
55  if (!photonCollection.isValid()) {
56  edm::LogError("SUSY_HLT_PhotonHT") << "invalid egamma collection"
57  << "\n";
58  return;
59  }
60 
61  // check what is in the menu
63  e.getByToken(triggerResults_, hltresults);
64  if (!hltresults.isValid()) {
65  edm::LogError("SUSY_HLT_PhotonHT") << "invalid collection: TriggerResults"
66  << "\n";
67  return;
68  }
69 
70  //-------------------------------
71  //--- Trigger
72  //-------------------------------
74  e.getByToken(theTrigSummary_, triggerSummary);
75  if (!triggerSummary.isValid()) {
76  edm::LogError("SUSY_HLT_PhotonHT") << "invalid collection: TriggerSummary"
77  << "\n";
78  return;
79  }
80 
81  // get online objects
83 
84  // get the photon object
85  size_t filterIndexPhoton = triggerSummary->filterIndex(triggerFilterPhoton_);
86  if (filterIndexPhoton < triggerSummary->sizeFilters()) {
87  const trigger::Keys &keys = triggerSummary->filterKeys(filterIndexPhoton);
88  if (!keys.empty()) {
89  // take the leading photon
90  float pt = triggerObjects[keys[0]].pt();
91  h_photonPt->Fill(pt);
92  }
93  }
94 
95  // get ht
96  size_t filterIndexHt = triggerSummary->filterIndex(triggerFilterHt_);
97  if (filterIndexHt < triggerSummary->sizeFilters()) {
98  const trigger::Keys &keys = triggerSummary->filterKeys(filterIndexHt);
99  if (!keys.empty()) {
100  float ht = triggerObjects[keys[0]].pt();
101  h_ht->Fill(ht);
102  }
103  }
104 
105  bool hasFired = false, hasFiredAuxiliaryForHadronicLeg = false;
106  const edm::TriggerNames &trigNames = e.triggerNames(*hltresults);
107  unsigned int numTriggers = trigNames.size();
108  for (unsigned int hltIndex = 0; hltIndex < numTriggers; ++hltIndex) {
109  if (trigNames.triggerName(hltIndex).find(triggerPath_) != std::string::npos && hltresults->wasrun(hltIndex) &&
110  hltresults->accept(hltIndex))
111  hasFired = true;
112  if (trigNames.triggerName(hltIndex).find(triggerPathAuxiliaryForHadronic_) != std::string::npos &&
113  hltresults->wasrun(hltIndex) && hltresults->accept(hltIndex))
114  hasFiredAuxiliaryForHadronicLeg = true;
115  }
116 
117  if (hasFiredAuxiliaryForHadronicLeg || !e.isRealData()) {
118  float recoPhotonPt = !photonCollection->empty() ? photonCollection->begin()->et() : 0;
119  float recoHt = !pfMETCollection->empty() ? pfMETCollection->begin()->et() : 0;
120 
121  if (hasFired) {
122  if (!photonCollection->empty() && recoHt >= htThrOffline_)
123  h_photonTurnOn_num->Fill(recoPhotonPt);
124  if (!pfMETCollection->empty() && recoPhotonPt >= ptThrOffline_)
125  h_htTurnOn_num->Fill(recoHt);
126  }
127  if (!photonCollection->empty() && recoHt >= htThrOffline_)
128  h_photonTurnOn_den->Fill(recoPhotonPt);
129  if (!pfMETCollection->empty() && recoPhotonPt >= ptThrOffline_)
130  h_htTurnOn_den->Fill(recoPhotonPt);
131  }
132 }
133 
135  edm::LogInfo("SUSY_HLT_PhotonHT") << "SUSY_HLT_PhotonHT::endRun" << std::endl;
136 }
137 
139  ibooker_.cd();
140  ibooker_.setCurrentFolder("HLT/SUSYBSM/" + triggerPath_);
141 
142  // offline quantities
143  h_photonPt = ibooker_.book1D("photonPt", "Photon transverse momentum; p_{T} (GeV)", 20, 0, 500);
144  h_ht = ibooker_.book1D("ht", "Hadronic activity;H_{T} (GeV)", 20, 0, 2000);
145  h_htTurnOn_num = ibooker_.book1D("pfHtTurnOn_num", "PF HT Turn On Numerator", 20, 300, 800);
146  h_htTurnOn_den = ibooker_.book1D("pfHtTurnOn_den", "PF HT Turn On Denominator", 20, 300, 800);
147  h_photonTurnOn_num = ibooker_.book1D("photonTurnOn_num", "Photon Turn On Numerator", 20, 70, 130);
148  h_photonTurnOn_den = ibooker_.book1D("photonTurnOn_den", "Photon Turn On Denominator", 20, 70, 130);
149 
150  ibooker_.cd();
151 }
152 
153 // define this as a plug-in
MonitorElement * h_photonTurnOn_den
edm::EDGetTokenT< edm::TriggerResults > triggerResults_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool wasrun() const
Was at least one path run?
void bookHistos(DQMStore::IBooker &)
MonitorElement * h_ht
edm::InputTag triggerFilterHt_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
bool accept() const
Has at least one path accepted the event?
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:111
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:123
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
edm::InputTag triggerFilterPhoton_
Strings::size_type size() const
Definition: TriggerNames.cc:31
bool isRealData() const
Definition: EventBase.h:62
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
void Fill(long long x)
edm::EDGetTokenT< reco::PFMETCollection > thePfMETCollection_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
MonitorElement * h_htTurnOn_den
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
MonitorElement * h_photonPt
bool isValid() const
Definition: HandleBase.h:74
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:74
MonitorElement * h_htTurnOn_num
~SUSY_HLT_PhotonHT() override
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:22
std::vector< size_type > Keys
std::string triggerPathAuxiliaryForHadronic_
MonitorElement * h_photonTurnOn_num
std::string triggerPath_
edm::EDGetTokenT< reco::PhotonCollection > thePhotonCollection_
edm::EDGetTokenT< trigger::TriggerEvent > theTrigSummary_
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:256
SUSY_HLT_PhotonHT(const edm::ParameterSet &ps)
Definition: Run.h:45