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