CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes
MultiTrackValidator Class Reference

#include <MultiTrackValidator.h>

Inheritance diagram for MultiTrackValidator:
DQMGlobalEDAnalyzer< MultiTrackValidatorHistograms > DQMGlobalEDAnalyzerBase< MultiTrackValidatorHistograms, Args...> edm::global::EDProducer< T > edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper MultiTrackValidatorGenPs

Public Types

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
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
 

Public Member Functions

void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, Histograms &) const override
 Method called to book the DQM histograms. More...
 
void dqmAnalyze (const edm::Event &, const edm::EventSetup &, const Histograms &) const override
 Method called once per event. More...
 
 MultiTrackValidator (const edm::ParameterSet &pset)
 Constructor. More...
 
 ~MultiTrackValidator () override
 Destructor. More...
 
- Public Member Functions inherited from DQMGlobalEDAnalyzer< MultiTrackValidatorHistograms >
virtual void dqmEndRun (edm::Run const &, edm::EventSetup const &, MultiTrackValidatorHistogramsconst &) 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
< MultiTrackValidatorHistograms
globalBeginRun (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< T >
 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
 
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)
 
 ~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)
 

Protected Attributes

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
< MTVHistoProducerAlgoForTracker
histoProducerAlgo_
 
const bool ignoremissingtkcollection_
 
std::vector< edm::InputTaglabel
 
edm::EDGetTokenT< std::vector
< PileupSummaryInfo > > 
label_pileupinfo
 
edm::EDGetTokenT
< TrackingParticleCollection
label_tp_effic
 
edm::EDGetTokenT
< TrackingParticleRefVector
label_tp_effic_refvector
 
edm::EDGetTokenT
< TrackingParticleCollection
label_tp_fake
 
edm::EDGetTokenT
< TrackingParticleRefVector
label_tp_fake_refvector
 
edm::EDGetTokenT
< TrackingVertexCollection
label_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
< ParametersDefinerForTP
parametersDefinerTP_
 
std::vector< edm::EDGetTokenT
< std::vector< PSimHit > > > 
simHitTokens_
 
const edm::ESGetToken
< TrackerTopology,
TrackerTopologyRcd
tTopoEsToken
 
const bool useAssociators_
 
- Protected Attributes inherited from DQMGlobalEDAnalyzerBase< MultiTrackValidatorHistograms, Args...>
DQMStoredqmstore_
 
edm::EDPutTokenT< DQMTokenrunToken_
 

Private Types

using MVACollection = std::vector< float >
 
using QualityMaskCollection = std::vector< unsigned char >
 

Private Member Functions

const reco::Vertex::PointgetRecoPVPosition (const edm::Event &event, const edm::Handle< TrackingVertexCollection > &htv) const
 
const
TrackingVertex::LorentzVector
getSimPVPosition (const edm::Handle< TrackingVertexCollection > &htv) const
 
size_t tpDR (const TrackingParticleRefVector &tPCeff, const std::vector< size_t > &selected_tPCeff, DynArray< float > &dR_tPCeff, DynArray< float > &dR_tPCeff_jet, const edm::View< reco::Candidate > *cores) const
 
void tpParametersAndSelection (const Histograms &histograms, const TrackingParticleRefVector &tPCeff, const edm::Event &event, const edm::EventSetup &setup, const reco::BeamSpot &bs, std::vector< std::tuple< TrackingParticle::Vector, TrackingParticle::Point >> &momVert_tPCeff, std::vector< size_t > &selected_tPCeff) const
 
void trackDR (const edm::View< reco::Track > &trackCollection, const edm::View< reco::Track > &trackCollectionDr, DynArray< float > &dR_trk, DynArray< float > &dR_trk_jet, const edm::View< reco::Candidate > *cores) const
 

Private Attributes

edm::EDGetTokenT
< SimHitTPAssociationProducer::SimHitTPAssociationList
_simHitTpMapTag
 
std::vector< edm::EDGetTokenT
< reco::RecoToSimCollection > > 
associatormapRtSs
 
std::vector< edm::EDGetTokenT
< reco::SimToRecoCollection > > 
associatormapStRs
 
std::vector< edm::EDGetTokenT
< reco::TrackToTrackingParticleAssociator > > 
associatorTokens
 
edm::EDGetTokenT< edm::View
< reco::Candidate > > 
cores_
 
CosmicTrackingParticleSelector cosmictpSelector
 
std::string dirName_
 
TrackingParticleSelector dRtpSelector
 
std::unique_ptr
< RecoTrackSelectorBase
dRTrackSelector
 
edm::EDGetTokenT< edm::View
< reco::Track > > 
labelTokenForDrCalculation
 
std::vector< std::vector
< std::tuple< edm::EDGetTokenT
< MVACollection >
, edm::EDGetTokenT
< QualityMaskCollection > > > > 
mvaQualityCollectionTokens_
 
double ptMinJet_
 
edm::EDGetTokenT< edm::View
< reco::Vertex > > 
recoVertexToken_
 
const double simPVMaxZ_
 
edm::EDGetTokenT
< edm::ValueMap< unsigned int > > 
tpNLayersToken_
 
edm::EDGetTokenT
< edm::ValueMap< unsigned int > > 
tpNPixelLayersToken_
 
edm::EDGetTokenT
< edm::ValueMap< unsigned int > > 
tpNStripStereoLayersToken_
 
TrackingParticleSelector tpSelector
 
bool useGsf
 
edm::EDGetTokenT
< reco::VertexToTrackingVertexAssociator
vertexAssociatorToken_
 

Additional Inherited Members

- 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
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< B > consumes (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 () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
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)
 

Detailed Description

Class that prodecs histrograms to validate Track Reconstruction performances

Author
cerati

Definition at line 39 of file MultiTrackValidator.h.

Member Typedef Documentation

Definition at line 41 of file MultiTrackValidator.h.

using MultiTrackValidator::MVACollection = std::vector<float>
private

Definition at line 129 of file MultiTrackValidator.h.

using MultiTrackValidator::QualityMaskCollection = std::vector<unsigned char>
private

Definition at line 130 of file MultiTrackValidator.h.

Constructor & Destructor Documentation

MultiTrackValidator::MultiTrackValidator ( const edm::ParameterSet pset)

Constructor.

Definition at line 48 of file MultiTrackValidator.cc.

References HLT_FULL_cff::beamSpotTag, SplitLinear::begin, bsSrc, edm::EDConsumerBase::consumes(), edm::EDConsumerBase::consumesCollector(), cores_, dirName_, dodEdxPlots_, doMVAPlots_, doPlotsOnlyForTruePV_, doPVAssociationPlots_, doResolutionPlots_, TrackValidation_cff::doResolutionPlotsForLabels, doSeedPlots_, relativeConstraints::empty, dataset::end, Exception, spr::find(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), histoProducerAlgo_, cmsLHEtoEOSManager::l, edm::InputTag::label(), label, label_pileupinfo, label_tp_effic, label_tp_effic_refvector, label_tp_fake, label_tp_fake_refvector, label_tv, HLT_FULL_cff::labels, edm::EDConsumerBase::labelsForToken(), labelToken, m_dEdx1Tag, m_dEdx2Tag, edm::ProductLabels::module, mvaQualityCollectionTokens_, parametersDefinerIsCosmic_, parametersDefinerTP_, recoVertexToken_, simHitTokens_, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, tpNLayersToken_, tpNPixelLayersToken_, tpNStripStereoLayersToken_, edm::vector_transform(), and vertexAssociatorToken_.

