CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
TICLCandidateFromTrackstersProducer Class Reference
Inheritance diagram for TICLCandidateFromTrackstersProducer:
edm::stream::EDProducer<>

Public Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 
 TICLCandidateFromTrackstersProducer (const edm::ParameterSet &)
 
 ~TICLCandidateFromTrackstersProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

float min_particle_prob_
 
std::unique_ptr< TracksterMomentumPluginBasemomentum_algo_
 
std::unique_ptr< TracksterTrackPluginBasetrack_algo_
 
std::vector< edm::EDGetTokenT< std::vector< Trackster > > > trackster_tokens_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 24 of file TICLCandidateFromTrackstersProducer.cc.

Constructor & Destructor Documentation

TICLCandidateFromTrackstersProducer::TICLCandidateFromTrackstersProducer ( const edm::ParameterSet ps)

Definition at line 63 of file TICLCandidateFromTrackstersProducer.cc.

References timingPdfMaker::get, edm::ParameterSet::getParameter(), momentum_algo_, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, track_algo_, trackster_tokens_, and edm::vector_transform().

64  : min_particle_prob_(ps.getParameter<double>("minParticleProbability")) {
66  edm::vector_transform(ps.getParameter<std::vector<edm::InputTag>>("tracksterCollections"),
67  [this](edm::InputTag const& tag) { return consumes<std::vector<Trackster>>(tag); });
68  produces<std::vector<TICLCandidate>>();
69  auto pset_momentum = ps.getParameter<edm::ParameterSet>("momentumPlugin");
71  pset_momentum.getParameter<std::string>("plugin"), pset_momentum, consumesCollector());
72 
73  auto pset_track = ps.getParameter<edm::ParameterSet>("trackPlugin");
75  pset_track.getParameter<std::string>("plugin"), pset_track, consumesCollector());
76 }
T getParameter(std::string const &) const
std::unique_ptr< TracksterTrackPluginBase > track_algo_
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
std::unique_ptr< TracksterMomentumPluginBase > momentum_algo_
std::vector< edm::EDGetTokenT< std::vector< Trackster > > > trackster_tokens_
TICLCandidateFromTrackstersProducer::~TICLCandidateFromTrackstersProducer ( )
inlineoverride

Definition at line 27 of file TICLCandidateFromTrackstersProducer.cc.

References fillDescriptions().

27 {}

Member Function Documentation

void TICLCandidateFromTrackstersProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 78 of file TICLCandidateFromTrackstersProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), HLT_2018_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

78  {
80 
81  std::vector<edm::InputTag> source_vector{edm::InputTag("trackstersTrk"),
82  edm::InputTag("trackstersMIP"),
83  edm::InputTag("trackstersEM"),
84  edm::InputTag("trackstersHAD")};
85  desc.add<std::vector<edm::InputTag>>("tracksterCollections", source_vector);
86  desc.add<double>("minParticleProbability", 0.);
87 
88  edm::ParameterSetDescription desc_momentum;
89  desc_momentum.add<std::string>("plugin", "TracksterP4FromEnergySum");
90  desc_momentum.add<bool>("energyFromRegression", false);
91  desc_momentum.add<edm::InputTag>("vertices", edm::InputTag("offlinePrimaryVertices"));
92  desc_momentum.add<edm::InputTag>("layerClusters", edm::InputTag("hgcalLayerClusters"));
93  desc.add<edm::ParameterSetDescription>("momentumPlugin", desc_momentum);
94 
96  desc_track.add<std::string>("plugin", "TracksterRecoTrackPlugin");
97  desc.add<edm::ParameterSetDescription>("trackPlugin", desc_track);
98 
99  descriptions.add("ticlCandidateFromTrackstersProducer", desc);
100 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void TICLCandidateFromTrackstersProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 102 of file TICLCandidateFromTrackstersProducer.cc.

References begin, ALCARECOTkAlJpsiMuMu_cff::charge, HLT_2018_cff::distance, end, edm::Event::getByToken(), mps_fire::i, hgcal_clustering::max_index(), min_particle_prob_, momentum_algo_, eostools::move(), HiggsValidation_cfi::pdg_id, edm::Event::put(), mps_fire::result, track_algo_, and trackster_tokens_.

102  {
103  auto result = std::make_unique<std::vector<TICLCandidate>>();
104 
105  std::vector<const Trackster*> trackster_ptrs;
106 
107  // adds one TICLCandidate for each trackster that has a minimum particle probability
108  for (auto& trackster_token : trackster_tokens_) {
110  evt.getByToken(trackster_token, trackster_h);
111  for (size_t i_trackster = 0; i_trackster < trackster_h->size(); ++i_trackster) {
112  auto const& trackster = trackster_h->at(i_trackster);
113  auto id_prob_begin = std::begin(trackster.id_probabilities);
114  auto max_id_prob_it = std::max_element(id_prob_begin, std::end(trackster.id_probabilities));
115  float max_id_prob = *max_id_prob_it;
116  if (max_id_prob < min_particle_prob_)
117  continue;
118 
119  trackster_ptrs.push_back(&trackster);
120  auto& ticl_cand = result->emplace_back(edm::Ptr<ticl::Trackster>(trackster_h, i_trackster));
121  auto max_index = std::distance(id_prob_begin, max_id_prob_it);
122  auto pdg_id = pdg_id_from_particle_type(static_cast<ticl::Trackster::ParticleType>(max_index));
123  ticl_cand.setPdgId(pdg_id);
124  }
125  }
126 
127  momentum_algo_->setP4(trackster_ptrs, *result, evt);
128  track_algo_->setTrack(trackster_ptrs, *result, evt);
129 
130  // charge assignment
131  for (size_t i = 0; i < result->size(); ++i) {
132  auto& ticl_cand = result->at(i);
133  auto pdg_id = ticl_cand.pdgId();
134  if (pdg_id == -11 || pdg_id == -13 || pdg_id == 211) {
135  if (ticl_cand.trackPtr().isNonnull()) {
136  auto charge = ticl_cand.trackPtr()->charge();
137  ticl_cand.setCharge(charge);
138  ticl_cand.setPdgId(pdg_id * charge);
139  } else {
140  // FIXME - placeholder for downstream PF code to work, but proper symmetric charge assignment needed
141  ticl_cand.setCharge(1);
142  }
143  }
144  }
145 
146  evt.put(std::move(result));
147 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
std::unique_ptr< TracksterTrackPluginBase > track_algo_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
std::unique_ptr< TracksterMomentumPluginBase > momentum_algo_
std::vector< edm::EDGetTokenT< std::vector< Trackster > > > trackster_tokens_
size_t max_index(const std::vector< T > &v)
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

float TICLCandidateFromTrackstersProducer::min_particle_prob_
private

Definition at line 36 of file TICLCandidateFromTrackstersProducer.cc.

Referenced by produce().

std::unique_ptr<TracksterMomentumPluginBase> TICLCandidateFromTrackstersProducer::momentum_algo_
private
std::unique_ptr<TracksterTrackPluginBase> TICLCandidateFromTrackstersProducer::track_algo_
private
std::vector<edm::EDGetTokenT<std::vector<Trackster> > > TICLCandidateFromTrackstersProducer::trackster_tokens_
private