CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Member Functions | Private Attributes
TrackMVAClassifierBase Class Referenceabstract

#include <TrackMVAClassifier.h>

Inheritance diagram for TrackMVAClassifierBase:
edm::stream::EDProducer<> TrackMVAClassifier< MVA, EventCache >

Public Types

using MVACollection = std::vector< float >
 
using MVAPairCollection = std::vector< std::pair< float, bool > >
 
using QualityMaskCollection = std::vector< unsigned char >
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Public Member Functions

 TrackMVAClassifierBase (const edm::ParameterSet &cfg)
 
 ~TrackMVAClassifierBase () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Protected Member Functions

virtual void computeMVA (reco::TrackCollection const &tracks, reco::BeamSpot const &beamSpot, reco::VertexCollection const &vertices, MVAPairCollection &mvas) const =0
 
virtual void initEvent (const edm::EventSetup &es)=0
 

Static Protected Member Functions

static void fill (edm::ParameterSetDescription &desc)
 

Private Member Functions

void produce (edm::Event &evt, const edm::EventSetup &es) final
 

Private Attributes

edm::EDGetTokenT< reco::BeamSpotbeamspot_
 
bool ignoreVertices_
 
float qualityCuts [3]
 
edm::EDGetTokenT< reco::TrackCollectionsrc_
 source collection label More...
 
edm::EDGetTokenT< reco::VertexCollectionvertices_
 

Detailed Description

Definition at line 21 of file TrackMVAClassifier.h.

Member Typedef Documentation

◆ MVACollection

using TrackMVAClassifierBase::MVACollection = std::vector<float>

Definition at line 26 of file TrackMVAClassifier.h.

◆ MVAPairCollection

using TrackMVAClassifierBase::MVAPairCollection = std::vector<std::pair<float, bool> >

Definition at line 30 of file TrackMVAClassifier.h.

◆ QualityMaskCollection

using TrackMVAClassifierBase::QualityMaskCollection = std::vector<unsigned char>

Definition at line 27 of file TrackMVAClassifier.h.

Constructor & Destructor Documentation

◆ TrackMVAClassifierBase()

TrackMVAClassifierBase::TrackMVAClassifierBase ( const edm::ParameterSet cfg)
explicit

Definition at line 22 of file TrackMVAClassifierBase.cc.

23  : src_(consumes<reco::TrackCollection>(cfg.getParameter<edm::InputTag>("src"))),
24  beamspot_(consumes<reco::BeamSpot>(cfg.getParameter<edm::InputTag>("beamspot"))),
25  vertices_(mayConsume<reco::VertexCollection>(cfg.getParameter<edm::InputTag>("vertices"))),
26  ignoreVertices_(cfg.getParameter<bool>("ignoreVertices")) {
27  auto const& qv = cfg.getParameter<std::vector<double>>("qualityCuts");
28  assert(qv.size() == 3);
29  std::copy(std::begin(qv), std::end(qv), std::begin(qualityCuts));
30 
31  produces<MVACollection>("MVAValues");
32  produces<QualityMaskCollection>("QualityMasks");
33 }

References cms::cuda::assert(), looper::cfg, filterCSVwithJSON::copy, mps_fire::end, and qualityCuts.

◆ ~TrackMVAClassifierBase()

TrackMVAClassifierBase::~TrackMVAClassifierBase ( )
override

Definition at line 20 of file TrackMVAClassifierBase.cc.

20 {}

Member Function Documentation

◆ computeMVA()

virtual void TrackMVAClassifierBase::computeMVA ( reco::TrackCollection const &  tracks,
reco::BeamSpot const &  beamSpot,
reco::VertexCollection const &  vertices,
MVAPairCollection mvas 
) const
protectedpure virtual

Implemented in TrackMVAClassifier< MVA, EventCache >.

Referenced by produce().

◆ fill()

void TrackMVAClassifierBase::fill ( edm::ParameterSetDescription desc)
staticprotected

Definition at line 10 of file TrackMVAClassifierBase.cc.

10  {
11  desc.add<edm::InputTag>("src", edm::InputTag());
12  desc.add<edm::InputTag>("beamspot", edm::InputTag("offlineBeamSpot"));
13  desc.add<edm::InputTag>("vertices", edm::InputTag("firstStepPrimaryVertices"));
14  desc.add<bool>("ignoreVertices", false);
15  // default cuts for "cut based classification"
16  std::vector<double> cuts = {-.7, 0.1, .7};
17  desc.add<std::vector<double>>("qualityCuts", cuts);
18 }

References cuts, submitPVResolutionJobs::desc, and HLT_FULL_cff::InputTag.

Referenced by TrackMVAClassifier< MVA, EventCache >::fillDescriptions().

◆ initEvent()

virtual void TrackMVAClassifierBase::initEvent ( const edm::EventSetup es)
protectedpure virtual

Implemented in TrackMVAClassifier< MVA, EventCache >.

Referenced by produce().

◆ produce()

void TrackMVAClassifierBase::produce ( edm::Event evt,
const edm::EventSetup es 
)
finalprivate

Definition at line 35 of file TrackMVAClassifierBase.cc.