50  parametersDefinerIsCosmic_(pset.getParameter<std::string>("parametersDefiner") == "CosmicParametersDefinerForTP"),
51  associators(pset.getUntrackedParameter<std::vector<edm::InputTag>>("associators")),
52  label(pset.getParameter<std::vector<edm::InputTag>>("label")),
53  ignoremissingtkcollection_(pset.getUntrackedParameter<bool>("ignoremissingtrackcollection", false)),
54  useAssociators_(pset.getParameter<bool>("UseAssociators")),
55  calculateDrSingleCollection_(pset.getUntrackedParameter<bool>("calculateDrSingleCollection")),
56  doPlotsOnlyForTruePV_(pset.getUntrackedParameter<bool>("doPlotsOnlyForTruePV")),
57  doSummaryPlots_(pset.getUntrackedParameter<bool>("doSummaryPlots")),
58  doSimPlots_(pset.getUntrackedParameter<bool>("doSimPlots")),
59  doSimTrackPlots_(pset.getUntrackedParameter<bool>("doSimTrackPlots")),
60  doRecoTrackPlots_(pset.getUntrackedParameter<bool>("doRecoTrackPlots")),
61  dodEdxPlots_(pset.getUntrackedParameter<bool>("dodEdxPlots")),
62  doPVAssociationPlots_(pset.getUntrackedParameter<bool>("doPVAssociationPlots")),
63  doSeedPlots_(pset.getUntrackedParameter<bool>("doSeedPlots")),
64  doMVAPlots_(pset.getUntrackedParameter<bool>("doMVAPlots")),
65  simPVMaxZ_(pset.getUntrackedParameter<double>("simPVMaxZ")) {
66  if (not(pset.getParameter<edm::InputTag>("cores").label().empty())) {
67  cores_ = consumes<edm::View<reco::Candidate>>(pset.getParameter<edm::InputTag>("cores"));
68  }
69  if (label.empty()) {
70  // Disable prefetching of everything if there are no track collections
71  return;
72  }
73 
74  const edm::InputTag& label_tp_effic_tag = pset.getParameter<edm::InputTag>("label_tp_effic");
75  const edm::InputTag& label_tp_fake_tag = pset.getParameter<edm::InputTag>("label_tp_fake");
76 
77  if (pset.getParameter<bool>("label_tp_effic_refvector")) {
78  label_tp_effic_refvector = consumes<TrackingParticleRefVector>(label_tp_effic_tag);
79  } else {
80  label_tp_effic = consumes<TrackingParticleCollection>(label_tp_effic_tag);
81  }
82  if (pset.getParameter<bool>("label_tp_fake_refvector")) {
83  label_tp_fake_refvector = consumes<TrackingParticleRefVector>(label_tp_fake_tag);
84  } else {
85  label_tp_fake = consumes<TrackingParticleCollection>(label_tp_fake_tag);
86  }
87  label_pileupinfo = consumes<std::vector<PileupSummaryInfo>>(pset.getParameter<edm::InputTag>("label_pileupinfo"));
88  for (const auto& tag : pset.getParameter<std::vector<edm::InputTag>>("sim")) {
89  simHitTokens_.push_back(consumes<std::vector<PSimHit>>(tag));
90  }
91 
92  std::vector<edm::InputTag> doResolutionPlotsForLabels =
93  pset.getParameter<std::vector<edm::InputTag>>("doResolutionPlotsForLabels");
94  doResolutionPlots_.reserve(label.size());
95  for (auto& itag : label) {
96  labelToken.push_back(consumes<edm::View<reco::Track>>(itag));
97  const bool doResol = doResolutionPlotsForLabels.empty() ||
98  (std::find(cbegin(doResolutionPlotsForLabels), cend(doResolutionPlotsForLabels), itag) !=
99  cend(doResolutionPlotsForLabels));
100  doResolutionPlots_.push_back(doResol);
101  }
102  { // check for duplicates
103  auto labelTmp = edm::vector_transform(label, [&](const edm::InputTag& tag) { return tag.label(); });
104  std::sort(begin(labelTmp), end(labelTmp));
106  const std::string* prev = &empty;
107  for (const std::string& l : labelTmp) {
108  if (l == *prev) {
109  throw cms::Exception("Configuration") << "Duplicate InputTag in labels: " << l;
110  }
111  prev = &l;
112  }
113  }
114 
116  bsSrc = consumes<reco::BeamSpot>(beamSpotTag);
117 
119  parametersDefinerTP_ = std::make_unique<CosmicParametersDefinerForTP>(consumesCollector());
120  } else {
121  parametersDefinerTP_ = std::make_unique<ParametersDefinerForTP>(beamSpotTag, consumesCollector());
122  }
123 
124  ParameterSet psetForHistoProducerAlgo = pset.getParameter<ParameterSet>("histoProducerAlgoBlock");
125  histoProducerAlgo_ = std::make_unique<MTVHistoProducerAlgoForTracker>(psetForHistoProducerAlgo, doSeedPlots_);
126 
127  dirName_ = pset.getParameter<std::string>("dirName");
128 
129  tpNLayersToken_ = consumes<edm::ValueMap<unsigned int>>(pset.getParameter<edm::InputTag>("label_tp_nlayers"));
131  consumes<edm::ValueMap<unsigned int>>(pset.getParameter<edm::InputTag>("label_tp_npixellayers"));
133  consumes<edm::ValueMap<unsigned int>>(pset.getParameter<edm::InputTag>("label_tp_nstripstereolayers"));
134 
135  if (dodEdxPlots_) {
136  m_dEdx1Tag = consumes<edm::ValueMap<reco::DeDxData>>(pset.getParameter<edm::InputTag>("dEdx1Tag"));
137  m_dEdx2Tag = consumes<edm::ValueMap<reco::DeDxData>>(pset.getParameter<edm::InputTag>("dEdx2Tag"));
138  }
139 
140  label_tv = consumes<TrackingVertexCollection>(pset.getParameter<edm::InputTag>("label_tv"));
142  recoVertexToken_ = consumes<edm::View<reco::Vertex>>(pset.getUntrackedParameter<edm::InputTag>("label_vertex"));
144  consumes<reco::VertexToTrackingVertexAssociator>(pset.getUntrackedParameter<edm::InputTag>("vertexAssociator"));
145  }
146 
147  if (doMVAPlots_) {
149  auto mvaPSet = pset.getUntrackedParameter<edm::ParameterSet>("mvaLabels");
150  for (size_t iIter = 0; iIter < labelToken.size(); ++iIter) {
152  labelsForToken(labelToken[iIter], labels);
153  if (mvaPSet.exists(labels.module)) {
155  mvaPSet.getUntrackedParameter<std::vector<std::string>>(labels.module), [&](const std::string& tag) {
156  return std::make_tuple(consumes<MVACollection>(edm::InputTag(tag, "MVAValues")),
157  consumes<QualityMaskCollection>(edm::InputTag(tag, "QualityMasks")));
158  });
159  }
160  }
161  }
162 
163  tpSelector = TrackingParticleSelector(pset.getParameter<double>("ptMinTP"),
164  pset.getParameter<double>("ptMaxTP"),
165  pset.getParameter<double>("minRapidityTP"),
166  pset.getParameter<double>("maxRapidityTP"),
167  pset.getParameter<double>("tipTP"),
168  pset.getParameter<double>("lipTP"),
169  pset.getParameter<int>("minHitTP"),
170  pset.getParameter<bool>("signalOnlyTP"),
171  pset.getParameter<bool>("intimeOnlyTP"),
172  pset.getParameter<bool>("chargedOnlyTP"),
173  pset.getParameter<bool>("stableOnlyTP"),
174  pset.getParameter<std::vector<int>>("pdgIdTP"),
175  pset.getParameter<bool>("invertRapidityCutTP"));
176 
178  pset.getParameter<double>("minRapidityTP"),
179  pset.getParameter<double>("maxRapidityTP"),
180  pset.getParameter<double>("tipTP"),
181  pset.getParameter<double>("lipTP"),
182  pset.getParameter<int>("minHitTP"),
183  pset.getParameter<bool>("chargedOnlyTP"),
184  pset.getParameter<std::vector<int>>("pdgIdTP"));
185 
186  ParameterSet psetVsPhi = psetForHistoProducerAlgo.getParameter<ParameterSet>("TpSelectorForEfficiencyVsPhi");
187  dRtpSelector = TrackingParticleSelector(psetVsPhi.getParameter<double>("ptMin"),
188  psetVsPhi.getParameter<double>("ptMax"),
189  psetVsPhi.getParameter<double>("minRapidity"),
190  psetVsPhi.getParameter<double>("maxRapidity"),
191  psetVsPhi.getParameter<double>("tip"),
192  psetVsPhi.getParameter<double>("lip"),
193  psetVsPhi.getParameter<int>("minHit"),
194  psetVsPhi.getParameter<bool>("signalOnly"),
195  psetVsPhi.getParameter<bool>("intimeOnly"),
196  psetVsPhi.getParameter<bool>("chargedOnly"),
197  psetVsPhi.getParameter<bool>("stableOnly"),
198  psetVsPhi.getParameter<std::vector<int>>("pdgId"),
199  psetVsPhi.getParameter<bool>("invertRapidityCut"));
200 
202 
203  useGsf = pset.getParameter<bool>("useGsf");
204 
205  _simHitTpMapTag = mayConsume<SimHitTPAssociationProducer::SimHitTPAssociationList>(
206  pset.getParameter<edm::InputTag>("simHitTpMapTag"));
207 
210  consumes<edm::View<reco::Track>>(pset.getParameter<edm::InputTag>("trackCollectionForDrCalculation"));
211  }
212 
213  if (useAssociators_) {
214  for (auto const& src : associators) {
215  associatorTokens.push_back(consumes<reco::TrackToTrackingParticleAssociator>(src));
216  }
217  } else {
218  for (auto const& src : associators) {
219  associatormapStRs.push_back(consumes<reco::SimToRecoCollection>(src));
220  associatormapRtSs.push_back(consumes<reco::RecoToSimCollection>(src));
221  }
222  }
223 }
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoEsToken
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< SimHitTPAssociationProducer::SimHitTPAssociationList > _simHitTpMapTag
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx2Tag
std::vector< edm::EDGetTokenT< reco::SimToRecoCollection > > associatormapStRs
CosmicTrackingParticleSelector cosmictpSelector
std::vector< std::vector< std::tuple< edm::EDGetTokenT< MVACollection >, edm::EDGetTokenT< QualityMaskCollection > > > > mvaQualityCollectionTokens_
edm::EDGetTokenT< edm::ValueMap< unsigned int > > tpNStripStereoLayersToken_
edm::EDGetTokenT< edm::ValueMap< unsigned int > > tpNLayersToken_
TrackingParticleSelector dRtpSelector
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > > associatorTokens
const bool doPlotsOnlyForTruePV_
edm::EDGetTokenT< reco::BeamSpot > bsSrc
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::ValueMap< unsigned int > > tpNPixelLayersToken_
std::vector< edm::InputTag > associators
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > labelToken
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx1Tag
std::vector< edm::EDGetTokenT< reco::RecoToSimCollection > > associatormapRtSs
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
TrackingParticleSelector tpSelector
std::vector< bool > doResolutionPlots_
edm::EDGetTokenT< edm::View< reco::Track > > labelTokenForDrCalculation
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > label_pileupinfo
std::vector< edm::InputTag > label
std::unique_ptr< ParametersDefinerForTP > parametersDefinerTP_
char const * module
Definition: ProductLabels.h:5
ObjectSelector< CosmicTrackingParticleSelector > CosmicTrackingParticleSelector
edm::EDGetTokenT< TrackingParticleRefVector > label_tp_fake_refvector
std::unique_ptr< MTVHistoProducerAlgoForTracker > histoProducerAlgo_
edm::EDGetTokenT< TrackingVertexCollection > label_tv
edm::EDGetTokenT< reco::VertexToTrackingVertexAssociator > vertexAssociatorToken_
std::unique_ptr< RecoTrackSelectorBase > dRTrackSelector
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const bool ignoremissingtkcollection_
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
std::string const & label() const
Definition: InputTag.h:36
const bool doPVAssociationPlots_
edm::EDGetTokenT< edm::View< reco::Vertex > > recoVertexToken_
std::vector< edm::EDGetTokenT< std::vector< PSimHit > > > simHitTokens_
const bool calculateDrSingleCollection_
string end
Definition: dataset.py:937
edm::EDGetTokenT< TrackingParticleCollection > label_tp_fake
edm::EDGetTokenT< edm::View< reco::Candidate > > cores_
edm::EDGetTokenT< TrackingParticleRefVector > label_tp_effic_refvector
static std::unique_ptr< RecoTrackSelectorBase > makeRecoTrackSelectorFromTPSelectorParameters(const edm::ParameterSet &pset)
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
edm::EDGetTokenT< TrackingParticleCollection > label_tp_effic
const bool parametersDefinerIsCosmic_
MultiTrackValidator::~MultiTrackValidator ( )
override

Destructor.

Definition at line 225 of file MultiTrackValidator.cc.

225 {}

Member Function Documentation

void MultiTrackValidator::bookHistograms ( DQMStore::IBooker ibook,
edm::Run const &  ,
edm::EventSetup const &  setup,
Histograms histograms 
) const
overridevirtual

Method called to book the DQM histograms.

Implements DQMGlobalEDAnalyzerBase< MultiTrackValidatorHistograms, Args...>.

Definition at line 227 of file MultiTrackValidator.cc.

