CMS 3D CMS Logo

DTRecHitQuality.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author G. Cerminara - INFN Torino
5  */
6 
7 #include <iostream>
8 #include <map>
9 
17 
18 #include "DTRecHitQuality.h"
19 #include "Histograms.h"
20 
21 using namespace std;
22 using namespace edm;
23 
24 struct Histograms{
25  HRes1DHit *hRes_S1RPhi; // RecHits, 1. step, RPh
26  HRes1DHit *hRes_S2RPhi; // RecHits, 2. step, RPhi
27  HRes1DHit *hRes_S3RPhi; // RecHits, 3. step, RPhi
28  HRes1DHit *hRes_S1RZ; // RecHits, 1. step, RZ
29  HRes1DHit *hRes_S2RZ; // RecHits, 2. step, RZ
30  HRes1DHit *hRes_S3RZ; // RecHits, 3. step, RZ
31  HRes1DHit *hRes_S1RZ_W0; // RecHits, 1. step, RZ, wheel 0
32  HRes1DHit *hRes_S2RZ_W0; // RecHits, 2. step, RZ, wheel 0
33  HRes1DHit *hRes_S3RZ_W0; // RecHits, 3. step, RZ, wheel 0
34  HRes1DHit *hRes_S1RZ_W1; // RecHits, 1. step, RZ, wheel +-1
35  HRes1DHit *hRes_S2RZ_W1; // RecHits, 2. step, RZ, wheel +-1
36  HRes1DHit *hRes_S3RZ_W1; // RecHits, 3. step, RZ, wheel +-1
37  HRes1DHit *hRes_S1RZ_W2; // RecHits, 1. step, RZ, wheel +-2
38  HRes1DHit *hRes_S2RZ_W2; // RecHits, 2. step, RZ, wheel +-2
39  HRes1DHit *hRes_S3RZ_W2; // RecHits, 3. step, RZ, wheel +-2
40  HRes1DHit *hRes_S1RPhi_W0; // RecHits, 1. step, RPhi, wheel 0
41  HRes1DHit *hRes_S2RPhi_W0; // RecHits, 2. step, RPhi, wheel 0
42  HRes1DHit *hRes_S3RPhi_W0; // RecHits, 3. step, RPhi, wheel 0
43  HRes1DHit *hRes_S1RPhi_W1; // RecHits, 1. step, RPhi, wheel +-1
44  HRes1DHit *hRes_S2RPhi_W1; // RecHits, 2. step, RPhi, wheel +-1
45  HRes1DHit *hRes_S3RPhi_W1; // RecHits, 3. step, RPhi, wheel +-1
46  HRes1DHit *hRes_S1RPhi_W2; // RecHits, 1. step, RPhi, wheel +-2
47  HRes1DHit *hRes_S2RPhi_W2; // RecHits, 2. step, RPhi, wheel +-2
48  HRes1DHit *hRes_S3RPhi_W2; // RecHits, 3. step, RPhi, wheel +-2
49  HRes1DHit* hRes_S3RPhiWS[3][4]; // RecHits, 3. step, by wheel/station
50  HRes1DHit* hRes_S3RZWS[3][4]; // RecHits, 3. step, by wheel/station
51 
52  HEff1DHit *hEff_S1RPhi; // RecHits, 1. step, RPhi
53  HEff1DHit *hEff_S2RPhi; // RecHits, 2. step, RPhi
54  HEff1DHit *hEff_S3RPhi; // RecHits, 3. step, RPhi
55  HEff1DHit *hEff_S1RZ; // RecHits, 1. step, RZ
56  HEff1DHit *hEff_S2RZ; // RecHits, 2. step, RZ
57  HEff1DHit *hEff_S3RZ; // RecHits, 3. step, RZ
58  HEff1DHit *hEff_S1RZ_W0; // RecHits, 1. step, RZ, wheel 0
59  HEff1DHit *hEff_S2RZ_W0; // RecHits, 2. step, RZ, wheel 0
60  HEff1DHit *hEff_S3RZ_W0; // RecHits, 3. step, RZ, wheel 0
61  HEff1DHit *hEff_S1RZ_W1; // RecHits, 1. step, RZ, wheel +-1
62  HEff1DHit *hEff_S2RZ_W1; // RecHits, 2. step, RZ, wheel +-1
63  HEff1DHit *hEff_S3RZ_W1; // RecHits, 3. step, RZ, wheel +-1
64  HEff1DHit *hEff_S1RZ_W2; // RecHits, 1. step, RZ, wheel +-2
65  HEff1DHit *hEff_S2RZ_W2; // RecHits, 2. step, RZ, wheel +-2
66  HEff1DHit *hEff_S3RZ_W2; // RecHits, 3. step, RZ, wheel +-2
67  HEff1DHit* hEff_S1RPhiWS[3][4]; // RecHits, 3. step, by wheel/station
68  HEff1DHit* hEff_S3RPhiWS[3][4]; // RecHits, 3. step, by wheel/station
69  HEff1DHit* hEff_S1RZWS[3][4]; // RecHits, 3. step, by wheel/station
70  HEff1DHit* hEff_S3RZWS[3][4]; // RecHits, 3. step, by wheel/station
71 };
72 
73 
74 // In phi SLs, The dependency on X and angle is specular in positive
75 // and negative wheels. Since positive and negative wheels are filled
76 // together into the same plots, it is useful to mirror negative wheels
77 // so that the actual dependency can be observerd instead of an artificially
78 // simmetrized one.
79 // Set mirrorMinusWheels to avoid this.
80 namespace {
81  bool mirrorMinusWheels = true;
82 }
83 
84 // Constructor
86  // Get the debug parameter for verbose output
87  debug_ = pset.getUntrackedParameter<bool>("debug");
88  // the name of the simhit collection
89  simHitLabel_ = pset.getUntrackedParameter<InputTag>("simHitLabel");
90  simHitToken_ = consumes<PSimHitContainer>(pset.getUntrackedParameter<InputTag>("simHitLabel"));
91  // the name of the 1D rec hit collection
92  recHitLabel_ = pset.getUntrackedParameter<InputTag>("recHitLabel");
93  recHitToken_ = consumes<DTRecHitCollection>(pset.getUntrackedParameter<InputTag>("recHitLabel"));
94  // the name of the 2D rec hit collection
95  segment2DLabel_ = pset.getUntrackedParameter<InputTag>("segment2DLabel");
96  segment2DToken_ = consumes<DTRecSegment2DCollection>(pset.getUntrackedParameter<InputTag>("segment2DLabel"));
97  // the name of the 4D rec hit collection
98  segment4DLabel_ = pset.getUntrackedParameter<InputTag>("segment4DLabel");
99  segment4DToken_ = consumes<DTRecSegment4DCollection>(pset.getUntrackedParameter<InputTag>("segment4DLabel"));
100  // Switches for analysis at various steps
101  doStep1_ = pset.getUntrackedParameter<bool>("doStep1", false);
102  doStep2_ = pset.getUntrackedParameter<bool>("doStep2", false);
103  doStep3_ = pset.getUntrackedParameter<bool>("doStep3", false);
104  doall_ = pset.getUntrackedParameter<bool>("doall", false);
105  local_ = pset.getUntrackedParameter<bool>("local", true);
106 }
107 
109  if (doall_ && doStep1_) {
110  histograms.hRes_S1RPhi = new HRes1DHit("S1RPhi", booker, true, local_); // RecHits, 1. step, RPhi
111  histograms.hRes_S1RPhi_W0 = new HRes1DHit("S1RPhi_W0", booker, true, local_); // RecHits, 1. step, RZ, wheel 0
112  histograms.hRes_S1RPhi_W1 = new HRes1DHit("S1RPhi_W1", booker, true, local_); // RecHits, 1. step, RZ, wheel +-1
113  histograms.hRes_S1RPhi_W2 = new HRes1DHit("S1RPhi_W2", booker, true, local_); // RecHits, 1. step, RZ, wheel +-2
114  histograms.hRes_S1RZ = new HRes1DHit("S1RZ", booker, true, local_); // RecHits, 1. step, RZ
115  histograms.hRes_S1RZ_W0 = new HRes1DHit("S1RZ_W0", booker, true, local_); // RecHits, 1. step, RZ, wheel 0
116  histograms.hRes_S1RZ_W1 = new HRes1DHit("S1RZ_W1", booker, true, local_); // RecHits, 1. step, RZ, wheel +-1
117  histograms.hRes_S1RZ_W2 = new HRes1DHit("S1RZ_W2", booker, true, local_); // RecHits, 1. step, RZ, wheel +-2
118  histograms.hEff_S1RPhi = new HEff1DHit("S1RPhi", booker); // RecHits, 1. step, RPhi
119  histograms.hEff_S1RZ = new HEff1DHit("S1RZ", booker); // RecHits, 1. step, RZ
120  histograms.hEff_S1RZ_W0 = new HEff1DHit("S1RZ_W0", booker); // RecHits, 1. step, RZ, wheel 0
121  histograms.hEff_S1RZ_W1 = new HEff1DHit("S1RZ_W1", booker); // RecHits, 1. step, RZ, wheel +-1
122  histograms.hEff_S1RZ_W2 = new HEff1DHit("S1RZ_W2", booker); // RecHits, 1. step, RZ, wheel +-2
123  }
124  if (doall_ && doStep2_) {
125  histograms.hRes_S2RPhi = new HRes1DHit("S2RPhi", booker, true, local_); // RecHits, 2. step, RPhi
126  histograms.hRes_S2RPhi_W0 = new HRes1DHit("S2RPhi_W0", booker, true, local_); // RecHits, 2. step, RPhi, wheel 0
127  histograms.hRes_S2RPhi_W1 = new HRes1DHit("S2RPhi_W1", booker, true, local_); // RecHits, 2. step, RPhi, wheel +-1
128  histograms.hRes_S2RPhi_W2 = new HRes1DHit("S2RPhi_W2", booker, true, local_); // RecHits, 2. step, RPhi, wheel +-2
129  histograms.hRes_S2RZ = new HRes1DHit("S2RZ", booker, true, local_); // RecHits, 2. step, RZ
130  histograms.hRes_S2RZ_W0 = new HRes1DHit("S2RZ_W0", booker, true, local_); // RecHits, 2. step, RZ, wheel 0
131  histograms.hRes_S2RZ_W1 = new HRes1DHit("S2RZ_W1", booker, true, local_); // RecHits, 2. step, RZ, wheel +-1
132  histograms.hRes_S2RZ_W2 = new HRes1DHit("S2RZ_W2", booker, true, local_); // RecHits, 2. step, RZ, wheel +-2
133  histograms.hEff_S2RPhi = new HEff1DHit("S2RPhi", booker); // RecHits, 2. step, RPhi
134  histograms.hEff_S2RZ_W0 = new HEff1DHit("S2RZ_W0", booker); // RecHits, 2. step, RZ, wheel 0
135  histograms.hEff_S2RZ_W1 = new HEff1DHit("S2RZ_W1", booker); // RecHits, 2. step, RZ, wheel +-1
136  histograms.hEff_S2RZ_W2 = new HEff1DHit("S2RZ_W2", booker); // RecHits, 2. step, RZ, wheel +-2
137  histograms.hEff_S2RZ = new HEff1DHit("S2RZ", booker); // RecHits, 2. step, RZ
138  }
139  if (doStep3_) {
140  histograms.hRes_S3RPhi = new HRes1DHit("S3RPhi", booker, doall_, local_); // RecHits, 3. step, RPhi
141  histograms.hRes_S3RPhi_W0 = new HRes1DHit("S3RPhi_W0", booker, doall_, local_); // RecHits, 3. step, RPhi, wheel 0
142  histograms.hRes_S3RPhi_W1 = new HRes1DHit("S3RPhi_W1", booker, doall_, local_); // RecHits, 3. step, RPhi, wheel +-1
143  histograms.hRes_S3RPhi_W2 = new HRes1DHit("S3RPhi_W2", booker, doall_, local_); // RecHits, 3. step, RPhi, wheel +-2
144  histograms.hRes_S3RZ = new HRes1DHit("S3RZ", booker, doall_, local_); // RecHits, 3. step, RZ
145  histograms.hRes_S3RZ_W0 = new HRes1DHit("S3RZ_W0", booker, doall_, local_); // RecHits, 3. step, RZ, wheel 0
146  histograms.hRes_S3RZ_W1 = new HRes1DHit("S3RZ_W1", booker, doall_, local_); // RecHits, 3. step, RZ, wheel +-1
147  histograms.hRes_S3RZ_W2 = new HRes1DHit("S3RZ_W2", booker, doall_, local_); // RecHits, 3. step, RZ, wheel +-2
148 
149  if (local_) {
150  // Plots with finer granularity, not to be included in DQM
151  TString name1 = "RPhi_W";
152  TString name2 = "RZ_W";
153  for (long w = 0; w <= 2; ++w) {
154  for (long s = 1;s <= 4; ++s) {
155  histograms.hRes_S3RPhiWS[w][s-1] = new HRes1DHit(("S3"+name1+w+"_St"+s).Data(), booker, doall_, local_);
156  histograms.hEff_S1RPhiWS[w][s-1] = new HEff1DHit(("S1"+name1+w+"_St"+s).Data(), booker);
157  histograms.hEff_S3RPhiWS[w][s-1] = new HEff1DHit(("S3"+name1+w+"_St"+s).Data(), booker);
158  if (s != 4) {
159  histograms.hRes_S3RZWS[w][s-1] = new HRes1DHit(("S3"+name2+w+"_St"+s).Data(), booker, doall_, local_);
160  histograms.hEff_S1RZWS[w][s-1] = new HEff1DHit(("S1"+name2+w+"_St"+s).Data(), booker);
161  histograms.hEff_S3RZWS[w][s-1] = new HEff1DHit(("S3"+name2+w+"_St"+s).Data(), booker);
162  }
163  }
164  }
165  }
166 
167  if (doall_) {
168  histograms.hEff_S3RPhi = new HEff1DHit("S3RPhi", booker); // RecHits, 3. step, RPhi
169  histograms.hEff_S3RZ = new HEff1DHit("S3RZ", booker); // RecHits, 3. step, RZ
170  histograms.hEff_S3RZ_W0 = new HEff1DHit("S3RZ_W0", booker); // RecHits, 3. step, RZ, wheel 0
171  histograms.hEff_S3RZ_W1 = new HEff1DHit("S3RZ_W1", booker); // RecHits, 3. step, RZ, wheel +-1
172  histograms.hEff_S3RZ_W2 = new HEff1DHit("S3RZ_W2", booker); // RecHits, 3. step, RZ, wheel +-2
173  }
174  }
175 }
176 
177 // The real analysis
179  if (debug_) {
180  cout << "--- [DTRecHitQuality] Analysing Event: #Run: " << event.id().run()
181  << " #Event: " << event.id().event() << endl;
182 }
183 
184  // Get the DT Geometry
185  ESHandle<DTGeometry> dtGeom;
186  setup.get<MuonGeometryRecord>().get(dtGeom);
187 
188  // Get the SimHit collection from the event
190  event.getByToken(simHitToken_, simHits);
191 
192  // Map simhits per wire
193  map<DTWireId, PSimHitContainer > simHitsPerWire =
195 
196  //=======================================================================================
197  // RecHit analysis at Step 1
198  if (doStep1_ && doall_) {
199  if (debug_) {
200  cout << " -- DTRecHit S1: begin analysis:" << endl;
201 }
202  // Get the rechit collection from the event
203  Handle<DTRecHitCollection> dtRecHits;
204  event.getByToken(recHitToken_, dtRecHits);
205 
206  if (!dtRecHits.isValid()) {
207  if (debug_) { cout << "[DTRecHitQuality]**Warning: no 1DRechits with label: " << recHitLabel_ << " in this event, skipping!" << endl;
208 }
209  return;
210  }
211 
212  // Map rechits per wire
213  auto const& recHitsPerWire = map1DRecHitsPerWire(dtRecHits.product());
214  compute(dtGeom.product(), simHitsPerWire, recHitsPerWire, histograms, 1);
215  }
216 
217  //=======================================================================================
218  // RecHit analysis at Step 2
219  if (doStep2_ && doall_) {
220  if (debug_) {
221  cout << " -- DTRecHit S2: begin analysis:" << endl;
222 }
223 
224  // Get the 2D rechits from the event
226  event.getByToken(segment2DToken_, segment2Ds);
227 
228  if (!segment2Ds.isValid()) {
229  if (debug_) {
230  cout << "[DTRecHitQuality]**Warning: no 2DSegments with label: " << segment2DLabel_
231  << " in this event, skipping!" << endl;
232 }
233 
234  }
235  else{
236  // Map rechits per wire
237  auto const& recHitsPerWire = map1DRecHitsPerWire(segment2Ds.product());
238  compute(dtGeom.product(), simHitsPerWire, recHitsPerWire, histograms, 2);
239  }
240  }
241 
242  //=======================================================================================
243  // RecHit analysis at Step 3
244  if (doStep3_) {
245  if (debug_) {
246  cout << " -- DTRecHit S3: begin analysis:" << endl;
247 }
248 
249  // Get the 4D rechits from the event
251  event.getByToken(segment4DToken_, segment4Ds);
252 
253  if (!segment4Ds.isValid()) {
254  if (debug_) { cout << "[DTRecHitQuality]**Warning: no 4D Segments with label: " << segment4DLabel_
255  << " in this event, skipping!" << endl;
256 }
257  return;
258  }
259 
260  // Map rechits per wire
261  auto const& recHitsPerWire = map1DRecHitsPerWire(segment4Ds.product());
262  compute(dtGeom.product(), simHitsPerWire, recHitsPerWire, histograms, 3);
263  }
264 }
265 
266 // Return a map between DTRecHit1DPair and wireId
267 map<DTWireId, vector<DTRecHit1DPair>>
269  map<DTWireId, vector<DTRecHit1DPair>> ret;
270 
271  for (const auto & dt1DRecHitPair : *dt1DRecHitPairs) {
272  ret[dt1DRecHitPair.wireId()].push_back(dt1DRecHitPair);
273  }
274 
275  return ret;
276 }
277 
278 
279 // Return a map between DTRecHit1D at S2 and wireId
280 map<DTWireId, vector<DTRecHit1D>>
282  map<DTWireId, vector<DTRecHit1D>> ret;
283 
284  // Loop over all 2D segments
285  for (const auto & segment2D : *segment2Ds) {
286  vector<DTRecHit1D> component1DHits = segment2D.specificRecHits();
287  // Loop over all component 1D hits
288  for (auto & component1DHit : component1DHits) {
289  ret[component1DHit.wireId()].push_back(component1DHit);
290  }
291  }
292  return ret;
293 }
294 
295 // Return a map between DTRecHit1D at S3 and wireId
296 map<DTWireId, std::vector<DTRecHit1D>>
298  map<DTWireId, vector<DTRecHit1D>> ret;
299  // Loop over all 4D segments
300  for (const auto & segment4D : *segment4Ds) {
301  // Get component 2D segments
302  vector<const TrackingRecHit*> segment2Ds = segment4D.recHits();
303  // Loop over 2D segments:
304  for (auto & segment2D : segment2Ds) {
305  // Get 1D component rechits
306  vector<const TrackingRecHit*> hits = segment2D->recHits();
307  // Loop over them
308  for (auto & hit : hits) {
309  const auto* hit1D = dynamic_cast<const DTRecHit1D*>(hit);
310  ret[hit1D->wireId()].push_back(*hit1D);
311  }
312  }
313  }
314 
315  return ret;
316 }
317 
318 // Compute SimHit distance from wire (cm)
320  const DTWireId& wireId,
321  const PSimHit& hit) const {
322  float xwire = layer->specificTopology().wirePosition(wireId.wire());
323  LocalPoint entryP = hit.entryPoint();
324  LocalPoint exitP = hit.exitPoint();
325  float xEntry = entryP.x() - xwire;
326  float xExit = exitP.x() - xwire;
327 
328  return fabs(xEntry - (entryP.z()*(xExit-xEntry))/(exitP.z()-entryP.z())); // FIXME: check...
329 }
330 
331 // Compute SimHit impact angle (in direction perp to wire), in the SL RF
333  const DTWireId& wireId,
334  const PSimHit& hit) const {
335  LocalPoint entryP = hit.entryPoint();
336  LocalPoint exitP = hit.exitPoint();
337  float theta =(exitP.x()-entryP.x())/(exitP.z()-entryP.z());
338  return atan(theta);
339 }
340 
341 // Compute SimHit distance from FrontEnd
343  const DTWireId& wireId,
344  const PSimHit& hit) const {
345  LocalPoint entryP = hit.entryPoint();
346  LocalPoint exitP = hit.exitPoint();
347  float wireLenght = layer->specificTopology().cellLenght();
348  // FIXME: should take only wireLenght/2.;
349  // moreover, pos+cellLenght/2. is shorter than the distance from FE.
350  // In fact it would make more sense to make plots vs y.
351  return (entryP.y()+exitP.y())/2.+wireLenght;
352 }
353 
354 
355 // Find the RecHit closest to the muon SimHit
356 template <typename type>
357 const type*
359  const DTWireId& wireId,
360  const vector<type>& recHits,
361  const float simHitDist) const {
362  float res = 99999;
363  const type* theBestRecHit = nullptr;
364  // Loop over RecHits within the cell
365  for (auto recHit = recHits.begin();
366  recHit != recHits.end();
367  recHit++) {
368  float distTmp = recHitDistFromWire(*recHit, layer);
369  if (fabs(distTmp-simHitDist) < res) {
370  res = fabs(distTmp-simHitDist);
371  theBestRecHit = &(*recHit);
372  }
373  } // End of loop over RecHits within the cell
374 
375  return theBestRecHit;
376 }
377 
378 
379 // Compute the distance from wire (cm) of a hits in a DTRecHit1DPair
380 float
381 DTRecHitQuality::recHitDistFromWire(const DTRecHit1DPair& hitPair, const DTLayer* layer) const {
382  // Compute the rechit distance from wire
383  return fabs(hitPair.localPosition(DTEnums::Left).x() -
384  hitPair.localPosition(DTEnums::Right).x())/2.;
385 }
386 
387 
388 
389 // Compute the distance from wire (cm) of a hits in a DTRecHit1D
390 float
392  return fabs(recHit.localPosition().x() - layer->specificTopology().wirePosition(recHit.wireId().wire()));
393 }
394 
395 
396 template <typename type>
398  const std::map<DTWireId, std::vector<PSimHit>>& simHitsPerWire,
399  const std::map<DTWireId, std::vector<type>>& recHitsPerWire,
400  Histograms const& histograms, int step) const {
401  // Loop over cells with a muon SimHit
402  for (const auto & wireAndSHits : simHitsPerWire) {
403  DTWireId wireId = wireAndSHits.first;
404  int wheel = wireId.wheel();
405  int sl = wireId.superLayer();
406 
407  vector<PSimHit> simHitsInCell = wireAndSHits.second;
408 
409  // Get the layer
410  const DTLayer* layer = dtGeom->layer(wireId);
411 
412  // Look for a mu hit in the cell
413  const PSimHit* muSimHit = DTHitQualityUtils::findMuSimHit(simHitsInCell);
414  if (muSimHit == nullptr) {
415  if (debug_) {
416  cout << " No mu SimHit in channel: " << wireId << ", skipping! " << endl;
417 }
418  continue; // Skip this cell
419  }
420 
421  // Find the distance of the simhit from the wire
422  float simHitWireDist = simHitDistFromWire(layer, wireId, *muSimHit);
423  // Skip simhits out of the cell
424  if (simHitWireDist>2.1) {
425  if (debug_) {
426  cout << " [DTRecHitQuality]###Warning: The mu SimHit in out of the cell, skipping!" << endl;
427 }
428  continue; // Skip this cell
429  }
430  GlobalPoint simHitGlobalPos = layer->toGlobal(muSimHit->localPosition());
431 
432  // find SH impact angle
433  float simHitTheta = simHitImpactAngle(layer, wireId, *muSimHit);
434 
435  // find SH distance from FE
436  float simHitFEDist = simHitDistFromFE(layer, wireId, *muSimHit);
437 
438  bool recHitReconstructed = false;
439 
440  // Look for RecHits in the same cell
441  if (recHitsPerWire.find(wireId) == recHitsPerWire.end()) {
442  // No RecHit found in this cell
443  if (debug_) {
444  cout << " No RecHit found at Step: " << step << " in cell: " << wireId << endl;
445 }
446  } else {
447  recHitReconstructed = true;
448  // vector<type> recHits = (*wireAndRecHits).second;
449  const vector<type>& recHits = recHitsPerWire.at(wireId);
450  if (debug_) {
451  cout << " " << recHits.size() << " RecHits, Step " << step << " in channel: " << wireId << endl;
452 }
453 
454  // Find the best RecHit
455  const type* theBestRecHit = findBestRecHit(layer, wireId, recHits, simHitWireDist);
456 
457 
458  float recHitWireDist = recHitDistFromWire(*theBestRecHit, layer);
459  if (debug_) {
460  cout << " SimHit distance from wire: " << simHitWireDist << endl
461  << " SimHit distance from FE: " << simHitFEDist << endl
462  << " SimHit angle in layer RF: " << simHitTheta << endl
463  << " RecHit distance from wire: " << recHitWireDist << endl;
464 }
465  float recHitErr = recHitPositionError(*theBestRecHit);
466  HRes1DHit *hRes = nullptr;
467  HRes1DHit *hResTot = nullptr;
468 
469  // Mirror angle in phi so that + and - wheels can be plotted together
470  if (mirrorMinusWheels && wheel<0 && sl!= 2) {
471  simHitTheta *= -1.;
472  // Note: local X, if used, would have to be mirrored as well
473  }
474 
475  // Fill residuals and pulls
476  // Select the histo to be filled
477  if (step == 1) {
478  // Step 1
479  if (sl != 2) {
480  hResTot = histograms.hRes_S1RPhi;
481  if (wheel == 0) {
482  hRes = histograms.hRes_S1RPhi_W0;
483 }
484  if (abs(wheel) == 1) {
485  hRes = histograms.hRes_S1RPhi_W1;
486 }
487  if (abs(wheel) == 2) {
488  hRes = histograms.hRes_S1RPhi_W2;
489 }
490  } else {
491  hResTot = histograms.hRes_S1RZ;
492  if (wheel == 0) {
493  hRes = histograms.hRes_S1RZ_W0;
494 }
495  if (abs(wheel) == 1) {
496  hRes = histograms.hRes_S1RZ_W1;
497 }
498  if (abs(wheel) == 2) {
499  hRes = histograms.hRes_S1RZ_W2;
500 }
501  }
502 
503  } else if (step == 2) {
504  // Step 2
505  if (sl != 2) {
506  hRes = histograms.hRes_S2RPhi;
507  if (wheel == 0) {
508  hRes = histograms.hRes_S2RPhi_W0;
509 }
510  if (abs(wheel) == 1) {
511  hRes = histograms.hRes_S2RPhi_W1;
512 }
513  if (abs(wheel) == 2) {
514  hRes = histograms.hRes_S2RPhi_W2;
515 }
516  } else {
517  hResTot = histograms.hRes_S2RZ;
518  if (wheel == 0) {
519  hRes = histograms.hRes_S2RZ_W0;
520 }
521  if (abs(wheel) == 1) {
522  hRes = histograms.hRes_S2RZ_W1;
523 }
524  if (abs(wheel) == 2) {
525  hRes = histograms.hRes_S2RZ_W2;
526 }
527  }
528 
529  } else if (step == 3) {
530  // Step 3
531  if (sl != 2) {
532  hResTot = histograms.hRes_S3RPhi;
533  if (wheel == 0) {
534  hRes = histograms.hRes_S3RPhi_W0;
535 }
536  if (abs(wheel) == 1) {
537  hRes = histograms.hRes_S3RPhi_W1;
538 }
539  if (abs(wheel) == 2) {
540  hRes = histograms.hRes_S3RPhi_W2;
541 }
542  if (local_) {
543  histograms.hRes_S3RPhiWS[abs(wheel)][wireId.station()-1]->fill(simHitWireDist, simHitTheta, simHitFEDist, recHitWireDist, simHitGlobalPos.eta(), simHitGlobalPos.phi(), recHitErr, wireId.station());
544 }
545  } else {
546  hResTot = histograms.hRes_S3RZ;
547  if (wheel == 0) {
548  hRes = histograms.hRes_S3RZ_W0;
549 }
550  if (abs(wheel) == 1) {
551  hRes = histograms.hRes_S3RZ_W1;
552 }
553  if (abs(wheel) == 2) {
554  hRes = histograms.hRes_S3RZ_W2;
555 }
556  if (local_) {
557  histograms.hRes_S3RZWS[abs(wheel)][wireId.station()-1]->fill(simHitWireDist, simHitTheta, simHitFEDist, recHitWireDist, simHitGlobalPos.eta(), simHitGlobalPos.phi(), recHitErr, wireId.station());
558 }
559  }
560  }
561 
562  // Fill
563  hRes->fill(simHitWireDist, simHitTheta, simHitFEDist, recHitWireDist, simHitGlobalPos.eta(),
564  simHitGlobalPos.phi(), recHitErr, wireId.station());
565  if (hResTot != nullptr) {
566  hResTot->fill(simHitWireDist, simHitTheta, simHitFEDist, recHitWireDist, simHitGlobalPos.eta(),
567  simHitGlobalPos.phi(), recHitErr, wireId.station());
568 }
569  }
570 
571  // Fill Efficiencies
572  if (doall_) {
573  HEff1DHit *hEff = nullptr;
574  HEff1DHit *hEffTot = nullptr;
575  if (step == 1) {
576  // Step 1
577  if (sl != 2) {
578  hEff = histograms.hEff_S1RPhi;
579  if (local_) { histograms.hEff_S1RPhiWS[abs(wheel)][wireId.station()-1]->fill(simHitWireDist, simHitGlobalPos.eta(), simHitGlobalPos.phi(), recHitReconstructed);
580 }
581  } else {
582  hEffTot = histograms.hEff_S1RZ;
583  if (wheel == 0) {
584  hEff = histograms.hEff_S1RZ_W0;
585 }
586  if (abs(wheel) == 1) {
587  hEff = histograms.hEff_S1RZ_W1;
588 }
589  if (abs(wheel) == 2) {
590  hEff = histograms.hEff_S1RZ_W2;
591 }
592  if (local_) { histograms.hEff_S1RZWS[abs(wheel)][wireId.station()-1]->fill(simHitWireDist, simHitGlobalPos.eta(), simHitGlobalPos.phi(), recHitReconstructed);
593 }
594  }
595 
596  } else if (step == 2) {
597  // Step 2
598  if (sl != 2) {
599  hEff = histograms.hEff_S2RPhi;
600  } else {
601  hEffTot = histograms.hEff_S2RZ;
602  if (wheel == 0) {
603  hEff = histograms.hEff_S2RZ_W0;
604 }
605  if (abs(wheel) == 1) {
606  hEff = histograms.hEff_S2RZ_W1;
607 }
608  if (abs(wheel) == 2) {
609  hEff = histograms.hEff_S2RZ_W2;
610 }
611  }
612 
613  } else if (step == 3) {
614  // Step 3
615  if (sl != 2) {
616  hEff = histograms.hEff_S3RPhi;
617  if (local_) { histograms.hEff_S3RPhiWS[abs(wheel)][wireId.station()-1]->fill(simHitWireDist, simHitGlobalPos.eta(), simHitGlobalPos.phi(), recHitReconstructed);
618 }
619  } else {
620  hEffTot = histograms.hEff_S3RZ;
621  if (wheel == 0) {
622  hEff = histograms.hEff_S3RZ_W0;
623 }
624  if (abs(wheel) == 1) {
625  hEff = histograms.hEff_S3RZ_W1;
626 }
627  if (abs(wheel) == 2) {
628  hEff = histograms.hEff_S3RZ_W2;
629 }
630  if (local_) { histograms.hEff_S3RZWS[abs(wheel)][wireId.station()-1]->fill(simHitWireDist, simHitGlobalPos.eta(), simHitGlobalPos.phi(), recHitReconstructed);
631 }
632  }
633 
634  }
635  // Fill
636  hEff->fill(simHitWireDist, simHitGlobalPos.eta(), simHitGlobalPos.phi(), recHitReconstructed);
637  if (hEffTot != nullptr) {
638  hEffTot->fill(simHitWireDist, simHitGlobalPos.eta(), simHitGlobalPos.phi(), recHitReconstructed);
639 }
640  }
641  }
642 }
643 
644 // Return the error on the measured (cm) coordinate
646  return sqrt(recHit.localPositionError(DTEnums::Left).xx());
647 }
648 
649 // Return the error on the measured (cm) coordinate
651  return sqrt(recHit.localPositionError().xx());
652 }
653 
654 // declare this as a framework plugin
HEff1DHit * hEff_S1RPhi
LocalPoint localPosition() const override
Return the 3-dimensional local position.
Definition: DTRecHit1D.h:60
type
Definition: HCALResponse.h:21
HRes1DHit * hRes_S2RPhi_W1
T getUntrackedParameter(std::string const &, T const &) const
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:86
HRes1DHit * hRes_S1RZ
float xx() const
Definition: LocalError.h:24
HRes1DHit * hRes_S2RPhi
HEff1DHit * hEff_S1RPhiWS[3][4]
HEff1DHit * hEff_S2RZ_W1
const double w
Definition: UKUtility.cc:23
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, Histograms const &) const override
Perform the real analysis.
LocalError localPositionError() const override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
LocalError localPositionError() const override
Return the 3-dimensional error on the local position.
Definition: DTRecHit1D.h:66
HRes1DHit * hRes_S1RPhi
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:54
HRes1DHit * hRes_S1RPhi_W1
A set of histograms fo efficiency computation for 1D RecHits (producer)
Definition: Histograms.h:133
HRes1DHit * hRes_S3RZ
float simHitImpactAngle(const DTLayer *layer, const DTWireId &wireId, const PSimHit &hit) const
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Geom::Theta< T > theta() const
T y() const
Definition: PV3DBase.h:63
static const PSimHit * findMuSimHit(const edm::PSimHitContainer &hits)
Select the SimHit from a muon in a vector of SimHits.
HRes1DHit * hRes_S1RPhi_W0
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
HRes1DHit * hRes_S2RPhi_W0
HRes1DHit * hRes_S2RPhi_W2
HRes1DHit * hRes_S3RZ_W0
Definition: Electron.h:6
std::map< DTWireId, std::vector< DTRecHit1DPair > > map1DRecHitsPerWire(const DTRecHitCollection *dt1DRecHitPairs) const
HEff1DHit * hEff_S1RZWS[3][4]
const DTTopology & specificTopology() const
Definition: DTLayer.cc:42
HEff1DHit * hEff_S3RPhi
Local3DPoint exitPoint() const
Exit point in the local Det frame.
Definition: PSimHit.h:38
HEff1DHit * hEff_S1RZ_W2
HEff1DHit * hEff_S3RZWS[3][4]
void fill(float distSimHit, float thetaSimHit, float distFESimHit, float distRecHit, float etaSimHit, float phiSimHit, float errRecHit, int station)
Definition: Histograms.h:80
DTRecHitQuality(const edm::ParameterSet &pset)
Constructor.
Local3DPoint localPosition() const
Definition: PSimHit.h:44
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
HEff1DHit * hEff_S2RZ_W2
HRes1DHit * hRes_S1RZ_W1
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int superLayer() const
Return the superlayer number.
HRes1DHit * hRes_S3RZ_W2
float simHitDistFromWire(const DTLayer *layer, const DTWireId &wireId, const PSimHit &hit) const
float recHitDistFromWire(const DTRecHit1DPair &hitPair, const DTLayer *layer) const
HEff1DHit * hEff_S3RZ_W0
const type * findBestRecHit(const DTLayer *layer, const DTWireId &wireId, const std::vector< type > &recHits, float simHitDist) const
HEff1DHit * hEff_S3RZ_W1
HEff1DHit * hEff_S1RZ_W0
HRes1DHit * hRes_S1RZ_W2
HRes1DHit * hRes_S3RZ_W1
HRes1DHit * hRes_S3RPhi
A set of histograms of residuals and pulls for 1D RecHits.
Definition: Histograms.h:46
HRes1DHit * hRes_S2RZ_W0
bool isValid() const
Definition: HandleBase.h:74
HRes1DHit * hRes_S2RZ
int wire() const
Return the wire number.
Definition: DTWireId.h:56
HEff1DHit * hEff_S2RZ_W0
HEff1DHit * hEff_S2RZ
HRes1DHit * hRes_S2RZ_W1
T const * product() const
Definition: Handle.h:81
HEff1DHit * hEff_S3RPhiWS[3][4]
const T & get() const
Definition: EventSetup.h:59
def compute(min, max)
HEff1DHit * hEff_S3RZ_W2
void bookHistograms(DQMStore::ConcurrentBooker &, edm::Run const &, edm::EventSetup const &, Histograms &) const override
Book the DQM plots.
HEff1DHit * hEff_S1RZ_W1
HRes1DHit * hRes_S3RPhi_W1
HRes1DHit * hRes_S2RZ_W2
T eta() const
Definition: PV3DBase.h:76
HLT enums.
HEff1DHit * hEff_S2RPhi
void compute(const DTGeometry *dtGeom, const std::map< DTWireId, std::vector< PSimHit >> &simHitsPerWire, const std::map< DTWireId, std::vector< type >> &recHitsPerWire, Histograms const &histograms, int step) const
HEff1DHit * hEff_S1RZ
HEff1DHit * hEff_S3RZ
void fill(float distSimHit, float etaSimHit, float phiSimHit, bool fillRecHit)
Definition: Histograms.h:148
HRes1DHit * hRes_S1RPhi_W2
LocalPoint localPosition() const override
step
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:109
static std::map< DTWireId, edm::PSimHitContainer > mapSimHitsPerWire(const edm::PSimHitContainer &simhits)
HRes1DHit * hRes_S3RPhi_W0
HRes1DHit * hRes_S3RZWS[3][4]
int station() const
Return the station number.
Definition: DTChamberId.h:51
float cellLenght() const
Definition: DTTopology.h:73
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
T x() const
Definition: PV3DBase.h:62
T const * product() const
Definition: ESHandle.h:86
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Definition: PSimHit.h:35
float recHitPositionError(const DTRecHit1DPair &recHit) const
HRes1DHit * hRes_S1RZ_W0
HRes1DHit * hRes_S3RPhiWS[3][4]
Definition: event.py:1
Definition: Run.h:43
HRes1DHit * hRes_S3RPhi_W2
float simHitDistFromFE(const DTLayer *layer, const DTWireId &wireId, const PSimHit &hit) const
DTWireId wireId() const
Return the wireId.
Definition: DTRecHit1D.h:107