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