CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AlignmentMonitorSegmentDifferences.cc
Go to the documentation of this file.
1 /*
2  * Package: CommonAlignmentProducer
3  * Class : AlignmentMonitorSegmentDifferences
4  *
5  * Original Author: Jim Pivarski
6  * Created: Mon Nov 12 13:30:14 CST 2007
7  *
8  * $Id: AlignmentMonitorSegmentDifferences.cc,v 1.5 2011/04/15 23:09:38 khotilov Exp $
9  */
10 
17 
24 
25 #include <sstream>
26 
33 
35 public:
38 
39  void book() override;
40 
41  void event(const edm::Event &iEvent,
42  const edm::EventSetup &iSetup,
43  const ConstTrajTrackPairCollection &iTrajTracks) override;
45 
46 private:
47  // es token
53 
54  // parameters
56  double m_minTrackPt;
57  double m_minTrackP;
58  double m_maxDxy;
66  bool m_doDT;
67  bool m_doCSC;
68 
69  // wheel, sector, stationdiff
70  TProfile *m_dt13_resid[5][12][3];
71  TProfile *m_dt13_slope[5][12][3];
72  TProfile *m_dt2_resid[5][12][2];
73  TProfile *m_dt2_slope[5][12][2];
74  TH1F *m_posdt13_resid[5][12][3];
75  TH1F *m_posdt13_slope[5][12][3];
76  TH1F *m_posdt2_resid[5][12][2];
77  TH1F *m_posdt2_slope[5][12][2];
78  TH1F *m_negdt13_resid[5][12][3];
79  TH1F *m_negdt13_slope[5][12][3];
80  TH1F *m_negdt2_resid[5][12][2];
81  TH1F *m_negdt2_slope[5][12][2];
82 
83  // endcap, chamber, stationdiff
84  TProfile *m_cscouter_resid[2][36][2];
85  TProfile *m_cscouter_slope[2][36][2];
86  TProfile *m_cscinner_resid[2][18][3];
87  TProfile *m_cscinner_slope[2][18][3];
88  TH1F *m_poscscouter_resid[2][36][2];
89  TH1F *m_poscscouter_slope[2][36][2];
90  TH1F *m_poscscinner_resid[2][18][3];
91  TH1F *m_poscscinner_slope[2][18][3];
92  TH1F *m_negcscouter_resid[2][36][2];
93  TH1F *m_negcscouter_slope[2][36][2];
94  TH1F *m_negcscinner_resid[2][18][3];
95  TH1F *m_negcscinner_slope[2][18][3];
96 
97  // cross-system segdiffs: // [endcap][dtsector]
98  TH1F *m_x_pos_dt1_csc1_resid[2][12]; // tracks going through DT W+-2 St1 and CSC St1 Ring3
99  TH1F *m_x_pos_dt1_csc2_resid[2][12]; // tracks going through DT W+-2 St1 and CSC St2 Ring2
100  TH1F *m_x_pos_dt2_csc1_resid[2][12]; // tracks going through DT W+-2 St2 and CSC St1 Ring3
104 };
105 
106 //
107 // constants, enums and typedefs
108 //
109 
110 //
111 // static data member definitions
112 //
113 
114 //
115 // member functions
116 //
117 
120  : AlignmentMonitorBase(cfg, iC, "AlignmentMonitorSegmentDifferences"),
121  m_esTokenGBTGeom(iC.esConsumes()),
122  m_esTokenDetId(iC.esConsumes(edm::ESInputTag("", "MuonDetIdAssociator"))),
123  m_esTokenProp(iC.esConsumes(edm::ESInputTag("", "SteppingHelixPropagatorAny"))),
124  m_esTokenMF(iC.esConsumes()),
125  m_esTokenBuilder(iC.esConsumes(MuonResidualsFromTrack::builderESInputTag())),
126  m_muonCollectionTag(cfg.getParameter<edm::InputTag>("muonCollectionTag")),
127  m_minTrackPt(cfg.getParameter<double>("minTrackPt")),
128  m_minTrackP(cfg.getParameter<double>("minTrackP")),
129  m_maxDxy(cfg.getParameter<double>("maxDxy")),
130  m_minTrackerHits(cfg.getParameter<int>("minTrackerHits")),
131  m_maxTrackerRedChi2(cfg.getParameter<double>("maxTrackerRedChi2")),
132  m_allowTIDTEC(cfg.getParameter<bool>("allowTIDTEC")),
133  m_minNCrossedChambers(cfg.getParameter<int>("minNCrossedChambers")),
134  m_minDT13Hits(cfg.getParameter<int>("minDT13Hits")),
135  m_minDT2Hits(cfg.getParameter<int>("minDT2Hits")),
136  m_minCSCHits(cfg.getParameter<int>("minCSCHits")),
137  m_doDT(cfg.getParameter<bool>("doDT")),
138  m_doCSC(cfg.getParameter<bool>("doCSC")) {}
139 
141  char name[225], pos[228], neg[228];
142 
143  double max_curv = 1. / m_minTrackPt;
144 
145  if (m_doDT)
146  for (int wheel = -2; wheel <= +2; wheel++) {
147  char wheel_label[][2] = {"A", "B", "C", "D", "E"};
148  for (int sector = 1; sector <= 12; sector++) {
149  char wheel_sector[50];
150  sprintf(wheel_sector, "%s_%02d", wheel_label[wheel + 2], sector);
151 
152  int nb = 100;
153  double wnd = 25.;
154 
155  sprintf(name, "dt13_resid_%s_12", wheel_sector);
156  sprintf(pos, "pos%s", name);
157  sprintf(neg, "neg%s", name);
158  m_dt13_resid[wheel + 2][sector - 1][0] =
159  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -100., 100., " ");
160  m_posdt13_resid[wheel + 2][sector - 1][0] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
161  m_negdt13_resid[wheel + 2][sector - 1][0] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
162 
163  sprintf(name, "dt13_resid_%s_23", wheel_sector);
164  sprintf(pos, "pos%s", name);
165  sprintf(neg, "neg%s", name);
166  m_dt13_resid[wheel + 2][sector - 1][1] =
167  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -100., 100., " ");
168  m_posdt13_resid[wheel + 2][sector - 1][1] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
169  m_negdt13_resid[wheel + 2][sector - 1][1] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
170 
171  sprintf(name, "dt13_resid_%s_34", wheel_sector);
172  sprintf(pos, "pos%s", name);
173  sprintf(neg, "neg%s", name);
174  m_dt13_resid[wheel + 2][sector - 1][2] =
175  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -100., 100., " ");
176  m_posdt13_resid[wheel + 2][sector - 1][2] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
177  m_negdt13_resid[wheel + 2][sector - 1][2] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
178 
179  sprintf(name, "dt2_resid_%s_12", wheel_sector);
180  sprintf(pos, "pos%s", name);
181  sprintf(neg, "neg%s", name);
182  m_dt2_resid[wheel + 2][sector - 1][0] =
183  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -200., 200., " ");
184  m_posdt2_resid[wheel + 2][sector - 1][0] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
185  m_negdt2_resid[wheel + 2][sector - 1][0] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
186 
187  sprintf(name, "dt2_resid_%s_23", wheel_sector);
188  sprintf(pos, "pos%s", name);
189  sprintf(neg, "neg%s", name);
190  m_dt2_resid[wheel + 2][sector - 1][1] =
191  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -200., 200., " ");
192  m_posdt2_resid[wheel + 2][sector - 1][1] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
193  m_negdt2_resid[wheel + 2][sector - 1][1] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
194 
195  sprintf(name, "dt13_slope_%s_12", wheel_sector);
196  sprintf(pos, "pos%s", name);
197  sprintf(neg, "neg%s", name);
198  m_dt13_slope[wheel + 2][sector - 1][0] =
199  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -100., 100., " ");
200  m_posdt13_slope[wheel + 2][sector - 1][0] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
201  m_negdt13_slope[wheel + 2][sector - 1][0] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
202 
203  sprintf(name, "dt13_slope_%s_23", wheel_sector);
204  sprintf(pos, "pos%s", name);
205  sprintf(neg, "neg%s", name);
206  m_dt13_slope[wheel + 2][sector - 1][1] =
207  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -100., 100., " ");
208  m_posdt13_slope[wheel + 2][sector - 1][1] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
209  m_negdt13_slope[wheel + 2][sector - 1][1] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
210 
211  sprintf(name, "dt13_slope_%s_34", wheel_sector);
212  sprintf(pos, "pos%s", name);
213  sprintf(neg, "neg%s", name);
214  m_dt13_slope[wheel + 2][sector - 1][2] =
215  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -100., 100., " ");
216  m_posdt13_slope[wheel + 2][sector - 1][2] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
217  m_negdt13_slope[wheel + 2][sector - 1][2] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
218 
219  sprintf(name, "dt2_slope_%s_12", wheel_sector);
220  sprintf(pos, "pos%s", name);
221  sprintf(neg, "neg%s", name);
222  m_dt2_slope[wheel + 2][sector - 1][0] =
223  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -1000., 1000., " ");
224  m_posdt2_slope[wheel + 2][sector - 1][0] = book1D("/iterN/", pos, pos, nb, -100., 100.);
225  m_negdt2_slope[wheel + 2][sector - 1][0] = book1D("/iterN/", neg, neg, nb, -100., 100.);
226 
227  sprintf(name, "dt2_slope_%s_23", wheel_sector);
228  sprintf(pos, "pos%s", name);
229  sprintf(neg, "neg%s", name);
230  m_dt2_slope[wheel + 2][sector - 1][1] =
231  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -1000., 1000., " ");
232  m_posdt2_slope[wheel + 2][sector - 1][1] = book1D("/iterN/", pos, pos, nb, -100., 100.);
233  m_negdt2_slope[wheel + 2][sector - 1][1] = book1D("/iterN/", neg, neg, nb, -100., 100.);
234  }
235  }
236 
237  if (m_doCSC)
238  for (int endcap = 1; endcap <= 2; endcap++) {
239  std::string endcapletter;
240  if (endcap == 1)
241  endcapletter = "p";
242  else if (endcap == 2)
243  endcapletter = "m";
244 
245  for (int chamber = 1; chamber <= 36; chamber++) {
246  char ec_chamber[50];
247  sprintf(ec_chamber, "%s_%02d", endcapletter.c_str(), chamber);
248 
249  int nb = 100;
250  double wnd = 60.;
251 
252  sprintf(name, "cscouter_resid_%s_12", ec_chamber);
253  sprintf(pos, "pos%s", name);
254  sprintf(neg, "neg%s", name);
255  m_cscouter_resid[endcap - 1][chamber - 1][0] =
256  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -100., 100., " ");
257  m_poscscouter_resid[endcap - 1][chamber - 1][0] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
258  m_negcscouter_resid[endcap - 1][chamber - 1][0] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
259 
260  sprintf(name, "cscouter_resid_%s_23", ec_chamber);
261  sprintf(pos, "pos%s", name);
262  sprintf(neg, "neg%s", name);
263  m_cscouter_resid[endcap - 1][chamber - 1][1] =
264  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -100., 100., " ");
265  m_poscscouter_resid[endcap - 1][chamber - 1][1] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
266  m_negcscouter_resid[endcap - 1][chamber - 1][1] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
267 
268  sprintf(name, "cscouter_slope_%s_12", ec_chamber);
269  sprintf(pos, "pos%s", name);
270  sprintf(neg, "neg%s", name);
271  m_cscouter_slope[endcap - 1][chamber - 1][0] =
272  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -100., 100., " ");
273  m_poscscouter_slope[endcap - 1][chamber - 1][0] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
274  m_negcscouter_slope[endcap - 1][chamber - 1][0] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
275 
276  sprintf(name, "cscouter_slope_%s_23", ec_chamber);
277  sprintf(pos, "pos%s", name);
278  sprintf(neg, "neg%s", name);
279  m_cscouter_slope[endcap - 1][chamber - 1][1] =
280  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -100., 100., " ");
281  m_poscscouter_slope[endcap - 1][chamber - 1][1] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
282  m_negcscouter_slope[endcap - 1][chamber - 1][1] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
283  }
284 
285  for (int chamber = 1; chamber <= 18; chamber++) {
286  char ec_chamber[50];
287  sprintf(ec_chamber, "%s_%02d", endcapletter.c_str(), chamber);
288 
289  int nb = 100;
290  double wnd = 40.;
291 
292  sprintf(name, "cscinner_resid_%s_12", ec_chamber);
293  sprintf(pos, "pos%s", name);
294  sprintf(neg, "neg%s", name);
295  m_cscinner_resid[endcap - 1][chamber - 1][0] =
296  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -100., 100., " ");
297  m_poscscinner_resid[endcap - 1][chamber - 1][0] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
298  m_negcscinner_resid[endcap - 1][chamber - 1][0] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
299 
300  sprintf(name, "cscinner_resid_%s_23", ec_chamber);
301  sprintf(pos, "pos%s", name);
302  sprintf(neg, "neg%s", name);
303  m_cscinner_resid[endcap - 1][chamber - 1][1] =
304  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -100., 100., " ");
305  m_poscscinner_resid[endcap - 1][chamber - 1][1] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
306  m_negcscinner_resid[endcap - 1][chamber - 1][1] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
307 
308  sprintf(name, "cscinner_resid_%s_34", ec_chamber);
309  sprintf(pos, "pos%s", name);
310  sprintf(neg, "neg%s", name);
311  m_cscinner_resid[endcap - 1][chamber - 1][2] =
312  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -100., 100., " ");
313  m_poscscinner_resid[endcap - 1][chamber - 1][2] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
314  m_negcscinner_resid[endcap - 1][chamber - 1][2] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
315 
316  sprintf(name, "cscinner_slope_%s_12", ec_chamber);
317  sprintf(pos, "pos%s", name);
318  sprintf(neg, "neg%s", name);
319  m_cscinner_slope[endcap - 1][chamber - 1][0] =
320  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -100., 100., " ");
321  m_poscscinner_slope[endcap - 1][chamber - 1][0] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
322  m_negcscinner_slope[endcap - 1][chamber - 1][0] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
323 
324  sprintf(name, "cscinner_slope_%s_23", ec_chamber);
325  sprintf(pos, "pos%s", name);
326  sprintf(neg, "neg%s", name);
327  m_cscinner_slope[endcap - 1][chamber - 1][1] =
328  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -100., 100., " ");
329  m_poscscinner_slope[endcap - 1][chamber - 1][1] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
330  m_negcscinner_slope[endcap - 1][chamber - 1][1] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
331 
332  sprintf(name, "cscinner_slope_%s_34", ec_chamber);
333  sprintf(pos, "pos%s", name);
334  sprintf(neg, "neg%s", name);
335  m_cscinner_slope[endcap - 1][chamber - 1][2] =
336  bookProfile("/iterN/", name, name, 20, -max_curv, max_curv, 1, -100., 100., " ");
337  m_poscscinner_slope[endcap - 1][chamber - 1][2] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
338  m_negcscinner_slope[endcap - 1][chamber - 1][2] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
339  }
340  }
341 
342  // cross-system
343  for (int e = 1; e <= 2; e++)
344  for (int s = 1; s <= 12; s++) {
345  char endcap_sector[50];
346  if (e == 1)
347  sprintf(endcap_sector, "Wp2S%02d", s);
348  if (e == 2)
349  sprintf(endcap_sector, "Wm2S%02d", s);
350 
351  int nb = 200;
352  double wnd = 100.;
353 
354  sprintf(pos, "pos_x_dt1_csc1_%s", endcap_sector);
355  sprintf(neg, "neg_x_dt1_csc1_%s", endcap_sector);
356  m_x_pos_dt1_csc1_resid[e - 1][s - 1] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
357  m_x_neg_dt1_csc1_resid[e - 1][s - 1] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
358 
359  sprintf(pos, "pos_x_dt1_csc2_%s", endcap_sector);
360  sprintf(neg, "neg_x_dt1_csc2_%s", endcap_sector);
361  m_x_pos_dt1_csc2_resid[e - 1][s - 1] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
362  m_x_neg_dt1_csc2_resid[e - 1][s - 1] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
363 
364  sprintf(pos, "pos_x_dt2_csc1_%s", endcap_sector);
365  sprintf(neg, "neg_x_dt2_csc1_%s", endcap_sector);
366  m_x_pos_dt2_csc1_resid[e - 1][s - 1] = book1D("/iterN/", pos, pos, nb, -wnd, wnd);
367  m_x_neg_dt2_csc1_resid[e - 1][s - 1] = book1D("/iterN/", neg, neg, nb, -wnd, wnd);
368  }
369 }
370 
372  const edm::EventSetup &iSetup,
373  const ConstTrajTrackPairCollection &trajtracks) {
375  iEvent.getByLabel(m_beamSpotTag, beamSpot);
376 
377  const GlobalTrackingGeometry *globalGeometry = &iSetup.getData(m_esTokenGBTGeom);
378  const DetIdAssociator *muonDetIdAssociator_ = &iSetup.getData(m_esTokenDetId);
379  const Propagator *prop = &iSetup.getData(m_esTokenProp);
381  auto builder = iSetup.getHandle(m_esTokenBuilder);
382 
383  if (m_muonCollectionTag.label().empty()) // use trajectories
384  {
385  for (ConstTrajTrackPairCollection::const_iterator trajtrack = trajtracks.begin(); trajtrack != trajtracks.end();
386  ++trajtrack) {
387  const Trajectory *traj = (*trajtrack).first;
388  const reco::Track *track = (*trajtrack).second;
389 
390  if (track->pt() > m_minTrackPt && track->p() > m_minTrackP && fabs(track->dxy(beamSpot->position())) < m_maxDxy) {
391  MuonResidualsFromTrack muonResidualsFromTrack(
392  builder, magneticField, globalGeometry, muonDetIdAssociator_, prop, traj, track, pNavigator(), 1000.);
393  processMuonResidualsFromTrack(muonResidualsFromTrack);
394  }
395  } // end loop over tracks
396  } else {
398  iEvent.getByLabel(m_muonCollectionTag, muons);
399 
400  for (reco::MuonCollection::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
401  if (!(muon->isTrackerMuon() && muon->innerTrack().isNonnull()))
402  continue;
403 
404  if (m_minTrackPt < muon->pt() && m_minTrackP < muon->p() &&
405  fabs(muon->innerTrack()->dxy(beamSpot->position())) < m_maxDxy) {
406  MuonResidualsFromTrack muonResidualsFromTrack(globalGeometry, &(*muon), pNavigator(), 100.);
407  processMuonResidualsFromTrack(muonResidualsFromTrack);
408  }
409  }
410  }
411 }
412 
414  if (mrft.trackerNumHits() < m_minTrackerHits)
415  return;
416  if (!m_allowTIDTEC && mrft.contains_TIDTEC())
417  return;
418  if (mrft.normalizedChi2() > m_maxTrackerRedChi2)
419  return;
420 
421  int nMuChambers = 0;
422  std::vector<DetId> chamberIds = mrft.chamberIds();
423  for (unsigned ch = 0; ch < chamberIds.size(); ch++)
424  if (chamberIds[ch].det() == DetId::Muon)
425  nMuChambers++;
426  if (nMuChambers < m_minNCrossedChambers)
427  return;
428 
429  double qoverpt = (mrft.getTrack()->charge() > 0 ? 1. : -1.) / mrft.getTrack()->pt();
430  double qoverpz = 0.;
431  if (fabs(mrft.getTrack()->pz()) > 0.01)
432  qoverpz = mrft.getTrack()->charge() / fabs(mrft.getTrack()->pz());
433 
434  for (std::vector<DetId>::const_iterator chamberId = chamberIds.begin(); chamberId != chamberIds.end(); ++chamberId) {
435  if (chamberId->det() != DetId::Muon)
436  continue;
437 
438  // **************** DT ****************
439  if (m_doDT && chamberId->subdetId() == MuonSubdetId::DT) {
442 
443  if (dt13 != nullptr && dt13->numHits() >= m_minDT13Hits) {
444  DTChamberId thisid(chamberId->rawId());
445  for (std::vector<DetId>::const_iterator otherId = chamberIds.begin(); otherId != chamberIds.end(); ++otherId) {
446  if (otherId->det() == DetId::Muon && otherId->subdetId() == MuonSubdetId::DT) {
447  DTChamberId thatid(otherId->rawId());
448  if (thisid.rawId() != thatid.rawId() && thisid.wheel() == thatid.wheel() &&
449  thisid.sector() == thatid.sector()) {
451  if (dt13other != nullptr && dt13other->numHits() >= m_minDT13Hits) {
452  double slopediff = 1000. * (dt13->global_resslope() - dt13other->global_resslope());
453  //double length = dt13->chamberAlignable()->surface().toGlobal(align::LocalPoint(0,0,0)).perp() -
454  // dt13other->chamberAlignable()->surface().toGlobal(align::LocalPoint(0,0,0)).perp();
455  //double residdiff = 10. * (dt13->global_residual() + length*dt13->global_resslope() - dt13other->global_residual());
456  double residdiff = 10. * (dt13->global_residual() - dt13other->global_residual());
457 
458  int st = 0;
459  if (thatid.station() - thisid.station() == 1)
460  st = thisid.station();
461  if (st > 0) {
462  m_dt13_resid[thisid.wheel() + 2][thisid.sector() - 1][st - 1]->Fill(qoverpt, residdiff);
463  m_dt13_slope[thisid.wheel() + 2][thisid.sector() - 1][st - 1]->Fill(qoverpt, slopediff);
464  if (qoverpt > 0) {
465  m_posdt13_resid[thisid.wheel() + 2][thisid.sector() - 1][st - 1]->Fill(residdiff);
466  m_posdt13_slope[thisid.wheel() + 2][thisid.sector() - 1][st - 1]->Fill(slopediff);
467  } else {
468  m_negdt13_resid[thisid.wheel() + 2][thisid.sector() - 1][st - 1]->Fill(residdiff);
469  m_negdt13_slope[thisid.wheel() + 2][thisid.sector() - 1][st - 1]->Fill(slopediff);
470  }
471  }
472  } // end other numhits
473  } // end this near other
474  } // end other is DT
475 
476  // cross-system: other is CSC
477  // only do it for DT stubs in W+-2 St1&2:
478  if (!(abs(thisid.wheel()) == 2 && (thisid.station() == 1 || thisid.station() == 2)))
479  continue;
480  if (otherId->det() == DetId::Muon && otherId->subdetId() == MuonSubdetId::CSC) {
481  CSCDetId thatid(otherId->rawId());
482  //only do it for CSC stubs in St1R3 or St2R2:
483  if (!((thatid.station() == 1 && thatid.ring() == 3) || (thatid.station() == 2 && thatid.ring() == 2)))
484  continue;
485 
487  if (cscother != nullptr && cscother->numHits() >= m_minCSCHits) {
488  // scale to adjust the csc residual size to be comparabe to dt's one
489  double csc_scale = dt13->chamberAlignable()
490  ->surface()
491  .toGlobal(align::LocalPoint(dt13->trackx(), dt13->tracky(), 0))
492  .perp() /
493  cscother->chamberAlignable()
494  ->surface()
495  .toGlobal(align::LocalPoint(cscother->trackx(), cscother->tracky(), 0))
496  .perp();
497  double residdiff = 10. * (dt13->global_residual() - cscother->global_residual() * csc_scale);
498  if (thisid.station() == 1 && thatid.station() == 1) {
499  if (qoverpt > 0)
500  m_x_pos_dt1_csc1_resid[thatid.endcap() - 1][thisid.sector() - 1]->Fill(residdiff);
501  else
502  m_x_neg_dt1_csc1_resid[thatid.endcap() - 1][thisid.sector() - 1]->Fill(residdiff);
503  } else if (thisid.station() == 1 && thatid.station() == 2) {
504  if (qoverpt > 0)
505  m_x_pos_dt1_csc2_resid[thatid.endcap() - 1][thisid.sector() - 1]->Fill(residdiff);
506  else
507  m_x_neg_dt1_csc2_resid[thatid.endcap() - 1][thisid.sector() - 1]->Fill(residdiff);
508  } else if (thisid.station() == 2 && thatid.station() == 1) {
509  if (qoverpt > 0)
510  m_x_pos_dt2_csc1_resid[thatid.endcap() - 1][thisid.sector() - 1]->Fill(residdiff);
511  else
512  m_x_neg_dt2_csc1_resid[thatid.endcap() - 1][thisid.sector() - 1]->Fill(residdiff);
513  }
514  }
515  } // end other is CSC
516  } // end loop over other
517  } // end if DT13
518 
519  // z-direction
520  if (dt2 != nullptr && dt2->numHits() >= m_minDT2Hits && (dt2->chi2() / double(dt2->ndof())) < 2.0) {
521  DTChamberId thisid(chamberId->rawId());
522  for (std::vector<DetId>::const_iterator otherId = chamberIds.begin(); otherId != chamberIds.end(); ++otherId) {
523  if (otherId->det() == DetId::Muon && otherId->subdetId() == MuonSubdetId::DT) {
524  DTChamberId thatid(otherId->rawId());
525  if (thisid.rawId() != thatid.rawId() && thisid.wheel() == thatid.wheel() &&
526  thisid.sector() == thatid.sector()) {
528  if (dt2other != nullptr && dt2other->numHits() >= m_minDT2Hits) {
529  double slopediff = 1000. * (dt2->global_resslope() - dt2other->global_resslope());
530  //double length = dt2->chamberAlignable()->surface().toGlobal(align::LocalPoint(0,0,0)).perp() -
531  // dt2other->chamberAlignable()->surface().toGlobal(align::LocalPoint(0,0,0)).perp();
532  //double residdiff = 10. * (dt2->global_residual() + length*dt2->global_resslope() - dt2other->global_residual());
533  double residdiff = 10. * (dt2->global_residual() - dt2other->global_residual());
534 
535  int st = 0;
536  if (thatid.station() - thisid.station() == 1)
537  st = thisid.station();
538  if (st > 0) {
539  m_dt2_resid[thisid.wheel() + 2][thisid.sector() - 1][st - 1]->Fill(qoverpt, residdiff);
540  m_dt2_slope[thisid.wheel() + 2][thisid.sector() - 1][st - 1]->Fill(qoverpt, slopediff);
541  if (qoverpt > 0) {
542  m_posdt2_resid[thisid.wheel() + 2][thisid.sector() - 1][st - 1]->Fill(residdiff);
543  m_posdt2_slope[thisid.wheel() + 2][thisid.sector() - 1][st - 1]->Fill(slopediff);
544  } else {
545  m_negdt2_resid[thisid.wheel() + 2][thisid.sector() - 1][st - 1]->Fill(residdiff);
546  m_negdt2_slope[thisid.wheel() + 2][thisid.sector() - 1][st - 1]->Fill(slopediff);
547  }
548  }
549  } // end other numhits
550  } // end this near other
551  } // end other is DT
552  } // end loop over other
553  } // end if DT2
554  } // end if DT
555 
556  // **************** CSC ****************
557  else if (m_doCSC && chamberId->subdetId() == MuonSubdetId::CSC) {
559  if (csc->numHits() >= m_minCSCHits) {
560  CSCDetId thisid(chamberId->rawId());
561  for (std::vector<DetId>::const_iterator otherId = chamberIds.begin(); otherId != chamberIds.end(); ++otherId) {
562  if (otherId->det() == DetId::Muon && otherId->subdetId() == MuonSubdetId::CSC) {
563  CSCDetId thatid(otherId->rawId());
564  if (thisid.rawId() != thatid.rawId() && thisid.endcap() == thatid.endcap()) {
566  if (cscother != nullptr && cscother->numHits() >= m_minCSCHits) {
567  double slopediff = 1000. * (csc->global_resslope() - cscother->global_resslope());
568  //double length = csc->chamberAlignable()->surface().toGlobal(align::LocalPoint(0,0,0)).z() -
569  // cscother->chamberAlignable()->surface().toGlobal(align::LocalPoint(0,0,0)).z();
570  //double residdiff = 10. * (csc->global_residual() + length*csc->global_resslope() - cscother->global_residual());
571  double residdiff = 10. * (csc->global_residual() - cscother->global_residual());
572 
573  int thischamber = thisid.chamber();
574  int thisring = thisid.ring();
575  if (thisid.station() == 1 && (thisring == 1 || thisring == 4)) {
576  thischamber = (thischamber - 1) / 2 + 1;
577  thisring = 1;
578  }
579 
580  if (thisring == thatid.ring() && thischamber == thatid.chamber()) {
581  bool inner = (thisring == 1);
582  bool outer = (thisring == 2);
583  int st = 0;
584  if (thatid.station() - thisid.station() == 1 && (inner || thisid.station() < 3))
585  st = thisid.station();
586 
587  if (outer && st > 0) {
588  m_cscouter_resid[thisid.endcap() - 1][thischamber - 1][st - 1]->Fill(qoverpz, residdiff);
589  m_cscouter_slope[thisid.endcap() - 1][thischamber - 1][st - 1]->Fill(qoverpz, slopediff);
590  if (qoverpz > 0) {
591  m_poscscouter_resid[thisid.endcap() - 1][thischamber - 1][st - 1]->Fill(residdiff);
592  m_poscscouter_slope[thisid.endcap() - 1][thischamber - 1][st - 1]->Fill(slopediff);
593  } else {
594  m_negcscouter_resid[thisid.endcap() - 1][thischamber - 1][st - 1]->Fill(residdiff);
595  m_negcscouter_slope[thisid.endcap() - 1][thischamber - 1][st - 1]->Fill(slopediff);
596  }
597  }
598  if (inner && st > 0) {
599  m_cscinner_resid[thisid.endcap() - 1][thischamber - 1][st - 1]->Fill(qoverpz, residdiff);
600  m_cscinner_slope[thisid.endcap() - 1][thischamber - 1][st - 1]->Fill(qoverpz, slopediff);
601  if (qoverpz > 0) {
602  m_poscscinner_resid[thisid.endcap() - 1][thischamber - 1][st - 1]->Fill(residdiff);
603  m_poscscinner_slope[thisid.endcap() - 1][thischamber - 1][st - 1]->Fill(slopediff);
604  } else {
605  m_negcscinner_resid[thisid.endcap() - 1][thischamber - 1][st - 1]->Fill(residdiff);
606  m_negcscinner_slope[thisid.endcap() - 1][thischamber - 1][st - 1]->Fill(slopediff);
607  }
608  }
609  } // end of same ring&chamber
610  } // end other min numhits
611  } // end this near other
612  } // end other is CSC
613  } // end loop over other
614 
615  } // end if this min numhits
616  } // end if CSC
617 
618  } // end loop over chamberIds
619 }
620 
623  "AlignmentMonitorSegmentDifferences");
double p() const
momentum vector magnitude
Definition: TrackBase.h:631
AlignableNavigator * pNavigator()
tuple cfg
Definition: looper.py:296
void event(const edm::Event &iEvent, const edm::EventSetup &iSetup, const ConstTrajTrackPairCollection &iTrajTracks) override
Called for each event (by &quot;run()&quot;): may be reimplemented.
const edm::ESGetToken< Propagator, TrackingComponentsRecord > m_esTokenProp
tuple magneticField
TProfile * bookProfile(std::string dir, std::string name, std::string title, int nchX, double lowX, double highX, int nchY=1, double lowY=0., double highY=0., const char *option="s")
double global_residual() const
double trackx() const
AlignmentMonitorSegmentDifferences(const edm::ParameterSet &cfg, edm::ConsumesCollector iC)
const std::vector< DetId > chamberIds() const
void book() override
Book or retrieve histograms; MUST be reimplemented.
bool getData(T &iHolder) const
Definition: EventSetup.h:128
int iEvent
Definition: GenABIO.cc:224
const MuonResidualsFromTrack::BuilderToken m_esTokenBuilder
double pt() const
track transverse momentum
Definition: TrackBase.h:637
const reco::Track * getTrack()
AlignableDetOrUnitPtr chamberAlignable() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection
const edm::InputTag m_beamSpotTag
double tracky() const
TH1F * book1D(std::string dir, std::string name, std::string title, int nchX, double lowX, double highX)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:500
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:132
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:646
void processMuonResidualsFromTrack(MuonResidualsFromTrack &mrft)
const edm::ESGetToken< DetIdAssociator, DetIdAssociatorRecord > m_esTokenDetId
std::string const & label() const
Definition: InputTag.h:36
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > m_esTokenGBTGeom
tuple muons
Definition: patZpeak.py:39
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
double global_resslope() const
int charge() const
track electric charge
Definition: TrackBase.h:596
#define DEFINE_EDM_PLUGIN(factory, type, name)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
static constexpr int DT
Definition: MuonSubdetId.h:11
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > m_esTokenMF
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:608
static constexpr int CSC
Definition: MuonSubdetId.h:12
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
MuonChamberResidual * chamberResidual(DetId chamberId, int type)