References dqm::implementation::IBooker::book1D(), dqm::implementation::NavigatorBase::cd(), TrackerOfflineValidation_Dqm_cff::dirName, dirName_, dodEdxPlots_, doMVAPlots_, doPVAssociationPlots_, doRecoTrackPlots_, doResolutionPlots_, doSeedPlots_, doSimPlots_, doSimTrackPlots_, doSummaryPlots_, MultiTrackValidatorHistograms::h_assoc2_coll, MultiTrackValidatorHistograms::h_assoc_coll, MultiTrackValidatorHistograms::h_looper_coll, MultiTrackValidatorHistograms::h_pileup_coll, MultiTrackValidatorHistograms::h_reco_coll, MultiTrackValidatorHistograms::h_simul_coll, MultiTrackValidatorHistograms::histoProducerAlgo, histoProducerAlgo_, mps_fire::i, edm::InputTag::instance(), edm::InputTag::label(), label, hlt_dqm_clientPB-live_cfg::me, mvaQualityCollectionTokens_, edm::InputTag::process(), python.rootplot.root2matplotlib::replace(), and dqm::implementation::NavigatorBase::setCurrentFolder().

230  {
231  if (label.empty()) {
232  // Disable histogram booking if there are no track collections
233  return;
234  }
235 
236  const auto minColl = -0.5;
237  const auto maxColl = label.size() - 0.5;
238  const auto nintColl = label.size();
239 
240  auto binLabels = [&](dqm::reco::MonitorElement* me) {
241  for (size_t i = 0; i < label.size(); ++i) {
242  me->setBinLabel(i + 1, label[i].label());
243  }
244  me->disableAlphanumeric();
245  return me;
246  };
247 
248  //Booking histograms concerning with simulated tracks
249  if (doSimPlots_) {
250  ibook.cd();
251  ibook.setCurrentFolder(dirName_ + "simulation");
252 
253  histoProducerAlgo_->bookSimHistos(ibook, histograms.histoProducerAlgo);
254 
255  ibook.cd();
256  ibook.setCurrentFolder(dirName_);
257  }
258 
259  for (unsigned int ww = 0; ww < associators.size(); ww++) {
260  ibook.cd();
261  // FIXME: these need to be moved to a subdirectory whose name depends on the associator
262  ibook.setCurrentFolder(dirName_);
263 
264  if (doSummaryPlots_) {
265  if (doSimTrackPlots_) {
266  histograms.h_assoc_coll.push_back(
267  binLabels(ibook.book1D("num_assoc(simToReco)_coll",
268  "N of associated (simToReco) tracks vs track collection",
269  nintColl,
270  minColl,
271  maxColl)));
272  histograms.h_simul_coll.push_back(binLabels(
273  ibook.book1D("num_simul_coll", "N of simulated tracks vs track collection", nintColl, minColl, maxColl)));
274  }
275  if (doRecoTrackPlots_) {
276  histograms.h_reco_coll.push_back(binLabels(
277  ibook.book1D("num_reco_coll", "N of reco track vs track collection", nintColl, minColl, maxColl)));
278  histograms.h_assoc2_coll.push_back(
279  binLabels(ibook.book1D("num_assoc(recoToSim)_coll",
280  "N of associated (recoToSim) tracks vs track collection",
281  nintColl,
282  minColl,
283  maxColl)));
284  histograms.h_looper_coll.push_back(
285  binLabels(ibook.book1D("num_duplicate_coll",
286  "N of associated (recoToSim) looper tracks vs track collection",
287  nintColl,
288  minColl,
289  maxColl)));
290  histograms.h_pileup_coll.push_back(
291  binLabels(ibook.book1D("num_pileup_coll",
292  "N of associated (recoToSim) pileup tracks vs track collection",
293  nintColl,
294  minColl,
295  maxColl)));
296  }
297  }
298 
299  for (unsigned int www = 0; www < label.size(); www++) {
300  ibook.cd();
301  InputTag algo = label[www];
302  string dirName = dirName_;
303  if (!algo.process().empty())
304  dirName += algo.process() + "_";
305  if (!algo.label().empty())
306  dirName += algo.label() + "_";
307  if (!algo.instance().empty())
308  dirName += algo.instance() + "_";
309  if (dirName.find("Tracks") < dirName.length()) {
310  dirName.replace(dirName.find("Tracks"), 6, "");
311  }
312  string assoc = associators[ww].label();
313  if (assoc.find("Track") < assoc.length()) {
314  assoc.replace(assoc.find("Track"), 5, "");
315  }
316  dirName += assoc;
317  std::replace(dirName.begin(), dirName.end(), ':', '_');
318 
319  ibook.setCurrentFolder(dirName);
320 
321  const bool doResolutionPlots = doResolutionPlots_[www];
322 
323  if (doSimTrackPlots_) {
324  histoProducerAlgo_->bookSimTrackHistos(ibook, histograms.histoProducerAlgo, doResolutionPlots);
326  histoProducerAlgo_->bookSimTrackPVAssociationHistos(ibook, histograms.histoProducerAlgo);
327  }
328 
329  //Booking histograms concerning with reconstructed tracks
330  if (doRecoTrackPlots_) {
331  histoProducerAlgo_->bookRecoHistos(ibook, histograms.histoProducerAlgo, doResolutionPlots);
332  if (dodEdxPlots_)
333  histoProducerAlgo_->bookRecodEdxHistos(ibook, histograms.histoProducerAlgo);
335  histoProducerAlgo_->bookRecoPVAssociationHistos(ibook, histograms.histoProducerAlgo);
336  if (doMVAPlots_)
337  histoProducerAlgo_->bookMVAHistos(
338  ibook, histograms.histoProducerAlgo, mvaQualityCollectionTokens_[www].size());
339  }
340 
341  if (doSeedPlots_) {
342  histoProducerAlgo_->bookSeedHistos(ibook, histograms.histoProducerAlgo);
343  }
344  } //end loop www
345  } // end loop ww
346 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
std::vector< std::vector< std::tuple< edm::EDGetTokenT< MVACollection >, edm::EDGetTokenT< QualityMaskCollection > > > > mvaQualityCollectionTokens_
std::vector< edm::InputTag > associators
std::vector< bool > doResolutionPlots_
std::vector< edm::InputTag > label
std::unique_ptr< MTVHistoProducerAlgoForTracker > histoProducerAlgo_
const bool doPVAssociationPlots_
std::string const & label() const
Definition: InputTag.h:36
std::string const & process() const
Definition: InputTag.h:40
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
std::string const & instance() const
Definition: InputTag.h:37
void MultiTrackValidator::dqmAnalyze ( const edm::Event event,
const edm::EventSetup setup,
const Histograms histograms 
) const
overridevirtual

Method called once per event.

Implements DQMGlobalEDAnalyzerBase< MultiTrackValidatorHistograms, Args...>.

Reimplemented in MultiTrackValidatorGenPs.

Definition at line 583 of file MultiTrackValidator.cc.

References _simHitTpMapTag, funct::abs(), associationMapFilterValues(), associatormapRtSs, associatormapStRs, associatorTokens, cms::cuda::bs, bsSrc, EncodedEventId::bunchCrossing(), calculateDrSingleCollection_, HLT_FULL_cff::cores, cores_, cosmictpSelector, declareDynArray, dodEdxPlots_, doMVAPlots_, doPlotsOnlyForTruePV_, doPVAssociationPlots_, doRecoTrackPlots_, doResolutionPlots_, doSeedPlots_, doSimTrackPlots_, doSummaryPlots_, dRtpSelector, dRTrackSelector, TrackingParticleIP::dxy(), TrackingParticleIP::dz(), relativeConstraints::empty, edm::AssociationMap< Tag >::end(), EncodedEventId::event(), TrackingParticle::eventId(), Exception, edm::AssociationMap< Tag >::find(), first, edm::Event::getByToken(), edm::EventSetup::getData(), getRecoPVPosition(), getSimPVPosition(), MultiTrackValidatorHistograms::h_assoc2_coll, MultiTrackValidatorHistograms::h_assoc_coll, MultiTrackValidatorHistograms::h_looper_coll, MultiTrackValidatorHistograms::h_pileup_coll, MultiTrackValidatorHistograms::h_reco_coll, MultiTrackValidatorHistograms::h_simul_coll, reco::TrackBase::highPurity, MultiTrackValidatorHistograms::histoProducerAlgo, histoProducerAlgo_, mps_fire::i, ignoremissingtkcollection_, CosmicTrackingParticleSelector::initEvent(), edm::EDGetTokenT< T >::isUninitialized(), edm::HandleBase::isValid(), label, label_pileupinfo, label_tp_effic, label_tp_effic_refvector, label_tp_fake, label_tp_fake_refvector, label_tv, labelToken, labelTokenForDrCalculation, LogDebug, LogTrace, reco::TrackBase::loose, m_dEdx1Tag, m_dEdx2Tag, SiStripPI::max, TrackingParticle::momentum(), beam_dqm_sourceclient-live_cfg::mva, mvaQualityCollectionTokens_, TrackingParticle::numberOfTrackerHits(), parametersDefinerIsCosmic_, parametersDefinerTP_, edm::Handle< T >::product(), edm::RefToBaseVector< T >::push_back(), dt_dqm_sourceclient_common_cff::reco, edm::View< T >::refAt(), hcal_runs::rt, simPVMaxZ_, edm::View< T >::size(), findQualityFiles::size, mathSSE::sqrt(), cmsswSequenceInfo::tp, tpDR(), tpNLayersToken_, tpNPixelLayersToken_, tpNStripStereoLayersToken_, tpParametersAndSelection(), HLT_FULL_cff::track, HLT_FULL_cff::trackCollection, trackDR(), trackFromSeedFitFailed(), tTopoEsToken, useAssociators_, TrackingParticle::vertex(), and w.

585  {
586  if (label.empty()) {
587  // Disable if there are no track collections
588  return;
589  }
590 
591  using namespace reco;
592 
593  LogDebug("TrackValidator") << "\n===================================================="
594  << "\n"
595  << "Analyzing new event"
596  << "\n"
597  << "====================================================\n"
598  << "\n";
599 
600  const TrackerTopology& ttopo = setup.getData(tTopoEsToken);
601 
602  // FIXME: we really need to move to edm::View for reading the
603  // TrackingParticles... Unfortunately it has non-trivial
604  // consequences on the associator/association interfaces etc.
605  TrackingParticleRefVector tmpTPeff;
606  TrackingParticleRefVector tmpTPfake;
607  const TrackingParticleRefVector* tmpTPeffPtr = nullptr;
608  const TrackingParticleRefVector* tmpTPfakePtr = nullptr;
609 
611  edm::Handle<TrackingParticleRefVector> TPCollectionHeffRefVector;
612 
613  const bool tp_effic_refvector = label_tp_effic.isUninitialized();
614  if (!tp_effic_refvector) {
615  event.getByToken(label_tp_effic, TPCollectionHeff);
616  tmpTPeff.reserve(TPCollectionHeff->size());
617  for (size_t i = 0, size = TPCollectionHeff->size(); i < size; ++i) {
618  tmpTPeff.push_back(TrackingParticleRef(TPCollectionHeff, i));
619  }
620  tmpTPeffPtr = &tmpTPeff;
621  } else {
622  event.getByToken(label_tp_effic_refvector, TPCollectionHeffRefVector);
623  tmpTPeffPtr = TPCollectionHeffRefVector.product();
624  }
626  edm::Handle<TrackingParticleCollection> TPCollectionHfake;
627  event.getByToken(label_tp_fake, TPCollectionHfake);
628  tmpTPfake.reserve(TPCollectionHfake->size());
629  for (size_t i = 0, size = TPCollectionHfake->size(); i < size; ++i) {
630  tmpTPfake.push_back(TrackingParticleRef(TPCollectionHfake, i));
631  }
632  tmpTPfakePtr = &tmpTPfake;
633  } else {
634  edm::Handle<TrackingParticleRefVector> TPCollectionHfakeRefVector;
635  event.getByToken(label_tp_fake_refvector, TPCollectionHfakeRefVector);
636  tmpTPfakePtr = TPCollectionHfakeRefVector.product();
637  }
638 
639  TrackingParticleRefVector const& tPCeff = *tmpTPeffPtr;
640  TrackingParticleRefVector const& tPCfake = *tmpTPfakePtr;
641 
642 #ifdef EDM_ML_DEBUG
643  ensureEffIsSubsetOfFake(tPCeff, tPCfake);
644 #endif
645 
648  //warning: make sure the TP collection used in the map is the same used in the MTV!
649  event.getByToken(_simHitTpMapTag, simHitsTPAssoc);
650  parametersDefinerTP_->initEvent(simHitsTPAssoc);
651  cosmictpSelector.initEvent(simHitsTPAssoc);
652  }
653 
654  // Find the sim PV and tak its position
656  event.getByToken(label_tv, htv);
657  const TrackingVertex::LorentzVector* theSimPVPosition = getSimPVPosition(htv);
658  if (simPVMaxZ_ >= 0) {
659  if (!theSimPVPosition)
660  return;
661  if (std::abs(theSimPVPosition->z()) > simPVMaxZ_)
662  return;
663  }
664 
665  // Check, when necessary, if reco PV matches to sim PV
666  const reco::Vertex::Point* thePVposition = nullptr;
668  thePVposition = getRecoPVPosition(event, htv);
669  if (doPlotsOnlyForTruePV_ && !thePVposition)
670  return;
671 
672  // Rest of the code assumes that if thePVposition is non-null, the
673  // PV-association histograms get filled. In above, the "nullness"
674  // is used to deliver the information if the reco PV is matched to
675  // the sim PV.
677  thePVposition = nullptr;
678  }
679 
680  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
681  event.getByToken(bsSrc, recoBeamSpotHandle);
682  reco::BeamSpot const& bs = *recoBeamSpotHandle;
683 
685  event.getByToken(label_pileupinfo, puinfoH);
686  PileupSummaryInfo puinfo;
687 
688  for (unsigned int puinfo_ite = 0; puinfo_ite < (*puinfoH).size(); ++puinfo_ite) {
689  if ((*puinfoH)[puinfo_ite].getBunchCrossing() == 0) {
690  puinfo = (*puinfoH)[puinfo_ite];
691  break;
692  }
693  }
694 
695  // Number of 3D layers for TPs
697  event.getByToken(tpNLayersToken_, tpNLayersH);
698  const auto& nLayers_tPCeff = *tpNLayersH;
699 
700  event.getByToken(tpNPixelLayersToken_, tpNLayersH);
701  const auto& nPixelLayers_tPCeff = *tpNLayersH;
702 
703  event.getByToken(tpNStripStereoLayersToken_, tpNLayersH);
704  const auto& nStripMonoAndStereoLayers_tPCeff = *tpNLayersH;
705 
706  // Precalculate TP selection (for efficiency), and momentum and vertex wrt PCA
707  //
708  // TODO: ParametersDefinerForTP ESProduct needs to be changed to
709  // EDProduct because of consumes.
710  //
711  // In principle, we could just precalculate the momentum and vertex
712  // wrt PCA for all TPs for once and put that to the event. To avoid
713  // repetitive calculations those should be calculated only once for
714  // each TP. That would imply that we should access TPs via Refs
715  // (i.e. View) in here, since, in general, the eff and fake TP
716  // collections can be different (and at least HI seems to use that
717  // feature). This would further imply that the
718  // RecoToSimCollection/SimToRecoCollection should be changed to use
719  // View<TP> instead of vector<TP>, and migrate everything.
720  //
721  // Or we could take only one input TP collection, and do another
722  // TP-selection to obtain the "fake" collection like we already do
723  // for "efficiency" TPs.
724  std::vector<size_t> selected_tPCeff;
725  std::vector<std::tuple<TrackingParticle::Vector, TrackingParticle::Point>> momVert_tPCeff;
726  tpParametersAndSelection(histograms, tPCeff, event, setup, bs, momVert_tPCeff, selected_tPCeff);
727 
728  //calculate dR for TPs
729  declareDynArray(float, tPCeff.size(), dR_tPCeff);
730 
731  //calculate dR_jet for TPs
732  const edm::View<reco::Candidate>* coresVector = nullptr;
733  if (not cores_.isUninitialized()) {
735  event.getByToken(cores_, cores);
736  if (cores.isValid()) {
737  coresVector = cores.product();
738  }
739  }
740  declareDynArray(float, tPCeff.size(), dR_tPCeff_jet);
741 
742  size_t n_selTP_dr = tpDR(tPCeff, selected_tPCeff, dR_tPCeff, dR_tPCeff_jet, coresVector);
743 
744  edm::Handle<View<Track>> trackCollectionForDrCalculation;
746  event.getByToken(labelTokenForDrCalculation, trackCollectionForDrCalculation);
747  }
748 
749  // dE/dx
750  // at some point this could be generalized, with a vector of tags and a corresponding vector of Handles
751  // I'm writing the interface such to take vectors of ValueMaps
752  std::vector<const edm::ValueMap<reco::DeDxData>*> v_dEdx;
753  if (dodEdxPlots_) {
756  event.getByToken(m_dEdx1Tag, dEdx1Handle);
757  event.getByToken(m_dEdx2Tag, dEdx2Handle);
758  v_dEdx.push_back(dEdx1Handle.product());
759  v_dEdx.push_back(dEdx2Handle.product());
760  }
761 
762  std::vector<const MVACollection*> mvaCollections;
763  std::vector<const QualityMaskCollection*> qualityMaskCollections;
764  std::vector<float> mvaValues;
765 
766  int w = 0; //counter counting the number of sets of histograms
767  for (unsigned int ww = 0; ww < associators.size(); ww++) {
768  // run value filtering of recoToSim map already here as it depends only on the association, not track collection
769  reco::SimToRecoCollection const* simRecCollPFull = nullptr;
770  reco::RecoToSimCollection const* recSimCollP = nullptr;
771  reco::RecoToSimCollection recSimCollL;
772  if (!useAssociators_) {
773  Handle<reco::SimToRecoCollection> simtorecoCollectionH;
774  event.getByToken(associatormapStRs[ww], simtorecoCollectionH);
775  simRecCollPFull = simtorecoCollectionH.product();
776 
777  Handle<reco::RecoToSimCollection> recotosimCollectionH;
778  event.getByToken(associatormapRtSs[ww], recotosimCollectionH);
779  recSimCollP = recotosimCollectionH.product();
780 
781  // We need to filter the associations of the fake-TrackingParticle
782  // collection only from RecoToSim collection, otherwise the
783  // RecoToSim histograms get false entries
784  recSimCollL = associationMapFilterValues(*recSimCollP, tPCfake);
785  recSimCollP = &recSimCollL;
786  }
787 
788  for (unsigned int www = 0; www < label.size();
789  www++, w++) { // need to increment w here, since there are many continues in the loop body
790  //
791  //get collections from the event
792  //
793  edm::Handle<View<Track>> trackCollectionHandle;
794  if (!event.getByToken(labelToken[www], trackCollectionHandle) && ignoremissingtkcollection_)
795  continue;
796  const edm::View<Track>& trackCollection = *trackCollectionHandle;
797 
798  reco::SimToRecoCollection const* simRecCollP = nullptr;
799  reco::SimToRecoCollection simRecCollL;
800 
801  //associate tracks
802  LogTrace("TrackValidator") << "Analyzing " << label[www] << " with " << associators[ww] << "\n";
803  if (useAssociators_) {
805  event.getByToken(associatorTokens[ww], theAssociator);
806 
807  // The associator interfaces really need to be fixed...
809  // trackRefs.vectorHolder()->reserve(trackCollection.size()); NOT a good idea
810  for (edm::View<Track>::size_type i = 0; i < trackCollection.size(); ++i) {
811  trackRefs.push_back(trackCollection.refAt(i));
812  }
813 
814  LogTrace("TrackValidator") << "Calling associateRecoToSim method"
815  << "\n";
816  recSimCollL = theAssociator->associateRecoToSim(trackRefs, tPCfake);
817  recSimCollP = &recSimCollL;
818  LogTrace("TrackValidator") << "Calling associateSimToReco method"
819  << "\n";
820  // It is necessary to do the association wrt. fake TPs,
821  // because this SimToReco association is used also for
822  // duplicates. Since the set of efficiency TPs are required to
823  // be a subset of the set of fake TPs, for efficiency
824  // histograms it doesn't matter if the association contains
825  // associations of TPs not in the set of efficiency TPs.
826  simRecCollL = theAssociator->associateSimToReco(trackRefs, tPCfake);
827  simRecCollP = &simRecCollL;
828  } else {
829  // We need to filter the associations of the current track
830  // collection only from SimToReco collection, otherwise the
831  // SimToReco histograms get false entries. The filtering must
832  // be done separately for each track collection.
833  simRecCollL = associationMapFilterValues(*simRecCollPFull, trackCollection);
834  simRecCollP = &simRecCollL;
835  }
836 
837  reco::RecoToSimCollection const& recSimColl = *recSimCollP;
838  reco::SimToRecoCollection const& simRecColl = *simRecCollP;
839 
840  // read MVA collections
844  for (const auto& tokenTpl : mvaQualityCollectionTokens_[www]) {
845  event.getByToken(std::get<0>(tokenTpl), hmva);
846  event.getByToken(std::get<1>(tokenTpl), hqual);
847 
848  mvaCollections.push_back(hmva.product());
849  qualityMaskCollections.push_back(hqual.product());
850  if (mvaCollections.back()->size() != trackCollection.size()) {
851  throw cms::Exception("Configuration")
852  << "Inconsistency in track collection and MVA sizes. Track collection " << www << " has "
853  << trackCollection.size() << " tracks, whereas the MVA " << (mvaCollections.size() - 1)
854  << " for it has " << mvaCollections.back()->size() << " entries. Double-check your configuration.";
855  }
856  if (qualityMaskCollections.back()->size() != trackCollection.size()) {
857  throw cms::Exception("Configuration")
858  << "Inconsistency in track collection and quality mask sizes. Track collection " << www << " has "
859  << trackCollection.size() << " tracks, whereas the quality mask " << (qualityMaskCollections.size() - 1)
860  << " for it has " << qualityMaskCollections.back()->size()
861  << " entries. Double-check your configuration.";
862  }
863  }
864  }
865 
866  // ########################################################
867  // fill simulation histograms (LOOP OVER TRACKINGPARTICLES)
868  // ########################################################
869 
870  //compute number of tracks per eta interval
871  //
872  LogTrace("TrackValidator") << "\n# of TrackingParticles: " << tPCeff.size() << "\n";
873  int ats(0); //This counter counts the number of simTracks that are "associated" to recoTracks
874  int st(0); //This counter counts the number of simulated tracks passing the MTV selection (i.e. tpSelector(tp) )
875 
876  //loop over already-selected TPs for tracking efficiency
877  for (size_t i = 0; i < selected_tPCeff.size(); ++i) {
878  size_t iTP = selected_tPCeff[i];
879  const TrackingParticleRef& tpr = tPCeff[iTP];
880  const TrackingParticle& tp = *tpr;
881 
882  auto const& momVert = momVert_tPCeff[i];
883  TrackingParticle::Vector momentumTP;
884  TrackingParticle::Point vertexTP;
885 
886  double dxySim(0);
887  double dzSim(0);
888  double dxyPVSim = 0;
889  double dzPVSim = 0;
890  double dR = dR_tPCeff[iTP];
891  double dR_jet = dR_tPCeff_jet[iTP];
892 
893  //---------- THIS PART HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
894  //If the TrackingParticle is collison like, get the momentum and vertex at production state
896  momentumTP = tp.momentum();
897  vertexTP = tp.vertex();
898  //Calcualte the impact parameters w.r.t. PCA
899  const TrackingParticle::Vector& momentum = std::get<TrackingParticle::Vector>(momVert);
900  const TrackingParticle::Point& vertex = std::get<TrackingParticle::Point>(momVert);
901  dxySim = TrackingParticleIP::dxy(vertex, momentum, bs.position());
902  dzSim = TrackingParticleIP::dz(vertex, momentum, bs.position());
903 
904  if (theSimPVPosition) {
905  dxyPVSim = TrackingParticleIP::dxy(vertex, momentum, *theSimPVPosition);
906  dzPVSim = TrackingParticleIP::dz(vertex, momentum, *theSimPVPosition);
907  }
908  }
909  //If the TrackingParticle is comics, get the momentum and vertex at PCA
910  else {
911  momentumTP = std::get<TrackingParticle::Vector>(momVert);
912  vertexTP = std::get<TrackingParticle::Point>(momVert);
913  dxySim = TrackingParticleIP::dxy(vertexTP, momentumTP, bs.position());
914  dzSim = TrackingParticleIP::dz(vertexTP, momentumTP, bs.position());
915 
916  // Do dxy and dz vs. PV make any sense for cosmics? I guess not
917  }
918  //---------- THE PART ABOVE HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
919 
920  // in the coming lines, histos are filled using as input
921  // - momentumTP
922  // - vertexTP
923  // - dxySim
924  // - dzSim
925  if (!doSimTrackPlots_)
926  continue;
927 
928  // ##############################################
929  // fill RecoAssociated SimTracks' histograms
930  // ##############################################
931  const reco::Track* matchedTrackPointer = nullptr;
932  const reco::Track* matchedSecondTrackPointer = nullptr;
933  unsigned int selectsLoose = mvaCollections.size();
934  unsigned int selectsHP = mvaCollections.size();
935  if (simRecColl.find(tpr) != simRecColl.end()) {
936  auto const& rt = simRecColl[tpr];
937  if (!rt.empty()) {
938  ats++; //This counter counts the number of simTracks that have a recoTrack associated
939  // isRecoMatched = true; // UNUSED
940  matchedTrackPointer = rt.begin()->first.get();
941  if (rt.size() >= 2) {
942  matchedSecondTrackPointer = (rt.begin() + 1)->first.get();
943  }
944  LogTrace("TrackValidator") << "TrackingParticle #" << st << " with pt=" << sqrt(momentumTP.perp2())
945  << " associated with quality:" << rt.begin()->second << "\n";
946 
947  if (doMVAPlots_) {
948  // for each MVA we need to take the value of the track
949  // with largest MVA value (for the cumulative histograms)
950  //
951  // also identify the first MVA that possibly selects any
952  // track matched to this TrackingParticle, separately
953  // for loose and highPurity qualities
954  for (size_t imva = 0; imva < mvaCollections.size(); ++imva) {
955  const auto& mva = *(mvaCollections[imva]);
956  const auto& qual = *(qualityMaskCollections[imva]);
957 
958  auto iMatch = rt.begin();
959  float maxMva = mva[iMatch->first.key()];
960  for (; iMatch != rt.end(); ++iMatch) {
961  auto itrk = iMatch->first.key();
962  maxMva = std::max(maxMva, mva[itrk]);
963 
964  if (selectsLoose >= imva && trackSelected(qual[itrk], reco::TrackBase::loose))
965  selectsLoose = imva;
966  if (selectsHP >= imva && trackSelected(qual[itrk], reco::TrackBase::highPurity))
967  selectsHP = imva;
968  }
969  mvaValues.push_back(maxMva);
970  }
971  }
972  }
973  } else {
974  LogTrace("TrackValidator") << "TrackingParticle #" << st << " with pt,eta,phi: " << sqrt(momentumTP.perp2())
975  << " , " << momentumTP.eta() << " , " << momentumTP.phi() << " , "
976  << " NOT associated to any reco::Track"
977  << "\n";
978  }
979 
980  int nSimHits = tp.numberOfTrackerHits();
981  int nSimLayers = nLayers_tPCeff[tpr];
982  int nSimPixelLayers = nPixelLayers_tPCeff[tpr];
983  int nSimStripMonoAndStereoLayers = nStripMonoAndStereoLayers_tPCeff[tpr];
984  histoProducerAlgo_->fill_recoAssociated_simTrack_histos(histograms.histoProducerAlgo,
985  w,
986  tp,
987  momentumTP,
988  vertexTP,
989  dxySim,
990  dzSim,
991  dxyPVSim,
992  dzPVSim,
993  nSimHits,
994  nSimLayers,
995  nSimPixelLayers,
996  nSimStripMonoAndStereoLayers,
997  matchedTrackPointer,
998  puinfo.getPU_NumInteractions(),
999  dR,
1000  dR_jet,
1001  thePVposition,
1002  theSimPVPosition,
1003  bs.position(),
1004  mvaValues,
1005  selectsLoose,
1006  selectsHP);
1007  mvaValues.clear();
1008 
1009  if (matchedTrackPointer && matchedSecondTrackPointer) {
1010  histoProducerAlgo_->fill_duplicate_histos(
1011  histograms.histoProducerAlgo, w, *matchedTrackPointer, *matchedSecondTrackPointer);
1012  }
1013 
1014  if (doSummaryPlots_) {
1015  if (dRtpSelector(tp)) {
1016  histograms.h_simul_coll[ww]->Fill(www);
1017  if (matchedTrackPointer) {
1018  histograms.h_assoc_coll[ww]->Fill(www);
1019  }
1020  }
1021  }
1022 
1023  } // End for (TrackingParticleCollection::size_type i=0; i<tPCeff.size(); i++){
1024 
1025  // ##############################################
1026  // fill recoTracks histograms (LOOP OVER TRACKS)
1027  // ##############################################
1028  if (!doRecoTrackPlots_)
1029  continue;
1030  LogTrace("TrackValidator") << "\n# of reco::Tracks with " << label[www].process() << ":" << label[www].label()
1031  << ":" << label[www].instance() << ": " << trackCollection.size() << "\n";
1032 
1033  int sat(0); //This counter counts the number of recoTracks that are associated to SimTracks from Signal only
1034  int at(0); //This counter counts the number of recoTracks that are associated to SimTracks
1035  int rT(0); //This counter counts the number of recoTracks in general
1036  int seed_fit_failed = 0;
1037  size_t n_selTrack_dr = 0;
1038 
1039  //calculate dR for tracks
1040  declareDynArray(float, trackCollection.size(), dR_trk);
1041  declareDynArray(float, trackCollection.size(), dR_trk_jet);
1042 #ifndef NO_TRACK_DR
1043  // this accounts for most of the time spent in MTV and it is used to fill just one histo that is of doubtful usefulness but (maybe) for the whole collection
1044  const edm::View<Track>* trackCollectionDr = &trackCollection;
1046  trackCollectionDr = trackCollectionForDrCalculation.product();
1047  }
1048  trackDR(trackCollection, *trackCollectionDr, dR_trk, dR_trk_jet, coresVector);
1049 #endif
1050 
1051  for (View<Track>::size_type i = 0; i < trackCollection.size(); ++i) {
1052  auto track = trackCollection.refAt(i);
1053  rT++;
1055  ++seed_fit_failed;
1056  if ((*dRTrackSelector)(*track, bs.position()))
1057  ++n_selTrack_dr;
1058 
1059  bool isSigSimMatched(false);
1060  bool isSimMatched(false);
1061  bool isChargeMatched(true);
1062  int numAssocRecoTracks = 0;
1063  int nSimHits = 0;
1064  double sharedFraction = 0.;
1065 
1066  auto tpFound = recSimColl.find(track);
1067  isSimMatched = tpFound != recSimColl.end();
1068  if (isSimMatched) {
1069  const auto& tp = tpFound->val;
1070  nSimHits = tp[0].first->numberOfTrackerHits();
1071  sharedFraction = tp[0].second;
1072  if (tp[0].first->charge() != track->charge())
1073  isChargeMatched = false;
1074  if (simRecColl.find(tp[0].first) != simRecColl.end())
1075  numAssocRecoTracks = simRecColl[tp[0].first].size();
1076  at++;
1077  for (unsigned int tp_ite = 0; tp_ite < tp.size(); ++tp_ite) {
1078  TrackingParticle trackpart = *(tp[tp_ite].first);
1079  if ((trackpart.eventId().event() == 0) && (trackpart.eventId().bunchCrossing() == 0)) {
1080  isSigSimMatched = true;
1081  sat++;
1082  break;
1083  }
1084  }
1085  LogTrace("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt()
1086  << " associated with quality:" << tp.begin()->second << "\n";
1087  } else {
1088  LogTrace("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt()
1089  << " NOT associated to any TrackingParticle"
1090  << "\n";
1091  }
1092 
1093  // set MVA values for this track
1094  // take also the indices of first MVAs to select by loose and
1095  // HP quality
1096  unsigned int selectsLoose = mvaCollections.size();
1097  unsigned int selectsHP = mvaCollections.size();
1098  if (doMVAPlots_) {
1099  for (size_t imva = 0; imva < mvaCollections.size(); ++imva) {
1100  const auto& mva = *(mvaCollections[imva]);
1101  const auto& qual = *(qualityMaskCollections[imva]);
1102  mvaValues.push_back(mva[i]);
1103 
1104  if (selectsLoose >= imva && trackSelected(qual[i], reco::TrackBase::loose))
1105  selectsLoose = imva;
1106  if (selectsHP >= imva && trackSelected(qual[i], reco::TrackBase::highPurity))
1107  selectsHP = imva;
1108  }
1109  }
1110 
1111  double dR = dR_trk[i];
1112  double dR_jet = dR_trk_jet[i];
1113  histoProducerAlgo_->fill_generic_recoTrack_histos(histograms.histoProducerAlgo,
1114  w,
1115  *track,
1116  ttopo,
1117  bs.position(),
1118  thePVposition,
1119  theSimPVPosition,
1120  isSimMatched,
1121  isSigSimMatched,
1122  isChargeMatched,
1123  numAssocRecoTracks,
1124  puinfo.getPU_NumInteractions(),
1125  nSimHits,
1126  sharedFraction,
1127  dR,
1128  dR_jet,
1129  mvaValues,
1130  selectsLoose,
1131  selectsHP);
1132  mvaValues.clear();
1133 
1134  if (doSummaryPlots_) {
1135  histograms.h_reco_coll[ww]->Fill(www);
1136  if (isSimMatched) {
1137  histograms.h_assoc2_coll[ww]->Fill(www);
1138  if (numAssocRecoTracks > 1) {
1139  histograms.h_looper_coll[ww]->Fill(www);
1140  }
1141  if (!isSigSimMatched) {
1142  histograms.h_pileup_coll[ww]->Fill(www);
1143  }
1144  }
1145  }
1146 
1147  // dE/dx
1148  if (dodEdxPlots_)
1149  histoProducerAlgo_->fill_dedx_recoTrack_histos(histograms.histoProducerAlgo, w, track, v_dEdx);
1150 
1151  //Fill other histos
1152  if (!isSimMatched)
1153  continue;
1154 
1155  histoProducerAlgo_->fill_simAssociated_recoTrack_histos(histograms.histoProducerAlgo, w, *track);
1156 
1157  /* TO BE FIXED LATER
1158  if (associators[ww]=="trackAssociatorByChi2"){
1159  //association chi2
1160  double assocChi2 = -tp.begin()->second;//in association map is stored -chi2
1161  h_assochi2[www]->Fill(assocChi2);
1162  h_assochi2_prob[www]->Fill(TMath::Prob((assocChi2)*5,5));
1163  }
1164  else if (associators[ww]=="quickTrackAssociatorByHits"){
1165  double fraction = tp.begin()->second;
1166  h_assocFraction[www]->Fill(fraction);
1167  h_assocSharedHit[www]->Fill(fraction*track->numberOfValidHits());
1168  }
1169  */
1170 
1171  if (doResolutionPlots_[www]) {
1172  //Get tracking particle parameters at point of closest approach to the beamline
1173  TrackingParticleRef tpr = tpFound->val.begin()->first;
1174  TrackingParticle::Vector momentumTP = parametersDefinerTP_->momentum(event, setup, tpr);
1175  TrackingParticle::Point vertexTP = parametersDefinerTP_->vertex(event, setup, tpr);
1176  int chargeTP = tpr->charge();
1177 
1178  histoProducerAlgo_->fill_ResoAndPull_recoTrack_histos(
1179  histograms.histoProducerAlgo, w, momentumTP, vertexTP, chargeTP, *track, bs.position());
1180  }
1181 
1182  //TO BE FIXED
1183  //std::vector<PSimHit> simhits=tpr.get()->trackPSimHit(DetId::Tracker);
1184  //nrecHit_vs_nsimHit_rec2sim[w]->Fill(track->numberOfValidHits(), (int)(simhits.end()-simhits.begin() ));
1185 
1186  } // End of for(View<Track>::size_type i=0; i<trackCollection.size(); ++i){
1187  mvaCollections.clear();
1188  qualityMaskCollections.clear();
1189 
1190  histoProducerAlgo_->fill_trackBased_histos(histograms.histoProducerAlgo, w, at, rT, n_selTrack_dr, n_selTP_dr);
1191  // Fill seed-specific histograms
1192  if (doSeedPlots_) {
1193  histoProducerAlgo_->fill_seed_histos(
1194  histograms.histoProducerAlgo, www, seed_fit_failed, trackCollection.size());
1195  }
1196 
1197  LogTrace("TrackValidator") << "Collection " << www << "\n"
1198  << "Total Simulated (selected): " << n_selTP_dr << "\n"
1199  << "Total Reconstructed (selected): " << n_selTrack_dr << "\n"
1200  << "Total Reconstructed: " << rT << "\n"
1201  << "Total Associated (recoToSim): " << at << "\n"
1202  << "Total Fakes: " << rT - at << "\n";
1203  } // End of for (unsigned int www=0;www<label.size();www++){
1204  } //END of for (unsigned int ww=0;ww<associators.size();ww++){
1205 }
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoEsToken
unsigned int size_type
Definition: View.h:90
edm::EDGetTokenT< SimHitTPAssociationProducer::SimHitTPAssociationList > _simHitTpMapTag
int event() const
get the contents of the subdetector field (should be protected?)
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx2Tag
bool trackFromSeedFitFailed(const reco::Track &track)
std::vector< edm::EDGetTokenT< reco::SimToRecoCollection > > associatormapStRs
const double w
Definition: UKUtility.cc:23
CosmicTrackingParticleSelector cosmictpSelector
size_t tpDR(const TrackingParticleRefVector &tPCeff, const std::vector< size_t > &selected_tPCeff, DynArray< float > &dR_tPCeff, DynArray< float > &dR_tPCeff_jet, const edm::View< reco::Candidate > *cores) const
Vector momentum() const
spatial momentum vector
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
const_iterator find(const key_type &k) const
find element with specified reference key
std::vector< std::vector< std::tuple< edm::EDGetTokenT< MVACollection >, edm::EDGetTokenT< QualityMaskCollection > > > > mvaQualityCollectionTokens_
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
edm::EDGetTokenT< edm::ValueMap< unsigned int > > tpNStripStereoLayersToken_
edm::EDGetTokenT< edm::ValueMap< unsigned int > > tpNLayersToken_
size_type size() const
T_AssociationMap associationMapFilterValues(const T_AssociationMap &map, const T_RefVector &valueRefs)
TrackingParticleSelector dRtpSelector
std::vector< edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > > associatorTokens
const bool doPlotsOnlyForTruePV_
edm::EDGetTokenT< reco::BeamSpot > bsSrc
const reco::Vertex::Point * getRecoPVPosition(const edm::Event &event, const edm::Handle< TrackingVertexCollection > &htv) const
list rt
Definition: hcal_runs.py:76
#define LogTrace(id)
RefToBase< value_type > refAt(size_type i) const
math::XYZPointD Point
point in the space
bool getData(T &iHolder) const
Definition: EventSetup.h:128
edm::EDGetTokenT< edm::ValueMap< unsigned int > > tpNPixelLayersToken_
math::XYZTLorentzVectorD LorentzVector
std::vector< edm::InputTag > associators
void trackDR(const edm::View< reco::Track > &trackCollection, const edm::View< reco::Track > &trackCollectionDr, DynArray< float > &dR_trk, DynArray< float > &dR_trk_jet, const edm::View< reco::Candidate > *cores) const
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > labelToken
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx1Tag
std::vector< edm::EDGetTokenT< reco::RecoToSimCollection > > associatormapRtSs
auto dz(const T_Vertex &vertex, const T_Momentum &momentum, const T_Point &point)
T sqrt(T t)
Definition: SSEVec.h:19
int bunchCrossing() const
get the detector field from this detid
std::vector< bool > doResolutionPlots_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual void Fill(const reco::Particle::LorentzVector &p1, const reco::Particle::LorentzVector &p2)
Definition: Histograms.h:60
edm::EDGetTokenT< edm::View< reco::Track > > labelTokenForDrCalculation
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > label_pileupinfo
std::vector< edm::InputTag > label
void initEvent(edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssocToSet) const
std::unique_ptr< ParametersDefinerForTP > parametersDefinerTP_
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< TrackingParticleRefVector > label_tp_fake_refvector
std::unique_ptr< MTVHistoProducerAlgoForTracker > histoProducerAlgo_
tuple trackCollection
T const * product() const
Definition: Handle.h:70
edm::EDGetTokenT< TrackingVertexCollection > label_tv
std::unique_ptr< RecoTrackSelectorBase > dRTrackSelector
const bool ignoremissingtkcollection_
const bool doPVAssociationPlots_
EncodedEventId eventId() const
Signal source, crossing number.
Point vertex() const
Parent vertex position.
const bool calculateDrSingleCollection_
auto dxy(const T_Vertex &vertex, const T_Momentum &momentum, const T_Point &point)
void push_back(const RefToBase< T > &)
edm::EDGetTokenT< TrackingParticleCollection > label_tp_fake
Monte Carlo truth information used for tracking validation.
#define declareDynArray(T, n, x)
Definition: DynArray.h:91
void tpParametersAndSelection(const Histograms &histograms, const TrackingParticleRefVector &tPCeff, const edm::Event &event, const edm::EventSetup &setup, const reco::BeamSpot &bs, std::vector< std::tuple< TrackingParticle::Vector, TrackingParticle::Point >> &momVert_tPCeff, std::vector< size_t > &selected_tPCeff) const
int numberOfTrackerHits() const
The number of hits in the tracker. Hits on overlaps in the same layer count separately.
edm::EDGetTokenT< edm::View< reco::Candidate > > cores_
math::XYZVectorD Vector
point in the space
edm::EDGetTokenT< TrackingParticleRefVector > label_tp_effic_refvector
edm::EDGetTokenT< TrackingParticleCollection > label_tp_effic
tuple size
Write out results.
edm::Ref< TrackingParticleCollection > TrackingParticleRef
const TrackingVertex::LorentzVector * getSimPVPosition(const edm::Handle< TrackingVertexCollection > &htv) const
#define LogDebug(id)
const bool parametersDefinerIsCosmic_
const reco::Vertex::Point * MultiTrackValidator::getRecoPVPosition ( const edm::Event event,
const edm::Handle< TrackingVertexCollection > &  htv 
) const
private

