CMS 3D CMS Logo

CosmicMuonRecoAnalyzer.cc
Go to the documentation of this file.
2 
7 
13 
17 
19 
20 using namespace std;
21 using namespace edm;
22 
24 public:
27 
29  ~CosmicMuonRecoAnalyzer() override;
30 
32  void analyze(const edm::Event&, const edm::EventSetup&) override;
33  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
34 
35 private:
36  // ----------member data ---------------------------
38 
40 
41  //histo binning parameters
42 
43  int hitsBin;
44  int hitsMin;
45  int hitsMax;
46 
47  int nTrkBin;
48  int nTrkMax;
49  int nTrkMin;
50 
51  int etaBin;
52  double etaMin;
53  double etaMax;
54 
55  int thetaBin;
56  double thetaMin;
57  double thetaMax;
58 
59  int phiBin;
60  double phiMin;
61  double phiMax;
62 
63  int chi2Bin;
64  double chi2Min;
65  double chi2Max;
66 
67  int pBin;
68  double pMin;
69  double pMax;
70 
71  int ptBin;
72  double ptMin;
73  double ptMax;
74 
75  int pResBin;
76  double pResMin;
77  double pResMax;
78 
79  // sta muon
81 
92 
97 
99 };
100 
102  parameters = pSet;
103 
104  // the services:
105  theMuonCollectionLabel_ = consumes<edm::View<reco::Track> >(parameters.getParameter<edm::InputTag>("MuonCollection"));
106 
107  nTrkBin = parameters.getParameter<int>("nTrkBin");
108  nTrkMax = parameters.getParameter<int>("nTrkMax");
109  nTrkMin = parameters.getParameter<int>("nTrkMin");
110  ptBin = parameters.getParameter<int>("ptBin");
111  ptMin = parameters.getParameter<double>("ptMin");
112  ptMax = parameters.getParameter<double>("ptMax");
113  pBin = parameters.getParameter<int>("pBin");
114  pMin = parameters.getParameter<double>("pMin");
115  pMax = parameters.getParameter<double>("pMax");
116  chi2Bin = parameters.getParameter<int>("chi2Bin");
117  chi2Min = parameters.getParameter<double>("chi2Min");
118  chi2Max = parameters.getParameter<double>("chi2Max");
119  phiBin = parameters.getParameter<int>("phiBin");
120  phiMin = parameters.getParameter<double>("phiMin");
121  phiMax = parameters.getParameter<double>("phiMax");
122  thetaBin = parameters.getParameter<int>("thetaBin");
123  thetaMin = parameters.getParameter<double>("thetaMin");
124  thetaMax = parameters.getParameter<double>("thetaMax");
125  etaBin = parameters.getParameter<int>("etaBin");
126  etaMin = parameters.getParameter<double>("etaMin");
127  etaMax = parameters.getParameter<double>("etaMax");
128  pResBin = parameters.getParameter<int>("pResBin");
129  pResMin = parameters.getParameter<double>("pResMin");
130  pResMax = parameters.getParameter<double>("pResMax");
131 
132  hitsBin = parameters.getParameter<int>("hitsBin");
133  hitsMin = parameters.getParameter<int>("hitsMin");
134  hitsMax = parameters.getParameter<int>("hitsMax");
135 
136  theFolder = parameters.getParameter<string>("folder");
137 }
138 
140 
142  edm::Run const& /*iRun*/,
143  edm::EventSetup const& /* iSetup */) {
144  ibooker.cd();
145  ibooker.setCurrentFolder(theFolder);
146 
148  // monitoring of eta parameter
150  std::string histname = "cosmicMuon";
151 
152  nTracksSta = ibooker.book1D(histname + "_traks", "#tracks", nTrkBin, nTrkMin, nTrkMax);
153 
154  etaStaTrack = ibooker.book1D(histname + "_eta", "#eta_{STA}", etaBin, etaMin, etaMax);
155 
157  // monitoring of theta parameter
159 
160  thetaStaTrack = ibooker.book1D(histname + "_theta", "#theta_{STA}", thetaBin, thetaMin, thetaMax);
161  thetaStaTrack->setAxisTitle("rad");
162 
163  // monitoring of phi paramater
164 
165  phiStaTrack = ibooker.book1D(histname + "_phi", "#phi_{STA}", phiBin, phiMin, phiMax);
166  phiStaTrack->setAxisTitle("rad");
167 
168  // monitoring of the chi2 parameter
169 
170  chi2OvDFStaTrack = ibooker.book1D(histname + "_chi2OverDf", "#chi_{2}OverDF_{STA}", chi2Bin, chi2Min, chi2Max);
171 
172  //--------------------------
173 
174  probchi2StaTrack = ibooker.book1D(histname + "_probchi", "Prob #chi_{STA}", 120, chi2Min, 1.20);
175 
176  // monitoring of the momentum
177 
178  pStaTrack = ibooker.book1D(histname + "_p", "p_{STA}", pBin, pMin, pMax);
179  pStaTrack->setAxisTitle("GeV");
180 
181  qOverPStaTrack = ibooker.book1D(histname + "_qoverp", "qoverp_{STA}", pResBin, pResMin, pResMax);
182  qOverPStaTrack->setAxisTitle("1/GeV");
183 
184  qOverPStaTrack_p =
185  ibooker.book2D(histname + "_qoverp_p", "qoverp_p_{STA}", pBin, pMin, pMax, pResBin, pResMin, pResMax);
186 
187  // monitoring of the transverse momentum
188 
189  ptStaTrack = ibooker.book1D(histname + "_pt", "pt_{STA}", ptBin, ptMin, pMax);
190  ptStaTrack->setAxisTitle("GeV");
191 
192  // monitoring of the muon charge
193 
194  qStaTrack = ibooker.book1D(histname + "_q", "q_{STA}", 5, -2.5, 2.5);
195 
197  // monitoring of the phi-eta
198 
199  phiVsetaStaTrack = ibooker.book2D(
200  histname + "_phiVseta", "#phi vs #eta (STA)", etaBin / 2, etaMin, etaMax, phiBin / 2, phiMin, phiMax);
201  phiVsetaStaTrack->setAxisTitle("eta", 1);
202  phiVsetaStaTrack->setAxisTitle("phi", 2);
203 
204  // monitoring the hits
205  nValidHitsStaTrack = ibooker.book1D(histname + "_nValidHits", "#valid hits (STA)", hitsBin, hitsMin, hitsMax);
206 
207  nValidHitsStaTrack_eta = ibooker.book2D(
208  histname + "_nValidHits_eta", "#valid hits vs eta (STA)", etaBin, etaMin, etaMax, hitsBin, hitsMin, hitsMax);
209 
210  nValidHitsStaTrack_phi = ibooker.book2D(
211  histname + "_nValidHits_phi", "#valid hits vs phi (STA)", phiBin, phiMin, phiMax, hitsBin, hitsMin, hitsMax);
212 }
213 
215  LogTrace("CosmicMuon") << "[MuonRecoAnalyzer] Analyze the mu";
216 
217  // Take the muon container
219  iEvent.getByToken(theMuonCollectionLabel_, muons);
220 
221  int nTracks_ = 0;
222 
223  if (!muons.isValid())
224  return;
225 
226  for (edm::View<reco::Track>::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
227  nTracks_++;
228 
229  // get the track using only the mu spectrometer data
230 
231  etaStaTrack->Fill(muon->eta());
232  thetaStaTrack->Fill(muon->theta());
233  phiStaTrack->Fill(muon->phi());
234  chi2OvDFStaTrack->Fill(muon->normalizedChi2());
235  probchi2StaTrack->Fill(TMath::Prob(muon->chi2(), muon->ndof()));
236  pStaTrack->Fill(muon->p());
237  ptStaTrack->Fill(muon->pt());
238  qStaTrack->Fill(muon->charge());
239  qOverPStaTrack->Fill(muon->qoverp());
240  qOverPStaTrack_p->Fill(muon->p(), muon->qoverp());
241  phiVsetaStaTrack->Fill(muon->eta(), muon->phi());
242 
243  nValidHitsStaTrack->Fill(muon->numberOfValidHits());
244  nValidHitsStaTrack_eta->Fill(muon->eta(), muon->numberOfValidHits());
245  nValidHitsStaTrack_phi->Fill(muon->phi(), muon->numberOfValidHits());
246  }
247 
248  nTracksSta->Fill(nTracks_);
249 }
250 
void analyze(const edm::Event &, const edm::EventSetup &) override
Inizialize parameters for histo binning.
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
constexpr float ptMin
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
MonitorElement * nValidHitsStaTrack
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
#define LogTrace(id)
example_stream void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * nValidHitsStaTrack_phi
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
~CosmicMuonRecoAnalyzer() override
Destructor.
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * nValidHitsStaTrack_eta
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:88
CosmicMuonRecoAnalyzer(const edm::ParameterSet &)
Constructor.
edm::EDGetTokenT< edm::View< reco::Track > > theMuonCollectionLabel_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
Definition: Run.h:45
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)