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