Definition at line 396 of file MultiTrackValidator.cc.

References EncodedEventId::bunchCrossing(), EncodedEventId::event(), TrackingVertex::eventId(), recoVertexToken_, and vertexAssociatorToken_.

Referenced by dqmAnalyze().

397  {
399  event.getByToken(recoVertexToken_, hvertex);
400 
402  event.getByToken(vertexAssociatorToken_, hvassociator);
403 
404  auto v_r2s = hvassociator->associateRecoToSim(hvertex, htv);
405  auto pvPtr = hvertex->refAt(0);
406  if (pvPtr->isFake() || pvPtr->ndof() < 0) // skip junk vertices
407  return nullptr;
408 
409  auto pvFound = v_r2s.find(pvPtr);
410  if (pvFound == v_r2s.end())
411  return nullptr;
412 
413  for (const auto& vertexRefQuality : pvFound->val) {
414  const TrackingVertex& tv = *(vertexRefQuality.first);
415  if (tv.eventId().event() == 0 && tv.eventId().bunchCrossing() == 0) {
416  return &(pvPtr->position());
417  }
418  }
419 
420  return nullptr;
421 }
int event() const
get the contents of the subdetector field (should be protected?)
int bunchCrossing() const
get the detector field from this detid
edm::EDGetTokenT< reco::VertexToTrackingVertexAssociator > vertexAssociatorToken_
edm::EDGetTokenT< edm::View< reco::Vertex > > recoVertexToken_
const EncodedEventId & eventId() const
const TrackingVertex::LorentzVector * MultiTrackValidator::getSimPVPosition ( const edm::Handle< TrackingVertexCollection > &  htv) const
private

