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