CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
MultiTrackValidatorGenPs Class Reference

#include <MultiTrackValidatorGenPs.h>

Inheritance diagram for MultiTrackValidatorGenPs:
MultiTrackValidator DQMGlobalEDAnalyzer< MultiTrackValidatorHistograms > edm::global::EDAnalyzer< edm::RunCache< MultiTrackValidatorHistograms >, Args... > edm::global::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void dqmAnalyze (const edm::Event &, const edm::EventSetup &, const Histograms &) const override
 Method called once per event. More...
 
 MultiTrackValidatorGenPs (const edm::ParameterSet &pset)
 Constructor. More...
 
 ~MultiTrackValidatorGenPs () override
 Destructor. More...
 
- Public Member Functions inherited from MultiTrackValidator
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, Histograms &) const override
 Method called to book the DQM histograms. More...
 
void dqmAnalyze (const edm::Event &, const edm::EventSetup &, const Histograms &) const override
 Method called once per event. More...
 
 MultiTrackValidator (const edm::ParameterSet &pset)
 Constructor. More...
 
 ~MultiTrackValidator () override
 Destructor. More...
 
- Public Member Functions inherited from edm::global::EDAnalyzer< edm::RunCache< MultiTrackValidatorHistograms >, Args... >
 EDAnalyzer ()=default
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

edm::EDGetTokenT< reco::GenToRecoCollectionassociatormapGtR
 
edm::EDGetTokenT< reco::RecoToGenCollectionassociatormapRtG
 
GenParticleCustomSelector gpSelector
 
edm::EDGetTokenT< reco::TrackToGenParticleAssociatorlabel_gen_associator
 

Additional Inherited Members

- Public Types inherited from MultiTrackValidator
using Histograms = MultiTrackValidatorHistograms
 
- Public Types inherited from DQMGlobalEDAnalyzer< MultiTrackValidatorHistograms >
typedef dqm::reco::DQMStore DQMStore
 
typedef dqm::reco::MonitorElement MonitorElement
 
- Public Types inherited from edm::global::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
- Protected Attributes inherited from MultiTrackValidator
std::vector< edm::InputTagassociators
 
edm::EDGetTokenT< reco::BeamSpotbsSrc
 
const bool calculateDrSingleCollection_
 
const bool dodEdxPlots_
 
const bool doMVAPlots_
 
const bool doPlotsOnlyForTruePV_
 
const bool doPVAssociationPlots_
 
const bool doRecoTrackPlots_
 
std::vector< bool > doResolutionPlots_
 
const bool doSeedPlots_
 
const bool doSimPlots_
 
const bool doSimTrackPlots_
 
const bool doSummaryPlots_
 
std::unique_ptr< MTVHistoProducerAlgoForTrackerhistoProducerAlgo_
 
const bool ignoremissingtkcollection_
 
std::vector< edm::InputTaglabel
 
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > label_pileupinfo
 
edm::EDGetTokenT< TrackingParticleCollectionlabel_tp_effic
 
edm::EDGetTokenT< TrackingParticleRefVectorlabel_tp_effic_refvector
 
edm::EDGetTokenT< TrackingParticleCollectionlabel_tp_fake
 
edm::EDGetTokenT< TrackingParticleRefVectorlabel_tp_fake_refvector
 
edm::EDGetTokenT< TrackingVertexCollectionlabel_tv
 
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > labelToken
 
std::vector< edm::EDGetTokenT< edm::View< TrajectorySeed > > > labelTokenSeed
 
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx1Tag
 
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx2Tag
 
std::string parametersDefiner
 
const bool parametersDefinerIsCosmic_
 
std::vector< edm::EDGetTokenT< std::vector< PSimHit > > > simHitTokens_
 
const bool useAssociators_
 

Detailed Description

Class that prodecs histrograms to validate Track Reconstruction performances

Author
cerati

Definition at line 14 of file MultiTrackValidatorGenPs.h.

Constructor & Destructor Documentation

MultiTrackValidatorGenPs::MultiTrackValidatorGenPs ( const edm::ParameterSet pset)

Constructor.

