CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonRecoOneHLT.cc
Go to the documentation of this file.
2 
7 
9 
13 
15 
16 #include <string>
17 #include "TMath.h"
18 using namespace std;
19 using namespace edm;
20 
21 // Uncomment to DEBUG
22 //#define DEBUG
23 
25  parameters = pSet;
26 
27  ParameterSet muonparms = parameters.getParameter<edm::ParameterSet>("SingleMuonTrigger");
28  ParameterSet dimuonparms = parameters.getParameter<edm::ParameterSet>("DoubleMuonTrigger");
30  _DoubleMuonEventFlag = new GenericTriggerEventFlag( dimuonparms );
31 
32  // Trigger Expresions in case de connection to the DB fails
33  singlemuonExpr_ = muonparms.getParameter<std::vector<std::string> >("hltPaths");
34  doublemuonExpr_ = dimuonparms.getParameter<std::vector<std::string> >("hltPaths");
35 }
36 
37 
39  delete _SingleMuonEventFlag;
40  delete _DoubleMuonEventFlag;
41 }
43 #ifdef DEBUG
44  cout << "[MuonRecoOneHLT] beginJob " << endl;
45 #endif
46  dbe->setCurrentFolder("Muons/MuonRecoOneHLT");
47 
49 
50  muReco = dbe->book1D("Muon_Reco", "Muon Reconstructed Tracks", 6, 1, 7);
51  muReco->setBinLabel(1,"glb+tk+sta");
52  muReco->setBinLabel(2,"glb+sta");
53  muReco->setBinLabel(3,"tk+sta");
54  muReco->setBinLabel(4,"tk");
55  muReco->setBinLabel(5,"sta");
56  muReco->setBinLabel(6,"calo");
57 
58  // monitoring of eta parameter
59  etaBin = parameters.getParameter<int>("etaBin");
60  etaMin = parameters.getParameter<double>("etaMin");
61  etaMax = parameters.getParameter<double>("etaMax");
62 
63  std::string histname = "GlbMuon_";
64  etaGlbTrack.push_back(dbe->book1D(histname+"Glb_eta", "#eta_{GLB}", etaBin, etaMin, etaMax));
65  etaGlbTrack.push_back(dbe->book1D(histname+"Tk_eta", "#eta_{TKfromGLB}", etaBin, etaMin, etaMax));
66  etaGlbTrack.push_back(dbe->book1D(histname+"Sta_eta", "#eta_{STAfromGLB}", etaBin, etaMin, etaMax));
67  etaTight = dbe->book1D("TightMuon_eta", "#eta_{GLB}", etaBin, etaMin, etaMax);
68  etaTrack = dbe->book1D("TkMuon_eta", "#eta_{TK}", etaBin, etaMin, etaMax);
69  etaStaTrack = dbe->book1D("StaMuon_eta", "#eta_{STA}", etaBin, etaMin, etaMax);
70 
71  // monitoring of phi paramater
72  phiBin = parameters.getParameter<int>("phiBin");
73  phiMin = parameters.getParameter<double>("phiMin");
74  phiMax = parameters.getParameter<double>("phiMax");
75  phiGlbTrack.push_back(dbe->book1D(histname+"Glb_phi", "#phi_{GLB}", phiBin, phiMin, phiMax));
76  phiGlbTrack[0]->setAxisTitle("rad");
77  phiGlbTrack.push_back(dbe->book1D(histname+"Tk_phi", "#phi_{TKfromGLB}", phiBin, phiMin, phiMax));
78  phiGlbTrack[1]->setAxisTitle("rad");
79  phiGlbTrack.push_back(dbe->book1D(histname+"Sta_phi", "#phi_{STAfromGLB}", phiBin, phiMin, phiMax));
80  phiGlbTrack[2]->setAxisTitle("rad");
81  phiTight = dbe->book1D("TightMuon_phi", "#phi_{GLB}", phiBin, phiMin, phiMax);
82  phiTrack = dbe->book1D("TkMuon_phi", "#phi_{TK}", phiBin, phiMin, phiMax);
83  phiTrack->setAxisTitle("rad");
84  phiStaTrack = dbe->book1D("StaMuon_phi", "#phi_{STA}", phiBin, phiMin, phiMax);
85  phiStaTrack->setAxisTitle("rad");
86 
87  // monitoring of the chi2 parameter
88  chi2Bin = parameters.getParameter<int>("chi2Bin");
89  chi2Min = parameters.getParameter<double>("chi2Min");
90  chi2Max = parameters.getParameter<double>("chi2Max");
91  chi2OvDFGlbTrack.push_back(dbe->book1D(histname+"Glb_chi2OverDf", "#chi_{2}OverDF_{GLB}", chi2Bin, chi2Min, chi2Max));
92  chi2OvDFGlbTrack.push_back(dbe->book1D(histname+"Tk_chi2OverDf", "#chi_{2}OverDF_{TKfromGLB}", phiBin, chi2Min, chi2Max));
93  chi2OvDFGlbTrack.push_back(dbe->book1D(histname+"Sta_chi2OverDf", "#chi_{2}OverDF_{STAfromGLB}", chi2Bin, chi2Min, chi2Max));
94  chi2OvDFTight = dbe->book1D("TightMuon_chi2OverDf", "#chi_{2}OverDF_{GLB}", chi2Bin, chi2Min, chi2Max);
95  chi2OvDFTrack = dbe->book1D("TkMuon_chi2OverDf", "#chi_{2}OverDF_{TK}", chi2Bin, chi2Min, chi2Max);
96  chi2OvDFStaTrack = dbe->book1D("StaMuon_chi2OverDf", "#chi_{2}OverDF_{STA}", chi2Bin, chi2Min, chi2Max);
97 
98  // monitoring of the transverse momentum
99  ptBin = parameters.getParameter<int>("ptBin");
100  ptMin = parameters.getParameter<double>("ptMin");
101  ptMax = parameters.getParameter<double>("ptMax");
102  ptGlbTrack.push_back(dbe->book1D(histname+"Glb_pt", "pt_{GLB}", ptBin, ptMin, ptMax));
103  ptGlbTrack[0]->setAxisTitle("GeV");
104  ptGlbTrack.push_back(dbe->book1D(histname+"Tk_pt", "pt_{TKfromGLB}", ptBin, ptMin, ptMax));
105  ptGlbTrack[1]->setAxisTitle("GeV");
106  ptGlbTrack.push_back(dbe->book1D(histname+"Sta_pt", "pt_{STAfromGLB}", ptBin, ptMin, ptMax));
107  ptGlbTrack[2]->setAxisTitle("GeV");
108  ptTight = dbe->book1D("TightMuon_pt", "pt_{GLB}", ptBin, ptMin, ptMax);
109  ptTight->setAxisTitle("GeV");
110  ptTrack = dbe->book1D("TkMuon_pt", "pt_{TK}", ptBin, ptMin, ptMax);
111  ptTrack->setAxisTitle("GeV");
112  ptStaTrack = dbe->book1D("StaMuon_pt", "pt_{STA}", ptBin, ptMin, ptMax);
113  ptStaTrack->setAxisTitle("GeV");
114 }
115 
116 void MuonRecoOneHLT::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup){
117 #ifdef DEBUG
118  cout << "[MuonRecoOneHLT] beginRun " << endl;
119  cout << "[MuonRecoOneHLT] Is MuonEventFlag On? "<< _SignleMuonEventFlag->on() << endl;
120 #endif
121  if ( _SingleMuonEventFlag->on() ) _SingleMuonEventFlag->initRun( iRun, iSetup );
122  if ( _DoubleMuonEventFlag->on() ) _DoubleMuonEventFlag->initRun( iRun, iSetup );
123 
128 }
130  // const reco::Muon& recoMu,
132 #ifdef DEBUG
133  cout << "[MuonRecoOneHLT] analyze "<< endl;
134 #endif
135 
136  // TEST FOR ONLY TAKE HIGHEST PT MUON
138  iEvent.getByLabel(theMuonCollectionLabel,muons);
139 
140 
141  std::map<float,reco::Muon> muonMap;
142  for (reco::MuonCollection::const_iterator recoMu = muons->begin(); recoMu!=muons->end(); ++recoMu){
143  muonMap[recoMu->pt()] = *recoMu;
144  }
145  std::vector<reco::Muon> LeadingMuon;
146  for( std::map<float,reco::Muon>::reverse_iterator rit=muonMap.rbegin(); rit!=muonMap.rend(); ++rit){
147  LeadingMuon.push_back( (*rit).second );
148  }
149 
151  Handle<reco::BeamSpot> beamSpotHandle;
152  iEvent.getByLabel("offlineBeamSpot", beamSpotHandle);
153  beamSpot = *beamSpotHandle;
154 
155  const edm::TriggerNames& triggerNames = iEvent.triggerNames(triggerResults);
156  const unsigned int nTrig(triggerNames.size());
157  bool _trig_SingleMu = false;
158  bool _trig_DoubleMu = false;
159  for (unsigned int i=0;i<nTrig;++i){
160  if (triggerNames.triggerName(i).find(singlemuonExpr_[0].substr(0,singlemuonExpr_[0].rfind("_v")+2))!=std::string::npos && triggerResults.accept(i))
161  _trig_SingleMu = true;
162  if (triggerNames.triggerName(i).find(doublemuonExpr_[0].substr(0,doublemuonExpr_[0].rfind("_v")+2))!=std::string::npos && triggerResults.accept(i))
163  _trig_DoubleMu = true;
164  }
165 #ifdef DEBUG
166  cout << "[MuonRecoOneHLT] Trigger Fired ? "<< _trig_SingleMu << endl;
167 #endif
168 
169  if (!_trig_SingleMu && !_trig_DoubleMu) return;
170  if (LeadingMuon.size() == 0) return;
171  // if (_MuonEventFlag->on() && !(_MuonEventFlag->accept(iEvent,iSetup))) return;
172 
173  // Check if Muon is Global
174  if(LeadingMuon[0].isGlobalMuon()) {
175  LogTrace(metname)<<"[MuonRecoOneHLT] The mu is global - filling the histos";
176  if(LeadingMuon[0].isTrackerMuon() && LeadingMuon[0].isStandAloneMuon()) muReco->Fill(1);
177  if(!(LeadingMuon[0].isTrackerMuon()) && LeadingMuon[0].isStandAloneMuon()) muReco->Fill(2);
178  if(!LeadingMuon[0].isStandAloneMuon())
179  LogTrace(metname)<<"[MuonRecoOneHLT] ERROR: the mu is global but not standalone!";
180 
181  // get the track combinig the information from both the Tracker and the Spectrometer
182  reco::TrackRef recoCombinedGlbTrack = LeadingMuon[0].combinedMuon();
183  // get the track using only the tracker data
184  reco::TrackRef recoTkGlbTrack = LeadingMuon[0].track();
185  // get the track using only the mu spectrometer data
186  reco::TrackRef recoStaGlbTrack = LeadingMuon[0].standAloneMuon();
187 
188  etaGlbTrack[0]->Fill(recoCombinedGlbTrack->eta());
189  etaGlbTrack[1]->Fill(recoTkGlbTrack->eta());
190  etaGlbTrack[2]->Fill(recoStaGlbTrack->eta());
191 
192  phiGlbTrack[0]->Fill(recoCombinedGlbTrack->phi());
193  phiGlbTrack[1]->Fill(recoTkGlbTrack->phi());
194  phiGlbTrack[2]->Fill(recoStaGlbTrack->phi());
195 
196  chi2OvDFGlbTrack[0]->Fill(recoCombinedGlbTrack->normalizedChi2());
197  chi2OvDFGlbTrack[1]->Fill(recoTkGlbTrack->normalizedChi2());
198  chi2OvDFGlbTrack[2]->Fill(recoStaGlbTrack->normalizedChi2());
199 
200  ptGlbTrack[0]->Fill(recoCombinedGlbTrack->pt());
201  ptGlbTrack[1]->Fill(recoTkGlbTrack->pt());
202  ptGlbTrack[2]->Fill(recoStaGlbTrack->pt());
203  }
204  // Check if Muon is Tight
205  if (LeadingMuon[0].isGlobalMuon() &&
206  LeadingMuon[0].isTrackerMuon() &&
207  LeadingMuon[0].combinedMuon()->normalizedChi2()<10. &&
208  LeadingMuon[0].combinedMuon()->hitPattern().numberOfValidMuonHits()>0 &&
209  fabs(LeadingMuon[0].combinedMuon()->dxy(beamSpot.position()))<0.2 &&
210  LeadingMuon[0].combinedMuon()->hitPattern().numberOfValidPixelHits()>0 &&
211  LeadingMuon[0].numberOfMatches() > 1){
212 
213  LogTrace(metname)<<"[MuonRecoOneHLT] The mu is tracker only - filling the histos";
214 
215  reco::TrackRef recoCombinedGlbTrack = LeadingMuon[0].combinedMuon();
216 
217  etaTight->Fill(recoCombinedGlbTrack->eta());
218  phiTight->Fill(recoCombinedGlbTrack->phi());
219  chi2OvDFTight->Fill(recoCombinedGlbTrack->normalizedChi2());
220  ptTight->Fill(recoCombinedGlbTrack->pt());
221  }
222 
223  // Check if Muon is Tracker but NOT Global
224  if(LeadingMuon[0].isTrackerMuon() && !(LeadingMuon[0].isGlobalMuon())) {
225  LogTrace(metname)<<"[MuonRecoOneHLT] The mu is tracker only - filling the histos";
226  if(LeadingMuon[0].isStandAloneMuon()) muReco->Fill(3);
227  if(!(LeadingMuon[0].isStandAloneMuon())) muReco->Fill(4);
228 
229  // get the track using only the tracker data
230  reco::TrackRef recoTrack = LeadingMuon[0].track();
231 
232  etaTrack->Fill(recoTrack->eta());
233  phiTrack->Fill(recoTrack->phi());
234  chi2OvDFTrack->Fill(recoTrack->normalizedChi2());
235  ptTrack->Fill(recoTrack->pt());
236  }
237 
238  // Check if Muon is STA but NOT Global
239  if(LeadingMuon[0].isStandAloneMuon() && !(LeadingMuon[0].isGlobalMuon())) {
240  LogTrace(metname)<<"[MuonRecoOneHLT] The mu is STA only - filling the histos";
241  if(!(LeadingMuon[0].isTrackerMuon())) muReco->Fill(5);
242 
243  // get the track using only the mu spectrometer data
244  reco::TrackRef recoStaTrack = LeadingMuon[0].standAloneMuon();
245 
246  etaStaTrack->Fill(recoStaTrack->eta());
247  phiStaTrack->Fill(recoStaTrack->phi());
248  chi2OvDFStaTrack->Fill(recoStaTrack->normalizedChi2());
249  ptStaTrack->Fill(recoStaTrack->pt());
250  }
251  // Check if Muon is Only CaloMuon
252  if(LeadingMuon[0].isCaloMuon() && !(LeadingMuon[0].isGlobalMuon()) && !(LeadingMuon[0].isTrackerMuon()) && !(LeadingMuon[0].isStandAloneMuon()))
253  muReco->Fill(6);
254 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
edm::ParameterSet parameters
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:199
void beginJob(DQMStore *dbe)
Inizialize parameters for histo binning.
MonitorElement * phiTight
MonitorElement * ptTrack
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
GenericTriggerEventFlag * _DoubleMuonEventFlag
MonitorElement * chi2OvDFTrack
bool accept() const
Has at least one path accepted the event?
GenericTriggerEventFlag * _SingleMuonEventFlag
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
Strings::size_type size() const
Definition: TriggerNames.cc:39
MonitorElement * etaTight
MonitorElement * etaStaTrack
std::string metname
std::vector< std::string > doublemuonExpr_
void Fill(long long x)
std::vector< std::string > expressionsFromDB(const std::string &key, const edm::EventSetup &setup)
Reads and returns logical expressions from DB.
int iEvent
Definition: GenABIO.cc:243
MonitorElement * chi2OvDFStaTrack
edm::InputTag theMuonCollectionLabel
std::vector< MonitorElement * > phiGlbTrack
MonitorElement * ptStaTrack
std::vector< std::string > singlemuonExpr_
std::vector< MonitorElement * > ptGlbTrack
MonitorElement * etaTrack
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
virtual ~MuonRecoOneHLT()
Destructor.
#define LogTrace(id)
std::vector< MonitorElement * > etaGlbTrack
MonitorElement * phiTrack
MonitorElement * ptTight
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
tuple muons
Definition: patZpeak.py:38
MonitorElement * phiStaTrack
tuple cout
Definition: gather_cfg.py:121
const Point & position() const
position
Definition: BeamSpot.h:63
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
void analyze(const edm::Event &, const edm::EventSetup &, const edm::TriggerResults &)
Get the analysis.
MonitorElement * muReco
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup)
MuonRecoOneHLT(const edm::ParameterSet &, MuonServiceProxy *theService)
Constructor.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33
MonitorElement * chi2OvDFTight
std::vector< MonitorElement * > chi2OvDFGlbTrack