CMS 3D CMS Logo

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

#include <MultiTrackValidator.h>

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

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 Method called once per event. More...
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 Method called to book the DQM histograms. More...
 
 MultiTrackValidator (const edm::ParameterSet &pset)
 Constructor. More...
 
virtual ~MultiTrackValidator ()
 Destructor. More...
 
- Public Member Functions inherited from DQMEDAnalyzer
virtual void beginRun (edm::Run const &, edm::EventSetup const &) final
 
virtual void beginStream (edm::StreamID id) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer (void)
 
virtual void endLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
virtual void endRunSummary (edm::Run const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
uint32_t streamId () const
 
- Public Member Functions inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::stream::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Attributes

const bool calculateDrSingleCollection_
 
const bool dodEdxPlots_
 
const bool doPlotsOnlyForTruePV_
 
const bool doPVAssociationPlots_
 
const bool doRecoTrackPlots_
 
const bool doSeedPlots_
 
const bool doSimPlots_
 
const bool doSimTrackPlots_
 
const bool doSummaryPlots_
 
std::unique_ptr
< MTVHistoProducerAlgoForTracker
histoProducerAlgo_
 
const bool parametersDefinerIsCosmic_
 
bool UseAssociators
 
- Protected Attributes inherited from MultiTrackValidatorBase
std::vector< edm::InputTagassociators
 
edm::EDGetTokenT< reco::BeamSpotbsSrc
 
bool ignoremissingtkcollection_
 
std::vector< edm::InputTaglabel
 
edm::EDGetTokenT< std::vector
< PileupSummaryInfo > > 
label_pileupinfo
 
edm::EDGetTokenT
< TrackingParticleCollection
label_tp_effic
 
edm::EDGetTokenT
< TrackingParticleCollection
label_tp_fake
 
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
 
std::string parametersDefiner
 
std::vector< edm::EDGetTokenT
< std::vector< PSimHit > > > 
simHitTokens_
 

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
 
CosmicTrackingParticleSelector cosmictpSelector
 
std::string dirName_
 
TrackingParticleSelector dRtpSelector
 
TrackingParticleSelector dRtpSelectorNoPtCut
 
std::vector< MonitorElement * > h_assoc2_coll
 
std::vector< MonitorElement * > h_assoc_coll
 
std::vector< MonitorElement * > h_assoc_coll_allPt
 
std::vector< MonitorElement * > h_looper_coll
 
std::vector< MonitorElement * > h_pileup_coll
 
std::vector< MonitorElement * > h_reco_coll
 
std::vector< MonitorElement * > h_simul_coll
 
std::vector< MonitorElement * > h_simul_coll_allPt
 
edm::EDGetTokenT< edm::View
< reco::Track > > 
labelTokenForDrCalculation
 
edm::EDGetTokenT< edm::View
< reco::Vertex > > 
recoVertexToken_
 
std::vector< edm::EDGetTokenT
< std::vector< int > > > 
seedToTrackTokens_
 
TrackingParticleSelector tpSelector
 
bool useGsf
 
edm::EDGetTokenT
< reco::VertexToTrackingVertexAssociator
vertexAssociatorToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDAnalyzerBase
typedef EDAnalyzerAdaptorBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static std::shared_ptr
< dqmDetails::NoCache
globalBeginLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
 
static std::shared_ptr
< dqmDetails::NoCache
globalBeginRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *)
 
static void globalEndLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *, dqmDetails::NoCache *)
 
static void globalEndRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *, dqmDetails::NoCache *)
 
- Static Public Member Functions inherited from edm::stream::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
- Protected Member Functions inherited from MultiTrackValidatorBase
 MultiTrackValidatorBase (const edm::ParameterSet &pset, edm::ConsumesCollector &&iC, bool isSeed=false)
 Constructor. More...
 
virtual ~MultiTrackValidatorBase ()
 Destructor. More...
 

Detailed Description

Class that prodecs histrograms to validate Track Reconstruction performances

Author
cerati

Definition at line 15 of file MultiTrackValidator.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 44 of file MultiTrackValidator.cc.

References _simHitTpMapTag, associatormapRtSs, associatormapStRs, MultiTrackValidatorBase::associators, associatorTokens, calculateDrSingleCollection_, edm::EDConsumerBase::consumes(), edm::EDConsumerBase::consumesCollector(), cosmictpSelector, dirName_, dodEdxPlots_, doPlotsOnlyForTruePV_, doPVAssociationPlots_, doSeedPlots_, dRtpSelector, dRtpSelectorNoPtCut, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), histoProducerAlgo_, MultiTrackValidatorBase::label_tv, labelTokenForDrCalculation, MultiTrackValidatorBase::m_dEdx1Tag, MultiTrackValidatorBase::m_dEdx2Tag, recoVertexToken_, seedToTrackTokens_, alcazmumu_cfi::src, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, tpSelector, UseAssociators, useGsf, and vertexAssociatorToken_.

