CMS 3D CMS Logo

PATVertexSlimmer.cc
Go to the documentation of this file.
1 #include <string>
2 #include <memory>
3 
4 // user include files
9 
15 
16 namespace pat {
18  public:
19  explicit PATVertexSlimmer(const edm::ParameterSet&);
20  ~PATVertexSlimmer() override;
21 
22  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
23 
24  private:
27  const bool rekeyScores_;
28  };
29 } // namespace pat
30 
32  : src_(consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("src"))),
33  score_(mayConsume<edm::ValueMap<float>>(
34  iConfig.existsAs<edm::InputTag>("score") ? iConfig.getParameter<edm::InputTag>("score") : edm::InputTag())),
35  rekeyScores_(iConfig.existsAs<edm::InputTag>("score")) {
36  produces<std::vector<reco::Vertex>>();
37  if (rekeyScores_)
38  produces<edm::ValueMap<float>>();
39 }
40 
42 
45  iEvent.getByToken(src_, vertices);
46  auto outPtr = std::make_unique<std::vector<reco::Vertex>>();
47 
48  outPtr->reserve(vertices->size());
49  for (unsigned int i = 0, n = vertices->size(); i < n; ++i) {
50  const reco::Vertex& v = (*vertices)[i];
51  auto co = v.covariance4D();
52  if (i > 0) {
53  for (size_t j = 0; j < 4; j++) {
54  for (size_t k = j; k < 4; k++) {
55  co(j, k) = MiniFloatConverter::reduceMantissaToNbits<10>(co(j, k));
56  }
57  }
58  }
59  outPtr->push_back(reco::Vertex(v.position(), co, v.t(), v.chi2(), v.ndof(), 0));
60  }
61 
62  auto oh = iEvent.put(std::move(outPtr));
63  if (rekeyScores_) {
65  iEvent.getByToken(score_, scores);
66  auto vertexScoreOutput = std::make_unique<edm::ValueMap<float>>();
67  edm::ValueMap<float>::const_iterator idIt = scores->begin();
68  for (; idIt != scores->end(); idIt++) {
69  if (idIt.id() == vertices.id())
70  break;
71  }
72  // std::find_if(scores->begin(), scores->end(), [vertices] (const edm::ValueMap<float>::const_iterator& s) { return s.id() == vertices.id(); } );
73  edm::ValueMap<float>::Filler vertexScoreFiller(*vertexScoreOutput);
74  vertexScoreFiller.insert(oh, idIt.begin(), idIt.end());
75  vertexScoreFiller.fill();
76  iEvent.put(std::move(vertexScoreOutput));
77  }
78 }
79 
edm::StreamID
Definition: StreamID.h:30
edm::helper::Filler::insert
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
mps_fire.i
i
Definition: mps_fire.py:428
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
pat::PATVertexSlimmer::src_
const edm::EDGetTokenT< std::vector< reco::Vertex > > src_
Definition: PATVertexSlimmer.cc:25
edm::EDGetTokenT
Definition: EDGetToken.h:33
pat::PATVertexSlimmer::PATVertexSlimmer
PATVertexSlimmer(const edm::ParameterSet &)
Definition: PATVertexSlimmer.cc:31
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::helper::Filler::fill
void fill()
Definition: ValueMap.h:65
pat::PATVertexSlimmer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: PATVertexSlimmer.cc:43
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
findQualityFiles.v
v
Definition: findQualityFiles.py:179
edm::Handle
Definition: AssociativeIterator.h:50
MakerMacros.h
edm::ValueMap::const_iterator
Definition: ValueMap.h:170
pat::PATVertexSlimmer::rekeyScores_
const bool rekeyScores_
Definition: PATVertexSlimmer.cc:27
libminifloat.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
dqmdumpme.k
k
Definition: dqmdumpme.py:60
edm::global::EDProducer
Definition: EDProducer.h:32
Vertex.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
pat::PATVertexSlimmer::~PATVertexSlimmer
~PATVertexSlimmer() override
Definition: PATVertexSlimmer.cc:41
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:57
pat
Definition: HeavyIon.h:7
ValueMap.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
HltBtagValidation_cff.Vertex
Vertex
Definition: HltBtagValidation_cff.py:32
Frameworkfwd.h
pat::PATVertexSlimmer
Definition: PATVertexSlimmer.cc:17
pat::PATVertexSlimmer::score_
const edm::EDGetTokenT< edm::ValueMap< float > > score_
Definition: PATVertexSlimmer.cc:26
cms::cuda::co
VT * co
Definition: prefixScan.h:46
edm::helper::Filler
Definition: ValueMap.h:22
ParameterSet.h
EDProducer.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::Event
Definition: Event.h:73
reco::Vertex
Definition: Vertex.h:35
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7