CMS 3D CMS Logo

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