CMS 3D CMS Logo

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

#include <MultiTrackValidatorGenPs.h>

Inheritance diagram for MultiTrackValidatorGenPs:
MultiTrackValidator DQMEDAnalyzer edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > > edm::stream::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &)
 Method called once per event. More...
 
 MultiTrackValidatorGenPs (const edm::ParameterSet &pset)
 Constructor. More...
 
virtual ~MultiTrackValidatorGenPs ()
 Destructor. More...
 
- Public Member Functions inherited from MultiTrackValidator
void analyze (const edm::Event &, const edm::EventSetup &) override
 Method called once per event. More...
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 Method called to book the DQM histograms. More...
 
 MultiTrackValidator (const edm::ParameterSet &pset)
 Constructor. More...
 
virtual ~MultiTrackValidator ()
 Destructor. More...
 
- Public Member Functions inherited from DQMEDAnalyzer
virtual void beginRun (edm::Run const &, edm::EventSetup const &) final
 
virtual void beginStream (edm::StreamID id) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer (void)
 
virtual void endLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
virtual void endRunSummary (edm::Run const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
uint32_t streamId () const
 
- Public Member Functions inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::stream::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- 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
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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 edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDAnalyzerBase
typedef EDAnalyzerAdaptorBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static std::shared_ptr< dqmDetails::NoCacheglobalBeginLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
 
static std::shared_ptr< dqmDetails::NoCacheglobalBeginRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *)
 
static void globalEndLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *, dqmDetails::NoCache *)
 
static void globalEndRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *, dqmDetails::NoCache *)
 
- Static Public Member Functions inherited from edm::stream::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 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 
40  gpSelector = GenParticleCustomSelector(pset.getParameter<double>("ptMinGP"),
41  pset.getParameter<double>("minRapidityGP"),
42  pset.getParameter<double>("maxRapidityGP"),
43  pset.getParameter<double>("tipGP"),
44  pset.getParameter<double>("lipGP"),
45  pset.getParameter<bool>("chargedOnlyGP"),
46  pset.getParameter<int>("statusGP"),
47  pset.getParameter<std::vector<int> >("pdgIdGP"));
48 
49  if(useAssociators_) {
50  for(auto const& src: associators) {
51  if( src.label() == kTrackAssociatorByChi2) {
52  label_gen_associator = consumes<reco::TrackToGenParticleAssociator>(src);
53  break;
54  }
55  }
56  }
57  else {
58  for (auto const& src: associators) {
59  associatormapGtR = consumes<reco::GenToRecoCollection>(src);
60  associatormapRtG = consumes<reco::RecoToGenCollection>(src);
61  break;
62  }
63  }
64 }
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
MultiTrackValidator(const edm::ParameterSet &pset)
Constructor.
SingleObjectSelector< GenParticleCollection,::GenParticleCustomSelector > GenParticleCustomSelector
edm::EDGetTokenT< reco::RecoToGenCollection > associatormapRtG
MultiTrackValidatorGenPs::~MultiTrackValidatorGenPs ( )
virtual

Destructor.

Definition at line 66 of file MultiTrackValidatorGenPs.cc.

66 {}

Member Function Documentation

void MultiTrackValidatorGenPs::analyze ( const edm::Event event,
const edm::EventSetup setup 
)

Method called once per event.

Definition at line 69 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_, PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, edm::AssociationMap< Tag >::end(), edm::AssociationMap< Tag >::find(), plotBeamSpotDB::first, edm::EventSetup::get(), edm::Ref< C, T, F >::get(), edm::Event::getByToken(), PileupSummaryInfo::getPU_NumInteractions(), gpSelector, 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(), HiIsolationCommonParameters_cff::track, findElectronsInSiStrips_cfi::trackCollection, MultiTrackValidator::useAssociators_, ParametersDefinerForTP::vertex(), reco::LeafCandidate::vertex(), and w.

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

Referenced by analyze(), and MultiTrackValidatorGenPs().

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

Definition at line 30 of file MultiTrackValidatorGenPs.h.

Referenced by analyze(), and MultiTrackValidatorGenPs().

GenParticleCustomSelector MultiTrackValidatorGenPs::gpSelector
private

Definition at line 27 of file MultiTrackValidatorGenPs.h.

Referenced by analyze(), and MultiTrackValidatorGenPs().

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

Definition at line 28 of file MultiTrackValidatorGenPs.h.

Referenced by analyze(), and MultiTrackValidatorGenPs().