CMS 3D CMS Logo

ObjectMultiplicityCounter.cc
Go to the documentation of this file.
1 //
2 
15 
19 
25 
26 template<typename T>
28  public:
29  explicit ObjectMultiplicityCounter(const edm::ParameterSet & iConfig);
30  ~ObjectMultiplicityCounter() override ;
31 
32  void produce(edm::Event & iEvent, const edm::EventSetup& iSetup) override;
33 
34  private:
37  StringCutObjectSelector<T,true> objCut_; // lazy parsing, to allow cutting on variables not in reco::Candidate class
38 };
39 
40 template<typename T>
42  probesToken_(consumes<edm::View<reco::Candidate> >(iConfig.getParameter<edm::InputTag>("probes"))),
43  objectsToken_(consumes<edm::View<T> >(iConfig.getParameter<edm::InputTag>("objects"))),
44  objCut_(iConfig.existsAs<std::string>("objectSelection") ? iConfig.getParameter<std::string>("objectSelection") : "", true)
45 {
46  produces<edm::ValueMap<float> >();
47 }
48 
49 
50 template<typename T>
52 {
53 }
54 
55 template<typename T>
56 void
58  using namespace edm;
59 
60  // read input
63  iEvent.getByToken(probesToken_, probes);
64  iEvent.getByToken(objectsToken_, objects);
65 
66  // fill
67  float count = 0.0;
68  typename View<T>::const_iterator object, endobjects = objects->end();
69  for (object = objects->begin(); object != endobjects; ++object) {
70  if ( !(objCut_(*object)) ) continue;
71  count += 1.0;
72  }
73 
74  // prepare vector for output
75  std::vector<float> values(probes->size(), count);
76 
77  // convert into ValueMap and store
78  auto valMap = std::make_unique<ValueMap<float>>();
80  filler.insert(probes, values.begin(), values.end());
81  filler.fill();
82  iEvent.put(std::move(valMap));
83 }
84 
85 
89 
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::EDGetTokenT< edm::View< reco::Candidate > > probesToken_
ObjectMultiplicityCounter< reco::Vertex > VertexMultiplicityCounter
StringCutObjectSelector< T, true > objCut_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Matcher of number of reconstructed objects in the event to probe.
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< edm::View< T > > objectsToken_
ObjectMultiplicityCounter< reco::Candidate > CandMultiplicityCounter
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
fixed size matrix
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
ObjectMultiplicityCounter< reco::Track > TrackMultiplicityCounter
ObjectMultiplicityCounter(const edm::ParameterSet &iConfig)
long double T
def move(src, dest)
Definition: eostools.py:510