CMS 3D CMS Logo

PATCompositeCandidateProducer.cc
Go to the documentation of this file.
1 
31 
32 namespace pat {
33 
35  public:
36  explicit PATCompositeCandidateProducer(const edm::ParameterSet& iConfig);
38 
39  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
40 
41  private:
42  // configurables
43  const edm::EDGetTokenT<edm::View<reco::CompositeCandidate> > srcToken_; // list of reco::CompositeCandidates
44 
45  const bool useUserData_;
47 
48  const bool addEfficiencies_;
50 
51  const bool addResolutions_;
53  };
54 
55 } // namespace pat
56 
57 using namespace pat;
58 using namespace std;
59 using namespace edm;
60 
62  : srcToken_(consumes<edm::View<reco::CompositeCandidate> >(iConfig.getParameter<InputTag>("src"))),
63  useUserData_(iConfig.exists("userData")),
64  userDataHelper_(iConfig.getParameter<edm::ParameterSet>("userData"), consumesCollector()),
65  addEfficiencies_(iConfig.getParameter<bool>("addEfficiencies")),
66  addResolutions_(iConfig.getParameter<bool>("addResolutions")) {
67  // Efficiency configurables
68  if (addEfficiencies_) {
70  pat::helper::EfficiencyLoader(iConfig.getParameter<edm::ParameterSet>("efficiencies"), consumesCollector());
71  }
72 
73  // Resolution configurables
74  if (addResolutions_) {
76  }
77 
78  // produces vector of particles
79  produces<vector<pat::CompositeCandidate> >();
80 }
81 
83 
85  // Get the vector of CompositeCandidate's from the event
87  iEvent.getByToken(srcToken_, cands);
88 
93 
94  auto myCompositeCandidates = std::make_unique<vector<pat::CompositeCandidate> >();
95 
96  if (cands.isValid()) {
97  View<reco::CompositeCandidate>::const_iterator ibegin = cands->begin(), iend = cands->end(), i = ibegin;
98  for (; i != iend; ++i) {
100 
101  if (useUserData_) {
102  userDataHelper_.add(cand, iEvent, iSetup);
103  }
104 
106  efficiencyLoader_.setEfficiencies(cand, cands->refAt(i - cands->begin()));
109 
110  myCompositeCandidates->push_back(std::move(cand));
111  }
112 
113  } // end if the two handles are valid
114 
115  iEvent.put(std::move(myCompositeCandidates));
116 }
117 
119 
pat::PATCompositeCandidateProducer::useUserData_
const bool useUserData_
Definition: PATCompositeCandidateProducer.cc:45
CompositeCandidate.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
pat::PATUserDataHelper< pat::CompositeCandidate >
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
pat::PATCompositeCandidateProducer::addResolutions_
const bool addResolutions_
Definition: PATCompositeCandidateProducer.cc:51
pat::helper::EfficiencyLoader
Definition: EfficiencyLoader.h:16
edm::EDGetTokenT
Definition: EDGetToken.h:33
pat::CompositeCandidate
Analysis-level particle class.
Definition: CompositeCandidate.h:31
edm
HLT enums.
Definition: AlignableModifier.h:19
pat::helper::EfficiencyLoader::enabled
bool enabled() const
'true' if this there is at least one efficiency configured
Definition: EfficiencyLoader.h:25
pat::PATCompositeCandidateProducer::efficiencyLoader_
pat::helper::EfficiencyLoader efficiencyLoader_
Definition: PATCompositeCandidateProducer.cc:49
EDProducer.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
Association.h
edm::Handle
Definition: AssociativeIterator.h:50
MultiIsolator.h
EfficiencyLoader.h
pat::helper::KinResolutionsLoader::enabled
bool enabled() const
'true' if this there is at least one efficiency configured
Definition: KinResolutionsLoader.h:27
pat::PATCompositeCandidateProducer::~PATCompositeCandidateProducer
~PATCompositeCandidateProducer() override
Definition: PATCompositeCandidateProducer.cc:82
GenParticle.h
pat::PATCompositeCandidateProducer::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: PATCompositeCandidateProducer.cc:84
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
pat::PATUserDataHelper::add
void add(ObjectType &patObject, edm::Event const &iEvent, edm::EventSetup const &iSetup)
Definition: PATUserDataHelper.h:114
pat::helper::EfficiencyLoader::newEvent
void newEvent(const edm::Event &event)
To be called for each new event, reads in the ValueMaps for efficiencies.
Definition: EfficiencyLoader.cc:21
GenParticleFwd.h
pat::helper::KinResolutionsLoader
Definition: KinResolutionsLoader.h:18
KinResolutionsLoader.h
pat::PATCompositeCandidateProducer::addEfficiencies_
const bool addEfficiencies_
Definition: PATCompositeCandidateProducer.cc:48
pat::helper::KinResolutionsLoader::setResolutions
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
Definition: KinResolutionsLoader.h:49
edm::View
Definition: CaloClusterFwd.h:14
HLT_FULL_cff.cands
cands
Definition: HLT_FULL_cff.py:15161
EtComparator.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
cand
Definition: decayParser.h:32
AddFourMomenta.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
pat
Definition: HeavyIon.h:7
pat::helper::KinResolutionsLoader::newEvent
void newEvent(const edm::Event &event, const edm::EventSetup &setup)
To be called for each new event, reads in the EventSetup object.
Definition: KinResolutionsLoader.cc:27
pat::PATCompositeCandidateProducer::resolutionLoader_
pat::helper::KinResolutionsLoader resolutionLoader_
Definition: PATCompositeCandidateProducer.cc:52
ValueMap.h
pat::PATCompositeCandidateProducer::PATCompositeCandidateProducer
PATCompositeCandidateProducer(const edm::ParameterSet &iConfig)
Definition: PATCompositeCandidateProducer.cc:61
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
VertexingHelper.h
pat::PATCompositeCandidateProducer
Produces the pat::CompositeCandidate.
Definition: PATCompositeCandidateProducer.cc:34
pat::helper::EfficiencyLoader::setEfficiencies
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
Definition: EfficiencyLoader.h:41
PATUserDataHelper.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
View.h
ParameterSet.h
edm::Event
Definition: Event.h:73
StringObjectFunction.h
edm::InputTag
Definition: InputTag.h:15
pat::PATCompositeCandidateProducer::srcToken_
const edm::EDGetTokenT< edm::View< reco::CompositeCandidate > > srcToken_
Definition: PATCompositeCandidateProducer.cc:43
pat::PATCompositeCandidateProducer::userDataHelper_
pat::PATUserDataHelper< pat::CompositeCandidate > userDataHelper_
Definition: PATCompositeCandidateProducer.cc:46