CMS 3D CMS Logo

TrackMVAClassifierBase.cc
Go to the documentation of this file.
2 
4 
7 
8 #include <cassert>
9 
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 }
19 
21 
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 }
34 
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 }
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
electrons_cff.bool
bool
Definition: electrons_cff.py:393
MessageLogger.h
reco::TrackBase::tight
Definition: TrackBase.h:153
reco::TrackBase::loose
Definition: TrackBase.h:152
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
align::BeamSpot
Definition: StructureType.h:89
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
edm
HLT enums.
Definition: AlignableModifier.h:19
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
cms::cuda::assert
assert(be >=bs)
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
beam_dqm_sourceclient-live_cfg.mva
mva
Definition: beam_dqm_sourceclient-live_cfg.py:124
edm::Handle< reco::TrackCollection >
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
TrackMVAClassifier.h
TrackMVAClassifierBase::ignoreVertices_
bool ignoreVertices_
Definition: TrackMVAClassifier.h:50
Track.h
mps_fire.end
end
Definition: mps_fire.py:242
TrackMVAClassifierBase::initEvent
virtual void initEvent(const edm::EventSetup &es)=0
TrackMVAClassifierBase::qualityCuts
float qualityCuts[3]
Definition: TrackMVAClassifier.h:55
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
dqmdumpme.k
k
Definition: dqmdumpme.py:60
Vertex.h
TrackMVAClassifierBase::TrackMVAClassifierBase
TrackMVAClassifierBase(const edm::ParameterSet &cfg)
Definition: TrackMVAClassifierBase.cc:22
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
TrackMVAClassifierBase::fill
static void fill(edm::ParameterSetDescription &desc)
Definition: TrackMVAClassifierBase.cc:10
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EventSetup
Definition: EventSetup.h:57
looper.cfg
cfg
Definition: looper.py:297
TrackMVAClassifierBase::computeMVA
virtual void computeMVA(reco::TrackCollection const &tracks, reco::BeamSpot const &beamSpot, reco::VertexCollection const &vertices, MVAPairCollection &mvas) const =0
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
TrackMVAClassifierBase::beamspot_
edm::EDGetTokenT< reco::BeamSpot > beamspot_
Definition: TrackMVAClassifier.h:47
TrackMVAClassifierBase::src_
edm::EDGetTokenT< reco::TrackCollection > src_
source collection label
Definition: TrackMVAClassifier.h:46
TrackMVAClassifierBase::~TrackMVAClassifierBase
~TrackMVAClassifierBase() override
Definition: TrackMVAClassifierBase.cc:20
L1TMuonDQMOffline_cfi.cuts
cuts
Definition: L1TMuonDQMOffline_cfi.py:41
TrackMVAClassifierBase::produce
void produce(edm::Event &evt, const edm::EventSetup &es) final
Definition: TrackMVAClassifierBase.cc:35
TrackMVAClassifierBase::vertices_
edm::EDGetTokenT< reco::VertexCollection > vertices_
Definition: TrackMVAClassifier.h:48
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7
reco::TrackBase::highPurity
Definition: TrackBase.h:154