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 
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
ChargedHadronPFTrackIsolationProducer::minTrackPt_
double minTrackPt_
Definition: ChargedHadronPFTrackIsolationProducer.cc:36
MessageLogger.h
PFCandidate.h
ChargedHadronPFTrackIsolationProducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: ChargedHadronPFTrackIsolationProducer.cc:49
edm::EDGetTokenT
Definition: EDGetToken.h:33
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
BeamSpotPI::nTracks
Definition: BeamSpotPayloadInspectorHelper.h:41
edm::Ref< PFBlockCollection >
reco::PFBlockElement::Type
Type
Definition: PFBlockElement.h:30
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
reco::PFBlockElement::TRACK
Definition: PFBlockElement.h:32
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
PFBlockElement.h
ParameterSetDescription.h
ChargedHadronPFTrackIsolationProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: ChargedHadronPFTrackIsolationProducer.cc:85
edm::global::EDProducer
Definition: EDProducer.h:32
reco::PFCandidate::ElementsInBlocks
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:379
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
ChargedHadronPFTrackIsolationProducer::srccandidates_
edm::InputTag srccandidates_
Definition: ChargedHadronPFTrackIsolationProducer.cc:34
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EventSetup
Definition: EventSetup.h:57
ChargedHadronPFTrackIsolationProducer::ChargedHadronPFTrackIsolationProducer
ChargedHadronPFTrackIsolationProducer(const edm::ParameterSet &cfg)
Definition: ChargedHadronPFTrackIsolationProducer.cc:40
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
looper.cfg
cfg
Definition: looper.py:297
ValueMap.h
ChargedHadronPFTrackIsolationProducer
Definition: ChargedHadronPFTrackIsolationProducer.cc:25
PFBlock.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
bookConverter.elements
elements
Definition: bookConverter.py:147
eostools.move
def move(src, dest)
Definition: eostools.py:511
HLT_FULL_cff.candidates
candidates
Definition: HLT_FULL_cff.py:54985
edm::ValueMap
Definition: ValueMap.h:107
EventSetup.h
Exception.h
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
edm::helper::Filler
Definition: ValueMap.h:22
ParameterSet.h
EDProducer.h
edm::Event
Definition: Event.h:73
edm::Event::getHandle
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:555
edm::InputTag
Definition: InputTag.h:15
ChargedHadronPFTrackIsolationProducer::~ChargedHadronPFTrackIsolationProducer
~ChargedHadronPFTrackIsolationProducer() override
Definition: ChargedHadronPFTrackIsolationProducer.cc:28
ChargedHadronPFTrackIsolationProducer::candidatesToken_
edm::EDGetTokenT< edm::View< reco::PFCandidate > > candidatesToken_
Definition: ChargedHadronPFTrackIsolationProducer.cc:35
edm::OwnVector< reco::PFBlockElement >
ChargedHadronPFTrackIsolationProducer::minRawCaloEnergy_
double minRawCaloEnergy_
Definition: ChargedHadronPFTrackIsolationProducer.cc:37