CMS 3D CMS Logo

ProbeMulteplicityProducer.cc
Go to the documentation of this file.
1 //
2 
15 
19 
23 
24 
26  public:
27  explicit ProbeMulteplicityProducer(const edm::ParameterSet & iConfig);
28  ~ProbeMulteplicityProducer() override ;
29 
30  void produce(edm::Event & iEvent, const edm::EventSetup & iSetup) override;
31 
32  private:
34  StringCutObjectSelector<reco::Candidate,true> pairCut_; // lazy parsing, to allow cutting on variables not in reco::Candidate class
35  StringCutObjectSelector<reco::Candidate,true> probeCut_; // lazy parsing, to allow cutting on variables not in reco::Candidate class
36 };
37 
38 
40  pairs_(consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("pairs"))),
41  pairCut_(iConfig.existsAs<std::string>("pairSelection") ? iConfig.getParameter<std::string>("pairSelection") : "", true),
42  probeCut_(iConfig.existsAs<std::string>("probeSelection") ? iConfig.getParameter<std::string>("probeSelection") : "", true)
43 {
44  produces<edm::ValueMap<float> >();
45 }
46 
47 
48 
50 {
51 }
52 
53 
54 void
56  using namespace edm;
57 
58  // read input
60  iEvent.getByToken(pairs_, pairs);
61 
62  // fill
63  unsigned int i = 0;
64  std::vector<unsigned int> tagKeys;
65  std::vector<float> values;
66  View<reco::Candidate>::const_iterator pair, endpairs = pairs->end();
67  for (pair = pairs->begin(); pair != endpairs; ++pair, ++i) {
68  reco::CandidateBaseRef probeRef = pair->daughter(1)->masterClone();
69  unsigned int tagKey = pair->daughter(0)->masterClone().key();
70  unsigned int copies = 1;
71  if (pairCut_(*pair) && probeCut_(*probeRef)) {
72  for (unsigned int j = 0; j < i; ++j) if (tagKeys[j] == tagKey) copies++;
73  for (unsigned int j = 0; j < i; ++j) if (tagKeys[j] == tagKey) values[j] = copies;
74  } else {
76  copies = 0;
77  }
78  tagKeys.push_back(tagKey);
79  values.push_back(copies);
80  }
81 
82  // convert into ValueMap and store
83  auto valMap = std::make_unique<ValueMap<float>>();
85  filler.insert(pairs, values.begin(), values.end());
86  filler.fill();
87  iEvent.put(std::move(valMap));
88 }
89 
edm::EDGetTokenT< reco::CandidateView > pairs_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
StringCutObjectSelector< reco::Candidate, true > probeCut_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:230
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Matcher of number of reconstructed objects in the event to probe.
fixed size matrix
HLT enums.
StringCutObjectSelector< reco::Candidate, true > pairCut_
ProbeMulteplicityProducer(const edm::ParameterSet &iConfig)
def move(src, dest)
Definition: eostools.py:510
edm::View< Candidate > CandidateView
view of a collection containing candidates
Definition: CandidateFwd.h:23