CMS 3D CMS Logo

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