CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | Static Private Attributes
pat::PackedCandidateTrackChi2Producer Class Reference
Inheritance diagram for pat::PackedCandidateTrackChi2Producer:
edm::stream::EDProducer<>

Public Member Functions

 PackedCandidateTrackChi2Producer (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 

Private Types

typedef edm::ValueMap< float > FloatMap
 

Private Attributes

edm::EDGetTokenT
< edm::Association
< reco::PFCandidateCollection > > 
candidate2PFToken_
 
const edm::EDGetTokenT
< pat::PackedCandidateCollection
candidateToken_
 
const bool doLostTracks_
 
edm::EDGetTokenT
< edm::Association
< pat::PackedCandidateCollection > > 
track2LostTrackToken_
 
const edm::EDGetTokenT
< reco::TrackCollection
trackToken_
 

Static Private Attributes

static const uint8_t roundingPrecision = 8
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 14 of file PackedCandidateTrackChi2Producer.cc.

Member Typedef Documentation

Definition at line 15 of file PackedCandidateTrackChi2Producer.cc.

Constructor & Destructor Documentation

pat::PackedCandidateTrackChi2Producer::PackedCandidateTrackChi2Producer ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 18 of file PackedCandidateTrackChi2Producer.cc.

References candidate2PFToken_, doLostTracks_, edm::ParameterSet::getParameter(), and track2LostTrackToken_.

19  : candidateToken_(consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("candidates"))),
20  trackToken_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("trackCollection"))),
21  doLostTracks_(iConfig.getParameter<bool>("doLostTracks")) {
22  if (doLostTracks_) {
23  track2LostTrackToken_ = consumes<edm::Association<pat::PackedCandidateCollection>>(
24  iConfig.getParameter<edm::InputTag>("candidates"));
25  } else {
27  consumes<edm::Association<reco::PFCandidateCollection>>(iConfig.getParameter<edm::InputTag>("candidates"));
28  }
29 
30  produces<FloatMap>();
31  }
const edm::EDGetTokenT< pat::PackedCandidateCollection > candidateToken_
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > track2LostTrackToken_
edm::EDGetTokenT< edm::Association< reco::PFCandidateCollection > > candidate2PFToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::EDGetTokenT< reco::TrackCollection > trackToken_

Member Function Documentation

void pat::PackedCandidateTrackChi2Producer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 102 of file PackedCandidateTrackChi2Producer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, and HLT_FULL_cff::InputTag.

102  {
104  desc.add<edm::InputTag>("candidates", edm::InputTag("packedPFCandidates"))
105  ->setComment("packed candidate input collection");
106  desc.add<edm::InputTag>("trackCollection", edm::InputTag("generalTracks"))->setComment("track input collection");
107  desc.add<bool>("doLostTracks", false);
108  descriptions.add("packedPFCandidateTrackChi2", desc);
109 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void pat::PackedCandidateTrackChi2Producer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 48 of file PackedCandidateTrackChi2Producer.cc.

References candidate2PFToken_, HLT_FULL_cff::candidates, candidateToken_, doLostTracks_, edm::Event::get(), edm::Event::getByToken(), edm::Event::getHandle(), mps_fire::i, eostools::move(), edm::Event::put(), track2LostTrackToken_, and trackToken_.

48  {
49  auto const candidates = iEvent.getHandle(candidateToken_);
50 
51  const edm::Association<reco::PFCandidateCollection>* candidate2PF = nullptr;
52  if (!doLostTracks_) {
53  candidate2PF = &iEvent.get(candidate2PFToken_);
54  }
55 
56  const edm::Association<pat::PackedCandidateCollection>* tracks2LT = nullptr;
58  if (doLostTracks_) {
59  tracks2LT = &iEvent.get(track2LostTrackToken_);
60  iEvent.getByToken(trackToken_, trks);
61  }
62 
63  const auto nCand = candidates->size();
64  std::vector<float> trkChi2Map(nCand, 0);
65 
66  if (doLostTracks_) { //for Lost tracks we don't have references to PFCands, so we must loop over tracks and check keys...
67  for (size_t i = 0; i < trks->size(); i++) {
68  const auto& trk = reco::TrackRef(trks, i);
69  const auto& lostTrack = (*tracks2LT)[trk];
70  if (lostTrack.isNonnull()) {
71  const float nChi2 = trk->normalizedChi2();
72  trkChi2Map.at(lostTrack.key()) = MiniFloatConverter::reduceMantissaToNbitsRounding<roundingPrecision>(nChi2);
73  }
74  }
75  } else { //for the regular PackedPFCands we have direct references...
76  for (size_t i = 0; i < nCand; i++) {
77  const auto& cand = pat::PackedCandidateRef(candidates, i);
78 
79  // ignore neutral candidates or without track
80  if (cand->charge() == 0 || !cand->hasTrackDetails())
81  continue;
82 
83  const auto& candTrack = (*candidate2PF)[cand]->trackRef();
84 
85  if (candTrack.isNonnull()) {
86  const float nChi2 = candTrack->normalizedChi2();
87 
88  trkChi2Map.at(i) = MiniFloatConverter::reduceMantissaToNbitsRounding<roundingPrecision>(nChi2);
89  }
90  }
91  }
92 
93  // fill the value maps
94  std::unique_ptr<FloatMap> valueMap = std::make_unique<FloatMap>();
95  FloatMap::Filler filler(*valueMap);
96  filler.insert(candidates, trkChi2Map.begin(), trkChi2Map.end());
97  filler.fill();
98  iEvent.put(std::move(valueMap), "");
99 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
const edm::EDGetTokenT< pat::PackedCandidateCollection > candidateToken_
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > track2LostTrackToken_
edm::EDGetTokenT< edm::Association< reco::PFCandidateCollection > > candidate2PFToken_
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:563
def move
Definition: eostools.py:511
edm::Ref< pat::PackedCandidateCollection > PackedCandidateRef
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
helper::Filler< ValueMap< float > > Filler
Definition: ValueMap.h:168
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
const edm::EDGetTokenT< reco::TrackCollection > trackToken_

Member Data Documentation

edm::EDGetTokenT<edm::Association<reco::PFCandidateCollection> > pat::PackedCandidateTrackChi2Producer::candidate2PFToken_
private
const edm::EDGetTokenT<pat::PackedCandidateCollection> pat::PackedCandidateTrackChi2Producer::candidateToken_
private

Definition at line 38 of file PackedCandidateTrackChi2Producer.cc.

Referenced by produce().

const bool pat::PackedCandidateTrackChi2Producer::doLostTracks_
private
const uint8_t pat::PackedCandidateTrackChi2Producer::roundingPrecision = 8
staticprivate

Definition at line 43 of file PackedCandidateTrackChi2Producer.cc.

edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection> > pat::PackedCandidateTrackChi2Producer::track2LostTrackToken_
private
const edm::EDGetTokenT<reco::TrackCollection> pat::PackedCandidateTrackChi2Producer::trackToken_
private

Definition at line 41 of file PackedCandidateTrackChi2Producer.cc.

Referenced by produce().