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 
24 
26 public:
29  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
30  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
31 
32 private:
33  // input collection
36  double minTrackPt_;
38 };
39 
41  srccandidates_ = cfg.getParameter<edm::InputTag>("src");
42  candidatesToken_ = consumes<edm::View<reco::PFCandidate> >(srccandidates_);
43  minTrackPt_ = cfg.getParameter<double>("minTrackPt");
44  minRawCaloEnergy_ = cfg.getParameter<double>("minRawCaloEnergy");
45 
46  produces<edm::ValueMap<bool> >();
47 }
48 
50  // get a view of our candidates via the base candidates
52 
53  std::vector<bool> values;
54 
55  for (auto const& c : *candidates) {
56  // Check that there is only one track in the block.
57  unsigned int nTracks = 0;
58  if ((c.particleId() == 1) && (c.pt() > minTrackPt_) &&
59  ((c.rawEcalEnergy() + c.rawHcalEnergy()) > minRawCaloEnergy_)) {
60  const reco::PFCandidate::ElementsInBlocks& theElements = c.elementsInBlocks();
61  if (theElements.empty())
62  nTracks = 1; // the PFBlockElements is empty for pfTICL charged candidates
63  // because they don't go through PFBlocks machanism. We consider each charged candidate to be well isolated for now.
64  else {
65  const reco::PFBlockRef blockRef = theElements[0].first;
66  const edm::OwnVector<reco::PFBlockElement>& elements = blockRef->elements();
67  // Find the tracks in the block
68  for (auto const& ele : elements) {
69  reco::PFBlockElement::Type type = ele.type();
71  nTracks++;
72  }
73  }
74  }
75  values.push_back((nTracks == 1));
76  }
77 
78  std::unique_ptr<edm::ValueMap<bool> > out(new edm::ValueMap<bool>());
80  filler.insert(candidates, values.begin(), values.end());
81  filler.fill();
82  evt.put(std::move(out));
83 }
84 
87  desc.add<edm::InputTag>("src", edm::InputTag("particleFlow"));
88  desc.add<double>("minTrackPt", 1);
89  desc.add<double>("minRawCaloEnergy", 0.5);
90  descriptions.add("chargedHadronPFTrackIsolation", desc);
91 }
92 
94 
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EDGetTokenT< edm::View< reco::PFCandidate > > candidatesToken_
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:404
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:564
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
def move(src, dest)
Definition: eostools.py:511