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