44  :
46  parametersDefinerIsCosmic_(parametersDefiner == "CosmicParametersDefinerForTP"),
47  calculateDrSingleCollection_(pset.getUntrackedParameter<bool>("calculateDrSingleCollection")),
48  doPlotsOnlyForTruePV_(pset.getUntrackedParameter<bool>("doPlotsOnlyForTruePV")),
49  doSummaryPlots_(pset.getUntrackedParameter<bool>("doSummaryPlots")),
50  doSimPlots_(pset.getUntrackedParameter<bool>("doSimPlots")),
51  doSimTrackPlots_(pset.getUntrackedParameter<bool>("doSimTrackPlots")),
52  doRecoTrackPlots_(pset.getUntrackedParameter<bool>("doRecoTrackPlots")),
53  dodEdxPlots_(pset.getUntrackedParameter<bool>("dodEdxPlots")),
54  doPVAssociationPlots_(pset.getUntrackedParameter<bool>("doPVAssociationPlots")),
55  doSeedPlots_(pset.getUntrackedParameter<bool>("doSeedPlots"))
56 {
57  ParameterSet psetForHistoProducerAlgo = pset.getParameter<ParameterSet>("histoProducerAlgoBlock");
58  histoProducerAlgo_ = std::make_unique<MTVHistoProducerAlgoForTracker>(psetForHistoProducerAlgo, consumesCollector());
59 
60  dirName_ = pset.getParameter<std::string>("dirName");
61  UseAssociators = pset.getParameter< bool >("UseAssociators");
62 
63  if(dodEdxPlots_) {
64  m_dEdx1Tag = consumes<edm::ValueMap<reco::DeDxData> >(pset.getParameter< edm::InputTag >("dEdx1Tag"));
65  m_dEdx2Tag = consumes<edm::ValueMap<reco::DeDxData> >(pset.getParameter< edm::InputTag >("dEdx2Tag"));
66  }
67 
69  label_tv = consumes<TrackingVertexCollection>(pset.getParameter< edm::InputTag >("label_tv"));
70  recoVertexToken_ = consumes<edm::View<reco::Vertex> >(pset.getUntrackedParameter<edm::InputTag>("label_vertex"));
71  vertexAssociatorToken_ = consumes<reco::VertexToTrackingVertexAssociator>(pset.getUntrackedParameter<edm::InputTag>("vertexAssociator"));
72  }
73 
74  tpSelector = TrackingParticleSelector(pset.getParameter<double>("ptMinTP"),
75  pset.getParameter<double>("minRapidityTP"),
76  pset.getParameter<double>("maxRapidityTP"),
77  pset.getParameter<double>("tipTP"),
78  pset.getParameter<double>("lipTP"),
79  pset.getParameter<int>("minHitTP"),
80  pset.getParameter<bool>("signalOnlyTP"),
81  pset.getParameter<bool>("intimeOnlyTP"),
82  pset.getParameter<bool>("chargedOnlyTP"),
83  pset.getParameter<bool>("stableOnlyTP"),
84  pset.getParameter<std::vector<int> >("pdgIdTP"));
85 
87  pset.getParameter<double>("minRapidityTP"),
88  pset.getParameter<double>("maxRapidityTP"),
89  pset.getParameter<double>("tipTP"),
90  pset.getParameter<double>("lipTP"),
91  pset.getParameter<int>("minHitTP"),
92  pset.getParameter<bool>("chargedOnlyTP"),
93  pset.getParameter<std::vector<int> >("pdgIdTP"));
94 
95 
96  ParameterSet psetVsPhi = psetForHistoProducerAlgo.getParameter<ParameterSet>("TpSelectorForEfficiencyVsPhi");
97  dRtpSelector = TrackingParticleSelector(psetVsPhi.getParameter<double>("ptMin"),
98  psetVsPhi.getParameter<double>("minRapidity"),
99  psetVsPhi.getParameter<double>("maxRapidity"),
100  psetVsPhi.getParameter<double>("tip"),
101  psetVsPhi.getParameter<double>("lip"),
102  psetVsPhi.getParameter<int>("minHit"),
103  psetVsPhi.getParameter<bool>("signalOnly"),
104  psetVsPhi.getParameter<bool>("intimeOnly"),
105  psetVsPhi.getParameter<bool>("chargedOnly"),
106  psetVsPhi.getParameter<bool>("stableOnly"),
107  psetVsPhi.getParameter<std::vector<int> >("pdgId"));
108 
110  psetVsPhi.getParameter<double>("minRapidity"),
111  psetVsPhi.getParameter<double>("maxRapidity"),
112  psetVsPhi.getParameter<double>("tip"),
113  psetVsPhi.getParameter<double>("lip"),
114  psetVsPhi.getParameter<int>("minHit"),
115  psetVsPhi.getParameter<bool>("signalOnly"),
116  psetVsPhi.getParameter<bool>("intimeOnly"),
117  psetVsPhi.getParameter<bool>("chargedOnly"),
118  psetVsPhi.getParameter<bool>("stableOnly"),
119  psetVsPhi.getParameter<std::vector<int> >("pdgId"));
120 
121  useGsf = pset.getParameter<bool>("useGsf");
122 
123  _simHitTpMapTag = mayConsume<SimHitTPAssociationProducer::SimHitTPAssociationList>(pset.getParameter<edm::InputTag>("simHitTpMapTag"));
124 
126  labelTokenForDrCalculation = consumes<edm::View<reco::Track> >(pset.getParameter<edm::InputTag>("trackCollectionForDrCalculation"));
127  }
128 
129  if(UseAssociators) {
130  for (auto const& src: associators) {
131  associatorTokens.push_back(consumes<reco::TrackToTrackingParticleAssociator>(src));
132  }
133  } else {
134  for (auto const& src: associators) {
135  associatormapStRs.push_back(consumes<reco::SimToRecoCollection>(src));
136  associatormapRtSs.push_back(consumes<reco::RecoToSimCollection>(src));
137  }
138  }
139 
140  if(doSeedPlots_) {
141  for(const auto& tag: pset.getParameter< std::vector<edm::InputTag> >("label")) {
142  seedToTrackTokens_.push_back(consumes<std::vector<int>>(tag));
143  }
144  }
145 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx1Tag
T getUntrackedParameter(std::string const &, T const &) const
std::vector< edm::InputTag > associators
edm::EDGetTokenT< SimHitTPAssociationProducer::SimHitTPAssociationList > _simHitTpMapTag
std::vector< edm::EDGetTokenT< reco::SimToRecoCollection > > associatormapStRs
CosmicTrackingParticleSelector cosmictpSelector
edm::EDGetTokenT< TrackingVertexCollection > label_tv
TrackingParticleSelector dRtpSelector
TrackingParticleSelector dRtpSelectorNoPtCut
std::vector< edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > > associatorTokens
const bool doPlotsOnlyForTruePV_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
std::vector< edm::EDGetTokenT< reco::RecoToSimCollection > > associatormapRtSs
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
TrackingParticleSelector tpSelector
MultiTrackValidatorBase(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC, bool isSeed=false)
Constructor.
edm::EDGetTokenT< edm::View< reco::Track > > labelTokenForDrCalculation
std::vector< edm::EDGetTokenT< std::vector< int > > > seedToTrackTokens_
ObjectSelector< CosmicTrackingParticleSelector > CosmicTrackingParticleSelector
std::unique_ptr< MTVHistoProducerAlgoForTracker > histoProducerAlgo_
edm::EDGetTokenT< reco::VertexToTrackingVertexAssociator > vertexAssociatorToken_
const bool doPVAssociationPlots_
edm::EDGetTokenT< edm::View< reco::Vertex > > recoVertexToken_
const bool calculateDrSingleCollection_
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx2Tag
const bool parametersDefinerIsCosmic_
MultiTrackValidator::~MultiTrackValidator ( )
virtual

Destructor.

Definition at line 148 of file MultiTrackValidator.cc.

148 {}

Member Function Documentation

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

Method called once per event.

Implements edm::stream::EDAnalyzerBase.

Reimplemented in MultiTrackValidatorGenPs.

Definition at line 240 of file MultiTrackValidator.cc.

