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  LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
181 
182  //Retrieve tracker topology from geometry
183  edm::ESHandle<TrackerTopology> tTopoHandle;
184  es.get<TrackerTopologyRcd>().get(tTopoHandle);
185  const TrackerTopology* const tTopo = tTopoHandle.product();
186 
187  // Step A: Get Inputs
191  e.getByToken(matchedRecHitsToken_, rechitsmatched);
192  e.getByToken(rphiRecHitsToken_, rechitsrphi);
193  e.getByToken(stereoRecHitsToken_, rechitsstereo);
194 
195  //Variables in order to count total num of rechitrphi,rechitstereo, rechitmatched in subdetectors
196  std::map<std::string, int > totnumrechitrphi;
197  std::map<std::string, int > totnumrechitstereo;
198  std::map<std::string, int > totnumrechitmatched;
199  int totrechitrphi =0;
200  int totrechitstereo =0;
201  int totrechitmatched =0;
202 
204 
206  es.get<TrackerDigiGeometryRecord> ().get (pDD);
207  const TrackerGeometry &tracker(*pDD);
208 
209  SiStripHistoId hidmanager;
210  SiStripFolderOrganizer fold_organ;
211  for (auto const& theDetSet : *rechitsrphi) {
212  DetId detid = theDetSet.detId();
213  uint32_t myid = detid.rawId();
214  totrechitrphi += theDetSet.size();
215 
216  std::string label = hidmanager.getSubdetid(myid,tTopo,true);
217  std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(label);
218  std::pair<std::string,int32_t> det_lay_pair = fold_organ.GetSubDetAndLayer(myid,tTopo,true);
219 
220  totnumrechitrphi[det_lay_pair.first] = totnumrechitrphi[det_lay_pair.first] + theDetSet.size();
221  //loop over rechits-rphi in the same subdetector
222  if(iLayerME != LayerMEsMap.end()){
223  for(auto const& rechit : theDetSet){
224  const GeomDetUnit * det = tracker.idToDetUnit(detid);
225  const StripTopology &topol=static_cast<const StripGeomDetUnit*>(det)->specificTopology();
226  //analyze RecHits
227  rechitanalysis(rechit,topol,associate);
228  // fill the result in a histogram
229  fillME(iLayerME->second.meWclusrphi,rechitpro.clusiz);
230  fillME(iLayerME->second.meAdcrphi,rechitpro.cluchg);
231  fillME(iLayerME->second.mePosxrphi,rechitpro.x);
232  fillME(iLayerME->second.meResolxrphi,rechitpro.resolxx);
233  fillME(iLayerME->second.meNsimHitrphi,rechitpro.NsimHit);
234  if (rechitpro.NsimHit > 0) {
235  std::map<std::string, SubDetMEs>::iterator iSubDetME = SubDetMEsMap.find(det_lay_pair.first);
236  fillME(iSubDetME->second.meBunchrphi, rechitpro.bunch);
237  if (rechitpro.bunch == 0) fillME(iSubDetME->second.meEventrphi, rechitpro.event);
238  }
239  if ( rechitpro.resx != -999999. || rechitpro.pullMF != -999999. || rechitpro.chi2 != -999999. ){
240  fillME(iLayerME->second.meResrphi,rechitpro.resx);
241  fillME(iLayerME->second.mePullLFrphi,rechitpro.resx/sqrt(rechitpro.resolxx));
242  fillME(iLayerME->second.mePullMFrphi,rechitpro.pullMF);
243  fillME(iLayerME->second.meChi2rphi,rechitpro.chi2);
244  }
245  }
246  }
247  }
248 
249  // start loops over detectors with detected rechitsstereo
250  for (auto const& theDetSet : *rechitsstereo) {
251  DetId detid = theDetSet.detId();
252  uint32_t myid= detid.rawId();
253  totrechitstereo += theDetSet.size();
254 
255  std::string label = hidmanager.getSubdetid(myid,tTopo,true);
256  std::map<std::string, StereoAndMatchedMEs>::iterator iStereoAndMatchedME = StereoAndMatchedMEsMap.find(label);
257  std::pair<std::string,int32_t> det_lay_pair = fold_organ.GetSubDetAndLayer(myid,tTopo,true);
258 
259  totnumrechitstereo[det_lay_pair.first] = totnumrechitstereo[det_lay_pair.first] + theDetSet.size();
260  //loop over rechits-stereo in the same subdetector
261  if(iStereoAndMatchedME != StereoAndMatchedMEsMap.end()){
262  for (auto const& rechit : theDetSet) {
263  const GeomDetUnit * det = tracker.idToDetUnit(detid);
264  const StripTopology &topol=static_cast<const StripGeomDetUnit*>(det)->specificTopology();
265  //analyze RecHits
266  rechitanalysis(rechit,topol,associate);
267  // fill the result in a histogram
268  fillME(iStereoAndMatchedME->second.meWclusStereo,rechitpro.clusiz);
269  fillME(iStereoAndMatchedME->second.meAdcStereo,rechitpro.cluchg);
270  fillME(iStereoAndMatchedME->second.mePosxStereo,rechitpro.x);
271  fillME(iStereoAndMatchedME->second.meResolxStereo,sqrt(rechitpro.resolxx));
272  fillME(iStereoAndMatchedME->second.meNsimHitStereo,rechitpro.NsimHit);
273  if (rechitpro.NsimHit > 0) {
274  std::map<std::string, SubDetMEs>::iterator iSubDetME = SubDetMEsMap.find(det_lay_pair.first);
275  fillME(iSubDetME->second.meBunchStereo, rechitpro.bunch);
276  if (rechitpro.bunch == 0) fillME(iSubDetME->second.meEventStereo, rechitpro.event);
277  }
278  if ( rechitpro.resx != -999999. || rechitpro.pullMF != -999999. || rechitpro.chi2 != -999999. ){
279  fillME(iStereoAndMatchedME->second.meResStereo,rechitpro.resx);
280  fillME(iStereoAndMatchedME->second.mePullLFStereo,rechitpro.resx/sqrt(rechitpro.resolxx));
281  fillME(iStereoAndMatchedME->second.mePullMFStereo,rechitpro.pullMF);
282  fillME(iStereoAndMatchedME->second.meChi2Stereo,rechitpro.chi2);
283  }
284  }
285  }
286  }
287 
288  // start loops over detectors with detected rechitmatched
289  for (auto const & theDetSet : *rechitsmatched) {
290  DetId detid = theDetSet.detId();
291  uint32_t myid = detid.rawId();
292  totrechitmatched += theDetSet.size();
293 
294  std::string label = hidmanager.getSubdetid(myid,tTopo,true);
295  std::map<std::string, StereoAndMatchedMEs>::iterator iStereoAndMatchedME = StereoAndMatchedMEsMap.find(label);
296  std::pair<std::string,int32_t> det_lay_pair = fold_organ.GetSubDetAndLayer(myid,tTopo,true);
297 
298  totnumrechitmatched[det_lay_pair.first] = totnumrechitmatched[det_lay_pair.first] + theDetSet.size();
299  //loop over rechits-matched in the same subdetector
300  if(iStereoAndMatchedME != StereoAndMatchedMEsMap.end()){
301  for (auto const& rechit : theDetSet) {
302  const GluedGeomDet* gluedDet = static_cast<const GluedGeomDet*>(tracker.idToDet(rechit.geographicalId()));
303  //analyze RecHits
304  rechitanalysis_matched(rechit, gluedDet, associate);
305  // fill the result in a histogram
306  fillME(iStereoAndMatchedME->second.mePosxMatched,rechitpro.x);
307  fillME(iStereoAndMatchedME->second.mePosyMatched,rechitpro.y);
308  fillME(iStereoAndMatchedME->second.meResolxMatched,sqrt(rechitpro.resolxx));
309  fillME(iStereoAndMatchedME->second.meResolyMatched,sqrt(rechitpro.resolyy));
310  fillME(iStereoAndMatchedME->second.meNsimHitMatched,rechitpro.NsimHit);
311  if (rechitpro.NsimHit > 0) {
312  std::map<std::string, SubDetMEs>::iterator iSubDetME = SubDetMEsMap.find(det_lay_pair.first);
313  fillME(iSubDetME->second.meBunchMatched, rechitpro.bunch);
314  if (rechitpro.bunch == 0) fillME(iSubDetME->second.meEventMatched, rechitpro.event);
315  }
316  if ( rechitpro.resx != -999999. || rechitpro.resy != -999999. || rechitpro.chi2 != -999999. ){
317  fillME(iStereoAndMatchedME->second.meResxMatched,rechitpro.resx);
318  fillME(iStereoAndMatchedME->second.meResyMatched,rechitpro.resy);
319  fillME(iStereoAndMatchedME->second.meChi2Matched,rechitpro.chi2);
320  }
321  }
322  }
323  }//End of loops over detectors
324 
325  //now fill the cumulative histograms of the hits
326  for (std::vector<std::string>::iterator iSubdet = SubDetList_.begin(); iSubdet != SubDetList_.end(); ++iSubdet){
327  std::map<std::string, SubDetMEs>::iterator iSubDetME = SubDetMEsMap.find((*iSubdet));
328  fillME(iSubDetME->second.meNumrphi,totnumrechitrphi[(*iSubdet)]);
329  fillME(iSubDetME->second.meNumStereo,totnumrechitstereo[(*iSubdet)]);
330  fillME(iSubDetME->second.meNumMatched,totnumrechitmatched[(*iSubdet)]);
331  }
332 
333  fillME(totalMEs.meNumTotrphi,totrechitrphi);
334  fillME(totalMEs.meNumTotStereo,totrechitstereo);
335  fillME(totalMEs.meNumTotMatched,totrechitmatched);
336 }
337 
338 
339 //needed by to do the residual for matched hits
340 std::pair<LocalPoint,LocalVector> SiStripRecHitsValid::projectHit( const PSimHit& hit, const StripGeomDetUnit* stripDet,
341  const BoundPlane& plane)
342 {
343  // const StripGeomDetUnit* stripDet = dynamic_cast<const StripGeomDetUnit*>(hit.det());
344  //if (stripDet == nullptr) throw MeasurementDetException("HitMatcher hit is not on StripGeomDetUnit");
345 
346  const StripTopology& topol = stripDet->specificTopology();
347  GlobalPoint globalpos= stripDet->surface().toGlobal(hit.localPosition());
348  LocalPoint localHit = plane.toLocal(globalpos);
349  //track direction
350  LocalVector locdir=hit.localDirection();
351  //rotate track in new frame
352 
353  GlobalVector globaldir= stripDet->surface().toGlobal(locdir);
354  LocalVector dir=plane.toLocal(globaldir);
355  double scale = -localHit.z() / dir.z();
356 
357  LocalPoint projectedPos = localHit + scale*dir;
358 
359  double selfAngle = topol.stripAngle( topol.strip( hit.localPosition()));
360 
361  LocalVector stripDir( sin(selfAngle), cos(selfAngle), 0); // vector along strip in hit frame
362 
363  LocalVector localStripDir( plane.toLocal(stripDet->surface().toGlobal( stripDir)));
364 
365  return std::pair<LocalPoint,LocalVector>( projectedPos, localStripDir);
366 }
367 //--------------------------------------------------------------------------------------------
369 
370  rechitpro.resx = -999999.; rechitpro.resy = -999999.; rechitpro.pullMF = -999999.;
371  rechitpro.chi2 = -999999.; rechitpro.bunch = -999999.; rechitpro.event = -999999.;
372 
375  MeasurementPoint Mposition = topol.measurementPosition(position);
376  MeasurementError Merror = topol.measurementError(position,error);
377  const auto & amplitudes=(rechit.cluster())->amplitudes();
378  int totcharge=0;
379  for(auto ia : amplitudes){
380  totcharge += ia;
381  }
382  rechitpro.x = position.x();
383  rechitpro.y = position.y();
384  //rechitpro.z = position.z();
385  rechitpro.resolxx = error.xx();
386  //rechitpro.resolxy = error.xy();
387  rechitpro.resolyy = error.yy();
388  rechitpro.clusiz = amplitudes.size();
389  rechitpro.cluchg = totcharge;
390 
391  auto const & matched = associate.associateHit(rechit);
392  rechitpro.NsimHit = matched.size();
393 
394  if(!matched.empty()){
395 
396  float mindist = std::numeric_limits<float>::max();
397  float dist = std::numeric_limits<float>::max();
398  PSimHit const * closest = nullptr;
399 
400  for(auto const &m : matched){
401  dist = fabs(rechitpro.x - m.localPosition().x());
402  if(dist<mindist){
403  mindist = dist;
404  closest = &m;
405  }
406  }
407  rechitpro.bunch = closest->eventId().bunchCrossing();
408  rechitpro.event = closest->eventId().event();
409  rechitpro.resx = rechitpro.x - closest->localPosition().x();
410  rechitpro.pullMF = (Mposition.x() - (topol.measurementPosition(closest->localPosition())).x())/sqrt(Merror.uu());
411 
412  //chi2test compare rechit errors with the simhit position ( using null matrix for the simhit).
413  //Can spot problems in the geometry better than a simple residual. (thanks to BorisM)
414  AlgebraicVector rhparameters(2);//= rechit.parameters();
415  rhparameters[0] = position.x();
416  rhparameters[1] = position.y();
417  AlgebraicVector shparameters(2);
418  shparameters[0] = closest->localPosition().x();
419  shparameters[1] = closest->localPosition().y();
420  AlgebraicVector r(rhparameters - shparameters);
421  AlgebraicSymMatrix R(2);// = rechit.parametersError();
422  R[0][0] = error.xx();
423  R[0][1] = error.xy();
424  R[1][1] = error.yy();
425  int ierr;
426  R.invert(ierr); // if (ierr != 0) throw exception;
427  float est = R.similarity(r);
428  rechitpro.chi2 = est;
429  }
430 
431 }
432 
433 
434 //--------------------------------------------------------------------------------------------
436 
437  rechitpro.resx = -999999.; rechitpro.resy = -999999.; rechitpro.pullMF = -999999.;
438  rechitpro.chi2 = -999999.; rechitpro.bunch = -999999.; rechitpro.event = -999999.;
439  rechitpro.clusiz = -999999.; rechitpro.cluchg = -999999.;
440 
443 
444  rechitpro.x = position.x();
445  rechitpro.y = position.y();
446  //rechitpro.z = position.z();
447  rechitpro.resolxx = error.xx();
448  //rechitpro.resolxy = error.xy();
449  rechitpro.resolyy = error.yy();
450 
451  auto const & matched = associate.associateHit(rechit);
452  rechitpro.NsimHit = matched.size();
453 
454  if(matched.empty()) return;
455  float mindist = std::numeric_limits<float>::max();
456  float dist = std::numeric_limits<float>::max();
457  float dist2 = std::numeric_limits<float>::max();
458  float distx = std::numeric_limits<float>::max();
459  float disty = std::numeric_limits<float>::max();
460  PSimHit const * closest = nullptr;
461  std::pair<LocalPoint,LocalVector> closestPair;
462 
463  const StripGeomDetUnit* partnerstripdet = static_cast<const StripGeomDetUnit*>(gluedDet->stereoDet());
464  std::pair<LocalPoint,LocalVector> hitPair;
465 
466  for(auto const &m : matched){
467  SiStripDetId hitDetId(m.detUnitId());
468  if (hitDetId.stereo()) { // project from the stereo sensor
469  //project simhit;
470  hitPair= projectHit(m,partnerstripdet,gluedDet->surface());
471  distx = rechitpro.x - hitPair.first.x();
472  disty = rechitpro.y - hitPair.first.y();
473  dist2 = distx*distx+disty*disty;
474  dist = sqrt(dist2);
475  if(dist<mindist){
476  mindist = dist;
477  closestPair = hitPair;
478  closest = &m;
479  }
480  }
481  }
482  if (!closest) return;
483  rechitpro.bunch = closest->eventId().bunchCrossing();
484  rechitpro.event = closest->eventId().event();
485  rechitpro.resx = rechitpro.x - closestPair.first.x();
486  rechitpro.resy = rechitpro.y - closestPair.first.y();
487 
488  //chi2test compare rechit errors with the simhit position ( using null matrix for the simhit).
489  //Can spot problems in the geometry better than a simple residual. (thanks to BorisM)
490  AlgebraicVector rhparameters(2);//= rechit.parameters();
491  rhparameters[0] = position.x();
492  rhparameters[1] = position.y();
493  LocalPoint sh = closestPair.first;
494  AlgebraicVector shparameters(2);
495  shparameters[0] = sh.x();
496  shparameters[1] = sh.y();
497  AlgebraicVector r(rhparameters - shparameters);
498  AlgebraicSymMatrix R(2);// = rechit.parametersError();
499  R[0][0] = error.xx();
500  R[0][1] = error.xy();
501  R[1][1] = error.yy();
502  int ierr;
503  R.invert(ierr); // if (ierr != 0) throw exception;
504  float est = R.similarity(r);
505  rechitpro.chi2 = est;
506 
507 
508 
509 }
510 
511 //--------------------------------------------------------------------------------------------
513 
514  //Retrieve tracker topology from geometry
515  edm::ESHandle<TrackerTopology> tTopoHandle;
516  es.get<TrackerTopologyRcd>().get(tTopoHandle);
517  const TrackerTopology* const tTopo = tTopoHandle.product();
518 
519  // take from eventSetup the SiStripDetCabling object - here will use SiStripDetControl later on
521 
522  // get list of active detectors from SiStripDetCabling
523  std::vector<uint32_t> activeDets;
525 
526  SiStripFolderOrganizer folder_organizer;
527  // folder_organizer.setSiStripFolderName(topFolderName_);
528  std::string curfold = topFolderName_;
529  folder_organizer.setSiStripFolderName(curfold);
530  folder_organizer.setSiStripFolder();
531 
532  createTotalMEs(ibooker);
533  // loop over detectors and book MEs
534  edm::LogInfo("SiStripTkRecHits|SiStripRecHitsValid")<<"nr. of activeDets: "<<activeDets.size();
535  const std::string& tec = "TEC", tid = "TID", tob = "TOB", tib = "TIB";
536  for(auto detid_iterator=activeDets.begin(), detid_end=activeDets.end(); detid_iterator!=detid_end; ++detid_iterator){
537  uint32_t detid = (*detid_iterator);
538  // remove any eventual zero elements - there should be none, but just in case
539  if(detid == 0) {
540  activeDets.erase(detid_iterator);
541  continue;
542  }
543 
544  // Create Layer Level MEs
545  std::pair<std::string,int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detid,tTopo,true);
546  SiStripHistoId hidmanager;
547  std::string label = hidmanager.getSubdetid(detid,tTopo,true);
548 
549  if(LayerMEsMap.find(label)==LayerMEsMap.end()) {
550 
551  // get detids for the layer
552  // Keep in mind that when we are on the TID or TEC we deal with rings not wheel
553  int32_t lnumber = det_layer_pair.second;
554  const std::string& lname = det_layer_pair.first;
555  std::vector<uint32_t> layerDetIds;
556  if (lname == tec) {
557  if (lnumber > 0) {
558  SiStripSubStructure::getTECDetectors(activeDets,layerDetIds,tTopo,2,0,0,0,abs(lnumber),0);
559  } else if (lnumber < 0) {
560  SiStripSubStructure::getTECDetectors(activeDets,layerDetIds,tTopo,1,0,0,0,abs(lnumber),0);
561  }
562  } else if (lname == tid) {
563  if (lnumber > 0) {
564  SiStripSubStructure::getTIDDetectors(activeDets,layerDetIds,tTopo,2,0,abs(lnumber),0);
565  } else if (lnumber < 0) {
566  SiStripSubStructure::getTIDDetectors(activeDets,layerDetIds,tTopo,1,0,abs(lnumber),0);
567  }
568  } else if (lname == tob) {
569  SiStripSubStructure::getTOBDetectors(activeDets,layerDetIds,tTopo,lnumber,0,0);
570  } else if (lname == tib) {
571  SiStripSubStructure::getTIBDetectors(activeDets,layerDetIds,tTopo,lnumber,0,0,0);
572  }
573  LayerDetMap[label] = layerDetIds;
574 
575  // book Layer MEs
576  folder_organizer.setLayerFolder(detid,tTopo,det_layer_pair.second,true);
577  createLayerMEs(ibooker,label);
578  }
579  // book sub-detector plots
580  if (SubDetMEsMap.find(det_layer_pair.first) == SubDetMEsMap.end()){
581  auto sdet_pair = folder_organizer.getSubDetFolderAndTag(detid, tTopo);
582  ibooker.setCurrentFolder(sdet_pair.first);
583  createSubDetMEs(ibooker,det_layer_pair.first);
584  }
585  //Create StereoAndMatchedMEs
586  if(StereoAndMatchedMEsMap.find(label)==StereoAndMatchedMEsMap.end()) {
587 
588  // get detids for the stereo and matched layer. We are going to need a bool for these layers
589  bool isStereo = false;
590  // Keep in mind that when we are on the TID or TEC we deal with rings not wheel
591  std::vector<uint32_t> stereoandmatchedDetIds;
592  int32_t stereolnumber = det_layer_pair.second;
593  const std::string& stereolname = det_layer_pair.first;
594  if ( stereolname == tec && (tTopo->tecIsStereo(detid)) ) {
595  if ( stereolnumber > 0 ) {
596  SiStripSubStructure::getTECDetectors(activeDets,stereoandmatchedDetIds,tTopo,2,0,0,0,abs(stereolnumber),1);
597  isStereo = true;
598  } else if ( stereolnumber < 0 ) {
599  SiStripSubStructure::getTECDetectors(activeDets,stereoandmatchedDetIds,tTopo,1,0,0,0,abs(stereolnumber),1);
600  isStereo = true;
601  }
602  } else if ( stereolname == tid && (tTopo->tidIsStereo(detid)) ) {
603  if ( stereolnumber > 0 ) {
604  SiStripSubStructure::getTIDDetectors(activeDets,stereoandmatchedDetIds,tTopo,2,0,abs(stereolnumber),1);
605  isStereo = true;
606  } else if ( stereolnumber < 0 ) {
607  SiStripSubStructure::getTIDDetectors(activeDets,stereoandmatchedDetIds,tTopo,1,0,abs(stereolnumber),1);
608  isStereo = true;
609  }
610  } else if ( stereolname == tob && (tTopo->tobIsStereo(detid)) ) {
611  SiStripSubStructure::getTOBDetectors(activeDets,stereoandmatchedDetIds,tTopo,stereolnumber,0,0);
612  isStereo = true;
613  } else if ( stereolname == tib && (tTopo->tibIsStereo(detid)) ) {
614  SiStripSubStructure::getTIBDetectors(activeDets,stereoandmatchedDetIds,tTopo,stereolnumber,0,0,0);
615  isStereo = true;
616  }
617 
618  StereoAndMatchedDetMap[label] = stereoandmatchedDetIds;
619 
620  if(isStereo){
621  //book StereoAndMatched MEs
622  folder_organizer.setLayerFolder(detid,tTopo,det_layer_pair.second,true);
623  //Create the Monitor Elements only when we have a stereo module
624  createStereoAndMatchedMEs(ibooker,label);
625  }
626  }
627  }//end of loop over detectors
628 }
629 //------------------------------------------------------------------------------------------
631 {
632  totalMEs.meNumTotrphi = nullptr;
633  totalMEs.meNumTotStereo = nullptr;
634  totalMEs.meNumTotMatched = nullptr;
635 
636  //NumTotrphi
637  if(switchNumTotrphi) {
638  totalMEs.meNumTotrphi = bookME1D(ibooker,"TH1NumTotrphi", "TH1NumTotrphi" ,"Num of RecHits rphi");
639  totalMEs.meNumTotrphi->setAxisTitle("Total number of RecHits");
640  }
641  //NumTotStereo
642  if(switchNumTotStereo) {
643  totalMEs.meNumTotStereo = bookME1D(ibooker,"TH1NumTotStereo", "TH1NumTotStereo","Num of RecHits stereo");
644  totalMEs.meNumTotStereo ->setAxisTitle("Total number of RecHits (stereo)");
645  }
646  //NumTotMatched
647  if(switchNumTotMatched) {
648  totalMEs.meNumTotMatched = bookME1D(ibooker,"TH1NumTotMatched","TH1NumTotMatched","Num of RecHits matched");
649  totalMEs.meNumTotMatched->setAxisTitle("Total number of matched RecHits");
650  }
651 
652 }
653 //------------------------------------------------------------------------------------------
655 {
656  SiStripHistoId hidmanager;
657  LayerMEs layerMEs;
658 
659  layerMEs.meWclusrphi = nullptr;
660  layerMEs.meAdcrphi = nullptr;
661  layerMEs.mePosxrphi = nullptr;
662  layerMEs.meResolxrphi = nullptr;
663  layerMEs.meResrphi = nullptr;
664  layerMEs.mePullLFrphi = nullptr;
665  layerMEs.mePullMFrphi = nullptr;
666  layerMEs.meChi2rphi = nullptr;
667  layerMEs.meNsimHitrphi = nullptr;
668 
669  //Wclusrphi
670  if(switchWclusrphi) {
671  layerMEs.meWclusrphi = bookME1D(ibooker,"TH1Wclusrphi", hidmanager.createHistoLayer("Wclus_rphi","layer",label,"").c_str() ,"Cluster Width - Number of strips that belong to the RecHit cluster");
672  layerMEs.meWclusrphi->setAxisTitle("Cluster Width [nr strips] in "+ label);
673  }
674  //Adcrphi
675  if(switchAdcrphi) {
676  layerMEs.meAdcrphi = bookME1D(ibooker,"TH1Adcrphi", hidmanager.createHistoLayer("Adc_rphi","layer",label,"").c_str() ,"RecHit Cluster Charge");
677  layerMEs.meAdcrphi->setAxisTitle("cluster charge [ADC] in " + label);
678  }
679  //Posxrphi
680  if(switchPosxrphi) {
681  layerMEs.mePosxrphi = bookME1D(ibooker,"TH1Posxrphi", hidmanager.createHistoLayer("Posx_rphi","layer",label,"").c_str() ,"RecHit x coord.");
682  layerMEs.mePosxrphi->setAxisTitle("x RecHit coord. (local frame) in " + label);
683  }
684  //Resolxrphi
685  if(switchResolxrphi) {
686  layerMEs.meResolxrphi = bookME1D(ibooker,"TH1Resolxrphi", hidmanager.createHistoLayer("Resolx_rphi","layer",label,"").c_str() ,"RecHit resol(x) coord."); //<resolor>~20micron
687  layerMEs.meResolxrphi->setAxisTitle("resol(x) RecHit coord. (local frame) in " + label);
688  }
689  //Resrphi
690  if(switchResrphi) {
691  layerMEs.meResrphi = bookME1D(ibooker,"TH1Resrphi", hidmanager.createHistoLayer("Res_rphi","layer",label,"").c_str() ,"Residuals of the hit x coordinate");
692  layerMEs.meResrphi->setAxisTitle("RecHit Res(x) in " + label);
693  }
694  //PullLFrphi
695  if(switchPullLFrphi) {
696  layerMEs.mePullLFrphi = bookME1D(ibooker,"TH1PullLFrphi", hidmanager.createHistoLayer("Pull_LF_rphi","layer",label,"").c_str() ,"Pull distribution");
697  layerMEs.mePullLFrphi->setAxisTitle("Pull distribution (local frame) in " + label);
698  }
699  //PullMFrphi
700  if(switchPullMFrphi) {
701  layerMEs.mePullMFrphi = bookME1D(ibooker,"TH1PullMFrphi", hidmanager.createHistoLayer("Pull_MF_rphi","layer",label,"").c_str() ,"Pull distribution");
702  layerMEs.mePullMFrphi->setAxisTitle("Pull distribution (measurement frame) in " + label);
703  }
704  //Chi2rphi
705  if(switchChi2rphi) {
706  layerMEs.meChi2rphi = bookME1D(ibooker,"TH1Chi2rphi", hidmanager.createHistoLayer("Chi2_rphi","layer",label,"").c_str() ,"RecHit Chi2 test");
707  layerMEs.meChi2rphi->setAxisTitle("RecHit Chi2 test in " + label);
708  }
709  //NsimHitrphi
710  if(switchNsimHitrphi) {
711  layerMEs.meNsimHitrphi = bookME1D(ibooker,"TH1NsimHitrphi", hidmanager.createHistoLayer("NsimHit_rphi","layer",label,"").c_str() ,"No. of assoc. simHits");
712  layerMEs.meNsimHitrphi->setAxisTitle("Number of assoc. simHits in " + label);
713  }
714 
715  LayerMEsMap[label]=layerMEs;
716 
717 }
718 //------------------------------------------------------------------------------------------
720 {
721  SiStripHistoId hidmanager;
722  StereoAndMatchedMEs stereoandmatchedMEs;
723 
724  stereoandmatchedMEs.meWclusStereo = nullptr;
725  stereoandmatchedMEs.meAdcStereo = nullptr;
726  stereoandmatchedMEs.mePosxStereo = nullptr;
727  stereoandmatchedMEs.meResolxStereo = nullptr;
728  stereoandmatchedMEs.meResStereo = nullptr;
729  stereoandmatchedMEs.mePullLFStereo = nullptr;
730  stereoandmatchedMEs.mePullMFStereo = nullptr;
731  stereoandmatchedMEs.meChi2Stereo = nullptr;
732  stereoandmatchedMEs.meNsimHitStereo = nullptr;
733  stereoandmatchedMEs.mePosxMatched = nullptr;
734  stereoandmatchedMEs.mePosyMatched = nullptr;
735  stereoandmatchedMEs.meResolxMatched = nullptr;
736  stereoandmatchedMEs.meResolyMatched = nullptr;
737  stereoandmatchedMEs.meResxMatched = nullptr;
738  stereoandmatchedMEs.meResyMatched = nullptr;
739  stereoandmatchedMEs.meChi2Matched = nullptr;
740  stereoandmatchedMEs.meNsimHitMatched = nullptr;
741 
742  //WclusStereo
743  if(switchWclusStereo) {
744  stereoandmatchedMEs.meWclusStereo = bookME1D(ibooker,"TH1WclusStereo", hidmanager.createHistoLayer("Wclus_stereo","layer",label,"").c_str() ,"Cluster Width - Number of strips that belong to the RecHit cluster");
745  stereoandmatchedMEs.meWclusStereo->setAxisTitle("Cluster Width [nr strips] in stereo modules in "+ label);
746  }
747  //AdcStereo
748  if(switchAdcStereo) {
749  stereoandmatchedMEs.meAdcStereo = bookME1D(ibooker,"TH1AdcStereo", hidmanager.createHistoLayer("Adc_stereo","layer",label,"").c_str() ,"RecHit Cluster Charge");
750  stereoandmatchedMEs.meAdcStereo->setAxisTitle("cluster charge [ADC] in stereo modules in " + label);
751  }
752  //PosxStereo
753  if(switchPosxStereo) {
754  stereoandmatchedMEs.mePosxStereo = bookME1D(ibooker,"TH1PosxStereo", hidmanager.createHistoLayer("Posx_stereo","layer",label,"").c_str() ,"RecHit x coord.");
755  stereoandmatchedMEs.mePosxStereo->setAxisTitle("x RecHit coord. (local frame) in stereo modules in " + label);
756  }
757  //ResolxStereo
758  if(switchResolxStereo) {
759  stereoandmatchedMEs.meResolxStereo = bookME1D(ibooker,"TH1ResolxStereo", hidmanager.createHistoLayer("Resolx_stereo","layer",label,"").c_str() ,"RecHit resol(x) coord.");
760  stereoandmatchedMEs.meResolxStereo->setAxisTitle("resol(x) RecHit coord. (local frame) in stereo modules in " + label);
761  }
762  //ResStereo
763  if(switchResStereo) {
764  stereoandmatchedMEs.meResStereo = bookME1D(ibooker,"TH1ResStereo", hidmanager.createHistoLayer("Res_stereo","layer",label,"").c_str() ,"Residuals of the hit x coordinate");
765  stereoandmatchedMEs.meResStereo->setAxisTitle("RecHit Res(x) in stereo modules in " + label);
766  }
767  //PullLFStereo
768  if(switchPullLFStereo) {
769  stereoandmatchedMEs.mePullLFStereo = bookME1D(ibooker,"TH1PullLFStereo", hidmanager.createHistoLayer("Pull_LF_stereo","layer",label,"").c_str() ,"Pull distribution");
770  stereoandmatchedMEs.mePullLFStereo->setAxisTitle("Pull distribution (local frame) in stereo modules in " + label);
771  }
772  //PullMFStereo
773  if(switchPullMFStereo) {
774  stereoandmatchedMEs.mePullMFStereo = bookME1D(ibooker,"TH1PullMFStereo", hidmanager.createHistoLayer("Pull_MF_stereo","layer",label,"").c_str() ,"Pull distribution");
775  stereoandmatchedMEs.mePullMFStereo->setAxisTitle("Pull distribution (measurement frame) in stereo modules in " + label);
776  }
777  //Chi2Stereo
778  if(switchChi2Stereo) {
779  stereoandmatchedMEs.meChi2Stereo = bookME1D(ibooker,"TH1Chi2Stereo", hidmanager.createHistoLayer("Chi2_stereo","layer",label,"").c_str() ,"RecHit Chi2 test");
780  stereoandmatchedMEs.meChi2Stereo->setAxisTitle("RecHit Chi2 test in stereo modules in " + label);
781  }
782  //NsimHitStereo
783  if(switchNsimHitStereo) {
784  stereoandmatchedMEs.meNsimHitStereo = bookME1D(ibooker,"TH1NsimHitStereo", hidmanager.createHistoLayer("NsimHit_stereo","layer",label,"").c_str() ,"No. of assoc. simHits");
785  stereoandmatchedMEs.meNsimHitStereo->setAxisTitle("Number of assoc. simHits in stereo modules in " + label);
786  }
787  //PosxMatched
788  if(switchPosxMatched) {
789  stereoandmatchedMEs.mePosxMatched = bookME1D(ibooker,"TH1PosxMatched", hidmanager.createHistoLayer("Posx_matched","layer",label,"").c_str() ,"RecHit x coord.");
790  stereoandmatchedMEs.mePosxMatched->setAxisTitle("x coord. matched RecHit (local frame) in " + label);
791  }
792  //PosyMatched
793  if(switchPosyMatched) {
794  stereoandmatchedMEs.mePosyMatched = bookME1D(ibooker,"TH1PosyMatched", hidmanager.createHistoLayer("Posy_matched","layer",label,"").c_str() ,"RecHit y coord.");
795  stereoandmatchedMEs.mePosyMatched->setAxisTitle("y coord. matched RecHit (local frame) in " + label);
796  }
797  //ResolxMatched
798  if(switchResolxMatched) {
799  stereoandmatchedMEs.meResolxMatched = bookME1D(ibooker,"TH1ResolxMatched", hidmanager.createHistoLayer("Resolx_matched","layer",label,"").c_str() ,"RecHit resol(x) coord.");
800  stereoandmatchedMEs.meResolxMatched->setAxisTitle("resol(x) coord. matched RecHit (local frame) in " + label);
801  }
802  //ResolyMatched
803  if(switchResolyMatched) {
804  stereoandmatchedMEs.meResolyMatched = bookME1D(ibooker,"TH1ResolyMatched", hidmanager.createHistoLayer("Resoly_matched","layer",label,"").c_str() ,"RecHit resol(y) coord.");
805  stereoandmatchedMEs.meResolyMatched->setAxisTitle("resol(y) coord. matched RecHit (local frame) in " + label);
806  }
807  //ResxMatched
808  if(switchResxMatched) {
809  stereoandmatchedMEs.meResxMatched = bookME1D(ibooker,"TH1ResxMatched", hidmanager.createHistoLayer("Resx_matched","layer",label,"").c_str() ,"Residuals of the hit x coord.");
810  stereoandmatchedMEs.meResxMatched->setAxisTitle("Res(x) in matched RecHit in " + label);
811  }
812  //ResyMatched
813  if(switchResyMatched) {
814  stereoandmatchedMEs.meResyMatched = bookME1D(ibooker,"TH1ResyMatched", hidmanager.createHistoLayer("Resy_matched","layer",label,"").c_str() ,"Residuals of the hit y coord.");
815  stereoandmatchedMEs.meResyMatched->setAxisTitle("Res(y) in matched RecHit in " + label);
816  }
817  //Chi2Matched
818  if(switchChi2Matched) {
819  stereoandmatchedMEs.meChi2Matched = bookME1D(ibooker,"TH1Chi2Matched", hidmanager.createHistoLayer("Chi2_matched","layer",label,"").c_str() ,"RecHit Chi2 test");
820  stereoandmatchedMEs.meChi2Matched->setAxisTitle("Matched RecHit Chi2 test in " + label);
821  }
822  //NsimHitMatched
824  stereoandmatchedMEs.meNsimHitMatched = bookME1D(ibooker,"TH1NsimHitMatched", hidmanager.createHistoLayer("NsimHit_matched","layer",label,"").c_str() ,"No. of assoc. simHits");
825  stereoandmatchedMEs.meNsimHitMatched->setAxisTitle("Number of assoc. simHits in " + label);
826  }
827 
828  StereoAndMatchedMEsMap[label]=stereoandmatchedMEs;
829 
830 }
831 //------------------------------------------------------------------------------------------
833 
834  SubDetMEs subdetMEs;
835  subdetMEs.meNumrphi = nullptr;
836  subdetMEs.meBunchrphi = nullptr;
837  subdetMEs.meEventrphi = nullptr;
838  subdetMEs.meNumStereo = nullptr;
839  subdetMEs.meBunchStereo = nullptr;
840  subdetMEs.meEventStereo = nullptr;
841  subdetMEs.meNumMatched = nullptr;
842  subdetMEs.meBunchMatched = nullptr;
843  subdetMEs.meEventMatched = nullptr;
844 
846  //Numrphi
847  if (switchNumrphi){
848  HistoName = "TH1Numrphi__" + label;
849  subdetMEs.meNumrphi = bookME1D(ibooker,"TH1Numrphi",HistoName.c_str(),"Num of RecHits");
850  subdetMEs.meNumrphi->setAxisTitle("Total number of RecHits in "+ label);
851  }
852  //Bunchrphi
853  if(switchBunchrphi) {
854  HistoName = "TH1Bunchrphi__" + label;
855  subdetMEs.meBunchrphi = bookME1D(ibooker,"TH1Bunchrphi",HistoName.c_str(),"Bunch Crossing");
856  subdetMEs.meBunchrphi->setAxisTitle("Bunch crossing in " + label);
857  }
858  //Eventrphi
859  if(switchEventrphi) {
860  HistoName = "TH1Eventrphi__" + label;
861  subdetMEs.meEventrphi = bookME1D(ibooker,"TH1Eventrphi",HistoName.c_str(),"Event (in-time bunch)");
862  subdetMEs.meEventrphi->setAxisTitle("Event (in-time bunch) in " + label);
863  }
864  //NumStereo
865  if (switchNumStereo){
866  HistoName = "TH1NumStereo__" + label;
867  subdetMEs.meNumStereo = bookME1D(ibooker,"TH1NumStereo",HistoName.c_str(),"Num of RecHits in stereo modules");
868  subdetMEs.meNumStereo->setAxisTitle("Total number of RecHits, stereo modules in "+ label);
869  }
870  //BunchStereo
871  if(switchBunchStereo) {
872  HistoName = "TH1BunchStereo__" + label;
873  subdetMEs.meBunchStereo = bookME1D(ibooker,"TH1BunchStereo",HistoName.c_str(),"Bunch Crossing");
874  subdetMEs.meBunchStereo->setAxisTitle("Bunch crossing, stereo modules in " + label);
875  }
876  //EventStereo
877  if(switchEventStereo) {
878  HistoName = "TH1EventStereo__" + label;
879  subdetMEs.meEventStereo = bookME1D(ibooker,"TH1EventStereo",HistoName.c_str(),"Event (in-time bunch)");
880  subdetMEs.meEventStereo->setAxisTitle("Event (in-time bunch), stereo modules in " + label);
881  }
882  //NumMatched
883  if (switchNumMatched){
884  HistoName = "TH1NumMatched__" + label;
885  subdetMEs.meNumMatched = bookME1D(ibooker,"TH1NumMatched",HistoName.c_str(),"Num of matched RecHits" );
886  subdetMEs.meNumMatched->setAxisTitle("Total number of matched RecHits in "+ label);
887  }
888  //BunchMatched
889  if(switchBunchMatched) {
890  HistoName = "TH1BunchMatched__" + label;
891  subdetMEs.meBunchMatched = bookME1D(ibooker,"TH1BunchMatched",HistoName.c_str(),"Bunch Crossing");
892  subdetMEs.meBunchMatched->setAxisTitle("Bunch crossing, matched RecHits in " + label);
893  }
894  //EventMatched
895  if(switchEventMatched) {
896  HistoName = "TH1EventMatched__" + label;
897  subdetMEs.meEventMatched = bookME1D(ibooker,"TH1EventMatched",HistoName.c_str(),"Event (in-time bunch)");
898  subdetMEs.meEventMatched->setAxisTitle("Event (in-time bunch), matched RecHits in " + label);
899  }
900 
901  SubDetMEsMap[label]=subdetMEs;
902 }
903 //------------------------------------------------------------------------------------------
904 inline MonitorElement* SiStripRecHitsValid::bookME1D(DQMStore::IBooker & ibooker, const char* ParameterSetLabel, const char* HistoName, const char* HistoTitle)
905 {
907  return ibooker.book1D(HistoName,HistoTitle,
908  parameters.getParameter<int32_t>("Nbinx"),
909  parameters.getParameter<double>("xmin"),
910  parameters.getParameter<double>("xmax")
911  );
912 }
913 
914 //define this as a plug-in
916 
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 getTIBDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tibDetRawIds, const TrackerTopology *trackerTopology, uint32_t layer=0, uint32_t bkw_frw=0, uint32_t int_ext=0, uint32_t string=0)
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:579
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
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
std::map< std::string, StereoAndMatchedMEs > StereoAndMatchedMEsMap
T y() const
Definition: PV3DBase.h:63
void getTIDDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tidDetRawIds, const TrackerTopology *trackerTopology, uint32_t side=0, uint32_t wheel=0, uint32_t ring=0, uint32_t ster=0)
virtual float strip(const LocalPoint &) const =0
void setLayerFolder(uint32_t rawdetid, const TrackerTopology *tTopo, int32_t layer=0, bool ring_flag=false)
void getTECDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tecDetRawIds, const TrackerTopology *trackerTopology, 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)
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_
char const * label
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 setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
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:106
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
Definition: DetId.h:18
std::map< std::string, LayerMEs > LayerMEsMap
edm::ESHandle< SiStripDetCabling > SiStripDetCabling_
CLHEP::HepVector AlgebraicVector
std::map< std::string, std::vector< uint32_t > > StereoAndMatchedDetMap
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 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
T get() const
Definition: EventSetup.h:68
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
dbl *** dir
Definition: mlp_gen.cc:35
unsigned long long m_cacheID_
void getTOBDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tobDetRawIds, const TrackerTopology *trackerTopology, uint32_t layer=0, uint32_t bkw_frw=0, uint32_t rod=0)
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:84
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
Definition: Run.h:44