Definition at line 384 of file MultiTrackValidator.cc.

Referenced by dqmAnalyze().

385  {
386  for (const auto& simV : *htv) {
387  if (simV.eventId().bunchCrossing() != 0)
388  continue; // remove OOTPU
389  if (simV.eventId().event() != 0)
390  continue; // pick the PV of hard scatter
391  return &(simV.position());
392  }
393  return nullptr;
394 }
size_t MultiTrackValidator::tpDR ( const TrackingParticleRefVector tPCeff,
const std::vector< size_t > &  selected_tPCeff,
DynArray< float > &  dR_tPCeff,
DynArray< float > &  dR_tPCeff_jet,
const edm::View< reco::Candidate > *  cores 
) const
private

Definition at line 481 of file MultiTrackValidator.cc.

References reco::deltaR2(), dRtpSelector, edm::RefVector< C, T, F >::empty(), PVValHelper::eta, reco::Candidate::eta(), metsig::jet, SiStripPI::max, AlCaHLTBitMon_ParallelJobs::p, phi, reco::Candidate::phi(), edm::RefVector< C, T, F >::size(), edm::View< T >::size(), mathSSE::sqrt(), and cmsswSequenceInfo::tp.

Referenced by dqmAnalyze().

485  {
486  if (tPCeff.empty()) {
487  return 0;
488  }
489  float etaL[tPCeff.size()], phiL[tPCeff.size()];
490  size_t n_selTP_dr = 0;
491  for (size_t iTP : selected_tPCeff) {
492  //calculare dR wrt inclusive collection (also with PU, low pT, displaced)
493  auto const& tp2 = *(tPCeff[iTP]);
494  auto&& p = tp2.momentum();
495  etaL[iTP] = etaFromXYZ(p.x(), p.y(), p.z());
496  phiL[iTP] = atan2f(p.y(), p.x());
497  }
498  for (size_t iTP1 : selected_tPCeff) {
499  auto const& tp = *(tPCeff[iTP1]);
500  double dR = std::numeric_limits<double>::max();
501  double dR_jet = std::numeric_limits<double>::max();
502  if (dRtpSelector(tp)) { //only for those needed for efficiency!
503  ++n_selTP_dr;
504  float eta = etaL[iTP1];
505  float phi = phiL[iTP1];
506  for (size_t iTP2 : selected_tPCeff) {
507  //calculare dR wrt inclusive collection (also with PU, low pT, displaced)
508  if (iTP1 == iTP2) {
509  continue;
510  }
511  auto dR_tmp = reco::deltaR2(eta, phi, etaL[iTP2], phiL[iTP2]);
512  if (dR_tmp < dR)
513  dR = dR_tmp;
514  } // ttp2 (iTP)
515  if (cores != nullptr) {
516  for (unsigned int ji = 0; ji < cores->size(); ji++) { //jet loop
517  const reco::Candidate& jet = (*cores)[ji];
518  double jet_eta = jet.eta();
519  double jet_phi = jet.phi();
520  auto dR_jet_tmp = reco::deltaR2(eta, phi, jet_eta, jet_phi);
521  if (dR_jet_tmp < dR_jet)
522  dR_jet = dR_jet_tmp;
523  }
524  }
525  }
526  dR_tPCeff[iTP1] = std::sqrt(dR);
527  dR_tPCeff_jet[iTP1] = std::sqrt(dR_jet);
528 
529  } // tp
530  return n_selTP_dr;
531 }
size_type size() const
TrackingParticleSelector dRtpSelector
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:99
T sqrt(T t)
Definition: SSEVec.h:19
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
virtual double phi() const =0
momentum azimuthal angle
virtual double eta() const =0
momentum pseudorapidity
void MultiTrackValidator::tpParametersAndSelection ( const Histograms histograms,
const TrackingParticleRefVector tPCeff,
const edm::Event event,
const edm::EventSetup setup,
const reco::BeamSpot bs,
std::vector< std::tuple< TrackingParticle::Vector, TrackingParticle::Point >> &  momVert_tPCeff,
std::vector< size_t > &  selected_tPCeff 
) const
private

