CMS 3D CMS Logo

HotlineDQM.cc
Go to the documentation of this file.
7 
9 {
10 
11  edm::LogInfo("HotlineDQM") << "Constructor HotlineDQM::HotlineDQM " << std::endl;
12  // Get parameters from configuration file
13  theMuonCollection_ = consumes<reco::MuonCollection>(ps.getParameter<edm::InputTag>("muonCollection"));
14  thePfMETCollection_ = consumes<reco::PFMETCollection>(ps.getParameter<edm::InputTag>("pfMetCollection"));
15  theMETCollection_ = consumes<reco::CaloMETCollection>(ps.getParameter<edm::InputTag>("caloMetCollection"));
16  theCaloJetCollection_ = consumes<reco::CaloJetCollection>(ps.getParameter<edm::InputTag>("caloJetCollection"));
17  thePhotonCollection_ = consumes<reco::PhotonCollection>(ps.getParameter<edm::InputTag>("photonCollection"));
18  theTrigSummary_ = consumes<trigger::TriggerEvent>(ps.getParameter<edm::InputTag>("trigSummary"));
19  triggerResults_ = consumes<edm::TriggerResults>(ps.getParameter<edm::InputTag>("triggerResults"));
20  triggerPath_ = ps.getParameter<std::string>("triggerPath");
21  triggerFilter_ = ps.getParameter<edm::InputTag>("triggerFilter");
22  useMuons = ps.getParameter<bool>("useMuons");
23  useMet = ps.getParameter<bool>("useMet");
24  usePFMet = ps.getParameter<bool>("usePFMet");
25  useHT = ps.getParameter<bool>("useHT");
26  usePhotons = ps.getParameter<bool>("usePhotons");
27 }
28 
30 {
31  edm::LogInfo("HotlineDQM") << "Destructor HotlineDQM::~HotlineDQM " << std::endl;
32 }
33 
35 {
36  edm::LogInfo("HotlineDQM") << "HotlineDQM::bookHistograms" << std::endl;
37 
38  ibooker_.cd();
39  ibooker_.setCurrentFolder("HLT/Hotline/" + triggerPath_);
40 
41  //online quantities
42  h_MuPt = ibooker_.book1D("MuPt", "Muon Pt; GeV", 20, 0.0, 2000.0);
43  h_PhotonPt = ibooker_.book1D("PhotonPt", "Photon Pt; GeV", 20, 0.0, 4000.0);
44  h_HT = ibooker_.book1D("HT", "HT; GeV", 20, 0.0, 6000.0);
45  h_MetPt = ibooker_.book1D("MetPt", "Calo MET; GeV", 20, 0.0, 2000);
46  h_PFMetPt = ibooker_.book1D("PFMetPt", "PF MET; GeV", 20, 0.0, 2000);
47 
48  if(useMuons) h_OnlineMuPt = ibooker_.book1D("OnlineMuPt", "Online Muon Pt; GeV", 20, 0.0, 2000.0);
49  if(usePhotons) h_OnlinePhotonPt = ibooker_.book1D("OnlinePhotonPt", "Online Photon Pt; GeV", 20, 0.0, 4000.0);
50  if(useHT) h_OnlineHT = ibooker_.book1D("OnlineHT", "Online HT; GeV", 20, 0.0, 6000.0);
51  if(useMet) h_OnlineMetPt = ibooker_.book1D("OnlineMetPt", "Online Calo MET; GeV", 20, 0.0, 2000);
52  if(usePFMet) h_OnlinePFMetPt = ibooker_.book1D("OnlinePFMetPt", "Online PF MET; GeV", 20, 0.0, 2000);
53 
54  ibooker_.cd();
55 }
56 
57 void HotlineDQM::analyze(edm::Event const& e, edm::EventSetup const& eSetup){
58  edm::LogInfo("HotlineDQM") << "HotlineDQM::analyze" << std::endl;
59 
60  //-------------------------------
61  //--- MET
62  //-------------------------------
63  edm::Handle<reco::PFMETCollection> pfMETCollection;
64  e.getByToken(thePfMETCollection_, pfMETCollection);
65  if ( !pfMETCollection.isValid() ){
66  edm::LogError ("HotlineDQM") << "invalid collection: PFMET" << "\n";
67  return;
68  }
69  edm::Handle<reco::CaloMETCollection> caloMETCollection;
70  e.getByToken(theMETCollection_, caloMETCollection);
71  if ( !caloMETCollection.isValid() ){
72  edm::LogError ("HotlineDQM") << "invalid collection: CaloMET" << "\n";
73  return;
74  }
75 
76  //-------------------------------
77  //--- Jets
78  //-------------------------------
79  edm::Handle<reco::CaloJetCollection> caloJetCollection;
80  e.getByToken (theCaloJetCollection_,caloJetCollection);
81  if ( !caloJetCollection.isValid() ){
82  edm::LogError ("HotlineDQM") << "invalid collection: CaloJets" << "\n";
83  return;
84  }
85 
86  //-------------------------------
87  //--- Muon
88  //-------------------------------
90  e.getByToken (theMuonCollection_, MuonCollection);
91  if ( !MuonCollection.isValid() ){
92  edm::LogError ("HotlineDQM") << "invalid collection: Muons " << "\n";
93  return;
94  }
95 
96  //-------------------------------
97  //--- Photon
98  //-------------------------------
100  e.getByToken (thePhotonCollection_, PhotonCollection);
101  if ( !PhotonCollection.isValid() ){
102  edm::LogError ("HotlineDQM") << "invalid collection: Photons " << "\n";
103  return;
104  }
105 
106  //-------------------------------
107  //--- Trigger
108  //-------------------------------
110  e.getByToken(triggerResults_,hltresults);
111  if(!hltresults.isValid()){
112  edm::LogError ("HotlineDQM") << "invalid collection: TriggerResults" << "\n";
113  return;
114  }
115  edm::Handle<trigger::TriggerEvent> triggerSummary;
116  e.getByToken(theTrigSummary_, triggerSummary);
117  if(!triggerSummary.isValid()) {
118  edm::LogError ("HotlineDQM") << "invalid collection: TriggerSummary" << "\n";
119  return;
120  }
121 
122  bool hasFired = false;
123  const edm::TriggerNames& trigNames = e.triggerNames(*hltresults);
124  unsigned int numTriggers = trigNames.size();
125  for( unsigned int hltIndex=0; hltIndex<numTriggers; ++hltIndex ){
126  if (trigNames.triggerName(hltIndex).find(triggerPath_) != std::string::npos && hltresults->wasrun(hltIndex) && hltresults->accept(hltIndex)){
127  hasFired = true;
128  }
129  }
130 
131  //get online objects
132  float ptMuon=-1, ptPhoton=-1, met=-1, pfMet=-1, ht = 0;
133  size_t filterIndex = triggerSummary->filterIndex( triggerFilter_ );
135  if( !(filterIndex >= triggerSummary->sizeFilters()) ){
136  const trigger::Keys& keys = triggerSummary->filterKeys( filterIndex );
137  for( size_t j = 0; j < keys.size(); ++j ){
138  trigger::TriggerObject foundObject = triggerObjects[keys[j]];
139  if(useMuons && fabs(foundObject.id()) == 13){ //muon
140  if(foundObject.pt() > ptMuon) ptMuon = foundObject.pt();
141  }
142  else if(usePhotons && fabs(foundObject.id()) == 0){ //photon
143  if(foundObject.pt() > ptPhoton) ptPhoton = foundObject.pt();
144  }
145  else if(useMet && fabs(foundObject.id()) == 0){ //MET
146  met = foundObject.pt();
147  }
148  else if(usePFMet && fabs(foundObject.id()) == 0){ //PFMET
149  pfMet = foundObject.pt();
150  }
151  else if(useHT && fabs(foundObject.id()) == 89){ //HT
152  ht = foundObject.pt();
153  }
154  }
155  }
156 
157  if(hasFired) {
158  //fill appropriate online histogram
159  if(useMuons) h_OnlineMuPt->Fill(ptMuon);
160  if(usePhotons) h_OnlinePhotonPt->Fill(ptPhoton);
163  if(useHT) h_OnlineHT->Fill(ht);
164 
165  //fill muon pt histogram
166  if(MuonCollection->size() > 0){
167  float maxMuPt = -1.0;
168  for(auto &mu : *MuonCollection){
169  if(mu.pt() > maxMuPt) maxMuPt = mu.pt();
170  }
171  h_MuPt->Fill(maxMuPt);
172  }
173 
174  //fill photon pt histogram
175  if(PhotonCollection->size() > 0){
176  float maxPhoPt = -1.0;
177  for(auto &pho : *PhotonCollection){
178  if(pho.pt() > maxPhoPt) maxPhoPt = pho.pt();
179  }
180  h_PhotonPt->Fill(maxPhoPt);
181  }
182 
183  //fill HT histogram
184  float caloHT = 0.0;
185  for (reco::CaloJetCollection::const_iterator i_calojet = caloJetCollection->begin(); i_calojet != caloJetCollection->end(); ++i_calojet){
186  if (i_calojet->pt() < 40) continue;
187  if (fabs(i_calojet->eta()) > 3.0) continue;
188  caloHT += i_calojet->pt();
189  }
190  h_HT->Fill(caloHT);
191 
192  //fill CaloMET histogram
193  h_MetPt->Fill(caloMETCollection->front().et());
194 
195  //fill PFMET histogram
196  h_PFMetPt->Fill(pfMETCollection->front().et());
197  }
198 }
199 
202  desc.add<edm::InputTag>("photonCollection", edm::InputTag("photons"));
203  desc.add<edm::InputTag>("muonCollection", edm::InputTag("muons"));
204  desc.add<edm::InputTag>("caloJetCollection", edm::InputTag("ak4CaloJets"));
205  desc.add<edm::InputTag>("pfMetCollection", edm::InputTag("pfMet"));
206  desc.add<edm::InputTag>("caloMetCollection", edm::InputTag("caloMet"));
207  desc.add<edm::InputTag>("triggerResults",edm::InputTag("TriggerResults","","HLT"));
208  desc.add<edm::InputTag>("trigSummary",edm::InputTag("hltTriggerSummaryAOD"));
209  desc.add<std::string>("triggerPath","HLT_HT2000_v")->setComment("trigger path name");
210  desc.add<edm::InputTag>("triggerFilter",edm::InputTag("hltHt2000","","HLT"))->setComment("name of the last filter in the path");
211  desc.add<bool>("useMuons", false);
212  desc.add<bool>("usePhotons", false);
213  desc.add<bool>("useMet", false);
214  desc.add<bool>("usePFMet", false);
215  desc.add<bool>("useHT", false);
216  descriptions.add("HotlineDQM",desc);
217 }
218 
219 //define this as a plug-in
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::PhotonCollection > thePhotonCollection_
Definition: HotlineDQM.h:57
bool wasrun() const
Was at least one path run?
bool usePhotons
Definition: HotlineDQM.h:64
MonitorElement * h_PhotonPt
Definition: HotlineDQM.h:68
edm::EDGetTokenT< reco::MuonCollection > theMuonCollection_
Definition: HotlineDQM.h:53
int id() const
getters
Definition: TriggerObject.h:55
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:135
edm::EDGetTokenT< reco::CaloJetCollection > theCaloJetCollection_
Definition: HotlineDQM.h:56
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
void cd(void)
Definition: DQMStore.cc:269
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
HotlineDQM(const edm::ParameterSet &ps)
Definition: HotlineDQM.cc:8
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
MonitorElement * h_MuPt
Definition: HotlineDQM.h:67
Strings::size_type size() const
Definition: TriggerNames.cc:39
MonitorElement * h_OnlinePhotonPt
Definition: HotlineDQM.h:74
std::string triggerPath_
Definition: HotlineDQM.h:61
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HotlineDQM.cc:200
void Fill(long long x)
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:22
edm::EDGetTokenT< edm::TriggerResults > triggerResults_
Definition: HotlineDQM.h:58
MonitorElement * h_OnlineMuPt
Definition: HotlineDQM.h:73
MonitorElement * h_OnlineHT
Definition: HotlineDQM.h:75
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
MonitorElement * h_MetPt
Definition: HotlineDQM.h:70
pfMet
____________________________________________________________________________||
Definition: PFMET_cfi.py:4
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
edm::EDGetTokenT< reco::PFMETCollection > thePfMETCollection_
Definition: HotlineDQM.h:54
const int mu
Definition: Constants.h:22
bool useMuons
Definition: HotlineDQM.h:64
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
MonitorElement * h_OnlineMetPt
Definition: HotlineDQM.h:76
edm::InputTag triggerFilter_
Definition: HotlineDQM.h:62
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
MonitorElement * h_OnlinePFMetPt
Definition: HotlineDQM.h:77
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:74
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
edm::EDGetTokenT< trigger::TriggerEvent > theTrigSummary_
Definition: HotlineDQM.h:59
virtual ~HotlineDQM()
Definition: HotlineDQM.cc:29
met
===> hadronic RAZOR
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
std::vector< size_type > Keys
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
edm::EDGetTokenT< reco::CaloMETCollection > theMETCollection_
Definition: HotlineDQM.h:55
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: HotlineDQM.cc:34
bool useHT
Definition: HotlineDQM.h:64
MonitorElement * h_HT
Definition: HotlineDQM.h:69
bool useMet
Definition: HotlineDQM.h:64
MonitorElement * h_PFMetPt
Definition: HotlineDQM.h:71
bool usePFMet
Definition: HotlineDQM.h:64
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
Definition: HotlineDQM.cc:57
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:239
Definition: Run.h:42