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