11 #include "TLorentzVector.h"
21 LogTrace(
"TriggerMatching") <<
"[TriggerMatchMonitor] Parameters initialization";
26 primaryVerticesToken_ =
28 theMuonCollectionLabel_ = consumes<edm::View<reco::Muon>>(
parameters.getParameter<
edm::InputTag>(
"MuonCollection"));
29 thePATMuonCollectionLabel_ =
33 triggerResultsToken_ =
38 triggerPathName1_ =
parameters.getParameter<
string>(
"triggerPathName1");
39 triggerHistName1_ =
parameters.getParameter<
string>(
"triggerHistName1");
40 triggerPtThresholdPath1_ =
parameters.getParameter<
double>(
"triggerPtThresholdPath1");
41 triggerPathName2_ =
parameters.getParameter<
string>(
"triggerPathName2");
42 triggerHistName2_ =
parameters.getParameter<
string>(
"triggerHistName2");
43 triggerPtThresholdPath2_ =
parameters.getParameter<
double>(
"triggerPtThresholdPath2");
44 theFolder =
parameters.getParameter<
string>(
"folder");
56 matchHists.push_back(ibooker.
book1D(
"DelR_HLT_" + triggerHistName1_ +
"_v1",
57 "DeltaR_(offline,HLT)_triggerPass(" + triggerHistName1_ +
")",
61 matchHists.push_back(ibooker.
book1D(
"DelR_HLT_" + triggerHistName1_ +
"_v2",
62 "DeltaR_(offline,HLT)_triggerPass(" + triggerHistName1_ +
")",
66 matchHists.push_back(ibooker.
book1D(
67 "PtRatio_HLT_" + triggerHistName1_,
"PtRatio_(HLTPt/OfflinePt)_" + triggerHistName1_, 200, -5., 5.0));
69 matchHists.push_back(ibooker.
book1D(
"DelR_L1_" + triggerHistName1_ +
"_v1",
70 "DeltaR_(offline, L1)_triggerPass(" + triggerHistName1_ +
")",
74 matchHists.push_back(ibooker.
book1D(
"DelR_L1_" + triggerHistName1_ +
"_v2",
75 "DeltaR_(offline, L1)_triggerPass(" + triggerHistName1_ +
")",
79 matchHists.push_back(ibooker.
book1D(
80 "PtRatio_L1_" + triggerHistName1_,
"PtRatio_(HLTPt/OfflinePt)_" + triggerHistName1_, 200, -5., 5.0));
82 matchHists.push_back(ibooker.
book1D(
"DelR_HLT_" + triggerHistName2_ +
"_v1",
83 "DeltaR_(offline,HLT)_triggerPass(" + triggerHistName2_ +
")",
87 matchHists.push_back(ibooker.
book1D(
"DelR_HLT_" + triggerHistName2_ +
"_v2",
88 "DeltaR_(offline,HLT)_triggerPass(" + triggerHistName2_ +
")",
92 matchHists.push_back(ibooker.
book1D(
93 "PtRatio_HLT_" + triggerHistName2_,
"PtRatio_(HLTPt/OfflinePt)_" + triggerHistName2_, 200, -5., 5.0));
95 matchHists.push_back(ibooker.
book1D(
"DelR_L1_" + triggerHistName2_ +
"_v1",
96 "DeltaR_(offline, L1)_triggerPass(" + triggerHistName2_ +
")",
100 matchHists.push_back(ibooker.
book1D(
"DelR_L1_" + triggerHistName2_ +
"_v2",
101 "DeltaR_(offline, L1)_triggerPass(" + triggerHistName2_ +
")",
105 matchHists.push_back(ibooker.
book1D(
106 "PtRatio_L1_" + triggerHistName2_,
"PtRatio_(HLTPt/OfflinePt)_" + triggerHistName2_, 200, -5., 5.0));
111 h_passHLTPath1_eta_Tight = ibooker.
book1D(
112 "passHLT" + triggerHistName1_ +
"_eta_Tight",
" HLT(" + triggerHistName1_ +
") pass #eta", 8, -2.5, 2.5);
113 h_passHLTPath1_pt_Tight = ibooker.
book1D(
114 "passHLT" + triggerHistName1_ +
"_pt_Tight",
" HLT(" + triggerHistName1_ +
") pass pt", 10, 20, 220);
115 h_passHLTPath1_phi_Tight = ibooker.
book1D(
116 "passHLT" + triggerHistName1_ +
"_phi_Tight",
" HLT(" + triggerHistName1_ +
") pass phi", 8, -3.0, 3.0);
117 h_totalHLTPath1_eta_Tight = ibooker.
book1D(
118 "totalHLT" + triggerHistName1_ +
"_eta_Tight",
" HLT(" + triggerHistName1_ +
") total #eta", 8, -2.5, 2.5);
119 h_totalHLTPath1_pt_Tight = ibooker.
book1D(
120 "totalHLT" + triggerHistName1_ +
"_pt_Tight",
" HLT(" + triggerHistName1_ +
") total pt", 10, 20., 220);
121 h_totalHLTPath1_phi_Tight = ibooker.
book1D(
122 "totalHLT" + triggerHistName1_ +
"_phi_Tight",
" HLT(" + triggerHistName1_ +
") total phi", 8, -3.0, 3.0);
124 h_passHLTPath2_eta_Tight = ibooker.
book1D(
125 "passHLT" + triggerHistName2_ +
"_eta_Tight",
" HLT(" + triggerHistName2_ +
") pass #eta", 8, -2.5, 2.5);
126 h_passHLTPath2_pt_Tight = ibooker.
book1D(
127 "passHLT" + triggerHistName2_ +
"_pt_Tight",
" HLT(" + triggerHistName2_ +
") pass pt", 10, 20., 220);
128 h_passHLTPath2_phi_Tight = ibooker.
book1D(
129 "passHLT" + triggerHistName2_ +
"_phi_Tight",
" HLT(" + triggerHistName2_ +
") pass phi", 8, -3.0, 3.0);
130 h_totalHLTPath2_eta_Tight = ibooker.
book1D(
131 "totalHLT" + triggerHistName2_ +
"_eta_Tight",
" HLT(" + triggerHistName2_ +
") total #eta", 8, -2.5, 2.5);
132 h_totalHLTPath2_pt_Tight = ibooker.
book1D(
133 "totalHLT" + triggerHistName2_ +
"_pt_Tight",
" HLT(" + triggerHistName2_ +
") total pt", 10, 20, 220);
134 h_totalHLTPath2_phi_Tight = ibooker.
book1D(
135 "totalHLT" + triggerHistName2_ +
"_phi_Tight",
" HLT(" + triggerHistName2_ +
") total phi", 8, -3.0, 3.0);
138 LogTrace(
"TriggerMatching") <<
"[TriggerMatchMonitor] Analyze the mu in different eta regions";
141 iEvent.
getByToken(theMuonCollectionLabel_, muons);
144 iEvent.
getByToken(thePATMuonCollectionLabel_, PATmuons);
147 iEvent.
getByToken(triggerObjects_, triggerObjects);
150 iEvent.
getByToken(triggerResultsToken_, triggerResults);
155 iEvent.
getByToken(primaryVerticesToken_, recVtxs);
156 unsigned int theIndexOfThePrimaryVertex = 999.;
157 for (
unsigned int ind = 0; ind < recVtxs->size(); ++ind) {
158 if ((*recVtxs)[ind].isValid() && !((*recVtxs)[ind].isFake())) {
159 theIndexOfThePrimaryVertex = ind;
163 if (theIndexOfThePrimaryVertex < 100) {
164 posVtx = ((*recVtxs)[theIndexOfThePrimaryVertex]).
position();
165 errVtx = ((*recVtxs)[theIndexOfThePrimaryVertex]).
error();
167 LogInfo(
"RecoMuonValidator") <<
"reco::PrimaryVertex not found, use BeamSpot position instead\n";
169 iEvent.
getByToken(beamSpotToken_, recoBeamSpotHandle);
174 errVtx(2, 2) = bs.
sigmaZ();
179 for (
const auto& patMuon : *PATmuons) {
181 patMuon.pfIsolationR04().sumChargedHadronPt +
183 patMuon.pfIsolationR04().sumNeutralHadronEt + patMuon.pfIsolationR04().sumPhotonEt -
184 0.5 * patMuon.pfIsolationR04().sumPUPt) /
188 if (patMuon.isGlobalMuon() && Isolated && patMuon.isTightMuon(thePrimaryVertex)) {
190 TLorentzVector offlineMuon;
191 offlineMuon.SetPtEtaPhiM(patMuon.pt(), patMuon.eta(), patMuon.phi(), 0.0);
193 const char* ptrmuPath1 = triggerPathName1_.c_str();
194 const char* ptrmuPath2 = triggerPathName2_.c_str();
195 if (patMuon.pt() > triggerPtThresholdPath1_) {
196 h_totalHLTPath1_eta_Tight->Fill(patMuon.eta());
197 h_totalHLTPath1_pt_Tight->Fill(patMuon.pt());
198 h_totalHLTPath1_phi_Tight->Fill(patMuon.phi());
200 if (patMuon.pt() > triggerPtThresholdPath2_) {
201 h_totalHLTPath2_eta_Tight->Fill(patMuon.eta());
202 h_totalHLTPath2_pt_Tight->Fill(patMuon.pt());
203 h_totalHLTPath2_phi_Tight->Fill(patMuon.phi());
205 if (patMuon.triggered(ptrmuPath1) && patMuon.hltObject() !=
nullptr) {
206 TLorentzVector hltMuon;
207 hltMuon.SetPtEtaPhiM(patMuon.hltObject()->pt(), patMuon.hltObject()->eta(), patMuon.hltObject()->phi(), 0.0);
208 double DelRrecoHLT = offlineMuon.DeltaR(hltMuon);
210 matchHists[0]->Fill(DelRrecoHLT);
211 matchHists[1]->Fill(DelRrecoHLT);
212 matchHists[2]->Fill(patMuon.hltObject()->pt() / patMuon.pt());
213 if (DelRrecoHLT < 0.2 && patMuon.pt() > triggerPtThresholdPath1_) {
214 h_passHLTPath1_eta_Tight->Fill(patMuon.eta());
215 h_passHLTPath1_pt_Tight->Fill(patMuon.pt());
216 h_passHLTPath1_phi_Tight->Fill(patMuon.phi());
218 if (patMuon.l1Object() !=
nullptr) {
219 TLorentzVector L1Muon;
220 L1Muon.SetPtEtaPhiM(patMuon.l1Object()->pt(), patMuon.l1Object()->eta(), patMuon.l1Object()->phi(), 0.0);
221 double DelRrecoL1 = offlineMuon.DeltaR(L1Muon);
222 matchHists[3]->Fill(DelRrecoL1);
223 matchHists[4]->Fill(DelRrecoL1);
224 matchHists[5]->Fill(patMuon.l1Object()->pt() / patMuon.pt());
229 if (patMuon.triggered(ptrmuPath2)) {
230 TLorentzVector hltMuon50;
231 hltMuon50.SetPtEtaPhiM(
232 patMuon.hltObject()->pt(), patMuon.hltObject()->eta(), patMuon.hltObject()->phi(), 0.0);
233 double DelRrecoHLT50 = offlineMuon.DeltaR(hltMuon50);
235 matchHists[6]->Fill(DelRrecoHLT50);
236 matchHists[7]->Fill(DelRrecoHLT50);
237 matchHists[8]->Fill(patMuon.hltObject()->pt() / patMuon.pt());
238 if (DelRrecoHLT50 < 0.2 && patMuon.pt() > triggerPtThresholdPath2_) {
239 h_passHLTPath2_eta_Tight->Fill(patMuon.eta());
240 h_passHLTPath2_pt_Tight->Fill(patMuon.pt());
241 h_passHLTPath2_phi_Tight->Fill(patMuon.phi());
244 if (patMuon.l1Object() !=
nullptr) {
245 TLorentzVector L1Muon50;
246 L1Muon50.SetPtEtaPhiM(patMuon.l1Object()->pt(), patMuon.l1Object()->eta(), patMuon.l1Object()->phi(), 0.0);
247 double DelRrecoL150 = offlineMuon.DeltaR(L1Muon50);
248 matchHists[9]->Fill(DelRrecoL150);
249 matchHists[10]->Fill(DelRrecoL150);
250 matchHists[11]->Fill(patMuon.l1Object()->pt() / patMuon.pt());
virtual void setCurrentFolder(std::string const &fullpath)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
math::Error< dimension >::type Error
covariance error matrix (3x3)
~TriggerMatchMonitor() override
Destructor.
math::XYZPoint Point
point in the space
double BeamWidthX() const
beam width X
static std::string const triggerResults
Log< level::Info, false > LogInfo
double sigmaZ() const
sigma z
double BeamWidthY() const
beam width Y
static int position[264][3]
void analyze(const edm::Event &, const edm::EventSetup &) override
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
const Point & position() const
position
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
TriggerMatchMonitor(const edm::ParameterSet &pSet)
Constructor.