CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripMonitorMuonHLT.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripMonitorMuonHLT
4 // Class: SiStripMonitorMuonHLT
5 //
13 //
14 // Original Author: Eric Chabert
15 // Created: Wed Sep 23 17:26:42 CEST 2009
16 //
17 
21 
22 //
23 // constructors and destructor
24 //
26 {
27  cached_detid=0;
28  cached_layer=0;
29  //now do what ever initialization is needed
30  parameters_ = iConfig;
31  verbose_ = parameters_.getUntrackedParameter<bool>("verbose",false);
32  normalize_ = parameters_.getUntrackedParameter<bool>("normalize",true);
33  printNormalize_ = parameters_.getUntrackedParameter<bool>("printNormalize",false);
34  monitorName_ = parameters_.getUntrackedParameter<std::string>("monitorName","HLT/HLTMonMuon");
35  prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt",-1);
36 
37  //booleans
38  runOnClusters_ = parameters_.getUntrackedParameter<bool>("runOnClusters",true);
39  runOnMuonCandidates_ = parameters_.getUntrackedParameter<bool>("runOnMuonCandidates",true);
40  runOnTracks_ = parameters_.getUntrackedParameter<bool>("runOnTracks",true);
41 
42  //tags
43  clusterCollectionTag_ = parameters_.getUntrackedParameter < edm::InputTag > ("clusterCollectionTag",edm::InputTag("hltSiStripRawToClustersFacility"));
44  l3collectionTag_ = parameters_.getUntrackedParameter < edm::InputTag > ("l3MuonTag",edm::InputTag("hltL3MuonCandidates"));
45  TrackCollectionTag_ = parameters_.getUntrackedParameter < edm::InputTag > ("trackCollectionTag",edm::InputTag("hltL3TkTracksFromL2"));
47  clusterCollectionToken_ = consumes<edm::LazyGetter < SiStripCluster > >(clusterCollectionTag_);
48  l3collectionToken_ = consumes<reco::RecoChargedCandidateCollection>(l3collectionTag_);
49  TrackCollectionToken_ = consumes<reco::TrackCollection>(TrackCollectionTag_);
50 
51 
52  HistoNumber = 35;
53 
54  //services
55  tkdetmap_ = 0;
57  {
58  edm::LogError ("TkHistoMap") <<
59  "\n------------------------------------------"
60  "\nUnAvailable Service TkHistoMap: please insert in the configuration file an instance like" "\n\tprocess.TkDetMap = cms.Service(\"TkDetMap\")" "\n------------------------------------------";
61  }
63 }
64 
65 
67 {
68 
69  // do anything here that needs to be done at desctruction time
70  // (e.g. close files, deallocate resources etc.)
71 
72 }
73 
74 
75 //
76 // member functions
77 //
78 
80  float etaWeight = 1.;
81  for (unsigned int i = 0; i < m_BinEta[label].size() - 1; i++){
82  if (m_BinEta[label][i] < clustgp.eta() && clustgp.eta() < m_BinEta[label][i+1]){
83  if (m_ModNormEta[label][i] > 0.1) etaWeight = 1./m_ModNormEta[label][i];
84  else etaWeight = 1.;
85  }
86  }
87  return etaWeight;
88 }
89 
91  float phiWeight = 1.;
92  for (unsigned int i = 0; i < m_BinPhi[label].size() - 1; i++){
93  if (m_BinPhi[label][i] < clustgp.phi() && clustgp.phi() < m_BinPhi[label][i+1]){
94  if (m_ModNormPhi[label][i] > 0.1) phiWeight = 1./m_ModNormPhi[label][i];
95  else phiWeight = 1.;
96  }
97  }
98  return phiWeight;
99 }
100 
101 // ------------ method called to for each event ------------
102 void
104 {
105  counterEvt_++;
106  if (prescaleEvt_ > 0 && counterEvt_ % prescaleEvt_ != 0)
107  return;
108  LogDebug ("SiStripMonitorHLTMuon") << " processing conterEvt_: " << counterEvt_ << std::endl;
109 
110 
112  iSetup.get < TrackerDigiGeometryRecord > ().get (TG);
113  const TrackerGeometry *theTrackerGeometry = TG.product ();
114  const TrackerGeometry & theTracker (*theTrackerGeometry);
115 
116 
118 
119  //Access to L3MuonCand
121  bool accessToL3Muons = true;
122  iEvent.getByToken (l3collectionToken_, l3mucands);
123  reco::RecoChargedCandidateCollection::const_iterator cand;
124 
125  //Access to clusters
127  bool accessToClusters = true;
128  iEvent.getByToken (clusterCollectionToken_, clusters);
130 
131  //Access to Tracks
133  bool accessToTracks = true;
134  iEvent.getByToken (TrackCollectionToken_, trackCollection);
135  reco::TrackCollection::const_iterator track;
137 
138 
139  if (runOnClusters_ && accessToClusters && !clusters.failedToGet () && clusters.isValid())
140  {
141  for (clust = clusters->begin_record (); clust != clusters->end_record (); ++clust)
142  {
143 
144  uint detID = 0; // zero since long time clust->geographicalId ();
145  std::stringstream ss;
146  int layer = tkdetmap_->FindLayer (detID , cached_detid , cached_layer , cached_XYbin);
148  const StripGeomDetUnit *theGeomDet = dynamic_cast < const StripGeomDetUnit * >(theTracker.idToDet (detID));
149  const StripTopology *topol = dynamic_cast < const StripTopology * >(&(theGeomDet->specificTopology ()));
150  // get the cluster position in local coordinates (cm)
151  LocalPoint clustlp = topol->localPosition (clust->barycenter ());
152  GlobalPoint clustgp = theGeomDet->surface ().toGlobal (clustlp);
153 
154  //NORMALIZE HISTO IF ASKED
155  float etaWeight = 1.;
156  float phiWeight = 1.;
157  if (normalize_){
158  etaWeight = GetEtaWeight(label, clustgp);
159  phiWeight = GetPhiWeight(label,clustgp);
160  }
161  LayerMEMap[label.c_str ()].EtaDistribAllClustersMap->Fill (clustgp.eta (),etaWeight);
162  LayerMEMap[label.c_str ()].PhiDistribAllClustersMap->Fill (clustgp.phi (),phiWeight);
163  LayerMEMap[label.c_str ()].EtaPhiAllClustersMap->Fill (clustgp.eta (), clustgp.phi ());
164  tkmapAllClusters->add(detID,1.);
165  }
166  }
167 
168  if (runOnMuonCandidates_ && accessToL3Muons && !l3mucands.failedToGet () && l3mucands.isValid())
169  {
170  for (cand = l3mucands->begin (); cand != l3mucands->end (); ++cand)
171  {
172  //TrackRef l3tk = cand->get < TrackRef > ();
173  const reco::Track* l3tk = cand->get < reco::TrackRef > ().get();
174  analyzeOnTrackClusters(l3tk, theTracker, true);
175  } //loop over l3mucands
176  } //if l3seed
177 
178  if (runOnTracks_ && accessToTracks && !trackCollection.failedToGet() && trackCollection.isValid()){
179  for (track = trackCollection->begin (); track != trackCollection->end() ; ++ track)
180  {
181  const reco::Track* tk = &(*track);
182  analyzeOnTrackClusters(tk, theTracker, false);
183  }
184  }
185 
186 }
187 
188 void SiStripMonitorMuonHLT::analyzeOnTrackClusters( const reco::Track* l3tk, const TrackerGeometry & theTracker, bool isL3MuTrack ){
189 
190  for (size_t hit = 0; hit < l3tk->recHitsSize (); hit++)
191  {
192  //if hit is valid and in tracker say true
193  if (l3tk->recHit (hit)->isValid () == true && l3tk->recHit (hit)->geographicalId ().det () == DetId::Tracker)
194  {
195  uint detID = l3tk->recHit (hit)->geographicalId ()();
196 
197  const SiStripRecHit1D *hit1D = dynamic_cast < const SiStripRecHit1D * >(l3tk->recHit (hit).get ());
198  const SiStripRecHit2D *hit2D = dynamic_cast < const SiStripRecHit2D * >(l3tk->recHit (hit).get ());
199  const SiStripMatchedRecHit2D *hitMatched2D = dynamic_cast < const SiStripMatchedRecHit2D * >(l3tk->recHit (hit).get ());
200  const ProjectedSiStripRecHit2D *hitProj2D = dynamic_cast < const ProjectedSiStripRecHit2D * >(l3tk->recHit (hit).get ());
201 
202 
203  // if SiStripRecHit1D
204  if (hit1D != 0)
205  {
206  int layer = tkdetmap_->FindLayer (detID , cached_detid , cached_layer , cached_XYbin);
208  const StripGeomDetUnit *theGeomDet = dynamic_cast < const StripGeomDetUnit * >(theTracker.idToDet (detID));
209  if (theGeomDet != 0)
210  {
211  const StripTopology *topol = dynamic_cast < const StripTopology * >(&(theGeomDet->specificTopology ()));
212  if (topol != 0)
213  {
214  // get the cluster position in local coordinates (cm)
215  LocalPoint clustlp = topol->localPosition (hit1D->cluster()->barycenter ());
216  GlobalPoint clustgp = theGeomDet->surface ().toGlobal (clustlp);
217  //NORMALIZE HISTO IF ASKED
218  float etaWeight = 1.;
219  float phiWeight = 1.;
220  if (normalize_){
221  etaWeight = GetEtaWeight(label, clustgp);
222  phiWeight = GetPhiWeight(label,clustgp);
223  }
224  if(!isL3MuTrack){
225  LayerMEMap[label.c_str ()].EtaDistribOnTrackClustersMap->Fill (clustgp.eta (),etaWeight);
226  LayerMEMap[label.c_str ()].PhiDistribOnTrackClustersMap->Fill (clustgp.phi (),phiWeight);
227  LayerMEMap[label.c_str ()].EtaPhiOnTrackClustersMap->Fill (clustgp.eta (), clustgp.phi ());
228  tkmapOnTrackClusters->add(detID,1.);
229  }
230  else{
231  LayerMEMap[label.c_str ()].EtaDistribL3MuTrackClustersMap->Fill (clustgp.eta (),etaWeight);
232  LayerMEMap[label.c_str ()].PhiDistribL3MuTrackClustersMap->Fill (clustgp.phi (),phiWeight);
233  LayerMEMap[label.c_str ()].EtaPhiL3MuTrackClustersMap->Fill (clustgp.eta (), clustgp.phi ());
234  tkmapL3MuTrackClusters->add(detID,1.);
235  }
236  }
237  }
238  }
239  // if SiStripRecHit2D
240  if (hit2D != 0)
241  {
242  int layer = tkdetmap_->FindLayer (detID , cached_detid , cached_layer , cached_XYbin);
244  const StripGeomDetUnit *theGeomDet = dynamic_cast < const StripGeomDetUnit * >(theTracker.idToDet (detID));
245  if (theGeomDet != 0)
246  {
247  const StripTopology *topol = dynamic_cast < const StripTopology * >(&(theGeomDet->specificTopology ()));
248  if (topol != 0)
249  {
250  // get the cluster position in local coordinates (cm)
251  LocalPoint clustlp = topol->localPosition (hit2D->cluster()->barycenter ());
252  GlobalPoint clustgp = theGeomDet->surface ().toGlobal (clustlp);
253 
254  //NORMALIZE HISTO IF ASKED
255  float etaWeight = 1.;
256  float phiWeight = 1.;
257  if (normalize_){
258  etaWeight = GetEtaWeight(label, clustgp);
259  phiWeight = GetPhiWeight(label,clustgp);
260  }
261  if(!isL3MuTrack){
262  LayerMEMap[label.c_str ()].EtaDistribOnTrackClustersMap->Fill (clustgp.eta (),etaWeight);
263  LayerMEMap[label.c_str ()].PhiDistribOnTrackClustersMap->Fill (clustgp.phi (),phiWeight);
264  LayerMEMap[label.c_str ()].EtaPhiOnTrackClustersMap->Fill (clustgp.eta (), clustgp.phi ());
265  tkmapOnTrackClusters->add(detID,1.);
266  }
267  else{
268  LayerMEMap[label.c_str ()].EtaDistribL3MuTrackClustersMap->Fill (clustgp.eta (),etaWeight);
269  LayerMEMap[label.c_str ()].PhiDistribL3MuTrackClustersMap->Fill (clustgp.phi (),phiWeight);
270  LayerMEMap[label.c_str ()].EtaPhiL3MuTrackClustersMap->Fill (clustgp.eta (), clustgp.phi ());
271  tkmapL3MuTrackClusters->add(detID,1.);
272  }
273  }
274  }
275  }
276  // if SiStripMatchedRecHit2D
277  if (hitMatched2D != 0)
278  {
279  //hit mono
280  detID = hitMatched2D->monoId();
281  int layer = tkdetmap_->FindLayer (detID , cached_detid , cached_layer , cached_XYbin);
283  const StripGeomDetUnit *theGeomDet = dynamic_cast < const StripGeomDetUnit * >(theTracker.idToDet (detID));
284  if (theGeomDet != 0)
285  {
286  const StripTopology *topol = dynamic_cast < const StripTopology * >(&(theGeomDet->specificTopology ()));
287  if (topol != 0)
288  {
289  // get the cluster position in local coordinates (cm)
290  LocalPoint clustlp = topol->localPosition (hitMatched2D->monoCluster().barycenter ());
291  GlobalPoint clustgp = theGeomDet->surface ().toGlobal (clustlp);
292  //NORMALIZE HISTO IF ASKED
293  float etaWeight = 1.;
294  float phiWeight = 1.;
295  if (normalize_){
296  etaWeight = GetEtaWeight(label, clustgp);
297  phiWeight = GetPhiWeight(label,clustgp);
298  }
299  if(!isL3MuTrack){
300  LayerMEMap[label.c_str ()].EtaDistribOnTrackClustersMap->Fill (clustgp.eta (),etaWeight);
301  LayerMEMap[label.c_str ()].PhiDistribOnTrackClustersMap->Fill (clustgp.phi (),phiWeight);
302  LayerMEMap[label.c_str ()].EtaPhiOnTrackClustersMap->Fill (clustgp.eta (), clustgp.phi ());
303  tkmapOnTrackClusters->add(detID,1.);
304  }
305  else{
306  LayerMEMap[label.c_str ()].EtaDistribL3MuTrackClustersMap->Fill (clustgp.eta (),etaWeight);
307  LayerMEMap[label.c_str ()].PhiDistribL3MuTrackClustersMap->Fill (clustgp.phi (),phiWeight);
308  LayerMEMap[label.c_str ()].EtaPhiL3MuTrackClustersMap->Fill (clustgp.eta (), clustgp.phi ());
309  tkmapL3MuTrackClusters->add(detID,1.);
310  }
311  }
312  }
313 
314  //hit stereo
315  detID = hitMatched2D->stereoId ();
317  label = tkdetmap_->getLayerName (layer);
318  const StripGeomDetUnit *theGeomDet2 = dynamic_cast < const StripGeomDetUnit * >(theTracker.idToDet (detID));
319  if (theGeomDet2 != 0)
320  {
321  const StripTopology *topol = dynamic_cast < const StripTopology * >(&(theGeomDet2->specificTopology ()));
322  if (topol != 0)
323  {
324  // get the cluster position in local coordinates (cm)
325  LocalPoint clustlp = topol->localPosition (hitMatched2D->stereoCluster().barycenter ());
326  GlobalPoint clustgp = theGeomDet2->surface ().toGlobal (clustlp);
327  //NORMALIZE HISTO IF ASKED
328  float etaWeight = 1.;
329  float phiWeight = 1.;
330  if (normalize_){
331  etaWeight = GetEtaWeight(label, clustgp);
332  phiWeight = GetPhiWeight(label,clustgp);
333  }
334  if(!isL3MuTrack){
335  LayerMEMap[label.c_str ()].EtaDistribOnTrackClustersMap->Fill (clustgp.eta (),etaWeight);
336  LayerMEMap[label.c_str ()].PhiDistribOnTrackClustersMap->Fill (clustgp.phi (),phiWeight);
337  LayerMEMap[label.c_str ()].EtaPhiOnTrackClustersMap->Fill (clustgp.eta (), clustgp.phi ());
338  tkmapOnTrackClusters->add(detID,1.);
339  }
340  else{
341  LayerMEMap[label.c_str ()].EtaDistribL3MuTrackClustersMap->Fill (clustgp.eta (),etaWeight);
342  LayerMEMap[label.c_str ()].PhiDistribL3MuTrackClustersMap->Fill (clustgp.phi (),phiWeight);
343  LayerMEMap[label.c_str ()].EtaPhiL3MuTrackClustersMap->Fill (clustgp.eta (), clustgp.phi ());
344  tkmapL3MuTrackClusters->add(detID,1.);
345  }
346  }
347  }
348 
349  }
350 
351  //if ProjectedSiStripRecHit2D
352  if (hitProj2D != 0)
353  {
354  detID = hitProj2D->geographicalId ();
355  int layer = tkdetmap_->FindLayer (detID , cached_detid , cached_layer , cached_XYbin);
357  const StripGeomDetUnit *theGeomDet = dynamic_cast < const StripGeomDetUnit * >(theTracker.idToDet (detID));
358  if (theGeomDet != 0)
359  {
360  const StripTopology *topol = dynamic_cast < const StripTopology * >(&(theGeomDet->specificTopology ()));
361  if (topol != 0)
362  {
363  // get the cluster position in local coordinates (cm)
364  LocalPoint clustlp = topol->localPosition (hitProj2D->cluster()->barycenter ());
365  GlobalPoint clustgp = theGeomDet->surface ().toGlobal (clustlp);
366  //NORMALIZE HISTO IF ASKED
367  float etaWeight = 1.;
368  float phiWeight = 1.;
369  if (normalize_){
370  etaWeight = GetEtaWeight(label, clustgp);
371  phiWeight = GetPhiWeight(label,clustgp);
372  }
373  if(!isL3MuTrack){
374  LayerMEMap[label.c_str ()].EtaDistribOnTrackClustersMap->Fill (clustgp.eta (),etaWeight);
375  LayerMEMap[label.c_str ()].PhiDistribOnTrackClustersMap->Fill (clustgp.phi (),phiWeight);
376  LayerMEMap[label.c_str ()].EtaPhiOnTrackClustersMap->Fill (clustgp.eta (), clustgp.phi ());
377  tkmapOnTrackClusters->add(detID,1.);
378  }
379  else{
380  LayerMEMap[label.c_str ()].EtaDistribL3MuTrackClustersMap->Fill (clustgp.eta (),etaWeight);
381  LayerMEMap[label.c_str ()].PhiDistribL3MuTrackClustersMap->Fill (clustgp.phi (),phiWeight);
382  LayerMEMap[label.c_str ()].EtaPhiL3MuTrackClustersMap->Fill (clustgp.eta (), clustgp.phi ());
383  tkmapL3MuTrackClusters->add(detID,1.);
384  }
385  }
386  }
387  }
388 
389  }
390  } //loop over RecHits
391 }
392 
393 void
395 {
396 
397  // vector used
398  std::vector <float *> tgraphEta;
399  std::vector <float *> tgraphPhi;
400  std::vector <int> tgraphSize;
401 
402  std::vector <std::vector<float> > binningEta;
403  std::vector <std::vector<float> > binningPhi;
404 
405  for (int p = 0; p < 34; p++){
406  tgraphEta.push_back (new float[1000]);
407  tgraphPhi.push_back (new float[1000]);
408  }
409 
410  // FOR COMPUTING BINNING
411  std::map< std::string,std::vector<float> > m_BinEta_Prel ;
412  std::map< std::string,std::vector<float> > m_PhiStripMod_Eta;
413  std::map< std::string,std::vector<float> > m_PhiStripMod_Nb;
414 
415  //----------------
416 
417  //Get the tracker geometry
419  es.get < TrackerDigiGeometryRecord > ().get (TG);
420  const TrackerGeometry *theTrackerGeometry = TG.product ();
421  const TrackerGeometry & theTracker (*theTrackerGeometry);
422 
423  std::vector<DetId> Dets = theTracker.detUnitIds();
424 
425 
426  //CALL GEOMETRY METHOD
427  GeometryFromTrackGeom(Dets,theTracker,es,m_PhiStripMod_Eta,m_PhiStripMod_Nb);
428 
429 
434 
435  std::string fullName, folder;
436 
437  //STRUCTURE OF DETECTORS
438  int p =0;
439 
440  //Loop over layers
441  for (int layer = 1; layer < HistoNumber; ++layer)
442  {
443  SiStripFolderOrganizer folderOrg;
444  std::stringstream ss;
446  uint32_t subdetlayer, side;
447  tkdetmap_->getSubDetLayerSide (layer, subDet, subdetlayer, side);
448  folderOrg.getSubDetLayerFolderName (ss, subDet, subdetlayer, side);
449  folder = ss.str ();
450  ibooker.setCurrentFolder (monitorName_ + folder);
451 
452  LayerMEs layerMEs;
453  layerMEs.EtaPhiAllClustersMap = 0;
454  layerMEs.EtaDistribAllClustersMap = 0;
455  layerMEs.PhiDistribAllClustersMap = 0;
456  layerMEs.EtaPhiOnTrackClustersMap = 0;
457  layerMEs.EtaDistribOnTrackClustersMap = 0;
458  layerMEs.PhiDistribOnTrackClustersMap = 0;
459  layerMEs.EtaPhiL3MuTrackClustersMap = 0;
460  layerMEs.EtaDistribL3MuTrackClustersMap = 0;
461  layerMEs.PhiDistribL3MuTrackClustersMap = 0;
462 
463  std::string histoname;
465  std::string labelHisto = tkdetmap_->getLayerName (layer);
466 
467  std::string labelHisto_ID = labelHisto;
468  labelHisto_ID.erase(3);
469 
470  //
471  unsigned int sizePhi = 0;
472  unsigned int sizeEta = 0;
473  float * xbinsPhi = new float[100];
474  float * xbinsEta = new float[100];
475 
476  //TEC && TID && TOB && TIB
477  if (labelHisto_ID == "TEC" || labelHisto_ID == "TID" || labelHisto_ID == "TOB" || labelHisto_ID == "TIB"){
478 
479  // PHI BINNING
480  //ADDING BORDERS
481  m_BinPhi[labelHisto].push_back(-M_PI);
482  m_BinPhi[labelHisto].push_back(M_PI);
483 
484  //SORTING
485  sort(m_BinPhi[labelHisto].begin(),m_BinPhi[labelHisto].end());
486  //CREATING XBIN VECTOR
487  sizePhi = m_BinPhi[labelHisto].size();
488 
489  for (unsigned int i = 0; i < sizePhi; i++){
490  xbinsPhi[i] = m_BinPhi[labelHisto][i];
491  }
492 
493  //ETA BINNING
494  std::vector <float > v_BinEta_Prel;
495  // LOOPING ON RINGS
496  for (unsigned int i = 0; i < 12; i++){
497  // COMPUTE BARYCENTER IF NON NULL
498  if (m_PhiStripMod_Nb[labelHisto][i] != 0 && fabs(m_PhiStripMod_Eta[labelHisto][i]) > 0.05){
499  float EtaBarycenter = m_PhiStripMod_Eta[labelHisto][i]/m_PhiStripMod_Nb[labelHisto][i];
500  v_BinEta_Prel.push_back(EtaBarycenter);
501  }
502  }
503 
504  //SORT THEM IN ETA
505  sort(v_BinEta_Prel.begin(),v_BinEta_Prel.end());
506 
507  //RECOMPUTE THE BINS BY TAKING THE HALF OF THE DISTANCE
508  for (unsigned int i = 0; i < v_BinEta_Prel.size(); i++){
509  if (i == 0) m_BinEta[labelHisto].push_back(v_BinEta_Prel[i] - 0.15);
510  if (i != 0) {
511  float shift = v_BinEta_Prel[i] - v_BinEta_Prel[i-1];
512  m_BinEta[labelHisto].push_back(v_BinEta_Prel[i] - shift/2.);
513  }
514  if (i == v_BinEta_Prel.size()-1) m_BinEta[labelHisto].push_back(v_BinEta_Prel[i] + 0.15);
515  }
516 
517  sort(m_BinEta[labelHisto].begin(),m_BinEta[labelHisto].end());
518 
519  //CREATING XBIN VECTOR
520  sizeEta = m_BinEta[labelHisto].size();
521 
522  for (unsigned int i = 0; i < sizeEta; i++){
523  xbinsEta[i] = m_BinEta[labelHisto][i];
524  }
525 
526  } // END SISTRIP DETECTORS
527 
528  // all clusters
529  if(runOnClusters_){
530  histoname = "EtaAllClustersDistrib_" + labelHisto;
531  title = "#eta(All Clusters) in " + labelHisto;
532  layerMEs.EtaDistribAllClustersMap = ibooker.book1D (histoname, title, sizeEta - 1, xbinsEta);
533  histoname = "PhiAllClustersDistrib_" + labelHisto;
534  title = "#phi(All Clusters) in " + labelHisto;
535  layerMEs.PhiDistribAllClustersMap = ibooker.book1D (histoname, title, sizePhi - 1, xbinsPhi);
536  histoname = "EtaPhiAllClustersMap_" + labelHisto;
537  title = "#eta-#phi All Clusters map in " + labelHisto;
538  layerMEs.EtaPhiAllClustersMap = ibooker.book2D (histoname, title, sizeEta - 1, xbinsEta, sizePhi - 1, xbinsPhi);
539  }
540  // on track clusters
541  if(runOnTracks_){
542  histoname = "EtaOnTrackClustersDistrib_" + labelHisto;
543  title = "#eta(OnTrack Clusters) in " + labelHisto;
544  layerMEs.EtaDistribOnTrackClustersMap = ibooker.book1D (histoname, title, sizeEta - 1, xbinsEta);
545  histoname = "PhiOnTrackClustersDistrib_" + labelHisto;
546  title = "#phi(OnTrack Clusters) in " + labelHisto;
547  layerMEs.PhiDistribOnTrackClustersMap = ibooker.book1D (histoname, title, sizePhi - 1, xbinsPhi);
548  histoname = "EtaPhiOnTrackClustersMap_" + labelHisto;
549  title = "#eta-#phi OnTrack Clusters map in " + labelHisto;
550  layerMEs.EtaPhiOnTrackClustersMap = ibooker.book2D (histoname, title, sizeEta - 1, xbinsEta, sizePhi - 1, xbinsPhi);
551  }
553  // L3 muon track clusters
554  histoname = "EtaL3MuTrackClustersDistrib_" + labelHisto;
555  title = "#eta(L3MuTrack Clusters) in " + labelHisto;
556  layerMEs.EtaDistribL3MuTrackClustersMap = ibooker.book1D (histoname, title, sizeEta - 1, xbinsEta);
557  histoname = "PhiL3MuTrackClustersDistrib_" + labelHisto;
558  title = "#phi(L3MuTrack Clusters) in " + labelHisto;
559  layerMEs.PhiDistribL3MuTrackClustersMap = ibooker.book1D (histoname, title, sizePhi - 1, xbinsPhi);
560  histoname = "EtaPhiL3MuTrackClustersMap_" + labelHisto;
561  title = "#eta-#phi L3MuTrack Clusters map in " + labelHisto;
562  layerMEs.EtaPhiL3MuTrackClustersMap = ibooker.book2D (histoname, title, sizeEta - 1, xbinsEta, sizePhi - 1, xbinsPhi);
563  }
564  LayerMEMap[labelHisto] = layerMEs;
565 
566  //PUTTING ERRORS
567  if(runOnClusters_){
568  LayerMEMap[labelHisto].EtaDistribAllClustersMap->getTH1F()->Sumw2();
569  LayerMEMap[labelHisto].PhiDistribAllClustersMap->getTH1F()->Sumw2();
570  LayerMEMap[labelHisto].EtaPhiAllClustersMap->getTH2F()->Sumw2();
571  }
572  if(runOnTracks_){
573  LayerMEMap[labelHisto].EtaDistribOnTrackClustersMap->getTH1F()->Sumw2();
574  LayerMEMap[labelHisto].PhiDistribOnTrackClustersMap->getTH1F()->Sumw2();
575  LayerMEMap[labelHisto].EtaPhiOnTrackClustersMap->getTH2F()->Sumw2();
576  }
578  LayerMEMap[labelHisto].EtaDistribL3MuTrackClustersMap->getTH1F()->Sumw2();
579  LayerMEMap[labelHisto].PhiDistribL3MuTrackClustersMap->getTH1F()->Sumw2();
580  LayerMEMap[labelHisto].EtaPhiL3MuTrackClustersMap->getTH2F()->Sumw2();
581  }
582 
583  p++;
584  } //end of loop over layers
585 
586 
587  //CALL THE NORMALIZATION METHOD
588  Normalizer(Dets,theTracker);
589 
590 } //end of method
591 
592 
593 void
594 SiStripMonitorMuonHLT::GeometryFromTrackGeom (const std::vector<DetId>& Dets,const TrackerGeometry & theTracker, const edm::EventSetup& es,
595  std::map< std::string,std::vector<float> > & m_PhiStripMod_Eta,std::map< std::string,std::vector<float> > & m_PhiStripMod_Nb){
596 
597  //Retrieve tracker topology from geometry
598  edm::ESHandle<TrackerTopology> tTopoHandle;
599  es.get<TrackerTopologyRcd>().get(tTopoHandle);
600  const TrackerTopology* const tTopo = tTopoHandle.product();
601 
602  std::vector<std::string> v_LabelHisto;
603 
604  //Loop over DetIds
605  //-----------------------------------------
606  for(std::vector<DetId>::const_iterator detid_iterator = Dets.begin(); detid_iterator!=Dets.end(); ++detid_iterator){
607  uint32_t detid = (*detid_iterator)();
608 
609  if ( (*detid_iterator).null() == true) break;
610  if (detid == 0) break;
611 
612  // Select the propers detectors - avoid pixels
613  const GeomDetUnit * GeomDet = theTracker.idToDetUnit(detid);
614  const GeomDet::SubDetector detector = GeomDet->subDetector();
615 
616  int mylayer;
617  std::string mylabelHisto;
618 
619  // SELECT SISTRIP DETECTORS
620  if (detector == GeomDetEnumerators::TEC
621  || detector == GeomDetEnumerators::TID
622  || detector == GeomDetEnumerators::TOB
623  || detector == GeomDetEnumerators::TIB
624  ){
625 
626  const StripGeomDetUnit *theGeomDet = dynamic_cast < const StripGeomDetUnit * >(theTracker.idToDet (detid));
627  const StripTopology *topol = dynamic_cast < const StripTopology * >(&(theGeomDet->specificTopology ()));
628 
629  // Get the position of the 1st strip in local coordinates (cm)
630  LocalPoint clustlp = topol->localPosition (1.);
631  GlobalPoint clustgp = theGeomDet->surface ().toGlobal (clustlp);
632 
633  // Get the eta, phi of modules
634  mylayer = tkdetmap_->FindLayer (detid , cached_detid , cached_layer , cached_XYbin);
635  mylabelHisto = tkdetmap_->getLayerName (mylayer);
636 
637  // SiStripDetId stripdet = SiStripDetId(detid);
638 
639  // INITIALISATION OF m_PhiStripMod_Eta + BOOKING LAYERS
640 
641  //TEST IF NEW LAYER
642  unsigned int count = 0;
643  while (count < v_LabelHisto.size()){
644  if (mylabelHisto == v_LabelHisto[count]) break;
645  count++;
646  }
647  if (count == v_LabelHisto.size()){
648 
649  //FILL THE NEW LAYER
650  v_LabelHisto.push_back(mylabelHisto);
651 
652  //INITIALIZE
653 
654  // LOOPING ON RINGS
655  for (int i = 0; i < 12; i++){
656  m_PhiStripMod_Eta[mylabelHisto].push_back(0.);
657  m_PhiStripMod_Nb[mylabelHisto].push_back(0.);
658  }
659  }
660 
661  //TEC
662  if (detector == GeomDetEnumerators::TEC ){
663 
664 
665 
666  //PHI BINNING
667  //Select 7th ring
668  if (tTopo->tecRing(detid) == 7){
669  //SELECT FP
670  if (tTopo->tecModule(detid) == 1 && tTopo->tecIsFrontPetal(detid) == true) m_BinPhi[mylabelHisto].push_back(clustgp.phi());
671  //SELECT BP
672  if (tTopo->tecModule(detid) == 1 && tTopo->tecIsBackPetal(detid) == true) m_BinPhi[mylabelHisto].push_back(clustgp.phi());
673  }
674 
675  //ETA BINNING
676  //Select arbitrary petal
677  if (tTopo->tecPetalNumber(detid) == 1 ){
678  m_PhiStripMod_Eta[mylabelHisto][tTopo->tecRing(detid)-1] = m_PhiStripMod_Eta[mylabelHisto][tTopo->tecRing(detid)-1] + clustgp.eta();
679  m_PhiStripMod_Nb[mylabelHisto][tTopo->tecRing(detid)-1]++;
680  }
681 
682  } //END TEC
683 
684  //TID
685  if (detector == GeomDetEnumerators::TID ){
686 
687 
688 
689  //PHI BINNING
690  //Select 1st ring
691  if (tTopo->tecRing(detid) == 1){
692  //SELECT MONO
693  if (tTopo->tecIsFrontPetal(detid) == true && tTopo->tecIsStereo(detid) == false) m_BinPhi[mylabelHisto].push_back(clustgp.phi());
694  //SELECT STEREO
695  if (tTopo->tecIsFrontPetal(detid) == true && tTopo->tecIsStereo(detid) == true) m_BinPhi[mylabelHisto].push_back(clustgp.phi());
696  }
697 
698  //ETA BINNING
699  //Select arbitrary line in eta (phi fixed)
700  if (tTopo->tecModule(detid) == 1){
701  m_PhiStripMod_Eta[mylabelHisto][tTopo->tecRing(detid)-1] = m_PhiStripMod_Eta[mylabelHisto][tTopo->tecRing(detid)-1] + clustgp.eta();
702  m_PhiStripMod_Nb[mylabelHisto][tTopo->tecRing(detid)-1]++;
703  }
704 
705  } //END TID
706 
707  //TOB
708  if (detector == GeomDetEnumerators::TOB ){
709 
710 
711  //PHI BINNING
712  //Select arbitrary line in phi (detid)ta fixed)
713  if (tTopo->tecModule(detid) == 1 && tTopo->tecIsZMinusSide(detid) == true){
714  //SELECT MONO
715  if (tTopo->tecIsStereo(detid) == false) m_BinPhi[mylabelHisto].push_back(clustgp.phi());
716  }
717 
718  //ETA BINNING
719  //Select arbitrary rod
720  if ( (tTopo->tobRod(detid) == 2 && tTopo->tobIsStereo(detid) == false)
721  || (tTopo->tobRod(detid) == 1 && tTopo->tobIsStereo(detid) == true)
722  ){
723  if (tTopo->tobIsZMinusSide(detid) == true){
724  m_PhiStripMod_Eta[mylabelHisto][tTopo->tobModule(detid)-1] = m_PhiStripMod_Eta[mylabelHisto][tTopo->tobModule(detid)-1] + clustgp.eta();
725  m_PhiStripMod_Nb[mylabelHisto][tTopo->tobModule(detid)-1]++;
726  }
727  if (tTopo->tobIsZMinusSide(detid) == false){
728  m_PhiStripMod_Eta[mylabelHisto][tTopo->tobModule(detid)+5] = m_PhiStripMod_Eta[mylabelHisto][tTopo->tobModule(detid)+5] + clustgp.eta();
729  m_PhiStripMod_Nb[mylabelHisto][tTopo->tobModule(detid)+5]++;
730  }
731  }
732 
733  } //END TOB
734 
735  //TIB
736  if (detector == GeomDetEnumerators::TIB ){
737 
738 
739 
740  //PHI BINNING
741  //Select arbitrary line in phi (eta fixed)
742  if (tTopo->tibModule(detid) == 1 && tTopo->tibIsZMinusSide(detid) == true){
743  //SELECT MONO
744  if (tTopo->tibIsInternalString(detid) == true && tTopo->tibIsStereo(detid) == false) m_BinPhi[mylabelHisto].push_back(clustgp.phi());
745  }
746 
747  //ETA BINNING
748  //Select arbitrary string
749  if ( (tTopo->tibString(detid) == 2 && tTopo->tibIsStereo(detid) == false)
750  || (tTopo->tibString(detid) == 1 && tTopo->tibIsStereo(detid) == true)
751  ){
752  if (tTopo->tibIsZMinusSide(detid) == true){
753  if (tTopo->tibIsInternalString(detid) == true){
754  m_PhiStripMod_Eta[mylabelHisto][tTopo->tibModule(detid)-1] = m_PhiStripMod_Eta[mylabelHisto][tTopo->tibModule(detid)-1] + clustgp.eta();
755  m_PhiStripMod_Nb[mylabelHisto][tTopo->tibModule(detid)-1]++;
756  }
757  if (tTopo->tibIsInternalString(detid) == false){
758  m_PhiStripMod_Eta[mylabelHisto][tTopo->tibModule(detid)+2] = m_PhiStripMod_Eta[mylabelHisto][tTopo->tibModule(detid)+2] + clustgp.eta();
759  m_PhiStripMod_Nb[mylabelHisto][tTopo->tibModule(detid)+2]++;
760  }
761  }
762  if (tTopo->tibIsZMinusSide(detid) == false){
763  if (tTopo->tibIsInternalString(detid) == true){
764  m_PhiStripMod_Eta[mylabelHisto][tTopo->tibModule(detid)+5] = m_PhiStripMod_Eta[mylabelHisto][tTopo->tibModule(detid)+5] + clustgp.eta();
765  m_PhiStripMod_Nb[mylabelHisto][tTopo->tibModule(detid)+5]++;
766  }
767  if (tTopo->tibIsInternalString(detid) == false){
768  m_PhiStripMod_Eta[mylabelHisto][tTopo->tibModule(detid)+8] = m_PhiStripMod_Eta[mylabelHisto][tTopo->tibModule(detid)+8] + clustgp.eta();
769  m_PhiStripMod_Nb[mylabelHisto][tTopo->tibModule(detid)+8]++;
770  }
771  }
772  }
773 
774  } //END TIB
775 
776  } // END SISTRIP DETECTORS
777  } // END DETID LOOP
778 
779 } //END OF METHOD
780 
781 
782 
783 void
784 SiStripMonitorMuonHLT::Normalizer (const std::vector<DetId>& Dets,const TrackerGeometry & theTracker){
785 
786 
787  std::vector<std::string> v_LabelHisto;
788 
789  //Loop over DetIds
790  //-----------------------------------------
791  for(std::vector<DetId>::const_iterator detid_iterator = Dets.begin(); detid_iterator!=Dets.end(); detid_iterator++){
792  uint32_t detid = (*detid_iterator)();
793 
794  if ( (*detid_iterator).null() == true) break;
795  if (detid == 0) break;
796 
797  // Select the propers detectors - avoid pixels
798  const GeomDetUnit * GeomDet = theTracker.idToDetUnit(detid);
799  const GeomDet::SubDetector detector = GeomDet->subDetector();
800 
801  int mylayer;
802  std::string mylabelHisto;
803 
804  // SELECT SISTRIP DETECTORS
805  if (detector == GeomDetEnumerators::TEC
806  || detector == GeomDetEnumerators::TID
807  || detector == GeomDetEnumerators::TOB
808  || detector == GeomDetEnumerators::TIB
809  ){
810 
811  const StripGeomDetUnit *theGeomDet = dynamic_cast < const StripGeomDetUnit * >(theTracker.idToDet (detid));
812  // const StripTopology *topol = dynamic_cast < const StripTopology * >(&(theGeomDet->specificTopology ()));
813 
814  // Get the eta, phi of modules
815  mylayer = tkdetmap_->FindLayer (detid , cached_detid , cached_layer , cached_XYbin);
816  mylabelHisto = tkdetmap_->getLayerName (mylayer);
817 
818  // SiStripDetId stripdet = SiStripDetId(detid);
819 
820  // INITIALISATION OF m_ModNormEta + BOOKING LAYERS
821 
822  //TEST IF NEW LAYER
823  unsigned int count = 0;
824 
825  while (count < v_LabelHisto.size()){
826  if (mylabelHisto == v_LabelHisto[count]) break;
827  count++;
828  }
829 
830  if (count == v_LabelHisto.size()){
831  //FILL THE NEW LAYER
832  v_LabelHisto.push_back(mylabelHisto);
833 
834  //INITIALIZE
835  // LOOPING ON ETA VECTOR
836  for (unsigned int i = 0; i < m_BinEta[mylabelHisto].size() -1; i++){
837  m_ModNormEta[mylabelHisto].push_back(0.);
838  }
839 
840  // LOOPING ON PHI VECTOR
841  for (unsigned int i = 0; i < m_BinPhi[mylabelHisto].size() -1; i++){
842  m_ModNormPhi[mylabelHisto].push_back(0.);
843  }
844  }
845 
846  // Get the position of the 1st strip in local coordinates (cm)
847  // LocalPoint clustlp_1 = topol->localPosition (1.);
848  // GlobalPoint clustgp_1 = theGeomDet->surface ().toGlobal (clustlp_1);
849 
850  // Get the position of the center of the module
851  LocalPoint clustlp(0.,0.);
852  GlobalPoint clustgp = theGeomDet->surface ().toGlobal (clustlp);
853 
854  // Get the position of the last strip
855  // LocalPoint Border_clustlp = topol->localPosition (topol->nstrips());
856  // GlobalPoint Border_clustgp = theGeomDet->surface ().toGlobal (Border_clustlp);
857 
858  //GETTING SURFACE VALUE
859  const BoundPlane& GeomDetSurface = GeomDet->surface();
860  const Bounds& bound = GeomDetSurface.bounds();
861 
862  std::string labelHisto_ID = mylabelHisto;
863  labelHisto_ID.erase(3);
864 
865  float length = 0.;
866  float width = 0.;
867 
868  std::vector <GlobalPoint> v_Edge_G;
869 
870  float ratio = 0.;
871  float factor = 1.;
872 
873  //RECTANGULAR BOUNDS
874  if (labelHisto_ID == "TOB" || labelHisto_ID == "TIB"){
875  const RectangularPlaneBounds *rectangularBound = dynamic_cast < const RectangularPlaneBounds * >(& bound);
876  length = rectangularBound->length();
877  width = rectangularBound->width();
878  ratio = width/length;
879 
880  //EDGES POINTS
881  LocalPoint topleft(-width/2., length/2.);
882  LocalPoint topright(width/2., length/2.); LocalPoint botleft(-width/2., -length/2.);
883  LocalPoint botright(width/2., -length/2.);
884  v_Edge_G.push_back(theGeomDet->surface ().toGlobal (topleft));
885  v_Edge_G.push_back(theGeomDet->surface ().toGlobal (topright));
886  v_Edge_G.push_back(theGeomDet->surface ().toGlobal (botleft)); v_Edge_G.push_back(theGeomDet->surface ().toGlobal (botright));
887  }
888  //TRAPEZOIDAL BOUNDS
889  if (labelHisto_ID == "TEC" || labelHisto_ID == "TID"){
890  const TrapezoidalPlaneBounds *trapezoidalBound = dynamic_cast < const TrapezoidalPlaneBounds * >(& bound);
891 
892  length = trapezoidalBound->length();
893  width = trapezoidalBound->widthAtHalfLength();
894 
895  ratio = width/length;
896 
897  //EDGES POINTS
898  LocalPoint topleft(-width/2., length/2.);
899  LocalPoint topright(width/2., length/2.);
900  LocalPoint botleft(-width/2., -length/2.);
901  LocalPoint botright(width/2., -length/2.);
902 
903  v_Edge_G.push_back(theGeomDet->surface ().toGlobal (topleft));
904  v_Edge_G.push_back(theGeomDet->surface ().toGlobal (topright));
905  v_Edge_G.push_back(theGeomDet->surface ().toGlobal (botleft));
906  v_Edge_G.push_back(theGeomDet->surface ().toGlobal (botright));
907  }
908 
909  //SORTING EDGES POINTS
910  GlobalPoint top_left_G;
911  GlobalPoint top_rightG;
912  GlobalPoint bot_left_G;
913  GlobalPoint bot_rightG;
914 
915  std::vector <bool> v_Fill;
916  v_Fill.push_back(false);
917  v_Fill.push_back(false);
918  v_Fill.push_back(false);
919  v_Fill.push_back(false);
920 
921  for (unsigned int i =0 ; i< v_Edge_G.size() ; i++){
922  if (v_Edge_G[i].eta() < clustgp.eta()){
923  if (v_Edge_G[i].phi() < clustgp.phi()) {
924  bot_left_G = v_Edge_G[i];
925  v_Fill[0] = true;
926  }
927  if (v_Edge_G[i].phi() > clustgp.phi()){
928  top_left_G = v_Edge_G[i];
929  v_Fill[1] = true;
930  }
931  }
932  if (v_Edge_G[i].eta() > clustgp.eta()){
933  if (v_Edge_G[i].phi() < clustgp.phi()){
934  bot_rightG = v_Edge_G[i];
935  v_Fill[2] = true;
936  }
937  if (v_Edge_G[i].phi() > clustgp.phi()){
938  top_rightG = v_Edge_G[i];
939  v_Fill[3] = true;
940  }
941  }
942  }
943 
944  //USE EDGES FOR COMPUTING WIDTH AND LENGTH
945 
946  float G_length = 0.;
947  float G_width = 0.;
948 
949  bool flag_border = false;
950 
951  if (v_Fill[0] == true
952  && v_Fill[1] == true
953  && v_Fill[2] == true
954  && v_Fill[3] == true){
955 
956  //LENGTH BETWEEN TL AND TR
957  G_length = sqrt( (top_left_G.x()-top_rightG.x())*(top_left_G.x()-top_rightG.x()) + (top_left_G.y()-top_rightG.y())*(top_left_G.y()-top_rightG.y()) + (top_left_G.z()-top_rightG.z())*(top_left_G.z()-top_rightG.z()) );
958 
959  //WIDTH BETWEEN BL AND TL
960  G_width = sqrt( (bot_left_G.x()-top_left_G.x())*(bot_left_G.x()-top_left_G.x()) + (bot_left_G.y()-top_left_G.y())*(bot_left_G.y()-top_left_G.y()) + (bot_left_G.z()-top_left_G.z())*(bot_left_G.z()-top_left_G.z()) );
961 
962  }
963  else {
964 
965  // MODULE IN THE PHI BORDER (-PI,PI)
966  flag_border = true;
967 
968  //SORT THE EDGES POINTS
969  for (unsigned int i =0 ; i< v_Edge_G.size() ; i++){
970 
971  if (v_Edge_G[i].phi() > 0. ){
972  if (v_Edge_G[i].eta() < clustgp.eta()){
973  bot_left_G = v_Edge_G[i];
974  }
975  if (v_Edge_G[i].eta() > clustgp.eta()){
976  bot_rightG = v_Edge_G[i];
977  }
978  }
979  if (v_Edge_G[i].phi() < 0. ){
980  if (v_Edge_G[i].eta() < clustgp.eta()){
981  top_left_G = v_Edge_G[i];
982  }
983  if (v_Edge_G[i].eta() > clustgp.eta()){
984  top_rightG = v_Edge_G[i];
985  }
986  }
987  }
988 
989  // XYZ WIDTH AND LENGTH
990  G_length = sqrt( (top_left_G.x()-top_rightG.x())*(top_left_G.x()-top_rightG.x()) + (top_left_G.y()-top_rightG.y())*(top_left_G.y()-top_rightG.y()) + (top_left_G.z()-top_rightG.z())*(top_left_G.z()-top_rightG.z()) );
991  G_width = G_length*ratio;
992  }
993 
994 
995  //ETA PLOTS
996  //unsigned int LastBinEta = m_BinEta[mylabelHisto].size() - 2;
997  for (unsigned int i = 0; i < m_BinEta[mylabelHisto].size() - 1; i++){
998  if (m_BinEta[mylabelHisto][i] <= clustgp.eta() && clustgp.eta() < m_BinEta[mylabelHisto][i+1]){
999 
1000  // NO NEED TO DO CORRECTIONS FOR ETA
1001  m_ModNormEta[mylabelHisto][i] = m_ModNormEta[mylabelHisto][i] + factor*G_length*G_width;
1002 
1003  }
1004  } //END ETA
1005 
1006  //PHI PLOTS
1007  unsigned int LastBinPhi = m_BinPhi[mylabelHisto].size() - 2;
1008  for (unsigned int i = 0; i < m_BinPhi[mylabelHisto].size() - 1; i++){
1009  if (m_BinPhi[mylabelHisto][i] <= clustgp.phi() && clustgp.phi() < m_BinPhi[mylabelHisto][i+1]){
1010 
1011  // SCRIPT TO INTEGRATE THE SURFACE INTO PHI BIN
1012 
1013  float phiMin = std::min(bot_left_G.phi(),bot_rightG.phi());
1014  float phiMax = std::max(top_left_G.phi(),top_rightG.phi());
1015 
1016  bool offlimit_prev = false;
1017  bool offlimit_foll = false;
1018 
1019  if (phiMin < m_BinPhi[mylabelHisto][i]) offlimit_prev = true;
1020  if (i != LastBinPhi){
1021  if (phiMax > m_BinPhi[mylabelHisto][i+1]) offlimit_foll = true;
1022  }
1023 
1024  //LOOKING FOR THE INTERSECTION POINTS
1025  float MidPoint_X_prev;
1026  float MidPoint_Y_prev;
1027  float MidPoint_Z_prev;
1028  float MidPoint_X_foll;
1029  float MidPoint_Y_foll;
1030  float MidPoint_Z_foll;
1031 
1032  // OFF LIMIT IN THE PREVIOUS BIN
1033  if (offlimit_prev){
1034 
1035  // BL TL
1036  float tStar1 = (m_BinPhi[mylabelHisto][i]-bot_left_G.phi())/(top_left_G.phi()-bot_left_G.phi());
1037 
1038  // BR TR
1039  float tStar2 = (m_BinPhi[mylabelHisto][i]-bot_rightG.phi())/(top_rightG.phi()-bot_rightG.phi());
1040 
1041  if (tStar1 < 0.) tStar1 = 0.;
1042  if (tStar2 < 0.) tStar2 = 0.;
1043 
1044  //FIND Z OF STAR POINT
1045  float xStar1 = bot_left_G.x() + (tStar1*1.)*(top_left_G.x()-bot_left_G.x());
1046  float xStar2 = bot_rightG.x() + (tStar2*1.)*(top_rightG.x()-bot_rightG.x());
1047 
1048  float yStar1 = bot_left_G.y() + (tStar1*1.)*(top_left_G.y()-bot_left_G.y());
1049  float yStar2 = bot_rightG.y() + (tStar2*1.)*(top_rightG.y()-bot_rightG.y());
1050 
1051  float zStar1 = bot_left_G.z() + (tStar1*1.)*(top_left_G.z()-bot_left_G.z());
1052  float zStar2 = bot_rightG.z() + (tStar2*1.)*(top_rightG.z()-bot_rightG.z());
1053 
1054  //MIDPOINT
1055  MidPoint_X_prev = (xStar1 + xStar2)/2.;
1056  MidPoint_Y_prev = (yStar1 + yStar2)/2.;
1057  MidPoint_Z_prev = (zStar1 + zStar2)/2.;
1058  }
1059 
1060  if (offlimit_prev == false){
1061  MidPoint_X_prev = (bot_left_G.x() + bot_rightG.x())/2.;
1062  MidPoint_Y_prev = (bot_left_G.y() + bot_rightG.y())/2.;
1063  MidPoint_Z_prev = (bot_left_G.z() + bot_rightG.z())/2.;
1064  }
1065 
1066  // OFF LIMIT IN THE FOLLOWING BIN
1067  if (offlimit_foll){
1068 
1069  // BL TL
1070  float tStar1 = (m_BinPhi[mylabelHisto][i+1]-bot_left_G.phi())/(top_left_G.phi()-bot_left_G.phi());
1071 
1072  // BR TR
1073  float tStar2 = (m_BinPhi[mylabelHisto][i+1]-bot_rightG.phi())/(top_rightG.phi()-bot_rightG.phi());
1074 
1075  if (tStar1 > 1.) tStar1 = 1.;
1076  if (tStar2 > 1.) tStar2 = 1.;
1077 
1078  //FIND Z OF STAR POINT
1079  float xStar1 = bot_left_G.x() + (tStar1*1.)*(top_left_G.x()-bot_left_G.x());
1080  float xStar2 = bot_rightG.x() + (tStar2*1.)*(top_rightG.x()-bot_rightG.x());
1081 
1082  float yStar1 = bot_left_G.y() + (tStar1*1.)*(top_left_G.y()-bot_left_G.y());
1083  float yStar2 = bot_rightG.y() + (tStar2*1.)*(top_rightG.y()-bot_rightG.y());
1084 
1085  float zStar1 = bot_left_G.z() + (tStar1*1.)*(top_left_G.z()-bot_left_G.z());
1086  float zStar2 = bot_rightG.z() + (tStar2*1.)*(top_rightG.z()-bot_rightG.z());
1087 
1088  //MIDPOINT
1089  MidPoint_X_foll = (xStar1 + xStar2)/2.;
1090  MidPoint_Y_foll = (yStar1 + yStar2)/2.;
1091  MidPoint_Z_foll = (zStar1 + zStar2)/2.;
1092  }
1093 
1094  if (offlimit_foll == false){
1095  MidPoint_X_foll = (top_left_G.x() + top_rightG.x())/2.;
1096  MidPoint_Y_foll = (top_left_G.y() + top_rightG.y())/2.;
1097  MidPoint_Z_foll = (top_left_G.z() + top_rightG.z())/2.;
1098  }
1099 
1100  //COMPUTE THE B AND T EDGES
1101  float EdgePoint_X_B = (bot_left_G.x() + bot_rightG.x())/2.;
1102  float EdgePoint_Y_B = (bot_left_G.y() + bot_rightG.y())/2.;
1103  float EdgePoint_Z_B = (bot_left_G.z() + bot_rightG.z())/2.;
1104 
1105  float EdgePoint_X_T = (top_left_G.x() + top_rightG.x())/2.;
1106  float EdgePoint_Y_T = (top_left_G.y() + top_rightG.y())/2.;
1107  float EdgePoint_Z_T = (top_left_G.z() + top_rightG.z())/2.;
1108  // FILL INSIDE WIDTH
1109  float G_width_Ins = sqrt( (MidPoint_X_foll-MidPoint_X_prev)*(MidPoint_X_foll-MidPoint_X_prev) + (MidPoint_Y_foll-MidPoint_Y_prev)*(MidPoint_Y_foll-MidPoint_Y_prev) + (MidPoint_Z_foll-MidPoint_Z_prev)*(MidPoint_Z_foll-MidPoint_Z_prev) );
1110 
1111  //IF BORDER
1112  if (flag_border){
1113 
1114  // A) 3 POINT AND 1 POINT
1115  if (i != 0 && i != LastBinPhi){
1116  m_ModNormPhi[mylabelHisto][i] = m_ModNormPhi[mylabelHisto][i] + factor*G_length*G_width;
1117  }
1118 
1119  // B) MODULE SPLITTED IN TWO
1120  if (i == 0 || i == LastBinPhi){
1121  float PhiBalance = 0.;
1122  if (clustgp.phi() > 0.) PhiBalance = clustgp.phi() - M_PI ;
1123  if (clustgp.phi() < 0.) PhiBalance = clustgp.phi() + M_PI ;
1124 
1125  // Average Phi width of a phi bin
1126  float Phi_Width = m_BinPhi[mylabelHisto][3] - m_BinPhi[mylabelHisto][2];
1127 
1128  float weight_FirstBin = (1.+ (PhiBalance/(Phi_Width/2.)))/2. ;
1129  float weight_LastBin = fabs(1. - weight_FirstBin);
1130 
1131  m_ModNormPhi[mylabelHisto][0] = m_ModNormPhi[mylabelHisto][0] + weight_FirstBin*(factor*G_length*G_width);
1132  m_ModNormPhi[mylabelHisto][LastBinPhi] = m_ModNormPhi[mylabelHisto][LastBinPhi] + weight_LastBin*(factor*G_length*G_width);
1133  }
1134  }
1135 
1136  if (flag_border == false){
1137 
1138  // A) SURFACE TOTALY CONTAINED IN THE BIN
1139  if (offlimit_prev == false && offlimit_foll == false){
1140  m_ModNormPhi[mylabelHisto][i] = m_ModNormPhi[mylabelHisto][i] + factor*G_length*G_width;
1141  }
1142 
1143  // B) SURFACE CONTAINED IN 2 BINS
1144  if ((offlimit_prev == true && offlimit_foll == false)
1145  ||(offlimit_prev == false && offlimit_foll == true) ){
1146  float G_width_Out = fabs(G_width - G_width_Ins);
1147 
1148  //FILL INSIDE CELL
1149  m_ModNormPhi[mylabelHisto][i] = m_ModNormPhi[mylabelHisto][i] + factor*G_width_Ins*G_length;
1150 
1151  //FILL OFF LIMITS CELLS
1152  if (offlimit_prev && i != 0) m_ModNormPhi[mylabelHisto][i-1] = m_ModNormPhi[mylabelHisto][i-1] + factor*G_width_Out*G_length;
1153  if (offlimit_foll && i != LastBinPhi) m_ModNormPhi[mylabelHisto][i+1] = m_ModNormPhi[mylabelHisto][i+1] + factor*G_width_Out*G_length;
1154  }
1155 
1156  // C) SURFACE CONTAINED IN 3 BINS
1157  if (offlimit_prev == true && offlimit_foll == true){
1158 
1159  //COMPUTE OFF LIMITS LENGTHS
1160  float G_width_T = sqrt( (MidPoint_X_foll-EdgePoint_X_T)*(MidPoint_X_foll-EdgePoint_X_T) + (MidPoint_Y_foll-EdgePoint_Y_T)*(MidPoint_Y_foll-EdgePoint_Y_T) + (MidPoint_Z_foll-EdgePoint_Z_T)*(MidPoint_Z_foll-EdgePoint_Z_T) );
1161  float G_width_B = sqrt( (MidPoint_X_prev-EdgePoint_X_B)*(MidPoint_X_prev-EdgePoint_X_B) + (MidPoint_Y_prev-EdgePoint_Y_B)*(MidPoint_Y_prev-EdgePoint_Y_B) + (MidPoint_Z_prev-EdgePoint_Z_B)*(MidPoint_Z_prev-EdgePoint_Z_B) );
1162 
1163  //FOR SAFETY
1164  if (i != 0 && i != LastBinPhi){
1165  //FILL INSIDE CELL
1166  m_ModNormPhi[mylabelHisto][i] = m_ModNormPhi[mylabelHisto][i] + factor*G_width_Ins*G_length;
1167 
1168  //FILL OFF LIMITS CELLS
1169  if (i != 0) m_ModNormPhi[mylabelHisto][i-1] = m_ModNormPhi[mylabelHisto][i-1] + factor*G_width_B*G_length;
1170  if (i != LastBinPhi) m_ModNormPhi[mylabelHisto][i+1] = m_ModNormPhi[mylabelHisto][i+1] + factor*G_width_T*G_length;
1171  }
1172 
1173  }
1174  }
1175  }
1176  } // END PHI
1177 
1178  } // END SISTRIP DETECTORS
1179 
1180  } // END DETID LOOP
1181 
1182  //PRINT NORMALIZATION IF ASKED
1183  if (printNormalize_) {
1184  TFile output("MuonHLTDQMNormalization.root","recreate");
1185  output.cd();
1186  PrintNormalization(v_LabelHisto);
1187  output.Close();
1188  }
1189 
1190 } //END METHOD
1191 
1192 
1193 
1194 void
1195 SiStripMonitorMuonHLT::PrintNormalization (const std::vector<std::string>& v_LabelHisto)
1196 {
1197  std::vector <TH1F *> h_ModNorm_Eta;
1198  std::vector <TH1F *> h_ModNorm_Phi;
1199 
1200  for (unsigned int p = 0; p < v_LabelHisto.size(); p++){
1201 
1202  std::string titleHistoEta = v_LabelHisto[p] + "_eta" ;
1203  std::string titleHistoPhi = v_LabelHisto[p] + "_phi" ;
1204 
1205  std::string labelHisto = v_LabelHisto[p];
1206 
1207  float * xbinsPhi = new float[100];
1208  float * xbinsEta = new float[100];
1209 
1210  //CREATING XBIN VECTOR
1211  unsigned int sizePhi = m_BinPhi[labelHisto].size();
1212  for (unsigned int i = 0; i < sizePhi; i++){
1213  xbinsPhi[i] = m_BinPhi[labelHisto][i];
1214  }
1215  //CREATING XBIN VECTOR
1216  unsigned int sizeEta = m_BinEta[labelHisto].size();
1217  for (unsigned int i = 0; i < sizeEta; i++){
1218  xbinsEta[i] = m_BinEta[labelHisto][i];
1219  }
1220 
1221  h_ModNorm_Eta.push_back(new TH1F (titleHistoEta.c_str(),titleHistoEta.c_str(),sizeEta - 1,xbinsEta));
1222  h_ModNorm_Phi.push_back(new TH1F (titleHistoPhi.c_str(),titleHistoPhi.c_str(),sizePhi - 1,xbinsPhi));
1223 
1224  for (unsigned int i = 0; i < m_ModNormEta[labelHisto].size(); i++){
1225  (*h_ModNorm_Eta[p]).SetBinContent(i+1,m_ModNormEta[labelHisto][i]);
1226  }
1227  for (unsigned int i = 0; i < m_ModNormPhi[labelHisto].size(); i++){
1228  (*h_ModNorm_Phi[p]).SetBinContent(i+1,m_ModNormPhi[labelHisto][i]);
1229  }
1230 
1231  (*h_ModNorm_Eta[p]).Write();
1232  (*h_ModNorm_Phi[p]).Write();
1233  }
1234 
1235 }
1236 
1237 
1239 {
1240  if (monitorName_ != "")
1241  monitorName_ = monitorName_ + "/";
1242  ibooker.setCurrentFolder (monitorName_);
1243  edm::LogInfo ("HLTMuonDQMSource") << "===>DQM event prescale = " << prescaleEvt_ << " events " << std::endl;
1244  createMEs (ibooker , es);
1245  //create TKHistoMap
1246  if(runOnClusters_)
1247  tkmapAllClusters = new TkHistoMap(ibooker , "HLT/HLTMonMuon/SiStrip" ,"TkHMap_AllClusters",0.0,0);
1248  if(runOnTracks_)
1249  tkmapOnTrackClusters = new TkHistoMap(ibooker , "HLT/HLTMonMuon/SiStrip" ,"TkHMap_OnTrackClusters",0.0,0);
1251  tkmapL3MuTrackClusters = new TkHistoMap(ibooker , "HLT/HLTMonMuon/SiStrip" ,"TkHMap_L3MuTrackClusters",0.0,0);
1252 }
1253 
1254 // ------------ method called once each job just after ending the event loop ------------
1255 void
1257 {
1258  edm::LogInfo ("SiStripMonitorHLTMuon") << "analyzed " << counterEvt_ << " events";
1259  return;
1260 }
1261 
#define LogDebug(id)
ClusterRef cluster() const
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:114
virtual const TrackerGeomDet * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::map< std::string, std::vector< float > > m_BinPhi
unsigned int tibString(const DetId &id) const
edm::EDGetTokenT< reco::TrackCollection > TrackCollectionToken_
bool tobIsStereo(const DetId &id) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:119
unsigned int tecRing(const DetId &id) const
ring id
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
float GetPhiWeight(std::string label, GlobalPoint gp)
TkLayerMap::XYbin cached_XYbin
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > l3collectionToken_
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
void GeometryFromTrackGeom(const std::vector< DetId > &Dets, const TrackerGeometry &theTracker, const edm::EventSetup &iSetup, std::map< std::string, std::vector< float > > &m_PhiStripMod_Eta, std::map< std::string, std::vector< float > > &m_PhiStripMod_Nb)
bool tecIsZMinusSide(const DetId &id) const
void getSubDetLayerFolderName(std::stringstream &ss, SiStripDetId::SubDetector subDet, uint32_t layer, uint32_t side=0)
bool tecIsStereo(const DetId &id) const
float GetEtaWeight(std::string label, GlobalPoint gp)
record_type::const_iterator record_iterator
Definition: LazyGetter.h:317
int iEvent
Definition: GenABIO.cc:230
bool tibIsZMinusSide(const DetId &id) const
void getSubDetLayerSide(int &in, SiStripDetId::SubDetector &, uint32_t &layer, uint32_t &side) const
Definition: TkDetMap.cc:849
std::string getLayerName(int &in) const
Definition: TkDetMap.cc:702
T sqrt(T t)
Definition: SSEVec.h:48
bool verbose_
every n events
T z() const
Definition: PV3DBase.h:64
bool tobIsZMinusSide(const DetId &id) const
void analyzeOnTrackClusters(const reco::Track *l3tk, const TrackerGeometry &theTracker, bool isL3MuTrack=true)
bool isAvailable() const
Definition: Service.h:46
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
SiStripMonitorMuonHLT(const edm::ParameterSet &ps)
#define end
Definition: vmac.h:37
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:244
T min(T a, T b)
Definition: MathUtil.h:58
virtual float width() const
Width along local X.
bool isValid() const
Definition: HandleBase.h:75
#define M_PI
int prescaleEvt_
mutriggered events
unsigned int tibModule(const DetId &id) const
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::map< std::string, LayerMEs > LayerMEMap
unsigned int tecModule(const DetId &id) const
bool tecIsFrontPetal(const DetId &id) const
bool failedToGet() const
Definition: HandleBase.h:79
bool tecIsBackPetal(const DetId &id) const
void Normalizer(const std::vector< DetId > &Dets, const TrackerGeometry &theTracker)
string fullName
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
std::map< std::string, std::vector< float > > m_BinEta
std::map< std::string, std::vector< float > > m_ModNormPhi
virtual float widthAtHalfLength() const
const T & get() const
Definition: EventSetup.h:55
bool tibIsStereo(const DetId &id) const
T const * product() const
Definition: ESHandle.h:86
void PrintNormalization(const std::vector< std::string > &v_LabelHisto)
unsigned int tobModule(const DetId &id) const
T eta() const
Definition: PV3DBase.h:76
#define begin
Definition: vmac.h:30
edm::EDGetTokenT< edm::LazyGetter< SiStripCluster > > clusterCollectionToken_
virtual float length() const
Lenght along local Y.
TrackingRecHitRef recHit(size_t i) const
Get i-th hit on the track.
Definition: Track.h:114
virtual const DetIdContainer & detUnitIds() const
Returm a vector of all GeomDetUnit DetIds.
static unsigned int const shift
virtual LocalPoint localPosition(float strip) const =0
int16_t FindLayer(uint32_t &detid, uint32_t &cached_detid, int16_t &cached_layer, TkLayerMap::XYbin &cached_XYbin) const
Definition: TkDetMap.cc:664
unsigned int tecPetalNumber(const DetId &id) const
Definition: Bounds.h:22
virtual float length() const
std::map< std::string, std::vector< float > > m_ModNormEta
unsigned int tobRod(const DetId &id) const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
virtual SubDetector subDetector() const
Which subdetector.
Definition: GeomDet.cc:49
bool tibIsInternalString(const DetId &id) const
T x() const
Definition: PV3DBase.h:62
void add(uint32_t &detid, float value)
Definition: TkHistoMap.cc:213
Definition: Run.h:41
edm::ParameterSet parameters_
virtual const TrackerGeomDet * idToDet(DetId) const
void createMEs(DQMStore::IBooker &, const edm::EventSetup &es)