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 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 ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- 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 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, GBRForest const *forestP, MVACollection &mvas) const =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 beginStream (edm::StreamID) overridefinal
 
void produce (edm::Event &evt, const edm::EventSetup &es) overridefinal
 

Private Attributes

edm::EDGetTokenT< reco::BeamSpotbeamspot_
 
const std::string dbFileName_
 
std::unique_ptr< GBRForestforest_
 
const std::string forestLabel_
 
float qualityCuts [3]
 
edm::EDGetTokenT
< reco::TrackCollection
src_
 source collection label More...
 
const bool useForestFromDB_
 
edm::EDGetTokenT
< reco::VertexCollection
vertices_
 

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, 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::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
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 27 of file TrackMVAClassifierBase.cc.

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

27  :
28  src_( consumes<reco::TrackCollection>( cfg.getParameter<edm::InputTag>( "src" ) ) ),
29  beamspot_( consumes<reco::BeamSpot>( cfg.getParameter<edm::InputTag>( "beamspot" ) ) ),
30  vertices_(consumes<reco::VertexCollection>(cfg.getParameter<edm::InputTag>( "vertices" ))),
31  forestLabel_(cfg.getParameter<std::string>("GBRForestLabel")),
32  dbFileName_(cfg.getParameter<std::string>("GBRForestFileName")),
33  useForestFromDB_( (!forestLabel_.empty()) & dbFileName_.empty()) {
34 
35  auto const & qv = cfg.getParameter<std::vector<double>>("qualityCuts");
36  assert(qv.size()==3);
38 
39  produces<MVACollection>("MVAValues");
40  produces<QualityMaskCollection>("QualityMasks");
41 
42 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCollection > src_
source collection label
const std::string forestLabel_
assert(m_qm.get())
const std::string dbFileName_
edm::EDGetTokenT< reco::BeamSpot > beamspot_
edm::EDGetTokenT< reco::VertexCollection > vertices_
#define end
Definition: vmac.h:37
#define begin
Definition: vmac.h:30
TrackMVAClassifierBase::~TrackMVAClassifierBase ( )

Definition at line 25 of file TrackMVAClassifierBase.cc.

25 {}

Member Function Documentation

void TrackMVAClassifierBase::beginStream ( edm::StreamID  )
finaloverrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 94 of file TrackMVAClassifierBase.cc.

References dbFileName_, forest_, and forestLabel_.

94  {
95  if(!dbFileName_.empty()){
96  TFile gbrfile(dbFileName_.c_str());
97  forest_.reset((GBRForest*)gbrfile.Get(forestLabel_.c_str()));
98  }
99 }
const std::string forestLabel_
const std::string dbFileName_
std::unique_ptr< GBRForest > forest_
virtual void TrackMVAClassifierBase::computeMVA ( reco::TrackCollection const &  tracks,
reco::BeamSpot const &  beamSpot,
reco::VertexCollection const &  vertices,
GBRForest const *  forestP,
MVACollection mvas 
) const
protectedpure virtual

Implemented in TrackMVAClassifier< MVA >.

Referenced by produce().

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

Definition at line 13 of file TrackMVAClassifierBase.cc.

References edm::ParameterSetDescription::add(), hpstanc_transforms::cuts, HLT_FULL_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

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

13  {
14  desc.add<edm::InputTag>("src",edm::InputTag());
15  desc.add<edm::InputTag>("beamspot",edm::InputTag("offlineBeamSpot"));
16  desc.add<edm::InputTag>("vertices",edm::InputTag("firstStepPrimaryVertices"));
17  desc.add<std::string>("GBRForestLabel",std::string());
18  desc.add<std::string>("GBRForestFileName",std::string());
19  // default cuts for "cut based classification"
20  std::vector<double> cuts = {-.7, 0.1, .7};
21  desc.add<std::vector<double>>("qualityCuts", cuts);
22 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void TrackMVAClassifierBase::produce ( edm::Event evt,
const edm::EventSetup es 
)
finaloverrideprivatevirtual

Implements edm::stream::EDProducerBase.

Definition at line 44 of file TrackMVAClassifierBase.cc.

References assert(), beamspot_, computeMVA(), forest_, forestLabel_, edm::EventSetup::get(), edm::Event::getByToken(), reco::TrackBase::highPurity, relval_2017::k, reco::TrackBase::loose, eostools::move(), HLT_FULL_cff::mva, edm::ESHandle< class >::product(), edm::Event::put(), qualityCuts, src_, reco::TrackBase::tight, testEve_cfg::tracks, useForestFromDB_, and vertices_.

44  {
45 
46  // Get tracks
48  evt.getByToken(src_, hSrcTrack );
49  auto const & tracks(*hSrcTrack);
50 
51  // looking for the beam spot
53  evt.getByToken(beamspot_, hBsp);
54 
55 
56  // Select good primary vertices for use in subsequent track selection
58  evt.getByToken(vertices_, hVtx);
59 
60  GBRForest const * forest = forest_.get();
61  if(useForestFromDB_){
62  edm::ESHandle<GBRForest> forestHandle;
63  es.get<GBRWrapperRcd>().get(forestLabel_,forestHandle);
64  forest = forestHandle.product();
65  }
66 
67  // products
68  auto mvas = std::make_unique<MVACollection>(tracks.size(),-99.f);
69  auto quals = std::make_unique<QualityMaskCollection>(tracks.size(),0);
70 
71 
72 
73  computeMVA(tracks,*hBsp,*hVtx,forest,*mvas);
74  assert((*mvas).size()==tracks.size());
75 
76  unsigned int k=0;
77  for (auto mva : *mvas) {
78  (*quals)[k++]
82  ;
83 
84  }
85 
86 
87  evt.put(std::move(mvas),"MVAValues");
88  evt.put(std::move(quals),"QualityMasks");
89 
90 }
virtual void computeMVA(reco::TrackCollection const &tracks, reco::BeamSpot const &beamSpot, reco::VertexCollection const &vertices, GBRForest const *forestP, MVACollection &mvas) const =0
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
edm::EDGetTokenT< reco::TrackCollection > src_
source collection label
const std::string forestLabel_
assert(m_qm.get())
edm::EDGetTokenT< reco::BeamSpot > beamspot_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
def move
Definition: eostools.py:510
edm::EDGetTokenT< reco::VertexCollection > vertices_
std::unique_ptr< GBRForest > forest_
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86

Member Data Documentation

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

Definition at line 50 of file TrackMVAClassifier.h.

Referenced by produce().

const std::string TrackMVAClassifierBase::dbFileName_
private

Definition at line 57 of file TrackMVAClassifier.h.

Referenced by beginStream().

std::unique_ptr<GBRForest> TrackMVAClassifierBase::forest_
private

Definition at line 55 of file TrackMVAClassifier.h.

Referenced by beginStream(), and produce().

const std::string TrackMVAClassifierBase::forestLabel_
private

Definition at line 56 of file TrackMVAClassifier.h.

Referenced by beginStream(), and produce().

float TrackMVAClassifierBase::qualityCuts[3]
private

Definition at line 61 of file TrackMVAClassifier.h.

Referenced by produce(), and TrackMVAClassifierBase().

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

source collection label

Definition at line 49 of file TrackMVAClassifier.h.

Referenced by produce().

const bool TrackMVAClassifierBase::useForestFromDB_
private

Definition at line 58 of file TrackMVAClassifier.h.

Referenced by produce().

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

Definition at line 51 of file TrackMVAClassifier.h.

Referenced by produce().