test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackMVAClassifier.h
Go to the documentation of this file.
1 #ifndef RecoTracker_FinalTrackSelectors_TrackMVAClassifierBase_h
2 #define RecoTracker_FinalTrackSelectors_TrackMVAClassifierBase_h
3 
4 
5 
9 
10 
16 
18 
20 
21 #include <vector>
22 #include <memory>
23 
25 public:
26  explicit TrackMVAClassifierBase( const edm::ParameterSet & cfg );
28 protected:
29 
30  static void fill( edm::ParameterSetDescription& desc);
31 
32 
33  using MVACollection = std::vector<float>;
34  using QualityMaskCollection = std::vector<unsigned char>;
35 
36  virtual void computeMVA(reco::TrackCollection const & tracks,
37  reco::BeamSpot const & beamSpot,
39  GBRForest const * forestP,
40  MVACollection & mvas) const = 0;
41 
42 
43 private:
44 
45  void beginStream(edm::StreamID) override final;
46 
47  void produce(edm::Event& evt, const edm::EventSetup& es ) override final;
48 
50  edm::EDGetTokenT<reco::TrackCollection> src_;
51  edm::EDGetTokenT<reco::BeamSpot> beamspot_;
52  edm::EDGetTokenT<reco::VertexCollection> vertices_;
53 
54 
55  // MVA
56  std::unique_ptr<GBRForest> forest_;
57  const std::string forestLabel_;
58  const std::string dbFileName_;
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 
96  MVA mva;
97 };
98 
99 
100 
101 #endif // RecoTracker_FinalTrackSelectors_TrackMVAClassifierBase_h
102 
TrackMVAClassifierBase(const edm::ParameterSet &cfg)
tuple cfg
Definition: looper.py:293
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::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
void produce(edm::Event &evt, const edm::EventSetup &es) overridefinal
void beginStream(edm::StreamID) overridefinal
edm::EDGetTokenT< reco::BeamSpot > beamspot_
edm::EDGetTokenT< reco::VertexCollection > vertices_
std::unique_ptr< GBRForest > forest_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void computeMVA(reco::TrackCollection const &tracks, reco::BeamSpot const &beamSpot, reco::VertexCollection const &vertices, GBRForest const *forestP, MVACollection &mvas) const final
tuple tracks
Definition: testEve_cfg.py:39
string const
Definition: compareJSON.py:14
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< unsigned char > QualityMaskCollection
TrackMVAClassifier(const edm::ParameterSet &cfg)
def template
Definition: svgfig.py:520