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<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Public Member Functions

 TrackMVAClassifierBase (const edm::ParameterSet &cfg)
 
 ~TrackMVAClassifierBase () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 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
 
const EDProduceroperator= (const EDProducer &)=delete
 

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 22 of file TrackMVAClassifier.h.

Member Typedef Documentation

◆ MVACollection

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

Definition at line 27 of file TrackMVAClassifier.h.

◆ MVAPairCollection

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

Definition at line 31 of file TrackMVAClassifier.h.

◆ QualityMaskCollection

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

Definition at line 28 of file TrackMVAClassifier.h.

Constructor & Destructor Documentation

◆ TrackMVAClassifierBase()

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

Definition at line 22 of file TrackMVAClassifierBase.cc.

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

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 }
edm::EDGetTokenT< reco::TrackCollection > src_
source collection label
assert(be >=bs)
edm::EDGetTokenT< reco::BeamSpot > beamspot_
edm::EDGetTokenT< reco::VertexCollection > vertices_

◆ ~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.

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

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

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 }
TkSoA const *__restrict__ CAHitNtupletGeneratorKernelsGPU::QualityCuts cuts

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

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, AlignmentTracksFromVertexSelector_cfi::vertices, and vertices_.

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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
virtual void initEvent(const edm::EventSetup &es)=0
edm::EDGetTokenT< reco::TrackCollection > src_
source collection label
virtual void computeMVA(reco::TrackCollection const &tracks, reco::BeamSpot const &beamSpot, reco::VertexCollection const &vertices, MVAPairCollection &mvas) const =0
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
assert(be >=bs)
edm::EDGetTokenT< reco::BeamSpot > beamspot_
double f[11][100]
edm::EDGetTokenT< reco::VertexCollection > vertices_
auto const & tracks
cannot be loose
bool isValid() const
Definition: HandleBase.h:70
Log< level::Warning, false > LogWarning
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ beamspot_

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

Definition at line 48 of file TrackMVAClassifier.h.

Referenced by produce().

◆ ignoreVertices_

bool TrackMVAClassifierBase::ignoreVertices_
private

Definition at line 51 of file TrackMVAClassifier.h.

Referenced by produce().

◆ qualityCuts

float TrackMVAClassifierBase::qualityCuts[3]
private

Definition at line 56 of file TrackMVAClassifier.h.

Referenced by produce(), and TrackMVAClassifierBase().

◆ src_

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

source collection label

Definition at line 47 of file TrackMVAClassifier.h.

Referenced by produce().

◆ vertices_

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

Definition at line 49 of file TrackMVAClassifier.h.

Referenced by produce().