CMS 3D CMS Logo

SUSY_HLT_PhotonHT.cc
Go to the documentation of this file.
7 
8 
10 {
11  edm::LogInfo("SUSY_HLT_PhotonHT") << "Constructor SUSY_HLT_PhotonHT::SUSY_HLT_PhotonHT " << std::endl;
12  // Get parameters from configuration file
13  theTrigSummary_ = consumes<trigger::TriggerEvent>(ps.getParameter<edm::InputTag>("trigSummary"));
14  thePfMETCollection_ = consumes<reco::PFMETCollection>(ps.getParameter<edm::InputTag>("pfMETCollection"));
15  thePhotonCollection_ = consumes<reco::PhotonCollection>(ps.getParameter<edm::InputTag>("photonCollection"));
16  triggerResults_ = consumes<edm::TriggerResults>(ps.getParameter<edm::InputTag>("TriggerResults"));
17  triggerPath_ = ps.getParameter<std::string>("TriggerPath");
18  triggerPathAuxiliaryForHadronic_ = ps.getParameter<std::string>("TriggerPathAuxiliaryForHadronic");
19  triggerFilterPhoton_ = ps.getParameter<edm::InputTag>("TriggerFilterPhoton");
20  triggerFilterHt_ = ps.getParameter<edm::InputTag>("TriggerFilterHt");
21  ptThrOffline_ = ps.getUntrackedParameter<double>("ptThrOffline");
22  htThrOffline_ = ps.getUntrackedParameter<double>("htThrOffline");
23 }
24 
26 {
27  edm::LogInfo("SUSY_HLT_PhotonHT") << "Destructor SUSY_HLT_PhotonHT::~SUSY_HLT_PhotonHT " << std::endl;
28 }
29 
31 {
32  edm::LogInfo("SUSY_HLT_PhotonHT") << "SUSY_HLT_PhotonHT::beginRun" << std::endl;
33 }
34 
36 {
37  edm::LogInfo("SUSY_HLT_PhotonHT") << "SUSY_HLT_PhotonHT::bookHistograms" << std::endl;
38  //book at beginRun
39  bookHistos(ibooker_);
40 }
41 
42 
44  edm::LogInfo("SUSY_HLT_PhotonHT") << "SUSY_HLT_PhotonHT::analyze" << std::endl;
45 
46 
47  //-------------------------------
48  //--- MET / HT
49  //-------------------------------
50  edm::Handle<reco::PFMETCollection> pfMETCollection;
51  e.getByToken(thePfMETCollection_, pfMETCollection);
52  if ( !pfMETCollection.isValid() ){
53  edm::LogError ("SUSY_HLT_PhotonHT") << "invalid met collection" << "\n";
54  return;
55  }
56  //-------------------------------
57  //--- Photon
58  //-------------------------------
60  e.getByToken (thePhotonCollection_, photonCollection);
61  if ( !photonCollection.isValid() ){
62  edm::LogError ("SUSY_HLT_PhotonHT") << "invalid egamma collection" << "\n";
63  return;
64  }
65 
66  //check what is in the menu
68  e.getByToken(triggerResults_,hltresults);
69  if(!hltresults.isValid()){
70  edm::LogError ("SUSY_HLT_PhotonHT") << "invalid collection: TriggerResults" << "\n";
71  return;
72  }
73 
74  //-------------------------------
75  //--- Trigger
76  //-------------------------------
78  e.getByToken(theTrigSummary_, triggerSummary);
79  if(!triggerSummary.isValid()) {
80  edm::LogError ("SUSY_HLT_PhotonHT") << "invalid collection: TriggerSummary" << "\n";
81  return;
82  }
83 
84  // get online objects
86 
87  // get the photon object
88  size_t filterIndexPhoton = triggerSummary->filterIndex( triggerFilterPhoton_ );
89  if( filterIndexPhoton < triggerSummary->sizeFilters() ) {
90  const trigger::Keys& keys = triggerSummary->filterKeys( filterIndexPhoton );
91  if( !keys.empty() ) {
92  // take the leading photon
93  float pt = triggerObjects[ keys[0] ].pt();
94  h_photonPt->Fill( pt );
95  }
96  }
97 
98  // get ht
99  size_t filterIndexHt = triggerSummary->filterIndex( triggerFilterHt_ );
100  if( filterIndexHt < triggerSummary->sizeFilters() ) {
101  const trigger::Keys& keys = triggerSummary->filterKeys( filterIndexHt );
102  if( !keys.empty() ) {
103  float ht = triggerObjects[ keys[0] ].pt();
104  h_ht->Fill( ht );
105  }
106  }
107 
108  bool hasFired = false, hasFiredAuxiliaryForHadronicLeg=false;
109  const edm::TriggerNames& trigNames = e.triggerNames(*hltresults);
110  unsigned int numTriggers = trigNames.size();
111  for( unsigned int hltIndex=0; hltIndex<numTriggers; ++hltIndex ){
112  if (trigNames.triggerName(hltIndex).find(triggerPath_) != std::string::npos && hltresults->wasrun(hltIndex) && hltresults->accept(hltIndex)) hasFired = true;
113  if (trigNames.triggerName(hltIndex).find(triggerPathAuxiliaryForHadronic_) != std::string::npos && hltresults->wasrun(hltIndex) && hltresults->accept(hltIndex)) hasFiredAuxiliaryForHadronicLeg = true;
114  }
115 
116  if(hasFiredAuxiliaryForHadronicLeg || !e.isRealData()) {
117  float recoPhotonPt = !photonCollection->empty() ? photonCollection->begin()->et() : 0;
118  float recoHt = !pfMETCollection->empty() ? pfMETCollection->begin()->et() : 0;
119 
120  if(hasFired){
121  if( !photonCollection->empty() && recoHt >= htThrOffline_ ) h_photonTurnOn_num -> Fill( recoPhotonPt );
122  if( !pfMETCollection->empty() && recoPhotonPt >= ptThrOffline_ ) h_htTurnOn_num -> Fill( recoHt );
123  }
124  if( !photonCollection->empty() && recoHt >= htThrOffline_ ) h_photonTurnOn_den -> Fill( recoPhotonPt );
125  if( !pfMETCollection->empty() && recoPhotonPt >= ptThrOffline_ ) h_htTurnOn_den -> Fill( recoPhotonPt );
126  }
127 
128 }
129 
130 
131 
133 {
134  edm::LogInfo("SUSY_HLT_PhotonHT") << "SUSY_HLT_PhotonHT::endRun" << std::endl;
135 }
136 
138 {
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:579
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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:39
bool isRealData() const
Definition: EventBase.h:64
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
void Fill(long long x)
edm::EDGetTokenT< reco::PFMETCollection > thePfMETCollection_
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
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:27
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:301
SUSY_HLT_PhotonHT(const edm::ParameterSet &ps)
Definition: Run.h:44