27 singlemuonExpr_ = muonparms.
getParameter<std::vector<std::string> >(
"hltPaths");
28 doublemuonExpr_ = dimuonparms.getParameter<std::vector<std::string> >(
"hltPaths");
30 theMuonCollectionLabel_ = consumes<reco::MuonCollection>(
parameters.getParameter<
edm::InputTag>(
"MuonCollection"));
33 theTriggerResultsLabel_ = consumes<TriggerResults>(
parameters.getParameter<
InputTag>(
"TriggerResultsLabel"));
38 delete _SingleMuonEventFlag;
39 delete _DoubleMuonEventFlag;
43 cout <<
"[MuonRecoOneHLT] beginJob " << endl;
50 cout <<
"[MuonRecoOneHLT] beginRun " << endl;
51 cout <<
"[MuonRecoOneHLT] Is MuonEventFlag On? "<< _SingleMuonEventFlag->on() << endl;
55 dbe->setCurrentFolder(
"Muons/MuonRecoOneHLT");
57 muReco = dbe->book1D(
"Muon_Reco",
"Muon Reconstructed Tracks", 6, 1, 7);
58 muReco->setBinLabel(1,
"glb+tk+sta");
59 muReco->setBinLabel(2,
"glb+sta");
60 muReco->setBinLabel(3,
"tk+sta");
61 muReco->setBinLabel(4,
"tk");
62 muReco->setBinLabel(5,
"sta");
63 muReco->setBinLabel(6,
"calo");
66 etaBin =
parameters.getParameter<
int>(
"etaBin");
71 etaGlbTrack.push_back(dbe->book1D(histname+
"Glb_eta",
"#eta_{GLB}", etaBin, etaMin, etaMax));
72 etaGlbTrack.push_back(dbe->book1D(histname+
"Tk_eta",
"#eta_{TKfromGLB}", etaBin, etaMin, etaMax));
73 etaGlbTrack.push_back(dbe->book1D(histname+
"Sta_eta",
"#eta_{STAfromGLB}", etaBin, etaMin, etaMax));
74 etaTight = dbe->book1D(
"TightMuon_eta",
"#eta_{GLB}", etaBin, etaMin, etaMax);
75 etaTrack = dbe->book1D(
"TkMuon_eta",
"#eta_{TK}", etaBin, etaMin, etaMax);
76 etaStaTrack = dbe->book1D(
"StaMuon_eta",
"#eta_{STA}", etaBin, etaMin, etaMax);
79 phiBin =
parameters.getParameter<
int>(
"phiBin");
82 phiGlbTrack.push_back(dbe->book1D(histname+
"Glb_phi",
"#phi_{GLB}", phiBin, phiMin, phiMax));
83 phiGlbTrack[0]->setAxisTitle(
"rad");
84 phiGlbTrack.push_back(dbe->book1D(histname+
"Tk_phi",
"#phi_{TKfromGLB}", phiBin, phiMin, phiMax));
85 phiGlbTrack[1]->setAxisTitle(
"rad");
86 phiGlbTrack.push_back(dbe->book1D(histname+
"Sta_phi",
"#phi_{STAfromGLB}", phiBin, phiMin, phiMax));
87 phiGlbTrack[2]->setAxisTitle(
"rad");
88 phiTight = dbe->book1D(
"TightMuon_phi",
"#phi_{GLB}", phiBin, phiMin, phiMax);
89 phiTrack = dbe->book1D(
"TkMuon_phi",
"#phi_{TK}", phiBin, phiMin, phiMax);
90 phiTrack->setAxisTitle(
"rad");
91 phiStaTrack = dbe->book1D(
"StaMuon_phi",
"#phi_{STA}", phiBin, phiMin, phiMax);
92 phiStaTrack->setAxisTitle(
"rad");
95 chi2Bin =
parameters.getParameter<
int>(
"chi2Bin");
96 chi2Min =
parameters.getParameter<
double>(
"chi2Min");
97 chi2Max =
parameters.getParameter<
double>(
"chi2Max");
98 chi2OvDFGlbTrack.push_back(dbe->book1D(histname+
"Glb_chi2OverDf",
"#chi_{2}OverDF_{GLB}", chi2Bin, chi2Min, chi2Max));
99 chi2OvDFGlbTrack.push_back(dbe->book1D(histname+
"Tk_chi2OverDf",
"#chi_{2}OverDF_{TKfromGLB}", phiBin, chi2Min, chi2Max));
100 chi2OvDFGlbTrack.push_back(dbe->book1D(histname+
"Sta_chi2OverDf",
"#chi_{2}OverDF_{STAfromGLB}", chi2Bin, chi2Min, chi2Max));
101 chi2OvDFTight = dbe->book1D(
"TightMuon_chi2OverDf",
"#chi_{2}OverDF_{GLB}", chi2Bin, chi2Min, chi2Max);
102 chi2OvDFTrack = dbe->book1D(
"TkMuon_chi2OverDf",
"#chi_{2}OverDF_{TK}", chi2Bin, chi2Min, chi2Max);
103 chi2OvDFStaTrack = dbe->book1D(
"StaMuon_chi2OverDf",
"#chi_{2}OverDF_{STA}", chi2Bin, chi2Min, chi2Max);
106 ptBin =
parameters.getParameter<
int>(
"ptBin");
109 ptGlbTrack.push_back(dbe->book1D(histname+
"Glb_pt",
"pt_{GLB}", ptBin, ptMin, ptMax));
110 ptGlbTrack[0]->setAxisTitle(
"GeV");
111 ptGlbTrack.push_back(dbe->book1D(histname+
"Tk_pt",
"pt_{TKfromGLB}", ptBin, ptMin, ptMax));
112 ptGlbTrack[1]->setAxisTitle(
"GeV");
113 ptGlbTrack.push_back(dbe->book1D(histname+
"Sta_pt",
"pt_{STAfromGLB}", ptBin, ptMin, ptMax));
114 ptGlbTrack[2]->setAxisTitle(
"GeV");
115 ptTight = dbe->book1D(
"TightMuon_pt",
"pt_{GLB}", ptBin, ptMin, ptMax);
116 ptTight->setAxisTitle(
"GeV");
117 ptTrack = dbe->book1D(
"TkMuon_pt",
"pt_{TK}", ptBin, ptMin, ptMax);
118 ptTrack->setAxisTitle(
"GeV");
119 ptStaTrack = dbe->book1D(
"StaMuon_pt",
"pt_{STA}", ptBin, ptMin, ptMax);
120 ptStaTrack->setAxisTitle(
"GeV");
122 if ( _SingleMuonEventFlag->on() ) _SingleMuonEventFlag->initRun( iRun, iSetup );
123 if ( _DoubleMuonEventFlag->on() ) _DoubleMuonEventFlag->initRun( iRun, iSetup );
125 if (_SingleMuonEventFlag->on() && _SingleMuonEventFlag->expressionsFromDB(_SingleMuonEventFlag->hltDBKey(), iSetup)[0] !=
"CONFIG_ERROR")
126 singlemuonExpr_ = _SingleMuonEventFlag->expressionsFromDB(_SingleMuonEventFlag->hltDBKey(),iSetup);
127 if (_DoubleMuonEventFlag->on() && _DoubleMuonEventFlag->expressionsFromDB(_DoubleMuonEventFlag->hltDBKey(), iSetup)[0] !=
"CONFIG_ERROR")
128 singlemuonExpr_ = _DoubleMuonEventFlag->expressionsFromDB(_DoubleMuonEventFlag->hltDBKey(),iSetup);
131 theService->update(iSetup);
137 unsigned int theIndexOfThePrimaryVertex = 999.;
142 for (
unsigned int ind=0; ind<vertex->size(); ++ind) {
143 if ( (*vertex)[ind].isValid() && !((*vertex)[ind].isFake()) ) {
144 theIndexOfThePrimaryVertex = ind;
150 if (theIndexOfThePrimaryVertex<100) {
151 posVtx = ((*vertex)[theIndexOfThePrimaryVertex]).
position();
152 errVtx = ((*vertex)[theIndexOfThePrimaryVertex]).
error();
155 LogInfo(
"RecoMuonValidator") <<
"reco::PrimaryVertex not found, use BeamSpot position instead\n";
158 iEvent.
getByToken(theBeamSpotLabel_,recoBeamSpotHandle);
164 errVtx(2,2) = bs.
sigmaZ();
173 iEvent.
getByToken(theMuonCollectionLabel_,muons);
176 iEvent.
getByToken(theTriggerResultsLabel_, triggerResults);
182 std::map<float,reco::Muon> muonMap;
183 for (reco::MuonCollection::const_iterator recoMu = muons->begin(); recoMu!=muons->end(); ++recoMu){
184 muonMap[recoMu->pt()] = *recoMu;
186 std::vector<reco::Muon> LeadingMuon;
187 for( std::map<float,reco::Muon>::reverse_iterator rit=muonMap.rbegin(); rit!=muonMap.rend(); ++rit){
188 LeadingMuon.push_back( (*rit).second );
193 const unsigned int nTrig(triggerNames.
size());
194 bool _trig_SingleMu =
false;
195 bool _trig_DoubleMu =
false;
196 for (
unsigned int i=0;
i<nTrig;++
i){
197 if (triggerNames.
triggerName(
i).find(singlemuonExpr_[0].substr(0,singlemuonExpr_[0].rfind(
"_v")+2))!=std::string::npos && triggerResults->accept(
i))
198 _trig_SingleMu =
true;
199 if (triggerNames.
triggerName(
i).find(doublemuonExpr_[0].substr(0,doublemuonExpr_[0].rfind(
"_v")+2))!=std::string::npos && triggerResults->accept(
i))
200 _trig_DoubleMu =
true;
203 cout <<
"[MuonRecoOneHLT] Trigger Fired ? "<< (_trig_SingleMu || _trig_DoubleMu) << endl;
206 if (!_trig_SingleMu && !_trig_DoubleMu)
return;
207 if (LeadingMuon.size() == 0)
return;
211 if(LeadingMuon[0].isGlobalMuon()) {
212 LogTrace(
metname)<<
"[MuonRecoOneHLT] The mu is global - filling the histos";
213 if(LeadingMuon[0].isTrackerMuon() && LeadingMuon[0].isStandAloneMuon()) muReco->Fill(1);
214 if(!(LeadingMuon[0].isTrackerMuon()) && LeadingMuon[0].isStandAloneMuon()) muReco->Fill(2);
215 if(!LeadingMuon[0].isStandAloneMuon())
216 LogTrace(
metname)<<
"[MuonRecoOneHLT] ERROR: the mu is global but not standalone!";
219 reco::TrackRef recoCombinedGlbTrack = LeadingMuon[0].combinedMuon();
225 etaGlbTrack[0]->Fill(recoCombinedGlbTrack->eta());
226 etaGlbTrack[1]->Fill(recoTkGlbTrack->eta());
227 etaGlbTrack[2]->Fill(recoStaGlbTrack->eta());
229 phiGlbTrack[0]->Fill(recoCombinedGlbTrack->phi());
230 phiGlbTrack[1]->Fill(recoTkGlbTrack->phi());
231 phiGlbTrack[2]->Fill(recoStaGlbTrack->phi());
233 chi2OvDFGlbTrack[0]->Fill(recoCombinedGlbTrack->normalizedChi2());
234 chi2OvDFGlbTrack[1]->Fill(recoTkGlbTrack->normalizedChi2());
235 chi2OvDFGlbTrack[2]->Fill(recoStaGlbTrack->normalizedChi2());
237 ptGlbTrack[0]->Fill(recoCombinedGlbTrack->pt());
238 ptGlbTrack[1]->Fill(recoTkGlbTrack->pt());
239 ptGlbTrack[2]->Fill(recoStaGlbTrack->pt());
244 LogTrace(
metname)<<
"[MuonRecoOneHLT] The mu is tracker only - filling the histos";
246 reco::TrackRef recoCombinedGlbTrack = LeadingMuon[0].combinedMuon();
248 etaTight->Fill(recoCombinedGlbTrack->eta());
249 phiTight->Fill(recoCombinedGlbTrack->phi());
250 chi2OvDFTight->Fill(recoCombinedGlbTrack->normalizedChi2());
251 ptTight->Fill(recoCombinedGlbTrack->pt());
255 if(LeadingMuon[0].isTrackerMuon() && !(LeadingMuon[0].isGlobalMuon())) {
256 LogTrace(
metname)<<
"[MuonRecoOneHLT] The mu is tracker only - filling the histos";
257 if(LeadingMuon[0].isStandAloneMuon()) muReco->Fill(3);
258 if(!(LeadingMuon[0].isStandAloneMuon())) muReco->Fill(4);
263 etaTrack->Fill(recoTrack->eta());
264 phiTrack->Fill(recoTrack->phi());
265 chi2OvDFTrack->Fill(recoTrack->normalizedChi2());
266 ptTrack->Fill(recoTrack->pt());
270 if(LeadingMuon[0].isStandAloneMuon() && !(LeadingMuon[0].isGlobalMuon())) {
271 LogTrace(
metname)<<
"[MuonRecoOneHLT] The mu is STA only - filling the histos";
272 if(!(LeadingMuon[0].isTrackerMuon())) muReco->Fill(5);
277 etaStaTrack->Fill(recoStaTrack->eta());
278 phiStaTrack->Fill(recoStaTrack->phi());
279 chi2OvDFStaTrack->Fill(recoStaTrack->normalizedChi2());
280 ptStaTrack->Fill(recoStaTrack->pt());
283 if(LeadingMuon[0].isCaloMuon() && !(LeadingMuon[0].isGlobalMuon()) && !(LeadingMuon[0].isTrackerMuon()) && !(LeadingMuon[0].isStandAloneMuon()))
T getParameter(std::string const &) const
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const std::string metname
void analyze(const edm::Event &, const edm::EventSetup &)
Get the analysis.
math::Error< dimension >::type Error
covariance error matrix (3x3)
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
Strings::size_type size() const
static int position[TOTALCHAMBERS][3]
void beginJob()
Inizialize parameters for histo binning.
math::XYZPoint Point
point in the space
double BeamWidthX() const
beam width X
static std::string const triggerResults
~MuonRecoOneHLT()
Destructor.
MuonRecoOneHLT(const edm::ParameterSet &)
Constructor.
std::string const & triggerName(unsigned int index) const
double sigmaZ() const
sigma z
double BeamWidthY() const
beam width Y
const Point & position() const
position
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
void beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup)