CMS 3D CMS Logo

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