References _simHitTpMapTag, associationMapFilterValues(), associatormapRtSs, associatormapStRs, MultiTrackValidatorBase::associators, associatorTokens, MultiTrackValidatorBase::bsSrc, EncodedEventId::bunchCrossing(), TrackingParticleNumberOfLayers::calculate(), calculateDrSingleCollection_, reco::TrackBase::charge(), funct::cos(), cosmictpSelector, KineDebug3::count(), reco::deltaR2(), dodEdxPlots_, doPlotsOnlyForTruePV_, doPVAssociationPlots_, doRecoTrackPlots_, doSeedPlots_, doSimPlots_, doSimTrackPlots_, doSummaryPlots_, PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, dRtpSelector, dRtpSelectorNoPtCut, edm::AssociationMap< Tag >::end(), eta, EncodedEventId::event(), TrackingParticle::eventId(), TrackingVertex::eventId(), edm::AssociationMap< Tag >::find(), plotBeamSpotDB::first, edm::EventSetup::get(), edm::Event::getByToken(), h_assoc2_coll, h_assoc_coll, h_assoc_coll_allPt, h_looper_coll, h_pileup_coll, h_reco_coll, h_simul_coll, h_simul_coll_allPt, histoProducerAlgo_, i, MultiTrackValidatorBase::ignoremissingtkcollection_, CosmicTrackingParticleSelector::initEvent(), j, MultiTrackValidatorBase::label, MultiTrackValidatorBase::label_pileupinfo, MultiTrackValidatorBase::label_tp_effic, MultiTrackValidatorBase::label_tp_fake, MultiTrackValidatorBase::label_tv, MultiTrackValidatorBase::labelToken, labelTokenForDrCalculation, LogDebug, LogTrace, MultiTrackValidatorBase::m_dEdx1Tag, MultiTrackValidatorBase::m_dEdx2Tag, bookConverter::max, min(), TrackingParticle::momentum(), eostools::move(), TrackingParticle::numberOfTrackerHits(), AlCaHLTBitMon_ParallelJobs::p, MultiTrackValidatorBase::parametersDefiner, parametersDefinerIsCosmic_, phi, edm::Handle< T >::product(), reco::TrackBase::pt(), dt_dqm_sourceclient_common_cff::reco, recoVertexToken_, seedToTrackTokens_, MultiTrackValidatorBase::simHitTokens_, funct::sin(), edm::View< T >::size(), findQualityFiles::size, mathSSE::sqrt(), tpSelector, HLT_25ns10e33_v2_cff::trackCollection, UseAssociators, TrackingParticle::vertex(), vertexAssociatorToken_, and w.

