CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
814  storeSeedAndMCID(ev);
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!)
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
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_);
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
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
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 
1071  // first compute score...
1072  for (auto& seedtrack : seedtracks) {
1073  seedtrack.setScore(getScoreCand(seedtrack));
1074  }
1075 
1076  // ...then use map to set seed type to for build/fit tracks and compute scores
1077  for (const auto& candToSeedPair : candToSeedMapDumbCMSSW_) {
1078  auto& candtrack = candtracks[candToSeedPair.first];
1079 
1080  candtrack.setScore(getScoreCand(candtrack));
1081  }
1082  for (const auto& fitToSeedPair : fitToSeedMapDumbCMSSW_) {
1083  auto& fittrack = fittracks[fitToSeedPair.first];
1084 
1085  fittrack.setScore(getScoreCand(fittrack));
1086  }
1087  }
1088 
1090  const auto& buildtracks = ev.candidateTracks_;
1091  auto& buildextras = ev.candidateTracksExtra_;
1092 
1093  const auto& fittracks = ev.fitTracks_;
1094  auto& fitextras = ev.fitTracksExtra_;
1095 
1096  const auto& cmsswtracks = ev.cmsswTracks_;
1097  auto& cmsswextras = ev.cmsswTracksExtra_;
1098 
1099  // first set candidate tracks, use as base for fittracks
1100  int newlabel = -1;
1101  for (int itrack = 0; itrack < (int)buildtracks.size(); itrack++) {
1102  auto& extra = buildextras[itrack];
1103  const int seedID = extra.seedID();
1104 
1105  extra.setmcTrackID(seedID);
1106 
1107  if (seedToCmsswMap_.count(seedID)) {
1108  extra.setseedID(seedToCmsswMap_[seedID]);
1110  for (int ctrack = 0; ctrack < (int)cmsswextras.size(); ctrack++) {
1111  if (cmsswextras[ctrack].seedID() == extra.seedID()) {
1112  buildToCmsswMap_[itrack] = cmsswtracks[ctrack].label(); // cmsstracks[ctrack].label() == ctrack!
1113  break;
1114  }
1115  }
1116  }
1117  } else {
1118  extra.setseedID(--newlabel);
1119  }
1120  }
1121 
1122  // set according to candidate tracks for fit tracks through map
1123  for (int itrack = 0; itrack < (int)fittracks.size(); itrack++) {
1124  auto& extra = fitextras[itrack];
1125 
1126  extra.setmcTrackID(buildextras[fitToBuildMap_[itrack]].mcTrackID());
1127  extra.setseedID(buildextras[fitToBuildMap_[itrack]].seedID());
1128  }
1129  }
1130 
1132  RedTrackVec& reducedCMSSW,
1133  LayIdxIDVecMapMap& cmsswHitIDMap) {
1134  // get the tracks + hits + extras
1135  const auto& layerhits = ev.layerHits_;
1136  const auto& cmsswtracks = ev.cmsswTracks_;
1137  auto& cmsswextras = ev.cmsswTracksExtra_;
1138  const auto& seedtracks = ev.seedTracks_;
1139 
1140  // resize accordingly
1141  reducedCMSSW.resize(cmsswtracks.size());
1142 
1143  for (int itrack = 0; itrack < (int)cmsswtracks.size(); itrack++) {
1144  // get the needed tracks and extras
1145  auto& cmsswextra = cmsswextras[itrack];
1146  const auto& cmsswtrack = cmsswtracks[itrack];
1147  const auto& seedtrack = seedtracks[cmsswToSeedMap_[cmsswtrack.label()]]; // since cmsswtrack.label() == itrack
1148 
1149  // set seed hits!
1150  cmsswextra.findMatchingSeedHits(cmsswtrack, seedtrack, layerhits);
1151 
1152  // get tmp vars
1153  const auto seedID = cmsswextra.seedID();
1154  const auto& params = cmsswtrack.parameters();
1155  SVector2 tmpv(params[3], params[5]);
1156 
1157  HitLayerMap tmpmap;
1158  for (int ihit = 0; ihit < cmsswtrack.nTotalHits(); ihit++) {
1159  const int lyr = cmsswtrack.getHitLyr(ihit);
1160  const int idx = cmsswtrack.getHitIdx(ihit);
1161 
1162  // don't bother with storing seed layers in reduced cmssw
1163  if (cmsswextra.isSeedHit(lyr, idx))
1164  continue;
1165 
1166  if (lyr >= 0 && idx >= 0) {
1167  tmpmap[lyr].push_back(idx);
1168  cmsswHitIDMap[lyr][idx].push_back(cmsswtrack.label());
1169  }
1170  }
1171 
1172  // index inside object is label (as cmsswtracks are now aligned)
1173  reducedCMSSW[itrack] = ReducedTrack(cmsswtrack.label(), seedID, tmpv, cmsswtrack.momPhi(), tmpmap);
1174  }
1175  }
1176 
1177  int TTreeValidation::getLastFoundHit(const int trackMCHitID, const int mcTrackID, const Event& ev) {
1178  int mcHitID = -1;
1179  if (ev.simHitsInfo_[trackMCHitID].mcTrackID() == mcTrackID) {
1180  mcHitID = trackMCHitID;
1181  } else {
1182  mcHitID = ev.simTracks_[mcTrackID].getMCHitIDFromLayer(ev.layerHits_, ev.simHitsInfo_[trackMCHitID].layer());
1183  }
1184  return mcHitID;
1185  }
1186 
1187  int TTreeValidation::getMaskAssignment(const int refID) {
1188  // initialize
1189  auto refmask = -99;
1190 
1191  if (refID >= 0) // seed track matched to seed and sim
1192  {
1193  refmask = 1; // matched track to sim
1194  } else if (refID == -10) {
1195  refmask = -2;
1196  } else {
1197  if (Config::inclusiveShorts) // only used by standard simval!
1198  {
1199  if (refID == -1 || refID == -5 || refID == -8 || refID == -9) {
1200  refmask = 0;
1201  } else if (refID == -2) {
1202  refmask = 2;
1203  } else // mcID == -3,-4,-6,-7
1204  {
1205  refmask = -1;
1206  }
1207  } else // only count long tracks (in mtvLike: all reco tracks are counted!)
1208  {
1209  if (refID == -1 || refID == -9) {
1210  refmask = 0;
1211  } else if (Config::mtvLikeValidation && refID == -4) {
1212  refmask = 2;
1213  } else // mcID == -2,-3,-4,-5,-6,-7,-8: standard simval
1214  {
1215  refmask = -1;
1216  }
1217  }
1218  } // end check over not matched
1219 
1220  return refmask;
1221  }
1222 
1224  for (int ilayer = 0; ilayer < ntotallayers_fit_; ++ilayer) {
1225  z_prop_fit_[ilayer] = -1000.f;
1226  ez_prop_fit_[ilayer] = -1000.f;
1227  z_hit_fit_[ilayer] = -1000.f;
1228  ez_hit_fit_[ilayer] = -1000.f;
1229  z_sim_fit_[ilayer] = -1000.f;
1230  ez_sim_fit_[ilayer] = -1000.f;
1231 
1232  pphi_prop_fit_[ilayer] = -1000.f;
1233  epphi_prop_fit_[ilayer] = -1000.f;
1234  pphi_hit_fit_[ilayer] = -1000.f;
1235  epphi_hit_fit_[ilayer] = -1000.f;
1236  pphi_sim_fit_[ilayer] = -1000.f;
1237  epphi_sim_fit_[ilayer] = -1000.f;
1238 
1239  pt_up_fit_[ilayer] = -1000.f;
1240  ept_up_fit_[ilayer] = -1000.f;
1241  pt_sim_fit_[ilayer] = -1000.f;
1242  ept_sim_fit_[ilayer] = -1000.f;
1243 
1244  mphi_up_fit_[ilayer] = -1000.f;
1245  emphi_up_fit_[ilayer] = -1000.f;
1246  mphi_sim_fit_[ilayer] = -1000.f;
1247  emphi_sim_fit_[ilayer] = -1000.f;
1248 
1249  meta_up_fit_[ilayer] = -1000.f;
1250  emeta_up_fit_[ilayer] = -1000.f;
1251  meta_sim_fit_[ilayer] = -1000.f;
1252  emeta_sim_fit_[ilayer] = -1000.f;
1253  }
1254  }
1255 
1257  std::lock_guard<std::mutex> locker(glock_);
1258 
1259  evtid_fit_ = ev.evtID();
1260  const auto& simtracks = ev.simTracks_;
1261  const auto& layerhits = ev.layerHits_;
1262  const auto& simtrackstates = ev.simTrackStates_;
1263 
1264  for (auto&& fitvalmapmap : fitValTkMapMap_) {
1266 
1267  tkid_fit_ = fitvalmapmap.first; // seed id (label) is the same as the mcID
1268 
1269  const auto& simtrack = simtracks[tkid_fit_];
1270  const auto& fitvalmap = fitvalmapmap.second;
1271  for (int ilayer = 0; ilayer < ntotallayers_fit_; ++ilayer) {
1272  if (fitvalmap.count(ilayer)) {
1273  const auto& hit = layerhits[ilayer][simtrack.getHitIdx(ilayer)];
1274  const auto& initTS = simtrackstates.at(hit.mcHitID());
1275  const auto& fitval = fitvalmap.at(ilayer);
1276 
1277  z_hit_fit_[ilayer] = hit.z();
1278  ez_hit_fit_[ilayer] = std::sqrt(hit.ezz());
1279  z_sim_fit_[ilayer] = initTS.z();
1280  ez_sim_fit_[ilayer] = initTS.ezz();
1281  z_prop_fit_[ilayer] = fitval.ppz;
1282  ez_prop_fit_[ilayer] = fitval.eppz;
1283 
1284  pphi_hit_fit_[ilayer] = hit.phi();
1285  epphi_hit_fit_[ilayer] = std::sqrt(hit.ephi());
1286  pphi_sim_fit_[ilayer] = initTS.posPhi();
1287  epphi_sim_fit_[ilayer] = initTS.eposPhi();
1288  pphi_prop_fit_[ilayer] = fitval.ppphi;
1289  epphi_prop_fit_[ilayer] = fitval.eppphi;
1290 
1291  pt_up_fit_[ilayer] = fitval.upt;
1292  ept_up_fit_[ilayer] = fitval.eupt;
1293  pt_sim_fit_[ilayer] = initTS.pT();
1294  ept_sim_fit_[ilayer] = initTS.epT();
1295 
1296  mphi_up_fit_[ilayer] = fitval.umphi;
1297  emphi_up_fit_[ilayer] = fitval.eumphi;
1298  mphi_sim_fit_[ilayer] = initTS.momPhi();
1299  emphi_sim_fit_[ilayer] = initTS.emomPhi();
1300 
1301  meta_up_fit_[ilayer] = fitval.umeta;
1302  emeta_up_fit_[ilayer] = fitval.eumeta;
1303  meta_sim_fit_[ilayer] = initTS.momEta();
1304  emeta_sim_fit_[ilayer] = initTS.emomEta();
1305  }
1306  }
1307  fittree_->Fill();
1308  }
1309  }
1310 
1312  const Track& track,
1313  std::vector<int>& lyrs,
1314  std::vector<int>& idxs,
1315  std::vector<int>& mcTkIDs,
1316  std::vector<float>& xs,
1317  std::vector<float>& ys,
1318  std::vector<float>& zs) {
1319  // get event info
1320  const auto& layerHits = ev.layerHits_;
1321  const auto& simHitsInfo = ev.simHitsInfo_;
1322 
1323  // resize vectors
1324  const auto nTotalHits = track.nTotalHits();
1325  lyrs.resize(nTotalHits);
1326  idxs.resize(nTotalHits);
1327  mcTkIDs.resize(nTotalHits, -99);
1328  xs.resize(nTotalHits, -9999.f);
1329  ys.resize(nTotalHits, -9999.f);
1330  zs.resize(nTotalHits, -9999.f);
1331 
1332  // loop over size of total hits
1333  for (auto ihit = 0; ihit < nTotalHits; ihit++) {
1334  const auto lyr = track.getHitLyr(ihit);
1335  const auto idx = track.getHitIdx(ihit);
1336 
1337  lyrs[ihit] = lyr;
1338  idxs[ihit] = idx;
1339 
1340  if (lyr < 0)
1341  continue;
1342  if (idx < 0)
1343  continue;
1344 
1345  const auto& hit = layerHits[lyr][idx];
1346  mcTkIDs[ihit] = hit.mcTrackID(simHitsInfo);
1347  xs[ihit] = hit.x();
1348  ys[ihit] = hit.y();
1349  zs[ihit] = hit.z();
1350  }
1351  }
1352 
1353  void TTreeValidation::fillMinHitInfo(const Track& track, std::vector<int>& lyrs, std::vector<int>& idxs) {
1354  for (int ihit = 0; ihit < track.nTotalHits(); ihit++) {
1355  lyrs.emplace_back(track.getHitLyr(ihit));
1356  idxs.emplace_back(track.getHitIdx(ihit));
1357  }
1358  }
1359 
1361  std::lock_guard<std::mutex> locker(glock_);
1362 
1363  const auto ievt = ev.evtID();
1364  const auto& evt_sim_tracks = ev.simTracks_;
1365  const auto& evt_seed_tracks = ev.seedTracks_;
1366  const auto& evt_seed_extras = ev.seedTracksExtra_;
1367  const auto& evt_build_tracks = ev.candidateTracks_;
1368  const auto& evt_build_extras = ev.candidateTracksExtra_;
1369  const auto& evt_fit_tracks = ev.fitTracks_;
1370  const auto& evt_fit_extras = ev.fitTracksExtra_;
1371  const auto& evt_layer_hits = ev.layerHits_;
1372  const auto& evt_sim_trackstates = ev.simTrackStates_;
1373 
1374  unsigned int count = 0;
1375  for (const auto& simtrack : evt_sim_tracks) {
1376  // clear the branches first
1377  if (Config::keepHitInfo) {
1378  hitlyrs_mc_eff_.clear();
1379  hitlyrs_seed_eff_.clear();
1380  hitlyrs_build_eff_.clear();
1381  hitlyrs_fit_eff_.clear();
1382 
1383  hitidxs_mc_eff_.clear();
1384  hitidxs_seed_eff_.clear();
1385  hitidxs_build_eff_.clear();
1386  hitidxs_fit_eff_.clear();
1387 
1388  hitmcTkIDs_mc_eff_.clear();
1389  hitmcTkIDs_seed_eff_.clear();
1390  hitmcTkIDs_build_eff_.clear();
1391  hitmcTkIDs_fit_eff_.clear();
1392 
1393  hitxs_mc_eff_.clear();
1394  hitxs_seed_eff_.clear();
1395  hitxs_build_eff_.clear();
1396  hitxs_fit_eff_.clear();
1397 
1398  hitys_mc_eff_.clear();
1399  hitys_seed_eff_.clear();
1400  hitys_build_eff_.clear();
1401  hitys_fit_eff_.clear();
1402 
1403  hitzs_mc_eff_.clear();
1404  hitzs_seed_eff_.clear();
1405  hitzs_build_eff_.clear();
1406  hitzs_fit_eff_.clear();
1407  }
1408 
1409  evtID_eff_ = ievt;
1410  mcID_eff_ = simtrack.label();
1411 
1412  // generated values
1413  x_mc_gen_eff_ = simtrack.x();
1414  y_mc_gen_eff_ = simtrack.y();
1415  z_mc_gen_eff_ = simtrack.z();
1416 
1417  pt_mc_gen_eff_ = simtrack.pT();
1418  phi_mc_gen_eff_ = simtrack.momPhi();
1419  eta_mc_gen_eff_ = simtrack.momEta();
1420  nHits_mc_eff_ = simtrack.nFoundHits(); // could be that the sim track skips layers!
1421  nLayers_mc_eff_ = simtrack.nUniqueLayers();
1422  lastlyr_mc_eff_ = simtrack.getLastFoundHitLyr();
1423 
1424  itermask_seed_eff_ = 0;
1425  itermask_build_eff_ = 0;
1426  itermask_fit_eff_ = 0;
1430  algo_seed_eff_ = 0;
1431 
1433  for (auto aa : ev.simTracksExtra_[count].seedAlgos()) {
1434  algo_seed_eff_ = (algo_seed_eff_ | (1 << aa));
1435  }
1436  }
1437  count++;
1438 
1439  // hit indices
1440  if (Config::keepHitInfo)
1442  simtrack,
1446  hitxs_mc_eff_,
1447  hitys_mc_eff_,
1448  hitzs_mc_eff_);
1449 
1450  // matched seed track
1451  if (simToSeedMap_.count(mcID_eff_) &&
1452  simtrack
1453  .isFindable()) // recoToSim match : save best match with best score, i.e. simToSeedMap_[matched SimID][first element in vector]
1454  {
1455  for (unsigned int ii = 0; ii < simToSeedMap_[mcID_eff_].size(); ii++) {
1456  const int theAlgo = evt_seed_tracks[simToSeedMap_[mcID_eff_][ii]].algoint();
1457  if ((itermask_seed_eff_ >> theAlgo) & 1)
1458  iterduplmask_seed_eff_ = (iterduplmask_seed_eff_ | (1 << theAlgo)); //filled at the second time
1459  itermask_seed_eff_ = (itermask_seed_eff_ | (1 << theAlgo));
1460  }
1461  const auto& seedtrack =
1462  evt_seed_tracks[simToSeedMap_[mcID_eff_][0]]; // returns seedTrack best matched to sim track
1463  const auto& seedextra = evt_seed_extras[seedtrack.label()]; // returns track extra best aligned with seed track
1464  mcmask_seed_eff_ = 1; // quick logic for matched
1465 
1466  seedID_seed_eff_ = seedextra.seedID();
1467 
1468  // use this to access correct sim track layer params
1469  const int mcHitID =
1470  TTreeValidation::getLastFoundHit(seedtrack.getLastFoundMCHitID(evt_layer_hits), mcID_eff_, ev);
1471  if (mcHitID >= 0 && Config::readSimTrackStates) {
1472  const TrackState& initLayTS = evt_sim_trackstates[mcHitID];
1473 
1474  pt_mc_seed_eff_ = initLayTS.pT();
1475  phi_mc_seed_eff_ = initLayTS.momPhi();
1476  eta_mc_seed_eff_ = initLayTS.momEta();
1477  helixchi2_seed_eff_ = computeHelixChi2(initLayTS.parameters, seedtrack.parameters(), seedtrack.errors());
1478 
1479  mcTSmask_seed_eff_ = 1;
1480  } 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
1481  {
1482  // reuse info already set
1486  helixchi2_seed_eff_ = computeHelixChi2(simtrack.parameters(), seedtrack.parameters(), seedtrack.errors());
1487 
1488  mcTSmask_seed_eff_ = 0;
1489  } else {
1490  pt_mc_seed_eff_ = -101;
1491  phi_mc_seed_eff_ = -101;
1492  eta_mc_seed_eff_ = -101;
1493  helixchi2_seed_eff_ = -101;
1494 
1495  mcTSmask_seed_eff_ = -2;
1496  }
1497 
1498  // last hit info
1499  const Hit& lasthit = evt_layer_hits[seedtrack.getLastFoundHitLyr()][seedtrack.getLastFoundHitIdx()];
1500  xhit_seed_eff_ = lasthit.x();
1501  yhit_seed_eff_ = lasthit.y();
1502  zhit_seed_eff_ = lasthit.z();
1503 
1504  pt_seed_eff_ = seedtrack.pT();
1505  ept_seed_eff_ = seedtrack.epT();
1506  phi_seed_eff_ = seedtrack.momPhi();
1507  ephi_seed_eff_ = seedtrack.emomPhi();
1508  eta_seed_eff_ = seedtrack.momEta();
1509  eeta_seed_eff_ = seedtrack.emomEta();
1510 
1511  // rest of mc info
1512  nHits_seed_eff_ = seedtrack.nFoundHits();
1513  nLayers_seed_eff_ = seedtrack.nUniqueLayers();
1514  nHitsMatched_seed_eff_ = seedextra.nHitsMatched();
1515  fracHitsMatched_seed_eff_ = seedextra.fracHitsMatched();
1516  lastlyr_seed_eff_ = seedtrack.getLastFoundHitLyr();
1517 
1518  // swim dphi
1519  dphi_seed_eff_ = seedextra.dPhi();
1520 
1521  // quality info
1522  hitchi2_seed_eff_ = seedtrack.chi2(); // currently not being used
1523  score_seed_eff_ = seedtrack.score(); // currently a constant by definition
1524 
1525  duplmask_seed_eff_ = seedextra.isDuplicate();
1526  nTkMatches_seed_eff_ = simToSeedMap_[mcID_eff_].size(); // n reco matches to this sim track.
1527 
1528  // hit indices
1529  if (Config::keepHitInfo)
1531  seedtrack,
1537  hitzs_seed_eff_);
1538  } else // unmatched simTracks ... put -99 for all reco values to denote unmatched
1539  {
1540  mcmask_seed_eff_ = (simtrack.isFindable() ? 0 : -1); // quick logic for not matched
1541 
1542  seedID_seed_eff_ = -99;
1543 
1544  pt_mc_seed_eff_ = -99;
1545  phi_mc_seed_eff_ = -99;
1546  eta_mc_seed_eff_ = -99;
1547  helixchi2_seed_eff_ = -99;
1548 
1549  mcTSmask_seed_eff_ = -1; // mask means unmatched sim track
1550 
1551  xhit_seed_eff_ = -2000;
1552  yhit_seed_eff_ = -2000;
1553  zhit_seed_eff_ = -2000;
1554 
1555  pt_seed_eff_ = -99;
1556  ept_seed_eff_ = -99;
1557  phi_seed_eff_ = -99;
1558  ephi_seed_eff_ = -99;
1559  eta_seed_eff_ = -99;
1560  eeta_seed_eff_ = -99;
1561 
1562  nHits_seed_eff_ = -99;
1563  nLayers_seed_eff_ = -99;
1564  nHitsMatched_seed_eff_ = -99;
1566  lastlyr_seed_eff_ = -99;
1567 
1568  dphi_seed_eff_ = -99;
1569 
1570  hitchi2_seed_eff_ = -99;
1571  score_seed_eff_ = -17000;
1572 
1573  duplmask_seed_eff_ = -1; // mask means unmatched sim track
1574  nTkMatches_seed_eff_ = -99; // unmatched
1575  }
1576 
1577  // matched build track
1578  if (simToBuildMap_.count(mcID_eff_) &&
1579  simtrack
1580  .isFindable()) // recoToSim match : save best match with best score i.e. simToBuildMap_[matched SimID][first element in vector]
1581  {
1582  for (unsigned int ii = 0; ii < simToBuildMap_[mcID_eff_].size(); ii++) {
1583  const int theAlgo = evt_build_tracks[simToBuildMap_[mcID_eff_][ii]].algoint();
1584  if ((itermask_build_eff_ >> theAlgo) & 1)
1585  iterduplmask_build_eff_ = (iterduplmask_build_eff_ | (1 << theAlgo)); //filled at the second time
1586  itermask_build_eff_ = (itermask_build_eff_ | (1 << theAlgo));
1587  }
1588  const auto& buildtrack =
1589  evt_build_tracks[simToBuildMap_[mcID_eff_][0]]; // returns buildTrack best matched to sim track
1590  const auto& buildextra =
1591  evt_build_extras[buildtrack.label()]; // returns track extra best aligned with build track
1592  mcmask_build_eff_ = 1; // quick logic for matched
1593 
1594  seedID_build_eff_ = buildextra.seedID();
1595 
1596  // use this to access correct sim track layer params
1597  const int mcHitID =
1598  TTreeValidation::getLastFoundHit(buildtrack.getLastFoundMCHitID(evt_layer_hits), mcID_eff_, ev);
1599  if (mcHitID >= 0 && Config::readSimTrackStates) {
1600  const TrackState& initLayTS = evt_sim_trackstates[mcHitID];
1601 
1602  pt_mc_build_eff_ = initLayTS.pT();
1603  phi_mc_build_eff_ = initLayTS.momPhi();
1604  eta_mc_build_eff_ = initLayTS.momEta();
1605  helixchi2_build_eff_ = computeHelixChi2(initLayTS.parameters, buildtrack.parameters(), buildtrack.errors());
1606 
1607  mcTSmask_build_eff_ = 1;
1608  } 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
1609  {
1610  // reuse info already set
1614  helixchi2_build_eff_ = computeHelixChi2(simtrack.parameters(), buildtrack.parameters(), buildtrack.errors());
1615 
1616  mcTSmask_build_eff_ = 0;
1617  } else {
1618  pt_mc_build_eff_ = -101;
1619  phi_mc_build_eff_ = -101;
1620  eta_mc_build_eff_ = -101;
1621  helixchi2_build_eff_ = -101;
1622 
1623  mcTSmask_build_eff_ = -2;
1624  }
1625 
1626  // last hit info
1627  const Hit& lasthit = evt_layer_hits[buildtrack.getLastFoundHitLyr()][buildtrack.getLastFoundHitIdx()];
1628  xhit_build_eff_ = lasthit.x();
1629  yhit_build_eff_ = lasthit.y();
1630  zhit_build_eff_ = lasthit.z();
1631 
1632  pt_build_eff_ = buildtrack.pT();
1633  ept_build_eff_ = buildtrack.epT();
1634  phi_build_eff_ = buildtrack.momPhi();
1635  ephi_build_eff_ = buildtrack.emomPhi();
1636  eta_build_eff_ = buildtrack.momEta();
1637  eeta_build_eff_ = buildtrack.emomEta();
1638 
1639  nHits_build_eff_ = buildtrack.nFoundHits();
1640  nLayers_build_eff_ = buildtrack.nUniqueLayers();
1641  nHitsMatched_build_eff_ = buildextra.nHitsMatched();
1642  fracHitsMatched_build_eff_ = buildextra.fracHitsMatched();
1643  lastlyr_build_eff_ = buildtrack.getLastFoundHitLyr();
1644 
1645  // swim dphi
1646  dphi_build_eff_ = buildextra.dPhi();
1647 
1648  // quality info
1649  hitchi2_build_eff_ = buildtrack.chi2();
1650  score_build_eff_ = buildtrack.score();
1651 
1652  duplmask_build_eff_ = buildextra.isDuplicate();
1653  nTkMatches_build_eff_ = simToBuildMap_[mcID_eff_].size(); // n reco matches to this sim track.
1654 
1655  // hit indices
1656  if (Config::keepHitInfo)
1658  buildtrack,
1665  } else // unmatched simTracks ... put -99 for all reco values to denote unmatched
1666  {
1667  mcmask_build_eff_ = (simtrack.isFindable() ? 0 : -1); // quick logic for not matched
1668 
1669  seedID_build_eff_ = -99;
1670 
1671  pt_mc_build_eff_ = -99;
1672  phi_mc_build_eff_ = -99;
1673  eta_mc_build_eff_ = -99;
1674  helixchi2_build_eff_ = -99;
1675 
1676  mcTSmask_build_eff_ = -1;
1677 
1678  xhit_build_eff_ = -2000;
1679  yhit_build_eff_ = -2000;
1680  zhit_build_eff_ = -2000;
1681 
1682  pt_build_eff_ = -99;
1683  ept_build_eff_ = -99;
1684  phi_build_eff_ = -99;
1685  ephi_build_eff_ = -99;
1686  eta_build_eff_ = -99;
1687  eeta_build_eff_ = -99;
1688 
1689  nHits_build_eff_ = -99;
1690  nLayers_build_eff_ = -99;
1693  lastlyr_build_eff_ = -99;
1694 
1695  dphi_build_eff_ = -99;
1696 
1697  hitchi2_build_eff_ = -99;
1698  score_build_eff_ = -17000;
1699 
1700  duplmask_build_eff_ = -1; // mask means unmatched sim track
1701  nTkMatches_build_eff_ = -99; // unmatched
1702  }
1703 
1704  // matched fit track
1705  if (simToFitMap_.count(mcID_eff_) &&
1706  simtrack
1707  .isFindable()) // recoToSim match : save best match with best score i.e. simToFitMap_[matched SimID][first element in vector]
1708  {
1709  for (unsigned int ii = 0; ii < simToFitMap_[mcID_eff_].size(); ii++) {
1710  const int theAlgo = evt_fit_tracks[simToFitMap_[mcID_eff_][ii]].algoint();
1711  if ((itermask_fit_eff_ >> theAlgo) & 1)
1712  iterduplmask_fit_eff_ = (iterduplmask_fit_eff_ | (1 << theAlgo)); //filled at the second time
1713  itermask_fit_eff_ = (itermask_fit_eff_ | (1 << theAlgo));
1714  }
1715  const auto& fittrack =
1716  evt_fit_tracks[simToFitMap_[mcID_eff_][0]]; // returns fitTrack best matched to sim track
1717  const auto& fitextra = evt_fit_extras[fittrack.label()]; // returns track extra best aligned with fit track
1718  mcmask_fit_eff_ = 1; // quick logic for matched
1719 
1720  seedID_fit_eff_ = fitextra.seedID();
1721 
1722  // use this to access correct sim track layer params
1723  const int mcHitID =
1724  TTreeValidation::getLastFoundHit(fittrack.getLastFoundMCHitID(evt_layer_hits), mcID_eff_, ev);
1725  if (mcHitID >= 0 && Config::readSimTrackStates) {
1726  const TrackState& initLayTS = evt_sim_trackstates[mcHitID];
1727 
1728  pt_mc_fit_eff_ = initLayTS.pT();
1729  phi_mc_fit_eff_ = initLayTS.momPhi();
1730  eta_mc_fit_eff_ = initLayTS.momEta();
1731  helixchi2_fit_eff_ = computeHelixChi2(initLayTS.parameters, fittrack.parameters(), fittrack.errors());
1732 
1733  mcTSmask_fit_eff_ = 1;
1734  } 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
1735  {
1736  // reuse info already set
1740  helixchi2_fit_eff_ = computeHelixChi2(simtrack.parameters(), fittrack.parameters(), fittrack.errors());
1741 
1742  mcTSmask_fit_eff_ = 0;
1743  } else {
1744  pt_mc_fit_eff_ = -101;
1745  phi_mc_fit_eff_ = -101;
1746  eta_mc_fit_eff_ = -101;
1747  helixchi2_fit_eff_ = -101;
1748 
1749  mcTSmask_fit_eff_ = -2;
1750  }
1751 
1752  // last hit info
1753  const Hit& lasthit = evt_layer_hits[fittrack.getLastFoundHitLyr()][fittrack.getLastFoundHitIdx()];
1754  xhit_fit_eff_ = lasthit.x();
1755  yhit_fit_eff_ = lasthit.y();
1756  zhit_fit_eff_ = lasthit.z();
1757 
1758  pt_fit_eff_ = fittrack.pT();
1759  ept_fit_eff_ = fittrack.epT();
1760  phi_fit_eff_ = fittrack.momPhi();
1761  ephi_fit_eff_ = fittrack.emomPhi();
1762  eta_fit_eff_ = fittrack.momEta();
1763  eeta_fit_eff_ = fittrack.emomEta();
1764 
1765  // rest of mc info
1766  nHits_fit_eff_ = fittrack.nFoundHits();
1767  nLayers_fit_eff_ = fittrack.nUniqueLayers();
1768  nHitsMatched_fit_eff_ = fitextra.nHitsMatched();
1769  fracHitsMatched_fit_eff_ = fitextra.fracHitsMatched();
1770  lastlyr_fit_eff_ = fittrack.getLastFoundHitLyr();
1771 
1772  // swim dphi
1773  dphi_fit_eff_ = fitextra.dPhi();
1774 
1775  // quality info
1776  hitchi2_fit_eff_ = fittrack.chi2(); // -10 when not used
1777  score_fit_eff_ = fittrack.score();
1778 
1779  duplmask_fit_eff_ = fitextra.isDuplicate();
1780  nTkMatches_fit_eff_ = simToFitMap_[mcID_eff_].size(); // n reco matches to this sim track.
1781 
1782  // hit indices
1783  if (Config::keepHitInfo)
1785  fittrack,
1791  hitzs_fit_eff_);
1792  } else // unmatched simTracks ... put -99 for all reco values to denote unmatched
1793  {
1794  mcmask_fit_eff_ = (simtrack.isFindable() ? 0 : -1); // quick logic for not matched
1795 
1796  seedID_fit_eff_ = -99;
1797 
1798  pt_mc_fit_eff_ = -99;
1799  phi_mc_fit_eff_ = -99;
1800  eta_mc_fit_eff_ = -99;
1801  helixchi2_fit_eff_ = -99;
1802 
1803  mcTSmask_fit_eff_ = -1;
1804 
1805  xhit_fit_eff_ = -2000;
1806  yhit_fit_eff_ = -2000;
1807  zhit_fit_eff_ = -2000;
1808 
1809  pt_fit_eff_ = -99;
1810  ept_fit_eff_ = -99;
1811  phi_fit_eff_ = -99;
1812  ephi_fit_eff_ = -99;
1813  eta_fit_eff_ = -99;
1814  eeta_fit_eff_ = -99;
1815 
1816  nHits_fit_eff_ = -99;
1817  nLayers_fit_eff_ = -99;
1818  nHitsMatched_fit_eff_ = -99;
1820  lastlyr_fit_eff_ = -99;
1821 
1822  dphi_fit_eff_ = -99;
1823 
1824  hitchi2_fit_eff_ = -99;
1825  score_fit_eff_ = -17000;
1826 
1827  duplmask_fit_eff_ = -1; // mask means unmatched sim track
1828  nTkMatches_fit_eff_ = -99; // unmatched
1829  }
1830 
1831  efftree_->Fill(); // fill it once per sim track!
1832  }
1833  }
1834 
1836  std::lock_guard<std::mutex> locker(glock_);
1837 
1838  const auto ievt = ev.evtID();
1839  const auto& evt_sim_tracks =
1840  ev.simTracks_; // store sim info at that final layer!!! --> gen info stored only in eff tree
1841  const auto& evt_seed_tracks = ev.seedTracks_;
1842  const auto& evt_seed_extras = ev.seedTracksExtra_;
1843  const auto& evt_build_tracks = ev.candidateTracks_;
1844  const auto& evt_build_extras = ev.candidateTracksExtra_;
1845  const auto& evt_fit_tracks = ev.fitTracks_;
1846  const auto& evt_fit_extras = ev.fitTracksExtra_;
1847  const auto& evt_layer_hits = ev.layerHits_;
1848  const auto& evt_sim_trackstates = ev.simTrackStates_;
1849 
1850  for (const auto& seedtrack : evt_seed_tracks) {
1851  if (Config::keepHitInfo) {
1852  hitlyrs_seed_FR_.clear();
1853  hitlyrs_mc_seed_FR_.clear();
1854  hitlyrs_build_FR_.clear();
1855  hitlyrs_mc_build_FR_.clear();
1856  hitlyrs_fit_FR_.clear();
1857  hitlyrs_mc_fit_FR_.clear();
1858 
1859  hitidxs_seed_FR_.clear();
1860  hitidxs_mc_seed_FR_.clear();
1861  hitidxs_build_FR_.clear();
1862  hitidxs_mc_build_FR_.clear();
1863  hitidxs_fit_FR_.clear();
1864  hitidxs_mc_fit_FR_.clear();
1865 
1866  hitmcTkIDs_seed_FR_.clear();
1867  hitmcTkIDs_mc_seed_FR_.clear();
1868  hitmcTkIDs_build_FR_.clear();
1869  hitmcTkIDs_mc_build_FR_.clear();
1870  hitmcTkIDs_fit_FR_.clear();
1871  hitmcTkIDs_mc_fit_FR_.clear();
1872 
1873  hitxs_seed_FR_.clear();
1874  hitxs_mc_seed_FR_.clear();
1875  hitxs_build_FR_.clear();
1876  hitxs_mc_build_FR_.clear();
1877  hitxs_fit_FR_.clear();
1878  hitxs_mc_fit_FR_.clear();
1879 
1880  hitys_seed_FR_.clear();
1881  hitys_mc_seed_FR_.clear();
1882  hitys_build_FR_.clear();
1883  hitys_mc_build_FR_.clear();
1884  hitys_fit_FR_.clear();
1885  hitys_mc_fit_FR_.clear();
1886 
1887  hitzs_seed_FR_.clear();
1888  hitzs_mc_seed_FR_.clear();
1889  hitzs_build_FR_.clear();
1890  hitzs_mc_build_FR_.clear();
1891  hitzs_fit_FR_.clear();
1892  hitzs_mc_fit_FR_.clear();
1893  }
1894 
1895  evtID_FR_ = ievt;
1896 
1897  // seed info
1898  const auto& seedextra = evt_seed_extras[seedtrack.label()];
1899  seedID_FR_ = seedextra.seedID();
1901  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.
1902 
1903  // last hit info
1904  // const Hit& lasthit = evt_layer_hits[seedtrack.getLastFoundHitLyr()][seedtrack.getLastFoundHitIdx()];
1905  xhit_seed_FR_ = 0; //lasthit.x();
1906  yhit_seed_FR_ = 0; //lasthit.y();
1907  zhit_seed_FR_ = 0; //lasthit.z();
1908 
1909  pt_seed_FR_ = seedtrack.pT();
1910  ept_seed_FR_ = seedtrack.epT();
1911  phi_seed_FR_ = seedtrack.momPhi();
1912  ephi_seed_FR_ = seedtrack.emomPhi();
1913  eta_seed_FR_ = seedtrack.momEta();
1914  eeta_seed_FR_ = seedtrack.emomEta();
1915 
1916  nHits_seed_FR_ = seedtrack.nFoundHits();
1917  nLayers_seed_FR_ = seedtrack.nUniqueLayers();
1918  nHitsMatched_seed_FR_ = seedextra.nHitsMatched();
1919  fracHitsMatched_seed_FR_ = seedextra.fracHitsMatched();
1920  lastlyr_seed_FR_ = seedtrack.getLastFoundHitLyr();
1921 
1922  algorithm_FR_ = seedtrack.algoint();
1923 
1924  // swim dphi
1925  dphi_seed_FR_ = seedextra.dPhi();
1926 
1927  // quality info
1928  hitchi2_seed_FR_ = seedtrack.chi2(); //--> not currently used
1929  score_seed_FR_ = seedtrack.score();
1930 
1931  if (Config::keepHitInfo)
1933  seedtrack,
1939  hitzs_seed_FR_);
1940 
1941  // sim info for seed track
1942  mcID_seed_FR_ = seedextra.mcTrackID();
1944 
1945  if (mcmask_seed_FR_ == 1) // matched track to sim
1946  {
1947  const auto& simtrack = evt_sim_tracks[mcID_seed_FR_];
1948 
1949  const int mcHitID =
1950  TTreeValidation::getLastFoundHit(seedtrack.getLastFoundMCHitID(evt_layer_hits), mcID_seed_FR_, ev);
1951  if (mcHitID >= 0 && Config::readSimTrackStates) {
1952  const TrackState& initLayTS = evt_sim_trackstates[mcHitID];
1953  pt_mc_seed_FR_ = initLayTS.pT();
1954  phi_mc_seed_FR_ = initLayTS.momPhi();
1955  eta_mc_seed_FR_ = initLayTS.momEta();
1956  helixchi2_seed_FR_ = computeHelixChi2(initLayTS.parameters, seedtrack.parameters(), seedtrack.errors());
1957 
1958  mcTSmask_seed_FR_ = 1;
1959  } else if (Config::tryToSaveSimInfo) {
1960  pt_mc_seed_FR_ = simtrack.pT();
1961  phi_mc_seed_FR_ = simtrack.momPhi();
1962  eta_mc_seed_FR_ = simtrack.momEta();
1963  helixchi2_seed_FR_ = computeHelixChi2(simtrack.parameters(), seedtrack.parameters(), seedtrack.errors());
1964 
1965  mcTSmask_seed_FR_ = 0;
1966  } else {
1967  pt_mc_seed_FR_ = -101;
1968  phi_mc_seed_FR_ = -101;
1969  eta_mc_seed_FR_ = -101;
1970  helixchi2_seed_FR_ = -101;
1971 
1972  mcTSmask_seed_FR_ = -2;
1973  }
1974 
1975  nHits_mc_seed_FR_ = simtrack.nFoundHits();
1976  nLayers_mc_seed_FR_ = simtrack.nUniqueLayers();
1977  lastlyr_mc_seed_FR_ = simtrack.getLastFoundHitLyr();
1978 
1979  duplmask_seed_FR_ = seedextra.isDuplicate();
1981  seedextra
1982  .duplicateID(); // ith duplicate seed track, i = 0 "best" match, i > 0 "still matched, real reco, not as good as i-1 track"
1983 
1984  if (Config::keepHitInfo)
1986  simtrack,
1993  } else {
1994  // -99 for all sim info for reco tracks not associated to reco tracks
1995  pt_mc_seed_FR_ = -99;
1996  phi_mc_seed_FR_ = -99;
1997  eta_mc_seed_FR_ = -99;
1998  helixchi2_seed_FR_ = -99;
1999 
2000  mcTSmask_seed_FR_ = -1;
2001 
2002  nHits_mc_seed_FR_ = -99;
2003  nLayers_mc_seed_FR_ = -99;
2004  lastlyr_mc_seed_FR_ = -99;
2005 
2006  duplmask_seed_FR_ = -1;
2007  iTkMatches_seed_FR_ = -99;
2008  }
2009 
2010  //==========================//
2011 
2012  // fill build information if track still alive
2013  if (seedToBuildMap_.count(seedID_FR_)) {
2014  seedmask_build_FR_ = 1; // quick logic
2015 
2016  const auto& buildtrack = evt_build_tracks[seedToBuildMap_[seedID_FR_]];
2017  const auto& buildextra = evt_build_extras[buildtrack.label()];
2018 
2019  // last hit info
2020  const Hit& lasthit = evt_layer_hits[buildtrack.getLastFoundHitLyr()][buildtrack.getLastFoundHitIdx()];
2021  xhit_build_FR_ = lasthit.x();
2022  yhit_build_FR_ = lasthit.y();
2023  zhit_build_FR_ = lasthit.z();
2024 
2025  pt_build_FR_ = buildtrack.pT();
2026  ept_build_FR_ = buildtrack.epT();
2027  phi_build_FR_ = buildtrack.momPhi();
2028  ephi_build_FR_ = buildtrack.emomPhi();
2029  eta_build_FR_ = buildtrack.momEta();
2030  eeta_build_FR_ = buildtrack.emomEta();
2031 
2032  nHits_build_FR_ = buildtrack.nFoundHits();
2033  nLayers_build_FR_ = buildtrack.nUniqueLayers();
2034  nHitsMatched_build_FR_ = buildextra.nHitsMatched();
2035  fracHitsMatched_build_FR_ = buildextra.fracHitsMatched();
2036  lastlyr_build_FR_ = buildtrack.getLastFoundHitLyr();
2037 
2038  // swim dphi
2039  dphi_build_FR_ = buildextra.dPhi();
2040 
2041  // quality info
2042  hitchi2_build_FR_ = buildtrack.chi2();
2043  score_build_FR_ = buildtrack.score();
2044 
2045  if (Config::keepHitInfo)
2047  buildtrack,
2053  hitzs_build_FR_);
2054 
2055  // sim info for build track
2056  mcID_build_FR_ = buildextra.mcTrackID();
2058 
2059  if (mcmask_build_FR_ == 1) // build track matched to seed and sim
2060  {
2061  const auto& simtrack = evt_sim_tracks[mcID_build_FR_];
2062 
2063  const int mcHitID =
2064  TTreeValidation::getLastFoundHit(buildtrack.getLastFoundMCHitID(evt_layer_hits), mcID_build_FR_, ev);
2065  if (mcHitID >= 0 && Config::readSimTrackStates) {
2066  const TrackState& initLayTS = evt_sim_trackstates[mcHitID];
2067  pt_mc_build_FR_ = initLayTS.pT();
2068  phi_mc_build_FR_ = initLayTS.momPhi();
2069  eta_mc_build_FR_ = initLayTS.momEta();
2070  helixchi2_build_FR_ = computeHelixChi2(initLayTS.parameters, buildtrack.parameters(), buildtrack.errors());
2071 
2072  mcTSmask_build_FR_ = 1;
2073  } else if (Config::tryToSaveSimInfo) {
2074  pt_mc_build_FR_ = simtrack.pT();
2075  phi_mc_build_FR_ = simtrack.momPhi();
2076  eta_mc_build_FR_ = simtrack.momEta();
2077  helixchi2_build_FR_ = computeHelixChi2(simtrack.parameters(), buildtrack.parameters(), buildtrack.errors());
2078 
2079  mcTSmask_build_FR_ = 0;
2080  } else {
2081  pt_mc_build_FR_ = -101;
2082  phi_mc_build_FR_ = -101;
2083  eta_mc_build_FR_ = -101;
2084  helixchi2_build_FR_ = -101;
2085 
2086  mcTSmask_build_FR_ = -2;
2087  }
2088 
2089  nHits_mc_build_FR_ = simtrack.nFoundHits();
2090  nLayers_mc_build_FR_ = simtrack.nUniqueLayers();
2091  lastlyr_mc_build_FR_ = simtrack.getLastFoundHitLyr();
2092 
2093  duplmask_build_FR_ = buildextra.isDuplicate();
2095  buildextra
2096  .duplicateID(); // ith duplicate build track, i = 0 "best" match, i > 0 "still matched, real reco, not as good as i-1 track"
2097 
2098  if (Config::keepHitInfo)
2100  simtrack,
2107  } else // build track matched only to seed not to sim
2108  {
2109  // -99 for all sim info for reco tracks not associated to reco tracks
2110  pt_mc_build_FR_ = -99;
2111  phi_mc_build_FR_ = -99;
2112  eta_mc_build_FR_ = -99;
2113  helixchi2_build_FR_ = -99;
2114 
2115  mcTSmask_build_FR_ = -1;
2116 
2117  nHits_mc_build_FR_ = -99;
2118  nLayers_mc_build_FR_ = -99;
2119  lastlyr_mc_build_FR_ = -99;
2120 
2121  duplmask_build_FR_ = -1;
2122  iTkMatches_build_FR_ = -99;
2123  } // matched seed to build, not build to sim
2124  }
2125 
2126  else // seed has no matching build track (therefore no matching sim to build track)
2127  {
2128  seedmask_build_FR_ = 0; // quick logic
2129 
2130  // -3000 for position info if no build track for seed
2131  xhit_build_FR_ = -3000;
2132  yhit_build_FR_ = -3000;
2133  zhit_build_FR_ = -3000;
2134 
2135  // -100 for all reco info as no actual build track for this seed
2136  pt_build_FR_ = -100;
2137  ept_build_FR_ = -100;
2138  phi_build_FR_ = -100;
2139  ephi_build_FR_ = -100;
2140  eta_build_FR_ = -100;
2141  eeta_build_FR_ = -100;
2142 
2143  nHits_build_FR_ = -100;
2144  nLayers_build_FR_ = -100;
2145  nHitsMatched_build_FR_ = -100;
2147  lastlyr_build_FR_ = -100;
2148 
2149  dphi_build_FR_ = -100;
2150 
2151  hitchi2_build_FR_ = -100;
2152  score_build_FR_ = -5001;
2153 
2154  // keep -100 for all sim variables as no such reco exists for this seed
2155  mcmask_build_FR_ = -2; // do not want to count towards build FR
2156  mcID_build_FR_ = -100;
2157 
2158  pt_mc_build_FR_ = -100;
2159  phi_mc_build_FR_ = -100;
2160  eta_mc_build_FR_ = -100;
2161  helixchi2_build_FR_ = -100;
2162 
2163  mcTSmask_build_FR_ = -3;
2164 
2165  nHits_mc_build_FR_ = -100;
2166  nLayers_mc_build_FR_ = -100;
2167  lastlyr_mc_build_FR_ = -100;
2168 
2169  duplmask_build_FR_ = -2;
2170  iTkMatches_build_FR_ = -100;
2171  }
2172 
2173  //============================// fit tracks
2174  if (seedToFitMap_.count(seedID_FR_)) {
2175  seedmask_fit_FR_ = 1; // quick logic
2176 
2177  const auto& fittrack = evt_fit_tracks[seedToFitMap_[seedID_FR_]];
2178  const auto& fitextra = evt_fit_extras[fittrack.label()];
2179 
2180  // last hit info
2181  const Hit& lasthit = evt_layer_hits[fittrack.getLastFoundHitLyr()][fittrack.getLastFoundHitIdx()];
2182  xhit_fit_FR_ = lasthit.x();
2183  yhit_fit_FR_ = lasthit.y();
2184  zhit_fit_FR_ = lasthit.z();
2185 
2186  pt_fit_FR_ = fittrack.pT();
2187  ept_fit_FR_ = fittrack.epT();
2188  phi_fit_FR_ = fittrack.momPhi();
2189  ephi_fit_FR_ = fittrack.emomPhi();
2190  eta_fit_FR_ = fittrack.momEta();
2191  eeta_fit_FR_ = fittrack.emomEta();
2192 
2193  nHits_fit_FR_ = fittrack.nFoundHits();
2194  nLayers_fit_FR_ = fittrack.nUniqueLayers();
2195  nHitsMatched_fit_FR_ = fitextra.nHitsMatched();
2196  fracHitsMatched_fit_FR_ = fitextra.fracHitsMatched();
2197  lastlyr_fit_FR_ = fittrack.getLastFoundHitLyr();
2198 
2199  // swim dphi
2200  dphi_fit_FR_ = fitextra.dPhi();
2201 
2202  // quality info
2203  hitchi2_fit_FR_ = fittrack.chi2(); // -10 when not used
2204  score_fit_FR_ = fittrack.score();
2205 
2206  if (Config::keepHitInfo)
2208  fittrack,
2212  hitxs_fit_FR_,
2213  hitys_fit_FR_,
2214  hitzs_fit_FR_);
2215 
2216  // sim info for fit track
2217  mcID_fit_FR_ = fitextra.mcTrackID();
2219 
2220  if (mcmask_fit_FR_ == 1) // fit track matched to seed and sim
2221  {
2222  const auto& simtrack = evt_sim_tracks[mcID_fit_FR_];
2223 
2224  const int mcHitID = TTreeValidation::getLastFoundHit(
2225  fittrack.getLastFoundMCHitID(evt_layer_hits), mcID_fit_FR_, ev); // only works for outward fit for now
2226  if (mcHitID >= 0 && Config::readSimTrackStates) {
2227  const TrackState& initLayTS = evt_sim_trackstates[mcHitID];
2228  pt_mc_fit_FR_ = initLayTS.pT();
2229  phi_mc_fit_FR_ = initLayTS.momPhi();
2230  eta_mc_fit_FR_ = initLayTS.momEta();
2231  helixchi2_fit_FR_ = computeHelixChi2(initLayTS.parameters, fittrack.parameters(), fittrack.errors());
2232 
2233  mcTSmask_fit_FR_ = 1;
2234  } else if (Config::tryToSaveSimInfo) {
2235  pt_mc_fit_FR_ = simtrack.pT();
2236  phi_mc_fit_FR_ = simtrack.momPhi();
2237  eta_mc_fit_FR_ = simtrack.momEta();
2238  helixchi2_fit_FR_ = computeHelixChi2(simtrack.parameters(), fittrack.parameters(), fittrack.errors());
2239 
2240  mcTSmask_fit_FR_ = 0;
2241  } else {
2242  pt_mc_fit_FR_ = -101;
2243  phi_mc_fit_FR_ = -101;
2244  eta_mc_fit_FR_ = -101;
2245  helixchi2_fit_FR_ = -101;
2246 
2247  mcTSmask_fit_FR_ = -2;
2248  }
2249 
2250  nHits_mc_fit_FR_ = simtrack.nFoundHits();
2251  nLayers_mc_fit_FR_ = simtrack.nUniqueLayers();
2252  lastlyr_mc_fit_FR_ = simtrack.getLastFoundHitLyr();
2253 
2254  duplmask_fit_FR_ = fitextra.isDuplicate();
2256  fitextra
2257  .duplicateID(); // ith duplicate fit track, i = 0 "best" match, i > 0 "still matched, real reco, not as good as i-1 track"
2258 
2259  if (Config::keepHitInfo)
2261  simtrack,
2268  } else // fit track matched only to seed not to sim
2269  {
2270  // -99 for all sim info for reco tracks not associated to reco tracks
2271  pt_mc_fit_FR_ = -99;
2272  phi_mc_fit_FR_ = -99;
2273  eta_mc_fit_FR_ = -99;
2274  helixchi2_fit_FR_ = -99;
2275 
2276  mcTSmask_fit_FR_ = -1;
2277 
2278  nHits_mc_fit_FR_ = -99;
2279  nLayers_mc_fit_FR_ = -99;
2280  lastlyr_mc_fit_FR_ = -99;
2281 
2282  duplmask_fit_FR_ = -1;
2283  iTkMatches_fit_FR_ = -99;
2284  } // matched seed to fit, not fit to sim
2285  }
2286 
2287  else // seed has no matching fit track (therefore no matching sim to fit track)
2288  {
2289  seedmask_fit_FR_ = 0; // quick logic
2290 
2291  // -3000 for position info if no fit track for seed
2292  xhit_fit_FR_ = -3000;
2293  yhit_fit_FR_ = -3000;
2294  zhit_fit_FR_ = -3000;
2295 
2296  // -100 for all reco info as no actual fit track for this seed
2297  pt_fit_FR_ = -100;
2298  ept_fit_FR_ = -100;
2299  phi_fit_FR_ = -100;
2300  ephi_fit_FR_ = -100;
2301  eta_fit_FR_ = -100;
2302  eeta_fit_FR_ = -100;
2303 
2304  nHits_fit_FR_ = -100;
2305  nLayers_fit_FR_ = -100;
2306  nHitsMatched_fit_FR_ = -100;
2307  fracHitsMatched_fit_FR_ = -100;
2308  lastlyr_fit_FR_ = -100;
2309 
2310  dphi_fit_FR_ = -100;
2311 
2312  hitchi2_fit_FR_ = -100;
2313  score_fit_FR_ = -5001;
2314 
2315  // keep -100 for all sim variables as no such reco exists for this seed
2316  mcmask_fit_FR_ = -2; // do not want to count towards fit FR
2317  mcID_fit_FR_ = -100;
2318 
2319  pt_mc_fit_FR_ = -100;
2320  phi_mc_fit_FR_ = -100;
2321  eta_mc_fit_FR_ = -100;
2322  helixchi2_fit_FR_ = -100;
2323 
2324  mcTSmask_fit_FR_ = -3;
2325 
2326  nHits_mc_fit_FR_ = -100;
2327  nLayers_mc_fit_FR_ = -100;
2328  lastlyr_mc_fit_FR_ = -100;
2329 
2330  duplmask_fit_FR_ = -2;
2331  iTkMatches_fit_FR_ = -100;
2332  }
2333 
2334  frtree_->Fill(); // fill once per seed!
2335  } // end of seed to seed loop
2336  }
2337 
2339  std::lock_guard<std::mutex> locker(glock_);
2340 
2343 
2345 
2346  nlayers_per_seed_ = Config::ItrInfo[0].m_params.nlayers_per_seed;
2347  maxCand_ = Config::ItrInfo[0].m_params.maxCandsPerSeed;
2348  chi2Cut_min_ = Config::ItrInfo[0].m_params.chi2Cut_min;
2354 
2358 
2361 
2366  varZ_ = Config::varZ;
2367 
2374 
2375  configtree_->Fill();
2376  }
2377 
2379  std::lock_guard<std::mutex> locker(glock_);
2380 
2381  const auto ievt = ev.evtID();
2382  const auto& evt_sim_tracks = ev.simTracks_;
2383  const auto& evt_cmssw_tracks = ev.cmsswTracks_;
2384  const auto& evt_cmssw_extras = ev.cmsswTracksExtra_;
2385  const auto& evt_build_tracks = ev.candidateTracks_;
2386  const auto& evt_build_extras = ev.candidateTracksExtra_;
2387  const auto& evt_fit_tracks = ev.fitTracks_;
2388  const auto& evt_fit_extras = ev.fitTracksExtra_;
2389  const auto& evt_layer_hits = ev.layerHits_;
2390 
2391  for (const auto& cmsswtrack : evt_cmssw_tracks) {
2392  // clear hit info
2393  if (Config::keepHitInfo) {
2394  hitlyrs_cmssw_ceff_.clear();
2395  hitlyrs_build_ceff_.clear();
2396  hitlyrs_mc_build_ceff_.clear();
2397  hitlyrs_fit_ceff_.clear();
2398  hitlyrs_mc_fit_ceff_.clear();
2399 
2400  hitidxs_cmssw_ceff_.clear();
2401  hitidxs_build_ceff_.clear();
2402  hitidxs_mc_build_ceff_.clear();
2403  hitidxs_fit_ceff_.clear();
2404  hitidxs_mc_fit_ceff_.clear();
2405  }
2406 
2407  const auto& cmsswextra = evt_cmssw_extras[cmsswtrack.label()];
2408 
2409  evtID_ceff_ = ievt;
2410  cmsswID_ceff_ = cmsswtrack.label();
2411  seedID_cmssw_ceff_ = cmsswextra.seedID();
2412 
2413  // PCA parameters
2414  x_cmssw_ceff_ = cmsswtrack.x();
2415  y_cmssw_ceff_ = cmsswtrack.y();
2416  z_cmssw_ceff_ = cmsswtrack.z();
2417 
2418  pt_cmssw_ceff_ = cmsswtrack.pT();
2419  phi_cmssw_ceff_ = cmsswtrack.momPhi();
2420  eta_cmssw_ceff_ = cmsswtrack.momEta();
2421 
2422  nHits_cmssw_ceff_ = cmsswtrack.nFoundHits();
2423  nLayers_cmssw_ceff_ = cmsswtrack.nUniqueLayers();
2424  lastlyr_cmssw_ceff_ = cmsswtrack.getLastFoundHitLyr();
2425 
2427  itermask_fit_ceff_ = 0;
2430  algo_seed_ceff_ = 0;
2431 
2432  for (auto aa : cmsswextra.seedAlgos())
2433  algo_seed_ceff_ = (algo_seed_ceff_ | (1 << aa));
2434 
2435  if (Config::keepHitInfo)
2437 
2438  // matched build track
2439  if (cmsswToBuildMap_.count(cmsswID_ceff_) &&
2440  cmsswtrack
2441  .isFindable()) // recoToCmssw match : save best match with best score i.e. cmsswToBuildMap_[matched CmsswID][first element in vector]
2442  {
2443  for (unsigned int ii = 0; ii < cmsswToBuildMap_[cmsswID_ceff_].size(); ii++) {
2444  const int theAlgo = evt_build_tracks[cmsswToBuildMap_[cmsswID_ceff_][ii]].algoint();
2445  if ((itermask_build_ceff_ >> theAlgo) & 1)
2446  iterduplmask_build_ceff_ = (iterduplmask_build_ceff_ | (1 << theAlgo)); //filled at the second time
2447  itermask_build_ceff_ = (itermask_build_ceff_ | (1 << theAlgo));
2448  }
2449 
2450  const auto& buildtrack =
2451  evt_build_tracks[cmsswToBuildMap_[cmsswID_ceff_][0]]; // returns buildTrack best matched to cmssw track
2452  const auto& buildextra =
2453  evt_build_extras[buildtrack.label()]; // returns track extra best aligned with build track
2454  cmsswmask_build_ceff_ = 1; // quick logic for matched
2455 
2456  seedID_build_ceff_ = buildextra.seedID();
2457  mcTrackID_build_ceff_ = buildextra.mcTrackID();
2458 
2459  // track parameters
2460  pt_build_ceff_ = buildtrack.pT();
2461  ept_build_ceff_ = buildtrack.epT();
2462  phi_build_ceff_ = buildtrack.momPhi();
2463  ephi_build_ceff_ = buildtrack.emomPhi();
2464  eta_build_ceff_ = buildtrack.momEta();
2465  eeta_build_ceff_ = buildtrack.emomEta();
2466 
2467  // gen info
2468  if (mcTrackID_build_ceff_ >= 0) {
2469  const auto& simtrack = evt_sim_tracks[mcTrackID_build_ceff_];
2470  x_mc_build_ceff_ = simtrack.x();
2471  y_mc_build_ceff_ = simtrack.y();
2472  z_mc_build_ceff_ = simtrack.z();
2473  pt_mc_build_ceff_ = simtrack.pT();
2474  phi_mc_build_ceff_ = simtrack.momPhi();
2475  eta_mc_build_ceff_ = simtrack.momEta();
2476 
2477  if (Config::keepHitInfo)
2479  } else {
2480  x_mc_build_ceff_ = -1000;
2481  y_mc_build_ceff_ = -1000;
2482  z_mc_build_ceff_ = -1000;
2483  pt_mc_build_ceff_ = -99;
2484  phi_mc_build_ceff_ = -99;
2485  eta_mc_build_ceff_ = -99;
2486  }
2487 
2488  // hit/layer info
2489  nHits_build_ceff_ = buildtrack.nFoundHits();
2490  nLayers_build_ceff_ = buildtrack.nUniqueLayers();
2491  nHitsMatched_build_ceff_ = buildextra.nHitsMatched();
2492  fracHitsMatched_build_ceff_ = buildextra.fracHitsMatched();
2493  lastlyr_build_ceff_ = buildtrack.getLastFoundHitLyr();
2494 
2495  // hit info
2496  const Hit& lasthit = evt_layer_hits[buildtrack.getLastFoundHitLyr()][buildtrack.getLastFoundHitIdx()];
2497  xhit_build_ceff_ = lasthit.x();
2498  yhit_build_ceff_ = lasthit.y();
2499  zhit_build_ceff_ = lasthit.z();
2500 
2501  // quality info
2502  hitchi2_build_ceff_ = buildtrack.chi2();
2503  helixchi2_build_ceff_ = buildextra.helixChi2();
2504  score_build_ceff_ = buildtrack.score();
2505 
2506  // swim dphi
2507  dphi_build_ceff_ = buildextra.dPhi();
2508 
2509  // duplicate info
2510  duplmask_build_ceff_ = buildextra.isDuplicate();
2511  nTkMatches_build_ceff_ = cmsswToBuildMap_[cmsswID_ceff_].size(); // n reco matches to this cmssw track.
2512 
2513  if (Config::keepHitInfo)
2515  } else // unmatched cmsswtracks ... put -99 for all reco values to denote unmatched
2516  {
2517  cmsswmask_build_ceff_ = (cmsswtrack.isFindable() ? 0 : -1); // quick logic for not matched
2518 
2519  seedID_build_ceff_ = -99;
2520  mcTrackID_build_ceff_ = -99;
2521 
2522  pt_build_ceff_ = -99;
2523  ept_build_ceff_ = -99;
2524  phi_build_ceff_ = -99;
2525  ephi_build_ceff_ = -99;
2526  eta_build_ceff_ = -99;
2527  eeta_build_ceff_ = -99;
2528 
2529  x_mc_build_ceff_ = -2000;
2530  y_mc_build_ceff_ = -2000;
2531  z_mc_build_ceff_ = -2000;
2532  pt_mc_build_ceff_ = -99;
2533  phi_mc_build_ceff_ = -99;
2534  eta_mc_build_ceff_ = -99;
2535 
2536  nHits_build_ceff_ = -99;
2537  nLayers_build_ceff_ = -99;
2540  lastlyr_build_ceff_ = -99;
2541 
2542  xhit_build_ceff_ = -2000;
2543  yhit_build_ceff_ = -2000;
2544  zhit_build_ceff_ = -2000;
2545 
2546  hitchi2_build_ceff_ = -99;
2547  helixchi2_build_ceff_ = -99;
2548  score_build_ceff_ = -17000;
2549 
2550  dphi_build_ceff_ = -99;
2551 
2552  duplmask_build_ceff_ = -1; // mask means unmatched cmssw track
2553  nTkMatches_build_ceff_ = -99; // unmatched
2554  }
2555 
2556  // matched fit track
2557  if (cmsswToFitMap_.count(cmsswID_ceff_) &&
2558  cmsswtrack
2559  .isFindable()) // recoToCmssw match : save best match with best score i.e. cmsswToFitMap_[matched CmsswID][first element in vector]
2560  {
2561  for (unsigned int ii = 0; ii < cmsswToFitMap_[cmsswID_ceff_].size(); ii++) {
2562  const int theAlgo = evt_build_tracks[cmsswToFitMap_[cmsswID_ceff_][ii]].algoint();
2563  if ((itermask_fit_ceff_ >> theAlgo) & 1)
2564  iterduplmask_fit_ceff_ = (iterduplmask_fit_ceff_ | (1 << theAlgo)); //filled at the second time
2565  itermask_fit_ceff_ = (itermask_fit_ceff_ | (1 << theAlgo));
2566  }
2567 
2568  const auto& fittrack =
2569  evt_fit_tracks[cmsswToFitMap_[cmsswID_ceff_][0]]; // returns fitTrack best matched to cmssw track
2570  const auto& fitextra = evt_fit_extras[fittrack.label()]; // returns track extra best aligned with fit track
2571  cmsswmask_fit_ceff_ = 1; // quick logic for matched
2572 
2573  seedID_fit_ceff_ = fitextra.seedID();
2574  mcTrackID_fit_ceff_ = fitextra.mcTrackID();
2575 
2576  // track parameters
2577  pt_fit_ceff_ = fittrack.pT();
2578  ept_fit_ceff_ = fittrack.epT();
2579  phi_fit_ceff_ = fittrack.momPhi();
2580  ephi_fit_ceff_ = fittrack.emomPhi();
2581  eta_fit_ceff_ = fittrack.momEta();
2582  eeta_fit_ceff_ = fittrack.emomEta();
2583 
2584  // gen info
2585  if (mcTrackID_fit_ceff_ >= 0) {
2586  const auto& simtrack = evt_sim_tracks[mcTrackID_fit_ceff_];
2587  x_mc_fit_ceff_ = simtrack.x();
2588  y_mc_fit_ceff_ = simtrack.y();
2589  z_mc_fit_ceff_ = simtrack.z();
2590  pt_mc_fit_ceff_ = simtrack.pT();
2591  phi_mc_fit_ceff_ = simtrack.momPhi();
2592  eta_mc_fit_ceff_ = simtrack.momEta();
2593 
2594  if (Config::keepHitInfo)
2596  } else {
2597  x_mc_fit_ceff_ = -1000;
2598  y_mc_fit_ceff_ = -1000;
2599  z_mc_fit_ceff_ = -1000;
2600  pt_mc_fit_ceff_ = -99;
2601  phi_mc_fit_ceff_ = -99;
2602  eta_mc_fit_ceff_ = -99;
2603  }
2604 
2605  // hit/layer info
2606  nHits_fit_ceff_ = fittrack.nFoundHits();
2607  nLayers_fit_ceff_ = fittrack.nUniqueLayers();
2608  nHitsMatched_fit_ceff_ = fitextra.nHitsMatched();
2609  fracHitsMatched_fit_ceff_ = fitextra.fracHitsMatched();
2610  lastlyr_fit_ceff_ = fittrack.getLastFoundHitLyr();
2611 
2612  // hit info
2613  const Hit& lasthit = evt_layer_hits[fittrack.getLastFoundHitLyr()][fittrack.getLastFoundHitIdx()];
2614  xhit_fit_ceff_ = lasthit.x();
2615  yhit_fit_ceff_ = lasthit.y();
2616  zhit_fit_ceff_ = lasthit.z();
2617 
2618  // quality info
2619  hitchi2_fit_ceff_ = fittrack.chi2();
2620  helixchi2_fit_ceff_ = fitextra.helixChi2();
2621  score_fit_ceff_ = fittrack.score();
2622 
2623  // swim dphi
2624  dphi_fit_ceff_ = fitextra.dPhi();
2625 
2626  // duplicate info
2627  duplmask_fit_ceff_ = fitextra.isDuplicate();
2628  nTkMatches_fit_ceff_ = cmsswToFitMap_[cmsswID_ceff_].size(); // n reco matches to this cmssw track.
2629 
2630  if (Config::keepHitInfo)
2632  } else // unmatched cmsswtracks ... put -99 for all reco values to denote unmatched
2633  {
2634  cmsswmask_fit_ceff_ = (cmsswtrack.isFindable() ? 0 : -1); // quick logic for not matched
2635 
2636  seedID_fit_ceff_ = -99;
2637  mcTrackID_fit_ceff_ = -99;
2638 
2639  pt_fit_ceff_ = -99;
2640  ept_fit_ceff_ = -99;
2641  phi_fit_ceff_ = -99;
2642  ephi_fit_ceff_ = -99;
2643  eta_fit_ceff_ = -99;
2644  eeta_fit_ceff_ = -99;
2645 
2646  x_mc_fit_ceff_ = -2000;
2647  y_mc_fit_ceff_ = -2000;
2648  z_mc_fit_ceff_ = -2000;
2649  pt_mc_fit_ceff_ = -99;
2650  phi_mc_fit_ceff_ = -99;
2651  eta_mc_fit_ceff_ = -99;
2652 
2653  nHits_fit_ceff_ = -99;
2654  nLayers_fit_ceff_ = -99;
2655  nHitsMatched_fit_ceff_ = -99;
2657  lastlyr_fit_ceff_ = -99;
2658 
2659  xhit_fit_ceff_ = -2000;
2660  yhit_fit_ceff_ = -2000;
2661  zhit_fit_ceff_ = -2000;
2662 
2663  hitchi2_fit_ceff_ = -99;
2664  helixchi2_fit_ceff_ = -99;
2665  score_fit_ceff_ = -17000;
2666 
2667  dphi_fit_ceff_ = -99;
2668 
2669  duplmask_fit_ceff_ = -1; // mask means unmatched cmssw track
2670  nTkMatches_fit_ceff_ = -99; // unmatched
2671  }
2672 
2673  cmsswefftree_->Fill();
2674  }
2675  }
2676 
2678  std::lock_guard<std::mutex> locker(glock_);
2679 
2680  auto ievt = ev.evtID();
2681  const auto& evt_sim_tracks = ev.simTracks_;
2682  const auto& evt_cmssw_tracks = ev.cmsswTracks_;
2683  const auto& evt_cmssw_extras = ev.cmsswTracksExtra_;
2684  const auto& evt_build_tracks = ev.candidateTracks_;
2685  const auto& evt_build_extras = ev.candidateTracksExtra_;
2686  const auto& evt_fit_tracks = ev.fitTracks_;
2687  const auto& evt_fit_extras = ev.fitTracksExtra_;
2688  const auto& evt_layer_hits = ev.layerHits_;
2689 
2690  for (const auto& buildtrack : evt_build_tracks) {
2691  if (Config::keepHitInfo) {
2692  hitlyrs_mc_cFR_.clear();
2693  hitlyrs_build_cFR_.clear();
2694  hitlyrs_cmssw_build_cFR_.clear();
2695  hitlyrs_fit_cFR_.clear();
2696  hitlyrs_cmssw_fit_cFR_.clear();
2697 
2698  hitidxs_mc_cFR_.clear();
2699  hitidxs_build_cFR_.clear();
2700  hitidxs_cmssw_build_cFR_.clear();
2701  hitidxs_fit_cFR_.clear();
2702  hitidxs_cmssw_fit_cFR_.clear();
2703  }
2704 
2705  algorithm_cFR_ = buildtrack.algoint();
2706 
2707  const auto& buildextra = evt_build_extras[buildtrack.label()];
2708 
2709  // same for fit and build tracks
2710  evtID_cFR_ = ievt;
2711  seedID_cFR_ = buildextra.seedID();
2712  mcTrackID_cFR_ = buildextra.mcTrackID();
2713 
2714  // track parameters
2715  pt_build_cFR_ = buildtrack.pT();
2716  ept_build_cFR_ = buildtrack.epT();
2717  phi_build_cFR_ = buildtrack.momPhi();
2718  ephi_build_cFR_ = buildtrack.emomPhi();
2719  eta_build_cFR_ = buildtrack.momEta();
2720  eeta_build_cFR_ = buildtrack.emomEta();
2721 
2722  // gen info
2723  if (mcTrackID_cFR_ >= 0) {
2724  const auto& simtrack = evt_sim_tracks[mcTrackID_cFR_];
2725  x_mc_cFR_ = simtrack.x();
2726  y_mc_cFR_ = simtrack.y();
2727  z_mc_cFR_ = simtrack.z();
2728  pt_mc_cFR_ = simtrack.pT();
2729  phi_mc_cFR_ = simtrack.momPhi();
2730  eta_mc_cFR_ = simtrack.momEta();
2731 
2732  if (Config::keepHitInfo)
2734  } else {
2735  x_mc_cFR_ = -1000;
2736  y_mc_cFR_ = -1000;
2737  z_mc_cFR_ = -1000;
2738  pt_mc_cFR_ = -99;
2739  phi_mc_cFR_ = -99;
2740  eta_mc_cFR_ = -99;
2741  }
2742 
2743  // hit/layer info
2744  nHits_build_cFR_ = buildtrack.nFoundHits();
2745  nLayers_build_cFR_ = buildtrack.nUniqueLayers();
2746  nHitsMatched_build_cFR_ = buildextra.nHitsMatched();
2747  fracHitsMatched_build_cFR_ = buildextra.fracHitsMatched();
2748  lastlyr_build_cFR_ = buildtrack.getLastFoundHitLyr();
2749 
2750  // hit info
2751  const Hit& lasthit = evt_layer_hits[buildtrack.getLastFoundHitLyr()][buildtrack.getLastFoundHitIdx()];
2752  xhit_build_cFR_ = lasthit.x();
2753  yhit_build_cFR_ = lasthit.y();
2754  zhit_build_cFR_ = lasthit.z();
2755 
2756  // quality info
2757  hitchi2_build_cFR_ = buildtrack.chi2();
2758  helixchi2_build_cFR_ = buildextra.helixChi2();
2759  score_build_cFR_ = buildtrack.score();
2760 
2761  // stored dphi
2762  dphi_build_cFR_ = buildextra.dPhi();
2763 
2764  if (Config::keepHitInfo)
2766 
2767  // cmssw match?
2768  cmsswID_build_cFR_ = buildextra.cmsswTrackID();
2770 
2771  if (cmsswmask_build_cFR_ == 1) // matched track to cmssw
2772  {
2773  const auto& cmsswtrack = evt_cmssw_tracks[cmsswID_build_cFR_];
2774  const auto& cmsswextra = evt_cmssw_extras[cmsswtrack.label()];
2775 
2776  seedID_cmssw_build_cFR_ = cmsswextra.seedID();
2777 
2778  x_cmssw_build_cFR_ = cmsswtrack.x();
2779  y_cmssw_build_cFR_ = cmsswtrack.y();
2780  z_cmssw_build_cFR_ = cmsswtrack.z();
2781 
2782  pt_cmssw_build_cFR_ = cmsswtrack.pT();
2783  phi_cmssw_build_cFR_ = cmsswtrack.momPhi();
2784  eta_cmssw_build_cFR_ = cmsswtrack.momEta();
2785 
2786  nHits_cmssw_build_cFR_ = cmsswtrack.nFoundHits();
2787  nLayers_cmssw_build_cFR_ = cmsswtrack.nUniqueLayers();
2788  lastlyr_cmssw_build_cFR_ = cmsswtrack.getLastFoundHitLyr();
2789 
2790  // duplicate info
2791  duplmask_build_cFR_ = buildextra.isDuplicate();
2792  iTkMatches_build_cFR_ = buildextra.duplicateID();
2793 
2794  if (Config::keepHitInfo)
2796  } else // unmatched cmsswtracks ... put -99 for all reco values to denote unmatched
2797  {
2799 
2800  x_cmssw_build_cFR_ = -2000;
2801  y_cmssw_build_cFR_ = -2000;
2802  z_cmssw_build_cFR_ = -2000;
2803 
2804  pt_cmssw_build_cFR_ = -99;
2805  phi_cmssw_build_cFR_ = -99;
2806  eta_cmssw_build_cFR_ = -99;
2807 
2808  nHits_cmssw_build_cFR_ = -99;
2811 
2812  duplmask_build_cFR_ = -1;
2813  iTkMatches_build_cFR_ = -99;
2814  }
2815 
2816  // ensure there is a fit track to mess with
2817  if (buildToFitMap_.count(buildtrack.label())) {
2818  const auto& fittrack = evt_fit_tracks[buildToFitMap_[buildtrack.label()]];
2819  const auto& fitextra = evt_fit_extras[fittrack.label()];
2820 
2821  // track parameters
2822  pt_fit_cFR_ = fittrack.pT();
2823  ept_fit_cFR_ = fittrack.epT();
2824  phi_fit_cFR_ = fittrack.momPhi();
2825  ephi_fit_cFR_ = fittrack.emomPhi();
2826  eta_fit_cFR_ = fittrack.momEta();
2827  eeta_fit_cFR_ = fittrack.emomEta();
2828 
2829  // hit/layer info
2830  nHits_fit_cFR_ = fittrack.nFoundHits();
2831  nLayers_fit_cFR_ = fittrack.nUniqueLayers();
2832  nHitsMatched_fit_cFR_ = fitextra.nHitsMatched();
2833  fracHitsMatched_fit_cFR_ = fitextra.fracHitsMatched();
2834  lastlyr_fit_cFR_ = fittrack.getLastFoundHitLyr();
2835 
2836  // hit info
2837  const Hit& lasthit = evt_layer_hits[fittrack.getLastFoundHitLyr()][fittrack.getLastFoundHitIdx()];
2838  xhit_fit_cFR_ = lasthit.x();
2839  yhit_fit_cFR_ = lasthit.y();
2840  zhit_fit_cFR_ = lasthit.z();
2841 
2842  // chi2 info
2843  hitchi2_fit_cFR_ = fittrack.chi2();
2844  helixchi2_fit_cFR_ = fitextra.helixChi2();
2845  score_fit_cFR_ = fittrack.score();
2846 
2847  // stored dphi
2848  dphi_fit_cFR_ = fitextra.dPhi();
2849 
2850  if (Config::keepHitInfo)
2852 
2853  // cmssw match?
2854  cmsswID_fit_cFR_ = fitextra.cmsswTrackID();
2856 
2857  if (cmsswmask_fit_cFR_ == 1) // matched track to cmssw
2858  {
2859  const auto& cmsswtrack = evt_cmssw_tracks[cmsswID_fit_cFR_];
2860  const auto& cmsswextra = evt_cmssw_extras[cmsswtrack.label()];
2861 
2862  seedID_cmssw_fit_cFR_ = cmsswextra.seedID();
2863 
2864  x_cmssw_fit_cFR_ = cmsswtrack.x();
2865  y_cmssw_fit_cFR_ = cmsswtrack.y();
2866  z_cmssw_fit_cFR_ = cmsswtrack.z();
2867 
2868  pt_cmssw_fit_cFR_ = cmsswtrack.pT();
2869  phi_cmssw_fit_cFR_ = cmsswtrack.momPhi();
2870  eta_cmssw_fit_cFR_ = cmsswtrack.momEta();
2871 
2872  nHits_cmssw_fit_cFR_ = cmsswtrack.nFoundHits();
2873  nLayers_cmssw_fit_cFR_ = cmsswtrack.nUniqueLayers();
2874  lastlyr_cmssw_fit_cFR_ = cmsswtrack.getLastFoundHitLyr();
2875 
2876  // duplicate info
2877  duplmask_fit_cFR_ = fitextra.isDuplicate();
2878  iTkMatches_fit_cFR_ = fitextra.duplicateID();
2879 
2880  if (Config::keepHitInfo)
2882  } else // unmatched cmsswtracks ... put -99 for all reco values to denote unmatched
2883  {
2884  seedID_cmssw_fit_cFR_ = -99;
2885 
2886  x_cmssw_fit_cFR_ = -2000;
2887  y_cmssw_fit_cFR_ = -2000;
2888  z_cmssw_fit_cFR_ = -2000;
2889 
2890  pt_cmssw_fit_cFR_ = -99;
2891  phi_cmssw_fit_cFR_ = -99;
2892  eta_cmssw_fit_cFR_ = -99;
2893 
2894  nHits_cmssw_fit_cFR_ = -99;
2895  nLayers_cmssw_fit_cFR_ = -99;
2896  lastlyr_cmssw_fit_cFR_ = -99;
2897 
2898  duplmask_fit_cFR_ = -1;
2899  iTkMatches_fit_cFR_ = -99;
2900  }
2901  } else // no fit track to match to a build track!
2902  {
2903  pt_fit_cFR_ = -100;
2904  ept_fit_cFR_ = -100;
2905  phi_fit_cFR_ = -100;
2906  ephi_fit_cFR_ = -100;
2907  eta_fit_cFR_ = -100;
2908  eeta_fit_cFR_ = -100;
2909 
2910  nHits_fit_cFR_ = -100;
2911  nLayers_fit_cFR_ = -100;
2912  nHitsMatched_fit_cFR_ = -100;
2913  fracHitsMatched_fit_cFR_ = -100;
2914  lastlyr_fit_cFR_ = -100;
2915 
2916  xhit_fit_cFR_ = -3000;
2917  yhit_fit_cFR_ = -3000;
2918  zhit_fit_cFR_ = -3000;
2919 
2920  hitchi2_fit_cFR_ = -100;
2921  helixchi2_fit_cFR_ = -100;
2922  score_fit_cFR_ = -5001;
2923  dphi_fit_cFR_ = -100;
2924 
2925  cmsswID_fit_cFR_ = -100;
2926  cmsswmask_fit_cFR_ = -2;
2927 
2928  seedID_cmssw_fit_cFR_ = -100;
2929 
2930  x_cmssw_fit_cFR_ = -3000;
2931  y_cmssw_fit_cFR_ = -3000;
2932  z_cmssw_fit_cFR_ = -3000;
2933 
2934  pt_cmssw_fit_cFR_ = -100;
2935  phi_cmssw_fit_cFR_ = -100;
2936  eta_cmssw_fit_cFR_ = -100;
2937 
2938  nHits_cmssw_fit_cFR_ = -100;
2939  nLayers_cmssw_fit_cFR_ = -100;
2940  lastlyr_cmssw_fit_cFR_ = -100;
2941 
2942  duplmask_fit_cFR_ = -2;
2943  iTkMatches_fit_cFR_ = -100;
2944  }
2945 
2946  cmsswfrtree_->Fill();
2947  }
2948  }
2949 
2951  std::lock_guard<std::mutex> locker(glock_);
2952  f_->cd();
2953 
2955  efftree_->SetDirectory(f_.get());
2956  efftree_->Write();
2957 
2958  frtree_->SetDirectory(f_.get());
2959  frtree_->Write();
2960  }
2961  if (Config::cmssw_val) {
2962  cmsswefftree_->SetDirectory(f_.get());
2963  cmsswefftree_->Write();
2964 
2965  cmsswfrtree_->SetDirectory(f_.get());
2966  cmsswfrtree_->Write();
2967  }
2968  if (Config::fit_val) {
2969  fittree_->SetDirectory(f_.get());
2970  fittree_->Write();
2971  }
2972 
2973  configtree_->SetDirectory(f_.get());
2974  configtree_->Write();
2975  }
2976 
2977 } // end namespace mkfit
2978 #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_
TkIDToTkIDMap fitToSeedMapDumbCMSSW_
std::vector< float > & emeta_up_fit_
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:664
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
TrackVec cmsswTracks_
Definition: Event.h:62
int evtID() const
Definition: Event.h:23
TrackExtraVec candidateTracksExtra_
Definition: Event.h:64
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)
TrackVec seedTracks_
Definition: Event.h:61
float y() const
Definition: Hit.h:162
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:16
int ii
Definition: cuy.py:589
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_
constexpr std::array< uint8_t, layerIndexSize > layer
std::vector< int > hitlyrs_fit_cFR_
std::vector< int > hitidxs_seed_FR_
TkIDToTkIDMap seedToFitMap_
float momEta() const
Definition: Track.h:104
char const * label
constexpr int nLayers
Definition: Config.h:73
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_
float z() const
Definition: Hit.h:163
std::vector< int > hitmcTkIDs_mc_eff_
std::unique_ptr< TTree > cmsswefftree_
matchOpts cmsswMatchingBK
float momPhi() const
Definition: Track.h:98
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_
float pT() const
Definition: Track.h:100
T sqrt(T t)
Definition: SSEVec.h:19
std::unordered_map< int, int > TkIDToTkIDMap
Definition: TrackExtra.h:124
std::unique_ptr< TTree > fittree_
int getHitIdx(int posHitIdx) const
Definition: Track.h:455
std::vector< float > & ez_sim_fit_
std::unique_ptr< TTree > efftree_
constexpr float minDEta
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:596
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
TrackExtraVec cmsswTracksExtra_
Definition: Event.h:65
constexpr float beamspotX
void fillCMSSWEfficiencyTree(const Event &ev) override
constexpr float hitposerrR
TkIDToTkIDMap candToSeedMapDumbCMSSW_
std::vector< int > hitidxs_cmssw_ceff_
TrackExtraVec simTracksExtra_
Definition: Event.h:64
std::vector< float > hitys_mc_eff_
void makeCMSSWTkToRecoTksMaps(Event &ev) override
TkIDtoFitValLayMapMap fitValTkMapMap_
std::vector< int > hitlyrs_cmssw_fit_cFR_
MCHitInfoVec simHitsInfo_
Definition: Event.h:59
IterationsInfo ItrInfo
constexpr float hitposerrZ
void mapRefTkToRecoTks(const TrackVec &evt_tracks, TrackExtraVec &evt_extras, TkIDToTkIDVecMap &refTkMap)
std::vector< HitVec > layerHits_
Definition: Event.h:57
std::vector< float > hitxs_build_FR_
TTreeValidation(std::string fileName, const TrackerInfo *trk_info)
int getHitLyr(int posHitIdx) const
Definition: Track.h:456
TrackVec simTracks_
Definition: Event.h:61
TSVec simTrackStates_
Definition: Event.h:67
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_
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
float getScoreCand(const TrackCand &cand1, bool penalizeTailMissHits=false, bool inFindCandidates=false)
std::vector< float > hitys_build_FR_
float x() const
Definition: Hit.h:161
std::vector< float > & emphi_up_fit_
std::vector< float > hitys_seed_FR_
std::vector< float > hitzs_mc_eff_
TrackExtraVec fitTracksExtra_
Definition: Event.h:64
TkIDToTkIDMap seedToBuildMap_
TkIDToTkIDVecMap simToSeedMap_
SVector6 parameters
Definition: Track.h:60
std::vector< float > hitzs_build_eff_
TrackExtraVec seedTracksExtra_
Definition: Event.h:64
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_
constexpr float varXY
TrackVec fitTracks_
Definition: Event.h:61
std::vector< int > hitlyrs_mc_eff_
std::vector< int > hitlyrs_mc_fit_FR_
std::vector< int > hitmcTkIDs_build_eff_
constexpr float phierr049
int n_layers() const
Definition: TrackerInfo.h:145
std::vector< float > hitys_fit_eff_
std::vector< float > hitzs_fit_FR_
std::vector< float > hitxs_mc_eff_
TrackVec candidateTracks_
Definition: Event.h:61
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_
constexpr float beamspotZ
std::vector< int > hitlyrs_mc_fit_ceff_
std::vector< int > hitidxs_mc_fit_ceff_
TkIDToTkIDVecMap cmsswToFitMap_
constexpr float ptinverr012
int nTotalHits() const
Definition: Track.h:517
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_
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_
std::vector< int > hitlyrs_mc_build_FR_