11 #include "TLorentzVector.h" 29 primaryVerticesToken_ =
31 theMuonCollectionLabel_ = consumes<edm::View<reco::Muon>>(
parameters.getParameter<
edm::InputTag>(
"MuonCollection"));
32 thePATMuonCollectionLabel_ =
36 triggerResultsToken_ =
41 triggerPathName1_ =
parameters.getParameter<
string>(
"triggerPathName1");
42 triggerHistName1_ =
parameters.getParameter<
string>(
"triggerHistName1");
43 triggerPtThresholdPath1_ =
parameters.getParameter<
double>(
"triggerPtThresholdPath1");
44 triggerPathName2_ =
parameters.getParameter<
string>(
"triggerPathName2");
45 triggerHistName2_ =
parameters.getParameter<
string>(
"triggerHistName2");
46 triggerPtThresholdPath2_ =
parameters.getParameter<
double>(
"triggerPtThresholdPath2");
47 theFolder =
parameters.getParameter<
string>(
"folder");
59 matchHists.push_back(ibooker.
book1D(
"DelR_HLT_" + triggerHistName1_ +
"_v1",
60 "DeltaR_(offline,HLT)_triggerPass(" + triggerHistName1_ +
")",
64 matchHists.push_back(ibooker.
book1D(
"DelR_HLT_" + triggerHistName1_ +
"_v2",
65 "DeltaR_(offline,HLT)_triggerPass(" + triggerHistName1_ +
")",
69 matchHists.push_back(ibooker.
book1D(
70 "PtRatio_HLT_" + triggerHistName1_,
"PtRatio_(HLTPt/OfflinePt)_" + triggerHistName1_, 200, -5., 5.0));
72 matchHists.push_back(ibooker.
book1D(
"DelR_L1_" + triggerHistName1_ +
"_v1",
73 "DeltaR_(offline, L1)_triggerPass(" + triggerHistName1_ +
")",
77 matchHists.push_back(ibooker.
book1D(
"DelR_L1_" + triggerHistName1_ +
"_v2",
78 "DeltaR_(offline, L1)_triggerPass(" + triggerHistName1_ +
")",
82 matchHists.push_back(ibooker.
book1D(
83 "PtRatio_L1_" + triggerHistName1_,
"PtRatio_(HLTPt/OfflinePt)_" + triggerHistName1_, 200, -5., 5.0));
85 matchHists.push_back(ibooker.
book1D(
"DelR_HLT_" + triggerHistName2_ +
"_v1",
86 "DeltaR_(offline,HLT)_triggerPass(" + triggerHistName2_ +
")",
90 matchHists.push_back(ibooker.
book1D(
"DelR_HLT_" + triggerHistName2_ +
"_v2",
91 "DeltaR_(offline,HLT)_triggerPass(" + triggerHistName2_ +
")",
95 matchHists.push_back(ibooker.
book1D(
96 "PtRatio_HLT_" + triggerHistName2_,
"PtRatio_(HLTPt/OfflinePt)_" + triggerHistName2_, 200, -5., 5.0));
98 matchHists.push_back(ibooker.
book1D(
"DelR_L1_" + triggerHistName2_ +
"_v1",
99 "DeltaR_(offline, L1)_triggerPass(" + triggerHistName2_ +
")",
103 matchHists.push_back(ibooker.
book1D(
"DelR_L1_" + triggerHistName2_ +
"_v2",
104 "DeltaR_(offline, L1)_triggerPass(" + triggerHistName2_ +
")",
108 matchHists.push_back(ibooker.
book1D(
109 "PtRatio_L1_" + triggerHistName2_,
"PtRatio_(HLTPt/OfflinePt)_" + triggerHistName2_, 200, -5., 5.0));
114 h_passHLTPath1_eta_Tight = ibooker.
book1D(
115 "passHLT" + triggerHistName1_ +
"_eta_Tight",
" HLT(" + triggerHistName1_ +
") pass #eta", 8, -2.5, 2.5);
116 h_passHLTPath1_pt_Tight = ibooker.
book1D(
117 "passHLT" + triggerHistName1_ +
"_pt_Tight",
" HLT(" + triggerHistName1_ +
") pass pt", 10, 20, 220);
118 h_passHLTPath1_phi_Tight = ibooker.
book1D(
119 "passHLT" + triggerHistName1_ +
"_phi_Tight",
" HLT(" + triggerHistName1_ +
") pass phi", 8, -3.0, 3.0);
120 h_totalHLTPath1_eta_Tight = ibooker.
book1D(
121 "totalHLT" + triggerHistName1_ +
"_eta_Tight",
" HLT(" + triggerHistName1_ +
") total #eta", 8, -2.5, 2.5);
122 h_totalHLTPath1_pt_Tight = ibooker.
book1D(
123 "totalHLT" + triggerHistName1_ +
"_pt_Tight",
" HLT(" + triggerHistName1_ +
") total pt", 10, 20., 220);
124 h_totalHLTPath1_phi_Tight = ibooker.
book1D(
125 "totalHLT" + triggerHistName1_ +
"_phi_Tight",
" HLT(" + triggerHistName1_ +
") total phi", 8, -3.0, 3.0);
127 h_passHLTPath2_eta_Tight = ibooker.
book1D(
128 "passHLT" + triggerHistName2_ +
"_eta_Tight",
" HLT(" + triggerHistName2_ +
") pass #eta", 8, -2.5, 2.5);
129 h_passHLTPath2_pt_Tight = ibooker.
book1D(
130 "passHLT" + triggerHistName2_ +
"_pt_Tight",
" HLT(" + triggerHistName2_ +
") pass pt", 10, 20., 220);
131 h_passHLTPath2_phi_Tight = ibooker.
book1D(
132 "passHLT" + triggerHistName2_ +
"_phi_Tight",
" HLT(" + triggerHistName2_ +
") pass phi", 8, -3.0, 3.0);
133 h_totalHLTPath2_eta_Tight = ibooker.
book1D(
134 "totalHLT" + triggerHistName2_ +
"_eta_Tight",
" HLT(" + triggerHistName2_ +
") total #eta", 8, -2.5, 2.5);
135 h_totalHLTPath2_pt_Tight = ibooker.
book1D(
136 "totalHLT" + triggerHistName2_ +
"_pt_Tight",
" HLT(" + triggerHistName2_ +
") total pt", 10, 20, 220);
137 h_totalHLTPath2_phi_Tight = ibooker.
book1D(
138 "totalHLT" + triggerHistName2_ +
"_phi_Tight",
" HLT(" + triggerHistName2_ +
") total phi", 8, -3.0, 3.0);
141 LogTrace(
metname) <<
"[TriggerMatchMonitor] Analyze the mu in different eta regions";
142 theService->update(iSetup);
145 iEvent.
getByToken(theMuonCollectionLabel_, muons);
148 iEvent.
getByToken(thePATMuonCollectionLabel_, PATmuons);
151 iEvent.
getByToken(triggerObjects_, triggerObjects);
154 iEvent.
getByToken(triggerResultsToken_, triggerResults);
159 iEvent.
getByToken(primaryVerticesToken_, recVtxs);
160 unsigned int theIndexOfThePrimaryVertex = 999.;
161 for (
unsigned int ind = 0; ind < recVtxs->size(); ++ind) {
162 if ((*recVtxs)[ind].isValid() && !((*recVtxs)[ind].isFake())) {
163 theIndexOfThePrimaryVertex = ind;
167 if (theIndexOfThePrimaryVertex < 100) {
168 posVtx = ((*recVtxs)[theIndexOfThePrimaryVertex]).
position();
169 errVtx = ((*recVtxs)[theIndexOfThePrimaryVertex]).
error();
171 LogInfo(
"RecoMuonValidator") <<
"reco::PrimaryVertex not found, use BeamSpot position instead\n";
173 iEvent.
getByToken(beamSpotToken_, recoBeamSpotHandle);
178 errVtx(2, 2) = bs.
sigmaZ();
183 for (
const auto& patMuon : *PATmuons) {
185 patMuon.pfIsolationR04().sumChargedHadronPt +
187 patMuon.pfIsolationR04().sumNeutralHadronEt + patMuon.pfIsolationR04().sumPhotonEt -
188 0.5 * patMuon.pfIsolationR04().sumPUPt) /
192 if (patMuon.isGlobalMuon() && Isolated && patMuon.isTightMuon(thePrimaryVertex)) {
194 TLorentzVector offlineMuon;
195 offlineMuon.SetPtEtaPhiM(patMuon.pt(), patMuon.eta(), patMuon.phi(), 0.0);
197 const char* ptrmuPath1 = triggerPathName1_.c_str();
198 const char* ptrmuPath2 = triggerPathName2_.c_str();
199 if (patMuon.pt() > triggerPtThresholdPath1_) {
200 h_totalHLTPath1_eta_Tight->Fill(patMuon.eta());
201 h_totalHLTPath1_pt_Tight->Fill(patMuon.pt());
202 h_totalHLTPath1_phi_Tight->Fill(patMuon.phi());
204 if (patMuon.pt() > triggerPtThresholdPath2_) {
205 h_totalHLTPath2_eta_Tight->Fill(patMuon.eta());
206 h_totalHLTPath2_pt_Tight->Fill(patMuon.pt());
207 h_totalHLTPath2_phi_Tight->Fill(patMuon.phi());
209 if (patMuon.triggered(ptrmuPath1) && patMuon.hltObject() !=
nullptr) {
210 TLorentzVector hltMuon;
211 hltMuon.SetPtEtaPhiM(patMuon.hltObject()->pt(), patMuon.hltObject()->eta(), patMuon.hltObject()->phi(), 0.0);
212 double DelRrecoHLT = offlineMuon.DeltaR(hltMuon);
214 matchHists[0]->Fill(DelRrecoHLT);
215 matchHists[1]->Fill(DelRrecoHLT);
216 matchHists[2]->Fill(patMuon.hltObject()->pt() / patMuon.pt());
217 if (DelRrecoHLT < 0.2 && patMuon.pt() > triggerPtThresholdPath1_) {
218 h_passHLTPath1_eta_Tight->Fill(patMuon.eta());
219 h_passHLTPath1_pt_Tight->Fill(patMuon.pt());
220 h_passHLTPath1_phi_Tight->Fill(patMuon.phi());
222 if (patMuon.l1Object() !=
nullptr) {
223 TLorentzVector L1Muon;
224 L1Muon.SetPtEtaPhiM(patMuon.l1Object()->pt(), patMuon.l1Object()->eta(), patMuon.l1Object()->phi(), 0.0);
225 double DelRrecoL1 = offlineMuon.DeltaR(L1Muon);
226 matchHists[3]->Fill(DelRrecoL1);
227 matchHists[4]->Fill(DelRrecoL1);
228 matchHists[5]->Fill(patMuon.l1Object()->pt() / patMuon.pt());
233 if (patMuon.triggered(ptrmuPath2)) {
234 TLorentzVector hltMuon50;
235 hltMuon50.SetPtEtaPhiM(
236 patMuon.hltObject()->pt(), patMuon.hltObject()->eta(), patMuon.hltObject()->phi(), 0.0);
237 double DelRrecoHLT50 = offlineMuon.DeltaR(hltMuon50);
239 matchHists[6]->Fill(DelRrecoHLT50);
240 matchHists[7]->Fill(DelRrecoHLT50);
241 matchHists[8]->Fill(patMuon.hltObject()->pt() / patMuon.pt());
242 if (DelRrecoHLT50 < 0.2 && patMuon.pt() > triggerPtThresholdPath2_) {
243 h_passHLTPath2_eta_Tight->Fill(patMuon.eta());
244 h_passHLTPath2_pt_Tight->Fill(patMuon.pt());
245 h_passHLTPath2_phi_Tight->Fill(patMuon.phi());
248 if (patMuon.l1Object() !=
nullptr) {
249 TLorentzVector L1Muon50;
250 L1Muon50.SetPtEtaPhiM(patMuon.l1Object()->pt(), patMuon.l1Object()->eta(), patMuon.l1Object()->phi(), 0.0);
251 double DelRrecoL150 = offlineMuon.DeltaR(L1Muon50);
252 matchHists[9]->Fill(DelRrecoL150);
253 matchHists[10]->Fill(DelRrecoL150);
254 matchHists[11]->Fill(patMuon.l1Object()->pt() / patMuon.pt());
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const std::string metname
void setCurrentFolder(std::string const &fullpath)
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
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
TriggerMatchMonitor(const edm::ParameterSet &pSet)
Constructor.