CMS 3D CMS Logo

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