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