test
CMS 3D CMS Logo

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