35  {
36  // Get tracks
38  evt.getByToken(src_, hSrcTrack);
39  auto const& tracks(*hSrcTrack);
40 
41  // looking for the beam spot
43  evt.getByToken(beamspot_, hBsp);
44 
45  // Select good primary vertices for use in subsequent track selection
47  evt.getByToken(vertices_, hVtx);
48 
49  initEvent(es);
50 
51  // products
52  auto mvaPairs = std::make_unique<MVAPairCollection>(tracks.size(), std::make_pair(-99.f, true));
53  auto mvas = std::make_unique<MVACollection>(tracks.size(), -99.f);
54  auto quals = std::make_unique<QualityMaskCollection>(tracks.size(), 0);
55 
56  if (hVtx.isValid() && !ignoreVertices_) {
57  computeMVA(tracks, *hBsp, *hVtx, *mvaPairs);
58  } else {
59  if (!ignoreVertices_)
60  edm::LogWarning("TrackMVAClassifierBase")
61  << "ignoreVertices is set to False in the configuration, but the vertex collection is not valid";
62  std::vector<reco::Vertex> vertices;
63  computeMVA(tracks, *hBsp, vertices, *mvaPairs);
64  }
65  assert((*mvaPairs).size() == tracks.size());
66 
67  unsigned int k = 0;
68  for (auto const& output : *mvaPairs) {
69  if (output.second) {
70  (*mvas)[k] = output.first;
71  } else {
72  // If the MVA value is known to be unreliable, force into generalTracks collection
73  (*mvas)[k] = std::max(output.first, float(qualityCuts[0] + 0.001));
74  }
75  float mva = (*mvas)[k];
76  (*quals)[k++] = (mva > qualityCuts[0]) << reco::TrackBase::loose |
79  }
80 
81  evt.put(std::move(mvas), "MVAValues");
82  evt.put(std::move(quals), "QualityMasks");
83 }

References cms::cuda::assert(), beamspot_, computeMVA(), f, edm::Event::getByToken(), reco::TrackBase::highPurity, ignoreVertices_, initEvent(), edm::HandleBase::isValid(), dqmdumpme::k, reco::TrackBase::loose, SiStripPI::max, eostools::move(), beam_dqm_sourceclient-live_cfg::mva, convertSQLitetoXML_cfg::output, edm::Event::put(), qualityCuts, src_, reco::TrackBase::tight, tracks, pwdgSkimBPark_cfi::vertices, and vertices_.

Member Data Documentation

◆ beamspot_

edm::EDGetTokenT<reco::BeamSpot> TrackMVAClassifierBase::beamspot_
private

Definition at line 47 of file TrackMVAClassifier.h.

Referenced by produce().

◆ ignoreVertices_

bool TrackMVAClassifierBase::ignoreVertices_
private

Definition at line 50 of file TrackMVAClassifier.h.

Referenced by produce().

◆ qualityCuts

float TrackMVAClassifierBase::qualityCuts[3]
private

Definition at line 55 of file TrackMVAClassifier.h.

Referenced by produce(), and TrackMVAClassifierBase().

◆ src_

edm::EDGetTokenT<reco::TrackCollection> TrackMVAClassifierBase::src_
private

source collection label

Definition at line 46 of file TrackMVAClassifier.h.

Referenced by produce().

◆ vertices_

edm::EDGetTokenT<reco::VertexCollection> TrackMVAClassifierBase::vertices_
private

Definition at line 48 of file TrackMVAClassifier.h.

Referenced by produce().

reco::TrackBase::tight
Definition: TrackBase.h:153
reco::TrackBase::loose
Definition: TrackBase.h:152
cuts
const TkSoA *__restrict__ CAHitNtupletGeneratorKernelsGPU::QualityCuts cuts
Definition: CAHitNtupletGeneratorKernelsImpl.h:338
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
cms::cuda::assert
assert(be >=bs)
beam_dqm_sourceclient-live_cfg.mva
mva
Definition: beam_dqm_sourceclient-live_cfg.py:126
edm::Handle< reco::TrackCollection >
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
TrackMVAClassifierBase::ignoreVertices_
bool ignoreVertices_
Definition: TrackMVAClassifier.h:50
mps_fire.end
end
Definition: mps_fire.py:242
TrackMVAClassifierBase::initEvent
virtual void initEvent(const edm::EventSetup &es)=0
TrackMVAClassifierBase::qualityCuts
float qualityCuts[3]
Definition: TrackMVAClassifier.h:55
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:535
dqmdumpme.k
k
Definition: dqmdumpme.py:60
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:159
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
looper.cfg
cfg
Definition: looper.py:297
TrackMVAClassifierBase::computeMVA
virtual void computeMVA(reco::TrackCollection const &tracks, reco::BeamSpot const &beamSpot, reco::VertexCollection const &vertices, MVAPairCollection &mvas) const =0
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
TrackMVAClassifierBase::beamspot_
edm::EDGetTokenT< reco::BeamSpot > beamspot_
Definition: TrackMVAClassifier.h:47
TrackMVAClassifierBase::src_
edm::EDGetTokenT< reco::TrackCollection > src_
source collection label
Definition: TrackMVAClassifier.h:46
TrackMVAClassifierBase::vertices_
edm::EDGetTokenT< reco::VertexCollection > vertices_
Definition: TrackMVAClassifier.h:48
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7
reco::TrackBase::highPurity
Definition: TrackBase.h:154