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.11 2010/04/28 14:22:22 echabert 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 
69  outputFile_ = parameters_.getUntrackedParameter < std::string > ("outputFile","");
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
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);
175  std::string label = tkdetmap_->getLayerName (layer);
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);
242  std::string label = tkdetmap_->getLayerName (layer);
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);
285  std::string label = tkdetmap_->getLayerName (layer);
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  if (hitMatched2D->monoHit ()->cluster_regional ().isNonnull ())
323  {
324  if (hitMatched2D->monoHit ()->cluster_regional ().isAvailable ())
325  {
326  detID = hitMatched2D->monoHit ()->cluster_regional ()->geographicalId ();
327  }
328  }
329  int layer = tkdetmap_->FindLayer (detID);
330  std::string label = tkdetmap_->getLayerName (layer);
331  const StripGeomDetUnit *theGeomDet = dynamic_cast < const StripGeomDetUnit * >(theTracker.idToDet (detID));
332  if (theGeomDet != 0)
333  {
334  const StripTopology *topol = dynamic_cast < const StripTopology * >(&(theGeomDet->specificTopology ()));
335  if (topol != 0)
336  {
337  // get the cluster position in local coordinates (cm)
338  LocalPoint clustlp = topol->localPosition (hitMatched2D->monoHit ()->cluster_regional ()->barycenter ());
339  GlobalPoint clustgp = theGeomDet->surface ().toGlobal (clustlp);
340  //NORMALIZE HISTO IF ASKED
341  float etaWeight = 1.;
342  float phiWeight = 1.;
343  if (normalize_){
344  etaWeight = GetEtaWeight(label, clustgp);
345  phiWeight = GetPhiWeight(label,clustgp);
346  }
347  if(!isL3MuTrack){
348  LayerMEMap[label.c_str ()].EtaDistribOnTrackClustersMap->Fill (clustgp.eta (),etaWeight);
349  LayerMEMap[label.c_str ()].PhiDistribOnTrackClustersMap->Fill (clustgp.phi (),phiWeight);
350  LayerMEMap[label.c_str ()].EtaPhiOnTrackClustersMap->Fill (clustgp.eta (), clustgp.phi ());
351  tkmapOnTrackClusters->add(detID,1.);
352  }
353  else{
354  LayerMEMap[label.c_str ()].EtaDistribL3MuTrackClustersMap->Fill (clustgp.eta (),etaWeight);
355  LayerMEMap[label.c_str ()].PhiDistribL3MuTrackClustersMap->Fill (clustgp.phi (),phiWeight);
356  LayerMEMap[label.c_str ()].EtaPhiL3MuTrackClustersMap->Fill (clustgp.eta (), clustgp.phi ());
357  tkmapL3MuTrackClusters->add(detID,1.);
358  }
359  }
360  }
361 
362  //hit stereo
363  if (hitMatched2D->stereoHit ()->cluster_regional ().isNonnull ())
364  {
365  if (hitMatched2D->stereoHit ()->cluster_regional ().isAvailable ())
366  {
367  detID = hitMatched2D->stereoHit ()->cluster_regional ()->geographicalId ();
368  }
369  }
370  layer = tkdetmap_->FindLayer (detID);
371  label = tkdetmap_->getLayerName (layer);
372  const StripGeomDetUnit *theGeomDet2 = dynamic_cast < const StripGeomDetUnit * >(theTracker.idToDet (detID));
373  if (theGeomDet2 != 0)
374  {
375  const StripTopology *topol = dynamic_cast < const StripTopology * >(&(theGeomDet2->specificTopology ()));
376  if (topol != 0)
377  {
378  // get the cluster position in local coordinates (cm)
379  LocalPoint clustlp = topol->localPosition (hitMatched2D->stereoHit ()->cluster_regional ()->barycenter ());
380  GlobalPoint clustgp = theGeomDet2->surface ().toGlobal (clustlp);
381  //NORMALIZE HISTO IF ASKED
382  float etaWeight = 1.;
383  float phiWeight = 1.;
384  if (normalize_){
385  etaWeight = GetEtaWeight(label, clustgp);
386  phiWeight = GetPhiWeight(label,clustgp);
387  }
388  if(!isL3MuTrack){
389  LayerMEMap[label.c_str ()].EtaDistribOnTrackClustersMap->Fill (clustgp.eta (),etaWeight);
390  LayerMEMap[label.c_str ()].PhiDistribOnTrackClustersMap->Fill (clustgp.phi (),phiWeight);
391  LayerMEMap[label.c_str ()].EtaPhiOnTrackClustersMap->Fill (clustgp.eta (), clustgp.phi ());
392  tkmapOnTrackClusters->add(detID,1.);
393  }
394  else{
395  LayerMEMap[label.c_str ()].EtaDistribL3MuTrackClustersMap->Fill (clustgp.eta (),etaWeight);
396  LayerMEMap[label.c_str ()].PhiDistribL3MuTrackClustersMap->Fill (clustgp.phi (),phiWeight);
397  LayerMEMap[label.c_str ()].EtaPhiL3MuTrackClustersMap->Fill (clustgp.eta (), clustgp.phi ());
398  tkmapL3MuTrackClusters->add(detID,1.);
399  }
400  }
401  }
402 
403  }
404 
405  //if ProjectedSiStripRecHit2D
406  if (hitProj2D != 0)
407  {
408  if (hitProj2D->originalHit ().cluster_regional ().isNonnull ())
409  {
410  if (hitProj2D->originalHit ().cluster_regional ().isAvailable ())
411  {
412  detID = hitProj2D->originalHit ().cluster_regional ()->geographicalId ();
413  }
414  }
415  int layer = tkdetmap_->FindLayer (detID);
416  std::string label = tkdetmap_->getLayerName (layer);
417  const StripGeomDetUnit *theGeomDet = dynamic_cast < const StripGeomDetUnit * >(theTracker.idToDet (detID));
418  if (theGeomDet != 0)
419  {
420  const StripTopology *topol = dynamic_cast < const StripTopology * >(&(theGeomDet->specificTopology ()));
421  if (topol != 0)
422  {
423  // get the cluster position in local coordinates (cm)
424  LocalPoint clustlp = topol->localPosition (hitProj2D->originalHit ().cluster_regional ()->barycenter ());
425  GlobalPoint clustgp = theGeomDet->surface ().toGlobal (clustlp);
426  //NORMALIZE HISTO IF ASKED
427  float etaWeight = 1.;
428  float phiWeight = 1.;
429  if (normalize_){
430  etaWeight = GetEtaWeight(label, clustgp);
431  phiWeight = GetPhiWeight(label,clustgp);
432  }
433  if(!isL3MuTrack){
434  LayerMEMap[label.c_str ()].EtaDistribOnTrackClustersMap->Fill (clustgp.eta (),etaWeight);
435  LayerMEMap[label.c_str ()].PhiDistribOnTrackClustersMap->Fill (clustgp.phi (),phiWeight);
436  LayerMEMap[label.c_str ()].EtaPhiOnTrackClustersMap->Fill (clustgp.eta (), clustgp.phi ());
437  tkmapOnTrackClusters->add(detID,1.);
438  }
439  else{
440  LayerMEMap[label.c_str ()].EtaDistribL3MuTrackClustersMap->Fill (clustgp.eta (),etaWeight);
441  LayerMEMap[label.c_str ()].PhiDistribL3MuTrackClustersMap->Fill (clustgp.phi (),phiWeight);
442  LayerMEMap[label.c_str ()].EtaPhiL3MuTrackClustersMap->Fill (clustgp.eta (), clustgp.phi ());
443  tkmapL3MuTrackClusters->add(detID,1.);
444  }
445  }
446  }
447  }
448 
449  }
450  } //loop over RecHits
451 }
452 
453 void
455 {
456 
457  // vector used
458  std::vector <float *> tgraphEta;
459  std::vector <float *> tgraphPhi;
460  std::vector <int> tgraphSize;
461 
462  std::vector <std::vector<float> > binningEta;
463  std::vector <std::vector<float> > binningPhi;
464 
465  for (int p = 0; p < 34; p++){
466  tgraphEta.push_back (new float[1000]);
467  tgraphPhi.push_back (new float[1000]);
468  }
469 
470  // FOR COMPUTING BINNING
471  std::map< std::string,std::vector<float> > m_BinEta_Prel ;
472  std::map< std::string,std::vector<float> > m_PhiStripMod_Eta;
473  std::map< std::string,std::vector<float> > m_PhiStripMod_Nb;
474 
475  //----------------
476 
477  //Get the tracker geometry
479  es.get < TrackerDigiGeometryRecord > ().get (TG);
480  const TrackerGeometry *theTrackerGeometry = TG.product ();
481  const TrackerGeometry & theTracker (*theTrackerGeometry);
482 
483  std::vector<DetId> Dets = theTracker.detUnitIds();
484 
485 
486  //CALL GEOMETRY METHOD
487  GeometryFromTrackGeom(Dets,theTracker,m_PhiStripMod_Eta,m_PhiStripMod_Nb);
488 
489 
494 
495  std::string fullName, folder;
496 
497  //STRUCTURE OF DETECTORS
498  int p =0;
499 
500  //Loop over layers
501  for (int layer = 1; layer < HistoNumber; ++layer)
502  {
503  SiStripFolderOrganizer folderOrg;
504  std::stringstream ss;
506  uint32_t subdetlayer, side;
507  tkdetmap_->getSubDetLayerSide (layer, subDet, subdetlayer, side);
508  folderOrg.getSubDetLayerFolderName (ss, subDet, subdetlayer, side);
509  folder = ss.str ();
510  dbe_->setCurrentFolder (monitorName_ + folder);
511 
512  LayerMEs layerMEs;
513  layerMEs.EtaPhiAllClustersMap = 0;
514  layerMEs.EtaDistribAllClustersMap = 0;
515  layerMEs.PhiDistribAllClustersMap = 0;
516  layerMEs.EtaPhiOnTrackClustersMap = 0;
517  layerMEs.EtaDistribOnTrackClustersMap = 0;
518  layerMEs.PhiDistribOnTrackClustersMap = 0;
519  layerMEs.EtaPhiL3MuTrackClustersMap = 0;
520  layerMEs.EtaDistribL3MuTrackClustersMap = 0;
521  layerMEs.PhiDistribL3MuTrackClustersMap = 0;
522 
523  std::string histoname;
524  std::string title;
525  std::string labelHisto = tkdetmap_->getLayerName (layer);
526 
527  std::string labelHisto_ID = labelHisto;
528  labelHisto_ID.erase(3);
529 
530  //
531  unsigned int sizePhi = 0;
532  unsigned int sizeEta = 0;
533  float * xbinsPhi = new float[100];
534  float * xbinsEta = new float[100];
535 
536  //TEC && TID && TOB && TIB
537  if (labelHisto_ID == "TEC" || labelHisto_ID == "TID" || labelHisto_ID == "TOB" || labelHisto_ID == "TIB"){
538 
539  // PHI BINNING
540  //ADDING BORDERS
541  m_BinPhi[labelHisto].push_back(-M_PI);
542  m_BinPhi[labelHisto].push_back(M_PI);
543 
544  //SORTING
545  sort(m_BinPhi[labelHisto].begin(),m_BinPhi[labelHisto].end());
546  //CREATING XBIN VECTOR
547  sizePhi = m_BinPhi[labelHisto].size();
548 
549  for (unsigned int i = 0; i < sizePhi; i++){
550  xbinsPhi[i] = m_BinPhi[labelHisto][i];
551  }
552 
553  //ETA BINNING
554  std::vector <float > v_BinEta_Prel;
555  // LOOPING ON RINGS
556  for (unsigned int i = 0; i < 12; i++){
557  // COMPUTE BARYCENTER IF NON NULL
558  if (m_PhiStripMod_Nb[labelHisto][i] != 0 && fabs(m_PhiStripMod_Eta[labelHisto][i]) > 0.05){
559  float EtaBarycenter = m_PhiStripMod_Eta[labelHisto][i]/m_PhiStripMod_Nb[labelHisto][i];
560  v_BinEta_Prel.push_back(EtaBarycenter);
561  }
562  }
563 
564  //SORT THEM IN ETA
565  sort(v_BinEta_Prel.begin(),v_BinEta_Prel.end());
566 
567  //RECOMPUTE THE BINS BY TAKING THE HALF OF THE DISTANCE
568  for (unsigned int i = 0; i < v_BinEta_Prel.size(); i++){
569  if (i == 0) m_BinEta[labelHisto].push_back(v_BinEta_Prel[i] - 0.15);
570  if (i != 0) {
571  float shift = v_BinEta_Prel[i] - v_BinEta_Prel[i-1];
572  m_BinEta[labelHisto].push_back(v_BinEta_Prel[i] - shift/2.);
573  }
574  if (i == v_BinEta_Prel.size()-1) m_BinEta[labelHisto].push_back(v_BinEta_Prel[i] + 0.15);
575  }
576 
577  sort(m_BinEta[labelHisto].begin(),m_BinEta[labelHisto].end());
578 
579  //CREATING XBIN VECTOR
580  sizeEta = m_BinEta[labelHisto].size();
581 
582  for (unsigned int i = 0; i < sizeEta; i++){
583  xbinsEta[i] = m_BinEta[labelHisto][i];
584  }
585 
586  } // END SISTRIP DETECTORS
587 
588  // all clusters
589  if(runOnClusters_){
590  histoname = "EtaAllClustersDistrib_" + labelHisto;
591  title = "#eta(All Clusters) in " + labelHisto;
592  layerMEs.EtaDistribAllClustersMap = dbe_->book1D (histoname, title, sizeEta - 1, xbinsEta);
593  histoname = "PhiAllClustersDistrib_" + labelHisto;
594  title = "#phi(All Clusters) in " + labelHisto;
595  layerMEs.PhiDistribAllClustersMap = dbe_->book1D (histoname, title, sizePhi - 1, xbinsPhi);
596  histoname = "EtaPhiAllClustersMap_" + labelHisto;
597  title = "#eta-#phi All Clusters map in " + labelHisto;
598  layerMEs.EtaPhiAllClustersMap = dbe_->book2D (histoname, title, sizeEta - 1, xbinsEta, sizePhi - 1, xbinsPhi);
599  }
600  // on track clusters
601  if(runOnTracks_){
602  histoname = "EtaOnTrackClustersDistrib_" + labelHisto;
603  title = "#eta(OnTrack Clusters) in " + labelHisto;
604  layerMEs.EtaDistribOnTrackClustersMap = dbe_->book1D (histoname, title, sizeEta - 1, xbinsEta);
605  histoname = "PhiOnTrackClustersDistrib_" + labelHisto;
606  title = "#phi(OnTrack Clusters) in " + labelHisto;
607  layerMEs.PhiDistribOnTrackClustersMap = dbe_->book1D (histoname, title, sizePhi - 1, xbinsPhi);
608  histoname = "EtaPhiOnTrackClustersMap_" + labelHisto;
609  title = "#eta-#phi OnTrack Clusters map in " + labelHisto;
610  layerMEs.EtaPhiOnTrackClustersMap = dbe_->book2D (histoname, title, sizeEta - 1, xbinsEta, sizePhi - 1, xbinsPhi);
611  }
613  // L3 muon track clusters
614  histoname = "EtaL3MuTrackClustersDistrib_" + labelHisto;
615  title = "#eta(L3MuTrack Clusters) in " + labelHisto;
616  layerMEs.EtaDistribL3MuTrackClustersMap = dbe_->book1D (histoname, title, sizeEta - 1, xbinsEta);
617  histoname = "PhiL3MuTrackClustersDistrib_" + labelHisto;
618  title = "#phi(L3MuTrack Clusters) in " + labelHisto;
619  layerMEs.PhiDistribL3MuTrackClustersMap = dbe_->book1D (histoname, title, sizePhi - 1, xbinsPhi);
620  histoname = "EtaPhiL3MuTrackClustersMap_" + labelHisto;
621  title = "#eta-#phi L3MuTrack Clusters map in " + labelHisto;
622  layerMEs.EtaPhiL3MuTrackClustersMap = dbe_->book2D (histoname, title, sizeEta - 1, xbinsEta, sizePhi - 1, xbinsPhi);
623  }
624  LayerMEMap[labelHisto] = layerMEs;
625 
626  //PUTTING ERRORS
627  if(runOnClusters_){
628  LayerMEMap[labelHisto].EtaDistribAllClustersMap->getTH1F()->Sumw2();
629  LayerMEMap[labelHisto].PhiDistribAllClustersMap->getTH1F()->Sumw2();
630  LayerMEMap[labelHisto].EtaPhiAllClustersMap->getTH2F()->Sumw2();
631  }
632  if(runOnTracks_){
633  LayerMEMap[labelHisto].EtaDistribOnTrackClustersMap->getTH1F()->Sumw2();
634  LayerMEMap[labelHisto].PhiDistribOnTrackClustersMap->getTH1F()->Sumw2();
635  LayerMEMap[labelHisto].EtaPhiOnTrackClustersMap->getTH2F()->Sumw2();
636  }
638  LayerMEMap[labelHisto].EtaDistribL3MuTrackClustersMap->getTH1F()->Sumw2();
639  LayerMEMap[labelHisto].PhiDistribL3MuTrackClustersMap->getTH1F()->Sumw2();
640  LayerMEMap[labelHisto].EtaPhiL3MuTrackClustersMap->getTH2F()->Sumw2();
641  }
642 
643  p++;
644  } //end of loop over layers
645 
646 
647  //CALL THE NORMALIZATION METHOD
648  Normalizer(Dets,theTracker);
649 
650 } //end of method
651 
652 
653 void
654 SiStripMonitorMuonHLT::GeometryFromTrackGeom (std::vector<DetId> Dets,const TrackerGeometry & theTracker,
655  std::map< std::string,std::vector<float> > & m_PhiStripMod_Eta,std::map< std::string,std::vector<float> > & m_PhiStripMod_Nb){
656 
657 
658  std::vector<std::string> v_LabelHisto;
659 
660  //Loop over DetIds
661  //-----------------------------------------
662  for(std::vector<DetId>::iterator detid_iterator = Dets.begin(); detid_iterator!=Dets.end(); detid_iterator++){
663  uint32_t detid = (*detid_iterator)();
664 
665  if ( (*detid_iterator).null() == true) break;
666  if (detid == 0) break;
667 
668  // Select the propers detectors - avoid pixels
669  const GeomDetUnit * GeomDet = theTracker.idToDetUnit(detid);
670  const GeomDet::SubDetector detector = GeomDet->subDetector();
671 
672  int mylayer;
673  std::string mylabelHisto;
674 
675  // SELECT SISTRIP DETECTORS
676  if (detector == GeomDetEnumerators::TEC
677  || detector == GeomDetEnumerators::TID
678  || detector == GeomDetEnumerators::TOB
679  || detector == GeomDetEnumerators::TIB
680  ){
681 
682  const StripGeomDetUnit *theGeomDet = dynamic_cast < const StripGeomDetUnit * >(theTracker.idToDet (detid));
683  const StripTopology *topol = dynamic_cast < const StripTopology * >(&(theGeomDet->specificTopology ()));
684 
685  // Get the position of the 1st strip in local coordinates (cm)
686  LocalPoint clustlp = topol->localPosition (1.);
687  GlobalPoint clustgp = theGeomDet->surface ().toGlobal (clustlp);
688 
689  // Get the eta, phi of modules
690  mylayer = tkdetmap_->FindLayer (detid);
691  mylabelHisto = tkdetmap_->getLayerName (mylayer);
692 
693  SiStripDetId stripdet = SiStripDetId(detid);
694 
695  // INITIALISATION OF m_PhiStripMod_Eta + BOOKING LAYERS
696 
697  //TEST IF NEW LAYER
698  unsigned int count = 0;
699  while (count < v_LabelHisto.size()){
700  if (mylabelHisto == v_LabelHisto[count]) break;
701  count++;
702  }
703  if (count == v_LabelHisto.size()){
704 
705  //FILL THE NEW LAYER
706  v_LabelHisto.push_back(mylabelHisto);
707 
708  //INITIALIZE
709 
710  // LOOPING ON RINGS
711  for (int i = 0; i < 12; i++){
712  m_PhiStripMod_Eta[mylabelHisto].push_back(0.);
713  m_PhiStripMod_Nb[mylabelHisto].push_back(0.);
714  }
715  }
716 
717  //TEC
718  if (detector == GeomDetEnumerators::TEC ){
719 
720  TECDetId id = TECDetId(detid);
721 
722  //PHI BINNING
723  //Select 7th ring
724  if (id.ringNumber() == 7){
725  //SELECT FP
726  if (id.moduleNumber() == 1 && id.isFrontPetal() == true) m_BinPhi[mylabelHisto].push_back(clustgp.phi());
727  //SELECT BP
728  if (id.moduleNumber() == 1 && id.isBackPetal() == true) m_BinPhi[mylabelHisto].push_back(clustgp.phi());
729  }
730 
731  //ETA BINNING
732  //Select arbitrary petal
733  if (id.petalNumber() == 1 ){
734  m_PhiStripMod_Eta[mylabelHisto][id.ringNumber()-1] = m_PhiStripMod_Eta[mylabelHisto][id.ringNumber()-1] + clustgp.eta();
735  m_PhiStripMod_Nb[mylabelHisto][id.ringNumber()-1]++;
736  }
737 
738  } //END TEC
739 
740  //TID
741  if (detector == GeomDetEnumerators::TID ){
742 
743  TIDDetId id = TIDDetId(detid);
744 
745  //PHI BINNING
746  //Select 1st ring
747  if (id.ringNumber() == 1){
748  //SELECT MONO
749  if (id.isFrontRing() == true && id.isStereo() == false) m_BinPhi[mylabelHisto].push_back(clustgp.phi());
750  //SELECT STEREO
751  if (id.isFrontRing() == true && id.isStereo() == true) m_BinPhi[mylabelHisto].push_back(clustgp.phi());
752  }
753 
754  //ETA BINNING
755  //Select arbitrary line in eta (phi fixed)
756  if (id.moduleNumber() == 1){
757  m_PhiStripMod_Eta[mylabelHisto][id.ringNumber()-1] = m_PhiStripMod_Eta[mylabelHisto][id.ringNumber()-1] + clustgp.eta();
758  m_PhiStripMod_Nb[mylabelHisto][id.ringNumber()-1]++;
759  }
760 
761  } //END TID
762 
763  //TOB
764  if (detector == GeomDetEnumerators::TOB ){
765 
766  TOBDetId id = TOBDetId(detid);
767  //PHI BINNING
768  //Select arbitrary line in phi (eta fixed)
769  if (id.moduleNumber() == 1 && id.isZMinusSide() == true){
770  //SELECT MONO
771  if (id.isStereo() == false) m_BinPhi[mylabelHisto].push_back(clustgp.phi());
772  }
773 
774  //ETA BINNING
775  //Select arbitrary rod
776  if ( (id.rodNumber() == 2 && id.isStereo() == false)
777  || (id.rodNumber() == 1 && id.isStereo() == true)
778  ){
779  if (id.isZMinusSide() == true){
780  m_PhiStripMod_Eta[mylabelHisto][id.moduleNumber()-1] = m_PhiStripMod_Eta[mylabelHisto][id.moduleNumber()-1] + clustgp.eta();
781  m_PhiStripMod_Nb[mylabelHisto][id.moduleNumber()-1]++;
782  }
783  if (id.isZMinusSide() == false){
784  m_PhiStripMod_Eta[mylabelHisto][id.moduleNumber()+5] = m_PhiStripMod_Eta[mylabelHisto][id.moduleNumber()+5] + clustgp.eta();
785  m_PhiStripMod_Nb[mylabelHisto][id.moduleNumber()+5]++;
786  }
787  }
788 
789  } //END TOB
790 
791  //TIB
792  if (detector == GeomDetEnumerators::TIB ){
793 
794  TIBDetId id = TIBDetId(detid);
795 
796  //PHI BINNING
797  //Select arbitrary line in phi (eta fixed)
798  if (id.moduleNumber() == 1 && id.isZMinusSide() == true){
799  //SELECT MONO
800  if (id.isInternalString() == true && id.isStereo() == false) m_BinPhi[mylabelHisto].push_back(clustgp.phi());
801  }
802 
803  //ETA BINNING
804  //Select arbitrary string
805  if ( (id.stringNumber() == 2 && id.isStereo() == false)
806  || (id.stringNumber() == 1 && id.isStereo() == true)
807  ){
808  if (id.isZMinusSide() == true){
809  if (id.isInternalString() == true){
810  m_PhiStripMod_Eta[mylabelHisto][id.moduleNumber()-1] = m_PhiStripMod_Eta[mylabelHisto][id.moduleNumber()-1] + clustgp.eta();
811  m_PhiStripMod_Nb[mylabelHisto][id.moduleNumber()-1]++;
812  }
813  if (id.isInternalString() == false){
814  m_PhiStripMod_Eta[mylabelHisto][id.moduleNumber()+2] = m_PhiStripMod_Eta[mylabelHisto][id.moduleNumber()+2] + clustgp.eta();
815  m_PhiStripMod_Nb[mylabelHisto][id.moduleNumber()+2]++;
816  }
817  }
818  if (id.isZMinusSide() == false){
819  if (id.isInternalString() == true){
820  m_PhiStripMod_Eta[mylabelHisto][id.moduleNumber()+5] = m_PhiStripMod_Eta[mylabelHisto][id.moduleNumber()+5] + clustgp.eta();
821  m_PhiStripMod_Nb[mylabelHisto][id.moduleNumber()+5]++;
822  }
823  if (id.isInternalString() == false){
824  m_PhiStripMod_Eta[mylabelHisto][id.moduleNumber()+8] = m_PhiStripMod_Eta[mylabelHisto][id.moduleNumber()+8] + clustgp.eta();
825  m_PhiStripMod_Nb[mylabelHisto][id.moduleNumber()+8]++;
826  }
827  }
828  }
829 
830  } //END TIB
831 
832  } // END SISTRIP DETECTORS
833  } // END DETID LOOP
834 
835 } //END OF METHOD
836 
837 
838 
839 void
840 SiStripMonitorMuonHLT::Normalizer (std::vector<DetId> Dets,const TrackerGeometry & theTracker){
841 
842 
843  std::vector<std::string> v_LabelHisto;
844 
845  //Loop over DetIds
846  //-----------------------------------------
847  for(std::vector<DetId>::iterator detid_iterator = Dets.begin(); detid_iterator!=Dets.end(); detid_iterator++){
848  uint32_t detid = (*detid_iterator)();
849 
850  if ( (*detid_iterator).null() == true) break;
851  if (detid == 0) break;
852 
853  // Select the propers detectors - avoid pixels
854  const GeomDetUnit * GeomDet = theTracker.idToDetUnit(detid);
855  const GeomDet::SubDetector detector = GeomDet->subDetector();
856 
857  int mylayer;
858  std::string mylabelHisto;
859 
860  // SELECT SISTRIP DETECTORS
861  if (detector == GeomDetEnumerators::TEC
862  || detector == GeomDetEnumerators::TID
863  || detector == GeomDetEnumerators::TOB
864  || detector == GeomDetEnumerators::TIB
865  ){
866 
867  const StripGeomDetUnit *theGeomDet = dynamic_cast < const StripGeomDetUnit * >(theTracker.idToDet (detid));
868  const StripTopology *topol = dynamic_cast < const StripTopology * >(&(theGeomDet->specificTopology ()));
869 
870  // Get the eta, phi of modules
871  mylayer = tkdetmap_->FindLayer (detid);
872  mylabelHisto = tkdetmap_->getLayerName (mylayer);
873 
874  SiStripDetId stripdet = SiStripDetId(detid);
875 
876  // INITIALISATION OF m_ModNormEta + BOOKING LAYERS
877 
878  //TEST IF NEW LAYER
879  unsigned int count = 0;
880 
881  while (count < v_LabelHisto.size()){
882  if (mylabelHisto == v_LabelHisto[count]) break;
883  count++;
884  }
885 
886  if (count == v_LabelHisto.size()){
887  //FILL THE NEW LAYER
888  v_LabelHisto.push_back(mylabelHisto);
889 
890  //INITIALIZE
891  // LOOPING ON ETA VECTOR
892  for (unsigned int i = 0; i < m_BinEta[mylabelHisto].size() -1; i++){
893  m_ModNormEta[mylabelHisto].push_back(0.);
894  }
895 
896  // LOOPING ON PHI VECTOR
897  for (unsigned int i = 0; i < m_BinPhi[mylabelHisto].size() -1; i++){
898  m_ModNormPhi[mylabelHisto].push_back(0.);
899  }
900  }
901 
902  // Get the position of the 1st strip in local coordinates (cm)
903  LocalPoint clustlp_1 = topol->localPosition (1.);
904  GlobalPoint clustgp_1 = theGeomDet->surface ().toGlobal (clustlp_1);
905 
906  // Get the position of the center of the module
907  LocalPoint clustlp(0.,0.);
908  GlobalPoint clustgp = theGeomDet->surface ().toGlobal (clustlp);
909 
910  // Get the position of the last strip
911  LocalPoint Border_clustlp = topol->localPosition (topol->nstrips());
912  GlobalPoint Border_clustgp = theGeomDet->surface ().toGlobal (Border_clustlp);
913 
914  //GETTING SURFACE VALUE
915  const BoundPlane& GeomDetSurface = GeomDet->surface();
916  const Bounds& bound = GeomDetSurface.bounds();
917 
918  std::string labelHisto_ID = mylabelHisto;
919  labelHisto_ID.erase(3);
920 
921  float length = 0.;
922  float width = 0.;
923 
924  std::vector <GlobalPoint> v_Edge_G;
925 
926  float ratio = 0.;
927  float factor = 1.;
928 
929  //RECTANGULAR BOUNDS
930  if (labelHisto_ID == "TOB" || labelHisto_ID == "TIB"){
931  const RectangularPlaneBounds *rectangularBound = dynamic_cast < const RectangularPlaneBounds * >(& bound);
932  length = rectangularBound->length();
933  width = rectangularBound->width();
934  ratio = width/length;
935 
936  //EDGES POINTS
937  LocalPoint topleft(-width/2., length/2.);
938  LocalPoint topright(width/2., length/2.); LocalPoint botleft(-width/2., -length/2.);
939  LocalPoint botright(width/2., -length/2.);
940  v_Edge_G.push_back(theGeomDet->surface ().toGlobal (topleft));
941  v_Edge_G.push_back(theGeomDet->surface ().toGlobal (topright));
942  v_Edge_G.push_back(theGeomDet->surface ().toGlobal (botleft)); v_Edge_G.push_back(theGeomDet->surface ().toGlobal (botright));
943  }
944  //TRAPEZOIDAL BOUNDS
945  if (labelHisto_ID == "TEC" || labelHisto_ID == "TID"){
946  const TrapezoidalPlaneBounds *trapezoidalBound = dynamic_cast < const TrapezoidalPlaneBounds * >(& bound);
947 
948  length = trapezoidalBound->length();
949  width = trapezoidalBound->widthAtHalfLength();
950 
951  ratio = width/length;
952 
953  //EDGES POINTS
954  LocalPoint topleft(-width/2., length/2.);
955  LocalPoint topright(width/2., length/2.);
956  LocalPoint botleft(-width/2., -length/2.);
957  LocalPoint botright(width/2., -length/2.);
958 
959  v_Edge_G.push_back(theGeomDet->surface ().toGlobal (topleft));
960  v_Edge_G.push_back(theGeomDet->surface ().toGlobal (topright));
961  v_Edge_G.push_back(theGeomDet->surface ().toGlobal (botleft));
962  v_Edge_G.push_back(theGeomDet->surface ().toGlobal (botright));
963  }
964 
965  //SORTING EDGES POINTS
966  GlobalPoint top_left_G;
967  GlobalPoint top_rightG;
968  GlobalPoint bot_left_G;
969  GlobalPoint bot_rightG;
970 
971  std::vector <bool> v_Fill;
972  v_Fill.push_back(false);
973  v_Fill.push_back(false);
974  v_Fill.push_back(false);
975  v_Fill.push_back(false);
976 
977  for (unsigned int i =0 ; i< v_Edge_G.size() ; i++){
978  if (v_Edge_G[i].eta() < clustgp.eta()){
979  if (v_Edge_G[i].phi() < clustgp.phi()) {
980  bot_left_G = v_Edge_G[i];
981  v_Fill[0] = true;
982  }
983  if (v_Edge_G[i].phi() > clustgp.phi()){
984  top_left_G = v_Edge_G[i];
985  v_Fill[1] = true;
986  }
987  }
988  if (v_Edge_G[i].eta() > clustgp.eta()){
989  if (v_Edge_G[i].phi() < clustgp.phi()){
990  bot_rightG = v_Edge_G[i];
991  v_Fill[2] = true;
992  }
993  if (v_Edge_G[i].phi() > clustgp.phi()){
994  top_rightG = v_Edge_G[i];
995  v_Fill[3] = true;
996  }
997  }
998  }
999 
1000  //USE EDGES FOR COMPUTING WIDTH AND LENGTH
1001 
1002  float G_length = 0.;
1003  float G_width = 0.;
1004 
1005  bool flag_border = false;
1006 
1007  if (v_Fill[0] == true
1008  && v_Fill[1] == true
1009  && v_Fill[2] == true
1010  && v_Fill[3] == true){
1011 
1012  //LENGTH BETWEEN TL AND TR
1013  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()) );
1014 
1015  //WIDTH BETWEEN BL AND TL
1016  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()) );
1017 
1018  }
1019  else {
1020 
1021  // MODULE IN THE PHI BORDER (-PI,PI)
1022  flag_border = true;
1023 
1024  //SORT THE EDGES POINTS
1025  for (unsigned int i =0 ; i< v_Edge_G.size() ; i++){
1026 
1027  if (v_Edge_G[i].phi() > 0. ){
1028  if (v_Edge_G[i].eta() < clustgp.eta()){
1029  bot_left_G = v_Edge_G[i];
1030  }
1031  if (v_Edge_G[i].eta() > clustgp.eta()){
1032  bot_rightG = v_Edge_G[i];
1033  }
1034  }
1035  if (v_Edge_G[i].phi() < 0. ){
1036  if (v_Edge_G[i].eta() < clustgp.eta()){
1037  top_left_G = v_Edge_G[i];
1038  }
1039  if (v_Edge_G[i].eta() > clustgp.eta()){
1040  top_rightG = v_Edge_G[i];
1041  }
1042  }
1043  }
1044 
1045  // XYZ WIDTH AND LENGTH
1046  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()) );
1047  G_width = G_length*ratio;
1048  }
1049 
1050 
1051  //ETA PLOTS
1052  //unsigned int LastBinEta = m_BinEta[mylabelHisto].size() - 2;
1053  for (unsigned int i = 0; i < m_BinEta[mylabelHisto].size() - 1; i++){
1054  if (m_BinEta[mylabelHisto][i] <= clustgp.eta() && clustgp.eta() < m_BinEta[mylabelHisto][i+1]){
1055 
1056  // NO NEED TO DO CORRECTIONS FOR ETA
1057  m_ModNormEta[mylabelHisto][i] = m_ModNormEta[mylabelHisto][i] + factor*G_length*G_width;
1058 
1059  }
1060  } //END ETA
1061 
1062  //PHI PLOTS
1063  unsigned int LastBinPhi = m_BinPhi[mylabelHisto].size() - 2;
1064  for (unsigned int i = 0; i < m_BinPhi[mylabelHisto].size() - 1; i++){
1065  if (m_BinPhi[mylabelHisto][i] <= clustgp.phi() && clustgp.phi() < m_BinPhi[mylabelHisto][i+1]){
1066 
1067  // SCRIPT TO INTEGRATE THE SURFACE INTO PHI BIN
1068 
1069  float phiMin = std::min(bot_left_G.phi(),bot_rightG.phi());
1070  float phiMax = std::max(top_left_G.phi(),top_rightG.phi());
1071 
1072  bool offlimit_prev = false;
1073  bool offlimit_foll = false;
1074 
1075  if (phiMin < m_BinPhi[mylabelHisto][i]) offlimit_prev = true;
1076  if (i != LastBinPhi){
1077  if (phiMax > m_BinPhi[mylabelHisto][i+1]) offlimit_foll = true;
1078  }
1079 
1080  //LOOKING FOR THE INTERSECTION POINTS
1081  float MidPoint_X_prev;
1082  float MidPoint_Y_prev;
1083  float MidPoint_Z_prev;
1084  float MidPoint_X_foll;
1085  float MidPoint_Y_foll;
1086  float MidPoint_Z_foll;
1087 
1088  // OFF LIMIT IN THE PREVIOUS BIN
1089  if (offlimit_prev){
1090 
1091  // BL TL
1092  float tStar1 = (m_BinPhi[mylabelHisto][i]-bot_left_G.phi())/(top_left_G.phi()-bot_left_G.phi());
1093 
1094  // BR TR
1095  float tStar2 = (m_BinPhi[mylabelHisto][i]-bot_rightG.phi())/(top_rightG.phi()-bot_rightG.phi());
1096 
1097  if (tStar1 < 0.) tStar1 = 0.;
1098  if (tStar2 < 0.) tStar2 = 0.;
1099 
1100  //FIND Z OF STAR POINT
1101  float xStar1 = bot_left_G.x() + (tStar1*1.)*(top_left_G.x()-bot_left_G.x());
1102  float xStar2 = bot_rightG.x() + (tStar2*1.)*(top_rightG.x()-bot_rightG.x());
1103 
1104  float yStar1 = bot_left_G.y() + (tStar1*1.)*(top_left_G.y()-bot_left_G.y());
1105  float yStar2 = bot_rightG.y() + (tStar2*1.)*(top_rightG.y()-bot_rightG.y());
1106 
1107  float zStar1 = bot_left_G.z() + (tStar1*1.)*(top_left_G.z()-bot_left_G.z());
1108  float zStar2 = bot_rightG.z() + (tStar2*1.)*(top_rightG.z()-bot_rightG.z());
1109 
1110  //MIDPOINT
1111  MidPoint_X_prev = (xStar1 + xStar2)/2.;
1112  MidPoint_Y_prev = (yStar1 + yStar2)/2.;
1113  MidPoint_Z_prev = (zStar1 + zStar2)/2.;
1114  }
1115 
1116  if (offlimit_prev == false){
1117  MidPoint_X_prev = (bot_left_G.x() + bot_rightG.x())/2.;
1118  MidPoint_Y_prev = (bot_left_G.y() + bot_rightG.y())/2.;
1119  MidPoint_Z_prev = (bot_left_G.z() + bot_rightG.z())/2.;
1120  }
1121 
1122  // OFF LIMIT IN THE FOLLOWING BIN
1123  if (offlimit_foll){
1124 
1125  // BL TL
1126  float tStar1 = (m_BinPhi[mylabelHisto][i+1]-bot_left_G.phi())/(top_left_G.phi()-bot_left_G.phi());
1127 
1128  // BR TR
1129  float tStar2 = (m_BinPhi[mylabelHisto][i+1]-bot_rightG.phi())/(top_rightG.phi()-bot_rightG.phi());
1130 
1131  if (tStar1 > 1.) tStar1 = 1.;
1132  if (tStar2 > 1.) tStar2 = 1.;
1133 
1134  //FIND Z OF STAR POINT
1135  float xStar1 = bot_left_G.x() + (tStar1*1.)*(top_left_G.x()-bot_left_G.x());
1136  float xStar2 = bot_rightG.x() + (tStar2*1.)*(top_rightG.x()-bot_rightG.x());
1137 
1138  float yStar1 = bot_left_G.y() + (tStar1*1.)*(top_left_G.y()-bot_left_G.y());
1139  float yStar2 = bot_rightG.y() + (tStar2*1.)*(top_rightG.y()-bot_rightG.y());
1140 
1141  float zStar1 = bot_left_G.z() + (tStar1*1.)*(top_left_G.z()-bot_left_G.z());
1142  float zStar2 = bot_rightG.z() + (tStar2*1.)*(top_rightG.z()-bot_rightG.z());
1143 
1144  //MIDPOINT
1145  MidPoint_X_foll = (xStar1 + xStar2)/2.;
1146  MidPoint_Y_foll = (yStar1 + yStar2)/2.;
1147  MidPoint_Z_foll = (zStar1 + zStar2)/2.;
1148  }
1149 
1150  if (offlimit_foll == false){
1151  MidPoint_X_foll = (top_left_G.x() + top_rightG.x())/2.;
1152  MidPoint_Y_foll = (top_left_G.y() + top_rightG.y())/2.;
1153  MidPoint_Z_foll = (top_left_G.z() + top_rightG.z())/2.;
1154  }
1155 
1156  //COMPUTE THE B AND T EDGES
1157  float EdgePoint_X_B = (bot_left_G.x() + bot_rightG.x())/2.;
1158  float EdgePoint_Y_B = (bot_left_G.y() + bot_rightG.y())/2.;
1159  float EdgePoint_Z_B = (bot_left_G.z() + bot_rightG.z())/2.;
1160 
1161  float EdgePoint_X_T = (top_left_G.x() + top_rightG.x())/2.;
1162  float EdgePoint_Y_T = (top_left_G.y() + top_rightG.y())/2.;
1163  float EdgePoint_Z_T = (top_left_G.z() + top_rightG.z())/2.;
1164  // FILL INSIDE WIDTH
1165  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) );
1166 
1167  //IF BORDER
1168  if (flag_border){
1169 
1170  // A) 3 POINT AND 1 POINT
1171  if (i != 0 && i != LastBinPhi){
1172  m_ModNormPhi[mylabelHisto][i] = m_ModNormPhi[mylabelHisto][i] + factor*G_length*G_width;
1173  }
1174 
1175  // B) MODULE SPLITTED IN TWO
1176  if (i == 0 || i == LastBinPhi){
1177  float PhiBalance = 0.;
1178  if (clustgp.phi() > 0.) PhiBalance = clustgp.phi() - M_PI ;
1179  if (clustgp.phi() < 0.) PhiBalance = clustgp.phi() + M_PI ;
1180 
1181  // Average Phi width of a phi bin
1182  float Phi_Width = m_BinPhi[mylabelHisto][3] - m_BinPhi[mylabelHisto][2];
1183 
1184  float weight_FirstBin = (1.+ (PhiBalance/(Phi_Width/2.)))/2. ;
1185  float weight_LastBin = fabs(1. - weight_FirstBin);
1186 
1187  m_ModNormPhi[mylabelHisto][0] = m_ModNormPhi[mylabelHisto][0] + weight_FirstBin*(factor*G_length*G_width);
1188  m_ModNormPhi[mylabelHisto][LastBinPhi] = m_ModNormPhi[mylabelHisto][LastBinPhi] + weight_LastBin*(factor*G_length*G_width);
1189  }
1190  }
1191 
1192  if (flag_border == false){
1193 
1194  // A) SURFACE TOTALY CONTAINED IN THE BIN
1195  if (offlimit_prev == false && offlimit_foll == false){
1196  m_ModNormPhi[mylabelHisto][i] = m_ModNormPhi[mylabelHisto][i] + factor*G_length*G_width;
1197  }
1198 
1199  // B) SURFACE CONTAINED IN 2 BINS
1200  if ((offlimit_prev == true && offlimit_foll == false)
1201  ||(offlimit_prev == false && offlimit_foll == true) ){
1202  float G_width_Out = fabs(G_width - G_width_Ins);
1203 
1204  //FILL INSIDE CELL
1205  m_ModNormPhi[mylabelHisto][i] = m_ModNormPhi[mylabelHisto][i] + factor*G_width_Ins*G_length;
1206 
1207  //FILL OFF LIMITS CELLS
1208  if (offlimit_prev && i != 0) m_ModNormPhi[mylabelHisto][i-1] = m_ModNormPhi[mylabelHisto][i-1] + factor*G_width_Out*G_length;
1209  if (offlimit_foll && i != LastBinPhi) m_ModNormPhi[mylabelHisto][i+1] = m_ModNormPhi[mylabelHisto][i+1] + factor*G_width_Out*G_length;
1210  }
1211 
1212  // C) SURFACE CONTAINED IN 3 BINS
1213  if (offlimit_prev == true && offlimit_foll == true){
1214 
1215  //COMPUTE OFF LIMITS LENGTHS
1216  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) );
1217  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) );
1218 
1219  //FOR SAFETY
1220  if (i != 0 && i != LastBinPhi){
1221  //FILL INSIDE CELL
1222  m_ModNormPhi[mylabelHisto][i] = m_ModNormPhi[mylabelHisto][i] + factor*G_width_Ins*G_length;
1223 
1224  //FILL OFF LIMITS CELLS
1225  if (i != 0) m_ModNormPhi[mylabelHisto][i-1] = m_ModNormPhi[mylabelHisto][i-1] + factor*G_width_B*G_length;
1226  if (i != LastBinPhi) m_ModNormPhi[mylabelHisto][i+1] = m_ModNormPhi[mylabelHisto][i+1] + factor*G_width_T*G_length;
1227  }
1228 
1229  }
1230  }
1231  }
1232  } // END PHI
1233 
1234  } // END SISTRIP DETECTORS
1235 
1236  } // END DETID LOOP
1237 
1238  //PRINT NORMALIZATION IF ASKED
1239  if (printNormalize_) {
1240  TFile output("MuonHLTDQMNormalization.root","recreate");
1241  output.cd();
1242  PrintNormalization(v_LabelHisto);
1243  output.Close();
1244  }
1245 
1246 } //END METHOD
1247 
1248 
1249 
1250 void
1251 SiStripMonitorMuonHLT::PrintNormalization (std::vector<std::string> v_LabelHisto)
1252 {
1253  std::vector <TH1F *> h_ModNorm_Eta;
1254  std::vector <TH1F *> h_ModNorm_Phi;
1255 
1256  for (unsigned int p = 0; p < v_LabelHisto.size(); p++){
1257 
1258  std::string titleHistoEta = v_LabelHisto[p] + "_eta" ;
1259  std::string titleHistoPhi = v_LabelHisto[p] + "_phi" ;
1260 
1261  std::string labelHisto = v_LabelHisto[p];
1262 
1263  float * xbinsPhi = new float[100];
1264  float * xbinsEta = new float[100];
1265 
1266  //CREATING XBIN VECTOR
1267  unsigned int sizePhi = m_BinPhi[labelHisto].size();
1268  for (unsigned int i = 0; i < sizePhi; i++){
1269  xbinsPhi[i] = m_BinPhi[labelHisto][i];
1270  }
1271  //CREATING XBIN VECTOR
1272  unsigned int sizeEta = m_BinEta[labelHisto].size();
1273  for (unsigned int i = 0; i < sizeEta; i++){
1274  xbinsEta[i] = m_BinEta[labelHisto][i];
1275  }
1276 
1277  h_ModNorm_Eta.push_back(new TH1F (titleHistoEta.c_str(),titleHistoEta.c_str(),sizeEta - 1,xbinsEta));
1278  h_ModNorm_Phi.push_back(new TH1F (titleHistoPhi.c_str(),titleHistoPhi.c_str(),sizePhi - 1,xbinsPhi));
1279 
1280  for (unsigned int i = 0; i < m_ModNormEta[labelHisto].size(); i++){
1281  (*h_ModNorm_Eta[p]).SetBinContent(i+1,m_ModNormEta[labelHisto][i]);
1282  }
1283  for (unsigned int i = 0; i < m_ModNormPhi[labelHisto].size(); i++){
1284  (*h_ModNorm_Phi[p]).SetBinContent(i+1,m_ModNormPhi[labelHisto][i]);
1285  }
1286 
1287  (*h_ModNorm_Eta[p]).Write();
1288  (*h_ModNorm_Phi[p]).Write();
1289  }
1290 
1291 }
1292 
1293 
1294 // ------------ method called once each job just before starting event loop ------------
1295 void
1297 {
1298  if (dbe_)
1299  {
1300  if (monitorName_ != "")
1301  monitorName_ = monitorName_ + "/";
1302  edm::LogInfo ("HLTMuonDQMSource") << "===>DQM event prescale = " << prescaleEvt_ << " events " << std::endl;
1303  createMEs (es);
1304  //create TKHistoMap
1305  if(runOnClusters_)
1306  tkmapAllClusters = new TkHistoMap("HLT/HLTMonMuon/SiStrip" ,"TkHMap_AllClusters",0.0,0);
1307  if(runOnTracks_)
1308  tkmapOnTrackClusters = new TkHistoMap("HLT/HLTMonMuon/SiStrip" ,"TkHMap_OnTrackClusters",0.0,0);
1310  tkmapL3MuTrackClusters = new TkHistoMap("HLT/HLTMonMuon/SiStrip" ,"TkHMap_L3MuTrackClusters",0.0,0);
1311  }
1312 }
1313 
1314 // ------------ method called once each job just after ending the event loop ------------
1315 void
1317 {
1318  edm::LogInfo ("SiStripMonitorHLTMuon") << "analyzed " << counterEvt_ << " events";
1319  return;
1320 }
1321 
#define LogDebug(id)
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:78
unsigned int moduleNumber(align::ID)
Module number increases (decreases) with phi for +z (-z) endcap.
Definition: TECNameSpace.h:42
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::map< std::string, std::vector< float > > m_BinPhi
const std::string & label
Definition: MVAComputer.cc:186
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:519
unsigned int rodNumber(align::ID)
Rod number increases with phi.
Definition: TOBNameSpace.h:41
unsigned int ringNumber(align::ID)
Ring number increases with rho.
Definition: TECNameSpace.h:47
#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
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
T y() const
Definition: PV3DBase.h:57
#define NULL
Definition: scimark2.h:8
float GetPhiWeight(std::string label, GlobalPoint gp)
#define min(a, b)
Definition: mlp_lapack.h:161
bool isAvailable() const
Definition: Ref.h:278
void PrintNormalization(std::vector< std::string > v_LabelHisto)
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
T eta() const
dictionary map
Definition: Association.py:160
void getSubDetLayerFolderName(std::stringstream &ss, SiStripDetId::SubDetector subDet, uint32_t layer, uint32_t side=0)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:248
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:306
int iEvent
Definition: GenABIO.cc:243
const T & max(const T &a, const T &b)
void GeometryFromTrackGeom(std::vector< DetId > Dets, const TrackerGeometry &theTracker, std::map< std::string, std::vector< float > > &m_PhiStripMod_Eta, std::map< std::string, std::vector< float > > &m_PhiStripMod_Nb)
T sqrt(T t)
Definition: SSEVec.h:28
bool verbose_
every n events
T z() const
Definition: PV3DBase.h:58
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:201
virtual float width() const
Width along local X.
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:359
int prescaleEvt_
mutriggered events
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::map< std::string, LayerMEs > LayerMEMap
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
bool failedToGet() const
Definition: HandleBase.h:80
const Bounds & bounds() const
Definition: BoundSurface.h:89
#define M_PI
Definition: BFit3D.cc:3
string fullName
unsigned int stringNumber(align::ID)
Definition: TIBNameSpace.h:51
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
T const * product() const
Definition: ESHandle.h:62
ClusterRegionalRef const & cluster_regional() const
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 petalNumber(align::ID)
Petal number increases with phi from 1 to 8.
Definition: TECNameSpace.h:52
T eta() const
Definition: PV3DBase.h:70
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
#define begin
Definition: vmac.h:31
virtual float length() const
Lenght along local Y.
TrackingRecHitRef recHit(size_t i) const
Get i-th hit on the track.
Definition: Track.h:67
virtual const DetIdContainer & detUnitIds() const
Returm a vector of all GeomDetUnit DetIds.
std::string getLayerName(int &in)
Definition: TkDetMap.cc:684
static unsigned int const shift
virtual LocalPoint localPosition(float strip) const =0
virtual SubDetector subDetector() const
Which subdetector.
Definition: GeomDetUnit.cc:15
Definition: Bounds.h:18
virtual float length() const
std::map< std::string, std::vector< float > > m_ModNormEta
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:647
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:239
T x() const
Definition: PV3DBase.h:56
void add(uint32_t &detid, float value)
Definition: TkHistoMap.cc:163
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:237
Definition: Run.h:31
edm::ParameterSet parameters_
Definition: DDAxes.h:10