CMS 3D CMS Logo

MultiTrackValidator.cc
Go to the documentation of this file.
3 
7 
26 
32 #include<type_traits>
33 
34 
35 #include "TMath.h"
36 #include <TF1.h>
39 //#include <iostream>
40 
41 using namespace std;
42 using namespace edm;
43 
45 namespace {
46  bool trackSelected(unsigned char mask, unsigned char qual) {
47  return mask & 1<<qual;
48  }
49 
50 }
51 
53  associators(pset.getUntrackedParameter< std::vector<edm::InputTag> >("associators")),
54  label(pset.getParameter< std::vector<edm::InputTag> >("label")),
55  parametersDefiner(pset.getParameter<std::string>("parametersDefiner")),
56  parametersDefinerIsCosmic_(parametersDefiner == "CosmicParametersDefinerForTP"),
57  ignoremissingtkcollection_(pset.getUntrackedParameter<bool>("ignoremissingtrackcollection",false)),
58  useAssociators_(pset.getParameter< bool >("UseAssociators")),
59  calculateDrSingleCollection_(pset.getUntrackedParameter<bool>("calculateDrSingleCollection")),
60  doPlotsOnlyForTruePV_(pset.getUntrackedParameter<bool>("doPlotsOnlyForTruePV")),
61  doSummaryPlots_(pset.getUntrackedParameter<bool>("doSummaryPlots")),
62  doSimPlots_(pset.getUntrackedParameter<bool>("doSimPlots")),
63  doSimTrackPlots_(pset.getUntrackedParameter<bool>("doSimTrackPlots")),
64  doRecoTrackPlots_(pset.getUntrackedParameter<bool>("doRecoTrackPlots")),
65  dodEdxPlots_(pset.getUntrackedParameter<bool>("dodEdxPlots")),
66  doPVAssociationPlots_(pset.getUntrackedParameter<bool>("doPVAssociationPlots")),
67  doSeedPlots_(pset.getUntrackedParameter<bool>("doSeedPlots")),
68  doMVAPlots_(pset.getUntrackedParameter<bool>("doMVAPlots")),
69  simPVMaxZ_(pset.getUntrackedParameter<double>("simPVMaxZ"))
70 {
71  if(label.empty()) {
72  // Disable prefetching of everything if there are no track collections
73  return;
74  }
75 
76  const edm::InputTag& label_tp_effic_tag = pset.getParameter< edm::InputTag >("label_tp_effic");
77  const edm::InputTag& label_tp_fake_tag = pset.getParameter< edm::InputTag >("label_tp_fake");
78 
79  if(pset.getParameter<bool>("label_tp_effic_refvector")) {
80  label_tp_effic_refvector = consumes<TrackingParticleRefVector>(label_tp_effic_tag);
81  }
82  else {
83  label_tp_effic = consumes<TrackingParticleCollection>(label_tp_effic_tag);
84  }
85  if(pset.getParameter<bool>("label_tp_fake_refvector")) {
86  label_tp_fake_refvector = consumes<TrackingParticleRefVector>(label_tp_fake_tag);
87  }
88  else {
89  label_tp_fake = consumes<TrackingParticleCollection>(label_tp_fake_tag);
90  }
91  label_pileupinfo = consumes<std::vector<PileupSummaryInfo> >(pset.getParameter< edm::InputTag >("label_pileupinfo"));
92  for(const auto& tag: pset.getParameter<std::vector<edm::InputTag>>("sim")) {
93  simHitTokens_.push_back(consumes<std::vector<PSimHit>>(tag));
94  }
95 
96  std::vector<edm::InputTag> doResolutionPlotsForLabels = pset.getParameter<std::vector<edm::InputTag> >("doResolutionPlotsForLabels");
97  doResolutionPlots_.reserve(label.size());
98  for (auto& itag : label) {
99  labelToken.push_back(consumes<edm::View<reco::Track> >(itag));
100  const bool doResol = doResolutionPlotsForLabels.empty() || (std::find(cbegin(doResolutionPlotsForLabels), cend(doResolutionPlotsForLabels), itag) != cend(doResolutionPlotsForLabels));
101  doResolutionPlots_.push_back(doResol);
102  }
103  { // check for duplicates
104  auto labelTmp = edm::vector_transform(label, [&](const edm::InputTag& tag) { return tag.label(); });
105  std::sort(begin(labelTmp), end(labelTmp));
107  const std::string* prev = &empty;
108  for(const std::string& l: labelTmp) {
109  if(l == *prev) {
110  throw cms::Exception("Configuration") << "Duplicate InputTag in labels: " << l;
111  }
112  prev = &l;
113  }
114  }
115 
117  bsSrc = consumes<reco::BeamSpot>(beamSpotTag);
118 
119  ParameterSet psetForHistoProducerAlgo = pset.getParameter<ParameterSet>("histoProducerAlgoBlock");
120  histoProducerAlgo_ = std::make_unique<MTVHistoProducerAlgoForTracker>(psetForHistoProducerAlgo, doSeedPlots_);
121 
122  dirName_ = pset.getParameter<std::string>("dirName");
123 
124  tpNLayersToken_ = consumes<edm::ValueMap<unsigned int> >(pset.getParameter<edm::InputTag>("label_tp_nlayers"));
125  tpNPixelLayersToken_ = consumes<edm::ValueMap<unsigned int> >(pset.getParameter<edm::InputTag>("label_tp_npixellayers"));
126  tpNStripStereoLayersToken_ = consumes<edm::ValueMap<unsigned int> >(pset.getParameter<edm::InputTag>("label_tp_nstripstereolayers"));
127 
128  if(dodEdxPlots_) {
129  m_dEdx1Tag = consumes<edm::ValueMap<reco::DeDxData> >(pset.getParameter< edm::InputTag >("dEdx1Tag"));
130  m_dEdx2Tag = consumes<edm::ValueMap<reco::DeDxData> >(pset.getParameter< edm::InputTag >("dEdx2Tag"));
131  }
132 
133  label_tv = consumes<TrackingVertexCollection>(pset.getParameter< edm::InputTag >("label_tv"));
135  recoVertexToken_ = consumes<edm::View<reco::Vertex> >(pset.getUntrackedParameter<edm::InputTag>("label_vertex"));
136  vertexAssociatorToken_ = consumes<reco::VertexToTrackingVertexAssociator>(pset.getUntrackedParameter<edm::InputTag>("vertexAssociator"));
137  }
138 
139  if(doMVAPlots_) {
141  auto mvaPSet = pset.getUntrackedParameter<edm::ParameterSet>("mvaLabels");
142  for(size_t iIter=0; iIter<labelToken.size(); ++iIter) {
144  labelsForToken(labelToken[iIter], labels);
145  if(mvaPSet.exists(labels.module)) {
146  mvaQualityCollectionTokens_[iIter] = edm::vector_transform(mvaPSet.getUntrackedParameter<std::vector<std::string> >(labels.module),
147  [&](const std::string& tag) {
148  return std::make_tuple(consumes<MVACollection>(edm::InputTag(tag, "MVAValues")),
149  consumes<QualityMaskCollection>(edm::InputTag(tag, "QualityMasks")));
150  });
151  }
152  }
153  }
154 
155  tpSelector = TrackingParticleSelector(pset.getParameter<double>("ptMinTP"),
156  pset.getParameter<double>("ptMaxTP"),
157  pset.getParameter<double>("minRapidityTP"),
158  pset.getParameter<double>("maxRapidityTP"),
159  pset.getParameter<double>("tipTP"),
160  pset.getParameter<double>("lipTP"),
161  pset.getParameter<int>("minHitTP"),
162  pset.getParameter<bool>("signalOnlyTP"),
163  pset.getParameter<bool>("intimeOnlyTP"),
164  pset.getParameter<bool>("chargedOnlyTP"),
165  pset.getParameter<bool>("stableOnlyTP"),
166  pset.getParameter<std::vector<int> >("pdgIdTP"));
167 
169  pset.getParameter<double>("minRapidityTP"),
170  pset.getParameter<double>("maxRapidityTP"),
171  pset.getParameter<double>("tipTP"),
172  pset.getParameter<double>("lipTP"),
173  pset.getParameter<int>("minHitTP"),
174  pset.getParameter<bool>("chargedOnlyTP"),
175  pset.getParameter<std::vector<int> >("pdgIdTP"));
176 
177 
178  ParameterSet psetVsPhi = psetForHistoProducerAlgo.getParameter<ParameterSet>("TpSelectorForEfficiencyVsPhi");
179  dRtpSelector = TrackingParticleSelector(psetVsPhi.getParameter<double>("ptMin"),
180  psetVsPhi.getParameter<double>("ptMax"),
181  psetVsPhi.getParameter<double>("minRapidity"),
182  psetVsPhi.getParameter<double>("maxRapidity"),
183  psetVsPhi.getParameter<double>("tip"),
184  psetVsPhi.getParameter<double>("lip"),
185  psetVsPhi.getParameter<int>("minHit"),
186  psetVsPhi.getParameter<bool>("signalOnly"),
187  psetVsPhi.getParameter<bool>("intimeOnly"),
188  psetVsPhi.getParameter<bool>("chargedOnly"),
189  psetVsPhi.getParameter<bool>("stableOnly"),
190  psetVsPhi.getParameter<std::vector<int> >("pdgId"));
191 
193 
194  useGsf = pset.getParameter<bool>("useGsf");
195 
196  _simHitTpMapTag = mayConsume<SimHitTPAssociationProducer::SimHitTPAssociationList>(pset.getParameter<edm::InputTag>("simHitTpMapTag"));
197 
199  labelTokenForDrCalculation = consumes<edm::View<reco::Track> >(pset.getParameter<edm::InputTag>("trackCollectionForDrCalculation"));
200  }
201 
202  if(useAssociators_) {
203  for (auto const& src: associators) {
204  associatorTokens.push_back(consumes<reco::TrackToTrackingParticleAssociator>(src));
205  }
206  } else {
207  for (auto const& src: associators) {
208  associatormapStRs.push_back(consumes<reco::SimToRecoCollection>(src));
209  associatormapRtSs.push_back(consumes<reco::RecoToSimCollection>(src));
210  }
211  }
212 }
213 
214 
216 
217 
219  if(label.empty()) {
220  // Disable histogram booking if there are no track collections
221  return;
222  }
223 
224  const auto minColl = -0.5;
225  const auto maxColl = label.size()-0.5;
226  const auto nintColl = label.size();
227 
228  auto binLabels = [&](ConcurrentMonitorElement me) {
229  for(size_t i=0; i<label.size(); ++i) {
230  me.setBinLabel(i+1, label[i].label());
231  }
232  me.disableAlphanumeric();
233  return me;
234  };
235 
236  //Booking histograms concerning with simulated tracks
237  if(doSimPlots_) {
238  ibook.cd();
239  ibook.setCurrentFolder(dirName_ + "simulation");
240 
241  histoProducerAlgo_->bookSimHistos(ibook, histograms.histoProducerAlgo);
242 
243  ibook.cd();
244  ibook.setCurrentFolder(dirName_);
245  }
246 
247  for (unsigned int ww=0;ww<associators.size();ww++){
248  ibook.cd();
249  // FIXME: these need to be moved to a subdirectory whose name depends on the associator
250  ibook.setCurrentFolder(dirName_);
251 
252  if(doSummaryPlots_) {
253  if(doSimTrackPlots_) {
254  histograms.h_assoc_coll.push_back(binLabels( ibook.book1D("num_assoc(simToReco)_coll", "N of associated (simToReco) tracks vs track collection", nintColl, minColl, maxColl) ));
255  histograms.h_simul_coll.push_back(binLabels( ibook.book1D("num_simul_coll", "N of simulated tracks vs track collection", nintColl, minColl, maxColl) ));
256  }
257  if(doRecoTrackPlots_) {
258  histograms.h_reco_coll.push_back(binLabels( ibook.book1D("num_reco_coll", "N of reco track vs track collection", nintColl, minColl, maxColl) ));
259  histograms.h_assoc2_coll.push_back(binLabels( ibook.book1D("num_assoc(recoToSim)_coll", "N of associated (recoToSim) tracks vs track collection", nintColl, minColl, maxColl) ));
260  histograms.h_looper_coll.push_back(binLabels( ibook.book1D("num_duplicate_coll", "N of associated (recoToSim) looper tracks vs track collection", nintColl, minColl, maxColl) ));
261  histograms.h_pileup_coll.push_back(binLabels( ibook.book1D("num_pileup_coll", "N of associated (recoToSim) pileup tracks vs track collection", nintColl, minColl, maxColl) ));
262  }
263  }
264 
265  for (unsigned int www=0;www<label.size();www++){
266  ibook.cd();
267  InputTag algo = label[www];
268  string dirName=dirName_;
269  if (!algo.process().empty())
270  dirName+=algo.process()+"_";
271  if(!algo.label().empty())
272  dirName+=algo.label()+"_";
273  if(!algo.instance().empty())
274  dirName+=algo.instance()+"_";
275  if (dirName.find("Tracks")<dirName.length()){
276  dirName.replace(dirName.find("Tracks"),6,"");
277  }
278  string assoc= associators[ww].label();
279  if (assoc.find("Track")<assoc.length()){
280  assoc.replace(assoc.find("Track"),5,"");
281  }
282  dirName+=assoc;
283  std::replace(dirName.begin(), dirName.end(), ':', '_');
284 
285  ibook.setCurrentFolder(dirName);
286 
287  const bool doResolutionPlots = doResolutionPlots_[www];
288 
289  if(doSimTrackPlots_) {
290  histoProducerAlgo_->bookSimTrackHistos(ibook, histograms.histoProducerAlgo, doResolutionPlots);
291  if(doPVAssociationPlots_) histoProducerAlgo_->bookSimTrackPVAssociationHistos(ibook, histograms.histoProducerAlgo);
292  }
293 
294  //Booking histograms concerning with reconstructed tracks
295  if(doRecoTrackPlots_) {
296  histoProducerAlgo_->bookRecoHistos(ibook, histograms.histoProducerAlgo, doResolutionPlots);
297  if (dodEdxPlots_) histoProducerAlgo_->bookRecodEdxHistos(ibook, histograms.histoProducerAlgo);
298  if (doPVAssociationPlots_) histoProducerAlgo_->bookRecoPVAssociationHistos(ibook, histograms.histoProducerAlgo);
299  if (doMVAPlots_) histoProducerAlgo_->bookMVAHistos(ibook, histograms.histoProducerAlgo, mvaQualityCollectionTokens_[www].size());
300  }
301 
302  if(doSeedPlots_) {
303  histoProducerAlgo_->bookSeedHistos(ibook, histograms.histoProducerAlgo);
304  }
305  }//end loop www
306  }// end loop ww
307 }
308 
309 namespace {
310  void ensureEffIsSubsetOfFake(const TrackingParticleRefVector& eff, const TrackingParticleRefVector& fake) {
311  // If efficiency RefVector is empty, don't check the product ids
312  // as it will be 0:0 for empty. This covers also the case where
313  // both are empty. The case of fake being empty and eff not is an
314  // error.
315  if(eff.empty())
316  return;
317 
318  // First ensure product ids
319  if(eff.id() != fake.id()) {
320  throw cms::Exception("Configuration") << "Efficiency and fake TrackingParticle (refs) point to different collections (eff " << eff.id() << " fake " << fake.id() << "). This is not supported. Efficiency TP set must be the same or a subset of the fake TP set.";
321  }
322 
323  // Same technique as in associationMapFilterValues
324  edm::IndexSet fakeKeys;
325  fakeKeys.reserve(fake.size());
326  for(const auto& ref: fake) {
327  fakeKeys.insert(ref.key());
328  }
329 
330  for(const auto& ref: eff) {
331  if(!fakeKeys.has(ref.key())) {
332  throw cms::Exception("Configuration") << "Efficiency TrackingParticle " << ref.key() << " is not found from the set of fake TPs. This is not supported. The efficiency TP set must be the same or a subset of the fake TP set.";
333  }
334  }
335  }
336 }
337 
339  for(const auto& simV: *htv) {
340  if(simV.eventId().bunchCrossing() != 0) continue; // remove OOTPU
341  if(simV.eventId().event() != 0) continue; // pick the PV of hard scatter
342  return &(simV.position());
343  }
344  return nullptr;
345 }
346 
349  event.getByToken(recoVertexToken_, hvertex);
350 
352  event.getByToken(vertexAssociatorToken_, hvassociator);
353 
354  auto v_r2s = hvassociator->associateRecoToSim(hvertex, htv);
355  auto pvPtr = hvertex->refAt(0);
356  if(pvPtr->isFake() || pvPtr->ndof() < 0) // skip junk vertices
357  return nullptr;
358 
359  auto pvFound = v_r2s.find(pvPtr);
360  if(pvFound == v_r2s.end())
361  return nullptr;
362 
363  for(const auto& vertexRefQuality: pvFound->val) {
364  const TrackingVertex& tv = *(vertexRefQuality.first);
365  if(tv.eventId().event() == 0 && tv.eventId().bunchCrossing() == 0) {
366  return &(pvPtr->position());
367  }
368  }
369 
370  return nullptr;
371 }
372 
374  const TrackingParticleRefVector& tPCeff,
375  const ParametersDefinerForTP& parametersDefinerTP,
376  const edm::Event& event, const edm::EventSetup& setup,
377  const reco::BeamSpot& bs,
378  std::vector<std::tuple<TrackingParticle::Vector, TrackingParticle::Point> >& momVert_tPCeff,
379  std::vector<size_t>& selected_tPCeff) const {
380  selected_tPCeff.reserve(tPCeff.size());
381  momVert_tPCeff.reserve(tPCeff.size());
382  int nIntimeTPs = 0;
384  for(size_t j=0; j<tPCeff.size(); ++j) {
385  const TrackingParticleRef& tpr = tPCeff[j];
386 
387  TrackingParticle::Vector momentum = parametersDefinerTP.momentum(event,setup,tpr);
388  TrackingParticle::Point vertex = parametersDefinerTP.vertex(event,setup,tpr);
389  if(doSimPlots_) {
390  histoProducerAlgo_->fill_generic_simTrack_histos(histograms.histoProducerAlgo, momentum, vertex, tpr->eventId().bunchCrossing());
391  }
392  if(tpr->eventId().bunchCrossing() == 0)
393  ++nIntimeTPs;
394 
395  if(cosmictpSelector(tpr,&bs,event,setup)) {
396  selected_tPCeff.push_back(j);
397  momVert_tPCeff.emplace_back(momentum, vertex);
398  }
399  }
400  }
401  else {
402  size_t j=0;
403  for(auto const& tpr: tPCeff) {
404  const TrackingParticle& tp = *tpr;
405 
406  // TODO: do we want to fill these from all TPs that include IT
407  // and OOT (as below), or limit to IT+OOT TPs passing tpSelector
408  // (as it was before)? The latter would require another instance
409  // of tpSelector with intimeOnly=False.
410  if(doSimPlots_) {
411  histoProducerAlgo_->fill_generic_simTrack_histos(histograms.histoProducerAlgo, tp.momentum(), tp.vertex(), tp.eventId().bunchCrossing());
412  }
413  if(tp.eventId().bunchCrossing() == 0)
414  ++nIntimeTPs;
415 
416  if(tpSelector(tp)) {
417  selected_tPCeff.push_back(j);
418  TrackingParticle::Vector momentum = parametersDefinerTP.momentum(event,setup,tpr);
419  TrackingParticle::Point vertex = parametersDefinerTP.vertex(event,setup,tpr);
420  momVert_tPCeff.emplace_back(momentum, vertex);
421  }
422  ++j;
423  }
424  }
425  if(doSimPlots_) {
426  histoProducerAlgo_->fill_simTrackBased_histos(histograms.histoProducerAlgo, nIntimeTPs);
427  }
428 }
429 
430 
432  const std::vector<size_t>& selected_tPCeff,
433  DynArray<float>& dR_tPCeff) const {
434  float etaL[tPCeff.size()], phiL[tPCeff.size()];
435  size_t n_selTP_dr = 0;
436  for(size_t iTP: selected_tPCeff) {
437  //calculare dR wrt inclusive collection (also with PU, low pT, displaced)
438  auto const& tp2 = *(tPCeff[iTP]);
439  auto && p = tp2.momentum();
440  etaL[iTP] = etaFromXYZ(p.x(),p.y(),p.z());
441  phiL[iTP] = atan2f(p.y(),p.x());
442  }
443  for(size_t iTP1: selected_tPCeff) {
444  auto const& tp = *(tPCeff[iTP1]);
446  if(dRtpSelector(tp)) {//only for those needed for efficiency!
447  ++n_selTP_dr;
448  float eta = etaL[iTP1];
449  float phi = phiL[iTP1];
450  for(size_t iTP2: selected_tPCeff) {
451  //calculare dR wrt inclusive collection (also with PU, low pT, displaced)
452  if (iTP1==iTP2) {continue;}
453  auto dR_tmp = reco::deltaR2(eta, phi, etaL[iTP2], phiL[iTP2]);
454  if (dR_tmp<dR) dR=dR_tmp;
455  } // ttp2 (iTP)
456  }
457  dR_tPCeff[iTP1] = std::sqrt(dR);
458  } // tp
459  return n_selTP_dr;
460 }
461 
463  int i=0;
464  float etaL[trackCollectionDr.size()];
465  float phiL[trackCollectionDr.size()];
466  bool validL[trackCollectionDr.size()];
467  for (auto const & track2 : trackCollectionDr) {
468  auto && p = track2.momentum();
469  etaL[i] = etaFromXYZ(p.x(),p.y(),p.z());
470  phiL[i] = atan2f(p.y(),p.x());
471  validL[i] = !trackFromSeedFitFailed(track2);
472  ++i;
473  }
474  for(View<reco::Track>::size_type i=0; i<trackCollection.size(); ++i){
475  auto const & track = trackCollection[i];
478  auto && p = track.momentum();
479  float eta = etaFromXYZ(p.x(),p.y(),p.z());
480  float phi = atan2f(p.y(),p.x());
481  for(View<reco::Track>::size_type j=0; j<trackCollectionDr.size(); ++j){
482  if(!validL[j]) continue;
483  auto dR_tmp = reco::deltaR2(eta, phi, etaL[j], phiL[j]);
484  if ( (dR_tmp<dR) & (dR_tmp>std::numeric_limits<float>::min())) dR=dR_tmp;
485  }
486  }
487  dR_trk[i] = std::sqrt(dR);
488  }
489 }
490 
491 
493  if(label.empty()) {
494  // Disable if there are no track collections
495  return;
496  }
497 
498  using namespace reco;
499 
500  LogDebug("TrackValidator") << "\n====================================================" << "\n"
501  << "Analyzing new event" << "\n"
502  << "====================================================\n" << "\n";
503 
504 
505  edm::ESHandle<ParametersDefinerForTP> parametersDefinerTPHandle;
506  setup.get<TrackAssociatorRecord>().get(parametersDefiner,parametersDefinerTPHandle);
507  //Since we modify the object, we must clone it
508  auto parametersDefinerTP = parametersDefinerTPHandle->clone();
509 
511  setup.get<TrackerTopologyRcd>().get(httopo);
512  const TrackerTopology& ttopo = *httopo;
513 
514  // FIXME: we really need to move to edm::View for reading the
515  // TrackingParticles... Unfortunately it has non-trivial
516  // consequences on the associator/association interfaces etc.
517  TrackingParticleRefVector tmpTPeff;
518  TrackingParticleRefVector tmpTPfake;
519  const TrackingParticleRefVector *tmpTPeffPtr = nullptr;
520  const TrackingParticleRefVector *tmpTPfakePtr = nullptr;
521 
523  edm::Handle<TrackingParticleRefVector> TPCollectionHeffRefVector;
524 
525  const bool tp_effic_refvector = label_tp_effic.isUninitialized();
526  if(!tp_effic_refvector) {
527  event.getByToken(label_tp_effic, TPCollectionHeff);
528  for(size_t i=0, size=TPCollectionHeff->size(); i<size; ++i) {
529  tmpTPeff.push_back(TrackingParticleRef(TPCollectionHeff, i));
530  }
531  tmpTPeffPtr = &tmpTPeff;
532  }
533  else {
534  event.getByToken(label_tp_effic_refvector, TPCollectionHeffRefVector);
535  tmpTPeffPtr = TPCollectionHeffRefVector.product();
536  }
538  edm::Handle<TrackingParticleCollection> TPCollectionHfake ;
539  event.getByToken(label_tp_fake,TPCollectionHfake);
540  for(size_t i=0, size=TPCollectionHfake->size(); i<size; ++i) {
541  tmpTPfake.push_back(TrackingParticleRef(TPCollectionHfake, i));
542  }
543  tmpTPfakePtr = &tmpTPfake;
544  }
545  else {
546  edm::Handle<TrackingParticleRefVector> TPCollectionHfakeRefVector;
547  event.getByToken(label_tp_fake_refvector, TPCollectionHfakeRefVector);
548  tmpTPfakePtr = TPCollectionHfakeRefVector.product();
549  }
550 
551  TrackingParticleRefVector const & tPCeff = *tmpTPeffPtr;
552  TrackingParticleRefVector const & tPCfake = *tmpTPfakePtr;
553 
554  ensureEffIsSubsetOfFake(tPCeff, tPCfake);
555 
558  //warning: make sure the TP collection used in the map is the same used in the MTV!
559  event.getByToken(_simHitTpMapTag,simHitsTPAssoc);
560  parametersDefinerTP->initEvent(simHitsTPAssoc);
561  cosmictpSelector.initEvent(simHitsTPAssoc);
562  }
563 
564  // Find the sim PV and tak its position
566  event.getByToken(label_tv, htv);
567  const TrackingVertex::LorentzVector *theSimPVPosition = getSimPVPosition(htv);
568  if(simPVMaxZ_ >= 0) {
569  if(!theSimPVPosition) return;
570  if(std::abs(theSimPVPosition->z()) > simPVMaxZ_) return;
571  }
572 
573  // Check, when necessary, if reco PV matches to sim PV
574  const reco::Vertex::Point *thePVposition = nullptr;
576  thePVposition = getRecoPVPosition(event, htv);
577  if(doPlotsOnlyForTruePV_ && !thePVposition)
578  return;
579 
580  // Rest of the code assumes that if thePVposition is non-null, the
581  // PV-association histograms get filled. In above, the "nullness"
582  // is used to deliver the information if the reco PV is matched to
583  // the sim PV.
585  thePVposition = nullptr;
586  }
587 
588  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
589  event.getByToken(bsSrc,recoBeamSpotHandle);
590  reco::BeamSpot const & bs = *recoBeamSpotHandle;
591 
593  event.getByToken(label_pileupinfo,puinfoH);
594  PileupSummaryInfo puinfo;
595 
596  for (unsigned int puinfo_ite=0;puinfo_ite<(*puinfoH).size();++puinfo_ite){
597  if ((*puinfoH)[puinfo_ite].getBunchCrossing()==0){
598  puinfo=(*puinfoH)[puinfo_ite];
599  break;
600  }
601  }
602 
603  // Number of 3D layers for TPs
605  event.getByToken(tpNLayersToken_, tpNLayersH);
606  const auto& nLayers_tPCeff = *tpNLayersH;
607 
608  event.getByToken(tpNPixelLayersToken_, tpNLayersH);
609  const auto& nPixelLayers_tPCeff = *tpNLayersH;
610 
611  event.getByToken(tpNStripStereoLayersToken_, tpNLayersH);
612  const auto& nStripMonoAndStereoLayers_tPCeff = *tpNLayersH;
613 
614  // Precalculate TP selection (for efficiency), and momentum and vertex wrt PCA
615  //
616  // TODO: ParametersDefinerForTP ESProduct needs to be changed to
617  // EDProduct because of consumes.
618  //
619  // In principle, we could just precalculate the momentum and vertex
620  // wrt PCA for all TPs for once and put that to the event. To avoid
621  // repetitive calculations those should be calculated only once for
622  // each TP. That would imply that we should access TPs via Refs
623  // (i.e. View) in here, since, in general, the eff and fake TP
624  // collections can be different (and at least HI seems to use that
625  // feature). This would further imply that the
626  // RecoToSimCollection/SimToRecoCollection should be changed to use
627  // View<TP> instead of vector<TP>, and migrate everything.
628  //
629  // Or we could take only one input TP collection, and do another
630  // TP-selection to obtain the "fake" collection like we already do
631  // for "efficiency" TPs.
632  std::vector<size_t> selected_tPCeff;
633  std::vector<std::tuple<TrackingParticle::Vector, TrackingParticle::Point>> momVert_tPCeff;
634  tpParametersAndSelection(histograms, tPCeff, *parametersDefinerTP, event, setup, bs, momVert_tPCeff, selected_tPCeff);
635 
636  //calculate dR for TPs
637  declareDynArray(float, tPCeff.size(), dR_tPCeff);
638  size_t n_selTP_dr = tpDR(tPCeff, selected_tPCeff, dR_tPCeff);
639 
642  event.getByToken(labelTokenForDrCalculation, trackCollectionForDrCalculation);
643  }
644 
645  // dE/dx
646  // at some point this could be generalized, with a vector of tags and a corresponding vector of Handles
647  // I'm writing the interface such to take vectors of ValueMaps
648  std::vector<const edm::ValueMap<reco::DeDxData> *> v_dEdx;
649  if(dodEdxPlots_) {
652  event.getByToken(m_dEdx1Tag, dEdx1Handle);
653  event.getByToken(m_dEdx2Tag, dEdx2Handle);
654  v_dEdx.push_back(dEdx1Handle.product());
655  v_dEdx.push_back(dEdx2Handle.product());
656  }
657 
658  std::vector<const MVACollection *> mvaCollections;
659  std::vector<const QualityMaskCollection *> qualityMaskCollections;
660  std::vector<float> mvaValues;
661 
662  int w=0; //counter counting the number of sets of histograms
663  for (unsigned int ww=0;ww<associators.size();ww++){
664  // run value filtering of recoToSim map already here as it depends only on the association, not track collection
665  reco::SimToRecoCollection const * simRecCollPFull=nullptr;
666  reco::RecoToSimCollection const * recSimCollP=nullptr;
667  reco::RecoToSimCollection recSimCollL;
668  if(!useAssociators_) {
669  Handle<reco::SimToRecoCollection > simtorecoCollectionH;
670  event.getByToken(associatormapStRs[ww], simtorecoCollectionH);
671  simRecCollPFull = simtorecoCollectionH.product();
672 
673  Handle<reco::RecoToSimCollection > recotosimCollectionH;
674  event.getByToken(associatormapRtSs[ww],recotosimCollectionH);
675  recSimCollP = recotosimCollectionH.product();
676 
677  // We need to filter the associations of the fake-TrackingParticle
678  // collection only from RecoToSim collection, otherwise the
679  // RecoToSim histograms get false entries
680  recSimCollL = associationMapFilterValues(*recSimCollP, tPCfake);
681  recSimCollP = &recSimCollL;
682  }
683 
684  for (unsigned int www=0;www<label.size();www++, w++){ // need to increment w here, since there are many continues in the loop body
685  //
686  //get collections from the event
687  //
688  edm::Handle<View<Track> > trackCollectionHandle;
689  if(!event.getByToken(labelToken[www], trackCollectionHandle)&&ignoremissingtkcollection_)continue;
690  const edm::View<Track>& trackCollection = *trackCollectionHandle;
691 
692  reco::SimToRecoCollection const * simRecCollP=nullptr;
693  reco::SimToRecoCollection simRecCollL;
694 
695  //associate tracks
696  LogTrace("TrackValidator") << "Analyzing "
697  << label[www] << " with "
698  << associators[ww] <<"\n";
699  if(useAssociators_){
701  event.getByToken(associatorTokens[ww], theAssociator);
702 
703  // The associator interfaces really need to be fixed...
705  for(edm::View<Track>::size_type i=0; i<trackCollection.size(); ++i) {
706  trackRefs.push_back(trackCollection.refAt(i));
707  }
708 
709 
710  LogTrace("TrackValidator") << "Calling associateRecoToSim method" << "\n";
711  recSimCollL = theAssociator->associateRecoToSim(trackRefs, tPCfake);
712  recSimCollP = &recSimCollL;
713  LogTrace("TrackValidator") << "Calling associateSimToReco method" << "\n";
714  // It is necessary to do the association wrt. fake TPs,
715  // because this SimToReco association is used also for
716  // duplicates. Since the set of efficiency TPs are required to
717  // be a subset of the set of fake TPs, for efficiency
718  // histograms it doesn't matter if the association contains
719  // associations of TPs not in the set of efficiency TPs.
720  simRecCollL = theAssociator->associateSimToReco(trackRefs, tPCfake);
721  simRecCollP = &simRecCollL;
722  }
723  else{
724  // We need to filter the associations of the current track
725  // collection only from SimToReco collection, otherwise the
726  // SimToReco histograms get false entries. The filtering must
727  // be done separately for each track collection.
728  simRecCollL = associationMapFilterValues(*simRecCollPFull, trackCollection);
729  simRecCollP = &simRecCollL;
730  }
731 
732  reco::RecoToSimCollection const & recSimColl = *recSimCollP;
733  reco::SimToRecoCollection const & simRecColl = *simRecCollP;
734 
735  // read MVA collections
739  for(const auto& tokenTpl: mvaQualityCollectionTokens_[www]) {
740  event.getByToken(std::get<0>(tokenTpl), hmva);
741  event.getByToken(std::get<1>(tokenTpl), hqual);
742 
743  mvaCollections.push_back(hmva.product());
744  qualityMaskCollections.push_back(hqual.product());
745  if(mvaCollections.back()->size() != trackCollection.size()) {
746  throw cms::Exception("Configuration") << "Inconsistency in track collection and MVA sizes. Track collection " << www << " has " << trackCollection.size() << " tracks, whereas the MVA " << (mvaCollections.size()-1) << " for it has " << mvaCollections.back()->size() << " entries. Double-check your configuration.";
747  }
748  if(qualityMaskCollections.back()->size() != trackCollection.size()) {
749  throw cms::Exception("Configuration") << "Inconsistency in track collection and quality mask sizes. Track collection " << www << " has " << trackCollection.size() << " tracks, whereas the quality mask " << (qualityMaskCollections.size()-1) << " for it has " << qualityMaskCollections.back()->size() << " entries. Double-check your configuration.";
750  }
751  }
752  }
753 
754  // ########################################################
755  // fill simulation histograms (LOOP OVER TRACKINGPARTICLES)
756  // ########################################################
757 
758  //compute number of tracks per eta interval
759  //
760  LogTrace("TrackValidator") << "\n# of TrackingParticles: " << tPCeff.size() << "\n";
761  int ats(0); //This counter counts the number of simTracks that are "associated" to recoTracks
762  int st(0); //This counter counts the number of simulated tracks passing the MTV selection (i.e. tpSelector(tp) )
763 
764  //loop over already-selected TPs for tracking efficiency
765  for(size_t i=0; i<selected_tPCeff.size(); ++i) {
766  size_t iTP = selected_tPCeff[i];
767  const TrackingParticleRef& tpr = tPCeff[iTP];
768  const TrackingParticle& tp = *tpr;
769 
770  auto const& momVert = momVert_tPCeff[i];
771  TrackingParticle::Vector momentumTP;
772  TrackingParticle::Point vertexTP;
773 
774  double dxySim(0);
775  double dzSim(0);
776  double dxyPVSim = 0;
777  double dzPVSim = 0;
778  double dR=dR_tPCeff[iTP];
779 
780  //---------- THIS PART HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
781  //If the TrackingParticle is collison like, get the momentum and vertex at production state
783  {
784  momentumTP = tp.momentum();
785  vertexTP = tp.vertex();
786  //Calcualte the impact parameters w.r.t. PCA
787  const TrackingParticle::Vector& momentum = std::get<TrackingParticle::Vector>(momVert);
788  const TrackingParticle::Point& vertex = std::get<TrackingParticle::Point>(momVert);
789  dxySim = TrackingParticleIP::dxy(vertex, momentum, bs.position());
790  dzSim = TrackingParticleIP::dz(vertex, momentum, bs.position());
791 
792  if(theSimPVPosition) {
793  dxyPVSim = TrackingParticleIP::dxy(vertex, momentum, *theSimPVPosition);
794  dzPVSim = TrackingParticleIP::dz(vertex, momentum, *theSimPVPosition);
795  }
796  }
797  //If the TrackingParticle is comics, get the momentum and vertex at PCA
798  else
799  {
800  momentumTP = std::get<TrackingParticle::Vector>(momVert);
801  vertexTP = std::get<TrackingParticle::Point>(momVert);
802  dxySim = TrackingParticleIP::dxy(vertexTP, momentumTP, bs.position());
803  dzSim = TrackingParticleIP::dz(vertexTP, momentumTP, bs.position());
804 
805  // Do dxy and dz vs. PV make any sense for cosmics? I guess not
806  }
807  //---------- THE PART ABOVE HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
808 
809  // in the coming lines, histos are filled using as input
810  // - momentumTP
811  // - vertexTP
812  // - dxySim
813  // - dzSim
814  if(!doSimTrackPlots_)
815  continue;
816 
817  // ##############################################
818  // fill RecoAssociated SimTracks' histograms
819  // ##############################################
820  const reco::Track *matchedTrackPointer = nullptr;
821  const reco::Track *matchedSecondTrackPointer = nullptr;
822  unsigned int selectsLoose = mvaCollections.size();
823  unsigned int selectsHP = mvaCollections.size();
824  if(simRecColl.find(tpr) != simRecColl.end()){
825  auto const & rt = simRecColl[tpr];
826  if (!rt.empty()) {
827  ats++; //This counter counts the number of simTracks that have a recoTrack associated
828  // isRecoMatched = true; // UNUSED
829  matchedTrackPointer = rt.begin()->first.get();
830  if(rt.size() >= 2) {
831  matchedSecondTrackPointer = (rt.begin()+1)->first.get();
832  }
833  LogTrace("TrackValidator") << "TrackingParticle #" << st
834  << " with pt=" << sqrt(momentumTP.perp2())
835  << " associated with quality:" << rt.begin()->second <<"\n";
836 
837  if(doMVAPlots_) {
838  // for each MVA we need to take the value of the track
839  // with largest MVA value (for the cumulative histograms)
840  //
841  // also identify the first MVA that possibly selects any
842  // track matched to this TrackingParticle, separately
843  // for loose and highPurity qualities
844  for(size_t imva=0; imva<mvaCollections.size(); ++imva) {
845  const auto& mva = *(mvaCollections[imva]);
846  const auto& qual = *(qualityMaskCollections[imva]);
847 
848  auto iMatch = rt.begin();
849  float maxMva = mva[iMatch->first.key()];
850  for(; iMatch!=rt.end(); ++iMatch) {
851  auto itrk = iMatch->first.key();
852  maxMva = std::max(maxMva, mva[itrk]);
853 
854  if(selectsLoose >= imva && trackSelected(qual[itrk], reco::TrackBase::loose))
855  selectsLoose = imva;
856  if(selectsHP >= imva && trackSelected(qual[itrk], reco::TrackBase::highPurity))
857  selectsHP = imva;
858  }
859  mvaValues.push_back(maxMva);
860  }
861  }
862  }
863  }else{
864  LogTrace("TrackValidator")
865  << "TrackingParticle #" << st
866  << " with pt,eta,phi: "
867  << sqrt(momentumTP.perp2()) << " , "
868  << momentumTP.eta() << " , "
869  << momentumTP.phi() << " , "
870  << " NOT associated to any reco::Track" << "\n";
871  }
872 
873 
874 
875 
876  int nSimHits = tp.numberOfTrackerHits();
877  int nSimLayers = nLayers_tPCeff[tpr];
878  int nSimPixelLayers = nPixelLayers_tPCeff[tpr];
879  int nSimStripMonoAndStereoLayers = nStripMonoAndStereoLayers_tPCeff[tpr];
880  histoProducerAlgo_->fill_recoAssociated_simTrack_histos(histograms.histoProducerAlgo,w,tp,momentumTP,vertexTP,dxySim,dzSim,dxyPVSim,dzPVSim,nSimHits,nSimLayers,nSimPixelLayers,nSimStripMonoAndStereoLayers,matchedTrackPointer,puinfo.getPU_NumInteractions(), dR, thePVposition, theSimPVPosition, bs.position(), mvaValues, selectsLoose, selectsHP);
881  mvaValues.clear();
882 
883  if(matchedTrackPointer && matchedSecondTrackPointer) {
884  histoProducerAlgo_->fill_duplicate_histos(histograms.histoProducerAlgo,w, *matchedTrackPointer, *matchedSecondTrackPointer);
885  }
886 
887  if(doSummaryPlots_) {
888  if(dRtpSelector(tp)) {
889  histograms.h_simul_coll[ww].fill(www);
890  if (matchedTrackPointer) {
891  histograms.h_assoc_coll[ww].fill(www);
892  }
893  }
894  }
895 
896 
897 
898 
899  } // End for (TrackingParticleCollection::size_type i=0; i<tPCeff.size(); i++){
900 
901  // ##############################################
902  // fill recoTracks histograms (LOOP OVER TRACKS)
903  // ##############################################
904  if(!doRecoTrackPlots_)
905  continue;
906  LogTrace("TrackValidator") << "\n# of reco::Tracks with "
907  << label[www].process()<<":"
908  << label[www].label()<<":"
909  << label[www].instance()
910  << ": " << trackCollection.size() << "\n";
911 
912  int sat(0); //This counter counts the number of recoTracks that are associated to SimTracks from Signal only
913  int at(0); //This counter counts the number of recoTracks that are associated to SimTracks
914  int rT(0); //This counter counts the number of recoTracks in general
915  int seed_fit_failed = 0;
916  size_t n_selTrack_dr = 0;
917 
918  //calculate dR for tracks
919  const edm::View<Track> *trackCollectionDr = &trackCollection;
921  trackCollectionDr = trackCollectionForDrCalculation.product();
922  }
923  declareDynArray(float, trackCollection.size(), dR_trk);
924  trackDR(trackCollection, *trackCollectionDr, dR_trk);
925 
926  for(View<Track>::size_type i=0; i<trackCollection.size(); ++i){
927  auto track = trackCollection.refAt(i);
928  rT++;
929  if(trackFromSeedFitFailed(*track)) ++seed_fit_failed;
930  if((*dRTrackSelector)(*track, bs.position())) ++n_selTrack_dr;
931 
932  bool isSigSimMatched(false);
933  bool isSimMatched(false);
934  bool isChargeMatched(true);
935  int numAssocRecoTracks = 0;
936  int nSimHits = 0;
937  double sharedFraction = 0.;
938 
939  auto tpFound = recSimColl.find(track);
940  isSimMatched = tpFound != recSimColl.end();
941  if (isSimMatched) {
942  const auto& tp = tpFound->val;
943  nSimHits = tp[0].first->numberOfTrackerHits();
944  sharedFraction = tp[0].second;
945  if (tp[0].first->charge() != track->charge()) isChargeMatched = false;
946  if(simRecColl.find(tp[0].first) != simRecColl.end()) numAssocRecoTracks = simRecColl[tp[0].first].size();
947  at++;
948  for (unsigned int tp_ite=0;tp_ite<tp.size();++tp_ite){
949  TrackingParticle trackpart = *(tp[tp_ite].first);
950  if ((trackpart.eventId().event() == 0) && (trackpart.eventId().bunchCrossing() == 0)){
951  isSigSimMatched = true;
952  sat++;
953  break;
954  }
955  }
956  LogTrace("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt()
957  << " associated with quality:" << tp.begin()->second <<"\n";
958  } else {
959  LogTrace("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt()
960  << " NOT associated to any TrackingParticle" << "\n";
961  }
962 
963  // set MVA values for this track
964  // take also the indices of first MVAs to select by loose and
965  // HP quality
966  unsigned int selectsLoose = mvaCollections.size();
967  unsigned int selectsHP = mvaCollections.size();
968  if(doMVAPlots_) {
969  for(size_t imva=0; imva<mvaCollections.size(); ++imva) {
970  const auto& mva = *(mvaCollections[imva]);
971  const auto& qual = *(qualityMaskCollections[imva]);
972  mvaValues.push_back(mva[i]);
973 
974  if(selectsLoose >= imva && trackSelected(qual[i], reco::TrackBase::loose))
975  selectsLoose = imva;
976  if(selectsHP >= imva && trackSelected(qual[i], reco::TrackBase::highPurity))
977  selectsHP = imva;
978  }
979  }
980 
981  double dR=dR_trk[i];
982  histoProducerAlgo_->fill_generic_recoTrack_histos(histograms.histoProducerAlgo,w,*track, ttopo, bs.position(), thePVposition, theSimPVPosition, isSimMatched,isSigSimMatched, isChargeMatched, numAssocRecoTracks, puinfo.getPU_NumInteractions(), nSimHits, sharedFraction, dR, mvaValues, selectsLoose, selectsHP);
983  mvaValues.clear();
984 
985  if(doSummaryPlots_) {
986  histograms.h_reco_coll[ww].fill(www);
987  if(isSimMatched) {
988  histograms.h_assoc2_coll[ww].fill(www);
989  if(numAssocRecoTracks>1) {
990  histograms.h_looper_coll[ww].fill(www);
991  }
992  if(!isSigSimMatched) {
993  histograms.h_pileup_coll[ww].fill(www);
994  }
995  }
996  }
997 
998  // dE/dx
999  if (dodEdxPlots_) histoProducerAlgo_->fill_dedx_recoTrack_histos(histograms.histoProducerAlgo,w,track, v_dEdx);
1000 
1001 
1002  //Fill other histos
1003  if (!isSimMatched) continue;
1004 
1005  histoProducerAlgo_->fill_simAssociated_recoTrack_histos(histograms.histoProducerAlgo,w,*track);
1006 
1007  /* TO BE FIXED LATER
1008  if (associators[ww]=="trackAssociatorByChi2"){
1009  //association chi2
1010  double assocChi2 = -tp.begin()->second;//in association map is stored -chi2
1011  h_assochi2[www]->Fill(assocChi2);
1012  h_assochi2_prob[www]->Fill(TMath::Prob((assocChi2)*5,5));
1013  }
1014  else if (associators[ww]=="quickTrackAssociatorByHits"){
1015  double fraction = tp.begin()->second;
1016  h_assocFraction[www]->Fill(fraction);
1017  h_assocSharedHit[www]->Fill(fraction*track->numberOfValidHits());
1018  }
1019  */
1020 
1021 
1022  if(doResolutionPlots_[www]) {
1023  //Get tracking particle parameters at point of closest approach to the beamline
1024  TrackingParticleRef tpr = tpFound->val.begin()->first;
1025  TrackingParticle::Vector momentumTP = parametersDefinerTP->momentum(event,setup,tpr);
1026  TrackingParticle::Point vertexTP = parametersDefinerTP->vertex(event,setup,tpr);
1027  int chargeTP = tpr->charge();
1028 
1029  histoProducerAlgo_->fill_ResoAndPull_recoTrack_histos(histograms.histoProducerAlgo,w,momentumTP,vertexTP,chargeTP,
1030  *track,bs.position());
1031  }
1032 
1033 
1034  //TO BE FIXED
1035  //std::vector<PSimHit> simhits=tpr.get()->trackPSimHit(DetId::Tracker);
1036  //nrecHit_vs_nsimHit_rec2sim[w]->Fill(track->numberOfValidHits(), (int)(simhits.end()-simhits.begin() ));
1037 
1038  } // End of for(View<Track>::size_type i=0; i<trackCollection.size(); ++i){
1039  mvaCollections.clear();
1040  qualityMaskCollections.clear();
1041 
1042  histoProducerAlgo_->fill_trackBased_histos(histograms.histoProducerAlgo,w,at,rT, n_selTrack_dr, n_selTP_dr);
1043  // Fill seed-specific histograms
1044  if(doSeedPlots_) {
1045  histoProducerAlgo_->fill_seed_histos(histograms.histoProducerAlgo,www, seed_fit_failed, trackCollection.size());
1046  }
1047 
1048 
1049  LogTrace("TrackValidator") << "Collection " << www << "\n"
1050  << "Total Simulated (selected): " << n_selTP_dr << "\n"
1051  << "Total Reconstructed (selected): " << n_selTrack_dr << "\n"
1052  << "Total Reconstructed: " << rT << "\n"
1053  << "Total Associated (recoToSim): " << at << "\n"
1054  << "Total Fakes: " << rT-at << "\n";
1055  } // End of for (unsigned int www=0;www<label.size();www++){
1056  } //END of for (unsigned int ww=0;ww<associators.size();ww++){
1057 
1058 }
#define LogDebug(id)
size
Write out results.
void trackDR(const edm::View< reco::Track > &trackCollection, const edm::View< reco::Track > &trackCollectionDr, DynArray< float > &dR_trk) const
T getParameter(std::string const &) const
unsigned int size_type
Definition: View.h:90
T getUntrackedParameter(std::string const &, T const &) const
std::vector< ConcurrentMonitorElement > h_pileup_coll
edm::EDGetTokenT< SimHitTPAssociationProducer::SimHitTPAssociationList > _simHitTpMapTag
int event() const
get the contents of the subdetector field (should be protected?)
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx2Tag
bool trackFromSeedFitFailed(const reco::Track &track)
std::vector< edm::EDGetTokenT< reco::SimToRecoCollection > > associatormapStRs
const double w
Definition: UKUtility.cc:23
CosmicTrackingParticleSelector cosmictpSelector
Vector momentum() const
spatial momentum vector
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
const_iterator find(const key_type &k) const
find element with specified reference key
std::vector< std::vector< std::tuple< edm::EDGetTokenT< MVACollection >, edm::EDGetTokenT< QualityMaskCollection > > > > mvaQualityCollectionTokens_
std::vector< ConcurrentMonitorElement > h_simul_coll
edm::EDGetTokenT< edm::ValueMap< unsigned int > > tpNStripStereoLayersToken_
def replace(string, replacements)
edm::EDGetTokenT< edm::ValueMap< unsigned int > > tpNLayersToken_
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
size_type size() const
T_AssociationMap associationMapFilterValues(const T_AssociationMap &map, const T_RefVector &valueRefs)
TrackingParticleSelector dRtpSelector
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > > associatorTokens
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:104
const bool doPlotsOnlyForTruePV_
edm::EDGetTokenT< reco::BeamSpot > bsSrc
const reco::Vertex::Point * getRecoPVPosition(const edm::Event &event, const edm::Handle< TrackingVertexCollection > &htv) const
std::vector< ConcurrentMonitorElement > h_looper_coll
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void tpParametersAndSelection(const Histograms &histograms, const TrackingParticleRefVector &tPCeff, const ParametersDefinerForTP &parametersDefinerTP, const edm::Event &event, const edm::EventSetup &setup, const reco::BeamSpot &bs, std::vector< std::tuple< TrackingParticle::Vector, TrackingParticle::Point > > &momVert_tPCeff, std::vector< size_t > &selected_tPCeff) const
std::vector< ConcurrentMonitorElement > h_reco_coll
~MultiTrackValidator() override
Destructor.
RefToBase< value_type > refAt(size_type i) const
math::XYZPointD Point
point in the space
edm::EDGetTokenT< edm::ValueMap< unsigned int > > tpNPixelLayersToken_
math::XYZTLorentzVectorD LorentzVector
std::vector< edm::InputTag > associators
char const * label
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > labelToken
bool has(unsigned int index) const
Check if an element (=index) is in the set.
Definition: IndexSet.h:55
edm::Ref< edm::HepMCProduct, HepMC::GenParticle > GenParticleRef
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx1Tag
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
ProductID id() const
Accessor for product ID.
Definition: RefVector.h:122
std::vector< edm::EDGetTokenT< reco::RecoToSimCollection > > associatormapRtSs
auto dz(const T_Vertex &vertex, const T_Momentum &momentum, const T_Point &point)
T sqrt(T t)
Definition: SSEVec.h:18
size_t tpDR(const TrackingParticleRefVector &tPCeff, const std::vector< size_t > &selected_tPCeff, DynArray< float > &dR_tPCeff) const
int bunchCrossing() const
get the detector field from this detid
TrackingParticleSelector tpSelector
std::vector< bool > doResolutionPlots_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< ConcurrentMonitorElement > h_assoc_coll
ConcurrentMonitorElement book1D(Args &&...args)
Definition: DQMStore.h:160
virtual TrackingParticle::Vector momentum(const edm::Event &iEvent, const edm::EventSetup &iSetup, const Charge ch, const Point &vtx, const LorentzVector &lv) const
edm::EDGetTokenT< edm::View< reco::Track > > labelTokenForDrCalculation
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > label_pileupinfo
std::vector< edm::InputTag > label
void initEvent(edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssocToSet) const
#define end
Definition: vmac.h:39
T min(T a, T b)
Definition: MathUtil.h:58
char const * module
Definition: ProductLabels.h:5
virtual std::unique_ptr< ParametersDefinerForTP > clone() const
MultiTrackValidator(const edm::ParameterSet &pset)
Constructor.
#define LogTrace(id)
ObjectSelector< CosmicTrackingParticleSelector > CosmicTrackingParticleSelector
edm::EDGetTokenT< TrackingParticleRefVector > label_tp_fake_refvector
std::unique_ptr< MTVHistoProducerAlgoForTracker > histoProducerAlgo_
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
T const * product() const
Definition: Handle.h:81
edm::EDGetTokenT< TrackingVertexCollection > label_tv
reco::RecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Track > > &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
compare reco to sim the handle of reco::Track and TrackingParticle collections
edm::EDGetTokenT< reco::VertexToTrackingVertexAssociator > vertexAssociatorToken_
std::unique_ptr< RecoTrackSelectorBase > dRTrackSelector
const bool ignoremissingtkcollection_
MTVHistoProducerAlgoForTrackerHistograms histoProducerAlgo
const int getPU_NumInteractions() const
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
const bool doPVAssociationPlots_
std::string const & label() const
Definition: InputTag.h:36
EncodedEventId eventId() const
Signal source, crossing number.
Point vertex() const
Parent vertex position.
edm::EDGetTokenT< edm::View< reco::Vertex > > recoVertexToken_
std::vector< edm::EDGetTokenT< std::vector< PSimHit > > > simHitTokens_
std::string const & process() const
Definition: InputTag.h:40
void dqmAnalyze(const edm::Event &, const edm::EventSetup &, const Histograms &) const override
Method called once per event.
const EncodedEventId & eventId() const
const bool calculateDrSingleCollection_
fixed size matrix
#define begin
Definition: vmac.h:32
HLT enums.
auto dxy(const T_Vertex &vertex, const T_Momentum &momentum, const T_Point &point)
void bookHistograms(DQMStore::ConcurrentBooker &, edm::Run const &, edm::EventSetup const &, Histograms &) const override
Method called to book the DQM histograms.
T get() const
Definition: EventSetup.h:68
void push_back(const RefToBase< T > &)
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:69
size_type size() const
Size of the RefVector.
Definition: RefVector.h:107
edm::EDGetTokenT< TrackingParticleCollection > label_tp_fake
Monte Carlo truth information used for tracking validation.
void insert(unsigned int index)
Insert an element (=index) to the set.
Definition: IndexSet.h:48
bool isUninitialized() const
Definition: EDGetToken.h:73
const Point & position() const
position
Definition: BeamSpot.h:62
#define declareDynArray(T, n, x)
Definition: DynArray.h:59
int numberOfTrackerHits() const
The number of hits in the tracker. Hits on overlaps in the same layer count separately.
reco::SimToRecoCollection associateSimToReco(const edm::Handle< edm::View< reco::Track > > &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
compare reco to sim the handle of reco::Track and TrackingParticle collections
math::XYZVectorD Vector
point in the space
edm::EDGetTokenT< TrackingParticleRefVector > label_tp_effic_refvector
reco::VertexRecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Vertex > > &vCH, const edm::Handle< TrackingVertexCollection > &tVCH) const
compare reco to sim the handle of reco::Vertex and TrackingVertex collections
doResolutionPlotsForLabels
do resolution plots only for these labels (or all if empty)
static std::unique_ptr< RecoTrackSelectorBase > makeRecoTrackSelectorFromTPSelectorParameters(const edm::ParameterSet &pset)
void reserve(unsigned int size)
Reserve memory for the set.
Definition: IndexSet.h:35
std::vector< ConcurrentMonitorElement > h_assoc2_coll
edm::EDGetTokenT< TrackingParticleCollection > label_tp_effic
std::string const & instance() const
Definition: InputTag.h:37
edm::Ref< TrackingParticleCollection > TrackingParticleRef
Definition: event.py:1
Definition: Run.h:44
virtual TrackingParticle::Point vertex(const edm::Event &iEvent, const edm::EventSetup &iSetup, const Charge ch, const Point &vtx, const LorentzVector &lv) const
const TrackingVertex::LorentzVector * getSimPVPosition(const edm::Handle< TrackingVertexCollection > &htv) const
const bool parametersDefinerIsCosmic_