240  {
241  using namespace reco;
242 
243  LogDebug("TrackValidator") << "\n====================================================" << "\n"
244  << "Analyzing new event" << "\n"
245  << "====================================================\n" << "\n";
246 
247 
248  edm::ESHandle<ParametersDefinerForTP> parametersDefinerTPHandle;
249  setup.get<TrackAssociatorRecord>().get(parametersDefiner,parametersDefinerTPHandle);
250  //Since we modify the object, we must clone it
251  auto parametersDefinerTP = parametersDefinerTPHandle->clone();
252 
253  edm::Handle<TrackingParticleCollection> TPCollectionHeff ;
254  event.getByToken(label_tp_effic,TPCollectionHeff);
255  TrackingParticleCollection const & tPCeff = *(TPCollectionHeff.product());
256 
257  edm::Handle<TrackingParticleCollection> TPCollectionHfake ;
258  event.getByToken(label_tp_fake,TPCollectionHfake);
259 
260 
263  //warning: make sure the TP collection used in the map is the same used in the MTV!
264  event.getByToken(_simHitTpMapTag,simHitsTPAssoc);
265  parametersDefinerTP->initEvent(simHitsTPAssoc);
266  cosmictpSelector.initEvent(simHitsTPAssoc);
267  }
268 
269  const reco::Vertex::Point *thePVposition = nullptr;
270  const TrackingVertex::LorentzVector *theSimPVPosition = nullptr;
273  event.getByToken(label_tv, htv);
274 
276  event.getByToken(recoVertexToken_, hvertex);
277 
279  event.getByToken(vertexAssociatorToken_, hvassociator);
280 
281  auto v_r2s = hvassociator->associateRecoToSim(hvertex, htv);
282  auto pvPtr = hvertex->refAt(0);
283  if(!(pvPtr->isFake() || pvPtr->ndof() < 0)) { // skip junk vertices
284  auto pvFound = v_r2s.find(pvPtr);
285  if(pvFound != v_r2s.end()) {
286  int simPVindex = -1;
287  int i=0;
288  for(const auto& vertexRefQuality: pvFound->val) {
289  const TrackingVertex& tv = *(vertexRefQuality.first);
290  if(tv.eventId().event() == 0 && tv.eventId().bunchCrossing() == 0) {
291  simPVindex = i;
292  }
293  ++i;
294  }
295  if(simPVindex >= 0) {
297  thePVposition = &(pvPtr->position());
298  theSimPVPosition = &(pvFound->val[simPVindex].first->position());
299  }
300  }
301  else if(doPlotsOnlyForTruePV_)
302  return;
303  }
304  else if(doPlotsOnlyForTruePV_)
305  return;
306  }
307  else if(doPlotsOnlyForTruePV_)
308  return;
309  }
310 
311  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
312  event.getByToken(bsSrc,recoBeamSpotHandle);
313  reco::BeamSpot const & bs = *recoBeamSpotHandle;
314 
316  event.getByToken(label_pileupinfo,puinfoH);
317  PileupSummaryInfo puinfo;
318 
319  for (unsigned int puinfo_ite=0;puinfo_ite<(*puinfoH).size();++puinfo_ite){
320  if ((*puinfoH)[puinfo_ite].getBunchCrossing()==0){
321  puinfo=(*puinfoH)[puinfo_ite];
322  break;
323  }
324  }
325 
326  /*
327  edm::Handle<TrackingVertexCollection> tvH;
328  event.getByToken(label_tv,tvH);
329  TrackingVertexCollection const & tv = *tvH;
330  */
331 
332  // Calculate the number of 3D layers for TPs
333  //
334  // I would have preferred to produce the ValueMap to Event and read
335  // it from there, but there would have been quite some number of
336  // knock-on effects, and again the fact that we take two TP
337  // collections do not support Ref<TP>'s would have complicated that.
338  //
339  // In principle we could use the SimHitTPAssociationList read above
340  // for parametersDefinerIsCosmic_, but since we don't currently
341  // support Ref<TP>s, we can't in general use it since eff/fake TP
342  // collections can, in general, be different.
343  TrackingParticleNumberOfLayers tpNumberOfLayersAlgo(event, simHitTokens_);
344  auto nlayers_tPCeff_ptrs = tpNumberOfLayersAlgo.calculate(TPCollectionHeff, setup);
345  const auto& nLayers_tPCeff = *(std::get<TrackingParticleNumberOfLayers::nTrackerLayers>(nlayers_tPCeff_ptrs));
346  const auto& nPixelLayers_tPCeff = *(std::get<TrackingParticleNumberOfLayers::nPixelLayers>(nlayers_tPCeff_ptrs));
347  const auto& nStripMonoAndStereoLayers_tPCeff = *(std::get<TrackingParticleNumberOfLayers::nStripMonoAndStereoLayers>(nlayers_tPCeff_ptrs));
348 
349  // Precalculate TP selection (for efficiency), and momentum and vertex wrt PCA
350  //
351  // TODO: ParametersDefinerForTP ESProduct needs to be changed to
352  // EDProduct because of consumes.
353  //
354  // In principle, we could just precalculate the momentum and vertex
355  // wrt PCA for all TPs for once and put that to the event. To avoid
356  // repetitive calculations those should be calculated only once for
357  // each TP. That would imply that we should access TPs via Refs
358  // (i.e. View) in here, since, in general, the eff and fake TP
359  // collections can be different (and at least HI seems to use that
360  // feature). This would further imply that the
361  // RecoToSimCollection/SimToRecoCollection should be changed to use
362  // View<TP> instead of vector<TP>, and migrate everything.
363  //
364  // Or we could take only one input TP collection, and do another
365  // TP-selection to obtain the "fake" collection like we already do
366  // for "efficiency" TPs.
367  std::vector<size_t> selected_tPCeff;
368  std::vector<std::tuple<TrackingParticle::Vector, TrackingParticle::Point>> momVert_tPCeff;
369  selected_tPCeff.reserve(tPCeff.size());
370  momVert_tPCeff.reserve(tPCeff.size());
371  int nIntimeTPs = 0;
373  for(size_t j=0; j<tPCeff.size(); ++j) {
374  TrackingParticleRef tpr(TPCollectionHeff, j);
375 
376  TrackingParticle::Vector momentum = parametersDefinerTP->momentum(event,setup,tpr);
377  TrackingParticle::Point vertex = parametersDefinerTP->vertex(event,setup,tpr);
378  if(doSimPlots_) {
379  histoProducerAlgo_->fill_generic_simTrack_histos(momentum, vertex, tpr->eventId().bunchCrossing());
380  }
381  if(tpr->eventId().bunchCrossing() == 0)
382  ++nIntimeTPs;
383 
384  if(cosmictpSelector(tpr,&bs,event,setup)) {
385  selected_tPCeff.push_back(j);
386  momVert_tPCeff.emplace_back(momentum, vertex);
387  }
388  }
389  }
390  else {
391  size_t j=0;
392  for(auto const& tp: tPCeff) {
393 
394  // TODO: do we want to fill these from all TPs that include IT
395  // and OOT (as below), or limit to IT+OOT TPs passing tpSelector
396  // (as it was before)? The latter would require another instance
397  // of tpSelector with intimeOnly=False.
398  if(doSimPlots_) {
399  histoProducerAlgo_->fill_generic_simTrack_histos(tp.momentum(), tp.vertex(), tp.eventId().bunchCrossing());
400  }
401  if(tp.eventId().bunchCrossing() == 0)
402  ++nIntimeTPs;
403 
404  if(tpSelector(tp)) {
405  selected_tPCeff.push_back(j);
406  TrackingParticleRef tpr(TPCollectionHeff, j);
407  TrackingParticle::Vector momentum = parametersDefinerTP->momentum(event,setup,tpr);
408  TrackingParticle::Point vertex = parametersDefinerTP->vertex(event,setup,tpr);
409  momVert_tPCeff.emplace_back(momentum, vertex);
410  }
411  ++j;
412  }
413  }
414  if(doSimPlots_) {
415  histoProducerAlgo_->fill_simTrackBased_histos(nIntimeTPs);
416  }
417 
418  //calculate dR for TPs
419  float dR_tPCeff[tPCeff.size()];
420  {
421  float etaL[tPCeff.size()], phiL[tPCeff.size()];
422  for(size_t iTP: selected_tPCeff) {
423  //calculare dR wrt inclusive collection (also with PU, low pT, displaced)
424  auto const& tp2 = tPCeff[iTP];
425  auto && p = tp2.momentum();
426  etaL[iTP] = etaFromXYZ(p.x(),p.y(),p.z());
427  phiL[iTP] = atan2f(p.y(),p.x());
428  }
429  auto i=0U;
430  for ( auto const & tp : tPCeff) {
432  if(dRtpSelector(tp)) {//only for those needed for efficiency!
433  auto && p = tp.momentum();
434  float eta = etaFromXYZ(p.x(),p.y(),p.z());
435  float phi = atan2f(p.y(),p.x());
436  for(size_t iTP: selected_tPCeff) {
437  //calculare dR wrt inclusive collection (also with PU, low pT, displaced)
438  if (i==iTP) {continue;}
439  auto dR_tmp = reco::deltaR2(eta, phi, etaL[iTP], phiL[iTP]);
440  if (dR_tmp<dR) dR=dR_tmp;
441  } // ttp2 (iTP)
442  }
443  dR_tPCeff[i++] = std::sqrt(dR);
444  } // tp
445  }
446 
447  edm::Handle<View<Track> > trackCollectionForDrCalculation;
449  event.getByToken(labelTokenForDrCalculation, trackCollectionForDrCalculation);
450  }
451 
452  // dE/dx
453  // at some point this could be generalized, with a vector of tags and a corresponding vector of Handles
454  // I'm writing the interface such to take vectors of ValueMaps
455  std::vector<const edm::ValueMap<reco::DeDxData> *> v_dEdx;
456  if(dodEdxPlots_) {
459  event.getByToken(m_dEdx1Tag, dEdx1Handle);
460  event.getByToken(m_dEdx2Tag, dEdx2Handle);
461  v_dEdx.push_back(dEdx1Handle.product());
462  v_dEdx.push_back(dEdx2Handle.product());
463  }
464 
465  int w=0; //counter counting the number of sets of histograms
466  for (unsigned int ww=0;ww<associators.size();ww++){
467  for (unsigned int www=0;www<label.size();www++, w++){ // need to increment w here, since there are many continues in the loop body
468  //
469  //get collections from the event
470  //
472  if(!event.getByToken(labelToken[www], trackCollection)&&ignoremissingtkcollection_)continue;
473 
474  reco::RecoToSimCollection const * recSimCollP=nullptr;
475  reco::SimToRecoCollection const * simRecCollP=nullptr;
476  reco::RecoToSimCollection recSimCollL;
477  reco::SimToRecoCollection simRecCollL;
478 
479  //associate tracks
480  LogTrace("TrackValidator") << "Analyzing "
481  << label[www] << " with "
482  << associators[ww] <<"\n";
483  if(UseAssociators){
485  event.getByToken(associatorTokens[ww], theAssociator);
486 
487  LogTrace("TrackValidator") << "Calling associateRecoToSim method" << "\n";
488  recSimCollL = std::move(theAssociator->associateRecoToSim(trackCollection,
489  TPCollectionHfake));
490  recSimCollP = &recSimCollL;
491  LogTrace("TrackValidator") << "Calling associateSimToReco method" << "\n";
492  simRecCollL = std::move(theAssociator->associateSimToReco(trackCollection,
493  TPCollectionHeff));
494  simRecCollP = &simRecCollL;
495  }
496  else{
497  Handle<reco::SimToRecoCollection > simtorecoCollectionH;
498  event.getByToken(associatormapStRs[ww], simtorecoCollectionH);
499  simRecCollP = simtorecoCollectionH.product();
500 
501  // We need to filter the associations of the current track
502  // collection only from SimToReco collection, otherwise the
503  // SimToReco histograms get false entries
504  simRecCollL = associationMapFilterValues(*simRecCollP, *trackCollection);
505  simRecCollP = &simRecCollL;
506 
507  Handle<reco::RecoToSimCollection > recotosimCollectionH;
508  event.getByToken(associatormapRtSs[ww],recotosimCollectionH);
509  recSimCollP = recotosimCollectionH.product();
510 
511  // In general, we should filter also the RecoToSim collection.
512  // But, that would require changing the input type of TPs to
513  // View<TrackingParticle>, and either replace current
514  // associator interfaces with (View<Track>, View<TP>) or
515  // adding the View,View interface (same goes for
516  // RefToBaseVector,RefToBaseVector). Since there is currently
517  // no compelling-enough use-case, we do not filter the
518  // RecoToSim collection here. If an association using a subset
519  // of the Sim collection is needed, user has to produce such
520  // an association explicitly.
521  }
522 
523  reco::RecoToSimCollection const & recSimColl = *recSimCollP;
524  reco::SimToRecoCollection const & simRecColl = *simRecCollP;
525 
526 
527  // Fill seed-specific histograms
528  if(doSeedPlots_) {
529  edm::Handle<std::vector<int>> hseedToTrack;
530  event.getByToken(seedToTrackTokens_[www], hseedToTrack);
531  const int failed = std::count(hseedToTrack->begin(), hseedToTrack->end(), -1);
532  histoProducerAlgo_->fill_seed_histos(www, failed, hseedToTrack->size());
533  }
534 
535 
536  // ########################################################
537  // fill simulation histograms (LOOP OVER TRACKINGPARTICLES)
538  // ########################################################
539 
540  //compute number of tracks per eta interval
541  //
542  LogTrace("TrackValidator") << "\n# of TrackingParticles: " << tPCeff.size() << "\n";
543  int ats(0); //This counter counts the number of simTracks that are "associated" to recoTracks
544  int st(0); //This counter counts the number of simulated tracks passing the MTV selection (i.e. tpSelector(tp) )
545  unsigned sts(0); //This counter counts the number of simTracks surviving the bunchcrossing cut
546  unsigned asts(0); //This counter counts the number of simTracks that are "associated" to recoTracks surviving the bunchcrossing cut
547 
548  //loop over already-selected TPs for tracking efficiency
549  for(size_t i=0; i<selected_tPCeff.size(); ++i) {
550  size_t iTP = selected_tPCeff[i];
551  TrackingParticleRef tpr(TPCollectionHeff, iTP);
552  const TrackingParticle& tp = tPCeff[iTP];
553 
554  auto const& momVert = momVert_tPCeff[i];
555  TrackingParticle::Vector momentumTP;
556  TrackingParticle::Point vertexTP;
557 
558  double dxySim(0);
559  double dzSim(0);
560  double dxyPVSim = 0;
561  double dzPVSim = 0;
562  double dR=dR_tPCeff[iTP];
563 
564  //---------- THIS PART HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
565  //If the TrackingParticle is collison like, get the momentum and vertex at production state
567  {
568  momentumTP = tp.momentum();
569  vertexTP = tp.vertex();
570  //Calcualte the impact parameters w.r.t. PCA
571  const TrackingParticle::Vector& momentum = std::get<TrackingParticle::Vector>(momVert);
572  const TrackingParticle::Point& vertex = std::get<TrackingParticle::Point>(momVert);
573  dxySim = (-vertex.x()*sin(momentum.phi())+vertex.y()*cos(momentum.phi()));
574  dzSim = vertex.z() - (vertex.x()*momentum.x()+vertex.y()*momentum.y())/sqrt(momentum.perp2())
575  * momentum.z()/sqrt(momentum.perp2());
576 
577  if(theSimPVPosition) {
578  // As in TrackBase::dxy(Point) and dz(Point)
579  dxyPVSim = -(vertex.x()-theSimPVPosition->x())*sin(momentum.phi()) + (vertex.y()-theSimPVPosition->y())*cos(momentum.phi());
580  dzPVSim = vertex.z()-theSimPVPosition->z() - ( (vertex.x()-theSimPVPosition->x()) + (vertex.y()-theSimPVPosition->y()) )/sqrt(momentum.perp2()) * momentum.z()/sqrt(momentum.perp2());
581  }
582  }
583  //If the TrackingParticle is comics, get the momentum and vertex at PCA
584  else
585  {
586  momentumTP = std::get<TrackingParticle::Vector>(momVert);
587  vertexTP = std::get<TrackingParticle::Point>(momVert);
588  dxySim = (-vertexTP.x()*sin(momentumTP.phi())+vertexTP.y()*cos(momentumTP.phi()));
589  dzSim = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y())/sqrt(momentumTP.perp2())
590  * momentumTP.z()/sqrt(momentumTP.perp2());
591 
592  // Do dxy and dz vs. PV make any sense for cosmics? I guess not
593  }
594  //---------- THE PART ABOVE HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
595 
596  //This counter counts the number of simulated tracks passing the MTV selection (i.e. tpSelector(tp) ), but only for in-time TPs
597  if(tp.eventId().bunchCrossing() == 0) {
598  st++;
599  }
600 
601  // in the coming lines, histos are filled using as input
602  // - momentumTP
603  // - vertexTP
604  // - dxySim
605  // - dzSim
606  if(!doSimTrackPlots_)
607  continue;
608 
609  // ##############################################
610  // fill RecoAssociated SimTracks' histograms
611  // ##############################################
612  const reco::Track* matchedTrackPointer=0;
613  if(simRecColl.find(tpr) != simRecColl.end()){
614  auto const & rt = simRecColl[tpr];
615  if (rt.size()!=0) {
616  ats++; //This counter counts the number of simTracks that have a recoTrack associated
617  // isRecoMatched = true; // UNUSED
618  matchedTrackPointer = rt.begin()->first.get();
619  LogTrace("TrackValidator") << "TrackingParticle #" << st
620  << " with pt=" << sqrt(momentumTP.perp2())
621  << " associated with quality:" << rt.begin()->second <<"\n";
622  }
623  }else{
624  LogTrace("TrackValidator")
625  << "TrackingParticle #" << st
626  << " with pt,eta,phi: "
627  << sqrt(momentumTP.perp2()) << " , "
628  << momentumTP.eta() << " , "
629  << momentumTP.phi() << " , "
630  << " NOT associated to any reco::Track" << "\n";
631  }
632 
633 
634 
635 
636  int nSimHits = tp.numberOfTrackerHits();
637  int nSimLayers = nLayers_tPCeff[tpr];
638  int nSimPixelLayers = nPixelLayers_tPCeff[tpr];
639  int nSimStripMonoAndStereoLayers = nStripMonoAndStereoLayers_tPCeff[tpr];
640  histoProducerAlgo_->fill_recoAssociated_simTrack_histos(w,tp,momentumTP,vertexTP,dxySim,dzSim,dxyPVSim,dzPVSim,nSimHits,nSimLayers,nSimPixelLayers,nSimStripMonoAndStereoLayers,matchedTrackPointer,puinfo.getPU_NumInteractions(), dR, thePVposition);
641  sts++;
642  if(matchedTrackPointer)
643  asts++;
644  if(doSummaryPlots_) {
645  if(dRtpSelectorNoPtCut(tp)) {
646  h_simul_coll_allPt[ww]->Fill(www);
647  if (matchedTrackPointer) {
648  h_assoc_coll_allPt[ww]->Fill(www);
649  }
650 
651  if(dRtpSelector(tp)) {
652  h_simul_coll[ww]->Fill(www);
653  if (matchedTrackPointer) {
654  h_assoc_coll[ww]->Fill(www);
655  }
656  }
657  }
658  }
659 
660 
661 
662 
663  } // End for (TrackingParticleCollection::size_type i=0; i<tPCeff.size(); i++){
664 
665  // ##############################################
666  // fill recoTracks histograms (LOOP OVER TRACKS)
667  // ##############################################
668  if(!doRecoTrackPlots_)
669  continue;
670  LogTrace("TrackValidator") << "\n# of reco::Tracks with "
671  << label[www].process()<<":"
672  << label[www].label()<<":"
673  << label[www].instance()
674  << ": " << trackCollection->size() << "\n";
675 
676  int sat(0); //This counter counts the number of recoTracks that are associated to SimTracks from Signal only
677  int at(0); //This counter counts the number of recoTracks that are associated to SimTracks
678  int rT(0); //This counter counts the number of recoTracks in general
679 
680  //calculate dR for tracks
681  const edm::View<Track> *trackCollectionDr = trackCollection.product();
683  trackCollectionDr = trackCollectionForDrCalculation.product();
684  }
685  float dR_trk[trackCollection->size()];
686  int i=0;
687  float etaL[trackCollectionDr->size()];
688  float phiL[trackCollectionDr->size()];
689  for (auto const & track2 : *trackCollectionDr) {
690  auto && p = track2.momentum();
691  etaL[i] = etaFromXYZ(p.x(),p.y(),p.z());
692  phiL[i] = atan2f(p.y(),p.x());
693  ++i;
694  }
695  for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){
696  auto const & track = (*trackCollection)[i];
698  auto && p = track.momentum();
699  float eta = etaFromXYZ(p.x(),p.y(),p.z());
700  float phi = atan2f(p.y(),p.x());
701  for(View<Track>::size_type j=0; j<trackCollectionDr->size(); ++j){
702  auto dR_tmp = reco::deltaR2(eta, phi, etaL[j], phiL[j]);
703  if ( (dR_tmp<dR) & (dR_tmp>std::numeric_limits<float>::min())) dR=dR_tmp;
704  }
705  dR_trk[i] = std::sqrt(dR);
706  }
707 
708  for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){
709 
710  RefToBase<Track> track(trackCollection, i);
711  rT++;
712 
713  bool isSigSimMatched(false);
714  bool isSimMatched(false);
715  bool isChargeMatched(true);
716  int numAssocRecoTracks = 0;
717  int nSimHits = 0;
718  double sharedFraction = 0.;
719 
720  auto tpFound = recSimColl.find(track);
721  isSimMatched = tpFound != recSimColl.end();
722  if (isSimMatched) {
723  const auto& tp = tpFound->val;
724  nSimHits = tp[0].first->numberOfTrackerHits();
725  sharedFraction = tp[0].second;
726  if (tp[0].first->charge() != track->charge()) isChargeMatched = false;
727  if(simRecColl.find(tp[0].first) != simRecColl.end()) numAssocRecoTracks = simRecColl[tp[0].first].size();
728  at++;
729  for (unsigned int tp_ite=0;tp_ite<tp.size();++tp_ite){
730  TrackingParticle trackpart = *(tp[tp_ite].first);
731  if ((trackpart.eventId().event() == 0) && (trackpart.eventId().bunchCrossing() == 0)){
732  isSigSimMatched = true;
733  sat++;
734  break;
735  }
736  }
737  LogTrace("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt()
738  << " associated with quality:" << tp.begin()->second <<"\n";
739  } else {
740  LogTrace("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt()
741  << " NOT associated to any TrackingParticle" << "\n";
742  }
743 
744  double dR=dR_trk[i];
745  histoProducerAlgo_->fill_generic_recoTrack_histos(w,*track,bs.position(), thePVposition, isSimMatched,isSigSimMatched, isChargeMatched, numAssocRecoTracks, puinfo.getPU_NumInteractions(), nSimHits, sharedFraction, dR);
746  if(doSummaryPlots_) {
747  h_reco_coll[ww]->Fill(www);
748  if(isSimMatched) {
749  h_assoc2_coll[ww]->Fill(www);
750  if(numAssocRecoTracks>1) {
751  h_looper_coll[ww]->Fill(www);
752  }
753  if(!isSigSimMatched) {
754  h_pileup_coll[ww]->Fill(www);
755  }
756  }
757  }
758 
759  // dE/dx
760  if (dodEdxPlots_) histoProducerAlgo_->fill_dedx_recoTrack_histos(w,track, v_dEdx);
761 
762 
763  //Fill other histos
764  if (!isSimMatched) continue;
765 
766  histoProducerAlgo_->fill_simAssociated_recoTrack_histos(w,*track);
767 
768  TrackingParticleRef tpr = tpFound->val.begin()->first;
769 
770  /* TO BE FIXED LATER
771  if (associators[ww]=="trackAssociatorByChi2"){
772  //association chi2
773  double assocChi2 = -tp.begin()->second;//in association map is stored -chi2
774  h_assochi2[www]->Fill(assocChi2);
775  h_assochi2_prob[www]->Fill(TMath::Prob((assocChi2)*5,5));
776  }
777  else if (associators[ww]=="quickTrackAssociatorByHits"){
778  double fraction = tp.begin()->second;
779  h_assocFraction[www]->Fill(fraction);
780  h_assocSharedHit[www]->Fill(fraction*track->numberOfValidHits());
781  }
782  */
783 
784 
785  //Get tracking particle parameters at point of closest approach to the beamline
786  TrackingParticle::Vector momentumTP = parametersDefinerTP->momentum(event,setup,tpr);
787  TrackingParticle::Point vertexTP = parametersDefinerTP->vertex(event,setup,tpr);
788  int chargeTP = tpr->charge();
789 
790  histoProducerAlgo_->fill_ResoAndPull_recoTrack_histos(w,momentumTP,vertexTP,chargeTP,
791  *track,bs.position());
792 
793 
794  //TO BE FIXED
795  //std::vector<PSimHit> simhits=tpr.get()->trackPSimHit(DetId::Tracker);
796  //nrecHit_vs_nsimHit_rec2sim[w]->Fill(track->numberOfValidHits(), (int)(simhits.end()-simhits.begin() ));
797 
798  } // End of for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){
799 
800  histoProducerAlgo_->fill_trackBased_histos(w,at,rT,st);
801 
802  LogTrace("TrackValidator") << "Total Simulated: " << st << "\n"
803  << "Total Associated (simToReco): " << ats << "\n"
804  << "Total Reconstructed: " << rT << "\n"
805  << "Total Associated (recoToSim): " << at << "\n"
806  << "Total Fakes: " << rT-at << "\n";
807  } // End of for (unsigned int www=0;www<label.size();www++){
808  } //END of for (unsigned int ww=0;ww<associators.size();ww++){
809 
810 }
#define LogDebug(id)
unsigned int size_type
Definition: View.h:85
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx1Tag
int i
Definition: DBlmapReader.cc:9
std::vector< edm::InputTag > associators
edm::EDGetTokenT< SimHitTPAssociationProducer::SimHitTPAssociationList > _simHitTpMapTag
int event() const
get the contents of the subdetector field (should be protected?)
std::vector< MonitorElement * > h_reco_coll
std::vector< edm::EDGetTokenT< reco::SimToRecoCollection > > associatormapStRs
const double w
Definition: UKUtility.cc:23
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > label_pileupinfo
CosmicTrackingParticleSelector cosmictpSelector
std::vector< TrackingParticle > TrackingParticleCollection
Vector momentum() const
spatial momentum vector
const_iterator end() const
last iterator over the map (read only)
std::vector< MonitorElement * > h_simul_coll
edm::EDGetTokenT< TrackingParticleCollection > label_tp_effic
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const_iterator find(const key_type &k) const
find element with specified reference key
size_type size() const
edm::EDGetTokenT< TrackingVertexCollection > label_tv
T_AssociationMap associationMapFilterValues(const T_AssociationMap &map, const T_RefVector &valueRefs)
TrackingParticleSelector dRtpSelector
TrackingParticleSelector dRtpSelectorNoPtCut
std::vector< edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > > associatorTokens
const bool doPlotsOnlyForTruePV_
edm::EDGetTokenT< reco::BeamSpot > bsSrc
math::XYZPointD Point
point in the space
std::vector< MonitorElement * > h_looper_coll
math::XYZTLorentzVectorD LorentzVector
std::vector< MonitorElement * > h_pileup_coll
std::vector< MonitorElement * > h_assoc_coll
std::vector< edm::InputTag > label
std::vector< edm::EDGetTokenT< reco::RecoToSimCollection > > associatormapRtSs
T sqrt(T t)
Definition: SSEVec.h:18
int bunchCrossing() const
get the detector field from this detid
TrackingParticleSelector tpSelector
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
def move
Definition: eostools.py:510
int j
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< edm::View< reco::Track > > labelTokenForDrCalculation
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
void initEvent(edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssocToSet) const
std::vector< edm::EDGetTokenT< std::vector< int > > > seedToTrackTokens_
T min(T a, T b)
Definition: MathUtil.h:58
#define LogTrace(id)
std::unique_ptr< MTVHistoProducerAlgoForTracker > histoProducerAlgo_
std::vector< MonitorElement * > h_assoc_coll_allPt
T const * product() const
Definition: Handle.h:81
edm::EDGetTokenT< reco::VertexToTrackingVertexAssociator > vertexAssociatorToken_
const T & get() const
Definition: EventSetup.h:56
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
const bool doPVAssociationPlots_
EncodedEventId eventId() const
Signal source, crossing number.
Point vertex() const
Parent vertex position.
edm::EDGetTokenT< edm::View< reco::Vertex > > recoVertexToken_
const EncodedEventId & eventId() const
const bool calculateDrSingleCollection_
std::vector< MonitorElement * > h_simul_coll_allPt
std::vector< MonitorElement * > h_assoc2_coll
Monte Carlo truth information used for tracking validation.
int numberOfTrackerHits() const
The number of hits in the tracker. Hits on overlaps in the same layer count separately.
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > labelToken
math::XYZVectorD Vector
point in the space
std::vector< edm::EDGetTokenT< std::vector< PSimHit > > > simHitTokens_
edm::EDGetTokenT< TrackingParticleCollection > label_tp_fake
tuple size
Write out results.
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx2Tag
const bool parametersDefinerIsCosmic_
void MultiTrackValidator::bookHistograms ( DQMStore::IBooker ibook,
edm::Run const &  ,
edm::EventSetup const &  setup 
)
overridevirtual

