CMS 3D CMS Logo

TrackBuildingAnalyzer.cc
Go to the documentation of this file.
12 
15 
20 #include <string>
21 #include "TMath.h"
22 
23 #include <iostream>
24 
26  doAllPlots( iConfig.getParameter<bool>("doAllPlots")),
27  doAllSeedPlots(iConfig.getParameter<bool>("doSeedParameterHistos")),
28  doTCPlots( iConfig.getParameter<bool>("doTrackCandHistos")),
29  doAllTCPlots( iConfig.getParameter<bool>("doAllTrackCandHistos")),
30  doPT( iConfig.getParameter<bool>("doSeedPTHisto")),
31  doETA( iConfig.getParameter<bool>("doSeedETAHisto")),
32  doPHI( iConfig.getParameter<bool>("doSeedPHIHisto")),
33  doPHIVsETA( iConfig.getParameter<bool>("doSeedPHIVsETAHisto")),
34  doTheta( iConfig.getParameter<bool>("doSeedThetaHisto")),
35  doQ( iConfig.getParameter<bool>("doSeedQHisto")),
36  doDxy( iConfig.getParameter<bool>("doSeedDxyHisto")),
37  doDz( iConfig.getParameter<bool>("doSeedDzHisto")),
38  doNRecHits( iConfig.getParameter<bool>("doSeedNRecHitsHisto")),
39  doProfPHI( iConfig.getParameter<bool>("doSeedNVsPhiProf")),
40  doProfETA( iConfig.getParameter<bool>("doSeedNVsEtaProf")),
41  doStopSource( iConfig.getParameter<bool>("doStopSource")),
42  doMVAPlots( iConfig.getParameter<bool>("doMVAPlots")),
43  doRegionPlots( iConfig.getParameter<bool>("doRegionPlots")),
44  doRegionCandidatePlots( iConfig.getParameter<bool>("doRegionCandidatePlots"))
45 {
46 }
47 
49 {
50 
51  // parameters from the configuration
52  std::string AlgoName = iConfig.getParameter<std::string>("AlgoName");
53  std::string MEFolderName = iConfig.getParameter<std::string>("FolderName");
54 
55  // std::cout << "[TrackBuildingAnalyzer::beginRun] AlgoName: " << AlgoName << std::endl;
56 
57  // use the AlgoName and Quality Name
58  const std::string& CatagoryName = AlgoName;
59 
60  // get binning from the configuration
61  int TrackPtBin = iConfig.getParameter<int>( "TrackPtBin");
62  double TrackPtMin = iConfig.getParameter<double>("TrackPtMin");
63  double TrackPtMax = iConfig.getParameter<double>("TrackPtMax");
64 
65  int PhiBin = iConfig.getParameter<int>( "PhiBin");
66  double PhiMin = iConfig.getParameter<double>("PhiMin");
67  double PhiMax = iConfig.getParameter<double>("PhiMax");
68  phiBinWidth = PhiBin > 0 ? (PhiMax-PhiMin)/PhiBin : 0.;
69 
70  int EtaBin = iConfig.getParameter<int>( "EtaBin");
71  double EtaMin = iConfig.getParameter<double>("EtaMin");
72  double EtaMax = iConfig.getParameter<double>("EtaMax");
73  etaBinWidth = EtaBin > 0 ? (EtaMax-EtaMin)/EtaBin : 0.;
74 
75  int ThetaBin = iConfig.getParameter<int>( "ThetaBin");
76  double ThetaMin = iConfig.getParameter<double>("ThetaMin");
77  double ThetaMax = iConfig.getParameter<double>("ThetaMax");
78 
79  int TrackQBin = iConfig.getParameter<int>( "TrackQBin");
80  double TrackQMin = iConfig.getParameter<double>("TrackQMin");
81  double TrackQMax = iConfig.getParameter<double>("TrackQMax");
82 
83  int SeedDxyBin = iConfig.getParameter<int>( "SeedDxyBin");
84  double SeedDxyMin = iConfig.getParameter<double>("SeedDxyMin");
85  double SeedDxyMax = iConfig.getParameter<double>("SeedDxyMax");
86 
87  int SeedDzBin = iConfig.getParameter<int>( "SeedDzBin");
88  double SeedDzMin = iConfig.getParameter<double>("SeedDzMin");
89  double SeedDzMax = iConfig.getParameter<double>("SeedDzMax");
90 
91  int SeedHitBin = iConfig.getParameter<int>( "SeedHitBin");
92  double SeedHitMin = iConfig.getParameter<double>("SeedHitMin");
93  double SeedHitMax = iConfig.getParameter<double>("SeedHitMax");
94 
95  int TCDxyBin = iConfig.getParameter<int>( "TCDxyBin");
96  double TCDxyMin = iConfig.getParameter<double>("TCDxyMin");
97  double TCDxyMax = iConfig.getParameter<double>("TCDxyMax");
98 
99  int TCDzBin = iConfig.getParameter<int>( "TCDzBin");
100  double TCDzMin = iConfig.getParameter<double>("TCDzMin");
101  double TCDzMax = iConfig.getParameter<double>("TCDzMax");
102 
103  int TCHitBin = iConfig.getParameter<int>( "TCHitBin");
104  double TCHitMin = iConfig.getParameter<double>("TCHitMin");
105  double TCHitMax = iConfig.getParameter<double>("TCHitMax");
106 
107  int MVABin = iConfig.getParameter<int>( "MVABin");
108  double MVAMin = iConfig.getParameter<double>("MVAMin");
109  double MVAMax = iConfig.getParameter<double>("MVAMax");
110 
111 
112  edm::InputTag seedProducer = iConfig.getParameter<edm::InputTag>("SeedProducer");
113  edm::InputTag tcProducer = iConfig.getParameter<edm::InputTag>("TCProducer");
114  std::vector<std::string> mvaProducers = iConfig.getParameter<std::vector<std::string> >("MVAProducers");
115  edm::InputTag regionProducer = iConfig.getParameter<edm::InputTag>("RegionProducer");
116 
117  // if (doAllPlots){doAllSeedPlots=true; doTCPlots=true;}
118 
119  ibooker.setCurrentFolder(MEFolderName);
120 
121  // book the Seed histograms
122  // ---------------------------------------------------------------------------------//
123  // std::cout << "[TrackBuildingAnalyzer::beginRun] MEFolderName: " << MEFolderName << std::endl;
124  ibooker.setCurrentFolder(MEFolderName+"/TrackBuilding");
125 
126  if (doAllSeedPlots || doPT) {
127  histname = "SeedPt_"+seedProducer.label() + "_";
128  SeedPt = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, TrackPtBin, TrackPtMin, TrackPtMax);
129  SeedPt->setAxisTitle("Seed p_{T} (GeV/c)", 1);
130  SeedPt->setAxisTitle("Number of Seeds", 2);
131  }
132 
133  if (doAllSeedPlots || doETA) {
134  histname = "SeedEta_"+seedProducer.label() + "_";
135  SeedEta = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, EtaBin, EtaMin, EtaMax);
136  SeedEta->setAxisTitle("Seed #eta", 1);
137  SeedEta->setAxisTitle("Number of Seeds", 2);
138  }
139 
140  if (doAllSeedPlots || doPHI) {
141  histname = "SeedPhi_"+seedProducer.label() + "_";
142  SeedPhi = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, PhiBin, PhiMin, PhiMax);
143  SeedPhi->setAxisTitle("Seed #phi", 1);
144  SeedPhi->setAxisTitle("Number of Seed", 2);
145  }
146 
147  if (doAllSeedPlots || doPHIVsETA) {
148  histname = "SeedPhiVsEta_"+seedProducer.label() + "_";
149  SeedPhiVsEta = ibooker.book2D(histname+CatagoryName, histname+CatagoryName, EtaBin, EtaMin, EtaMax, PhiBin, PhiMin, PhiMax);
150  SeedPhiVsEta->setAxisTitle("Seed #eta", 1);
151  SeedPhiVsEta->setAxisTitle("Seed #phi", 2);
152  }
153 
154  if (doAllSeedPlots || doTheta){
155  histname = "SeedTheta_"+seedProducer.label() + "_";
156  SeedTheta = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, ThetaBin, ThetaMin, ThetaMax);
157  SeedTheta->setAxisTitle("Seed #theta", 1);
158  SeedTheta->setAxisTitle("Number of Seeds", 2);
159  }
160 
161  if (doAllSeedPlots || doQ){
162  histname = "SeedQ_"+seedProducer.label() + "_";
163  SeedQ = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, TrackQBin, TrackQMin, TrackQMax);
164  SeedQ->setAxisTitle("Seed Charge", 1);
165  SeedQ->setAxisTitle("Number of Seeds",2);
166  }
167 
168  if (doAllSeedPlots || doDxy){
169  histname = "SeedDxy_"+seedProducer.label() + "_";
170  SeedDxy = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, SeedDxyBin, SeedDxyMin, SeedDxyMax);
171  SeedDxy->setAxisTitle("Seed d_{xy} (cm)", 1);
172  SeedDxy->setAxisTitle("Number of Seeds",2);
173  }
174 
175  if (doAllSeedPlots || doDz){
176  histname = "SeedDz_"+seedProducer.label() + "_";
177  SeedDz = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, SeedDzBin, SeedDzMin, SeedDzMax);
178  SeedDz->setAxisTitle("Seed d_{z} (cm)", 1);
179  SeedDz->setAxisTitle("Number of Seeds",2);
180  }
181 
182  if (doAllSeedPlots || doNRecHits){
183  histname = "NumberOfRecHitsPerSeed_"+seedProducer.label() + "_";
184  NumberOfRecHitsPerSeed = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, SeedHitBin, SeedHitMin, SeedHitMax);
185  NumberOfRecHitsPerSeed->setAxisTitle("Number of RecHits per Seed", 1);
186  NumberOfRecHitsPerSeed->setAxisTitle("Number of Seeds",2);
187  }
188 
189  if (doAllSeedPlots || doProfPHI){
190  histname = "NumberOfRecHitsPerSeedVsPhiProfile_"+seedProducer.label() + "_";
191  NumberOfRecHitsPerSeedVsPhiProfile = ibooker.bookProfile(histname+CatagoryName, histname+CatagoryName, PhiBin, PhiMin, PhiMax, SeedHitBin, SeedHitMin, SeedHitMax,"s");
193  NumberOfRecHitsPerSeedVsPhiProfile->setAxisTitle("Number of RecHits of each Seed",2);
194  }
195 
196  if (doAllSeedPlots || doProfETA){
197  histname = "NumberOfRecHitsPerSeedVsEtaProfile_"+seedProducer.label() + "_";
198  NumberOfRecHitsPerSeedVsEtaProfile = ibooker.bookProfile(histname+CatagoryName, histname+CatagoryName, EtaBin, EtaMin, EtaMax, SeedHitBin, SeedHitMin, SeedHitMax,"s");
200  NumberOfRecHitsPerSeedVsEtaProfile->setAxisTitle("Number of RecHits of each Seed",2);
201  }
202 
203  if (doRegionPlots) {
204  if (doAllSeedPlots || doETA) {
205  histname = "TrackingRegionEta_"+seedProducer.label() + "_";
206  TrackingRegionEta = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, EtaBin, EtaMin, EtaMax);
207  TrackingRegionEta->setAxisTitle("TrackingRegion-covered #eta", 1);
208  TrackingRegionEta->setAxisTitle("Number of TrackingRegions", 2);
209  }
210 
211  if (doAllSeedPlots || doPHI) {
212  histname = "TrackingRegionPhi_"+seedProducer.label() + "_";
213  TrackingRegionPhi = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, PhiBin, PhiMin, PhiMax);
214  TrackingRegionPhi->setAxisTitle("TrackingRegion-covered #phi", 1);
215  TrackingRegionPhi->setAxisTitle("Number of TrackingRegions", 2);
216  }
217 
218  if (doAllSeedPlots || doPHIVsETA) {
219  histname = "TrackingRegionPhiVsEta_"+seedProducer.label() + "_";
220  TrackingRegionPhiVsEta = ibooker.book2D(histname+CatagoryName, histname+CatagoryName, EtaBin, EtaMin, EtaMax, PhiBin, PhiMin, PhiMax);
221  TrackingRegionPhiVsEta->setAxisTitle("TrackingRegion-covered #eta", 1);
222  TrackingRegionPhiVsEta->setAxisTitle("TrackingRegion-covered #phi", 2);
223  }
224 
226  if (doAllSeedPlots || doPT) {
227  auto ptBin = iConfig.getParameter<int>( "RegionCandidatePtBin");
228  auto ptMin = iConfig.getParameter<double>("RegionCandidatePtMin");
229  auto ptMax = iConfig.getParameter<double>("RegionCandidatePtMax");
230 
231  histname = "TrackingRegionCandidatePt_"+seedProducer.label() + "_";
232  TrackingRegionCandidatePt = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, ptBin, ptMin, ptMax);
233  TrackingRegionCandidatePt->setAxisTitle("TrackingRegion Candidate p_{T} (GeV/c)", 1);
234  TrackingRegionCandidatePt->setAxisTitle("Number of TrackingRegion Candidates", 2);
235  }
236 
237  if (doAllSeedPlots || doETA) {
238  histname = "TrackingRegionCandidateEta_"+seedProducer.label() + "_";
239  TrackingRegionCandidateEta = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, EtaBin, EtaMin, EtaMax);
240  TrackingRegionCandidateEta->setAxisTitle("TrackingRegion Candidate #eta", 1);
241  TrackingRegionCandidateEta->setAxisTitle("Number of TrackingRegion Candidates", 2);
242  }
243 
244  if (doAllSeedPlots || doPHI) {
245  histname = "TrackingRegionCandidatePhi_"+seedProducer.label() + "_";
246  TrackingRegionCandidatePhi = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, PhiBin, PhiMin, PhiMax);
247  TrackingRegionCandidatePhi->setAxisTitle("TrackingRegion Candidate #phi", 1);
248  TrackingRegionCandidatePhi->setAxisTitle("Number of TrackingRegion Candidates", 2);
249  }
250 
251  if (doAllSeedPlots || doPHIVsETA) {
252  histname = "TrackingRegionCandidatePhiVsEta_"+seedProducer.label() + "_";
253  TrackingRegionCandidatePhiVsEta = ibooker.book2D(histname+CatagoryName, histname+CatagoryName, EtaBin, EtaMin, EtaMax, PhiBin, PhiMin, PhiMax);
254  TrackingRegionCandidatePhiVsEta->setAxisTitle("TrackingRegion Candidate #eta", 1);
255  TrackingRegionCandidatePhiVsEta->setAxisTitle("TrackingRegion Candidate #phi", 2);
256  }
257  }
258  }
259 
260  if (doAllSeedPlots || doStopSource) {
261  const auto stopReasonSize = static_cast<unsigned int>(SeedStopReason::SIZE);
262 
263  const auto candsBin = iConfig.getParameter<int>( "SeedCandBin");
264  const auto candsMin = iConfig.getParameter<double>("SeedCandMin");
265  const auto candsMax = iConfig.getParameter<double>("SeedCandMax");
266 
267  histname = "SeedStoppingSource_"+seedProducer.label() + "_";
268  seedStoppingSource = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, stopReasonSize, 0., stopReasonSize);
269  seedStoppingSource->setAxisTitle("Stopping reason",1);
270  seedStoppingSource->setAxisTitle("Number of seeds",2);
271 
272  histname = "SeedStoppingSourceVsPhi_"+seedProducer.label() + "_";
273  seedStoppingSourceVsPhi = ibooker.bookProfile(histname+CatagoryName, histname+CatagoryName, PhiBin, PhiMin, PhiMax, 2, 0., 2.);
274  seedStoppingSourceVsPhi->setAxisTitle("seed #phi",1);
275  seedStoppingSourceVsPhi->setAxisTitle("fraction stopped",2);
276 
277  histname = "SeedStoppingSourceVsEta_"+seedProducer.label() + "_";
278  seedStoppingSourceVsEta = ibooker.bookProfile(histname+CatagoryName, histname+CatagoryName, EtaBin, EtaMin, EtaMax, 2, 0., 2.);
279  seedStoppingSourceVsEta->setAxisTitle("seed #eta",1);
280  seedStoppingSourceVsEta->setAxisTitle("fraction stopped",2);
281 
282  histname = "NumberOfTrajCandsPerSeed_"+seedProducer.label() + "_";
283  numberOfTrajCandsPerSeed = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, candsBin, candsMin, candsMax);
284  numberOfTrajCandsPerSeed->setAxisTitle("Number of Trajectory Candidate for each Seed", 1);
285  numberOfTrajCandsPerSeed->setAxisTitle("Number of Seeds", 2);
286 
287  histname = "NumberOfTrajCandsPerSeedVsPhi_"+seedProducer.label() + "_";
288  numberOfTrajCandsPerSeedVsPhi = ibooker.bookProfile(histname+CatagoryName, histname+CatagoryName, PhiBin, PhiMin, PhiMax, candsBin, candsMin, candsMax);
290  numberOfTrajCandsPerSeedVsPhi->setAxisTitle("Number of Trajectory Candidates for each Seed", 2);
291 
292  histname = "NumberOfTrajCandsPerSeedVsEta_"+seedProducer.label() + "_";
293  numberOfTrajCandsPerSeedVsEta = ibooker.bookProfile(histname+CatagoryName, histname+CatagoryName, EtaBin, EtaMin, EtaMax, candsBin, candsMin, candsMax);
295  numberOfTrajCandsPerSeedVsEta->setAxisTitle("Number of Trajectory Candidates for each Seed", 2);
296 
297  histname = "SeedStoppingSourceVsNumberOfTrajCandsPerSeed_"+seedProducer.label() + "_";
298  seedStoppingSourceVsNumberOfTrajCandsPerSeed = ibooker.bookProfile(histname+CatagoryName, histname+CatagoryName, candsBin, candsMin, candsMax, 2, 0., 2.);
299  seedStoppingSourceVsNumberOfTrajCandsPerSeed->setAxisTitle("Number of Trajectory Candidates for each Seed", 1);
301 
302  for(unsigned int i=0; i<stopReasonSize; ++i) {
304  }
305  }
306 
307  if (doAllTCPlots || doStopSource) {
308  // DataFormats/TrackReco/interface/TrajectoryStopReasons.h
309  size_t StopReasonNameSize = sizeof(StopReasonName::StopReasonName)/sizeof(std::string);
310 
311  histname = "StoppingSource_"+seedProducer.label() + "_";
312  stoppingSource = ibooker.book1D(histname+CatagoryName,
313  histname+CatagoryName,
314  StopReasonNameSize,
315  0., double(StopReasonNameSize));
316  stoppingSource->setAxisTitle("stopping reason",1);
317  stoppingSource->setAxisTitle("Number of Tracks",2);
318 
319  histname = "StoppingSourceVSeta_"+seedProducer.label() + "_";
320  stoppingSourceVSeta = ibooker.bookProfile(histname+CatagoryName,
321  histname+CatagoryName,
322  EtaBin,
323  EtaMin,
324  EtaMax,
325  2,
326  0., 2.);
327  stoppingSourceVSeta->setAxisTitle("track #eta",1);
328  stoppingSourceVSeta->setAxisTitle("fraction stopped",2);
329 
330  histname = "StoppingSourceVSphi_"+seedProducer.label() + "_";
331  stoppingSourceVSphi = ibooker.bookProfile(histname+CatagoryName,
332  histname+CatagoryName,
333  PhiBin,
334  PhiMin,
335  PhiMax,
336  2,
337  0., 2.);
338  stoppingSourceVSphi->setAxisTitle("track #phi",1);
339  stoppingSourceVSphi->setAxisTitle("fraction stopped",2);
340 
341  for (size_t ibin=0; ibin<StopReasonNameSize; ibin++) {
343  }
344  }
345 
346 
347 
348  // book the TrackCandidate histograms
349  // ---------------------------------------------------------------------------------//
350 
351  if (doTCPlots){
352 
353  ibooker.setCurrentFolder(MEFolderName+"/TrackBuilding");
354 
355  histname = "TrackCandPt_"+tcProducer.label() + "_";
356  TrackCandPt = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, TrackPtBin, TrackPtMin, TrackPtMax);
357  TrackCandPt->setAxisTitle("Track Candidate p_{T} (GeV/c)", 1);
358  TrackCandPt->setAxisTitle("Number of Track Candidates", 2);
359 
360  histname = "TrackCandEta_"+tcProducer.label() + "_";
361  TrackCandEta = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, EtaBin, EtaMin, EtaMax);
362  TrackCandEta->setAxisTitle("Track Candidate #eta", 1);
363  TrackCandEta->setAxisTitle("Number of Track Candidates", 2);
364 
365  histname = "TrackCandPhi_"+tcProducer.label() + "_";
366  TrackCandPhi = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, PhiBin, PhiMin, PhiMax);
367  TrackCandPhi->setAxisTitle("Track Candidate #phi", 1);
368  TrackCandPhi->setAxisTitle("Number of Track Candidates", 2);
369 
370  if (doTheta) {
371  histname = "TrackCandTheta_"+tcProducer.label() + "_";
372  TrackCandTheta = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, ThetaBin, ThetaMin, ThetaMax);
373  TrackCandTheta->setAxisTitle("Track Candidate #theta", 1);
374  TrackCandTheta->setAxisTitle("Number of Track Candidates", 2);
375  }
376 
377  if (doAllTCPlots) {
378  histname = "TrackCandQ_"+tcProducer.label() + "_";
379  TrackCandQ = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, TrackQBin, TrackQMin, TrackQMax);
380  TrackCandQ->setAxisTitle("Track Candidate Charge", 1);
381  TrackCandQ->setAxisTitle("Number of Track Candidates",2);
382 
383  histname = "TrackCandDxy_"+tcProducer.label() + "_";
384  TrackCandDxy = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, TCDxyBin, TCDxyMin, TCDxyMax);
385  TrackCandDxy->setAxisTitle("Track Candidate d_{xy} (cm)", 1);
386  TrackCandDxy->setAxisTitle("Number of Track Candidates",2);
387 
388  histname = "TrackCandDz_"+tcProducer.label() + "_";
389  TrackCandDz = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, TCDzBin, TCDzMin, TCDzMax);
390  TrackCandDz->setAxisTitle("Track Candidate d_{z} (cm)", 1);
391  TrackCandDz->setAxisTitle("Number of Track Candidates",2);
392 
393  histname = "NumberOfRecHitsPerTrackCand_"+tcProducer.label() + "_";
394  NumberOfRecHitsPerTrackCand = ibooker.book1D(histname+CatagoryName, histname+CatagoryName, TCHitBin, TCHitMin, TCHitMax);
395  NumberOfRecHitsPerTrackCand->setAxisTitle("Number of RecHits per Track Candidate", 1);
396  NumberOfRecHitsPerTrackCand->setAxisTitle("Number of Track Candidates",2);
397 
398  histname = "NumberOfRecHitsPerTrackCandVsPhiProfile_"+tcProducer.label() + "_";
399  NumberOfRecHitsPerTrackCandVsPhiProfile = ibooker.bookProfile(histname+CatagoryName, histname+CatagoryName, PhiBin, PhiMin, PhiMax, TCHitBin, TCHitMin, TCHitMax,"s");
400  NumberOfRecHitsPerTrackCandVsPhiProfile->setAxisTitle("Track Candidate #phi",1);
401  NumberOfRecHitsPerTrackCandVsPhiProfile->setAxisTitle("Number of RecHits of each Track Candidate",2);
402 
403  histname = "NumberOfRecHitsPerTrackCandVsEtaProfile_"+tcProducer.label() + "_";
404  NumberOfRecHitsPerTrackCandVsEtaProfile = ibooker.bookProfile(histname+CatagoryName, histname+CatagoryName, EtaBin, EtaMin, EtaMax, TCHitBin, TCHitMin, TCHitMax,"s");
405  NumberOfRecHitsPerTrackCandVsEtaProfile->setAxisTitle("Track Candidate #eta",1);
406  NumberOfRecHitsPerTrackCandVsEtaProfile->setAxisTitle("Number of RecHits of each Track Candidate",2);
407  }
408 
409  histname = "TrackCandPhiVsEta_"+tcProducer.label() + "_";
410  TrackCandPhiVsEta = ibooker.book2D(histname+CatagoryName, histname+CatagoryName, EtaBin, EtaMin, EtaMax, PhiBin, PhiMin, PhiMax);
411  TrackCandPhiVsEta->setAxisTitle("Track Candidate #eta", 1);
412  TrackCandPhiVsEta->setAxisTitle("Track Candidate #phi", 2);
413 
414  if(doAllTCPlots || doMVAPlots) {
415  for(size_t i=1, end=mvaProducers.size(); i<=end; ++i) {
416  auto num = std::to_string(i);
417  std::string pfix;
418 
419  if(i == 1) {
420  trackMVAsHP.push_back(nullptr);
421  trackMVAsHPVsPtProfile.push_back(nullptr);
422  trackMVAsHPVsEtaProfile.push_back(nullptr);
423  }
424  else {
425  pfix = " (not loose-selected)";
426  std::string pfix2 = " (not HP-selected)";
427  histname = "TrackMVA"+num+"HP_"+tcProducer.label() + "_";
428  trackMVAsHP.push_back(ibooker.book1D(histname+CatagoryName, histname+CatagoryName+pfix2, MVABin, MVAMin, MVAMax));
429  trackMVAsHP.back()->setAxisTitle("Track selection MVA"+num, 1);
430  trackMVAsHP.back()->setAxisTitle("Number of tracks", 2);
431 
432  histname = "TrackMVA"+num+"HPVsPtProfile_"+tcProducer.label() + "_";
433  trackMVAsHPVsPtProfile.push_back(ibooker.bookProfile(histname+CatagoryName, histname+CatagoryName+pfix2, TrackPtBin, TrackPtMin, TrackPtMax, MVABin, MVAMin, MVAMax));
434  trackMVAsHPVsPtProfile.back()->setAxisTitle("Track p_{T} (GeV/c)", 1);
435  trackMVAsHPVsPtProfile.back()->setAxisTitle("Track selection MVA"+num, 2);
436 
437  histname = "TrackMVA"+num+"HPVsEtaProfile_"+tcProducer.label() + "_";
438  trackMVAsHPVsEtaProfile.push_back(ibooker.bookProfile(histname+CatagoryName, histname+CatagoryName+pfix2, EtaBin, EtaMin, EtaMax, MVABin, MVAMin, MVAMax));
439  trackMVAsHPVsEtaProfile.back()->setAxisTitle("Track #eta", 1);
440  trackMVAsHPVsEtaProfile.back()->setAxisTitle("Track selection MVA"+num, 2);
441  }
442 
443  histname = "TrackMVA"+num+"_"+tcProducer.label() + "_";
444  trackMVAs.push_back(ibooker.book1D(histname+CatagoryName, histname+CatagoryName+pfix, MVABin, MVAMin, MVAMax));
445  trackMVAs.back()->setAxisTitle("Track selection MVA"+num, 1);
446  trackMVAs.back()->setAxisTitle("Number of tracks", 2);
447 
448  histname = "TrackMVA"+num+"VsPtProfile_"+tcProducer.label() + "_";
449  trackMVAsVsPtProfile.push_back(ibooker.bookProfile(histname+CatagoryName, histname+CatagoryName+pfix, TrackPtBin, TrackPtMin, TrackPtMax, MVABin, MVAMin, MVAMax));
450  trackMVAsVsPtProfile.back()->setAxisTitle("Track p_{T} (GeV/c)", 1);
451  trackMVAsVsPtProfile.back()->setAxisTitle("Track selection MVA"+num, 2);
452 
453  histname = "TrackMVA"+num+"VsEtaProfile_"+tcProducer.label() + "_";
454  trackMVAsVsEtaProfile.push_back(ibooker.bookProfile(histname+CatagoryName, histname+CatagoryName+pfix, EtaBin, EtaMin, EtaMax, MVABin, MVAMin, MVAMax));
455  trackMVAsVsEtaProfile.back()->setAxisTitle("Track #eta", 1);
456  trackMVAsVsEtaProfile.back()->setAxisTitle("Track selection MVA"+num, 2);
457  }
458  }
459  }
460 
461 }
462 
463 // -- Analyse
464 // ---------------------------------------------------------------------------------//
466 (
467  const edm::Event& iEvent,
468  const edm::EventSetup& iSetup,
469  const TrajectorySeed& candidate,
470  const SeedStopInfo& stopInfo,
471  const reco::BeamSpot& bs,
472  const edm::ESHandle<MagneticField>& theMF,
474 )
475 {
476  TSCBLBuilderNoMaterial tscblBuilder;
477 
478  //get parameters and errors from the candidate state
479  auto const & theG = ((TkTransientTrackingRecHitBuilder const *)(theTTRHBuilder.product()))->geometry();
480  auto const & candSS = candidate.startingState();
481  TrajectoryStateOnSurface state = trajectoryStateTransform::transientState( candSS, &(theG->idToDet(candSS.detId())->surface()), theMF.product());
482  TrajectoryStateClosestToBeamLine tsAtClosestApproachSeed = tscblBuilder(*state.freeState(),bs);//as in TrackProducerAlgorithm
483  if(!(tsAtClosestApproachSeed.isValid())) {
484  edm::LogVerbatim("TrackBuilding") << "TrajectoryStateClosestToBeamLine not valid";
485  return;
486  }
487  GlobalPoint v0 = tsAtClosestApproachSeed.trackStateAtPCA().position();
488  GlobalVector p = tsAtClosestApproachSeed.trackStateAtPCA().momentum();
489  GlobalPoint v(v0.x()-bs.x0(),v0.y()-bs.y0(),v0.z()-bs.z0());
490 
491  double pt = sqrt(state.globalMomentum().perp2());
492  double eta = state.globalPosition().eta();
493  double phi = state.globalPosition().phi();
494  double theta = state.globalPosition().theta();
495  //double pm = sqrt(state.globalMomentum().mag2());
496  //double pz = state.globalMomentum().z();
497  //double qoverp = tsAtClosestApproachSeed.trackStateAtPCA().charge()/p.mag();
498  //double theta = p.theta();
499  //double lambda = M_PI/2-p.theta();
500  double numberOfHits = candidate.recHits().second-candidate.recHits().first;
501  double dxy = (-v.x()*sin(p.phi())+v.y()*cos(p.phi()));
502  double dz = v.z() - (v.x()*p.x()+v.y()*p.y())/p.perp() * p.z()/p.perp();
503 
504  // fill the ME's
505  if (doAllSeedPlots || doQ)SeedQ->Fill( state.charge() );
506  if (doAllSeedPlots || doPT) SeedPt->Fill( pt );
507  if (doAllSeedPlots || doETA) SeedEta->Fill( eta );
508  if (doAllSeedPlots || doPHI) SeedPhi->Fill( phi );
509  if (doAllSeedPlots || doPHIVsETA) SeedPhiVsEta->Fill( eta, phi);
510  if (doAllSeedPlots || doTheta) SeedTheta->Fill( theta );
511  if (doAllSeedPlots || doDxy) SeedDxy->Fill( dxy );
512  if (doAllSeedPlots || doDz) SeedDz->Fill( dz );
513  if (doAllSeedPlots || doNRecHits) NumberOfRecHitsPerSeed->Fill( numberOfHits );
514  if (doAllSeedPlots || doProfETA) NumberOfRecHitsPerSeedVsEtaProfile->Fill( eta, numberOfHits );
515  if (doAllSeedPlots || doProfPHI) NumberOfRecHitsPerSeedVsPhiProfile->Fill( phi, numberOfHits );
516  if (doAllSeedPlots || doStopSource) {
517  const double stopped = stopInfo.stopReason() == SeedStopReason::NOT_STOPPED ? 0. : 1.;
518  seedStoppingSource->Fill(stopInfo.stopReasonUC());
519  seedStoppingSourceVsPhi->Fill(phi, stopped);
520  seedStoppingSourceVsEta->Fill(eta, stopped);
521 
522  const auto ncands = stopInfo.candidatesPerSeed();
524  numberOfTrajCandsPerSeedVsPhi->Fill(phi, ncands);
525  numberOfTrajCandsPerSeedVsEta->Fill(eta, ncands);
526 
528  }
529 }
530 
531 // -- Analyse
532 // ---------------------------------------------------------------------------------//
534 (
535  const edm::Event& iEvent,
536  const edm::EventSetup& iSetup,
537  const TrackCandidate& candidate,
538  const reco::BeamSpot& bs,
539  const edm::ESHandle<MagneticField>& theMF,
541 )
542 {
543  TSCBLBuilderNoMaterial tscblBuilder;
544 
545  //get parameters and errors from the candidate state
546  auto const & theG = ((TkTransientTrackingRecHitBuilder const *)(theTTRHBuilder.product()))->geometry();
547  auto const & candSS = candidate.trajectoryStateOnDet();
548  TrajectoryStateOnSurface state = trajectoryStateTransform::transientState( candSS, &(theG->idToDet(candSS.detId())->surface()), theMF.product());
549  TrajectoryStateClosestToBeamLine tsAtClosestApproachTrackCand = tscblBuilder(*state.freeState(),bs);//as in TrackProducerAlgorithm
550  if(!(tsAtClosestApproachTrackCand.isValid())) {
551  edm::LogVerbatim("TrackBuilding") << "TrajectoryStateClosestToBeamLine not valid";
552  return;
553  }
554  GlobalPoint v0 = tsAtClosestApproachTrackCand.trackStateAtPCA().position();
555  GlobalVector p = tsAtClosestApproachTrackCand.trackStateAtPCA().momentum();
556  GlobalPoint v(v0.x()-bs.x0(),v0.y()-bs.y0(),v0.z()-bs.z0());
557 
558  double pt = sqrt(state.globalMomentum().perp2());
559  double eta = state.globalPosition().eta();
560  double phi = state.globalPosition().phi();
561  double theta = state.globalPosition().theta();
562  //double pm = sqrt(state.globalMomentum().mag2());
563  //double pz = state.globalMomentum().z();
564  //double qoverp = tsAtClosestApproachTrackCand.trackStateAtPCA().charge()/p.mag();
565  //double theta = p.theta();
566  //double lambda = M_PI/2-p.theta();
567  double numberOfHits = candidate.recHits().second-candidate.recHits().first;
568  double dxy = (-v.x()*sin(p.phi())+v.y()*cos(p.phi()));
569 
570  double dz = v.z() - (v.x()*p.x()+v.y()*p.y())/p.perp() * p.z()/p.perp();
571 
572  if (doAllTCPlots || doStopSource) {
573  // stopping source
574  int max = stoppingSource->getNbinsX();
575  double stop = candidate.stopReason() > max ? double(max-1) : static_cast<double>(candidate.stopReason());
576  double stopped = int(StopReason::NOT_STOPPED)==candidate.stopReason() ? 0. : 1.;
577  stoppingSource ->Fill(stop);
578  stoppingSourceVSeta ->Fill(eta,stopped);
579  stoppingSourceVSphi ->Fill(phi,stopped);
580  }
581 
582  if (doTCPlots){
583  // fill the ME's
584  if (doAllTCPlots) TrackCandQ->Fill( state.charge() );
585  TrackCandPt->Fill( pt );
586  TrackCandEta->Fill( eta );
587  TrackCandPhi->Fill( phi );
588  TrackCandPhiVsEta->Fill( eta, phi );
589  if (doTheta) TrackCandTheta->Fill( theta );
590  if (doAllTCPlots) TrackCandDxy->Fill( dxy );
591  if (doAllTCPlots) TrackCandDz->Fill( dz );
592  if (doAllTCPlots) NumberOfRecHitsPerTrackCand->Fill( numberOfHits );
593  if (doAllTCPlots) NumberOfRecHitsPerTrackCandVsEtaProfile->Fill( eta, numberOfHits );
594  if (doAllTCPlots) NumberOfRecHitsPerTrackCandVsPhiProfile->Fill( phi, numberOfHits );
595  }
596 }
597 
598 namespace {
599  bool trackSelected(unsigned char mask, unsigned char qual) {
600  return mask & 1<<qual;
601  }
602 }
604  const std::vector<const MVACollection *>& mvaCollections,
605  const std::vector<const QualityMaskCollection *>& qualityMaskCollections) {
606  if(!(doAllTCPlots || doMVAPlots))
607  return;
608  if(trackCollection.empty())
609  return;
610 
611  const auto ntracks = trackCollection.size();
612  const auto nmva = mvaCollections.size();
613  for(const auto mva: mvaCollections) {
614  if(mva->size() != ntracks) {
615  edm::LogError("LogicError") << "TrackBuildingAnalyzer: Incompatible size of MVACollection, " << mva->size() << " differs from the size of the track collection " << ntracks;
616  return;
617  }
618  }
619  for(const auto qual: qualityMaskCollections) {
620  if(qual->size() != ntracks) {
621  edm::LogError("LogicError") << "TrackBuildingAnalyzer: Incompatible size of QualityMaskCollection, " << qual->size() << " differs from the size of the track collection " << ntracks;
622  return;
623  }
624  }
625 
626 
627  for(size_t iTrack=0; iTrack<ntracks; ++iTrack) {
628  // Fill MVA1 histos with all tracks, MVA2 histos only with tracks
629  // not selected by MVA1 etc
630  bool selectedLoose = false;
631  bool selectedHP = false;
632 
633  const auto pt = trackCollection[iTrack].pt();
634  const auto eta = trackCollection[iTrack].eta();
635 
636  for(size_t iMVA=0; iMVA<nmva; ++iMVA) {
637  const auto mva = (*(mvaCollections[iMVA]))[iTrack];
638  if(!selectedLoose) {
639  trackMVAs[iMVA]->Fill(mva);
640  trackMVAsVsPtProfile[iMVA]->Fill(pt, mva);
641  trackMVAsVsEtaProfile[iMVA]->Fill(eta, mva);
642  }
643  if(iMVA >= 1 && !selectedHP) {
644  trackMVAsHP[iMVA]->Fill(mva);
645  trackMVAsHPVsPtProfile[iMVA]->Fill(pt, mva);
646  trackMVAsHPVsEtaProfile[iMVA]->Fill(eta, mva);
647  }
648 
649  const auto qual = (*(qualityMaskCollections)[iMVA])[iTrack];
650  selectedLoose |= trackSelected(qual, reco::TrackBase::loose);
651  selectedHP |= trackSelected(qual, reco::TrackBase::highPurity);
652 
653  if(selectedLoose && selectedHP)
654  break;
655  }
656  }
657 }
658 
661  return;
662 
663  for(const auto& candidate: regionCandidates) {
664  const auto eta = candidate.eta();
665  const auto phi = candidate.phi();
666  if (doAllSeedPlots || doPT) TrackingRegionCandidatePt->Fill( candidate.pt() );
670  }
671 }
672 
674  analyzeRegions(regions);
675 }
677  analyzeRegions(regions);
678 }
679 
680 namespace {
681  const TrackingRegion *regionPtr(const TrackingRegion& region) {
682  return &region;
683  }
684  const TrackingRegion *regionPtr(const TrackingRegionsSeedingLayerSets::RegionLayers& regionLayers) {
685  return &(regionLayers.region());
686  }
687 }
688 
689 template <typename T>
691  if(!doRegionPlots && etaBinWidth <= 0. && phiBinWidth <= 0.)
692  return;
693 
694  for(const auto& tmp: regions) {
695  if(const auto *etaPhiRegion = dynamic_cast<const RectangularEtaPhiTrackingRegion *>(regionPtr(tmp))) {
696  const auto& etaRange = etaPhiRegion->etaRange();
697  const auto& phiMargin = etaPhiRegion->phiMargin();
698 
699  const auto etaMin = etaRange.min();
700  const auto etaMax = etaRange.max();
701 
702  const auto phiMin = etaPhiRegion->phiDirection() - phiMargin.left();
703  const auto phiMax = etaPhiRegion->phiDirection() + phiMargin.right();
704 
705  if(doAllSeedPlots || doETA) {
706  for(auto eta = etaMin; eta < etaMax; eta += etaBinWidth) {
708  }
709  }
710  if(doAllSeedPlots || doPHI) {
711  for(auto phi = phiMin; phi < phiMax; phi += phiBinWidth) {
713  }
714  }
715  if (doAllSeedPlots || doPHIVsETA) {
716  for(auto phi = phiMin; phi < phiMax; phi += phiBinWidth) {
717  const auto reducedPhi = reco::reduceRange(phi);
718  for(auto eta = etaMin; eta < etaMax; eta += etaBinWidth) {
719  TrackingRegionPhiVsEta->Fill(eta, reducedPhi);
720  }
721  }
722  }
723  }
724  }
725 }
726 
MonitorElement * NumberOfRecHitsPerTrackCandVsPhiProfile
T getParameter(std::string const &) const
MonitorElement * seedStoppingSourceVsPhi
double z0() const
z coordinate
Definition: BeamSpot.h:68
MonitorElement * numberOfTrajCandsPerSeed
MonitorElement * TrackingRegionCandidatePhiVsEta
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrajectorySeed &seed, const SeedStopInfo &stopInfo, const reco::BeamSpot &bs, const edm::ESHandle< MagneticField > &theMF, const edm::ESHandle< TransientTrackingRecHitBuilder > &theTTRHBuilder)
T perp() const
Definition: PV3DBase.h:72
SeedStopReason stopReason() const
Definition: SeedStopInfo.h:15
constexpr T reduceRange(T x)
Definition: deltaPhi.h:15
range recHits() const
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:160
std::vector< MonitorElement * > trackMVAsHPVsEtaProfile
std::vector< MonitorElement * > trackMVAsVsPtProfile
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Geom::Theta< T > theta() const
T y() const
Definition: PV3DBase.h:63
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)
MonitorElement * stoppingSourceVSphi
GlobalPoint globalPosition() const
size_type size() const
std::vector< MonitorElement * > trackMVAsVsEtaProfile
T perp2() const
Definition: PV3DBase.h:71
const double EtaMax[kNumberCalorimeter]
static const std::string StopReasonName[]
void initHisto(DQMStore::IBooker &ibooker, const edm::ParameterSet &)
MonitorElement * TrackCandPhiVsEta
MonitorElement * TrackingRegionCandidatePt
unsigned short candidatesPerSeed() const
Definition: SeedStopInfo.h:12
static const std::string SeedStopReasonName[]
void Fill(long long x)
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
MonitorElement * NumberOfRecHitsPerTrackCandVsEtaProfile
MonitorElement * stoppingSource
PTrajectoryStateOnDet const & trajectoryStateOnDet() const
MonitorElement * NumberOfRecHitsPerSeed
int iEvent
Definition: GenABIO.cc:230
MonitorElement * NumberOfRecHitsPerSeedVsPhiProfile
void analyzeRegions(const T &regions)
T sqrt(T t)
Definition: SSEVec.h:18
FreeTrajectoryState const * freeState(bool withErrors=true) const
T z() const
Definition: PV3DBase.h:64
std::vector< MonitorElement * > trackMVAsHP
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
bool empty() const
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
const double EtaMin[kNumberCalorimeter]
#define end
Definition: vmac.h:39
MonitorElement * numberOfTrajCandsPerSeedVsPhi
MonitorElement * TrackingRegionPhi
unsigned char stopReasonUC() const
Definition: SeedStopInfo.h:16
TrackBuildingAnalyzer(const edm::ParameterSet &)
MonitorElement * numberOfTrajCandsPerSeedVsEta
std::vector< MonitorElement * > trackMVAs
MonitorElement * TrackingRegionPhiVsEta
PTrajectoryStateOnDet const & startingState() const
MonitorElement * stoppingSourceVSeta
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:136
MonitorElement * TrackingRegionEta
range recHits() const
MonitorElement * TrackCandTheta
T eta() const
Definition: PV3DBase.h:76
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
std::vector< MonitorElement * > trackMVAsHPVsPtProfile
MonitorElement * TrackingRegionCandidateEta
GlobalVector globalMomentum() const
MonitorElement * seedStoppingSourceVsEta
MonitorElement * TrackingRegionCandidatePhi
double y0() const
y coordinate
Definition: BeamSpot.h:66
MonitorElement * seedStoppingSourceVsNumberOfTrajCandsPerSeed
MonitorElement * NumberOfRecHitsPerSeedVsEtaProfile
int getNbinsX() const
get # of bins in X-axis
long double T
T x() const
Definition: PV3DBase.h:62
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
T const * product() const
Definition: ESHandle.h:86
MonitorElement * NumberOfRecHitsPerTrackCand
uint8_t stopReason() const
MonitorElement * seedStoppingSource
double x0() const
x coordinate
Definition: BeamSpot.h:64