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