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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::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 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 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<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
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_2022v15_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  unsigned sts(0); //This counter counts the number of simTracks surviving the bunchcrossing cut
181  unsigned asts(
182  0); //This counter counts the number of simTracks that are "associated" to recoTracks surviving the bunchcrossing cut
183  for (GenParticleCollection::size_type i = 0; i < tPCeff.size();
184  i++) { //loop over TPs collection for tracking efficiency
185  GenParticleRef tpr(TPCollectionHeff, i);
186  GenParticle* tp = const_cast<GenParticle*>(tpr.get());
187  TrackingParticle::Vector momentumTP;
188  TrackingParticle::Point vertexTP;
189  double dxyGen(0);
190  double dzGen(0);
191 
192  //---------- THIS PART HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
193  //If the GenParticle is collison like, get the momentum and vertex at production state
195  //fixme this one shold be implemented
196  if (!gpSelector(*tp))
197  continue;
198  momentumTP = tp->momentum();
199  vertexTP = tp->vertex();
200  //Calcualte the impact parameters w.r.t. PCA
203  dxyGen = (-vertex.x() * sin(momentum.phi()) + vertex.y() * cos(momentum.phi()));
204  dzGen = vertex.z() - (vertex.x() * momentum.x() + vertex.y() * momentum.y()) / sqrt(momentum.perp2()) *
205  momentum.z() / sqrt(momentum.perp2());
206  }
207  //If the GenParticle is comics, get the momentum and vertex at PCA
208  else {
209  //if(! cosmictpSelector(*tp,&bs,event,setup)) continue;
210  momentumTP = parametersDefinerTP_->momentum(event, setup, *tp);
211  vertexTP = parametersDefinerTP_->vertex(event, setup, *tp);
212  dxyGen = (-vertexTP.x() * sin(momentumTP.phi()) + vertexTP.y() * cos(momentumTP.phi()));
213  dzGen = vertexTP.z() - (vertexTP.x() * momentumTP.x() + vertexTP.y() * momentumTP.y()) /
214  sqrt(momentumTP.perp2()) * momentumTP.z() / sqrt(momentumTP.perp2());
215  }
216  //---------- THE PART ABOVE HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
217 
218  st++; //This counter counts the number of simulated tracks passing the MTV selection (i.e. tpSelector(tp) )
219 
220  // in the coming lines, histos are filled using as input
221  // - momentumTP
222  // - vertexTP
223  // - dxyGen
224  // - dzGen
225 
226  if (doSimPlots_ && w == 0) {
227  histoProducerAlgo_->fill_generic_simTrack_histos(histograms.histoProducerAlgo,
228  momentumTP,
229  vertexTP,
230  tp->collisionId()); //fixme: check meaning of collisionId
231  }
232  if (!doSimTrackPlots_)
233  continue;
234 
235  // ##############################################
236  // fill RecoAssociated GenTracks' histograms
237  // ##############################################
238  // bool isRecoMatched(false); // UNUSED
239  const reco::Track* matchedTrackPointer = nullptr;
240  std::vector<std::pair<RefToBase<Track>, double> > rt;
241  if (genRecColl.find(tpr) != genRecColl.end()) {
242  rt = (std::vector<std::pair<RefToBase<Track>, double> >)genRecColl[tpr];
243  if (!rt.empty()) {
244  ats++; //This counter counts the number of simTracks that have a recoTrack associated
245  // isRecoMatched = true; // UNUSED
246  matchedTrackPointer = rt.begin()->first.get();
247  edm::LogVerbatim("TrackValidator") << "GenParticle #" << st << " with pt=" << sqrt(momentumTP.perp2())
248  << " associated with quality:" << rt.begin()->second << "\n";
249  }
250  } else {
251  edm::LogVerbatim("TrackValidator") << "GenParticle #" << st << " with pt,eta,phi: " << sqrt(momentumTP.perp2())
252  << " , " << momentumTP.eta() << " , " << momentumTP.phi() << " , "
253  << " NOT associated to any reco::Track"
254  << "\n";
255  }
256 
257  int nSimHits = 0;
258  histoProducerAlgo_->fill_recoAssociated_simTrack_histos(histograms.histoProducerAlgo,
259  w,
260  *tp,
261  momentumTP,
262  vertexTP,
263  dxyGen,
264  dzGen,
265  nSimHits,
266  matchedTrackPointer,
267  puinfo.getPU_NumInteractions());
268 
269  sts++;
270  if (matchedTrackPointer)
271  asts++;
272 
273  } // End for (GenParticleCollection::size_type i=0; i<tPCeff.size(); i++){
274 
275  if (doSimPlots_ && w == 0) {
276  histoProducerAlgo_->fill_simTrackBased_histos(histograms.histoProducerAlgo, st);
277  }
278 
279  // ##############################################
280  // fill recoTracks histograms (LOOP OVER TRACKS)
281  // ##############################################
282  if (!doRecoTrackPlots_)
283  continue;
284  edm::LogVerbatim("TrackValidator") << "\n# of reco::Tracks with " << label[www].process() << ":"
285  << label[www].label() << ":" << label[www].instance() << ": "
286  << trackCollection->size() << "\n";
287 
288  //int sat(0); //This counter counts the number of recoTracks that are associated to GenTracks from Signal only
289  int at(0); //This counter counts the number of recoTracks that are associated to GenTracks
290  int rT(0); //This counter counts the number of recoTracks in general
291 
292  for (View<Track>::size_type i = 0; i < trackCollection->size(); ++i) {
294  rT++;
295 
296  bool isSigGenMatched(false);
297  bool isGenMatched(false);
298  bool isChargeMatched(true);
299  int numAssocRecoTracks = 0;
300  int nSimHits = 0;
301  double sharedFraction = 0.;
302  std::vector<std::pair<GenParticleRef, double> > tp;
303  if (recGenColl.find(track) != recGenColl.end()) {
304  tp = recGenColl[track];
305  if (!tp.empty()) {
306  /*
307  std::vector<PSimHit> simhits=tp[0].first->trackPSimHit(DetId::Tracker);
308  nSimHits = simhits.end()-simhits.begin();
309  */
310  sharedFraction = tp[0].second;
311  isGenMatched = true;
312  if (tp[0].first->charge() != track->charge())
313  isChargeMatched = false;
314  if (genRecColl.find(tp[0].first) != genRecColl.end())
315  numAssocRecoTracks = genRecColl[tp[0].first].size();
316  //std::cout << numAssocRecoTracks << std::endl;
317  at++;
318  for (unsigned int tp_ite = 0; tp_ite < tp.size(); ++tp_ite) {
319  GenParticle trackpart = *(tp[tp_ite].first);
320  /*
321  if ((trackpart.eventId().event() == 0) && (trackpart.eventId().bunchCrossing() == 0)){
322  isSigGenMatched = true;
323  sat++;
324  break;
325  }
326  */
327  }
328  edm::LogVerbatim("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt()
329  << " associated with quality:" << tp.begin()->second << "\n";
330  }
331  } else {
332  edm::LogVerbatim("TrackValidator")
333  << "reco::Track #" << rT << " with pt=" << track->pt() << " NOT associated to any GenParticle"
334  << "\n";
335  }
336 
337  double dR = 0; //fixme: plots vs dR and vs dRjet not implemented for now
338  histoProducerAlgo_->fill_generic_recoTrack_histos(histograms.histoProducerAlgo,
339  w,
340  *track,
341  ttopo,
342  bs.position(),
343  nullptr,
344  nullptr,
345  isGenMatched,
346  isSigGenMatched,
347  isChargeMatched,
348  numAssocRecoTracks,
349  puinfo.getPU_NumInteractions(),
350  nSimHits,
351  sharedFraction,
352  dR,
353  dR,
354  mvaDummy,
355  0,
356  0);
357 
358  // dE/dx
359  if (dodEdxPlots_)
360  histoProducerAlgo_->fill_dedx_recoTrack_histos(histograms.histoProducerAlgo, w, track, v_dEdx);
361 
362  //Fill other histos
363  //try{ //Is this really necessary ????
364 
365  if (tp.empty())
366  continue;
367 
368  histoProducerAlgo_->fill_simAssociated_recoTrack_histos(histograms.histoProducerAlgo, w, *track);
369 
370  GenParticleRef tpr = tp.begin()->first;
371 
372  /* TO BE FIXED LATER
373  if (associators[ww]=="TrackAssociatorByChi2"){
374  //association chi2
375  double assocChi2 = -tp.begin()->second;//in association map is stored -chi2
376  h_assochi2[www]->Fill(assocChi2);
377  h_assochi2_prob[www]->Fill(TMath::Prob((assocChi2)*5,5));
378  }
379  else if (associators[ww]=="quickTrackAssociatorByHits"){
380  double fraction = tp.begin()->second;
381  h_assocFraction[www]->Fill(fraction);
382  h_assocSharedHit[www]->Fill(fraction*track->numberOfValidHits());
383  }
384  */
385 
386  //Get tracking particle parameters at point of closest approach to the beamline
387  TrackingParticle::Vector momentumTP = parametersDefinerTP_->momentum(event, setup, *(tpr.get()));
388  TrackingParticle::Point vertexTP = parametersDefinerTP_->vertex(event, setup, *(tpr.get()));
389  int chargeTP = tpr->charge();
390 
391  histoProducerAlgo_->fill_ResoAndPull_recoTrack_histos(
392  histograms.histoProducerAlgo, w, momentumTP, vertexTP, chargeTP, *track, bs.position());
393 
394  //TO BE FIXED
395  //std::vector<PSimHit> simhits=tpr.get()->trackPSimHit(DetId::Tracker);
396  //nrecHit_vs_nsimHit_rec2sim[w]->Fill(track->numberOfValidHits(), (int)(simhits.end()-simhits.begin() ));
397 
398  /*
399  } // End of try{
400  catch (cms::Exception e){
401  LogTrace("TrackValidator") << "exception found: " << e.what() << "\n";
402  }
403  */
404 
405  } // End of for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){
406 
407  histoProducerAlgo_->fill_trackBased_histos(histograms.histoProducerAlgo, w, at, rT, rT, st);
408 
409  edm::LogVerbatim("TrackValidator") << "Total Simulated: " << st << "\n"
410  << "Total Associated (genToReco): " << ats << "\n"
411  << "Total Reconstructed: " << rT << "\n"
412  << "Total Associated (recoToGen): " << at << "\n"
413  << "Total Fakes: " << rT - at << "\n";
414 
415  w++;
416  } // End of for (unsigned int www=0;www<label.size();www++){
417 }
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:90
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().