CMS 3D CMS Logo

ChargedHadronPFTrackIsolationProducer.cc
Go to the documentation of this file.
1 /*
2  * ChargedHadronPFTrackIsolationProducer
3  *
4  * Author: Andreas Hinzmann
5  *
6  * Associates PF isolation flag to charged hadron candidates
7  *
8  */
9 
16 
19 
25 
27 public:
30  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
31  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
32 
33 private:
34  // input collection
37  double minTrackPt_;
39 };
40 
43  candidatesToken_ = consumes<edm::View<reco::PFCandidate> >(srccandidates_);
44  minTrackPt_ = cfg.getParameter<double>("minTrackPt");
45  minRawCaloEnergy_ = cfg.getParameter<double>("minRawCaloEnergy");
46 
47  produces<edm::ValueMap<bool> >();
48 }
49 
51  // get a view of our candidates via the base candidates
53 
54  std::vector<bool> values;
55 
56  for (auto const& c : *candidates) {
57  // Check that there is only one track in the block.
58  unsigned int nTracks = 0;
59  if ((c.particleId() == 1) && (c.pt() > minTrackPt_) &&
60  ((c.rawEcalEnergy() + c.rawHcalEnergy()) > minRawCaloEnergy_)) {
61  const reco::PFCandidate::ElementsInBlocks& theElements = c.elementsInBlocks();
62  if (theElements.empty())
63  continue;
64  const reco::PFBlockRef blockRef = theElements[0].first;
65  const edm::OwnVector<reco::PFBlockElement>& elements = blockRef->elements();
66  // Find the tracks in the block
67  for (auto const& ele : elements) {
68  reco::PFBlockElement::Type type = ele.type();
69  if (type == reco::PFBlockElement::TRACK)
70  nTracks++;
71  }
72  }
73  values.push_back((nTracks == 1));
74  }
75 
76  std::unique_ptr<edm::ValueMap<bool> > out(new edm::ValueMap<bool>());
78  filler.insert(candidates, values.begin(), values.end());
79  filler.fill();
80  evt.put(std::move(out));
81 }
82 
85  desc.add<edm::InputTag>("src", edm::InputTag("particleFlow"));
86  desc.add<double>("minTrackPt", 1);
87  desc.add<double>("minRawCaloEnergy", 0.5);
88  descriptions.add("chargedHadronPFTrackIsolation", desc);
89 }
90 
92 
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
const unsigned int nTracks(const reco::Vertex &sv)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
edm::EDGetTokenT< edm::View< reco::PFCandidate > > candidatesToken_
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:378
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:547
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
def move(src, dest)
Definition: eostools.py:511