CMS 3D CMS Logo

CosmicMuonRecoAnalyzer.cc
Go to the documentation of this file.
3 
10 
11 #include <memory>
12 #include <fstream>
19 
23 
25 
28 
29 #include <string>
30 #include "TMath.h"
31 #include "TList.h"
32 
33 using namespace std;
34 using namespace edm;
35 
36 
38 public:
41 
43  ~CosmicMuonRecoAnalyzer() override;
44 
46  void analyze(const edm::Event&, const edm::EventSetup&) override;
47  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
48 
49 private:
50  // ----------member data ---------------------------
53 
55 
56  //histo binning parameters
57 
58  int hitsBin;
59  int hitsMin;
60  int hitsMax;
61 
62  int nTrkBin;
63  int nTrkMax;
64  int nTrkMin;
65 
66  int etaBin;
67  double etaMin;
68  double etaMax;
69 
70  int thetaBin;
71  double thetaMin;
72  double thetaMax;
73 
74  int phiBin;
75  double phiMin;
76  double phiMax;
77 
78  int chi2Bin;
79  double chi2Min;
80  double chi2Max;
81 
82  int pBin;
83  double pMin;
84  double pMax;
85 
86  int ptBin;
87  double ptMin;
88  double ptMax;
89 
90  int pResBin;
91  double pResMin;
92  double pResMax;
93 
94  // sta muon
96 
107 
112 
114 };
115 
116 
118  parameters = pSet;
119 
120  // the services:
121  theService = new MuonServiceProxy(parameters.getParameter<ParameterSet>("ServiceParameters"));
122  theMuonCollectionLabel_ = consumes<edm::View<reco::Track> >(parameters.getParameter<edm::InputTag>("MuonCollection"));
123 
124  nTrkBin = parameters.getParameter<int>("nTrkBin");
125  nTrkMax = parameters.getParameter<int>("nTrkMax");
126  nTrkMin = parameters.getParameter<int>("nTrkMin");
127  ptBin = parameters.getParameter<int>("ptBin");
128  ptMin = parameters.getParameter<double>("ptMin");
129  ptMax = parameters.getParameter<double>("ptMax");
130  pBin = parameters.getParameter<int>("pBin");
131  pMin = parameters.getParameter<double>("pMin");
132  pMax = parameters.getParameter<double>("pMax");
133  chi2Bin = parameters.getParameter<int>("chi2Bin");
134  chi2Min = parameters.getParameter<double>("chi2Min");
135  chi2Max = parameters.getParameter<double>("chi2Max");
136  phiBin = parameters.getParameter<int>("phiBin");
137  phiMin = parameters.getParameter<double>("phiMin");
138  phiMax = parameters.getParameter<double>("phiMax");
139  thetaBin = parameters.getParameter<int>("thetaBin");
140  thetaMin = parameters.getParameter<double>("thetaMin");
141  thetaMax = parameters.getParameter<double>("thetaMax");
142  etaBin = parameters.getParameter<int>("etaBin");
143  etaMin = parameters.getParameter<double>("etaMin");
144  etaMax = parameters.getParameter<double>("etaMax");
145  pResBin = parameters.getParameter<int>("pResBin");
146  pResMin = parameters.getParameter<double>("pResMin");
147  pResMax = parameters.getParameter<double>("pResMax");
148 
149  hitsBin = parameters.getParameter<int>("hitsBin");
150  hitsMin = parameters.getParameter<int>("hitsMin");
151  hitsMax = parameters.getParameter<int>("hitsMax");
152 
153  theFolder = parameters.getParameter<string>("folder");
154 }
155 
157 
159  edm::Run const& /*iRun*/,
160  edm::EventSetup const& /* iSetup */) {
161  ibooker.cd();
162  ibooker.setCurrentFolder(theFolder);
163 
165  // monitoring of eta parameter
167  std::string histname = "cosmicMuon";
168 
169  nTracksSta = ibooker.book1D(histname + "_traks", "#tracks", nTrkBin, nTrkMin, nTrkMax);
170 
171  etaStaTrack = ibooker.book1D(histname + "_eta", "#eta_{STA}", etaBin, etaMin, etaMax);
172 
174  // monitoring of theta parameter
176 
177  thetaStaTrack = ibooker.book1D(histname + "_theta", "#theta_{STA}", thetaBin, thetaMin, thetaMax);
178  thetaStaTrack->setAxisTitle("rad");
179 
180  // monitoring of phi paramater
181 
182  phiStaTrack = ibooker.book1D(histname + "_phi", "#phi_{STA}", phiBin, phiMin, phiMax);
183  phiStaTrack->setAxisTitle("rad");
184 
185  // monitoring of the chi2 parameter
186 
187  chi2OvDFStaTrack = ibooker.book1D(histname + "_chi2OverDf", "#chi_{2}OverDF_{STA}", chi2Bin, chi2Min, chi2Max);
188 
189  //--------------------------
190 
191  probchi2StaTrack = ibooker.book1D(histname + "_probchi", "Prob #chi_{STA}", 120, chi2Min, 1.20);
192 
193  // monitoring of the momentum
194 
195  pStaTrack = ibooker.book1D(histname + "_p", "p_{STA}", pBin, pMin, pMax);
196  pStaTrack->setAxisTitle("GeV");
197 
198  qOverPStaTrack = ibooker.book1D(histname + "_qoverp", "qoverp_{STA}", pResBin, pResMin, pResMax);
199  qOverPStaTrack->setAxisTitle("1/GeV");
200 
201  qOverPStaTrack_p =
202  ibooker.book2D(histname + "_qoverp_p", "qoverp_p_{STA}", pBin, pMin, pMax, pResBin, pResMin, pResMax);
203 
204  // monitoring of the transverse momentum
205 
206  ptStaTrack = ibooker.book1D(histname + "_pt", "pt_{STA}", ptBin, ptMin, pMax);
207  ptStaTrack->setAxisTitle("GeV");
208 
209  // monitoring of the muon charge
210 
211  qStaTrack = ibooker.book1D(histname + "_q", "q_{STA}", 5, -2.5, 2.5);
212 
214  // monitoring of the phi-eta
215 
216  phiVsetaStaTrack = ibooker.book2D(
217  histname + "_phiVseta", "#phi vs #eta (STA)", etaBin / 2, etaMin, etaMax, phiBin / 2, phiMin, phiMax);
218  phiVsetaStaTrack->setAxisTitle("eta", 1);
219  phiVsetaStaTrack->setAxisTitle("phi", 2);
220 
221  // monitoring the hits
222  nValidHitsStaTrack = ibooker.book1D(histname + "_nValidHits", "#valid hits (STA)", hitsBin, hitsMin, hitsMax);
223 
224  nValidHitsStaTrack_eta = ibooker.book2D(
225  histname + "_nValidHits_eta", "#valid hits vs eta (STA)", etaBin, etaMin, etaMax, hitsBin, hitsMin, hitsMax);
226 
227  nValidHitsStaTrack_phi = ibooker.book2D(
228  histname + "_nValidHits_phi", "#valid hits vs phi (STA)", phiBin, phiMin, phiMax, hitsBin, hitsMin, hitsMax);
229 }
230 
232  LogTrace(metname) << "[MuonRecoAnalyzer] Analyze the mu";
233  theService->update(iSetup);
234 
235  // Take the muon container
237  iEvent.getByToken(theMuonCollectionLabel_, muons);
238 
239  int nTracks_ = 0;
240 
241  if (!muons.isValid())
242  return;
243 
244  for (edm::View<reco::Track>::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
245  nTracks_++;
246 
247  //Needed for MVA soft muon
248 
249  // get the track using only the mu spectrometer data
250 
251  etaStaTrack->Fill(muon->eta());
252  thetaStaTrack->Fill(muon->theta());
253  phiStaTrack->Fill(muon->phi());
254  chi2OvDFStaTrack->Fill(muon->normalizedChi2());
255  probchi2StaTrack->Fill(TMath::Prob(muon->chi2(), muon->ndof()));
256  pStaTrack->Fill(muon->p());
257  ptStaTrack->Fill(muon->pt());
258  qStaTrack->Fill(muon->charge());
259  qOverPStaTrack->Fill(muon->qoverp());
260  qOverPStaTrack_p->Fill(muon->p(), muon->qoverp());
261  phiVsetaStaTrack->Fill(muon->eta(), muon->phi());
262 
263  nValidHitsStaTrack->Fill(muon->numberOfValidHits());
264  nValidHitsStaTrack_eta->Fill(muon->eta(), muon->numberOfValidHits());
265  nValidHitsStaTrack_phi->Fill(muon->phi(), muon->numberOfValidHits());
266  }
267 
268  nTracksSta->Fill(nTracks_);
269 }
270 
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:517
const std::string metname
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
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
bool isValid() const
Definition: HandleBase.h:74
~CosmicMuonRecoAnalyzer() override
Destructor.
#define LogTrace(id)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * nValidHitsStaTrack_eta
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
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_
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: Run.h:45