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 
236  const DTRecSegment4D* seg4D = dynamic_cast<const DTRecSegment4D*>((*segment)->hit());
237  if ((*seg4D).hasPhi())
238  hitsFromSegmDt += (*seg4D).phiSegment()->specificRecHits().size();
239  if ((*seg4D).hasZed())
240  hitsFromSegmDt += (*seg4D).zSegment()->specificRecHits().size();
241  }
242 
243  // hits from CSC segments
244  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC) {
245  hitsFromSegmCsc += (*segment)->recHits().size();
246  segmFromCsc++;
247  }
248 
249 #ifdef DEBUG
250  cout << "[SegmentTrackAnalyzer] # of segments from DT and CSC: " << segmFromDt << ", " << segmFromCsc << endl;
251  cout << "[SegmentTrackAnalyzer] # of HITS from segments from DT: " << hitsFromSegmDt << endl;
252  cout << "[SegmentTrackAnalyzer] # of HITS from segments from CSC " << hitsFromSegmCsc << endl;
253 #endif
254  }
255 
256  // hits from track
257  for (trackingRecHit_iterator recHit = recoTrack->recHitsBegin(); recHit != recoTrack->recHitsEnd(); ++recHit) {
258  hitsFromTrack++;
259  DetId id = (*recHit)->geographicalId();
260  // hits from DT
261  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::DT)
262  hitsFromDt++;
263  // hits from CSC
264  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC)
265  hitsFromCsc++;
266  // hits from RPC
267  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::RPC)
268  hitsFromRpc++;
269  // hits from Tracker
270  if (id.det() == DetId::Tracker) {
271  hitsFromTk++;
272  if (id.subdetId() == PixelSubdetector::PixelBarrel)
273  hitTkrProvenance->Fill(1);
274  if (id.subdetId() == PixelSubdetector::PixelEndcap)
275  hitTkrProvenance->Fill(2);
276  if (id.subdetId() == SiStripDetId::TIB)
277  hitTkrProvenance->Fill(3);
278  if (id.subdetId() == SiStripDetId::TID)
279  hitTkrProvenance->Fill(4);
280  if (id.subdetId() == SiStripDetId::TOB)
281  hitTkrProvenance->Fill(5);
282  if (id.subdetId() == SiStripDetId::TEC)
283  hitTkrProvenance->Fill(6);
284  }
285  }
286 
287  // fill the histos
288  hitsNotUsed->Fill(hitsFromSegmDt + hitsFromSegmCsc + hitsFromRpc + hitsFromTk - hitsFromTrack);
289  hitsNotUsedPercentual->Fill(double(hitsFromSegmDt + hitsFromSegmCsc + hitsFromRpc + hitsFromTk - hitsFromTrack) /
290  hitsFromTrack);
291 
292  if (hitsFromDt != 0 && hitsFromCsc != 0)
293  TrackSegm->Fill(1, segmFromDt + segmFromCsc);
294  if (hitsFromDt != 0 && hitsFromCsc == 0)
295  TrackSegm->Fill(2, segmFromDt);
296  if (hitsFromDt == 0 && hitsFromCsc != 0)
297  TrackSegm->Fill(3, segmFromCsc);
298 
299  if (hitsFromDt != 0 && hitsFromCsc == 0 && hitsFromRpc == 0)
300  hitStaProvenance->Fill(1);
301  if (hitsFromCsc != 0 && hitsFromDt == 0 && hitsFromRpc == 0)
302  hitStaProvenance->Fill(2);
303  if (hitsFromRpc != 0 && hitsFromDt == 0 && hitsFromCsc == 0)
304  hitStaProvenance->Fill(3);
305  if (hitsFromDt != 0 && hitsFromCsc != 0 && hitsFromRpc == 0)
306  hitStaProvenance->Fill(4);
307  if (hitsFromDt != 0 && hitsFromRpc != 0 && hitsFromCsc == 0)
308  hitStaProvenance->Fill(5);
309  if (hitsFromCsc != 0 && hitsFromRpc != 0 && hitsFromDt == 0)
310  hitStaProvenance->Fill(6);
311  if (hitsFromDt != 0 && hitsFromCsc != 0 && hitsFromRpc != 0)
312  hitStaProvenance->Fill(7);
313 
314  if (hitsFromSegmDt + hitsFromSegmCsc != 0) {
315  trackHitPercentualVsEta->Fill(recoTrack->eta(),
316  double(hitsFromDt + hitsFromCsc) / (hitsFromSegmDt + hitsFromSegmCsc));
317  trackHitPercentualVsPhi->Fill(recoTrack->phi(),
318  double(hitsFromDt + hitsFromCsc) / (hitsFromSegmDt + hitsFromSegmCsc));
319  trackHitPercentualVsPt->Fill(recoTrack->pt(),
320  double(hitsFromDt + hitsFromCsc) / (hitsFromSegmDt + hitsFromSegmCsc));
321  }
322 
323  if (hitsFromSegmDt != 0) {
324  dtTrackHitPercentualVsEta->Fill(recoTrack->eta(), double(hitsFromDt) / hitsFromSegmDt);
325  dtTrackHitPercentualVsPhi->Fill(recoTrack->phi(), double(hitsFromDt) / hitsFromSegmDt);
326  dtTrackHitPercentualVsPt->Fill(recoTrack->pt(), double(hitsFromDt) / hitsFromSegmDt);
327  }
328 
329  if (hitsFromSegmCsc != 0) {
330  cscTrackHitPercentualVsEta->Fill(recoTrack->eta(), double(hitsFromCsc) / hitsFromSegmCsc);
331  cscTrackHitPercentualVsPhi->Fill(recoTrack->phi(), double(hitsFromCsc) / hitsFromSegmCsc);
332  cscTrackHitPercentualVsPt->Fill(recoTrack->pt(), double(hitsFromCsc) / hitsFromSegmCsc);
333  }
334  }
335 }
size
Write out results.
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
static PFTauRenderPlugin instance
static constexpr auto TID
Definition: SiStripDetId.h:38
constexpr float ptMin
char const * label
int iEvent
Definition: GenABIO.cc:224
SegmentTrackAnalyzer(const edm::ParameterSet &)
Constructor.
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)
static constexpr auto TOB
Definition: SiStripDetId.h:39
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: DetId.h:17
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
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:212
static constexpr int RPC
Definition: MuonSubdetId.h:13
static constexpr auto TIB
Definition: SiStripDetId.h:37
HLT enums.
static constexpr int DT
Definition: MuonSubdetId.h:11
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
static constexpr int CSC
Definition: MuonSubdetId.h:12
std::vector< MuonRecHitPointer > MuonRecHitContainer
int etaBin(const l1t::HGCalMulticluster *cl)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
static constexpr auto TEC
Definition: SiStripDetId.h:40
Definition: Run.h:45
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)