CMS 3D CMS Logo

SUSY_HLT_PhotonMET.cc
Go to the documentation of this file.
7 
9  edm::LogInfo("SUSY_HLT_PhotonMET") << "Constructor SUSY_HLT_PhotonMET::SUSY_HLT_PhotonMET " << std::endl;
10  // Get parameters from configuration file
11  thePfMETCollection_ = consumes<reco::PFMETCollection>(ps.getParameter<edm::InputTag>("pfMETCollection"));
12  thePhotonCollection_ = consumes<reco::PhotonCollection>(ps.getParameter<edm::InputTag>("photonCollection"));
13  triggerResults_ = consumes<edm::TriggerResults>(ps.getParameter<edm::InputTag>("TriggerResults"));
14  triggerPath_ = ps.getParameter<std::string>("TriggerPath");
15  triggerPathBase_ = ps.getParameter<std::string>("TriggerPathBase");
16  ptThrOffline_ = ps.getUntrackedParameter<double>("ptThrOffline");
17  metThrOffline_ = ps.getUntrackedParameter<double>("metThrOffline");
18 }
19 
21  edm::LogInfo("SUSY_HLT_PhotonMET") << "Destructor SUSY_HLT_PhotonMET::~SUSY_HLT_PhotonMET " << std::endl;
22 }
23 
25  edm::LogInfo("SUSY_HLT_PhotonMET") << "SUSY_HLT_PhotonMET::beginRun" << std::endl;
26 }
27 
29  edm::LogInfo("SUSY_HLT_PhotonMET") << "SUSY_HLT_PhotonMET::bookHistograms" << std::endl;
30  // book at beginRun
31  bookHistos(ibooker_);
32 }
33 
35  edm::LogInfo("SUSY_HLT_PhotonMET") << "SUSY_HLT_PhotonMET::analyze" << std::endl;
36 
37  //-------------------------------
38  //--- MET
39  //-------------------------------
40  edm::Handle<reco::PFMETCollection> pfMETCollection;
41  e.getByToken(thePfMETCollection_, pfMETCollection);
42  if (!pfMETCollection.isValid()) {
43  edm::LogError("SUSY_HLT_PhotonMET") << "invalid met collection"
44  << "\n";
45  return;
46  }
47  //-------------------------------
48  //--- Photon
49  //-------------------------------
51  e.getByToken(thePhotonCollection_, photonCollection);
52  if (!photonCollection.isValid()) {
53  edm::LogError("SUSY_HLT_PhotonMET") << "invalid egamma collection"
54  << "\n";
55  return;
56  }
57 
58  // check what is in the menu
60  e.getByToken(triggerResults_, hltresults);
61  if (!hltresults.isValid()) {
62  edm::LogError("SUSY_HLT_PhotonMET") << "invalid collection: TriggerResults"
63  << "\n";
64  return;
65  }
66 
67  // use only events with leading photon in barrel
68  if (photonCollection->empty() || abs(photonCollection->begin()->superCluster()->eta()) > 1.4442)
69  return;
70 
71  // get reco photon and met
72  float const recoPhotonPt = !photonCollection->empty() ? photonCollection->begin()->et() : 0;
73  float const recoMET = !pfMETCollection->empty() ? pfMETCollection->begin()->et() : 0;
74  h_recoPhotonPt->Fill(recoPhotonPt);
75  h_recoMet->Fill(recoMET);
76 
77  // the actual trigger efficiencies
78  bool hasFired = false, hasFiredBaseTrigger = false;
79  edm::TriggerNames const &trigNames = e.triggerNames(*hltresults);
80  unsigned int const numTriggers = trigNames.size();
81  for (unsigned int hltIndex = 0; hltIndex < numTriggers; ++hltIndex) {
82  if (trigNames.triggerName(hltIndex).find(triggerPath_) != std::string::npos && hltresults->wasrun(hltIndex) &&
83  hltresults->accept(hltIndex))
84  hasFired = true;
85  if (trigNames.triggerName(hltIndex).find(triggerPathBase_) != std::string::npos && hltresults->wasrun(hltIndex) &&
86  hltresults->accept(hltIndex))
87  hasFiredBaseTrigger = true;
88  }
89 
90  if (hasFiredBaseTrigger || !e.isRealData()) {
91  // passed base trigger
92  if (recoPhotonPt > ptThrOffline_)
93  h_metTurnOn_den->Fill(recoMET);
94  if (recoMET > metThrOffline_)
95  h_photonTurnOn_den->Fill(recoPhotonPt);
96  if (hasFired) {
97  // passed base and signal trigger
98  if (recoPhotonPt > ptThrOffline_)
99  h_metTurnOn_num->Fill(recoMET);
100  if (recoMET > metThrOffline_)
101  h_photonTurnOn_num->Fill(recoPhotonPt);
102  }
103  }
104 }
105 
107  edm::LogInfo("SUSY_HLT_PhotonMET") << "SUSY_HLT_PhotonMET::endRun" << std::endl;
108 }
109 
111  ibooker_.cd();
112  ibooker_.setCurrentFolder("HLT/SUSYBSM/" + triggerPath_);
113 
114  // offline quantities
115  h_recoPhotonPt = ibooker_.book1D("recoPhotonPt", "reco Photon transverse momentum; p_{T} (GeV)", 20, 0, 1000);
116  h_recoMet = ibooker_.book1D("recoMet", "reco Missing transverse energy;E_{T}^{miss} (GeV)", 20, 0, 1000);
117  h_metTurnOn_num = ibooker_.book1D("pfMetTurnOn_num", "PF MET Turn On Numerator", 20, 0, 500);
118  h_metTurnOn_den = ibooker_.book1D("pfMetTurnOn_den", "PF MET Turn On Denominator", 20, 0, 500);
119  h_photonTurnOn_num = ibooker_.book1D("photonTurnOn_num", "Photon Turn On Numerator", 20, 0, 1000);
120  h_photonTurnOn_den = ibooker_.book1D("photonTurnOn_den", "Photon Turn On Denominator", 20, 0, 1000);
121 
122  ibooker_.cd();
123 }
124 
125 // define this as a plug-in
MonitorElement * h_recoMet
MonitorElement * h_metTurnOn_den
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool wasrun() const
Was at least one path run?
MonitorElement * h_recoPhotonPt
MonitorElement * h_metTurnOn_num
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
~SUSY_HLT_PhotonMET() override
bool accept() const
Has at least one path accepted the event?
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
Strings::size_type size() const
Definition: TriggerNames.cc:31
bool isRealData() const
Definition: EventBase.h:62
void Fill(long long x)
MonitorElement * h_photonTurnOn_den
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
edm::EDGetTokenT< reco::PhotonCollection > thePhotonCollection_
edm::EDGetTokenT< edm::TriggerResults > triggerResults_
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
bool isValid() const
Definition: HandleBase.h:74
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:74
edm::EDGetTokenT< reco::PFMETCollection > thePfMETCollection_
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:22
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * h_photonTurnOn_num
std::string triggerPathBase_
SUSY_HLT_PhotonMET(const edm::ParameterSet &ps)
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
void bookHistos(DQMStore::IBooker &)
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:256
Definition: Run.h:45