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 {
28 public:
29 
32  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
33  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
34 
35 private:
36  // input collection
39  double minTrackPt_;
41 
42 };
43 
45 {
47  candidatesToken_ = consumes<edm::View<reco::PFCandidate> >(srccandidates_);
48  minTrackPt_ = cfg.getParameter<double>("minTrackPt");
49  minRawCaloEnergy_ = cfg.getParameter<double>("minRawCaloEnergy");
50 
51  produces<edm::ValueMap<bool> >();
52 }
53 
55 {
56  // get a view of our candidates via the base candidates
58 
59  std::vector<bool> values;
60 
61  for( auto const& c : *candidates ) {
62  // Check that there is only one track in the block.
63  unsigned int nTracks = 0;
64  if ((c.particleId()==1) && (c.pt()>minTrackPt_) && ((c.rawEcalEnergy()+c.rawHcalEnergy())>minRawCaloEnergy_)) {
65  const reco::PFCandidate::ElementsInBlocks& theElements = c.elementsInBlocks();
66  if( theElements.empty() ) continue;
67  const reco::PFBlockRef blockRef = theElements[0].first;
68  const edm::OwnVector<reco::PFBlockElement>& elements = blockRef->elements();
69  // Find the tracks in the block
70  for( auto const & ele : elements ) {
71  reco::PFBlockElement::Type type = ele.type();
72  if( type== reco::PFBlockElement::TRACK)
73  nTracks++;
74  }
75  }
76  values.push_back((nTracks==1));
77  }
78 
79  std::unique_ptr<edm::ValueMap<bool> > out(new edm::ValueMap<bool>());
81  filler.insert(candidates,values.begin(),values.end());
82  filler.fill();
83  evt.put(std::move(out));
84 }
85 
88  desc.add<edm::InputTag>("src", edm::InputTag("particleFlow"));
89  desc.add<double>("minTrackPt", 1);
90  desc.add<double>("minRawCaloEnergy", 0.5);
91  descriptions.add("chargedHadronPFTrackIsolation", desc);
92 }
93 
95 
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:125
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:387
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:539
#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