Definition at line 423 of file MultiTrackValidator.cc.

References EncodedEventId::bunchCrossing(), cosmictpSelector, doSimPlots_, TrackingParticle::eventId(), MultiTrackValidatorHistograms::histoProducerAlgo, histoProducerAlgo_, dqmiolumiharvest::j, TrackingParticle::momentum(), parametersDefinerIsCosmic_, parametersDefinerTP_, edm::RefVector< C, T, F >::size(), cmsswSequenceInfo::tp, tpSelector, and TrackingParticle::vertex().

Referenced by dqmAnalyze().

430  {
431  selected_tPCeff.reserve(tPCeff.size());
432  momVert_tPCeff.reserve(tPCeff.size());
433  int nIntimeTPs = 0;
435  for (size_t j = 0; j < tPCeff.size(); ++j) {
436  const TrackingParticleRef& tpr = tPCeff[j];
437 
438  auto const& rec = parametersDefinerTP_->momentumAndVertex(event, setup, tpr);
439  TrackingParticle::Vector const& momentum = std::get<0>(rec);
440  TrackingParticle::Point const& vertex = std::get<1>(rec);
441  if (doSimPlots_) {
442  histoProducerAlgo_->fill_generic_simTrack_histos(
443  histograms.histoProducerAlgo, momentum, vertex, tpr->eventId().bunchCrossing());
444  }
445  if (tpr->eventId().bunchCrossing() == 0)
446  ++nIntimeTPs;
447 
448  if (cosmictpSelector(tpr, &bs, event, setup)) {
449  selected_tPCeff.push_back(j);
450  momVert_tPCeff.emplace_back(momentum, vertex);
451  }
452  }
453  } else {
454  size_t j = 0;
455  for (auto const& tpr : tPCeff) {
456  const TrackingParticle& tp = *tpr;
457 
458  // TODO: do we want to fill these from all TPs that include IT
459  // and OOT (as below), or limit to IT+OOT TPs passing tpSelector
460  // (as it was before)? The latter would require another instance
461  // of tpSelector with intimeOnly=False.
462  if (doSimPlots_) {
463  histoProducerAlgo_->fill_generic_simTrack_histos(
464  histograms.histoProducerAlgo, tp.momentum(), tp.vertex(), tp.eventId().bunchCrossing());
465  }
466  if (tp.eventId().bunchCrossing() == 0)
467  ++nIntimeTPs;
468 
469  if (tpSelector(tp)) {
470  selected_tPCeff.push_back(j);
471  momVert_tPCeff.emplace_back(parametersDefinerTP_->momentumAndVertex(event, setup, tpr));
472  }
473  ++j;
474  }
475  }
476  if (doSimPlots_) {
477  histoProducerAlgo_->fill_simTrackBased_histos(histograms.histoProducerAlgo, nIntimeTPs);
478  }
479 }
CosmicTrackingParticleSelector cosmictpSelector
Vector momentum() const
spatial momentum vector
math::XYZPointD Point
point in the space
int bunchCrossing() const
get the detector field from this detid
TrackingParticleSelector tpSelector
std::unique_ptr< ParametersDefinerForTP > parametersDefinerTP_
std::unique_ptr< MTVHistoProducerAlgoForTracker > histoProducerAlgo_
EncodedEventId eventId() const
Signal source, crossing number.
Point vertex() const
Parent vertex position.
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
Monte Carlo truth information used for tracking validation.
math::XYZVectorD Vector
point in the space
const bool parametersDefinerIsCosmic_
void MultiTrackValidator::trackDR ( const edm::View< reco::Track > &  trackCollection,
const edm::View< reco::Track > &  trackCollectionDr,
DynArray< float > &  dR_trk,
DynArray< float > &  dR_trk_jet,
const edm::View< reco::Candidate > *  cores 
) const
private