Definition at line 38 of file MultiTrackValidatorGenPs.cc.

References associatormapGtR, associatormapRtG, MultiTrackValidator::associators, edm::ParameterSet::getParameter(), gpSelector, kTrackAssociatorByChi2(), label_gen_associator, TrackRefitter_38T_cff::src, and MultiTrackValidator::useAssociators_.

38  : MultiTrackValidator(pset) {
39  gpSelector = GenParticleCustomSelector(pset.getParameter<double>("ptMinGP"),
40  pset.getParameter<double>("minRapidityGP"),
41  pset.getParameter<double>("maxRapidityGP"),
42  pset.getParameter<double>("tipGP"),
43  pset.getParameter<double>("lipGP"),
44  pset.getParameter<bool>("chargedOnlyGP"),
45  pset.getParameter<int>("statusGP"),
46  pset.getParameter<std::vector<int> >("pdgIdGP"));
47 
48  if (useAssociators_) {
49  for (auto const& src : associators) {
50  if (src.label() == kTrackAssociatorByChi2) {
51  label_gen_associator = consumes<reco::TrackToGenParticleAssociator>(src);
52  break;
53  }
54  }
55  } else {
56  for (auto const& src : associators) {
57  associatormapGtR = consumes<reco::GenToRecoCollection>(src);
58  associatormapRtG = consumes<reco::RecoToGenCollection>(src);
59  break;
60  }
61  }
62 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::GenToRecoCollection > associatormapGtR
static const std::string kTrackAssociatorByChi2("trackAssociatorByChi2")
std::vector< edm::InputTag > associators
edm::EDGetTokenT< reco::TrackToGenParticleAssociator > label_gen_associator
GenParticleCustomSelector gpSelector
SingleObjectSelector< GenParticleCollection,::GenParticleCustomSelector > GenParticleCustomSelector
MultiTrackValidator(const edm::ParameterSet &pset)
Constructor.
edm::EDGetTokenT< reco::RecoToGenCollection > associatormapRtG
MultiTrackValidatorGenPs::~MultiTrackValidatorGenPs ( )
override

Destructor.

Definition at line 64 of file MultiTrackValidatorGenPs.cc.

64 {}

Member Function Documentation

void MultiTrackValidatorGenPs::dqmAnalyze ( const edm::Event event,
const edm::EventSetup setup,
const Histograms histograms 
) const
override

Method called once per event.

Definition at line 66 of file MultiTrackValidatorGenPs.cc.

References reco::TrackToGenParticleAssociator::associateGenToReco(), reco::TrackToGenParticleAssociator::associateRecoToGen(), associatormapGtR, associatormapRtG, MultiTrackValidator::associators, MultiTrackValidator::bsSrc, reco::TrackBase::charge(), reco::GenParticle::collisionId(), funct::cos(), MultiTrackValidator::dodEdxPlots_, MultiTrackValidator::doRecoTrackPlots_, MultiTrackValidator::doSimPlots_, MultiTrackValidator::doSimTrackPlots_, HGC3DClusterGenMatchSelector_cfi::dR, edm::AssociationMap< Tag >::end(), edm::AssociationMap< Tag >::find(), dqmdumpme::first, edm::EventSetup::get(), edm::Ref< C, T, F >::get(), edm::Event::getByToken(), PileupSummaryInfo::getPU_NumInteractions(), gpSelector, MultiTrackValidatorHistograms::histoProducerAlgo, MultiTrackValidator::histoProducerAlgo_, mps_fire::i, MultiTrackValidator::ignoremissingtkcollection_, edm::EDGetTokenT< T >::isUninitialized(), kTrackAssociatorByChi2(), MultiTrackValidator::label, label_gen_associator, MultiTrackValidator::label_pileupinfo, MultiTrackValidator::label_tp_effic, MultiTrackValidator::label_tp_fake, MultiTrackValidator::labelToken, LogTrace, MultiTrackValidator::m_dEdx1Tag, MultiTrackValidator::m_dEdx2Tag, ParametersDefinerForTP::momentum(), reco::LeafCandidate::momentum(), MultiTrackValidator::parametersDefiner, MultiTrackValidator::parametersDefinerIsCosmic_, reco::BeamSpot::position(), edm::Handle< T >::product(), reco::TrackBase::pt(), funct::sin(), findQualityFiles::size, mathSSE::sqrt(), HLT_2018_cff::track, duplicaterechits_cfi::trackCollection, MultiTrackValidator::useAssociators_, bphysicsOniaDQM_cfi::vertex, ParametersDefinerForTP::vertex(), reco::LeafCandidate::vertex(), and w.

68  {
69  using namespace reco;
70 
71  edm::LogInfo("TrackValidator") << "\n===================================================="
72  << "\n"
73  << "Analyzing new event"
74  << "\n"
75  << "====================================================\n"
76  << "\n";
77 
78  edm::ESHandle<ParametersDefinerForTP> parametersDefinerTP;
79  setup.get<TrackAssociatorRecord>().get(parametersDefiner, parametersDefinerTP);
80 
82  setup.get<TrackerTopologyRcd>().get(httopo);
83  const TrackerTopology& ttopo = *httopo;
84 
85  edm::Handle<GenParticleCollection> TPCollectionHeff;
86  event.getByToken(label_tp_effic, TPCollectionHeff);
87  const GenParticleCollection tPCeff = *(TPCollectionHeff.product());
88 
89  edm::Handle<GenParticleCollection> TPCollectionHfake;
90  event.getByToken(label_tp_fake, TPCollectionHfake);
91  const GenParticleCollection tPCfake = *(TPCollectionHfake.product());
92 
93  //if (tPCeff.size()==0) {edm::LogInfo("TrackValidator")
94  //<< "TP Collection for efficiency studies has size = 0! Skipping Event." ; return;}
95  //if (tPCfake.size()==0) {edm::LogInfo("TrackValidator")
96  //<< "TP Collection for fake rate studies has size = 0! Skipping Event." ; return;}
97 
98  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
99  event.getByToken(bsSrc, recoBeamSpotHandle);
100  reco::BeamSpot bs = *recoBeamSpotHandle;
101 
103  event.getByToken(label_pileupinfo, puinfoH);
104  PileupSummaryInfo puinfo;
105 
106  for (unsigned int puinfo_ite = 0; puinfo_ite < (*puinfoH).size(); ++puinfo_ite) {
107  if ((*puinfoH)[puinfo_ite].getBunchCrossing() == 0) {
108  puinfo = (*puinfoH)[puinfo_ite];
109  break;
110  }
111  }
112 
113  const reco::TrackToGenParticleAssociator* trackGenAssociator = nullptr;
114  if (useAssociators_) {
116  return;
117  } else {
119  event.getByToken(label_gen_associator, trackGenAssociatorH);
120  trackGenAssociator = trackGenAssociatorH.product();
121  }
122  } else if (associatormapGtR.isUninitialized()) {
123  return;
124  }
125 
126  // dE/dx
127  // at some point this could be generalized, with a vector of tags and a corresponding vector of Handles
128  // I'm writing the interface such to take vectors of ValueMaps
129  std::vector<const edm::ValueMap<reco::DeDxData>*> v_dEdx;
130  if (dodEdxPlots_) {
133  event.getByToken(m_dEdx1Tag, dEdx1Handle);
134  event.getByToken(m_dEdx2Tag, dEdx2Handle);
135  v_dEdx.push_back(dEdx1Handle.product());
136  v_dEdx.push_back(dEdx2Handle.product());
137  }
138 
139  std::vector<float> mvaDummy;
140 
141  int w = 0; //counter counting the number of sets of histograms
142  for (unsigned int www = 0; www < label.size(); www++) {
143  //
144  //get collections from the event
145  //
147  if (!event.getByToken(labelToken[www], trackCollection) && ignoremissingtkcollection_)
148  continue;
149  //if (trackCollection->size()==0)
150  //edm::LogInfo("TrackValidator") << "TrackCollection size = 0!" ;
151  //continue;
152  //}
153  reco::RecoToGenCollection recGenColl;
154  reco::GenToRecoCollection genRecColl;
155  //associate tracks
156  if (useAssociators_) {
157  edm::LogVerbatim("TrackValidator") << "Analyzing " << label[www].process() << ":" << label[www].label() << ":"
158  << label[www].instance() << " with " << kTrackAssociatorByChi2 << "\n";
159 
160  LogTrace("TrackValidator") << "Calling associateRecoToGen method"
161  << "\n";
162  recGenColl = trackGenAssociator->associateRecoToGen(trackCollection, TPCollectionHfake);
163  LogTrace("TrackValidator") << "Calling associateGenToReco method"
164  << "\n";
165  genRecColl = trackGenAssociator->associateGenToReco(trackCollection, TPCollectionHeff);
166  } else {
167  edm::LogVerbatim("TrackValidator") << "Analyzing " << label[www].process() << ":" << label[www].label() << ":"
168  << label[www].instance() << " with " << associators[0] << "\n";
169 
170  Handle<reco::GenToRecoCollection> gentorecoCollectionH;
171  event.getByToken(associatormapGtR, gentorecoCollectionH);
172  genRecColl = *(gentorecoCollectionH.product());
173 
174  Handle<reco::RecoToGenCollection> recotogenCollectionH;
175  event.getByToken(associatormapRtG, recotogenCollectionH);
176  recGenColl = *(recotogenCollectionH.product());
177  }
178 
179  // ########################################################
180  // fill simulation histograms (LOOP OVER TRACKINGPARTICLES)
181  // ########################################################
182 
183  //compute number of tracks per eta interval
184  //
185  edm::LogVerbatim("TrackValidator") << "\n# of GenParticles: " << tPCeff.size() << "\n";
186  int ats(0); //This counter counts the number of simTracks that are "associated" to recoTracks
187  int st(0); //This counter counts the number of simulated tracks passing the MTV selection (i.e. tpSelector(tp) )
188  unsigned sts(0); //This counter counts the number of simTracks surviving the bunchcrossing cut
189  unsigned asts(
190  0); //This counter counts the number of simTracks that are "associated" to recoTracks surviving the bunchcrossing cut
191  for (GenParticleCollection::size_type i = 0; i < tPCeff.size();
192  i++) { //loop over TPs collection for tracking efficiency
193  GenParticleRef tpr(TPCollectionHeff, i);
194  GenParticle* tp = const_cast<GenParticle*>(tpr.get());
195  TrackingParticle::Vector momentumTP;
196  TrackingParticle::Point vertexTP;
197  double dxyGen(0);
198  double dzGen(0);
199 
200  //---------- THIS PART HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
201  //If the GenParticle is collison like, get the momentum and vertex at production state
203  //fixme this one shold be implemented
204  if (!gpSelector(*tp))
205  continue;
206  momentumTP = tp->momentum();
207  vertexTP = tp->vertex();
208  //Calcualte the impact parameters w.r.t. PCA
209  TrackingParticle::Vector momentum = parametersDefinerTP->momentum(event, setup, *tp);
210  TrackingParticle::Point vertex = parametersDefinerTP->vertex(event, setup, *tp);
211  dxyGen = (-vertex.x() * sin(momentum.phi()) + vertex.y() * cos(momentum.phi()));
212  dzGen = vertex.z() - (vertex.x() * momentum.x() + vertex.y() * momentum.y()) / sqrt(momentum.perp2()) *
213  momentum.z() / sqrt(momentum.perp2());
214  }
215  //If the GenParticle is comics, get the momentum and vertex at PCA
216  else {
217  //if(! cosmictpSelector(*tp,&bs,event,setup)) continue;
218  momentumTP = parametersDefinerTP->momentum(event, setup, *tp);
219  vertexTP = parametersDefinerTP->vertex(event, setup, *tp);
220  dxyGen = (-vertexTP.x() * sin(momentumTP.phi()) + vertexTP.y() * cos(momentumTP.phi()));
221  dzGen = vertexTP.z() - (vertexTP.x() * momentumTP.x() + vertexTP.y() * momentumTP.y()) /
222  sqrt(momentumTP.perp2()) * momentumTP.z() / sqrt(momentumTP.perp2());
223  }
224  //---------- THE PART ABOVE HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
225 
226  st++; //This counter counts the number of simulated tracks passing the MTV selection (i.e. tpSelector(tp) )
227 
228  // in the coming lines, histos are filled using as input
229  // - momentumTP
230  // - vertexTP
231  // - dxyGen
232  // - dzGen
233 
234  if (doSimPlots_ && w == 0) {
235  histoProducerAlgo_->fill_generic_simTrack_histos(histograms.histoProducerAlgo,
236  momentumTP,
237  vertexTP,
238  tp->collisionId()); //fixme: check meaning of collisionId
239  }
240  if (!doSimTrackPlots_)
241  continue;
242 
243  // ##############################################
244  // fill RecoAssociated GenTracks' histograms
245  // ##############################################
246  // bool isRecoMatched(false); // UNUSED
247  const reco::Track* matchedTrackPointer = nullptr;
248  std::vector<std::pair<RefToBase<Track>, double> > rt;
249  if (genRecColl.find(tpr) != genRecColl.end()) {
250  rt = (std::vector<std::pair<RefToBase<Track>, double> >)genRecColl[tpr];
251  if (!rt.empty()) {
252  ats++; //This counter counts the number of simTracks that have a recoTrack associated
253  // isRecoMatched = true; // UNUSED
254  matchedTrackPointer = rt.begin()->first.get();
255  edm::LogVerbatim("TrackValidator") << "GenParticle #" << st << " with pt=" << sqrt(momentumTP.perp2())
256  << " associated with quality:" << rt.begin()->second << "\n";
257  }
258  } else {
259  edm::LogVerbatim("TrackValidator") << "GenParticle #" << st << " with pt,eta,phi: " << sqrt(momentumTP.perp2())
260  << " , " << momentumTP.eta() << " , " << momentumTP.phi() << " , "
261  << " NOT associated to any reco::Track"
262  << "\n";
263  }
264 
265  int nSimHits = 0;
266  histoProducerAlgo_->fill_recoAssociated_simTrack_histos(histograms.histoProducerAlgo,
267  w,
268  *tp,
269  momentumTP,
270  vertexTP,
271  dxyGen,
272  dzGen,
273  nSimHits,
274  matchedTrackPointer,
275  puinfo.getPU_NumInteractions());
276 
277  sts++;
278  if (matchedTrackPointer)
279  asts++;
280 
281  } // End for (GenParticleCollection::size_type i=0; i<tPCeff.size(); i++){
282 
283  if (doSimPlots_ && w == 0) {
284  histoProducerAlgo_->fill_simTrackBased_histos(histograms.histoProducerAlgo, st);
285  }
286 
287  // ##############################################
288  // fill recoTracks histograms (LOOP OVER TRACKS)
289  // ##############################################
290  if (!doRecoTrackPlots_)
291  continue;
292  edm::LogVerbatim("TrackValidator") << "\n# of reco::Tracks with " << label[www].process() << ":"
293  << label[www].label() << ":" << label[www].instance() << ": "
294  << trackCollection->size() << "\n";
295 
296  //int sat(0); //This counter counts the number of recoTracks that are associated to GenTracks from Signal only
297  int at(0); //This counter counts the number of recoTracks that are associated to GenTracks
298  int rT(0); //This counter counts the number of recoTracks in general
299 
300  for (View<Track>::size_type i = 0; i < trackCollection->size(); ++i) {
301  RefToBase<Track> track(trackCollection, i);
302  rT++;
303 
304  bool isSigGenMatched(false);
305  bool isGenMatched(false);
306  bool isChargeMatched(true);
307  int numAssocRecoTracks = 0;
308  int nSimHits = 0;
309  double sharedFraction = 0.;
310  std::vector<std::pair<GenParticleRef, double> > tp;
311  if (recGenColl.find(track) != recGenColl.end()) {
312  tp = recGenColl[track];
313  if (!tp.empty()) {
314  /*
315  std::vector<PSimHit> simhits=tp[0].first->trackPSimHit(DetId::Tracker);
316  nSimHits = simhits.end()-simhits.begin();
317  */
318  sharedFraction = tp[0].second;
319  isGenMatched = true;
320  if (tp[0].first->charge() != track->charge())
321  isChargeMatched = false;
322  if (genRecColl.find(tp[0].first) != genRecColl.end())
323  numAssocRecoTracks = genRecColl[tp[0].first].size();
324  //std::cout << numAssocRecoTracks << std::endl;
325  at++;
326  for (unsigned int tp_ite = 0; tp_ite < tp.size(); ++tp_ite) {
327  GenParticle trackpart = *(tp[tp_ite].first);
328  /*
329  if ((trackpart.eventId().event() == 0) && (trackpart.eventId().bunchCrossing() == 0)){
330  isSigGenMatched = true;
331  sat++;
332  break;
333  }
334  */
335  }
336  edm::LogVerbatim("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt()
337  << " associated with quality:" << tp.begin()->second << "\n";
338  }
339  } else {
340  edm::LogVerbatim("TrackValidator")
341  << "reco::Track #" << rT << " with pt=" << track->pt() << " NOT associated to any GenParticle"
342  << "\n";
343  }
344 
345  double dR = 0; //fixme: plots vs dR and vs dRjet not implemented for now
346  histoProducerAlgo_->fill_generic_recoTrack_histos(histograms.histoProducerAlgo,
347  w,
348  *track,
349  ttopo,
350  bs.position(),
351  nullptr,
352  nullptr,
353  isGenMatched,
354  isSigGenMatched,
355  isChargeMatched,
356  numAssocRecoTracks,
357  puinfo.getPU_NumInteractions(),
358  nSimHits,
359  sharedFraction,
360  dR,
361  dR,
362  mvaDummy,
363  0,
364  0);
365 
366  // dE/dx
367  if (dodEdxPlots_)
368  histoProducerAlgo_->fill_dedx_recoTrack_histos(histograms.histoProducerAlgo, w, track, v_dEdx);
369 
370  //Fill other histos
371  //try{ //Is this really necessary ????
372 
373  if (tp.empty())
374  continue;
375 
376  histoProducerAlgo_->fill_simAssociated_recoTrack_histos(histograms.histoProducerAlgo, w, *track);
377 
378  GenParticleRef tpr = tp.begin()->first;
379 
380  /* TO BE FIXED LATER
381  if (associators[ww]=="TrackAssociatorByChi2"){
382  //association chi2
383  double assocChi2 = -tp.begin()->second;//in association map is stored -chi2
384  h_assochi2[www]->Fill(assocChi2);
385  h_assochi2_prob[www]->Fill(TMath::Prob((assocChi2)*5,5));
386  }
387  else if (associators[ww]=="quickTrackAssociatorByHits"){
388  double fraction = tp.begin()->second;
389  h_assocFraction[www]->Fill(fraction);
390  h_assocSharedHit[www]->Fill(fraction*track->numberOfValidHits());
391  }
392  */
393 
394  //Get tracking particle parameters at point of closest approach to the beamline
395  TrackingParticle::Vector momentumTP = parametersDefinerTP->momentum(event, setup, *(tpr.get()));
396  TrackingParticle::Point vertexTP = parametersDefinerTP->vertex(event, setup, *(tpr.get()));
397  int chargeTP = tpr->charge();
398 
399  histoProducerAlgo_->fill_ResoAndPull_recoTrack_histos(
400  histograms.histoProducerAlgo, w, momentumTP, vertexTP, chargeTP, *track, bs.position());
401 
402  //TO BE FIXED
403  //std::vector<PSimHit> simhits=tpr.get()->trackPSimHit(DetId::Tracker);
404  //nrecHit_vs_nsimHit_rec2sim[w]->Fill(track->numberOfValidHits(), (int)(simhits.end()-simhits.begin() ));
405 
406  /*
407  } // End of try{
408  catch (cms::Exception e){
409  LogTrace("TrackValidator") << "exception found: " << e.what() << "\n";
410  }
411  */
412 
413  } // End of for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){
414 
415  histoProducerAlgo_->fill_trackBased_histos(histograms.histoProducerAlgo, w, at, rT, rT, st);
416 
417  edm::LogVerbatim("TrackValidator") << "Total Simulated: " << st << "\n"
418  << "Total Associated (genToReco): " << ats << "\n"
419  << "Total Reconstructed: " << rT << "\n"
420  << "Total Associated (recoToGen): " << at << "\n"
421  << "Total Fakes: " << rT - at << "\n";
422 
423  w++;
424  } // End of for (unsigned int www=0;www<label.size();www++){
425 }
size
Write out results.
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
unsigned int size_type
Definition: View.h:90
edm::EDGetTokenT< reco::GenToRecoCollection > associatormapGtR
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx2Tag
static const std::string kTrackAssociatorByChi2("trackAssociatorByChi2")
const double w
Definition: UKUtility.cc:23
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const_iterator find(const key_type &k) const
find element with specified reference key
int collisionId() const
Definition: GenParticle.h:36
reco::RecoToGenCollection associateRecoToGen(const edm::RefToBaseVector< reco::Track > &tracks, const edm::RefVector< reco::GenParticleCollection > &gens) const
Association Sim To Reco with Collections (Gen Particle version)
uint16_t size_type
edm::EDGetTokenT< reco::BeamSpot > bsSrc
math::XYZPointD Point
point in the space
std::vector< edm::InputTag > associators
edm::EDGetTokenT< reco::TrackToGenParticleAssociator > label_gen_associator
Vector momentum() const final
spatial momentum vector
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > labelToken
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx1Tag
GenParticleCustomSelector gpSelector
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const Point & vertex() const override
vertex position (overwritten by PF...)
virtual TrackingParticle::Vector momentum(const edm::Event &iEvent, const edm::EventSetup &iSetup, const Charge ch, const Point &vtx, const LorentzVector &lv) const
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > label_pileupinfo
std::vector< edm::InputTag > label
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
reco::GenToRecoCollection associateGenToReco(const edm::RefToBaseVector< reco::Track > &tracks, const edm::RefVector< reco::GenParticleCollection > &gens) const
Association Sim To Reco with Collections (Gen Particle version)
#define LogTrace(id)
std::unique_ptr< MTVHistoProducerAlgoForTracker > histoProducerAlgo_
T const * product() const
Definition: Handle.h:69
const bool ignoremissingtkcollection_
const int getPU_NumInteractions() const
fixed size matrix
T get() const
Definition: EventSetup.h:73
edm::EDGetTokenT< TrackingParticleCollection > label_tp_fake
bool isUninitialized() const
Definition: EDGetToken.h:70
const Point & position() const
position
Definition: BeamSpot.h:59
math::XYZVectorD Vector
point in the space
edm::EDGetTokenT< reco::RecoToGenCollection > associatormapRtG
edm::EDGetTokenT< TrackingParticleCollection > label_tp_effic
virtual TrackingParticle::Point vertex(const edm::Event &iEvent, const edm::EventSetup &iSetup, const Charge ch, const Point &vtx, const LorentzVector &lv) const
const bool parametersDefinerIsCosmic_

Member Data Documentation

edm::EDGetTokenT<reco::GenToRecoCollection> MultiTrackValidatorGenPs::associatormapGtR
private

Definition at line 28 of file MultiTrackValidatorGenPs.h.

Referenced by dqmAnalyze(), and MultiTrackValidatorGenPs().

edm::EDGetTokenT<reco::RecoToGenCollection> MultiTrackValidatorGenPs::associatormapRtG
private

Definition at line 29 of file MultiTrackValidatorGenPs.h.

Referenced by dqmAnalyze(), and MultiTrackValidatorGenPs().

GenParticleCustomSelector MultiTrackValidatorGenPs::gpSelector
private

Definition at line 26 of file MultiTrackValidatorGenPs.h.

Referenced by dqmAnalyze(), and MultiTrackValidatorGenPs().

edm::EDGetTokenT<reco::TrackToGenParticleAssociator> MultiTrackValidatorGenPs::label_gen_associator
private

Definition at line 27 of file MultiTrackValidatorGenPs.h.

Referenced by dqmAnalyze(), and MultiTrackValidatorGenPs().