CMS 3D CMS Logo

TTreeValidation.cc
Go to the documentation of this file.
1 #include "TTreeValidation.h"
2 #include "Event.h"
6 
7 #ifndef NO_ROOT
8 
9 namespace mkfit {
10 
12  std::lock_guard<std::mutex> locker(glock_);
13  gROOT->ProcessLine("#include <vector>");
14 
15  ntotallayers_fit_ = trk_info->n_layers();
16 
17  // KPM via DSR's ROOT wizardry: ROOT's context management implicitly assumes that a file is opened and
18  // closed on the same thread. To avoid the problem, we declare a local
19  // TContext object; when it goes out of scope, its destructor unregisters
20  // the context, guaranteeing the context is unregistered in the same thread
21  // it was registered in. (do this for tfiles and trees
22  TDirectory::TContext contextEraser;
23  f_ = std::unique_ptr<TFile>(TFile::Open(fileName.c_str(), "recreate"));
24 
28  }
29  if (Config::cmssw_val) {
32  }
33  if (Config::fit_val) {
34  for (int i = 0; i < nfvs_; ++i)
35  fvs_[i].resize(ntotallayers_fit_);
37  }
39  }
40 
42  // efficiency validation
43  efftree_ = std::make_unique<TTree>("efftree", "efftree");
44  efftree_->SetDirectory(0);
45 
46  efftree_->Branch("evtID", &evtID_eff_);
47  efftree_->Branch("mcID", &mcID_eff_);
48 
49  efftree_->Branch("nHits_mc", &nHits_mc_eff_);
50  efftree_->Branch("nLayers_mc", &nLayers_mc_eff_);
51  efftree_->Branch("lastlyr_mc", &lastlyr_mc_eff_);
52 
53  efftree_->Branch("seedID_seed", &seedID_seed_eff_);
54  efftree_->Branch("seedID_build", &seedID_build_eff_);
55  efftree_->Branch("seedID_fit", &seedID_fit_eff_);
56 
57  efftree_->Branch("x_mc_gen", &x_mc_gen_eff_);
58  efftree_->Branch("y_mc_gen", &y_mc_gen_eff_);
59  efftree_->Branch("z_mc_gen", &z_mc_gen_eff_);
60 
61  efftree_->Branch("pt_mc_gen", &pt_mc_gen_eff_);
62  efftree_->Branch("phi_mc_gen", &phi_mc_gen_eff_);
63  efftree_->Branch("eta_mc_gen", &eta_mc_gen_eff_);
64 
65  efftree_->Branch("mcmask_seed", &mcmask_seed_eff_);
66  efftree_->Branch("mcmask_build", &mcmask_build_eff_);
67  efftree_->Branch("mcmask_fit", &mcmask_fit_eff_);
68 
69  efftree_->Branch("mcTSmask_seed", &mcTSmask_seed_eff_);
70  efftree_->Branch("mcTSmask_build", &mcTSmask_build_eff_);
71  efftree_->Branch("mcTSmask_fit", &mcTSmask_fit_eff_);
72 
73  efftree_->Branch("xhit_seed", &xhit_seed_eff_);
74  efftree_->Branch("xhit_build", &xhit_build_eff_);
75  efftree_->Branch("xhit_fit", &xhit_fit_eff_);
76 
77  efftree_->Branch("yhit_seed", &yhit_seed_eff_);
78  efftree_->Branch("yhit_build", &yhit_build_eff_);
79  efftree_->Branch("yhit_fit", &yhit_fit_eff_);
80 
81  efftree_->Branch("zhit_seed", &zhit_seed_eff_);
82  efftree_->Branch("zhit_build", &zhit_build_eff_);
83  efftree_->Branch("zhit_fit", &zhit_fit_eff_);
84 
85  efftree_->Branch("pt_mc_seed", &pt_mc_seed_eff_);
86  efftree_->Branch("pt_seed", &pt_seed_eff_);
87  efftree_->Branch("ept_seed", &ept_seed_eff_);
88  efftree_->Branch("pt_mc_build", &pt_mc_build_eff_);
89  efftree_->Branch("pt_build", &pt_build_eff_);
90  efftree_->Branch("ept_build", &ept_build_eff_);
91  efftree_->Branch("pt_mc_fit", &pt_mc_fit_eff_);
92  efftree_->Branch("pt_fit", &pt_fit_eff_);
93  efftree_->Branch("ept_fit", &ept_fit_eff_);
94 
95  efftree_->Branch("phi_mc_seed", &phi_mc_seed_eff_);
96  efftree_->Branch("phi_seed", &phi_seed_eff_);
97  efftree_->Branch("ephi_seed", &ephi_seed_eff_);
98  efftree_->Branch("phi_mc_build", &phi_mc_build_eff_);
99  efftree_->Branch("phi_build", &phi_build_eff_);
100  efftree_->Branch("ephi_build", &ephi_build_eff_);
101  efftree_->Branch("phi_mc_fit", &phi_mc_fit_eff_);
102  efftree_->Branch("phi_fit", &phi_fit_eff_);
103  efftree_->Branch("ephi_fit", &ephi_fit_eff_);
104 
105  efftree_->Branch("eta_mc_seed", &eta_mc_seed_eff_);
106  efftree_->Branch("eta_seed", &eta_seed_eff_);
107  efftree_->Branch("eeta_seed", &eeta_seed_eff_);
108  efftree_->Branch("eta_mc_build", &eta_mc_build_eff_);
109  efftree_->Branch("eta_build", &eta_build_eff_);
110  efftree_->Branch("eeta_build", &eeta_build_eff_);
111  efftree_->Branch("eta_mc_fit", &eta_mc_fit_eff_);
112  efftree_->Branch("eta_fit", &eta_fit_eff_);
113  efftree_->Branch("eeta_fit", &eeta_fit_eff_);
114 
115  efftree_->Branch("nHits_seed", &nHits_seed_eff_);
116  efftree_->Branch("nHits_build", &nHits_build_eff_);
117  efftree_->Branch("nHits_fit", &nHits_fit_eff_);
118 
119  efftree_->Branch("nLayers_seed", &nLayers_seed_eff_);
120  efftree_->Branch("nLayers_build", &nLayers_build_eff_);
121  efftree_->Branch("nLayers_fit", &nLayers_fit_eff_);
122 
123  efftree_->Branch("nHitsMatched_seed", &nHitsMatched_seed_eff_);
124  efftree_->Branch("nHitsMatched_build", &nHitsMatched_build_eff_);
125  efftree_->Branch("nHitsMatched_fit", &nHitsMatched_fit_eff_);
126 
127  efftree_->Branch("fracHitsMatched_seed", &fracHitsMatched_seed_eff_);
128  efftree_->Branch("fracHitsMatched_build", &fracHitsMatched_build_eff_);
129  efftree_->Branch("fracHitsMatched_fit", &fracHitsMatched_fit_eff_);
130 
131  efftree_->Branch("lastlyr_seed", &lastlyr_seed_eff_);
132  efftree_->Branch("lastlyr_build", &lastlyr_build_eff_);
133  efftree_->Branch("lastlyr_fit", &lastlyr_fit_eff_);
134 
135  efftree_->Branch("dphi_seed", &dphi_seed_eff_);
136  efftree_->Branch("dphi_build", &dphi_build_eff_);
137  efftree_->Branch("dphi_fit", &dphi_fit_eff_);
138 
139  efftree_->Branch("hitchi2_seed", &hitchi2_seed_eff_);
140  efftree_->Branch("hitchi2_build", &hitchi2_build_eff_);
141  efftree_->Branch("hitchi2_fit", &hitchi2_fit_eff_);
142 
143  efftree_->Branch("score_seed", &score_seed_eff_);
144  efftree_->Branch("score_build", &score_build_eff_);
145  efftree_->Branch("score_fit", &score_fit_eff_);
146 
147  efftree_->Branch("helixchi2_seed", &helixchi2_seed_eff_);
148  efftree_->Branch("helixchi2_build", &helixchi2_build_eff_);
149  efftree_->Branch("helixchi2_fit", &helixchi2_fit_eff_);
150 
151  efftree_->Branch("duplmask_seed", &duplmask_seed_eff_);
152  efftree_->Branch("duplmask_build", &duplmask_build_eff_);
153  efftree_->Branch("duplmask_fit", &duplmask_fit_eff_);
154 
155  efftree_->Branch("nTkMatches_seed", &nTkMatches_seed_eff_);
156  efftree_->Branch("nTkMatches_build", &nTkMatches_build_eff_);
157  efftree_->Branch("nTkMatches_fit", &nTkMatches_fit_eff_);
158 
159  efftree_->Branch("itermask_seed", &itermask_seed_eff_);
160  efftree_->Branch("itermask_build", &itermask_build_eff_);
161  efftree_->Branch("itermask_fit", &itermask_fit_eff_);
162  efftree_->Branch("iterduplmask_seed", &iterduplmask_seed_eff_);
163  efftree_->Branch("iterduplmask_build", &iterduplmask_build_eff_);
164  efftree_->Branch("iterduplmask_fit", &iterduplmask_fit_eff_);
165  efftree_->Branch("algo_seed", &algo_seed_eff_);
166 
167  if (Config::keepHitInfo) {
168  efftree_->Branch("hitlyrs_mc", &hitlyrs_mc_eff_);
169  efftree_->Branch("hitlyrs_seed", &hitlyrs_seed_eff_);
170  efftree_->Branch("hitlyrs_build", &hitlyrs_build_eff_);
171  efftree_->Branch("hitlyrs_fit", &hitlyrs_fit_eff_);
172 
173  efftree_->Branch("hitidxs_mc", &hitidxs_mc_eff_);
174  efftree_->Branch("hitidxs_seed", &hitidxs_seed_eff_);
175  efftree_->Branch("hitidxs_build", &hitidxs_build_eff_);
176  efftree_->Branch("hitidxs_fit", &hitidxs_fit_eff_);
177 
178  efftree_->Branch("hitmcTkIDs_mc", &hitmcTkIDs_mc_eff_);
179  efftree_->Branch("hitmcTkIDs_seed", &hitmcTkIDs_seed_eff_);
180  efftree_->Branch("hitmcTkIDs_build", &hitmcTkIDs_build_eff_);
181  efftree_->Branch("hitmcTkIDs_fit", &hitmcTkIDs_fit_eff_);
182 
183  efftree_->Branch("hitxs_mc", &hitxs_mc_eff_);
184  efftree_->Branch("hitxs_seed", &hitxs_seed_eff_);
185  efftree_->Branch("hitxs_build", &hitxs_build_eff_);
186  efftree_->Branch("hitxs_fit", &hitxs_fit_eff_);
187 
188  efftree_->Branch("hitys_mc", &hitys_mc_eff_);
189  efftree_->Branch("hitys_seed", &hitys_seed_eff_);
190  efftree_->Branch("hitys_build", &hitys_build_eff_);
191  efftree_->Branch("hitys_fit", &hitys_fit_eff_);
192 
193  efftree_->Branch("hitzs_mc", &hitzs_mc_eff_);
194  efftree_->Branch("hitzs_seed", &hitzs_seed_eff_);
195  efftree_->Branch("hitzs_build", &hitzs_build_eff_);
196  efftree_->Branch("hitzs_fit", &hitzs_fit_eff_);
197  }
198  }
199 
201  // fake rate validation
202  frtree_ = std::make_unique<TTree>("frtree", "frtree");
203  frtree_->SetDirectory(0);
204 
205  frtree_->Branch("evtID", &evtID_FR_);
206  frtree_->Branch("seedID", &seedID_FR_);
207 
208  frtree_->Branch("seedmask_seed", &seedmask_seed_FR_);
209  frtree_->Branch("seedmask_build", &seedmask_build_FR_);
210  frtree_->Branch("seedmask_fit", &seedmask_fit_FR_);
211 
212  frtree_->Branch("xhit_seed", &xhit_seed_FR_);
213  frtree_->Branch("xhit_build", &xhit_build_FR_);
214  frtree_->Branch("xhit_fit", &xhit_fit_FR_);
215 
216  frtree_->Branch("yhit_seed", &yhit_seed_FR_);
217  frtree_->Branch("yhit_build", &yhit_build_FR_);
218  frtree_->Branch("yhit_fit", &yhit_fit_FR_);
219 
220  frtree_->Branch("zhit_seed", &zhit_seed_FR_);
221  frtree_->Branch("zhit_build", &zhit_build_FR_);
222  frtree_->Branch("zhit_fit", &zhit_fit_FR_);
223 
224  frtree_->Branch("pt_seed", &pt_seed_FR_);
225  frtree_->Branch("ept_seed", &ept_seed_FR_);
226  frtree_->Branch("pt_build", &pt_build_FR_);
227  frtree_->Branch("ept_build", &ept_build_FR_);
228  frtree_->Branch("pt_fit", &pt_fit_FR_);
229  frtree_->Branch("ept_fit", &ept_fit_FR_);
230 
231  frtree_->Branch("phi_seed", &phi_seed_FR_);
232  frtree_->Branch("ephi_seed", &ephi_seed_FR_);
233  frtree_->Branch("phi_build", &phi_build_FR_);
234  frtree_->Branch("ephi_build", &ephi_build_FR_);
235  frtree_->Branch("phi_fit", &phi_fit_FR_);
236  frtree_->Branch("ephi_fit", &ephi_fit_FR_);
237 
238  frtree_->Branch("eta_seed", &eta_seed_FR_);
239  frtree_->Branch("eeta_seed", &eeta_seed_FR_);
240  frtree_->Branch("eta_build", &eta_build_FR_);
241  frtree_->Branch("eeta_build", &eeta_build_FR_);
242  frtree_->Branch("eta_fit", &eta_fit_FR_);
243  frtree_->Branch("eeta_fit", &eeta_fit_FR_);
244 
245  frtree_->Branch("nHits_seed", &nHits_seed_FR_);
246  frtree_->Branch("nHits_build", &nHits_build_FR_);
247  frtree_->Branch("nHits_fit", &nHits_fit_FR_);
248 
249  frtree_->Branch("nLayers_seed", &nLayers_seed_FR_);
250  frtree_->Branch("nLayers_build", &nLayers_build_FR_);
251  frtree_->Branch("nLayers_fit", &nLayers_fit_FR_);
252 
253  frtree_->Branch("nHitsMatched_seed", &nHitsMatched_seed_FR_);
254  frtree_->Branch("nHitsMatched_build", &nHitsMatched_build_FR_);
255  frtree_->Branch("nHitsMatched_fit", &nHitsMatched_fit_FR_);
256 
257  frtree_->Branch("fracHitsMatched_seed", &fracHitsMatched_seed_FR_);
258  frtree_->Branch("fracHitsMatched_build", &fracHitsMatched_build_FR_);
259  frtree_->Branch("fracHitsMatched_fit", &fracHitsMatched_fit_FR_);
260 
261  frtree_->Branch("lastlyr_seed", &lastlyr_seed_FR_);
262  frtree_->Branch("lastlyr_build", &lastlyr_build_FR_);
263  frtree_->Branch("lastlyr_fit", &lastlyr_fit_FR_);
264 
265  frtree_->Branch("dphi_seed", &dphi_seed_FR_);
266  frtree_->Branch("dphi_build", &dphi_build_FR_);
267  frtree_->Branch("dphi_fit", &dphi_fit_FR_);
268 
269  frtree_->Branch("hitchi2_seed", &hitchi2_seed_FR_);
270  frtree_->Branch("hitchi2_build", &hitchi2_build_FR_);
271  frtree_->Branch("hitchi2_fit", &hitchi2_fit_FR_);
272 
273  frtree_->Branch("score_seed", &score_seed_FR_);
274  frtree_->Branch("score_build", &score_build_FR_);
275  frtree_->Branch("score_fit", &score_fit_FR_);
276 
277  // sim info of seed,build,fit tracks
278  frtree_->Branch("mcID_seed", &mcID_seed_FR_);
279  frtree_->Branch("mcID_build", &mcID_build_FR_);
280  frtree_->Branch("mcID_fit", &mcID_fit_FR_);
281 
282  frtree_->Branch("mcmask_seed", &mcmask_seed_FR_);
283  frtree_->Branch("mcmask_build", &mcmask_build_FR_);
284  frtree_->Branch("mcmask_fit", &mcmask_fit_FR_);
285 
286  frtree_->Branch("mcTSmask_seed", &mcTSmask_seed_FR_);
287  frtree_->Branch("mcTSmask_build", &mcTSmask_build_FR_);
288  frtree_->Branch("mcTSmask_fit", &mcTSmask_fit_FR_);
289 
290  frtree_->Branch("pt_mc_seed", &pt_mc_seed_FR_);
291  frtree_->Branch("pt_mc_build", &pt_mc_build_FR_);
292  frtree_->Branch("pt_mc_fit", &pt_mc_fit_FR_);
293 
294  frtree_->Branch("phi_mc_seed", &phi_mc_seed_FR_);
295  frtree_->Branch("phi_mc_build", &phi_mc_build_FR_);
296  frtree_->Branch("phi_mc_fit", &phi_mc_fit_FR_);
297 
298  frtree_->Branch("eta_mc_seed", &eta_mc_seed_FR_);
299  frtree_->Branch("eta_mc_build", &eta_mc_build_FR_);
300  frtree_->Branch("eta_mc_fit", &eta_mc_fit_FR_);
301 
302  frtree_->Branch("nHits_mc_seed", &nHits_mc_seed_FR_);
303  frtree_->Branch("nHits_mc_build", &nHits_mc_build_FR_);
304  frtree_->Branch("nHits_mc_fit", &nHits_mc_fit_FR_);
305 
306  frtree_->Branch("nLayers_mc_seed", &nLayers_mc_seed_FR_);
307  frtree_->Branch("nLayers_mc_build", &nLayers_mc_build_FR_);
308  frtree_->Branch("nLayers_mc_fit", &nLayers_mc_fit_FR_);
309 
310  frtree_->Branch("lastlyr_mc_seed", &lastlyr_mc_seed_FR_);
311  frtree_->Branch("lastlyr_mc_build", &lastlyr_mc_build_FR_);
312  frtree_->Branch("lastlyr_mc_fit", &lastlyr_mc_fit_FR_);
313 
314  frtree_->Branch("helixchi2_seed", &helixchi2_seed_FR_);
315  frtree_->Branch("helixchi2_build", &helixchi2_build_FR_);
316  frtree_->Branch("helixchi2_fit", &helixchi2_fit_FR_);
317 
318  frtree_->Branch("duplmask_seed", &duplmask_seed_FR_);
319  frtree_->Branch("duplmask_build", &duplmask_build_FR_);
320  frtree_->Branch("duplmask_fit", &duplmask_fit_FR_);
321 
322  frtree_->Branch("iTkMatches_seed", &iTkMatches_seed_FR_);
323  frtree_->Branch("iTkMatches_build", &iTkMatches_build_FR_);
324  frtree_->Branch("iTkMatches_fit", &iTkMatches_fit_FR_);
325 
326  frtree_->Branch("algorithm", &algorithm_FR_);
327 
328  if (Config::keepHitInfo) {
329  frtree_->Branch("hitlyrs_seed", &hitlyrs_seed_FR_);
330  frtree_->Branch("hitlyrs_mc_seed", &hitlyrs_mc_seed_FR_);
331  frtree_->Branch("hitlyrs_build", &hitlyrs_build_FR_);
332  frtree_->Branch("hitlyrs_mc_build", &hitlyrs_mc_build_FR_);
333  frtree_->Branch("hitlyrs_fit", &hitlyrs_fit_FR_);
334  frtree_->Branch("hitlyrs_mc_fit", &hitlyrs_mc_fit_FR_);
335 
336  frtree_->Branch("hitidxs_seed", &hitidxs_seed_FR_);
337  frtree_->Branch("hitidxs_mc_seed", &hitidxs_mc_seed_FR_);
338  frtree_->Branch("hitidxs_build", &hitidxs_build_FR_);
339  frtree_->Branch("hitidxs_mc_build", &hitidxs_mc_build_FR_);
340  frtree_->Branch("hitidxs_fit", &hitidxs_fit_FR_);
341  frtree_->Branch("hitidxs_mc_fit", &hitidxs_mc_fit_FR_);
342 
343  frtree_->Branch("hitmcTkIDs_seed", &hitmcTkIDs_seed_FR_);
344  frtree_->Branch("hitmcTkIDs_mc_seed", &hitmcTkIDs_mc_seed_FR_);
345  frtree_->Branch("hitmcTkIDs_build", &hitmcTkIDs_build_FR_);
346  frtree_->Branch("hitmcTkIDs_mc_build", &hitmcTkIDs_mc_build_FR_);
347  frtree_->Branch("hitmcTkIDs_fit", &hitmcTkIDs_fit_FR_);
348  frtree_->Branch("hitmcTkIDs_mc_fit", &hitmcTkIDs_mc_fit_FR_);
349 
350  frtree_->Branch("hitxs_seed", &hitxs_seed_FR_);
351  frtree_->Branch("hitxs_mc_seed", &hitxs_mc_seed_FR_);
352  frtree_->Branch("hitxs_build", &hitxs_build_FR_);
353  frtree_->Branch("hitxs_mc_build", &hitxs_mc_build_FR_);
354  frtree_->Branch("hitxs_fit", &hitxs_fit_FR_);
355  frtree_->Branch("hitxs_mc_fit", &hitxs_mc_fit_FR_);
356 
357  frtree_->Branch("hitys_seed", &hitys_seed_FR_);
358  frtree_->Branch("hitys_mc_seed", &hitys_mc_seed_FR_);
359  frtree_->Branch("hitys_build", &hitys_build_FR_);
360  frtree_->Branch("hitys_mc_build", &hitys_mc_build_FR_);
361  frtree_->Branch("hitys_fit", &hitys_fit_FR_);
362  frtree_->Branch("hitys_mc_fit", &hitys_mc_fit_FR_);
363 
364  frtree_->Branch("hitzs_seed", &hitzs_seed_FR_);
365  frtree_->Branch("hitzs_mc_seed", &hitzs_mc_seed_FR_);
366  frtree_->Branch("hitzs_build", &hitzs_build_FR_);
367  frtree_->Branch("hitzs_mc_build", &hitzs_mc_build_FR_);
368  frtree_->Branch("hitzs_fit", &hitzs_fit_FR_);
369  frtree_->Branch("hitzs_mc_fit", &hitzs_mc_fit_FR_);
370  }
371  }
372 
374  // include config ++ real seeding parameters ...
375  configtree_ = std::make_unique<TTree>("configtree", "configtree");
376  configtree_->SetDirectory(0);
377 
378  configtree_->Branch("Ntracks", &Ntracks_);
379  configtree_->Branch("Nevents", &Nevents_);
380 
381  configtree_->Branch("nLayers", &nLayers_);
382 
383  configtree_->Branch("nlayers_per_seed", &nlayers_per_seed_);
384  configtree_->Branch("maxCand", &maxCand_);
385  configtree_->Branch("chi2Cut_min", &chi2Cut_min_);
386  configtree_->Branch("nSigma", &nSigma_);
387  configtree_->Branch("minDPhi", &minDPhi_);
388  configtree_->Branch("maxDPhi", &maxDPhi_);
389  configtree_->Branch("minDEta", &minDEta_);
390  configtree_->Branch("maxDEta", &maxDEta_);
391 
392  configtree_->Branch("beamspotX", &beamspotX_);
393  configtree_->Branch("beamspotY", &beamspotY_);
394  configtree_->Branch("beamspotZ", &beamspotZ_);
395 
396  configtree_->Branch("minSimPt", &minSimPt_);
397  configtree_->Branch("maxSimPt", &maxSimPt_);
398 
399  configtree_->Branch("hitposerrXY", &hitposerrXY_);
400  configtree_->Branch("hitposerrZ", &hitposerrZ_);
401  configtree_->Branch("hitposerrR", &hitposerrR_);
402 
403  configtree_->Branch("varXY", &varXY_);
404  configtree_->Branch("varZ", &varZ_);
405 
406  configtree_->Branch("ptinverr049", &ptinverr049_);
407  configtree_->Branch("phierr049", &phierr049_);
408  configtree_->Branch("thetaerr049", &thetaerr049_);
409  configtree_->Branch("ptinverr012", &ptinverr012_);
410  configtree_->Branch("phierr012", &phierr012_);
411  configtree_->Branch("thetaerr012", &thetaerr012_);
412  }
413 
415  // cmssw reco track efficiency validation
416  cmsswefftree_ = std::make_unique<TTree>("cmsswefftree", "cmsswefftree");
417  cmsswefftree_->SetDirectory(0);
418 
419  cmsswefftree_->Branch("evtID", &evtID_ceff_);
420  cmsswefftree_->Branch("cmsswID", &cmsswID_ceff_);
421  cmsswefftree_->Branch("seedID_cmssw", &seedID_cmssw_ceff_);
422 
423  // CMSSW
424  cmsswefftree_->Branch("x_cmssw", &x_cmssw_ceff_);
425  cmsswefftree_->Branch("y_cmssw", &y_cmssw_ceff_);
426  cmsswefftree_->Branch("z_cmssw", &z_cmssw_ceff_);
427 
428  cmsswefftree_->Branch("pt_cmssw", &pt_cmssw_ceff_);
429  cmsswefftree_->Branch("phi_cmssw", &phi_cmssw_ceff_);
430  cmsswefftree_->Branch("eta_cmssw", &eta_cmssw_ceff_);
431 
432  cmsswefftree_->Branch("nHits_cmssw", &nHits_cmssw_ceff_);
433  cmsswefftree_->Branch("nLayers_cmssw", &nLayers_cmssw_ceff_);
434  cmsswefftree_->Branch("lastlyr_cmssw", &lastlyr_cmssw_ceff_);
435 
436  // Build
437  cmsswefftree_->Branch("cmsswmask_build", &cmsswmask_build_ceff_);
438  cmsswefftree_->Branch("seedID_build", &seedID_build_ceff_);
439  cmsswefftree_->Branch("mcTrackID_build", &mcTrackID_build_ceff_);
440 
441  cmsswefftree_->Branch("pt_build", &pt_build_ceff_);
442  cmsswefftree_->Branch("ept_build", &ept_build_ceff_);
443  cmsswefftree_->Branch("phi_build", &phi_build_ceff_);
444  cmsswefftree_->Branch("ephi_build", &ephi_build_ceff_);
445  cmsswefftree_->Branch("eta_build", &eta_build_ceff_);
446  cmsswefftree_->Branch("eeta_build", &eeta_build_ceff_);
447 
448  cmsswefftree_->Branch("x_mc_build", &x_mc_build_ceff_);
449  cmsswefftree_->Branch("y_mc_build", &y_mc_build_ceff_);
450  cmsswefftree_->Branch("z_mc_build", &z_mc_build_ceff_);
451  cmsswefftree_->Branch("pt_mc_build", &pt_mc_build_ceff_);
452  cmsswefftree_->Branch("phi_mc_build", &phi_mc_build_ceff_);
453  cmsswefftree_->Branch("eta_mc_build", &eta_mc_build_ceff_);
454 
455  cmsswefftree_->Branch("nHits_build", &nHits_build_ceff_);
456  cmsswefftree_->Branch("nLayers_build", &nLayers_build_ceff_);
457  cmsswefftree_->Branch("nHitsMatched_build", &nHitsMatched_build_ceff_);
458  cmsswefftree_->Branch("fracHitsMatched_build", &fracHitsMatched_build_ceff_);
459  cmsswefftree_->Branch("lastlyr_build", &lastlyr_build_ceff_);
460 
461  cmsswefftree_->Branch("xhit_build", &xhit_build_ceff_);
462  cmsswefftree_->Branch("yhit_build", &yhit_build_ceff_);
463  cmsswefftree_->Branch("zhit_build", &zhit_build_ceff_);
464 
465  cmsswefftree_->Branch("hitchi2_build", &hitchi2_build_ceff_);
466  cmsswefftree_->Branch("helixchi2_build", &helixchi2_build_ceff_);
467  cmsswefftree_->Branch("score_build", &score_build_ceff_);
468  cmsswefftree_->Branch("dphi_build", &dphi_build_ceff_);
469 
470  cmsswefftree_->Branch("duplmask_build", &duplmask_build_ceff_);
471  cmsswefftree_->Branch("nTkMatches_build", &nTkMatches_build_ceff_);
472 
473  cmsswefftree_->Branch("itermask_build", &itermask_build_ceff_);
474  cmsswefftree_->Branch("iterduplmask_build", &iterduplmask_build_ceff_);
475 
476  // Fit
477  cmsswefftree_->Branch("cmsswmask_fit", &cmsswmask_fit_ceff_);
478  cmsswefftree_->Branch("seedID_fit", &seedID_fit_ceff_);
479  cmsswefftree_->Branch("mcTrackID_fit", &mcTrackID_fit_ceff_);
480 
481  cmsswefftree_->Branch("pt_fit", &pt_fit_ceff_);
482  cmsswefftree_->Branch("ept_fit", &ept_fit_ceff_);
483  cmsswefftree_->Branch("phi_fit", &phi_fit_ceff_);
484  cmsswefftree_->Branch("ephi_fit", &ephi_fit_ceff_);
485  cmsswefftree_->Branch("eta_fit", &eta_fit_ceff_);
486  cmsswefftree_->Branch("eeta_fit", &eeta_fit_ceff_);
487 
488  cmsswefftree_->Branch("x_mc_fit", &x_mc_fit_ceff_);
489  cmsswefftree_->Branch("y_mc_fit", &y_mc_fit_ceff_);
490  cmsswefftree_->Branch("z_mc_fit", &z_mc_fit_ceff_);
491  cmsswefftree_->Branch("pt_mc_fit", &pt_mc_fit_ceff_);
492  cmsswefftree_->Branch("phi_mc_fit", &phi_mc_fit_ceff_);
493  cmsswefftree_->Branch("eta_mc_fit", &eta_mc_fit_ceff_);
494 
495  cmsswefftree_->Branch("nHits_fit", &nHits_fit_ceff_);
496  cmsswefftree_->Branch("nLayers_fit", &nLayers_fit_ceff_);
497  cmsswefftree_->Branch("nHitsMatched_fit", &nHitsMatched_fit_ceff_);
498  cmsswefftree_->Branch("fracHitsMatched_fit", &fracHitsMatched_fit_ceff_);
499  cmsswefftree_->Branch("lastlyr_fit", &lastlyr_fit_ceff_);
500 
501  cmsswefftree_->Branch("xhit_fit", &xhit_fit_ceff_);
502  cmsswefftree_->Branch("yhit_fit", &yhit_fit_ceff_);
503  cmsswefftree_->Branch("zhit_fit", &zhit_fit_ceff_);
504 
505  cmsswefftree_->Branch("hitchi2_fit", &hitchi2_fit_ceff_);
506  cmsswefftree_->Branch("helixchi2_fit", &helixchi2_fit_ceff_);
507  cmsswefftree_->Branch("score_fit", &score_fit_ceff_);
508  cmsswefftree_->Branch("dphi_fit", &dphi_fit_ceff_);
509 
510  cmsswefftree_->Branch("duplmask_fit", &duplmask_fit_ceff_);
511  cmsswefftree_->Branch("nTkMatches_fit", &nTkMatches_fit_ceff_);
512 
513  cmsswefftree_->Branch("itermask_fit", &itermask_fit_ceff_);
514  cmsswefftree_->Branch("iterduplmask_fit", &iterduplmask_fit_ceff_);
515 
516  cmsswefftree_->Branch("algo_seed", &algo_seed_ceff_);
517 
518  if (Config::keepHitInfo) {
519  cmsswefftree_->Branch("hitlyrs_cmssw", &hitlyrs_cmssw_ceff_);
520  cmsswefftree_->Branch("hitlyrs_build", &hitlyrs_build_ceff_);
521  cmsswefftree_->Branch("hitlyrs_mc_build", &hitlyrs_mc_build_ceff_);
522  cmsswefftree_->Branch("hitlyrs_fit", &hitlyrs_fit_ceff_);
523  cmsswefftree_->Branch("hitlyrs_mc_fit", &hitlyrs_mc_fit_ceff_);
524 
525  cmsswefftree_->Branch("hitidxs_cmssw", &hitidxs_cmssw_ceff_);
526  cmsswefftree_->Branch("hitidxs_build", &hitidxs_build_ceff_);
527  cmsswefftree_->Branch("hitidxs_mc_build", &hitidxs_mc_build_ceff_);
528  cmsswefftree_->Branch("hitidxs_fit", &hitidxs_fit_ceff_);
529  cmsswefftree_->Branch("hitidxs_mc_fit", &hitidxs_mc_fit_ceff_);
530  }
531  }
532 
534  // cmssw reco track efficiency validation
535  cmsswfrtree_ = std::make_unique<TTree>("cmsswfrtree", "cmsswfrtree");
536  cmsswfrtree_->SetDirectory(0);
537 
538  cmsswfrtree_->Branch("evtID", &evtID_cFR_);
539  cmsswfrtree_->Branch("seedID", &seedID_cFR_);
540  cmsswfrtree_->Branch("mcTrackID", &mcTrackID_cFR_);
541 
542  // mc
543  cmsswfrtree_->Branch("x_mc", &x_mc_cFR_);
544  cmsswfrtree_->Branch("y_mc", &y_mc_cFR_);
545  cmsswfrtree_->Branch("z_mc", &z_mc_cFR_);
546  cmsswfrtree_->Branch("pt_mc", &pt_mc_cFR_);
547  cmsswfrtree_->Branch("phi_mc", &phi_mc_cFR_);
548  cmsswfrtree_->Branch("eta_mc", &eta_mc_cFR_);
549 
550  // build
551  cmsswfrtree_->Branch("cmsswID_build", &cmsswID_build_cFR_);
552  cmsswfrtree_->Branch("cmsswmask_build", &cmsswmask_build_cFR_);
553 
554  cmsswfrtree_->Branch("pt_build", &pt_build_cFR_);
555  cmsswfrtree_->Branch("ept_build", &ept_build_cFR_);
556  cmsswfrtree_->Branch("phi_build", &phi_build_cFR_);
557  cmsswfrtree_->Branch("ephi_build", &ephi_build_cFR_);
558  cmsswfrtree_->Branch("eta_build", &eta_build_cFR_);
559  cmsswfrtree_->Branch("eeta_build", &eeta_build_cFR_);
560 
561  cmsswfrtree_->Branch("nHits_build", &nHits_build_cFR_);
562  cmsswfrtree_->Branch("nLayers_build", &nLayers_build_cFR_);
563  cmsswfrtree_->Branch("nHitsMatched_build", &nHitsMatched_build_cFR_);
564  cmsswfrtree_->Branch("fracHitsMatched_build", &fracHitsMatched_build_cFR_);
565  cmsswfrtree_->Branch("lastlyr_build", &lastlyr_build_cFR_);
566 
567  cmsswfrtree_->Branch("xhit_build", &xhit_build_cFR_);
568  cmsswfrtree_->Branch("yhit_build", &yhit_build_cFR_);
569  cmsswfrtree_->Branch("zhit_build", &zhit_build_cFR_);
570 
571  cmsswfrtree_->Branch("hitchi2_build", &hitchi2_build_cFR_);
572  cmsswfrtree_->Branch("helixchi2_build", &helixchi2_build_cFR_);
573  cmsswfrtree_->Branch("score_build", &score_build_cFR_);
574  cmsswfrtree_->Branch("dphi_build", &dphi_build_cFR_);
575 
576  cmsswfrtree_->Branch("duplmask_build", &duplmask_build_cFR_);
577  cmsswfrtree_->Branch("iTkMatches_build", &iTkMatches_build_cFR_);
578 
579  cmsswfrtree_->Branch("seedID_cmssw_build", &seedID_cmssw_build_cFR_);
580 
581  cmsswfrtree_->Branch("x_cmssw_build", &x_cmssw_build_cFR_);
582  cmsswfrtree_->Branch("y_cmssw_build", &y_cmssw_build_cFR_);
583  cmsswfrtree_->Branch("z_cmssw_build", &z_cmssw_build_cFR_);
584 
585  cmsswfrtree_->Branch("pt_cmssw_build", &pt_cmssw_build_cFR_);
586  cmsswfrtree_->Branch("phi_cmssw_build", &phi_cmssw_build_cFR_);
587  cmsswfrtree_->Branch("eta_cmssw_build", &eta_cmssw_build_cFR_);
588 
589  cmsswfrtree_->Branch("nHits_cmssw_build", &nHits_cmssw_build_cFR_);
590  cmsswfrtree_->Branch("nLayers_cmssw_build", &nLayers_cmssw_build_cFR_);
591  cmsswfrtree_->Branch("lastlyr_cmssw_build", &lastlyr_cmssw_build_cFR_);
592 
593  // fit
594  cmsswfrtree_->Branch("cmsswID_fit", &cmsswID_fit_cFR_);
595  cmsswfrtree_->Branch("cmsswmask_fit", &cmsswmask_fit_cFR_);
596 
597  cmsswfrtree_->Branch("pt_fit", &pt_fit_cFR_);
598  cmsswfrtree_->Branch("ept_fit", &ept_fit_cFR_);
599  cmsswfrtree_->Branch("phi_fit", &phi_fit_cFR_);
600  cmsswfrtree_->Branch("ephi_fit", &ephi_fit_cFR_);
601  cmsswfrtree_->Branch("eta_fit", &eta_fit_cFR_);
602  cmsswfrtree_->Branch("eeta_fit", &eeta_fit_cFR_);
603 
604  cmsswfrtree_->Branch("nHits_fit", &nHits_fit_cFR_);
605  cmsswfrtree_->Branch("nLayers_fit", &nLayers_fit_cFR_);
606  cmsswfrtree_->Branch("nHitsMatched_fit", &nHitsMatched_fit_cFR_);
607  cmsswfrtree_->Branch("fracHitsMatched_fit", &fracHitsMatched_fit_cFR_);
608  cmsswfrtree_->Branch("lastlyr_fit", &lastlyr_fit_cFR_);
609 
610  cmsswfrtree_->Branch("xhit_fit", &xhit_fit_cFR_);
611  cmsswfrtree_->Branch("yhit_fit", &yhit_fit_cFR_);
612  cmsswfrtree_->Branch("zhit_fit", &zhit_fit_cFR_);
613 
614  cmsswfrtree_->Branch("hitchi2_fit", &hitchi2_fit_cFR_);
615  cmsswfrtree_->Branch("helixchi2_fit", &helixchi2_fit_cFR_);
616  cmsswfrtree_->Branch("score_fit", &score_fit_cFR_);
617  cmsswfrtree_->Branch("dphi_fit", &dphi_fit_cFR_);
618 
619  cmsswfrtree_->Branch("duplmask_fit", &duplmask_fit_cFR_);
620  cmsswfrtree_->Branch("iTkMatches_fit", &iTkMatches_fit_cFR_);
621 
622  cmsswfrtree_->Branch("seedID_cmssw_fit", &seedID_cmssw_fit_cFR_);
623 
624  cmsswfrtree_->Branch("x_cmssw_fit", &x_cmssw_fit_cFR_);
625  cmsswfrtree_->Branch("y_cmssw_fit", &y_cmssw_fit_cFR_);
626  cmsswfrtree_->Branch("z_cmssw_fit", &z_cmssw_fit_cFR_);
627 
628  cmsswfrtree_->Branch("pt_cmssw_fit", &pt_cmssw_fit_cFR_);
629  cmsswfrtree_->Branch("phi_cmssw_fit", &phi_cmssw_fit_cFR_);
630  cmsswfrtree_->Branch("eta_cmssw_fit", &eta_cmssw_fit_cFR_);
631 
632  cmsswfrtree_->Branch("nHits_cmssw_fit", &nHits_cmssw_fit_cFR_);
633  cmsswfrtree_->Branch("nLayers_cmssw_fit", &nLayers_cmssw_fit_cFR_);
634  cmsswfrtree_->Branch("lastlyr_cmssw_fit", &lastlyr_cmssw_fit_cFR_);
635 
636  cmsswfrtree_->Branch("algorithm", &algorithm_cFR_);
637 
638  if (Config::keepHitInfo) {
639  cmsswfrtree_->Branch("hitlyrs_mc", &hitlyrs_mc_cFR_);
640  cmsswfrtree_->Branch("hitlyrs_build", &hitlyrs_build_cFR_);
641  cmsswfrtree_->Branch("hitlyrs_cmssw_build", &hitlyrs_cmssw_build_cFR_);
642  cmsswfrtree_->Branch("hitlyrs_fit", &hitlyrs_fit_cFR_);
643  cmsswfrtree_->Branch("hitlyrs_cmssw_fit", &hitlyrs_cmssw_fit_cFR_);
644 
645  cmsswfrtree_->Branch("hitidxs_mc", &hitidxs_mc_cFR_);
646  cmsswfrtree_->Branch("hitidxs_build", &hitidxs_build_cFR_);
647  cmsswfrtree_->Branch("hitidxs_cmssw_build", &hitidxs_cmssw_build_cFR_);
648  cmsswfrtree_->Branch("hitidxs_fit", &hitidxs_fit_cFR_);
649  cmsswfrtree_->Branch("hitidxs_cmssw_fit", &hitidxs_cmssw_fit_cFR_);
650  }
651  }
652 
654  fittree_ = std::make_unique<TTree>("fittree", "fittree");
655  fittree_->SetDirectory(0);
656 
657  fittree_->Branch("ntotallayers", &ntotallayers_fit_, "ntotallayers_fit_/I");
658  fittree_->Branch("tkid", &tkid_fit_, "tkid_fit_/I");
659  fittree_->Branch("evtid", &evtid_fit_, "evtid_fit_/I");
660 
661  fittree_->Branch("z_prop", &z_prop_fit_, "z_prop_fit_[ntotallayers_fit_]/F");
662  fittree_->Branch("ez_prop", &ez_prop_fit_, "ez_prop_fit_[ntotallayers_fit_]/F");
663  fittree_->Branch("z_hit", &z_hit_fit_, "z_hit_fit_[ntotallayers_fit_]/F");
664  fittree_->Branch("ez_hit", &ez_hit_fit_, "ez_hit_fit_[ntotallayers_fit_]/F");
665  fittree_->Branch("z_sim", &z_sim_fit_, "z_sim_fit_[ntotallayers_fit_]/F");
666  fittree_->Branch("ez_sim", &ez_sim_fit_, "ez_sim_fit_[ntotallayers_fit_]/F");
667 
668  fittree_->Branch("pphi_prop", &pphi_prop_fit_, "pphi_prop_fit_[ntotallayers_fit_]/F");
669  fittree_->Branch("epphi_prop", &epphi_prop_fit_, "epphi_prop_fit_[ntotallayers_fit_]/F");
670  fittree_->Branch("pphi_hit", &pphi_hit_fit_, "pphi_hit_fit_[ntotallayers_fit_]/F");
671  fittree_->Branch("epphi_hit", &epphi_hit_fit_, "epphi_hit_fit_[ntotallayers_fit_]/F");
672  fittree_->Branch("pphi_sim", &pphi_sim_fit_, "pphi_sim_fit_[ntotallayers_fit_]/F");
673  fittree_->Branch("epphi_sim", &epphi_sim_fit_, "epphi_sim_fit_[ntotallayers_fit_]/F");
674 
675  fittree_->Branch("pt_up", &pt_up_fit_, "pt_up_fit_[ntotallayers_fit_]/F");
676  fittree_->Branch("ept_up", &ept_up_fit_, "ept_up_fit_[ntotallayers_fit_]/F");
677  fittree_->Branch("pt_sim", &pt_sim_fit_, "pt_sim_fit_[ntotallayers_fit_]/F");
678  fittree_->Branch("ept_sim", &ept_sim_fit_, "ept_sim_fit_[ntotallayers_fit_]/F");
679 
680  fittree_->Branch("mphi_up", &mphi_up_fit_, "mphi_up_fit_[ntotallayers_fit_]/F");
681  fittree_->Branch("emphi_up", &emphi_up_fit_, "emphi_up_fit_[ntotallayers_fit_]/F");
682  fittree_->Branch("mphi_sim", &mphi_sim_fit_, "mphi_sim_fit_[ntotallayers_fit_]/F");
683  fittree_->Branch("emphi_sim", &emphi_sim_fit_, "emphi_sim_fit_[ntotallayers_fit_]/F");
684 
685  fittree_->Branch("meta_up", &meta_up_fit_, "meta_up_fit_[ntotallayers_fit_]/F");
686  fittree_->Branch("emeta_up", &emeta_up_fit_, "emeta_up_fit_[ntotallayers_fit_]/F");
687  fittree_->Branch("meta_sim", &meta_sim_fit_, "meta_sim_fit_[ntotallayers_fit_]/F");
688  fittree_->Branch("emeta_sim", &emeta_sim_fit_, "emeta_sim_fit_[ntotallayers_fit_]/F");
689  }
690 
691  void TTreeValidation::alignTracks(TrackVec& evt_tracks, TrackExtraVec& evt_extras, bool alignExtra) {
692  std::lock_guard<std::mutex> locker(glock_);
693 
694  // redo trackExtras first if necessary
695  if (alignExtra) {
696  TrackExtraVec trackExtra_tmp(evt_tracks.size());
697 
698  // align temporary tkExVec with new track collection ordering
699  for (int itrack = 0; itrack < (int)evt_tracks.size(); itrack++) {
700  trackExtra_tmp[itrack] = evt_extras[evt_tracks[itrack].label()]; // label is old seedID!
701  }
702 
703  // now copy the temporary back in the old one
704  evt_extras = trackExtra_tmp;
705  }
706 
707  // redo track labels to match index in vector
708  for (int itrack = 0; itrack < (int)evt_tracks.size(); itrack++) {
709  evt_tracks[itrack].setLabel(itrack);
710  }
711  }
712 
713  void TTreeValidation::collectFitInfo(const FitVal& tmpfitval, int tkid, int layer) {
714  std::lock_guard<std::mutex> locker(glock_);
715 
716  fitValTkMapMap_[tkid][layer] = tmpfitval;
717  }
718 
720  std::lock_guard<std::mutex> locker(glock_);
721  // reset fit validation map
722  fitValTkMapMap_.clear();
723 
724  // reset map of sim tracks to reco tracks
725  simToSeedMap_.clear();
726  simToBuildMap_.clear();
727  simToFitMap_.clear();
728 
729  // reset map of seed tracks to reco tracks
730  seedToBuildMap_.clear();
731  seedToFitMap_.clear();
732 
733  // reset map of cmssw tracks to reco tracks
734  cmsswToBuildMap_.clear();
735  cmsswToFitMap_.clear();
736 
737  // reset special map of seed labels to cmssw tracks
738  seedToCmsswMap_.clear();
739  cmsswToSeedMap_.clear();
740 
741  // reset special map of matching build tracks exactly to cmssw tracks through seedIDs
742  buildToCmsswMap_.clear();
743 
744  // reset special maps used for pairing build to fit tracks CMSSW only
745  buildToFitMap_.clear();
746  fitToBuildMap_.clear();
747 
748  // reset special maps used for associating seed tracks to reco tracks for sim_val_for_cmssw
749  candToSeedMapDumbCMSSW_.clear();
750  fitToSeedMapDumbCMSSW_.clear();
751  }
752 
754  std::lock_guard<std::mutex> locker(glock_);
755 
756  const auto& layerhits = ev.layerHits_;
757 
759  const auto& simhits = ev.simHitsInfo_;
760  const auto& simtracks = ev.simTracks_;
761  const auto& seedtracks = ev.seedTracks_;
762  auto& seedextras = ev.seedTracksExtra_;
763  const auto& buildtracks = ev.candidateTracks_;
764  auto& buildextras = ev.candidateTracksExtra_;
765  const auto& fittracks = ev.fitTracks_;
766  auto& fitextras = ev.fitTracksExtra_;
767 
768  // set mcTrackID for seed tracks
769  for (int itrack = 0; itrack < (int)seedtracks.size(); itrack++) {
770  const auto& track = seedtracks[itrack];
771  auto& extra = seedextras[itrack];
772 
773  extra.findMatchingSeedHits(track, track, layerhits);
774  extra.setMCTrackIDInfo(
775  track,
776  layerhits,
777  simhits,
778  simtracks,
779  true,
780  (Config::seedInput == simSeeds)); // otherwise seeds are completely unmatched in ToyMC Sim Seeds
781  }
782 
783  // set mcTrackID for built tracks
784  for (int itrack = 0; itrack < (int)buildtracks.size(); itrack++) {
785  const auto& track = buildtracks[itrack];
786  auto& extra = buildextras[itrack];
787 
788  if (Config::sim_val) {
789  extra.findMatchingSeedHits(track, seedtracks[track.label()], layerhits);
790  } else if (Config::sim_val_for_cmssw) {
791  extra.findMatchingSeedHits(track, seedtracks[candToSeedMapDumbCMSSW_[track.label()]], layerhits);
792  }
793 
794  extra.setMCTrackIDInfo(track, layerhits, simhits, simtracks, false, (Config::seedInput == simSeeds));
795  }
796 
797  // set mcTrackID for fit tracks
798  for (int itrack = 0; itrack < (int)fittracks.size(); itrack++) {
799  const auto& track = fittracks[itrack];
800  auto& extra = fitextras[itrack];
801 
802  if (Config::sim_val) {
803  extra.findMatchingSeedHits(track, seedtracks[track.label()], layerhits);
804  } else if (Config::sim_val_for_cmssw) {
805  extra.findMatchingSeedHits(track, seedtracks[fitToSeedMapDumbCMSSW_[track.label()]], layerhits);
806  }
807 
808  extra.setMCTrackIDInfo(track, layerhits, simhits, simtracks, false, (Config::seedInput == simSeeds));
809  }
810  }
811 
812  if (Config::cmssw_val) {
813  // store mcTrackID and seedID correctly
815 
816  const auto& cmsswtracks = ev.cmsswTracks_;
817  const auto& cmsswextras = ev.cmsswTracksExtra_;
818  const auto& seedtracks = ev.seedTracks_;
819  const auto& buildtracks = ev.candidateTracks_;
820  auto& buildextras = ev.candidateTracksExtra_;
821  const auto& fittracks = ev.fitTracks_;
822  auto& fitextras = ev.fitTracksExtra_;
823 
824  // store seed hits, reduced parameters, hit map of cmssw tracks, and global hit map
825  RedTrackVec reducedCMSSW;
826  LayIdxIDVecMapMap cmsswHitIDMap;
827  setupCMSSWMatching(ev, reducedCMSSW, cmsswHitIDMap);
828 
829  // set cmsswTrackID for built tracks
830  for (int itrack = 0; itrack < (int)buildtracks.size(); itrack++) {
831  const auto& track = buildtracks[itrack];
832  auto& extra = buildextras[itrack];
833 
834  // set vector of hitsOnTrack for seed
835  extra.findMatchingSeedHits(track,
836  seedtracks[track.label()],
837  layerhits); // itrack == track.label() == seedtrack index == seedtrack.label()
838 
840  extra.setCMSSWTrackIDInfoByTrkParams(track, layerhits, cmsswtracks, reducedCMSSW, true);
841  } else if (Config::cmsswMatchingFW == hitBased) {
842  extra.setCMSSWTrackIDInfoByHits(track,
843  cmsswHitIDMap,
844  cmsswtracks,
845  cmsswextras,
846  reducedCMSSW,
847  -1); // == -1 for not passing truth info about cmssw tracks
848  } else if (Config::cmsswMatchingFW == labelBased) // can only be used if using pure seeds!
849  {
850  extra.setCMSSWTrackIDInfoByHits(track,
851  cmsswHitIDMap,
852  cmsswtracks,
853  cmsswextras,
854  reducedCMSSW,
855  reducedCMSSW[cmsswtracks[buildToCmsswMap_[track.label()]].label()].label());
856  } else {
857  std::cerr << "Specified CMSSW validation, but using an incorrect matching option! Exiting..." << std::endl;
858  exit(1);
859  }
860  }
861 
862  // set cmsswTrackID for fit tracks
863  for (int itrack = 0; itrack < (int)fittracks.size(); itrack++) {
864  const auto& track = fittracks[itrack];
865  auto& extra = fitextras[itrack];
866 
867  // set vector of hitsOnTrack for seed
868  extra.findMatchingSeedHits(track,
869  seedtracks[track.label()],
870  layerhits); // itrack == track.label() == seedtrack index == seedtrack.label()
871 
873  extra.setCMSSWTrackIDInfoByTrkParams(track, layerhits, cmsswtracks, reducedCMSSW, true);
874  } else if (Config::cmsswMatchingBK == hitBased) {
875  extra.setCMSSWTrackIDInfoByHits(track,
876  cmsswHitIDMap,
877  cmsswtracks,
878  cmsswextras,
879  reducedCMSSW,
880  -1); // == -1 not passing truth info about cmssw
881  } else if (Config::cmsswMatchingBK == labelBased) // can only be used if using pure seeds!
882  {
883  extra.setCMSSWTrackIDInfoByHits(
884  track,
885  cmsswHitIDMap,
886  cmsswtracks,
887  cmsswextras,
888  reducedCMSSW,
889  reducedCMSSW[cmsswtracks[buildToCmsswMap_[fitToBuildMap_[track.label()]]].label()].label());
890  } else {
891  std::cerr << "Specified CMSSW validation, but using an incorrect matching option! Exiting..." << std::endl;
892  exit(1);
893  }
894  }
895  }
896  }
897 
899  std::lock_guard<std::mutex> locker(glock_);
900  // map sim track ids to reco labels sort by each (simTracks set in order by default!)
901  TTreeValidation::mapRefTkToRecoTks(ev.seedTracks_, ev.seedTracksExtra_, simToSeedMap_);
902  TTreeValidation::mapRefTkToRecoTks(ev.candidateTracks_, ev.candidateTracksExtra_, simToBuildMap_);
903  TTreeValidation::mapRefTkToRecoTks(ev.fitTracks_, ev.fitTracksExtra_, simToFitMap_);
904  }
905 
907  TrackExtraVec& evt_extras,
908  TkIDToTkIDVecMap& refTkMap) {
909  for (auto itrack = 0; itrack < (int)evt_tracks.size(); ++itrack) {
910  auto&& track(evt_tracks[itrack]);
911  auto&& extra(evt_extras[itrack]);
913  if (extra.mcTrackID() >= 0) // skip fakes, don't store them at all in sim map
914  {
915  refTkMap[extra.mcTrackID()].push_back(
916  track.label()); // store vector of reco tk labels, mapped to the sim track label (i.e. mcTrackID)
917  }
918  }
919  if (Config::cmssw_val) {
920  if (extra.cmsswTrackID() >= 0) // skip fakes, don't store them at all in cmssw map
921  {
922  refTkMap[extra.cmsswTrackID()].push_back(
923  track.label()); // store vector of reco tk labels, mapped to the cmssw track label (i.e. cmsswTrackID)
924  }
925  }
926  }
927 
928  for (auto&& refTkMatches : refTkMap) {
929  if (refTkMatches.second.size() < 2) // no duplicates
930  {
931  auto& extra(evt_extras[refTkMatches.second[0]]);
932  extra.setDuplicateInfo(0, bool(false));
933  } else // sort duplicates (ghosts) to keep best one --> best score
934  {
935  // really should sort on indices with a reduced data structure... this is a hack way to do this for now...
936  // e.g. std::pair<int, int> (label, score)
937  TrackVec tmpMatches;
938  for (auto&& label :
939  refTkMatches.second) // loop over vector of reco track labels, push back the track with each label
940  {
941  tmpMatches.emplace_back(evt_tracks[label]);
942  }
943  //std::sort(tmpMatches.begin(), tmpMatches.end(), sortByHitsChi2); // sort the tracks
944  std::sort(tmpMatches.begin(), tmpMatches.end(), sortByScoreCand); // sort the tracks
945  for (auto itrack = 0; itrack < (int)tmpMatches.size();
946  itrack++) // loop over sorted tracks, now set the vector of sorted labels match
947  {
948  refTkMatches.second[itrack] = tmpMatches[itrack].label();
949  }
950 
951  int duplicateID = 0;
952  for (auto&& label : refTkMatches.second) // loop over vector of reco tracsk
953  {
954  auto& extra(evt_extras[label]);
955  extra.setDuplicateInfo(duplicateID, bool(true));
956  duplicateID++; // used in fake rate trees!
957  }
958  }
959  }
960  }
961 
963  std::lock_guard<std::mutex> locker(glock_);
964  // map seed to reco tracks --> seed track collection assumed to map to itself, unless we use some cuts
965  TTreeValidation::mapSeedTkToRecoTk(ev.candidateTracks_, ev.candidateTracksExtra_, seedToBuildMap_);
966  TTreeValidation::mapSeedTkToRecoTk(ev.fitTracks_, ev.fitTracksExtra_, seedToFitMap_);
967  }
968 
970  const TrackExtraVec& evt_extras,
971  TkIDToTkIDMap& seedTkMap) {
972  for (auto&& track : evt_tracks) {
973  seedTkMap[evt_extras[track.label()].seedID()] = track.label();
974  }
975  }
976 
978  std::lock_guard<std::mutex> locker(glock_);
980  buildToFitMap_, ev.candidateTracks_, ev.candidateTracksExtra_, ev.fitTracks_, ev.fitTracksExtra_);
982  fitToBuildMap_, ev.fitTracks_, ev.fitTracksExtra_, ev.candidateTracks_, ev.candidateTracksExtra_);
983  }
984 
986  const TrackVec& reftracks,
987  const TrackExtraVec& refextras,
988  const TrackVec& pairtracks,
989  const TrackExtraVec& pairextras) {
990  // at this point in the code, the labels of the tracks point their position inside the vector
991  // while the seedID is the label prior to relabeling (in reality, this is the MC track ID)
992  for (auto&& reftrack : reftracks) {
993  const auto& refextra = refextras[reftrack.label()];
994  for (auto&& pairtrack : pairtracks) {
995  const auto& pairextra = pairextras[pairtrack.label()];
996  if (refextra.seedID() == pairextra.seedID()) {
997  refToPairMap[reftrack.label()] = pairtrack.label();
998  break;
999  }
1000  }
1001  }
1002  }
1003 
1005  std::lock_guard<std::mutex> locker(glock_);
1006  // can reuse this function
1007  TTreeValidation::mapRefTkToRecoTks(ev.candidateTracks_, ev.candidateTracksExtra_, cmsswToBuildMap_);
1008  TTreeValidation::mapRefTkToRecoTks(ev.fitTracks_, ev.fitTracksExtra_, cmsswToFitMap_);
1009  }
1010 
1012  const auto& seedtracks = ev.seedTracks_;
1013  const auto& cmsswtracks = ev.cmsswTracks_;
1014  for (int itrack = 0; itrack < (int)seedtracks.size(); itrack++) {
1015  for (auto&& cmsswtrack : cmsswtracks) {
1016  if (cmsswtrack.label() == itrack) {
1017  seedToCmsswMap_[seedtracks[itrack].label()] = cmsswtrack.label();
1018  break;
1019  }
1020  }
1021  }
1022  }
1023 
1025  const auto& seedtracks = ev.seedTracks_;
1026 
1027  for (const auto& seedToCmsswPair : seedToCmsswMap_) {
1028  const auto seedlabel =
1029  seedToCmsswPair
1030  .first; // !! in cmssw validation, seed label != seed index in vector as they are not aligned!! --> need to find itrack!
1031  const auto cmsswlabel = seedToCmsswPair.second; // however, cmssw tracks ARE aligned for label == index
1032 
1033  for (int itrack = 0; itrack < (int)seedtracks.size(); itrack++) {
1034  const auto& seedtrack = seedtracks[itrack];
1035  if (seedtrack.label() == seedlabel) {
1036  cmsswToSeedMap_[cmsswlabel] = itrack;
1037  break;
1038  }
1039  }
1040  }
1041  }
1042 
1044  std::lock_guard<std::mutex> locker(glock_);
1045  // special functions for matching seeds to reco tracks for sim_val_for_cmssw
1047  ev.candidateTracksExtra_, ev.seedTracksExtra_, candToSeedMapDumbCMSSW_);
1049  }
1050 
1052  const TrackExtraVec& seedextras,
1053  TkIDToTkIDMap& recoToSeedMap) {
1054  for (int itrack = 0; itrack < (int)recoextras.size(); itrack++) {
1055  const auto reco_seedID = recoextras[itrack].seedID();
1056  for (int jtrack = 0; jtrack < (int)seedextras.size(); jtrack++) {
1057  const auto seed_seedID = seedextras[jtrack].seedID();
1058  if (reco_seedID == seed_seedID) {
1059  recoToSeedMap[itrack] = jtrack;
1060  break;
1061  }
1062  }
1063  }
1064  }
1065 
1067  auto& seedtracks = ev.seedTracks_;
1068  auto& candtracks = ev.candidateTracks_;
1069  auto& fittracks = ev.fitTracks_;
1070  auto score_calc = IterationConfig::get_track_scorer("default");
1071 
1072  // first compute score...
1073  for (auto& seedtrack : seedtracks) {
1074  seedtrack.setScore(getScoreCand(score_calc, seedtrack));
1075  }
1076 
1077  // ...then use map to set seed type to for build/fit tracks and compute scores
1078  for (const auto& candToSeedPair : candToSeedMapDumbCMSSW_) {
1079  auto& candtrack = candtracks[candToSeedPair.first];
1080 
1081  candtrack.setScore(getScoreCand(score_calc, candtrack));
1082  }
1083  for (const auto& fitToSeedPair : fitToSeedMapDumbCMSSW_) {
1084  auto& fittrack = fittracks[fitToSeedPair.first];
1085 
1086  fittrack.setScore(getScoreCand(score_calc, fittrack));
1087  }
1088  }
1089 
1091  const auto& buildtracks = ev.candidateTracks_;
1092  auto& buildextras = ev.candidateTracksExtra_;
1093 
1094  const auto& fittracks = ev.fitTracks_;
1095  auto& fitextras = ev.fitTracksExtra_;
1096 
1097  const auto& cmsswtracks = ev.cmsswTracks_;
1098  auto& cmsswextras = ev.cmsswTracksExtra_;
1099 
1100  // first set candidate tracks, use as base for fittracks
1101  int newlabel = -1;
1102  for (int itrack = 0; itrack < (int)buildtracks.size(); itrack++) {
1103  auto& extra = buildextras[itrack];
1104  const int seedID = extra.seedID();
1105 
1106  extra.setmcTrackID(seedID);
1107 
1108  if (seedToCmsswMap_.count(seedID)) {
1109  extra.setseedID(seedToCmsswMap_[seedID]);
1111  for (int ctrack = 0; ctrack < (int)cmsswextras.size(); ctrack++) {
1112  if (cmsswextras[ctrack].seedID() == extra.seedID()) {
1113  buildToCmsswMap_[itrack] = cmsswtracks[ctrack].label(); // cmsstracks[ctrack].label() == ctrack!
1114  break;
1115  }
1116  }
1117  }
1118  } else {
1119  extra.setseedID(--newlabel);
1120  }
1121  }
1122 
1123  // set according to candidate tracks for fit tracks through map
1124  for (int itrack = 0; itrack < (int)fittracks.size(); itrack++) {
1125  auto& extra = fitextras[itrack];
1126 
1127  extra.setmcTrackID(buildextras[fitToBuildMap_[itrack]].mcTrackID());
1128  extra.setseedID(buildextras[fitToBuildMap_[itrack]].seedID());
1129  }
1130  }
1131 
1133  RedTrackVec& reducedCMSSW,
1134  LayIdxIDVecMapMap& cmsswHitIDMap) {
1135  // get the tracks + hits + extras
1136  const auto& layerhits = ev.layerHits_;
1137  const auto& cmsswtracks = ev.cmsswTracks_;
1138  auto& cmsswextras = ev.cmsswTracksExtra_;
1139  const auto& seedtracks = ev.seedTracks_;
1140 
1141  // resize accordingly
1142  reducedCMSSW.resize(cmsswtracks.size());
1143 
1144  for (int itrack = 0; itrack < (int)cmsswtracks.size(); itrack++) {
1145  // get the needed tracks and extras
1146  auto& cmsswextra = cmsswextras[itrack];
1147  const auto& cmsswtrack = cmsswtracks[itrack];
1148  const auto& seedtrack = seedtracks[cmsswToSeedMap_[cmsswtrack.label()]]; // since cmsswtrack.label() == itrack
1149 
1150  // set seed hits!
1151  cmsswextra.findMatchingSeedHits(cmsswtrack, seedtrack, layerhits);
1152 
1153  // get tmp vars
1154  const auto seedID = cmsswextra.seedID();
1155  const auto& params = cmsswtrack.parameters();
1156  SVector2 tmpv(params[3], params[5]);
1157 
1158  HitLayerMap tmpmap;
1159  for (int ihit = 0; ihit < cmsswtrack.nTotalHits(); ihit++) {
1160  const int lyr = cmsswtrack.getHitLyr(ihit);
1161  const int idx = cmsswtrack.getHitIdx(ihit);
1162 
1163  // don't bother with storing seed layers in reduced cmssw
1164  if (cmsswextra.isSeedHit(lyr, idx))
1165  continue;
1166 
1167  if (lyr >= 0 && idx >= 0) {
1168  tmpmap[lyr].push_back(idx);
1169  cmsswHitIDMap[lyr][idx].push_back(cmsswtrack.label());
1170  }
1171  }
1172 
1173  // index inside object is label (as cmsswtracks are now aligned)
1174  reducedCMSSW[itrack] = ReducedTrack(cmsswtrack.label(), seedID, tmpv, cmsswtrack.momPhi(), tmpmap);
1175  }
1176  }
1177 
1178  int TTreeValidation::getLastFoundHit(const int trackMCHitID, const int mcTrackID, const Event& ev) {
1179  int mcHitID = -1;
1180  if (ev.simHitsInfo_[trackMCHitID].mcTrackID() == mcTrackID) {
1181  mcHitID = trackMCHitID;
1182  } else {
1183  mcHitID = ev.simTracks_[mcTrackID].getMCHitIDFromLayer(ev.layerHits_, ev.simHitsInfo_[trackMCHitID].layer());
1184  }
1185  return mcHitID;
1186  }
1187 
1188  int TTreeValidation::getMaskAssignment(const int refID) {
1189  // initialize
1190  auto refmask = -99;
1191 
1192  if (refID >= 0) // seed track matched to seed and sim
1193  {
1194  refmask = 1; // matched track to sim
1195  } else if (refID == -10) {
1196  refmask = -2;
1197  } else {
1198  if (Config::inclusiveShorts) // only used by standard simval!
1199  {
1200  if (refID == -1 || refID == -5 || refID == -8 || refID == -9) {
1201  refmask = 0;
1202  } else if (refID == -2) {
1203  refmask = 2;
1204  } else // mcID == -3,-4,-6,-7
1205  {
1206  refmask = -1;
1207  }
1208  } else // only count long tracks (in mtvLike: all reco tracks are counted!)
1209  {
1210  if (refID == -1 || refID == -9) {
1211  refmask = 0;
1212  } else if (Config::mtvLikeValidation && refID == -4) {
1213  refmask = 2;
1214  } else // mcID == -2,-3,-4,-5,-6,-7,-8: standard simval
1215  {
1216  refmask = -1;
1217  }
1218  }
1219  } // end check over not matched
1220 
1221  return refmask;
1222  }
1223 
1225  for (int ilayer = 0; ilayer < ntotallayers_fit_; ++ilayer) {
1226  z_prop_fit_[ilayer] = -1000.f;
1227  ez_prop_fit_[ilayer] = -1000.f;
1228  z_hit_fit_[ilayer] = -1000.f;
1229  ez_hit_fit_[ilayer] = -1000.f;
1230  z_sim_fit_[ilayer] = -1000.f;
1231  ez_sim_fit_[ilayer] = -1000.f;
1232 
1233  pphi_prop_fit_[ilayer] = -1000.f;
1234  epphi_prop_fit_[ilayer] = -1000.f;
1235  pphi_hit_fit_[ilayer] = -1000.f;
1236  epphi_hit_fit_[ilayer] = -1000.f;
1237  pphi_sim_fit_[ilayer] = -1000.f;
1238  epphi_sim_fit_[ilayer] = -1000.f;
1239 
1240  pt_up_fit_[ilayer] = -1000.f;
1241  ept_up_fit_[ilayer] = -1000.f;
1242  pt_sim_fit_[ilayer] = -1000.f;
1243  ept_sim_fit_[ilayer] = -1000.f;
1244 
1245  mphi_up_fit_[ilayer] = -1000.f;
1246  emphi_up_fit_[ilayer] = -1000.f;
1247  mphi_sim_fit_[ilayer] = -1000.f;
1248  emphi_sim_fit_[ilayer] = -1000.f;
1249 
1250  meta_up_fit_[ilayer] = -1000.f;
1251  emeta_up_fit_[ilayer] = -1000.f;
1252  meta_sim_fit_[ilayer] = -1000.f;
1253  emeta_sim_fit_[ilayer] = -1000.f;
1254  }
1255  }
1256 
1258  std::lock_guard<std::mutex> locker(glock_);
1259 
1260  evtid_fit_ = ev.evtID();
1261  const auto& simtracks = ev.simTracks_;
1262  const auto& layerhits = ev.layerHits_;
1263  const auto& simtrackstates = ev.simTrackStates_;
1264 
1265  for (auto&& fitvalmapmap : fitValTkMapMap_) {
1267 
1268  tkid_fit_ = fitvalmapmap.first; // seed id (label) is the same as the mcID
1269 
1270  const auto& simtrack = simtracks[tkid_fit_];
1271  const auto& fitvalmap = fitvalmapmap.second;
1272  for (int ilayer = 0; ilayer < ntotallayers_fit_; ++ilayer) {
1273  if (fitvalmap.count(ilayer)) {
1274  const auto& hit = layerhits[ilayer][simtrack.getHitIdx(ilayer)];
1275  const auto& initTS = simtrackstates.at(hit.mcHitID());
1276  const auto& fitval = fitvalmap.at(ilayer);
1277 
1278  z_hit_fit_[ilayer] = hit.z();
1279  ez_hit_fit_[ilayer] = std::sqrt(hit.ezz());
1280  z_sim_fit_[ilayer] = initTS.z();
1281  ez_sim_fit_[ilayer] = initTS.ezz();
1282  z_prop_fit_[ilayer] = fitval.ppz;
1283  ez_prop_fit_[ilayer] = fitval.eppz;
1284 
1285  pphi_hit_fit_[ilayer] = hit.phi();
1286  epphi_hit_fit_[ilayer] = std::sqrt(hit.ephi());
1287  pphi_sim_fit_[ilayer] = initTS.posPhi();
1288  epphi_sim_fit_[ilayer] = initTS.eposPhi();
1289  pphi_prop_fit_[ilayer] = fitval.ppphi;
1290  epphi_prop_fit_[ilayer] = fitval.eppphi;
1291 
1292  pt_up_fit_[ilayer] = fitval.upt;
1293  ept_up_fit_[ilayer] = fitval.eupt;
1294  pt_sim_fit_[ilayer] = initTS.pT();
1295  ept_sim_fit_[ilayer] = initTS.epT();
1296 
1297  mphi_up_fit_[ilayer] = fitval.umphi;
1298  emphi_up_fit_[ilayer] = fitval.eumphi;
1299  mphi_sim_fit_[ilayer] = initTS.momPhi();
1300  emphi_sim_fit_[ilayer] = initTS.emomPhi();
1301 
1302  meta_up_fit_[ilayer] = fitval.umeta;
1303  emeta_up_fit_[ilayer] = fitval.eumeta;
1304  meta_sim_fit_[ilayer] = initTS.momEta();
1305  emeta_sim_fit_[ilayer] = initTS.emomEta();
1306  }
1307  }
1308  fittree_->Fill();
1309  }
1310  }
1311 
1313  const Track& track,
1314  std::vector<int>& lyrs,
1315  std::vector<int>& idxs,
1316  std::vector<int>& mcTkIDs,
1317  std::vector<float>& xs,
1318  std::vector<float>& ys,
1319  std::vector<float>& zs) {
1320  // get event info
1321  const auto& layerHits = ev.layerHits_;
1322  const auto& simHitsInfo = ev.simHitsInfo_;
1323 
1324  // resize vectors
1325  const auto nTotalHits = track.nTotalHits();
1326  lyrs.resize(nTotalHits);
1327  idxs.resize(nTotalHits);
1328  mcTkIDs.resize(nTotalHits, -99);
1329  xs.resize(nTotalHits, -9999.f);
1330  ys.resize(nTotalHits, -9999.f);
1331  zs.resize(nTotalHits, -9999.f);
1332 
1333  // loop over size of total hits
1334  for (auto ihit = 0; ihit < nTotalHits; ihit++) {
1335  const auto lyr = track.getHitLyr(ihit);
1336  const auto idx = track.getHitIdx(ihit);
1337 
1338  lyrs[ihit] = lyr;
1339  idxs[ihit] = idx;
1340 
1341  if (lyr < 0)
1342  continue;
1343  if (idx < 0)
1344  continue;
1345 
1346  const auto& hit = layerHits[lyr][idx];
1347  mcTkIDs[ihit] = hit.mcTrackID(simHitsInfo);
1348  xs[ihit] = hit.x();
1349  ys[ihit] = hit.y();
1350  zs[ihit] = hit.z();
1351  }
1352  }
1353 
1354  void TTreeValidation::fillMinHitInfo(const Track& track, std::vector<int>& lyrs, std::vector<int>& idxs) {
1355  for (int ihit = 0; ihit < track.nTotalHits(); ihit++) {
1356  lyrs.emplace_back(track.getHitLyr(ihit));
1357  idxs.emplace_back(track.getHitIdx(ihit));
1358  }
1359  }
1360 
1362  std::lock_guard<std::mutex> locker(glock_);
1363 
1364  const auto ievt = ev.evtID();
1365  const auto& evt_sim_tracks = ev.simTracks_;
1366  const auto& evt_seed_tracks = ev.seedTracks_;
1367  const auto& evt_seed_extras = ev.seedTracksExtra_;
1368  const auto& evt_build_tracks = ev.candidateTracks_;
1369  const auto& evt_build_extras = ev.candidateTracksExtra_;
1370  const auto& evt_fit_tracks = ev.fitTracks_;
1371  const auto& evt_fit_extras = ev.fitTracksExtra_;
1372  const auto& evt_layer_hits = ev.layerHits_;
1373  const auto& evt_sim_trackstates = ev.simTrackStates_;
1374 
1375  unsigned int count = 0;
1376  for (const auto& simtrack : evt_sim_tracks) {
1377  // clear the branches first
1378  if (Config::keepHitInfo) {
1379  hitlyrs_mc_eff_.clear();
1380  hitlyrs_seed_eff_.clear();
1381  hitlyrs_build_eff_.clear();
1382  hitlyrs_fit_eff_.clear();
1383 
1384  hitidxs_mc_eff_.clear();
1385  hitidxs_seed_eff_.clear();
1386  hitidxs_build_eff_.clear();
1387  hitidxs_fit_eff_.clear();
1388 
1389  hitmcTkIDs_mc_eff_.clear();
1390  hitmcTkIDs_seed_eff_.clear();
1391  hitmcTkIDs_build_eff_.clear();
1392  hitmcTkIDs_fit_eff_.clear();
1393 
1394  hitxs_mc_eff_.clear();
1395  hitxs_seed_eff_.clear();
1396  hitxs_build_eff_.clear();
1397  hitxs_fit_eff_.clear();
1398 
1399  hitys_mc_eff_.clear();
1400  hitys_seed_eff_.clear();
1401  hitys_build_eff_.clear();
1402  hitys_fit_eff_.clear();
1403 
1404  hitzs_mc_eff_.clear();
1405  hitzs_seed_eff_.clear();
1406  hitzs_build_eff_.clear();
1407  hitzs_fit_eff_.clear();
1408  }
1409 
1410  evtID_eff_ = ievt;
1411  mcID_eff_ = simtrack.label();
1412 
1413  // generated values
1414  x_mc_gen_eff_ = simtrack.x();
1415  y_mc_gen_eff_ = simtrack.y();
1416  z_mc_gen_eff_ = simtrack.z();
1417 
1418  pt_mc_gen_eff_ = simtrack.pT();
1419  phi_mc_gen_eff_ = simtrack.momPhi();
1420  eta_mc_gen_eff_ = simtrack.momEta();
1421  nHits_mc_eff_ = simtrack.nFoundHits(); // could be that the sim track skips layers!
1422  nLayers_mc_eff_ = simtrack.nUniqueLayers();
1423  lastlyr_mc_eff_ = simtrack.getLastFoundHitLyr();
1424 
1425  itermask_seed_eff_ = 0;
1426  itermask_build_eff_ = 0;
1427  itermask_fit_eff_ = 0;
1431  algo_seed_eff_ = 0;
1432 
1434  for (auto aa : ev.simTracksExtra_[count].seedAlgos()) {
1435  algo_seed_eff_ = (algo_seed_eff_ | (1 << aa));
1436  }
1437  }
1438  count++;
1439 
1440  // hit indices
1441  if (Config::keepHitInfo)
1443  simtrack,
1447  hitxs_mc_eff_,
1448  hitys_mc_eff_,
1449  hitzs_mc_eff_);
1450 
1451  // matched seed track
1452  if (simToSeedMap_.count(mcID_eff_) &&
1453  simtrack
1454  .isFindable()) // recoToSim match : save best match with best score, i.e. simToSeedMap_[matched SimID][first element in vector]
1455  {
1456  for (unsigned int ii = 0; ii < simToSeedMap_[mcID_eff_].size(); ii++) {
1457  const int theAlgo = evt_seed_tracks[simToSeedMap_[mcID_eff_][ii]].algoint();
1458  if ((itermask_seed_eff_ >> theAlgo) & 1)
1459  iterduplmask_seed_eff_ = (iterduplmask_seed_eff_ | (1 << theAlgo)); //filled at the second time
1460  itermask_seed_eff_ = (itermask_seed_eff_ | (1 << theAlgo));
1461  }
1462  const auto& seedtrack =
1463  evt_seed_tracks[simToSeedMap_[mcID_eff_][0]]; // returns seedTrack best matched to sim track
1464  const auto& seedextra = evt_seed_extras[seedtrack.label()]; // returns track extra best aligned with seed track
1465  mcmask_seed_eff_ = 1; // quick logic for matched
1466 
1467  seedID_seed_eff_ = seedextra.seedID();
1468 
1469  // use this to access correct sim track layer params
1470  const int mcHitID =
1471  TTreeValidation::getLastFoundHit(seedtrack.getLastFoundMCHitID(evt_layer_hits), mcID_eff_, ev);
1472  if (mcHitID >= 0 && Config::readSimTrackStates) {
1473  const TrackState& initLayTS = evt_sim_trackstates[mcHitID];
1474 
1475  pt_mc_seed_eff_ = initLayTS.pT();
1476  phi_mc_seed_eff_ = initLayTS.momPhi();
1477  eta_mc_seed_eff_ = initLayTS.momEta();
1478  helixchi2_seed_eff_ = computeHelixChi2(initLayTS.parameters, seedtrack.parameters(), seedtrack.errors());
1479 
1480  mcTSmask_seed_eff_ = 1;
1481  } else if (Config::tryToSaveSimInfo) // can enter this block if: we actually read sim track states, but could not find the mchit OR we chose not to read the sim track states
1482  {
1483  // reuse info already set
1487  helixchi2_seed_eff_ = computeHelixChi2(simtrack.parameters(), seedtrack.parameters(), seedtrack.errors());
1488 
1489  mcTSmask_seed_eff_ = 0;
1490  } else {
1491  pt_mc_seed_eff_ = -101;
1492  phi_mc_seed_eff_ = -101;
1493  eta_mc_seed_eff_ = -101;
1494  helixchi2_seed_eff_ = -101;
1495 
1496  mcTSmask_seed_eff_ = -2;
1497  }
1498 
1499  // last hit info
1500  const Hit& lasthit = evt_layer_hits[seedtrack.getLastFoundHitLyr()][seedtrack.getLastFoundHitIdx()];
1501  xhit_seed_eff_ = lasthit.x();
1502  yhit_seed_eff_ = lasthit.y();
1503  zhit_seed_eff_ = lasthit.z();
1504 
1505  pt_seed_eff_ = seedtrack.pT();
1506  ept_seed_eff_ = seedtrack.epT();
1507  phi_seed_eff_ = seedtrack.momPhi();
1508  ephi_seed_eff_ = seedtrack.emomPhi();
1509  eta_seed_eff_ = seedtrack.momEta();
1510  eeta_seed_eff_ = seedtrack.emomEta();
1511 
1512  // rest of mc info
1513  nHits_seed_eff_ = seedtrack.nFoundHits();
1514  nLayers_seed_eff_ = seedtrack.nUniqueLayers();
1515  nHitsMatched_seed_eff_ = seedextra.nHitsMatched();
1516  fracHitsMatched_seed_eff_ = seedextra.fracHitsMatched();
1517  lastlyr_seed_eff_ = seedtrack.getLastFoundHitLyr();
1518 
1519  // swim dphi
1520  dphi_seed_eff_ = seedextra.dPhi();
1521 
1522  // quality info
1523  hitchi2_seed_eff_ = seedtrack.chi2(); // currently not being used
1524  score_seed_eff_ = seedtrack.score(); // currently a constant by definition
1525 
1526  duplmask_seed_eff_ = seedextra.isDuplicate();
1527  nTkMatches_seed_eff_ = simToSeedMap_[mcID_eff_].size(); // n reco matches to this sim track.
1528 
1529  // hit indices
1530  if (Config::keepHitInfo)
1532  seedtrack,
1538  hitzs_seed_eff_);
1539  } else // unmatched simTracks ... put -99 for all reco values to denote unmatched
1540  {
1541  mcmask_seed_eff_ = (simtrack.isFindable() ? 0 : -1); // quick logic for not matched
1542 
1543  seedID_seed_eff_ = -99;
1544 
1545  pt_mc_seed_eff_ = -99;
1546  phi_mc_seed_eff_ = -99;
1547  eta_mc_seed_eff_ = -99;
1548  helixchi2_seed_eff_ = -99;
1549 
1550  mcTSmask_seed_eff_ = -1; // mask means unmatched sim track
1551 
1552  xhit_seed_eff_ = -2000;
1553  yhit_seed_eff_ = -2000;
1554  zhit_seed_eff_ = -2000;
1555 
1556  pt_seed_eff_ = -99;
1557  ept_seed_eff_ = -99;
1558  phi_seed_eff_ = -99;
1559  ephi_seed_eff_ = -99;
1560  eta_seed_eff_ = -99;
1561  eeta_seed_eff_ = -99;
1562 
1563  nHits_seed_eff_ = -99;
1564  nLayers_seed_eff_ = -99;
1565  nHitsMatched_seed_eff_ = -99;
1567  lastlyr_seed_eff_ = -99;
1568 
1569  dphi_seed_eff_ = -99;
1570 
1571  hitchi2_seed_eff_ = -99;
1572  score_seed_eff_ = -17000;
1573 
1574  duplmask_seed_eff_ = -1; // mask means unmatched sim track
1575  nTkMatches_seed_eff_ = -99; // unmatched
1576  }
1577 
1578  // matched build track
1579  if (simToBuildMap_.count(mcID_eff_) &&
1580  simtrack
1581  .isFindable()) // recoToSim match : save best match with best score i.e. simToBuildMap_[matched SimID][first element in vector]
1582  {
1583  for (unsigned int ii = 0; ii < simToBuildMap_[mcID_eff_].size(); ii++) {
1584  const int theAlgo = evt_build_tracks[simToBuildMap_[mcID_eff_][ii]].algoint();
1585  if ((itermask_build_eff_ >> theAlgo) & 1)
1586  iterduplmask_build_eff_ = (iterduplmask_build_eff_ | (1 << theAlgo)); //filled at the second time
1587  itermask_build_eff_ = (itermask_build_eff_ | (1 << theAlgo));
1588  }
1589  const auto& buildtrack =
1590  evt_build_tracks[simToBuildMap_[mcID_eff_][0]]; // returns buildTrack best matched to sim track
1591  const auto& buildextra =
1592  evt_build_extras[buildtrack.label()]; // returns track extra best aligned with build track
1593  mcmask_build_eff_ = 1; // quick logic for matched
1594 
1595  seedID_build_eff_ = buildextra.seedID();
1596 
1597  // use this to access correct sim track layer params
1598  const int mcHitID =
1599  TTreeValidation::getLastFoundHit(buildtrack.getLastFoundMCHitID(evt_layer_hits), mcID_eff_, ev);
1600  if (mcHitID >= 0 && Config::readSimTrackStates) {
1601  const TrackState& initLayTS = evt_sim_trackstates[mcHitID];
1602 
1603  pt_mc_build_eff_ = initLayTS.pT();
1604  phi_mc_build_eff_ = initLayTS.momPhi();
1605  eta_mc_build_eff_ = initLayTS.momEta();
1606  helixchi2_build_eff_ = computeHelixChi2(initLayTS.parameters, buildtrack.parameters(), buildtrack.errors());
1607 
1608  mcTSmask_build_eff_ = 1;
1609  } else if (Config::tryToSaveSimInfo) // can enter this block if: we actually read sim track states, but could not find the mchit OR we chose not to read the sim track states
1610  {
1611  // reuse info already set
1615  helixchi2_build_eff_ = computeHelixChi2(simtrack.parameters(), buildtrack.parameters(), buildtrack.errors());
1616 
1617  mcTSmask_build_eff_ = 0;
1618  } else {
1619  pt_mc_build_eff_ = -101;
1620  phi_mc_build_eff_ = -101;
1621  eta_mc_build_eff_ = -101;
1622  helixchi2_build_eff_ = -101;
1623 
1624  mcTSmask_build_eff_ = -2;
1625  }
1626 
1627  // last hit info
1628  const Hit& lasthit = evt_layer_hits[buildtrack.getLastFoundHitLyr()][buildtrack.getLastFoundHitIdx()];
1629  xhit_build_eff_ = lasthit.x();
1630  yhit_build_eff_ = lasthit.y();
1631  zhit_build_eff_ = lasthit.z();
1632 
1633  pt_build_eff_ = buildtrack.pT();
1634  ept_build_eff_ = buildtrack.epT();
1635  phi_build_eff_ = buildtrack.momPhi();
1636  ephi_build_eff_ = buildtrack.emomPhi();
1637  eta_build_eff_ = buildtrack.momEta();
1638  eeta_build_eff_ = buildtrack.emomEta();
1639 
1640  nHits_build_eff_ = buildtrack.nFoundHits();
1641  nLayers_build_eff_ = buildtrack.nUniqueLayers();
1642  nHitsMatched_build_eff_ = buildextra.nHitsMatched();
1643  fracHitsMatched_build_eff_ = buildextra.fracHitsMatched();
1644  lastlyr_build_eff_ = buildtrack.getLastFoundHitLyr();
1645 
1646  // swim dphi
1647  dphi_build_eff_ = buildextra.dPhi();
1648 
1649  // quality info
1650  hitchi2_build_eff_ = buildtrack.chi2();
1651  score_build_eff_ = buildtrack.score();
1652 
1653  duplmask_build_eff_ = buildextra.isDuplicate();
1654  nTkMatches_build_eff_ = simToBuildMap_[mcID_eff_].size(); // n reco matches to this sim track.
1655 
1656  // hit indices
1657  if (Config::keepHitInfo)
1659  buildtrack,
1666  } else // unmatched simTracks ... put -99 for all reco values to denote unmatched
1667  {
1668  mcmask_build_eff_ = (simtrack.isFindable() ? 0 : -1); // quick logic for not matched
1669 
1670  seedID_build_eff_ = -99;
1671 
1672  pt_mc_build_eff_ = -99;
1673  phi_mc_build_eff_ = -99;
1674  eta_mc_build_eff_ = -99;
1675  helixchi2_build_eff_ = -99;
1676 
1677  mcTSmask_build_eff_ = -1;
1678 
1679  xhit_build_eff_ = -2000;
1680  yhit_build_eff_ = -2000;
1681  zhit_build_eff_ = -2000;
1682 
1683  pt_build_eff_ = -99;
1684  ept_build_eff_ = -99;
1685  phi_build_eff_ = -99;
1686  ephi_build_eff_ = -99;
1687  eta_build_eff_ = -99;
1688  eeta_build_eff_ = -99;
1689 
1690  nHits_build_eff_ = -99;
1691  nLayers_build_eff_ = -99;
1694  lastlyr_build_eff_ = -99;
1695 
1696  dphi_build_eff_ = -99;
1697 
1698  hitchi2_build_eff_ = -99;
1699  score_build_eff_ = -17000;
1700 
1701  duplmask_build_eff_ = -1; // mask means unmatched sim track
1702  nTkMatches_build_eff_ = -99; // unmatched
1703  }
1704 
1705  // matched fit track
1706  if (simToFitMap_.count(mcID_eff_) &&
1707  simtrack
1708  .isFindable()) // recoToSim match : save best match with best score i.e. simToFitMap_[matched SimID][first element in vector]
1709  {
1710  for (unsigned int ii = 0; ii < simToFitMap_[mcID_eff_].size(); ii++) {
1711  const int theAlgo = evt_fit_tracks[simToFitMap_[mcID_eff_][ii]].algoint();
1712  if ((itermask_fit_eff_ >> theAlgo) & 1)
1713  iterduplmask_fit_eff_ = (iterduplmask_fit_eff_ | (1 << theAlgo)); //filled at the second time
1714  itermask_fit_eff_ = (itermask_fit_eff_ | (1 << theAlgo));
1715  }
1716  const auto& fittrack =
1717  evt_fit_tracks[simToFitMap_[mcID_eff_][0]]; // returns fitTrack best matched to sim track
1718  const auto& fitextra = evt_fit_extras[fittrack.label()]; // returns track extra best aligned with fit track
1719  mcmask_fit_eff_ = 1; // quick logic for matched
1720 
1721  seedID_fit_eff_ = fitextra.seedID();
1722 
1723  // use this to access correct sim track layer params
1724  const int mcHitID =
1725  TTreeValidation::getLastFoundHit(fittrack.getLastFoundMCHitID(evt_layer_hits), mcID_eff_, ev);
1726  if (mcHitID >= 0 && Config::readSimTrackStates) {
1727  const TrackState& initLayTS = evt_sim_trackstates[mcHitID];
1728 
1729  pt_mc_fit_eff_ = initLayTS.pT();
1730  phi_mc_fit_eff_ = initLayTS.momPhi();
1731  eta_mc_fit_eff_ = initLayTS.momEta();
1732  helixchi2_fit_eff_ = computeHelixChi2(initLayTS.parameters, fittrack.parameters(), fittrack.errors());
1733 
1734  mcTSmask_fit_eff_ = 1;
1735  } else if (Config::tryToSaveSimInfo) // can enter this block if: we actually read sim track states, but could not find the mchit OR we chose not to read the sim track states
1736  {
1737  // reuse info already set
1741  helixchi2_fit_eff_ = computeHelixChi2(simtrack.parameters(), fittrack.parameters(), fittrack.errors());
1742 
1743  mcTSmask_fit_eff_ = 0;
1744  } else {
1745  pt_mc_fit_eff_ = -101;
1746  phi_mc_fit_eff_ = -101;
1747  eta_mc_fit_eff_ = -101;
1748  helixchi2_fit_eff_ = -101;
1749 
1750  mcTSmask_fit_eff_ = -2;
1751  }
1752 
1753  // last hit info
1754  const Hit& lasthit = evt_layer_hits[fittrack.getLastFoundHitLyr()][fittrack.getLastFoundHitIdx()];
1755  xhit_fit_eff_ = lasthit.x();
1756  yhit_fit_eff_ = lasthit.y();
1757  zhit_fit_eff_ = lasthit.z();
1758 
1759  pt_fit_eff_ = fittrack.pT();
1760  ept_fit_eff_ = fittrack.epT();
1761  phi_fit_eff_ = fittrack.momPhi();
1762  ephi_fit_eff_ = fittrack.emomPhi();
1763  eta_fit_eff_ = fittrack.momEta();
1764  eeta_fit_eff_ = fittrack.emomEta();
1765 
1766  // rest of mc info
1767  nHits_fit_eff_ = fittrack.nFoundHits();
1768  nLayers_fit_eff_ = fittrack.nUniqueLayers();
1769  nHitsMatched_fit_eff_ = fitextra.nHitsMatched();
1770  fracHitsMatched_fit_eff_ = fitextra.fracHitsMatched();
1771  lastlyr_fit_eff_ = fittrack.getLastFoundHitLyr();
1772 
1773  // swim dphi
1774  dphi_fit_eff_ = fitextra.dPhi();
1775 
1776  // quality info
1777  hitchi2_fit_eff_ = fittrack.chi2(); // -10 when not used
1778  score_fit_eff_ = fittrack.score();
1779 
1780  duplmask_fit_eff_ = fitextra.isDuplicate();
1781  nTkMatches_fit_eff_ = simToFitMap_[mcID_eff_].size(); // n reco matches to this sim track.
1782 
1783  // hit indices
1784  if (Config::keepHitInfo)
1786  fittrack,
1792  hitzs_fit_eff_);
1793  } else // unmatched simTracks ... put -99 for all reco values to denote unmatched
1794  {
1795  mcmask_fit_eff_ = (simtrack.isFindable() ? 0 : -1); // quick logic for not matched
1796 
1797  seedID_fit_eff_ = -99;
1798 
1799  pt_mc_fit_eff_ = -99;
1800  phi_mc_fit_eff_ = -99;
1801  eta_mc_fit_eff_ = -99;
1802  helixchi2_fit_eff_ = -99;
1803 
1804  mcTSmask_fit_eff_ = -1;
1805 
1806  xhit_fit_eff_ = -2000;
1807  yhit_fit_eff_ = -2000;
1808  zhit_fit_eff_ = -2000;
1809 
1810  pt_fit_eff_ = -99;
1811  ept_fit_eff_ = -99;
1812  phi_fit_eff_ = -99;
1813  ephi_fit_eff_ = -99;
1814  eta_fit_eff_ = -99;
1815  eeta_fit_eff_ = -99;
1816 
1817  nHits_fit_eff_ = -99;
1818  nLayers_fit_eff_ = -99;
1819  nHitsMatched_fit_eff_ = -99;
1821  lastlyr_fit_eff_ = -99;
1822 
1823  dphi_fit_eff_ = -99;
1824 
1825  hitchi2_fit_eff_ = -99;
1826  score_fit_eff_ = -17000;
1827 
1828  duplmask_fit_eff_ = -1; // mask means unmatched sim track
1829  nTkMatches_fit_eff_ = -99; // unmatched
1830  }
1831 
1832  efftree_->Fill(); // fill it once per sim track!
1833  }
1834  }
1835 
1837  std::lock_guard<std::mutex> locker(glock_);
1838 
1839  const auto ievt = ev.evtID();
1840  const auto& evt_sim_tracks =
1841  ev.simTracks_; // store sim info at that final layer!!! --> gen info stored only in eff tree
1842  const auto& evt_seed_tracks = ev.seedTracks_;
1843  const auto& evt_seed_extras = ev.seedTracksExtra_;
1844  const auto& evt_build_tracks = ev.candidateTracks_;
1845  const auto& evt_build_extras = ev.candidateTracksExtra_;
1846  const auto& evt_fit_tracks = ev.fitTracks_;
1847  const auto& evt_fit_extras = ev.fitTracksExtra_;
1848  const auto& evt_layer_hits = ev.layerHits_;
1849  const auto& evt_sim_trackstates = ev.simTrackStates_;
1850 
1851  for (const auto& seedtrack : evt_seed_tracks) {
1852  if (Config::keepHitInfo) {
1853  hitlyrs_seed_FR_.clear();
1854  hitlyrs_mc_seed_FR_.clear();
1855  hitlyrs_build_FR_.clear();
1856  hitlyrs_mc_build_FR_.clear();
1857  hitlyrs_fit_FR_.clear();
1858  hitlyrs_mc_fit_FR_.clear();
1859 
1860  hitidxs_seed_FR_.clear();
1861  hitidxs_mc_seed_FR_.clear();
1862  hitidxs_build_FR_.clear();
1863  hitidxs_mc_build_FR_.clear();
1864  hitidxs_fit_FR_.clear();
1865  hitidxs_mc_fit_FR_.clear();
1866 
1867  hitmcTkIDs_seed_FR_.clear();
1868  hitmcTkIDs_mc_seed_FR_.clear();
1869  hitmcTkIDs_build_FR_.clear();
1870  hitmcTkIDs_mc_build_FR_.clear();
1871  hitmcTkIDs_fit_FR_.clear();
1872  hitmcTkIDs_mc_fit_FR_.clear();
1873 
1874  hitxs_seed_FR_.clear();
1875  hitxs_mc_seed_FR_.clear();
1876  hitxs_build_FR_.clear();
1877  hitxs_mc_build_FR_.clear();
1878  hitxs_fit_FR_.clear();
1879  hitxs_mc_fit_FR_.clear();
1880 
1881  hitys_seed_FR_.clear();
1882  hitys_mc_seed_FR_.clear();
1883  hitys_build_FR_.clear();
1884  hitys_mc_build_FR_.clear();
1885  hitys_fit_FR_.clear();
1886  hitys_mc_fit_FR_.clear();
1887 
1888  hitzs_seed_FR_.clear();
1889  hitzs_mc_seed_FR_.clear();
1890  hitzs_build_FR_.clear();
1891  hitzs_mc_build_FR_.clear();
1892  hitzs_fit_FR_.clear();
1893  hitzs_mc_fit_FR_.clear();
1894  }
1895 
1896  evtID_FR_ = ievt;
1897 
1898  // seed info
1899  const auto& seedextra = evt_seed_extras[seedtrack.label()];
1900  seedID_FR_ = seedextra.seedID();
1902  1; // automatically set to 1, because at the moment no cuts on seeds after conformal+KF fit. seed triplets filtered by RZ chi2 before fitting.
1903 
1904  // last hit info
1905  // const Hit& lasthit = evt_layer_hits[seedtrack.getLastFoundHitLyr()][seedtrack.getLastFoundHitIdx()];
1906  xhit_seed_FR_ = 0; //lasthit.x();
1907  yhit_seed_FR_ = 0; //lasthit.y();
1908  zhit_seed_FR_ = 0; //lasthit.z();
1909 
1910  pt_seed_FR_ = seedtrack.pT();
1911  ept_seed_FR_ = seedtrack.epT();
1912  phi_seed_FR_ = seedtrack.momPhi();
1913  ephi_seed_FR_ = seedtrack.emomPhi();
1914  eta_seed_FR_ = seedtrack.momEta();
1915  eeta_seed_FR_ = seedtrack.emomEta();
1916 
1917  nHits_seed_FR_ = seedtrack.nFoundHits();
1918  nLayers_seed_FR_ = seedtrack.nUniqueLayers();
1919  nHitsMatched_seed_FR_ = seedextra.nHitsMatched();
1920  fracHitsMatched_seed_FR_ = seedextra.fracHitsMatched();
1921  lastlyr_seed_FR_ = seedtrack.getLastFoundHitLyr();
1922 
1923  algorithm_FR_ = seedtrack.algoint();
1924 
1925  // swim dphi
1926  dphi_seed_FR_ = seedextra.dPhi();
1927 
1928  // quality info
1929  hitchi2_seed_FR_ = seedtrack.chi2(); //--> not currently used
1930  score_seed_FR_ = seedtrack.score();
1931 
1932  if (Config::keepHitInfo)
1934  seedtrack,
1940  hitzs_seed_FR_);
1941 
1942  // sim info for seed track
1943  mcID_seed_FR_ = seedextra.mcTrackID();
1945 
1946  if (mcmask_seed_FR_ == 1) // matched track to sim
1947  {
1948  const auto& simtrack = evt_sim_tracks[mcID_seed_FR_];
1949 
1950  const int mcHitID =
1951  TTreeValidation::getLastFoundHit(seedtrack.getLastFoundMCHitID(evt_layer_hits), mcID_seed_FR_, ev);
1952  if (mcHitID >= 0 && Config::readSimTrackStates) {
1953  const TrackState& initLayTS = evt_sim_trackstates[mcHitID];
1954  pt_mc_seed_FR_ = initLayTS.pT();
1955  phi_mc_seed_FR_ = initLayTS.momPhi();
1956  eta_mc_seed_FR_ = initLayTS.momEta();
1957  helixchi2_seed_FR_ = computeHelixChi2(initLayTS.parameters, seedtrack.parameters(), seedtrack.errors());
1958 
1959  mcTSmask_seed_FR_ = 1;
1960  } else if (Config::tryToSaveSimInfo) {
1961  pt_mc_seed_FR_ = simtrack.pT();
1962  phi_mc_seed_FR_ = simtrack.momPhi();
1963  eta_mc_seed_FR_ = simtrack.momEta();
1964  helixchi2_seed_FR_ = computeHelixChi2(simtrack.parameters(), seedtrack.parameters(), seedtrack.errors());
1965 
1966  mcTSmask_seed_FR_ = 0;
1967  } else {
1968  pt_mc_seed_FR_ = -101;
1969  phi_mc_seed_FR_ = -101;
1970  eta_mc_seed_FR_ = -101;
1971  helixchi2_seed_FR_ = -101;
1972 
1973  mcTSmask_seed_FR_ = -2;
1974  }
1975 
1976  nHits_mc_seed_FR_ = simtrack.nFoundHits();
1977  nLayers_mc_seed_FR_ = simtrack.nUniqueLayers();
1978  lastlyr_mc_seed_FR_ = simtrack.getLastFoundHitLyr();
1979 
1980  duplmask_seed_FR_ = seedextra.isDuplicate();
1982  seedextra
1983  .duplicateID(); // ith duplicate seed track, i = 0 "best" match, i > 0 "still matched, real reco, not as good as i-1 track"
1984 
1985  if (Config::keepHitInfo)
1987  simtrack,
1994  } else {
1995  // -99 for all sim info for reco tracks not associated to reco tracks
1996  pt_mc_seed_FR_ = -99;
1997  phi_mc_seed_FR_ = -99;
1998  eta_mc_seed_FR_ = -99;
1999  helixchi2_seed_FR_ = -99;
2000 
2001  mcTSmask_seed_FR_ = -1;
2002 
2003  nHits_mc_seed_FR_ = -99;
2004  nLayers_mc_seed_FR_ = -99;
2005  lastlyr_mc_seed_FR_ = -99;
2006 
2007  duplmask_seed_FR_ = -1;
2008  iTkMatches_seed_FR_ = -99;
2009  }
2010 
2011  //==========================//
2012 
2013  // fill build information if track still alive
2014  if (seedToBuildMap_.count(seedID_FR_)) {
2015  seedmask_build_FR_ = 1; // quick logic
2016 
2017  const auto& buildtrack = evt_build_tracks[seedToBuildMap_[seedID_FR_]];
2018  const auto& buildextra = evt_build_extras[buildtrack.label()];
2019 
2020  // last hit info
2021  const Hit& lasthit = evt_layer_hits[buildtrack.getLastFoundHitLyr()][buildtrack.getLastFoundHitIdx()];
2022  xhit_build_FR_ = lasthit.x();
2023  yhit_build_FR_ = lasthit.y();
2024  zhit_build_FR_ = lasthit.z();
2025 
2026  pt_build_FR_ = buildtrack.pT();
2027  ept_build_FR_ = buildtrack.epT();
2028  phi_build_FR_ = buildtrack.momPhi();
2029  ephi_build_FR_ = buildtrack.emomPhi();
2030  eta_build_FR_ = buildtrack.momEta();
2031  eeta_build_FR_ = buildtrack.emomEta();
2032 
2033  nHits_build_FR_ = buildtrack.nFoundHits();
2034  nLayers_build_FR_ = buildtrack.nUniqueLayers();
2035  nHitsMatched_build_FR_ = buildextra.nHitsMatched();
2036  fracHitsMatched_build_FR_ = buildextra.fracHitsMatched();
2037  lastlyr_build_FR_ = buildtrack.getLastFoundHitLyr();
2038 
2039  // swim dphi
2040  dphi_build_FR_ = buildextra.dPhi();
2041 
2042  // quality info
2043  hitchi2_build_FR_ = buildtrack.chi2();
2044  score_build_FR_ = buildtrack.score();
2045 
2046  if (Config::keepHitInfo)
2048  buildtrack,
2054  hitzs_build_FR_);
2055 
2056  // sim info for build track
2057  mcID_build_FR_ = buildextra.mcTrackID();
2059 
2060  if (mcmask_build_FR_ == 1) // build track matched to seed and sim
2061  {
2062  const auto& simtrack = evt_sim_tracks[mcID_build_FR_];
2063 
2064  const int mcHitID =
2065  TTreeValidation::getLastFoundHit(buildtrack.getLastFoundMCHitID(evt_layer_hits), mcID_build_FR_, ev);
2066  if (mcHitID >= 0 && Config::readSimTrackStates) {
2067  const TrackState& initLayTS = evt_sim_trackstates[mcHitID];
2068  pt_mc_build_FR_ = initLayTS.pT();
2069  phi_mc_build_FR_ = initLayTS.momPhi();
2070  eta_mc_build_FR_ = initLayTS.momEta();
2071  helixchi2_build_FR_ = computeHelixChi2(initLayTS.parameters, buildtrack.parameters(), buildtrack.errors());
2072 
2073  mcTSmask_build_FR_ = 1;
2074  } else if (Config::tryToSaveSimInfo) {
2075  pt_mc_build_FR_ = simtrack.pT();
2076  phi_mc_build_FR_ = simtrack.momPhi();
2077  eta_mc_build_FR_ = simtrack.momEta();
2078  helixchi2_build_FR_ = computeHelixChi2(simtrack.parameters(), buildtrack.parameters(), buildtrack.errors());
2079 
2080  mcTSmask_build_FR_ = 0;
2081  } else {
2082  pt_mc_build_FR_ = -101;
2083  phi_mc_build_FR_ = -101;
2084  eta_mc_build_FR_ = -101;
2085  helixchi2_build_FR_ = -101;
2086 
2087  mcTSmask_build_FR_ = -2;
2088  }
2089 
2090  nHits_mc_build_FR_ = simtrack.nFoundHits();
2091  nLayers_mc_build_FR_ = simtrack.nUniqueLayers();
2092  lastlyr_mc_build_FR_ = simtrack.getLastFoundHitLyr();
2093 
2094  duplmask_build_FR_ = buildextra.isDuplicate();
2096  buildextra
2097  .duplicateID(); // ith duplicate build track, i = 0 "best" match, i > 0 "still matched, real reco, not as good as i-1 track"
2098 
2099  if (Config::keepHitInfo)
2101  simtrack,
2108  } else // build track matched only to seed not to sim
2109  {
2110  // -99 for all sim info for reco tracks not associated to reco tracks
2111  pt_mc_build_FR_ = -99;
2112  phi_mc_build_FR_ = -99;
2113  eta_mc_build_FR_ = -99;
2114  helixchi2_build_FR_ = -99;
2115 
2116  mcTSmask_build_FR_ = -1;
2117 
2118  nHits_mc_build_FR_ = -99;
2119  nLayers_mc_build_FR_ = -99;
2120  lastlyr_mc_build_FR_ = -99;
2121 
2122  duplmask_build_FR_ = -1;
2123  iTkMatches_build_FR_ = -99;
2124  } // matched seed to build, not build to sim
2125  }
2126 
2127  else // seed has no matching build track (therefore no matching sim to build track)
2128  {
2129  seedmask_build_FR_ = 0; // quick logic
2130 
2131  // -3000 for position info if no build track for seed
2132  xhit_build_FR_ = -3000;
2133  yhit_build_FR_ = -3000;
2134  zhit_build_FR_ = -3000;
2135 
2136  // -100 for all reco info as no actual build track for this seed
2137  pt_build_FR_ = -100;
2138  ept_build_FR_ = -100;
2139  phi_build_FR_ = -100;
2140  ephi_build_FR_ = -100;
2141  eta_build_FR_ = -100;
2142  eeta_build_FR_ = -100;
2143 
2144  nHits_build_FR_ = -100;
2145  nLayers_build_FR_ = -100;
2146  nHitsMatched_build_FR_ = -100;
2148  lastlyr_build_FR_ = -100;
2149 
2150  dphi_build_FR_ = -100;
2151 
2152  hitchi2_build_FR_ = -100;
2153  score_build_FR_ = -5001;
2154 
2155  // keep -100 for all sim variables as no such reco exists for this seed
2156  mcmask_build_FR_ = -2; // do not want to count towards build FR
2157  mcID_build_FR_ = -100;
2158 
2159  pt_mc_build_FR_ = -100;
2160  phi_mc_build_FR_ = -100;
2161  eta_mc_build_FR_ = -100;
2162  helixchi2_build_FR_ = -100;
2163 
2164  mcTSmask_build_FR_ = -3;
2165 
2166  nHits_mc_build_FR_ = -100;
2167  nLayers_mc_build_FR_ = -100;
2168  lastlyr_mc_build_FR_ = -100;
2169 
2170  duplmask_build_FR_ = -2;
2171  iTkMatches_build_FR_ = -100;
2172  }
2173 
2174  //============================// fit tracks
2175  if (seedToFitMap_.count(seedID_FR_)) {
2176  seedmask_fit_FR_ = 1; // quick logic
2177 
2178  const auto& fittrack = evt_fit_tracks[seedToFitMap_[seedID_FR_]];
2179  const auto& fitextra = evt_fit_extras[fittrack.label()];
2180 
2181  // last hit info
2182  const Hit& lasthit = evt_layer_hits[fittrack.getLastFoundHitLyr()][fittrack.getLastFoundHitIdx()];
2183  xhit_fit_FR_ = lasthit.x();
2184  yhit_fit_FR_ = lasthit.y();
2185  zhit_fit_FR_ = lasthit.z();
2186 
2187  pt_fit_FR_ = fittrack.pT();
2188  ept_fit_FR_ = fittrack.epT();
2189  phi_fit_FR_ = fittrack.momPhi();
2190  ephi_fit_FR_ = fittrack.emomPhi();
2191  eta_fit_FR_ = fittrack.momEta();
2192  eeta_fit_FR_ = fittrack.emomEta();
2193 
2194  nHits_fit_FR_ = fittrack.nFoundHits();
2195  nLayers_fit_FR_ = fittrack.nUniqueLayers();
2196  nHitsMatched_fit_FR_ = fitextra.nHitsMatched();
2197  fracHitsMatched_fit_FR_ = fitextra.fracHitsMatched();
2198  lastlyr_fit_FR_ = fittrack.getLastFoundHitLyr();
2199 
2200  // swim dphi
2201  dphi_fit_FR_ = fitextra.dPhi();
2202 
2203  // quality info
2204  hitchi2_fit_FR_ = fittrack.chi2(); // -10 when not used
2205  score_fit_FR_ = fittrack.score();
2206 
2207  if (Config::keepHitInfo)
2209  fittrack,
2213  hitxs_fit_FR_,
2214  hitys_fit_FR_,
2215  hitzs_fit_FR_);
2216 
2217  // sim info for fit track
2218  mcID_fit_FR_ = fitextra.mcTrackID();
2220 
2221  if (mcmask_fit_FR_ == 1) // fit track matched to seed and sim
2222  {
2223  const auto& simtrack = evt_sim_tracks[mcID_fit_FR_];
2224 
2225  const int mcHitID = TTreeValidation::getLastFoundHit(
2226  fittrack.getLastFoundMCHitID(evt_layer_hits), mcID_fit_FR_, ev); // only works for outward fit for now
2227  if (mcHitID >= 0 && Config::readSimTrackStates) {
2228  const TrackState& initLayTS = evt_sim_trackstates[mcHitID];
2229  pt_mc_fit_FR_ = initLayTS.pT();
2230  phi_mc_fit_FR_ = initLayTS.momPhi();
2231  eta_mc_fit_FR_ = initLayTS.momEta();
2232  helixchi2_fit_FR_ = computeHelixChi2(initLayTS.parameters, fittrack.parameters(), fittrack.errors());
2233 
2234  mcTSmask_fit_FR_ = 1;
2235  } else if (Config::tryToSaveSimInfo) {
2236  pt_mc_fit_FR_ = simtrack.pT();
2237  phi_mc_fit_FR_ = simtrack.momPhi();
2238  eta_mc_fit_FR_ = simtrack.momEta();
2239  helixchi2_fit_FR_ = computeHelixChi2(simtrack.parameters(), fittrack.parameters(), fittrack.errors());
2240 
2241  mcTSmask_fit_FR_ = 0;
2242  } else {
2243  pt_mc_fit_FR_ = -101;
2244  phi_mc_fit_FR_ = -101;
2245  eta_mc_fit_FR_ = -101;
2246  helixchi2_fit_FR_ = -101;
2247 
2248  mcTSmask_fit_FR_ = -2;
2249  }
2250 
2251  nHits_mc_fit_FR_ = simtrack.nFoundHits();
2252  nLayers_mc_fit_FR_ = simtrack.nUniqueLayers();
2253  lastlyr_mc_fit_FR_ = simtrack.getLastFoundHitLyr();
2254 
2255  duplmask_fit_FR_ = fitextra.isDuplicate();
2257  fitextra
2258  .duplicateID(); // ith duplicate fit track, i = 0 "best" match, i > 0 "still matched, real reco, not as good as i-1 track"
2259 
2260  if (Config::keepHitInfo)
2262  simtrack,
2269  } else // fit track matched only to seed not to sim
2270  {
2271  // -99 for all sim info for reco tracks not associated to reco tracks
2272  pt_mc_fit_FR_ = -99;
2273  phi_mc_fit_FR_ = -99;
2274  eta_mc_fit_FR_ = -99;
2275  helixchi2_fit_FR_ = -99;
2276 
2277  mcTSmask_fit_FR_ = -1;
2278 
2279  nHits_mc_fit_FR_ = -99;
2280  nLayers_mc_fit_FR_ = -99;
2281  lastlyr_mc_fit_FR_ = -99;
2282 
2283  duplmask_fit_FR_ = -1;
2284  iTkMatches_fit_FR_ = -99;
2285  } // matched seed to fit, not fit to sim
2286  }
2287 
2288  else // seed has no matching fit track (therefore no matching sim to fit track)
2289  {
2290  seedmask_fit_FR_ = 0; // quick logic
2291 
2292  // -3000 for position info if no fit track for seed
2293  xhit_fit_FR_ = -3000;
2294  yhit_fit_FR_ = -3000;
2295  zhit_fit_FR_ = -3000;
2296 
2297  // -100 for all reco info as no actual fit track for this seed
2298  pt_fit_FR_ = -100;
2299  ept_fit_FR_ = -100;
2300  phi_fit_FR_ = -100;
2301  ephi_fit_FR_ = -100;
2302  eta_fit_FR_ = -100;
2303  eeta_fit_FR_ = -100;
2304 
2305  nHits_fit_FR_ = -100;
2306  nLayers_fit_FR_ = -100;
2307  nHitsMatched_fit_FR_ = -100;
2308  fracHitsMatched_fit_FR_ = -100;
2309  lastlyr_fit_FR_ = -100;
2310 
2311  dphi_fit_FR_ = -100;
2312 
2313  hitchi2_fit_FR_ = -100;
2314  score_fit_FR_ = -5001;
2315 
2316  // keep -100 for all sim variables as no such reco exists for this seed
2317  mcmask_fit_FR_ = -2; // do not want to count towards fit FR
2318  mcID_fit_FR_ = -100;
2319 
2320  pt_mc_fit_FR_ = -100;
2321  phi_mc_fit_FR_ = -100;
2322  eta_mc_fit_FR_ = -100;
2323  helixchi2_fit_FR_ = -100;
2324 
2325  mcTSmask_fit_FR_ = -3;
2326 
2327  nHits_mc_fit_FR_ = -100;
2328  nLayers_mc_fit_FR_ = -100;
2329  lastlyr_mc_fit_FR_ = -100;
2330 
2331  duplmask_fit_FR_ = -2;
2332  iTkMatches_fit_FR_ = -100;
2333  }
2334 
2335  frtree_->Fill(); // fill once per seed!
2336  } // end of seed to seed loop
2337  }
2338 
2340  std::lock_guard<std::mutex> locker(glock_);
2341 
2344 
2346 
2347  nlayers_per_seed_ = Config::ItrInfo[0].m_params.nlayers_per_seed;
2348  maxCand_ = Config::ItrInfo[0].m_params.maxCandsPerSeed;
2349  chi2Cut_min_ = Config::ItrInfo[0].m_params.chi2Cut_min;
2355 
2359 
2362 
2367  varZ_ = Config::varZ;
2368 
2375 
2376  configtree_->Fill();
2377  }
2378 
2380  std::lock_guard<std::mutex> locker(glock_);
2381 
2382  const auto ievt = ev.evtID();
2383  const auto& evt_sim_tracks = ev.simTracks_;
2384  const auto& evt_cmssw_tracks = ev.cmsswTracks_;
2385  const auto& evt_cmssw_extras = ev.cmsswTracksExtra_;
2386  const auto& evt_build_tracks = ev.candidateTracks_;
2387  const auto& evt_build_extras = ev.candidateTracksExtra_;
2388  const auto& evt_fit_tracks = ev.fitTracks_;
2389  const auto& evt_fit_extras = ev.fitTracksExtra_;
2390  const auto& evt_layer_hits = ev.layerHits_;
2391 
2392  for (const auto& cmsswtrack : evt_cmssw_tracks) {
2393  // clear hit info
2394  if (Config::keepHitInfo) {
2395  hitlyrs_cmssw_ceff_.clear();
2396  hitlyrs_build_ceff_.clear();
2397  hitlyrs_mc_build_ceff_.clear();
2398  hitlyrs_fit_ceff_.clear();
2399  hitlyrs_mc_fit_ceff_.clear();
2400 
2401  hitidxs_cmssw_ceff_.clear();
2402  hitidxs_build_ceff_.clear();
2403  hitidxs_mc_build_ceff_.clear();
2404  hitidxs_fit_ceff_.clear();
2405  hitidxs_mc_fit_ceff_.clear();
2406  }
2407 
2408  const auto& cmsswextra = evt_cmssw_extras[cmsswtrack.label()];
2409 
2410  evtID_ceff_ = ievt;
2411  cmsswID_ceff_ = cmsswtrack.label();
2412  seedID_cmssw_ceff_ = cmsswextra.seedID();
2413 
2414  // PCA parameters
2415  x_cmssw_ceff_ = cmsswtrack.x();
2416  y_cmssw_ceff_ = cmsswtrack.y();
2417  z_cmssw_ceff_ = cmsswtrack.z();
2418 
2419  pt_cmssw_ceff_ = cmsswtrack.pT();
2420  phi_cmssw_ceff_ = cmsswtrack.momPhi();
2421  eta_cmssw_ceff_ = cmsswtrack.momEta();
2422 
2423  nHits_cmssw_ceff_ = cmsswtrack.nFoundHits();
2424  nLayers_cmssw_ceff_ = cmsswtrack.nUniqueLayers();
2425  lastlyr_cmssw_ceff_ = cmsswtrack.getLastFoundHitLyr();
2426 
2428  itermask_fit_ceff_ = 0;
2431  algo_seed_ceff_ = 0;
2432 
2433  for (auto aa : cmsswextra.seedAlgos())
2434  algo_seed_ceff_ = (algo_seed_ceff_ | (1 << aa));
2435 
2436  if (Config::keepHitInfo)
2438 
2439  // matched build track
2440  if (cmsswToBuildMap_.count(cmsswID_ceff_) &&
2441  cmsswtrack
2442  .isFindable()) // recoToCmssw match : save best match with best score i.e. cmsswToBuildMap_[matched CmsswID][first element in vector]
2443  {
2444  for (unsigned int ii = 0; ii < cmsswToBuildMap_[cmsswID_ceff_].size(); ii++) {
2445  const int theAlgo = evt_build_tracks[cmsswToBuildMap_[cmsswID_ceff_][ii]].algoint();
2446  if ((itermask_build_ceff_ >> theAlgo) & 1)
2447  iterduplmask_build_ceff_ = (iterduplmask_build_ceff_ | (1 << theAlgo)); //filled at the second time
2448  itermask_build_ceff_ = (itermask_build_ceff_ | (1 << theAlgo));
2449  }
2450 
2451  const auto& buildtrack =
2452  evt_build_tracks[cmsswToBuildMap_[cmsswID_ceff_][0]]; // returns buildTrack best matched to cmssw track
2453  const auto& buildextra =
2454  evt_build_extras[buildtrack.label()]; // returns track extra best aligned with build track
2455  cmsswmask_build_ceff_ = 1; // quick logic for matched
2456 
2457  seedID_build_ceff_ = buildextra.seedID();
2458  mcTrackID_build_ceff_ = buildextra.mcTrackID();
2459 
2460  // track parameters
2461  pt_build_ceff_ = buildtrack.pT();
2462  ept_build_ceff_ = buildtrack.epT();
2463  phi_build_ceff_ = buildtrack.momPhi();
2464  ephi_build_ceff_ = buildtrack.emomPhi();
2465  eta_build_ceff_ = buildtrack.momEta();
2466  eeta_build_ceff_ = buildtrack.emomEta();
2467 
2468  // gen info
2469  if (mcTrackID_build_ceff_ >= 0) {
2470  const auto& simtrack = evt_sim_tracks[mcTrackID_build_ceff_];
2471  x_mc_build_ceff_ = simtrack.x();
2472  y_mc_build_ceff_ = simtrack.y();
2473  z_mc_build_ceff_ = simtrack.z();
2474  pt_mc_build_ceff_ = simtrack.pT();
2475  phi_mc_build_ceff_ = simtrack.momPhi();
2476  eta_mc_build_ceff_ = simtrack.momEta();
2477 
2478  if (Config::keepHitInfo)
2480  } else {
2481  x_mc_build_ceff_ = -1000;
2482  y_mc_build_ceff_ = -1000;
2483  z_mc_build_ceff_ = -1000;
2484  pt_mc_build_ceff_ = -99;
2485  phi_mc_build_ceff_ = -99;
2486  eta_mc_build_ceff_ = -99;
2487  }
2488 
2489  // hit/layer info
2490  nHits_build_ceff_ = buildtrack.nFoundHits();
2491  nLayers_build_ceff_ = buildtrack.nUniqueLayers();
2492  nHitsMatched_build_ceff_ = buildextra.nHitsMatched();
2493  fracHitsMatched_build_ceff_ = buildextra.fracHitsMatched();
2494  lastlyr_build_ceff_ = buildtrack.getLastFoundHitLyr();
2495 
2496  // hit info
2497  const Hit& lasthit = evt_layer_hits[buildtrack.getLastFoundHitLyr()][buildtrack.getLastFoundHitIdx()];
2498  xhit_build_ceff_ = lasthit.x();
2499  yhit_build_ceff_ = lasthit.y();
2500  zhit_build_ceff_ = lasthit.z();
2501 
2502  // quality info
2503  hitchi2_build_ceff_ = buildtrack.chi2();
2504  helixchi2_build_ceff_ = buildextra.helixChi2();
2505  score_build_ceff_ = buildtrack.score();
2506 
2507  // swim dphi
2508  dphi_build_ceff_ = buildextra.dPhi();
2509 
2510  // duplicate info
2511  duplmask_build_ceff_ = buildextra.isDuplicate();
2512  nTkMatches_build_ceff_ = cmsswToBuildMap_[cmsswID_ceff_].size(); // n reco matches to this cmssw track.
2513 
2514  if (Config::keepHitInfo)
2516  } else // unmatched cmsswtracks ... put -99 for all reco values to denote unmatched
2517  {
2518  cmsswmask_build_ceff_ = (cmsswtrack.isFindable() ? 0 : -1); // quick logic for not matched
2519 
2520  seedID_build_ceff_ = -99;
2521  mcTrackID_build_ceff_ = -99;
2522 
2523  pt_build_ceff_ = -99;
2524  ept_build_ceff_ = -99;
2525  phi_build_ceff_ = -99;
2526  ephi_build_ceff_ = -99;
2527  eta_build_ceff_ = -99;
2528  eeta_build_ceff_ = -99;
2529 
2530  x_mc_build_ceff_ = -2000;
2531  y_mc_build_ceff_ = -2000;
2532  z_mc_build_ceff_ = -2000;
2533  pt_mc_build_ceff_ = -99;
2534  phi_mc_build_ceff_ = -99;
2535  eta_mc_build_ceff_ = -99;
2536 
2537  nHits_build_ceff_ = -99;
2538  nLayers_build_ceff_ = -99;
2541  lastlyr_build_ceff_ = -99;
2542 
2543  xhit_build_ceff_ = -2000;
2544  yhit_build_ceff_ = -2000;
2545  zhit_build_ceff_ = -2000;
2546 
2547  hitchi2_build_ceff_ = -99;
2548  helixchi2_build_ceff_ = -99;
2549  score_build_ceff_ = -17000;
2550 
2551  dphi_build_ceff_ = -99;
2552 
2553  duplmask_build_ceff_ = -1; // mask means unmatched cmssw track
2554  nTkMatches_build_ceff_ = -99; // unmatched
2555  }
2556 
2557  // matched fit track
2558  if (cmsswToFitMap_.count(cmsswID_ceff_) &&
2559  cmsswtrack
2560  .isFindable()) // recoToCmssw match : save best match with best score i.e. cmsswToFitMap_[matched CmsswID][first element in vector]
2561  {
2562  for (unsigned int ii = 0; ii < cmsswToFitMap_[cmsswID_ceff_].size(); ii++) {
2563  const int theAlgo = evt_build_tracks[cmsswToFitMap_[cmsswID_ceff_][ii]].algoint();
2564  if ((itermask_fit_ceff_ >> theAlgo) & 1)
2565  iterduplmask_fit_ceff_ = (iterduplmask_fit_ceff_ | (1 << theAlgo)); //filled at the second time
2566  itermask_fit_ceff_ = (itermask_fit_ceff_ | (1 << theAlgo));
2567  }
2568 
2569  const auto& fittrack =
2570  evt_fit_tracks[cmsswToFitMap_[cmsswID_ceff_][0]]; // returns fitTrack best matched to cmssw track
2571  const auto& fitextra = evt_fit_extras[fittrack.label()]; // returns track extra best aligned with fit track
2572  cmsswmask_fit_ceff_ = 1; // quick logic for matched
2573 
2574  seedID_fit_ceff_ = fitextra.seedID();
2575  mcTrackID_fit_ceff_ = fitextra.mcTrackID();
2576 
2577  // track parameters
2578  pt_fit_ceff_ = fittrack.pT();
2579  ept_fit_ceff_ = fittrack.epT();
2580  phi_fit_ceff_ = fittrack.momPhi();
2581  ephi_fit_ceff_ = fittrack.emomPhi();
2582  eta_fit_ceff_ = fittrack.momEta();
2583  eeta_fit_ceff_ = fittrack.emomEta();
2584 
2585  // gen info
2586  if (mcTrackID_fit_ceff_ >= 0) {
2587  const auto& simtrack = evt_sim_tracks[mcTrackID_fit_ceff_];
2588  x_mc_fit_ceff_ = simtrack.x();
2589  y_mc_fit_ceff_ = simtrack.y();
2590  z_mc_fit_ceff_ = simtrack.z();
2591  pt_mc_fit_ceff_ = simtrack.pT();
2592  phi_mc_fit_ceff_ = simtrack.momPhi();
2593  eta_mc_fit_ceff_ = simtrack.momEta();
2594 
2595  if (Config::keepHitInfo)
2597  } else {
2598  x_mc_fit_ceff_ = -1000;
2599  y_mc_fit_ceff_ = -1000;
2600  z_mc_fit_ceff_ = -1000;
2601  pt_mc_fit_ceff_ = -99;
2602  phi_mc_fit_ceff_ = -99;
2603  eta_mc_fit_ceff_ = -99;
2604  }
2605 
2606  // hit/layer info
2607  nHits_fit_ceff_ = fittrack.nFoundHits();
2608  nLayers_fit_ceff_ = fittrack.nUniqueLayers();
2609  nHitsMatched_fit_ceff_ = fitextra.nHitsMatched();
2610  fracHitsMatched_fit_ceff_ = fitextra.fracHitsMatched();
2611  lastlyr_fit_ceff_ = fittrack.getLastFoundHitLyr();
2612 
2613  // hit info
2614  const Hit& lasthit = evt_layer_hits[fittrack.getLastFoundHitLyr()][fittrack.getLastFoundHitIdx()];
2615  xhit_fit_ceff_ = lasthit.x();
2616  yhit_fit_ceff_ = lasthit.y();
2617  zhit_fit_ceff_ = lasthit.z();
2618 
2619  // quality info
2620  hitchi2_fit_ceff_ = fittrack.chi2();
2621  helixchi2_fit_ceff_ = fitextra.helixChi2();
2622  score_fit_ceff_ = fittrack.score();
2623 
2624  // swim dphi
2625  dphi_fit_ceff_ = fitextra.dPhi();
2626 
2627  // duplicate info
2628  duplmask_fit_ceff_ = fitextra.isDuplicate();
2629  nTkMatches_fit_ceff_ = cmsswToFitMap_[cmsswID_ceff_].size(); // n reco matches to this cmssw track.
2630 
2631  if (Config::keepHitInfo)
2633  } else // unmatched cmsswtracks ... put -99 for all reco values to denote unmatched
2634  {
2635  cmsswmask_fit_ceff_ = (cmsswtrack.isFindable() ? 0 : -1); // quick logic for not matched
2636 
2637  seedID_fit_ceff_ = -99;
2638  mcTrackID_fit_ceff_ = -99;
2639 
2640  pt_fit_ceff_ = -99;
2641  ept_fit_ceff_ = -99;
2642  phi_fit_ceff_ = -99;
2643  ephi_fit_ceff_ = -99;
2644  eta_fit_ceff_ = -99;
2645  eeta_fit_ceff_ = -99;
2646 
2647  x_mc_fit_ceff_ = -2000;
2648  y_mc_fit_ceff_ = -2000;
2649  z_mc_fit_ceff_ = -2000;
2650  pt_mc_fit_ceff_ = -99;
2651  phi_mc_fit_ceff_ = -99;
2652  eta_mc_fit_ceff_ = -99;
2653 
2654  nHits_fit_ceff_ = -99;
2655  nLayers_fit_ceff_ = -99;
2656  nHitsMatched_fit_ceff_ = -99;
2658  lastlyr_fit_ceff_ = -99;
2659 
2660  xhit_fit_ceff_ = -2000;
2661  yhit_fit_ceff_ = -2000;
2662  zhit_fit_ceff_ = -2000;
2663 
2664  hitchi2_fit_ceff_ = -99;
2665  helixchi2_fit_ceff_ = -99;
2666  score_fit_ceff_ = -17000;
2667 
2668  dphi_fit_ceff_ = -99;
2669 
2670  duplmask_fit_ceff_ = -1; // mask means unmatched cmssw track
2671  nTkMatches_fit_ceff_ = -99; // unmatched
2672  }
2673 
2674  cmsswefftree_->Fill();
2675  }
2676  }
2677 
2679  std::lock_guard<std::mutex> locker(glock_);
2680 
2681  auto ievt = ev.evtID();
2682  const auto& evt_sim_tracks = ev.simTracks_;
2683  const auto& evt_cmssw_tracks = ev.cmsswTracks_;
2684  const auto& evt_cmssw_extras = ev.cmsswTracksExtra_;
2685  const auto& evt_build_tracks = ev.candidateTracks_;
2686  const auto& evt_build_extras = ev.candidateTracksExtra_;
2687  const auto& evt_fit_tracks = ev.fitTracks_;
2688  const auto& evt_fit_extras = ev.fitTracksExtra_;
2689  const auto& evt_layer_hits = ev.layerHits_;
2690 
2691  for (const auto& buildtrack : evt_build_tracks) {
2692  if (Config::keepHitInfo) {
2693  hitlyrs_mc_cFR_.clear();
2694  hitlyrs_build_cFR_.clear();
2695  hitlyrs_cmssw_build_cFR_.clear();
2696  hitlyrs_fit_cFR_.clear();
2697  hitlyrs_cmssw_fit_cFR_.clear();
2698 
2699  hitidxs_mc_cFR_.clear();
2700  hitidxs_build_cFR_.clear();
2701  hitidxs_cmssw_build_cFR_.clear();
2702  hitidxs_fit_cFR_.clear();
2703  hitidxs_cmssw_fit_cFR_.clear();
2704  }
2705 
2706  algorithm_cFR_ = buildtrack.algoint();
2707 
2708  const auto& buildextra = evt_build_extras[buildtrack.label()];
2709 
2710  // same for fit and build tracks
2711  evtID_cFR_ = ievt;
2712  seedID_cFR_ = buildextra.seedID();
2713  mcTrackID_cFR_ = buildextra.mcTrackID();
2714 
2715  // track parameters
2716  pt_build_cFR_ = buildtrack.pT();
2717  ept_build_cFR_ = buildtrack.epT();
2718  phi_build_cFR_ = buildtrack.momPhi();
2719  ephi_build_cFR_ = buildtrack.emomPhi();
2720  eta_build_cFR_ = buildtrack.momEta();
2721  eeta_build_cFR_ = buildtrack.emomEta();
2722 
2723  // gen info
2724  if (mcTrackID_cFR_ >= 0) {
2725  const auto& simtrack = evt_sim_tracks[mcTrackID_cFR_];
2726  x_mc_cFR_ = simtrack.x();
2727  y_mc_cFR_ = simtrack.y();
2728  z_mc_cFR_ = simtrack.z();
2729  pt_mc_cFR_ = simtrack.pT();
2730  phi_mc_cFR_ = simtrack.momPhi();
2731  eta_mc_cFR_ = simtrack.momEta();
2732 
2733  if (Config::keepHitInfo)
2735  } else {
2736  x_mc_cFR_ = -1000;
2737  y_mc_cFR_ = -1000;
2738  z_mc_cFR_ = -1000;
2739  pt_mc_cFR_ = -99;
2740  phi_mc_cFR_ = -99;
2741  eta_mc_cFR_ = -99;
2742  }
2743 
2744  // hit/layer info
2745  nHits_build_cFR_ = buildtrack.nFoundHits();
2746  nLayers_build_cFR_ = buildtrack.nUniqueLayers();
2747  nHitsMatched_build_cFR_ = buildextra.nHitsMatched();
2748  fracHitsMatched_build_cFR_ = buildextra.fracHitsMatched();
2749  lastlyr_build_cFR_ = buildtrack.getLastFoundHitLyr();
2750 
2751  // hit info
2752  const Hit& lasthit = evt_layer_hits[buildtrack.getLastFoundHitLyr()][buildtrack.getLastFoundHitIdx()];
2753  xhit_build_cFR_ = lasthit.x();
2754  yhit_build_cFR_ = lasthit.y();
2755  zhit_build_cFR_ = lasthit.z();
2756 
2757  // quality info
2758  hitchi2_build_cFR_ = buildtrack.chi2();
2759  helixchi2_build_cFR_ = buildextra.helixChi2();
2760  score_build_cFR_ = buildtrack.score();
2761 
2762  // stored dphi
2763  dphi_build_cFR_ = buildextra.dPhi();
2764 
2765  if (Config::keepHitInfo)
2767 
2768  // cmssw match?
2769  cmsswID_build_cFR_ = buildextra.cmsswTrackID();
2771 
2772  if (cmsswmask_build_cFR_ == 1) // matched track to cmssw
2773  {
2774  const auto& cmsswtrack = evt_cmssw_tracks[cmsswID_build_cFR_];
2775  const auto& cmsswextra = evt_cmssw_extras[cmsswtrack.label()];
2776 
2777  seedID_cmssw_build_cFR_ = cmsswextra.seedID();
2778 
2779  x_cmssw_build_cFR_ = cmsswtrack.x();
2780  y_cmssw_build_cFR_ = cmsswtrack.y();
2781  z_cmssw_build_cFR_ = cmsswtrack.z();
2782 
2783  pt_cmssw_build_cFR_ = cmsswtrack.pT();
2784  phi_cmssw_build_cFR_ = cmsswtrack.momPhi();
2785  eta_cmssw_build_cFR_ = cmsswtrack.momEta();
2786 
2787  nHits_cmssw_build_cFR_ = cmsswtrack.nFoundHits();
2788  nLayers_cmssw_build_cFR_ = cmsswtrack.nUniqueLayers();
2789  lastlyr_cmssw_build_cFR_ = cmsswtrack.getLastFoundHitLyr();
2790 
2791  // duplicate info
2792  duplmask_build_cFR_ = buildextra.isDuplicate();
2793  iTkMatches_build_cFR_ = buildextra.duplicateID();
2794 
2795  if (Config::keepHitInfo)
2797  } else // unmatched cmsswtracks ... put -99 for all reco values to denote unmatched
2798  {
2800 
2801  x_cmssw_build_cFR_ = -2000;
2802  y_cmssw_build_cFR_ = -2000;
2803  z_cmssw_build_cFR_ = -2000;
2804 
2805  pt_cmssw_build_cFR_ = -99;
2806  phi_cmssw_build_cFR_ = -99;
2807  eta_cmssw_build_cFR_ = -99;
2808 
2809  nHits_cmssw_build_cFR_ = -99;
2812 
2813  duplmask_build_cFR_ = -1;
2814  iTkMatches_build_cFR_ = -99;
2815  }
2816 
2817  // ensure there is a fit track to mess with
2818  if (buildToFitMap_.count(buildtrack.label())) {
2819  const auto& fittrack = evt_fit_tracks[buildToFitMap_[buildtrack.label()]];
2820  const auto& fitextra = evt_fit_extras[fittrack.label()];
2821 
2822  // track parameters
2823  pt_fit_cFR_ = fittrack.pT();
2824  ept_fit_cFR_ = fittrack.epT();
2825  phi_fit_cFR_ = fittrack.momPhi();
2826  ephi_fit_cFR_ = fittrack.emomPhi();
2827  eta_fit_cFR_ = fittrack.momEta();
2828  eeta_fit_cFR_ = fittrack.emomEta();
2829 
2830  // hit/layer info
2831  nHits_fit_cFR_ = fittrack.nFoundHits();
2832  nLayers_fit_cFR_ = fittrack.nUniqueLayers();
2833  nHitsMatched_fit_cFR_ = fitextra.nHitsMatched();
2834  fracHitsMatched_fit_cFR_ = fitextra.fracHitsMatched();
2835  lastlyr_fit_cFR_ = fittrack.getLastFoundHitLyr();
2836 
2837  // hit info
2838  const Hit& lasthit = evt_layer_hits[fittrack.getLastFoundHitLyr()][fittrack.getLastFoundHitIdx()];
2839  xhit_fit_cFR_ = lasthit.x();
2840  yhit_fit_cFR_ = lasthit.y();
2841  zhit_fit_cFR_ = lasthit.z();
2842 
2843  // chi2 info
2844  hitchi2_fit_cFR_ = fittrack.chi2();
2845  helixchi2_fit_cFR_ = fitextra.helixChi2();
2846  score_fit_cFR_ = fittrack.score();
2847 
2848  // stored dphi
2849  dphi_fit_cFR_ = fitextra.dPhi();
2850 
2851  if (Config::keepHitInfo)
2853 
2854  // cmssw match?
2855  cmsswID_fit_cFR_ = fitextra.cmsswTrackID();
2857 
2858  if (cmsswmask_fit_cFR_ == 1) // matched track to cmssw
2859  {
2860  const auto& cmsswtrack = evt_cmssw_tracks[cmsswID_fit_cFR_];
2861  const auto& cmsswextra = evt_cmssw_extras[cmsswtrack.label()];
2862 
2863  seedID_cmssw_fit_cFR_ = cmsswextra.seedID();
2864 
2865  x_cmssw_fit_cFR_ = cmsswtrack.x();
2866  y_cmssw_fit_cFR_ = cmsswtrack.y();
2867  z_cmssw_fit_cFR_ = cmsswtrack.z();
2868 
2869  pt_cmssw_fit_cFR_ = cmsswtrack.pT();
2870  phi_cmssw_fit_cFR_ = cmsswtrack.momPhi();
2871  eta_cmssw_fit_cFR_ = cmsswtrack.momEta();
2872 
2873  nHits_cmssw_fit_cFR_ = cmsswtrack.nFoundHits();
2874  nLayers_cmssw_fit_cFR_ = cmsswtrack.nUniqueLayers();
2875  lastlyr_cmssw_fit_cFR_ = cmsswtrack.getLastFoundHitLyr();
2876 
2877  // duplicate info
2878  duplmask_fit_cFR_ = fitextra.isDuplicate();
2879  iTkMatches_fit_cFR_ = fitextra.duplicateID();
2880 
2881  if (Config::keepHitInfo)
2883  } else // unmatched cmsswtracks ... put -99 for all reco values to denote unmatched
2884  {
2885  seedID_cmssw_fit_cFR_ = -99;
2886 
2887  x_cmssw_fit_cFR_ = -2000;
2888  y_cmssw_fit_cFR_ = -2000;
2889  z_cmssw_fit_cFR_ = -2000;
2890 
2891  pt_cmssw_fit_cFR_ = -99;
2892  phi_cmssw_fit_cFR_ = -99;
2893  eta_cmssw_fit_cFR_ = -99;
2894 
2895  nHits_cmssw_fit_cFR_ = -99;
2896  nLayers_cmssw_fit_cFR_ = -99;
2897  lastlyr_cmssw_fit_cFR_ = -99;
2898 
2899  duplmask_fit_cFR_ = -1;
2900  iTkMatches_fit_cFR_ = -99;
2901  }
2902  } else // no fit track to match to a build track!
2903  {
2904  pt_fit_cFR_ = -100;
2905  ept_fit_cFR_ = -100;
2906  phi_fit_cFR_ = -100;
2907  ephi_fit_cFR_ = -100;
2908  eta_fit_cFR_ = -100;
2909  eeta_fit_cFR_ = -100;
2910 
2911  nHits_fit_cFR_ = -100;
2912  nLayers_fit_cFR_ = -100;
2913  nHitsMatched_fit_cFR_ = -100;
2914  fracHitsMatched_fit_cFR_ = -100;
2915  lastlyr_fit_cFR_ = -100;
2916 
2917  xhit_fit_cFR_ = -3000;
2918  yhit_fit_cFR_ = -3000;
2919  zhit_fit_cFR_ = -3000;
2920 
2921  hitchi2_fit_cFR_ = -100;
2922  helixchi2_fit_cFR_ = -100;
2923  score_fit_cFR_ = -5001;
2924  dphi_fit_cFR_ = -100;
2925 
2926  cmsswID_fit_cFR_ = -100;
2927  cmsswmask_fit_cFR_ = -2;
2928 
2929  seedID_cmssw_fit_cFR_ = -100;
2930 
2931  x_cmssw_fit_cFR_ = -3000;
2932  y_cmssw_fit_cFR_ = -3000;
2933  z_cmssw_fit_cFR_ = -3000;
2934 
2935  pt_cmssw_fit_cFR_ = -100;
2936  phi_cmssw_fit_cFR_ = -100;
2937  eta_cmssw_fit_cFR_ = -100;
2938 
2939  nHits_cmssw_fit_cFR_ = -100;
2940  nLayers_cmssw_fit_cFR_ = -100;
2941  lastlyr_cmssw_fit_cFR_ = -100;
2942 
2943  duplmask_fit_cFR_ = -2;
2944  iTkMatches_fit_cFR_ = -100;
2945  }
2946 
2947  cmsswfrtree_->Fill();
2948  }
2949  }
2950 
2952  std::lock_guard<std::mutex> locker(glock_);
2953  f_->cd();
2954 
2956  efftree_->SetDirectory(f_.get());
2957  efftree_->Write();
2958 
2959  frtree_->SetDirectory(f_.get());
2960  frtree_->Write();
2961  }
2962  if (Config::cmssw_val) {
2963  cmsswefftree_->SetDirectory(f_.get());
2964  cmsswefftree_->Write();
2965 
2966  cmsswfrtree_->SetDirectory(f_.get());
2967  cmsswfrtree_->Write();
2968  }
2969  if (Config::fit_val) {
2970  fittree_->SetDirectory(f_.get());
2971  fittree_->Write();
2972  }
2973 
2974  configtree_->SetDirectory(f_.get());
2975  configtree_->Write();
2976  }
2977 
2978 } // end namespace mkfit
2979 #endif
std::vector< int > hitlyrs_mc_seed_FR_
std::vector< int > hitidxs_build_ceff_
std::unique_ptr< TFile > f_
std::unique_ptr< TTree > cmsswfrtree_
std::vector< int > hitmcTkIDs_fit_FR_
float getScoreCand(const track_score_func &score_func, const Track &cand1, bool penalizeTailMissHits=false, bool inFindCandidates=false)
Definition: Track.h:608
TkIDToTkIDMap fitToSeedMapDumbCMSSW_
std::vector< float > & emeta_up_fit_
float x() const
Definition: Hit.h:162
void setTrackExtras(Event &ev) override
void fillFitTree(const Event &ev) override
std::vector< TrackExtra > TrackExtraVec
std::vector< int > hitidxs_mc_build_ceff_
TkIDToTkIDVecMap simToBuildMap_
std::vector< float > hitzs_mc_seed_FR_
std::vector< float > & ez_hit_fit_
float computeHelixChi2(const Vector &simV, const Vector &recoV, const Matrix &recoM, const bool diagOnly=false)
Definition: Track.h:645
constexpr float maxDPhi
void makeRecoTkToSeedTkMapsDumbCMSSW(Event &ev) override
std::vector< int > hitlyrs_build_cFR_
std::vector< int > hitmcTkIDs_mc_fit_FR_
TkIDToTkIDVecMap simToFitMap_
void makeCMSSWTkToSeedTkMap(Event &ev) override
void fillCMSSWFakeRateTree(const Event &ev) override
void makeSeedTkToCMSSWTkMap(Event &ev) override
std::vector< int > hitlyrs_fit_FR_
std::vector< float > hitzs_seed_eff_
std::vector< int > hitidxs_fit_cFR_
std::vector< int > hitmcTkIDs_mc_seed_FR_
constexpr float hitposerrXY
std::vector< int > hitidxs_cmssw_fit_cFR_
std::vector< int > hitidxs_build_FR_
int getMaskAssignment(const int refID)
std::vector< float > hitxs_mc_fit_FR_
std::vector< float > & ez_prop_fit_
TkIDToTkIDMap buildToCmsswMap_
std::vector< float > hitxs_fit_eff_
ROOT::Math::SVector< float, 2 > SVector2
Definition: MatrixSTypes.h:18
void setTrackScoresDumbCMSSW(Event &) override
std::vector< float > & mphi_up_fit_
void mapSeedTkToRecoTk(const TrackVec &evt_tracks, const TrackExtraVec &evt_extras, TkIDToTkIDMap &seedTkMap)
std::vector< int > hitlyrs_mc_cFR_
TkIDToTkIDVecMap cmsswToBuildMap_
std::vector< int > hitlyrs_build_eff_
void saveTTrees() override
static const int nfvs_
std::vector< float > & mphi_sim_fit_
TkIDToTkIDMap seedToCmsswMap_
TkIDToTkIDMap fitToBuildMap_
std::map< int, std::vector< int > > HitLayerMap
Definition: Track.h:18
constexpr float nSigma
void makeRecoTkToSeedTkMapDumbCMSSW(const TrackExtraVec &recoextras, const TrackExtraVec &seedextras, TkIDToTkIDMap &recoToSeedMap)
std::vector< int > hitmcTkIDs_mc_build_FR_
std::vector< int > hitidxs_mc_build_FR_
std::vector< float > & pphi_prop_fit_
std::vector< float > & meta_up_fit_
std::unordered_map< int, std::vector< int > > TkIDToTkIDVecMap
Definition: TrackExtra.h:125
constexpr float phierr012
std::vector< int > hitlyrs_seed_eff_
constexpr float minDPhi
std::vector< int > hitidxs_fit_ceff_
std::vector< float > & ept_up_fit_
void fillConfigTree() override
constexpr float thetaerr049
std::vector< float > hitys_build_eff_
std::vector< int > hitlyrs_cmssw_build_cFR_
std::vector< float > & emphi_sim_fit_
std::vector< int > hitlyrs_fit_cFR_
std::vector< int > hitidxs_seed_FR_
TkIDToTkIDMap seedToFitMap_
char const * label
constexpr int nLayers
Definition: Config.h:81
std::vector< int > hitidxs_fit_FR_
matchOpts cmsswMatchingFW
std::vector< float > & pphi_hit_fit_
std::vector< float > & pt_up_fit_
std::vector< float > & pphi_sim_fit_
std::vector< int > hitidxs_mc_eff_
std::vector< int > hitmcTkIDs_mc_eff_
std::unique_ptr< TTree > cmsswefftree_
matchOpts cmsswMatchingBK
void fillFakeRateTree(const Event &ev) override
std::vector< float > hitys_mc_fit_FR_
constexpr float varZ
std::vector< int > hitidxs_mc_cFR_
void setupCMSSWMatching(const Event &ev, RedTrackVec &reducedCMSSW, LayIdxIDVecMapMap &cmsswHitIDMap)
std::vector< int > hitlyrs_build_ceff_
std::vector< int > hitlyrs_build_FR_
std::vector< float > hitxs_build_eff_
std::vector< int > hitlyrs_fit_eff_
T sqrt(T t)
Definition: SSEVec.h:19
std::unordered_map< int, int > TkIDToTkIDMap
Definition: TrackExtra.h:124
std::unique_ptr< TTree > fittree_
std::vector< float > & ez_sim_fit_
std::unique_ptr< TTree > efftree_
constexpr float minDEta
int n_layers() const
Definition: TrackerInfo.h:161
std::vector< int > hitidxs_mc_fit_FR_
std::vector< int > hitidxs_cmssw_build_cFR_
ULong64_t iterduplmask_build_ceff_
std::vector< ReducedTrack > RedTrackVec
Definition: TrackExtra.h:35
std::vector< float > & z_sim_fit_
std::vector< float > hitzs_mc_build_FR_
std::vector< float > & emeta_sim_fit_
std::vector< int > hitmcTkIDs_fit_eff_
bool sortByScoreCand(const Track &cand1, const Track &cand2)
Definition: Track.h:598
void makeRecoTkToRecoTkMap(TkIDToTkIDMap &refToPairMap, const TrackVec &reftracks, const TrackExtraVec &refextras, const TrackVec &pairtracks, const TrackExtraVec &pairextras)
std::vector< float > hitxs_seed_FR_
constexpr float ptinverr049
constexpr float beamspotX
void fillCMSSWEfficiencyTree(const Event &ev) override
double f[11][100]
float momPhi() const
Definition: Track.h:100
constexpr float hitposerrR
TkIDToTkIDMap candToSeedMapDumbCMSSW_
std::vector< int > hitidxs_cmssw_ceff_
std::vector< float > hitys_mc_eff_
void makeCMSSWTkToRecoTksMaps(Event &ev) override
TkIDtoFitValLayMapMap fitValTkMapMap_
std::vector< int > hitlyrs_cmssw_fit_cFR_
IterationsInfo ItrInfo
constexpr float hitposerrZ
void mapRefTkToRecoTks(const TrackVec &evt_tracks, TrackExtraVec &evt_extras, TkIDToTkIDVecMap &refTkMap)
ii
Definition: cuy.py:589
std::vector< float > hitxs_build_FR_
TTreeValidation(std::string fileName, const TrackerInfo *trk_info)
std::vector< float > hitzs_seed_FR_
constexpr float thetaerr012
int getLastFoundHit(const int trackMCHitID, const int mcTrackID, const Event &ev)
std::vector< int > hitidxs_build_cFR_
std::vector< float > & meta_sim_fit_
std::vector< float > hitxs_fit_FR_
float y() const
Definition: Hit.h:163
std::vector< float > hitxs_mc_build_FR_
std::vector< float > & epphi_hit_fit_
std::vector< Track > TrackVec
std::vector< float > hitxs_seed_eff_
constexpr float beamspotY
static track_score_func get_track_scorer(const std::string &name)
std::vector< float > hitys_build_FR_
std::vector< float > & emphi_up_fit_
std::vector< float > hitys_seed_FR_
std::vector< float > hitzs_mc_eff_
TkIDToTkIDMap seedToBuildMap_
TkIDToTkIDVecMap simToSeedMap_
SVector6 parameters
Definition: Track.h:62
std::vector< float > hitzs_build_eff_
void fillEfficiencyTree(const Event &ev) override
constexpr float minSimPt
std::vector< int > hitmcTkIDs_seed_FR_
std::vector< float > & ept_sim_fit_
std::vector< float > fvs_[nfvs_]
std::vector< float > hitzs_fit_eff_
std::vector< float > hitzs_build_FR_
std::vector< float > hitzs_mc_fit_FR_
void fillFullHitInfo(const Event &ev, const Track &track, std::vector< int > &lyrs, std::vector< int > &idxs, std::vector< int > &mcTkIDs, std::vector< float > &xs, std::vector< float > &ys, std::vector< float > &zs)
std::vector< float > hitxs_mc_seed_FR_
void alignTracks(TrackVec &evt_tracks, TrackExtraVec &evt_extra, bool alignExtra) override
std::vector< float > & z_hit_fit_
std::vector< float > & epphi_prop_fit_
std::vector< int > hitidxs_build_eff_
std::vector< float > hitys_mc_build_FR_
float z() const
Definition: Hit.h:164
constexpr float varXY
std::vector< int > hitlyrs_mc_eff_
std::vector< int > hitlyrs_mc_fit_FR_
std::vector< int > hitmcTkIDs_build_eff_
constexpr float phierr049
std::vector< float > hitys_fit_eff_
std::vector< float > hitzs_fit_FR_
std::vector< float > hitxs_mc_eff_
void storeSeedAndMCID(Event &ev)
void makeRecoTkToRecoTkMaps(Event &ev) override
std::vector< int > hitlyrs_seed_FR_
std::vector< int > hitlyrs_cmssw_ceff_
std::vector< float > hitys_mc_seed_FR_
std::vector< int > hitlyrs_fit_ceff_
float momEta() const
Definition: Track.h:106
constexpr float beamspotZ
std::vector< int > hitlyrs_mc_fit_ceff_
std::vector< int > hitidxs_mc_fit_ceff_
TkIDToTkIDVecMap cmsswToFitMap_
constexpr float ptinverr012
std::vector< int > hitmcTkIDs_build_FR_
TkIDToTkIDMap cmsswToSeedMap_
std::vector< float > hitys_fit_FR_
std::map< int, std::map< int, std::vector< int > > > LayIdxIDVecMapMap
Definition: TrackExtra.h:37
constexpr float maxDEta
std::vector< int > hitmcTkIDs_seed_eff_
std::vector< int > hitlyrs_mc_build_ceff_
std::vector< float > hitys_seed_eff_
void makeSimTkToRecoTksMaps(Event &ev) override
std::unique_ptr< TTree > frtree_
std::vector< int > hitidxs_mc_seed_FR_
std::vector< float > & pt_sim_fit_
constexpr float maxSimPt
std::vector< float > & z_prop_fit_
void makeSeedTkToRecoTkMaps(Event &ev) override
void resetValidationMaps() override
void collectFitInfo(const FitVal &tmpfitval, int tkid, int layer) override
TkIDToTkIDMap buildToFitMap_
float pT() const
Definition: Track.h:102
std::vector< int > hitidxs_seed_eff_
void fillMinHitInfo(const Track &track, std::vector< int > &lyrs, std::vector< int > &idxs)
std::unique_ptr< TTree > configtree_
std::vector< float > & epphi_sim_fit_
std::vector< int > hitidxs_fit_eff_
def exit(msg="")
std::vector< int > hitlyrs_mc_build_FR_