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 // -*- C++ -*-
2 //
3 // Package: CommonAlignmentProducer
4 // Class : AlignmentMonitorSegmentDifferences
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Jim Pivarski
10 // Created: Mon Nov 12 13:30:14 CST 2007
11 //
12 
13 // system include files
21 
26 
27 #include <sstream>
28 
29 // user include files
30 
31 //
32 // class definition
33 //
34 
36 public:
39 
40  void book();
41  void event(const edm::Event &iEvent, const edm::EventSetup &iSetup, const ConstTrajTrackPairCollection& iTrajTracks);
42  void afterAlignment(const edm::EventSetup &iSetup);
43 
44 private:
45  double m_minTrackPt;
52 
53  // wheel, sector, stationdiff
54  TProfile *m_dt13_resid[5][12][3];
55  TProfile *m_dt13_slope[5][12][3];
56  TProfile *m_dt2_resid[5][12][2];
57  TProfile *m_dt2_slope[5][12][2];
58  TH1F *m_posdt13_resid[5][12][3];
59  TH1F *m_posdt13_slope[5][12][3];
60  TH1F *m_posdt2_resid[5][12][2];
61  TH1F *m_posdt2_slope[5][12][2];
62  TH1F *m_negdt13_resid[5][12][3];
63  TH1F *m_negdt13_slope[5][12][3];
64  TH1F *m_negdt2_resid[5][12][2];
65  TH1F *m_negdt2_slope[5][12][2];
66 
67  // endcap, chamber, stationdiff
68  TProfile *m_cscouter_resid[2][36][2];
69  TProfile *m_cscouter_slope[2][36][2];
70  TProfile *m_cscinner_resid[2][18][3];
71  TProfile *m_cscinner_slope[2][18][3];
72  TH1F *m_poscscouter_resid[2][36][2];
73  TH1F *m_poscscouter_slope[2][36][2];
74  TH1F *m_poscscinner_resid[2][18][3];
75  TH1F *m_poscscinner_slope[2][18][3];
76  TH1F *m_negcscouter_resid[2][36][2];
77  TH1F *m_negcscouter_slope[2][36][2];
78  TH1F *m_negcscinner_resid[2][18][3];
79  TH1F *m_negcscinner_slope[2][18][3];
80 };
81 
82 //
83 // constants, enums and typedefs
84 //
85 
86 //
87 // static data member definitions
88 //
89 
90 //
91 // member functions
92 //
93 
95  : AlignmentMonitorBase(cfg, "AlignmentMonitorSegmentDifferences")
96  , m_minTrackPt(cfg.getParameter<double>("minTrackPt"))
97  , m_minTrackerHits(cfg.getParameter<int>("minTrackerHits"))
98  , m_maxTrackerRedChi2(cfg.getParameter<double>("maxTrackerRedChi2"))
99  , m_allowTIDTEC(cfg.getParameter<bool>("allowTIDTEC"))
100  , m_minDT13Hits(cfg.getParameter<int>("minDT13Hits"))
101  , m_minDT2Hits(cfg.getParameter<int>("minDT2Hits"))
102  , m_minCSCHits(cfg.getParameter<int>("minCSCHits"))
103 {
104 }
105 
107  for (int wheel = -2; wheel <= +2; wheel++) {
108  for (int sector = 1; sector <= 12; sector++) {
109  char num[3];
110  num[0] = ('0' + (sector / 10));
111  num[1] = ('0' + (sector % 10));
112  num[2] = 0;
113 
114  std::string wheelletter;
115  if (wheel == -2) wheelletter = "A";
116  else if (wheel == -1) wheelletter = "B";
117  else if (wheel == 0) wheelletter = "C";
118  else if (wheel == +1) wheelletter = "D";
119  else if (wheel == +2) wheelletter = "E";
120 
121  std::string name, pos, neg;
122 
123  name = (std::string("dt13_resid_") + wheelletter + std::string("_") + std::string(num) + std::string("_12"));
124  m_dt13_resid[wheel+2][sector-1][0] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -100., 100., " ");
125  pos = std::string("pos") + name;
126  m_posdt13_resid[wheel+2][sector-1][0] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -10., 10.);
127  neg = std::string("neg") + name;
128  m_negdt13_resid[wheel+2][sector-1][0] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -10., 10.);
129 
130  name = (std::string("dt13_resid_") + wheelletter + std::string("_") + std::string(num) + std::string("_23"));
131  m_dt13_resid[wheel+2][sector-1][1] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -100., 100., " ");
132  pos = std::string("pos") + name;
133  m_posdt13_resid[wheel+2][sector-1][1] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -10., 10.);
134  neg = std::string("neg") + name;
135  m_negdt13_resid[wheel+2][sector-1][1] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -10., 10.);
136 
137  name = (std::string("dt13_resid_") + wheelletter + std::string("_") + std::string(num) + std::string("_34"));
138  m_dt13_resid[wheel+2][sector-1][2] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -100., 100., " ");
139  pos = std::string("pos") + name;
140  m_posdt13_resid[wheel+2][sector-1][2] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -10., 10.);
141  neg = std::string("neg") + name;
142  m_negdt13_resid[wheel+2][sector-1][2] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -10., 10.);
143 
144  name = (std::string("dt2_resid_") + wheelletter + std::string("_") + std::string(num) + std::string("_12"));
145  m_dt2_resid[wheel+2][sector-1][0] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -200., 200., " ");
146  pos = std::string("pos") + name;
147  m_posdt2_resid[wheel+2][sector-1][0] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -20., 20.);
148  neg = std::string("neg") + name;
149  m_negdt2_resid[wheel+2][sector-1][0] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -20., 20.);
150 
151  name = (std::string("dt2_resid_") + wheelletter + std::string("_") + std::string(num) + std::string("_23"));
152  m_dt2_resid[wheel+2][sector-1][1] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -200., 200., " ");
153  pos = std::string("pos") + name;
154  m_posdt2_resid[wheel+2][sector-1][1] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -20., 20.);
155  neg = std::string("neg") + name;
156  m_negdt2_resid[wheel+2][sector-1][1] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -20., 20.);
157 
158  name = (std::string("dt13_slope_") + wheelletter + std::string("_") + std::string(num) + std::string("_12"));
159  m_dt13_slope[wheel+2][sector-1][0] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -100., 100., " ");
160  pos = std::string("pos") + name;
161  m_posdt13_slope[wheel+2][sector-1][0] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -10., 10.);
162  neg = std::string("neg") + name;
163  m_negdt13_slope[wheel+2][sector-1][0] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -10., 10.);
164 
165  name = (std::string("dt13_slope_") + wheelletter + std::string("_") + std::string(num) + std::string("_23"));
166  m_dt13_slope[wheel+2][sector-1][1] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -100., 100., " ");
167  pos = std::string("pos") + name;
168  m_posdt13_slope[wheel+2][sector-1][1] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -10., 10.);
169  neg = std::string("neg") + name;
170  m_negdt13_slope[wheel+2][sector-1][1] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -10., 10.);
171 
172  name = (std::string("dt13_slope_") + wheelletter + std::string("_") + std::string(num) + std::string("_34"));
173  m_dt13_slope[wheel+2][sector-1][2] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -100., 100., " ");
174  pos = std::string("pos") + name;
175  m_posdt13_slope[wheel+2][sector-1][2] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -10., 10.);
176  neg = std::string("neg") + name;
177  m_negdt13_slope[wheel+2][sector-1][2] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -10., 10.);
178 
179  name = (std::string("dt2_slope_") + wheelletter + std::string("_") + std::string(num) + std::string("_12"));
180  m_dt2_slope[wheel+2][sector-1][0] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -1000., 1000., " ");
181  pos = std::string("pos") + name;
182  m_posdt2_slope[wheel+2][sector-1][0] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -100., 100.);
183  neg = std::string("neg") + name;
184  m_negdt2_slope[wheel+2][sector-1][0] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -100., 100.);
185 
186  name = (std::string("dt2_slope_") + wheelletter + std::string("_") + std::string(num) + std::string("_23"));
187  m_dt2_slope[wheel+2][sector-1][1] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -1000., 1000., " ");
188  pos = std::string("pos") + name;
189  m_posdt2_slope[wheel+2][sector-1][1] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -100., 100.);
190  neg = std::string("neg") + name;
191  m_negdt2_slope[wheel+2][sector-1][1] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -100., 100.);
192  }
193  }
194 
195  for (int endcap = 1; endcap <= 2; endcap++) {
196  for (int chamber = 1; chamber <= 36; chamber++) {
197  char num[3];
198  num[0] = ('0' + (chamber / 10));
199  num[1] = ('0' + (chamber % 10));
200  num[2] = 0;
201 
202  std::string endcapletter;
203  if (endcap == 1) endcapletter = "p";
204  else if (endcap == 2) endcapletter = "m";
205 
206  std::string name, pos, neg;
207 
208  name = (std::string("cscouter_resid_") + endcapletter + std::string("_") + std::string(num) + std::string("_12"));
209  m_cscouter_resid[endcap-1][chamber-1][0] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -100., 100., " ");
210  pos = std::string("pos") + name;
211  m_poscscouter_resid[endcap-1][chamber-1][0] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -10., 10.);
212  neg = std::string("neg") + name;
213  m_negcscouter_resid[endcap-1][chamber-1][0] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -10., 10.);
214 
215  name = (std::string("cscouter_resid_") + endcapletter + std::string("_") + std::string(num) + std::string("_23"));
216  m_cscouter_resid[endcap-1][chamber-1][1] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -100., 100., " ");
217  pos = std::string("pos") + name;
218  m_poscscouter_resid[endcap-1][chamber-1][1] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -10., 10.);
219  neg = std::string("neg") + name;
220  m_negcscouter_resid[endcap-1][chamber-1][1] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -10., 10.);
221 
222  name = (std::string("cscouter_slope_") + endcapletter + std::string("_") + std::string(num) + std::string("_12"));
223  m_cscouter_slope[endcap-1][chamber-1][0] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -100., 100., " ");
224  pos = std::string("pos") + name;
225  m_poscscouter_slope[endcap-1][chamber-1][0] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -10., 10.);
226  neg = std::string("neg") + name;
227  m_negcscouter_slope[endcap-1][chamber-1][0] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -10., 10.);
228 
229  name = (std::string("cscouter_slope_") + endcapletter + std::string("_") + std::string(num) + std::string("_23"));
230  m_cscouter_slope[endcap-1][chamber-1][1] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -100., 100., " ");
231  pos = std::string("pos") + name;
232  m_poscscouter_slope[endcap-1][chamber-1][1] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -10., 10.);
233  neg = std::string("neg") + name;
234  m_negcscouter_slope[endcap-1][chamber-1][1] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -10., 10.);
235  }
236 
237  for (int chamber = 1; chamber <= 18; chamber++) {
238  char num[3];
239  num[0] = ('0' + (chamber / 10));
240  num[1] = ('0' + (chamber % 10));
241  num[2] = 0;
242 
243  std::string endcapletter;
244  if (endcap == 1) endcapletter = "p";
245  else if (endcap == 2) endcapletter = "m";
246 
247  std::string name, pos, neg;
248 
249  name = (std::string("cscinner_resid_") + endcapletter + std::string("_") + std::string(num) + std::string("_12"));
250  m_cscinner_resid[endcap-1][chamber-1][0] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -100., 100., " ");
251  pos = std::string("pos") + name;
252  m_poscscinner_resid[endcap-1][chamber-1][0] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -10., 10.);
253  neg = std::string("neg") + name;
254  m_negcscinner_resid[endcap-1][chamber-1][0] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -10., 10.);
255 
256  name = (std::string("cscinner_resid_") + endcapletter + std::string("_") + std::string(num) + std::string("_23"));
257  m_cscinner_resid[endcap-1][chamber-1][1] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -100., 100., " ");
258  pos = std::string("pos") + name;
259  m_poscscinner_resid[endcap-1][chamber-1][1] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -10., 10.);
260  neg = std::string("neg") + name;
261  m_negcscinner_resid[endcap-1][chamber-1][1] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -10., 10.);
262 
263  name = (std::string("cscinner_resid_") + endcapletter + std::string("_") + std::string(num) + std::string("_34"));
264  m_cscinner_resid[endcap-1][chamber-1][2] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -100., 100., " ");
265  pos = std::string("pos") + name;
266  m_poscscinner_resid[endcap-1][chamber-1][2] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -10., 10.);
267  neg = std::string("neg") + name;
268  m_negcscinner_resid[endcap-1][chamber-1][2] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -10., 10.);
269 
270  name = (std::string("cscinner_slope_") + endcapletter + std::string("_") + std::string(num) + std::string("_12"));
271  m_cscinner_slope[endcap-1][chamber-1][0] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -100., 100., " ");
272  pos = std::string("pos") + name;
273  m_poscscinner_slope[endcap-1][chamber-1][0] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -10., 10.);
274  neg = std::string("neg") + name;
275  m_negcscinner_slope[endcap-1][chamber-1][0] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -10., 10.);
276 
277  name = (std::string("cscinner_slope_") + endcapletter + std::string("_") + std::string(num) + std::string("_23"));
278  m_cscinner_slope[endcap-1][chamber-1][1] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -100., 100., " ");
279  pos = std::string("pos") + name;
280  m_poscscinner_slope[endcap-1][chamber-1][1] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -10., 10.);
281  neg = std::string("neg") + name;
282  m_negcscinner_slope[endcap-1][chamber-1][1] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -10., 10.);
283 
284  name = (std::string("cscinner_slope_") + endcapletter + std::string("_") + std::string(num) + std::string("_34"));
285  m_cscinner_slope[endcap-1][chamber-1][2] = bookProfile("/iterN/", name.c_str(), name.c_str(), 20, -1./m_minTrackPt, 1./m_minTrackPt, 1, -100., 100., " ");
286  pos = std::string("pos") + name;
287  m_poscscinner_slope[endcap-1][chamber-1][2] = book1D("/iterN/", pos.c_str(), pos.c_str(), 100, -10., 10.);
288  neg = std::string("neg") + name;
289  m_negcscinner_slope[endcap-1][chamber-1][2] = book1D("/iterN/", neg.c_str(), neg.c_str(), 100, -10., 10.);
290  }
291  }
292 }
293 
296  iSetup.get<GlobalTrackingGeometryRecord>().get(globalGeometry);
297 
298  for (ConstTrajTrackPairCollection::const_iterator trajtrack = trajtracks.begin(); trajtrack != trajtracks.end(); ++trajtrack) {
299  const Trajectory* traj = (*trajtrack).first;
300  const reco::Track* track = (*trajtrack).second;
301 
302  if (track->pt() > m_minTrackPt) {
303  double qoverpt = (track->charge() > 0 ? 1. : -1.) / track->pt();
304  MuonResidualsFromTrack muonResidualsFromTrack(globalGeometry, traj, pNavigator(), 1000.);
305 
306  if (muonResidualsFromTrack.trackerNumHits() >= m_minTrackerHits && muonResidualsFromTrack.trackerRedChi2() < m_maxTrackerRedChi2 && (m_allowTIDTEC || !muonResidualsFromTrack.contains_TIDTEC())) {
307  std::vector<DetId> chamberIds = muonResidualsFromTrack.chamberIds();
308 
309  for (std::vector<DetId>::const_iterator chamberId = chamberIds.begin(); chamberId != chamberIds.end(); ++chamberId) {
310  if (chamberId->det() == DetId::Muon && chamberId->subdetId() == MuonSubdetId::DT) {
311  MuonChamberResidual *dt13 = muonResidualsFromTrack.chamberResidual(*chamberId, MuonChamberResidual::kDT13);
312  MuonChamberResidual *dt2 = muonResidualsFromTrack.chamberResidual(*chamberId, MuonChamberResidual::kDT2);
313 
314  if (dt13 != NULL && dt13->numHits() >= m_minDT13Hits) {
315  DTChamberId thisid(chamberId->rawId());
316 
317  for (std::vector<DetId>::const_iterator otherId = chamberIds.begin(); otherId != chamberIds.end(); ++otherId) {
318  if (otherId->det() == DetId::Muon && otherId->subdetId() == MuonSubdetId::DT) {
319  DTChamberId thatid(otherId->rawId());
320  if (thisid.rawId() != thatid.rawId() && thisid.wheel() == thatid.wheel() && thisid.sector() == thatid.sector()) {
321  MuonChamberResidual *dt13other = muonResidualsFromTrack.chamberResidual(*otherId, MuonChamberResidual::kDT13);
322  if (dt13other != NULL && dt13other->numHits() >= m_minDT13Hits) {
323  double slopediff = 1000. * (dt13->global_resslope() - dt13other->global_resslope());
324 
325  double length = dt13->chamberAlignable()->surface().toGlobal(LocalPoint(0,0,0)).perp() - dt13other->chamberAlignable()->surface().toGlobal(LocalPoint(0,0,0)).perp();
326  double residdiff = 10. * (dt13->global_residual() + length*dt13->global_resslope() - dt13other->global_residual());
327 
328  if (thisid.station() == 1 && thatid.station() == 2) {
329  m_dt13_resid[thisid.wheel()+2][thisid.sector()-1][0]->Fill(qoverpt, residdiff);
330  m_dt13_slope[thisid.wheel()+2][thisid.sector()-1][0]->Fill(qoverpt, slopediff);
331  if (qoverpt > 0) {
332  m_posdt13_resid[thisid.wheel()+2][thisid.sector()-1][0]->Fill(residdiff);
333  m_posdt13_slope[thisid.wheel()+2][thisid.sector()-1][0]->Fill(slopediff);
334  }
335  else {
336  m_negdt13_resid[thisid.wheel()+2][thisid.sector()-1][0]->Fill(residdiff);
337  m_negdt13_slope[thisid.wheel()+2][thisid.sector()-1][0]->Fill(slopediff);
338  }
339  }
340  else if (thisid.station() == 2 && thatid.station() == 3) {
341  m_dt13_resid[thisid.wheel()+2][thisid.sector()-1][1]->Fill(qoverpt, residdiff);
342  m_dt13_slope[thisid.wheel()+2][thisid.sector()-1][1]->Fill(qoverpt, slopediff);
343  if (qoverpt > 0) {
344  m_posdt13_resid[thisid.wheel()+2][thisid.sector()-1][1]->Fill(residdiff);
345  m_posdt13_slope[thisid.wheel()+2][thisid.sector()-1][1]->Fill(slopediff);
346  }
347  else {
348  m_negdt13_resid[thisid.wheel()+2][thisid.sector()-1][1]->Fill(residdiff);
349  m_negdt13_slope[thisid.wheel()+2][thisid.sector()-1][1]->Fill(slopediff);
350  }
351  }
352  else if (thisid.station() == 3 && thatid.station() == 4) {
353  m_dt13_resid[thisid.wheel()+2][thisid.sector()-1][2]->Fill(qoverpt, residdiff);
354  m_dt13_slope[thisid.wheel()+2][thisid.sector()-1][2]->Fill(qoverpt, slopediff);
355  if (qoverpt > 0) {
356  m_posdt13_resid[thisid.wheel()+2][thisid.sector()-1][2]->Fill(residdiff);
357  m_posdt13_slope[thisid.wheel()+2][thisid.sector()-1][2]->Fill(slopediff);
358  }
359  else {
360  m_negdt13_resid[thisid.wheel()+2][thisid.sector()-1][2]->Fill(residdiff);
361  m_negdt13_slope[thisid.wheel()+2][thisid.sector()-1][2]->Fill(slopediff);
362  }
363  }
364 
365  } // end other numhits
366  } // end this near other
367  } // end other is DT
368  } // end loop over other
369 
370  } // end if DT13
371 
372  if (dt2 != NULL && dt2->numHits() >= m_minDT2Hits) {
373  DTChamberId thisid(chamberId->rawId());
374 
375  for (std::vector<DetId>::const_iterator otherId = chamberIds.begin(); otherId != chamberIds.end(); ++otherId) {
376  if (otherId->det() == DetId::Muon && otherId->subdetId() == MuonSubdetId::DT) {
377  DTChamberId thatid(otherId->rawId());
378  if (thisid.rawId() != thatid.rawId() && thisid.wheel() == thatid.wheel() && thisid.sector() == thatid.sector()) {
379  MuonChamberResidual *dt2other = muonResidualsFromTrack.chamberResidual(*otherId, MuonChamberResidual::kDT2);
380  if (dt2other != NULL && dt2other->numHits() >= m_minDT2Hits) {
381  double slopediff = 1000. * (dt2->global_resslope() - dt2other->global_resslope());
382 
383  double length = dt2->chamberAlignable()->surface().toGlobal(LocalPoint(0,0,0)).perp() - dt2other->chamberAlignable()->surface().toGlobal(LocalPoint(0,0,0)).perp();
384  double residdiff = 10. * (dt2->global_residual() + length*dt2->global_resslope() - dt2other->global_residual());
385 
386  if (thisid.station() == 1 && thatid.station() == 2) {
387  m_dt2_resid[thisid.wheel()+2][thisid.sector()-1][0]->Fill(qoverpt, residdiff);
388  m_dt2_slope[thisid.wheel()+2][thisid.sector()-1][0]->Fill(qoverpt, slopediff);
389  if (qoverpt > 0) {
390  m_posdt2_resid[thisid.wheel()+2][thisid.sector()-1][0]->Fill(residdiff);
391  m_posdt2_slope[thisid.wheel()+2][thisid.sector()-1][0]->Fill(slopediff);
392  }
393  else {
394  m_negdt2_resid[thisid.wheel()+2][thisid.sector()-1][0]->Fill(residdiff);
395  m_negdt2_slope[thisid.wheel()+2][thisid.sector()-1][0]->Fill(slopediff);
396  }
397  }
398  else if (thisid.station() == 2 && thatid.station() == 3) {
399  m_dt2_resid[thisid.wheel()+2][thisid.sector()-1][1]->Fill(qoverpt, residdiff);
400  m_dt2_slope[thisid.wheel()+2][thisid.sector()-1][1]->Fill(qoverpt, slopediff);
401  if (qoverpt > 0) {
402  m_posdt2_resid[thisid.wheel()+2][thisid.sector()-1][1]->Fill(residdiff);
403  m_posdt2_slope[thisid.wheel()+2][thisid.sector()-1][1]->Fill(slopediff);
404  }
405  else {
406  m_negdt2_resid[thisid.wheel()+2][thisid.sector()-1][1]->Fill(residdiff);
407  m_negdt2_slope[thisid.wheel()+2][thisid.sector()-1][1]->Fill(slopediff);
408  }
409  }
410  else if (thisid.station() == 3 && thatid.station() == 4) {
411  m_dt2_resid[thisid.wheel()+2][thisid.sector()-1][2]->Fill(qoverpt, residdiff);
412  m_dt2_slope[thisid.wheel()+2][thisid.sector()-1][2]->Fill(qoverpt, slopediff);
413  if (qoverpt > 0) {
414  m_posdt2_resid[thisid.wheel()+2][thisid.sector()-1][2]->Fill(residdiff);
415  m_posdt2_slope[thisid.wheel()+2][thisid.sector()-1][2]->Fill(slopediff);
416  }
417  else {
418  m_negdt2_resid[thisid.wheel()+2][thisid.sector()-1][2]->Fill(residdiff);
419  m_negdt2_slope[thisid.wheel()+2][thisid.sector()-1][2]->Fill(slopediff);
420  }
421  }
422 
423  } // end other numhits
424  } // end this near other
425  } // end other is DT
426  } // end loop over other
427 
428  } // end if DT2
429  } // end if DT
430 
431  else if (chamberId->det() == DetId::Muon && chamberId->subdetId() == MuonSubdetId::CSC) {
432  MuonChamberResidual *csc = muonResidualsFromTrack.chamberResidual(*chamberId, MuonChamberResidual::kCSC);
433 
434  if (csc->numHits() >= m_minCSCHits) {
435  CSCDetId thisid(chamberId->rawId());
436 
437  for (std::vector<DetId>::const_iterator otherId = chamberIds.begin(); otherId != chamberIds.end(); ++otherId) {
438  if (otherId->det() == DetId::Muon && otherId->subdetId() == MuonSubdetId::CSC) {
439  CSCDetId thatid(otherId->rawId());
440  if (thisid.rawId() != thatid.rawId() && thisid.endcap() == thatid.endcap()) {
441  MuonChamberResidual *cscother = muonResidualsFromTrack.chamberResidual(*otherId, MuonChamberResidual::kCSC);
442  if (cscother != NULL && cscother->numHits() >= m_minCSCHits) {
443  double slopediff = 1000. * (csc->global_resslope() - cscother->global_resslope());
444 
445  double length = csc->chamberAlignable()->surface().toGlobal(LocalPoint(0,0,0)).z() - cscother->chamberAlignable()->surface().toGlobal(LocalPoint(0,0,0)).z();
446  double residdiff = 10. * (csc->global_residual() + length*csc->global_resslope() - cscother->global_residual());
447 
448  int thischamber = thisid.chamber();
449  int thisring = thisid.ring();
450  if (thisid.station() == 1 && (thisring == 1 || thisring == 4)) {
451  thischamber = (thischamber - 1) / 2 + 1;
452  thisring = 1;
453  }
454 
455  if (thisring == thatid.ring() && thischamber == thatid.chamber()) {
456  if (thisring == 2 && thisid.station() == 1 && thatid.station() == 2) {
457  m_cscouter_resid[thisid.endcap()-1][thischamber-1][0]->Fill(qoverpt, residdiff);
458  m_cscouter_slope[thisid.endcap()-1][thischamber-1][0]->Fill(qoverpt, slopediff);
459  if (qoverpt > 0) {
460  m_poscscouter_resid[thisid.endcap()-1][thischamber-1][0]->Fill(residdiff);
461  m_poscscouter_slope[thisid.endcap()-1][thischamber-1][0]->Fill(slopediff);
462  }
463  else {
464  m_negcscouter_resid[thisid.endcap()-1][thischamber-1][0]->Fill(residdiff);
465  m_negcscouter_slope[thisid.endcap()-1][thischamber-1][0]->Fill(slopediff);
466  }
467  }
468  else if (thisring == 2 && thisid.station() == 2 && thatid.station() == 3) {
469  m_cscouter_resid[thisid.endcap()-1][thischamber-1][1]->Fill(qoverpt, residdiff);
470  m_cscouter_slope[thisid.endcap()-1][thischamber-1][1]->Fill(qoverpt, slopediff);
471  if (qoverpt > 0) {
472  m_poscscouter_resid[thisid.endcap()-1][thischamber-1][1]->Fill(residdiff);
473  m_poscscouter_slope[thisid.endcap()-1][thischamber-1][1]->Fill(slopediff);
474  }
475  else {
476  m_negcscouter_resid[thisid.endcap()-1][thischamber-1][1]->Fill(residdiff);
477  m_negcscouter_slope[thisid.endcap()-1][thischamber-1][1]->Fill(slopediff);
478  }
479  }
480  else if (thisring == 1 && thisid.station() == 1 && thatid.station() == 2) {
481  m_cscinner_resid[thisid.endcap()-1][thischamber-1][0]->Fill(qoverpt, residdiff);
482  m_cscinner_slope[thisid.endcap()-1][thischamber-1][0]->Fill(qoverpt, slopediff);
483  if (qoverpt > 0) {
484  m_poscscinner_resid[thisid.endcap()-1][thischamber-1][0]->Fill(residdiff);
485  m_poscscinner_slope[thisid.endcap()-1][thischamber-1][0]->Fill(slopediff);
486  }
487  else {
488  m_negcscinner_resid[thisid.endcap()-1][thischamber-1][0]->Fill(residdiff);
489  m_negcscinner_slope[thisid.endcap()-1][thischamber-1][0]->Fill(slopediff);
490  }
491  }
492  else if (thisring == 1 && thisid.station() == 2 && thatid.station() == 3) {
493  m_cscinner_resid[thisid.endcap()-1][thischamber-1][1]->Fill(qoverpt, residdiff);
494  m_cscinner_slope[thisid.endcap()-1][thischamber-1][1]->Fill(qoverpt, slopediff);
495  if (qoverpt > 0) {
496  m_poscscinner_resid[thisid.endcap()-1][thischamber-1][1]->Fill(residdiff);
497  m_poscscinner_slope[thisid.endcap()-1][thischamber-1][1]->Fill(slopediff);
498  }
499  else {
500  m_negcscinner_resid[thisid.endcap()-1][thischamber-1][1]->Fill(residdiff);
501  m_negcscinner_slope[thisid.endcap()-1][thischamber-1][1]->Fill(slopediff);
502  }
503  }
504  else if (thisring == 1 && thisid.station() == 3 && thatid.station() == 4) {
505  m_cscinner_resid[thisid.endcap()-1][thischamber-1][2]->Fill(qoverpt, residdiff);
506  m_cscinner_slope[thisid.endcap()-1][thischamber-1][2]->Fill(qoverpt, slopediff);
507  if (qoverpt > 0) {
508  m_poscscinner_resid[thisid.endcap()-1][thischamber-1][2]->Fill(residdiff);
509  m_poscscinner_slope[thisid.endcap()-1][thischamber-1][2]->Fill(slopediff);
510  }
511  else {
512  m_negcscinner_resid[thisid.endcap()-1][thischamber-1][2]->Fill(residdiff);
513  m_negcscinner_slope[thisid.endcap()-1][thischamber-1][2]->Fill(slopediff);
514  }
515  }
516  }
517  } // end other numhits
518  } // end this near other
519  } // end other is DT
520  } // end loop over other
521 
522  } // end if csc
523  } // end if CSC
524 
525  } // end loop over chamberIds
526  } // end if refit is okay
527  } // end if track pT is within range
528  } // end loop over tracks
529 }
530 
532 }
533 
534 //
535 // constructors and destructor
536 //
537 
538 // AlignmentMonitorSegmentDifferences::AlignmentMonitorSegmentDifferences(const AlignmentMonitorSegmentDifferences& rhs)
539 // {
540 // // do actual copying here;
541 // }
542 
543 //
544 // assignment operators
545 //
546 // const AlignmentMonitorSegmentDifferences& AlignmentMonitorSegmentDifferences::operator=(const AlignmentMonitorSegmentDifferences& rhs)
547 // {
548 // //An exception safe implementation is
549 // AlignmentMonitorSegmentDifferences temp(rhs);
550 // swap(rhs);
551 //
552 // return *this;
553 // }
554 
555 //
556 // const member functions
557 //
558 
559 //
560 // static member functions
561 //
562 
563 //
564 // SEAL definitions
565 //
566 
AlignableNavigator * pNavigator()
void book()
Book or retrieve histograms; MUST be reimplemented.
AlignmentMonitorSegmentDifferences(const edm::ParameterSet &cfg)
#define NULL
Definition: scimark2.h:8
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
void event(const edm::Event &iEvent, const edm::EventSetup &iSetup, const ConstTrajTrackPairCollection &iTrajTracks)
Called for each event (by &quot;run()&quot;): may be reimplemented.
const std::vector< DetId > chamberIds() const
int iEvent
Definition: GenABIO.cc:243
static const int CSC
Definition: MuonSubdetId.h:15
void afterAlignment(const edm::EventSetup &iSetup)
double pt() const
track transverse momentum
Definition: TrackBase.h:130
AlignableDetOrUnitPtr chamberAlignable() const
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection
TH1F * book1D(std::string dir, std::string name, std::string title, int nchX, double lowX, double highX)
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
const T & get() const
Definition: EventSetup.h:55
long long int num
Definition: procUtils.cc:71
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
double global_resslope() const
int charge() const
track electric charge
Definition: TrackBase.h:112
#define DEFINE_EDM_PLUGIN(factory, type, name)
static const int DT
Definition: MuonSubdetId.h:14
MuonChamberResidual * chamberResidual(DetId chamberId, int type)