Method called to book the DQM histograms.

Implements DQMEDAnalyzer.

Definition at line 151 of file MultiTrackValidator.cc.

References ecalcalib_dqm_sourceclient-live_cfg::algo, MultiTrackValidatorBase::associators, DQMStore::IBooker::book1D(), DQMStore::IBooker::cd(), TrackerOfflineValidation_Dqm_cff::dirName, dirName_, dodEdxPlots_, doPVAssociationPlots_, doRecoTrackPlots_, doSeedPlots_, doSimPlots_, doSimTrackPlots_, doSummaryPlots_, h, h_assoc2_coll, h_assoc_coll, h_assoc_coll_allPt, h_looper_coll, h_pileup_coll, h_reco_coll, h_simul_coll, h_simul_coll_allPt, histoProducerAlgo_, i, edm::InputTag::instance(), edm::InputTag::label(), MultiTrackValidatorBase::label, hlt_dqm_clientPB-live_cfg::me, edm::InputTag::process(), python.rootplot.root2matplotlib::replace(), and DQMStore::IBooker::setCurrentFolder().

151  {
152 
153  const auto minColl = -0.5;
154  const auto maxColl = label.size()-0.5;
155  const auto nintColl = label.size();
156 
157  auto binLabels = [&](MonitorElement *me) {
158  TH1 *h = me->getTH1();
159  for(size_t i=0; i<label.size(); ++i) {
160  h->GetXaxis()->SetBinLabel(i+1, label[i].label().c_str());
161  }
162  return me;
163  };
164 
165  //Booking histograms concerning with simulated tracks
166  if(doSimPlots_) {
167  ibook.cd();
168  ibook.setCurrentFolder(dirName_ + "simulation");
169 
170  histoProducerAlgo_->bookSimHistos(ibook);
171 
172  ibook.cd();
173  ibook.setCurrentFolder(dirName_);
174  }
175 
176  for (unsigned int ww=0;ww<associators.size();ww++){
177  ibook.cd();
178  // FIXME: these need to be moved to a subdirectory whose name depends on the associator
179  ibook.setCurrentFolder(dirName_);
180 
181  if(doSummaryPlots_) {
182  if(doSimTrackPlots_) {
183  h_assoc_coll.push_back(binLabels( ibook.book1D("num_assoc(simToReco)_coll", "N of associated (simToReco) tracks vs track collection", nintColl, minColl, maxColl) ));
184  h_simul_coll.push_back(binLabels( ibook.book1D("num_simul_coll", "N of simulated tracks vs track collection", nintColl, minColl, maxColl) ));
185 
186  h_assoc_coll_allPt.push_back(binLabels( ibook.book1D("num_assoc(simToReco)_coll_allPt", "N of associated (simToReco) tracks vs track collection", nintColl, minColl, maxColl) ));
187  h_simul_coll_allPt.push_back(binLabels( ibook.book1D("num_simul_coll_allPt", "N of simulated tracks vs track collection", nintColl, minColl, maxColl) ));
188 
189  }
190  if(doRecoTrackPlots_) {
191  h_reco_coll.push_back(binLabels( ibook.book1D("num_reco_coll", "N of reco track vs track collection", nintColl, minColl, maxColl) ));
192  h_assoc2_coll.push_back(binLabels( ibook.book1D("num_assoc(recoToSim)_coll", "N of associated (recoToSim) tracks vs track collection", nintColl, minColl, maxColl) ));
193  h_looper_coll.push_back(binLabels( ibook.book1D("num_duplicate_coll", "N of associated (recoToSim) looper tracks vs track collection", nintColl, minColl, maxColl) ));
194  h_pileup_coll.push_back(binLabels( ibook.book1D("num_pileup_coll", "N of associated (recoToSim) pileup tracks vs track collection", nintColl, minColl, maxColl) ));
195  }
196  }
197 
198  for (unsigned int www=0;www<label.size();www++){
199  ibook.cd();
200  InputTag algo = label[www];
201  string dirName=dirName_;
202  if (algo.process()!="")
203  dirName+=algo.process()+"_";
204  if(algo.label()!="")
205  dirName+=algo.label()+"_";
206  if(algo.instance()!="")
207  dirName+=algo.instance()+"_";
208  if (dirName.find("Tracks")<dirName.length()){
209  dirName.replace(dirName.find("Tracks"),6,"");
210  }
211  string assoc= associators[ww].label();
212  if (assoc.find("Track")<assoc.length()){
213  assoc.replace(assoc.find("Track"),5,"");
214  }
215  dirName+=assoc;
216  std::replace(dirName.begin(), dirName.end(), ':', '_');
217 
218  ibook.setCurrentFolder(dirName.c_str());
219 
220  if(doSimTrackPlots_) {
221  histoProducerAlgo_->bookSimTrackHistos(ibook);
222  if(doPVAssociationPlots_) histoProducerAlgo_->bookSimTrackPVAssociationHistos(ibook);
223  }
224 
225  //Booking histograms concerning with reconstructed tracks
226  if(doRecoTrackPlots_) {
227  histoProducerAlgo_->bookRecoHistos(ibook);
228  if (dodEdxPlots_) histoProducerAlgo_->bookRecodEdxHistos(ibook);
229  if (doPVAssociationPlots_) histoProducerAlgo_->bookRecoPVAssociationHistos(ibook);
230  }
231 
232  if(doSeedPlots_) {
233  histoProducerAlgo_->bookSeedHistos(ibook);
234  }
235  }//end loop www
236  }// end loop ww
237 }
int i
Definition: DBlmapReader.cc:9
std::vector< edm::InputTag > associators
std::vector< MonitorElement * > h_reco_coll
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
std::vector< MonitorElement * > h_simul_coll
void cd(void)
Definition: DQMStore.cc:268
std::vector< MonitorElement * > h_looper_coll
std::vector< MonitorElement * > h_pileup_coll
std::vector< MonitorElement * > h_assoc_coll
std::vector< edm::InputTag > label
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
std::unique_ptr< MTVHistoProducerAlgoForTracker > histoProducerAlgo_
std::vector< MonitorElement * > h_assoc_coll_allPt
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:276
const bool doPVAssociationPlots_
std::string const & label() const
Definition: InputTag.h:36
std::string const & process() const
Definition: InputTag.h:40
std::vector< MonitorElement * > h_simul_coll_allPt
std::vector< MonitorElement * > h_assoc2_coll
std::string const & instance() const
Definition: InputTag.h:37

