CMS 3D CMS Logo

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