CMS 3D CMS Logo

SegmentTrackAnalyzer.cc
Go to the documentation of this file.
1 
2 /*
3  * See header file for a description of this class.
4  *
5  * \author G. Mila - INFN Torino
6  */
7 
9 
18 
20 #include <string>
21 
22 using namespace std;
23 using namespace edm;
24 
25 //#define DEBUG
26 
28  parameters = pSet;
29 
30  // Read Data:
31  theMuTrackCollectionLabel_ =
32  consumes<reco::TrackCollection>(parameters.getParameter<edm::InputTag>("MuTrackCollection"));
33 
34  // SegmentTrackAssociatior Parameters
36  parameters.getParameter<ParameterSet>("SegmentsTrackAssociatorParameters");
37 
38  edm::ConsumesCollector iC = consumesCollector();
39  theSegmentsAssociator = new SegmentsTrackAssociator(SegmentsTrackAssociatorParameters, iC);
40 
41  trackCollection = parameters.getParameter<edm::InputTag>("MuTrackCollection").label() +
42  parameters.getParameter<edm::InputTag>("MuTrackCollection").instance();
43 
44  etaBin = parameters.getParameter<int>("etaBin");
45  etaMin = parameters.getParameter<double>("etaMin");
46  etaMax = parameters.getParameter<double>("etaMax");
47  phiBin = parameters.getParameter<int>("phiBin");
48  phiMin = parameters.getParameter<double>("phiMin");
49  phiMax = parameters.getParameter<double>("phiMax");
50  ptBin = parameters.getParameter<int>("ptBin");
51  ptMin = parameters.getParameter<double>("ptMin");
52  ptMax = parameters.getParameter<double>("ptMax");
53 }
55  const edm::Run& /*iRun*/,
56  const edm::EventSetup& /*iSetup*/) {
57  ibooker.cd();
58  ibooker.setCurrentFolder("Muons/SegmentTrackAnalyzer");
59 
60  // histograms initalization
61  hitsNotUsed = ibooker.book1D("HitsNotUsedForGlobalTracking_" + trackCollection,
62  "recHits not used for GLB [" + trackCollection + "]",
63  50,
64  -0.5,
65  49.5);
66  hitsNotUsedPercentual = ibooker.book1D("HitsNotUsedForGlobalTrackingDvHitUsed_" + trackCollection,
67  "(recHits_{notUsedForGLB}) / (recHits_{GLB}) [" + trackCollection + "]",
68  100,
69  0,
70  1.);
71 
72  TrackSegm = ibooker.book2D("trackSegments_" + trackCollection,
73  "Number of segments associated to the track [" + trackCollection + "]",
74  3,
75  0.5,
76  3.5,
77  8,
78  0,
79  8);
80  TrackSegm->setBinLabel(1, "DT+CSC", 1);
81  TrackSegm->setBinLabel(2, "DT", 1);
82  TrackSegm->setBinLabel(3, "CSC", 1);
83 
84  hitStaProvenance = ibooker.book1D("trackHitStaProvenance_" + trackCollection,
85  "Number of recHits_{STAinTrack} [" + trackCollection + "]",
86  7,
87  0.5,
88  7.5);
89  hitStaProvenance->setBinLabel(1, "DT");
90  hitStaProvenance->setBinLabel(2, "CSC");
91  hitStaProvenance->setBinLabel(3, "RPC");
92  hitStaProvenance->setBinLabel(4, "DT+CSC");
93  hitStaProvenance->setBinLabel(5, "DT+RPC");
94  hitStaProvenance->setBinLabel(6, "CSC+RPC");
95  hitStaProvenance->setBinLabel(7, "DT+CSC+RPC");
96 
97  if (trackCollection != "standAloneMuons") {
98  hitTkrProvenance = ibooker.book1D("trackHitTkrProvenance_" + trackCollection,
99  "Number of recHits_{TKinTrack} [" + trackCollection + "]",
100  6,
101  0.5,
102  6.5);
103  hitTkrProvenance->setBinLabel(1, "PixBarrel");
104  hitTkrProvenance->setBinLabel(2, "PixEndCap");
105  hitTkrProvenance->setBinLabel(3, "TIB");
106  hitTkrProvenance->setBinLabel(4, "TID");
107  hitTkrProvenance->setBinLabel(5, "TOB");
108  hitTkrProvenance->setBinLabel(6, "TEC");
109  }
110 
111  trackHitPercentualVsEta =
112  ibooker.book2D("trackHitDivtrackSegmHitVsEta_" + trackCollection,
113  "(recHits_{Track} / recHits_{associatedSegm}) vs #eta [" + trackCollection + "]",
114  etaBin,
115  etaMin,
116  etaMax,
117  20,
118  0,
119  1);
120  dtTrackHitPercentualVsEta =
121  ibooker.book2D("dtTrackHitDivtrackSegmHitVsEta_" + trackCollection,
122  "(recHits_{DTinTrack} / recHits_{associatedSegm}) vs #eta [" + trackCollection + "]",
123  etaBin,
124  etaMin,
125  etaMax,
126  20,
127  0,
128  1);
129  cscTrackHitPercentualVsEta =
130  ibooker.book2D("cscTrackHitDivtrackSegmHitVsEta_" + trackCollection,
131  "(recHits_{CSCinTrack} / recHits_{associatedSegm}) vs #eta [" + trackCollection + "]",
132  etaBin,
133  etaMin,
134  etaMax,
135  20,
136  0,
137  1);
138 
139  trackHitPercentualVsPhi =
140  ibooker.book2D("trackHitDivtrackSegmHitVsPhi_" + trackCollection,
141  "(recHits_{Track} / recHits_{associatedSegm}) vs #phi [" + trackCollection + "]",
142  phiBin,
143  phiMin,
144  phiMax,
145  20,
146  0,
147  1);
148  trackHitPercentualVsPhi->setAxisTitle("rad", 2);
149  dtTrackHitPercentualVsPhi =
150  ibooker.book2D("dtTrackHitDivtrackSegmHitVsPhi_" + trackCollection,
151  "(recHits_{DTinTrack} / recHits_{associatedSegm}) vs #phi [" + trackCollection + "]",
152  phiBin,
153  phiMin,
154  phiMax,
155  20,
156  0,
157  1);
158  dtTrackHitPercentualVsPhi->setAxisTitle("rad", 2);
159  cscTrackHitPercentualVsPhi =
160  ibooker.book2D("cscTrackHitDivtrackSegmHitVsPhi_" + trackCollection,
161  "(recHits_{CSCinTrack} / recHits_{associatedSegm}) vs #phi [" + trackCollection + "]",
162  phiBin,
163  phiMin,
164  phiMax,
165  20,
166  0,
167  1);
168  cscTrackHitPercentualVsPhi->setAxisTitle("rad", 2);
169 
170  trackHitPercentualVsPt =
171  ibooker.book2D("trackHitDivtrackSegmHitVsPt_" + trackCollection,
172  "(recHits_{Track} / recHits_{associatedSegm}) vs 1/p_{t} [" + trackCollection + "]",
173  ptBin,
174  ptMin,
175  ptMax,
176  20,
177  0,
178  1);
179  trackHitPercentualVsPt->setAxisTitle("GeV", 2);
180  dtTrackHitPercentualVsPt =
181  ibooker.book2D("dtTrackHitDivtrackSegmHitVsPt_" + trackCollection,
182  "(recHits_{DTinTrack} / recHits_{associatedSegm}) vs 1/p_{t} [" + trackCollection + "]",
183  ptBin,
184  ptMin,
185  ptMax,
186  20,
187  0,
188  1);
189  dtTrackHitPercentualVsPt->setAxisTitle("GeV", 2);
190  cscTrackHitPercentualVsPt =
191  ibooker.book2D("cscTrackHitDivtrackSegmHitVsPt_" + trackCollection,
192  "(recHits_{CSCinTrack} / recHits_{associatedSegm}) vs 1/p_{t} [" + trackCollection + "]",
193  ptBin,
194  ptMin,
195  ptMax,
196  20,
197  0,
198  1);
199  cscTrackHitPercentualVsPt->setAxisTitle("GeV", 2);
200 }
201 
204  iEvent.getByToken(theMuTrackCollectionLabel_, glbTracks);
205 
206  for (reco::TrackCollection::const_iterator recoTrack = glbTracks->begin(); recoTrack != glbTracks->end();
207  ++recoTrack) {
209  theSegmentsAssociator->associate(iEvent, iSetup, *recoTrack);
210 
211 #ifdef DEBUG
212  cout << "[SegmentTrackAnalyzer] # of segments associated to the track: " << (segments).size() << endl;
213 #endif
214 
215  // hit counters
216  int hitsFromDt = 0;
217  int hitsFromCsc = 0;
218  int hitsFromRpc = 0;
219  int hitsFromTk = 0;
220  int hitsFromTrack = 0;
221  int hitsFromSegmDt = 0;
222  int hitsFromSegmCsc = 0;
223  // segment counters
224  int segmFromDt = 0;
225  int segmFromCsc = 0;
226 
227  for (MuonTransientTrackingRecHit::MuonRecHitContainer::const_iterator segment = segments.begin();
228  segment != segments.end();
229  segment++) {
230  DetId id = (*segment)->geographicalId();
231 
232  // hits from DT segments
233  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::DT) {
234  ++segmFromDt;
235  const DTRecSegment4D* seg4D = dynamic_cast<const DTRecSegment4D*>((*segment)->hit());
236  if ((*seg4D).hasPhi())
237  hitsFromSegmDt += (*seg4D).phiSegment()->specificRecHits().size();
238  if ((*seg4D).hasZed())
239  hitsFromSegmDt += (*seg4D).zSegment()->specificRecHits().size();
240  }
241 
242  // hits from CSC segments
243  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC) {
244  hitsFromSegmCsc += (*segment)->recHits().size();
245  segmFromCsc++;
246  }
247  }
248 
249  // hits from track
250  for (trackingRecHit_iterator recHit = recoTrack->recHitsBegin(); recHit != recoTrack->recHitsEnd(); ++recHit) {
251  hitsFromTrack++;
252  DetId id = (*recHit)->geographicalId();
253  // hits from DT
254  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::DT)
255  hitsFromDt++;
256  // hits from CSC
257  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC)
258  hitsFromCsc++;
259  // hits from RPC
260  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::RPC)
261  hitsFromRpc++;
262  // hits from Tracker
263  if (id.det() == DetId::Tracker) {
264  hitsFromTk++;
265  if (id.subdetId() == PixelSubdetector::PixelBarrel)
266  hitTkrProvenance->Fill(1);
267  if (id.subdetId() == PixelSubdetector::PixelEndcap)
268  hitTkrProvenance->Fill(2);
269  if (id.subdetId() == SiStripDetId::TIB)
270  hitTkrProvenance->Fill(3);
271  if (id.subdetId() == SiStripDetId::TID)
272  hitTkrProvenance->Fill(4);
273  if (id.subdetId() == SiStripDetId::TOB)
274  hitTkrProvenance->Fill(5);
275  if (id.subdetId() == SiStripDetId::TEC)
276  hitTkrProvenance->Fill(6);
277  }
278  }
279 
280  // fill the histos
281  hitsNotUsed->Fill(hitsFromSegmDt + hitsFromSegmCsc + hitsFromRpc + hitsFromTk - hitsFromTrack);
282  hitsNotUsedPercentual->Fill(double(hitsFromSegmDt + hitsFromSegmCsc + hitsFromRpc + hitsFromTk - hitsFromTrack) /
283  hitsFromTrack);
284 
285  if (hitsFromDt != 0 && hitsFromCsc != 0)
286  TrackSegm->Fill(1, segmFromDt + segmFromCsc);
287  if (hitsFromDt != 0 && hitsFromCsc == 0)
288  TrackSegm->Fill(2, segmFromDt);
289  if (hitsFromDt == 0 && hitsFromCsc != 0)
290  TrackSegm->Fill(3, segmFromCsc);
291 
292  if (hitsFromDt != 0 && hitsFromCsc == 0 && hitsFromRpc == 0)
293  hitStaProvenance->Fill(1);
294  if (hitsFromCsc != 0 && hitsFromDt == 0 && hitsFromRpc == 0)
295  hitStaProvenance->Fill(2);
296  if (hitsFromRpc != 0 && hitsFromDt == 0 && hitsFromCsc == 0)
297  hitStaProvenance->Fill(3);
298  if (hitsFromDt != 0 && hitsFromCsc != 0 && hitsFromRpc == 0)
299  hitStaProvenance->Fill(4);
300  if (hitsFromDt != 0 && hitsFromRpc != 0 && hitsFromCsc == 0)
301  hitStaProvenance->Fill(5);
302  if (hitsFromCsc != 0 && hitsFromRpc != 0 && hitsFromDt == 0)
303  hitStaProvenance->Fill(6);
304  if (hitsFromDt != 0 && hitsFromCsc != 0 && hitsFromRpc != 0)
305  hitStaProvenance->Fill(7);
306 
307  if (hitsFromSegmDt + hitsFromSegmCsc != 0) {
308  trackHitPercentualVsEta->Fill(recoTrack->eta(),
309  double(hitsFromDt + hitsFromCsc) / (hitsFromSegmDt + hitsFromSegmCsc));
310  trackHitPercentualVsPhi->Fill(recoTrack->phi(),
311  double(hitsFromDt + hitsFromCsc) / (hitsFromSegmDt + hitsFromSegmCsc));
312  trackHitPercentualVsPt->Fill(recoTrack->pt(),
313  double(hitsFromDt + hitsFromCsc) / (hitsFromSegmDt + hitsFromSegmCsc));
314  }
315 
316  if (hitsFromSegmDt != 0) {
317  dtTrackHitPercentualVsEta->Fill(recoTrack->eta(), double(hitsFromDt) / hitsFromSegmDt);
318  dtTrackHitPercentualVsPhi->Fill(recoTrack->phi(), double(hitsFromDt) / hitsFromSegmDt);
319  dtTrackHitPercentualVsPt->Fill(recoTrack->pt(), double(hitsFromDt) / hitsFromSegmDt);
320  }
321 
322  if (hitsFromSegmCsc != 0) {
323  cscTrackHitPercentualVsEta->Fill(recoTrack->eta(), double(hitsFromCsc) / hitsFromSegmCsc);
324  cscTrackHitPercentualVsPhi->Fill(recoTrack->phi(), double(hitsFromCsc) / hitsFromSegmCsc);
325  cscTrackHitPercentualVsPt->Fill(recoTrack->pt(), double(hitsFromCsc) / hitsFromSegmCsc);
326  }
327  }
328 }
MuonSubdetId::CSC
static constexpr int CSC
Definition: MuonSubdetId.h:12
DTRecSegment4D
Definition: DTRecSegment4D.h:23
Handle.h
ALCARECOTkAlBeamHalo_cff.etaMin
etaMin
GeV.
Definition: ALCARECOTkAlBeamHalo_cff.py:32
PixelSubdetector.h
MessageLogger.h
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
DTRecHitCollection.h
etaBin
int etaBin(const l1t::HGCalMulticluster *cl)
Definition: L1EGammaEEProducer.cc:19
edm::Run
Definition: Run.h:45
BeamMonitor_cff.phiBin
phiBin
Definition: BeamMonitor_cff.py:75
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ptMin
constexpr float ptMin
Definition: PhotonIDValueMapProducer.cc:153
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
SiStripDetId.h
MuonTransientTrackingRecHit::MuonRecHitContainer
std::vector< MuonRecHitPointer > MuonRecHitContainer
Definition: MuonTransientTrackingRecHit.h:26
SegmentsTrackAssociator
Definition: SegmentsTrackAssociator.h:39
MuonTransientTrackingRecHit.h
edm::Handle< reco::TrackCollection >
muonRecoAnalyzer_cfi.ptBin
ptBin
Definition: muonRecoAnalyzer_cfi.py:45
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
parameters
parameters
Definition: BeamSpot_PayloadInspector.cc:14
std::size
constexpr auto size(const C &c) -> decltype(c.size())
Definition: cuda_cxx17.h:13
DetId
Definition: DetId.h:17
AlignmentTrackSelector_cfi.ptMax
ptMax
Definition: AlignmentTrackSelector_cfi.py:12
SegmentTrackAnalyzer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: SegmentTrackAnalyzer.cc:202
AlignmentTrackSelector_cfi.phiMin
phiMin
Definition: AlignmentTrackSelector_cfi.py:18
AlignmentTrackSelector_cfi.phiMax
phiMax
Definition: AlignmentTrackSelector_cfi.py:17
dqm::implementation::NavigatorBase::cd
virtual void cd()
Definition: DQMStore.cc:29
MuonSubdetId::DT
static constexpr int DT
Definition: MuonSubdetId.h:11
SiStripDetId::TEC
static constexpr auto TEC
Definition: SiStripDetId.h:40
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
edm::ParameterSet
Definition: ParameterSet.h:36
DetId::Tracker
Definition: DetId.h:25
segmentTrackAnalyzer_cfi.SegmentsTrackAssociatorParameters
SegmentsTrackAssociatorParameters
Definition: segmentTrackAnalyzer_cfi.py:11
duplicaterechits_cfi.trackCollection
trackCollection
Definition: duplicaterechits_cfi.py:4
SegmentTrackAnalyzer::SegmentTrackAnalyzer
SegmentTrackAnalyzer(const edm::ParameterSet &)
Constructor.
Definition: SegmentTrackAnalyzer.cc:27
iEvent
int iEvent
Definition: GenABIO.cc:224
dqm::impl::MonitorElement::setBinLabel
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:771
SegmentTrackAnalyzer::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: SegmentTrackAnalyzer.cc:54
SiStripDetId::TOB
static constexpr auto TOB
Definition: SiStripDetId.h:39
edm::EventSetup
Definition: EventSetup.h:57
MuonSubdetId.h
instance
static PFTauRenderPlugin instance
Definition: PFTauRenderPlugin.cc:70
SiStripDetId::TID
static constexpr auto TID
Definition: SiStripDetId.h:38
std
Definition: JetResolutionObject.h:76
MuonSubdetId::RPC
static constexpr int RPC
Definition: MuonSubdetId.h:13
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
MuonServiceProxy.h
ALCARECOTkAlBeamHalo_cff.etaMax
etaMax
Definition: ALCARECOTkAlBeamHalo_cff.py:33
SiStripDetId::TIB
static constexpr auto TIB
Definition: SiStripDetId.h:37
DTRecSegment2D::specificRecHits
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
Definition: DTRecSegment2D.cc:104
SegmentTrackAnalyzer.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
DetId::Muon
Definition: DetId.h:26
edm::Event
Definition: Event.h:73
DTRecSegment4D::phiSegment
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
Definition: DTRecSegment4D.h:96
dqm::impl::MonitorElement::setAxisTitle
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:800
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
label
const char * label
Definition: PFTauDecayModeTools.cc:11
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
DTRecSegment4DCollection.h