Member Data Documentation

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

Definition at line 60 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

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

Definition at line 48 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

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

Definition at line 47 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

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

Definition at line 46 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

const bool MultiTrackValidator::calculateDrSingleCollection_
protected

Definition at line 34 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

CosmicTrackingParticleSelector MultiTrackValidator::cosmictpSelector
private

Definition at line 56 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

std::string MultiTrackValidator::dirName_
private

Definition at line 50 of file MultiTrackValidator.h.

Referenced by bookHistograms(), and MultiTrackValidator().

const bool MultiTrackValidator::dodEdxPlots_
protected
const bool MultiTrackValidator::doPlotsOnlyForTruePV_
protected

Definition at line 35 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

const bool MultiTrackValidator::doPVAssociationPlots_
protected

Definition at line 41 of file MultiTrackValidator.h.

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

const bool MultiTrackValidator::doRecoTrackPlots_
protected
const bool MultiTrackValidator::doSeedPlots_
protected

Definition at line 42 of file MultiTrackValidator.h.

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

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

Definition at line 36 of file MultiTrackValidator.h.

Referenced by analyze(), and bookHistograms().

TrackingParticleSelector MultiTrackValidator::dRtpSelector
private

Definition at line 57 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

TrackingParticleSelector MultiTrackValidator::dRtpSelectorNoPtCut
private

