CMS 3D CMS Logo

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