Definition at line 533 of file MultiTrackValidator.cc.

References reco::deltaR2(), edm::View< T >::empty(), PVValHelper::eta, reco::Candidate::eta(), mps_fire::i, dqmiolumiharvest::j, metsig::jet, SiStripPI::max, min(), AlCaHLTBitMon_ParallelJobs::p, phi, reco::Candidate::phi(), edm::View< T >::size(), mathSSE::sqrt(), HLT_FULL_cff::track, and trackFromSeedFitFailed().

Referenced by dqmAnalyze().

537  {
538  if (trackCollectionDr.empty()) {
539  return;
540  }
541  int i = 0;
542  float etaL[trackCollectionDr.size()];
543  float phiL[trackCollectionDr.size()];
544  bool validL[trackCollectionDr.size()];
545  for (auto const& track2 : trackCollectionDr) {
546  auto&& p = track2.momentum();
547  etaL[i] = etaFromXYZ(p.x(), p.y(), p.z());
548  phiL[i] = atan2f(p.y(), p.x());
549  validL[i] = !trackFromSeedFitFailed(track2);
550  ++i;
551  }
552  for (View<reco::Track>::size_type i = 0; i < trackCollection.size(); ++i) {
553  auto const& track = trackCollection[i];
555  auto dR_jet = std::numeric_limits<float>::max();
557  auto&& p = track.momentum();
558  float eta = etaFromXYZ(p.x(), p.y(), p.z());
559  float phi = atan2f(p.y(), p.x());
560  for (View<reco::Track>::size_type j = 0; j < trackCollectionDr.size(); ++j) {
561  if (!validL[j])
562  continue;
563  auto dR_tmp = reco::deltaR2(eta, phi, etaL[j], phiL[j]);
564  if ((dR_tmp < dR) & (dR_tmp > std::numeric_limits<float>::min()))
565  dR = dR_tmp;
566  }
567  if (cores != nullptr) {
568  for (unsigned int ji = 0; ji < cores->size(); ji++) { //jet loop
569  const reco::Candidate& jet = (*cores)[ji];
570  double jet_eta = jet.eta();
571  double jet_phi = jet.phi();
572  auto dR_jet_tmp = reco::deltaR2(eta, phi, jet_eta, jet_phi);
573  if (dR_jet_tmp < dR_jet)
574  dR_jet = dR_jet_tmp;
575  }
576  }
577  }
578  dR_trk[i] = std::sqrt(dR);
579  dR_trk_jet[i] = std::sqrt(dR_jet);
580  }
581 }
unsigned int size_type
Definition: View.h:90
bool trackFromSeedFitFailed(const reco::Track &track)
size_type size() const
T sqrt(T t)
Definition: SSEVec.h:19
bool empty() const
T min(T a, T b)
Definition: MathUtil.h:58
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
virtual double phi() const =0
momentum azimuthal angle
virtual double eta() const =0
momentum pseudorapidity

