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 > DQMGlobalEDAnalyzerBase< MultiTrackValidatorHistograms, Args... > edm::global::EDProducer< edm::RunCache< MultiTrackValidatorHistograms >, edm::EndRunProducer, edm::Accumulator, Args... > edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

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...
 
 MultiTrackValidator (const edm::ParameterSet &pset)
 Constructor. More...
 
 ~MultiTrackValidator () override
 Destructor. More...
 
- Public Member Functions inherited from DQMGlobalEDAnalyzer< MultiTrackValidatorHistograms >
virtual void dqmEndRun (edm::Run const &, edm::EventSetup const &, MultiTrackValidatorHistograms const &) const
 
void globalEndRunProduce (edm::Run &run, edm::EventSetup const &setup) const final
 
- Public Member Functions inherited from DQMGlobalEDAnalyzerBase< MultiTrackValidatorHistograms, Args... >
void accumulate (edm::StreamID id, edm::Event const &event, edm::EventSetup const &setup) const final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &, MultiTrackValidatorHistograms &) const
 
 DQMGlobalEDAnalyzerBase ()
 
std::shared_ptr< MultiTrackValidatorHistogramsglobalBeginRun (edm::Run const &run, edm::EventSetup const &setup) const final
 
void globalEndRun (edm::Run const &, edm::EventSetup const &) const final
 
- Public Member Functions inherited from edm::global::EDProducer< edm::RunCache< MultiTrackValidatorHistograms >, edm::EndRunProducer, edm::Accumulator, Args... >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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 DQMGlobalEDAnalyzerBase< MultiTrackValidatorHistograms, Args... >
typedef dqm::reco::DQMStore DQMStore
 
typedef dqm::reco::MonitorElement MonitorElement
 
- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from DQMGlobalEDAnalyzerBase< MultiTrackValidatorHistograms, Args... >
uint64_t meId (edm::Run const &run) const
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 
- Protected Attributes inherited from MultiTrackValidator
const bool applyTPSelToSimMatch_
 
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
 
const bool parametersDefinerIsCosmic_
 
std::unique_ptr< ParametersDefinerForTPparametersDefinerTP_
 
std::vector< edm::EDGetTokenT< std::vector< PSimHit > > > simHitTokens_
 
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtTopoEsToken
 
const bool useAssociators_
 
- Protected Attributes inherited from DQMGlobalEDAnalyzerBase< MultiTrackValidatorHistograms, Args... >
DQMStoredqmstore_
 
edm::EDPutTokenT< DQMTokenrunToken_
 

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::MultiTrackValidatorGenPs ( const edm::ParameterSet pset)

Constructor.

Definition at line 35 of file MultiTrackValidatorGenPs.cc.

References associatormapGtR, associatormapRtG, MultiTrackValidator::associators, gpSelector, kTrackAssociatorByChi2(), label_gen_associator, muonDTDigis_cfi::pset, TrackRefitter_38T_cff::src, and MultiTrackValidator::useAssociators_.

36  gpSelector = GenParticleCustomSelector(pset.getParameter<double>("ptMinGP"),
37  pset.getParameter<double>("minRapidityGP"),
38  pset.getParameter<double>("maxRapidityGP"),
39  pset.getParameter<double>("tipGP"),
40  pset.getParameter<double>("lipGP"),
41  pset.getParameter<bool>("chargedOnlyGP"),
42  pset.getParameter<int>("statusGP"),
43  pset.getParameter<std::vector<int> >("pdgIdGP"));
44 
45  if (useAssociators_) {
46  for (auto const& src : associators) {
47  if (src.label() == kTrackAssociatorByChi2) {
48  label_gen_associator = consumes<reco::TrackToGenParticleAssociator>(src);
49  break;
50  }
51  }
52  } else {
53  for (auto const& src : associators) {
54  associatormapGtR = consumes<reco::GenToRecoCollection>(src);
55  associatormapRtG = consumes<reco::RecoToGenCollection>(src);
56  break;
57  }
58  }
59 }
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::~MultiTrackValidatorGenPs ( )
override

Destructor.

Definition at line 61 of file MultiTrackValidatorGenPs.cc.

61 {}

Member Function Documentation

◆ dqmAnalyze()

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

Method called once per event.

Reimplemented from MultiTrackValidator.

Definition at line 63 of file MultiTrackValidatorGenPs.cc.

References reco::TrackToGenParticleAssociator::associateGenToReco(), reco::TrackToGenParticleAssociator::associateRecoToGen(), associatormapGtR, associatormapRtG, MultiTrackValidator::associators, cms::cuda::bs, MultiTrackValidator::bsSrc, funct::cos(), MultiTrackValidator::dodEdxPlots_, MultiTrackValidator::doRecoTrackPlots_, MultiTrackValidator::doSimPlots_, MultiTrackValidator::doSimTrackPlots_, HGC3DClusterGenMatchSelector_cfi::dR, edm::AssociationMap< Tag >::end(), edm::AssociationMap< Tag >::find(), dqmdumpme::first, edm::Ref< C, T, F >::get(), 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, MultiTrackValidator::parametersDefinerIsCosmic_, MultiTrackValidator::parametersDefinerTP_, edm::Handle< T >::product(), hcal_runs::rt, singleTopDQM_cfi::setup, funct::sin(), findQualityFiles::size, mathSSE::sqrt(), cmsswSequenceInfo::tp, HLT_2024v14_cff::track, JetHT_cfg::trackCollection, MultiTrackValidator::tTopoEsToken, MultiTrackValidator::useAssociators_, bphysicsOniaDQM_cfi::vertex, and w().

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

Member Data Documentation

◆ associatormapGtR

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

Definition at line 28 of file MultiTrackValidatorGenPs.h.

Referenced by dqmAnalyze(), and MultiTrackValidatorGenPs().

◆ associatormapRtG

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

Definition at line 29 of file MultiTrackValidatorGenPs.h.

Referenced by dqmAnalyze(), and MultiTrackValidatorGenPs().

◆ gpSelector

GenParticleCustomSelector MultiTrackValidatorGenPs::gpSelector
private

Definition at line 26 of file MultiTrackValidatorGenPs.h.

Referenced by dqmAnalyze(), and MultiTrackValidatorGenPs().

◆ label_gen_associator

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

Definition at line 27 of file MultiTrackValidatorGenPs.h.

Referenced by dqmAnalyze(), and MultiTrackValidatorGenPs().