CMS 3D CMS Logo

SiStripRecHitsValid.cc
Go to the documentation of this file.
2 
3 //needed for the geometry:
15 
16 //--- for RecHit
21 
23 
24 using namespace std;
25 using namespace edm;
26 
27 
28 //Constructor
30  conf_(ps),
31  trackerHitAssociatorConfig_(ps, consumesCollector()),
32  m_cacheID_(0)
33  // matchedRecHits_( ps.getParameter<edm::InputTag>("matchedRecHits") ),
34  // rphiRecHits_( ps.getParameter<edm::InputTag>("rphiRecHits") ),
35  // stereoRecHits_( ps.getParameter<edm::InputTag>("stereoRecHits") )
36 {
37  matchedRecHitsToken_ = consumes<SiStripMatchedRecHit2DCollection>( ps.getParameter<edm::InputTag>("matchedRecHits") );
38 
39  rphiRecHitsToken_ = consumes<SiStripRecHit2DCollection>( ps.getParameter<edm::InputTag>("rphiRecHits") );
40 
41  stereoRecHitsToken_ = consumes<SiStripRecHit2DCollection>( ps.getParameter<edm::InputTag>("stereoRecHits") );
42 
43  topFolderName_ = conf_.getParameter<std::string>("TopFolderName");
44 
45  SubDetList_ = conf_.getParameter<std::vector<std::string> >("SubDetList");
46 
47  edm::ParameterSet ParametersNumTotrphi = conf_.getParameter<edm::ParameterSet>("TH1NumTotrphi");
48  switchNumTotrphi = ParametersNumTotrphi.getParameter<bool>("switchon");
49 
50  edm::ParameterSet ParametersNumTotStereo = conf_.getParameter<edm::ParameterSet>("TH1NumTotStereo");
51  switchNumTotStereo = ParametersNumTotStereo.getParameter<bool>("switchon");
52 
53  edm::ParameterSet ParametersNumTotMatched = conf_.getParameter<edm::ParameterSet>("TH1NumTotMatched");
54  switchNumTotMatched = ParametersNumTotMatched.getParameter<bool>("switchon");
55 
56  edm::ParameterSet ParametersNumrphi = conf_.getParameter<edm::ParameterSet>("TH1Numrphi");
57  switchNumrphi = ParametersNumrphi.getParameter<bool>("switchon");
58 
59  edm::ParameterSet ParametersBunchrphi = conf_.getParameter<edm::ParameterSet>("TH1Bunchrphi");
60  switchBunchrphi = ParametersBunchrphi.getParameter<bool>("switchon");
61 
62  edm::ParameterSet ParametersEventrphi = conf_.getParameter<edm::ParameterSet>("TH1Eventrphi");
63  switchEventrphi = ParametersEventrphi.getParameter<bool>("switchon");
64 
65  edm::ParameterSet ParametersNumStereo = conf_.getParameter<edm::ParameterSet>("TH1NumStereo");
66  switchNumStereo = ParametersNumStereo.getParameter<bool>("switchon");
67 
68  edm::ParameterSet ParametersBunchStereo = conf_.getParameter<edm::ParameterSet>("TH1BunchStereo");
69  switchBunchStereo = ParametersBunchStereo.getParameter<bool>("switchon");
70 
71  edm::ParameterSet ParametersEventStereo = conf_.getParameter<edm::ParameterSet>("TH1EventStereo");
72  switchEventStereo = ParametersEventStereo.getParameter<bool>("switchon");
73 
74  edm::ParameterSet ParametersNumMatched = conf_.getParameter<edm::ParameterSet>("TH1NumMatched");
75  switchNumMatched = ParametersNumMatched.getParameter<bool>("switchon");
76 
77  edm::ParameterSet ParametersBunchMatched = conf_.getParameter<edm::ParameterSet>("TH1BunchMatched");
78  switchBunchMatched = ParametersBunchMatched.getParameter<bool>("switchon");
79 
80  edm::ParameterSet ParametersEventMatched = conf_.getParameter<edm::ParameterSet>("TH1EventMatched");
81  switchEventMatched = ParametersEventMatched.getParameter<bool>("switchon");
82 
83  edm::ParameterSet ParametersWclusrphi = conf_.getParameter<edm::ParameterSet>("TH1Wclusrphi");
84  switchWclusrphi = ParametersWclusrphi.getParameter<bool>("switchon");
85 
86  edm::ParameterSet ParametersAdcrphi = conf_.getParameter<edm::ParameterSet>("TH1Adcrphi");
87  switchAdcrphi = ParametersAdcrphi.getParameter<bool>("switchon");
88 
89  edm::ParameterSet ParametersPosxrphi = conf_.getParameter<edm::ParameterSet>("TH1Posxrphi");
90  switchPosxrphi = ParametersPosxrphi.getParameter<bool>("switchon");
91 
92  edm::ParameterSet ParametersResolxrphi = conf_.getParameter<edm::ParameterSet>("TH1Resolxrphi");
93  switchResolxrphi = ParametersResolxrphi.getParameter<bool>("switchon");
94 
95  edm::ParameterSet ParametersResrphi = conf_.getParameter<edm::ParameterSet>("TH1Resrphi");
96  switchResrphi = ParametersResrphi.getParameter<bool>("switchon");
97 
98  edm::ParameterSet ParametersPullLFrphi = conf_.getParameter<edm::ParameterSet>("TH1PullLFrphi");
99  switchPullLFrphi = ParametersPullLFrphi.getParameter<bool>("switchon");
100 
101  edm::ParameterSet ParametersPullMFrphi = conf_.getParameter<edm::ParameterSet>("TH1PullMFrphi");
102  switchPullMFrphi = ParametersPullMFrphi.getParameter<bool>("switchon");
103 
104  edm::ParameterSet ParametersChi2rphi = conf_.getParameter<edm::ParameterSet>("TH1Chi2rphi");
105  switchChi2rphi = ParametersChi2rphi.getParameter<bool>("switchon");
106 
107  edm::ParameterSet ParametersNsimHitrphi = conf_.getParameter<edm::ParameterSet>("TH1NsimHitrphi");
108  switchNsimHitrphi = ParametersNsimHitrphi.getParameter<bool>("switchon");
109 
110  edm::ParameterSet ParametersWclusStereo = conf_.getParameter<edm::ParameterSet>("TH1WclusStereo");
111  switchWclusStereo = ParametersWclusStereo.getParameter<bool>("switchon");
112 
113  edm::ParameterSet ParametersAdcStereo = conf_.getParameter<edm::ParameterSet>("TH1AdcStereo");
114  switchAdcStereo = ParametersAdcStereo.getParameter<bool>("switchon");
115 
116  edm::ParameterSet ParametersPosxStereo = conf_.getParameter<edm::ParameterSet>("TH1PosxStereo");
117  switchPosxStereo = ParametersPosxStereo.getParameter<bool>("switchon");
118 
119  edm::ParameterSet ParametersResolxStereo = conf_.getParameter<edm::ParameterSet>("TH1ResolxStereo");
120  switchResolxStereo = ParametersResolxStereo.getParameter<bool>("switchon");
121 
122  edm::ParameterSet ParametersResStereo = conf_.getParameter<edm::ParameterSet>("TH1ResStereo");
123  switchResStereo = ParametersResStereo.getParameter<bool>("switchon");
124 
125  edm::ParameterSet ParametersPullLFStereo = conf_.getParameter<edm::ParameterSet>("TH1PullLFStereo");
126  switchPullLFStereo = ParametersPullLFStereo.getParameter<bool>("switchon");
127 
128  edm::ParameterSet ParametersPullMFStereo = conf_.getParameter<edm::ParameterSet>("TH1PullMFStereo");
129  switchPullMFStereo = ParametersPullMFStereo.getParameter<bool>("switchon");
130 
131  edm::ParameterSet ParametersChi2Stereo = conf_.getParameter<edm::ParameterSet>("TH1Chi2Stereo");
132  switchChi2Stereo = ParametersChi2Stereo.getParameter<bool>("switchon");
133 
134  edm::ParameterSet ParametersNsimHitStereo = conf_.getParameter<edm::ParameterSet>("TH1NsimHitStereo");
135  switchNsimHitStereo = ParametersNsimHitStereo.getParameter<bool>("switchon");
136 
137  edm::ParameterSet ParametersPosxMatched = conf_.getParameter<edm::ParameterSet>("TH1PosxMatched");
138  switchPosxMatched = ParametersPosxMatched.getParameter<bool>("switchon");
139 
140  edm::ParameterSet ParametersPosyMatched = conf_.getParameter<edm::ParameterSet>("TH1PosyMatched");
141  switchPosyMatched = ParametersPosyMatched.getParameter<bool>("switchon");
142 
143  edm::ParameterSet ParametersResolxMatched = conf_.getParameter<edm::ParameterSet>("TH1ResolxMatched");
144  switchResolxMatched = ParametersResolxMatched.getParameter<bool>("switchon");
145 
146  edm::ParameterSet ParametersResolyMatched = conf_.getParameter<edm::ParameterSet>("TH1ResolyMatched");
147  switchResolyMatched = ParametersResolyMatched.getParameter<bool>("switchon");
148 
149  edm::ParameterSet ParametersResxMatched = conf_.getParameter<edm::ParameterSet>("TH1ResxMatched");
150  switchResxMatched = ParametersResxMatched.getParameter<bool>("switchon");
151 
152  edm::ParameterSet ParametersResyMatched = conf_.getParameter<edm::ParameterSet>("TH1ResyMatched");
153  switchResyMatched = ParametersResyMatched.getParameter<bool>("switchon");
154 
155  edm::ParameterSet ParametersChi2Matched = conf_.getParameter<edm::ParameterSet>("TH1Chi2Matched");
156  switchChi2Matched = ParametersChi2Matched.getParameter<bool>("switchon");
157 
158  edm::ParameterSet ParametersNsimHitMatched = conf_.getParameter<edm::ParameterSet>("TH1NsimHitMatched");
159  switchNsimHitMatched = ParametersNsimHitMatched.getParameter<bool>("switchon");
160 }
161 
163 }
164 
165 //--------------------------------------------------------------------------------------------
167 
168  unsigned long long cacheID = es.get<SiStripDetCablingRcd>().cacheIdentifier();
169  if (m_cacheID_ != cacheID) {
170  m_cacheID_ = cacheID;
171  edm::LogInfo("SiStripRecHitsValid") <<"SiStripRecHitsValid::beginRun: "
172  << " Creating MEs for new Cabling ";
173 
174  createMEs(ibooker,es);
175  }
176 }
177 
179 }
180 
182 
183  LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
184 
185  //Retrieve tracker topology from geometry
186  edm::ESHandle<TrackerTopology> tTopoHandle;
187  es.get<TrackerTopologyRcd>().get(tTopoHandle);
188  const TrackerTopology* const tTopo = tTopoHandle.product();
189 
190  // Step A: Get Inputs
194  e.getByToken(matchedRecHitsToken_, rechitsmatched);
195  e.getByToken(rphiRecHitsToken_, rechitsrphi);
196  e.getByToken(stereoRecHitsToken_, rechitsstereo);
197 
198  //Variables in order to count total num of rechitrphi,rechitstereo, rechitmatched in subdetectors
199  std::map<std::string, int > totnumrechitrphi;
200  std::map<std::string, int > totnumrechitstereo;
201  std::map<std::string, int > totnumrechitmatched;
202  int totrechitrphi =0;
203  int totrechitstereo =0;
204  int totrechitmatched =0;
205 
207 
209  es.get<TrackerDigiGeometryRecord> ().get (pDD);
210  const TrackerGeometry &tracker(*pDD);
211 
212  SiStripHistoId hidmanager;
213  SiStripFolderOrganizer fold_organ;
214  for (auto const& theDetSet : *rechitsrphi) {
215  DetId detid = theDetSet.detId();
216  uint32_t myid = detid.rawId();
217  totrechitrphi += theDetSet.size();
218 
219  std::string label = hidmanager.getSubdetid(myid,tTopo,true);
220  std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(label);
221  std::pair<std::string,int32_t> det_lay_pair = fold_organ.GetSubDetAndLayer(myid,tTopo,true);
222 
223  totnumrechitrphi[det_lay_pair.first] = totnumrechitrphi[det_lay_pair.first] + theDetSet.size();
224  //loop over rechits-rphi in the same subdetector
225  if(iLayerME != LayerMEsMap.end()){
226  for(auto const& rechit : theDetSet){
227  const GeomDetUnit * det = tracker.idToDetUnit(detid);
228  const StripGeomDetUnit * stripdet=(const StripGeomDetUnit*)(det);
229  const StripTopology &topol=(StripTopology&)stripdet->topology();
230  //analyze RecHits
231  rechitanalysis(rechit,topol,associate);
232  // fill the result in a histogram
233  fillME(iLayerME->second.meWclusrphi,rechitpro.clusiz);
234  fillME(iLayerME->second.meAdcrphi,rechitpro.cluchg);
235  fillME(iLayerME->second.mePosxrphi,rechitpro.x);
236  fillME(iLayerME->second.meResolxrphi,rechitpro.resolxx);
237  fillME(iLayerME->second.meNsimHitrphi,rechitpro.NsimHit);
238  if (rechitpro.NsimHit > 0) {
239  std::map<std::string, SubDetMEs>::iterator iSubDetME = SubDetMEsMap.find(det_lay_pair.first);
240  fillME(iSubDetME->second.meBunchrphi, rechitpro.bunch);
241  if (rechitpro.bunch == 0) fillME(iSubDetME->second.meEventrphi, rechitpro.event);
242  }
243  if ( rechitpro.resx != -999999. || rechitpro.pullMF != -999999. || rechitpro.chi2 != -999999. ){
244  fillME(iLayerME->second.meResrphi,rechitpro.resx);
245  fillME(iLayerME->second.mePullLFrphi,rechitpro.resx/sqrt(rechitpro.resolxx));
246  fillME(iLayerME->second.mePullMFrphi,rechitpro.pullMF);
247  fillME(iLayerME->second.meChi2rphi,rechitpro.chi2);
248  }
249  }
250  }
251  }
252 
253  // start loops over detectors with detected rechitsstereo
254  for (auto const& theDetSet : *rechitsstereo) {
255  DetId detid = theDetSet.detId();
256  uint32_t myid= detid.rawId();
257  totrechitstereo += theDetSet.size();
258 
259  std::string label = hidmanager.getSubdetid(myid,tTopo,true);
260  std::map<std::string, StereoAndMatchedMEs>::iterator iStereoAndMatchedME = StereoAndMatchedMEsMap.find(label);
261  std::pair<std::string,int32_t> det_lay_pair = fold_organ.GetSubDetAndLayer(myid,tTopo,true);
262 
263  totnumrechitstereo[det_lay_pair.first] = totnumrechitstereo[det_lay_pair.first] + theDetSet.size();
264  //loop over rechits-stereo in the same subdetector
265  if(iStereoAndMatchedME != StereoAndMatchedMEsMap.end()){
266  for (auto const& rechit : theDetSet) {
267  const GeomDetUnit * det = tracker.idToDetUnit(detid);
268  const StripGeomDetUnit * stripdet=(const StripGeomDetUnit*)(det);
269  const StripTopology &topol=(StripTopology&)stripdet->topology();
270  //analyze RecHits
271  rechitanalysis(rechit,topol,associate);
272  // fill the result in a histogram
273  fillME(iStereoAndMatchedME->second.meWclusStereo,rechitpro.clusiz);
274  fillME(iStereoAndMatchedME->second.meAdcStereo,rechitpro.cluchg);
275  fillME(iStereoAndMatchedME->second.mePosxStereo,rechitpro.x);
276  fillME(iStereoAndMatchedME->second.meResolxStereo,sqrt(rechitpro.resolxx));
277  fillME(iStereoAndMatchedME->second.meNsimHitStereo,rechitpro.NsimHit);
278  if (rechitpro.NsimHit > 0) {
279  std::map<std::string, SubDetMEs>::iterator iSubDetME = SubDetMEsMap.find(det_lay_pair.first);
280  fillME(iSubDetME->second.meBunchStereo, rechitpro.bunch);
281  if (rechitpro.bunch == 0) fillME(iSubDetME->second.meEventStereo, rechitpro.event);
282  }
283  if ( rechitpro.resx != -999999. || rechitpro.pullMF != -999999. || rechitpro.chi2 != -999999. ){
284  fillME(iStereoAndMatchedME->second.meResStereo,rechitpro.resx);
285  fillME(iStereoAndMatchedME->second.mePullLFStereo,rechitpro.resx/sqrt(rechitpro.resolxx));
286  fillME(iStereoAndMatchedME->second.mePullMFStereo,rechitpro.pullMF);
287  fillME(iStereoAndMatchedME->second.meChi2Stereo,rechitpro.chi2);
288  }
289  }
290  }
291  }
292 
293  // start loops over detectors with detected rechitmatched
294  for (auto const & theDetSet : *rechitsmatched) {
295  DetId detid = theDetSet.detId();
296  uint32_t myid = detid.rawId();
297  totrechitmatched += theDetSet.size();
298 
299  std::string label = hidmanager.getSubdetid(myid,tTopo,true);
300  std::map<std::string, StereoAndMatchedMEs>::iterator iStereoAndMatchedME = StereoAndMatchedMEsMap.find(label);
301  std::pair<std::string,int32_t> det_lay_pair = fold_organ.GetSubDetAndLayer(myid,tTopo,true);
302 
303  totnumrechitmatched[det_lay_pair.first] = totnumrechitmatched[det_lay_pair.first] + theDetSet.size();
304  //loop over rechits-matched in the same subdetector
305  if(iStereoAndMatchedME != StereoAndMatchedMEsMap.end()){
306  for (auto const& rechit : theDetSet) {
307  const GluedGeomDet* gluedDet = (const GluedGeomDet*)tracker.idToDet(rechit.geographicalId());
308  //analyze RecHits
309  rechitanalysis_matched(rechit, gluedDet, associate);
310  // fill the result in a histogram
311  fillME(iStereoAndMatchedME->second.mePosxMatched,rechitpro.x);
312  fillME(iStereoAndMatchedME->second.mePosyMatched,rechitpro.y);
313  fillME(iStereoAndMatchedME->second.meResolxMatched,sqrt(rechitpro.resolxx));
314  fillME(iStereoAndMatchedME->second.meResolyMatched,sqrt(rechitpro.resolyy));
315  fillME(iStereoAndMatchedME->second.meNsimHitMatched,rechitpro.NsimHit);
316  if (rechitpro.NsimHit > 0) {
317  std::map<std::string, SubDetMEs>::iterator iSubDetME = SubDetMEsMap.find(det_lay_pair.first);
318  fillME(iSubDetME->second.meBunchMatched, rechitpro.bunch);
319  if (rechitpro.bunch == 0) fillME(iSubDetME->second.meEventMatched, rechitpro.event);
320  }
321  if ( rechitpro.resx != -999999. || rechitpro.resy != -999999. || rechitpro.chi2 != -999999. ){
322  fillME(iStereoAndMatchedME->second.meResxMatched,rechitpro.resx);
323  fillME(iStereoAndMatchedME->second.meResyMatched,rechitpro.resy);
324  fillME(iStereoAndMatchedME->second.meChi2Matched,rechitpro.chi2);
325  }
326  }
327  }
328  }//End of loops over detectors
329 
330  //now fill the cumulative histograms of the hits
331  for (std::vector<std::string>::iterator iSubdet = SubDetList_.begin(); iSubdet != SubDetList_.end(); ++iSubdet){
332  std::map<std::string, SubDetMEs>::iterator iSubDetME = SubDetMEsMap.find((*iSubdet));
333  fillME(iSubDetME->second.meNumrphi,totnumrechitrphi[(*iSubdet)]);
334  fillME(iSubDetME->second.meNumStereo,totnumrechitstereo[(*iSubdet)]);
335  fillME(iSubDetME->second.meNumMatched,totnumrechitmatched[(*iSubdet)]);
336  }
337 
338  fillME(totalMEs.meNumTotrphi,totrechitrphi);
339  fillME(totalMEs.meNumTotStereo,totrechitstereo);
340  fillME(totalMEs.meNumTotMatched,totrechitmatched);
341 }
342 
343 
344 //needed by to do the residual for matched hits
345 std::pair<LocalPoint,LocalVector> SiStripRecHitsValid::projectHit( const PSimHit& hit, const StripGeomDetUnit* stripDet,
346  const BoundPlane& plane)
347 {
348  // const StripGeomDetUnit* stripDet = dynamic_cast<const StripGeomDetUnit*>(hit.det());
349  //if (stripDet == nullptr) throw MeasurementDetException("HitMatcher hit is not on StripGeomDetUnit");
350 
351  const StripTopology& topol = stripDet->specificTopology();
352  GlobalPoint globalpos= stripDet->surface().toGlobal(hit.localPosition());
353  LocalPoint localHit = plane.toLocal(globalpos);
354  //track direction
355  LocalVector locdir=hit.localDirection();
356  //rotate track in new frame
357 
358  GlobalVector globaldir= stripDet->surface().toGlobal(locdir);
359  LocalVector dir=plane.toLocal(globaldir);
360  double scale = -localHit.z() / dir.z();
361 
362  LocalPoint projectedPos = localHit + scale*dir;
363 
364  double selfAngle = topol.stripAngle( topol.strip( hit.localPosition()));
365 
366  LocalVector stripDir( sin(selfAngle), cos(selfAngle), 0); // vector along strip in hit frame
367 
368  LocalVector localStripDir( plane.toLocal(stripDet->surface().toGlobal( stripDir)));
369 
370  return std::pair<LocalPoint,LocalVector>( projectedPos, localStripDir);
371 }
372 //--------------------------------------------------------------------------------------------
374 
375  rechitpro.resx = -999999.; rechitpro.resy = -999999.; rechitpro.pullMF = -999999.;
376  rechitpro.chi2 = -999999.; rechitpro.bunch = -999999.; rechitpro.event = -999999.;
377 
380  MeasurementPoint Mposition = topol.measurementPosition(position);
381  MeasurementError Merror = topol.measurementError(position,error);
382  const auto & amplitudes=(rechit.cluster())->amplitudes();
383  int totcharge=0;
384  for(auto ia : amplitudes){
385  totcharge += ia;
386  }
387  rechitpro.x = position.x();
388  rechitpro.y = position.y();
389  //rechitpro.z = position.z();
390  rechitpro.resolxx = error.xx();
391  //rechitpro.resolxy = error.xy();
392  rechitpro.resolyy = error.yy();
393  rechitpro.clusiz = amplitudes.size();
394  rechitpro.cluchg = totcharge;
395 
396  auto const & matched = associate.associateHit(rechit);
397  rechitpro.NsimHit = matched.size();
398 
399  if(!matched.empty()){
400 
401  float mindist = std::numeric_limits<float>::max();
402  float dist = std::numeric_limits<float>::max();
403  PSimHit const * closest = nullptr;
404 
405  for(auto const &m : matched){
406  dist = fabs(rechitpro.x - m.localPosition().x());
407  if(dist<mindist){
408  mindist = dist;
409  closest = &m;
410  }
411  }
412  rechitpro.bunch = closest->eventId().bunchCrossing();
413  rechitpro.event = closest->eventId().event();
414  rechitpro.resx = rechitpro.x - closest->localPosition().x();
415  rechitpro.pullMF = (Mposition.x() - (topol.measurementPosition(closest->localPosition())).x())/sqrt(Merror.uu());
416 
417  //chi2test compare rechit errors with the simhit position ( using null matrix for the simhit).
418  //Can spot problems in the geometry better than a simple residual. (thanks to BorisM)
419  AlgebraicVector rhparameters(2);//= rechit.parameters();
420  rhparameters[0] = position.x();
421  rhparameters[1] = position.y();
422  AlgebraicVector shparameters(2);
423  shparameters[0] = closest->localPosition().x();
424  shparameters[1] = closest->localPosition().y();
425  AlgebraicVector r(rhparameters - shparameters);
426  AlgebraicSymMatrix R(2);// = rechit.parametersError();
427  R[0][0] = error.xx();
428  R[0][1] = error.xy();
429  R[1][1] = error.yy();
430  int ierr;
431  R.invert(ierr); // if (ierr != 0) throw exception;
432  float est = R.similarity(r);
433  rechitpro.chi2 = est;
434  }
435 
436 }
437 
438 
439 //--------------------------------------------------------------------------------------------
441 
442  rechitpro.resx = -999999.; rechitpro.resy = -999999.; rechitpro.pullMF = -999999.;
443  rechitpro.chi2 = -999999.; rechitpro.bunch = -999999.; rechitpro.event = -999999.;
444  rechitpro.clusiz = -999999.; rechitpro.cluchg = -999999.;
445 
448 
449  rechitpro.x = position.x();
450  rechitpro.y = position.y();
451  //rechitpro.z = position.z();
452  rechitpro.resolxx = error.xx();
453  //rechitpro.resolxy = error.xy();
454  rechitpro.resolyy = error.yy();
455 
456  auto const & matched = associate.associateHit(rechit);
457  rechitpro.NsimHit = matched.size();
458 
459  if(matched.empty()) return;
460  float mindist = std::numeric_limits<float>::max();
461  float dist = std::numeric_limits<float>::max();
462  float dist2 = std::numeric_limits<float>::max();
463  float distx = std::numeric_limits<float>::max();
464  float disty = std::numeric_limits<float>::max();
465  PSimHit const * closest = nullptr;
466  std::pair<LocalPoint,LocalVector> closestPair;
467 
468  const StripGeomDetUnit* partnerstripdet =(StripGeomDetUnit*) gluedDet->stereoDet();
469  std::pair<LocalPoint,LocalVector> hitPair;
470 
471  for(auto const &m : matched){
472  SiStripDetId hitDetId(m.detUnitId());
473  if (hitDetId.stereo()) { // project from the stereo sensor
474  //project simhit;
475  hitPair= projectHit(m,partnerstripdet,gluedDet->surface());
476  distx = rechitpro.x - hitPair.first.x();
477  disty = rechitpro.y - hitPair.first.y();
478  dist2 = distx*distx+disty*disty;
479  dist = sqrt(dist2);
480  if(dist<mindist){
481  mindist = dist;
482  closestPair = hitPair;
483  closest = &m;
484  }
485  }
486  }
487  if (!closest) return;
488  rechitpro.bunch = closest->eventId().bunchCrossing();
489  rechitpro.event = closest->eventId().event();
490  rechitpro.resx = rechitpro.x - closestPair.first.x();
491  rechitpro.resy = rechitpro.y - closestPair.first.y();
492 
493  //chi2test compare rechit errors with the simhit position ( using null matrix for the simhit).
494  //Can spot problems in the geometry better than a simple residual. (thanks to BorisM)
495  AlgebraicVector rhparameters(2);//= rechit.parameters();
496  rhparameters[0] = position.x();
497  rhparameters[1] = position.y();
498  LocalPoint sh = closestPair.first;
499  AlgebraicVector shparameters(2);
500  shparameters[0] = sh.x();
501  shparameters[1] = sh.y();
502  AlgebraicVector r(rhparameters - shparameters);
503  AlgebraicSymMatrix R(2);// = rechit.parametersError();
504  R[0][0] = error.xx();
505  R[0][1] = error.xy();
506  R[1][1] = error.yy();
507  int ierr;
508  R.invert(ierr); // if (ierr != 0) throw exception;
509  float est = R.similarity(r);
510  rechitpro.chi2 = est;
511 
512 
513 
514 }
515 
516 //--------------------------------------------------------------------------------------------
518 
519  //Retrieve tracker topology from geometry
520  edm::ESHandle<TrackerTopology> tTopoHandle;
521  es.get<TrackerTopologyRcd>().get(tTopoHandle);
522  const TrackerTopology* const tTopo = tTopoHandle.product();
523 
524  // take from eventSetup the SiStripDetCabling object - here will use SiStripDetControl later on
526 
527  // get list of active detectors from SiStripDetCabling
528  std::vector<uint32_t> activeDets;
530 
531  SiStripSubStructure substructure;
532 
533  SiStripFolderOrganizer folder_organizer;
534  // folder_organizer.setSiStripFolderName(topFolderName_);
535  std::string curfold = topFolderName_;
536  folder_organizer.setSiStripFolderName(curfold);
537  folder_organizer.setSiStripFolder();
538 
539  createTotalMEs(ibooker);
540  // loop over detectors and book MEs
541  edm::LogInfo("SiStripTkRecHits|SiStripRecHitsValid")<<"nr. of activeDets: "<<activeDets.size();
542  const std::string& tec = "TEC", tid = "TID", tob = "TOB", tib = "TIB";
543  for(auto detid_iterator=activeDets.begin(), detid_end=activeDets.end(); detid_iterator!=detid_end; ++detid_iterator){
544  uint32_t detid = (*detid_iterator);
545  // remove any eventual zero elements - there should be none, but just in case
546  if(detid == 0) {
547  activeDets.erase(detid_iterator);
548  continue;
549  }
550 
551  // Create Layer Level MEs
552  std::pair<std::string,int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detid,tTopo,true);
553  SiStripHistoId hidmanager;
554  std::string label = hidmanager.getSubdetid(detid,tTopo,true);
555 
556  if(LayerMEsMap.find(label)==LayerMEsMap.end()) {
557 
558  // get detids for the layer
559  // Keep in mind that when we are on the TID or TEC we deal with rings not wheel
560  int32_t lnumber = det_layer_pair.second;
561  const std::string& lname = det_layer_pair.first;
562  std::vector<uint32_t> layerDetIds;
563  if (lname == tec) {
564  if (lnumber > 0) {
565  substructure.getTECDetectors(activeDets,layerDetIds,2,0,0,0,abs(lnumber),0);
566  } else if (lnumber < 0) {
567  substructure.getTECDetectors(activeDets,layerDetIds,1,0,0,0,abs(lnumber),0);
568  }
569  } else if (lname == tid) {
570  if (lnumber > 0) {
571  substructure.getTIDDetectors(activeDets,layerDetIds,2,0,abs(lnumber),0);
572  } else if (lnumber < 0) {
573  substructure.getTIDDetectors(activeDets,layerDetIds,1,0,abs(lnumber),0);
574  }
575  } else if (lname == tob) {
576  substructure.getTOBDetectors(activeDets,layerDetIds,lnumber,0,0);
577  } else if (lname == tib) {
578  substructure.getTIBDetectors(activeDets,layerDetIds,lnumber,0,0,0);
579  }
580  LayerDetMap[label] = layerDetIds;
581 
582  // book Layer MEs
583  folder_organizer.setLayerFolder(detid,tTopo,det_layer_pair.second,true);
584  createLayerMEs(ibooker,label);
585  }
586  // book sub-detector plots
587  if (SubDetMEsMap.find(det_layer_pair.first) == SubDetMEsMap.end()){
588  auto sdet_pair = folder_organizer.getSubDetFolderAndTag(detid, tTopo);
589  ibooker.setCurrentFolder(sdet_pair.first);
590  createSubDetMEs(ibooker,det_layer_pair.first);
591  }
592  //Create StereoAndMatchedMEs
593  if(StereoAndMatchedMEsMap.find(label)==StereoAndMatchedMEsMap.end()) {
594 
595  // get detids for the stereo and matched layer. We are going to need a bool for these layers
596  bool isStereo = false;
597  // Keep in mind that when we are on the TID or TEC we deal with rings not wheel
598  std::vector<uint32_t> stereoandmatchedDetIds;
599  int32_t stereolnumber = det_layer_pair.second;
600  const std::string& stereolname = det_layer_pair.first;
601  if ( stereolname == tec && (tTopo->tecIsStereo(detid)) ) {
602  if ( stereolnumber > 0 ) {
603  substructure.getTECDetectors(activeDets,stereoandmatchedDetIds,2,0,0,0,abs(stereolnumber),1);
604  isStereo = true;
605  } else if ( stereolnumber < 0 ) {
606  substructure.getTECDetectors(activeDets,stereoandmatchedDetIds,1,0,0,0,abs(stereolnumber),1);
607  isStereo = true;
608  }
609  } else if ( stereolname == tid && (tTopo->tidIsStereo(detid)) ) {
610  if ( stereolnumber > 0 ) {
611  substructure.getTIDDetectors(activeDets,stereoandmatchedDetIds,2,0,abs(stereolnumber),1);
612  isStereo = true;
613  } else if ( stereolnumber < 0 ) {
614  substructure.getTIDDetectors(activeDets,stereoandmatchedDetIds,1,0,abs(stereolnumber),1);
615  isStereo = true;
616  }
617  } else if ( stereolname == tob && (tTopo->tobIsStereo(detid)) ) {
618  substructure.getTOBDetectors(activeDets,stereoandmatchedDetIds,stereolnumber,0,0);
619  isStereo = true;
620  } else if ( stereolname == tib && (tTopo->tibIsStereo(detid)) ) {
621  substructure.getTIBDetectors(activeDets,stereoandmatchedDetIds,stereolnumber,0,0,0);
622  isStereo = true;
623  }
624 
625  StereoAndMatchedDetMap[label] = stereoandmatchedDetIds;
626 
627  if(isStereo){
628  //book StereoAndMatched MEs
629  folder_organizer.setLayerFolder(detid,tTopo,det_layer_pair.second,true);
630  //Create the Monitor Elements only when we have a stereo module
631  createStereoAndMatchedMEs(ibooker,label);
632  }
633  }
634  }//end of loop over detectors
635 }
636 //------------------------------------------------------------------------------------------
638 {
639  totalMEs.meNumTotrphi = nullptr;
640  totalMEs.meNumTotStereo = nullptr;
641  totalMEs.meNumTotMatched = nullptr;
642 
643  //NumTotrphi
644  if(switchNumTotrphi) {
645  totalMEs.meNumTotrphi = bookME1D(ibooker,"TH1NumTotrphi", "TH1NumTotrphi" ,"Num of RecHits rphi");
646  totalMEs.meNumTotrphi->setAxisTitle("Total number of RecHits");
647  }
648  //NumTotStereo
649  if(switchNumTotStereo) {
650  totalMEs.meNumTotStereo = bookME1D(ibooker,"TH1NumTotStereo", "TH1NumTotStereo","Num of RecHits stereo");
651  totalMEs.meNumTotStereo ->setAxisTitle("Total number of RecHits (stereo)");
652  }
653  //NumTotMatched
654  if(switchNumTotMatched) {
655  totalMEs.meNumTotMatched = bookME1D(ibooker,"TH1NumTotMatched","TH1NumTotMatched","Num of RecHits matched");
656  totalMEs.meNumTotMatched->setAxisTitle("Total number of matched RecHits");
657  }
658 
659 }
660 //------------------------------------------------------------------------------------------
662 {
663  SiStripHistoId hidmanager;
664  LayerMEs layerMEs;
665 
666  layerMEs.meWclusrphi = nullptr;
667  layerMEs.meAdcrphi = nullptr;
668  layerMEs.mePosxrphi = nullptr;
669  layerMEs.meResolxrphi = nullptr;
670  layerMEs.meResrphi = nullptr;
671  layerMEs.mePullLFrphi = nullptr;
672  layerMEs.mePullMFrphi = nullptr;
673  layerMEs.meChi2rphi = nullptr;
674  layerMEs.meNsimHitrphi = nullptr;
675 
676  //Wclusrphi
677  if(switchWclusrphi) {
678  layerMEs.meWclusrphi = bookME1D(ibooker,"TH1Wclusrphi", hidmanager.createHistoLayer("Wclus_rphi","layer",label,"").c_str() ,"Cluster Width - Number of strips that belong to the RecHit cluster");
679  layerMEs.meWclusrphi->setAxisTitle("Cluster Width [nr strips] in "+ label);
680  }
681  //Adcrphi
682  if(switchAdcrphi) {
683  layerMEs.meAdcrphi = bookME1D(ibooker,"TH1Adcrphi", hidmanager.createHistoLayer("Adc_rphi","layer",label,"").c_str() ,"RecHit Cluster Charge");
684  layerMEs.meAdcrphi->setAxisTitle("cluster charge [ADC] in " + label);
685  }
686  //Posxrphi
687  if(switchPosxrphi) {
688  layerMEs.mePosxrphi = bookME1D(ibooker,"TH1Posxrphi", hidmanager.createHistoLayer("Posx_rphi","layer",label,"").c_str() ,"RecHit x coord.");
689  layerMEs.mePosxrphi->setAxisTitle("x RecHit coord. (local frame) in " + label);
690  }
691  //Resolxrphi
692  if(switchResolxrphi) {
693  layerMEs.meResolxrphi = bookME1D(ibooker,"TH1Resolxrphi", hidmanager.createHistoLayer("Resolx_rphi","layer",label,"").c_str() ,"RecHit resol(x) coord."); //<resolor>~20micron
694  layerMEs.meResolxrphi->setAxisTitle("resol(x) RecHit coord. (local frame) in " + label);
695  }
696  //Resrphi
697  if(switchResrphi) {
698  layerMEs.meResrphi = bookME1D(ibooker,"TH1Resrphi", hidmanager.createHistoLayer("Res_rphi","layer",label,"").c_str() ,"Residuals of the hit x coordinate");
699  layerMEs.meResrphi->setAxisTitle("RecHit Res(x) in " + label);
700  }
701  //PullLFrphi
702  if(switchPullLFrphi) {
703  layerMEs.mePullLFrphi = bookME1D(ibooker,"TH1PullLFrphi", hidmanager.createHistoLayer("Pull_LF_rphi","layer",label,"").c_str() ,"Pull distribution");
704  layerMEs.mePullLFrphi->setAxisTitle("Pull distribution (local frame) in " + label);
705  }
706  //PullMFrphi
707  if(switchPullMFrphi) {
708  layerMEs.mePullMFrphi = bookME1D(ibooker,"TH1PullMFrphi", hidmanager.createHistoLayer("Pull_MF_rphi","layer",label,"").c_str() ,"Pull distribution");
709  layerMEs.mePullMFrphi->setAxisTitle("Pull distribution (measurement frame) in " + label);
710  }
711  //Chi2rphi
712  if(switchChi2rphi) {
713  layerMEs.meChi2rphi = bookME1D(ibooker,"TH1Chi2rphi", hidmanager.createHistoLayer("Chi2_rphi","layer",label,"").c_str() ,"RecHit Chi2 test");
714  layerMEs.meChi2rphi->setAxisTitle("RecHit Chi2 test in " + label);
715  }
716  //NsimHitrphi
717  if(switchNsimHitrphi) {
718  layerMEs.meNsimHitrphi = bookME1D(ibooker,"TH1NsimHitrphi", hidmanager.createHistoLayer("NsimHit_rphi","layer",label,"").c_str() ,"No. of assoc. simHits");
719  layerMEs.meNsimHitrphi->setAxisTitle("Number of assoc. simHits in " + label);
720  }
721 
722  LayerMEsMap[label]=layerMEs;
723 
724 }
725 //------------------------------------------------------------------------------------------
727 {
728  SiStripHistoId hidmanager;
729  StereoAndMatchedMEs stereoandmatchedMEs;
730 
731  stereoandmatchedMEs.meWclusStereo = nullptr;
732  stereoandmatchedMEs.meAdcStereo = nullptr;
733  stereoandmatchedMEs.mePosxStereo = nullptr;
734  stereoandmatchedMEs.meResolxStereo = nullptr;
735  stereoandmatchedMEs.meResStereo = nullptr;
736  stereoandmatchedMEs.mePullLFStereo = nullptr;
737  stereoandmatchedMEs.mePullMFStereo = nullptr;
738  stereoandmatchedMEs.meChi2Stereo = nullptr;
739  stereoandmatchedMEs.meNsimHitStereo = nullptr;
740  stereoandmatchedMEs.mePosxMatched = nullptr;
741  stereoandmatchedMEs.mePosyMatched = nullptr;
742  stereoandmatchedMEs.meResolxMatched = nullptr;
743  stereoandmatchedMEs.meResolyMatched = nullptr;
744  stereoandmatchedMEs.meResxMatched = nullptr;
745  stereoandmatchedMEs.meResyMatched = nullptr;
746  stereoandmatchedMEs.meChi2Matched = nullptr;
747  stereoandmatchedMEs.meNsimHitMatched = nullptr;
748 
749  //WclusStereo
750  if(switchWclusStereo) {
751  stereoandmatchedMEs.meWclusStereo = bookME1D(ibooker,"TH1WclusStereo", hidmanager.createHistoLayer("Wclus_stereo","layer",label,"").c_str() ,"Cluster Width - Number of strips that belong to the RecHit cluster");
752  stereoandmatchedMEs.meWclusStereo->setAxisTitle("Cluster Width [nr strips] in stereo modules in "+ label);
753  }
754  //AdcStereo
755  if(switchAdcStereo) {
756  stereoandmatchedMEs.meAdcStereo = bookME1D(ibooker,"TH1AdcStereo", hidmanager.createHistoLayer("Adc_stereo","layer",label,"").c_str() ,"RecHit Cluster Charge");
757  stereoandmatchedMEs.meAdcStereo->setAxisTitle("cluster charge [ADC] in stereo modules in " + label);
758  }
759  //PosxStereo
760  if(switchPosxStereo) {
761  stereoandmatchedMEs.mePosxStereo = bookME1D(ibooker,"TH1PosxStereo", hidmanager.createHistoLayer("Posx_stereo","layer",label,"").c_str() ,"RecHit x coord.");
762  stereoandmatchedMEs.mePosxStereo->setAxisTitle("x RecHit coord. (local frame) in stereo modules in " + label);
763  }
764  //ResolxStereo
765  if(switchResolxStereo) {
766  stereoandmatchedMEs.meResolxStereo = bookME1D(ibooker,"TH1ResolxStereo", hidmanager.createHistoLayer("Resolx_stereo","layer",label,"").c_str() ,"RecHit resol(x) coord.");
767  stereoandmatchedMEs.meResolxStereo->setAxisTitle("resol(x) RecHit coord. (local frame) in stereo modules in " + label);
768  }
769  //ResStereo
770  if(switchResStereo) {
771  stereoandmatchedMEs.meResStereo = bookME1D(ibooker,"TH1ResStereo", hidmanager.createHistoLayer("Res_stereo","layer",label,"").c_str() ,"Residuals of the hit x coordinate");
772  stereoandmatchedMEs.meResStereo->setAxisTitle("RecHit Res(x) in stereo modules in " + label);
773  }
774  //PullLFStereo
775  if(switchPullLFStereo) {
776  stereoandmatchedMEs.mePullLFStereo = bookME1D(ibooker,"TH1PullLFStereo", hidmanager.createHistoLayer("Pull_LF_stereo","layer",label,"").c_str() ,"Pull distribution");
777  stereoandmatchedMEs.mePullLFStereo->setAxisTitle("Pull distribution (local frame) in stereo modules in " + label);
778  }
779  //PullMFStereo
780  if(switchPullMFStereo) {
781  stereoandmatchedMEs.mePullMFStereo = bookME1D(ibooker,"TH1PullMFStereo", hidmanager.createHistoLayer("Pull_MF_stereo","layer",label,"").c_str() ,"Pull distribution");
782  stereoandmatchedMEs.mePullMFStereo->setAxisTitle("Pull distribution (measurement frame) in stereo modules in " + label);
783  }
784  //Chi2Stereo
785  if(switchChi2Stereo) {
786  stereoandmatchedMEs.meChi2Stereo = bookME1D(ibooker,"TH1Chi2Stereo", hidmanager.createHistoLayer("Chi2_stereo","layer",label,"").c_str() ,"RecHit Chi2 test");
787  stereoandmatchedMEs.meChi2Stereo->setAxisTitle("RecHit Chi2 test in stereo modules in " + label);
788  }
789  //NsimHitStereo
790  if(switchNsimHitStereo) {
791  stereoandmatchedMEs.meNsimHitStereo = bookME1D(ibooker,"TH1NsimHitStereo", hidmanager.createHistoLayer("NsimHit_stereo","layer",label,"").c_str() ,"No. of assoc. simHits");
792  stereoandmatchedMEs.meNsimHitStereo->setAxisTitle("Number of assoc. simHits in stereo modules in " + label);
793  }
794  //PosxMatched
795  if(switchPosxMatched) {
796  stereoandmatchedMEs.mePosxMatched = bookME1D(ibooker,"TH1PosxMatched", hidmanager.createHistoLayer("Posx_matched","layer",label,"").c_str() ,"RecHit x coord.");
797  stereoandmatchedMEs.mePosxMatched->setAxisTitle("x coord. matched RecHit (local frame) in " + label);
798  }
799  //PosyMatched
800  if(switchPosyMatched) {
801  stereoandmatchedMEs.mePosyMatched = bookME1D(ibooker,"TH1PosyMatched", hidmanager.createHistoLayer("Posy_matched","layer",label,"").c_str() ,"RecHit y coord.");
802  stereoandmatchedMEs.mePosyMatched->setAxisTitle("y coord. matched RecHit (local frame) in " + label);
803  }
804  //ResolxMatched
805  if(switchResolxMatched) {
806  stereoandmatchedMEs.meResolxMatched = bookME1D(ibooker,"TH1ResolxMatched", hidmanager.createHistoLayer("Resolx_matched","layer",label,"").c_str() ,"RecHit resol(x) coord.");
807  stereoandmatchedMEs.meResolxMatched->setAxisTitle("resol(x) coord. matched RecHit (local frame) in " + label);
808  }
809  //ResolyMatched
810  if(switchResolyMatched) {
811  stereoandmatchedMEs.meResolyMatched = bookME1D(ibooker,"TH1ResolyMatched", hidmanager.createHistoLayer("Resoly_matched","layer",label,"").c_str() ,"RecHit resol(y) coord.");
812  stereoandmatchedMEs.meResolyMatched->setAxisTitle("resol(y) coord. matched RecHit (local frame) in " + label);
813  }
814  //ResxMatched
815  if(switchResxMatched) {
816  stereoandmatchedMEs.meResxMatched = bookME1D(ibooker,"TH1ResxMatched", hidmanager.createHistoLayer("Resx_matched","layer",label,"").c_str() ,"Residuals of the hit x coord.");
817  stereoandmatchedMEs.meResxMatched->setAxisTitle("Res(x) in matched RecHit in " + label);
818  }
819  //ResyMatched
820  if(switchResyMatched) {
821  stereoandmatchedMEs.meResyMatched = bookME1D(ibooker,"TH1ResyMatched", hidmanager.createHistoLayer("Resy_matched","layer",label,"").c_str() ,"Residuals of the hit y coord.");
822  stereoandmatchedMEs.meResyMatched->setAxisTitle("Res(y) in matched RecHit in " + label);
823  }
824  //Chi2Matched
825  if(switchChi2Matched) {
826  stereoandmatchedMEs.meChi2Matched = bookME1D(ibooker,"TH1Chi2Matched", hidmanager.createHistoLayer("Chi2_matched","layer",label,"").c_str() ,"RecHit Chi2 test");
827  stereoandmatchedMEs.meChi2Matched->setAxisTitle("Matched RecHit Chi2 test in " + label);
828  }
829  //NsimHitMatched
831  stereoandmatchedMEs.meNsimHitMatched = bookME1D(ibooker,"TH1NsimHitMatched", hidmanager.createHistoLayer("NsimHit_matched","layer",label,"").c_str() ,"No. of assoc. simHits");
832  stereoandmatchedMEs.meNsimHitMatched->setAxisTitle("Number of assoc. simHits in " + label);
833  }
834 
835  StereoAndMatchedMEsMap[label]=stereoandmatchedMEs;
836 
837 }
838 //------------------------------------------------------------------------------------------
840 
841  SubDetMEs subdetMEs;
842  subdetMEs.meNumrphi = nullptr;
843  subdetMEs.meBunchrphi = nullptr;
844  subdetMEs.meEventrphi = nullptr;
845  subdetMEs.meNumStereo = nullptr;
846  subdetMEs.meBunchStereo = nullptr;
847  subdetMEs.meEventStereo = nullptr;
848  subdetMEs.meNumMatched = nullptr;
849  subdetMEs.meBunchMatched = nullptr;
850  subdetMEs.meEventMatched = nullptr;
851 
853  //Numrphi
854  if (switchNumrphi){
855  HistoName = "TH1Numrphi__" + label;
856  subdetMEs.meNumrphi = bookME1D(ibooker,"TH1Numrphi",HistoName.c_str(),"Num of RecHits");
857  subdetMEs.meNumrphi->setAxisTitle("Total number of RecHits in "+ label);
858  }
859  //Bunchrphi
860  if(switchBunchrphi) {
861  HistoName = "TH1Bunchrphi__" + label;
862  subdetMEs.meBunchrphi = bookME1D(ibooker,"TH1Bunchrphi",HistoName.c_str(),"Bunch Crossing");
863  subdetMEs.meBunchrphi->setAxisTitle("Bunch crossing in " + label);
864  }
865  //Eventrphi
866  if(switchEventrphi) {
867  HistoName = "TH1Eventrphi__" + label;
868  subdetMEs.meEventrphi = bookME1D(ibooker,"TH1Eventrphi",HistoName.c_str(),"Event (in-time bunch)");
869  subdetMEs.meEventrphi->setAxisTitle("Event (in-time bunch) in " + label);
870  }
871  //NumStereo
872  if (switchNumStereo){
873  HistoName = "TH1NumStereo__" + label;
874  subdetMEs.meNumStereo = bookME1D(ibooker,"TH1NumStereo",HistoName.c_str(),"Num of RecHits in stereo modules");
875  subdetMEs.meNumStereo->setAxisTitle("Total number of RecHits, stereo modules in "+ label);
876  }
877  //BunchStereo
878  if(switchBunchStereo) {
879  HistoName = "TH1BunchStereo__" + label;
880  subdetMEs.meBunchStereo = bookME1D(ibooker,"TH1BunchStereo",HistoName.c_str(),"Bunch Crossing");
881  subdetMEs.meBunchStereo->setAxisTitle("Bunch crossing, stereo modules in " + label);
882  }
883  //EventStereo
884  if(switchEventStereo) {
885  HistoName = "TH1EventStereo__" + label;
886  subdetMEs.meEventStereo = bookME1D(ibooker,"TH1EventStereo",HistoName.c_str(),"Event (in-time bunch)");
887  subdetMEs.meEventStereo->setAxisTitle("Event (in-time bunch), stereo modules in " + label);
888  }
889  //NumMatched
890  if (switchNumMatched){
891  HistoName = "TH1NumMatched__" + label;
892  subdetMEs.meNumMatched = bookME1D(ibooker,"TH1NumMatched",HistoName.c_str(),"Num of matched RecHits" );
893  subdetMEs.meNumMatched->setAxisTitle("Total number of matched RecHits in "+ label);
894  }
895  //BunchMatched
896  if(switchBunchMatched) {
897  HistoName = "TH1BunchMatched__" + label;
898  subdetMEs.meBunchMatched = bookME1D(ibooker,"TH1BunchMatched",HistoName.c_str(),"Bunch Crossing");
899  subdetMEs.meBunchMatched->setAxisTitle("Bunch crossing, matched RecHits in " + label);
900  }
901  //EventMatched
902  if(switchEventMatched) {
903  HistoName = "TH1EventMatched__" + label;
904  subdetMEs.meEventMatched = bookME1D(ibooker,"TH1EventMatched",HistoName.c_str(),"Event (in-time bunch)");
905  subdetMEs.meEventMatched->setAxisTitle("Event (in-time bunch), matched RecHits in " + label);
906  }
907 
908  SubDetMEsMap[label]=subdetMEs;
909 }
910 //------------------------------------------------------------------------------------------
911 inline MonitorElement* SiStripRecHitsValid::bookME1D(DQMStore::IBooker & ibooker, const char* ParameterSetLabel, const char* HistoName, const char* HistoTitle)
912 {
914  return ibooker.book1D(HistoName,HistoTitle,
915  parameters.getParameter<int32_t>("Nbinx"),
916  parameters.getParameter<double>("xmin"),
917  parameters.getParameter<double>("xmax")
918  );
919 }
920 
921 //define this as a plug-in
923 
RunNumber_t run() const
Definition: EventID.h:39
RecHitProperties rechitpro
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
std::vector< std::string > SubDetList_
float xx() const
Definition: LocalError.h:24
void rechitanalysis_matched(SiStripMatchedRecHit2D const rechit, const GluedGeomDet *gluedDet, TrackerHitAssociator &associate)
void createStereoAndMatchedMEs(DQMStore::IBooker &ibooker, std::string label)
int event() const
get the contents of the subdetector field (should be protected?)
void addActiveDetectorsRawIds(std::vector< uint32_t > &) const
void setSiStripFolderName(std::string name)
LocalError localPositionError() const final
void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &es) override
std::pair< const std::string, const char * > getSubDetFolderAndTag(const uint32_t &detid, const TrackerTopology *tTopo)
bool tobIsStereo(const DetId &id) const
std::map< std::string, std::vector< uint32_t > > LayerDetMap
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
void createSubDetMEs(DQMStore::IBooker &ibooker, std::string label)
TrackerHitAssociator::Config trackerHitAssociatorConfig_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::map< std::string, SubDetMEs > SubDetMEsMap
void rechitanalysis(SiStripRecHit2D const rechit, const StripTopology &topol, TrackerHitAssociator &associate)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::map< std::string, StereoAndMatchedMEs > StereoAndMatchedMEsMap
T y() const
Definition: PV3DBase.h:63
virtual float strip(const LocalPoint &) const =0
void setLayerFolder(uint32_t rawdetid, const TrackerTopology *tTopo, int32_t layer=0, bool ring_flag=false)
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
void analyze(const edm::Event &e, const edm::EventSetup &c) override
bool tidIsStereo(const DetId &id) const
edm::EDGetTokenT< SiStripRecHit2DCollection > stereoRecHitsToken_
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
bool tecIsStereo(const DetId &id) const
float xy() const
Definition: LocalError.h:25
void getTOBDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tobDetRawIds, uint32_t layer=0, uint32_t bkw_frw=0, uint32_t rod=0) const
float yy() const
Definition: LocalError.h:26
Local3DPoint localPosition() const
Definition: PSimHit.h:44
virtual float stripAngle(float strip) const =0
T sqrt(T t)
Definition: SSEVec.h:18
int bunchCrossing() const
get the detector field from this detid
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
float uu() const
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ClusterRef cluster() const
void createMEs(DQMStore::IBooker &ibooker, const edm::EventSetup &es)
EncodedEventId eventId() const
Definition: PSimHit.h:105
edm::EDGetTokenT< SiStripRecHit2DCollection > rphiRecHitsToken_
std::string getSubdetid(uint32_t id, const TrackerTopology *tTopo, bool flag_ring)
MonitorElement * bookME1D(DQMStore::IBooker &ibooker, const char *ParameterSetLabel, const char *HistoName, const char *HistoTitle)
LocalVector localDirection() const
Obsolete. Same as momentumAtEntry().unit(), for backward compatibility.
Definition: PSimHit.h:52
SiStripRecHitsValid(const edm::ParameterSet &conf)
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
const Topology & topology() const override
Returns a reference to the strip proxy topology.
Definition: DetId.h:18
std::map< std::string, LayerMEs > LayerMEsMap
edm::ESHandle< SiStripDetCabling > SiStripDetCabling_
CLHEP::HepVector AlgebraicVector
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
std::map< std::string, std::vector< uint32_t > > StereoAndMatchedDetMap
const T & get() const
Definition: EventSetup.h:55
bool tibIsStereo(const DetId &id) const
std::pair< LocalPoint, LocalVector > projectHit(const PSimHit &hit, const StripGeomDetUnit *stripDet, const BoundPlane &plane)
std::string HistoName
std::pair< std::string, int32_t > GetSubDetAndLayer(const uint32_t &detid, const TrackerTopology *tTopo, bool ring_flag=false)
void getTECDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tecDetRawIds, uint32_t side=0, uint32_t wheel=0, uint32_t petal_bkw_frw=0, uint32_t petal=0, uint32_t ring=0, uint32_t ster=0) const
void createTotalMEs(DQMStore::IBooker &ibooker)
edm::ParameterSet conf_
edm::EventID id() const
Definition: EventBase.h:60
edm::EDGetTokenT< SiStripMatchedRecHit2DCollection > matchedRecHitsToken_
HLT enums.
static int position[264][3]
Definition: ReadPGInfo.cc:509
void beginJob(const edm::EventSetup &es)
void getTIBDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tibDetRawIds, uint32_t layer=0, uint32_t bkw_frw=0, uint32_t int_ext=0, uint32_t string=0) const
CLHEP::HepSymMatrix AlgebraicSymMatrix
const TrackerGeomDet * idToDet(DetId) const override
void createLayerMEs(DQMStore::IBooker &ibooker, std::string label)
void fillME(MonitorElement *ME, float value1)
std::vector< PSimHit > associateHit(const TrackingRecHit &thit) const
LocalPoint localPosition() const final
void getTIDDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tidDetRawIds, uint32_t side=0, uint32_t wheel=0, uint32_t ring=0, uint32_t ster=0) const
dbl *** dir
Definition: mlp_gen.cc:35
unsigned long long m_cacheID_
std::string createHistoLayer(std::string description, std::string id_type, std::string path, std::string flag)
virtual MeasurementError measurementError(const LocalPoint &, const LocalError &) const =0
T x() const
Definition: PV2DBase.h:45
T x() const
Definition: PV3DBase.h:62
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
T const * product() const
Definition: ESHandle.h:86
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
Definition: Run.h:43