Definition at line 58 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

std::vector<MonitorElement *> MultiTrackValidator::h_assoc2_coll
private

Definition at line 66 of file MultiTrackValidator.h.

Referenced by analyze(), and bookHistograms().

std::vector<MonitorElement *> MultiTrackValidator::h_assoc_coll
private

Definition at line 66 of file MultiTrackValidator.h.

Referenced by analyze(), and bookHistograms().

std::vector<MonitorElement *> MultiTrackValidator::h_assoc_coll_allPt
private

Definition at line 67 of file MultiTrackValidator.h.

Referenced by analyze(), and bookHistograms().

std::vector<MonitorElement *> MultiTrackValidator::h_looper_coll
private

Definition at line 66 of file MultiTrackValidator.h.

Referenced by analyze(), and bookHistograms().

std::vector<MonitorElement *> MultiTrackValidator::h_pileup_coll
private

Definition at line 66 of file MultiTrackValidator.h.

Referenced by analyze(), and bookHistograms().

std::vector<MonitorElement *> MultiTrackValidator::h_reco_coll
private

Definition at line 66 of file MultiTrackValidator.h.

Referenced by analyze(), and bookHistograms().

std::vector<MonitorElement *> MultiTrackValidator::h_simul_coll
private

Definition at line 66 of file MultiTrackValidator.h.

Referenced by analyze(), and bookHistograms().

std::vector<MonitorElement *> MultiTrackValidator::h_simul_coll_allPt
private

Definition at line 67 of file MultiTrackValidator.h.

Referenced by analyze(), and bookHistograms().

std::unique_ptr<MTVHistoProducerAlgoForTracker> MultiTrackValidator::histoProducerAlgo_
protected
edm::EDGetTokenT<edm::View<reco::Track> > MultiTrackValidator::labelTokenForDrCalculation
private

Definition at line 61 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

const bool MultiTrackValidator::parametersDefinerIsCosmic_
protected

Definition at line 33 of file MultiTrackValidator.h.

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

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

Definition at line 62 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

std::vector<edm::EDGetTokenT<std::vector<int> > > MultiTrackValidator::seedToTrackTokens_
private

Definition at line 64 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

TrackingParticleSelector MultiTrackValidator::tpSelector
private

Definition at line 55 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

bool MultiTrackValidator::UseAssociators
protected
bool MultiTrackValidator::useGsf
private

Definition at line 52 of file MultiTrackValidator.h.

Referenced by MultiTrackValidator().

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

Definition at line 63 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().