Member Data Documentation

edm::EDGetTokenT<SimHitTPAssociationProducer::SimHitTPAssociationList> MultiTrackValidator::_simHitTpMapTag
private

Definition at line 148 of file MultiTrackValidator.h.

Referenced by dqmAnalyze().

std::vector<edm::EDGetTokenT<reco::RecoToSimCollection> > MultiTrackValidator::associatormapRtSs
private

Definition at line 123 of file MultiTrackValidator.h.

Referenced by dqmAnalyze().

std::vector<edm::EDGetTokenT<reco::SimToRecoCollection> > MultiTrackValidator::associatormapStRs
private

Definition at line 122 of file MultiTrackValidator.h.

Referenced by dqmAnalyze().

std::vector<edm::InputTag> MultiTrackValidator::associators
protected
std::vector<edm::EDGetTokenT<reco::TrackToTrackingParticleAssociator> > MultiTrackValidator::associatorTokens
private

Definition at line 121 of file MultiTrackValidator.h.

Referenced by dqmAnalyze().

edm::EDGetTokenT<reco::BeamSpot> MultiTrackValidator::bsSrc
protected
const bool MultiTrackValidator::calculateDrSingleCollection_
protected

Definition at line 83 of file MultiTrackValidator.h.

Referenced by dqmAnalyze().

edm::EDGetTokenT<edm::View<reco::Candidate> > MultiTrackValidator::cores_
private

Definition at line 139 of file MultiTrackValidator.h.

Referenced by dqmAnalyze(), and MultiTrackValidator().

CosmicTrackingParticleSelector MultiTrackValidator::cosmictpSelector
private

Definition at line 144 of file MultiTrackValidator.h.

Referenced by dqmAnalyze(), and tpParametersAndSelection().

std::string MultiTrackValidator::dirName_
private

Definition at line 134 of file MultiTrackValidator.h.

Referenced by bookHistograms(), and MultiTrackValidator().

const bool MultiTrackValidator::dodEdxPlots_
protected
const bool MultiTrackValidator::doMVAPlots_
protected

Definition at line 92 of file MultiTrackValidator.h.

Referenced by bookHistograms(), dqmAnalyze(), and MultiTrackValidator().

const bool MultiTrackValidator::doPlotsOnlyForTruePV_
protected

Definition at line 84 of file MultiTrackValidator.h.

Referenced by dqmAnalyze(), and MultiTrackValidator().

const bool MultiTrackValidator::doPVAssociationPlots_
protected

Definition at line 90 of file MultiTrackValidator.h.

Referenced by bookHistograms(), dqmAnalyze(), and MultiTrackValidator().

const bool MultiTrackValidator::doRecoTrackPlots_
protected
std::vector<bool> MultiTrackValidator::doResolutionPlots_
protected

Definition at line 94 of file MultiTrackValidator.h.

Referenced by bookHistograms(), dqmAnalyze(), and MultiTrackValidator().

const bool MultiTrackValidator::doSeedPlots_
protected

Definition at line 91 of file MultiTrackValidator.h.

Referenced by bookHistograms(), dqmAnalyze(), and MultiTrackValidator().

const bool MultiTrackValidator::doSimPlots_
protected
const bool MultiTrackValidator::doSimTrackPlots_
protected
const bool MultiTrackValidator::doSummaryPlots_
protected

Definition at line 85 of file MultiTrackValidator.h.

Referenced by bookHistograms(), and dqmAnalyze().

TrackingParticleSelector MultiTrackValidator::dRtpSelector
private

Definition at line 145 of file MultiTrackValidator.h.

Referenced by dqmAnalyze(), and tpDR().

std::unique_ptr<RecoTrackSelectorBase> MultiTrackValidator::dRTrackSelector
private

Definition at line 146 of file MultiTrackValidator.h.

Referenced by dqmAnalyze().

std::unique_ptr<MTVHistoProducerAlgoForTracker> MultiTrackValidator::histoProducerAlgo_
protected
const bool MultiTrackValidator::ignoremissingtkcollection_
protected

Definition at line 81 of file MultiTrackValidator.h.

Referenced by MultiTrackValidatorGenPs::dqmAnalyze(), and dqmAnalyze().

std::vector<edm::InputTag> MultiTrackValidator::label
protected
edm::EDGetTokenT<std::vector<PileupSummaryInfo> > MultiTrackValidator::label_pileupinfo
protected
edm::EDGetTokenT<TrackingParticleCollection> MultiTrackValidator::label_tp_effic
protected
edm::EDGetTokenT<TrackingParticleRefVector> MultiTrackValidator::label_tp_effic_refvector
protected

Definition at line 66 of file MultiTrackValidator.h.

Referenced by dqmAnalyze(), and MultiTrackValidator().

edm::EDGetTokenT<TrackingParticleCollection> MultiTrackValidator::label_tp_fake
protected
edm::EDGetTokenT<TrackingParticleRefVector> MultiTrackValidator::label_tp_fake_refvector
protected

Definition at line 67 of file MultiTrackValidator.h.

Referenced by dqmAnalyze(), and MultiTrackValidator().

edm::EDGetTokenT<TrackingVertexCollection> MultiTrackValidator::label_tv
protected

Definition at line 68 of file MultiTrackValidator.h.

Referenced by dqmAnalyze(), and MultiTrackValidator().

std::vector<edm::EDGetTokenT<edm::View<reco::Track> > > MultiTrackValidator::labelToken
protected
edm::EDGetTokenT<edm::View<reco::Track> > MultiTrackValidator::labelTokenForDrCalculation
private

Definition at line 149 of file MultiTrackValidator.h.

Referenced by dqmAnalyze().

std::vector<edm::EDGetTokenT<edm::View<TrajectorySeed> > > MultiTrackValidator::labelTokenSeed
protected

Definition at line 75 of file MultiTrackValidator.h.

edm::EDGetTokenT<edm::ValueMap<reco::DeDxData> > MultiTrackValidator::m_dEdx1Tag
protected
edm::EDGetTokenT<edm::ValueMap<reco::DeDxData> > MultiTrackValidator::m_dEdx2Tag
protected
std::vector<std::vector<std::tuple<edm::EDGetTokenT<MVACollection>, edm::EDGetTokenT<QualityMaskCollection> > > > MultiTrackValidator::mvaQualityCollectionTokens_
private

Definition at line 132 of file MultiTrackValidator.h.

Referenced by bookHistograms(), dqmAnalyze(), and MultiTrackValidator().

const bool MultiTrackValidator::parametersDefinerIsCosmic_
protected
std::unique_ptr<ParametersDefinerForTP> MultiTrackValidator::parametersDefinerTP_
protected
double MultiTrackValidator::ptMinJet_
private

Definition at line 140 of file MultiTrackValidator.h.

edm::EDGetTokenT<edm::View<reco::Vertex> > MultiTrackValidator::recoVertexToken_
private

Definition at line 150 of file MultiTrackValidator.h.

Referenced by getRecoPVPosition(), and MultiTrackValidator().

std::vector<edm::EDGetTokenT<std::vector<PSimHit> > > MultiTrackValidator::simHitTokens_
protected

Definition at line 71 of file MultiTrackValidator.h.

Referenced by MultiTrackValidator().

const double MultiTrackValidator::simPVMaxZ_
private

Definition at line 137 of file MultiTrackValidator.h.

Referenced by dqmAnalyze().

edm::EDGetTokenT<edm::ValueMap<unsigned int> > MultiTrackValidator::tpNLayersToken_
private

Definition at line 125 of file MultiTrackValidator.h.

Referenced by dqmAnalyze(), and MultiTrackValidator().

edm::EDGetTokenT<edm::ValueMap<unsigned int> > MultiTrackValidator::tpNPixelLayersToken_
private

Definition at line 126 of file MultiTrackValidator.h.

Referenced by dqmAnalyze(), and MultiTrackValidator().

edm::EDGetTokenT<edm::ValueMap<unsigned int> > MultiTrackValidator::tpNStripStereoLayersToken_
private

Definition at line 127 of file MultiTrackValidator.h.

Referenced by dqmAnalyze(), and MultiTrackValidator().

TrackingParticleSelector MultiTrackValidator::tpSelector
private

Definition at line 143 of file MultiTrackValidator.h.

Referenced by tpParametersAndSelection().

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> MultiTrackValidator::tTopoEsToken
protected

Definition at line 56 of file MultiTrackValidator.h.

Referenced by MultiTrackValidatorGenPs::dqmAnalyze(), and dqmAnalyze().

const bool MultiTrackValidator::useAssociators_
protected
bool MultiTrackValidator::useGsf
private

Definition at line 136 of file MultiTrackValidator.h.

edm::EDGetTokenT<reco::VertexToTrackingVertexAssociator> MultiTrackValidator::vertexAssociatorToken_
private

Definition at line 151 of file MultiTrackValidator.h.

Referenced by getRecoPVPosition(), and MultiTrackValidator().