CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
43  edm::EventSetup const& context)
44 {
45  edm::LogInfo("SUSY_HLT_PhotonHT") << "SUSY_HLT_PhotonHT::beginLuminosityBlock" << std::endl;
46 }
47 
49  edm::LogInfo("SUSY_HLT_PhotonHT") << "SUSY_HLT_PhotonHT::analyze" << std::endl;
50 
51 
52  //-------------------------------
53  //--- MET / HT
54  //-------------------------------
55  edm::Handle<reco::PFMETCollection> pfMETCollection;
56  e.getByToken(thePfMETCollection_, pfMETCollection);
57  if ( !pfMETCollection.isValid() ){
58  edm::LogError ("SUSY_HLT_PhotonHT") << "invalid met collection" << "\n";
59  return;
60  }
61  //-------------------------------
62  //--- Photon
63  //-------------------------------
64  edm::Handle<reco::PhotonCollection> photonCollection;
65  e.getByToken (thePhotonCollection_, photonCollection);
66  if ( !photonCollection.isValid() ){
67  edm::LogError ("SUSY_HLT_PhotonHT") << "invalid egamma collection" << "\n";
68  return;
69  }
70 
71  //check what is in the menu
73  e.getByToken(triggerResults_,hltresults);
74  if(!hltresults.isValid()){
75  edm::LogError ("SUSY_HLT_PhotonHT") << "invalid collection: TriggerResults" << "\n";
76  return;
77  }
78 
79  //-------------------------------
80  //--- Trigger
81  //-------------------------------
83  e.getByToken(theTrigSummary_, triggerSummary);
84  if(!triggerSummary.isValid()) {
85  edm::LogError ("SUSY_HLT_PhotonHT") << "invalid collection: TriggerSummary" << "\n";
86  return;
87  }
88 
89  // get online objects
90  trigger::TriggerObjectCollection triggerObjects = triggerSummary->getObjects();
91 
92  // get the photon object
93  size_t filterIndexPhoton = triggerSummary->filterIndex( triggerFilterPhoton_ );
94  if( filterIndexPhoton < triggerSummary->sizeFilters() ) {
95  const trigger::Keys& keys = triggerSummary->filterKeys( filterIndexPhoton );
96  if( keys.size() ) {
97  // take the leading photon
98  float pt = triggerObjects[ keys[0] ].pt();
99  h_photonPt->Fill( pt );
100  }
101  }
102 
103  // get ht
104  size_t filterIndexHt = triggerSummary->filterIndex( triggerFilterHt_ );
105  if( filterIndexHt < triggerSummary->sizeFilters() ) {
106  const trigger::Keys& keys = triggerSummary->filterKeys( filterIndexHt );
107  if( keys.size() ) {
108  float ht = triggerObjects[ keys[0] ].pt();
109  h_ht->Fill( ht );
110  }
111  }
112 
113  bool hasFired = false, hasFiredAuxiliaryForHadronicLeg=false;
114  const edm::TriggerNames& trigNames = e.triggerNames(*hltresults);
115  unsigned int numTriggers = trigNames.size();
116  for( unsigned int hltIndex=0; hltIndex<numTriggers; ++hltIndex ){
117  if (trigNames.triggerName(hltIndex).find(triggerPath_) != std::string::npos && hltresults->wasrun(hltIndex) && hltresults->accept(hltIndex)) hasFired = true;
118  if (trigNames.triggerName(hltIndex).find(triggerPathAuxiliaryForHadronic_) != std::string::npos && hltresults->wasrun(hltIndex) && hltresults->accept(hltIndex)) hasFiredAuxiliaryForHadronicLeg = true;
119  }
120 
121  if(hasFiredAuxiliaryForHadronicLeg || !e.isRealData()) {
122  float recoPhotonPt = photonCollection->size() ? photonCollection->begin()->et() : 0;
123  float recoHt = pfMETCollection->size() ? pfMETCollection->begin()->et() : 0;
124 
125  if(hasFired){
126  if( photonCollection->size() && recoHt >= htThrOffline_ ) h_photonTurnOn_num -> Fill( recoPhotonPt );
127  if( pfMETCollection->size() && recoPhotonPt >= ptThrOffline_ ) h_htTurnOn_num -> Fill( recoHt );
128  }
129  if( photonCollection->size() && recoHt >= htThrOffline_ ) h_photonTurnOn_den -> Fill( recoPhotonPt );
130  if( pfMETCollection->size() && recoPhotonPt >= ptThrOffline_ ) h_htTurnOn_den -> Fill( recoPhotonPt );
131  }
132 
133 }
134 
136 {
137  edm::LogInfo("SUSY_HLT_PhotonHT") << "SUSY_HLT_PhotonHT::endLuminosityBlock" << std::endl;
138 }
139 
140 
142 {
143  edm::LogInfo("SUSY_HLT_PhotonHT") << "SUSY_HLT_PhotonHT::endRun" << std::endl;
144 }
145 
147 {
148  ibooker_.cd();
149  ibooker_.setCurrentFolder("HLT/SUSYBSM/" + triggerPath_);
150 
151  //offline quantities
152  h_photonPt = ibooker_.book1D("photonPt", "Photon transverse momentum; p_{T} (GeV)", 20, 0, 500 );
153  h_ht = ibooker_.book1D("ht", "Hadronic activity;H_{T} (GeV)", 20, 0, 2000 );
154  h_htTurnOn_num = ibooker_.book1D("pfHtTurnOn_num", "PF HT Turn On Numerator", 20, 300, 800 );
155  h_htTurnOn_den = ibooker_.book1D("pfHtTurnOn_den", "PF HT Turn On Denominator", 20, 300, 800 );
156  h_photonTurnOn_num = ibooker_.book1D("photonTurnOn_num", "Photon Turn On Numerator", 20, 70, 130 );
157  h_photonTurnOn_den = ibooker_.book1D("photonTurnOn_den", "Photon Turn On Denominator", 20, 70, 130 );
158 
159  ibooker_.cd();
160 }
161 
162  //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
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:199
void bookHistos(DQMStore::IBooker &)
MonitorElement * h_ht
edm::InputTag triggerFilterHt_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
void cd(void)
Definition: DQMStore.cc:266
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
void analyze(edm::Event const &e, edm::EventSetup const &eSetup)
edm::InputTag triggerFilterPhoton_
Strings::size_type size() const
Definition: TriggerNames.cc:39
bool isRealData() const
Definition: EventBase.h:60
void Fill(long long x)
edm::EDGetTokenT< reco::PFMETCollection > thePfMETCollection_
virtual ~SUSY_HLT_PhotonHT()
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
MonitorElement * h_htTurnOn_den
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
MonitorElement * h_photonPt
bool isValid() const
Definition: HandleBase.h:76
void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup)
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
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
std::vector< size_type > Keys
std::string triggerPathAuxiliaryForHadronic_
void endRun(edm::Run const &run, edm::EventSetup const &eSetup)
MonitorElement * h_photonTurnOn_num
std::string triggerPath_
edm::EDGetTokenT< reco::PhotonCollection > thePhotonCollection_
void endLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup)
edm::EDGetTokenT< trigger::TriggerEvent > theTrigSummary_
SUSY_HLT_PhotonHT(const edm::ParameterSet &ps)
Definition: Run.h:41