CMS 3D CMS Logo

TrackMVAClassifier.h
Go to the documentation of this file.
1 #ifndef RecoTracker_FinalTrackSelectors_TrackMVAClassifierBase_h
2 #define RecoTracker_FinalTrackSelectors_TrackMVAClassifierBase_h
3 
4 
8 
9 
15 
17 
19 
20 #include <vector>
21 #include <memory>
22 
24 public:
25  explicit TrackMVAClassifierBase( const edm::ParameterSet & cfg );
27 protected:
28 
29  static void fill( edm::ParameterSetDescription& desc);
30 
31 
32  using MVACollection = std::vector<float>;
33  using QualityMaskCollection = std::vector<unsigned char>;
34 
35  virtual void computeMVA(reco::TrackCollection const & tracks,
36  reco::BeamSpot const & beamSpot,
38  GBRForest const * forestP,
39  MVACollection & mvas) const = 0;
40 
41 
42 private:
43 
44  void beginStream(edm::StreamID) override final;
45 
46  void produce(edm::Event& evt, const edm::EventSetup& es ) override final;
47 
49  edm::EDGetTokenT<reco::TrackCollection> src_;
50  edm::EDGetTokenT<reco::BeamSpot> beamspot_;
52 
54 
55  // MVA
56  std::unique_ptr<GBRForest> forest_;
57  const std::string forestLabel_;
58  const std::string dbFileName_;
59  const bool useForestFromDB_;
60 
61  // qualitycuts (loose, tight, hp)
62  float qualityCuts[3];
63 
64 };
65 
66 template<typename MVA>
68 public:
69  explicit TrackMVAClassifier( const edm::ParameterSet & cfg ) :
70  TrackMVAClassifierBase(cfg),
71  mva(cfg.getParameter<edm::ParameterSet>("mva")){}
72 
73  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
75  fill(desc);
77  MVA::fillDescriptions(mvaDesc);
78  desc.add<edm::ParameterSetDescription>("mva",mvaDesc);
79  descriptions.add(MVA::name(), desc);
80  }
81 
82 
83 private:
85  reco::BeamSpot const & beamSpot,
87  GBRForest const * forestP,
88  MVACollection & mvas) const final {
89 
90  size_t current = 0;
91  for (auto const & trk : tracks) {
92  mvas[current++]= mva(trk,beamSpot,vertices,forestP);
93  }
94  }
95 
97 };
98 
99 
100 
101 #endif // RecoTracker_FinalTrackSelectors_TrackMVAClassifierBase_h
102 
void computeMVA(reco::TrackCollection const &tracks, reco::BeamSpot const &beamSpot, reco::VertexCollection const &vertices, GBRForest const *forestP, MVACollection &mvas) const final
void beginStream(edm::StreamID) override final
TrackMVAClassifierBase(const edm::ParameterSet &cfg)
void produce(edm::Event &evt, const edm::EventSetup &es) override final
edm::EDGetTokenT< reco::TrackCollection > src_
source collection label
const std::string forestLabel_
const std::string dbFileName_
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
static void fill(edm::ParameterSetDescription &desc)
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
std::vector< float > MVACollection
virtual void computeMVA(reco::TrackCollection const &tracks, reco::BeamSpot const &beamSpot, reco::VertexCollection const &vertices, GBRForest const *forestP, MVACollection &mvas) const =0
edm::EDGetTokenT< reco::BeamSpot > beamspot_
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:520
edm::EDGetTokenT< reco::VertexCollection > vertices_
std::unique_ptr< GBRForest > forest_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
fixed size matrix
HLT enums.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< unsigned char > QualityMaskCollection
TrackMVAClassifier(const edm::ParameterSet &cfg)