CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Types | 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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper TrackMVAClassifier< MVA >

Public Member Functions

 TrackMVAClassifierBase (const edm::ParameterSet &cfg)
 
 ~TrackMVAClassifierBase () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::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)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
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::vector< ModuleDescription const * > &modules, 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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Types

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

Protected Member Functions

virtual void computeMVA (reco::TrackCollection const &tracks, reco::BeamSpot const &beamSpot, reco::VertexCollection const &vertices, MVACollection &mvas) const =0
 
virtual void initEvent (const edm::EventSetup &es)=0
 
- 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)
 

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_
 

Additional Inherited Members

- 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 Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase 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
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Detailed Description

Definition at line 23 of file TrackMVAClassifier.h.

Member Typedef Documentation

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

Definition at line 32 of file TrackMVAClassifier.h.

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

Definition at line 33 of file TrackMVAClassifier.h.

Constructor & Destructor Documentation

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

Definition at line 24 of file TrackMVAClassifierBase.cc.

References begin, popcon2dropbox::copy(), end, edm::ParameterSet::getParameter(), and qualityCuts.

24  :
25  src_ ( consumes<reco::TrackCollection> (cfg.getParameter<edm::InputTag>( "src" )) ),
26  beamspot_( consumes<reco::BeamSpot> (cfg.getParameter<edm::InputTag>( "beamspot" )) ),
27  vertices_( mayConsume<reco::VertexCollection>(cfg.getParameter<edm::InputTag>( "vertices" )) ),
28  ignoreVertices_( cfg.getParameter<bool>( "ignoreVertices" ) ) {
29 
30  auto const & qv = cfg.getParameter<std::vector<double>>("qualityCuts");
31  assert(qv.size()==3);
33 
34  produces<MVACollection>("MVAValues");
35  produces<QualityMaskCollection>("QualityMasks");
36 
37 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCollection > src_
source collection label
edm::EDGetTokenT< reco::BeamSpot > beamspot_
edm::EDGetTokenT< reco::VertexCollection > vertices_
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
TrackMVAClassifierBase::~TrackMVAClassifierBase ( )
override

Definition at line 22 of file TrackMVAClassifierBase.cc.

22 {}

Member Function Documentation

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

Implemented in TrackMVAClassifier< MVA >.

Referenced by produce().

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

Definition at line 11 of file TrackMVAClassifierBase.cc.

References edm::ParameterSetDescription::add(), and particleFlowClusterECALTimeSelected_cfi::cuts.

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

11  {
12  desc.add<edm::InputTag>("src",edm::InputTag());
13  desc.add<edm::InputTag>("beamspot",edm::InputTag("offlineBeamSpot"));
14  desc.add<edm::InputTag>("vertices",edm::InputTag("firstStepPrimaryVertices"));
15  desc.add<bool>("ignoreVertices",false);
16  // default cuts for "cut based classification"
17  std::vector<double> cuts = {-.7, 0.1, .7};
18  desc.add<std::vector<double>>("qualityCuts", cuts);
19 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
virtual void TrackMVAClassifierBase::initEvent ( const edm::EventSetup es)
protectedpure virtual

Implemented in TrackMVAClassifier< MVA >.

Referenced by produce().

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

Definition at line 39 of file TrackMVAClassifierBase.cc.

References beamspot_, computeMVA(), edm::Event::getByToken(), reco::TrackBase::highPurity, ignoreVertices_, initEvent(), edm::HandleBase::isValid(), gen::k, reco::TrackBase::loose, eostools::move(), DetachedQuadStep_cff::mva, RecoTauHPSTancTauProdcuer_cfi::mvas, edm::Event::put(), qualityCuts, src_, reco::TrackBase::tight, l1t::tracks, electrons_cff::vertices, and vertices_.

39  {
40 
41  // Get tracks
43  evt.getByToken(src_, hSrcTrack );
44  auto const & tracks(*hSrcTrack);
45 
46  // looking for the beam spot
48  evt.getByToken(beamspot_, hBsp);
49 
50  // Select good primary vertices for use in subsequent track selection
52  evt.getByToken(vertices_, hVtx);
53 
54  initEvent(es);
55 
56  // products
57  auto mvas = std::make_unique<MVACollection>(tracks.size(),-99.f);
58  auto quals = std::make_unique<QualityMaskCollection>(tracks.size(),0);
59 
60  if ( hVtx.isValid() && !ignoreVertices_ ) {
61  computeMVA(tracks,*hBsp,*hVtx,*mvas);
62  } else {
63  if ( !ignoreVertices_ )
64  edm::LogWarning("TrackMVAClassifierBase") << "ignoreVertices is set to False in the configuration, but the vertex collection is not valid";
65  std::vector<reco::Vertex> vertices;
66  computeMVA(tracks,*hBsp,vertices,*mvas);
67  }
68  assert((*mvas).size()==tracks.size());
69 
70  unsigned int k=0;
71  for (auto mva : *mvas) {
72  (*quals)[k++]
76  ;
77 
78  }
79 
80 
81  evt.put(std::move(mvas),"MVAValues");
82  evt.put(std::move(quals),"QualityMasks");
83 
84 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
virtual void initEvent(const edm::EventSetup &es)=0
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
edm::EDGetTokenT< reco::TrackCollection > src_
source collection label
virtual void computeMVA(reco::TrackCollection const &tracks, reco::BeamSpot const &beamSpot, reco::VertexCollection const &vertices, MVACollection &mvas) const =0
edm::EDGetTokenT< reco::BeamSpot > beamspot_
edm::EDGetTokenT< reco::VertexCollection > vertices_
bool isValid() const
Definition: HandleBase.h:74
int k[5][pyjets_maxn]
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

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

Definition at line 47 of file TrackMVAClassifier.h.

Referenced by produce().

bool TrackMVAClassifierBase::ignoreVertices_
private

Definition at line 50 of file TrackMVAClassifier.h.

Referenced by produce().

float TrackMVAClassifierBase::qualityCuts[3]
private

Definition at line 55 of file TrackMVAClassifier.h.

Referenced by produce(), and TrackMVAClassifierBase().

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

source collection label

Definition at line 46 of file TrackMVAClassifier.h.

Referenced by produce().

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

Definition at line 48 of file TrackMVAClassifier.h.

Referenced by produce().