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